From c6f2115b0ae44d7329e8a817e6be9074819bf5d3 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Mon, 15 Aug 2022 12:41:45 +0100 Subject: [PATCH] Import qbs_1.23.1.orig.tar.gz [dgit import orig qbs_1.23.1.orig.tar.gz] --- .clang-tidy | 273 + .dockerignore | 3 + .gitattributes | 3 + .github/actions/download-dm/action.yml | 15 + .github/actions/download-mingw/action.yml | 19 + .github/actions/download-ow/action.yml | 15 + .github/actions/download-qt/action.yml | 22 + .github/actions/download-qtc/action.yml | 15 + .github/workflows/docs.yml | 38 + .github/workflows/main.yml | 887 + .github/workflows/release.yml | 246 + .gitignore | 44 + .gitmodules | 3 + .mailmap | 28 + CMakeLists.txt | 75 + CONTRIBUTING.md | 102 + LGPL_EXCEPTION.txt | 22 + LICENSE.GPL3-EXCEPT | 704 + LICENSE.LGPLv21 | 504 + LICENSE.LGPLv3 | 173 + README.md | 36 + VERSION | 1 + bin/ibmsvc.xml | 12 + bin/ibqbs.bat | 1 + changelogs/changes-1.10.0.md | 43 + changelogs/changes-1.10.1.md | 11 + changelogs/changes-1.11.0.md | 57 + changelogs/changes-1.11.1.md | 5 + changelogs/changes-1.12.0.md | 41 + changelogs/changes-1.12.1.md | 8 + changelogs/changes-1.12.2.md | 10 + changelogs/changes-1.13.0.md | 37 + changelogs/changes-1.13.1.md | 9 + changelogs/changes-1.14.0.md | 35 + changelogs/changes-1.14.1.md | 4 + changelogs/changes-1.15.0.md | 44 + changelogs/changes-1.16.0.md | 126 + changelogs/changes-1.17.0.md | 98 + changelogs/changes-1.17.1.md | 10 + changelogs/changes-1.18.0.md | 84 + changelogs/changes-1.18.2.md | 41 + changelogs/changes-1.19.0.md | 65 + changelogs/changes-1.19.1.md | 12 + changelogs/changes-1.19.2.md | 5 + changelogs/changes-1.20.0.md | 62 + changelogs/changes-1.20.1.md | 12 + changelogs/changes-1.21.0.md | 56 + changelogs/changes-1.22.0.md | 31 + changelogs/changes-1.22.1.md | 16 + changelogs/changes-1.23.0.md | 16 + changelogs/changes-1.23.1.md | 19 + changelogs/changes-1.6.0 | 16 + changelogs/changes-1.6.1 | 6 + changelogs/changes-1.7.0 | 23 + changelogs/changes-1.7.1 | 5 + changelogs/changes-1.7.2 | 5 + changelogs/changes-1.8.0 | 33 + changelogs/changes-1.8.1 | 12 + changelogs/changes-1.9.0.md | 58 + changelogs/changes-1.9.1.md | 4 + cmake/QbsBuildConfig.cmake | 252 + cmake/QbsDocumentation.cmake | 307 + dist/.gitignore | 1 + doc/CMakeLists.txt | 28 + doc/appendix/json-api.qdoc | 811 + doc/appendix/qbs-porting.qdoc | 503 + doc/classic.css | 295 + doc/codeattributions.qdoc | 241 + doc/config/macros.qdocconf | 66 + doc/config/qbs-project.qdocconf | 40 + doc/config/style/qt5-sidebar.html | 18 + doc/doc.pri | 18 + doc/doc.qbs | 110 + doc/doc_shared.pri | 14 + doc/doc_targets.pri | 86 + doc/external-resources.qdoc | 136 + doc/fix-qmlimports.py | 153 + doc/fixnavi.pl | 182 + doc/howtos.qdoc | 848 + doc/images/qbs-build-process.png | Bin 0 -> 5335 bytes doc/images/qbs-dmg.png | Bin 0 -> 41386 bytes doc/images/qbs-settings-gui.png | Bin 0 -> 31364 bytes doc/man/man.pri | 5 + doc/man/man.qbs | 74 + doc/man/qbs.1 | 79 + doc/man/see-also.h2m | 11 + doc/qbs-hugo.qdocconf | 6 + doc/qbs-online.qdocconf | 19 + doc/qbs.qdoc | 2111 + doc/qbs.qdocconf | 2 + doc/reference/cli/builtin/cli-build.qdoc | 121 + doc/reference/cli/builtin/cli-clean.qdoc | 71 + .../cli/builtin/cli-dump-nodes-tree.qdoc | 65 + doc/reference/cli/builtin/cli-generate.qdoc | 82 + doc/reference/cli/builtin/cli-help.qdoc | 63 + doc/reference/cli/builtin/cli-install.qdoc | 80 + .../cli/builtin/cli-list-products.qdoc | 62 + doc/reference/cli/builtin/cli-resolve.qdoc | 72 + doc/reference/cli/builtin/cli-run.qdoc | 94 + doc/reference/cli/builtin/cli-session.qdoc | 53 + doc/reference/cli/builtin/cli-shell.qdoc | 68 + doc/reference/cli/builtin/cli-status.qdoc | 62 + .../cli/builtin/cli-update-timestamps.qdoc | 68 + doc/reference/cli/builtin/cli-version.qdoc | 49 + doc/reference/cli/cli-options.qdocinc | 540 + doc/reference/cli/cli-parameters.qdocinc | 104 + doc/reference/cli/cli.qdoc | 42 + doc/reference/cli/tools/cli-config-ui.qdoc | 67 + doc/reference/cli/tools/cli-config.qdoc | 121 + .../cli/tools/cli-create-project.qdoc | 71 + .../cli/tools/cli-setup-android.qdoc | 68 + doc/reference/cli/tools/cli-setup-qt.qdoc | 75 + .../cli/tools/cli-setup-toolchains.qdoc | 85 + doc/reference/commands.qdoc | 242 + .../appleapplicationdiskimage.qdoc | 99 + .../items/convenience/applediskimage.qdoc | 43 + .../items/convenience/application.qdoc | 94 + .../convenience/applicationextension.qdoc | 42 + .../items/convenience/autotestrunner.qdoc | 182 + .../items/convenience/cppapplication.qdoc | 46 + .../items/convenience/dynamiclibrary.qdoc | 48 + .../items/convenience/innosetup.qdoc | 40 + .../items/convenience/installpackage.qdoc | 89 + .../convenience/javaclasscollection.qdoc | 42 + .../items/convenience/javajarfile.qdoc | 49 + doc/reference/items/convenience/library.qdoc | 129 + .../items/convenience/loadablemodule.qdoc | 41 + .../items/convenience/qtapplication.qdoc | 48 + .../items/convenience/qtguiapplication.qdoc | 40 + .../items/convenience/staticlibrary.qdoc | 40 + .../items/convenience/xpcservice.qdoc | 40 + doc/reference/items/language/artifact.qdoc | 85 + doc/reference/items/language/depends.qdoc | 196 + doc/reference/items/language/export.qdoc | 125 + doc/reference/items/language/filetagger.qdoc | 108 + doc/reference/items/language/group.qbs | 44 + doc/reference/items/language/group.qdoc | 205 + doc/reference/items/language/joblimit.qdoc | 106 + doc/reference/items/language/module.qdoc | 356 + .../items/language/moduleprovider.qdoc | 112 + doc/reference/items/language/parameter.qdoc | 51 + doc/reference/items/language/parameters.qdoc | 66 + doc/reference/items/language/probe.qdoc | 84 + doc/reference/items/language/product.qdoc | 297 + doc/reference/items/language/profile.qdoc | 93 + doc/reference/items/language/project.qdoc | 143 + doc/reference/items/language/properties.qdoc | 129 + .../items/language/propertyoptions.qdoc | 63 + doc/reference/items/language/rule.qdoc | 348 + doc/reference/items/language/scanner.qdoc | 107 + doc/reference/items/language/subproject.qdoc | 126 + doc/reference/items/probe/binary-probe.qdoc | 84 + .../items/probe/conanfile-probe.qdoc | 257 + doc/reference/items/probe/dmc-probe.qdoc | 111 + .../items/probe/framework-probe.qdoc | 59 + doc/reference/items/probe/iar-probe.qdoc | 95 + doc/reference/items/probe/include-probe.qdoc | 53 + doc/reference/items/probe/keil-probe.qdoc | 92 + doc/reference/items/probe/library-probe.qdoc | 61 + doc/reference/items/probe/path-probe.qdoc | 237 + .../items/probe/pkgconfig-probe.qdoc | 236 + doc/reference/items/probe/sdcc-probe.qdoc | 92 + doc/reference/items/probe/watcom-probe.qdoc | 129 + .../jsextensions/jsextension-binaryfile.qdoc | 113 + .../jsextensions/jsextension-environment.qdoc | 68 + .../jsextensions/jsextension-file.qdoc | 96 + .../jsextensions/jsextension-fileinfo.qdoc | 167 + .../jsextensions/jsextension-host.qdoc | 139 + .../jsextensions/jsextension-process.qdoc | 181 + .../jsextension-propertylist.qdoc | 130 + .../jsextension-temporarydir.qdoc | 67 + .../jsextensions/jsextension-textfile.qdoc | 112 + .../jsextensions/jsextension-utilities.qdoc | 81 + .../jsextensions/jsextension-xml.qdoc | 341 + .../jsextensions/jsextensions-general.qdoc | 156 + .../qbspkgconfig-module-provider.qdoc | 124 + .../module-providers/qt-module-provider.qdoc | 76 + doc/reference/modules/android-ndk-module.qdoc | 120 + doc/reference/modules/android-sdk-module.qdoc | 280 + doc/reference/modules/archiver-module.qdoc | 177 + doc/reference/modules/asan-module.qdoc | 77 + doc/reference/modules/autotest-module.qdoc | 79 + doc/reference/modules/bundle-module.qdoc | 477 + .../modules/capnprotocpp-module.qdoc | 125 + doc/reference/modules/codesign-module.qdoc | 395 + doc/reference/modules/cpp-module.qdoc | 1942 + doc/reference/modules/cpufeatures-module.qdoc | 219 + doc/reference/modules/dmg-module.qdoc | 421 + .../modules/exporter-pkgconfig-module.qdoc | 209 + .../modules/exporter-qbs-module.qdoc | 130 + doc/reference/modules/freedesktop-module.qdoc | 140 + doc/reference/modules/ib-module.qdoc | 281 + doc/reference/modules/ico-module.qdoc | 123 + doc/reference/modules/innosetup-module.qdoc | 187 + doc/reference/modules/java-module.qdoc | 244 + doc/reference/modules/lexyacc-module.qdoc | 155 + doc/reference/modules/nodejs-module.qdoc | 47 + doc/reference/modules/nsis-module.qdoc | 227 + doc/reference/modules/pkgconfig-module.qdoc | 91 + doc/reference/modules/protobufcpp-module.qdoc | 223 + .../modules/protobufnanopb-module.qdoc | 155 + .../modules/protobufobjc-module.qdoc | 127 + doc/reference/modules/qbs-module.qdoc | 819 + doc/reference/modules/qnx-module.qdoc | 84 + .../modules/qt-android_support-module.qdoc | 92 + doc/reference/modules/qt-core-module.qdoc | 470 + doc/reference/modules/qt-dbus-module.qdoc | 87 + .../modules/qt-declarative-module.qdoc | 61 + doc/reference/modules/qt-gui-module.qdoc | 62 + doc/reference/modules/qt-modules.qdoc | 194 + .../modules/qt-plugin_support-module.qdoc | 84 + doc/reference/modules/qt-qml-module.qdoc | 188 + doc/reference/modules/qt-quick-module.qdoc | 101 + doc/reference/modules/qt-scxml-module.qdoc | 94 + .../modules/texttemplate-module.qdoc | 117 + doc/reference/modules/typescript-module.qdoc | 203 + doc/reference/modules/vcs-module.qdoc | 107 + doc/reference/modules/wix-module.qdoc | 342 + doc/reference/modules/xcode-module.qdoc | 165 + doc/reference/reference.qdoc | 115 + doc/targets/qbs-target-android.qdoc | 76 + doc/targets/qbs-target-apple-common.qdocinc | 108 + doc/targets/qbs-target-integrity.qdoc | 40 + doc/targets/qbs-target-ios.qdoc | 40 + doc/targets/qbs-target-linux.qdoc | 36 + doc/targets/qbs-target-macos.qdoc | 84 + doc/targets/qbs-target-platforms.qdoc | 50 + doc/targets/qbs-target-qnx.qdoc | 68 + doc/targets/qbs-target-tvos.qdoc | 40 + doc/targets/qbs-target-vxworks.qdoc | 40 + doc/targets/qbs-target-watchos.qdoc | 40 + doc/targets/qbs-target-windows.qdoc | 78 + docker-compose.yml | 196 + docker/docker.qbs | 8 + docker/focal/Dockerfile | 109 + docker/focal/entrypoint.sh | 96 + docker/focal/test-android-no-qt.Dockerfile | 105 + docker/focal/test-android.Dockerfile | 129 + docker/focal/test-baremetal.Dockerfile | 50 + docker/focal/test-qt4.Dockerfile | 40 + docker/focal/test-qt6-static.Dockerfile | 218 + docker/leap/Dockerfile | 96 + docker/leap/entrypoint.sh | 96 + docker/windowsservercore/Dockerfile | 54 + examples/app-and-lib/app-and-lib.qbs | 57 + examples/app-and-lib/app/app.qbs | 57 + examples/app-and-lib/app/main.cpp | 58 + examples/app-and-lib/lib/lib.cpp | 61 + examples/app-and-lib/lib/lib.h | 56 + examples/app-and-lib/lib/lib.qbs | 65 + .../at90can128olimex/at90can128olimex.qbs | 56 + .../at90can128olimex/redblink/README.md | 9 + .../at90can128olimex/redblink/gpio.c | 76 + .../at90can128olimex/redblink/gpio.h | 65 + .../at90can128olimex/redblink/main.c | 69 + .../at90can128olimex/redblink/redblink.qbs | 128 + examples/baremetal/baremetal.qbs | 65 + .../cc2540usbdongle/cc2540usbdongle.qbs | 56 + .../cc2540usbdongle/greenblink/README.md | 9 + .../cc2540usbdongle/greenblink/gpio.c | 65 + .../cc2540usbdongle/greenblink/gpio.h | 65 + .../cc2540usbdongle/greenblink/greenblink.qbs | 129 + .../cc2540usbdongle/greenblink/main.c | 69 + .../cc2540usbdongle/greenblink/system.h | 85 + examples/baremetal/cy7c68013a/cy7c68013a.qbs | 56 + .../cy7c68013a/nes-gamepads/README.md | 42 + .../baremetal/cy7c68013a/nes-gamepads/core.c | 86 + .../baremetal/cy7c68013a/nes-gamepads/core.h | 298 + .../baremetal/cy7c68013a/nes-gamepads/defs.h | 173 + .../baremetal/cy7c68013a/nes-gamepads/gpio.c | 161 + .../baremetal/cy7c68013a/nes-gamepads/gpio.h | 65 + .../baremetal/cy7c68013a/nes-gamepads/hid.c | 85 + .../baremetal/cy7c68013a/nes-gamepads/hid.h | 92 + .../cy7c68013a/nes-gamepads/hiddesc.c | 345 + .../cy7c68013a/nes-gamepads/hidep0.c | 377 + .../cy7c68013a/nes-gamepads/hidep1.c | 89 + .../baremetal/cy7c68013a/nes-gamepads/irqs.h | 77 + .../baremetal/cy7c68013a/nes-gamepads/main.c | 85 + .../cy7c68013a/nes-gamepads/nes-gamepads.qbs | 136 + .../baremetal/cy7c68013a/nes-gamepads/regs.h | 779 + .../baremetal/cy7c68013a/nes-gamepads/usb.c | 118 + .../baremetal/cy7c68013a/nes-gamepads/usb.h | 217 + examples/baremetal/esp8266/README.md | 34 + .../esp8266/access-point/access-point.qbs | 28 + .../esp8266/access-point/user_config.h | 62 + .../esp8266/access-point/user_main.c | 105 + examples/baremetal/esp8266/esp8266.qbs | 57 + .../esp8266/qbs/imports/Esp8266SdkProbe.qbs | 25 + .../modules/esp8266_sdk/Esp8266SdkModule.qbs | 66 + .../baremetal/msp430f5529/msp430f5529.qbs | 57 + .../msp430f5529/nes-gamepads/README.md | 36 + .../msp430f5529/nes-gamepads/gamepads.ld | 57 + .../baremetal/msp430f5529/nes-gamepads/gpio.c | 167 + .../baremetal/msp430f5529/nes-gamepads/gpio.h | 110 + .../baremetal/msp430f5529/nes-gamepads/hid.h | 116 + .../msp430f5529/nes-gamepads/hiddesc.c | 303 + .../msp430f5529/nes-gamepads/hidep0.c | 554 + .../msp430f5529/nes-gamepads/hidep1.c | 214 + .../msp430f5529/nes-gamepads/hwdefs.h | 81 + .../baremetal/msp430f5529/nes-gamepads/main.c | 92 + .../msp430f5529/nes-gamepads/nes-gamepads.qbs | 146 + .../baremetal/msp430f5529/nes-gamepads/pmm.c | 237 + .../baremetal/msp430f5529/nes-gamepads/pmm.h | 73 + .../baremetal/msp430f5529/nes-gamepads/ucs.c | 264 + .../baremetal/msp430f5529/nes-gamepads/ucs.h | 106 + .../baremetal/msp430f5529/nes-gamepads/usb.c | 317 + .../baremetal/msp430f5529/nes-gamepads/usb.h | 148 + .../msp430f5529/nes-gamepads/wdt_a.c | 60 + .../msp430f5529/nes-gamepads/wdt_a.h | 64 + .../baremetal/msp430f5529/redblink/README.md | 9 + .../baremetal/msp430f5529/redblink/gpio.c | 76 + .../baremetal/msp430f5529/redblink/gpio.h | 65 + .../baremetal/msp430f5529/redblink/main.c | 72 + .../msp430f5529/redblink/redblink.qbs | 127 + .../baremetal/msp430f5529/redblink/system.c | 65 + .../baremetal/msp430f5529/redblink/system.h | 64 + .../baremetal/pca10001/greenblink/README.md | 10 + .../pca10001/greenblink/gcc/flash.ld | 150 + .../pca10001/greenblink/gcc/startup.s | 173 + examples/baremetal/pca10001/greenblink/gpio.c | 96 + examples/baremetal/pca10001/greenblink/gpio.h | 65 + .../pca10001/greenblink/greenblink.qbs | 170 + .../pca10001/greenblink/iar/flash.icf | 73 + .../pca10001/greenblink/iar/startup.s | 124 + .../pca10001/greenblink/keil/flash.sct | 65 + .../pca10001/greenblink/keil/startup.s | 134 + examples/baremetal/pca10001/greenblink/main.c | 69 + .../baremetal/pca10001/greenblink/system.h | 82 + examples/baremetal/pca10001/pca10001.qbs | 56 + .../baremetal/pca10040/greenblink/README.md | 10 + .../pca10040/greenblink/gcc/flash.ld | 151 + .../pca10040/greenblink/gcc/startup.s | 253 + examples/baremetal/pca10040/greenblink/gpio.c | 96 + examples/baremetal/pca10040/greenblink/gpio.h | 65 + .../pca10040/greenblink/greenblink.qbs | 176 + .../pca10040/greenblink/iar/flash.icf | 102 + .../pca10040/greenblink/iar/startup.s | 202 + .../pca10040/greenblink/keil/flash.sct | 65 + .../pca10040/greenblink/keil/startup.s | 215 + examples/baremetal/pca10040/greenblink/main.c | 69 + .../baremetal/pca10040/greenblink/system.h | 84 + examples/baremetal/pca10040/pca10040.qbs | 56 + .../baremetal/stm32f103/greenblink/README.md | 10 + .../stm32f103/greenblink/gcc/flash.ld | 172 + .../stm32f103/greenblink/gcc/startup.s | 177 + .../baremetal/stm32f103/greenblink/gpio.c | 83 + .../baremetal/stm32f103/greenblink/gpio.h | 65 + .../stm32f103/greenblink/greenblink.qbs | 172 + .../stm32f103/greenblink/iar/flash.icf | 74 + .../stm32f103/greenblink/iar/startup.s | 132 + .../stm32f103/greenblink/keil/flash.sct | 65 + .../stm32f103/greenblink/keil/startup.s | 145 + .../baremetal/stm32f103/greenblink/main.c | 69 + .../baremetal/stm32f103/greenblink/system.h | 102 + examples/baremetal/stm32f103/stm32f103.qbs | 56 + .../stm32f4discovery/blueblink/README.md | 10 + .../stm32f4discovery/blueblink/blueblink.qbs | 176 + .../stm32f4discovery/blueblink/gcc/flash.ld | 185 + .../stm32f4discovery/blueblink/gcc/startup.s | 211 + .../stm32f4discovery/blueblink/gpio.c | 79 + .../stm32f4discovery/blueblink/gpio.h | 65 + .../stm32f4discovery/blueblink/iar/flash.icf | 77 + .../stm32f4discovery/blueblink/iar/startup.s | 171 + .../stm32f4discovery/blueblink/keil/flash.sct | 64 + .../stm32f4discovery/blueblink/keil/startup.s | 184 + .../stm32f4discovery/blueblink/main.c | 69 + .../stm32f4discovery/blueblink/system.h | 129 + .../stm32f4discovery/stm32f4discovery.qbs | 56 + .../baremetal/stm8s103f3/redblink/README.md | 8 + examples/baremetal/stm8s103f3/redblink/gpio.c | 68 + examples/baremetal/stm8s103f3/redblink/gpio.h | 65 + examples/baremetal/stm8s103f3/redblink/main.c | 69 + .../stm8s103f3/redblink/redblink.qbs | 109 + .../baremetal/stm8s103f3/redblink/system.h | 84 + examples/baremetal/stm8s103f3/stm8s103f3.qbs | 56 + .../addressbook_cpp/addressbook.capnp | 55 + .../capnproto/addressbook_cpp/addressbook.cpp | 288 + .../addressbook_cpp/addressbook_cpp.qbs | 11 + .../calculator_cpp/calculator-client.cpp | 367 + .../calculator_cpp/calculator-server.cpp | 215 + .../capnproto/calculator_cpp/calculator.capnp | 118 + .../calculator_cpp/calculator_cpp.qbs | 28 + .../project.pbxproj | 309 + .../CocoaApplication/AppDelegate.h | 58 + .../CocoaApplication/AppDelegate.m | 47 + .../CocoaApplication-Info.plist | 34 + .../CocoaApplication-Prefix.pch | 33 + .../AppIcon.appiconset/Contents.json | 68 + .../AppIcon.appiconset/icon_128x128.png | Bin 0 -> 5256 bytes .../AppIcon.appiconset/icon_128x128@2x.png | Bin 0 -> 11304 bytes .../AppIcon.appiconset/icon_16x16.png | Bin 0 -> 487 bytes .../AppIcon.appiconset/icon_16x16@2x.png | Bin 0 -> 1374 bytes .../AppIcon.appiconset/icon_256x256.png | Bin 0 -> 11304 bytes .../AppIcon.appiconset/icon_256x256@2x.png | Bin 0 -> 26984 bytes .../AppIcon.appiconset/icon_32x32.png | Bin 0 -> 1374 bytes .../AppIcon.appiconset/icon_32x32@2x.png | Bin 0 -> 2423 bytes .../AppIcon.appiconset/icon_512x512.png | Bin 0 -> 26984 bytes .../AppIcon.appiconset/icon_512x512@2x.png | Bin 0 -> 63576 bytes .../CocoaApplication/background.png | Bin 0 -> 86627 bytes .../CocoaApplication/background@2x.png | Bin 0 -> 217596 bytes .../dmg.iconset/icon_128x128.png | Bin 0 -> 5256 bytes .../dmg.iconset/icon_128x128@2x.png | Bin 0 -> 11304 bytes .../dmg.iconset/icon_16x16.png | Bin 0 -> 487 bytes .../dmg.iconset/icon_16x16@2x.png | Bin 0 -> 1374 bytes .../dmg.iconset/icon_256x256.png | Bin 0 -> 11304 bytes .../dmg.iconset/icon_256x256@2x.png | Bin 0 -> 26984 bytes .../dmg.iconset/icon_32x32.png | Bin 0 -> 1374 bytes .../dmg.iconset/icon_32x32@2x.png | Bin 0 -> 2423 bytes .../dmg.iconset/icon_512x512.png | Bin 0 -> 26984 bytes .../dmg.iconset/icon_512x512@2x.png | Bin 0 -> 63576 bytes .../CocoaApplication/en.lproj/Credits.rtf | 29 + .../en.lproj/InfoPlist.strings | 1 + .../CocoaApplication/en.lproj/LICENSE | 27 + .../CocoaApplication/en.lproj/MainMenu.xib | 4666 ++ .../CocoaApplication/en_US.lproj/Credits.rtf | 29 + .../en_US.lproj/InfoPlist.strings | 1 + .../CocoaApplication/en_US.lproj/LICENSE | 27 + .../CocoaApplication/en_US.lproj/MainMenu.xib | 4666 ++ .../cocoa-application/CocoaApplication/main.m | 36 + examples/cocoa-application/app.qbs | 110 + .../cocoa-application/cocoa-application.qbs | 65 + examples/cocoa-application/dmg.qbs | 84 + .../project.pbxproj | 384 + .../CocoaTouchApplication/AppDelegate.h | 67 + .../CocoaTouchApplication/AppDelegate.m | 97 + .../CocoaTouchApplication-Info.plist | 57 + .../CocoaTouchApplication-Prefix.pch | 40 + .../DetailViewController.h | 65 + .../DetailViewController.m | 107 + .../LaunchScreen.storyboard | 49 + .../MasterViewController.h | 64 + .../MasterViewController.m | 155 + .../en.lproj/DetailViewController_iPad.xib | 223 + .../en.lproj/DetailViewController_iPhone.xib | 253 + .../en.lproj/InfoPlist.strings | 1 + .../en.lproj/MasterViewController_iPad.xib | 152 + .../en.lproj/MasterViewController_iPhone.xib | 147 + .../CocoaTouchApplication/main.m | 40 + .../cocoa-touch-application.qbs | 113 + examples/code-generator/code-generator.qbs | 82 + examples/code-generator/hwgen.cpp | 65 + examples/collidingmice/collidingmice.qbs | 68 + examples/collidingmice/images/cheese.jpg | Bin 0 -> 3029 bytes examples/collidingmice/main.cpp | 104 + examples/collidingmice/mice.qrc | 5 + examples/collidingmice/mouse.cpp | 209 + examples/collidingmice/mouse.h | 80 + examples/compiled-qml/MainForm.ui.qml | 68 + examples/compiled-qml/cheese.jpg | Bin 0 -> 3029 bytes examples/compiled-qml/compiled-qml.qbs | 64 + examples/compiled-qml/main.cpp | 62 + examples/compiled-qml/main.qml | 62 + examples/compiled-qml/qml.qrc | 7 + examples/examples.qbs | 71 + examples/grpc/client.cpp | 115 + examples/grpc/grpc.qbs | 75 + examples/grpc/ping-pong-grpc.proto | 15 + examples/grpc/server.cpp | 98 + .../helloworld-complex/helloworld-complex.qbs | 87 + examples/helloworld-complex/src/foo.cpp | 59 + examples/helloworld-complex/src/foo.h | 57 + examples/helloworld-complex/src/main.cpp | 79 + .../helloworld-complex/src/specialfeature.cpp | 58 + .../helloworld-complex/src/specialfeature.h | 56 + .../helloworld-minimal/helloworld-minimal.qbs | 54 + examples/helloworld-minimal/main.cpp | 56 + examples/helloworld-qt/helloworld-qt.qbs | 54 + examples/helloworld-qt/main.cpp | 61 + examples/install-bundle/MainMenu.xib | 680 + examples/install-bundle/Storyboard.storyboard | 52 + .../other.imageset/Contents.json | 22 + .../other.imageset/icon_16x16.png | Bin 0 -> 649 bytes .../other.imageset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../other.imageset/Contents.json | 22 + .../other.imageset/icon_16x16.png | Bin 0 -> 649 bytes .../other.imageset/icon_16x16@2x.png | Bin 0 -> 665 bytes examples/install-bundle/coreutils.cpp | 56 + examples/install-bundle/coreutils.h | 54 + examples/install-bundle/install-bundle.qbs | 51 + examples/install-bundle/main.cpp | 60 + .../white.iconset/icon_16x16.png | Bin 0 -> 649 bytes .../white.iconset/icon_16x16@2x.png | Bin 0 -> 665 bytes examples/pkgconfig-provider/main.c | 137 + .../pkgconfig-provider/pkgconfig-provider.qbs | 60 + examples/protobuf/addressbook_cpp/README.md | 13 + .../addressbook_cpp/addressbook_cpp.qbs | 18 + examples/protobuf/addressbook_cpp/main.cpp | 179 + examples/protobuf/addressbook_objc/README.md | 5 + .../addressbook_objc/addressbook_objc.qbs | 13 + examples/protobuf/addressbook_objc/main.m | 183 + examples/protobuf/shared/addressbook.proto | 51 + examples/rpaths/main.cpp | 68 + examples/rpaths/objecta.cpp | 71 + examples/rpaths/objecta.h | 70 + examples/rpaths/objectb.cpp | 64 + examples/rpaths/objectb.h | 71 + examples/rpaths/rpaths.qbs | 61 + examples/rule/lorem_ipsum.txt | 4 + examples/rule/rule.qbs | 36 + qbs-resources/imports/QbsApp.qbs | 18 + qbs-resources/imports/QbsAutotest.qbs | 28 + qbs-resources/imports/QbsLibrary.qbs | 75 + qbs-resources/imports/QbsProduct.qbs | 23 + qbs-resources/imports/QbsStaticLibrary.qbs | 9 + qbs-resources/imports/QbsUnittest.qbs | 21 + .../modules/qbsbuildconfig/qbsbuildconfig.qbs | 87 + .../modules/qbsversion/qbsversion.qbs | 23 + qbs.pro | 77 + qbs.qbs | 68 + qbs_version.pri | 4 + scripts/address-sanitizer-suppressions.txt | 3 + scripts/build-qbs-doc.sh | 59 + scripts/build-qbs-with-cmake.sh | 105 + scripts/build-qbs-with-qbs.sh | 145 + scripts/build-qbs-with-qmake.sh | 83 + scripts/cpu-count.sh | 50 + scripts/install-dm.sh | 135 + scripts/install-ow.sh | 128 + scripts/install-qt.sh | 394 + scripts/make-release-archives.bat | 77 + scripts/make-release-archives.sh | 50 + scripts/run-analyzer.sh | 109 + scripts/scripts.qbs | 7 + scripts/test-baremetal.sh | 54 + scripts/test-for-android.sh | 66 + scripts/test-qbs.sh | 59 + scripts/test-qt-for-android.sh | 86 + scripts/test-qt.sh | 53 + scripts/test-qt4.sh | 58 + scripts/thread-sanitizer-suppressions.txt | 1 + scripts/update-dmgbuild.sh | 49 + scripts/update-xcspecs.sh | 53 + share/CMakeLists.txt | 114 + .../imports/qbs/BundleTools/bundle-tools.js | 78 + .../imports/qbs/DarwinTools/darwin-tools.js | 271 + share/qbs/imports/qbs/ModUtils/utils.js | 649 + share/qbs/imports/qbs/PathTools/path-tools.js | 234 + .../imports/qbs/Probes/AndroidNdkProbe.qbs | 135 + .../imports/qbs/Probes/AndroidSdkProbe.qbs | 71 + share/qbs/imports/qbs/Probes/BinaryProbe.qbs | 37 + .../qbs/imports/qbs/Probes/ClBinaryProbe.qbs | 71 + .../imports/qbs/Probes/ClangClBinaryProbe.qbs | 73 + share/qbs/imports/qbs/Probes/ClangClProbe.qbs | 102 + .../qbs/imports/qbs/Probes/ConanfileProbe.qbs | 146 + share/qbs/imports/qbs/Probes/CosmicProbe.qbs | 87 + share/qbs/imports/qbs/Probes/DmcProbe.qbs | 97 + .../qbs/imports/qbs/Probes/FrameworkProbe.qbs | 39 + .../qbs/imports/qbs/Probes/GccBinaryProbe.qbs | 78 + share/qbs/imports/qbs/Probes/GccProbe.qbs | 110 + .../imports/qbs/Probes/GccVersionProbe.qbs | 67 + share/qbs/imports/qbs/Probes/IarProbe.qbs | 88 + .../qbs/Probes/IcoUtilsVersionProbe.qbs | 44 + share/qbs/imports/qbs/Probes/IncludeProbe.qbs | 43 + .../qbs/imports/qbs/Probes/InnoSetupProbe.qbs | 60 + share/qbs/imports/qbs/Probes/JdkProbe.qbs | 54 + .../imports/qbs/Probes/JdkVersionProbe.qbs | 44 + share/qbs/imports/qbs/Probes/KeilProbe.qbs | 86 + share/qbs/imports/qbs/Probes/LibraryProbe.qbs | 85 + share/qbs/imports/qbs/Probes/MsvcProbe.qbs | 97 + share/qbs/imports/qbs/Probes/NodeJsProbe.qbs | 49 + share/qbs/imports/qbs/Probes/NpmProbe.qbs | 87 + share/qbs/imports/qbs/Probes/PathProbe.qbs | 72 + .../qbs/imports/qbs/Probes/PkgConfigProbe.qbs | 137 + share/qbs/imports/qbs/Probes/SdccProbe.qbs | 89 + .../imports/qbs/Probes/TypeScriptProbe.qbs | 93 + share/qbs/imports/qbs/Probes/WatcomProbe.qbs | 98 + share/qbs/imports/qbs/Probes/WiXProbe.qbs | 75 + .../imports/qbs/Probes/XcodeLocationProbe.qbs | 47 + share/qbs/imports/qbs/Probes/XcodeProbe.qbs | 105 + share/qbs/imports/qbs/Probes/path-probe.js | 146 + share/qbs/imports/qbs/UnixUtils/unix-utils.js | 59 + .../imports/qbs/WindowsUtils/windows-utils.js | 105 + share/qbs/imports/qbs/base/AndroidApk.qbs | 38 + .../qbs/base/AppleApplicationDiskImage.qbs | 109 + share/qbs/imports/qbs/base/AppleDiskImage.qbs | 34 + share/qbs/imports/qbs/base/Application.qbs | 77 + .../imports/qbs/base/ApplicationExtension.qbs | 67 + share/qbs/imports/qbs/base/AutotestRunner.qbs | 107 + share/qbs/imports/qbs/base/CppApplication.qbs | 35 + share/qbs/imports/qbs/base/DynamicLibrary.qbs | 33 + share/qbs/imports/qbs/base/InnoSetup.qbs | 35 + share/qbs/imports/qbs/base/InstallPackage.qbs | 68 + .../imports/qbs/base/JavaClassCollection.qbs | 34 + share/qbs/imports/qbs/base/JavaJarFile.qbs | 35 + share/qbs/imports/qbs/base/Library.qbs | 94 + share/qbs/imports/qbs/base/LoadableModule.qbs | 33 + share/qbs/imports/qbs/base/NSISSetup.qbs | 34 + share/qbs/imports/qbs/base/NativeBinary.qbs | 72 + share/qbs/imports/qbs/base/NetModule.qbs | 4 + .../imports/qbs/base/NodeJSApplication.qbs | 33 + share/qbs/imports/qbs/base/QtApplication.qbs | 33 + .../qbs/imports/qbs/base/QtGuiApplication.qbs | 33 + share/qbs/imports/qbs/base/StaticLibrary.qbs | 33 + .../qbs/base/WindowsInstallerPackage.qbs | 34 + .../imports/qbs/base/WindowsSetupPackage.qbs | 34 + share/qbs/imports/qbs/base/XPCService.qbs | 47 + share/qbs/module-providers/Qt/provider.qbs | 6 + share/qbs/module-providers/Qt/setup-qt.js | 1707 + .../Qt/templates/QtModule.qbs | 86 + .../Qt/templates/QtPlugin.qbs | 51 + .../Qt/templates/android_support.qbs | 542 + .../module-providers/Qt/templates/core.qbs | 561 + .../qbs/module-providers/Qt/templates/dbus.js | 62 + .../module-providers/Qt/templates/dbus.qbs | 70 + .../qbs/module-providers/Qt/templates/gui.qbs | 73 + .../qbs/module-providers/Qt/templates/moc.js | 117 + .../module-providers/Qt/templates/module.qbs | 30 + .../module-providers/Qt/templates/plugin.qbs | 27 + .../Qt/templates/plugin_support.qbs | 77 + .../qbs/module-providers/Qt/templates/qdoc.js | 84 + .../qbs/module-providers/Qt/templates/qml.js | 89 + .../qbs/module-providers/Qt/templates/qml.qbs | 216 + .../Qt/templates/qmlcache.qbs | 86 + .../module-providers/Qt/templates/quick.js | 86 + .../module-providers/Qt/templates/quick.qbs | 218 + .../qbs/module-providers/Qt/templates/rcc.js | 8 + .../module-providers/Qt/templates/scxml.qbs | 81 + .../module-providers/__fallback/fallback.qbs | 76 + .../module-providers/__fallback/provider.qbs | 53 + share/qbs/module-providers/qbspkgconfig.qbs | 273 + share/qbs/modules/Android/android-utils.js | 50 + share/qbs/modules/Android/ndk/ndk.qbs | 141 + share/qbs/modules/Android/ndk/utils.js | 106 + share/qbs/modules/Android/sdk/sdk.qbs | 548 + share/qbs/modules/Android/sdk/utils.js | 449 + .../modules/Exporter/pkgconfig/pkgconfig.js | 228 + .../modules/Exporter/pkgconfig/pkgconfig.qbs | 87 + share/qbs/modules/Exporter/qbs/qbsexporter.js | 272 + .../qbs/modules/Exporter/qbs/qbsexporter.qbs | 78 + share/qbs/modules/Sanitizers/address/asan.qbs | 75 + share/qbs/modules/archiver/archiver.qbs | 241 + share/qbs/modules/autotest/autotest.qbs | 6 + share/qbs/modules/bundle/BundleModule.qbs | 789 + .../bundle/MacOSX-Package-Types.xcspec | 533 + .../bundle/MacOSX-Product-Types.xcspec | 803 + share/qbs/modules/bundle/bundle.js | 332 + share/qbs/modules/capnproto/capnproto.js | 97 + share/qbs/modules/capnproto/capnprotobase.qbs | 64 + .../modules/capnproto/cpp/capnprotocpp.qbs | 64 + share/qbs/modules/cli/CLIModule.qbs | 190 + share/qbs/modules/cli/cli.js | 181 + share/qbs/modules/cli/mono.qbs | 27 + share/qbs/modules/cli/windows-dotnet.qbs | 35 + share/qbs/modules/codesign/CodeSignModule.qbs | 52 + share/qbs/modules/codesign/android.qbs | 116 + share/qbs/modules/codesign/apple.qbs | 387 + share/qbs/modules/codesign/codesign.js | 473 + share/qbs/modules/codesign/noop.qbs | 35 + share/qbs/modules/codesign/signtool.qbs | 103 + share/qbs/modules/cpp/CppModule.qbs | 578 + share/qbs/modules/cpp/DarwinGCC.qbs | 296 + share/qbs/modules/cpp/GenericGCC.qbs | 720 + share/qbs/modules/cpp/LinuxGCC.qbs | 73 + share/qbs/modules/cpp/MingwBaseModule.qbs | 114 + share/qbs/modules/cpp/UnixGCC.qbs | 48 + share/qbs/modules/cpp/android-gcc.qbs | 193 + share/qbs/modules/cpp/cosmic.js | 443 + share/qbs/modules/cpp/cosmic.qbs | 147 + share/qbs/modules/cpp/cpp.js | 469 + share/qbs/modules/cpp/darwin.js | 188 + share/qbs/modules/cpp/dmc.js | 506 + share/qbs/modules/cpp/dmc.qbs | 194 + share/qbs/modules/cpp/freebsd-gcc.qbs | 43 + share/qbs/modules/cpp/freebsd.js | 10 + share/qbs/modules/cpp/gcc.js | 1579 + share/qbs/modules/cpp/iar.js | 768 + share/qbs/modules/cpp/iar.qbs | 154 + share/qbs/modules/cpp/ios-gcc.qbs | 93 + share/qbs/modules/cpp/keil.js | 992 + share/qbs/modules/cpp/keil.qbs | 151 + share/qbs/modules/cpp/macos-gcc.qbs | 48 + share/qbs/modules/cpp/msvc.js | 679 + share/qbs/modules/cpp/qnx-qcc.qbs | 96 + share/qbs/modules/cpp/sdcc.js | 573 + share/qbs/modules/cpp/sdcc.qbs | 155 + share/qbs/modules/cpp/setuprunenv.js | 149 + share/qbs/modules/cpp/tvos-gcc.qbs | 45 + share/qbs/modules/cpp/watchos-gcc.qbs | 46 + share/qbs/modules/cpp/watcom.js | 568 + share/qbs/modules/cpp/watcom.qbs | 196 + share/qbs/modules/cpp/windows-clang-cl.qbs | 98 + share/qbs/modules/cpp/windows-clang-mingw.qbs | 100 + share/qbs/modules/cpp/windows-mingw.qbs | 105 + share/qbs/modules/cpp/windows-msvc-base.qbs | 341 + share/qbs/modules/cpp/windows-msvc.qbs | 71 + share/qbs/modules/cpufeatures/cpufeatures.qbs | 23 + share/qbs/modules/dmg/DMGModule.qbs | 153 + share/qbs/modules/dmg/dmg.js | 212 + share/qbs/modules/freedesktop/FreeDesktop.qbs | 123 + share/qbs/modules/freedesktop/freedesktop.js | 69 + share/qbs/modules/ib/IBModule.qbs | 239 + share/qbs/modules/ib/ib.js | 367 + share/qbs/modules/ico/IcoModule.qbs | 101 + share/qbs/modules/ico/ico.js | 99 + .../qbs/modules/innosetup/InnoSetupModule.qbs | 146 + share/qbs/modules/java/JavaModule.qbs | 361 + .../qbs/modules/java/io/qt/qbs/Artifact.java | 76 + .../io/qt/qbs/ArtifactListJsonWriter.java | 153 + .../java/io/qt/qbs/ArtifactListWriter.java | 39 + .../qt/qbs/tools/JavaCompilerScannerTool.java | 51 + .../qbs/tools/utils/JavaCompilerOptions.java | 102 + .../qbs/tools/utils/JavaCompilerScanner.java | 107 + .../io/qt/qbs/tools/utils/NullFileObject.java | 147 + share/qbs/modules/java/utils.js | 360 + share/qbs/modules/lex_yacc/lexyacc.js | 84 + share/qbs/modules/lex_yacc/lexyacc.qbs | 102 + share/qbs/modules/nodejs/NodeJS.qbs | 156 + share/qbs/modules/nodejs/nodejs.js | 44 + share/qbs/modules/nsis/NSISModule.qbs | 245 + share/qbs/modules/pkgconfig/pkgconfig.qbs | 66 + .../qbs/modules/protobuf/cpp/protobufcpp.qbs | 172 + share/qbs/modules/protobuf/nanopb/nanopb.qbs | 103 + .../modules/protobuf/objc/protobufobjc.qbs | 64 + share/qbs/modules/protobuf/protobuf.js | 126 + share/qbs/modules/protobuf/protobufbase.qbs | 23 + share/qbs/modules/qbs/common.qbs | 213 + share/qbs/modules/qnx/qnx.qbs | 128 + .../qbs/modules/texttemplate/texttemplate.qbs | 64 + .../modules/typescript/TypeScriptModule.qbs | 295 + .../typescript/qbs-tsc-scan/.gitignore | 5 + .../typescript/qbs-tsc-scan/qbs-tsc-scan.ts | 68 + share/qbs/modules/typescript/typescript.js | 273 + share/qbs/modules/vcs/vcs-module.qbs | 154 + share/qbs/modules/wix/WiXModule.qbs | 453 + share/qbs/modules/xcode/xcode.js | 253 + share/qbs/modules/xcode/xcode.qbs | 207 + share/share.qbs | 145 + src/3rdparty/python/.gitignore | 3 + src/3rdparty/python/bin/dmgbuild | 36 + .../python2.7/site-packages/biplist/LICENSE | 25 + .../site-packages/biplist/__init__.py | 977 + .../site-packages/biplist/qt_attribution.json | 13 + .../python2.7/site-packages/dmgbuild/LICENSE | 19 + .../site-packages/dmgbuild/__init__.py | 3 + .../python2.7/site-packages/dmgbuild/badge.py | 143 + .../site-packages/dmgbuild/colors.py | 498 + .../python2.7/site-packages/dmgbuild/core.py | 655 + .../site-packages/dmgbuild/licensing.py | 461 + .../dmgbuild/qt_attribution.json | 13 + .../site-packages/dmgbuild/resources.py | 359 + .../python2.7/site-packages/ds_store/LICENSE | 19 + .../site-packages/ds_store/__init__.py | 3 + .../python2.7/site-packages/ds_store/buddy.py | 478 + .../ds_store/qt_attribution.json | 13 + .../python2.7/site-packages/ds_store/store.py | 1251 + .../python2.7/site-packages/mac_alias/LICENSE | 19 + .../site-packages/mac_alias/__init__.py | 27 + .../site-packages/mac_alias/alias.py | 607 + .../site-packages/mac_alias/bookmark.py | 665 + .../python2.7/site-packages/mac_alias/osx.py | 827 + .../mac_alias/qt_attribution.json | 13 + .../site-packages/mac_alias/utils.py | 18 + src/CMakeLists.txt | 5 + src/app/CMakeLists.txt | 8 + src/app/app.pri | 23 + src/app/app.pro | 10 + src/app/apps.qbs | 12 + src/app/config-ui/CMakeLists.txt | 19 + src/app/config-ui/Info.plist | 14 + src/app/config-ui/commandlineparser.cpp | 111 + src/app/config-ui/commandlineparser.h | 69 + src/app/config-ui/config-ui.pro | 26 + src/app/config-ui/config-ui.qbs | 32 + src/app/config-ui/fgapp.mm | 47 + src/app/config-ui/main.cpp | 69 + src/app/config-ui/mainwindow.cpp | 257 + src/app/config-ui/mainwindow.h | 77 + src/app/config-ui/mainwindow.ui | 37 + src/app/config/CMakeLists.txt | 13 + src/app/config/config.pro | 13 + src/app/config/config.qbs | 12 + src/app/config/configcommand.h | 60 + src/app/config/configcommandexecutor.cpp | 173 + src/app/config/configcommandexecutor.h | 67 + src/app/config/configcommandlineparser.cpp | 177 + src/app/config/configcommandlineparser.h | 81 + src/app/config/configmain.cpp | 76 + src/app/qbs-create-project/CMakeLists.txt | 10 + .../create-project-main.cpp | 93 + src/app/qbs-create-project/createproject.cpp | 234 + src/app/qbs-create-project/createproject.h | 90 + .../qbs-create-project/qbs-create-project.pro | 9 + .../qbs-create-project/qbs-create-project.qbs | 8 + src/app/qbs-setup-android/CMakeLists.txt | 12 + src/app/qbs-setup-android/android-setup.cpp | 256 + src/app/qbs-setup-android/android-setup.h | 55 + .../qbs-setup-android/commandlineparser.cpp | 147 + src/app/qbs-setup-android/commandlineparser.h | 80 + src/app/qbs-setup-android/main.cpp | 70 + .../qbs-setup-android.exe.manifest | 13 + .../qbs-setup-android/qbs-setup-android.pro | 12 + .../qbs-setup-android/qbs-setup-android.qbs | 20 + .../qbs-setup-android/qbs-setup-android.rc | 4 + src/app/qbs-setup-qt/CMakeLists.txt | 12 + src/app/qbs-setup-qt/commandlineparser.cpp | 137 + src/app/qbs-setup-qt/commandlineparser.h | 76 + src/app/qbs-setup-qt/main.cpp | 109 + .../qbs-setup-qt/qbs-setup-qt.exe.manifest | 13 + src/app/qbs-setup-qt/qbs-setup-qt.pro | 16 + src/app/qbs-setup-qt/qbs-setup-qt.qbs | 21 + src/app/qbs-setup-qt/qbs-setup-qt.rc | 4 + src/app/qbs-setup-qt/setupqt.cpp | 389 + src/app/qbs-setup-qt/setupqt.h | 81 + src/app/qbs-setup-toolchains/CMakeLists.txt | 32 + src/app/qbs-setup-toolchains/clangclprobe.cpp | 133 + src/app/qbs-setup-toolchains/clangclprobe.h | 61 + .../commandlineparser.cpp | 145 + .../qbs-setup-toolchains/commandlineparser.h | 79 + src/app/qbs-setup-toolchains/cosmicprobe.cpp | 179 + src/app/qbs-setup-toolchains/cosmicprobe.h | 61 + src/app/qbs-setup-toolchains/dmcprobe.cpp | 265 + src/app/qbs-setup-toolchains/dmcprobe.h | 61 + src/app/qbs-setup-toolchains/gccprobe.cpp | 589 + src/app/qbs-setup-toolchains/gccprobe.h | 62 + src/app/qbs-setup-toolchains/iarewprobe.cpp | 331 + src/app/qbs-setup-toolchains/iarewprobe.h | 61 + src/app/qbs-setup-toolchains/keilprobe.cpp | 424 + src/app/qbs-setup-toolchains/keilprobe.h | 61 + src/app/qbs-setup-toolchains/main.cpp | 82 + src/app/qbs-setup-toolchains/msvcprobe.cpp | 221 + src/app/qbs-setup-toolchains/msvcprobe.h | 61 + src/app/qbs-setup-toolchains/probe.cpp | 339 + src/app/qbs-setup-toolchains/probe.h | 85 + .../qbs-setup-toolchains.exe.manifest | 13 + .../qbs-setup-toolchains.pro | 36 + .../qbs-setup-toolchains.qbs | 41 + .../qbs-setup-toolchains.rc | 4 + src/app/qbs-setup-toolchains/sdccprobe.cpp | 275 + src/app/qbs-setup-toolchains/sdccprobe.h | 75 + src/app/qbs-setup-toolchains/watcomprobe.cpp | 255 + src/app/qbs-setup-toolchains/watcomprobe.h | 59 + src/app/qbs-setup-toolchains/xcodeprobe.cpp | 236 + src/app/qbs-setup-toolchains/xcodeprobe.h | 52 + src/app/qbs/CMakeLists.txt | 50 + src/app/qbs/application.cpp | 78 + src/app/qbs/application.h | 66 + src/app/qbs/commandlinefrontend.cpp | 704 + src/app/qbs/commandlinefrontend.h | 130 + src/app/qbs/consoleprogressobserver.cpp | 117 + src/app/qbs/consoleprogressobserver.h | 71 + src/app/qbs/ctrlchandler.cpp | 80 + src/app/qbs/ctrlchandler.h | 45 + src/app/qbs/main.cpp | 96 + src/app/qbs/parser/commandlineoption.cpp | 701 + src/app/qbs/parser/commandlineoption.h | 428 + src/app/qbs/parser/commandlineoptionpool.cpp | 290 + src/app/qbs/parser/commandlineoptionpool.h | 89 + src/app/qbs/parser/commandlineparser.cpp | 622 + src/app/qbs/parser/commandlineparser.h | 100 + src/app/qbs/parser/commandpool.cpp | 106 + src/app/qbs/parser/commandpool.h | 66 + src/app/qbs/parser/commandtype.h | 53 + src/app/qbs/parser/parser.pri | 16 + src/app/qbs/parser/parsercommand.cpp | 617 + src/app/qbs/parser/parsercommand.h | 280 + src/app/qbs/qbs.pro | 54 + src/app/qbs/qbs.qbs | 58 + src/app/qbs/qbstool.cpp | 104 + src/app/qbs/qbstool.h | 66 + src/app/qbs/session.cpp | 762 + src/app/qbs/session.h | 51 + src/app/qbs/sessionpacket.cpp | 113 + src/app/qbs/sessionpacket.h | 70 + src/app/qbs/sessionpacketreader.cpp | 85 + src/app/qbs/sessionpacketreader.h | 72 + src/app/qbs/status.cpp | 168 + src/app/qbs/status.h | 50 + src/app/qbs/stdinreader.cpp | 166 + src/app/qbs/stdinreader.h | 66 + src/app/shared/CMakeLists.txt | 1 + src/app/shared/logging/CMakeLists.txt | 12 + src/app/shared/logging/coloredoutput.cpp | 111 + src/app/shared/logging/coloredoutput.h | 73 + src/app/shared/logging/consolelogger.cpp | 117 + src/app/shared/logging/consolelogger.h | 88 + src/app/shared/logging/logging.pri | 2 + src/app/shared/logging/logging.qbs | 14 + src/app/shared/shared.qbs | 5 + src/install_prefix.pri | 1 + src/lib/CMakeLists.txt | 7 + src/lib/bundledlibs.pri | 3 + src/lib/corelib/CMakeLists.txt | 474 + src/lib/corelib/api/api.pri | 49 + src/lib/corelib/api/changeset.cpp | 372 + src/lib/corelib/api/changeset.h | 136 + src/lib/corelib/api/internaljobs.cpp | 464 + src/lib/corelib/api/internaljobs.h | 230 + src/lib/corelib/api/jobs.cpp | 375 + src/lib/corelib/api/jobs.h | 173 + src/lib/corelib/api/languageinfo.cpp | 134 + src/lib/corelib/api/languageinfo.h | 62 + src/lib/corelib/api/project.cpp | 1153 + src/lib/corelib/api/project.h | 181 + src/lib/corelib/api/project_p.h | 138 + src/lib/corelib/api/projectdata.cpp | 1020 + src/lib/corelib/api/projectdata.h | 263 + src/lib/corelib/api/projectdata_p.h | 137 + src/lib/corelib/api/projectfileupdater.cpp | 561 + src/lib/corelib/api/projectfileupdater.h | 147 + src/lib/corelib/api/propertymap_p.h | 57 + src/lib/corelib/api/qmljsrewriter.cpp | 713 + src/lib/corelib/api/qmljsrewriter.h | 130 + src/lib/corelib/api/rulecommand.cpp | 154 + src/lib/corelib/api/rulecommand.h | 89 + src/lib/corelib/api/rulecommand_p.h | 69 + src/lib/corelib/api/runenvironment.cpp | 481 + src/lib/corelib/api/runenvironment.h | 105 + src/lib/corelib/api/transformerdata.cpp | 56 + src/lib/corelib/api/transformerdata.h | 78 + src/lib/corelib/api/transformerdata_p.h | 59 + .../buildgraph/abstractcommandexecutor.cpp | 107 + .../buildgraph/abstractcommandexecutor.h | 104 + src/lib/corelib/buildgraph/artifact.cpp | 187 + src/lib/corelib/buildgraph/artifact.h | 178 + .../corelib/buildgraph/artifactcleaner.cpp | 232 + src/lib/corelib/buildgraph/artifactcleaner.h | 72 + .../buildgraph/artifactsscriptvalue.cpp | 218 + .../corelib/buildgraph/artifactsscriptvalue.h | 63 + .../corelib/buildgraph/artifactvisitor.cpp | 83 + src/lib/corelib/buildgraph/artifactvisitor.h | 71 + src/lib/corelib/buildgraph/buildgraph.cpp | 856 + src/lib/corelib/buildgraph/buildgraph.h | 102 + src/lib/corelib/buildgraph/buildgraph.pri | 89 + .../corelib/buildgraph/buildgraphloader.cpp | 983 + src/lib/corelib/buildgraph/buildgraphloader.h | 154 + src/lib/corelib/buildgraph/buildgraphnode.cpp | 87 + src/lib/corelib/buildgraph/buildgraphnode.h | 104 + .../corelib/buildgraph/buildgraphvisitor.h | 68 + src/lib/corelib/buildgraph/cycledetector.cpp | 110 + src/lib/corelib/buildgraph/cycledetector.h | 77 + .../dependencyparametersscriptvalue.cpp | 85 + .../dependencyparametersscriptvalue.h | 55 + src/lib/corelib/buildgraph/depscanner.cpp | 270 + src/lib/corelib/buildgraph/depscanner.h | 129 + .../buildgraph/emptydirectoriesremover.cpp | 116 + .../buildgraph/emptydirectoriesremover.h | 73 + .../buildgraph/environmentscriptrunner.cpp | 223 + .../buildgraph/environmentscriptrunner.h | 78 + src/lib/corelib/buildgraph/executor.cpp | 1330 + src/lib/corelib/buildgraph/executor.h | 200 + src/lib/corelib/buildgraph/executorjob.cpp | 180 + src/lib/corelib/buildgraph/executorjob.h | 103 + src/lib/corelib/buildgraph/filedependency.cpp | 90 + src/lib/corelib/buildgraph/filedependency.h | 96 + src/lib/corelib/buildgraph/forward_decls.h | 76 + .../buildgraph/inputartifactscanner.cpp | 406 + .../corelib/buildgraph/inputartifactscanner.h | 150 + .../corelib/buildgraph/jscommandexecutor.cpp | 292 + .../corelib/buildgraph/jscommandexecutor.h | 84 + src/lib/corelib/buildgraph/nodeset.cpp | 73 + src/lib/corelib/buildgraph/nodeset.h | 137 + src/lib/corelib/buildgraph/nodetreedumper.cpp | 127 + src/lib/corelib/buildgraph/nodetreedumper.h | 83 + .../buildgraph/processcommandexecutor.cpp | 424 + .../buildgraph/processcommandexecutor.h | 101 + .../corelib/buildgraph/productbuilddata.cpp | 142 + src/lib/corelib/buildgraph/productbuilddata.h | 120 + .../corelib/buildgraph/productinstaller.cpp | 254 + src/lib/corelib/buildgraph/productinstaller.h | 85 + .../corelib/buildgraph/projectbuilddata.cpp | 482 + src/lib/corelib/buildgraph/projectbuilddata.h | 138 + src/lib/corelib/buildgraph/qtmocscanner.cpp | 278 + src/lib/corelib/buildgraph/qtmocscanner.h | 83 + .../buildgraph/rawscanneddependency.cpp | 83 + .../corelib/buildgraph/rawscanneddependency.h | 87 + src/lib/corelib/buildgraph/rawscanresults.cpp | 72 + src/lib/corelib/buildgraph/rawscanresults.h | 106 + .../corelib/buildgraph/requestedartifacts.cpp | 204 + .../corelib/buildgraph/requestedartifacts.h | 106 + .../buildgraph/requesteddependencies.cpp | 91 + .../buildgraph/requesteddependencies.h | 77 + .../buildgraph/rescuableartifactdata.h | 139 + src/lib/corelib/buildgraph/rulecommands.cpp | 489 + src/lib/corelib/buildgraph/rulecommands.h | 237 + src/lib/corelib/buildgraph/rulegraph.cpp | 150 + src/lib/corelib/buildgraph/rulegraph.h | 92 + src/lib/corelib/buildgraph/rulenode.cpp | 321 + src/lib/corelib/buildgraph/rulenode.h | 122 + .../corelib/buildgraph/rulesapplicator.cpp | 684 + src/lib/corelib/buildgraph/rulesapplicator.h | 137 + .../buildgraph/rulesevaluationcontext.cpp | 122 + .../buildgraph/rulesevaluationcontext.h | 98 + .../buildgraph/scriptclasspropertyiterator.h | 110 + .../corelib/buildgraph/timestampsupdater.cpp | 97 + .../corelib/buildgraph/timestampsupdater.h | 60 + src/lib/corelib/buildgraph/transformer.cpp | 331 + src/lib/corelib/buildgraph/transformer.h | 140 + .../buildgraph/transformerchangetracking.cpp | 379 + .../buildgraph/transformerchangetracking.h | 53 + src/lib/corelib/corelib.pro | 43 + src/lib/corelib/corelib.qbs | 535 + .../generators/generatableprojectiterator.cpp | 89 + .../generators/generatableprojectiterator.h | 63 + src/lib/corelib/generators/generator.cpp | 248 + src/lib/corelib/generators/generator.h | 99 + src/lib/corelib/generators/generatordata.cpp | 155 + src/lib/corelib/generators/generatordata.h | 183 + src/lib/corelib/generators/generators.pri | 38 + src/lib/corelib/generators/generatorutils.cpp | 263 + src/lib/corelib/generators/generatorutils.h | 99 + .../generators/generatorversioninfo.cpp | 51 + .../corelib/generators/generatorversioninfo.h | 85 + .../generators/igeneratableprojectvisitor.h | 107 + src/lib/corelib/generators/ixmlnodevisitor.h | 69 + src/lib/corelib/generators/xmlproject.cpp | 50 + src/lib/corelib/generators/xmlproject.h | 54 + .../corelib/generators/xmlprojectwriter.cpp | 93 + src/lib/corelib/generators/xmlprojectwriter.h | 70 + src/lib/corelib/generators/xmlproperty.cpp | 56 + src/lib/corelib/generators/xmlproperty.h | 88 + .../corelib/generators/xmlpropertygroup.cpp | 66 + src/lib/corelib/generators/xmlpropertygroup.h | 78 + src/lib/corelib/generators/xmlworkspace.cpp | 66 + src/lib/corelib/generators/xmlworkspace.h | 69 + .../corelib/generators/xmlworkspacewriter.cpp | 93 + .../corelib/generators/xmlworkspacewriter.h | 70 + src/lib/corelib/jsextensions/binaryfile.cpp | 265 + src/lib/corelib/jsextensions/domxml.cpp | 465 + .../jsextensions/environmentextension.cpp | 160 + src/lib/corelib/jsextensions/file.cpp | 290 + .../jsextensions/fileinfoextension.cpp | 350 + src/lib/corelib/jsextensions/host.cpp | 193 + src/lib/corelib/jsextensions/jsextensions.cpp | 107 + src/lib/corelib/jsextensions/jsextensions.h | 66 + src/lib/corelib/jsextensions/jsextensions.pri | 29 + .../corelib/jsextensions/moduleproperties.cpp | 357 + .../corelib/jsextensions/moduleproperties.h | 86 + src/lib/corelib/jsextensions/pkgconfigjs.cpp | 264 + src/lib/corelib/jsextensions/pkgconfigjs.h | 104 + src/lib/corelib/jsextensions/process.cpp | 350 + src/lib/corelib/jsextensions/propertylist.cpp | 48 + .../jsextensions/propertylist_darwin.h | 91 + .../jsextensions/propertylist_darwin.mm | 343 + .../corelib/jsextensions/propertylistutils.h | 74 + .../corelib/jsextensions/propertylistutils.mm | 185 + src/lib/corelib/jsextensions/temporarydir.cpp | 122 + src/lib/corelib/jsextensions/textfile.cpp | 262 + .../jsextensions/utilitiesextension.cpp | 978 + .../corelib/language/artifactproperties.cpp | 72 + src/lib/corelib/language/artifactproperties.h | 85 + .../corelib/language/astimportshandler.cpp | 305 + src/lib/corelib/language/astimportshandler.h | 94 + .../language/astpropertiesitemhandler.cpp | 192 + .../language/astpropertiesitemhandler.h | 63 + src/lib/corelib/language/asttools.cpp | 74 + src/lib/corelib/language/asttools.h | 58 + .../corelib/language/builtindeclarations.cpp | 608 + .../corelib/language/builtindeclarations.h | 102 + src/lib/corelib/language/deprecationinfo.h | 71 + src/lib/corelib/language/evaluationdata.h | 66 + src/lib/corelib/language/evaluator.cpp | 286 + src/lib/corelib/language/evaluator.h | 141 + .../corelib/language/evaluatorscriptclass.cpp | 776 + .../corelib/language/evaluatorscriptclass.h | 133 + src/lib/corelib/language/filecontext.cpp | 64 + src/lib/corelib/language/filecontext.h | 74 + src/lib/corelib/language/filecontextbase.cpp | 53 + src/lib/corelib/language/filecontextbase.h | 79 + src/lib/corelib/language/filetags.cpp | 99 + src/lib/corelib/language/filetags.h | 96 + src/lib/corelib/language/forward_decls.h | 161 + src/lib/corelib/language/identifiersearch.cpp | 77 + src/lib/corelib/language/identifiersearch.h | 70 + src/lib/corelib/language/item.cpp | 414 + src/lib/corelib/language/item.h | 183 + src/lib/corelib/language/itemdeclaration.cpp | 64 + src/lib/corelib/language/itemdeclaration.h | 84 + src/lib/corelib/language/itemobserver.h | 58 + src/lib/corelib/language/itempool.cpp | 62 + src/lib/corelib/language/itempool.h | 71 + src/lib/corelib/language/itemreader.cpp | 147 + src/lib/corelib/language/itemreader.h | 102 + .../corelib/language/itemreaderastvisitor.cpp | 405 + .../corelib/language/itemreaderastvisitor.h | 97 + .../language/itemreadervisitorstate.cpp | 195 + .../corelib/language/itemreadervisitorstate.h | 83 + src/lib/corelib/language/itemtype.h | 91 + src/lib/corelib/language/jsimports.h | 91 + src/lib/corelib/language/language.cpp | 982 + src/lib/corelib/language/language.h | 752 + src/lib/corelib/language/language.pri | 86 + src/lib/corelib/language/loader.cpp | 222 + src/lib/corelib/language/loader.h | 88 + src/lib/corelib/language/moduleloader.cpp | 3840 ++ src/lib/corelib/language/moduleloader.h | 459 + src/lib/corelib/language/modulemerger.cpp | 267 + src/lib/corelib/language/modulemerger.h | 89 + src/lib/corelib/language/moduleproviderinfo.h | 109 + .../corelib/language/moduleproviderloader.cpp | 316 + .../corelib/language/moduleproviderloader.h | 134 + .../language/preparescriptobserver.cpp | 97 + .../corelib/language/preparescriptobserver.h | 96 + src/lib/corelib/language/probesresolver.cpp | 299 + src/lib/corelib/language/probesresolver.h | 92 + src/lib/corelib/language/projectresolver.cpp | 1920 + src/lib/corelib/language/projectresolver.h | 208 + src/lib/corelib/language/property.cpp | 61 + src/lib/corelib/language/property.h | 108 + .../corelib/language/propertydeclaration.cpp | 303 + .../corelib/language/propertydeclaration.h | 130 + .../corelib/language/propertymapinternal.cpp | 108 + .../corelib/language/propertymapinternal.h | 90 + src/lib/corelib/language/qualifiedid.cpp | 70 + src/lib/corelib/language/qualifiedid.h | 73 + .../corelib/language/resolvedfilecontext.cpp | 61 + .../corelib/language/resolvedfilecontext.h | 79 + src/lib/corelib/language/scriptengine.cpp | 830 + src/lib/corelib/language/scriptengine.h | 388 + src/lib/corelib/language/scriptimporter.cpp | 163 + src/lib/corelib/language/scriptimporter.h | 68 + .../language/scriptpropertyobserver.cpp | 54 + .../corelib/language/scriptpropertyobserver.h | 81 + src/lib/corelib/language/value.cpp | 221 + src/lib/corelib/language/value.h | 231 + src/lib/corelib/logging/categories.cpp | 55 + src/lib/corelib/logging/categories.h | 60 + src/lib/corelib/logging/ilogsink.cpp | 125 + src/lib/corelib/logging/ilogsink.h | 93 + src/lib/corelib/logging/logger.cpp | 238 + src/lib/corelib/logging/logger.h | 143 + src/lib/corelib/logging/logging.pri | 18 + src/lib/corelib/logging/translator.h | 57 + src/lib/corelib/parser/parser.pri | 21 + src/lib/corelib/parser/qmlerror.cpp | 297 + src/lib/corelib/parser/qmlerror.h | 86 + src/lib/corelib/parser/qmljs.g | 3023 ++ src/lib/corelib/parser/qmljsast.cpp | 925 + src/lib/corelib/parser/qmljsast_p.h | 2637 + src/lib/corelib/parser/qmljsastfwd_p.h | 182 + src/lib/corelib/parser/qmljsastvisitor.cpp | 50 + src/lib/corelib/parser/qmljsastvisitor_p.h | 326 + src/lib/corelib/parser/qmljsengine_p.cpp | 158 + src/lib/corelib/parser/qmljsengine_p.h | 135 + src/lib/corelib/parser/qmljsglobal_p.h | 71 + src/lib/corelib/parser/qmljsgrammar.cpp | 1017 + src/lib/corelib/parser/qmljsgrammar_p.h | 210 + src/lib/corelib/parser/qmljskeywords_p.h | 862 + src/lib/corelib/parser/qmljslexer.cpp | 1155 + src/lib/corelib/parser/qmljslexer_p.h | 248 + src/lib/corelib/parser/qmljsmemorypool_p.h | 167 + src/lib/corelib/parser/qmljsparser.cpp | 1819 + src/lib/corelib/parser/qmljsparser_p.h | 241 + src/lib/corelib/qbs.h | 68 + src/lib/corelib/tools/applecodesignutils.cpp | 156 + src/lib/corelib/tools/applecodesignutils.h | 56 + src/lib/corelib/tools/architectures.cpp | 159 + src/lib/corelib/tools/architectures.h | 58 + src/lib/corelib/tools/buildgraphlocker.cpp | 166 + src/lib/corelib/tools/buildgraphlocker.h | 87 + src/lib/corelib/tools/buildoptions.cpp | 463 + src/lib/corelib/tools/buildoptions.h | 125 + src/lib/corelib/tools/clangclinfo.cpp | 173 + src/lib/corelib/tools/clangclinfo.h | 61 + src/lib/corelib/tools/cleanoptions.cpp | 158 + src/lib/corelib/tools/cleanoptions.h | 80 + src/lib/corelib/tools/codelocation.cpp | 184 + src/lib/corelib/tools/codelocation.h | 94 + src/lib/corelib/tools/commandechomode.cpp | 101 + src/lib/corelib/tools/commandechomode.h | 66 + src/lib/corelib/tools/dynamictypecheck.h | 42 + src/lib/corelib/tools/error.cpp | 340 + src/lib/corelib/tools/error.h | 138 + src/lib/corelib/tools/executablefinder.cpp | 153 + src/lib/corelib/tools/executablefinder.h | 77 + src/lib/corelib/tools/fileinfo.cpp | 603 + src/lib/corelib/tools/fileinfo.h | 110 + src/lib/corelib/tools/filesaver.cpp | 116 + src/lib/corelib/tools/filesaver.h | 75 + src/lib/corelib/tools/filetime.cpp | 215 + src/lib/corelib/tools/filetime.h | 112 + src/lib/corelib/tools/generateoptions.cpp | 94 + src/lib/corelib/tools/generateoptions.h | 71 + src/lib/corelib/tools/hostosinfo.h | 287 + src/lib/corelib/tools/id.cpp | 284 + src/lib/corelib/tools/id.h | 96 + src/lib/corelib/tools/installoptions.cpp | 242 + src/lib/corelib/tools/installoptions.h | 96 + src/lib/corelib/tools/iosutils.h | 110 + src/lib/corelib/tools/joblimits.cpp | 176 + src/lib/corelib/tools/joblimits.h | 102 + src/lib/corelib/tools/jsliterals.cpp | 108 + src/lib/corelib/tools/jsliterals.h | 58 + src/lib/corelib/tools/jsonhelper.h | 88 + src/lib/corelib/tools/launcherinterface.cpp | 180 + src/lib/corelib/tools/launcherinterface.h | 88 + src/lib/corelib/tools/launcherpackets.cpp | 174 + src/lib/corelib/tools/launcherpackets.h | 178 + src/lib/corelib/tools/launchersocket.cpp | 153 + src/lib/corelib/tools/launchersocket.h | 93 + src/lib/corelib/tools/msvcinfo.cpp | 729 + src/lib/corelib/tools/msvcinfo.h | 145 + src/lib/corelib/tools/pathutils.h | 65 + src/lib/corelib/tools/persistence.cpp | 238 + src/lib/corelib/tools/persistence.h | 548 + src/lib/corelib/tools/porting.h | 55 + src/lib/corelib/tools/preferences.cpp | 203 + src/lib/corelib/tools/preferences.h | 84 + src/lib/corelib/tools/processresult.cpp | 154 + src/lib/corelib/tools/processresult.h | 87 + src/lib/corelib/tools/processresult_p.h | 66 + src/lib/corelib/tools/processutils.cpp | 133 + src/lib/corelib/tools/processutils.h | 57 + src/lib/corelib/tools/profile.cpp | 257 + src/lib/corelib/tools/profile.h | 108 + src/lib/corelib/tools/profiling.cpp | 125 + src/lib/corelib/tools/profiling.h | 84 + src/lib/corelib/tools/progressobserver.cpp | 105 + src/lib/corelib/tools/progressobserver.h | 72 + .../corelib/tools/projectgeneratormanager.cpp | 81 + .../corelib/tools/projectgeneratormanager.h | 71 + src/lib/corelib/tools/qbs_export.h | 75 + src/lib/corelib/tools/qbsassert.cpp | 60 + src/lib/corelib/tools/qbsassert.h | 69 + src/lib/corelib/tools/qbspluginmanager.cpp | 162 + src/lib/corelib/tools/qbspluginmanager.h | 90 + src/lib/corelib/tools/qbsprocess.cpp | 185 + src/lib/corelib/tools/qbsprocess.h | 106 + src/lib/corelib/tools/qttools.cpp | 81 + src/lib/corelib/tools/qttools.h | 234 + .../corelib/tools/scannerpluginmanager.cpp | 86 + src/lib/corelib/tools/scannerpluginmanager.h | 72 + src/lib/corelib/tools/scripttools.cpp | 81 + src/lib/corelib/tools/scripttools.h | 96 + src/lib/corelib/tools/set.h | 400 + src/lib/corelib/tools/settings.cpp | 259 + src/lib/corelib/tools/settings.h | 109 + src/lib/corelib/tools/settingscreator.cpp | 126 + src/lib/corelib/tools/settingscreator.h | 80 + src/lib/corelib/tools/settingsmodel.cpp | 398 + src/lib/corelib/tools/settingsmodel.h | 91 + .../corelib/tools/settingsrepresentation.cpp | 82 + .../corelib/tools/settingsrepresentation.h | 55 + .../corelib/tools/setupprojectparameters.cpp | 691 + .../corelib/tools/setupprojectparameters.h | 153 + src/lib/corelib/tools/shellutils.cpp | 262 + src/lib/corelib/tools/shellutils.h | 94 + src/lib/corelib/tools/stlutils.h | 259 + src/lib/corelib/tools/stringconstants.h | 262 + src/lib/corelib/tools/stringutils.h | 135 + src/lib/corelib/tools/toolchains.cpp | 122 + src/lib/corelib/tools/toolchains.h | 52 + src/lib/corelib/tools/tools.pri | 147 + src/lib/corelib/tools/version.cpp | 87 + src/lib/corelib/tools/version.h | 137 + .../corelib/tools/visualstudioversioninfo.cpp | 193 + .../corelib/tools/visualstudioversioninfo.h | 87 + .../corelib/tools/vsenvironmentdetector.cpp | 287 + src/lib/corelib/tools/vsenvironmentdetector.h | 81 + src/lib/corelib/tools/weakpointer.h | 94 + src/lib/corelib/use_corelib.pri | 47 + src/lib/corelib/use_installed_corelib.pri | 37 + src/lib/library.pri | 32 + src/lib/library_base.pri | 21 + src/lib/libs.qbs | 8 + src/lib/msbuild/CMakeLists.txt | 72 + src/lib/msbuild/io/msbuildprojectwriter.cpp | 235 + src/lib/msbuild/io/msbuildprojectwriter.h | 60 + .../msbuild/io/visualstudiosolutionwriter.cpp | 167 + .../msbuild/io/visualstudiosolutionwriter.h | 67 + src/lib/msbuild/msbuild.pro | 58 + src/lib/msbuild/msbuild.qbs | 86 + src/lib/msbuild/msbuild/imsbuildgroup.cpp | 65 + src/lib/msbuild/msbuild/imsbuildgroup.h | 66 + src/lib/msbuild/msbuild/imsbuildnode.cpp | 37 + src/lib/msbuild/msbuild/imsbuildnode.h | 47 + src/lib/msbuild/msbuild/imsbuildnodevisitor.h | 81 + .../msbuild/items/msbuildclcompile.cpp | 42 + .../msbuild/msbuild/items/msbuildclcompile.h | 48 + .../msbuild/items/msbuildclinclude.cpp | 42 + .../msbuild/msbuild/items/msbuildclinclude.h | 48 + .../msbuild/msbuild/items/msbuildfileitem.cpp | 74 + .../msbuild/msbuild/items/msbuildfileitem.h | 60 + .../msbuild/msbuild/items/msbuildfilter.cpp | 117 + src/lib/msbuild/msbuild/items/msbuildfilter.h | 68 + src/lib/msbuild/msbuild/items/msbuildlink.cpp | 44 + src/lib/msbuild/msbuild/items/msbuildlink.h | 49 + src/lib/msbuild/msbuild/items/msbuildnone.cpp | 40 + src/lib/msbuild/msbuild/items/msbuildnone.h | 48 + src/lib/msbuild/msbuild/msbuildimport.cpp | 86 + src/lib/msbuild/msbuild/msbuildimport.h | 72 + .../msbuild/msbuild/msbuildimportgroup.cpp | 74 + src/lib/msbuild/msbuild/msbuildimportgroup.h | 66 + src/lib/msbuild/msbuild/msbuilditem.cpp | 93 + src/lib/msbuild/msbuild/msbuilditem.h | 74 + .../msbuild/msbuilditemdefinitiongroup.cpp | 57 + .../msbuild/msbuilditemdefinitiongroup.h | 59 + src/lib/msbuild/msbuild/msbuilditemgroup.cpp | 76 + src/lib/msbuild/msbuild/msbuilditemgroup.h | 68 + .../msbuild/msbuild/msbuilditemmetadata.cpp | 57 + src/lib/msbuild/msbuild/msbuilditemmetadata.h | 60 + src/lib/msbuild/msbuild/msbuildproject.cpp | 97 + src/lib/msbuild/msbuild/msbuildproject.h | 70 + src/lib/msbuild/msbuild/msbuildproperty.cpp | 57 + src/lib/msbuild/msbuild/msbuildproperty.h | 59 + .../msbuild/msbuild/msbuildpropertybase.cpp | 81 + src/lib/msbuild/msbuild/msbuildpropertybase.h | 67 + .../msbuild/msbuild/msbuildpropertygroup.cpp | 80 + .../msbuild/msbuild/msbuildpropertygroup.h | 68 + .../solution/ivisualstudiosolutionproject.cpp | 71 + .../solution/ivisualstudiosolutionproject.h | 67 + .../msbuild/solution/visualstudiosolution.cpp | 117 + .../msbuild/solution/visualstudiosolution.h | 85 + .../visualstudiosolutionfileproject.cpp | 76 + .../visualstudiosolutionfileproject.h | 63 + .../visualstudiosolutionfolderproject.cpp | 47 + .../visualstudiosolutionfolderproject.h | 50 + .../visualstudiosolutionglobalsection.cpp | 86 + .../visualstudiosolutionglobalsection.h | 65 + src/lib/msbuild/use_installed_msbuild.pri | 20 + src/lib/msbuild/use_msbuild.pri | 38 + src/lib/pkgconfig/CMakeLists.txt | 32 + src/lib/pkgconfig/pcpackage.cpp | 172 + src/lib/pkgconfig/pcpackage.h | 196 + src/lib/pkgconfig/pcparser.cpp | 781 + src/lib/pkgconfig/pcparser.h | 84 + src/lib/pkgconfig/pkgconfig.cpp | 494 + src/lib/pkgconfig/pkgconfig.h | 90 + src/lib/pkgconfig/pkgconfig.pro | 25 + src/lib/pkgconfig/pkgconfig.qbs | 68 + src/lib/pkgconfig/use_pkgconfig.pri | 52 + src/lib/scriptengine/CMakeLists.txt | 367 + src/lib/scriptengine/scriptengine.pro | 98 + src/lib/scriptengine/scriptengine.qbs | 464 + src/lib/scriptengine/use_scriptengine.pri | 30 + src/lib/staticlibrary.pri | 4 + src/libexec/CMakeLists.txt | 1 + src/libexec/libexec.pri | 11 + src/libexec/libexec.pro | 3 + src/libexec/libexec.qbs | 5 + .../qbs_processlauncher/CMakeLists.txt | 25 + .../qbs_processlauncher/launcherlogging.cpp | 46 + .../qbs_processlauncher/launcherlogging.h | 54 + .../launchersockethandler.cpp | 295 + .../launchersockethandler.h | 92 + .../processlauncher-main.cpp | 71 + .../qbs_processlauncher.pro | 21 + .../qbs_processlauncher.qbs | 38 + src/library_dirname.pri | 1 + src/packages/archive/archive.qbs | 88 + src/packages/chocolatey/chocolatey.qbs | 129 + src/packages/chocolatey/chocolateyinstall.ps1 | 23 + src/packages/chocolatey/icon.png | Bin 0 -> 6915 bytes src/packages/chocolatey/qbs.nuspec | 23 + src/packages/packages.qbs | 14 + src/plugins/CMakeLists.txt | 2 + src/plugins/generator/CMakeLists.txt | 5 + .../clangcompilationdb/CMakeLists.txt | 10 + .../clangcompilationdb/clangcompilationdb.pri | 1 + .../clangcompilationdb/clangcompilationdb.pro | 11 + .../clangcompilationdb/clangcompilationdb.qbs | 10 + .../clangcompilationdbgenerator.cpp | 155 + .../clangcompilationdbgenerator.h | 67 + .../clangcompilationdbgeneratorplugin.cpp | 64 + src/plugins/generator/generator.pro | 6 + src/plugins/generator/iarew/CMakeLists.txt | 119 + .../archs/arm/armarchiversettingsgroup_v8.cpp | 95 + .../archs/arm/armarchiversettingsgroup_v8.h | 58 + .../arm/armassemblersettingsgroup_v8.cpp | 230 + .../archs/arm/armassemblersettingsgroup_v8.h | 63 + .../arm/armbuildconfigurationgroup_v8.cpp | 98 + .../archs/arm/armbuildconfigurationgroup_v8.h | 71 + .../archs/arm/armcompilersettingsgroup_v8.cpp | 478 + .../archs/arm/armcompilersettingsgroup_v8.h | 63 + .../archs/arm/armgeneralsettingsgroup_v8.cpp | 551 + .../archs/arm/armgeneralsettingsgroup_v8.h | 63 + .../archs/arm/armlinkersettingsgroup_v8.cpp | 488 + .../archs/arm/armlinkersettingsgroup_v8.h | 71 + .../archs/avr/avrarchiversettingsgroup_v7.cpp | 94 + .../archs/avr/avrarchiversettingsgroup_v7.h | 58 + .../avr/avrassemblersettingsgroup_v7.cpp | 226 + .../archs/avr/avrassemblersettingsgroup_v7.h | 61 + .../avr/avrbuildconfigurationgroup_v7.cpp | 98 + .../archs/avr/avrbuildconfigurationgroup_v7.h | 72 + .../archs/avr/avrcompilersettingsgroup_v7.cpp | 492 + .../archs/avr/avrcompilersettingsgroup_v7.h | 64 + .../archs/avr/avrgeneralsettingsgroup_v7.cpp | 774 + .../archs/avr/avrgeneralsettingsgroup_v7.h | 63 + .../archs/avr/avrlinkersettingsgroup_v7.cpp | 387 + .../archs/avr/avrlinkersettingsgroup_v7.h | 66 + .../mcs51/mcs51archiversettingsgroup_v10.cpp | 95 + .../mcs51/mcs51archiversettingsgroup_v10.h | 59 + .../mcs51/mcs51assemblersettingsgroup_v10.cpp | 228 + .../mcs51/mcs51assemblersettingsgroup_v10.h | 62 + .../mcs51buildconfigurationgroup_v10.cpp | 98 + .../mcs51/mcs51buildconfigurationgroup_v10.h | 71 + .../mcs51/mcs51compilersettingsgroup_v10.cpp | 476 + .../mcs51/mcs51compilersettingsgroup_v10.h | 65 + .../mcs51/mcs51generalsettingsgroup_v10.cpp | 1013 + .../mcs51/mcs51generalsettingsgroup_v10.h | 66 + .../mcs51/mcs51linkersettingsgroup_v10.cpp | 335 + .../mcs51/mcs51linkersettingsgroup_v10.h | 68 + .../msp430/msp430archiversettingsgroup_v7.cpp | 94 + .../msp430/msp430archiversettingsgroup_v7.h | 59 + .../msp430assemblersettingsgroup_v7.cpp | 229 + .../msp430/msp430assemblersettingsgroup_v7.h | 62 + .../msp430buildconfigurationgroup_v7.cpp | 98 + .../msp430/msp430buildconfigurationgroup_v7.h | 72 + .../msp430/msp430compilersettingsgroup_v7.cpp | 486 + .../msp430/msp430compilersettingsgroup_v7.h | 65 + .../msp430/msp430generalsettingsgroup_v7.cpp | 482 + .../msp430/msp430generalsettingsgroup_v7.h | 64 + .../msp430/msp430linkersettingsgroup_v7.cpp | 289 + .../msp430/msp430linkersettingsgroup_v7.h | 65 + .../stm8/stm8archiversettingsgroup_v3.cpp | 94 + .../archs/stm8/stm8archiversettingsgroup_v3.h | 59 + .../stm8/stm8assemblersettingsgroup_v3.cpp | 229 + .../stm8/stm8assemblersettingsgroup_v3.h | 62 + .../stm8/stm8buildconfigurationgroup_v3.cpp | 98 + .../stm8/stm8buildconfigurationgroup_v3.h | 72 + .../stm8/stm8compilersettingsgroup_v3.cpp | 442 + .../archs/stm8/stm8compilersettingsgroup_v3.h | 64 + .../stm8/stm8generalsettingsgroup_v3.cpp | 366 + .../archs/stm8/stm8generalsettingsgroup_v3.h | 64 + .../archs/stm8/stm8linkersettingsgroup_v3.cpp | 409 + .../archs/stm8/stm8linkersettingsgroup_v3.h | 73 + src/plugins/generator/iarew/iarew.pri | 1 + src/plugins/generator/iarew/iarew.pro | 131 + src/plugins/generator/iarew/iarew.qbs | 130 + .../iarew/iarewfileversionproperty.cpp | 57 + .../iarew/iarewfileversionproperty.h | 48 + .../generator/iarew/iarewgenerator.cpp | 158 + src/plugins/generator/iarew/iarewgenerator.h | 70 + .../generator/iarew/iarewgeneratorplugin.cpp | 67 + .../iarew/iarewoptionpropertygroup.cpp | 57 + .../iarew/iarewoptionpropertygroup.h | 50 + src/plugins/generator/iarew/iarewproject.cpp | 130 + src/plugins/generator/iarew/iarewproject.h | 54 + .../generator/iarew/iarewprojectwriter.cpp | 52 + .../generator/iarew/iarewprojectwriter.h | 51 + .../iarew/iarewsettingspropertygroup.cpp | 106 + .../iarew/iarewsettingspropertygroup.h | 68 + .../iarew/iarewsourcefilepropertygroup.cpp | 54 + .../iarew/iarewsourcefilepropertygroup.h | 52 + .../iarew/iarewsourcefilespropertygroup.cpp | 56 + .../iarew/iarewsourcefilespropertygroup.h | 50 + .../iarew/iarewtoolchainpropertygroup.cpp | 43 + .../iarew/iarewtoolchainpropertygroup.h | 48 + src/plugins/generator/iarew/iarewutils.cpp | 156 + src/plugins/generator/iarew/iarewutils.h | 75 + .../generator/iarew/iarewversioninfo.h | 60 + .../generator/iarew/iarewworkspace.cpp | 63 + src/plugins/generator/iarew/iarewworkspace.h | 58 + .../generator/iarew/iarewworkspacewriter.cpp | 52 + .../generator/iarew/iarewworkspacewriter.h | 51 + src/plugins/generator/keiluv/CMakeLists.txt | 80 + .../archs/arm/armbuildtargetgroup_v5.cpp | 108 + .../keiluv/archs/arm/armbuildtargetgroup_v5.h | 70 + .../archs/arm/armcommonpropertygroup_v5.cpp | 50 + .../archs/arm/armcommonpropertygroup_v5.h | 54 + .../archs/arm/armdebugoptiongroup_v5.cpp | 50 + .../keiluv/archs/arm/armdebugoptiongroup_v5.h | 54 + .../keiluv/archs/arm/armdlloptiongroup_v5.cpp | 50 + .../keiluv/archs/arm/armdlloptiongroup_v5.h | 54 + .../archs/arm/armtargetassemblergroup_v5.cpp | 154 + .../archs/arm/armtargetassemblergroup_v5.h | 54 + .../arm/armtargetcommonoptionsgroup_v5.cpp | 208 + .../arm/armtargetcommonoptionsgroup_v5.h | 54 + .../archs/arm/armtargetcompilergroup_v5.cpp | 218 + .../archs/arm/armtargetcompilergroup_v5.h | 54 + .../keiluv/archs/arm/armtargetgroup_v5.cpp | 56 + .../keiluv/archs/arm/armtargetgroup_v5.h | 54 + .../archs/arm/armtargetlinkergroup_v5.cpp | 162 + .../archs/arm/armtargetlinkergroup_v5.h | 54 + .../archs/arm/armtargetmiscgroup_v5.cpp | 75 + .../keiluv/archs/arm/armtargetmiscgroup_v5.h | 54 + .../keiluv/archs/arm/armutilitiesgroup_v5.cpp | 50 + .../keiluv/archs/arm/armutilitiesgroup_v5.h | 54 + .../archs/mcs51/mcs51buildtargetgroup_v5.cpp | 109 + .../archs/mcs51/mcs51buildtargetgroup_v5.h | 70 + .../mcs51/mcs51commonpropertygroup_v5.cpp | 50 + .../archs/mcs51/mcs51commonpropertygroup_v5.h | 54 + .../archs/mcs51/mcs51debugoptiongroup_v5.cpp | 50 + .../archs/mcs51/mcs51debugoptiongroup_v5.h | 54 + .../archs/mcs51/mcs51dlloptiongroup_v5.cpp | 50 + .../archs/mcs51/mcs51dlloptiongroup_v5.h | 54 + .../mcs51/mcs51targetassemblergroup_v5.cpp | 143 + .../mcs51/mcs51targetassemblergroup_v5.h | 54 + .../mcs51targetcommonoptionsgroup_v5.cpp | 140 + .../mcs51/mcs51targetcommonoptionsgroup_v5.h | 54 + .../mcs51/mcs51targetcompilergroup_v5.cpp | 281 + .../archs/mcs51/mcs51targetcompilergroup_v5.h | 54 + .../archs/mcs51/mcs51targetgroup_v5.cpp | 56 + .../keiluv/archs/mcs51/mcs51targetgroup_v5.h | 54 + .../archs/mcs51/mcs51targetlinkergroup_v5.cpp | 240 + .../archs/mcs51/mcs51targetlinkergroup_v5.h | 54 + .../archs/mcs51/mcs51targetmiscgroup_v5.cpp | 104 + .../archs/mcs51/mcs51targetmiscgroup_v5.h | 54 + .../archs/mcs51/mcs51utilitiesgroup_v5.cpp | 50 + .../archs/mcs51/mcs51utilitiesgroup_v5.h | 54 + .../keiluv/archs/mcs51/mcs51utils.cpp | 84 + .../generator/keiluv/archs/mcs51/mcs51utils.h | 56 + src/plugins/generator/keiluv/keiluv.pri | 1 + src/plugins/generator/keiluv/keiluv.pro | 90 + src/plugins/generator/keiluv/keiluv.qbs | 88 + .../generator/keiluv/keiluvconstants.h | 44 + .../keiluv/keiluvfilesgroupspropertygroup.cpp | 197 + .../keiluv/keiluvfilesgroupspropertygroup.h | 52 + .../generator/keiluv/keiluvgenerator.cpp | 149 + .../generator/keiluv/keiluvgenerator.h | 71 + .../keiluv/keiluvgeneratorplugin.cpp | 67 + .../generator/keiluv/keiluvproject.cpp | 113 + src/plugins/generator/keiluv/keiluvproject.h | 56 + .../generator/keiluv/keiluvprojectwriter.cpp | 58 + .../generator/keiluv/keiluvprojectwriter.h | 51 + src/plugins/generator/keiluv/keiluvutils.cpp | 118 + src/plugins/generator/keiluv/keiluvutils.h | 64 + .../generator/keiluv/keiluvversioninfo.h | 60 + .../generator/keiluv/keiluvworkspace.cpp | 68 + .../generator/keiluv/keiluvworkspace.h | 56 + .../keiluv/keiluvworkspacewriter.cpp | 58 + .../generator/keiluv/keiluvworkspacewriter.h | 51 + .../makefilegenerator/CMakeLists.txt | 10 + .../makefilegenerator/makefilegenerator.cpp | 362 + .../makefilegenerator/makefilegenerator.h | 55 + .../makefilegenerator/makefilegenerator.pri | 1 + .../makefilegenerator/makefilegenerator.pro | 11 + .../makefilegenerator/makefilegenerator.qbs | 10 + .../makefilegeneratorplugin.cpp | 64 + .../generator/visualstudio/CMakeLists.txt | 25 + .../visualstudio/msbuildfiltersproject.cpp | 154 + .../visualstudio/msbuildfiltersproject.h | 54 + .../msbuildqbsgenerateproject.cpp | 70 + .../visualstudio/msbuildqbsgenerateproject.h | 53 + .../visualstudio/msbuildqbsproductproject.cpp | 428 + .../visualstudio/msbuildqbsproductproject.h | 74 + ...msbuildsharedsolutionpropertiesproject.cpp | 151 + .../msbuildsharedsolutionpropertiesproject.h | 53 + .../msbuildsolutionpropertiesproject.cpp | 69 + .../msbuildsolutionpropertiesproject.h | 56 + .../visualstudio/msbuildtargetproject.cpp | 136 + .../visualstudio/msbuildtargetproject.h | 73 + .../generator/visualstudio/msbuildutils.h | 113 + .../generator/visualstudio/visualstudio.pri | 1 + .../generator/visualstudio/visualstudio.pro | 32 + .../generator/visualstudio/visualstudio.qbs | 33 + .../visualstudio/visualstudiogenerator.cpp | 365 + .../visualstudio/visualstudiogenerator.h | 80 + .../visualstudiogeneratorplugin.cpp | 67 + .../visualstudio/visualstudioguidpool.cpp | 93 + .../visualstudio/visualstudioguidpool.h | 62 + src/plugins/plugins.pri | 21 + src/plugins/plugins.pro | 2 + src/plugins/plugins.qbs | 12 + src/plugins/qbs_plugin_common.pri | 9 + src/plugins/qbsplugin.qbs | 48 + src/plugins/scanner/CMakeLists.txt | 2 + src/plugins/scanner/cpp/CMakeLists.txt | 16 + .../cpp/CPlusPlusForwardDeclarations.h | 153 + src/plugins/scanner/cpp/Lexer.cpp | 670 + src/plugins/scanner/cpp/Lexer.h | 161 + src/plugins/scanner/cpp/Token.cpp | 148 + src/plugins/scanner/cpp/Token.h | 368 + src/plugins/scanner/cpp/cpp.pri | 1 + src/plugins/scanner/cpp/cpp.pro | 10 + src/plugins/scanner/cpp/cpp.qbs | 17 + src/plugins/scanner/cpp/cpp_global.h | 49 + src/plugins/scanner/cpp/cppscanner.cpp | 335 + src/plugins/scanner/qt/CMakeLists.txt | 4 + src/plugins/scanner/qt/qt.pri | 1 + src/plugins/scanner/qt/qt.pro | 8 + src/plugins/scanner/qt/qt.qbs | 10 + src/plugins/scanner/qt/qtscanner.cpp | 194 + src/plugins/scanner/scanner.h | 106 + src/plugins/scanner/scanner.pro | 3 + src/plugins/use_plugin.pri | 10 + src/shared/CMakeLists.txt | 2 + src/shared/bundledqt/bundledqt.qbs | 188 + src/shared/bundledqt/qt.conf | 2 + src/shared/json/CMakeLists.txt | 4 + src/shared/json/README.md | 2 + src/shared/json/json.cpp | 4979 ++ src/shared/json/json.h | 589 + src/shared/json/json.pri | 3 + src/shared/json/json.qbs | 7 + src/shared/qtscript/.gitattributes | 3 + src/shared/qtscript/.gitignore | 265 + src/shared/qtscript/.qmake.conf | 6 + src/shared/qtscript/.tag | 1 + src/shared/qtscript/LICENSE.FDL | 450 + src/shared/qtscript/LICENSE.GPL2 | 339 + src/shared/qtscript/LICENSE.GPL3 | 674 + src/shared/qtscript/LICENSE.GPL3-EXCEPT | 704 + src/shared/qtscript/LICENSE.LGPL3 | 165 + src/shared/qtscript/configure.json | 5 + src/shared/qtscript/dependencies.yaml | 7 + src/shared/qtscript/dist/changes-5.0.1 | 48 + src/shared/qtscript/dist/changes-5.0.2 | 25 + src/shared/qtscript/dist/changes-5.1.0 | 22 + src/shared/qtscript/dist/changes-5.1.1 | 25 + src/shared/qtscript/dist/changes-5.10.1 | 26 + src/shared/qtscript/dist/changes-5.11.0 | 22 + src/shared/qtscript/dist/changes-5.11.1 | 29 + src/shared/qtscript/dist/changes-5.11.2 | 24 + src/shared/qtscript/dist/changes-5.11.3 | 20 + src/shared/qtscript/dist/changes-5.12.0 | 18 + src/shared/qtscript/dist/changes-5.12.1 | 20 + src/shared/qtscript/dist/changes-5.12.2 | 20 + src/shared/qtscript/dist/changes-5.12.3 | 20 + src/shared/qtscript/dist/changes-5.12.4 | 20 + src/shared/qtscript/dist/changes-5.12.5 | 20 + src/shared/qtscript/dist/changes-5.13.0 | 18 + src/shared/qtscript/dist/changes-5.13.1 | 20 + src/shared/qtscript/dist/changes-5.13.2 | 20 + src/shared/qtscript/dist/changes-5.14.0 | 18 + src/shared/qtscript/dist/changes-5.14.1 | 20 + src/shared/qtscript/dist/changes-5.9.4 | 25 + src/shared/qtscript/dist/changes-5.9.5 | 24 + src/shared/qtscript/dist/changes-5.9.6 | 24 + src/shared/qtscript/examples/examples.pro | 2 + src/shared/qtscript/examples/script/README | 9 + .../examples/script/calculator/calculator.js | 281 + .../examples/script/calculator/calculator.pro | 11 + .../examples/script/calculator/calculator.qrc | 6 + .../examples/script/calculator/calculator.ui | 416 + .../examples/script/calculator/main.cpp | 110 + .../examples/script/context2d/context2d.cpp | 830 + .../examples/script/context2d/context2d.h | 270 + .../examples/script/context2d/context2d.pro | 23 + .../examples/script/context2d/context2d.qrc | 5 + .../images/context2d-example-smileysmile.png | Bin 0 -> 3457 bytes .../doc/images/context2d-example.png | Bin 0 -> 14160 bytes .../script/context2d/doc/src/context2d.qdoc | 339 + .../examples/script/context2d/domimage.cpp | 166 + .../examples/script/context2d/domimage.h | 96 + .../examples/script/context2d/environment.cpp | 587 + .../examples/script/context2d/environment.h | 156 + .../examples/script/context2d/main.cpp | 73 + .../script/context2d/qcontext2dcanvas.cpp | 152 + .../script/context2d/qcontext2dcanvas.h | 107 + .../script/context2d/scripts/alpha.js | 21 + .../examples/script/context2d/scripts/arc.js | 30 + .../script/context2d/scripts/bezier.js | 26 + .../script/context2d/scripts/clock.js | 99 + .../script/context2d/scripts/fill1.js | 8 + .../examples/script/context2d/scripts/grad.js | 20 + .../script/context2d/scripts/linecap.js | 24 + .../script/context2d/scripts/linestye.js | 10 + .../script/context2d/scripts/moveto.js | 20 + .../script/context2d/scripts/moveto2.js | 24 + .../script/context2d/scripts/pacman.js | 83 + .../script/context2d/scripts/plasma.js | 58 + .../examples/script/context2d/scripts/pong.js | 235 + .../examples/script/context2d/scripts/quad.js | 21 + .../examples/script/context2d/scripts/rgba.js | 19 + .../script/context2d/scripts/rotate.js | 16 + .../script/context2d/scripts/scale.js | 67 + .../script/context2d/scripts/stroke1.js | 10 + .../script/context2d/scripts/translate.js | 29 + .../examples/script/context2d/window.cpp | 190 + .../examples/script/context2d/window.h | 90 + .../script/customclass/bytearrayclass.cpp | 319 + .../script/customclass/bytearrayclass.h | 106 + .../script/customclass/bytearrayclass.pri | 6 + .../script/customclass/bytearrayprototype.cpp | 145 + .../script/customclass/bytearrayprototype.h | 89 + .../script/customclass/customclass.pro | 12 + .../examples/script/customclass/main.cpp | 85 + .../examples/script/defaultprototypes/code.js | 18 + .../defaultprototypes/defaultprototypes.pro | 9 + .../defaultprototypes/defaultprototypes.qrc | 5 + .../doc/images/defaultprototypes-example.png | Bin 0 -> 5840 bytes .../doc/src/defaultprototypes.qdoc | 124 + .../script/defaultprototypes/main.cpp | 95 + .../script/defaultprototypes/prototypes.cpp | 126 + .../script/defaultprototypes/prototypes.h | 87 + .../helloscript/doc/src/helloscript.qdoc | 128 + .../script/helloscript/helloscript.js | 5 + .../script/helloscript/helloscript.pro | 8 + .../script/helloscript/helloscript.qrc | 5 + .../examples/script/helloscript/main.cpp | 109 + .../qtscript/examples/script/marshal/main.cpp | 115 + .../examples/script/marshal/marshal.pro | 8 + .../qtscript/examples/script/qscript/main.cpp | 222 + .../examples/script/qscript/qscript.pro | 13 + .../qtscript/examples/script/qsdbg/example.js | 17 + .../qtscript/examples/script/qsdbg/main.cpp | 86 + .../qtscript/examples/script/qsdbg/qsdbg.pri | 9 + .../qtscript/examples/script/qsdbg/qsdbg.pro | 14 + .../script/qsdbg/scriptbreakpointmanager.cpp | 168 + .../script/qsdbg/scriptbreakpointmanager.h | 131 + .../examples/script/qsdbg/scriptdebugger.cpp | 747 + .../examples/script/qsdbg/scriptdebugger.h | 94 + .../examples/script/qstetrix/main.cpp | 153 + .../examples/script/qstetrix/qstetrix.pro | 14 + .../examples/script/qstetrix/tetrix.qrc | 8 + .../examples/script/qstetrix/tetrixboard.cpp | 153 + .../examples/script/qstetrix/tetrixboard.h | 109 + .../examples/script/qstetrix/tetrixboard.js | 261 + .../examples/script/qstetrix/tetrixpiece.js | 131 + .../examples/script/qstetrix/tetrixwindow.js | 16 + .../examples/script/qstetrix/tetrixwindow.ui | 175 + .../qtscript/examples/script/script.pro | 28 + src/shared/qtscript/qtscript.pro | 3 + .../JavaScriptCore/API/APICast.h | 154 + .../JavaScriptCore/API/APIShims.h | 99 + .../JavaScriptCore/API/JSBase.cpp | 112 + .../JavaScriptCore/API/JSBase.h | 132 + .../JavaScriptCore/API/JSBasePrivate.h | 52 + .../API/JSCallbackConstructor.cpp | 87 + .../API/JSCallbackConstructor.h | 60 + .../JavaScriptCore/API/JSCallbackFunction.cpp | 80 + .../JavaScriptCore/API/JSCallbackFunction.h | 58 + .../JavaScriptCore/API/JSCallbackObject.cpp | 41 + .../JavaScriptCore/API/JSCallbackObject.h | 118 + .../API/JSCallbackObjectFunctions.h | 603 + .../JavaScriptCore/API/JSClassRef.cpp | 241 + .../JavaScriptCore/API/JSClassRef.h | 123 + .../JavaScriptCore/API/JSContextRef.cpp | 158 + .../JavaScriptCore/API/JSContextRef.h | 132 + .../JavaScriptCore/API/JSContextRefPrivate.h | 53 + .../JavaScriptCore/API/JSObjectRef.cpp | 496 + .../JavaScriptCore/API/JSObjectRef.h | 694 + .../JavaScriptCore/API/JSProfilerPrivate.cpp | 46 + .../JavaScriptCore/API/JSProfilerPrivate.h | 63 + .../JavaScriptCore/API/JSRetainPtr.h | 173 + .../JavaScriptCore/API/JSStringRef.cpp | 119 + .../JavaScriptCore/API/JSStringRef.h | 145 + .../JavaScriptCore/API/JSStringRefBSTR.cpp | 42 + .../JavaScriptCore/API/JSStringRefBSTR.h | 62 + .../JavaScriptCore/API/JSStringRefCF.cpp | 57 + .../JavaScriptCore/API/JSStringRefCF.h | 60 + .../JavaScriptCore/API/JSValueRef.cpp | 301 + .../JavaScriptCore/API/JSValueRef.h | 278 + .../JavaScriptCore/API/JavaScript.h | 36 + .../JavaScriptCore/API/JavaScriptCore.h | 32 + .../JavaScriptCore/API/OpaqueJSString.cpp | 55 + .../JavaScriptCore/API/OpaqueJSString.h | 81 + .../JavaScriptCore/API/WebKitAvailability.h | 764 + .../javascriptcore/JavaScriptCore/AUTHORS | 2 + .../javascriptcore/JavaScriptCore/COPYING.LIB | 488 + .../javascriptcore/JavaScriptCore/ChangeLog | 19026 ++++++++ .../JavaScriptCore/ChangeLog-2002-12-03 | 2271 + .../JavaScriptCore/ChangeLog-2003-10-25 | 1483 + .../JavaScriptCore/ChangeLog-2007-10-14 | 26221 ++++++++++ .../JavaScriptCore/ChangeLog-2008-08-10 | 31482 ++++++++++++ .../JavaScriptCore/ChangeLog-2009-06-16 | 39978 ++++++++++++++++ .../JavaScriptCore/DerivedSources.make | 76 + .../JavaScriptCore/APICast.h | 1 + .../ForwardingHeaders/JavaScriptCore/JSBase.h | 1 + .../JavaScriptCore/JSContextRef.h | 1 + .../JavaScriptCore/JSObjectRef.h | 1 + .../JavaScriptCore/JSRetainPtr.h | 1 + .../JavaScriptCore/JSStringRef.h | 1 + .../JavaScriptCore/JSStringRefCF.h | 1 + .../JavaScriptCore/JSValueRef.h | 1 + .../JavaScriptCore/JavaScript.h | 1 + .../JavaScriptCore/JavaScriptCore.h | 1 + .../JavaScriptCore/OpaqueJSString.h | 1 + .../JavaScriptCore/WebKitAvailability.h | 1 + .../javascriptcore/JavaScriptCore/Info.plist | 24 + .../JavaScriptCore/JavaScriptCore.gypi | 458 + .../JavaScriptCore/JavaScriptCore.order | 1963 + .../JavaScriptCore/JavaScriptCore.pri | 231 + .../JavaScriptCore/JavaScriptCorePrefix.h | 35 + .../javascriptcore/JavaScriptCore/THANKS | 8 + .../JavaScriptCore/assembler/ARMAssembler.cpp | 377 + .../JavaScriptCore/assembler/ARMAssembler.h | 836 + .../JavaScriptCore/assembler/ARMv7Assembler.h | 1837 + .../assembler/AbstractMacroAssembler.h | 535 + .../assembler/AssemblerBuffer.h | 173 + .../AssemblerBufferWithConstantPool.h | 318 + .../JavaScriptCore/assembler/CodeLocation.h | 186 + .../JavaScriptCore/assembler/LinkBuffer.h | 195 + .../JavaScriptCore/assembler/MacroAssembler.h | 338 + .../assembler/MacroAssemblerARM.cpp | 98 + .../assembler/MacroAssemblerARM.h | 940 + .../assembler/MacroAssemblerARMv7.h | 1132 + .../assembler/MacroAssemblerCodeRef.h | 194 + .../assembler/MacroAssemblerX86.h | 204 + .../assembler/MacroAssemblerX86Common.h | 1023 + .../assembler/MacroAssemblerX86_64.h | 453 + .../JavaScriptCore/assembler/RepatchBuffer.h | 136 + .../JavaScriptCore/assembler/X86Assembler.h | 2053 + .../JavaScriptCore/bytecode/CodeBlock.cpp | 1678 + .../JavaScriptCore/bytecode/CodeBlock.h | 647 + .../JavaScriptCore/bytecode/EvalCodeCache.h | 77 + .../JavaScriptCore/bytecode/Instruction.h | 167 + .../JavaScriptCore/bytecode/JumpTable.cpp | 45 + .../JavaScriptCore/bytecode/JumpTable.h | 103 + .../JavaScriptCore/bytecode/Opcode.cpp | 186 + .../JavaScriptCore/bytecode/Opcode.h | 244 + .../JavaScriptCore/bytecode/SamplingTool.cpp | 406 + .../JavaScriptCore/bytecode/SamplingTool.h | 418 + .../bytecode/StructureStubInfo.cpp | 80 + .../bytecode/StructureStubInfo.h | 185 + .../bytecompiler/BytecodeGenerator.cpp | 2028 + .../bytecompiler/BytecodeGenerator.h | 531 + .../JavaScriptCore/bytecompiler/Label.h | 90 + .../JavaScriptCore/bytecompiler/LabelScope.h | 79 + .../bytecompiler/NodesCodegen.cpp | 2012 + .../JavaScriptCore/bytecompiler/RegisterID.h | 121 + .../javascriptcore/JavaScriptCore/config.h | 89 + .../JavaScriptCore/create_hash_table | 274 + .../JavaScriptCore/debugger/Debugger.cpp | 112 + .../JavaScriptCore/debugger/Debugger.h | 112 + .../debugger/DebuggerActivation.cpp | 104 + .../debugger/DebuggerActivation.h | 66 + .../debugger/DebuggerCallFrame.cpp | 90 + .../debugger/DebuggerCallFrame.h | 70 + .../JavaScriptCore/docs/make-bytecode-docs.pl | 42 + .../generated/ArrayPrototype.lut.h | 34 + .../generated/DatePrototype.lut.h | 59 + .../generated/GeneratedJITStubs_RVCT.h | 1199 + .../JavaScriptCore/generated/Grammar.cpp | 5604 +++ .../JavaScriptCore/generated/Grammar.h | 173 + .../JavaScriptCore/generated/JSONObject.lut.h | 15 + .../JavaScriptCore/generated/Lexer.lut.h | 49 + .../JavaScriptCore/generated/MathObject.lut.h | 31 + .../generated/NumberConstructor.lut.h | 18 + .../generated/RegExpConstructor.lut.h | 34 + .../generated/RegExpObject.lut.h | 18 + .../generated/StringPrototype.lut.h | 48 + .../JavaScriptCore/generated/chartables.c | 96 + .../javascriptcore/JavaScriptCore/headers.pri | 9 + .../JavaScriptCore/interpreter/CachedCall.h | 78 + .../JavaScriptCore/interpreter/CallFrame.cpp | 52 + .../JavaScriptCore/interpreter/CallFrame.h | 155 + .../interpreter/CallFrameClosure.h | 60 + .../interpreter/Interpreter.cpp | 4090 ++ .../JavaScriptCore/interpreter/Interpreter.h | 169 + .../JavaScriptCore/interpreter/Register.h | 219 + .../interpreter/RegisterFile.cpp | 61 + .../JavaScriptCore/interpreter/RegisterFile.h | 292 + .../jit/ExecutableAllocator.cpp | 59 + .../JavaScriptCore/jit/ExecutableAllocator.h | 289 + .../jit/ExecutableAllocatorFixedVMPool.cpp | 462 + .../jit/ExecutableAllocatorPosix.cpp | 60 + .../jit/ExecutableAllocatorSymbian.cpp | 75 + .../jit/ExecutableAllocatorWin.cpp | 63 + .../javascriptcore/JavaScriptCore/jit/JIT.cpp | 616 + .../javascriptcore/JavaScriptCore/jit/JIT.h | 1001 + .../JavaScriptCore/jit/JITArithmetic.cpp | 2756 ++ .../JavaScriptCore/jit/JITCall.cpp | 732 + .../JavaScriptCore/jit/JITCode.h | 118 + .../JavaScriptCore/jit/JITInlineMethods.h | 867 + .../JavaScriptCore/jit/JITOpcodes.cpp | 2998 ++ .../JavaScriptCore/jit/JITPropertyAccess.cpp | 1901 + .../JavaScriptCore/jit/JITStubCall.h | 235 + .../JavaScriptCore/jit/JITStubs.cpp | 3227 ++ .../JavaScriptCore/jit/JITStubs.h | 384 + .../javascriptcore/JavaScriptCore/jsc.cpp | 560 + .../JavaScriptCore/make-generated-sources.sh | 11 + .../JavaScriptCore/os-win32/WinMain.cpp | 81 + .../JavaScriptCore/os-win32/stdbool.h | 45 + .../JavaScriptCore/parser/Grammar.y | 2099 + .../JavaScriptCore/parser/Keywords.table | 72 + .../JavaScriptCore/parser/Lexer.cpp | 1048 + .../JavaScriptCore/parser/Lexer.h | 147 + .../JavaScriptCore/parser/NodeConstructors.h | 898 + .../JavaScriptCore/parser/NodeInfo.h | 63 + .../JavaScriptCore/parser/Nodes.cpp | 195 + .../JavaScriptCore/parser/Nodes.h | 1599 + .../JavaScriptCore/parser/Parser.cpp | 79 + .../JavaScriptCore/parser/Parser.h | 103 + .../JavaScriptCore/parser/ParserArena.cpp | 135 + .../JavaScriptCore/parser/ParserArena.h | 130 + .../JavaScriptCore/parser/ResultType.h | 182 + .../JavaScriptCore/parser/SourceCode.h | 100 + .../JavaScriptCore/parser/SourceProvider.h | 89 + .../JavaScriptCore/pcre/AUTHORS | 12 + .../JavaScriptCore/pcre/COPYING | 35 + .../JavaScriptCore/pcre/dftables | 273 + .../javascriptcore/JavaScriptCore/pcre/pcre.h | 68 + .../JavaScriptCore/pcre/pcre.pri | 11 + .../JavaScriptCore/pcre/pcre_compile.cpp | 2704 ++ .../JavaScriptCore/pcre/pcre_exec.cpp | 2177 + .../JavaScriptCore/pcre/pcre_internal.h | 455 + .../JavaScriptCore/pcre/pcre_tables.cpp | 72 + .../pcre/pcre_ucp_searchfuncs.cpp | 99 + .../JavaScriptCore/pcre/pcre_xclass.cpp | 115 + .../JavaScriptCore/pcre/ucpinternal.h | 126 + .../JavaScriptCore/pcre/ucptable.cpp | 2968 ++ .../JavaScriptCore/profiler/CallIdentifier.h | 98 + .../JavaScriptCore/profiler/Profile.cpp | 136 + .../JavaScriptCore/profiler/Profile.h | 72 + .../profiler/ProfileGenerator.cpp | 170 + .../profiler/ProfileGenerator.h | 77 + .../JavaScriptCore/profiler/ProfileNode.cpp | 348 + .../JavaScriptCore/profiler/ProfileNode.h | 168 + .../JavaScriptCore/profiler/Profiler.cpp | 161 + .../JavaScriptCore/profiler/Profiler.h | 75 + .../JavaScriptCore/profiler/ProfilerServer.h | 35 + .../JavaScriptCore/profiler/ProfilerServer.mm | 115 + .../JavaScriptCore/runtime/ArgList.cpp | 79 + .../JavaScriptCore/runtime/ArgList.h | 238 + .../JavaScriptCore/runtime/Arguments.cpp | 304 + .../JavaScriptCore/runtime/Arguments.h | 260 + .../runtime/ArrayConstructor.cpp | 97 + .../JavaScriptCore/runtime/ArrayConstructor.h | 40 + .../JavaScriptCore/runtime/ArrayPrototype.cpp | 1079 + .../JavaScriptCore/runtime/ArrayPrototype.h | 42 + .../runtime/BatchedTransitionOptimizer.h | 55 + .../runtime/BooleanConstructor.cpp | 78 + .../runtime/BooleanConstructor.h | 44 + .../JavaScriptCore/runtime/BooleanObject.cpp | 35 + .../JavaScriptCore/runtime/BooleanObject.h | 51 + .../runtime/BooleanPrototype.cpp | 83 + .../JavaScriptCore/runtime/BooleanPrototype.h | 35 + .../JavaScriptCore/runtime/CallData.cpp | 65 + .../JavaScriptCore/runtime/CallData.h | 91 + .../JavaScriptCore/runtime/ClassInfo.h | 62 + .../JavaScriptCore/runtime/Collector.cpp | 1319 + .../JavaScriptCore/runtime/Collector.h | 297 + .../runtime/CollectorHeapIterator.h | 138 + .../runtime/CommonIdentifiers.cpp | 39 + .../runtime/CommonIdentifiers.h | 105 + .../JavaScriptCore/runtime/Completion.cpp | 72 + .../JavaScriptCore/runtime/Completion.h | 63 + .../JavaScriptCore/runtime/ConstructData.cpp | 64 + .../JavaScriptCore/runtime/ConstructData.h | 96 + .../runtime/DateConstructor.cpp | 180 + .../JavaScriptCore/runtime/DateConstructor.h | 43 + .../JavaScriptCore/runtime/DateConversion.cpp | 116 + .../JavaScriptCore/runtime/DateConversion.h | 63 + .../JavaScriptCore/runtime/DateInstance.cpp | 80 + .../JavaScriptCore/runtime/DateInstance.h | 81 + .../runtime/DateInstanceCache.h | 94 + .../JavaScriptCore/runtime/DatePrototype.cpp | 1026 + .../JavaScriptCore/runtime/DatePrototype.h | 52 + .../JavaScriptCore/runtime/Error.cpp | 134 + .../JavaScriptCore/runtime/Error.h | 74 + .../runtime/ErrorConstructor.cpp | 73 + .../JavaScriptCore/runtime/ErrorConstructor.h | 44 + .../JavaScriptCore/runtime/ErrorInstance.cpp | 33 + .../JavaScriptCore/runtime/ErrorInstance.h | 38 + .../JavaScriptCore/runtime/ErrorPrototype.cpp | 66 + .../JavaScriptCore/runtime/ErrorPrototype.h | 37 + .../runtime/ExceptionHelpers.cpp | 191 + .../JavaScriptCore/runtime/ExceptionHelpers.h | 57 + .../JavaScriptCore/runtime/Executable.cpp | 280 + .../JavaScriptCore/runtime/Executable.h | 361 + .../runtime/FunctionConstructor.cpp | 113 + .../runtime/FunctionConstructor.h | 44 + .../runtime/FunctionPrototype.cpp | 149 + .../runtime/FunctionPrototype.h | 46 + .../JavaScriptCore/runtime/GetterSetter.cpp | 46 + .../JavaScriptCore/runtime/GetterSetter.h | 73 + .../runtime/GlobalEvalFunction.cpp | 48 + .../runtime/GlobalEvalFunction.h | 54 + .../JavaScriptCore/runtime/Identifier.cpp | 292 + .../JavaScriptCore/runtime/Identifier.h | 208 + .../runtime/InitializeThreading.cpp | 72 + .../runtime/InitializeThreading.h | 40 + .../runtime/InternalFunction.cpp | 71 + .../JavaScriptCore/runtime/InternalFunction.h | 68 + .../runtime/JSAPIValueWrapper.cpp | 31 + .../runtime/JSAPIValueWrapper.h | 64 + .../JavaScriptCore/runtime/JSActivation.cpp | 172 + .../JavaScriptCore/runtime/JSActivation.h | 108 + .../JavaScriptCore/runtime/JSArray.cpp | 1074 + .../JavaScriptCore/runtime/JSArray.h | 226 + .../JavaScriptCore/runtime/JSByteArray.cpp | 116 + .../JavaScriptCore/runtime/JSByteArray.h | 123 + .../JavaScriptCore/runtime/JSCell.cpp | 227 + .../JavaScriptCore/runtime/JSCell.h | 363 + .../JavaScriptCore/runtime/JSFunction.cpp | 269 + .../JavaScriptCore/runtime/JSFunction.h | 135 + .../JavaScriptCore/runtime/JSGlobalData.cpp | 281 + .../JavaScriptCore/runtime/JSGlobalData.h | 208 + .../JavaScriptCore/runtime/JSGlobalObject.cpp | 478 + .../JavaScriptCore/runtime/JSGlobalObject.h | 469 + .../runtime/JSGlobalObjectFunctions.cpp | 441 + .../runtime/JSGlobalObjectFunctions.h | 60 + .../JavaScriptCore/runtime/JSImmediate.cpp | 26 + .../JavaScriptCore/runtime/JSImmediate.h | 729 + .../JavaScriptCore/runtime/JSLock.cpp | 254 + .../JavaScriptCore/runtime/JSLock.h | 104 + .../JavaScriptCore/runtime/JSNotAnObject.cpp | 129 + .../JavaScriptCore/runtime/JSNotAnObject.h | 101 + .../JavaScriptCore/runtime/JSNumberCell.cpp | 113 + .../JavaScriptCore/runtime/JSNumberCell.h | 359 + .../JavaScriptCore/runtime/JSONObject.cpp | 878 + .../JavaScriptCore/runtime/JSONObject.h | 62 + .../JavaScriptCore/runtime/JSObject.cpp | 699 + .../JavaScriptCore/runtime/JSObject.h | 703 + .../runtime/JSPropertyNameIterator.cpp | 90 + .../runtime/JSPropertyNameIterator.h | 105 + .../runtime/JSStaticScopeObject.cpp | 77 + .../runtime/JSStaticScopeObject.h | 70 + .../JavaScriptCore/runtime/JSString.cpp | 251 + .../JavaScriptCore/runtime/JSString.h | 570 + .../JavaScriptCore/runtime/JSType.h | 44 + .../JavaScriptCore/runtime/JSTypeInfo.h | 78 + .../JavaScriptCore/runtime/JSValue.cpp | 184 + .../JavaScriptCore/runtime/JSValue.h | 858 + .../runtime/JSVariableObject.cpp | 71 + .../JavaScriptCore/runtime/JSVariableObject.h | 169 + .../runtime/JSWrapperObject.cpp | 36 + .../JavaScriptCore/runtime/JSWrapperObject.h | 67 + .../JavaScriptCore/runtime/JSZombie.cpp | 48 + .../JavaScriptCore/runtime/JSZombie.h | 78 + .../JavaScriptCore/runtime/LiteralParser.cpp | 455 + .../JavaScriptCore/runtime/LiteralParser.h | 110 + .../JavaScriptCore/runtime/Lookup.cpp | 82 + .../JavaScriptCore/runtime/Lookup.h | 323 + .../JavaScriptCore/runtime/MarkStack.cpp | 40 + .../JavaScriptCore/runtime/MarkStack.h | 187 + .../JavaScriptCore/runtime/MarkStackNone.cpp | 49 + .../JavaScriptCore/runtime/MarkStackPosix.cpp | 52 + .../runtime/MarkStackSymbian.cpp | 48 + .../JavaScriptCore/runtime/MarkStackWin.cpp | 55 + .../JavaScriptCore/runtime/MathObject.cpp | 240 + .../JavaScriptCore/runtime/MathObject.h | 49 + .../runtime/NativeErrorConstructor.cpp | 73 + .../runtime/NativeErrorConstructor.h | 51 + .../runtime/NativeErrorPrototype.cpp | 43 + .../runtime/NativeErrorPrototype.h | 44 + .../runtime/NativeFunctionWrapper.h | 39 + .../runtime/NumberConstructor.cpp | 128 + .../runtime/NumberConstructor.h | 59 + .../JavaScriptCore/runtime/NumberObject.cpp | 51 + .../JavaScriptCore/runtime/NumberObject.h | 56 + .../runtime/NumberPrototype.cpp | 453 + .../JavaScriptCore/runtime/NumberPrototype.h | 35 + .../JavaScriptCore/runtime/NumericStrings.h | 74 + .../runtime/ObjectConstructor.cpp | 317 + .../runtime/ObjectConstructor.h | 41 + .../runtime/ObjectPrototype.cpp | 154 + .../JavaScriptCore/runtime/ObjectPrototype.h | 43 + .../JavaScriptCore/runtime/Operations.cpp | 118 + .../JavaScriptCore/runtime/Operations.h | 420 + .../runtime/PropertyDescriptor.cpp | 195 + .../runtime/PropertyDescriptor.h | 80 + .../runtime/PropertyMapHashTable.h | 91 + .../runtime/PropertyNameArray.cpp | 53 + .../runtime/PropertyNameArray.h | 99 + .../JavaScriptCore/runtime/PropertySlot.cpp | 44 + .../JavaScriptCore/runtime/PropertySlot.h | 210 + .../JavaScriptCore/runtime/Protect.h | 215 + .../runtime/PrototypeFunction.cpp | 57 + .../runtime/PrototypeFunction.h | 45 + .../JavaScriptCore/runtime/PutPropertySlot.h | 77 + .../JavaScriptCore/runtime/RegExp.cpp | 282 + .../JavaScriptCore/runtime/RegExp.h | 87 + .../runtime/RegExpConstructor.cpp | 354 + .../runtime/RegExpConstructor.h | 133 + .../runtime/RegExpMatchesArray.h | 94 + .../JavaScriptCore/runtime/RegExpObject.cpp | 173 + .../JavaScriptCore/runtime/RegExpObject.h | 87 + .../runtime/RegExpPrototype.cpp | 122 + .../JavaScriptCore/runtime/RegExpPrototype.h | 38 + .../JavaScriptCore/runtime/ScopeChain.cpp | 68 + .../JavaScriptCore/runtime/ScopeChain.h | 242 + .../JavaScriptCore/runtime/ScopeChainMark.h | 36 + .../JavaScriptCore/runtime/SmallStrings.cpp | 114 + .../JavaScriptCore/runtime/SmallStrings.h | 74 + .../JavaScriptCore/runtime/StringBuilder.h | 81 + .../runtime/StringConstructor.cpp | 91 + .../runtime/StringConstructor.h | 40 + .../JavaScriptCore/runtime/StringObject.cpp | 99 + .../JavaScriptCore/runtime/StringObject.h | 69 + .../StringObjectThatMasqueradesAsUndefined.h | 57 + .../runtime/StringPrototype.cpp | 979 + .../JavaScriptCore/runtime/StringPrototype.h | 43 + .../JavaScriptCore/runtime/Structure.cpp | 1201 + .../JavaScriptCore/runtime/Structure.h | 326 + .../JavaScriptCore/runtime/StructureChain.cpp | 56 + .../JavaScriptCore/runtime/StructureChain.h | 57 + .../runtime/StructureTransitionTable.h | 214 + .../JavaScriptCore/runtime/SymbolTable.h | 130 + .../JavaScriptCore/runtime/TimeoutChecker.cpp | 158 + .../JavaScriptCore/runtime/TimeoutChecker.h | 77 + .../JavaScriptCore/runtime/Tracing.h | 50 + .../JavaScriptCore/runtime/UString.cpp | 908 + .../JavaScriptCore/runtime/UString.h | 609 + .../JavaScriptCore/runtime/UStringImpl.cpp | 84 + .../JavaScriptCore/runtime/UStringImpl.h | 278 + .../JavaScriptCore/runtime/WeakGCMap.h | 122 + .../JavaScriptCore/runtime/WeakGCPtr.h | 128 + .../JavaScriptCore/runtime/WeakRandom.h | 86 + .../JavaScriptCore/wrec/CharacterClass.cpp | 140 + .../JavaScriptCore/wrec/CharacterClass.h | 68 + .../wrec/CharacterClassConstructor.cpp | 257 + .../wrec/CharacterClassConstructor.h | 99 + .../JavaScriptCore/wrec/Escapes.h | 150 + .../JavaScriptCore/wrec/Quantifier.h | 66 + .../JavaScriptCore/wrec/WREC.cpp | 86 + .../javascriptcore/JavaScriptCore/wrec/WREC.h | 54 + .../JavaScriptCore/wrec/WRECFunctors.cpp | 80 + .../JavaScriptCore/wrec/WRECFunctors.h | 109 + .../JavaScriptCore/wrec/WRECGenerator.cpp | 653 + .../JavaScriptCore/wrec/WRECGenerator.h | 128 + .../JavaScriptCore/wrec/WRECParser.cpp | 643 + .../JavaScriptCore/wrec/WRECParser.h | 214 + .../javascriptcore/JavaScriptCore/wscript | 103 + .../JavaScriptCore/wtf/ASCIICType.h | 166 + .../JavaScriptCore/wtf/AVLTree.h | 959 + .../JavaScriptCore/wtf/AlwaysInline.h | 67 + .../JavaScriptCore/wtf/Assertions.cpp | 211 + .../JavaScriptCore/wtf/Assertions.h | 306 + .../JavaScriptCore/wtf/ByteArray.cpp | 38 + .../JavaScriptCore/wtf/ByteArray.h | 93 + .../wtf/CONTRIBUTORS.pthreads-win32 | 137 + .../wtf/CrossThreadRefCounted.h | 171 + .../JavaScriptCore/wtf/CurrentTime.cpp | 293 + .../JavaScriptCore/wtf/CurrentTime.h | 66 + .../JavaScriptCore/wtf/DateMath.cpp | 986 + .../JavaScriptCore/wtf/DateMath.h | 229 + .../javascriptcore/JavaScriptCore/wtf/Deque.h | 669 + .../JavaScriptCore/wtf/DisallowCType.h | 74 + .../JavaScriptCore/wtf/FastAllocBase.h | 413 + .../JavaScriptCore/wtf/FastMalloc.cpp | 4454 ++ .../JavaScriptCore/wtf/FastMalloc.h | 241 + .../JavaScriptCore/wtf/Forward.h | 44 + .../JavaScriptCore/wtf/GetPtr.h | 33 + .../JavaScriptCore/wtf/HashCountedSet.h | 225 + .../JavaScriptCore/wtf/HashFunctions.h | 183 + .../JavaScriptCore/wtf/HashIterators.h | 216 + .../JavaScriptCore/wtf/HashMap.h | 403 + .../JavaScriptCore/wtf/HashSet.h | 296 + .../JavaScriptCore/wtf/HashTable.cpp | 69 + .../JavaScriptCore/wtf/HashTable.h | 1159 + .../JavaScriptCore/wtf/HashTraits.h | 115 + .../JavaScriptCore/wtf/ListHashSet.h | 616 + .../JavaScriptCore/wtf/ListRefPtr.h | 70 + .../JavaScriptCore/wtf/Locker.h | 47 + .../JavaScriptCore/wtf/MainThread.cpp | 155 + .../JavaScriptCore/wtf/MainThread.h | 63 + .../JavaScriptCore/wtf/MallocZoneSupport.h | 65 + .../JavaScriptCore/wtf/MathExtras.h | 229 + .../JavaScriptCore/wtf/MessageQueue.h | 220 + .../JavaScriptCore/wtf/Noncopyable.h | 52 + .../JavaScriptCore/wtf/NotFound.h | 37 + .../JavaScriptCore/wtf/OwnArrayPtr.h | 75 + .../JavaScriptCore/wtf/OwnFastMallocPtr.h | 52 + .../JavaScriptCore/wtf/OwnPtr.h | 142 + .../JavaScriptCore/wtf/OwnPtrCommon.h | 61 + .../JavaScriptCore/wtf/OwnPtrWin.cpp | 76 + .../JavaScriptCore/wtf/PassOwnPtr.h | 177 + .../JavaScriptCore/wtf/PassRefPtr.h | 262 + .../JavaScriptCore/wtf/Platform.h | 1160 + .../JavaScriptCore/wtf/PossiblyNull.h | 59 + .../JavaScriptCore/wtf/PtrAndFlags.h | 79 + .../JavaScriptCore/wtf/RandomNumber.cpp | 119 + .../JavaScriptCore/wtf/RandomNumber.h | 45 + .../JavaScriptCore/wtf/RandomNumberSeed.h | 88 + .../JavaScriptCore/wtf/RefCounted.h | 137 + .../wtf/RefCountedLeakCounter.cpp | 102 + .../wtf/RefCountedLeakCounter.h | 48 + .../JavaScriptCore/wtf/RefPtr.h | 240 + .../JavaScriptCore/wtf/RefPtrHashMap.h | 350 + .../JavaScriptCore/wtf/RetainPtr.h | 203 + .../JavaScriptCore/wtf/SegmentedVector.h | 255 + .../JavaScriptCore/wtf/StdLibExtras.h | 82 + .../JavaScriptCore/wtf/StringExtras.cpp | 62 + .../JavaScriptCore/wtf/StringExtras.h | 115 + .../JavaScriptCore/wtf/StringHashFunctions.h | 157 + .../JavaScriptCore/wtf/TCPackedCache.h | 234 + .../JavaScriptCore/wtf/TCPageMap.h | 316 + .../JavaScriptCore/wtf/TCSpinLock.h | 240 + .../JavaScriptCore/wtf/TCSystemAlloc.cpp | 522 + .../JavaScriptCore/wtf/TCSystemAlloc.h | 75 + .../wtf/ThreadIdentifierDataPthreads.cpp | 97 + .../wtf/ThreadIdentifierDataPthreads.h | 77 + .../JavaScriptCore/wtf/ThreadSpecific.h | 310 + .../JavaScriptCore/wtf/ThreadSpecificWin.cpp | 54 + .../JavaScriptCore/wtf/Threading.cpp | 98 + .../JavaScriptCore/wtf/Threading.h | 344 + .../JavaScriptCore/wtf/ThreadingNone.cpp | 63 + .../JavaScriptCore/wtf/ThreadingPthreads.cpp | 393 + .../JavaScriptCore/wtf/ThreadingWin.cpp | 493 + .../JavaScriptCore/wtf/TypeTraits.cpp | 134 + .../JavaScriptCore/wtf/TypeTraits.h | 377 + .../JavaScriptCore/wtf/UnusedParam.h | 29 + .../JavaScriptCore/wtf/VMTags.h | 92 + .../JavaScriptCore/wtf/Vector.h | 1042 + .../JavaScriptCore/wtf/VectorTraits.h | 106 + .../wtf/android/AndroidThreading.h | 39 + .../wtf/android/MainThreadAndroid.cpp | 42 + .../JavaScriptCore/wtf/dtoa.cpp | 2467 + .../javascriptcore/JavaScriptCore/wtf/dtoa.h | 47 + .../JavaScriptCore/wtf/qt/MainThreadQt.cpp | 74 + .../JavaScriptCore/wtf/qt/ThreadingQt.cpp | 297 + .../wtf/symbian/BlockAllocatorSymbian.cpp | 132 + .../wtf/symbian/BlockAllocatorSymbian.h | 120 + .../symbian/RegisterFileAllocatorSymbian.cpp | 117 + .../symbian/RegisterFileAllocatorSymbian.h | 69 + .../wtf/symbian/SymbianDefines.h | 42 + .../JavaScriptCore/wtf/unicode/Collator.h | 67 + .../wtf/unicode/CollatorDefault.cpp | 75 + .../JavaScriptCore/wtf/unicode/UTF8.cpp | 304 + .../JavaScriptCore/wtf/unicode/UTF8.h | 75 + .../JavaScriptCore/wtf/unicode/Unicode.h | 42 + .../wtf/unicode/glib/UnicodeGLib.cpp | 215 + .../wtf/unicode/glib/UnicodeGLib.h | 243 + .../wtf/unicode/glib/UnicodeMacrosFromICU.h | 69 + .../wtf/unicode/icu/CollatorICU.cpp | 150 + .../wtf/unicode/icu/UnicodeIcu.h | 235 + .../wtf/unicode/qt4/UnicodeQt4.h | 315 + .../wtf/unicode/wince/UnicodeWince.cpp | 176 + .../wtf/unicode/wince/UnicodeWince.h | 216 + .../wtf/wince/FastMallocWince.h | 176 + .../wtf/wince/MemoryManager.cpp | 171 + .../JavaScriptCore/wtf/wince/MemoryManager.h | 80 + .../JavaScriptCore/wtf/wince/mt19937ar.c | 170 + .../JavaScriptCore/yarr/RegexCompiler.cpp | 728 + .../JavaScriptCore/yarr/RegexCompiler.h | 45 + .../JavaScriptCore/yarr/RegexInterpreter.cpp | 1638 + .../JavaScriptCore/yarr/RegexInterpreter.h | 337 + .../JavaScriptCore/yarr/RegexJIT.cpp | 1413 + .../JavaScriptCore/yarr/RegexJIT.h | 98 + .../JavaScriptCore/yarr/RegexParser.h | 854 + .../JavaScriptCore/yarr/RegexPattern.h | 356 + .../src/3rdparty/javascriptcore/VERSION.TXT | 11 + .../src/3rdparty/javascriptcore/WebKit.pri | 81 + .../javascriptcore/qt_attribution.json | 54 + .../src/plugins/script/qtdbus/main.cpp | 399 + .../qtscript/src/plugins/script/qtdbus/main.h | 177 + .../src/plugins/script/qtdbus/qtdbus.pro | 11 + .../script/qtdbus/qtdbusscriptplugin.json | 3 + .../qtscript/src/plugins/script/script.pro | 2 + src/shared/qtscript/src/script/api/api.pri | 36 + .../qtscript/src/script/api/qscriptable.cpp | 181 + .../qtscript/src/script/api/qscriptable.h | 82 + .../qtscript/src/script/api/qscriptable_p.h | 77 + .../qtscript/src/script/api/qscriptclass.cpp | 394 + .../qtscript/src/script/api/qscriptclass.h | 111 + .../api/qscriptclasspropertyiterator.cpp | 220 + .../script/api/qscriptclasspropertyiterator.h | 86 + .../src/script/api/qscriptcontext.cpp | 805 + .../qtscript/src/script/api/qscriptcontext.h | 115 + .../src/script/api/qscriptcontext_p.h | 74 + .../src/script/api/qscriptcontextinfo.cpp | 570 + .../src/script/api/qscriptcontextinfo.h | 116 + .../qtscript/src/script/api/qscriptengine.cpp | 4574 ++ .../qtscript/src/script/api/qscriptengine.h | 456 + .../qtscript/src/script/api/qscriptengine_p.h | 1168 + .../src/script/api/qscriptengineagent.cpp | 527 + .../src/script/api/qscriptengineagent.h | 103 + .../src/script/api/qscriptengineagent_p.h | 141 + .../script/api/qscriptextensioninterface.h | 65 + .../src/script/api/qscriptextensionplugin.cpp | 141 + .../src/script/api/qscriptextensionplugin.h | 69 + .../src/script/api/qscriptprogram.cpp | 231 + .../qtscript/src/script/api/qscriptprogram.h | 80 + .../src/script/api/qscriptprogram_p.h | 95 + .../qtscript/src/script/api/qscriptstring.cpp | 230 + .../qtscript/src/script/api/qscriptstring.h | 81 + .../qtscript/src/script/api/qscriptstring_p.h | 123 + .../qtscript/src/script/api/qscriptvalue.cpp | 2151 + .../qtscript/src/script/api/qscriptvalue.h | 235 + .../qtscript/src/script/api/qscriptvalue_p.h | 159 + .../src/script/api/qscriptvalueiterator.cpp | 378 + .../src/script/api/qscriptvalueiterator.h | 90 + .../qtscript/src/script/api/qtscriptglobal.h | 65 + .../qtscript/src/script/bridge/bridge.pri | 23 + .../script/bridge/qscriptactivationobject.cpp | 170 + .../script/bridge/qscriptactivationobject_p.h | 108 + .../src/script/bridge/qscriptclassobject.cpp | 296 + .../src/script/bridge/qscriptclassobject_p.h | 120 + .../script/bridge/qscriptdeclarativeclass.cpp | 609 + .../script/bridge/qscriptdeclarativeclass_p.h | 172 + .../bridge/qscriptdeclarativeobject.cpp | 206 + .../bridge/qscriptdeclarativeobject_p.h | 125 + .../src/script/bridge/qscriptfunction.cpp | 192 + .../src/script/bridge/qscriptfunction_p.h | 135 + .../src/script/bridge/qscriptglobalobject.cpp | 174 + .../src/script/bridge/qscriptglobalobject_p.h | 143 + .../src/script/bridge/qscriptobject.cpp | 238 + .../src/script/bridge/qscriptobject_p.h | 192 + .../src/script/bridge/qscriptqobject.cpp | 2435 + .../src/script/bridge/qscriptqobject_p.h | 361 + .../bridge/qscriptstaticscopeobject.cpp | 173 + .../bridge/qscriptstaticscopeobject_p.h | 119 + .../src/script/bridge/qscriptvariant.cpp | 167 + .../src/script/bridge/qscriptvariant_p.h | 100 + src/shared/qtscript/src/script/configure.json | 23 + .../script/doc/images/qtscript-debugger.png | Bin 0 -> 96223 bytes .../qtscript/src/script/doc/qtscript.qdocconf | 51 + .../code/doc_src_examples_hellotr.qdoc | 81 + .../doc/snippets/code/doc_src_qtscript.cpp | 578 + .../doc/snippets/code/doc_src_qtscript.js | 454 + .../doc/snippets/code/doc_src_qtscript.pro | 53 + .../doc/snippets/code/doc_src_qtscript.qdoc | 61 + .../code/doc_src_qtscriptextensions.js | 57 + .../snippets/code/src_script_qscriptable.cpp | 75 + .../snippets/code/src_script_qscriptclass.cpp | 60 + .../code/src_script_qscriptcontext.cpp | 78 + .../code/src_script_qscriptengine.cpp | 342 + .../code/src_script_qscriptengineagent.cpp | 62 + .../snippets/code/src_script_qscriptvalue.cpp | 90 + .../code/src_script_qscriptvalueiterator.cpp | 82 + .../doc/snippets/qtscript/evaluation/main.cpp | 60 + .../qtscript/registeringobjects/main.cpp | 66 + .../qtscript/registeringvalues/main.cpp | 62 + .../src/script/doc/src/ecmascript.qdoc | 368 + .../script/doc/src/external-resources.qdoc | 36 + .../doc/src/includes/deprecation.qdocinc | 3 + .../src/script/doc/src/qtscript-index.qdoc | 1889 + .../src/script/doc/src/qtscript-module.qdoc | 95 + .../doc/src/qtscriptdebugger-manual.qdoc | 422 + .../script/doc/src/qtscriptextensions.qdoc | 101 + .../qtscript/src/script/parser/make-parser.sh | 51 + .../qtscript/src/script/parser/parser.pri | 19 + .../qtscript/src/script/parser/qscript.g | 2043 + .../qtscript/src/script/parser/qscriptast.cpp | 783 + .../qtscript/src/script/parser/qscriptast_p.h | 1496 + .../src/script/parser/qscriptastfwd_p.h | 144 + .../src/script/parser/qscriptastvisitor.cpp | 56 + .../src/script/parser/qscriptastvisitor_p.h | 293 + .../src/script/parser/qscriptgrammar.cpp | 969 + .../src/script/parser/qscriptgrammar_p.h | 197 + .../src/script/parser/qscriptlexer.cpp | 1107 + .../src/script/parser/qscriptlexer_p.h | 240 + .../src/script/parser/qscriptparser.cpp | 1155 + .../src/script/parser/qscriptparser_p.h | 164 + .../script/parser/qscriptsyntaxchecker.cpp | 214 + .../script/parser/qscriptsyntaxchecker_p.h | 114 + src/shared/qtscript/src/script/script.pri | 3 + src/shared/qtscript/src/script/script.pro | 76 + .../src/scripttools/debugging/debugging.pri | 161 + .../debugging/images/breakpoint.png | Bin 0 -> 975 bytes .../debugging/images/breakpoint.svg | 154 + .../debugging/images/d_breakpoint.png | Bin 0 -> 956 bytes .../debugging/images/d_breakpoint.svg | 154 + .../debugging/images/d_interrupt.png | Bin 0 -> 367 bytes .../scripttools/debugging/images/d_play.png | Bin 0 -> 376 bytes .../scripttools/debugging/images/delete.png | Bin 0 -> 833 bytes .../src/scripttools/debugging/images/find.png | Bin 0 -> 843 bytes .../debugging/images/interrupt.png | Bin 0 -> 578 bytes .../scripttools/debugging/images/location.png | Bin 0 -> 600 bytes .../scripttools/debugging/images/location.svg | 121 + .../debugging/images/mac/closetab.png | Bin 0 -> 516 bytes .../scripttools/debugging/images/mac/next.png | Bin 0 -> 1310 bytes .../scripttools/debugging/images/mac/plus.png | Bin 0 -> 810 bytes .../debugging/images/mac/previous.png | Bin 0 -> 1080 bytes .../src/scripttools/debugging/images/new.png | Bin 0 -> 313 bytes .../src/scripttools/debugging/images/play.png | Bin 0 -> 620 bytes .../scripttools/debugging/images/reload.png | Bin 0 -> 1363 bytes .../scripttools/debugging/images/return.png | Bin 0 -> 536 bytes .../debugging/images/runtocursor.png | Bin 0 -> 436 bytes .../debugging/images/runtonewscript.png | Bin 0 -> 361 bytes .../scripttools/debugging/images/stepinto.png | Bin 0 -> 419 bytes .../scripttools/debugging/images/stepout.png | Bin 0 -> 408 bytes .../scripttools/debugging/images/stepover.png | Bin 0 -> 487 bytes .../debugging/images/win/closetab.png | Bin 0 -> 375 bytes .../scripttools/debugging/images/win/next.png | Bin 0 -> 1038 bytes .../scripttools/debugging/images/win/plus.png | Bin 0 -> 709 bytes .../debugging/images/win/previous.png | Bin 0 -> 898 bytes .../src/scripttools/debugging/images/wrap.png | Bin 0 -> 500 bytes .../debugging/qscriptbreakpointdata.cpp | 388 + .../debugging/qscriptbreakpointdata_p.h | 127 + .../debugging/qscriptbreakpointsmodel.cpp | 496 + .../debugging/qscriptbreakpointsmodel_p.h | 105 + .../debugging/qscriptbreakpointswidget.cpp | 387 + .../debugging/qscriptbreakpointswidget_p.h | 88 + .../qscriptbreakpointswidgetinterface.cpp | 64 + .../qscriptbreakpointswidgetinterface_p.h | 90 + .../qscriptbreakpointswidgetinterface_p_p.h | 70 + .../qscriptcompletionproviderinterface_p.h | 76 + .../debugging/qscriptcompletiontask.cpp | 307 + .../debugging/qscriptcompletiontask_p.h | 88 + .../qscriptcompletiontaskinterface.cpp | 108 + .../qscriptcompletiontaskinterface_p.h | 104 + .../qscriptcompletiontaskinterface_p_p.h | 79 + .../scripttools/debugging/qscriptdebugger.cpp | 2012 + .../scripttools/debugging/qscriptdebugger_p.h | 220 + .../debugging/qscriptdebuggeragent.cpp | 730 + .../debugging/qscriptdebuggeragent_p.h | 133 + .../debugging/qscriptdebuggeragent_p_p.h | 124 + .../debugging/qscriptdebuggerbackend.cpp | 992 + .../debugging/qscriptdebuggerbackend_p.h | 154 + .../debugging/qscriptdebuggerbackend_p_p.h | 135 + .../qscriptdebuggercodefinderwidget.cpp | 247 + .../qscriptdebuggercodefinderwidget_p.h | 90 + ...criptdebuggercodefinderwidgetinterface.cpp | 64 + ...criptdebuggercodefinderwidgetinterface_p.h | 91 + ...iptdebuggercodefinderwidgetinterface_p_p.h | 70 + .../debugging/qscriptdebuggercodeview.cpp | 258 + .../debugging/qscriptdebuggercodeview_p.h | 94 + .../qscriptdebuggercodeviewinterface.cpp | 64 + .../qscriptdebuggercodeviewinterface_p.h | 104 + .../qscriptdebuggercodeviewinterface_p_p.h | 70 + .../debugging/qscriptdebuggercodewidget.cpp | 303 + .../debugging/qscriptdebuggercodewidget_p.h | 97 + .../qscriptdebuggercodewidgetinterface.cpp | 64 + .../qscriptdebuggercodewidgetinterface_p.h | 99 + .../qscriptdebuggercodewidgetinterface_p_p.h | 70 + .../debugging/qscriptdebuggercommand.cpp | 705 + .../debugging/qscriptdebuggercommand_p.h | 266 + .../qscriptdebuggercommandexecutor.cpp | 522 + .../qscriptdebuggercommandexecutor_p.h | 85 + ...scriptdebuggercommandschedulerfrontend.cpp | 318 + ...scriptdebuggercommandschedulerfrontend_p.h | 146 + ...criptdebuggercommandschedulerinterface_p.h | 73 + .../qscriptdebuggercommandschedulerjob.cpp | 80 + .../qscriptdebuggercommandschedulerjob_p.h | 85 + .../qscriptdebuggercommandschedulerjob_p_p.h | 74 + .../debugging/qscriptdebuggerconsole.cpp | 603 + .../debugging/qscriptdebuggerconsole_p.h | 119 + .../qscriptdebuggerconsolecommand.cpp | 145 + .../qscriptdebuggerconsolecommand_p.h | 103 + .../qscriptdebuggerconsolecommand_p_p.h | 71 + ...qscriptdebuggerconsolecommandgroupdata.cpp | 124 + ...qscriptdebuggerconsolecommandgroupdata_p.h | 93 + .../qscriptdebuggerconsolecommandjob.cpp | 83 + .../qscriptdebuggerconsolecommandjob_p.h | 84 + .../qscriptdebuggerconsolecommandjob_p_p.h | 76 + .../qscriptdebuggerconsolecommandmanager.cpp | 244 + .../qscriptdebuggerconsolecommandmanager_p.h | 94 + .../qscriptdebuggerconsoleglobalobject.cpp | 461 + .../qscriptdebuggerconsoleglobalobject_p.h | 170 + ...criptdebuggerconsolehistorianinterface_p.h | 72 + .../qscriptdebuggerconsolewidget.cpp | 444 + .../qscriptdebuggerconsolewidget_p.h | 96 + .../qscriptdebuggerconsolewidgetinterface.cpp | 92 + .../qscriptdebuggerconsolewidgetinterface_p.h | 101 + ...scriptdebuggerconsolewidgetinterface_p_p.h | 76 + .../debugging/qscriptdebuggerevent.cpp | 316 + .../debugging/qscriptdebuggerevent_p.h | 162 + .../qscriptdebuggereventhandlerinterface_p.h | 70 + .../debugging/qscriptdebuggerfrontend.cpp | 233 + .../debugging/qscriptdebuggerfrontend_p.h | 100 + .../debugging/qscriptdebuggerfrontend_p_p.h | 91 + .../debugging/qscriptdebuggerjob.cpp | 108 + .../debugging/qscriptdebuggerjob_p.h | 87 + .../debugging/qscriptdebuggerjob_p_p.h | 76 + .../qscriptdebuggerjobschedulerinterface_p.h | 72 + .../debugging/qscriptdebuggerlocalsmodel.cpp | 957 + .../debugging/qscriptdebuggerlocalsmodel_p.h | 100 + .../debugging/qscriptdebuggerlocalswidget.cpp | 416 + .../debugging/qscriptdebuggerlocalswidget_p.h | 83 + .../qscriptdebuggerlocalswidgetinterface.cpp | 77 + .../qscriptdebuggerlocalswidgetinterface_p.h | 90 + ...qscriptdebuggerlocalswidgetinterface_p_p.h | 74 + .../qscriptdebuggerobjectsnapshotdelta_p.h | 76 + .../debugging/qscriptdebuggerresponse.cpp | 345 + .../debugging/qscriptdebuggerresponse_p.h | 138 + ...scriptdebuggerresponsehandlerinterface_p.h | 71 + .../qscriptdebuggerscriptedconsolecommand.cpp | 428 + .../qscriptdebuggerscriptedconsolecommand_p.h | 106 + .../debugging/qscriptdebuggerscriptsmodel.cpp | 333 + .../debugging/qscriptdebuggerscriptsmodel_p.h | 99 + .../qscriptdebuggerscriptswidget.cpp | 152 + .../qscriptdebuggerscriptswidget_p.h | 82 + .../qscriptdebuggerscriptswidgetinterface.cpp | 64 + .../qscriptdebuggerscriptswidgetinterface_p.h | 90 + ...scriptdebuggerscriptswidgetinterface_p_p.h | 70 + .../debugging/qscriptdebuggerstackmodel.cpp | 168 + .../debugging/qscriptdebuggerstackmodel_p.h | 85 + .../debugging/qscriptdebuggerstackwidget.cpp | 140 + .../debugging/qscriptdebuggerstackwidget_p.h | 82 + .../qscriptdebuggerstackwidgetinterface.cpp | 64 + .../qscriptdebuggerstackwidgetinterface_p.h | 89 + .../qscriptdebuggerstackwidgetinterface_p_p.h | 70 + .../qscriptdebuggerstandardwidgetfactory.cpp | 107 + .../qscriptdebuggerstandardwidgetfactory_p.h | 83 + .../debugging/qscriptdebuggervalue.cpp | 401 + .../debugging/qscriptdebuggervalue_p.h | 116 + .../qscriptdebuggervalueproperty.cpp | 228 + .../qscriptdebuggervalueproperty_p.h | 99 + .../qscriptdebuggerwidgetfactoryinterface_p.h | 86 + .../debugging/qscriptdebugoutputwidget.cpp | 157 + .../debugging/qscriptdebugoutputwidget_p.h | 81 + .../qscriptdebugoutputwidgetinterface.cpp | 64 + .../qscriptdebugoutputwidgetinterface_p.h | 82 + .../qscriptdebugoutputwidgetinterface_p_p.h | 70 + .../src/scripttools/debugging/qscriptedit.cpp | 461 + .../src/scripttools/debugging/qscriptedit_p.h | 130 + .../debugging/qscriptenginedebugger.cpp | 673 + .../debugging/qscriptenginedebugger.h | 131 + .../qscriptenginedebuggerfrontend.cpp | 334 + .../qscriptenginedebuggerfrontend_p.h | 87 + .../debugging/qscripterrorlogwidget.cpp | 133 + .../debugging/qscripterrorlogwidget_p.h | 81 + .../qscripterrorlogwidgetinterface.cpp | 64 + .../qscripterrorlogwidgetinterface_p.h | 82 + .../qscripterrorlogwidgetinterface_p_p.h | 70 + .../qscriptmessagehandlerinterface_p.h | 73 + .../debugging/qscriptobjectsnapshot.cpp | 145 + .../debugging/qscriptobjectsnapshot_p.h | 84 + .../debugging/qscriptscriptdata.cpp | 208 + .../debugging/qscriptscriptdata_p.h | 104 + .../debugging/qscriptstdmessagehandler.cpp | 97 + .../debugging/qscriptstdmessagehandler_p.h | 83 + .../debugging/qscriptsyntaxhighlighter.cpp | 543 + .../debugging/qscriptsyntaxhighlighter_p.h | 93 + .../qscripttooltipproviderinterface_p.h | 72 + .../debugging/qscriptvalueproperty.cpp | 158 + .../debugging/qscriptvalueproperty_p.h | 92 + .../debugging/qscriptxmlparser.cpp | 174 + .../debugging/qscriptxmlparser_p.h | 79 + .../debugging/scripts/commands/advance.qs | 41 + .../debugging/scripts/commands/backtrace.qs | 26 + .../debugging/scripts/commands/break.qs | 59 + .../debugging/scripts/commands/clear.qs | 59 + .../debugging/scripts/commands/complete.qs | 14 + .../debugging/scripts/commands/condition.qs | 52 + .../debugging/scripts/commands/continue.qs | 22 + .../debugging/scripts/commands/delete.qs | 36 + .../debugging/scripts/commands/disable.qs | 56 + .../debugging/scripts/commands/down.qs | 33 + .../debugging/scripts/commands/enable.qs | 56 + .../debugging/scripts/commands/eval.qs | 21 + .../debugging/scripts/commands/finish.qs | 16 + .../debugging/scripts/commands/frame.qs | 36 + .../debugging/scripts/commands/help.qs | 71 + .../debugging/scripts/commands/ignore.qs | 51 + .../debugging/scripts/commands/info.qs | 128 + .../debugging/scripts/commands/interrupt.qs | 14 + .../debugging/scripts/commands/list.qs | 90 + .../debugging/scripts/commands/next.qs | 27 + .../debugging/scripts/commands/print.qs | 23 + .../debugging/scripts/commands/return.qs | 20 + .../debugging/scripts/commands/step.qs | 26 + .../debugging/scripts/commands/tbreak.qs | 59 + .../debugging/scripts/commands/up.qs | 37 + .../debugging/scripttools_debugging.qrc | 63 + .../scripttools/doc/qtscripttools.qdocconf | 44 + .../doc/snippets/doc_src_qtscripttools.cpp | 53 + .../doc/snippets/doc_src_qtscripttools.pro | 53 + .../doc/snippets/scriptdebugger.cpp | 113 + .../src.scripttools.qscriptenginedebugger.cpp | 59 + .../doc/src/qtscripttools-index.qdoc | 69 + .../doc/src/qtscripttools-module.qdoc | 50 + .../qtscript/src/scripttools/scripttools.pro | 12 + src/shared/qtscript/src/src.pro | 7 + src/shared/qtscript/sync.profile | 6 + src/shared/qtscript/tests/README | 18 + src/shared/qtscript/tests/auto/auto.pro | 37 + src/shared/qtscript/tests/auto/bic/.gitignore | 2 + .../data/QtScript.5.0.0.linux-gcc-amd64.txt | 3605 ++ .../data/QtScript.5.1.0.linux-gcc-amd64.txt | 3669 ++ .../data/QtScript.5.10.0.linux-gcc-amd64.txt | 4739 ++ .../data/QtScript.5.11.0.linux-gcc-amd64.txt | 4739 ++ .../data/QtScript.5.13.0.linux-gcc-amd64.txt | 5174 ++ .../data/QtScript.5.14.0.linux-gcc-amd64.txt | 5213 ++ .../data/QtScript.5.2.0.linux-gcc-amd64.txt | 3789 ++ .../data/QtScript.5.3.0.linux-gcc-amd64.txt | 3800 ++ .../data/QtScript.5.4.0.linux-gcc-amd64.txt | 3832 ++ .../data/QtScript.5.6.0.linux-gcc-amd64.txt | 4096 ++ .../data/QtScript.5.7.0.linux-gcc-amd64.txt | 4378 ++ .../data/QtScript.5.8.0.linux-gcc-amd64.txt | 4403 ++ .../QtScriptTools.5.0.0.linux-gcc-amd64.txt | 3438 ++ .../QtScriptTools.5.1.0.linux-gcc-amd64.txt | 3502 ++ .../QtScriptTools.5.10.0.linux-gcc-amd64.txt | 4572 ++ .../QtScriptTools.5.11.0.linux-gcc-amd64.txt | 4572 ++ .../QtScriptTools.5.13.0.linux-gcc-amd64.txt | 5007 ++ .../QtScriptTools.5.14.0.linux-gcc-amd64.txt | 5046 ++ .../QtScriptTools.5.2.0.linux-gcc-amd64.txt | 3622 ++ .../QtScriptTools.5.3.0.linux-gcc-amd64.txt | 3633 ++ .../QtScriptTools.5.4.0.linux-gcc-amd64.txt | 3665 ++ .../QtScriptTools.5.6.0.linux-gcc-amd64.txt | 3929 ++ .../QtScriptTools.5.7.0.linux-gcc-amd64.txt | 4211 ++ .../QtScriptTools.5.8.0.linux-gcc-amd64.txt | 4236 ++ .../qtscript/tests/auto/cmake/CMakeLists.txt | 24 + .../qtscript/tests/auto/cmake/cmake.pro | 8 + .../tests/auto/guiapplauncher/README.txt | 2 + .../tests/auto/guiapplauncher/examples.txt | 2 + src/shared/qtscript/tests/auto/host.pro | 4 + .../tests/auto/qscriptable/.gitignore | 1 + .../tests/auto/qscriptable/qscriptable.pro | 7 + .../auto/qscriptable/tst_qscriptable.cpp | 435 + .../tests/auto/qscriptclass/.gitignore | 1 + .../tests/auto/qscriptclass/qscriptclass.pro | 5 + .../auto/qscriptclass/tst_qscriptclass.cpp | 1486 + .../tests/auto/qscriptcontext/.gitignore | 1 + .../auto/qscriptcontext/qscriptcontext.pro | 8 + .../qscriptcontext/tst_qscriptcontext.cpp | 1529 + .../tests/auto/qscriptcontextinfo/.gitignore | 1 + .../qscriptcontextinfo/qscriptcontextinfo.pro | 7 + .../tst_qscriptcontextinfo.cpp | 375 + .../tests/auto/qscriptengine/.gitignore | 1 + .../qscriptengine/idtranslatable-unicode.js | 5 + .../auto/qscriptengine/idtranslatable.js | 5 + .../auto/qscriptengine/qscriptengine.pro | 20 + .../auto/qscriptengine/qscriptengine.qrc | 8 + .../auto/qscriptengine/script/com/__init__.js | 9 + .../script/com/trolltech/__init__.js | 9 + .../com/trolltech/recursive/__init__.js | 1 + .../com/trolltech/syntaxerror/__init__.js | 5 + .../qscriptengine/translatable-unicode.js | 9 + .../tests/auto/qscriptengine/translatable.js | 12 + .../tests/auto/qscriptengine/translatable2.js | 9 + .../translations/idtranslatable-unicode.qm | Bin 0 -> 209 bytes .../translations/idtranslatable-unicode.ts | 26 + .../translations/idtranslatable_la.qm | Bin 0 -> 342 bytes .../translations/idtranslatable_la.ts | 30 + .../translations/translatable-unicode.qm | Bin 0 -> 322 bytes .../translations/translatable-unicode.ts | 37 + .../translations/translatable_la.qm | Bin 0 -> 975 bytes .../translations/translatable_la.ts | 88 + .../auto/qscriptengine/tst_qscriptengine.cpp | 6284 +++ .../tests/auto/qscriptengineagent/.gitignore | 1 + .../qscriptengineagent/qscriptengineagent.pro | 7 + .../tst_qscriptengineagent.cpp | 2543 + .../auto/qscriptenginedebugger/.gitignore | 1 + .../qscriptenginedebugger.pro | 5 + .../tst_qscriptenginedebugger.cpp | 847 + .../qscriptextensionplugin.pro | 4 + .../simpleplugin/simpleplugin.cpp | 70 + .../simpleplugin/simpleplugin.json | 3 + .../simpleplugin/simpleplugin.pro | 8 + .../staticplugin/__init__.js | 6 + .../staticplugin/staticplugin.cpp | 65 + .../staticplugin/staticplugin.json | 3 + .../staticplugin/staticplugin.pro | 10 + .../staticplugin/staticplugin.qrc | 6 + .../auto/qscriptextensionplugin/test/test.pro | 20 + .../tst_qscriptextensionplugin.cpp | 157 + .../tests/auto/qscriptextqobject/.gitignore | 1 + .../qscriptextqobject/qscriptextqobject.pro | 6 + .../tst_qscriptextqobject.cpp | 3793 ++ .../tests/auto/qscriptjstestsuite/.gitignore | 1 + .../tests/auto/qscriptjstestsuite/BLACKLIST | 8 + .../auto/qscriptjstestsuite/expect_fail.txt | 199 + .../qscriptjstestsuite/qscriptjstestsuite.pro | 14 + .../qscriptjstestsuite/qscriptjstestsuite.qrc | 6 + .../tests/auto/qscriptjstestsuite/skip.txt | 13 + .../tests/ecma/Array/15.4-1.js | 135 + .../tests/ecma/Array/15.4-2.js | 114 + .../tests/ecma/Array/15.4.1.1.js | 111 + .../tests/ecma/Array/15.4.1.2.js | 162 + .../tests/ecma/Array/15.4.1.3.js | 84 + .../tests/ecma/Array/15.4.1.js | 132 + .../tests/ecma/Array/15.4.2.1-1.js | 112 + .../tests/ecma/Array/15.4.2.1-2.js | 101 + .../tests/ecma/Array/15.4.2.1-3.js | 137 + .../tests/ecma/Array/15.4.2.2-1.js | 183 + .../tests/ecma/Array/15.4.2.2-2.js | 118 + .../tests/ecma/Array/15.4.2.3.js | 101 + .../tests/ecma/Array/15.4.3.1-2.js | 81 + .../tests/ecma/Array/15.4.3.2.js | 62 + .../tests/ecma/Array/15.4.4.1.js | 63 + .../tests/ecma/Array/15.4.4.2.js | 120 + .../tests/ecma/Array/15.4.4.3-1.js | 163 + .../tests/ecma/Array/15.4.4.4-1.js | 294 + .../tests/ecma/Array/15.4.4.4-2.js | 169 + .../tests/ecma/Array/15.4.4.5-1.js | 225 + .../tests/ecma/Array/15.4.4.5-2.js | 227 + .../tests/ecma/Array/15.4.4.5-3.js | 182 + .../tests/ecma/Array/15.4.4.js | 74 + .../tests/ecma/Array/15.4.5.1-1.js | 170 + .../tests/ecma/Array/15.4.5.1-2.js | 152 + .../tests/ecma/Array/15.4.5.2-1.js | 86 + .../tests/ecma/Array/15.4.5.2-2.js | 127 + .../tests/ecma/Array/browser.js | 0 .../tests/ecma/Array/shell.js | 1 + .../tests/ecma/Boolean/15.6.1.js | 96 + .../tests/ecma/Boolean/15.6.2.js | 161 + .../tests/ecma/Boolean/15.6.3.1-1.js | 72 + .../tests/ecma/Boolean/15.6.3.1-2.js | 71 + .../tests/ecma/Boolean/15.6.3.1-3.js | 71 + .../tests/ecma/Boolean/15.6.3.1-4.js | 75 + .../tests/ecma/Boolean/15.6.3.1.js | 69 + .../tests/ecma/Boolean/15.6.4-1.js | 72 + .../tests/ecma/Boolean/15.6.4.1.js | 62 + .../tests/ecma/Boolean/15.6.4.2-1.js | 97 + .../tests/ecma/Boolean/15.6.4.2-2.js | 73 + .../tests/ecma/Boolean/15.6.4.2-3.js | 65 + .../tests/ecma/Boolean/15.6.4.2-4-n.js | 69 + .../tests/ecma/Boolean/15.6.4.3-1.js | 88 + .../tests/ecma/Boolean/15.6.4.3-2.js | 67 + .../tests/ecma/Boolean/15.6.4.3-3.js | 66 + .../tests/ecma/Boolean/15.6.4.3-4-n.js | 69 + .../tests/ecma/Boolean/15.6.4.3.js | 83 + .../tests/ecma/Boolean/15.6.4.js | 80 + .../tests/ecma/Boolean/browser.js | 0 .../tests/ecma/Boolean/shell.js | 1 + .../tests/ecma/Date/15.9.1.1-1.js | 96 + .../tests/ecma/Date/15.9.1.1-2.js | 91 + .../tests/ecma/Date/15.9.1.13-1.js | 79 + .../tests/ecma/Date/15.9.2.1.js | 104 + .../tests/ecma/Date/15.9.2.2-1.js | 69 + .../tests/ecma/Date/15.9.2.2-2.js | 69 + .../tests/ecma/Date/15.9.2.2-3.js | 69 + .../tests/ecma/Date/15.9.2.2-4.js | 68 + .../tests/ecma/Date/15.9.2.2-5.js | 68 + .../tests/ecma/Date/15.9.2.2-6.js | 67 + .../tests/ecma/Date/15.9.3.1-1.js | 239 + .../tests/ecma/Date/15.9.3.1-2.js | 152 + .../tests/ecma/Date/15.9.3.1-3.js | 141 + .../tests/ecma/Date/15.9.3.1-4.js | 151 + .../tests/ecma/Date/15.9.3.1-5.js | 140 + .../tests/ecma/Date/15.9.3.2-1.js | 151 + .../tests/ecma/Date/15.9.3.2-2.js | 142 + .../tests/ecma/Date/15.9.3.2-3.js | 146 + .../tests/ecma/Date/15.9.3.2-4.js | 143 + .../tests/ecma/Date/15.9.3.2-5.js | 140 + .../tests/ecma/Date/15.9.3.8-1.js | 155 + .../tests/ecma/Date/15.9.3.8-2.js | 153 + .../tests/ecma/Date/15.9.3.8-3.js | 160 + .../tests/ecma/Date/15.9.3.8-4.js | 161 + .../tests/ecma/Date/15.9.3.8-5.js | 161 + .../tests/ecma/Date/15.9.4.2-1.js | 81 + .../tests/ecma/Date/15.9.4.2.js | 191 + .../tests/ecma/Date/15.9.4.3.js | 186 + .../tests/ecma/Date/15.9.5.1.js | 63 + .../tests/ecma/Date/15.9.5.10-1.js | 85 + .../tests/ecma/Date/15.9.5.10-10.js | 89 + .../tests/ecma/Date/15.9.5.10-11.js | 89 + .../tests/ecma/Date/15.9.5.10-12.js | 89 + .../tests/ecma/Date/15.9.5.10-13.js | 89 + .../tests/ecma/Date/15.9.5.10-2.js | 87 + .../tests/ecma/Date/15.9.5.10-3.js | 85 + .../tests/ecma/Date/15.9.5.10-4.js | 85 + .../tests/ecma/Date/15.9.5.10-5.js | 85 + .../tests/ecma/Date/15.9.5.10-6.js | 85 + .../tests/ecma/Date/15.9.5.10-7.js | 85 + .../tests/ecma/Date/15.9.5.10-8.js | 89 + .../tests/ecma/Date/15.9.5.10-9.js | 89 + .../tests/ecma/Date/15.9.5.11-1.js | 76 + .../tests/ecma/Date/15.9.5.11-2.js | 76 + .../tests/ecma/Date/15.9.5.11-3.js | 76 + .../tests/ecma/Date/15.9.5.11-4.js | 76 + .../tests/ecma/Date/15.9.5.11-5.js | 76 + .../tests/ecma/Date/15.9.5.11-6.js | 76 + .../tests/ecma/Date/15.9.5.11-7.js | 76 + .../tests/ecma/Date/15.9.5.12-1.js | 77 + .../tests/ecma/Date/15.9.5.12-2.js | 77 + .../tests/ecma/Date/15.9.5.12-3.js | 77 + .../tests/ecma/Date/15.9.5.12-4.js | 77 + .../tests/ecma/Date/15.9.5.12-5.js | 77 + .../tests/ecma/Date/15.9.5.12-6.js | 77 + .../tests/ecma/Date/15.9.5.12-7.js | 77 + .../tests/ecma/Date/15.9.5.12-8.js | 71 + .../tests/ecma/Date/15.9.5.13-1.js | 79 + .../tests/ecma/Date/15.9.5.13-2.js | 76 + .../tests/ecma/Date/15.9.5.13-3.js | 77 + .../tests/ecma/Date/15.9.5.13-4.js | 77 + .../tests/ecma/Date/15.9.5.13-5.js | 77 + .../tests/ecma/Date/15.9.5.13-6.js | 77 + .../tests/ecma/Date/15.9.5.13-7.js | 76 + .../tests/ecma/Date/15.9.5.13-8.js | 71 + .../tests/ecma/Date/15.9.5.14.js | 87 + .../tests/ecma/Date/15.9.5.15.js | 88 + .../tests/ecma/Date/15.9.5.16.js | 87 + .../tests/ecma/Date/15.9.5.17.js | 88 + .../tests/ecma/Date/15.9.5.18.js | 88 + .../tests/ecma/Date/15.9.5.19.js | 88 + .../tests/ecma/Date/15.9.5.2-1.js | 151 + .../tests/ecma/Date/15.9.5.2-2-n.js | 84 + .../tests/ecma/Date/15.9.5.2.js | 151 + .../tests/ecma/Date/15.9.5.20.js | 88 + .../tests/ecma/Date/15.9.5.21-1.js | 70 + .../tests/ecma/Date/15.9.5.21-2.js | 70 + .../tests/ecma/Date/15.9.5.21-3.js | 70 + .../tests/ecma/Date/15.9.5.21-4.js | 70 + .../tests/ecma/Date/15.9.5.21-5.js | 70 + .../tests/ecma/Date/15.9.5.21-6.js | 70 + .../tests/ecma/Date/15.9.5.21-7.js | 70 + .../tests/ecma/Date/15.9.5.21-8.js | 71 + .../tests/ecma/Date/15.9.5.22-1.js | 89 + .../tests/ecma/Date/15.9.5.22-2.js | 74 + .../tests/ecma/Date/15.9.5.22-3.js | 74 + .../tests/ecma/Date/15.9.5.22-4.js | 74 + .../tests/ecma/Date/15.9.5.22-5.js | 74 + .../tests/ecma/Date/15.9.5.22-6.js | 74 + .../tests/ecma/Date/15.9.5.22-7.js | 74 + .../tests/ecma/Date/15.9.5.22-8.js | 72 + .../tests/ecma/Date/15.9.5.23-1.js | 139 + .../tests/ecma/Date/15.9.5.23-10.js | 139 + .../tests/ecma/Date/15.9.5.23-11.js | 140 + .../tests/ecma/Date/15.9.5.23-12.js | 137 + .../tests/ecma/Date/15.9.5.23-13.js | 137 + .../tests/ecma/Date/15.9.5.23-14.js | 137 + .../tests/ecma/Date/15.9.5.23-15.js | 137 + .../tests/ecma/Date/15.9.5.23-16.js | 137 + .../tests/ecma/Date/15.9.5.23-17.js | 137 + .../tests/ecma/Date/15.9.5.23-18.js | 137 + .../tests/ecma/Date/15.9.5.23-2.js | 109 + .../tests/ecma/Date/15.9.5.23-3-n.js | 79 + .../tests/ecma/Date/15.9.5.23-4.js | 112 + .../tests/ecma/Date/15.9.5.23-5.js | 113 + .../tests/ecma/Date/15.9.5.23-6.js | 112 + .../tests/ecma/Date/15.9.5.23-7.js | 113 + .../tests/ecma/Date/15.9.5.23-8.js | 103 + .../tests/ecma/Date/15.9.5.23-9.js | 103 + .../tests/ecma/Date/15.9.5.24-1.js | 134 + .../tests/ecma/Date/15.9.5.24-2.js | 134 + .../tests/ecma/Date/15.9.5.24-3.js | 134 + .../tests/ecma/Date/15.9.5.24-4.js | 134 + .../tests/ecma/Date/15.9.5.24-5.js | 134 + .../tests/ecma/Date/15.9.5.24-6.js | 134 + .../tests/ecma/Date/15.9.5.24-7.js | 134 + .../tests/ecma/Date/15.9.5.24-8.js | 133 + .../tests/ecma/Date/15.9.5.25-1.js | 174 + .../tests/ecma/Date/15.9.5.26-1.js | 183 + .../tests/ecma/Date/15.9.5.27-1.js | 183 + .../tests/ecma/Date/15.9.5.28-1.js | 196 + .../tests/ecma/Date/15.9.5.29-1.js | 191 + .../tests/ecma/Date/15.9.5.3-1-n.js | 80 + .../tests/ecma/Date/15.9.5.3-2.js | 104 + .../tests/ecma/Date/15.9.5.30-1.js | 192 + .../tests/ecma/Date/15.9.5.31-1.js | 221 + .../tests/ecma/Date/15.9.5.32-1.js | 141 + .../tests/ecma/Date/15.9.5.33-1.js | 145 + .../tests/ecma/Date/15.9.5.34-1.js | 182 + .../tests/ecma/Date/15.9.5.35-1.js | 139 + .../tests/ecma/Date/15.9.5.36-1.js | 165 + .../tests/ecma/Date/15.9.5.36-2.js | 164 + .../tests/ecma/Date/15.9.5.36-3.js | 163 + .../tests/ecma/Date/15.9.5.36-4.js | 163 + .../tests/ecma/Date/15.9.5.36-5.js | 163 + .../tests/ecma/Date/15.9.5.36-6.js | 163 + .../tests/ecma/Date/15.9.5.36-7.js | 163 + .../tests/ecma/Date/15.9.5.37-1.js | 173 + .../tests/ecma/Date/15.9.5.37-2.js | 161 + .../tests/ecma/Date/15.9.5.37-3.js | 164 + .../tests/ecma/Date/15.9.5.37-4.js | 163 + .../tests/ecma/Date/15.9.5.37-5.js | 159 + .../tests/ecma/Date/15.9.5.4-1.js | 93 + .../tests/ecma/Date/15.9.5.4-2-n.js | 76 + .../tests/ecma/Date/15.9.5.5.js | 112 + .../tests/ecma/Date/15.9.5.6.js | 104 + .../tests/ecma/Date/15.9.5.7.js | 105 + .../tests/ecma/Date/15.9.5.8.js | 113 + .../tests/ecma/Date/15.9.5.9.js | 113 + .../tests/ecma/Date/15.9.5.js | 83 + .../tests/ecma/Date/browser.js | 0 .../tests/ecma/Date/shell.js | 1 + .../tests/ecma/ExecutionContexts/10.1.3-1.js | 107 + .../tests/ecma/ExecutionContexts/10.1.3-2.js | 73 + .../tests/ecma/ExecutionContexts/10.1.3.js | 170 + .../tests/ecma/ExecutionContexts/10.1.4-1.js | 111 + .../tests/ecma/ExecutionContexts/10.1.4-10.js | 105 + .../tests/ecma/ExecutionContexts/10.1.4-2.js | 113 + .../tests/ecma/ExecutionContexts/10.1.4-3.js | 111 + .../tests/ecma/ExecutionContexts/10.1.4-4.js | 113 + .../tests/ecma/ExecutionContexts/10.1.4-5.js | 112 + .../tests/ecma/ExecutionContexts/10.1.4-6.js | 100 + .../tests/ecma/ExecutionContexts/10.1.4-7.js | 112 + .../tests/ecma/ExecutionContexts/10.1.4-8.js | 113 + .../tests/ecma/ExecutionContexts/10.1.5-1.js | 118 + .../tests/ecma/ExecutionContexts/10.1.5-2.js | 100 + .../tests/ecma/ExecutionContexts/10.1.5-3.js | 130 + .../tests/ecma/ExecutionContexts/10.1.5-4.js | 91 + .../tests/ecma/ExecutionContexts/10.1.8-2.js | 120 + .../tests/ecma/ExecutionContexts/10.1.8-3.js | 66 + .../tests/ecma/ExecutionContexts/10.2.1.js | 85 + .../tests/ecma/ExecutionContexts/10.2.2-1.js | 122 + .../tests/ecma/ExecutionContexts/10.2.2-2.js | 133 + .../tests/ecma/ExecutionContexts/10.2.3-1.js | 86 + .../tests/ecma/ExecutionContexts/10.2.3-2.js | 92 + .../tests/ecma/ExecutionContexts/browser.js | 0 .../tests/ecma/ExecutionContexts/shell.js | 1 + .../tests/ecma/Expressions/11.1.1.js | 137 + .../tests/ecma/Expressions/11.10-1.js | 270 + .../tests/ecma/Expressions/11.10-2.js | 269 + .../tests/ecma/Expressions/11.10-3.js | 268 + .../tests/ecma/Expressions/11.12-1.js | 110 + .../tests/ecma/Expressions/11.12-2-n.js | 74 + .../tests/ecma/Expressions/11.12-3.js | 71 + .../tests/ecma/Expressions/11.12-4.js | 71 + .../tests/ecma/Expressions/11.13.1.js | 72 + .../tests/ecma/Expressions/11.13.2-1.js | 231 + .../tests/ecma/Expressions/11.13.2-2.js | 253 + .../tests/ecma/Expressions/11.13.2-3.js | 300 + .../tests/ecma/Expressions/11.13.2-4.js | 137 + .../tests/ecma/Expressions/11.13.2-5.js | 137 + .../tests/ecma/Expressions/11.13.js | 86 + .../tests/ecma/Expressions/11.14-1.js | 73 + .../tests/ecma/Expressions/11.2.1-1.js | 272 + .../tests/ecma/Expressions/11.2.1-2.js | 128 + .../tests/ecma/Expressions/11.2.1-3-n.js | 128 + .../tests/ecma/Expressions/11.2.1-4-n.js | 128 + .../tests/ecma/Expressions/11.2.1-5.js | 128 + .../tests/ecma/Expressions/11.2.2-1-n.js | 104 + .../tests/ecma/Expressions/11.2.2-1.js | 100 + .../tests/ecma/Expressions/11.2.2-10-n.js | 102 + .../tests/ecma/Expressions/11.2.2-11.js | 104 + .../tests/ecma/Expressions/11.2.2-2-n.js | 104 + .../tests/ecma/Expressions/11.2.2-3-n.js | 100 + .../tests/ecma/Expressions/11.2.2-4-n.js | 104 + .../tests/ecma/Expressions/11.2.2-5-n.js | 104 + .../tests/ecma/Expressions/11.2.2-6-n.js | 103 + .../tests/ecma/Expressions/11.2.2-7-n.js | 104 + .../tests/ecma/Expressions/11.2.2-8-n.js | 104 + .../tests/ecma/Expressions/11.2.2-9-n.js | 104 + .../tests/ecma/Expressions/11.2.3-1.js | 125 + .../tests/ecma/Expressions/11.2.3-2-n.js | 94 + .../tests/ecma/Expressions/11.2.3-3-n.js | 91 + .../tests/ecma/Expressions/11.2.3-4-n.js | 91 + .../tests/ecma/Expressions/11.2.3-5.js | 85 + .../tests/ecma/Expressions/11.3.1.js | 153 + .../tests/ecma/Expressions/11.3.2.js | 153 + .../tests/ecma/Expressions/11.4.1.js | 92 + .../tests/ecma/Expressions/11.4.2.js | 83 + .../tests/ecma/Expressions/11.4.3.js | 111 + .../tests/ecma/Expressions/11.4.4.js | 156 + .../tests/ecma/Expressions/11.4.5.js | 154 + .../tests/ecma/Expressions/11.4.6.js | 299 + .../tests/ecma/Expressions/11.4.7-01.js | 299 + .../tests/ecma/Expressions/11.4.7-02.js | 87 + .../tests/ecma/Expressions/11.4.8.js | 215 + .../tests/ecma/Expressions/11.4.9.js | 94 + .../tests/ecma/Expressions/11.5.1.js | 115 + .../tests/ecma/Expressions/11.5.2.js | 154 + .../tests/ecma/Expressions/11.5.3.js | 161 + .../tests/ecma/Expressions/11.6.1-1.js | 160 + .../tests/ecma/Expressions/11.6.1-2.js | 164 + .../tests/ecma/Expressions/11.6.1-3.js | 150 + .../tests/ecma/Expressions/11.6.2-1.js | 165 + .../tests/ecma/Expressions/11.6.3.js | 115 + .../tests/ecma/Expressions/11.7.1.js | 228 + .../tests/ecma/Expressions/11.7.2.js | 246 + .../tests/ecma/Expressions/11.7.3.js | 230 + .../tests/ecma/Expressions/11.8.1.js | 121 + .../tests/ecma/Expressions/11.8.2.js | 121 + .../tests/ecma/Expressions/11.8.3.js | 120 + .../tests/ecma/Expressions/11.8.4.js | 121 + .../tests/ecma/Expressions/11.9.1.js | 159 + .../tests/ecma/Expressions/11.9.2.js | 159 + .../tests/ecma/Expressions/11.9.3.js | 159 + .../tests/ecma/Expressions/browser.js | 0 .../tests/ecma/Expressions/shell.js | 1 + .../tests/ecma/FunctionObjects/15.3.1.1-1.js | 136 + .../tests/ecma/FunctionObjects/15.3.1.1-2.js | 183 + .../tests/ecma/FunctionObjects/15.3.1.1-3.js | 99 + .../tests/ecma/FunctionObjects/15.3.2.1-1.js | 132 + .../tests/ecma/FunctionObjects/15.3.2.1-2.js | 107 + .../tests/ecma/FunctionObjects/15.3.2.1-3.js | 95 + .../tests/ecma/FunctionObjects/15.3.3.1-2.js | 70 + .../tests/ecma/FunctionObjects/15.3.3.1-3.js | 79 + .../tests/ecma/FunctionObjects/15.3.3.1-4.js | 70 + .../tests/ecma/FunctionObjects/15.3.3.2.js | 62 + .../tests/ecma/FunctionObjects/15.3.4-1.js | 94 + .../tests/ecma/FunctionObjects/15.3.4.1.js | 61 + .../tests/ecma/FunctionObjects/15.3.4.js | 81 + .../tests/ecma/FunctionObjects/15.3.5-1.js | 117 + .../tests/ecma/FunctionObjects/15.3.5-2.js | 90 + .../tests/ecma/FunctionObjects/15.3.5.1.js | 83 + .../tests/ecma/FunctionObjects/15.3.5.3.js | 72 + .../tests/ecma/FunctionObjects/browser.js | 0 .../tests/ecma/FunctionObjects/shell.js | 1 + .../tests/ecma/GlobalObject/15.1-1-n.js | 70 + .../tests/ecma/GlobalObject/15.1-2-n.js | 67 + .../tests/ecma/GlobalObject/15.1.1.1.js | 63 + .../tests/ecma/GlobalObject/15.1.1.2.js | 62 + .../tests/ecma/GlobalObject/15.1.2.1-2.js | 66 + .../tests/ecma/GlobalObject/15.1.2.2-1.js | 410 + .../tests/ecma/GlobalObject/15.1.2.2-2.js | 238 + .../tests/ecma/GlobalObject/15.1.2.3-1.js | 441 + .../tests/ecma/GlobalObject/15.1.2.3-2.js | 291 + .../tests/ecma/GlobalObject/15.1.2.4.js | 205 + .../tests/ecma/GlobalObject/15.1.2.5-1.js | 206 + .../tests/ecma/GlobalObject/15.1.2.5-2.js | 183 + .../tests/ecma/GlobalObject/15.1.2.5-3.js | 207 + .../tests/ecma/GlobalObject/15.1.2.6.js | 125 + .../tests/ecma/GlobalObject/15.1.2.7.js | 130 + .../tests/ecma/GlobalObject/browser.js | 0 .../tests/ecma/GlobalObject/shell.js | 1 + .../tests/ecma/LexicalConventions/7.1-1.js | 82 + .../tests/ecma/LexicalConventions/7.1-2.js | 73 + .../tests/ecma/LexicalConventions/7.1-3.js | 89 + .../tests/ecma/LexicalConventions/7.2-1.js | 73 + .../tests/ecma/LexicalConventions/7.2-2-n.js | 74 + .../tests/ecma/LexicalConventions/7.2-3-n.js | 74 + .../tests/ecma/LexicalConventions/7.2-4-n.js | 73 + .../tests/ecma/LexicalConventions/7.2-5-n.js | 72 + .../tests/ecma/LexicalConventions/7.2-6.js | 68 + .../tests/ecma/LexicalConventions/7.3-1.js | 92 + .../tests/ecma/LexicalConventions/7.3-10.js | 65 + .../tests/ecma/LexicalConventions/7.3-11.js | 66 + .../tests/ecma/LexicalConventions/7.3-12.js | 64 + .../tests/ecma/LexicalConventions/7.3-13-n.js | 66 + .../tests/ecma/LexicalConventions/7.3-2.js | 65 + .../tests/ecma/LexicalConventions/7.3-3.js | 65 + .../tests/ecma/LexicalConventions/7.3-4.js | 65 + .../tests/ecma/LexicalConventions/7.3-5.js | 65 + .../tests/ecma/LexicalConventions/7.3-6.js | 65 + .../tests/ecma/LexicalConventions/7.3-7.js | 66 + .../tests/ecma/LexicalConventions/7.3-8.js | 65 + .../tests/ecma/LexicalConventions/7.3-9.js | 65 + .../ecma/LexicalConventions/7.4.1-1-n.js | 71 + .../ecma/LexicalConventions/7.4.1-2-n.js | 71 + .../ecma/LexicalConventions/7.4.1-3-n.js | 69 + .../ecma/LexicalConventions/7.4.2-1-n.js | 77 + .../ecma/LexicalConventions/7.4.2-10-n.js | 77 + .../ecma/LexicalConventions/7.4.2-11-n.js | 77 + .../ecma/LexicalConventions/7.4.2-12-n.js | 77 + .../ecma/LexicalConventions/7.4.2-13-n.js | 77 + .../ecma/LexicalConventions/7.4.2-14-n.js | 77 + .../ecma/LexicalConventions/7.4.2-15-n.js | 77 + .../ecma/LexicalConventions/7.4.2-16-n.js | 77 + .../ecma/LexicalConventions/7.4.2-2-n.js | 77 + .../ecma/LexicalConventions/7.4.2-3-n.js | 77 + .../ecma/LexicalConventions/7.4.2-4-n.js | 77 + .../ecma/LexicalConventions/7.4.2-5-n.js | 77 + .../ecma/LexicalConventions/7.4.2-6-n.js | 77 + .../ecma/LexicalConventions/7.4.2-7-n.js | 75 + .../ecma/LexicalConventions/7.4.2-8-n.js | 76 + .../ecma/LexicalConventions/7.4.2-9-n.js | 77 + .../ecma/LexicalConventions/7.4.3-1-n.js | 71 + .../ecma/LexicalConventions/7.4.3-10-n.js | 71 + .../ecma/LexicalConventions/7.4.3-11-n.js | 71 + .../ecma/LexicalConventions/7.4.3-12-n.js | 71 + .../ecma/LexicalConventions/7.4.3-13-n.js | 71 + .../ecma/LexicalConventions/7.4.3-14-n.js | 97 + .../ecma/LexicalConventions/7.4.3-15-n.js | 97 + .../ecma/LexicalConventions/7.4.3-16-n.js | 88 + .../ecma/LexicalConventions/7.4.3-2-n.js | 71 + .../ecma/LexicalConventions/7.4.3-3-n.js | 71 + .../ecma/LexicalConventions/7.4.3-4-n.js | 96 + .../ecma/LexicalConventions/7.4.3-5-n.js | 71 + .../ecma/LexicalConventions/7.4.3-6-n.js | 71 + .../ecma/LexicalConventions/7.4.3-7-n.js | 97 + .../ecma/LexicalConventions/7.4.3-8-n.js | 71 + .../ecma/LexicalConventions/7.4.3-9-n.js | 98 + .../tests/ecma/LexicalConventions/7.5-1.js | 62 + .../tests/ecma/LexicalConventions/7.5-10-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-2-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-3-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-4-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-5-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-6.js | 61 + .../tests/ecma/LexicalConventions/7.5-7.js | 61 + .../tests/ecma/LexicalConventions/7.5-8-n.js | 64 + .../tests/ecma/LexicalConventions/7.5-9-n.js | 64 + .../tests/ecma/LexicalConventions/7.6.js | 313 + .../tests/ecma/LexicalConventions/7.7.1.js | 64 + .../tests/ecma/LexicalConventions/7.7.2.js | 71 + .../tests/ecma/LexicalConventions/7.7.3-1.js | 198 + .../tests/ecma/LexicalConventions/7.7.3-2.js | 93 + .../tests/ecma/LexicalConventions/7.7.3.js | 331 + .../tests/ecma/LexicalConventions/7.7.4.js | 269 + .../tests/ecma/LexicalConventions/7.8.2-n.js | 63 + .../tests/ecma/LexicalConventions/browser.js | 0 .../tests/ecma/LexicalConventions/shell.js | 1 + .../tests/ecma/Math/15.8-2-n.js | 82 + .../tests/ecma/Math/15.8-3-n.js | 81 + .../tests/ecma/Math/15.8.1.1-1.js | 64 + .../tests/ecma/Math/15.8.1.1-2.js | 69 + .../tests/ecma/Math/15.8.1.2-1.js | 64 + .../tests/ecma/Math/15.8.1.2-2.js | 70 + .../tests/ecma/Math/15.8.1.3-1.js | 65 + .../tests/ecma/Math/15.8.1.3-2.js | 72 + .../tests/ecma/Math/15.8.1.4-1.js | 65 + .../tests/ecma/Math/15.8.1.4-2.js | 69 + .../tests/ecma/Math/15.8.1.5-1.js | 66 + .../tests/ecma/Math/15.8.1.5-2.js | 70 + .../tests/ecma/Math/15.8.1.6-1.js | 65 + .../tests/ecma/Math/15.8.1.6-2.js | 70 + .../tests/ecma/Math/15.8.1.7-1.js | 65 + .../tests/ecma/Math/15.8.1.7-2.js | 70 + .../tests/ecma/Math/15.8.1.8-1.js | 65 + .../tests/ecma/Math/15.8.1.8-2.js | 69 + .../tests/ecma/Math/15.8.1.8-3.js | 63 + .../tests/ecma/Math/15.8.1.js | 149 + .../tests/ecma/Math/15.8.2.1.js | 226 + .../tests/ecma/Math/15.8.2.10.js | 153 + .../tests/ecma/Math/15.8.2.11.js | 200 + .../tests/ecma/Math/15.8.2.12.js | 177 + .../tests/ecma/Math/15.8.2.13.js | 385 + .../tests/ecma/Math/15.8.2.14.js | 79 + .../tests/ecma/Math/15.8.2.15.js | 202 + .../tests/ecma/Math/15.8.2.16.js | 132 + .../tests/ecma/Math/15.8.2.17.js | 217 + .../tests/ecma/Math/15.8.2.18.js | 165 + .../tests/ecma/Math/15.8.2.2.js | 151 + .../tests/ecma/Math/15.8.2.3.js | 158 + .../tests/ecma/Math/15.8.2.4.js | 156 + .../tests/ecma/Math/15.8.2.5.js | 244 + .../tests/ecma/Math/15.8.2.6.js | 232 + .../tests/ecma/Math/15.8.2.7.js | 283 + .../tests/ecma/Math/15.8.2.8.js | 134 + .../tests/ecma/Math/15.8.2.9.js | 191 + .../tests/ecma/Math/browser.js | 0 .../tests/ecma/Math/shell.js | 1 + .../tests/ecma/NativeObjects/browser.js | 0 .../tests/ecma/NativeObjects/shell.js | 1 + .../tests/ecma/Number/15.7.1.js | 88 + .../tests/ecma/Number/15.7.2.js | 168 + .../tests/ecma/Number/15.7.3.1-1.js | 71 + .../tests/ecma/Number/15.7.3.1-2.js | 71 + .../tests/ecma/Number/15.7.3.1-3.js | 67 + .../tests/ecma/Number/15.7.3.2-1.js | 65 + .../tests/ecma/Number/15.7.3.2-2.js | 70 + .../tests/ecma/Number/15.7.3.2-3.js | 67 + .../tests/ecma/Number/15.7.3.2-4.js | 64 + .../tests/ecma/Number/15.7.3.3-1.js | 68 + .../tests/ecma/Number/15.7.3.3-2.js | 73 + .../tests/ecma/Number/15.7.3.3-3.js | 64 + .../tests/ecma/Number/15.7.3.3-4.js | 66 + .../tests/ecma/Number/15.7.3.4-1.js | 66 + .../tests/ecma/Number/15.7.3.4-2.js | 71 + .../tests/ecma/Number/15.7.3.4-3.js | 65 + .../tests/ecma/Number/15.7.3.4-4.js | 66 + .../tests/ecma/Number/15.7.3.5-1.js | 64 + .../tests/ecma/Number/15.7.3.5-2.js | 70 + .../tests/ecma/Number/15.7.3.5-3.js | 65 + .../tests/ecma/Number/15.7.3.5-4.js | 66 + .../tests/ecma/Number/15.7.3.6-1.js | 65 + .../tests/ecma/Number/15.7.3.6-2.js | 69 + .../tests/ecma/Number/15.7.3.6-3.js | 65 + .../tests/ecma/Number/15.7.3.6-4.js | 66 + .../tests/ecma/Number/15.7.3.js | 69 + .../tests/ecma/Number/15.7.4-1.js | 60 + .../tests/ecma/Number/15.7.4.1.js | 62 + .../tests/ecma/Number/15.7.4.2-1.js | 111 + .../tests/ecma/Number/15.7.4.2-2-n.js | 76 + .../tests/ecma/Number/15.7.4.2-3-n.js | 73 + .../tests/ecma/Number/15.7.4.2-4.js | 70 + .../tests/ecma/Number/15.7.4.3-1.js | 97 + .../tests/ecma/Number/15.7.4.3-2.js | 65 + .../tests/ecma/Number/15.7.4.3-3-n.js | 72 + .../tests/ecma/Number/browser.js | 0 .../tests/ecma/Number/shell.js | 1 + .../tests/ecma/ObjectObjects/15.2.1.1.js | 146 + .../tests/ecma/ObjectObjects/15.2.1.2.js | 81 + .../tests/ecma/ObjectObjects/15.2.2.1.js | 138 + .../tests/ecma/ObjectObjects/15.2.2.2.js | 74 + .../tests/ecma/ObjectObjects/15.2.3-1.js | 64 + .../tests/ecma/ObjectObjects/15.2.3.1-1.js | 69 + .../tests/ecma/ObjectObjects/15.2.3.1-2.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.1-3.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.1-4.js | 70 + .../tests/ecma/ObjectObjects/15.2.3.js | 67 + .../tests/ecma/ObjectObjects/15.2.4.1.js | 64 + .../tests/ecma/ObjectObjects/15.2.4.2.js | 130 + .../tests/ecma/ObjectObjects/15.2.4.3.js | 117 + .../tests/ecma/ObjectObjects/browser.js | 0 .../tests/ecma/ObjectObjects/shell.js | 1 + .../auto/qscriptjstestsuite/tests/ecma/README | 1 + .../tests/ecma/SourceText/6-1.js | 128 + .../tests/ecma/SourceText/6-2.js | 131 + .../tests/ecma/SourceText/browser.js | 0 .../tests/ecma/SourceText/shell.js | 1 + .../tests/ecma/Statements/12.10-1.js | 151 + .../tests/ecma/Statements/12.10.js | 61 + .../tests/ecma/Statements/12.2-1.js | 74 + .../tests/ecma/Statements/12.5-1.js | 102 + .../tests/ecma/Statements/12.5-2.js | 99 + .../tests/ecma/Statements/12.6.1-1.js | 74 + .../tests/ecma/Statements/12.6.2-1.js | 75 + .../tests/ecma/Statements/12.6.2-2.js | 76 + .../tests/ecma/Statements/12.6.2-3.js | 72 + .../tests/ecma/Statements/12.6.2-4.js | 72 + .../tests/ecma/Statements/12.6.2-5.js | 73 + .../tests/ecma/Statements/12.6.2-6.js | 75 + .../tests/ecma/Statements/12.6.2-7.js | 73 + .../tests/ecma/Statements/12.6.2-8.js | 71 + .../tests/ecma/Statements/12.6.2-9-n.js | 76 + .../tests/ecma/Statements/12.6.3-1.js | 63 + .../tests/ecma/Statements/12.6.3-10.js | 115 + .../tests/ecma/Statements/12.6.3-11.js | 98 + .../tests/ecma/Statements/12.6.3-12.js | 103 + .../tests/ecma/Statements/12.6.3-19.js | 117 + .../tests/ecma/Statements/12.6.3-2.js | 63 + .../tests/ecma/Statements/12.6.3-3.js | 73 + .../tests/ecma/Statements/12.6.3-4.js | 202 + .../tests/ecma/Statements/12.6.3-5-n.js | 110 + .../tests/ecma/Statements/12.6.3-6-n.js | 109 + .../tests/ecma/Statements/12.6.3-7-n.js | 110 + .../tests/ecma/Statements/12.6.3-8-n.js | 110 + .../tests/ecma/Statements/12.6.3-9-n.js | 109 + .../tests/ecma/Statements/12.7-1-n.js | 64 + .../tests/ecma/Statements/12.8-1-n.js | 67 + .../tests/ecma/Statements/12.9-1-n.js | 63 + .../tests/ecma/Statements/browser.js | 0 .../tests/ecma/Statements/shell.js | 1 + .../tests/ecma/String/15.5.1.js | 134 + .../tests/ecma/String/15.5.2.js | 110 + .../tests/ecma/String/15.5.3.1-1.js | 71 + .../tests/ecma/String/15.5.3.1-2.js | 69 + .../tests/ecma/String/15.5.3.1-3.js | 66 + .../tests/ecma/String/15.5.3.1-4.js | 66 + .../tests/ecma/String/15.5.3.2-1.js | 190 + .../tests/ecma/String/15.5.3.2-2.js | 77 + .../tests/ecma/String/15.5.3.2-3.js | 121 + .../tests/ecma/String/15.5.3.js | 66 + .../tests/ecma/String/15.5.4.1.js | 63 + .../tests/ecma/String/15.5.4.10-1.js | 217 + .../tests/ecma/String/15.5.4.11-1.js | 518 + .../tests/ecma/String/15.5.4.11-2.js | 515 + .../tests/ecma/String/15.5.4.11-3.js | 514 + .../tests/ecma/String/15.5.4.11-4.js | 507 + .../tests/ecma/String/15.5.4.11-5.js | 520 + .../tests/ecma/String/15.5.4.11-6.js | 516 + .../tests/ecma/String/15.5.4.12-1.js | 520 + .../tests/ecma/String/15.5.4.12-2.js | 518 + .../tests/ecma/String/15.5.4.12-3.js | 559 + .../tests/ecma/String/15.5.4.12-4.js | 515 + .../tests/ecma/String/15.5.4.12-5.js | 515 + .../tests/ecma/String/15.5.4.2-1.js | 72 + .../tests/ecma/String/15.5.4.2-2-n.js | 73 + .../tests/ecma/String/15.5.4.2-3.js | 83 + .../tests/ecma/String/15.5.4.2.js | 87 + .../tests/ecma/String/15.5.4.3-1.js | 72 + .../tests/ecma/String/15.5.4.3-2.js | 90 + .../tests/ecma/String/15.5.4.3-3-n.js | 72 + .../tests/ecma/String/15.5.4.4-1.js | 92 + .../tests/ecma/String/15.5.4.4-2.js | 136 + .../tests/ecma/String/15.5.4.4-3.js | 112 + .../tests/ecma/String/15.5.4.4-4.js | 124 + .../tests/ecma/String/15.5.4.5-1.js | 87 + .../tests/ecma/String/15.5.4.5-2.js | 121 + .../tests/ecma/String/15.5.4.5-3.js | 131 + .../tests/ecma/String/15.5.4.5-4.js | 75 + .../tests/ecma/String/15.5.4.5-5.js | 106 + .../tests/ecma/String/15.5.4.6-1.js | 155 + .../tests/ecma/String/15.5.4.6-2.js | 259 + .../tests/ecma/String/15.5.4.7-1.js | 219 + .../tests/ecma/String/15.5.4.7-2.js | 217 + .../tests/ecma/String/15.5.4.8-1.js | 232 + .../tests/ecma/String/15.5.4.8-2.js | 247 + .../tests/ecma/String/15.5.4.8-3.js | 204 + .../tests/ecma/String/15.5.4.9-1.js | 202 + .../tests/ecma/String/15.5.4.js | 108 + .../tests/ecma/String/15.5.5.1.js | 88 + .../tests/ecma/String/browser.js | 0 .../tests/ecma/String/shell.js | 1 + .../tests/ecma/TypeConversion/9.2.js | 138 + .../tests/ecma/TypeConversion/9.3-1.js | 100 + .../tests/ecma/TypeConversion/9.3.1-1.js | 323 + .../tests/ecma/TypeConversion/9.3.1-2.js | 87 + .../tests/ecma/TypeConversion/9.3.1-3.js | 743 + .../tests/ecma/TypeConversion/9.3.js | 87 + .../tests/ecma/TypeConversion/9.4-1.js | 112 + .../tests/ecma/TypeConversion/9.4-2.js | 112 + .../tests/ecma/TypeConversion/9.5-2.js | 173 + .../tests/ecma/TypeConversion/9.6.js | 140 + .../tests/ecma/TypeConversion/9.7.js | 160 + .../tests/ecma/TypeConversion/9.8.1.js | 167 + .../tests/ecma/TypeConversion/9.9-1.js | 119 + .../tests/ecma/TypeConversion/browser.js | 0 .../tests/ecma/TypeConversion/shell.js | 1 + .../tests/ecma/Types/8.1.js | 75 + .../tests/ecma/Types/8.4.js | 130 + .../tests/ecma/Types/8.6.2.1-1.js | 78 + .../tests/ecma/Types/browser.js | 0 .../tests/ecma/Types/shell.js | 1 + .../qscriptjstestsuite/tests/ecma/browser.js | 62 + .../tests/ecma/extensions/10.1.4-9.js | 110 + .../tests/ecma/extensions/10.1.6.js | 127 + .../tests/ecma/extensions/10.1.8-1.js | 135 + .../tests/ecma/extensions/11.6.1-1.js | 145 + .../tests/ecma/extensions/11.6.1-2.js | 136 + .../tests/ecma/extensions/11.6.1-3.js | 137 + .../tests/ecma/extensions/11.6.2-1.js | 124 + .../tests/ecma/extensions/15-1.js | 94 + .../tests/ecma/extensions/15-2.js | 77 + .../tests/ecma/extensions/15.1.2.1-1.js | 88 + .../tests/ecma/extensions/15.2.1.1.js | 82 + .../tests/ecma/extensions/15.2.3-1.js | 64 + .../tests/ecma/extensions/15.2.4.js | 66 + .../tests/ecma/extensions/15.3.1.1-1.js | 82 + .../tests/ecma/extensions/15.3.1.1-2.js | 82 + .../tests/ecma/extensions/15.3.2.1-1.js | 72 + .../tests/ecma/extensions/15.3.2.1-2.js | 72 + .../tests/ecma/extensions/15.3.3.1-1.js | 67 + .../tests/ecma/extensions/15.4.3.js | 63 + .../tests/ecma/extensions/15.5.3.js | 66 + .../tests/ecma/extensions/15.5.4.2.js | 59 + .../tests/ecma/extensions/15.5.4.4-4.js | 107 + .../tests/ecma/extensions/15.5.4.5-6.js | 94 + .../tests/ecma/extensions/15.5.4.7-3.js | 161 + .../tests/ecma/extensions/15.6.3.1-5.js | 58 + .../tests/ecma/extensions/15.6.3.js | 65 + .../tests/ecma/extensions/15.6.4-2.js | 66 + .../tests/ecma/extensions/15.7.3.js | 69 + .../tests/ecma/extensions/15.7.4.js | 90 + .../tests/ecma/extensions/15.8-1.js | 84 + .../tests/ecma/extensions/15.9.5.js | 76 + .../tests/ecma/extensions/8.6.2.1-1.js | 98 + .../tests/ecma/extensions/9.9-1.js | 102 + .../tests/ecma/extensions/browser.js | 0 .../tests/ecma/extensions/shell.js | 1 + .../qscriptjstestsuite/tests/ecma/jsref.js | 634 + .../qscriptjstestsuite/tests/ecma/shell.js | 577 + .../qscriptjstestsuite/tests/ecma/template.js | 70 + .../tests/ecma_2/Exceptions/boolean-001.js | 80 + .../tests/ecma_2/Exceptions/boolean-002.js | 84 + .../tests/ecma_2/Exceptions/browser.js | 0 .../tests/ecma_2/Exceptions/date-001.js | 93 + .../tests/ecma_2/Exceptions/date-002.js | 87 + .../tests/ecma_2/Exceptions/date-003.js | 89 + .../tests/ecma_2/Exceptions/date-004.js | 83 + .../tests/ecma_2/Exceptions/exception-001.js | 78 + .../tests/ecma_2/Exceptions/exception-002.js | 78 + .../tests/ecma_2/Exceptions/exception-003.js | 82 + .../tests/ecma_2/Exceptions/exception-004.js | 78 + .../tests/ecma_2/Exceptions/exception-005.js | 78 + .../tests/ecma_2/Exceptions/exception-006.js | 89 + .../tests/ecma_2/Exceptions/exception-007.js | 90 + .../tests/ecma_2/Exceptions/exception-008.js | 77 + .../tests/ecma_2/Exceptions/exception-009.js | 86 + .../ecma_2/Exceptions/exception-010-n.js | 61 + .../ecma_2/Exceptions/exception-011-n.js | 62 + .../tests/ecma_2/Exceptions/expression-001.js | 83 + .../tests/ecma_2/Exceptions/expression-002.js | 93 + .../tests/ecma_2/Exceptions/expression-003.js | 88 + .../tests/ecma_2/Exceptions/expression-004.js | 82 + .../tests/ecma_2/Exceptions/expression-005.js | 74 + .../tests/ecma_2/Exceptions/expression-006.js | 79 + .../tests/ecma_2/Exceptions/expression-007.js | 77 + .../tests/ecma_2/Exceptions/expression-008.js | 74 + .../tests/ecma_2/Exceptions/expression-009.js | 75 + .../tests/ecma_2/Exceptions/expression-010.js | 76 + .../tests/ecma_2/Exceptions/expression-011.js | 76 + .../tests/ecma_2/Exceptions/expression-012.js | 77 + .../tests/ecma_2/Exceptions/expression-013.js | 77 + .../tests/ecma_2/Exceptions/expression-014.js | 79 + .../tests/ecma_2/Exceptions/expression-015.js | 73 + .../tests/ecma_2/Exceptions/expression-016.js | 73 + .../tests/ecma_2/Exceptions/expression-017.js | 73 + .../tests/ecma_2/Exceptions/expression-019.js | 77 + .../tests/ecma_2/Exceptions/function-001.js | 86 + .../tests/ecma_2/Exceptions/global-001.js | 78 + .../tests/ecma_2/Exceptions/global-002.js | 78 + .../tests/ecma_2/Exceptions/lexical-001.js | 85 + .../tests/ecma_2/Exceptions/lexical-002.js | 85 + .../tests/ecma_2/Exceptions/lexical-003.js | 76 + .../tests/ecma_2/Exceptions/lexical-004.js | 85 + .../tests/ecma_2/Exceptions/lexical-005.js | 85 + .../tests/ecma_2/Exceptions/lexical-006.js | 91 + .../tests/ecma_2/Exceptions/lexical-007.js | 84 + .../tests/ecma_2/Exceptions/lexical-008.js | 86 + .../tests/ecma_2/Exceptions/lexical-009.js | 86 + .../tests/ecma_2/Exceptions/lexical-010.js | 84 + .../tests/ecma_2/Exceptions/lexical-011.js | 95 + .../tests/ecma_2/Exceptions/lexical-012.js | 86 + .../tests/ecma_2/Exceptions/lexical-013.js | 86 + .../tests/ecma_2/Exceptions/lexical-014.js | 95 + .../tests/ecma_2/Exceptions/lexical-015.js | 86 + .../tests/ecma_2/Exceptions/lexical-016.js | 95 + .../tests/ecma_2/Exceptions/lexical-017.js | 87 + .../tests/ecma_2/Exceptions/lexical-018.js | 86 + .../tests/ecma_2/Exceptions/lexical-019.js | 86 + .../tests/ecma_2/Exceptions/lexical-020.js | 86 + .../tests/ecma_2/Exceptions/lexical-021.js | 95 + .../tests/ecma_2/Exceptions/lexical-022.js | 86 + .../tests/ecma_2/Exceptions/lexical-023.js | 85 + .../tests/ecma_2/Exceptions/lexical-024.js | 92 + .../tests/ecma_2/Exceptions/lexical-025.js | 92 + .../tests/ecma_2/Exceptions/lexical-026.js | 92 + .../tests/ecma_2/Exceptions/lexical-027.js | 94 + .../tests/ecma_2/Exceptions/lexical-028.js | 92 + .../tests/ecma_2/Exceptions/lexical-029.js | 92 + .../tests/ecma_2/Exceptions/lexical-030.js | 92 + .../tests/ecma_2/Exceptions/lexical-031.js | 92 + .../tests/ecma_2/Exceptions/lexical-032.js | 92 + .../tests/ecma_2/Exceptions/lexical-033.js | 92 + .../tests/ecma_2/Exceptions/lexical-034.js | 91 + .../tests/ecma_2/Exceptions/lexical-035.js | 92 + .../tests/ecma_2/Exceptions/lexical-036.js | 92 + .../tests/ecma_2/Exceptions/lexical-037.js | 92 + .../tests/ecma_2/Exceptions/lexical-038.js | 92 + .../tests/ecma_2/Exceptions/lexical-039.js | 79 + .../tests/ecma_2/Exceptions/lexical-040.js | 79 + .../tests/ecma_2/Exceptions/lexical-041.js | 81 + .../tests/ecma_2/Exceptions/lexical-042.js | 82 + .../tests/ecma_2/Exceptions/lexical-047.js | 83 + .../tests/ecma_2/Exceptions/lexical-048.js | 77 + .../tests/ecma_2/Exceptions/lexical-049.js | 82 + .../tests/ecma_2/Exceptions/lexical-050.js | 78 + .../tests/ecma_2/Exceptions/lexical-051.js | 78 + .../tests/ecma_2/Exceptions/lexical-052.js | 80 + .../tests/ecma_2/Exceptions/lexical-053.js | 78 + .../tests/ecma_2/Exceptions/lexical-054.js | 79 + .../tests/ecma_2/Exceptions/number-001.js | 86 + .../tests/ecma_2/Exceptions/number-002.js | 81 + .../tests/ecma_2/Exceptions/number-003.js | 83 + .../tests/ecma_2/Exceptions/shell.js | 1 + .../tests/ecma_2/Exceptions/statement-001.js | 80 + .../tests/ecma_2/Exceptions/statement-002.js | 102 + .../tests/ecma_2/Exceptions/statement-003.js | 113 + .../tests/ecma_2/Exceptions/statement-004.js | 85 + .../tests/ecma_2/Exceptions/statement-005.js | 84 + .../tests/ecma_2/Exceptions/statement-006.js | 84 + .../tests/ecma_2/Exceptions/statement-007.js | 75 + .../tests/ecma_2/Exceptions/statement-008.js | 75 + .../tests/ecma_2/Exceptions/statement-009.js | 74 + .../tests/ecma_2/Exceptions/string-001.js | 86 + .../tests/ecma_2/Exceptions/string-002.js | 85 + .../ecma_2/Expressions/StrictEquality-001.js | 106 + .../tests/ecma_2/Expressions/browser.js | 0 .../tests/ecma_2/Expressions/shell.js | 1 + .../ecma_2/FunctionObjects/apply-001-n.js | 65 + .../tests/ecma_2/FunctionObjects/browser.js | 0 .../tests/ecma_2/FunctionObjects/call-1.js | 75 + .../tests/ecma_2/FunctionObjects/shell.js | 1 + .../ecma_2/LexicalConventions/browser.js | 0 .../ecma_2/LexicalConventions/keywords-001.js | 81 + .../LexicalConventions/regexp-literals-001.js | 77 + .../LexicalConventions/regexp-literals-002.js | 61 + .../tests/ecma_2/LexicalConventions/shell.js | 1 + .../qscriptjstestsuite/tests/ecma_2/README | 1 + .../tests/ecma_2/RegExp/browser.js | 0 .../tests/ecma_2/RegExp/constructor-001.js | 99 + .../tests/ecma_2/RegExp/exec-001.js | 73 + .../tests/ecma_2/RegExp/exec-002.js | 221 + .../tests/ecma_2/RegExp/function-001.js | 99 + .../tests/ecma_2/RegExp/hex-001.js | 102 + .../tests/ecma_2/RegExp/multiline-001.js | 101 + .../tests/ecma_2/RegExp/octal-001.js | 111 + .../tests/ecma_2/RegExp/octal-002.js | 126 + .../tests/ecma_2/RegExp/octal-003.js | 120 + .../tests/ecma_2/RegExp/properties-001.js | 124 + .../tests/ecma_2/RegExp/properties-002.js | 162 + .../ecma_2/RegExp/regexp-enumerate-001.js | 121 + .../tests/ecma_2/RegExp/regress-001.js | 78 + .../tests/ecma_2/RegExp/shell.js | 1 + .../tests/ecma_2/RegExp/unicode-001.js | 92 + .../tests/ecma_2/Statements/browser.js | 0 .../tests/ecma_2/Statements/dowhile-001.js | 77 + .../tests/ecma_2/Statements/dowhile-002.js | 104 + .../tests/ecma_2/Statements/dowhile-003.js | 96 + .../tests/ecma_2/Statements/dowhile-004.js | 100 + .../tests/ecma_2/Statements/dowhile-005.js | 106 + .../tests/ecma_2/Statements/dowhile-006.js | 122 + .../tests/ecma_2/Statements/dowhile-007.js | 130 + .../tests/ecma_2/Statements/forin-001.js | 330 + .../tests/ecma_2/Statements/forin-002.js | 109 + .../tests/ecma_2/Statements/if-001.js | 75 + .../tests/ecma_2/Statements/label-001.js | 75 + .../tests/ecma_2/Statements/label-002.js | 89 + .../tests/ecma_2/Statements/shell.js | 1 + .../tests/ecma_2/Statements/switch-001.js | 98 + .../tests/ecma_2/Statements/switch-002.js | 96 + .../tests/ecma_2/Statements/switch-003.js | 90 + .../tests/ecma_2/Statements/switch-004.js | 127 + .../tests/ecma_2/Statements/try-001.js | 118 + .../tests/ecma_2/Statements/try-003.js | 115 + .../tests/ecma_2/Statements/try-004.js | 87 + .../tests/ecma_2/Statements/try-005.js | 90 + .../tests/ecma_2/Statements/try-006.js | 120 + .../tests/ecma_2/Statements/try-007.js | 125 + .../tests/ecma_2/Statements/try-008.js | 92 + .../tests/ecma_2/Statements/try-009.js | 99 + .../tests/ecma_2/Statements/try-010.js | 106 + .../tests/ecma_2/Statements/try-012.js | 128 + .../tests/ecma_2/Statements/while-001.js | 75 + .../tests/ecma_2/Statements/while-002.js | 119 + .../tests/ecma_2/Statements/while-003.js | 120 + .../tests/ecma_2/Statements/while-004.js | 250 + .../tests/ecma_2/String/browser.js | 0 .../tests/ecma_2/String/match-001.js | 139 + .../tests/ecma_2/String/match-002.js | 207 + .../tests/ecma_2/String/match-003.js | 165 + .../tests/ecma_2/String/match-004.js | 206 + .../tests/ecma_2/String/replace-001.js | 99 + .../tests/ecma_2/String/shell.js | 1 + .../tests/ecma_2/String/split-001.js | 145 + .../tests/ecma_2/String/split-002.js | 303 + .../tests/ecma_2/String/split-003.js | 156 + .../tests/ecma_2/browser.js | 37 + .../tests/ecma_2/extensions/browser.js | 0 .../ecma_2/extensions/constructor-001.js | 74 + .../tests/ecma_2/extensions/function-001.js | 74 + .../tests/ecma_2/extensions/instanceof-001.js | 144 + .../tests/ecma_2/extensions/instanceof-002.js | 160 + .../ecma_2/extensions/instanceof-003-n.js | 121 + .../ecma_2/extensions/instanceof-004-n.js | 121 + .../ecma_2/extensions/instanceof-005-n.js | 122 + .../tests/ecma_2/extensions/instanceof-006.js | 119 + .../tests/ecma_2/extensions/shell.js | 1 + .../tests/ecma_2/instanceof/browser.js | 0 .../tests/ecma_2/instanceof/instanceof-001.js | 67 + .../tests/ecma_2/instanceof/instanceof-002.js | 84 + .../tests/ecma_2/instanceof/instanceof-003.js | 98 + .../tests/ecma_2/instanceof/regress-7635.js | 88 + .../tests/ecma_2/instanceof/shell.js | 1 + .../qscriptjstestsuite/tests/ecma_2/jsref.js | 591 + .../qscriptjstestsuite/tests/ecma_2/shell.js | 51 + .../tests/ecma_2/template.js | 57 + .../tests/ecma_3/Array/15.4.4.11-01.js | 61 + .../tests/ecma_3/Array/15.4.4.3-1.js | 88 + .../tests/ecma_3/Array/15.4.4.4-001.js | 153 + .../tests/ecma_3/Array/15.4.5.1-01.js | 93 + .../tests/ecma_3/Array/browser.js | 0 .../tests/ecma_3/Array/regress-101488.js | 172 + .../tests/ecma_3/Array/regress-130451.js | 219 + .../tests/ecma_3/Array/regress-322135-01.js | 73 + .../tests/ecma_3/Array/regress-322135-02.js | 65 + .../tests/ecma_3/Array/regress-322135-03.js | 73 + .../tests/ecma_3/Array/regress-322135-04.js | 71 + .../tests/ecma_3/Array/regress-387501.js | 94 + .../tests/ecma_3/Array/regress-421325.js | 67 + .../tests/ecma_3/Array/regress-430717.js | 65 + .../tests/ecma_3/Array/shell.js | 1 + .../tests/ecma_3/Date/15.9.1.2-01.js | 62 + .../tests/ecma_3/Date/15.9.3.2-1.js | 91 + .../tests/ecma_3/Date/15.9.4.3.js | 233 + .../tests/ecma_3/Date/15.9.5.3.js | 152 + .../tests/ecma_3/Date/15.9.5.4.js | 185 + .../tests/ecma_3/Date/15.9.5.5-02.js | 88 + .../tests/ecma_3/Date/15.9.5.5.js | 144 + .../tests/ecma_3/Date/15.9.5.6.js | 153 + .../tests/ecma_3/Date/15.9.5.7.js | 142 + .../tests/ecma_3/Date/browser.js | 37 + .../tests/ecma_3/Date/shell.js | 564 + .../tests/ecma_3/Exceptions/15.11.1.1.js | 137 + .../tests/ecma_3/Exceptions/15.11.4.4-1.js | 174 + .../tests/ecma_3/Exceptions/15.11.7.6-001.js | 130 + .../tests/ecma_3/Exceptions/15.11.7.6-002.js | 132 + .../tests/ecma_3/Exceptions/15.11.7.6-003.js | 132 + .../tests/ecma_3/Exceptions/binding-001.js | 128 + .../tests/ecma_3/Exceptions/browser.js | 0 .../tests/ecma_3/Exceptions/regress-181654.js | 155 + .../tests/ecma_3/Exceptions/regress-181914.js | 194 + .../tests/ecma_3/Exceptions/regress-58946.js | 71 + .../tests/ecma_3/Exceptions/regress-95101.js | 118 + .../tests/ecma_3/Exceptions/shell.js | 1 + .../ecma_3/ExecutionContexts/10.1.3-1.js | 201 + .../ecma_3/ExecutionContexts/10.1.3-2.js | 70 + .../tests/ecma_3/ExecutionContexts/10.1.3.js | 73 + .../ecma_3/ExecutionContexts/10.1.4-1.js | 85 + .../ecma_3/ExecutionContexts/10.6.1-01.js | 136 + .../tests/ecma_3/ExecutionContexts/browser.js | 0 .../ecma_3/ExecutionContexts/regress-23346.js | 71 + .../ExecutionContexts/regress-448595-01.js | 91 + .../tests/ecma_3/ExecutionContexts/shell.js | 1 + .../tests/ecma_3/Expressions/11.10-01.js | 76 + .../tests/ecma_3/Expressions/11.10-02.js | 76 + .../tests/ecma_3/Expressions/11.10-03.js | 76 + .../tests/ecma_3/Expressions/11.6.1-1.js | 176 + .../tests/ecma_3/Expressions/11.7.1-01.js | 76 + .../tests/ecma_3/Expressions/11.7.2-01.js | 76 + .../tests/ecma_3/Expressions/11.7.3-01.js | 76 + .../tests/ecma_3/Expressions/11.9.6-1.js | 213 + .../tests/ecma_3/Expressions/browser.js | 0 .../tests/ecma_3/Expressions/shell.js | 1 + .../tests/ecma_3/FunExpr/browser.js | 0 .../tests/ecma_3/FunExpr/fe-001-n.js | 58 + .../tests/ecma_3/FunExpr/fe-001.js | 57 + .../tests/ecma_3/FunExpr/fe-002.js | 61 + .../tests/ecma_3/FunExpr/shell.js | 1 + .../tests/ecma_3/Function/15.3.4.3-1.js | 210 + .../tests/ecma_3/Function/15.3.4.4-1.js | 185 + .../tests/ecma_3/Function/arguments-001.js | 169 + .../tests/ecma_3/Function/arguments-002.js | 73 + .../tests/ecma_3/Function/browser.js | 0 .../tests/ecma_3/Function/call-001.js | 153 + .../tests/ecma_3/Function/regress-131964.js | 196 + .../tests/ecma_3/Function/regress-137181.js | 113 + .../tests/ecma_3/Function/regress-193555.js | 136 + .../tests/ecma_3/Function/regress-313570.js | 63 + .../tests/ecma_3/Function/regress-49286.js | 137 + .../tests/ecma_3/Function/regress-58274.js | 226 + .../tests/ecma_3/Function/regress-85880.js | 173 + .../tests/ecma_3/Function/regress-94506.js | 163 + .../tests/ecma_3/Function/regress-97921.js | 152 + .../tests/ecma_3/Function/scope-001.js | 265 + .../tests/ecma_3/Function/scope-002.js | 245 + .../tests/ecma_3/Function/shell.js | 1 + .../tests/ecma_3/LexicalConventions/7.9.1.js | 157 + .../ecma_3/LexicalConventions/browser.js | 0 .../tests/ecma_3/LexicalConventions/shell.js | 1 + .../tests/ecma_3/Number/15.7.4.2-01.js | 77 + .../tests/ecma_3/Number/15.7.4.3-01.js | 69 + .../tests/ecma_3/Number/15.7.4.3-02.js | 53 + .../tests/ecma_3/Number/15.7.4.5-1.js | 145 + .../tests/ecma_3/Number/15.7.4.6-1.js | 134 + .../tests/ecma_3/Number/15.7.4.7-1.js | 139 + .../tests/ecma_3/Number/15.7.4.7-2.js | 72 + .../tests/ecma_3/Number/browser.js | 0 .../tests/ecma_3/Number/regress-442242-01.js | 62 + .../tests/ecma_3/Number/shell.js | 1 + .../tests/ecma_3/NumberFormatting/browser.js | 0 .../tests/ecma_3/NumberFormatting/shell.js | 1 + .../ecma_3/NumberFormatting/tostring-001.js | 60 + .../tests/ecma_3/Object/8.6.1-01.js | 113 + .../tests/ecma_3/Object/8.6.2.6-001.js | 113 + .../tests/ecma_3/Object/browser.js | 7 + .../tests/ecma_3/Object/class-001.js | 156 + .../tests/ecma_3/Object/class-002.js | 146 + .../tests/ecma_3/Object/class-003.js | 139 + .../tests/ecma_3/Object/class-004.js | 139 + .../tests/ecma_3/Object/class-005.js | 124 + .../tests/ecma_3/Object/regress-361274.js | 66 + .../tests/ecma_3/Object/regress-385393-07.js | 67 + .../tests/ecma_3/Object/regress-72773.js | 97 + .../tests/ecma_3/Object/regress-79129-001.js | 80 + .../tests/ecma_3/Object/shell.js | 105 + .../tests/ecma_3/Operators/11.13.1-001.js | 152 + .../tests/ecma_3/Operators/11.13.1-002.js | 57 + .../tests/ecma_3/Operators/11.4.1-001.js | 120 + .../tests/ecma_3/Operators/11.4.1-002.js | 72 + .../tests/ecma_3/Operators/browser.js | 0 .../tests/ecma_3/Operators/order-01.js | 108 + .../tests/ecma_3/Operators/shell.js | 1 + .../qscriptjstestsuite/tests/ecma_3/README | 1 + .../tests/ecma_3/RegExp/15.10.2-1.js | 181 + .../tests/ecma_3/RegExp/15.10.2.12.js | 63 + .../tests/ecma_3/RegExp/15.10.3.1-1.js | 136 + .../tests/ecma_3/RegExp/15.10.3.1-2.js | 144 + .../tests/ecma_3/RegExp/15.10.4.1-1.js | 127 + .../tests/ecma_3/RegExp/15.10.4.1-2.js | 133 + .../tests/ecma_3/RegExp/15.10.4.1-3.js | 139 + .../tests/ecma_3/RegExp/15.10.4.1-4.js | 146 + .../tests/ecma_3/RegExp/15.10.4.1-5-n.js | 139 + .../tests/ecma_3/RegExp/15.10.6.2-1.js | 140 + .../tests/ecma_3/RegExp/15.10.6.2-2.js | 367 + .../tests/ecma_3/RegExp/browser.js | 0 .../tests/ecma_3/RegExp/octal-001.js | 136 + .../tests/ecma_3/RegExp/octal-002.js | 218 + .../tests/ecma_3/RegExp/perlstress-001.js | 3230 ++ .../tests/ecma_3/RegExp/perlstress-002.js | 1842 + .../tests/ecma_3/RegExp/regress-100199.js | 307 + .../tests/ecma_3/RegExp/regress-105972.js | 157 + .../tests/ecma_3/RegExp/regress-119909.js | 92 + .../tests/ecma_3/RegExp/regress-122076.js | 110 + .../tests/ecma_3/RegExp/regress-123437.js | 112 + .../tests/ecma_3/RegExp/regress-165353.js | 122 + .../tests/ecma_3/RegExp/regress-169497.js | 105 + .../tests/ecma_3/RegExp/regress-169534.js | 95 + .../tests/ecma_3/RegExp/regress-187133.js | 142 + .../tests/ecma_3/RegExp/regress-188206.js | 219 + .../tests/ecma_3/RegExp/regress-191479.js | 198 + .../tests/ecma_3/RegExp/regress-202564.js | 101 + .../tests/ecma_3/RegExp/regress-209067.js | 1106 + .../tests/ecma_3/RegExp/regress-209919.js | 174 + .../tests/ecma_3/RegExp/regress-216591.js | 117 + .../tests/ecma_3/RegExp/regress-220367-001.js | 104 + .../tests/ecma_3/RegExp/regress-223273.js | 279 + .../tests/ecma_3/RegExp/regress-223535.js | 133 + .../tests/ecma_3/RegExp/regress-224676.js | 232 + .../tests/ecma_3/RegExp/regress-225289.js | 176 + .../tests/ecma_3/RegExp/regress-225343.js | 125 + .../tests/ecma_3/RegExp/regress-24712.js | 59 + .../tests/ecma_3/RegExp/regress-285219.js | 51 + .../tests/ecma_3/RegExp/regress-28686.js | 57 + .../tests/ecma_3/RegExp/regress-289669.js | 88 + .../tests/ecma_3/RegExp/regress-307456.js | 54 + .../tests/ecma_3/RegExp/regress-309840.js | 58 + .../tests/ecma_3/RegExp/regress-311414.js | 101 + .../tests/ecma_3/RegExp/regress-312351.js | 50 + .../tests/ecma_3/RegExp/regress-31316.js | 96 + .../tests/ecma_3/RegExp/regress-330684.js | 53 + .../tests/ecma_3/RegExp/regress-334158.js | 58 + .../tests/ecma_3/RegExp/regress-346090.js | 63 + .../tests/ecma_3/RegExp/regress-367888.js | 62 + .../tests/ecma_3/RegExp/regress-375642.js | 61 + .../tests/ecma_3/RegExp/regress-375711.js | 118 + .../ecma_3/RegExp/regress-375715-01-n.js | 63 + .../tests/ecma_3/RegExp/regress-375715-02.js | 60 + .../tests/ecma_3/RegExp/regress-375715-03.js | 60 + .../tests/ecma_3/RegExp/regress-375715-04.js | 68 + .../tests/ecma_3/RegExp/regress-57572.js | 150 + .../tests/ecma_3/RegExp/regress-57631.js | 152 + .../tests/ecma_3/RegExp/regress-67773.js | 211 + .../tests/ecma_3/RegExp/regress-72964.js | 121 + .../tests/ecma_3/RegExp/regress-76683.js | 114 + .../tests/ecma_3/RegExp/regress-78156.js | 123 + .../tests/ecma_3/RegExp/regress-85721.js | 276 + .../tests/ecma_3/RegExp/regress-87231.js | 145 + .../tests/ecma_3/RegExp/regress-98306.js | 99 + .../tests/ecma_3/RegExp/shell.js | 266 + .../tests/ecma_3/Regress/browser.js | 0 .../tests/ecma_3/Regress/regress-385393-04.js | 66 + .../tests/ecma_3/Regress/regress-419152.js | 90 + .../tests/ecma_3/Regress/regress-420087.js | 64 + .../tests/ecma_3/Regress/regress-420610.js | 50 + .../tests/ecma_3/Regress/regress-441477-01.js | 73 + .../tests/ecma_3/Regress/shell.js | 1 + .../tests/ecma_3/Statements/12.6.3.js | 80 + .../tests/ecma_3/Statements/browser.js | 0 .../tests/ecma_3/Statements/regress-121744.js | 217 + .../tests/ecma_3/Statements/regress-131348.js | 184 + .../tests/ecma_3/Statements/regress-157509.js | 111 + .../tests/ecma_3/Statements/regress-194364.js | 152 + .../tests/ecma_3/Statements/regress-226517.js | 112 + .../tests/ecma_3/Statements/regress-302439.js | 1368 + .../tests/ecma_3/Statements/regress-324650.js | 5461 +++ .../ecma_3/Statements/regress-74474-001.js | 139 + .../ecma_3/Statements/regress-74474-002.js | 9097 ++++ .../ecma_3/Statements/regress-74474-003.js | 9099 ++++ .../ecma_3/Statements/regress-83532-001.js | 71 + .../ecma_3/Statements/regress-83532-002.js | 74 + .../tests/ecma_3/Statements/shell.js | 1 + .../tests/ecma_3/Statements/switch-001.js | 143 + .../tests/ecma_3/String/15.5.4.11.js | 532 + .../tests/ecma_3/String/15.5.4.14.js | 50 + .../tests/ecma_3/String/browser.js | 0 .../tests/ecma_3/String/regress-104375.js | 116 + .../tests/ecma_3/String/regress-189898.js | 157 + .../tests/ecma_3/String/regress-304376.js | 68 + .../tests/ecma_3/String/regress-313567.js | 56 + .../tests/ecma_3/String/regress-392378.js | 77 + .../tests/ecma_3/String/regress-83293.js | 216 + .../tests/ecma_3/String/shell.js | 1 + .../tests/ecma_3/Unicode/browser.js | 0 .../tests/ecma_3/Unicode/regress-352044-01.js | 72 + .../ecma_3/Unicode/regress-352044-02-n.js | 72 + .../tests/ecma_3/Unicode/shell.js | 1 + .../tests/ecma_3/Unicode/uc-001-n.js | 62 + .../tests/ecma_3/Unicode/uc-001.js | 56 + .../tests/ecma_3/Unicode/uc-002-n.js | 55 + .../tests/ecma_3/Unicode/uc-002.js | 60 + .../tests/ecma_3/Unicode/uc-003.js | 71 + .../tests/ecma_3/Unicode/uc-004.js | 65 + .../tests/ecma_3/Unicode/uc-005.js | 276 + .../tests/ecma_3/browser.js | 36 + .../tests/ecma_3/extensions/10.1.3-2.js | 162 + .../tests/ecma_3/extensions/7.9.1.js | 83 + .../tests/ecma_3/extensions/browser.js | 0 .../tests/ecma_3/extensions/regress-103087.js | 178 + .../ecma_3/extensions/regress-188206-01.js | 108 + .../ecma_3/extensions/regress-188206-02.js | 158 + .../ecma_3/extensions/regress-220367-002.js | 112 + .../tests/ecma_3/extensions/regress-228087.js | 352 + .../tests/ecma_3/extensions/regress-274152.js | 83 + .../tests/ecma_3/extensions/regress-320854.js | 53 + .../tests/ecma_3/extensions/regress-327170.js | 58 + .../tests/ecma_3/extensions/regress-368516.js | 78 + .../ecma_3/extensions/regress-385393-03.js | 63 + .../tests/ecma_3/extensions/regress-429248.js | 67 + .../tests/ecma_3/extensions/regress-430740.js | 72 + .../tests/ecma_3/extensions/shell.js | 266 + .../qscriptjstestsuite/tests/ecma_3/shell.js | 40 + .../tests/ecma_3/template.js | 59 + .../auto/qscriptjstestsuite/tests/shell.js | 886 + .../tst_qscriptjstestsuite.cpp | 436 + .../auto/qscriptqwidgets/qscriptqwidgets.pro | 11 + .../qscriptqwidgets/tst_qscriptqwidgets.cpp | 131 + .../tests/auto/qscriptstring/.gitignore | 1 + .../auto/qscriptstring/qscriptstring.pro | 5 + .../auto/qscriptstring/tst_qscriptstring.cpp | 189 + .../qscriptv8testsuite/abstracttestsuite.cpp | 421 + .../qscriptv8testsuite/abstracttestsuite.h | 117 + .../qscriptv8testsuite/abstracttestsuite.pri | 3 + .../auto/qscriptv8testsuite/expect_fail.txt | 16 + .../qscriptv8testsuite/qscriptv8testsuite.pro | 7 + .../qscriptv8testsuite/qscriptv8testsuite.qrc | 7 + .../tests/auto/qscriptv8testsuite/skip.txt | 36 + .../auto/qscriptv8testsuite/tests/apply.js | 187 + .../tests/arguments-call-apply.js | 41 + .../tests/arguments-enum.js | 52 + .../tests/arguments-indirect.js | 47 + .../qscriptv8testsuite/tests/arguments-opt.js | 130 + .../qscriptv8testsuite/tests/arguments.js | 97 + .../qscriptv8testsuite/tests/array-concat.js | 101 + .../tests/array-functions-prototype.js | 159 + .../tests/array-indexing.js | 66 + .../tests/array-iteration.js | 228 + .../qscriptv8testsuite/tests/array-join.js | 45 + .../qscriptv8testsuite/tests/array-length.js | 111 + .../qscriptv8testsuite/tests/array-sort.js | 66 + .../tests/array-splice-webkit.js | 60 + .../qscriptv8testsuite/tests/array-splice.js | 313 + .../qscriptv8testsuite/tests/array_length.js | 53 + .../tests/ascii-regexp-subject.js | 45 + .../tests/binary-operation-overwrite.js | 36 + .../tests/body-not-visible.js | 39 + .../tests/call-non-function-call.js | 38 + .../tests/call-non-function.js | 54 + .../auto/qscriptv8testsuite/tests/call.js | 87 + .../qscriptv8testsuite/tests/char-escape.js | 53 + .../tests/class-of-builtins.js | 50 + .../auto/qscriptv8testsuite/tests/closure.js | 37 + .../qscriptv8testsuite/tests/compare-nan.js | 44 + .../qscriptv8testsuite/tests/const-redecl.js | 220 + .../auto/qscriptv8testsuite/tests/const.js | 68 + .../tests/cyclic-array-to-string.js | 65 + .../qscriptv8testsuite/tests/date-parse.js | 265 + .../auto/qscriptv8testsuite/tests/date.js | 126 + .../tests/declare-locally.js | 43 + .../tests/deep-recursion.js | 64 + .../tests/delay-syntax-error.js | 41 + .../tests/delete-global-properties.js | 37 + .../tests/delete-in-eval.js | 32 + .../tests/delete-in-with.js | 34 + .../tests/delete-vars-from-eval.js | 40 + .../auto/qscriptv8testsuite/tests/delete.js | 163 + .../tests/do-not-strip-fc.js | 31 + .../tests/dont-enum-array-holes.js | 35 + .../tests/dont-reinit-global-var.js | 47 + .../qscriptv8testsuite/tests/double-equals.js | 114 + .../auto/qscriptv8testsuite/tests/dtoa.js | 32 + .../tests/enumeration_order.js | 59 + .../auto/qscriptv8testsuite/tests/escape.js | 118 + .../tests/eval-typeof-non-existing.js | 32 + .../tests/execScript-case-insensitive.js | 34 + .../tests/extra-arguments.js | 54 + .../qscriptv8testsuite/tests/extra-commas.js | 46 + .../tests/for-in-null-or-undefined.js | 33 + .../tests/for-in-special-cases.js | 64 + .../auto/qscriptv8testsuite/tests/for-in.js | 69 + .../tests/fun-as-prototype.js | 36 + .../auto/qscriptv8testsuite/tests/fun_name.js | 34 + .../tests/function-arguments-null.js | 30 + .../tests/function-caller.js | 48 + .../tests/function-property.js | 29 + .../tests/function-prototype.js | 97 + .../tests/function-source.js | 49 + .../auto/qscriptv8testsuite/tests/function.js | 72 + .../tests/fuzz-accessors.js | 85 + .../tests/getter-in-value-prototype.js | 35 + .../tests/global-const-var-conflicts.js | 57 + .../tests/global-vars-eval.js | 34 + .../tests/global-vars-with.js | 43 + .../tests/has-own-property.js | 38 + .../qscriptv8testsuite/tests/html-comments.js | 57 + .../tests/html-string-funcs.js | 47 + .../tests/if-in-undefined.js | 36 + .../tests/auto/qscriptv8testsuite/tests/in.js | 158 + .../qscriptv8testsuite/tests/instanceof.js | 32 + .../tests/integer-to-string.js | 35 + .../qscriptv8testsuite/tests/invalid-lhs.js | 68 + .../auto/qscriptv8testsuite/tests/keyed-ic.js | 207 + .../tests/large-object-literal.js | 49 + .../qscriptv8testsuite/tests/lazy-load.js | 34 + .../auto/qscriptv8testsuite/tests/length.js | 78 + .../qscriptv8testsuite/tests/math-min-max.js | 72 + .../tests/megamorphic-callbacks.js | 70 + .../auto/qscriptv8testsuite/tests/mjsunit.js | 125 + .../tests/mul-exhaustive.js | 4511 ++ .../qscriptv8testsuite/tests/negate-zero.js | 42 + .../auto/qscriptv8testsuite/tests/negate.js | 59 + .../tests/nested-repetition-count-overflow.js | 43 + .../auto/qscriptv8testsuite/tests/new.js | 56 + .../tests/newline-in-string.js | 46 + .../tests/no-branch-elimination.js | 36 + .../tests/no-octal-constants-above-256.js | 32 + .../qscriptv8testsuite/tests/no-semicolon.js | 45 + .../tests/non-ascii-replace.js | 30 + .../tests/nul-characters.js | 38 + .../qscriptv8testsuite/tests/number-limits.js | 43 + .../tests/number-tostring.js | 338 + .../qscriptv8testsuite/tests/obj-construct.js | 46 + .../tests/parse-int-float.js | 82 + .../tests/property-object-key.js | 36 + .../auto/qscriptv8testsuite/tests/proto.js | 33 + .../qscriptv8testsuite/tests/prototype.js | 93 + .../tests/regexp-multiline-stack-trace.js | 114 + .../tests/regexp-multiline.js | 112 + .../tests/regexp-standalones.js | 78 + .../qscriptv8testsuite/tests/regexp-static.js | 122 + .../auto/qscriptv8testsuite/tests/regexp.js | 243 + .../auto/qscriptv8testsuite/tests/scanner.js | 30 + .../tests/smi-negative-zero.js | 100 + .../auto/qscriptv8testsuite/tests/smi-ops.js | 102 + .../tests/sparse-array-reverse.js | 123 + .../qscriptv8testsuite/tests/sparse-array.js | 41 + .../qscriptv8testsuite/tests/str-to-num.js | 158 + .../tests/stress-array-push.js | 34 + .../qscriptv8testsuite/tests/strict-equals.js | 90 + .../qscriptv8testsuite/tests/string-case.js | 28 + .../qscriptv8testsuite/tests/string-charat.js | 53 + .../tests/string-charcodeat.js | 189 + .../tests/string-flatten.js | 37 + .../qscriptv8testsuite/tests/string-index.js | 154 + .../tests/string-indexof.js | 49 + .../tests/string-lastindexof.js | 51 + .../tests/string-localecompare.js | 40 + .../qscriptv8testsuite/tests/string-search.js | 30 + .../qscriptv8testsuite/tests/string-split.js | 126 + .../auto/qscriptv8testsuite/tests/substr.js | 65 + .../tests/this-in-callbacks.js | 47 + .../auto/qscriptv8testsuite/tests/this.js | 46 + .../tests/throw-exception-for-null-access.js | 37 + .../qscriptv8testsuite/tests/to-precision.js | 82 + .../auto/qscriptv8testsuite/tests/tobool.js | 36 + .../auto/qscriptv8testsuite/tests/toint32.js | 80 + .../auto/qscriptv8testsuite/tests/touint32.js | 72 + .../tests/try-finally-nested.js | 46 + .../auto/qscriptv8testsuite/tests/try.js | 349 + .../tests/try_catch_scopes.js | 42 + .../tests/unicode-string-to-number.js | 46 + .../qscriptv8testsuite/tests/unicode-test.js | 9143 ++++ .../tests/unusual-constructor.js | 38 + .../auto/qscriptv8testsuite/tests/uri.js | 78 + .../tests/value-callic-prototype-change.js | 94 + .../auto/qscriptv8testsuite/tests/var.js | 37 + .../qscriptv8testsuite/tests/with-leave.js | 61 + .../tests/with-parameter-access.js | 47 + .../qscriptv8testsuite/tests/with-value.js | 38 + .../tst_qscriptv8testsuite.cpp | 262 + .../tests/auto/qscriptvalue/.gitignore | 1 + .../tests/auto/qscriptvalue/qscriptvalue.pro | 12 + .../auto/qscriptvalue/tst_qscriptvalue.cpp | 3974 ++ .../auto/qscriptvalue/tst_qscriptvalue.h | 183 + .../auto/qscriptvaluegenerated/.gitignore | 1 + .../qscriptvaluegenerated.pro | 20 + .../tst_qscriptvalue.cpp | 99 + .../qscriptvaluegenerated/tst_qscriptvalue.h | 385 + .../tst_qscriptvalue_generated_cast.cpp | 1469 + .../tst_qscriptvalue_generated_comparison.cpp | 7525 +++ .../tst_qscriptvalue_generated_init.cpp | 187 + .../tst_qscriptvalue_generated_isXXX.cpp | 769 + .../tst_qscriptvalue_generated_toXXX.cpp | 1922 + .../auto/qscriptvalueiterator/.gitignore | 1 + .../qscriptvalueiterator.pro | 7 + .../tst_qscriptvalueiterator.cpp | 694 + src/shared/qtscript/tests/auto/shared/util.h | 47 + .../qtscript/tests/auto/shared/util.pri | 1 + .../benchmarks/script/context2d/context2d.pro | 23 + .../script/context2d/tst_context2d.cpp | 164 + .../script/qscriptclass/qscriptclass.pro | 8 + .../script/qscriptclass/tst_qscriptclass.cpp | 272 + .../qscriptclass_bytearray.pro | 11 + .../qscriptclass_bytearray.qrc | 5 + .../tests/construct-copy.js | 3 + .../qscriptclass_bytearray/tests/construct.js | 2 + .../qscriptclass_bytearray/tests/for-in.js | 3 + .../tests/get-element.js | 3 + .../tests/get-length.js | 3 + .../qscriptclass_bytearray/tests/mid.js | 3 + .../tests/set-element.js | 3 + .../tests/set-length.js | 3 + .../qscriptclass_bytearray/tests/sum.js | 8 + .../qscriptclass_bytearray/tests/trimmed.js | 3 + .../tst_qscriptclass_bytearray.cpp | 96 + .../script/qscriptengine/qscriptengine.pro | 9 + .../qscriptengine/tst_qscriptengine.cpp | 560 + .../script/qscriptqobject/qscriptqobject.pro | 8 + .../qscriptqobject/tst_qscriptqobject.cpp | 1252 + .../script/qscriptvalue/qscriptvalue.pro | 8 + .../script/qscriptvalue/tst_qscriptvalue.cpp | 1007 + .../qscriptvalueiterator.pro | 8 + .../tst_qscriptvalueiterator.cpp | 278 + .../tests/benchmarks/script/script.pro | 20 + .../benchmarks/script/sunspider/sunspider.pro | 9 + .../benchmarks/script/sunspider/sunspider.qrc | 5 + .../script/sunspider/tests/3d-cube.js | 337 + .../script/sunspider/tests/3d-morph.js | 54 + .../script/sunspider/tests/3d-raytrace.js | 441 + .../script/sunspider/tests/LICENSE.txt | 64 + .../benchmarks/script/sunspider/tests/VERSION | 1 + .../sunspider/tests/access-binary-trees.js | 50 + .../script/sunspider/tests/access-fannkuch.js | 66 + .../script/sunspider/tests/access-nbody.js | 169 + .../script/sunspider/tests/access-nsieve.js | 38 + .../tests/bitops-3bit-bits-in-byte.js | 32 + .../sunspider/tests/bitops-bits-in-byte.js | 21 + .../sunspider/tests/bitops-bitwise-and.js | 28 + .../sunspider/tests/bitops-nsieve-bits.js | 32 + .../sunspider/tests/controlflow-recursive.js | 25 + .../script/sunspider/tests/crypto-aes.js | 422 + .../script/sunspider/tests/crypto-md5.js | 286 + .../script/sunspider/tests/crypto-sha1.js | 224 + .../sunspider/tests/date-format-tofte.js | 299 + .../sunspider/tests/date-format-xparb.js | 417 + .../script/sunspider/tests/math-cordic.js | 95 + .../sunspider/tests/math-partial-sums.js | 33 + .../sunspider/tests/math-spectral-norm.js | 51 + .../sunspider/tests/qt_attribution.json | 33 + .../script/sunspider/tests/regexp-dna.js | 1712 + .../script/sunspider/tests/string-base64.js | 135 + .../script/sunspider/tests/string-fasta.js | 85 + .../script/sunspider/tests/string-tagcloud.js | 265 + .../sunspider/tests/string-unpack-code.js | 68 + .../sunspider/tests/string-validate-input.js | 89 + .../script/sunspider/tst_sunspider.cpp | 109 + .../benchmarks/script/v8/tests/LICENSE.txt | 50 + .../benchmarks/script/v8/tests/README.txt | 79 + .../tests/benchmarks/script/v8/tests/base.js | 284 + .../benchmarks/script/v8/tests/crypto.js | 1698 + .../benchmarks/script/v8/tests/deltablue.js | 880 + .../script/v8/tests/earley-boyer.js | 4684 ++ .../script/v8/tests/qt_attribution.json | 17 + .../benchmarks/script/v8/tests/raytrace.js | 904 + .../benchmarks/script/v8/tests/regexp.js | 1764 + .../benchmarks/script/v8/tests/richards.js | 539 + .../tests/benchmarks/script/v8/tests/splay.js | 394 + .../tests/benchmarks/script/v8/tst_v8.cpp | 122 + .../tests/benchmarks/script/v8/v8.pro | 9 + .../tests/benchmarks/script/v8/v8.qrc | 5 + src/shared/qtscript/tests/global/.gitignore | 2 + src/shared/qtscript/tests/global/global.cfg | 6 + src/shared/qtscript/tests/tests.pro | 2 + .../qtscript/util/mkdist-javascriptcore | 193 + src/shared/variant/CMakeLists.txt | 4 + src/shared/variant/LICENSE.md | 23 + src/shared/variant/README.md | 37 + src/shared/variant/variant.h | 63 + src/shared/variant/variant.hpp | 2465 + src/shared/variant/variant.pri | 1 + src/shared/variant/variant.qbs | 13 + src/src.qbs | 12 + static-res.pro | 74 + static.pro | 83 + tests/CMakeLists.txt | 3 + tests/auto/CMakeLists.txt | 10 + tests/auto/api/CMakeLists.txt | 9 + tests/auto/api/api.pro | 27 + tests/auto/api/api.qbs | 19 + tests/auto/api/testdata/QBS-728/QBS-728.qbs | 5 + .../add-qobject-macro-to-cpp-file.qbs | 4 + .../add-qobject-macro-to-cpp-file/main.cpp | 35 + .../add-qobject-macro-to-cpp-file/object.cpp | 41 + .../add-qobject-macro-to-cpp-file/object.h | 32 + .../added-file-persistent.qbs | 6 + .../testdata/added-file-persistent/file.cpp | 29 + .../testdata/added-file-persistent/main.cpp | 31 + .../auto/api/testdata/app-without-sources/a.c | 29 + .../app-without-sources.qbs | 38 + .../auto/api/testdata/app-without-sources/b.c | 37 + .../testdata/base-properties/imports/Bar.qbs | 4 + .../testdata/base-properties/imports/Foo.qbs | 6 + .../api/testdata/base-properties/main.cpp | 42 + .../auto/api/testdata/base-properties/prj.qbs | 9 + .../build-error-code-location.qbs | 10 + .../build-properties-source.qbs | 15 + .../testdata/build-properties-source/main.cpp | 38 + .../build-single-file/build-single-file.qbs | 32 + .../testdata/build-single-file/compiled.cpp | 34 + .../testdata/build-single-file/ignored1.cpp | 0 .../testdata/build-single-file/ignored2.cpp | 0 .../auto/api/testdata/build-single-file/pch.h | 1 + .../buildgraph-info/buildgraph-info.qbs | 3 + .../buildgraph-locking/buildgraph-locking.qbs | 2 + .../change-dependent-lib.qbs | 26 + .../testdata/change-dependent-lib/main.cpp | 39 + .../testdata/change-dependent-lib/mylib.cpp | 37 + .../testdata/check-outputs/check-outputs.qbs | 36 + tests/auto/api/testdata/check-outputs/foo.txt | 1 + tests/auto/api/testdata/codegen/codegen.qbs | 73 + tests/auto/api/testdata/codegen/foo.txt | 1 + .../command-extraction/command-extraction.qbs | 3 + .../api/testdata/command-extraction/main.cpp | 29 + .../dependency-on-multiplexed-type.qbs | 16 + .../disabled-product/disabled-product.qbs | 8 + .../api/testdata/disabled-product/main.cpp | 1 + .../disabled-project/disabled-project.qbs | 6 + .../disabled_install_group.qbs | 9 + .../testdata/disabled_install_group/main.cpp | 29 + .../disappeared-wildcard-file.qbs | 4 + .../disappeared-wildcard-file/file1.txt | 0 .../disappeared-wildcard-file/file2.txt | 0 .../duplicate-product-names/explicit.qbs | 5 + .../implicit-indirect.qbs | 3 + .../duplicate-product-names/implicit.qbs | 5 + .../subdir1/subproject.qbs | 1 + .../subdir2/subproject.qbs | 1 + .../empty-filetag-list/dontcompilethis.cpp | 1 + .../empty-filetag-list/empty-filetag-list.qbs | 6 + .../empty-submodules-list.qbs | 6 + .../enable-and-disable-product.qbs | 6 + .../enable-and-disable-product/main.cpp | 29 + .../error-in-setup-run-environment.qbs | 3 + .../modules/mymodule/mymodule.qbs | 5 + .../excluded-inputs/excluded-inputs.qbs | 113 + .../api/testdata/explicitly-depends-on/a.in | 0 .../api/testdata/explicitly-depends-on/b.in | 0 .../api/testdata/explicitly-depends-on/c.in | 0 .../explicitly-depends-on/compiler.cpp | 11 + .../explicitly-depends-on.qbs | 70 + .../export-item-with-group.qbs | 15 + .../testdata/export-item-with-group/main.cpp | 29 + .../testdata/export-simple/export-simple.qbs | 51 + .../auto/api/testdata/export-simple/lib1.cpp | 36 + .../auto/api/testdata/export-simple/main.cpp | 38 + .../export-with-recursive-depends.qbs | 13 + .../export-with-recursive-depends/main1.cpp | 29 + .../export-with-recursive-depends/main2.cpp | 34 + .../modules/module1/module1.qbs | 3 + .../modules/module2/module2.qbs | 4 + .../testdata/fallback-gcc/fallback-gcc.qbs | 20 + tests/auto/api/testdata/file-tagger/bla.txt | 15 + .../auto/api/testdata/file-tagger/moc_cpp.qbs | 42 + .../filetagsfilter_override/InstalledApp.qbs | 9 + .../filetagsfilter_override.qbs | 10 + .../testdata/filetagsfilter_override/main.cpp | 29 + .../generated-files-list.qbs | 14 + .../testdata/generated-files-list/main.cpp | 39 + .../generated-files-list/mainwindow.cpp | 42 + .../generated-files-list/mainwindow.h | 50 + .../generated-files-list/mainwindow.ui | 24 + .../infinite-loop-js/infinite-loop.qbs | 19 + .../infinite-loop-process/infinite-loop.qbs | 34 + .../testdata/infinite-loop-process/main.cpp | 35 + .../infinite-loop-resolving.qbs | 3 + .../inherit-qbs-search-paths/imports/Foo.qbs | 6 + .../inherit-qbs-search-paths/main.cpp | 37 + .../testdata/inherit-qbs-search-paths/prj.qbs | 12 + .../subdir/modules/bli/m.qbs | 5 + .../subdir2/modules/bla/m.qbs | 5 + .../installed-artifact/installed-artifact.qbs | 28 + .../api/testdata/installed-artifact/main.cpp | 29 + .../api/testdata/is-runnable/is-runnable.qbs | 12 + .../lib-same-source/lib-same-source.qbs | 21 + .../api/testdata/lib-same-source/main.cpp | 34 + .../link-dynamiclibs-staticlibs/dynamic1.cpp | 12 + .../link-dynamiclibs-staticlibs/dynamic2.cpp | 10 + .../link-dynamiclibs-staticlibs.qbs | 45 + .../link-dynamiclibs-staticlibs/main.cpp | 11 + .../link-dynamiclibs-staticlibs/static1.cpp | 10 + .../link-dynamiclibs-staticlibs/static2.cpp | 7 + .../link-dynamiclibs-staticlibs/static2.h | 10 + .../api/testdata/link-dynamiclibs/lib1.cpp | 39 + .../api/testdata/link-dynamiclibs/lib2.cpp | 39 + .../api/testdata/link-dynamiclibs/lib3.cpp | 42 + .../api/testdata/link-dynamiclibs/lib4.cpp | 43 + .../auto/api/testdata/link-dynamiclibs/lib4.h | 51 + .../link-dynamiclibs/link-dynamiclibs.qbs | 71 + .../api/testdata/link-dynamiclibs/main.cpp | 42 + .../link-static-lib/helper1/helper1.cpp | 35 + .../link-static-lib/helper1/helper1.h | 34 + .../link-static-lib/helper2/helper2.cpp | 34 + .../link-static-lib/helper2/helper2.h | 34 + .../link-static-lib/link-static-lib.qbs | 45 + .../api/testdata/link-static-lib/main.cpp | 37 + .../testdata/link-static-lib/mystaticlib.cpp | 38 + .../link-static-lib/mystaticlibhelper.cpp | 33 + .../link-staticlib-dynamiclib.qbs | 19 + .../link-staticlib-dynamiclib/main.cpp | 7 + .../mydynamiclib.cpp | 3 + .../link-staticlib-dynamiclib/mystaticlib.cpp | 5 + .../link-staticlibs-dynamiclibs/dynamic1.cpp | 11 + .../link-staticlibs-dynamiclibs/dynamic2.cpp | 7 + .../link-staticlibs-dynamiclibs.qbs | 52 + .../link-staticlibs-dynamiclibs/main.cpp | 10 + .../link-staticlibs-dynamiclibs/static1.cpp | 11 + .../link-staticlibs-dynamiclibs/static2.cpp | 11 + .../link-staticlibs-dynamiclibs/static2.h | 10 + .../local-profiles/local-profiles.qbs | 44 + .../api/testdata/lots-of-dots/dotty.matrix.ui | 21 + .../testdata/lots-of-dots/lots-of-dots.qbs | 16 + .../api/testdata/lots-of-dots/m.a.i.n.cpp | 38 + .../api/testdata/lots-of-dots/object.narf.cpp | 35 + .../api/testdata/lots-of-dots/object.narf.h | 41 + .../api/testdata/lots-of-dots/polka.dots.qrc | 5 + .../testdata/missing-qobject-header/main.cpp | 34 + .../missing-qobject-header/myobject.cpp | 33 + .../missing-qobject-header/myobject.h | 38 + .../testdata/missing-source-file/file1.txt | 0 .../missing-source-file/file2.txt.missing | 0 .../testdata/missing-source-file/file3.txt | 0 .../missing-source-file.qbs | 7 + tests/auto/api/testdata/moc-cpp/bla.cpp | 43 + tests/auto/api/testdata/moc-cpp/moc-cpp.qbs | 13 + .../moc-hpp-included/moc-hpp-included.qbs | 19 + .../api/testdata/moc-hpp-included/object.cpp | 43 + .../api/testdata/moc-hpp-included/object.h | 41 + .../api/testdata/moc-hpp-included/object2.h | 41 + .../api/testdata/moc-hpp-included/object2.mm | 16 + tests/auto/api/testdata/moc-hpp/moc-hpp.qbs | 17 + tests/auto/api/testdata/moc-hpp/object.cpp | 41 + tests/auto/api/testdata/moc-hpp/object.h | 41 + .../api/testdata/multi-arch/host+target.input | 0 .../api/testdata/multi-arch/host-tool.input | 0 .../api/testdata/multi-arch/multi-arch.qbs | 56 + .../testdata/multiplexing/multiplexing.qbs | 94 + .../new-output-artifact-in-dependency/lib.cpp | 31 + .../main.cpp | 34 + .../new-output-artifact-in-dependency.qbs | 17 + .../new-pattern-match/new-pattern-match.qbs | 3 + .../invalidaccessfromproduct.qbs | 1 + .../nonexistingprojectproperties.qbs | 1 + tests/auto/api/testdata/objc/main.mm | 13 + tests/auto/api/testdata/objc/objc.qbs | 7 + .../precompiled-header-dynamic/autogen.h.in | 6 + .../precompiled-header-dynamic/main.cpp | 32 + .../testdata/precompiled-header-dynamic/pch.h | 29 + .../precompiled-header-dynamic.qbs | 29 + .../testdata/precompiled-header-new/main.cpp | 55 + .../precompiled-header-new/myobject.cpp | 41 + .../precompiled-header-new/myobject.h | 40 + .../precompiled-header-new.qbs | 10 + .../testdata/precompiled-header-new/stable.h | 37 + .../auto/api/testdata/process-result/main.cpp | 37 + .../process-result/process-result.qbs | 37 + .../api/testdata/productNameWithDots/app.cpp | 29 + .../api/testdata/productNameWithDots/lib.cpp | 29 + .../productNameWithDots.qbs | 13 + .../file.cpp | 29 + .../main.cpp | 29 + ...roject-data-after-product-invalidation.qbs | 7 + .../project-editing/existingfile1.txt | 0 .../project-editing/existingfile2.txt | 0 .../project-editing/existingfile3.txt | 0 .../api/testdata/project-editing/file.cpp | 27 + .../auto/api/testdata/project-editing/file.h | 27 + .../api/testdata/project-editing/main.cpp | 27 + .../api/testdata/project-editing/newfile1.txt | 0 .../api/testdata/project-editing/newfile2.txt | 0 .../api/testdata/project-editing/newfile3.txt | 0 .../api/testdata/project-editing/newfile4.txt | 0 .../project-editing/project-editing.qbs | 37 + .../project-editing/project-with-no-files.qbs | 5 + .../testdata/project-editing/subdir/file.txt | 0 .../testdata/project-editing/test.wildcard | 0 .../project.early-error.qbs | 4 + .../project.late-error.qbs | 12 + .../project-invalidation/project.no-error.qbs | 3 + .../project-locking/project-locking.qbs | 2 + .../project-properties-by-name/main1.cpp | 38 + .../project-properties-by-name/main2.cpp | 38 + .../project-properties-by-name.qbs | 20 + .../project-with-probe-and-profile-item.qbs | 19 + .../project-with-properties-item.qbs | 10 + tests/auto/api/testdata/projectd | 0 .../api/testdata/properties-blocks/main.cpp | 45 + .../properties-blocks/properties-blocks.qbs | 27 + .../api/testdata/qt5-plugin/echointerface.h | 51 + .../api/testdata/qt5-plugin/echoplugin.cpp | 34 + .../auto/api/testdata/qt5-plugin/echoplugin.h | 45 + .../qt5-plugin/echoplugin.json.source | 1 + .../testdata/qt5-plugin/echoplugin_dummy.cpp | 29 + .../api/testdata/qt5-plugin/qt5-plugin.qbs | 50 + tests/auto/api/testdata/rc/main.cpp | 32 + tests/auto/api/testdata/rc/rc.qbs | 15 + .../auto/api/testdata/rc/subdir/rc-include.h | 0 tests/auto/api/testdata/rc/test.rc | 24 + .../recursive-wildcards/dir/file1.txt | 0 .../recursive-wildcards/dir/subdir/file2.txt | 0 .../recursive-wildcards.qbs | 8 + .../ambiguousdir/p1.qbs | 0 .../ambiguousdir/p2.qbs | 0 .../testdata/referenced-file-errors/cycle.qbs | 5 + .../emptydir/.gitignore | 0 .../modules/brokenmodule/brokenmodule.qbs | 3 + .../testdata/referenced-file-errors/okay.qbs | 1 + .../testdata/referenced-file-errors/okay2.qbs | 1 + .../referenced-file-errors.qbs | 30 + .../referenced-file-errors/wrongtype.qbs | 1 + .../auto/api/testdata/references/invalid1.qbs | 3 + .../auto/api/testdata/references/invalid2.qbs | 3 + .../subproject1.qbs | 0 .../subproject2.qbs | 0 .../subproject3.qbs | 0 .../subdir-with-no-project/test.txt | 0 .../references/subdir-with-one-project/p.qbs | 1 + .../subdir-with-one-project/test.txt | 0 tests/auto/api/testdata/references/valid.qbs | 3 + .../relaxed-mode-recovery.qbs | 8 + .../testdata/remove-file-dependency/main.cpp | 37 + .../removeFileDependency.qbs | 5 + .../remove-file-dependency/someheader.h | 29 + .../auto/api/testdata/rename-product/lib.cpp | 31 + .../auto/api/testdata/rename-product/main.cpp | 34 + .../api/testdata/rename-product/rename.qbs | 18 + .../testdata/rename-target-artifact/lib.cpp | 31 + .../testdata/rename-target-artifact/main.cpp | 34 + .../rename-target-artifact/rename.qbs | 21 + .../renamed-qbs-source-file.qbs | 9 + .../the-product/the-prodduct.qbs | 1 + .../api/testdata/restored-warnings/file.cpp | 1 + .../api/testdata/restored-warnings/main.cpp | 1 + .../restored-warnings/restored-warnings.qbs | 14 + .../auto/api/testdata/rule-conflict/main.cpp | 29 + tests/auto/api/testdata/rule-conflict/pch1.h | 27 + tests/auto/api/testdata/rule-conflict/pch2.h | 27 + .../testdata/rule-conflict/rule-conflict.qbs | 8 + .../run-disabled-product.qbs | 4 + tests/auto/api/testdata/same-base-name/lib.c | 34 + .../auto/api/testdata/same-base-name/lib.cpp | 34 + tests/auto/api/testdata/same-base-name/lib.m | 6 + tests/auto/api/testdata/same-base-name/lib.mm | 8 + tests/auto/api/testdata/same-base-name/main.c | 46 + .../same-base-name/same-base-name.qbs | 31 + tests/auto/api/testdata/simple-probe/main.cpp | 29 + .../testdata/simple-probe/simple-probe.qbs | 31 + .../api/testdata/soft-dependency/main.cpp | 32 + .../soft-dependency/soft-dependency.qbs | 10 + .../source-file-in-build-dir/file.cpp | 29 + .../source-file-in-build-dir.qbs | 27 + .../auto/api/testdata/static-lib-deps/a1.cpp | 35 + .../auto/api/testdata/static-lib-deps/a2.cpp | 35 + tests/auto/api/testdata/static-lib-deps/b.cpp | 35 + tests/auto/api/testdata/static-lib-deps/c.cpp | 35 + tests/auto/api/testdata/static-lib-deps/d.cpp | 64 + tests/auto/api/testdata/static-lib-deps/d.mm | 8 + tests/auto/api/testdata/static-lib-deps/e.cpp | 35 + .../api/testdata/static-lib-deps/main.cpp | 35 + .../static-lib-deps/static-lib-deps.qbs | 95 + .../resources/imports/LibraryType/type.js | 1 + .../modules/QtCoreDepender/qtcoredepender.qbs | 3 + .../resources/modules/cute/core/core.qbs | 4 + .../resources/modules/cute/core/cuteglobal.h | 1 + .../testdata/subprojects/subproject1/main.cpp | 34 + .../subprojects/subproject2/subproject2.qbs | 13 + .../subproject2/subproject3/subproject3.qbs | 15 + .../subproject2/subproject3/testlib.cpp | 32 + .../testdata/subprojects/toplevelproject.qbs | 17 + .../target-artifact-status.qbs | 28 + .../auto/api/testdata/timeout-js/timeout.qbs | 20 + .../api/testdata/timeout-process/main.cpp | 37 + .../api/testdata/timeout-process/timeout.qbs | 42 + .../modules/thetool/thetool.qbs | 28 + .../use-outside-project.qbs | 5 + .../use-within-project/main.cpp | 10 + .../use-within-project/tool-input.txt | 0 .../use-within-project/use-within-project.qbs | 48 + .../transformer-data/transformer-data.qbs | 35 + tests/auto/api/testdata/transformers/main.cpp | 70 + .../testdata/transformers/transformers.qbs | 92 + .../modules/mymodule/mymodule.qbs | 23 + .../modules/myothermodule/myothermodule.qbs | 3 + .../two-default-property-values/test.txt | 0 .../two-default-property-values.qbs | 11 + tests/auto/api/testdata/type-change/main.cpp | 29 + .../api/testdata/type-change/type-change.qbs | 5 + tests/auto/api/testdata/uic/bla.cpp | 36 + tests/auto/api/testdata/uic/bla.h | 29 + tests/auto/api/testdata/uic/ui.h | 29 + tests/auto/api/testdata/uic/ui.ui | 31 + tests/auto/api/testdata/uic/uic.qbs | 14 + tests/auto/api/tst_api.cpp | 3127 ++ tests/auto/api/tst_api.h | 171 + tests/auto/auto.pri | 18 + tests/auto/auto.pro | 21 + tests/auto/auto.qbs | 21 + tests/auto/blackbox/CMakeLists.txt | 81 + tests/auto/blackbox/blackbox-android.pro | 21 + tests/auto/blackbox/blackbox-android.qbs | 21 + tests/auto/blackbox/blackbox-apple.pro | 20 + tests/auto/blackbox/blackbox-apple.qbs | 22 + tests/auto/blackbox/blackbox-baremetal.pro | 18 + tests/auto/blackbox/blackbox-baremetal.qbs | 21 + tests/auto/blackbox/blackbox-clangdb.pro | 18 + tests/auto/blackbox/blackbox-clangdb.qbs | 24 + tests/auto/blackbox/blackbox-examples.pro | 18 + tests/auto/blackbox/blackbox-examples.qbs | 21 + tests/auto/blackbox/blackbox-java.pro | 18 + tests/auto/blackbox/blackbox-java.qbs | 21 + tests/auto/blackbox/blackbox-joblimits.pro | 18 + tests/auto/blackbox/blackbox-joblimits.qbs | 20 + tests/auto/blackbox/blackbox-qt.pro | 18 + tests/auto/blackbox/blackbox-qt.qbs | 21 + tests/auto/blackbox/blackbox-windows.pro | 18 + tests/auto/blackbox/blackbox-windows.qbs | 21 + tests/auto/blackbox/blackbox.pro | 21 + tests/auto/blackbox/blackbox.qbs | 28 + tests/auto/blackbox/find/find-android.qbs | 91 + tests/auto/blackbox/find/find-jdk.qbs | 35 + tests/auto/blackbox/find/find-nodejs.qbs | 33 + tests/auto/blackbox/find/find-typescript.qbs | 34 + tests/auto/blackbox/find/find-xcode.qbs | 40 + .../testdata-android/aidl/AndroidManifest.xml | 13 + .../blackbox/testdata-android/aidl/aidl.qbs | 8 + .../aidl/io/qbs/aidltest/Interface1.aidl | 7 + .../aidl/io/qbs/aidltest/Interface2.aidl | 5 + .../aidl/io/qbs/aidltest/MainActivity.java | 18 + .../minimal-native/libdependency.so | 0 .../minimal-native/minimal-native.qbs | 13 + .../src/main/AndroidManifest.xml | 13 + .../main/java/my/minimal/MinimalNative.java | 22 + .../minimal-native/src/main/native/native.c | 9 + .../multiple-apks-per-project.qbs | 6 + .../product1/product1.qbs | 34 + .../product1/src/main/AndroidManifest.xml | 14 + .../src/main/java/io/qt/dummy1/Dummy.java | 19 + .../product1/src/main/jni/lib1.cpp | 29 + .../product1/src/main/jni/lib2.cpp | 29 + .../product1/src/main/res/values/strings.xml | 3 + .../product2/product2.qbs | 29 + .../product2/src/main/AndroidManifest.xml | 14 + .../src/main/java/io/qt/dummy2/Dummy.java | 17 + .../product2/src/main/jni/lib1.cpp | 29 + .../product2/src/main/jni/lib2.cpp | 29 + .../io/qbs/lib3/lib3.java | 6 + .../multiple-libs-per-apk/lib4.java | 2 + .../multiple-libs-per-apk/lib5.java | 2 + .../multiple-libs-per-apk/lib6.java | 2 + .../multiple-libs-per-apk/lib7.java | 2 + .../multiple-libs-per-apk/lib8.java | 2 + .../multiple-libs-per-apk.qbs | 84 + .../src/main/AndroidManifest.xml | 14 + .../src/main/java/io/qt/dummy/Dummy.java | 19 + .../src/main/jni/lib1.cpp | 29 + .../src/main/jni/lib2.cpp | 29 + .../src/main/res/values/strings.xml | 3 + .../testdata-android/no-native/no-native.qbs | 9 + .../testdata-android/qml-app/main.cpp | 21 + .../testdata-android/qml-app/main.qml | 9 + .../testdata-android/qml-app/qml-app.qbs | 16 + .../blackbox/testdata-android/qml-app/qml.qrc | 5 + .../qml-app/src/main/AndroidManifest.xml | 78 + .../qml-app/src/main/assets/dummyasset.txt | 0 .../testdata-android/qt-app/MainWindow.cpp | 11 + .../testdata-android/qt-app/MainWindow.h | 15 + .../testdata-android/qt-app/Test.java | 54 + .../testdata-android/qt-app/TestQt6.java | 54 + .../blackbox/testdata-android/qt-app/main.cpp | 11 + .../testdata-android/qt-app/qt-app.qbs | 27 + .../testdata-android/qt-app/test.keystore | Bin 0 -> 1284 bytes .../testdata-android/teapot/teapot.qbs | 150 + .../aggregateDependencyLinking.qbs | 56 + .../aggregateDependencyLinking/app.c | 8 + .../aggregateDependencyLinking/lib.c | 12 + .../testdata-apple/apple-dmg/apple-dmg.qbs | 81 + .../apple-dmg/de_DE.lproj/eula.txt | 6 + .../apple-dmg/en_GB.lproj/eula.txt | 6 + .../apple-dmg/en_US.lproj/eula.txt | 6 + .../apple-dmg/fr_FR.lproj/eula.txt | 6 + .../testdata-apple/apple-dmg/hello.icns | Bin 0 -> 1393763 bytes .../testdata-apple/apple-dmg/hello.tif | Bin 0 -> 866742 bytes .../apple-dmg/ja_JP.lproj/eula.txt | 6 + .../apple-dmg/ko_KR.lproj/eula.rtf | 49 + .../blackbox/testdata-apple/apple-dmg/main.c | 1 + .../apple-dmg/ru_RU.lproj/eula.txt | 6 + .../apple-dmg/white.iconset/icon_16x16.png | Bin 0 -> 649 bytes .../apple-dmg/white.iconset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../apple-dmg/zh_CN.lproj/eula.odt | Bin 0 -> 2680 bytes .../apple-dmg/zh_TW.lproj/eula.docx | Bin 0 -> 12338 bytes .../testdata-apple/apple-multiconfig/app.c | 2 + .../apple-multiconfig/apple-multiconfig.qbs | 187 + .../testdata-apple/apple-multiconfig/lib.c | 12 + .../bundle-structure/bundle-structure.qbs | 146 + .../testdata-apple/bundle-structure/dummy.c | 29 + .../testdata-apple/bundle-structure/dummy.h | 27 + .../testdata-apple/bundle-structure/dummy_p.h | 27 + .../bundle-structure/resource.txt | 0 .../blackbox/testdata-apple/codesign/app.cpp | 1 + .../testdata-apple/codesign/codesign.qbs | 51 + .../deploymentTarget/deployment.qbs | 14 + .../testdata-apple/deploymentTarget/main.c | 29 + .../embedInfoPlist/embedInfoPlist.qbs | 48 + .../testdata-apple/embedInfoPlist/main.m | 9 + .../frameworkStructure/BaseResource | 0 .../frameworkStructure/Widget.cpp | 29 + .../frameworkStructure/Widget.h | 29 + .../frameworkStructure/WidgetPrivate.h | 27 + .../en.lproj/EnglishResource | 0 .../frameworkStructure/frameworkStructure.qbs | 19 + .../AppIcon.appiconset/100.png | Bin 0 -> 6652 bytes .../AppIcon.appiconset/114.png | Bin 0 -> 7757 bytes .../AppIcon.appiconset/120.png | Bin 0 -> 7734 bytes .../AppIcon.appiconset/128.png | Bin 0 -> 8774 bytes .../AppIcon.appiconset/144.png | Bin 0 -> 9498 bytes .../AppIcon.appiconset/152.png | Bin 0 -> 10734 bytes .../AppIcon.appiconset/16.png | Bin 0 -> 811 bytes .../AppIcon.appiconset/167.png | Bin 0 -> 11990 bytes .../AppIcon.appiconset/172.png | Bin 0 -> 12179 bytes .../AppIcon.appiconset/180.png | Bin 0 -> 12444 bytes .../AppIcon.appiconset/196.png | Bin 0 -> 14143 bytes .../AppIcon.appiconset/20.png | Bin 0 -> 1012 bytes .../AppIcon.appiconset/216.png | Bin 0 -> 15831 bytes .../AppIcon.appiconset/256.png | Bin 0 -> 18825 bytes .../AppIcon.appiconset/29.png | Bin 0 -> 1644 bytes .../AppIcon.appiconset/32.png | Bin 0 -> 1835 bytes .../AppIcon.appiconset/40.png | Bin 0 -> 2484 bytes .../AppIcon.appiconset/48.png | Bin 0 -> 2746 bytes .../AppIcon.appiconset/50.png | Bin 0 -> 3075 bytes .../AppIcon.appiconset/512.png | Bin 0 -> 41488 bytes .../AppIcon.appiconset/55.png | Bin 0 -> 3418 bytes .../AppIcon.appiconset/57.png | Bin 0 -> 3532 bytes .../AppIcon.appiconset/58.png | Bin 0 -> 3543 bytes .../AppIcon.appiconset/60.png | Bin 0 -> 3679 bytes .../AppIcon.appiconset/64.png | Bin 0 -> 3984 bytes .../AppIcon.appiconset/72.png | Bin 0 -> 4525 bytes .../AppIcon.appiconset/76.png | Bin 0 -> 4785 bytes .../AppIcon.appiconset/80.png | Bin 0 -> 5180 bytes .../AppIcon.appiconset/87.png | Bin 0 -> 5632 bytes .../AppIcon.appiconset/88.png | Bin 0 -> 5784 bytes .../AppIcon.appiconset/Contents.json | 299 + .../ib/appiconset/appiconset.qbs | 10 + .../testdata-apple/ib/appiconset/main.c | 1 + .../assetcatalog/EmptyStoryboard.storyboard | 8 + .../ib/assetcatalog/MainMenu.xib | 4666 ++ .../ib/assetcatalog/Storyboard.storyboard | 53 + .../ib/assetcatalog/assetcatalogempty.qbs | 29 + .../empty.iconset/icon_16x16.png | Bin 0 -> 649 bytes .../empty.iconset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../other.imageset/Contents.json | 22 + .../other.imageset/icon_16x16.png | Bin 0 -> 649 bytes .../other.imageset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../testdata-apple/ib/assetcatalog/main.c | 32 + .../assetcatalog1.xcassets/.keep | 0 .../assetcatalog2.xcassets/.keep | 0 .../ib/empty-asset-catalogs/main.c | 29 + .../multiple-asset-catalogs.qbs | 8 + .../testdata-apple/ib/iconset/iconset.qbs | 5 + .../ib/iconset/white.iconset/icon_16x16.png | Bin 0 -> 649 bytes .../iconset/white.iconset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../ib/iconsetapp/iconsetapp.qbs | 9 + .../testdata-apple/ib/iconsetapp/main.c | 32 + .../iconsetapp/white.iconset/icon_16x16.png | Bin 0 -> 649 bytes .../white.iconset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../other.imageset/Contents.json | 22 + .../other.imageset/icon_16x16.png | Bin 0 -> 649 bytes .../other.imageset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../other.imageset/Contents.json | 22 + .../other.imageset/icon_16x16.png | Bin 0 -> 649 bytes .../other.imageset/icon_16x16@2x.png | Bin 0 -> 665 bytes .../ib/multiple-asset-catalogs/main.c | 29 + .../multiple-asset-catalogs.qbs | 8 + .../infoPlistVariables/Info.plist | 24 + .../infoPlistVariables/infoPlistVariables.qbs | 16 + .../testdata-apple/infoPlistVariables/main.c | 1 + .../testdata-apple/infoplist/infoplist.qbs | 4 + .../blackbox/testdata-apple/infoplist/main.c | 29 + .../testdata-apple/multiarch-helpers.js | 74 + .../blackbox/testdata-apple/objc-arc/arc.m | 3 + .../blackbox/testdata-apple/objc-arc/arc.mm | 3 + .../blackbox/testdata-apple/objc-arc/main.m | 4 + .../blackbox/testdata-apple/objc-arc/mrc.m | 3 + .../blackbox/testdata-apple/objc-arc/mrc.mm | 3 + .../testdata-apple/objc-arc/objc-arc.qbs | 19 + .../overrideInfoPlist/Override-Info.plist | 10 + .../testdata-apple/overrideInfoPlist/main.c | 1 + .../overrideInfoPlist/overrideInfoPlist.qbs | 16 + .../testdata-apple/xcode/xcode-project.qbs | 58 + .../BareMetalApplication.qbs | 29 + .../testdata-baremetal/BareMetalProduct.qbs | 158 + .../BareMetalStaticLibrary.qbs | 3 + .../compiler-defines-by-language/app.c | 4 + .../compiler-defines-by-language.qbs | 73 + .../compiler-defines-by-language/cpptest.cpp | 0 .../compiler-defines-by-language/ctest.c | 0 .../compiler-include-paths.qbs | 9 + .../compiler-include-paths/main.c | 4 + .../compiler-listing/compiler-listing.qbs | 14 + .../testdata-baremetal/compiler-listing/fun.c | 4 + .../compiler-listing/main.c | 6 + .../blackbox/testdata-baremetal/cosmic.lkf | 1 + .../testdata-baremetal/defines/defines.qbs | 6 + .../testdata-baremetal/defines/main.c | 11 + .../distribution-include-paths/bar/bar.h | 6 + .../distribution-include-paths.qbs | 6 + .../distribution-include-paths/foo/foo.h | 6 + .../distribution-include-paths/main.c | 7 + .../external-static-libraries.qbs | 34 + .../external-static-libraries/lib-a.c | 4 + .../external-static-libraries/lib-b.c | 6 + .../external-static-libraries/main.c | 6 + .../linker-map/linker-map.qbs | 8 + .../testdata-baremetal/linker-map/main.c | 4 + .../one-object-application/main.c | 4 + .../one-object-application.qbs | 5 + .../one-object-asm-application/78k-iar.s | 6 + .../one-object-asm-application/arm-cosmic.s | 5 + .../one-object-asm-application/arm-gcc.s | 5 + .../one-object-asm-application/arm-iar.s | 7 + .../one-object-asm-application/arm-keil.s | 7 + .../one-object-asm-application/avr-gcc.s | 6 + .../one-object-asm-application/avr-iar.s | 7 + .../one-object-asm-application/avr32-gcc.s | 8 + .../one-object-asm-application/avr32-iar.s | 7 + .../one-object-asm-application/c166-keil.s | 7 + .../one-object-asm-application/cr16-iar.s | 6 + .../one-object-asm-application/hcs12-cosmic.s | 5 + .../one-object-asm-application/hcs12-iar.s | 7 + .../one-object-asm-application/hcs8-cosmic.s | 5 + .../one-object-asm-application/hcs8-iar.s | 6 + .../one-object-asm-application/hcs8-sdcc.s | 6 + .../one-object-asm-application/m16c-iar.s | 6 + .../one-object-asm-application/m32c-gcc.s | 5 + .../one-object-asm-application/m32c-iar.s | 6 + .../one-object-asm-application/m32r-gcc.s | 9 + .../one-object-asm-application/m68k-cosmic.s | 5 + .../one-object-asm-application/m68k-gcc.s | 7 + .../one-object-asm-application/m68k-iar.s | 6 + .../one-object-asm-application/mcs251-keil.s | 8 + .../one-object-asm-application/mcs51-iar.s | 7 + .../one-object-asm-application/mcs51-keil.s | 8 + .../one-object-asm-application/mcs51-sdcc.s | 7 + .../one-object-asm-application/msp430-gcc.s | 5 + .../one-object-asm-application/msp430-iar.s | 6 + .../one-object-asm-application.qbs | 122 + .../one-object-asm-application/r32c-iar.s | 7 + .../one-object-asm-application/rh850-iar.s | 7 + .../one-object-asm-application/riscv-gcc.s | 11 + .../one-object-asm-application/riscv-iar.s | 7 + .../one-object-asm-application/rl78-gcc.s | 11 + .../one-object-asm-application/rl78-iar.s | 7 + .../one-object-asm-application/rx-gcc.s | 8 + .../one-object-asm-application/rx-iar.s | 5 + .../one-object-asm-application/sh-iar.s | 7 + .../one-object-asm-application/stm8-cosmic.s | 7 + .../one-object-asm-application/stm8-iar.s | 7 + .../one-object-asm-application/stm8-sdcc.s | 7 + .../one-object-asm-application/v850-gcc.s | 11 + .../one-object-asm-application/v850-iar.s | 7 + .../one-object-asm-application/xtensa-gcc.s | 11 + .../preinclude-headers/main.c | 4 + .../preinclude-headers/preinclude-headers.qbs | 18 + .../preinclude-headers/preinclude.h | 6 + .../testdata-baremetal/shared-libraries/app.c | 12 + .../shared-libraries/shared-libraries.qbs | 32 + .../shared-libraries/shared.c | 19 + .../static-library-dependencies/a1.c | 4 + .../static-library-dependencies/a2.c | 4 + .../static-library-dependencies/app.c | 6 + .../static-library-dependencies/b.c | 6 + .../static-library-dependencies/c.c | 6 + .../static-library-dependencies/d.c | 7 + .../static-library-dependencies/e.c | 7 + .../static-library-dependencies.qbs | 40 + .../system-include-paths/bar/bar.h | 6 + .../system-include-paths/foo/foo.h | 6 + .../system-include-paths/main.c | 7 + .../system-include-paths.qbs | 6 + .../target-platform/target-platform.qbs | 19 + .../toolchain-probe/probes/dmc.qbs | 31 + .../toolchain-probe/probes/sdcc.qbs | 29 + .../toolchain-probe/probes/watcom.qbs | 34 + .../toolchain-probe/toolchain-probe.qbs | 7 + .../two-object-application/fun.c | 4 + .../two-object-application/main.c | 6 + .../two-object-application.qbs | 5 + .../user-include-paths/bar/bar.h | 6 + .../user-include-paths/foo/foo.h | 6 + .../user-include-paths/main.c | 7 + .../user-include-paths/user-include-paths.qbs | 6 + .../project1/i like spaces.cpp | 42 + .../testdata-clangdb/project1/project.qbs | 41 + .../auto/blackbox/testdata-java/java/Car.java | 23 + .../blackbox/testdata-java/java/Car8.java | 28 + .../testdata-java/java/HelloWorld.java | 15 + .../testdata-java/java/HelloWorld8.java | 8 + .../auto/blackbox/testdata-java/java/Jet.java | 7 + .../blackbox/testdata-java/java/Manifest.mf | 1 + .../blackbox/testdata-java/java/Manifest2.mf | 2 + .../testdata-java/java/NoPackage.java | 5 + .../testdata-java/java/RandomStuff.java | 6 + .../blackbox/testdata-java/java/Ship.java | 12 + .../blackbox/testdata-java/java/Vehicle.java | 4 + .../blackbox/testdata-java/java/Vehicles.java | 37 + .../auto/blackbox/testdata-java/java/engine.c | 38 + .../java/inner-class/InnerClass.java | 6 + .../java/inner-class/inner-class.qbs | 3 + .../blackbox/testdata-java/java/vehicles.qbs | 115 + .../job-limits-init/job-limits-init.qbs | 10 + .../job-limits/job-limits.qbs | 97 + .../testdata-joblimits/job-limits/main.cpp | 87 + ...dd-qobject-macro-to-generated-cpp-file.qbs | 25 + .../main.cpp | 35 + .../object.cpp.in | 41 + .../object.h | 32 + .../testdata-qt/auto-qrc/auto-qrc.qbs | 41 + .../blackbox/testdata-qt/auto-qrc/main.cpp | 18 + .../auto-qrc/qrc-base/resource1.txt | 1 + .../auto-qrc/qrc-base/subdir/resource2.txt | 1 + .../auto-qrc/qrc-base/subdir/resource3.txt | 1 + .../testdata-qt/cached-qml/MainForm.ui.qml | 29 + .../testdata-qt/cached-qml/cached-qml.qbs | 38 + .../blackbox/testdata-qt/cached-qml/main.cpp | 14 + .../blackbox/testdata-qt/cached-qml/main.qml | 17 + .../blackbox/testdata-qt/cached-qml/qml.qrc | 7 + .../blackbox/testdata-qt/cached-qml/stuff.js | 1 + .../testdata-qt/combined-moc/combined-moc.qbs | 7 + .../testdata-qt/combined-moc/main.cpp | 6 + .../testdata-qt/combined-moc/theobject.h | 6 + .../testdata-qt/create-project/dummy.txt | 0 .../THIS.IS.A.STRANGE.FILENAME.CAR.XML | 11 + .../testdata-qt/dbus-adaptors/car.cpp | 149 + .../blackbox/testdata-qt/dbus-adaptors/car.h | 61 + .../testdata-qt/dbus-adaptors/car.qbs | 18 + .../testdata-qt/dbus-adaptors/main.cpp | 88 + .../testdata-qt/dbus-interfaces/car.xml | 11 + .../dbus-interfaces/controller.cpp | 93 + .../testdata-qt/dbus-interfaces/controller.h | 57 + .../dbus-interfaces/controller.qbs | 19 + .../testdata-qt/dbus-interfaces/controller.ui | 64 + .../testdata-qt/dbus-interfaces/main.cpp | 67 + .../testdata-qt/forced-moc/createqtclass.h | 14 + .../testdata-qt/forced-moc/forced-moc.qbs | 26 + .../blackbox/testdata-qt/forced-moc/main.cpp | 14 + .../testdata-qt/forced-moc/myqtclass.h | 8 + .../included-moc-cpp/included-moc-cpp.qbs | 16 + .../testdata-qt/included-moc-cpp/main.cpp | 7 + .../testdata-qt/included-moc-cpp/myobject.cpp | 3 + .../testdata-qt/included-moc-cpp/myobject.h | 11 + .../testdata-qt/linker-variant/main.cpp | 6 + .../linker-variant/qt-linker-variant.qbs | 10 + .../auto/blackbox/testdata-qt/lrelease/de.ts | 23 + .../auto/blackbox/testdata-qt/lrelease/hu.ts | 15 + .../testdata-qt/lrelease/lrelease.qbs | 6 + .../testdata-qt/metatypes/metatypes.qbs | 28 + .../testdata-qt/metatypes/mocableclass1.cpp | 3 + .../testdata-qt/metatypes/mocableclass1.h | 8 + .../testdata-qt/metatypes/mocableclass2.cpp | 10 + .../testdata-qt/metatypes/unmocableclass.cpp | 7 + .../testdata-qt/mixed-build-variants/main.cpp | 34 + .../mixed-build-variants.qbs | 9 + .../moc-and-cxx-combining/main.cpp | 6 + .../moc-and-cxx-combining.qbs | 4 + .../moc-and-cxx-combining/myobject.cpp | 14 + .../moc-and-cxx-combining/myobject.h | 6 + .../testdata-qt/moc-compiler-defines/main.cpp | 7 + .../moc-compiler-defines.qbs | 3 + .../moc-compiler-defines/object.cpp | 6 + .../testdata-qt/moc-compiler-defines/object.h | 58 + .../blackbox/testdata-qt/moc-flags/blubb.h | 37 + .../blackbox/testdata-qt/moc-flags/main.cpp | 34 + .../testdata-qt/moc-flags/moc-flags.qbs | 3 + .../testdata-qt/moc-same-file-name/main.cpp | 8 + .../moc-same-file-name/moc-same-file-name.qbs | 25 + .../moc-same-file-name/src1/someclass.cpp | 7 + .../moc-same-file-name/src1/someclass.h | 17 + .../moc-same-file-name/src1/somefile.cpp | 13 + .../moc-same-file-name/src2/someclass.cpp | 7 + .../moc-same-file-name/src2/someclass.h | 17 + .../moc-same-file-name/src2/somefile.cpp | 13 + .../testdata-qt/no-relink-on-qdebug/lib.cpp | 8 + .../testdata-qt/no-relink-on-qdebug/lib.h | 18 + .../testdata-qt/no-relink-on-qdebug/main.cpp | 3 + .../no-relink-on-qdebug/symbols-test.qbs | 27 + .../testdata-qt/pkgconfig-qt/dump-libpath.qbs | 6 + .../testdata-qt/pkgconfig-qt/main.cpp | 1 + .../module-providers/dummyProvider.qbs | 3 + .../testdata-qt/pkgconfig-qt/pkgconfig-qt.qbs | 6 + .../blackbox/testdata-qt/pkgconfig/main.cpp | 46 + .../testdata-qt/pkgconfig/pkgconfig.qbs | 24 + .../testdata-qt/plugin-meta-data/app.cpp | 83 + .../plugin-meta-data/metadata.json | 3 + .../plugin-meta-data/plugin-meta-data.qbs | 67 + .../plugin-meta-data/theplugin.cpp | 38 + .../plugin-support/modules/m1/m1.qbs | 12 + .../plugin-support/modules/m2/m2.qbs | 7 + .../plugin-support/plugin-support-main.cpp | 1 + .../plugin-support/plugin-support.qbs | 28 + .../testdata-qt/qml-debugging/main.cpp | 56 + .../qml-debugging/qml-debugging.qbs | 7 + .../testdata-qt/qmltyperegistrar/example.qml | 58 + .../testdata-qt/qmltyperegistrar/main.cpp | 71 + .../testdata-qt/qmltyperegistrar/person.cpp | 78 + .../testdata-qt/qmltyperegistrar/person.h | 78 + .../qmltyperegistrar/qmltyperegistrar.qbs | 33 + .../testdata-qt/qobject-in-mm/main.mm | 13 + .../qobject-in-mm/qobject-in-mm.qbs | 4 + tests/auto/blackbox/testdata-qt/qrc/bla.cpp | 44 + tests/auto/blackbox/testdata-qt/qrc/bla.qrc | 6 + tests/auto/blackbox/testdata-qt/qrc/i.qbs | 31 + tests/auto/blackbox/testdata-qt/qrc/stuff.txt | 1 + .../blackbox/testdata-qt/qrc/subdir/dummy.txt | 0 tests/auto/blackbox/testdata-qt/qrc/test.cpp | 1 + .../blackbox/testdata-qt/qt-keywords/main.cpp | 14 + .../testdata-qt/qt-keywords/qt-keywords.qbs | 3 + .../qtscxml/dummystatemachine.scxml | 3 + .../blackbox/testdata-qt/qtscxml/main.cpp | 15 + .../blackbox/testdata-qt/qtscxml/qtscxml.qbs | 63 + .../testdata-qt/quick-compiler/main.cpp | 18 + .../testdata-qt/quick-compiler/qml.qrc | 5 + .../quick-compiler/qml/subdir/test.qml | 5 + .../quick-compiler/quick-compiler.qbs | 26 + .../remove-moc-header-from-file-list/file.cpp | 10 + .../remove-moc-header-from-file-list/file.h | 13 + .../remove-moc-header-from-file-list.qbs | 7 + .../static-qt-plugin-linking/lib.cpp | 1 + .../static-qt-plugin-linking/main.cpp | 7 + .../static-qt-plugin-linking.qbs | 26 + .../trackAddMocInclude/after/main.cpp | 49 + .../trackAddMocInclude/before/main.cpp | 47 + .../trackAddMocInclude/before/test.qbs | 6 + .../testdata-qt/trackQObjChange/bla.cpp | 35 + .../trackQObjChange/bla_noqobject.h | 34 + .../testdata-qt/trackQObjChange/bla_qobject.h | 35 + .../testdata-qt/trackQObjChange/i.qbs | 17 + .../auto/blackbox/testdata-qt/unmocable/foo.h | 2 + .../blackbox/testdata-qt/unmocable/main.cpp | 6 + .../testdata-qt/unmocable/unmocable.qbs | 9 + .../testdata-windows/codesign/app.cpp | 1 + .../testdata-windows/codesign/codesign.qbs | 43 + .../testdata-windows/innosetup/inc/qbsinc.iss | 0 .../testdata-windows/innosetup/innosetup.qbs | 25 + .../testdata-windows/innosetup/test.iss | 6 + .../innosetupDependencies.qbs | 76 + .../innosetupDependencies/main.c | 1 + .../innosetupDependencies/test.iss | 8 + .../testdata-windows/wix/ExampleScript.bat | 1 + .../testdata-windows/wix/QbsBootstrapper.wxs | 10 + .../testdata-windows/wix/QbsSetup.wxs | 34 + .../auto/blackbox/testdata-windows/wix/Qt.wxs | 5 + .../testdata-windows/wix/WiXInstallers.qbs | 39 + .../auto/blackbox/testdata-windows/wix/de.wxl | 1 + .../wixDependencies/QbsSetup.wxs | 37 + .../testdata-windows/wixDependencies/main.c | 1 + .../wixDependencies/wixDependencies.qbs | 67 + .../QTBUG-51237/modules/mymodule/mymodule.qbs | 4 + .../testdata/QTBUG-51237/qtbug-51237.qbs | 17 + .../add-filetag-to-generated-artifact.qbs | 35 + .../main.cpp | 1 + .../allowed-values/allowed-values.qbs | 19 + .../testdata/allowed-values/modules/a/a.qbs | 18 + .../blackbox/testdata/always-run/dummy.txt | 0 .../blackbox/testdata/always-run/rule.qbs | 28 + .../testdata/always-run/transformer.qbs | 22 + .../blackbox/testdata/archiver/archivable.qbs | 11 + .../auto/blackbox/testdata/archiver/list.txt | 2 + .../auto/blackbox/testdata/archiver/test.txt | 0 .../artifact-scanning/artifact-scanning.qbs | 30 + .../artifact-scanning/external-indirect.h | 0 .../testdata/artifact-scanning/external.h | 1 + .../testdata/artifact-scanning/p1.cpp | 4 + .../testdata/artifact-scanning/p2.cpp | 3 + .../testdata/artifact-scanning/p3.cpp | 3 + .../testdata/artifact-scanning/shared.h | 1 + .../artifact-scanning/subdir/external2.h | 0 .../artifacts-map-change-tracking.qbs | 85 + .../artifacts-map-change-tracking/dummy.in | 0 .../artifacts-map-change-tracking/main.cpp | 3 + .../artifacts-map-change-tracking/test.cpp.in | 1 + .../artifacts-map-change-tracking/test.txt | 0 .../artifacts-map-invalidation.qbs | 57 + .../artifacts-map-invalidation/file.in | 0 .../artifacts-map-race-condition.qbs | 73 + .../blackbox/testdata/assembly/assembly.qbs | 74 + tests/auto/blackbox/testdata/assembly/testa.s | 3 + tests/auto/blackbox/testdata/assembly/testb.S | 3 + .../auto/blackbox/testdata/assembly/testc.sx | 3 + .../blackbox/testdata/assembly/testd_x86.asm | 11 + .../testdata/assembly/testd_x86_64.asm | 8 + .../autotest-timeout/autotests-timeout.qbs | 28 + .../testdata/autotest-timeout/test-main.cpp | 37 + .../autotest-with-dependencies.qbs | 38 + .../helper-main.cpp | 7 + .../autotest-with-dependencies/test-main.cpp | 10 + .../blackbox/testdata/autotests/autotests.qbs | 17 + .../testdata/autotests/test1/test1.cpp | 12 + .../testdata/autotests/test1/test1.qbs | 9 + .../autotests/test2/test2-resource.txt | 0 .../testdata/autotests/test2/test2.cpp | 13 + .../testdata/autotests/test2/test2.qbs | 9 + .../testdata/autotests/test3/test3.cpp | 9 + .../testdata/autotests/test3/test3.qbs | 9 + .../aux-inputs-from-deps.qbs | 79 + .../testdata/aux-inputs-from-deps/main.cpp | 3 + .../testdata/aux-inputs-from-deps/util.js | 8 + .../badInterpreter/badInterpreter.qbs | 56 + .../qbs/modules/script-test/script-test.qbs | 38 + .../badInterpreter/script-interp-missing | 1 + .../badInterpreter/script-interp-noexec | 1 + .../testdata/badInterpreter/script-noexec | 0 .../testdata/badInterpreter/script-ok | 1 + .../testdata/bom-sources/bom-sources.qbs | 4 + .../blackbox/testdata/bom-sources/main.cpp | 3 + .../blackbox/testdata/bom-sources/theheader.h | 0 .../build-data-of-disabled-product.qbs | 4 + .../build-data-of-disabled-product/main.cpp | 6 + .../build-data-of-disabled-product/test.cpp | 1 + .../build-directories/build-directories.qbs | 37 + .../build-graph-versions.qbs | 3 + .../testdata/build-graph-versions/main.cpp | 1 + .../build-variant-defaults.qbs | 16 + .../testdata/build-variant-defaults/main.cpp | 1 + .../buildenv-change/buildenv-change.qbs | 16 + .../blackbox/testdata/buildenv-change/file.c | 1 + .../testdata/buildenv-change/main.cpp | 3 + .../buildenv-change/subdir/theheader.h | 0 .../buildenv-change/subdir2/theheader.h | 0 .../blackbox/testdata/capnproto/bar.capnp | 8 + .../blackbox/testdata/capnproto/baz.capnp | 8 + .../capnproto/capnproto_absolute_import.cpp | 14 + .../capnproto/capnproto_absolute_import.qbs | 20 + .../testdata/capnproto/capnproto_cpp.cpp | 13 + .../testdata/capnproto/capnproto_cpp.qbs | 18 + .../capnproto/capnproto_cpp_pkgconfig.qbs | 19 + .../capnproto/capnproto_relative_import.cpp | 14 + .../capnproto/capnproto_relative_import.qbs | 19 + .../blackbox/testdata/capnproto/foo.capnp | 6 + .../testdata/capnproto/greeter-client.cpp | 25 + .../testdata/capnproto/greeter-server.cpp | 27 + .../blackbox/testdata/capnproto/greeter.capnp | 13 + .../testdata/capnproto/greeter_cpp.qbs | 34 + .../testdata/capnproto/imports/foo.capnp | 6 + .../change-in-disabled-product.qbs | 7 + .../change-in-disabled-product/test1.txt | 0 .../change-in-disabled-product/test2.txt | 0 .../change-in-imported-file.qbs | 22 + .../change-in-imported-file/prepare.js | 3 + .../testdata/change-in-imported-file/test.txt | 0 .../change-tracking-and-multiplexing.qbs | 11 + .../change-tracking-and-multiplexing/lib.cpp | 1 + .../testdata/changed-files/changed-files.qbs | 29 + .../blackbox/testdata/changed-files/file1.cpp | 29 + .../blackbox/testdata/changed-files/file2.cpp | 29 + .../blackbox/testdata/changed-files/main.cpp | 29 + .../changed-inputs-from-dependencies.qbs | 58 + .../input.txt | 0 .../changed-rule-inputs.qbs | 40 + .../check-timestamps/check-timestamps.qbs | 8 + .../testdata/check-timestamps/file.cpp | 3 + .../blackbox/testdata/check-timestamps/file.h | 1 + .../testdata/check-timestamps/main.cpp | 1 + .../choose-module-instance.qbs | 17 + .../choose-module-instance/gerbil.txt.in | 5 + .../modules/limerick/lord.qbs | 5 + .../modules/limerick/ritchie.qbs | 7 + .../modules/limerick/generic.qbs | 3 + tests/auto/blackbox/testdata/clean/clean.qbs | 19 + tests/auto/blackbox/testdata/clean/dep.cpp | 31 + tests/auto/blackbox/testdata/clean/main.cpp | 29 + .../auto/blackbox/testdata/cli/HelloWorld.cs | 12 + tests/auto/blackbox/testdata/cli/Libby.cs | 10 + tests/auto/blackbox/testdata/cli/Libby2.cs | 10 + tests/auto/blackbox/testdata/cli/Module.cs | 10 + tests/auto/blackbox/testdata/cli/Module.vb | 7 + .../auto/blackbox/testdata/cli/dotnettest.qbs | 49 + tests/auto/blackbox/testdata/cli/fshello.fs | 1 + tests/auto/blackbox/testdata/cli/fshello.qbs | 6 + .../testdata/combined-sources/combinable.cpp | 1 + .../combined-sources/combined-sources.qbs | 11 + .../testdata/combined-sources/main.cpp | 1 + .../combined-sources/uncombinable.cpp | 1 + .../testdata/command-file/command-file.qbs | 19 + .../blackbox/testdata/command-file/lib.cpp | 1 + .../blackbox/testdata/command-file/list.gcc | 1 + .../blackbox/testdata/command-file/list.msvc | 1 + .../blackbox/testdata/command-file/main.cpp | 6 + .../CppDefinesApp.qbs | 22 + .../testdata/compilerDefinesByLanguage/app.c | 4 + .../compilerDefinesByLanguage.qbs | 169 + .../testdata/compilerDefinesByLanguage/test.c | 0 .../compilerDefinesByLanguage/test.cpp | 0 .../testdata/compilerDefinesByLanguage/test.m | 0 .../compilerDefinesByLanguage/test.mm | 0 .../testapp/conanfile-probe-project.qbs | 23 + .../conanfile-probe/testapp/conanfile.py | 26 + .../conanfile-probe/testlib/conanfile.py | 25 + .../concurrent-executor.qbs | 67 + .../testdata/concurrent-executor/dummy1.input | 0 .../testdata/concurrent-executor/dummy2.input | 0 .../testdata/concurrent-executor/util.js | 8 + .../conditional-export/conditional-export.qbs | 16 + .../testdata/conditional-export/main.cpp | 33 + .../conditional-filetagger.qbs | 10 + .../conditional-filetagger/main.custom | 1 + .../blackbox/testdata/configure/configure.qbs | 21 + .../auto/blackbox/testdata/configure/main.cpp | 36 + .../configure/modules/definition/module.qbs | 34 + .../conflicting-artifacts.qbs | 14 + .../testdata/conflicting-artifacts/main.cpp | 29 + .../testdata/cpu-features/cpu-features.qbs | 14 + .../blackbox/testdata/cpu-features/main.cpp | 1 + .../cxx-language-version.qbs | 35 + .../testdata/cxx-language-version/main.cpp | 1 + .../dependenciesProperty.qbs | 42 + .../dependenciesProperty/product2.cpp | 29 + .../dependency-scanning-loop.qbs | 34 + .../dependency-scanning-loop/main.cpp | 1 + .../deprecated-property.qbs | 8 + .../modules/themodule/m.qbs | 27 + .../disappeared-profile.qbs | 12 + .../testdata/disappeared-profile/in1.txt | 0 .../testdata/disappeared-profile/in2.txt | 0 .../modules-dir/modules/m/m.qbs | 32 + .../discard-unused-data.qbs | 27 + .../testdata/discard-unused-data/main.cpp | 3 + .../distribution-include-paths.qbs | 4 + .../distribution-include-paths/main.cpp | 8 + .../subdir/gagagugu.h | 4 + .../driver-linker-flags.qbs | 17 + .../testdata/driver-linker-flags/main.cpp | 1 + .../dynamic-library-in-module/Dll.qbs | 15 + .../dynamic-library-in-module/lib1.cpp | 7 + .../dynamic-library-in-module/lib2.cpp | 7 + .../dynamic-library-in-module/lib3.cpp | 7 + .../dynamic-library-in-module/lib4.cpp | 8 + .../dynamic-library-in-module/lib5.cpp | 1 + .../dynamic-library-in-module/main.cpp | 13 + .../modules/thelib/broken.cpp | 1 + .../modules/thelib/thelib.qbs | 27 + .../modules/theotherlib/theotherlib.qbs | 21 + .../modules/thethirdlib/thethirdlib.qbs | 21 + .../dynamic-library-in-module/theapp.qbs | 39 + .../dynamic-library-in-module/thelibs.qbs | 14 + .../dynamic-project/dynamic-project.qbs | 41 + .../testdata/dynamic-project/src/app/main.cpp | 1 + .../dynamic-project/src/app2/main.cpp | 1 + .../dynamicMultiplexRule.qbs | 32 + .../testdata/dynamicMultiplexRule/one.txt | 0 .../testdata/dynamicMultiplexRule/three.txt | 0 .../testdata/dynamicMultiplexRule/two.txt | 0 .../dynamicRuleOutputs/after/numbers.l | 81 + .../before/flexoptionsreader.js | 103 + .../dynamicRuleOutputs/before/genlexer.qbs | 114 + .../dynamicRuleOutputs/before/numbers.l | 82 + .../testdata/empty-profile/empty-profile.qbs | 3 + .../blackbox/testdata/empty-profile/main.cpp | 1 + .../testdata/enableExceptions/empty.m | 1 + .../testdata/enableExceptions/empty.mm | 1 + .../testdata/enableExceptions/emptymain.cpp | 29 + .../enableExceptions/exceptions-objc.qbs | 4 + .../exceptions-objcpp-cpp.qbs | 6 + .../enableExceptions/exceptions-objcpp.qbs | 7 + .../testdata/enableExceptions/exceptions.qbs | 5 + .../testdata/enableExceptions/main.cpp | 40 + .../blackbox/testdata/enableExceptions/main.m | 5 + .../testdata/enableExceptions/none.qbs | 8 + .../blackbox/testdata/enableRtti/main.cpp | 59 + .../blackbox/testdata/enableRtti/rtti.qbs | 11 + .../testdata/env-merging/env-merging.qbs | 31 + .../auto/blackbox/testdata/env-merging/main.c | 8 + .../env-normalization/env-normalization.qbs | 11 + .../nonexistentWorkingDir.qbs | 18 + .../outputArtifacts-missing-filePath/main.cpp | 1 + .../outputArtifacts-missing-filePath.qbs | 16 + .../outputArtifacts-missing-fileTags/main.cpp | 1 + .../outputArtifacts-missing-fileTags.qbs | 16 + .../erroneous/tag-mismatch/tag-mismatch.qbs | 35 + .../boom.txt.in | 1 + .../texttemplate-unknown-placeholder.qbs | 6 + .../testdata/error-info/error-info.qbs | 71 + .../blackbox/testdata/error-info/helper.js | 9 + .../escaped-linker-flags.qbs | 13 + .../testdata/escaped-linker-flags/main.cpp | 1 + .../explicitly-depends-on.qbs | 123 + .../modules/module1/module-fish.txt | 1 + .../modules/module1/module1.qbs | 7 + .../testdata/explicitly-depends-on/step1.txt | 1 + .../blackbox/testdata/export-rule/blubber.cpp | 29 + .../testdata/export-rule/export-rule.qbs | 39 + .../blackbox/testdata/export-rule/myapp.blubb | 8 + .../export-to-outside-searchpath.qbs | 19 + .../qbs-resources/modules/aModule/aModule.qbs | 2 + ...xported-dependency-in-disabled-product.qbs | 17 + .../main.cpp | 1 + .../modules/broken/broken.qbs | 3 + .../exported-property-in-disabled-product.qbs | 18 + .../main.cpp | 1 + .../modules/broken/broken.qbs | 3 + .../testdata/exports-pkgconfig/TheFirstLib.pc | 10 + .../exports-pkgconfig/TheFirstLib_windows.pc | 10 + .../exports-pkgconfig/TheSecondLib.pc | 9 + .../exports-pkgconfig/boringstaticlib.cpp | 1 + .../exports-pkgconfig/exports-pkgconfig.qbs | 129 + .../testdata/exports-pkgconfig/firstlib.cpp | 3 + .../testdata/exports-pkgconfig/firstlib.h | 9 + .../modules/helper1/helper1.qbs | 5 + .../modules/helper2/helper2.qbs | 4 + .../modules/helper3/helper3.qbs | 4 + .../testdata/exports-pkgconfig/secondlib.cpp | 7 + .../testdata/exports-pkgconfig/secondlib.h | 9 + .../testdata/exports-qbs/consumer.cpp | 6 + .../testdata/exports-qbs/consumer.qbs | 29 + .../exports-qbs/exports-qbs-products.qbs | 0 .../testdata/exports-qbs/exports-qbs.qbs | 16 + .../testdata/exports-qbs/helper.cpp.in | 14 + .../blackbox/testdata/exports-qbs/helper.js | 1 + .../exports-qbs/imports/Helper2/helper2.js | 1 + .../blackbox/testdata/exports-qbs/lib.qbs | 59 + .../blackbox/testdata/exports-qbs/mylib.cpp | 5 + .../blackbox/testdata/exports-qbs/mylib.h | 17 + .../blackbox/testdata/exports-qbs/tool.cpp | 18 + .../blackbox/testdata/exports-qbs/tool.qbs | 57 + .../testdata/external-libs/external-libs.qbs | 33 + .../blackbox/testdata/external-libs/lib1.cpp | 1 + .../blackbox/testdata/external-libs/lib2.cpp | 3 + .../blackbox/testdata/external-libs/main.cpp | 6 + .../fallback-module-provider.qbs | 8 + .../libdir/qbsmetatestmodule.pc | 5 + .../fallback-module-provider/main.cpp | 5 + .../fileDependencies/awesomelib/awesome.h | 36 + .../fileDependencies/awesomelib/magnificent.h | 34 + .../fileDependencies/fileDependencies.qbs | 15 + .../testdata/fileDependencies/src/narf.cpp | 35 + .../testdata/fileDependencies/src/narf.h | 30 + .../testdata/fileDependencies/src/zort.cpp | 36 + .../filetagsfilter-merging/MyApplication.qbs | 9 + .../filetagsfilter-merging.qbs | 28 + .../testdata/filetagsfilter-merging/main.cpp | 1 + .../auto/blackbox/testdata/find/find-cli.qbs | 33 + .../testdata/freedesktop/freedesktop.qbs | 23 + .../blackbox/testdata/freedesktop/main.cpp | 4 + .../testdata/freedesktop/myapp.appdata.xml | 15 + .../testdata/freedesktop/myapp.desktop | 4 + .../blackbox/testdata/freedesktop/myapp.png | 0 .../generate-linker-map-file.qbs | 28 + .../generate-linker-map-file/main.cpp | 29 + .../input.txt | 1 + .../p.qbs | 54 + .../blackbox/testdata/generator/generator.qbs | 35 + .../testdata/generator/input.both.txt | 2 + .../testdata/generator/input.file1.txt | 1 + .../testdata/generator/input.file2.txt | 1 + .../testdata/generator/input.none.txt | 0 .../auto/blackbox/testdata/generator/main.cpp | 8 + .../group-condition-change.qbs | 25 + .../group-condition-change/input_kaputt.txt | 0 .../groups-in-modules/groups-in-modules.qbs | 30 + .../modules/helper/chunk.coal | 1 + .../modules/helper/diamondc.c | 54 + .../modules/helper/helper.qbs | 46 + .../modules/helper2/helper2.c | 29 + .../modules/helper2/helper2.qbs | 14 + .../modules/helper3/helper3.c | 29 + .../modules/helper3/helper3.qbs | 10 + .../modules/helper4/helper4.c | 29 + .../modules/helper4/helper4.qbs | 9 + .../modules/helper5/helper5.c | 33 + .../modules/helper5/helper5.qbs | 13 + .../modules/helper6/helper6.c | 29 + .../modules/helper6/helper6.qbs | 10 + .../testdata/groups-in-modules/rock.coal | 1 + .../groups-in-modules/someotherfile.txt | 0 .../groups-in-modules/someotherfile2.txt | 0 tests/auto/blackbox/testdata/grpc/grpc.cpp | 49 + tests/auto/blackbox/testdata/grpc/grpc.proto | 15 + .../auto/blackbox/testdata/grpc/grpc_cpp.qbs | 33 + .../host-os-properties/host-os-properties.qbs | 16 + .../testdata/host-os-properties/main.cpp | 7 + .../testdata/ico/dmg.iconset/icon_128x128.png | Bin 0 -> 5256 bytes .../testdata/ico/dmg.iconset/icon_16x16.png | Bin 0 -> 487 bytes .../testdata/ico/dmg.iconset/icon_256x256.png | Bin 0 -> 11304 bytes .../testdata/ico/dmg.iconset/icon_32x32.png | Bin 0 -> 1374 bytes .../testdata/ico/dmg.iconset/icon_512x512.png | Bin 0 -> 26984 bytes tests/auto/blackbox/testdata/ico/ico.qbs | 86 + .../auto/blackbox/testdata/ico/icon_16x16.png | Bin 0 -> 649 bytes .../auto/blackbox/testdata/ico/icon_32x32.png | Bin 0 -> 665 bytes .../import-assignment/import-assignment.qbs | 22 + .../imports/MyImport/myimport.js | 2 + .../import-change-tracking/custom1command.js | 3 + .../import-change-tracking/custom1prepare1.js | 4 + .../import-change-tracking/custom1prepare2.js | 10 + .../custom2prepare/custom2prepare1.js | 0 .../custom2prepare/custom2prepare2.js | 9 + .../import-change-tracking-product.qbs | 57 + .../import-change-tracking.qbs | 4 + .../imports/custom2command/custom2command1.js | 1 + .../imports/custom2command/custom2command2.js | 3 + .../import-change-tracking/input1.txt | 0 .../import-change-tracking/input2.txt | 0 .../import-change-tracking/irrelevant.js | 1 + .../testdata/import-change-tracking/probe1.js | 3 + .../testdata/import-change-tracking/probe2.js | 1 + .../import-in-properties-condition.qbs | 3 + .../modules/amodule/m.qbs | 9 + .../modules/depmodule/m.qbs | 3 + .../import-searchpath/import-searchpath.qbs | 9 + .../qbs/imports/CppApplication.qbs | 2 + .../src/import-searchpath-app1.qbs | 3 + .../src/import-searchpath-app2.qbs | 3 + .../testdata/import-searchpath/src/main.cpp | 1 + .../import-searchpath/src/somefile.cpp | 0 .../testdata/importing-product/header.h.in | 1 + .../importing-product/importing-product.qbs | 43 + .../testdata/importing-product/main.cpp | 29 + .../imports-conflict/imports-conflict.qbs | 9 + .../imports-conflict/modules/themodule/m.qbs | 5 + .../modules/themodule/utils.js | 1 + .../testdata/includeLookup/includeLookup.qbs | 21 + .../blackbox/testdata/includeLookup/main.cpp | 36 + .../modules/definition/fakeopenssl/sha.h | 0 .../modules/definition/module.qbs | 13 + .../input-tags-change-tracking.qbs | 63 + .../input-tags-change-tracking/input.txt | 1 + .../inputs-from-dependencies/file1.txt | 0 .../inputs-from-dependencies/file2.txt | 0 .../inputs-from-dependencies/file3.txt | 0 .../inputs-from-dependencies/file4.txt | 0 .../inputs-from-dependencies.qbs | 49 + .../install-duplicates-no-error/file1.txt | 0 .../install-duplicates-no-error/file2.txt | 0 .../install-duplicates-no-error/file3.txt | 0 .../install-duplicates-no-error.qbs | 35 + .../install-duplicates/dir1/file1.txt | 1 + .../install-duplicates/dir1/file2.txt | 1 + .../install-duplicates/dir2/file1.txt | 1 + .../install-duplicates/dir2/file2.txt | 1 + .../install-duplicates/dir2/file3.txt | 1 + .../install-duplicates/install-duplicates.qbs | 8 + .../install-locations/install-locations.qbs | 44 + .../testdata/install-locations/main.cpp | 1 + .../testdata/install-locations/thelib.cpp | 3 + .../testdata/install-locations/theplugin.cpp | 3 + .../install-root-from-project-file/file.txt | 0 .../install-root-from-project-file.qbs | 11 + .../testdata/install-tree/data/foo.txt | 0 .../install-tree/data/subdir1/bar.txt | 0 .../install-tree/data/subdir2/baz.txt | 0 .../testdata/install-tree/install-tree.qbs | 10 + .../blackbox/testdata/install-tree/main.cpp | 29 + .../installable-as-auxiliary-input.qbs | 85 + .../testdata/installable/installable.qbs | 42 + .../blackbox/testdata/installable/main.cpp | 29 + .../installed-source-files.qbs | 19 + .../testdata/installed-source-files/main.cpp | 29 + .../installed-source-files/readme.txt | 1 + .../installed-transformer-output/qbs668.qbs | 31 + .../installed_artifact/installed_artifact.qbs | 17 + .../testdata/installed_artifact/main.cpp | 29 + .../installpackage/installpackage.qbs | 49 + .../blackbox/testdata/installpackage/lib.cpp | 31 + .../blackbox/testdata/installpackage/lib.h | 37 + .../blackbox/testdata/installpackage/main.cpp | 34 + .../invalid-command-property/input.txt | 0 .../invalid-command-property.qbs | 32 + .../invalid-extension-instantiation.qbs | 26 + .../invalid-install-dir.qbs | 7 + .../testdata/invalid-install-dir/main.cpp | 1 + .../invalid-library-names.qbs | 10 + .../testdata/invalid-library-names/main.cpp | 29 + .../jsextensions-binaryfile/binaryfile.qbs | 44 + .../testdata/jsextensions-file/file.qbs | 52 + .../jsextensions-fileinfo/fileinfo.qbs | 49 + .../testdata/jsextensions-host/host.qbs | 31 + .../testdata/jsextensions-process/main.cpp | 20 + .../testdata/jsextensions-process/process.qbs | 97 + .../propertylist.qbs | 129 + .../jsextensions-temporarydir.qbs | 27 + .../jsextensions-textfile/textfile.qbs | 43 + .../last-module-candidate-broken.qbs | 5 + .../last-module-candidate-broken/main.cpp | 1 + .../qbs/modules/Foo/Foo1.qbs | 3 + .../qbs/modules/Foo/Foo2.qbs | 2 + tests/auto/blackbox/testdata/ld/coreutils.cpp | 34 + tests/auto/blackbox/testdata/ld/coreutils.h | 31 + tests/auto/blackbox/testdata/ld/ld.qbs | 23 + tests/auto/blackbox/testdata/ld/main.cpp | 37 + .../lexyacc/lex_outfile/lex_outfile.qbs | 16 + .../testdata/lexyacc/lex_outfile/lexer.l | 21 + .../testdata/lexyacc/lex_outfile/parser.y | 30 + .../testdata/lexyacc/lex_outfile/types.h | 50 + .../lexyacc/lex_prefix/lex_prefix.qbs | 16 + .../testdata/lexyacc/lex_prefix/lexer.l | 21 + .../testdata/lexyacc/lex_prefix/parser.y | 31 + .../testdata/lexyacc/lex_prefix/types.h | 50 + .../modules/bisonhelper/bisonhelper.qbs | 18 + .../testdata/lexyacc/one-grammar/lexer.l | 21 + .../lexyacc/one-grammar/one-grammar.qbs | 41 + .../testdata/lexyacc/one-grammar/parser.y | 30 + .../testdata/lexyacc/one-grammar/types.h | 50 + .../testdata/lexyacc/two-grammars/g1.l | 15 + .../testdata/lexyacc/two-grammars/g1.y | 7 + .../testdata/lexyacc/two-grammars/g2.l | 10 + .../testdata/lexyacc/two-grammars/g2.y | 7 + .../testdata/lexyacc/two-grammars/main.c | 37 + .../lexyacc/two-grammars/two-grammars.qbs | 18 + tests/auto/blackbox/testdata/lexyacc/unistd.h | 11 + .../testdata/lexyacc/yacc_output/lexer.l | 21 + .../testdata/lexyacc/yacc_output/parser.y | 31 + .../testdata/lexyacc/yacc_output/types.h | 50 + .../lexyacc/yacc_output/yacc_output.qbs | 14 + .../linker-library-duplicates/lib1.cpp | 3 + .../linker-library-duplicates/lib2.cpp | 3 + .../linker-library-duplicates/lib3.cpp | 3 + .../linker-library-duplicates/main.cpp | 13 + .../setup-run-environment.qbs | 46 + .../linker-module-definition.qbs | 20 + .../linker-module-definition/testapp.cpp | 39 + .../linker-module-definition/testlib.cpp | 41 + .../linker-module-definition/testlib.def | 3 + .../linker-variant/linker-variant.qbs | 20 + .../blackbox/testdata/linker-variant/main.cpp | 1 + .../testdata/linkerMode/linkerMode.qbs | 80 + .../auto/blackbox/testdata/linkerMode/main.c | 36 + .../blackbox/testdata/linkerMode/main.cpp | 36 + .../auto/blackbox/testdata/linkerMode/main.m | 7 + .../auto/blackbox/testdata/linkerMode/main.mm | 10 + .../auto/blackbox/testdata/linkerMode/main.s | 5 + .../testdata/linkerMode/staticlib.cpp | 37 + .../blackbox/testdata/linkerMode/staticmain.c | 34 + .../testdata/linkerscripts/linkerscript1 | 1 + .../testdata/linkerscripts/linkerscript2 | 1 + .../linkerscripts/linkerscript_recursive | 1 + .../linkerscripts/linkerscript_to_include | 2 + .../testdata/linkerscripts/linkerscripts.qbs | 61 + .../scripts/linkerscript_in_directory | 1 + .../blackbox/testdata/linkerscripts/testlib.c | 29 + .../testdata/list-products/list-products.qbs | 14 + .../list-properties-with-outer/dummy.txt | 0 .../list-properties-with-outer.qbs | 10 + .../modules/higher/higher.qbs | 4 + .../modules/lower/lower.qbs | 16 + .../testdata/list-property-order/dummy.txt | 0 .../modules/higher1/higher1.qbs | 4 + .../modules/higher2/higher2.qbs | 4 + .../modules/higher3/higher3.qbs | 4 + .../modules/lower/lower.qbs | 19 + .../testdata/list-property-order/product.qbs | 12 + .../testdata/loadablemodule/exported.cpp | 35 + .../testdata/loadablemodule/exported.h | 33 + .../loadablemodule/loadablemodule.qbs | 45 + .../blackbox/testdata/loadablemodule/main.cpp | 87 + .../localDeployment/localDeployment.qbs | 32 + .../testdata/localDeployment/main.cpp | 54 + .../testdata/makefile-generator/app.qbs | 24 + .../testdata/makefile-generator/main.cpp | 6 + .../maximum-c-language-version/main.c | 1 + .../maximum-c-language-version.qbs | 23 + .../modules/newermodule/newermodule.qbs | 4 + .../modules/newestmodule/newestmodule.qbs | 4 + .../modules/oldmodule/oldmodule.qbs | 4 + .../maximum-cxx-language-version/main.cpp | 1 + .../maximum-cxx-language-version.qbs | 10 + .../modules/newermodule/newermodule.qbs | 4 + .../modules/newestmodule/newestmodule.qbs | 4 + .../modules/oldmodule/oldmodule.qbs | 4 + .../minimumSystemVersion/fakewindows.qbs | 15 + .../minimumSystemVersion/macappstore.qbs | 17 + .../testdata/minimumSystemVersion/main.cpp | 103 + .../testdata/minimumSystemVersion/main.mm | 73 + .../minimumSystemVersion/specific.qbs | 32 + .../unspecified-forced.qbs | 30 + .../minimumSystemVersion/unspecified.qbs | 25 + .../testdata/missing-dependency/main.cpp | 33 + .../missing-dependency/missing-dependency.qbs | 32 + .../missing-override-prefix.qbs | 1 + .../missing-project-file/ambiguous-dir/p1.qbs | 0 .../missing-project-file/ambiguous-dir/p2.qbs | 0 .../missing-project-file/ambiguous-dir/p3.qbs | 0 .../empty-dir/irrelevant.txt | 0 .../missing-project-file/project-dir/file.cpp | 1 + .../missing-project-file/project-dir/main.cpp | 1 + .../project-dir/missing-project-file.qbs | 6 + .../module-conditions/module-conditions.qbs | 19 + .../module-conditions/modules/m/m1.qbs | 6 + .../module-conditions/modules/m/m2.qbs | 6 + .../module-conditions/modules/m/m3.qbs | 6 + .../module-conditions/modules/m/m4.qbs | 6 + .../testdata/module-providers/main.cpp | 8 + .../module-providers/module-providers.qbs | 35 + .../module-providers/mygenerator/provider.qbs | 31 + .../othergenerator/provider.qbs | 19 + .../testdata/moved-file-dependency/main.cpp | 3 + .../moved-file-dependency.qbs | 4 + .../moved-file-dependency/subdir1/theheader.h | 0 .../testdata/multiple-changes/dummy.txt | 0 .../multiple-changes/multiple-changes.qbs | 31 + .../testdata/multiple-configurations/file.cpp | 6 + .../testdata/multiple-configurations/file.h | 1 + .../testdata/multiple-configurations/lib.cpp | 1 + .../testdata/multiple-configurations/lib.h | 1 + .../testdata/multiple-configurations/main.cpp | 6 + .../multiple-configurations.qbs | 13 + .../multiplexed-tool/multiplexed-tool.qbs | 66 + .../testdata/multiplexed-tool/tool.cpp | 8 + .../blackbox/testdata/nested-groups/file3.cpp | 33 + .../blackbox/testdata/nested-groups/file3.h | 29 + .../blackbox/testdata/nested-groups/main.cpp | 40 + .../modules/themodule/themodule.qbs | 9 + .../testdata/nested-groups/nested-groups.qbs | 40 + .../testdata/nested-groups/subdir/file1.cpp | 37 + .../testdata/nested-groups/subdir/file1.h | 29 + .../testdata/nested-groups/subdir/file2.cpp | 37 + .../testdata/nested-groups/subdir/file2.h | 29 + .../testdata/nested-groups/subdir/main2.cpp | 29 + .../testdata/nested-groups/subdir/main3.cpp | 29 + .../testdata/nested-groups/subdir/other.cpp | 37 + .../testdata/nested-groups/subdir/other.h | 29 + .../testdata/nested-properties/dummy.txt | 0 .../modules/higherlevel/higher-level.qbs | 4 + .../modules/lowerlevel/lower-level.qbs | 17 + .../testdata/nested-properties/product.qbs | 20 + .../testdata/new-output-artifact/input.txt | 0 .../new-output-artifact.qbs | 37 + .../testdata/no-exported-symbols/lib.cpp | 1 + .../testdata/no-exported-symbols/lib.h | 6 + .../testdata/no-exported-symbols/main.cpp | 6 + .../no-exported-symbols.qbs | 28 + .../testdata/no-profile/no-profile.qbs | 3 + .../no-such-profile/no-such-profile.qbs | 4 + tests/auto/blackbox/testdata/nodejs/hello.js | 3 + tests/auto/blackbox/testdata/nodejs/hello.qbs | 12 + .../broken.cpp | 1 + .../fine.cpp | 29 + .../non-broken-files-in-broken-product.qbs | 4 + .../testdata/non-default-product/main.cpp | 29 + .../non-default-product.qbs | 15 + .../not-always-updated/not-always-updated.qbs | 31 + tests/auto/blackbox/testdata/nsis/hello.bat | 1 + tests/auto/blackbox/testdata/nsis/hello.nsi | 19 + tests/auto/blackbox/testdata/nsis/hello.qbs | 8 + .../testdata/nsisDependencies/hello.nsi | 8 + .../blackbox/testdata/nsisDependencies/main.c | 1 + .../nsisDependencies/nsisDependencies.qbs | 67 + .../testdata/out-of-date-marking/main.c | 3 + .../out-of-date-marking.qbs | 21 + .../broken.cpp.in | 1 + .../output-artifact-auto-tagging/main.cpp.in | 1 + .../output-artifact-auto-tagging.qbs | 30 + .../testdata/output-redirection/input.bin | Bin 0 -> 1024 bytes .../testdata/output-redirection/input.txt | 1 + .../output-redirection/output-redirection.qbs | 39 + .../testdata/output-redirection/output.bin | Bin 0 -> 2048 bytes .../testdata/output-redirection/output.txt | 2 + .../overrideProjectProperties/helper_lib.qbs | 9 + .../overrideProjectProperties/helperlib.cpp | 32 + .../overrideProjectProperties/main.cpp | 32 + .../overrideProjectProperties/main2.cpp | 38 + .../overrideProjectProperties.qbs | 33 + .../project_using_helper_lib.qbs | 12 + .../blackbox/testdata/path-probe/BaseApp.qbs | 132 + .../testdata/path-probe/bin/super-tool.1 | 0 .../blackbox/testdata/path-probe/bin/tool | 0 .../blackbox/testdata/path-probe/bin/tool.1 | 0 .../blackbox/testdata/path-probe/bin/tool.2 | 0 .../blackbox/testdata/path-probe/bin/tool.3 | 0 .../blackbox/testdata/path-probe/bin/tool.4 | 0 .../testdata/path-probe/candidate-filter.qbs | 13 + .../testdata/path-probe/environment-paths.qbs | 10 + .../path-probe/mult-files-common-suffixes.qbs | 10 + .../path-probe/mult-files-mult-suffixes.qbs | 9 + .../path-probe/mult-files-mult-variants.qbs | 10 + .../path-probe/mult-files-suffixes.qbs | 9 + .../testdata/path-probe/mult-files.qbs | 11 + .../testdata/path-probe/name-filter.qbs | 11 + .../path-probe/non-existent-selector.qbs | 9 + .../testdata/path-probe/non-existent.qbs | 5 + .../path-probe/single-file-mult-variants.qbs | 6 + .../path-probe/single-file-selector-array.qbs | 6 + .../path-probe/single-file-selector.qbs | 6 + .../path-probe/single-file-suffixes.qbs | 7 + .../testdata/path-probe/single-file.qbs | 6 + .../blackbox/testdata/path-probe/usr/bin/tool | 0 .../testdata/pch-change-tracking/header1.h | 35 + .../testdata/pch-change-tracking/header2.cpp | 8 + .../testdata/pch-change-tracking/header2.h | 30 + .../testdata/pch-change-tracking/main.cpp | 36 + .../pch-change-tracking.qbs | 12 + .../testdata/pch-change-tracking/pch.h | 29 + .../per-group-define-in-export-item/main.cpp | 3 + .../per-group-define-in-export-item.qbs | 16 + .../modules/themodule/themodule.qbs | 23 + .../pkg-config-probe-sysroot/pkg-config.qbs | 27 + .../sysroot1/usr/share/pkgconfig/dummy.pc | 7 + .../sysroot2/usr/share/pkgconfig/dummy.pc | 7 + .../pkg-config-probe/dummy1/dummy1.pc | 7 + .../pkg-config-probe/dummy2/dummy2.pc | 7 + .../modules/themodule/themodule.qbs | 34 + .../testdata/pkg-config-probe/pkg-config.qbs | 21 + .../testdata/plugin-dependency/helper1.cpp | 16 + .../testdata/plugin-dependency/helper2.cpp | 7 + .../testdata/plugin-dependency/main.cpp | 13 + .../plugin-dependency/plugin-dependency.qbs | 75 + .../testdata/plugin-dependency/plugin1.cpp | 7 + .../testdata/plugin-dependency/plugin2.cpp | 7 + .../testdata/plugin-dependency/plugin3.cpp | 7 + .../testdata/plugin-dependency/plugin4.cpp | 7 + .../precompiled-and-prefix-headers/main.cpp | 31 + .../precompiled-and-prefix-headers/pch.h | 28 + .../precompiled-and-prefix-headers.qbs | 11 + .../precompiled-and-prefix-headers/prefix.h | 28 + .../precompiled-headers-and-redefine/file.cpp | 1 + .../precompiled-headers-and-redefine/main.cpp | 33 + .../precompiled-headers-and-redefine/pch.h | 30 + .../precompiled-headers-and-redefine.qbs | 16 + .../prevent-floating-point-values.qbs | 4 + .../probe-change-tracking.qbs | 41 + .../probe-in-exported-module/dependee.qbs | 14 + .../probe-in-exported-module/dependency.qbs | 6 + .../modules/depmodule/depmodule.qbs | 18 + .../modules/mymodule/mymodule.qbs | 23 + .../modules/myothermodule/myothermodule.qbs | 4 + .../probe-in-exported-module.qbs | 3 + .../testdata/probe-in-exported-module/test.in | 0 .../probe-in-exported-module/test2.in | 0 .../module-providers/provider_a.qbs | 16 + .../probe-in-module-provider.qbs | 8 + .../testdata/probeProperties/bin/tool | 0 .../blackbox/testdata/probeProperties/main.c | 29 + .../probeProperties/probeProperties.qbs | 40 + .../modules/mymodule/mymodule.qbs | 25 + .../probes-and-array-properties.qbs | 6 + .../probes-and-shadow-products.qbs | 11 + .../modules/inner/inner.qbs | 19 + .../modules/outer/outer.qbs | 17 + .../probes-in-nested-modules.qbs | 36 + .../product-dependencies-by-type/main.cpp | 29 + .../modules/myconfig/myconfig.qbs | 3 + .../product-dependencies-by-type.qbs | 139 + .../modules/m/m.qbs | 3 + .../product-in-exported-module.qbs | 10 + .../testdata/productproperties/app.qbs | 10 + .../productproperties/blubb_header.h.in | 0 .../testdata/productproperties/header.qbs | 34 + .../testdata/productproperties/main.cpp | 36 + .../productproperties/productproperties.qbs | 4 + .../testdata/project_filepath_check/main.cpp | 29 + .../testdata/project_filepath_check/main2.cpp | 1 + .../project_filepath_check/project1.qbs | 3 + .../project_filepath_check/project2.qbs | 3 + .../blackbox/testdata/proper quoting/main.cpp | 41 + .../proper quoting/my static lib helper.cpp | 33 + .../testdata/proper quoting/my static lib.cpp | 38 + .../proper quoting/proper quoting.qbs | 46 + .../some helper/some helper.cpp | 35 + .../proper quoting/some helper/some helper.h | 35 + .../properties-in-export-items/main1.cpp | 31 + .../properties-in-export-items/main2.cpp | 31 + .../properties-in-export-items.qbs | 31 + .../main.cpp | 1 + .../modules/m/m.qbs | 9 + .../property-assignment-in-failed-module.qbs | 5 + ...perty-assignment-on-non-present-module.qbs | 4 + .../modules/base/base.qbs | 4 + .../modules/top/top.qbs | 6 + .../property-evaluation-context.qbs | 34 + .../testdata/property-precedence/dep.qbs | 9 + .../testdata/property-precedence/dummy.txt | 0 .../property-precedence/modules/leaf/leaf.qbs | 18 + .../modules/nonleaf/nonleaf.qbs | 6 + .../property-precedence.qbs | 16 + .../blackbox/testdata/propertyChanges/lib.cpp | 31 + .../modules/TestModule/module.qbs | 33 + .../propertyChanges/propertyChanges.qbs | 93 + .../testdata/propertyChanges/ruletest.qbs | 9 + .../testdata/propertyChanges/source1.cpp | 29 + .../testdata/propertyChanges/source2.cpp | 30 + .../testdata/propertyChanges/source3.cpp | 30 + .../blackbox/testdata/propertyChanges/test.in | 1 + .../protobuf-library-install/hello.proto | 8 + .../hello/world.proto | 6 + .../protobuf-library.qbs | 34 + .../testdata/protobuf/addressbook.proto | 51 + .../testdata/protobuf/addressbook_cpp.qbs | 28 + .../protobuf/addressbook_nanopb.options | 3 + .../protobuf/addressbook_nanopb.proto | 38 + .../testdata/protobuf/addressbook_nanopb.qbs | 30 + .../testdata/protobuf/addressbook_objc.qbs | 25 + .../protobuf/create-proto-library.qbs | 54 + .../testdata/protobuf/import-main.cpp | 38 + .../blackbox/testdata/protobuf/import.proto | 6 + .../blackbox/testdata/protobuf/import.qbs | 30 + .../auto/blackbox/testdata/protobuf/main.cpp | 58 + tests/auto/blackbox/testdata/protobuf/main.m | 50 + .../testdata/protobuf/main_nanopb.cpp | 61 + .../protobuf/needs-import-dir-main.cpp | 38 + .../testdata/protobuf/needs-import-dir.proto | 6 + .../testdata/protobuf/needs-import-dir.qbs | 31 + .../testdata/protobuf/subdir/myenum.proto | 6 + .../module-providers/provider_a.qbs | 9 + .../module-providers/provider_b.qbs | 9 + .../providers-properties.qbs | 12 + .../pseudo-multiplexing.qbs | 12 + .../module-providers/provider_a.qbs | 8 + .../module-providers/provider_b.qbs | 9 + .../qbs-module-providers-cli-override.qbs | 13 + .../module-providers/named_provider.qbs | 8 + .../qbsmetatestmodule/provider.qbs | 8 + .../qbs-module-providers-compatibility.qbs | 7 + .../testdata/qbs-module-providers-helpers.js | 23 + .../module-providers/provider_a.qbs | 8 + .../module-providers/provider_b.qbs | 9 + .../qbs-module-providers.qbs | 28 + .../blackbox/testdata/qbs-session/file1.cpp | 1 + .../blackbox/testdata/qbs-session/file2.cpp | 1 + .../blackbox/testdata/qbs-session/lib.cpp | 1 + .../auto/blackbox/testdata/qbs-session/lib.h | 1 + .../blackbox/testdata/qbs-session/main.cpp | 4 + .../qbs-session/modules/mymodule/mymodule.qbs | 5 + .../testdata/qbs-session/qbs-session.qbs | 25 + .../testdata/qbsVersion/qbs-version.qbs | 20 + .../libdir/libA.pc | 6 + .../libs/libA.cpp | 14 + .../qbspkgconfig-module-provider/libs/libA.h | 21 + .../libs/libs.qbs | 29 + .../qbspkgconfig-module-provider/main.cpp | 11 + .../qbspkgconfig-module-provider.qbs | 6 + .../rad-after-incomplete-build/dummy.txt | 0 .../project_with_rule.qbs | 25 + .../recursive_renaming/dir/subdir/blubb.txt | 0 .../recursive_renaming/dir/wasser.txt | 0 .../recursive_renaming/recursive_renaming.qbs | 8 + .../recursive_wildcards/dir/file1.txt | 0 .../recursive_wildcards/dir/subdir/file2.txt | 0 .../recursive_wildcards.qbs | 43 + .../testdata/referenceErrorInExport/main.c | 29 + .../referenceErrorInExport.qbs | 18 + .../remove-duplicate-libs/MyStaticLib.qbs | 10 + .../testdata/remove-duplicate-libs/main.c | 9 + .../testdata/remove-duplicate-libs/provider.c | 1 + .../remove-duplicate-libs/provider2.c | 1 + .../remove-duplicate-libs.qbs | 28 + .../remove-duplicate-libs/requestor1.c | 3 + .../remove-duplicate-libs/requestor2.c | 3 + .../testdata/renameDependency/after/lib2.cpp | 35 + .../testdata/renameDependency/after/lib2.h | 29 + .../testdata/renameDependency/before/lib.cpp | 35 + .../testdata/renameDependency/before/lib.h | 29 + .../testdata/renameDependency/before/main.cpp | 36 + .../before/renameDependency.qbs | 3 + .../testdata/reproducible-build/file1.cpp | 31 + .../testdata/reproducible-build/file2.cpp | 31 + .../testdata/reproducible-build/main.cpp | 36 + .../reproducible-build/reproducible-build.qbs | 5 + .../testdata/require-deprecated/blubb.js | 13 + .../testdata/require-deprecated/require.qbs | 21 + .../testdata/require-deprecated/zort.js | 11 + tests/auto/blackbox/testdata/require/blubb.js | 13 + .../blackbox/testdata/require/require.qbs | 21 + tests/auto/blackbox/testdata/require/zort.js | 11 + .../testdata/rescue-transformer-data/main.cpp | 1 + .../rescue-transformer-data/modules/m/m.qbs | 19 + .../transformer-data-rescue.qbs | 5 + .../response-files/cat-response-file.cpp | 67 + .../response-files/response-files.qbs | 83 + .../retagged-output-artifact.qbs | 42 + .../rule-connection-with-excluded-inputs.qbs | 40 + .../rule-with-no-inputs.qbs | 27 + .../rule-with-non-required-inputs/a.inp | 0 .../rule-with-non-required-inputs/b.inp | 0 .../rule-with-non-required-inputs/c.inp | 0 .../rule-with-non-required-inputs.qbs | 41 + .../blackbox/testdata/ruleConditions/foo.narf | 0 .../blackbox/testdata/ruleConditions/main.cpp | 29 + .../modules/narfzort/narfzort.qbs | 29 + .../ruleConditions/ruleConditions.qbs | 11 + .../ruleConditions/templates/zorduct.qbs | 10 + .../blackbox/testdata/ruleCycle/happy.grass | 1 + .../blackbox/testdata/ruleCycle/ruleCycle.qbs | 45 + .../blackbox/testdata/sanitizer/sanitizer.cpp | 4 + .../blackbox/testdata/sanitizer/sanitizer.qbs | 44 + .../scan-result-in-non-dependency/app/app.h | 1 + .../scan-result-in-non-dependency/app/app.qbs | 4 + .../app/main.cpp | 3 + .../scan-result-in-non-dependency/lib/lib.h | 3 + .../other/other.qbs | 24 + .../scan-result-in-non-dependency/p.qbs | 6 + .../scan-result-in-other-product/app/app.h | 1 + .../scan-result-in-other-product/app/app.qbs | 4 + .../scan-result-in-other-product/app/main.cpp | 3 + .../scan-result-in-other-product/lib/lib.h | 3 + .../scan-result-in-other-product/lib/lib.qbs | 7 + .../other/other.qbs | 24 + .../scan-result-in-other-product/p.qbs | 7 + .../testdata/scanner-item/modules/m/m.qbs | 9 + .../testdata/scanner-item/scanner-item.qbs | 24 + .../testdata/scanner-item/subdir1/file.inc | 0 .../testdata/scanner-item/subdir1/file1.in | 0 .../testdata/scanner-item/subdir2/file.inc | 0 .../testdata/scanner-item/subdir2/file2.in | 0 .../testdata/separate-debug-info/foo.cpp | 31 + .../testdata/separate-debug-info/main.cpp | 29 + .../separate-debug-info.qbs | 156 + .../modules/buildenv/buildenv.qbs | 8 + .../setup-build-environment/modules/m/m.qbs | 25 + .../setup-build-environment.qbs | 11 + .../testdata/setup-run-environment/lib1.cpp | 3 + .../testdata/setup-run-environment/lib2.cpp | 7 + .../testdata/setup-run-environment/lib3.cpp | 3 + .../testdata/setup-run-environment/lib4.cpp | 3 + .../testdata/setup-run-environment/lib5.cpp | 3 + .../testdata/setup-run-environment/main.cpp | 15 + .../setup-run-environment.qbs | 126 + .../blackbox/testdata/smart-relinking/lib.cpp | 24 + .../testdata/smart-relinking/main.cpp | 6 + .../smart-relinking/smart-relinking.qbs | 36 + .../testdata/smart-relinking/staticlib.cpp | 1 + .../modules/module_with_files/main.cpp | 1 + .../module_with_files/module_with_files.qbs | 15 + .../source-artifact-changes.qbs | 56 + .../header.h | 0 ...e-artifact-in-inputs-from-dependencies.qbs | 58 + .../auto/blackbox/testdata/soversion/lib.cpp | 1 + .../blackbox/testdata/soversion/soversion.qbs | 7 + .../static-lib-without-sources/lib.cpp | 1 + .../static-lib-without-sources.qbs | 14 + .../subprofile-change-tracking/main1.cpp | 29 + .../subprofile-change-tracking/main2.cpp | 29 + .../subprofile-change-tracking.qbs | 8 + .../testdata/successive-changes/input.in | 0 .../successive-changes/successive-changes.qbs | 29 + .../suspicious-calls/copy-command.qbs | 19 + .../testdata/suspicious-calls/copy-eval.qbs | 9 + .../suspicious-calls/copy-prepare.qbs | 20 + .../testdata/suspicious-calls/copy-probe.qbs | 13 + .../suspicious-calls/direntries-command.qbs | 21 + .../suspicious-calls/direntries-eval.qbs | 5 + .../suspicious-calls/direntries-prepare.qbs | 20 + .../suspicious-calls/direntries-probe.qbs | 14 + .../testdata/suspicious-calls/test.txt | 0 .../testdata/symbolLinkMode/indirect.cpp | 3 + .../blackbox/testdata/symbolLinkMode/lib.cpp | 11 + .../blackbox/testdata/symbolLinkMode/main.cpp | 17 + .../symbolLinkMode/symbolLinkMode.qbs | 115 + .../symlink-removal/symlink-removal.qbs | 17 + .../testdata/system-include-paths/main.cpp | 8 + .../system-include-paths/subdir/gagagugu.h | 4 + .../system-include-paths.qbs | 4 + .../testdata/system-run-paths/lib.cpp | 29 + .../testdata/system-run-paths/main.cpp | 34 + .../system-run-paths/system-run-paths.qbs | 23 + .../testdata/texttemplate/cdefgabc.txt.in | 1 + .../testdata/texttemplate/expected/lalala.txt | 1 + .../testdata/texttemplate/expected/output.txt | 12 + .../testdata/texttemplate/output.txt.in | 12 + .../texttemplate/texttemplatetest.qbs | 24 + .../qbs-resources/imports/MyProduct.qbs | 1 + .../toplevel-searchpath.qbs | 1 + .../testdata/trackAddFile/after/main.cpp | 41 + .../trackAddFile/after/trackAddFile.qbs | 22 + .../testdata/trackAddFile/after/zort.cpp | 35 + .../testdata/trackAddFile/after/zort.h | 38 + .../testdata/trackAddFile/before/main.cpp | 38 + .../testdata/trackAddFile/before/narf.cpp | 35 + .../testdata/trackAddFile/before/narf.h | 38 + .../trackAddFile/before/trackAddFile.qbs | 18 + .../environmentChange.cpp | 29 + .../trackExternalProductChanges/fileList.js | 6 + .../hidden/hiddenheaderqbs.h | 27 + .../trackExternalProductChanges/including.cpp | 31 + .../jsFileChange.cpp | 29 + .../trackExternalProductChanges/main.cpp | 29 + .../trackExternalProductChanges.qbs | 14 + .../testdata/trackFileTags/after/main.cpp | 37 + .../trackFileTags/after/trackFileTags.qbs | 60 + .../testdata/trackFileTags/before/main.cpp | 35 + .../trackFileTags/before/trackFileTags.qbs | 60 + .../testdata/trackProducts/after/product3.qbs | 6 + .../trackProducts/after/trackProducts.qbs | 5 + .../testdata/trackProducts/after/zoo.cpp | 34 + .../testdata/trackProducts/before/bar.cpp | 34 + .../testdata/trackProducts/before/foo.cpp | 34 + .../trackProducts/before/product1.qbs | 6 + .../trackProducts/before/product2.qbs | 6 + .../trackProducts/before/trackProducts.qbs | 5 + .../modules/a/a.qbs | 5 + .../modules/b/b.qbs | 3 + .../modules/c/c.qbs | 3 + .../modules/d/d.qbs | 4 + .../transitive-invalid-dependencies.qbs | 11 + .../modules/a/a.qbs | 3 + .../modules/b/b.qbs | 3 + .../transitive-optional-dependencies.qbs | 3 + .../blackbox/testdata/typescript/animals.ts | 21 + .../blackbox/testdata/typescript/extra.js | 3 + .../auto/blackbox/testdata/typescript/foo.ts | 5 + .../auto/blackbox/testdata/typescript/foo2.ts | 1 + .../blackbox/testdata/typescript/hello.ts | 1 + .../auto/blackbox/testdata/typescript/main.ts | 22 + .../testdata/typescript/typescript.qbs | 54 + .../testdata/typescript/woosh/extra.ts | 2 + .../undefined-target-platform.qbs | 13 + .../custom1.in | 0 .../custom2.in | 0 .../usings-as-sole-inputs-non-multiplexed.qbs | 61 + .../blackbox/testdata/variant-suffix/lib.cpp | 1 + .../variant-suffix/variant-suffix.qbs | 38 + tests/auto/blackbox/testdata/vcs/main.cpp | 7 + tests/auto/blackbox/testdata/vcs/vcstest.qbs | 13 + .../versioncheck/modules/higher/higher.qbs | 8 + .../versioncheck/modules/lower/lower.qbs | 1 + .../testdata/versioncheck/versioncheck.qbs | 10 + .../blackbox/testdata/versionscript/testlib.c | 30 + .../testdata/versionscript/versionscript | 1 + .../testdata/versionscript/versionscript.qbs | 27 + .../testdata/whole-archive/dynamiclib.cpp | 5 + .../blackbox/testdata/whole-archive/main1.cpp | 8 + .../blackbox/testdata/whole-archive/main2.cpp | 8 + .../blackbox/testdata/whole-archive/main3.cpp | 7 + .../blackbox/testdata/whole-archive/main4.cpp | 8 + .../testdata/whole-archive/unused1.cpp | 3 + .../testdata/whole-archive/unused2.cpp | 3 + .../testdata/whole-archive/unused3.cpp | 3 + .../testdata/whole-archive/unused4.cpp | 3 + .../blackbox/testdata/whole-archive/used.cpp | 1 + .../testdata/whole-archive/whole-archive.qbs | 71 + .../testdata/wildcard_renaming/pioniere.txt | 0 .../wildcard_renaming/wildcard_renaming.qbs | 7 + .../testdata/wildcards-and-rules/input1.inp | 0 .../wildcards-and-rules.qbs | 36 + tests/auto/blackbox/tst_blackbox.cpp | 8766 ++++ tests/auto/blackbox/tst_blackbox.h | 362 + tests/auto/blackbox/tst_blackboxandroid.cpp | 1086 + tests/auto/blackbox/tst_blackboxandroid.h | 49 + tests/auto/blackbox/tst_blackboxapple.cpp | 1181 + tests/auto/blackbox/tst_blackboxapple.h | 78 + tests/auto/blackbox/tst_blackboxbaremetal.cpp | 311 + tests/auto/blackbox/tst_blackboxbaremetal.h | 77 + tests/auto/blackbox/tst_blackboxbase.cpp | 274 + tests/auto/blackbox/tst_blackboxbase.h | 116 + tests/auto/blackbox/tst_blackboxexamples.cpp | 104 + tests/auto/blackbox/tst_blackboxexamples.h | 53 + tests/auto/blackbox/tst_blackboxjava.cpp | 249 + tests/auto/blackbox/tst_blackboxjava.h | 48 + tests/auto/blackbox/tst_blackboxjoblimits.cpp | 186 + tests/auto/blackbox/tst_blackboxqt.cpp | 728 + tests/auto/blackbox/tst_blackboxqt.h | 83 + tests/auto/blackbox/tst_blackboxwindows.cpp | 307 + tests/auto/blackbox/tst_blackboxwindows.h | 55 + tests/auto/blackbox/tst_clangdb.cpp | 220 + tests/auto/blackbox/tst_clangdb.h | 64 + tests/auto/buildgraph/CMakeLists.txt | 7 + tests/auto/buildgraph/buildgraph.pro | 13 + tests/auto/buildgraph/buildgraph.qbs | 9 + tests/auto/buildgraph/tst_buildgraph.cpp | 152 + tests/auto/buildgraph/tst_buildgraph.h | 70 + tests/auto/cmdlineparser/CMakeLists.txt | 23 + tests/auto/cmdlineparser/cmdlineparser.pro | 7 + tests/auto/cmdlineparser/cmdlineparser.qbs | 31 + .../auto/cmdlineparser/tst_cmdlineparser.cpp | 214 + tests/auto/dllexport.h | 39 + tests/auto/language/CMakeLists.txt | 9 + tests/auto/language/language.pro | 24 + tests/auto/language/language.qbs | 25 + tests/auto/language/testdata/Banana | 1 + tests/auto/language/testdata/MyProperties.qbs | 2 + .../language/testdata/ParentWithExport.qbs | 6 + tests/auto/language/testdata/aboutdialog.cpp | 0 .../testdata/additional-product-types.qbs | 12 + .../testdata/base-validate/base-validate.qbs | 3 + .../base-validate/modules/m/MParent.qbs | 4 + .../testdata/base-validate/modules/m/m.qbs | 9 + tests/auto/language/testdata/baseproperty.qbs | 7 + .../language/testdata/baseproperty_base.qbs | 4 + .../testdata/broken-dependency-cycle1.qbs | 18 + .../testdata/broken-dependency-cycle2.qbs | 18 + .../testdata/buildconfigstringlistsyntax.qbs | 3 + .../builtinFunctionInSearchPathsProperty.qbs | 8 + .../testdata/canonicalArchitecture.qbs | 5 + .../chained-probes/chained-probes.qbs | 3 + .../testdata/chained-probes/modules/m/m.qbs | 15 + .../language/testdata/conditionaldepends.qbs | 87 + .../testdata/conditionaldepends_base.qbs | 8 + .../language/testdata/defaultvalue/egon.qbs | 12 + .../defaultvalue/modules/higher/higher.qbs | 5 + .../defaultvalue/modules/lower/lower.qbs | 5 + .../language/testdata/defaultvalue/test.txt | 0 .../testdata/delayed-error/modules/m/m.qbs | 3 + .../testdata/delayed-error/nonexisting.qbs | 8 + .../testdata/delayed-error/validation.qbs | 8 + .../testdata/dependencyOnAllProfiles.qbs | 16 + .../derived-sub-project/DerivedSubProject.qbs | 2 + .../testdata/derived-sub-project/project.qbs | 8 + .../derived-sub-project/subproject.qbs | 2 + .../dirwithmultipleprojects/project.qbs | 0 .../dirwithmultipleprojects/project2.qbs | 0 .../testdata/dirwithnoprojects/.gitignore | 2 + .../testdata/dirwithoneproject/project.qbs | 0 .../language/testdata/disabled-subproject.qbs | 26 + .../testdata/dotted-names/dotted-names.qbs | 22 + .../testdata/dotted-names/modules/x/y/xy.qbs | 3 + tests/auto/language/testdata/drawline.asm | 0 tests/auto/language/testdata/dummy.txt | 0 tests/auto/language/testdata/empty-js-file.js | 0 .../auto/language/testdata/empty-js-file.qbs | 4 + .../language/testdata/enum-project-props.qbs | 12 + .../language/testdata/environmentvariable.qbs | 5 + .../testdata/erroneous/ParentItem.qbs | 4 + .../testdata/erroneous/ParentWithExport.qbs | 5 + .../ambiguous-multiplex-dependency.qbs | 14 + .../conflicting-module-instances.qbs | 3 + ...conflicting-properties-in-export-items.qbs | 5 + .../erroneous/conflicting_fileTagsFilter.qbs | 12 + .../dependency-profile-mismatch-2.qbs | 17 + .../erroneous/dependency-profile-mismatch.qbs | 14 + .../testdata/erroneous/dependency_cycle.qbs | 17 + .../testdata/erroneous/dependency_cycle2.qbs | 21 + .../testdata/erroneous/dependency_cycle3.qbs | 11 + .../testdata/erroneous/dependency_cycle4.qbs | 3 + .../erroneous/duplicate-multiplex-value.qbs | 8 + .../erroneous/duplicate-multiplex-value2.qbs | 8 + .../testdata/erroneous/duplicate_sources.qbs | 6 + .../erroneous/duplicate_sources_wildcards.qbs | 6 + .../testdata/erroneous/importloop1.qbs | 4 + .../testdata/erroneous/importloop2.qbs | 4 + .../erroneous/invalid-parameter-rhs.qbs | 5 + .../erroneous/invalid-parameter-type.qbs | 8 + .../erroneous/invalid-property-option.qbs | 3 + .../testdata/erroneous/invalid-references.qbs | 3 + .../erroneous/invalid_child_item_type.qbs | 4 + .../testdata/erroneous/invalid_file.qbs | 3 + .../erroneous/invalid_property_type.qbs | 3 + .../erroneous/invalid_stringlist_element.qbs | 3 + .../auto/language/testdata/erroneous/main.cpp | 40 + .../mismatching-multiplex-dependency.qbs | 13 + .../testdata/erroneous/missing-colon.qbs | 5 + .../erroneous/misused-inherited-property.qbs | 3 + .../erroneous/module-depends-on-product.qbs | 9 + .../conflicting-instance1.qbs | 2 + .../conflicting-instance2.qbs | 2 + .../erroneous/modules/module-a/module-a.qbs | 3 + .../erroneous/modules/module-b/module-b.qbs | 3 + .../module-with-invalid-original.qbs | 3 + .../module-with-product-dependency.qbs | 3 + .../module-with-wrong-property-option/m.qbs | 7 + .../module_with_parameters.qbs | 6 + .../no_such_property/no-such-property.qbs | 4 + .../erroneous/modules/prefix1/prefix1.qbs | 2 + .../modules/prefix1/suffix/suffix.qbs | 3 + .../erroneous/modules/prefix2/prefix2.qbs | 3 + .../modules/prefix2/suffix/suffix.qbs | 2 + .../erroneous/modules/readonly/readonly.qbs | 3 + .../testdata/erroneous/multiple_exports.qbs | 4 + .../multiple_properties_in_subproject.qbs | 6 + .../erroneous/no-configure-in-probe.qbs | 5 + .../testdata/erroneous/nonexistentouter.qbs | 5 + .../testdata/erroneous/oldQbsVersion.qbs | 6 + .../erroneous/original-in-export-item.qbs | 14 + .../erroneous/original-in-export-item2.qbs | 14 + .../erroneous/original-in-export-item3.qbs | 17 + .../original-in-module-prototype.qbs | 3 + .../original-in-product-property.qbs | 3 + .../overwrite-inherited-readonly-property.qbs | 3 + .../overwrite-readonly-module-property.qbs | 4 + ...properties-item-with-invalid-condition.qbs | 7 + .../testdata/erroneous/references_cycle.qbs | 4 + .../testdata/erroneous/references_cycle2.qbs | 4 + .../testdata/erroneous/references_cycle3.qbs | 4 + .../erroneous/reserved_name_in_import.qbs | 3 + .../erroneous/rule-without-output-tags.qbs | 11 + .../erroneous/same-module-prefix1.qbs | 3 + .../erroneous/same-module-prefix2.qbs | 3 + .../testdata/erroneous/subproject_cycle.qbs | 6 + .../testdata/erroneous/subproject_cycle2.qbs | 6 + .../testdata/erroneous/subproject_cycle3.qbs | 6 + .../erroneous/syntax-error-in-probe.qbs | 6 + .../erroneous/throw_in_property_binding.qbs | 5 + .../erroneous/undeclared-parameter1.qbs | 5 + .../erroneous/undeclared-parameter2.qbs | 5 + .../testdata/erroneous/undeclared_item.qbs | 4 + .../undeclared_module_property_in_module.qbs | 4 + .../erroneous/undeclared_property.qbs | 4 + ...undeclared_property_in_Properties_item.qbs | 6 + .../undeclared_property_in_export_item.qbs | 12 + .../undeclared_property_in_export_item2.qbs | 11 + .../undeclared_property_in_export_item3.qbs | 7 + .../erroneous/undeclared_property_wrapper.qbs | 5 + .../undefined_stringlist_element.qbs | 4 + .../undefined_stringlist_element_in_probe.qbs | 9 + .../testdata/erroneous/unknown_item_type.qbs | 3 + .../testdata/erroneous/unknown_module.qbs | 3 + .../erroneous/wrong-toplevel-item.qbs | 2 + .../erroneous/wrongQbsVersionFormat.qbs | 3 + .../testdata/error-in-disabled-product.qbs | 54 + .../eval-error-in-non-present-module.qbs | 5 + tests/auto/language/testdata/exports.qbs | 166 + .../language/testdata/exports_product.qbs | 9 + .../testdata/file-in-product-and-module.qbs | 9 + .../testdata/filecontextproperties.qbs | 5 + tests/auto/language/testdata/filetags.qbs | 79 + .../language/testdata/getNativeSetting.qbs | 28 + .../language/testdata/groupconditions.qbs | 51 + tests/auto/language/testdata/groupname.qbs | 20 + .../auto/language/testdata/homeDirectory.qbs | 16 + .../auto/language/testdata/id-uniqueness.qbs | 11 + tests/auto/language/testdata/idusage.qbs | 29 + .../auto/language/testdata/idusage_group.qbs | 5 + .../auto/language/testdata/idusage_group2.qbs | 5 + tests/auto/language/testdata/idusagebase.qbs | 16 + .../language/testdata/idusagebasebase.qbs | 5 + .../import-collection/collection/file1.js | 1 + .../import-collection/collection/file2.js | 1 + .../imports/Collection/file1.js | 1 + .../imports/Collection/file2.js | 1 + .../testdata/import-collection/product.qbs | 7 + .../testdata/import-collection/project.qbs | 4 + .../imports/DebugName.qbs | 4 + .../imports/ReleaseName.qbs | 4 + .../inherited-properties-items-product.qbs | 5 + .../inherited-properties-items.qbs | 4 + .../language/testdata/invalid-overrides.qbs | 14 + .../testdata/invalidBindingInDisabledItem.qbs | 14 + tests/auto/language/testdata/jsextensions.js | 65 + .../testdata/jsimportsinmultiplescopes.js | 12 + .../testdata/jsimportsinmultiplescopes.qbs | 7 + tests/auto/language/testdata/main.cpp | 0 .../module-merging-variant-values.qbs | 5 + .../modules/m1/m1.qbs | 6 + .../modules/m2/m2.qbs | 14 + .../bar/modules/conflicting-instances/bar.qbs | 3 + .../foo/modules/conflicting-instances/foo.qbs | 3 + .../product.qbs | 3 + .../project.qbs | 3 + .../module-property-overrides-per-product.qbs | 17 + .../language/testdata/moduleproperties.qbs | 73 + .../testdata/modulepropertiesingroups.qbs | 83 + tests/auto/language/testdata/modules.qbs | 57 + .../testdata/modules/broken/broken.qbs | 19 + .../deepdummy/deep/moat/dummydeepmoat.qbs | 5 + .../language/testdata/modules/dummy/dummy.qbs | 25 + .../testdata/modules/dummy/dummy_base.qbs | 4 + .../testdata/modules/dummy2/dummy2.qbs | 7 + .../testdata/modules/dummy3/dummy3.qbs | 4 + .../modules/dummy3_loader/dummy3_loader.qbs | 4 + .../modules/dummyqt/core/dummycore.qbs | 21 + .../testdata/modules/dummyqt/gui/dummygui.qbs | 10 + .../modules/dummyqt/network/dummynetwork.qbs | 7 + .../testdata/modules/gmod/gmod1/gmod1.qbs | 16 + .../language/testdata/modules/gmod2/gmod2.qbs | 6 + .../language/testdata/modules/gmod3/qmod3.qbs | 5 + .../language/testdata/modules/gmod4/gmod4.qbs | 6 + .../module-with-properties-item.qbs | 8 + .../module_with_file/module-with-file.qbs | 14 + .../modules/multiple_backends/backend1.qbs | 4 + .../modules/multiple_backends/backend2.qbs | 5 + .../modules/multiple_backends/backend3.qbs | 5 + .../testdata/modules/scopemod/scopemod.qbs | 10 + tests/auto/language/testdata/modulescope.qbs | 13 + .../language/testdata/modulescope_base.qbs | 4 + .../language/testdata/multiplexed-exports.qbs | 18 + .../testdata/multiplexing-by-profile/p1.qbs | 15 + .../testdata/multiplexing-by-profile/p2.qbs | 19 + .../testdata/multiplexing-by-profile/p3.qbs | 27 + .../testdata/multiplexing-by-profile/p4.qbs | 19 + tests/auto/language/testdata/narf | 0 tests/auto/language/testdata/narf.zort | 0 .../auto/language/testdata/nativesettings.ini | 1 + ...-applicable-module-property-in-profile.qbs | 16 + .../testdata/non-required-products.qbs | 33 + tests/auto/language/testdata/outerInGroup.qbs | 12 + .../overridden-properties-and-prototypes.qbs | 4 + .../testdata/overridden-variant-property.qbs | 4 + .../language/testdata/parameter-types.qbs | 17 + .../auto/language/testdata/pathproperties.qbs | 9 + .../language/testdata/productconditions.qbs | 35 + .../language/testdata/productdirectories.qbs | 3 + .../profilevaluesandoverriddenvalues.qbs | 19 + .../testdata/properties-block-in-group.qbs | 14 + .../testdata/properties-item-in-module.qbs | 4 + .../language/testdata/propertiesblocks.qbs | 235 + .../testdata/propertiesblocks_base.qbs | 11 + .../property-assignment-in-exported-group.qbs | 16 + .../qbs-properties-in-project-condition.qbs | 7 + .../qbs-property-convenience-override.qbs | 4 + tests/auto/language/testdata/qbs1275.qbs | 40 + .../recursive-dependencies.qbs | 17 + .../testdata/relaxed-error-mode/file1.txt | 0 .../testdata/relaxed-error-mode/file2.txt | 0 .../relaxed-error-mode/relaxed-error-mode.qbs | 29 + .../complicated.qbs | 5 + .../dependency-via-export.qbs | 13 + .../dependency-via-module.qbs | 4 + .../direct-dependencies.qbs | 4 + .../failing-validation-indirect.qbs | 3 + .../failing-validation/failing-validation.qbs | 3 + .../required-chain-export-indirect.qbs | 20 + .../required-chain-export.qbs | 13 + .../required-chain-module.qbs | 4 + .../language/testdata/rfc1034identifier.qbs | 9 + .../testdata/subdir/exports-mylib.qbs | 15 + .../testdata/subdir/pathproperties_base.qbs | 4 + .../testdata/subdir2/exports-mylib2.qbs | 11 + .../suppressed-and-non-suppressed-errors.qbs | 11 + .../auto/language/testdata/throwing-probe.qbs | 11 + .../testdata/use-internal-profile.qbs | 13 + .../auto/language/testdata/versionCompare.qbs | 20 + tests/auto/language/testdata/zort | 0 tests/auto/language/tst_language.cpp | 3293 ++ tests/auto/language/tst_language.h | 191 + tests/auto/pkgconfig/CMakeLists.txt | 8 + tests/auto/pkgconfig/pkgconfig.qbs | 19 + tests/auto/pkgconfig/testdata/base.name.json | 20 + tests/auto/pkgconfig/testdata/base.name.pc | 12 + .../pkgconfig/testdata/empty-variable.json | 21 + .../auto/pkgconfig/testdata/empty-variable.pc | 13 + .../pkgconfig/testdata/non-l-required.json | 12 + .../auto/pkgconfig/testdata/non-l-required.pc | 5 + tests/auto/pkgconfig/testdata/private-dep.pc | 6 + tests/auto/pkgconfig/testdata/public-dep.pc | 6 + .../testdata/requires-test-merged-static.json | 22 + .../testdata/requires-test-merged.json | 19 + .../pkgconfig/testdata/requires-test.json | 18 + .../auto/pkgconfig/testdata/requires-test.pc | 8 + tests/auto/pkgconfig/testdata/simple.json | 20 + tests/auto/pkgconfig/testdata/simple.pc | 12 + .../pkgconfig/testdata/special-flags.json | 30 + .../auto/pkgconfig/testdata/special-flags.pc | 11 + tests/auto/pkgconfig/testdata/sysroot.json | 21 + tests/auto/pkgconfig/testdata/sysroot.pc | 12 + tests/auto/pkgconfig/testdata/system.json | 17 + tests/auto/pkgconfig/testdata/system.pc | 10 + tests/auto/pkgconfig/testdata/tilde.json | 11 + tests/auto/pkgconfig/testdata/tilde.pc | 5 + tests/auto/pkgconfig/testdata/variables.json | 17 + tests/auto/pkgconfig/testdata/variables.pc | 11 + tests/auto/pkgconfig/testdata/whitespace.json | 24 + tests/auto/pkgconfig/testdata/whitespace.pc | 11 + tests/auto/pkgconfig/tst_pkgconfig.cpp | 217 + tests/auto/pkgconfig/tst_pkgconfig.h | 53 + tests/auto/shared.h | 368 + tests/auto/tools/CMakeLists.txt | 7 + tests/auto/tools/tools.pro | 6 + tests/auto/tools/tools.qbs | 14 + tests/auto/tools/tst_tools.cpp | 1352 + tests/auto/tools/tst_tools.h | 115 + tests/benchmarker/CMakeLists.txt | 18 + tests/benchmarker/activities.h | 42 + tests/benchmarker/benchmarker-main.cpp | 134 + tests/benchmarker/benchmarker.cpp | 133 + tests/benchmarker/benchmarker.h | 79 + tests/benchmarker/benchmarker.pro | 20 + tests/benchmarker/benchmarker.qbs | 30 + tests/benchmarker/commandlineparser.cpp | 137 + tests/benchmarker/commandlineparser.h | 66 + tests/benchmarker/exception.h | 53 + tests/benchmarker/runsupport.cpp | 71 + tests/benchmarker/runsupport.h | 47 + tests/benchmarker/valgrindrunner.cpp | 253 + tests/benchmarker/valgrindrunner.h | 86 + tests/fuzzy-test/CMakeLists.txt | 12 + tests/fuzzy-test/commandlineparser.cpp | 130 + tests/fuzzy-test/commandlineparser.h | 76 + tests/fuzzy-test/fuzzy-test.pro | 11 + tests/fuzzy-test/fuzzy-test.qbs | 19 + tests/fuzzy-test/fuzzytester.cpp | 308 + tests/fuzzy-test/fuzzytester.h | 84 + tests/fuzzy-test/main.cpp | 88 + tests/tests.pro | 4 + tests/tests.qbs | 42 + 6056 files changed, 989434 insertions(+) create mode 100644 .clang-tidy create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .github/actions/download-dm/action.yml create mode 100644 .github/actions/download-mingw/action.yml create mode 100644 .github/actions/download-ow/action.yml create mode 100644 .github/actions/download-qt/action.yml create mode 100644 .github/actions/download-qtc/action.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/release.yml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 .mailmap create mode 100644 CMakeLists.txt create mode 100644 CONTRIBUTING.md create mode 100644 LGPL_EXCEPTION.txt create mode 100644 LICENSE.GPL3-EXCEPT create mode 100644 LICENSE.LGPLv21 create mode 100644 LICENSE.LGPLv3 create mode 100644 README.md create mode 100644 VERSION create mode 100644 bin/ibmsvc.xml create mode 100644 bin/ibqbs.bat create mode 100644 changelogs/changes-1.10.0.md create mode 100644 changelogs/changes-1.10.1.md create mode 100644 changelogs/changes-1.11.0.md create mode 100644 changelogs/changes-1.11.1.md create mode 100644 changelogs/changes-1.12.0.md create mode 100644 changelogs/changes-1.12.1.md create mode 100644 changelogs/changes-1.12.2.md create mode 100644 changelogs/changes-1.13.0.md create mode 100644 changelogs/changes-1.13.1.md create mode 100644 changelogs/changes-1.14.0.md create mode 100644 changelogs/changes-1.14.1.md create mode 100644 changelogs/changes-1.15.0.md create mode 100644 changelogs/changes-1.16.0.md create mode 100644 changelogs/changes-1.17.0.md create mode 100644 changelogs/changes-1.17.1.md create mode 100644 changelogs/changes-1.18.0.md create mode 100644 changelogs/changes-1.18.2.md create mode 100644 changelogs/changes-1.19.0.md create mode 100644 changelogs/changes-1.19.1.md create mode 100644 changelogs/changes-1.19.2.md create mode 100644 changelogs/changes-1.20.0.md create mode 100644 changelogs/changes-1.20.1.md create mode 100644 changelogs/changes-1.21.0.md create mode 100644 changelogs/changes-1.22.0.md create mode 100644 changelogs/changes-1.22.1.md create mode 100644 changelogs/changes-1.23.0.md create mode 100644 changelogs/changes-1.23.1.md create mode 100644 changelogs/changes-1.6.0 create mode 100644 changelogs/changes-1.6.1 create mode 100644 changelogs/changes-1.7.0 create mode 100644 changelogs/changes-1.7.1 create mode 100644 changelogs/changes-1.7.2 create mode 100644 changelogs/changes-1.8.0 create mode 100644 changelogs/changes-1.8.1 create mode 100644 changelogs/changes-1.9.0.md create mode 100644 changelogs/changes-1.9.1.md create mode 100644 cmake/QbsBuildConfig.cmake create mode 100644 cmake/QbsDocumentation.cmake create mode 100644 dist/.gitignore create mode 100644 doc/CMakeLists.txt create mode 100644 doc/appendix/json-api.qdoc create mode 100644 doc/appendix/qbs-porting.qdoc create mode 100644 doc/classic.css create mode 100644 doc/codeattributions.qdoc create mode 100644 doc/config/macros.qdocconf create mode 100644 doc/config/qbs-project.qdocconf create mode 100644 doc/config/style/qt5-sidebar.html create mode 100644 doc/doc.pri create mode 100644 doc/doc.qbs create mode 100644 doc/doc_shared.pri create mode 100644 doc/doc_targets.pri create mode 100644 doc/external-resources.qdoc create mode 100755 doc/fix-qmlimports.py create mode 100644 doc/fixnavi.pl create mode 100644 doc/howtos.qdoc create mode 100644 doc/images/qbs-build-process.png create mode 100644 doc/images/qbs-dmg.png create mode 100644 doc/images/qbs-settings-gui.png create mode 100644 doc/man/man.pri create mode 100644 doc/man/man.qbs create mode 100644 doc/man/qbs.1 create mode 100644 doc/man/see-also.h2m create mode 100644 doc/qbs-hugo.qdocconf create mode 100644 doc/qbs-online.qdocconf create mode 100644 doc/qbs.qdoc create mode 100644 doc/qbs.qdocconf create mode 100644 doc/reference/cli/builtin/cli-build.qdoc create mode 100644 doc/reference/cli/builtin/cli-clean.qdoc create mode 100644 doc/reference/cli/builtin/cli-dump-nodes-tree.qdoc create mode 100644 doc/reference/cli/builtin/cli-generate.qdoc create mode 100644 doc/reference/cli/builtin/cli-help.qdoc create mode 100644 doc/reference/cli/builtin/cli-install.qdoc create mode 100644 doc/reference/cli/builtin/cli-list-products.qdoc create mode 100644 doc/reference/cli/builtin/cli-resolve.qdoc create mode 100644 doc/reference/cli/builtin/cli-run.qdoc create mode 100644 doc/reference/cli/builtin/cli-session.qdoc create mode 100644 doc/reference/cli/builtin/cli-shell.qdoc create mode 100644 doc/reference/cli/builtin/cli-status.qdoc create mode 100644 doc/reference/cli/builtin/cli-update-timestamps.qdoc create mode 100644 doc/reference/cli/builtin/cli-version.qdoc create mode 100644 doc/reference/cli/cli-options.qdocinc create mode 100644 doc/reference/cli/cli-parameters.qdocinc create mode 100644 doc/reference/cli/cli.qdoc create mode 100644 doc/reference/cli/tools/cli-config-ui.qdoc create mode 100644 doc/reference/cli/tools/cli-config.qdoc create mode 100644 doc/reference/cli/tools/cli-create-project.qdoc create mode 100644 doc/reference/cli/tools/cli-setup-android.qdoc create mode 100644 doc/reference/cli/tools/cli-setup-qt.qdoc create mode 100644 doc/reference/cli/tools/cli-setup-toolchains.qdoc create mode 100644 doc/reference/commands.qdoc create mode 100644 doc/reference/items/convenience/appleapplicationdiskimage.qdoc create mode 100644 doc/reference/items/convenience/applediskimage.qdoc create mode 100644 doc/reference/items/convenience/application.qdoc create mode 100644 doc/reference/items/convenience/applicationextension.qdoc create mode 100644 doc/reference/items/convenience/autotestrunner.qdoc create mode 100644 doc/reference/items/convenience/cppapplication.qdoc create mode 100644 doc/reference/items/convenience/dynamiclibrary.qdoc create mode 100644 doc/reference/items/convenience/innosetup.qdoc create mode 100644 doc/reference/items/convenience/installpackage.qdoc create mode 100644 doc/reference/items/convenience/javaclasscollection.qdoc create mode 100644 doc/reference/items/convenience/javajarfile.qdoc create mode 100644 doc/reference/items/convenience/library.qdoc create mode 100644 doc/reference/items/convenience/loadablemodule.qdoc create mode 100644 doc/reference/items/convenience/qtapplication.qdoc create mode 100644 doc/reference/items/convenience/qtguiapplication.qdoc create mode 100644 doc/reference/items/convenience/staticlibrary.qdoc create mode 100644 doc/reference/items/convenience/xpcservice.qdoc create mode 100644 doc/reference/items/language/artifact.qdoc create mode 100644 doc/reference/items/language/depends.qdoc create mode 100644 doc/reference/items/language/export.qdoc create mode 100644 doc/reference/items/language/filetagger.qdoc create mode 100644 doc/reference/items/language/group.qbs create mode 100644 doc/reference/items/language/group.qdoc create mode 100644 doc/reference/items/language/joblimit.qdoc create mode 100644 doc/reference/items/language/module.qdoc create mode 100644 doc/reference/items/language/moduleprovider.qdoc create mode 100644 doc/reference/items/language/parameter.qdoc create mode 100644 doc/reference/items/language/parameters.qdoc create mode 100644 doc/reference/items/language/probe.qdoc create mode 100644 doc/reference/items/language/product.qdoc create mode 100644 doc/reference/items/language/profile.qdoc create mode 100644 doc/reference/items/language/project.qdoc create mode 100644 doc/reference/items/language/properties.qdoc create mode 100644 doc/reference/items/language/propertyoptions.qdoc create mode 100644 doc/reference/items/language/rule.qdoc create mode 100644 doc/reference/items/language/scanner.qdoc create mode 100644 doc/reference/items/language/subproject.qdoc create mode 100644 doc/reference/items/probe/binary-probe.qdoc create mode 100644 doc/reference/items/probe/conanfile-probe.qdoc create mode 100644 doc/reference/items/probe/dmc-probe.qdoc create mode 100644 doc/reference/items/probe/framework-probe.qdoc create mode 100644 doc/reference/items/probe/iar-probe.qdoc create mode 100644 doc/reference/items/probe/include-probe.qdoc create mode 100644 doc/reference/items/probe/keil-probe.qdoc create mode 100644 doc/reference/items/probe/library-probe.qdoc create mode 100644 doc/reference/items/probe/path-probe.qdoc create mode 100644 doc/reference/items/probe/pkgconfig-probe.qdoc create mode 100644 doc/reference/items/probe/sdcc-probe.qdoc create mode 100644 doc/reference/items/probe/watcom-probe.qdoc create mode 100644 doc/reference/jsextensions/jsextension-binaryfile.qdoc create mode 100644 doc/reference/jsextensions/jsextension-environment.qdoc create mode 100644 doc/reference/jsextensions/jsextension-file.qdoc create mode 100644 doc/reference/jsextensions/jsextension-fileinfo.qdoc create mode 100644 doc/reference/jsextensions/jsextension-host.qdoc create mode 100644 doc/reference/jsextensions/jsextension-process.qdoc create mode 100644 doc/reference/jsextensions/jsextension-propertylist.qdoc create mode 100644 doc/reference/jsextensions/jsextension-temporarydir.qdoc create mode 100644 doc/reference/jsextensions/jsextension-textfile.qdoc create mode 100644 doc/reference/jsextensions/jsextension-utilities.qdoc create mode 100644 doc/reference/jsextensions/jsextension-xml.qdoc create mode 100644 doc/reference/jsextensions/jsextensions-general.qdoc create mode 100644 doc/reference/module-providers/qbspkgconfig-module-provider.qdoc create mode 100644 doc/reference/module-providers/qt-module-provider.qdoc create mode 100644 doc/reference/modules/android-ndk-module.qdoc create mode 100644 doc/reference/modules/android-sdk-module.qdoc create mode 100644 doc/reference/modules/archiver-module.qdoc create mode 100644 doc/reference/modules/asan-module.qdoc create mode 100644 doc/reference/modules/autotest-module.qdoc create mode 100644 doc/reference/modules/bundle-module.qdoc create mode 100644 doc/reference/modules/capnprotocpp-module.qdoc create mode 100644 doc/reference/modules/codesign-module.qdoc create mode 100644 doc/reference/modules/cpp-module.qdoc create mode 100644 doc/reference/modules/cpufeatures-module.qdoc create mode 100644 doc/reference/modules/dmg-module.qdoc create mode 100644 doc/reference/modules/exporter-pkgconfig-module.qdoc create mode 100644 doc/reference/modules/exporter-qbs-module.qdoc create mode 100644 doc/reference/modules/freedesktop-module.qdoc create mode 100644 doc/reference/modules/ib-module.qdoc create mode 100644 doc/reference/modules/ico-module.qdoc create mode 100644 doc/reference/modules/innosetup-module.qdoc create mode 100644 doc/reference/modules/java-module.qdoc create mode 100644 doc/reference/modules/lexyacc-module.qdoc create mode 100644 doc/reference/modules/nodejs-module.qdoc create mode 100644 doc/reference/modules/nsis-module.qdoc create mode 100644 doc/reference/modules/pkgconfig-module.qdoc create mode 100644 doc/reference/modules/protobufcpp-module.qdoc create mode 100644 doc/reference/modules/protobufnanopb-module.qdoc create mode 100644 doc/reference/modules/protobufobjc-module.qdoc create mode 100644 doc/reference/modules/qbs-module.qdoc create mode 100644 doc/reference/modules/qnx-module.qdoc create mode 100644 doc/reference/modules/qt-android_support-module.qdoc create mode 100644 doc/reference/modules/qt-core-module.qdoc create mode 100644 doc/reference/modules/qt-dbus-module.qdoc create mode 100644 doc/reference/modules/qt-declarative-module.qdoc create mode 100644 doc/reference/modules/qt-gui-module.qdoc create mode 100644 doc/reference/modules/qt-modules.qdoc create mode 100644 doc/reference/modules/qt-plugin_support-module.qdoc create mode 100644 doc/reference/modules/qt-qml-module.qdoc create mode 100644 doc/reference/modules/qt-quick-module.qdoc create mode 100644 doc/reference/modules/qt-scxml-module.qdoc create mode 100644 doc/reference/modules/texttemplate-module.qdoc create mode 100644 doc/reference/modules/typescript-module.qdoc create mode 100644 doc/reference/modules/vcs-module.qdoc create mode 100644 doc/reference/modules/wix-module.qdoc create mode 100644 doc/reference/modules/xcode-module.qdoc create mode 100644 doc/reference/reference.qdoc create mode 100644 doc/targets/qbs-target-android.qdoc create mode 100644 doc/targets/qbs-target-apple-common.qdocinc create mode 100644 doc/targets/qbs-target-integrity.qdoc create mode 100644 doc/targets/qbs-target-ios.qdoc create mode 100644 doc/targets/qbs-target-linux.qdoc create mode 100644 doc/targets/qbs-target-macos.qdoc create mode 100644 doc/targets/qbs-target-platforms.qdoc create mode 100644 doc/targets/qbs-target-qnx.qdoc create mode 100644 doc/targets/qbs-target-tvos.qdoc create mode 100644 doc/targets/qbs-target-vxworks.qdoc create mode 100644 doc/targets/qbs-target-watchos.qdoc create mode 100644 doc/targets/qbs-target-windows.qdoc create mode 100644 docker-compose.yml create mode 100644 docker/docker.qbs create mode 100644 docker/focal/Dockerfile create mode 100755 docker/focal/entrypoint.sh create mode 100644 docker/focal/test-android-no-qt.Dockerfile create mode 100644 docker/focal/test-android.Dockerfile create mode 100644 docker/focal/test-baremetal.Dockerfile create mode 100644 docker/focal/test-qt4.Dockerfile create mode 100644 docker/focal/test-qt6-static.Dockerfile create mode 100644 docker/leap/Dockerfile create mode 100755 docker/leap/entrypoint.sh create mode 100644 docker/windowsservercore/Dockerfile create mode 100644 examples/app-and-lib/app-and-lib.qbs create mode 100644 examples/app-and-lib/app/app.qbs create mode 100644 examples/app-and-lib/app/main.cpp create mode 100644 examples/app-and-lib/lib/lib.cpp create mode 100644 examples/app-and-lib/lib/lib.h create mode 100644 examples/app-and-lib/lib/lib.qbs create mode 100644 examples/baremetal/at90can128olimex/at90can128olimex.qbs create mode 100644 examples/baremetal/at90can128olimex/redblink/README.md create mode 100644 examples/baremetal/at90can128olimex/redblink/gpio.c create mode 100644 examples/baremetal/at90can128olimex/redblink/gpio.h create mode 100644 examples/baremetal/at90can128olimex/redblink/main.c create mode 100644 examples/baremetal/at90can128olimex/redblink/redblink.qbs create mode 100644 examples/baremetal/baremetal.qbs create mode 100644 examples/baremetal/cc2540usbdongle/cc2540usbdongle.qbs create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/README.md create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/gpio.c create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/gpio.h create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/greenblink.qbs create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/main.c create mode 100644 examples/baremetal/cc2540usbdongle/greenblink/system.h create mode 100644 examples/baremetal/cy7c68013a/cy7c68013a.qbs create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/README.md create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/core.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/core.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/defs.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/gpio.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/gpio.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/hid.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/hid.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/hiddesc.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/hidep0.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/hidep1.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/irqs.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/main.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/nes-gamepads.qbs create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/regs.h create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/usb.c create mode 100644 examples/baremetal/cy7c68013a/nes-gamepads/usb.h create mode 100644 examples/baremetal/esp8266/README.md create mode 100644 examples/baremetal/esp8266/access-point/access-point.qbs create mode 100644 examples/baremetal/esp8266/access-point/user_config.h create mode 100644 examples/baremetal/esp8266/access-point/user_main.c create mode 100644 examples/baremetal/esp8266/esp8266.qbs create mode 100644 examples/baremetal/esp8266/qbs/imports/Esp8266SdkProbe.qbs create mode 100644 examples/baremetal/esp8266/qbs/modules/esp8266_sdk/Esp8266SdkModule.qbs create mode 100644 examples/baremetal/msp430f5529/msp430f5529.qbs create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/README.md create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/gamepads.ld create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/gpio.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/gpio.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/hid.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/hiddesc.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/hidep0.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/hidep1.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/hwdefs.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/main.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/nes-gamepads.qbs create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/pmm.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/pmm.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/ucs.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/ucs.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/usb.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/usb.h create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/wdt_a.c create mode 100644 examples/baremetal/msp430f5529/nes-gamepads/wdt_a.h create mode 100644 examples/baremetal/msp430f5529/redblink/README.md create mode 100644 examples/baremetal/msp430f5529/redblink/gpio.c create mode 100644 examples/baremetal/msp430f5529/redblink/gpio.h create mode 100644 examples/baremetal/msp430f5529/redblink/main.c create mode 100644 examples/baremetal/msp430f5529/redblink/redblink.qbs create mode 100644 examples/baremetal/msp430f5529/redblink/system.c create mode 100644 examples/baremetal/msp430f5529/redblink/system.h create mode 100644 examples/baremetal/pca10001/greenblink/README.md create mode 100644 examples/baremetal/pca10001/greenblink/gcc/flash.ld create mode 100644 examples/baremetal/pca10001/greenblink/gcc/startup.s create mode 100644 examples/baremetal/pca10001/greenblink/gpio.c create mode 100644 examples/baremetal/pca10001/greenblink/gpio.h create mode 100644 examples/baremetal/pca10001/greenblink/greenblink.qbs create mode 100644 examples/baremetal/pca10001/greenblink/iar/flash.icf create mode 100644 examples/baremetal/pca10001/greenblink/iar/startup.s create mode 100644 examples/baremetal/pca10001/greenblink/keil/flash.sct create mode 100644 examples/baremetal/pca10001/greenblink/keil/startup.s create mode 100644 examples/baremetal/pca10001/greenblink/main.c create mode 100644 examples/baremetal/pca10001/greenblink/system.h create mode 100644 examples/baremetal/pca10001/pca10001.qbs create mode 100644 examples/baremetal/pca10040/greenblink/README.md create mode 100644 examples/baremetal/pca10040/greenblink/gcc/flash.ld create mode 100644 examples/baremetal/pca10040/greenblink/gcc/startup.s create mode 100644 examples/baremetal/pca10040/greenblink/gpio.c create mode 100644 examples/baremetal/pca10040/greenblink/gpio.h create mode 100644 examples/baremetal/pca10040/greenblink/greenblink.qbs create mode 100644 examples/baremetal/pca10040/greenblink/iar/flash.icf create mode 100644 examples/baremetal/pca10040/greenblink/iar/startup.s create mode 100644 examples/baremetal/pca10040/greenblink/keil/flash.sct create mode 100644 examples/baremetal/pca10040/greenblink/keil/startup.s create mode 100644 examples/baremetal/pca10040/greenblink/main.c create mode 100644 examples/baremetal/pca10040/greenblink/system.h create mode 100644 examples/baremetal/pca10040/pca10040.qbs create mode 100644 examples/baremetal/stm32f103/greenblink/README.md create mode 100644 examples/baremetal/stm32f103/greenblink/gcc/flash.ld create mode 100644 examples/baremetal/stm32f103/greenblink/gcc/startup.s create mode 100644 examples/baremetal/stm32f103/greenblink/gpio.c create mode 100644 examples/baremetal/stm32f103/greenblink/gpio.h create mode 100644 examples/baremetal/stm32f103/greenblink/greenblink.qbs create mode 100644 examples/baremetal/stm32f103/greenblink/iar/flash.icf create mode 100644 examples/baremetal/stm32f103/greenblink/iar/startup.s create mode 100644 examples/baremetal/stm32f103/greenblink/keil/flash.sct create mode 100644 examples/baremetal/stm32f103/greenblink/keil/startup.s create mode 100644 examples/baremetal/stm32f103/greenblink/main.c create mode 100644 examples/baremetal/stm32f103/greenblink/system.h create mode 100644 examples/baremetal/stm32f103/stm32f103.qbs create mode 100644 examples/baremetal/stm32f4discovery/blueblink/README.md create mode 100644 examples/baremetal/stm32f4discovery/blueblink/blueblink.qbs create mode 100644 examples/baremetal/stm32f4discovery/blueblink/gcc/flash.ld create mode 100644 examples/baremetal/stm32f4discovery/blueblink/gcc/startup.s create mode 100644 examples/baremetal/stm32f4discovery/blueblink/gpio.c create mode 100644 examples/baremetal/stm32f4discovery/blueblink/gpio.h create mode 100644 examples/baremetal/stm32f4discovery/blueblink/iar/flash.icf create mode 100644 examples/baremetal/stm32f4discovery/blueblink/iar/startup.s create mode 100644 examples/baremetal/stm32f4discovery/blueblink/keil/flash.sct create mode 100644 examples/baremetal/stm32f4discovery/blueblink/keil/startup.s create mode 100644 examples/baremetal/stm32f4discovery/blueblink/main.c create mode 100644 examples/baremetal/stm32f4discovery/blueblink/system.h create mode 100644 examples/baremetal/stm32f4discovery/stm32f4discovery.qbs create mode 100644 examples/baremetal/stm8s103f3/redblink/README.md create mode 100644 examples/baremetal/stm8s103f3/redblink/gpio.c create mode 100644 examples/baremetal/stm8s103f3/redblink/gpio.h create mode 100644 examples/baremetal/stm8s103f3/redblink/main.c create mode 100644 examples/baremetal/stm8s103f3/redblink/redblink.qbs create mode 100644 examples/baremetal/stm8s103f3/redblink/system.h create mode 100644 examples/baremetal/stm8s103f3/stm8s103f3.qbs create mode 100644 examples/capnproto/addressbook_cpp/addressbook.capnp create mode 100644 examples/capnproto/addressbook_cpp/addressbook.cpp create mode 100644 examples/capnproto/addressbook_cpp/addressbook_cpp.qbs create mode 100644 examples/capnproto/calculator_cpp/calculator-client.cpp create mode 100644 examples/capnproto/calculator_cpp/calculator-server.cpp create mode 100644 examples/capnproto/calculator_cpp/calculator.capnp create mode 100644 examples/capnproto/calculator_cpp/calculator_cpp.qbs create mode 100644 examples/cocoa-application/CocoaApplication.xcodeproj/project.pbxproj create mode 100644 examples/cocoa-application/CocoaApplication/AppDelegate.h create mode 100644 examples/cocoa-application/CocoaApplication/AppDelegate.m create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication-Info.plist create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication-Prefix.pch create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/Contents.json create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_16x16.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_16x16@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_32x32.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_32x32@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_512x512.png create mode 100644 examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_512x512@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/background.png create mode 100644 examples/cocoa-application/CocoaApplication/background@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_16x16.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_16x16@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_32x32.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_32x32@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_512x512.png create mode 100644 examples/cocoa-application/CocoaApplication/dmg.iconset/icon_512x512@2x.png create mode 100644 examples/cocoa-application/CocoaApplication/en.lproj/Credits.rtf create mode 100644 examples/cocoa-application/CocoaApplication/en.lproj/InfoPlist.strings create mode 100644 examples/cocoa-application/CocoaApplication/en.lproj/LICENSE create mode 100644 examples/cocoa-application/CocoaApplication/en.lproj/MainMenu.xib create mode 100644 examples/cocoa-application/CocoaApplication/en_US.lproj/Credits.rtf create mode 100644 examples/cocoa-application/CocoaApplication/en_US.lproj/InfoPlist.strings create mode 100644 examples/cocoa-application/CocoaApplication/en_US.lproj/LICENSE create mode 100644 examples/cocoa-application/CocoaApplication/en_US.lproj/MainMenu.xib create mode 100644 examples/cocoa-application/CocoaApplication/main.m create mode 100644 examples/cocoa-application/app.qbs create mode 100644 examples/cocoa-application/cocoa-application.qbs create mode 100644 examples/cocoa-application/dmg.qbs create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication.xcodeproj/project.pbxproj create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.h create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.m create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Info.plist create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Prefix.pch create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.h create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.m create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/LaunchScreen.storyboard create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.h create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.m create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPad.xib create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPhone.xib create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/InfoPlist.strings create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPad.xib create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPhone.xib create mode 100644 examples/cocoa-touch-application/CocoaTouchApplication/main.m create mode 100644 examples/cocoa-touch-application/cocoa-touch-application.qbs create mode 100644 examples/code-generator/code-generator.qbs create mode 100644 examples/code-generator/hwgen.cpp create mode 100644 examples/collidingmice/collidingmice.qbs create mode 100644 examples/collidingmice/images/cheese.jpg create mode 100644 examples/collidingmice/main.cpp create mode 100644 examples/collidingmice/mice.qrc create mode 100644 examples/collidingmice/mouse.cpp create mode 100644 examples/collidingmice/mouse.h create mode 100644 examples/compiled-qml/MainForm.ui.qml create mode 100644 examples/compiled-qml/cheese.jpg create mode 100644 examples/compiled-qml/compiled-qml.qbs create mode 100644 examples/compiled-qml/main.cpp create mode 100644 examples/compiled-qml/main.qml create mode 100644 examples/compiled-qml/qml.qrc create mode 100644 examples/examples.qbs create mode 100644 examples/grpc/client.cpp create mode 100644 examples/grpc/grpc.qbs create mode 100644 examples/grpc/ping-pong-grpc.proto create mode 100644 examples/grpc/server.cpp create mode 100644 examples/helloworld-complex/helloworld-complex.qbs create mode 100644 examples/helloworld-complex/src/foo.cpp create mode 100644 examples/helloworld-complex/src/foo.h create mode 100644 examples/helloworld-complex/src/main.cpp create mode 100644 examples/helloworld-complex/src/specialfeature.cpp create mode 100644 examples/helloworld-complex/src/specialfeature.h create mode 100644 examples/helloworld-minimal/helloworld-minimal.qbs create mode 100644 examples/helloworld-minimal/main.cpp create mode 100644 examples/helloworld-qt/helloworld-qt.qbs create mode 100644 examples/helloworld-qt/main.cpp create mode 100644 examples/install-bundle/MainMenu.xib create mode 100644 examples/install-bundle/Storyboard.storyboard create mode 100644 examples/install-bundle/assetcatalog1.xcassets/other.imageset/Contents.json create mode 100644 examples/install-bundle/assetcatalog1.xcassets/other.imageset/icon_16x16.png create mode 100644 examples/install-bundle/assetcatalog1.xcassets/other.imageset/icon_16x16@2x.png create mode 100644 examples/install-bundle/assetcatalog2.xcassets/other.imageset/Contents.json create mode 100644 examples/install-bundle/assetcatalog2.xcassets/other.imageset/icon_16x16.png create mode 100644 examples/install-bundle/assetcatalog2.xcassets/other.imageset/icon_16x16@2x.png create mode 100644 examples/install-bundle/coreutils.cpp create mode 100644 examples/install-bundle/coreutils.h create mode 100644 examples/install-bundle/install-bundle.qbs create mode 100644 examples/install-bundle/main.cpp create mode 100644 examples/install-bundle/white.iconset/icon_16x16.png create mode 100644 examples/install-bundle/white.iconset/icon_16x16@2x.png create mode 100644 examples/pkgconfig-provider/main.c create mode 100644 examples/pkgconfig-provider/pkgconfig-provider.qbs create mode 100644 examples/protobuf/addressbook_cpp/README.md create mode 100644 examples/protobuf/addressbook_cpp/addressbook_cpp.qbs create mode 100644 examples/protobuf/addressbook_cpp/main.cpp create mode 100644 examples/protobuf/addressbook_objc/README.md create mode 100644 examples/protobuf/addressbook_objc/addressbook_objc.qbs create mode 100644 examples/protobuf/addressbook_objc/main.m create mode 100644 examples/protobuf/shared/addressbook.proto create mode 100644 examples/rpaths/main.cpp create mode 100644 examples/rpaths/objecta.cpp create mode 100644 examples/rpaths/objecta.h create mode 100644 examples/rpaths/objectb.cpp create mode 100644 examples/rpaths/objectb.h create mode 100644 examples/rpaths/rpaths.qbs create mode 100644 examples/rule/lorem_ipsum.txt create mode 100644 examples/rule/rule.qbs create mode 100644 qbs-resources/imports/QbsApp.qbs create mode 100644 qbs-resources/imports/QbsAutotest.qbs create mode 100644 qbs-resources/imports/QbsLibrary.qbs create mode 100644 qbs-resources/imports/QbsProduct.qbs create mode 100644 qbs-resources/imports/QbsStaticLibrary.qbs create mode 100644 qbs-resources/imports/QbsUnittest.qbs create mode 100644 qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs create mode 100644 qbs-resources/modules/qbsversion/qbsversion.qbs create mode 100644 qbs.pro create mode 100644 qbs.qbs create mode 100644 qbs_version.pri create mode 100644 scripts/address-sanitizer-suppressions.txt create mode 100755 scripts/build-qbs-doc.sh create mode 100755 scripts/build-qbs-with-cmake.sh create mode 100755 scripts/build-qbs-with-qbs.sh create mode 100755 scripts/build-qbs-with-qmake.sh create mode 100755 scripts/cpu-count.sh create mode 100644 scripts/install-dm.sh create mode 100755 scripts/install-ow.sh create mode 100755 scripts/install-qt.sh create mode 100644 scripts/make-release-archives.bat create mode 100755 scripts/make-release-archives.sh create mode 100755 scripts/run-analyzer.sh create mode 100644 scripts/scripts.qbs create mode 100755 scripts/test-baremetal.sh create mode 100755 scripts/test-for-android.sh create mode 100755 scripts/test-qbs.sh create mode 100755 scripts/test-qt-for-android.sh create mode 100755 scripts/test-qt.sh create mode 100755 scripts/test-qt4.sh create mode 100644 scripts/thread-sanitizer-suppressions.txt create mode 100755 scripts/update-dmgbuild.sh create mode 100755 scripts/update-xcspecs.sh create mode 100644 share/CMakeLists.txt create mode 100644 share/qbs/imports/qbs/BundleTools/bundle-tools.js create mode 100644 share/qbs/imports/qbs/DarwinTools/darwin-tools.js create mode 100644 share/qbs/imports/qbs/ModUtils/utils.js create mode 100644 share/qbs/imports/qbs/PathTools/path-tools.js create mode 100644 share/qbs/imports/qbs/Probes/AndroidNdkProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/AndroidSdkProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/BinaryProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/ClBinaryProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/ClangClBinaryProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/ClangClProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/ConanfileProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/CosmicProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/DmcProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/FrameworkProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/GccBinaryProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/GccProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/GccVersionProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/IarProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/IcoUtilsVersionProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/IncludeProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/InnoSetupProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/JdkProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/JdkVersionProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/KeilProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/LibraryProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/MsvcProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/NodeJsProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/NpmProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/PathProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/SdccProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/WatcomProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/WiXProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/XcodeProbe.qbs create mode 100644 share/qbs/imports/qbs/Probes/path-probe.js create mode 100644 share/qbs/imports/qbs/UnixUtils/unix-utils.js create mode 100644 share/qbs/imports/qbs/WindowsUtils/windows-utils.js create mode 100644 share/qbs/imports/qbs/base/AndroidApk.qbs create mode 100644 share/qbs/imports/qbs/base/AppleApplicationDiskImage.qbs create mode 100644 share/qbs/imports/qbs/base/AppleDiskImage.qbs create mode 100644 share/qbs/imports/qbs/base/Application.qbs create mode 100644 share/qbs/imports/qbs/base/ApplicationExtension.qbs create mode 100644 share/qbs/imports/qbs/base/AutotestRunner.qbs create mode 100644 share/qbs/imports/qbs/base/CppApplication.qbs create mode 100644 share/qbs/imports/qbs/base/DynamicLibrary.qbs create mode 100644 share/qbs/imports/qbs/base/InnoSetup.qbs create mode 100644 share/qbs/imports/qbs/base/InstallPackage.qbs create mode 100644 share/qbs/imports/qbs/base/JavaClassCollection.qbs create mode 100644 share/qbs/imports/qbs/base/JavaJarFile.qbs create mode 100644 share/qbs/imports/qbs/base/Library.qbs create mode 100644 share/qbs/imports/qbs/base/LoadableModule.qbs create mode 100644 share/qbs/imports/qbs/base/NSISSetup.qbs create mode 100644 share/qbs/imports/qbs/base/NativeBinary.qbs create mode 100644 share/qbs/imports/qbs/base/NetModule.qbs create mode 100644 share/qbs/imports/qbs/base/NodeJSApplication.qbs create mode 100644 share/qbs/imports/qbs/base/QtApplication.qbs create mode 100644 share/qbs/imports/qbs/base/QtGuiApplication.qbs create mode 100644 share/qbs/imports/qbs/base/StaticLibrary.qbs create mode 100644 share/qbs/imports/qbs/base/WindowsInstallerPackage.qbs create mode 100644 share/qbs/imports/qbs/base/WindowsSetupPackage.qbs create mode 100644 share/qbs/imports/qbs/base/XPCService.qbs create mode 100644 share/qbs/module-providers/Qt/provider.qbs create mode 100644 share/qbs/module-providers/Qt/setup-qt.js create mode 100644 share/qbs/module-providers/Qt/templates/QtModule.qbs create mode 100644 share/qbs/module-providers/Qt/templates/QtPlugin.qbs create mode 100644 share/qbs/module-providers/Qt/templates/android_support.qbs create mode 100644 share/qbs/module-providers/Qt/templates/core.qbs create mode 100644 share/qbs/module-providers/Qt/templates/dbus.js create mode 100644 share/qbs/module-providers/Qt/templates/dbus.qbs create mode 100644 share/qbs/module-providers/Qt/templates/gui.qbs create mode 100644 share/qbs/module-providers/Qt/templates/moc.js create mode 100644 share/qbs/module-providers/Qt/templates/module.qbs create mode 100644 share/qbs/module-providers/Qt/templates/plugin.qbs create mode 100644 share/qbs/module-providers/Qt/templates/plugin_support.qbs create mode 100644 share/qbs/module-providers/Qt/templates/qdoc.js create mode 100644 share/qbs/module-providers/Qt/templates/qml.js create mode 100644 share/qbs/module-providers/Qt/templates/qml.qbs create mode 100644 share/qbs/module-providers/Qt/templates/qmlcache.qbs create mode 100644 share/qbs/module-providers/Qt/templates/quick.js create mode 100644 share/qbs/module-providers/Qt/templates/quick.qbs create mode 100644 share/qbs/module-providers/Qt/templates/rcc.js create mode 100644 share/qbs/module-providers/Qt/templates/scxml.qbs create mode 100644 share/qbs/module-providers/__fallback/fallback.qbs create mode 100644 share/qbs/module-providers/__fallback/provider.qbs create mode 100644 share/qbs/module-providers/qbspkgconfig.qbs create mode 100644 share/qbs/modules/Android/android-utils.js create mode 100644 share/qbs/modules/Android/ndk/ndk.qbs create mode 100644 share/qbs/modules/Android/ndk/utils.js create mode 100644 share/qbs/modules/Android/sdk/sdk.qbs create mode 100644 share/qbs/modules/Android/sdk/utils.js create mode 100644 share/qbs/modules/Exporter/pkgconfig/pkgconfig.js create mode 100644 share/qbs/modules/Exporter/pkgconfig/pkgconfig.qbs create mode 100644 share/qbs/modules/Exporter/qbs/qbsexporter.js create mode 100644 share/qbs/modules/Exporter/qbs/qbsexporter.qbs create mode 100644 share/qbs/modules/Sanitizers/address/asan.qbs create mode 100644 share/qbs/modules/archiver/archiver.qbs create mode 100644 share/qbs/modules/autotest/autotest.qbs create mode 100644 share/qbs/modules/bundle/BundleModule.qbs create mode 100644 share/qbs/modules/bundle/MacOSX-Package-Types.xcspec create mode 100644 share/qbs/modules/bundle/MacOSX-Product-Types.xcspec create mode 100644 share/qbs/modules/bundle/bundle.js create mode 100644 share/qbs/modules/capnproto/capnproto.js create mode 100644 share/qbs/modules/capnproto/capnprotobase.qbs create mode 100644 share/qbs/modules/capnproto/cpp/capnprotocpp.qbs create mode 100644 share/qbs/modules/cli/CLIModule.qbs create mode 100644 share/qbs/modules/cli/cli.js create mode 100644 share/qbs/modules/cli/mono.qbs create mode 100644 share/qbs/modules/cli/windows-dotnet.qbs create mode 100644 share/qbs/modules/codesign/CodeSignModule.qbs create mode 100644 share/qbs/modules/codesign/android.qbs create mode 100644 share/qbs/modules/codesign/apple.qbs create mode 100644 share/qbs/modules/codesign/codesign.js create mode 100644 share/qbs/modules/codesign/noop.qbs create mode 100644 share/qbs/modules/codesign/signtool.qbs create mode 100644 share/qbs/modules/cpp/CppModule.qbs create mode 100644 share/qbs/modules/cpp/DarwinGCC.qbs create mode 100644 share/qbs/modules/cpp/GenericGCC.qbs create mode 100644 share/qbs/modules/cpp/LinuxGCC.qbs create mode 100644 share/qbs/modules/cpp/MingwBaseModule.qbs create mode 100644 share/qbs/modules/cpp/UnixGCC.qbs create mode 100644 share/qbs/modules/cpp/android-gcc.qbs create mode 100644 share/qbs/modules/cpp/cosmic.js create mode 100644 share/qbs/modules/cpp/cosmic.qbs create mode 100644 share/qbs/modules/cpp/cpp.js create mode 100644 share/qbs/modules/cpp/darwin.js create mode 100644 share/qbs/modules/cpp/dmc.js create mode 100644 share/qbs/modules/cpp/dmc.qbs create mode 100644 share/qbs/modules/cpp/freebsd-gcc.qbs create mode 100644 share/qbs/modules/cpp/freebsd.js create mode 100644 share/qbs/modules/cpp/gcc.js create mode 100644 share/qbs/modules/cpp/iar.js create mode 100644 share/qbs/modules/cpp/iar.qbs create mode 100644 share/qbs/modules/cpp/ios-gcc.qbs create mode 100644 share/qbs/modules/cpp/keil.js create mode 100644 share/qbs/modules/cpp/keil.qbs create mode 100644 share/qbs/modules/cpp/macos-gcc.qbs create mode 100644 share/qbs/modules/cpp/msvc.js create mode 100644 share/qbs/modules/cpp/qnx-qcc.qbs create mode 100644 share/qbs/modules/cpp/sdcc.js create mode 100644 share/qbs/modules/cpp/sdcc.qbs create mode 100644 share/qbs/modules/cpp/setuprunenv.js create mode 100644 share/qbs/modules/cpp/tvos-gcc.qbs create mode 100644 share/qbs/modules/cpp/watchos-gcc.qbs create mode 100644 share/qbs/modules/cpp/watcom.js create mode 100644 share/qbs/modules/cpp/watcom.qbs create mode 100644 share/qbs/modules/cpp/windows-clang-cl.qbs create mode 100644 share/qbs/modules/cpp/windows-clang-mingw.qbs create mode 100644 share/qbs/modules/cpp/windows-mingw.qbs create mode 100644 share/qbs/modules/cpp/windows-msvc-base.qbs create mode 100644 share/qbs/modules/cpp/windows-msvc.qbs create mode 100644 share/qbs/modules/cpufeatures/cpufeatures.qbs create mode 100644 share/qbs/modules/dmg/DMGModule.qbs create mode 100644 share/qbs/modules/dmg/dmg.js create mode 100644 share/qbs/modules/freedesktop/FreeDesktop.qbs create mode 100644 share/qbs/modules/freedesktop/freedesktop.js create mode 100644 share/qbs/modules/ib/IBModule.qbs create mode 100644 share/qbs/modules/ib/ib.js create mode 100644 share/qbs/modules/ico/IcoModule.qbs create mode 100644 share/qbs/modules/ico/ico.js create mode 100644 share/qbs/modules/innosetup/InnoSetupModule.qbs create mode 100644 share/qbs/modules/java/JavaModule.qbs create mode 100644 share/qbs/modules/java/io/qt/qbs/Artifact.java create mode 100644 share/qbs/modules/java/io/qt/qbs/ArtifactListJsonWriter.java create mode 100644 share/qbs/modules/java/io/qt/qbs/ArtifactListWriter.java create mode 100644 share/qbs/modules/java/io/qt/qbs/tools/JavaCompilerScannerTool.java create mode 100644 share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerOptions.java create mode 100644 share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerScanner.java create mode 100644 share/qbs/modules/java/io/qt/qbs/tools/utils/NullFileObject.java create mode 100644 share/qbs/modules/java/utils.js create mode 100644 share/qbs/modules/lex_yacc/lexyacc.js create mode 100644 share/qbs/modules/lex_yacc/lexyacc.qbs create mode 100644 share/qbs/modules/nodejs/NodeJS.qbs create mode 100644 share/qbs/modules/nodejs/nodejs.js create mode 100644 share/qbs/modules/nsis/NSISModule.qbs create mode 100644 share/qbs/modules/pkgconfig/pkgconfig.qbs create mode 100644 share/qbs/modules/protobuf/cpp/protobufcpp.qbs create mode 100644 share/qbs/modules/protobuf/nanopb/nanopb.qbs create mode 100644 share/qbs/modules/protobuf/objc/protobufobjc.qbs create mode 100644 share/qbs/modules/protobuf/protobuf.js create mode 100644 share/qbs/modules/protobuf/protobufbase.qbs create mode 100644 share/qbs/modules/qbs/common.qbs create mode 100644 share/qbs/modules/qnx/qnx.qbs create mode 100644 share/qbs/modules/texttemplate/texttemplate.qbs create mode 100644 share/qbs/modules/typescript/TypeScriptModule.qbs create mode 100644 share/qbs/modules/typescript/qbs-tsc-scan/.gitignore create mode 100644 share/qbs/modules/typescript/qbs-tsc-scan/qbs-tsc-scan.ts create mode 100644 share/qbs/modules/typescript/typescript.js create mode 100644 share/qbs/modules/vcs/vcs-module.qbs create mode 100644 share/qbs/modules/wix/WiXModule.qbs create mode 100644 share/qbs/modules/xcode/xcode.js create mode 100644 share/qbs/modules/xcode/xcode.qbs create mode 100644 share/share.qbs create mode 100644 src/3rdparty/python/.gitignore create mode 100755 src/3rdparty/python/bin/dmgbuild create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/biplist/LICENSE create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/biplist/__init__.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/biplist/qt_attribution.json create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/LICENSE create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/__init__.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/badge.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/colors.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/core.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/licensing.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/qt_attribution.json create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/resources.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/ds_store/LICENSE create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/ds_store/__init__.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/ds_store/buddy.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/ds_store/qt_attribution.json create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/ds_store/store.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/LICENSE create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/__init__.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/alias.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/bookmark.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/osx.py create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/qt_attribution.json create mode 100644 src/3rdparty/python/lib/python2.7/site-packages/mac_alias/utils.py create mode 100644 src/CMakeLists.txt create mode 100644 src/app/CMakeLists.txt create mode 100644 src/app/app.pri create mode 100644 src/app/app.pro create mode 100644 src/app/apps.qbs create mode 100644 src/app/config-ui/CMakeLists.txt create mode 100644 src/app/config-ui/Info.plist create mode 100644 src/app/config-ui/commandlineparser.cpp create mode 100644 src/app/config-ui/commandlineparser.h create mode 100644 src/app/config-ui/config-ui.pro create mode 100644 src/app/config-ui/config-ui.qbs create mode 100644 src/app/config-ui/fgapp.mm create mode 100644 src/app/config-ui/main.cpp create mode 100644 src/app/config-ui/mainwindow.cpp create mode 100644 src/app/config-ui/mainwindow.h create mode 100644 src/app/config-ui/mainwindow.ui create mode 100644 src/app/config/CMakeLists.txt create mode 100644 src/app/config/config.pro create mode 100644 src/app/config/config.qbs create mode 100644 src/app/config/configcommand.h create mode 100644 src/app/config/configcommandexecutor.cpp create mode 100644 src/app/config/configcommandexecutor.h create mode 100644 src/app/config/configcommandlineparser.cpp create mode 100644 src/app/config/configcommandlineparser.h create mode 100644 src/app/config/configmain.cpp create mode 100644 src/app/qbs-create-project/CMakeLists.txt create mode 100644 src/app/qbs-create-project/create-project-main.cpp create mode 100644 src/app/qbs-create-project/createproject.cpp create mode 100644 src/app/qbs-create-project/createproject.h create mode 100644 src/app/qbs-create-project/qbs-create-project.pro create mode 100644 src/app/qbs-create-project/qbs-create-project.qbs create mode 100644 src/app/qbs-setup-android/CMakeLists.txt create mode 100644 src/app/qbs-setup-android/android-setup.cpp create mode 100644 src/app/qbs-setup-android/android-setup.h create mode 100644 src/app/qbs-setup-android/commandlineparser.cpp create mode 100644 src/app/qbs-setup-android/commandlineparser.h create mode 100644 src/app/qbs-setup-android/main.cpp create mode 100644 src/app/qbs-setup-android/qbs-setup-android.exe.manifest create mode 100644 src/app/qbs-setup-android/qbs-setup-android.pro create mode 100644 src/app/qbs-setup-android/qbs-setup-android.qbs create mode 100644 src/app/qbs-setup-android/qbs-setup-android.rc create mode 100644 src/app/qbs-setup-qt/CMakeLists.txt create mode 100644 src/app/qbs-setup-qt/commandlineparser.cpp create mode 100644 src/app/qbs-setup-qt/commandlineparser.h create mode 100644 src/app/qbs-setup-qt/main.cpp create mode 100644 src/app/qbs-setup-qt/qbs-setup-qt.exe.manifest create mode 100644 src/app/qbs-setup-qt/qbs-setup-qt.pro create mode 100644 src/app/qbs-setup-qt/qbs-setup-qt.qbs create mode 100644 src/app/qbs-setup-qt/qbs-setup-qt.rc create mode 100644 src/app/qbs-setup-qt/setupqt.cpp create mode 100644 src/app/qbs-setup-qt/setupqt.h create mode 100644 src/app/qbs-setup-toolchains/CMakeLists.txt create mode 100644 src/app/qbs-setup-toolchains/clangclprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/clangclprobe.h create mode 100644 src/app/qbs-setup-toolchains/commandlineparser.cpp create mode 100644 src/app/qbs-setup-toolchains/commandlineparser.h create mode 100644 src/app/qbs-setup-toolchains/cosmicprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/cosmicprobe.h create mode 100644 src/app/qbs-setup-toolchains/dmcprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/dmcprobe.h create mode 100644 src/app/qbs-setup-toolchains/gccprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/gccprobe.h create mode 100644 src/app/qbs-setup-toolchains/iarewprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/iarewprobe.h create mode 100644 src/app/qbs-setup-toolchains/keilprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/keilprobe.h create mode 100644 src/app/qbs-setup-toolchains/main.cpp create mode 100644 src/app/qbs-setup-toolchains/msvcprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/msvcprobe.h create mode 100644 src/app/qbs-setup-toolchains/probe.cpp create mode 100644 src/app/qbs-setup-toolchains/probe.h create mode 100644 src/app/qbs-setup-toolchains/qbs-setup-toolchains.exe.manifest create mode 100644 src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro create mode 100644 src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs create mode 100644 src/app/qbs-setup-toolchains/qbs-setup-toolchains.rc create mode 100644 src/app/qbs-setup-toolchains/sdccprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/sdccprobe.h create mode 100644 src/app/qbs-setup-toolchains/watcomprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/watcomprobe.h create mode 100644 src/app/qbs-setup-toolchains/xcodeprobe.cpp create mode 100644 src/app/qbs-setup-toolchains/xcodeprobe.h create mode 100644 src/app/qbs/CMakeLists.txt create mode 100644 src/app/qbs/application.cpp create mode 100644 src/app/qbs/application.h create mode 100644 src/app/qbs/commandlinefrontend.cpp create mode 100644 src/app/qbs/commandlinefrontend.h create mode 100644 src/app/qbs/consoleprogressobserver.cpp create mode 100644 src/app/qbs/consoleprogressobserver.h create mode 100644 src/app/qbs/ctrlchandler.cpp create mode 100644 src/app/qbs/ctrlchandler.h create mode 100644 src/app/qbs/main.cpp create mode 100644 src/app/qbs/parser/commandlineoption.cpp create mode 100644 src/app/qbs/parser/commandlineoption.h create mode 100644 src/app/qbs/parser/commandlineoptionpool.cpp create mode 100644 src/app/qbs/parser/commandlineoptionpool.h create mode 100644 src/app/qbs/parser/commandlineparser.cpp create mode 100644 src/app/qbs/parser/commandlineparser.h create mode 100644 src/app/qbs/parser/commandpool.cpp create mode 100644 src/app/qbs/parser/commandpool.h create mode 100644 src/app/qbs/parser/commandtype.h create mode 100644 src/app/qbs/parser/parser.pri create mode 100644 src/app/qbs/parser/parsercommand.cpp create mode 100644 src/app/qbs/parser/parsercommand.h create mode 100644 src/app/qbs/qbs.pro create mode 100644 src/app/qbs/qbs.qbs create mode 100644 src/app/qbs/qbstool.cpp create mode 100644 src/app/qbs/qbstool.h create mode 100644 src/app/qbs/session.cpp create mode 100644 src/app/qbs/session.h create mode 100644 src/app/qbs/sessionpacket.cpp create mode 100644 src/app/qbs/sessionpacket.h create mode 100644 src/app/qbs/sessionpacketreader.cpp create mode 100644 src/app/qbs/sessionpacketreader.h create mode 100644 src/app/qbs/status.cpp create mode 100644 src/app/qbs/status.h create mode 100644 src/app/qbs/stdinreader.cpp create mode 100644 src/app/qbs/stdinreader.h create mode 100644 src/app/shared/CMakeLists.txt create mode 100644 src/app/shared/logging/CMakeLists.txt create mode 100644 src/app/shared/logging/coloredoutput.cpp create mode 100644 src/app/shared/logging/coloredoutput.h create mode 100644 src/app/shared/logging/consolelogger.cpp create mode 100644 src/app/shared/logging/consolelogger.h create mode 100644 src/app/shared/logging/logging.pri create mode 100644 src/app/shared/logging/logging.qbs create mode 100644 src/app/shared/shared.qbs create mode 100644 src/install_prefix.pri create mode 100644 src/lib/CMakeLists.txt create mode 100644 src/lib/bundledlibs.pri create mode 100644 src/lib/corelib/CMakeLists.txt create mode 100644 src/lib/corelib/api/api.pri create mode 100644 src/lib/corelib/api/changeset.cpp create mode 100644 src/lib/corelib/api/changeset.h create mode 100644 src/lib/corelib/api/internaljobs.cpp create mode 100644 src/lib/corelib/api/internaljobs.h create mode 100644 src/lib/corelib/api/jobs.cpp create mode 100644 src/lib/corelib/api/jobs.h create mode 100644 src/lib/corelib/api/languageinfo.cpp create mode 100644 src/lib/corelib/api/languageinfo.h create mode 100644 src/lib/corelib/api/project.cpp create mode 100644 src/lib/corelib/api/project.h create mode 100644 src/lib/corelib/api/project_p.h create mode 100644 src/lib/corelib/api/projectdata.cpp create mode 100644 src/lib/corelib/api/projectdata.h create mode 100644 src/lib/corelib/api/projectdata_p.h create mode 100644 src/lib/corelib/api/projectfileupdater.cpp create mode 100644 src/lib/corelib/api/projectfileupdater.h create mode 100644 src/lib/corelib/api/propertymap_p.h create mode 100644 src/lib/corelib/api/qmljsrewriter.cpp create mode 100644 src/lib/corelib/api/qmljsrewriter.h create mode 100644 src/lib/corelib/api/rulecommand.cpp create mode 100644 src/lib/corelib/api/rulecommand.h create mode 100644 src/lib/corelib/api/rulecommand_p.h create mode 100644 src/lib/corelib/api/runenvironment.cpp create mode 100644 src/lib/corelib/api/runenvironment.h create mode 100644 src/lib/corelib/api/transformerdata.cpp create mode 100644 src/lib/corelib/api/transformerdata.h create mode 100644 src/lib/corelib/api/transformerdata_p.h create mode 100644 src/lib/corelib/buildgraph/abstractcommandexecutor.cpp create mode 100644 src/lib/corelib/buildgraph/abstractcommandexecutor.h create mode 100644 src/lib/corelib/buildgraph/artifact.cpp create mode 100644 src/lib/corelib/buildgraph/artifact.h create mode 100644 src/lib/corelib/buildgraph/artifactcleaner.cpp create mode 100644 src/lib/corelib/buildgraph/artifactcleaner.h create mode 100644 src/lib/corelib/buildgraph/artifactsscriptvalue.cpp create mode 100644 src/lib/corelib/buildgraph/artifactsscriptvalue.h create mode 100644 src/lib/corelib/buildgraph/artifactvisitor.cpp create mode 100644 src/lib/corelib/buildgraph/artifactvisitor.h create mode 100644 src/lib/corelib/buildgraph/buildgraph.cpp create mode 100644 src/lib/corelib/buildgraph/buildgraph.h create mode 100644 src/lib/corelib/buildgraph/buildgraph.pri create mode 100644 src/lib/corelib/buildgraph/buildgraphloader.cpp create mode 100644 src/lib/corelib/buildgraph/buildgraphloader.h create mode 100644 src/lib/corelib/buildgraph/buildgraphnode.cpp create mode 100644 src/lib/corelib/buildgraph/buildgraphnode.h create mode 100644 src/lib/corelib/buildgraph/buildgraphvisitor.h create mode 100644 src/lib/corelib/buildgraph/cycledetector.cpp create mode 100644 src/lib/corelib/buildgraph/cycledetector.h create mode 100644 src/lib/corelib/buildgraph/dependencyparametersscriptvalue.cpp create mode 100644 src/lib/corelib/buildgraph/dependencyparametersscriptvalue.h create mode 100644 src/lib/corelib/buildgraph/depscanner.cpp create mode 100644 src/lib/corelib/buildgraph/depscanner.h create mode 100644 src/lib/corelib/buildgraph/emptydirectoriesremover.cpp create mode 100644 src/lib/corelib/buildgraph/emptydirectoriesremover.h create mode 100644 src/lib/corelib/buildgraph/environmentscriptrunner.cpp create mode 100644 src/lib/corelib/buildgraph/environmentscriptrunner.h create mode 100644 src/lib/corelib/buildgraph/executor.cpp create mode 100644 src/lib/corelib/buildgraph/executor.h create mode 100644 src/lib/corelib/buildgraph/executorjob.cpp create mode 100644 src/lib/corelib/buildgraph/executorjob.h create mode 100644 src/lib/corelib/buildgraph/filedependency.cpp create mode 100644 src/lib/corelib/buildgraph/filedependency.h create mode 100644 src/lib/corelib/buildgraph/forward_decls.h create mode 100644 src/lib/corelib/buildgraph/inputartifactscanner.cpp create mode 100644 src/lib/corelib/buildgraph/inputartifactscanner.h create mode 100644 src/lib/corelib/buildgraph/jscommandexecutor.cpp create mode 100644 src/lib/corelib/buildgraph/jscommandexecutor.h create mode 100644 src/lib/corelib/buildgraph/nodeset.cpp create mode 100644 src/lib/corelib/buildgraph/nodeset.h create mode 100644 src/lib/corelib/buildgraph/nodetreedumper.cpp create mode 100644 src/lib/corelib/buildgraph/nodetreedumper.h create mode 100644 src/lib/corelib/buildgraph/processcommandexecutor.cpp create mode 100644 src/lib/corelib/buildgraph/processcommandexecutor.h create mode 100644 src/lib/corelib/buildgraph/productbuilddata.cpp create mode 100644 src/lib/corelib/buildgraph/productbuilddata.h create mode 100644 src/lib/corelib/buildgraph/productinstaller.cpp create mode 100644 src/lib/corelib/buildgraph/productinstaller.h create mode 100644 src/lib/corelib/buildgraph/projectbuilddata.cpp create mode 100644 src/lib/corelib/buildgraph/projectbuilddata.h create mode 100644 src/lib/corelib/buildgraph/qtmocscanner.cpp create mode 100644 src/lib/corelib/buildgraph/qtmocscanner.h create mode 100644 src/lib/corelib/buildgraph/rawscanneddependency.cpp create mode 100644 src/lib/corelib/buildgraph/rawscanneddependency.h create mode 100644 src/lib/corelib/buildgraph/rawscanresults.cpp create mode 100644 src/lib/corelib/buildgraph/rawscanresults.h create mode 100644 src/lib/corelib/buildgraph/requestedartifacts.cpp create mode 100644 src/lib/corelib/buildgraph/requestedartifacts.h create mode 100644 src/lib/corelib/buildgraph/requesteddependencies.cpp create mode 100644 src/lib/corelib/buildgraph/requesteddependencies.h create mode 100644 src/lib/corelib/buildgraph/rescuableartifactdata.h create mode 100644 src/lib/corelib/buildgraph/rulecommands.cpp create mode 100644 src/lib/corelib/buildgraph/rulecommands.h create mode 100644 src/lib/corelib/buildgraph/rulegraph.cpp create mode 100644 src/lib/corelib/buildgraph/rulegraph.h create mode 100644 src/lib/corelib/buildgraph/rulenode.cpp create mode 100644 src/lib/corelib/buildgraph/rulenode.h create mode 100644 src/lib/corelib/buildgraph/rulesapplicator.cpp create mode 100644 src/lib/corelib/buildgraph/rulesapplicator.h create mode 100644 src/lib/corelib/buildgraph/rulesevaluationcontext.cpp create mode 100644 src/lib/corelib/buildgraph/rulesevaluationcontext.h create mode 100644 src/lib/corelib/buildgraph/scriptclasspropertyiterator.h create mode 100644 src/lib/corelib/buildgraph/timestampsupdater.cpp create mode 100644 src/lib/corelib/buildgraph/timestampsupdater.h create mode 100644 src/lib/corelib/buildgraph/transformer.cpp create mode 100644 src/lib/corelib/buildgraph/transformer.h create mode 100644 src/lib/corelib/buildgraph/transformerchangetracking.cpp create mode 100644 src/lib/corelib/buildgraph/transformerchangetracking.h create mode 100644 src/lib/corelib/corelib.pro create mode 100644 src/lib/corelib/corelib.qbs create mode 100644 src/lib/corelib/generators/generatableprojectiterator.cpp create mode 100644 src/lib/corelib/generators/generatableprojectiterator.h create mode 100644 src/lib/corelib/generators/generator.cpp create mode 100644 src/lib/corelib/generators/generator.h create mode 100644 src/lib/corelib/generators/generatordata.cpp create mode 100644 src/lib/corelib/generators/generatordata.h create mode 100644 src/lib/corelib/generators/generators.pri create mode 100644 src/lib/corelib/generators/generatorutils.cpp create mode 100644 src/lib/corelib/generators/generatorutils.h create mode 100644 src/lib/corelib/generators/generatorversioninfo.cpp create mode 100644 src/lib/corelib/generators/generatorversioninfo.h create mode 100644 src/lib/corelib/generators/igeneratableprojectvisitor.h create mode 100644 src/lib/corelib/generators/ixmlnodevisitor.h create mode 100644 src/lib/corelib/generators/xmlproject.cpp create mode 100644 src/lib/corelib/generators/xmlproject.h create mode 100644 src/lib/corelib/generators/xmlprojectwriter.cpp create mode 100644 src/lib/corelib/generators/xmlprojectwriter.h create mode 100644 src/lib/corelib/generators/xmlproperty.cpp create mode 100644 src/lib/corelib/generators/xmlproperty.h create mode 100644 src/lib/corelib/generators/xmlpropertygroup.cpp create mode 100644 src/lib/corelib/generators/xmlpropertygroup.h create mode 100644 src/lib/corelib/generators/xmlworkspace.cpp create mode 100644 src/lib/corelib/generators/xmlworkspace.h create mode 100644 src/lib/corelib/generators/xmlworkspacewriter.cpp create mode 100644 src/lib/corelib/generators/xmlworkspacewriter.h create mode 100644 src/lib/corelib/jsextensions/binaryfile.cpp create mode 100644 src/lib/corelib/jsextensions/domxml.cpp create mode 100644 src/lib/corelib/jsextensions/environmentextension.cpp create mode 100644 src/lib/corelib/jsextensions/file.cpp create mode 100644 src/lib/corelib/jsextensions/fileinfoextension.cpp create mode 100644 src/lib/corelib/jsextensions/host.cpp create mode 100644 src/lib/corelib/jsextensions/jsextensions.cpp create mode 100644 src/lib/corelib/jsextensions/jsextensions.h create mode 100644 src/lib/corelib/jsextensions/jsextensions.pri create mode 100644 src/lib/corelib/jsextensions/moduleproperties.cpp create mode 100644 src/lib/corelib/jsextensions/moduleproperties.h create mode 100644 src/lib/corelib/jsextensions/pkgconfigjs.cpp create mode 100644 src/lib/corelib/jsextensions/pkgconfigjs.h create mode 100644 src/lib/corelib/jsextensions/process.cpp create mode 100644 src/lib/corelib/jsextensions/propertylist.cpp create mode 100644 src/lib/corelib/jsextensions/propertylist_darwin.h create mode 100644 src/lib/corelib/jsextensions/propertylist_darwin.mm create mode 100644 src/lib/corelib/jsextensions/propertylistutils.h create mode 100644 src/lib/corelib/jsextensions/propertylistutils.mm create mode 100644 src/lib/corelib/jsextensions/temporarydir.cpp create mode 100644 src/lib/corelib/jsextensions/textfile.cpp create mode 100644 src/lib/corelib/jsextensions/utilitiesextension.cpp create mode 100644 src/lib/corelib/language/artifactproperties.cpp create mode 100644 src/lib/corelib/language/artifactproperties.h create mode 100644 src/lib/corelib/language/astimportshandler.cpp create mode 100644 src/lib/corelib/language/astimportshandler.h create mode 100644 src/lib/corelib/language/astpropertiesitemhandler.cpp create mode 100644 src/lib/corelib/language/astpropertiesitemhandler.h create mode 100644 src/lib/corelib/language/asttools.cpp create mode 100644 src/lib/corelib/language/asttools.h create mode 100644 src/lib/corelib/language/builtindeclarations.cpp create mode 100644 src/lib/corelib/language/builtindeclarations.h create mode 100644 src/lib/corelib/language/deprecationinfo.h create mode 100644 src/lib/corelib/language/evaluationdata.h create mode 100644 src/lib/corelib/language/evaluator.cpp create mode 100644 src/lib/corelib/language/evaluator.h create mode 100644 src/lib/corelib/language/evaluatorscriptclass.cpp create mode 100755 src/lib/corelib/language/evaluatorscriptclass.h create mode 100644 src/lib/corelib/language/filecontext.cpp create mode 100644 src/lib/corelib/language/filecontext.h create mode 100644 src/lib/corelib/language/filecontextbase.cpp create mode 100644 src/lib/corelib/language/filecontextbase.h create mode 100644 src/lib/corelib/language/filetags.cpp create mode 100644 src/lib/corelib/language/filetags.h create mode 100644 src/lib/corelib/language/forward_decls.h create mode 100644 src/lib/corelib/language/identifiersearch.cpp create mode 100644 src/lib/corelib/language/identifiersearch.h create mode 100644 src/lib/corelib/language/item.cpp create mode 100644 src/lib/corelib/language/item.h create mode 100644 src/lib/corelib/language/itemdeclaration.cpp create mode 100644 src/lib/corelib/language/itemdeclaration.h create mode 100644 src/lib/corelib/language/itemobserver.h create mode 100644 src/lib/corelib/language/itempool.cpp create mode 100644 src/lib/corelib/language/itempool.h create mode 100644 src/lib/corelib/language/itemreader.cpp create mode 100644 src/lib/corelib/language/itemreader.h create mode 100644 src/lib/corelib/language/itemreaderastvisitor.cpp create mode 100644 src/lib/corelib/language/itemreaderastvisitor.h create mode 100644 src/lib/corelib/language/itemreadervisitorstate.cpp create mode 100644 src/lib/corelib/language/itemreadervisitorstate.h create mode 100644 src/lib/corelib/language/itemtype.h create mode 100644 src/lib/corelib/language/jsimports.h create mode 100644 src/lib/corelib/language/language.cpp create mode 100644 src/lib/corelib/language/language.h create mode 100644 src/lib/corelib/language/language.pri create mode 100644 src/lib/corelib/language/loader.cpp create mode 100644 src/lib/corelib/language/loader.h create mode 100644 src/lib/corelib/language/moduleloader.cpp create mode 100644 src/lib/corelib/language/moduleloader.h create mode 100644 src/lib/corelib/language/modulemerger.cpp create mode 100644 src/lib/corelib/language/modulemerger.h create mode 100644 src/lib/corelib/language/moduleproviderinfo.h create mode 100644 src/lib/corelib/language/moduleproviderloader.cpp create mode 100644 src/lib/corelib/language/moduleproviderloader.h create mode 100644 src/lib/corelib/language/preparescriptobserver.cpp create mode 100644 src/lib/corelib/language/preparescriptobserver.h create mode 100644 src/lib/corelib/language/probesresolver.cpp create mode 100644 src/lib/corelib/language/probesresolver.h create mode 100644 src/lib/corelib/language/projectresolver.cpp create mode 100644 src/lib/corelib/language/projectresolver.h create mode 100644 src/lib/corelib/language/property.cpp create mode 100644 src/lib/corelib/language/property.h create mode 100644 src/lib/corelib/language/propertydeclaration.cpp create mode 100644 src/lib/corelib/language/propertydeclaration.h create mode 100644 src/lib/corelib/language/propertymapinternal.cpp create mode 100644 src/lib/corelib/language/propertymapinternal.h create mode 100644 src/lib/corelib/language/qualifiedid.cpp create mode 100644 src/lib/corelib/language/qualifiedid.h create mode 100644 src/lib/corelib/language/resolvedfilecontext.cpp create mode 100644 src/lib/corelib/language/resolvedfilecontext.h create mode 100644 src/lib/corelib/language/scriptengine.cpp create mode 100644 src/lib/corelib/language/scriptengine.h create mode 100644 src/lib/corelib/language/scriptimporter.cpp create mode 100644 src/lib/corelib/language/scriptimporter.h create mode 100644 src/lib/corelib/language/scriptpropertyobserver.cpp create mode 100644 src/lib/corelib/language/scriptpropertyobserver.h create mode 100644 src/lib/corelib/language/value.cpp create mode 100644 src/lib/corelib/language/value.h create mode 100644 src/lib/corelib/logging/categories.cpp create mode 100644 src/lib/corelib/logging/categories.h create mode 100644 src/lib/corelib/logging/ilogsink.cpp create mode 100644 src/lib/corelib/logging/ilogsink.h create mode 100644 src/lib/corelib/logging/logger.cpp create mode 100644 src/lib/corelib/logging/logger.h create mode 100644 src/lib/corelib/logging/logging.pri create mode 100644 src/lib/corelib/logging/translator.h create mode 100644 src/lib/corelib/parser/parser.pri create mode 100644 src/lib/corelib/parser/qmlerror.cpp create mode 100644 src/lib/corelib/parser/qmlerror.h create mode 100644 src/lib/corelib/parser/qmljs.g create mode 100644 src/lib/corelib/parser/qmljsast.cpp create mode 100644 src/lib/corelib/parser/qmljsast_p.h create mode 100644 src/lib/corelib/parser/qmljsastfwd_p.h create mode 100644 src/lib/corelib/parser/qmljsastvisitor.cpp create mode 100644 src/lib/corelib/parser/qmljsastvisitor_p.h create mode 100644 src/lib/corelib/parser/qmljsengine_p.cpp create mode 100644 src/lib/corelib/parser/qmljsengine_p.h create mode 100644 src/lib/corelib/parser/qmljsglobal_p.h create mode 100644 src/lib/corelib/parser/qmljsgrammar.cpp create mode 100644 src/lib/corelib/parser/qmljsgrammar_p.h create mode 100644 src/lib/corelib/parser/qmljskeywords_p.h create mode 100644 src/lib/corelib/parser/qmljslexer.cpp create mode 100644 src/lib/corelib/parser/qmljslexer_p.h create mode 100644 src/lib/corelib/parser/qmljsmemorypool_p.h create mode 100644 src/lib/corelib/parser/qmljsparser.cpp create mode 100644 src/lib/corelib/parser/qmljsparser_p.h create mode 100644 src/lib/corelib/qbs.h create mode 100644 src/lib/corelib/tools/applecodesignutils.cpp create mode 100644 src/lib/corelib/tools/applecodesignutils.h create mode 100644 src/lib/corelib/tools/architectures.cpp create mode 100644 src/lib/corelib/tools/architectures.h create mode 100644 src/lib/corelib/tools/buildgraphlocker.cpp create mode 100644 src/lib/corelib/tools/buildgraphlocker.h create mode 100644 src/lib/corelib/tools/buildoptions.cpp create mode 100644 src/lib/corelib/tools/buildoptions.h create mode 100644 src/lib/corelib/tools/clangclinfo.cpp create mode 100644 src/lib/corelib/tools/clangclinfo.h create mode 100644 src/lib/corelib/tools/cleanoptions.cpp create mode 100644 src/lib/corelib/tools/cleanoptions.h create mode 100644 src/lib/corelib/tools/codelocation.cpp create mode 100644 src/lib/corelib/tools/codelocation.h create mode 100644 src/lib/corelib/tools/commandechomode.cpp create mode 100644 src/lib/corelib/tools/commandechomode.h create mode 100644 src/lib/corelib/tools/dynamictypecheck.h create mode 100644 src/lib/corelib/tools/error.cpp create mode 100644 src/lib/corelib/tools/error.h create mode 100644 src/lib/corelib/tools/executablefinder.cpp create mode 100644 src/lib/corelib/tools/executablefinder.h create mode 100644 src/lib/corelib/tools/fileinfo.cpp create mode 100644 src/lib/corelib/tools/fileinfo.h create mode 100644 src/lib/corelib/tools/filesaver.cpp create mode 100644 src/lib/corelib/tools/filesaver.h create mode 100644 src/lib/corelib/tools/filetime.cpp create mode 100644 src/lib/corelib/tools/filetime.h create mode 100644 src/lib/corelib/tools/generateoptions.cpp create mode 100644 src/lib/corelib/tools/generateoptions.h create mode 100644 src/lib/corelib/tools/hostosinfo.h create mode 100644 src/lib/corelib/tools/id.cpp create mode 100644 src/lib/corelib/tools/id.h create mode 100644 src/lib/corelib/tools/installoptions.cpp create mode 100644 src/lib/corelib/tools/installoptions.h create mode 100644 src/lib/corelib/tools/iosutils.h create mode 100644 src/lib/corelib/tools/joblimits.cpp create mode 100644 src/lib/corelib/tools/joblimits.h create mode 100644 src/lib/corelib/tools/jsliterals.cpp create mode 100644 src/lib/corelib/tools/jsliterals.h create mode 100644 src/lib/corelib/tools/jsonhelper.h create mode 100644 src/lib/corelib/tools/launcherinterface.cpp create mode 100644 src/lib/corelib/tools/launcherinterface.h create mode 100644 src/lib/corelib/tools/launcherpackets.cpp create mode 100644 src/lib/corelib/tools/launcherpackets.h create mode 100644 src/lib/corelib/tools/launchersocket.cpp create mode 100644 src/lib/corelib/tools/launchersocket.h create mode 100644 src/lib/corelib/tools/msvcinfo.cpp create mode 100644 src/lib/corelib/tools/msvcinfo.h create mode 100644 src/lib/corelib/tools/pathutils.h create mode 100644 src/lib/corelib/tools/persistence.cpp create mode 100644 src/lib/corelib/tools/persistence.h create mode 100644 src/lib/corelib/tools/porting.h create mode 100644 src/lib/corelib/tools/preferences.cpp create mode 100644 src/lib/corelib/tools/preferences.h create mode 100644 src/lib/corelib/tools/processresult.cpp create mode 100644 src/lib/corelib/tools/processresult.h create mode 100644 src/lib/corelib/tools/processresult_p.h create mode 100644 src/lib/corelib/tools/processutils.cpp create mode 100644 src/lib/corelib/tools/processutils.h create mode 100644 src/lib/corelib/tools/profile.cpp create mode 100644 src/lib/corelib/tools/profile.h create mode 100644 src/lib/corelib/tools/profiling.cpp create mode 100644 src/lib/corelib/tools/profiling.h create mode 100644 src/lib/corelib/tools/progressobserver.cpp create mode 100644 src/lib/corelib/tools/progressobserver.h create mode 100644 src/lib/corelib/tools/projectgeneratormanager.cpp create mode 100644 src/lib/corelib/tools/projectgeneratormanager.h create mode 100644 src/lib/corelib/tools/qbs_export.h create mode 100644 src/lib/corelib/tools/qbsassert.cpp create mode 100644 src/lib/corelib/tools/qbsassert.h create mode 100644 src/lib/corelib/tools/qbspluginmanager.cpp create mode 100644 src/lib/corelib/tools/qbspluginmanager.h create mode 100644 src/lib/corelib/tools/qbsprocess.cpp create mode 100644 src/lib/corelib/tools/qbsprocess.h create mode 100644 src/lib/corelib/tools/qttools.cpp create mode 100644 src/lib/corelib/tools/qttools.h create mode 100644 src/lib/corelib/tools/scannerpluginmanager.cpp create mode 100644 src/lib/corelib/tools/scannerpluginmanager.h create mode 100644 src/lib/corelib/tools/scripttools.cpp create mode 100644 src/lib/corelib/tools/scripttools.h create mode 100644 src/lib/corelib/tools/set.h create mode 100644 src/lib/corelib/tools/settings.cpp create mode 100644 src/lib/corelib/tools/settings.h create mode 100644 src/lib/corelib/tools/settingscreator.cpp create mode 100644 src/lib/corelib/tools/settingscreator.h create mode 100644 src/lib/corelib/tools/settingsmodel.cpp create mode 100644 src/lib/corelib/tools/settingsmodel.h create mode 100644 src/lib/corelib/tools/settingsrepresentation.cpp create mode 100644 src/lib/corelib/tools/settingsrepresentation.h create mode 100644 src/lib/corelib/tools/setupprojectparameters.cpp create mode 100644 src/lib/corelib/tools/setupprojectparameters.h create mode 100644 src/lib/corelib/tools/shellutils.cpp create mode 100644 src/lib/corelib/tools/shellutils.h create mode 100644 src/lib/corelib/tools/stlutils.h create mode 100644 src/lib/corelib/tools/stringconstants.h create mode 100644 src/lib/corelib/tools/stringutils.h create mode 100644 src/lib/corelib/tools/toolchains.cpp create mode 100644 src/lib/corelib/tools/toolchains.h create mode 100644 src/lib/corelib/tools/tools.pri create mode 100644 src/lib/corelib/tools/version.cpp create mode 100644 src/lib/corelib/tools/version.h create mode 100644 src/lib/corelib/tools/visualstudioversioninfo.cpp create mode 100644 src/lib/corelib/tools/visualstudioversioninfo.h create mode 100644 src/lib/corelib/tools/vsenvironmentdetector.cpp create mode 100644 src/lib/corelib/tools/vsenvironmentdetector.h create mode 100644 src/lib/corelib/tools/weakpointer.h create mode 100644 src/lib/corelib/use_corelib.pri create mode 100644 src/lib/corelib/use_installed_corelib.pri create mode 100644 src/lib/library.pri create mode 100644 src/lib/library_base.pri create mode 100644 src/lib/libs.qbs create mode 100644 src/lib/msbuild/CMakeLists.txt create mode 100644 src/lib/msbuild/io/msbuildprojectwriter.cpp create mode 100644 src/lib/msbuild/io/msbuildprojectwriter.h create mode 100644 src/lib/msbuild/io/visualstudiosolutionwriter.cpp create mode 100644 src/lib/msbuild/io/visualstudiosolutionwriter.h create mode 100644 src/lib/msbuild/msbuild.pro create mode 100644 src/lib/msbuild/msbuild.qbs create mode 100644 src/lib/msbuild/msbuild/imsbuildgroup.cpp create mode 100644 src/lib/msbuild/msbuild/imsbuildgroup.h create mode 100644 src/lib/msbuild/msbuild/imsbuildnode.cpp create mode 100644 src/lib/msbuild/msbuild/imsbuildnode.h create mode 100644 src/lib/msbuild/msbuild/imsbuildnodevisitor.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildclcompile.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildclcompile.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildclinclude.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildclinclude.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildfileitem.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildfileitem.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildfilter.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildfilter.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildlink.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildlink.h create mode 100644 src/lib/msbuild/msbuild/items/msbuildnone.cpp create mode 100644 src/lib/msbuild/msbuild/items/msbuildnone.h create mode 100644 src/lib/msbuild/msbuild/msbuildimport.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildimport.h create mode 100644 src/lib/msbuild/msbuild/msbuildimportgroup.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildimportgroup.h create mode 100644 src/lib/msbuild/msbuild/msbuilditem.cpp create mode 100644 src/lib/msbuild/msbuild/msbuilditem.h create mode 100644 src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp create mode 100644 src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h create mode 100644 src/lib/msbuild/msbuild/msbuilditemgroup.cpp create mode 100644 src/lib/msbuild/msbuild/msbuilditemgroup.h create mode 100644 src/lib/msbuild/msbuild/msbuilditemmetadata.cpp create mode 100644 src/lib/msbuild/msbuild/msbuilditemmetadata.h create mode 100644 src/lib/msbuild/msbuild/msbuildproject.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildproject.h create mode 100644 src/lib/msbuild/msbuild/msbuildproperty.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildproperty.h create mode 100644 src/lib/msbuild/msbuild/msbuildpropertybase.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildpropertybase.h create mode 100644 src/lib/msbuild/msbuild/msbuildpropertygroup.cpp create mode 100644 src/lib/msbuild/msbuild/msbuildpropertygroup.h create mode 100644 src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp create mode 100644 src/lib/msbuild/solution/ivisualstudiosolutionproject.h create mode 100644 src/lib/msbuild/solution/visualstudiosolution.cpp create mode 100644 src/lib/msbuild/solution/visualstudiosolution.h create mode 100644 src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp create mode 100644 src/lib/msbuild/solution/visualstudiosolutionfileproject.h create mode 100644 src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp create mode 100644 src/lib/msbuild/solution/visualstudiosolutionfolderproject.h create mode 100644 src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp create mode 100644 src/lib/msbuild/solution/visualstudiosolutionglobalsection.h create mode 100644 src/lib/msbuild/use_installed_msbuild.pri create mode 100644 src/lib/msbuild/use_msbuild.pri create mode 100644 src/lib/pkgconfig/CMakeLists.txt create mode 100644 src/lib/pkgconfig/pcpackage.cpp create mode 100644 src/lib/pkgconfig/pcpackage.h create mode 100644 src/lib/pkgconfig/pcparser.cpp create mode 100644 src/lib/pkgconfig/pcparser.h create mode 100644 src/lib/pkgconfig/pkgconfig.cpp create mode 100644 src/lib/pkgconfig/pkgconfig.h create mode 100644 src/lib/pkgconfig/pkgconfig.pro create mode 100644 src/lib/pkgconfig/pkgconfig.qbs create mode 100644 src/lib/pkgconfig/use_pkgconfig.pri create mode 100644 src/lib/scriptengine/CMakeLists.txt create mode 100644 src/lib/scriptengine/scriptengine.pro create mode 100644 src/lib/scriptengine/scriptengine.qbs create mode 100644 src/lib/scriptengine/use_scriptengine.pri create mode 100644 src/lib/staticlibrary.pri create mode 100644 src/libexec/CMakeLists.txt create mode 100644 src/libexec/libexec.pri create mode 100644 src/libexec/libexec.pro create mode 100644 src/libexec/libexec.qbs create mode 100644 src/libexec/qbs_processlauncher/CMakeLists.txt create mode 100644 src/libexec/qbs_processlauncher/launcherlogging.cpp create mode 100644 src/libexec/qbs_processlauncher/launcherlogging.h create mode 100644 src/libexec/qbs_processlauncher/launchersockethandler.cpp create mode 100644 src/libexec/qbs_processlauncher/launchersockethandler.h create mode 100644 src/libexec/qbs_processlauncher/processlauncher-main.cpp create mode 100644 src/libexec/qbs_processlauncher/qbs_processlauncher.pro create mode 100644 src/libexec/qbs_processlauncher/qbs_processlauncher.qbs create mode 100644 src/library_dirname.pri create mode 100644 src/packages/archive/archive.qbs create mode 100644 src/packages/chocolatey/chocolatey.qbs create mode 100644 src/packages/chocolatey/chocolateyinstall.ps1 create mode 100644 src/packages/chocolatey/icon.png create mode 100644 src/packages/chocolatey/qbs.nuspec create mode 100644 src/packages/packages.qbs create mode 100644 src/plugins/CMakeLists.txt create mode 100644 src/plugins/generator/CMakeLists.txt create mode 100644 src/plugins/generator/clangcompilationdb/CMakeLists.txt create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdb.pri create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdb.pro create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdb.qbs create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.h create mode 100644 src/plugins/generator/clangcompilationdb/clangcompilationdbgeneratorplugin.cpp create mode 100644 src/plugins/generator/generator.pro create mode 100644 src/plugins/generator/iarew/CMakeLists.txt create mode 100644 src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.cpp create mode 100644 src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.cpp create mode 100644 src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp create mode 100644 src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp create mode 100644 src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h create mode 100644 src/plugins/generator/iarew/iarew.pri create mode 100644 src/plugins/generator/iarew/iarew.pro create mode 100644 src/plugins/generator/iarew/iarew.qbs create mode 100644 src/plugins/generator/iarew/iarewfileversionproperty.cpp create mode 100644 src/plugins/generator/iarew/iarewfileversionproperty.h create mode 100644 src/plugins/generator/iarew/iarewgenerator.cpp create mode 100644 src/plugins/generator/iarew/iarewgenerator.h create mode 100644 src/plugins/generator/iarew/iarewgeneratorplugin.cpp create mode 100644 src/plugins/generator/iarew/iarewoptionpropertygroup.cpp create mode 100644 src/plugins/generator/iarew/iarewoptionpropertygroup.h create mode 100644 src/plugins/generator/iarew/iarewproject.cpp create mode 100644 src/plugins/generator/iarew/iarewproject.h create mode 100644 src/plugins/generator/iarew/iarewprojectwriter.cpp create mode 100644 src/plugins/generator/iarew/iarewprojectwriter.h create mode 100644 src/plugins/generator/iarew/iarewsettingspropertygroup.cpp create mode 100644 src/plugins/generator/iarew/iarewsettingspropertygroup.h create mode 100644 src/plugins/generator/iarew/iarewsourcefilepropertygroup.cpp create mode 100644 src/plugins/generator/iarew/iarewsourcefilepropertygroup.h create mode 100644 src/plugins/generator/iarew/iarewsourcefilespropertygroup.cpp create mode 100644 src/plugins/generator/iarew/iarewsourcefilespropertygroup.h create mode 100644 src/plugins/generator/iarew/iarewtoolchainpropertygroup.cpp create mode 100644 src/plugins/generator/iarew/iarewtoolchainpropertygroup.h create mode 100644 src/plugins/generator/iarew/iarewutils.cpp create mode 100644 src/plugins/generator/iarew/iarewutils.h create mode 100644 src/plugins/generator/iarew/iarewversioninfo.h create mode 100644 src/plugins/generator/iarew/iarewworkspace.cpp create mode 100644 src/plugins/generator/iarew/iarewworkspace.h create mode 100644 src/plugins/generator/iarew/iarewworkspacewriter.cpp create mode 100644 src/plugins/generator/iarew/iarewworkspacewriter.h create mode 100644 src/plugins/generator/keiluv/CMakeLists.txt create mode 100644 src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp create mode 100644 src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h create mode 100644 src/plugins/generator/keiluv/keiluv.pri create mode 100644 src/plugins/generator/keiluv/keiluv.pro create mode 100644 src/plugins/generator/keiluv/keiluv.qbs create mode 100644 src/plugins/generator/keiluv/keiluvconstants.h create mode 100644 src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.cpp create mode 100644 src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.h create mode 100644 src/plugins/generator/keiluv/keiluvgenerator.cpp create mode 100644 src/plugins/generator/keiluv/keiluvgenerator.h create mode 100644 src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp create mode 100644 src/plugins/generator/keiluv/keiluvproject.cpp create mode 100644 src/plugins/generator/keiluv/keiluvproject.h create mode 100644 src/plugins/generator/keiluv/keiluvprojectwriter.cpp create mode 100644 src/plugins/generator/keiluv/keiluvprojectwriter.h create mode 100644 src/plugins/generator/keiluv/keiluvutils.cpp create mode 100644 src/plugins/generator/keiluv/keiluvutils.h create mode 100644 src/plugins/generator/keiluv/keiluvversioninfo.h create mode 100644 src/plugins/generator/keiluv/keiluvworkspace.cpp create mode 100644 src/plugins/generator/keiluv/keiluvworkspace.h create mode 100644 src/plugins/generator/keiluv/keiluvworkspacewriter.cpp create mode 100644 src/plugins/generator/keiluv/keiluvworkspacewriter.h create mode 100644 src/plugins/generator/makefilegenerator/CMakeLists.txt create mode 100644 src/plugins/generator/makefilegenerator/makefilegenerator.cpp create mode 100644 src/plugins/generator/makefilegenerator/makefilegenerator.h create mode 100644 src/plugins/generator/makefilegenerator/makefilegenerator.pri create mode 100644 src/plugins/generator/makefilegenerator/makefilegenerator.pro create mode 100644 src/plugins/generator/makefilegenerator/makefilegenerator.qbs create mode 100644 src/plugins/generator/makefilegenerator/makefilegeneratorplugin.cpp create mode 100644 src/plugins/generator/visualstudio/CMakeLists.txt create mode 100644 src/plugins/generator/visualstudio/msbuildfiltersproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildfiltersproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildqbsgenerateproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildqbsgenerateproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildqbsproductproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildtargetproject.cpp create mode 100644 src/plugins/generator/visualstudio/msbuildtargetproject.h create mode 100644 src/plugins/generator/visualstudio/msbuildutils.h create mode 100644 src/plugins/generator/visualstudio/visualstudio.pri create mode 100644 src/plugins/generator/visualstudio/visualstudio.pro create mode 100644 src/plugins/generator/visualstudio/visualstudio.qbs create mode 100644 src/plugins/generator/visualstudio/visualstudiogenerator.cpp create mode 100644 src/plugins/generator/visualstudio/visualstudiogenerator.h create mode 100644 src/plugins/generator/visualstudio/visualstudiogeneratorplugin.cpp create mode 100644 src/plugins/generator/visualstudio/visualstudioguidpool.cpp create mode 100644 src/plugins/generator/visualstudio/visualstudioguidpool.h create mode 100644 src/plugins/plugins.pri create mode 100644 src/plugins/plugins.pro create mode 100644 src/plugins/plugins.qbs create mode 100644 src/plugins/qbs_plugin_common.pri create mode 100644 src/plugins/qbsplugin.qbs create mode 100644 src/plugins/scanner/CMakeLists.txt create mode 100644 src/plugins/scanner/cpp/CMakeLists.txt create mode 100644 src/plugins/scanner/cpp/CPlusPlusForwardDeclarations.h create mode 100644 src/plugins/scanner/cpp/Lexer.cpp create mode 100644 src/plugins/scanner/cpp/Lexer.h create mode 100644 src/plugins/scanner/cpp/Token.cpp create mode 100644 src/plugins/scanner/cpp/Token.h create mode 100644 src/plugins/scanner/cpp/cpp.pri create mode 100644 src/plugins/scanner/cpp/cpp.pro create mode 100644 src/plugins/scanner/cpp/cpp.qbs create mode 100644 src/plugins/scanner/cpp/cpp_global.h create mode 100644 src/plugins/scanner/cpp/cppscanner.cpp create mode 100644 src/plugins/scanner/qt/CMakeLists.txt create mode 100644 src/plugins/scanner/qt/qt.pri create mode 100644 src/plugins/scanner/qt/qt.pro create mode 100644 src/plugins/scanner/qt/qt.qbs create mode 100644 src/plugins/scanner/qt/qtscanner.cpp create mode 100644 src/plugins/scanner/scanner.h create mode 100644 src/plugins/scanner/scanner.pro create mode 100644 src/plugins/use_plugin.pri create mode 100644 src/shared/CMakeLists.txt create mode 100644 src/shared/bundledqt/bundledqt.qbs create mode 100644 src/shared/bundledqt/qt.conf create mode 100644 src/shared/json/CMakeLists.txt create mode 100644 src/shared/json/README.md create mode 100644 src/shared/json/json.cpp create mode 100644 src/shared/json/json.h create mode 100644 src/shared/json/json.pri create mode 100644 src/shared/json/json.qbs create mode 100644 src/shared/qtscript/.gitattributes create mode 100644 src/shared/qtscript/.gitignore create mode 100644 src/shared/qtscript/.qmake.conf create mode 100644 src/shared/qtscript/.tag create mode 100644 src/shared/qtscript/LICENSE.FDL create mode 100644 src/shared/qtscript/LICENSE.GPL2 create mode 100644 src/shared/qtscript/LICENSE.GPL3 create mode 100644 src/shared/qtscript/LICENSE.GPL3-EXCEPT create mode 100644 src/shared/qtscript/LICENSE.LGPL3 create mode 100644 src/shared/qtscript/configure.json create mode 100644 src/shared/qtscript/dependencies.yaml create mode 100644 src/shared/qtscript/dist/changes-5.0.1 create mode 100644 src/shared/qtscript/dist/changes-5.0.2 create mode 100644 src/shared/qtscript/dist/changes-5.1.0 create mode 100644 src/shared/qtscript/dist/changes-5.1.1 create mode 100644 src/shared/qtscript/dist/changes-5.10.1 create mode 100644 src/shared/qtscript/dist/changes-5.11.0 create mode 100644 src/shared/qtscript/dist/changes-5.11.1 create mode 100644 src/shared/qtscript/dist/changes-5.11.2 create mode 100644 src/shared/qtscript/dist/changes-5.11.3 create mode 100644 src/shared/qtscript/dist/changes-5.12.0 create mode 100644 src/shared/qtscript/dist/changes-5.12.1 create mode 100644 src/shared/qtscript/dist/changes-5.12.2 create mode 100644 src/shared/qtscript/dist/changes-5.12.3 create mode 100644 src/shared/qtscript/dist/changes-5.12.4 create mode 100644 src/shared/qtscript/dist/changes-5.12.5 create mode 100644 src/shared/qtscript/dist/changes-5.13.0 create mode 100644 src/shared/qtscript/dist/changes-5.13.1 create mode 100644 src/shared/qtscript/dist/changes-5.13.2 create mode 100644 src/shared/qtscript/dist/changes-5.14.0 create mode 100644 src/shared/qtscript/dist/changes-5.14.1 create mode 100644 src/shared/qtscript/dist/changes-5.9.4 create mode 100644 src/shared/qtscript/dist/changes-5.9.5 create mode 100644 src/shared/qtscript/dist/changes-5.9.6 create mode 100644 src/shared/qtscript/examples/examples.pro create mode 100644 src/shared/qtscript/examples/script/README create mode 100644 src/shared/qtscript/examples/script/calculator/calculator.js create mode 100644 src/shared/qtscript/examples/script/calculator/calculator.pro create mode 100644 src/shared/qtscript/examples/script/calculator/calculator.qrc create mode 100644 src/shared/qtscript/examples/script/calculator/calculator.ui create mode 100644 src/shared/qtscript/examples/script/calculator/main.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/context2d.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/context2d.h create mode 100644 src/shared/qtscript/examples/script/context2d/context2d.pro create mode 100644 src/shared/qtscript/examples/script/context2d/context2d.qrc create mode 100644 src/shared/qtscript/examples/script/context2d/doc/images/context2d-example-smileysmile.png create mode 100644 src/shared/qtscript/examples/script/context2d/doc/images/context2d-example.png create mode 100644 src/shared/qtscript/examples/script/context2d/doc/src/context2d.qdoc create mode 100644 src/shared/qtscript/examples/script/context2d/domimage.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/domimage.h create mode 100644 src/shared/qtscript/examples/script/context2d/environment.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/environment.h create mode 100644 src/shared/qtscript/examples/script/context2d/main.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.h create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/alpha.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/arc.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/bezier.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/clock.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/fill1.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/grad.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/linecap.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/linestye.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/moveto.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/moveto2.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/pacman.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/plasma.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/pong.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/quad.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/rgba.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/rotate.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/scale.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/stroke1.js create mode 100644 src/shared/qtscript/examples/script/context2d/scripts/translate.js create mode 100644 src/shared/qtscript/examples/script/context2d/window.cpp create mode 100644 src/shared/qtscript/examples/script/context2d/window.h create mode 100644 src/shared/qtscript/examples/script/customclass/bytearrayclass.cpp create mode 100644 src/shared/qtscript/examples/script/customclass/bytearrayclass.h create mode 100644 src/shared/qtscript/examples/script/customclass/bytearrayclass.pri create mode 100644 src/shared/qtscript/examples/script/customclass/bytearrayprototype.cpp create mode 100644 src/shared/qtscript/examples/script/customclass/bytearrayprototype.h create mode 100644 src/shared/qtscript/examples/script/customclass/customclass.pro create mode 100644 src/shared/qtscript/examples/script/customclass/main.cpp create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/code.js create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.pro create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.qrc create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/doc/images/defaultprototypes-example.png create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/doc/src/defaultprototypes.qdoc create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/main.cpp create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/prototypes.cpp create mode 100644 src/shared/qtscript/examples/script/defaultprototypes/prototypes.h create mode 100644 src/shared/qtscript/examples/script/helloscript/doc/src/helloscript.qdoc create mode 100644 src/shared/qtscript/examples/script/helloscript/helloscript.js create mode 100644 src/shared/qtscript/examples/script/helloscript/helloscript.pro create mode 100644 src/shared/qtscript/examples/script/helloscript/helloscript.qrc create mode 100644 src/shared/qtscript/examples/script/helloscript/main.cpp create mode 100644 src/shared/qtscript/examples/script/marshal/main.cpp create mode 100644 src/shared/qtscript/examples/script/marshal/marshal.pro create mode 100644 src/shared/qtscript/examples/script/qscript/main.cpp create mode 100644 src/shared/qtscript/examples/script/qscript/qscript.pro create mode 100644 src/shared/qtscript/examples/script/qsdbg/example.js create mode 100644 src/shared/qtscript/examples/script/qsdbg/main.cpp create mode 100644 src/shared/qtscript/examples/script/qsdbg/qsdbg.pri create mode 100644 src/shared/qtscript/examples/script/qsdbg/qsdbg.pro create mode 100644 src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.cpp create mode 100644 src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.h create mode 100644 src/shared/qtscript/examples/script/qsdbg/scriptdebugger.cpp create mode 100644 src/shared/qtscript/examples/script/qsdbg/scriptdebugger.h create mode 100644 src/shared/qtscript/examples/script/qstetrix/main.cpp create mode 100644 src/shared/qtscript/examples/script/qstetrix/qstetrix.pro create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrix.qrc create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixboard.cpp create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixboard.h create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixboard.js create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixpiece.js create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixwindow.js create mode 100644 src/shared/qtscript/examples/script/qstetrix/tetrixwindow.ui create mode 100644 src/shared/qtscript/examples/script/script.pro create mode 100644 src/shared/qtscript/qtscript.pro create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APICast.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APIShims.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObjectFunctions.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRefPrivate.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScript.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScriptCore.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/WebKitAvailability.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/AUTHORS create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/COPYING.LIB create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog-2002-12-03 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog-2003-10-25 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog-2007-10-14 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog-2008-08-10 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog-2009-06-16 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/DerivedSources.make create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/APICast.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSBase.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSContextRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSObjectRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSRetainPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSStringRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSStringRefCF.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JSValueRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JavaScript.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/JavaScriptCore.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/OpaqueJSString.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ForwardingHeaders/JavaScriptCore/WebKitAvailability.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/Info.plist create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.gypi create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.order create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCorePrefix.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/THANKS create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/ARMAssembler.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/ARMAssembler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/ARMv7Assembler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/AbstractMacroAssembler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/AssemblerBuffer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/AssemblerBufferWithConstantPool.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/CodeLocation.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/LinkBuffer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssembler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerARM.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerARM.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerARMv7.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerCodeRef.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerX86.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerX86Common.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/MacroAssemblerX86_64.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/RepatchBuffer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/assembler/X86Assembler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/CodeBlock.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/CodeBlock.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/EvalCodeCache.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/Instruction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/JumpTable.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/JumpTable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/Opcode.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/Opcode.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/SamplingTool.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/SamplingTool.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/StructureStubInfo.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecode/StructureStubInfo.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/BytecodeGenerator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/Label.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/LabelScope.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/NodesCodegen.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/RegisterID.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/config.h create mode 100755 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/create_hash_table create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/Debugger.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/Debugger.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/DebuggerActivation.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/DebuggerActivation.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/DebuggerCallFrame.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/debugger/DebuggerCallFrame.h create mode 100755 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/docs/make-bytecode-docs.pl create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/ArrayPrototype.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/DatePrototype.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/GeneratedJITStubs_RVCT.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/Grammar.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/Grammar.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/JSONObject.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/Lexer.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/MathObject.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/NumberConstructor.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/RegExpConstructor.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/RegExpObject.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/StringPrototype.lut.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/generated/chartables.c create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/headers.pri create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/CachedCall.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/CallFrame.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/CallFrame.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/CallFrameClosure.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Register.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/RegisterFile.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocator.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocatorPosix.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocatorSymbian.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/ExecutableAllocatorWin.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JIT.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JIT.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITArithmetic.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITCall.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITCode.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITInlineMethods.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITOpcodes.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITPropertyAccess.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubCall.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jit/JITStubs.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/jsc.cpp create mode 100755 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/make-generated-sources.sh create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/os-win32/WinMain.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/os-win32/stdbool.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Grammar.y create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Keywords.table create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Lexer.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Lexer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/NodeConstructors.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/NodeInfo.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Nodes.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Parser.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/Parser.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/ParserArena.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/ParserArena.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/ResultType.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/SourceCode.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/parser/SourceProvider.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/AUTHORS create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/COPYING create mode 100755 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/dftables create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre.pri create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_compile.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_exec.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_internal.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_tables.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_ucp_searchfuncs.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_xclass.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/ucpinternal.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/pcre/ucptable.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/CallIdentifier.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/Profile.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/Profile.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfileGenerator.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfileGenerator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfileNode.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfileNode.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/Profiler.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/Profiler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfilerServer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/profiler/ProfilerServer.mm create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArgList.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Arguments.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Arguments.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ArrayPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BatchedTransitionOptimizer.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/BooleanPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CallData.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CallData.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ClassInfo.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CollectorHeapIterator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CommonIdentifiers.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/CommonIdentifiers.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Completion.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Completion.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ConstructData.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ConstructData.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateConversion.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateConversion.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateInstance.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateInstance.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DateInstanceCache.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DatePrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/DatePrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Error.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Error.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorInstance.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorInstance.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ErrorPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ExceptionHelpers.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ExceptionHelpers.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Executable.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Executable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/FunctionConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/FunctionConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/FunctionPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/FunctionPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/GetterSetter.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/GetterSetter.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/GlobalEvalFunction.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/GlobalEvalFunction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Identifier.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Identifier.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/InitializeThreading.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/InitializeThreading.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/InternalFunction.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/InternalFunction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSAPIValueWrapper.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSAPIValueWrapper.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSActivation.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSActivation.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSArray.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSByteArray.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSByteArray.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSCell.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSCell.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalData.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalData.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObjectFunctions.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSImmediate.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSImmediate.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSLock.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSLock.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNotAnObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNotAnObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSNumberCell.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSONObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSONObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSPropertyNameIterator.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSPropertyNameIterator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSString.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSString.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSType.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSTypeInfo.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSValue.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSVariableObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSVariableObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSWrapperObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSWrapperObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSZombie.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSZombie.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/LiteralParser.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/LiteralParser.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Lookup.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Lookup.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStack.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStack.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStackNone.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStackPosix.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStackSymbian.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MarkStackWin.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MathObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/MathObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NativeErrorConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NativeErrorConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NativeErrorPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NativeErrorPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NativeFunctionWrapper.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumberPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumericStrings.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ObjectConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ObjectConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ObjectPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ObjectPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Operations.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Operations.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyDescriptor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyDescriptor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyMapHashTable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyNameArray.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertyNameArray.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertySlot.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PropertySlot.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Protect.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PrototypeFunction.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PrototypeFunction.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PutPropertySlot.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExp.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExp.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpMatchesArray.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/RegExpPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ScopeChain.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ScopeChain.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ScopeChainMark.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/SmallStrings.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/SmallStrings.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringBuilder.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringObject.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringObject.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringPrototype.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StringPrototype.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Structure.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureChain.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureChain.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/StructureTransitionTable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/SymbolTable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/TimeoutChecker.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/TimeoutChecker.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/Tracing.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UString.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UString.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UStringImpl.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/WeakGCMap.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/WeakGCPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/runtime/WeakRandom.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/CharacterClass.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/CharacterClass.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/CharacterClassConstructor.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/CharacterClassConstructor.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/Escapes.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/Quantifier.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WREC.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WREC.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECFunctors.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECFunctors.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECGenerator.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECGenerator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECParser.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wrec/WRECParser.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wscript create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ASCIICType.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/AVLTree.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ByteArray.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ByteArray.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/CONTRIBUTORS.pthreads-win32 create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/CrossThreadRefCounted.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/CurrentTime.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/CurrentTime.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DateMath.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Deque.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/DisallowCType.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastAllocBase.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Forward.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/GetPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashCountedSet.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashFunctions.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashIterators.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashMap.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashSet.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashTraits.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ListHashSet.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ListRefPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Locker.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MainThread.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MainThread.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MallocZoneSupport.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MathExtras.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/MessageQueue.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Noncopyable.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/NotFound.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnArrayPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnFastMallocPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtrCommon.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/OwnPtrWin.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/PassOwnPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/PassRefPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/PossiblyNull.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/PtrAndFlags.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RandomNumber.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RandomNumber.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RandomNumberSeed.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefCounted.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefCountedLeakCounter.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefCountedLeakCounter.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RefPtrHashMap.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/RetainPtr.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/SegmentedVector.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StdLibExtras.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringExtras.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/StringHashFunctions.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCPackedCache.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCPageMap.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSpinLock.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSystemAlloc.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSystemAlloc.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadIdentifierDataPthreads.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecific.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadSpecificWin.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Threading.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadingNone.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadingPthreads.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/ThreadingWin.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/UnusedParam.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/VMTags.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/VectorTraits.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/android/AndroidThreading.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/android/MainThreadAndroid.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/dtoa.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/qt/MainThreadQt.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/qt/ThreadingQt.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/BlockAllocatorSymbian.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/RegisterFileAllocatorSymbian.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/symbian/SymbianDefines.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/Collator.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/CollatorDefault.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/UTF8.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/UTF8.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/Unicode.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/glib/UnicodeGLib.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/glib/UnicodeMacrosFromICU.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/icu/CollatorICU.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/icu/UnicodeIcu.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/qt4/UnicodeQt4.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/wince/UnicodeWince.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/unicode/wince/UnicodeWince.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/wince/FastMallocWince.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/wince/MemoryManager.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/wince/MemoryManager.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/wtf/wince/mt19937ar.c create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexCompiler.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexCompiler.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexInterpreter.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexInterpreter.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.cpp create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexJIT.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexParser.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/yarr/RegexPattern.h create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/VERSION.TXT create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/WebKit.pri create mode 100644 src/shared/qtscript/src/3rdparty/javascriptcore/qt_attribution.json create mode 100644 src/shared/qtscript/src/plugins/script/qtdbus/main.cpp create mode 100644 src/shared/qtscript/src/plugins/script/qtdbus/main.h create mode 100644 src/shared/qtscript/src/plugins/script/qtdbus/qtdbus.pro create mode 100644 src/shared/qtscript/src/plugins/script/qtdbus/qtdbusscriptplugin.json create mode 100644 src/shared/qtscript/src/plugins/script/script.pro create mode 100644 src/shared/qtscript/src/script/api/api.pri create mode 100644 src/shared/qtscript/src/script/api/qscriptable.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptable.h create mode 100644 src/shared/qtscript/src/script/api/qscriptable_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptclass.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptclass.h create mode 100644 src/shared/qtscript/src/script/api/qscriptclasspropertyiterator.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptclasspropertyiterator.h create mode 100644 src/shared/qtscript/src/script/api/qscriptcontext.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptcontext.h create mode 100644 src/shared/qtscript/src/script/api/qscriptcontext_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptcontextinfo.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptcontextinfo.h create mode 100644 src/shared/qtscript/src/script/api/qscriptengine.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptengine.h create mode 100644 src/shared/qtscript/src/script/api/qscriptengine_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptengineagent.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptengineagent.h create mode 100644 src/shared/qtscript/src/script/api/qscriptengineagent_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptextensioninterface.h create mode 100644 src/shared/qtscript/src/script/api/qscriptextensionplugin.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptextensionplugin.h create mode 100644 src/shared/qtscript/src/script/api/qscriptprogram.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptprogram.h create mode 100644 src/shared/qtscript/src/script/api/qscriptprogram_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptstring.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptstring.h create mode 100644 src/shared/qtscript/src/script/api/qscriptstring_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptvalue.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptvalue.h create mode 100644 src/shared/qtscript/src/script/api/qscriptvalue_p.h create mode 100644 src/shared/qtscript/src/script/api/qscriptvalueiterator.cpp create mode 100644 src/shared/qtscript/src/script/api/qscriptvalueiterator.h create mode 100644 src/shared/qtscript/src/script/api/qtscriptglobal.h create mode 100644 src/shared/qtscript/src/script/bridge/bridge.pri create mode 100644 src/shared/qtscript/src/script/bridge/qscriptactivationobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptactivationobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptclassobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptclassobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptdeclarativeclass.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptdeclarativeclass_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptdeclarativeobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptdeclarativeobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptfunction.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptfunction_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptglobalobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptglobalobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptqobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptqobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptstaticscopeobject.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptstaticscopeobject_p.h create mode 100644 src/shared/qtscript/src/script/bridge/qscriptvariant.cpp create mode 100644 src/shared/qtscript/src/script/bridge/qscriptvariant_p.h create mode 100644 src/shared/qtscript/src/script/configure.json create mode 100644 src/shared/qtscript/src/script/doc/images/qtscript-debugger.png create mode 100644 src/shared/qtscript/src/script/doc/qtscript.qdocconf create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_examples_hellotr.qdoc create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_qtscript.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_qtscript.js create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_qtscript.pro create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_qtscript.qdoc create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/doc_src_qtscriptextensions.js create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptable.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptclass.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptcontext.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptengine.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptengineagent.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptvalue.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/code/src_script_qscriptvalueiterator.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/qtscript/evaluation/main.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/qtscript/registeringobjects/main.cpp create mode 100644 src/shared/qtscript/src/script/doc/snippets/qtscript/registeringvalues/main.cpp create mode 100644 src/shared/qtscript/src/script/doc/src/ecmascript.qdoc create mode 100644 src/shared/qtscript/src/script/doc/src/external-resources.qdoc create mode 100644 src/shared/qtscript/src/script/doc/src/includes/deprecation.qdocinc create mode 100644 src/shared/qtscript/src/script/doc/src/qtscript-index.qdoc create mode 100644 src/shared/qtscript/src/script/doc/src/qtscript-module.qdoc create mode 100644 src/shared/qtscript/src/script/doc/src/qtscriptdebugger-manual.qdoc create mode 100644 src/shared/qtscript/src/script/doc/src/qtscriptextensions.qdoc create mode 100755 src/shared/qtscript/src/script/parser/make-parser.sh create mode 100644 src/shared/qtscript/src/script/parser/parser.pri create mode 100644 src/shared/qtscript/src/script/parser/qscript.g create mode 100644 src/shared/qtscript/src/script/parser/qscriptast.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptast_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptastfwd_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptastvisitor.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptastvisitor_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptgrammar.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptgrammar_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptlexer.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptlexer_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptparser.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptparser_p.h create mode 100644 src/shared/qtscript/src/script/parser/qscriptsyntaxchecker.cpp create mode 100644 src/shared/qtscript/src/script/parser/qscriptsyntaxchecker_p.h create mode 100644 src/shared/qtscript/src/script/script.pri create mode 100644 src/shared/qtscript/src/script/script.pro create mode 100644 src/shared/qtscript/src/scripttools/debugging/debugging.pri create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/breakpoint.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/breakpoint.svg create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/d_breakpoint.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/d_breakpoint.svg create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/d_interrupt.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/d_play.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/delete.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/find.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/interrupt.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/location.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/location.svg create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/mac/closetab.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/mac/next.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/mac/plus.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/mac/previous.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/new.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/play.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/reload.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/return.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/runtocursor.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/runtonewscript.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/stepinto.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/stepout.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/stepover.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/win/closetab.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/win/next.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/win/plus.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/win/previous.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/images/wrap.png create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointdata.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointdata_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointsmodel.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointsmodel_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointswidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointswidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointswidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointswidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptbreakpointswidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletionproviderinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletiontask.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletiontask_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletiontaskinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletiontaskinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptcompletiontaskinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugger.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugger_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggeragent.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggeragent_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggeragent_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerbackend.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerbackend_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerbackend_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodefinderwidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodefinderwidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodefinderwidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodefinderwidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodefinderwidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodeview.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodeview_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodeviewinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodeviewinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodeviewinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodewidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodewidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodewidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodewidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercodewidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommand.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommand_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandexecutor_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerfrontend.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerfrontend_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerjob.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerjob_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggercommandschedulerjob_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsole.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsole_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommand.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommand_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommand_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandgroupdata_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandjob.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandjob_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandjob_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolecommandmanager_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsoleglobalobject_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolehistorianinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolewidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolewidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolewidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolewidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerconsolewidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerevent.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerevent_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggereventhandlerinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerfrontend.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerfrontend_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerfrontend_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerjob.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerjob_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerjob_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerjobschedulerinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalsmodel.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalsmodel_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalswidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalswidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalswidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalswidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerlocalswidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerobjectsnapshotdelta_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerresponse.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerresponse_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerresponsehandlerinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptsmodel.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptsmodel_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptswidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptswidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptswidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptswidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerscriptswidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackmodel.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackmodel_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackwidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackwidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackwidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackwidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstackwidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstandardwidgetfactory.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerstandardwidgetfactory_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggervalue.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggervalue_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggervalueproperty.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggervalueproperty_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebuggerwidgetfactoryinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugoutputwidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugoutputwidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugoutputwidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugoutputwidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptdebugoutputwidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptedit.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptedit_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptenginedebugger.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptenginedebugger.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptenginedebuggerfrontend.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptenginedebuggerfrontend_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripterrorlogwidget.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripterrorlogwidget_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripterrorlogwidgetinterface.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripterrorlogwidgetinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripterrorlogwidgetinterface_p_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptmessagehandlerinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptobjectsnapshot.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptobjectsnapshot_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptscriptdata.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptscriptdata_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptstdmessagehandler.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptstdmessagehandler_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptsyntaxhighlighter.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptsyntaxhighlighter_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscripttooltipproviderinterface_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptvalueproperty.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptvalueproperty_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptxmlparser.cpp create mode 100644 src/shared/qtscript/src/scripttools/debugging/qscriptxmlparser_p.h create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/advance.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/backtrace.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/break.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/clear.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/complete.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/condition.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/continue.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/delete.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/disable.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/down.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/enable.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/eval.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/finish.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/frame.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/help.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/ignore.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/info.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/interrupt.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/list.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/next.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/print.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/return.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/step.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/tbreak.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripts/commands/up.qs create mode 100644 src/shared/qtscript/src/scripttools/debugging/scripttools_debugging.qrc create mode 100644 src/shared/qtscript/src/scripttools/doc/qtscripttools.qdocconf create mode 100644 src/shared/qtscript/src/scripttools/doc/snippets/doc_src_qtscripttools.cpp create mode 100644 src/shared/qtscript/src/scripttools/doc/snippets/doc_src_qtscripttools.pro create mode 100644 src/shared/qtscript/src/scripttools/doc/snippets/scriptdebugger.cpp create mode 100644 src/shared/qtscript/src/scripttools/doc/snippets/src.scripttools.qscriptenginedebugger.cpp create mode 100644 src/shared/qtscript/src/scripttools/doc/src/qtscripttools-index.qdoc create mode 100644 src/shared/qtscript/src/scripttools/doc/src/qtscripttools-module.qdoc create mode 100644 src/shared/qtscript/src/scripttools/scripttools.pro create mode 100644 src/shared/qtscript/src/src.pro create mode 100644 src/shared/qtscript/sync.profile create mode 100644 src/shared/qtscript/tests/README create mode 100644 src/shared/qtscript/tests/auto/auto.pro create mode 100644 src/shared/qtscript/tests/auto/bic/.gitignore create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.0.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.1.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.10.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.11.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.13.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.14.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.2.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.3.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.4.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.6.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.7.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScript.5.8.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.0.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.1.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.10.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.11.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.13.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.14.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.2.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.3.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.4.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.6.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.7.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/bic/data/QtScriptTools.5.8.0.linux-gcc-amd64.txt create mode 100644 src/shared/qtscript/tests/auto/cmake/CMakeLists.txt create mode 100644 src/shared/qtscript/tests/auto/cmake/cmake.pro create mode 100644 src/shared/qtscript/tests/auto/guiapplauncher/README.txt create mode 100644 src/shared/qtscript/tests/auto/guiapplauncher/examples.txt create mode 100644 src/shared/qtscript/tests/auto/host.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptable/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptable/qscriptable.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptable/tst_qscriptable.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptclass/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptclass/qscriptclass.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptclass/tst_qscriptclass.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptcontext/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptcontext/qscriptcontext.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptcontext/tst_qscriptcontext.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptcontextinfo/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptcontextinfo/qscriptcontextinfo.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptcontextinfo/tst_qscriptcontextinfo.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/idtranslatable-unicode.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/idtranslatable.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/qscriptengine.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/qscriptengine.qrc create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/script/com/__init__.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/script/com/trolltech/__init__.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/script/com/trolltech/recursive/__init__.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/script/com/trolltech/syntaxerror/__init__.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translatable-unicode.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translatable.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translatable2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/idtranslatable-unicode.qm create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/idtranslatable-unicode.ts create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/idtranslatable_la.qm create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/idtranslatable_la.ts create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/translatable-unicode.qm create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/translatable-unicode.ts create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/translatable_la.qm create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/translations/translatable_la.ts create mode 100644 src/shared/qtscript/tests/auto/qscriptengine/tst_qscriptengine.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptengineagent/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptengineagent/qscriptengineagent.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptenginedebugger/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptenginedebugger/qscriptenginedebugger.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptenginedebugger/tst_qscriptenginedebugger.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/qscriptextensionplugin.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.json create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/simpleplugin/simpleplugin.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/staticplugin/__init__.js create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.json create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/staticplugin/staticplugin.qrc create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/test/test.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptextensionplugin/tst_qscriptextensionplugin.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptextqobject/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptextqobject/qscriptextqobject.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/BLACKLIST create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/expect_fail.txt create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/qscriptjstestsuite.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/qscriptjstestsuite.qrc create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/skip.txt create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.1.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.1.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.2.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.3.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.5-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.5.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.5.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.5.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/15.4.5.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Array/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.3.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.3.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.2-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.3-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.3-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/15.6.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Boolean/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.1.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.1.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.1.13-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.2.2-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.1-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.2-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.8-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.8-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.8-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.8-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.3.8-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.4.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-13.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.10-9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.11-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.12-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.13-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.14.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.15.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.16.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.17.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.18.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.19.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.20.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.21-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.22-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-13.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-14.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-15.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-16.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-17.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-18.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.23-9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.24-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.25-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.26-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.27-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.28-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.29-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.3-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.30-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.31-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.32-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.33-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.34-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.35-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.36-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.37-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.37-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.37-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.37-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.37-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.4-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/15.9.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Date/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.4-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.5-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.5-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.8-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.1.8-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.2.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.2.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.2.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.2.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/10.2.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ExecutionContexts/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.10-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.10-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.10-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.12-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.12-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.12-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.12-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.2-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.13.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.14-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.1-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.1-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.1-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-10-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-6-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-7-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-8-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.2-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.3-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.3-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.3-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.2.3-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.3.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.3.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.7-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.4.9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.5.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.5.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.5.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.6.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.6.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.6.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.6.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.6.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.7.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.7.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.7.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.8.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.8.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.8.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.8.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.9.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.9.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/11.9.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Expressions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.1.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.1.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.1.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.2.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.2.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.3.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.3.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.5.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/15.3.5.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/FunctionObjects/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.1.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.5-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/15.1.2.7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/GlobalObject/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.2-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-13-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.3-9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.1-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.1-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.1-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-10-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-11-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-12-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-13-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-14-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-15-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-16-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-6-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-7-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-8-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.2-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-10-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-11-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-12-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-13-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-14-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-15-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-16-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-6-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-7-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-8-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.4.3-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-10-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-4-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-8-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.5-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.7.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/7.8.2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/LexicalConventions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.6-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.7-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.7-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.8-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.8-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.8-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.13.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.14.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.15.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.16.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.17.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.18.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/15.8.2.9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Math/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/NativeObjects/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/NativeObjects/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.3-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.3-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.4-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.4-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.5-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.5-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.6-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.6-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.6-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.2-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/15.7.4.3-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Number/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.1.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.2.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.2.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/15.2.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/ObjectObjects/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/README create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/SourceText/6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/SourceText/6-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/SourceText/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/SourceText/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.10-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-8.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.2-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-10.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-19.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-6-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-7-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-8-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.6.3-9-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.7-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.8-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/12.9-1-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Statements/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.10-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.11-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.12-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.12-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.12-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.12-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.12-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.2-2-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.2-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.3-3-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.4-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.4-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.5-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.5-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.5-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.6-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.7-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.7-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.8-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.8-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.8-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.9-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/15.5.5.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/String/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.5-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.8.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/9.9-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/TypeConversion/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Types/8.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Types/8.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Types/8.6.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Types/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/Types/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/10.1.4-9.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/10.1.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/10.1.8-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/11.6.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/11.6.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/11.6.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/11.6.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.1.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.2.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.2.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.2.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.3.1.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.3.1.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.3.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.3.2.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.3.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.5.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.5.4.2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.5.4.4-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.5.4.5-6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.5.4.7-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.6.3.1-5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.6.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.6.4-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.7.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.7.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.8-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/15.9.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/8.6.2.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/9.9-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/extensions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/jsref.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma/template.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/boolean-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/boolean-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/date-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/date-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/date-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/date-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-008.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-009.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-010-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/exception-011-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-008.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-009.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-010.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-011.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-012.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-013.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-014.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-015.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-016.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-017.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/expression-019.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/function-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/global-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/global-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-008.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-009.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-010.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-011.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-012.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-013.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-014.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-015.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-016.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-017.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-018.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-019.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-020.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-021.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-022.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-023.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-024.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-025.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-026.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-027.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-028.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-029.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-030.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-031.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-032.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-033.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-034.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-035.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-036.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-037.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-038.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-039.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-040.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-041.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-042.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-047.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-048.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-049.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-050.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-051.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-052.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-053.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/lexical-054.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/number-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/number-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/number-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-008.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/statement-009.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/string-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Exceptions/string-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Expressions/StrictEquality-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Expressions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Expressions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/FunctionObjects/apply-001-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/FunctionObjects/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/FunctionObjects/call-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/FunctionObjects/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/LexicalConventions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/LexicalConventions/keywords-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/LexicalConventions/regexp-literals-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/LexicalConventions/regexp-literals-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/LexicalConventions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/README create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/constructor-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/exec-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/exec-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/function-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/hex-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/multiline-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/octal-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/octal-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/octal-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/properties-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/properties-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/regexp-enumerate-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/regress-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/RegExp/unicode-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/dowhile-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/forin-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/forin-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/if-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/label-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/label-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/switch-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/switch-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/switch-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/switch-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-007.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-008.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-009.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-010.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/try-012.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/while-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/while-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/while-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/Statements/while-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/match-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/match-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/match-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/match-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/replace-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/split-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/split-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/String/split-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/constructor-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/function-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-003-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-004-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-005-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/instanceof-006.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/extensions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/instanceof-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/instanceof-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/instanceof-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/regress-7635.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/instanceof/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/jsref.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_2/template.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/15.4.4.11-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/15.4.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/15.4.4.4-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/15.4.5.1-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-101488.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-130451.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-322135-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-322135-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-322135-03.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-322135-04.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-387501.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-421325.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/regress-430717.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Array/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.1.2-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.3.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.4.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.5-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.5.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.6.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/15.9.5.7.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Date/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/15.11.1.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/15.11.4.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/15.11.7.6-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/15.11.7.6-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/15.11.7.6-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/binding-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/regress-181654.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/regress-181914.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/regress-58946.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/regress-95101.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Exceptions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/10.1.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/10.1.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/10.1.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/10.1.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/10.6.1-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/regress-23346.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/regress-448595-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/ExecutionContexts/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.10-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.10-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.10-03.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.6.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.7.1-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.7.2-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.7.3-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/11.9.6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Expressions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/FunExpr/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/FunExpr/fe-001-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/FunExpr/fe-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/FunExpr/fe-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/FunExpr/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/15.3.4.3-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/15.3.4.4-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/arguments-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/arguments-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/call-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-131964.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-137181.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-193555.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-313570.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-49286.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-58274.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-85880.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-94506.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/regress-97921.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/scope-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/scope-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Function/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/LexicalConventions/7.9.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/LexicalConventions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/LexicalConventions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.2-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.3-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.3-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.5-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.6-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.7-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/15.7.4.7-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/regress-442242-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Number/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/NumberFormatting/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/NumberFormatting/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/NumberFormatting/tostring-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/8.6.1-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/8.6.2.6-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/class-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/class-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/class-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/class-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/class-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/regress-361274.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/regress-385393-07.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/regress-72773.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/regress-79129-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Object/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/11.13.1-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/11.13.1-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/11.4.1-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/11.4.1-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/order-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Operators/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/README create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.2.12.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.3.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.3.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.4.1-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.4.1-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.4.1-3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.4.1-4.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.4.1-5-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.6.2-1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/15.10.6.2-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/octal-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/octal-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/perlstress-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/perlstress-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-100199.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-105972.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-119909.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-122076.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-123437.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-165353.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-169497.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-169534.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-187133.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-188206.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-191479.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-202564.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-209067.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-209919.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-216591.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-220367-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-223273.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-223535.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-224676.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-225289.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-225343.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-24712.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-285219.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-28686.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-289669.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-307456.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-309840.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-311414.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-312351.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-31316.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-330684.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-334158.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-346090.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-367888.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375642.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375711.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375715-01-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375715-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375715-03.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-375715-04.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-57572.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-57631.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-67773.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-72964.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-76683.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-78156.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-85721.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-87231.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/regress-98306.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/RegExp/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/regress-385393-04.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/regress-419152.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/regress-420087.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/regress-420610.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/regress-441477-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Regress/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/12.6.3.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-121744.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-131348.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-157509.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-194364.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-226517.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-302439.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-324650.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-74474-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-74474-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-74474-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-83532-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/regress-83532-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Statements/switch-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/15.5.4.11.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/15.5.4.14.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-104375.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-189898.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-304376.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-313567.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-392378.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/regress-83293.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/String/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/regress-352044-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/regress-352044-02-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-001-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-001.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-002-n.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-003.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-004.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/Unicode/uc-005.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/10.1.3-2.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/7.9.1.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/browser.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-103087.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-188206-01.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-188206-02.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-220367-002.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-228087.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-274152.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-320854.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-327170.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-368516.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-385393-03.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-429248.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/regress-430740.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/extensions/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/ecma_3/template.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tests/shell.js create mode 100644 src/shared/qtscript/tests/auto/qscriptjstestsuite/tst_qscriptjstestsuite.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptqwidgets/qscriptqwidgets.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptqwidgets/tst_qscriptqwidgets.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptstring/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptstring/qscriptstring.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptstring/tst_qscriptstring.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/abstracttestsuite.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/abstracttestsuite.h create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/abstracttestsuite.pri create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/expect_fail.txt create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/qscriptv8testsuite.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/qscriptv8testsuite.qrc create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/skip.txt create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/apply.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/arguments-call-apply.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/arguments-enum.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/arguments-indirect.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/arguments-opt.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/arguments.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-concat.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-functions-prototype.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-indexing.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-iteration.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-join.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-length.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-sort.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-splice-webkit.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array-splice.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/array_length.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/ascii-regexp-subject.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/binary-operation-overwrite.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/body-not-visible.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/call-non-function-call.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/call-non-function.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/call.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/char-escape.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/class-of-builtins.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/closure.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/compare-nan.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/const-redecl.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/const.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/cyclic-array-to-string.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/date-parse.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/date.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/declare-locally.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/deep-recursion.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delay-syntax-error.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delete-global-properties.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delete-in-eval.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delete-in-with.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delete-vars-from-eval.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/delete.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/do-not-strip-fc.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/dont-enum-array-holes.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/dont-reinit-global-var.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/double-equals.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/dtoa.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/enumeration_order.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/escape.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/eval-typeof-non-existing.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/execScript-case-insensitive.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/extra-arguments.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/extra-commas.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/for-in-null-or-undefined.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/for-in-special-cases.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/for-in.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/fun-as-prototype.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/fun_name.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function-arguments-null.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function-caller.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function-property.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function-prototype.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function-source.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/function.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/fuzz-accessors.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/getter-in-value-prototype.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/global-const-var-conflicts.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/global-vars-eval.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/global-vars-with.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/has-own-property.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/html-comments.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/html-string-funcs.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/if-in-undefined.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/in.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/instanceof.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/integer-to-string.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/invalid-lhs.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/keyed-ic.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/large-object-literal.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/lazy-load.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/length.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/math-min-max.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/megamorphic-callbacks.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/mjsunit.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/mul-exhaustive.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/negate-zero.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/negate.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/nested-repetition-count-overflow.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/new.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/newline-in-string.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/no-branch-elimination.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/no-octal-constants-above-256.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/no-semicolon.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/non-ascii-replace.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/nul-characters.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/number-limits.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/number-tostring.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/obj-construct.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/parse-int-float.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/property-object-key.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/proto.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/prototype.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/regexp-multiline-stack-trace.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/regexp-multiline.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/regexp-standalones.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/regexp-static.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/regexp.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/scanner.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/smi-negative-zero.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/smi-ops.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/sparse-array-reverse.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/sparse-array.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/str-to-num.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/stress-array-push.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/strict-equals.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-case.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-charat.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-charcodeat.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-flatten.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-index.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-indexof.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-lastindexof.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-localecompare.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-search.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/string-split.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/substr.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/this-in-callbacks.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/this.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/throw-exception-for-null-access.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/to-precision.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/tobool.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/toint32.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/touint32.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/try-finally-nested.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/try.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/try_catch_scopes.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/unicode-string-to-number.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/unicode-test.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/unusual-constructor.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/uri.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/value-callic-prototype-change.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/var.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/with-leave.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/with-parameter-access.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tests/with-value.js create mode 100644 src/shared/qtscript/tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvalue/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptvalue/qscriptvalue.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptvalue/tst_qscriptvalue.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvalue/tst_qscriptvalue.h create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/qscriptvaluegenerated.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue.h create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_cast.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_comparison.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_init.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_isXXX.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvaluegenerated/tst_qscriptvalue_generated_toXXX.cpp create mode 100644 src/shared/qtscript/tests/auto/qscriptvalueiterator/.gitignore create mode 100644 src/shared/qtscript/tests/auto/qscriptvalueiterator/qscriptvalueiterator.pro create mode 100644 src/shared/qtscript/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp create mode 100644 src/shared/qtscript/tests/auto/shared/util.h create mode 100644 src/shared/qtscript/tests/auto/shared/util.pri create mode 100644 src/shared/qtscript/tests/benchmarks/script/context2d/context2d.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/context2d/tst_context2d.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass/qscriptclass.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass/tst_qscriptclass.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/qscriptclass_bytearray.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/qscriptclass_bytearray.qrc create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/construct-copy.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/construct.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/for-in.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/get-element.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/get-length.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/mid.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/set-element.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/set-length.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/sum.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tests/trimmed.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptclass_bytearray/tst_qscriptclass_bytearray.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptengine/qscriptengine.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptengine/tst_qscriptengine.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptqobject/qscriptqobject.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptqobject/tst_qscriptqobject.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptvalue/qscriptvalue.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptvalue/tst_qscriptvalue.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptvalueiterator/qscriptvalueiterator.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/qscriptvalueiterator/tst_qscriptvalueiterator.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/script.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/sunspider.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/sunspider.qrc create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/3d-cube.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/3d-morph.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/3d-raytrace.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/LICENSE.txt create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/VERSION create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/access-binary-trees.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/access-fannkuch.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/access-nbody.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/access-nsieve.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/bitops-3bit-bits-in-byte.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/bitops-bits-in-byte.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/bitops-bitwise-and.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/bitops-nsieve-bits.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/controlflow-recursive.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/crypto-aes.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/crypto-md5.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/crypto-sha1.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/date-format-tofte.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/date-format-xparb.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/math-cordic.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/math-partial-sums.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/math-spectral-norm.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/qt_attribution.json create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/regexp-dna.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/string-base64.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/string-fasta.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/string-tagcloud.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/string-unpack-code.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tests/string-validate-input.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/sunspider/tst_sunspider.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/LICENSE.txt create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/README.txt create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/base.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/crypto.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/deltablue.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/earley-boyer.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/qt_attribution.json create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/raytrace.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/regexp.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/richards.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tests/splay.js create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/tst_v8.cpp create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/v8.pro create mode 100644 src/shared/qtscript/tests/benchmarks/script/v8/v8.qrc create mode 100644 src/shared/qtscript/tests/global/.gitignore create mode 100644 src/shared/qtscript/tests/global/global.cfg create mode 100644 src/shared/qtscript/tests/tests.pro create mode 100755 src/shared/qtscript/util/mkdist-javascriptcore create mode 100644 src/shared/variant/CMakeLists.txt create mode 100644 src/shared/variant/LICENSE.md create mode 100644 src/shared/variant/README.md create mode 100644 src/shared/variant/variant.h create mode 100644 src/shared/variant/variant.hpp create mode 100644 src/shared/variant/variant.pri create mode 100644 src/shared/variant/variant.qbs create mode 100644 src/src.qbs create mode 100644 static-res.pro create mode 100644 static.pro create mode 100644 tests/CMakeLists.txt create mode 100644 tests/auto/CMakeLists.txt create mode 100644 tests/auto/api/CMakeLists.txt create mode 100644 tests/auto/api/api.pro create mode 100644 tests/auto/api/api.qbs create mode 100644 tests/auto/api/testdata/QBS-728/QBS-728.qbs create mode 100644 tests/auto/api/testdata/add-qobject-macro-to-cpp-file/add-qobject-macro-to-cpp-file.qbs create mode 100644 tests/auto/api/testdata/add-qobject-macro-to-cpp-file/main.cpp create mode 100644 tests/auto/api/testdata/add-qobject-macro-to-cpp-file/object.cpp create mode 100644 tests/auto/api/testdata/add-qobject-macro-to-cpp-file/object.h create mode 100644 tests/auto/api/testdata/added-file-persistent/added-file-persistent.qbs create mode 100644 tests/auto/api/testdata/added-file-persistent/file.cpp create mode 100644 tests/auto/api/testdata/added-file-persistent/main.cpp create mode 100644 tests/auto/api/testdata/app-without-sources/a.c create mode 100644 tests/auto/api/testdata/app-without-sources/app-without-sources.qbs create mode 100644 tests/auto/api/testdata/app-without-sources/b.c create mode 100644 tests/auto/api/testdata/base-properties/imports/Bar.qbs create mode 100644 tests/auto/api/testdata/base-properties/imports/Foo.qbs create mode 100644 tests/auto/api/testdata/base-properties/main.cpp create mode 100644 tests/auto/api/testdata/base-properties/prj.qbs create mode 100644 tests/auto/api/testdata/build-error-code-location/build-error-code-location.qbs create mode 100644 tests/auto/api/testdata/build-properties-source/build-properties-source.qbs create mode 100644 tests/auto/api/testdata/build-properties-source/main.cpp create mode 100644 tests/auto/api/testdata/build-single-file/build-single-file.qbs create mode 100644 tests/auto/api/testdata/build-single-file/compiled.cpp create mode 100644 tests/auto/api/testdata/build-single-file/ignored1.cpp create mode 100644 tests/auto/api/testdata/build-single-file/ignored2.cpp create mode 100644 tests/auto/api/testdata/build-single-file/pch.h create mode 100644 tests/auto/api/testdata/buildgraph-info/buildgraph-info.qbs create mode 100644 tests/auto/api/testdata/buildgraph-locking/buildgraph-locking.qbs create mode 100644 tests/auto/api/testdata/change-dependent-lib/change-dependent-lib.qbs create mode 100644 tests/auto/api/testdata/change-dependent-lib/main.cpp create mode 100644 tests/auto/api/testdata/change-dependent-lib/mylib.cpp create mode 100644 tests/auto/api/testdata/check-outputs/check-outputs.qbs create mode 100644 tests/auto/api/testdata/check-outputs/foo.txt create mode 100644 tests/auto/api/testdata/codegen/codegen.qbs create mode 100644 tests/auto/api/testdata/codegen/foo.txt create mode 100644 tests/auto/api/testdata/command-extraction/command-extraction.qbs create mode 100644 tests/auto/api/testdata/command-extraction/main.cpp create mode 100644 tests/auto/api/testdata/dependency-on-multiplexed-type/dependency-on-multiplexed-type.qbs create mode 100644 tests/auto/api/testdata/disabled-product/disabled-product.qbs create mode 100644 tests/auto/api/testdata/disabled-product/main.cpp create mode 100644 tests/auto/api/testdata/disabled-project/disabled-project.qbs create mode 100644 tests/auto/api/testdata/disabled_install_group/disabled_install_group.qbs create mode 100644 tests/auto/api/testdata/disabled_install_group/main.cpp create mode 100644 tests/auto/api/testdata/disappeared-wildcard-file/disappeared-wildcard-file.qbs create mode 100644 tests/auto/api/testdata/disappeared-wildcard-file/file1.txt create mode 100644 tests/auto/api/testdata/disappeared-wildcard-file/file2.txt create mode 100644 tests/auto/api/testdata/duplicate-product-names/explicit.qbs create mode 100644 tests/auto/api/testdata/duplicate-product-names/implicit-indirect.qbs create mode 100644 tests/auto/api/testdata/duplicate-product-names/implicit.qbs create mode 100644 tests/auto/api/testdata/duplicate-product-names/subdir1/subproject.qbs create mode 100644 tests/auto/api/testdata/duplicate-product-names/subdir2/subproject.qbs create mode 100644 tests/auto/api/testdata/empty-filetag-list/dontcompilethis.cpp create mode 100644 tests/auto/api/testdata/empty-filetag-list/empty-filetag-list.qbs create mode 100644 tests/auto/api/testdata/empty-submodules-list/empty-submodules-list.qbs create mode 100644 tests/auto/api/testdata/enable-and-disable-product/enable-and-disable-product.qbs create mode 100644 tests/auto/api/testdata/enable-and-disable-product/main.cpp create mode 100644 tests/auto/api/testdata/error-in-setup-run-environment/error-in-setup-run-environment.qbs create mode 100644 tests/auto/api/testdata/error-in-setup-run-environment/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs create mode 100644 tests/auto/api/testdata/explicitly-depends-on/a.in create mode 100644 tests/auto/api/testdata/explicitly-depends-on/b.in create mode 100644 tests/auto/api/testdata/explicitly-depends-on/c.in create mode 100644 tests/auto/api/testdata/explicitly-depends-on/compiler.cpp create mode 100644 tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs create mode 100644 tests/auto/api/testdata/export-item-with-group/export-item-with-group.qbs create mode 100644 tests/auto/api/testdata/export-item-with-group/main.cpp create mode 100644 tests/auto/api/testdata/export-simple/export-simple.qbs create mode 100644 tests/auto/api/testdata/export-simple/lib1.cpp create mode 100644 tests/auto/api/testdata/export-simple/main.cpp create mode 100644 tests/auto/api/testdata/export-with-recursive-depends/export-with-recursive-depends.qbs create mode 100644 tests/auto/api/testdata/export-with-recursive-depends/main1.cpp create mode 100644 tests/auto/api/testdata/export-with-recursive-depends/main2.cpp create mode 100644 tests/auto/api/testdata/export-with-recursive-depends/modules/module1/module1.qbs create mode 100644 tests/auto/api/testdata/export-with-recursive-depends/modules/module2/module2.qbs create mode 100644 tests/auto/api/testdata/fallback-gcc/fallback-gcc.qbs create mode 100644 tests/auto/api/testdata/file-tagger/bla.txt create mode 100644 tests/auto/api/testdata/file-tagger/moc_cpp.qbs create mode 100644 tests/auto/api/testdata/filetagsfilter_override/InstalledApp.qbs create mode 100644 tests/auto/api/testdata/filetagsfilter_override/filetagsfilter_override.qbs create mode 100644 tests/auto/api/testdata/filetagsfilter_override/main.cpp create mode 100644 tests/auto/api/testdata/generated-files-list/generated-files-list.qbs create mode 100644 tests/auto/api/testdata/generated-files-list/main.cpp create mode 100644 tests/auto/api/testdata/generated-files-list/mainwindow.cpp create mode 100644 tests/auto/api/testdata/generated-files-list/mainwindow.h create mode 100644 tests/auto/api/testdata/generated-files-list/mainwindow.ui create mode 100644 tests/auto/api/testdata/infinite-loop-js/infinite-loop.qbs create mode 100644 tests/auto/api/testdata/infinite-loop-process/infinite-loop.qbs create mode 100644 tests/auto/api/testdata/infinite-loop-process/main.cpp create mode 100644 tests/auto/api/testdata/infinite-loop-resolving/infinite-loop-resolving.qbs create mode 100644 tests/auto/api/testdata/inherit-qbs-search-paths/imports/Foo.qbs create mode 100644 tests/auto/api/testdata/inherit-qbs-search-paths/main.cpp create mode 100644 tests/auto/api/testdata/inherit-qbs-search-paths/prj.qbs create mode 100644 tests/auto/api/testdata/inherit-qbs-search-paths/subdir/modules/bli/m.qbs create mode 100644 tests/auto/api/testdata/inherit-qbs-search-paths/subdir2/modules/bla/m.qbs create mode 100644 tests/auto/api/testdata/installed-artifact/installed-artifact.qbs create mode 100644 tests/auto/api/testdata/installed-artifact/main.cpp create mode 100644 tests/auto/api/testdata/is-runnable/is-runnable.qbs create mode 100644 tests/auto/api/testdata/lib-same-source/lib-same-source.qbs create mode 100644 tests/auto/api/testdata/lib-same-source/main.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/dynamic1.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/dynamic2.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/link-dynamiclibs-staticlibs.qbs create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/main.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/static1.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/static2.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs-staticlibs/static2.h create mode 100644 tests/auto/api/testdata/link-dynamiclibs/lib1.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs/lib2.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs/lib3.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs/lib4.cpp create mode 100644 tests/auto/api/testdata/link-dynamiclibs/lib4.h create mode 100644 tests/auto/api/testdata/link-dynamiclibs/link-dynamiclibs.qbs create mode 100644 tests/auto/api/testdata/link-dynamiclibs/main.cpp create mode 100644 tests/auto/api/testdata/link-static-lib/helper1/helper1.cpp create mode 100644 tests/auto/api/testdata/link-static-lib/helper1/helper1.h create mode 100644 tests/auto/api/testdata/link-static-lib/helper2/helper2.cpp create mode 100644 tests/auto/api/testdata/link-static-lib/helper2/helper2.h create mode 100644 tests/auto/api/testdata/link-static-lib/link-static-lib.qbs create mode 100644 tests/auto/api/testdata/link-static-lib/main.cpp create mode 100644 tests/auto/api/testdata/link-static-lib/mystaticlib.cpp create mode 100644 tests/auto/api/testdata/link-static-lib/mystaticlibhelper.cpp create mode 100644 tests/auto/api/testdata/link-staticlib-dynamiclib/link-staticlib-dynamiclib.qbs create mode 100644 tests/auto/api/testdata/link-staticlib-dynamiclib/main.cpp create mode 100644 tests/auto/api/testdata/link-staticlib-dynamiclib/mydynamiclib.cpp create mode 100644 tests/auto/api/testdata/link-staticlib-dynamiclib/mystaticlib.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/dynamic1.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/dynamic2.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/link-staticlibs-dynamiclibs.qbs create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/main.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/static1.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/static2.cpp create mode 100644 tests/auto/api/testdata/link-staticlibs-dynamiclibs/static2.h create mode 100644 tests/auto/api/testdata/local-profiles/local-profiles.qbs create mode 100644 tests/auto/api/testdata/lots-of-dots/dotty.matrix.ui create mode 100644 tests/auto/api/testdata/lots-of-dots/lots-of-dots.qbs create mode 100644 tests/auto/api/testdata/lots-of-dots/m.a.i.n.cpp create mode 100644 tests/auto/api/testdata/lots-of-dots/object.narf.cpp create mode 100644 tests/auto/api/testdata/lots-of-dots/object.narf.h create mode 100644 tests/auto/api/testdata/lots-of-dots/polka.dots.qrc create mode 100644 tests/auto/api/testdata/missing-qobject-header/main.cpp create mode 100644 tests/auto/api/testdata/missing-qobject-header/myobject.cpp create mode 100644 tests/auto/api/testdata/missing-qobject-header/myobject.h create mode 100644 tests/auto/api/testdata/missing-source-file/file1.txt create mode 100644 tests/auto/api/testdata/missing-source-file/file2.txt.missing create mode 100644 tests/auto/api/testdata/missing-source-file/file3.txt create mode 100644 tests/auto/api/testdata/missing-source-file/missing-source-file.qbs create mode 100644 tests/auto/api/testdata/moc-cpp/bla.cpp create mode 100644 tests/auto/api/testdata/moc-cpp/moc-cpp.qbs create mode 100644 tests/auto/api/testdata/moc-hpp-included/moc-hpp-included.qbs create mode 100644 tests/auto/api/testdata/moc-hpp-included/object.cpp create mode 100644 tests/auto/api/testdata/moc-hpp-included/object.h create mode 100644 tests/auto/api/testdata/moc-hpp-included/object2.h create mode 100644 tests/auto/api/testdata/moc-hpp-included/object2.mm create mode 100644 tests/auto/api/testdata/moc-hpp/moc-hpp.qbs create mode 100644 tests/auto/api/testdata/moc-hpp/object.cpp create mode 100644 tests/auto/api/testdata/moc-hpp/object.h create mode 100644 tests/auto/api/testdata/multi-arch/host+target.input create mode 100644 tests/auto/api/testdata/multi-arch/host-tool.input create mode 100644 tests/auto/api/testdata/multi-arch/multi-arch.qbs create mode 100644 tests/auto/api/testdata/multiplexing/multiplexing.qbs create mode 100644 tests/auto/api/testdata/new-output-artifact-in-dependency/lib.cpp create mode 100644 tests/auto/api/testdata/new-output-artifact-in-dependency/main.cpp create mode 100644 tests/auto/api/testdata/new-output-artifact-in-dependency/new-output-artifact-in-dependency.qbs create mode 100644 tests/auto/api/testdata/new-pattern-match/new-pattern-match.qbs create mode 100644 tests/auto/api/testdata/nonexistingprojectproperties/invalidaccessfromproduct.qbs create mode 100644 tests/auto/api/testdata/nonexistingprojectproperties/nonexistingprojectproperties.qbs create mode 100644 tests/auto/api/testdata/objc/main.mm create mode 100644 tests/auto/api/testdata/objc/objc.qbs create mode 100644 tests/auto/api/testdata/precompiled-header-dynamic/autogen.h.in create mode 100644 tests/auto/api/testdata/precompiled-header-dynamic/main.cpp create mode 100644 tests/auto/api/testdata/precompiled-header-dynamic/pch.h create mode 100644 tests/auto/api/testdata/precompiled-header-dynamic/precompiled-header-dynamic.qbs create mode 100644 tests/auto/api/testdata/precompiled-header-new/main.cpp create mode 100644 tests/auto/api/testdata/precompiled-header-new/myobject.cpp create mode 100644 tests/auto/api/testdata/precompiled-header-new/myobject.h create mode 100644 tests/auto/api/testdata/precompiled-header-new/precompiled-header-new.qbs create mode 100644 tests/auto/api/testdata/precompiled-header-new/stable.h create mode 100644 tests/auto/api/testdata/process-result/main.cpp create mode 100644 tests/auto/api/testdata/process-result/process-result.qbs create mode 100644 tests/auto/api/testdata/productNameWithDots/app.cpp create mode 100644 tests/auto/api/testdata/productNameWithDots/lib.cpp create mode 100644 tests/auto/api/testdata/productNameWithDots/productNameWithDots.qbs create mode 100644 tests/auto/api/testdata/project-data-after-product-invalidation/file.cpp create mode 100644 tests/auto/api/testdata/project-data-after-product-invalidation/main.cpp create mode 100644 tests/auto/api/testdata/project-data-after-product-invalidation/project-data-after-product-invalidation.qbs create mode 100644 tests/auto/api/testdata/project-editing/existingfile1.txt create mode 100644 tests/auto/api/testdata/project-editing/existingfile2.txt create mode 100644 tests/auto/api/testdata/project-editing/existingfile3.txt create mode 100644 tests/auto/api/testdata/project-editing/file.cpp create mode 100644 tests/auto/api/testdata/project-editing/file.h create mode 100644 tests/auto/api/testdata/project-editing/main.cpp create mode 100644 tests/auto/api/testdata/project-editing/newfile1.txt create mode 100644 tests/auto/api/testdata/project-editing/newfile2.txt create mode 100644 tests/auto/api/testdata/project-editing/newfile3.txt create mode 100644 tests/auto/api/testdata/project-editing/newfile4.txt create mode 100644 tests/auto/api/testdata/project-editing/project-editing.qbs create mode 100644 tests/auto/api/testdata/project-editing/project-with-no-files.qbs create mode 100644 tests/auto/api/testdata/project-editing/subdir/file.txt create mode 100644 tests/auto/api/testdata/project-editing/test.wildcard create mode 100644 tests/auto/api/testdata/project-invalidation/project.early-error.qbs create mode 100644 tests/auto/api/testdata/project-invalidation/project.late-error.qbs create mode 100644 tests/auto/api/testdata/project-invalidation/project.no-error.qbs create mode 100644 tests/auto/api/testdata/project-locking/project-locking.qbs create mode 100644 tests/auto/api/testdata/project-properties-by-name/main1.cpp create mode 100644 tests/auto/api/testdata/project-properties-by-name/main2.cpp create mode 100644 tests/auto/api/testdata/project-properties-by-name/project-properties-by-name.qbs create mode 100644 tests/auto/api/testdata/project-with-probe-and-profile-item/project-with-probe-and-profile-item.qbs create mode 100644 tests/auto/api/testdata/project-with-properties-item/project-with-properties-item.qbs create mode 100644 tests/auto/api/testdata/projectd create mode 100644 tests/auto/api/testdata/properties-blocks/main.cpp create mode 100644 tests/auto/api/testdata/properties-blocks/properties-blocks.qbs create mode 100644 tests/auto/api/testdata/qt5-plugin/echointerface.h create mode 100644 tests/auto/api/testdata/qt5-plugin/echoplugin.cpp create mode 100644 tests/auto/api/testdata/qt5-plugin/echoplugin.h create mode 100644 tests/auto/api/testdata/qt5-plugin/echoplugin.json.source create mode 100644 tests/auto/api/testdata/qt5-plugin/echoplugin_dummy.cpp create mode 100644 tests/auto/api/testdata/qt5-plugin/qt5-plugin.qbs create mode 100644 tests/auto/api/testdata/rc/main.cpp create mode 100644 tests/auto/api/testdata/rc/rc.qbs create mode 100644 tests/auto/api/testdata/rc/subdir/rc-include.h create mode 100644 tests/auto/api/testdata/rc/test.rc create mode 100644 tests/auto/api/testdata/recursive-wildcards/dir/file1.txt create mode 100644 tests/auto/api/testdata/recursive-wildcards/dir/subdir/file2.txt create mode 100644 tests/auto/api/testdata/recursive-wildcards/recursive-wildcards.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/ambiguousdir/p1.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/ambiguousdir/p2.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/cycle.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/emptydir/.gitignore create mode 100644 tests/auto/api/testdata/referenced-file-errors/modules/brokenmodule/brokenmodule.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/okay.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/okay2.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/referenced-file-errors.qbs create mode 100644 tests/auto/api/testdata/referenced-file-errors/wrongtype.qbs create mode 100644 tests/auto/api/testdata/references/invalid1.qbs create mode 100644 tests/auto/api/testdata/references/invalid2.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-no-project/test.txt create mode 100644 tests/auto/api/testdata/references/subdir-with-one-project/p.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-one-project/test.txt create mode 100644 tests/auto/api/testdata/references/valid.qbs create mode 100644 tests/auto/api/testdata/relaxed-mode-recovery/relaxed-mode-recovery.qbs create mode 100644 tests/auto/api/testdata/remove-file-dependency/main.cpp create mode 100644 tests/auto/api/testdata/remove-file-dependency/removeFileDependency.qbs create mode 100644 tests/auto/api/testdata/remove-file-dependency/someheader.h create mode 100644 tests/auto/api/testdata/rename-product/lib.cpp create mode 100644 tests/auto/api/testdata/rename-product/main.cpp create mode 100644 tests/auto/api/testdata/rename-product/rename.qbs create mode 100644 tests/auto/api/testdata/rename-target-artifact/lib.cpp create mode 100644 tests/auto/api/testdata/rename-target-artifact/main.cpp create mode 100644 tests/auto/api/testdata/rename-target-artifact/rename.qbs create mode 100644 tests/auto/api/testdata/renamed-qbs-source-file/renamed-qbs-source-file.qbs create mode 100644 tests/auto/api/testdata/renamed-qbs-source-file/the-product/the-prodduct.qbs create mode 100644 tests/auto/api/testdata/restored-warnings/file.cpp create mode 100644 tests/auto/api/testdata/restored-warnings/main.cpp create mode 100644 tests/auto/api/testdata/restored-warnings/restored-warnings.qbs create mode 100644 tests/auto/api/testdata/rule-conflict/main.cpp create mode 100644 tests/auto/api/testdata/rule-conflict/pch1.h create mode 100644 tests/auto/api/testdata/rule-conflict/pch2.h create mode 100644 tests/auto/api/testdata/rule-conflict/rule-conflict.qbs create mode 100644 tests/auto/api/testdata/run-disabled-product/run-disabled-product.qbs create mode 100644 tests/auto/api/testdata/same-base-name/lib.c create mode 100644 tests/auto/api/testdata/same-base-name/lib.cpp create mode 100644 tests/auto/api/testdata/same-base-name/lib.m create mode 100644 tests/auto/api/testdata/same-base-name/lib.mm create mode 100644 tests/auto/api/testdata/same-base-name/main.c create mode 100644 tests/auto/api/testdata/same-base-name/same-base-name.qbs create mode 100644 tests/auto/api/testdata/simple-probe/main.cpp create mode 100644 tests/auto/api/testdata/simple-probe/simple-probe.qbs create mode 100644 tests/auto/api/testdata/soft-dependency/main.cpp create mode 100644 tests/auto/api/testdata/soft-dependency/soft-dependency.qbs create mode 100644 tests/auto/api/testdata/source-file-in-build-dir/file.cpp create mode 100644 tests/auto/api/testdata/source-file-in-build-dir/source-file-in-build-dir.qbs create mode 100644 tests/auto/api/testdata/static-lib-deps/a1.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/a2.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/b.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/c.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/d.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/d.mm create mode 100644 tests/auto/api/testdata/static-lib-deps/e.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/main.cpp create mode 100644 tests/auto/api/testdata/static-lib-deps/static-lib-deps.qbs create mode 100644 tests/auto/api/testdata/subprojects/resources/imports/LibraryType/type.js create mode 100644 tests/auto/api/testdata/subprojects/resources/modules/QtCoreDepender/qtcoredepender.qbs create mode 100644 tests/auto/api/testdata/subprojects/resources/modules/cute/core/core.qbs create mode 100644 tests/auto/api/testdata/subprojects/resources/modules/cute/core/cuteglobal.h create mode 100644 tests/auto/api/testdata/subprojects/subproject1/main.cpp create mode 100644 tests/auto/api/testdata/subprojects/subproject2/subproject2.qbs create mode 100644 tests/auto/api/testdata/subprojects/subproject2/subproject3/subproject3.qbs create mode 100644 tests/auto/api/testdata/subprojects/subproject2/subproject3/testlib.cpp create mode 100644 tests/auto/api/testdata/subprojects/toplevelproject.qbs create mode 100644 tests/auto/api/testdata/target-artifact-status/target-artifact-status.qbs create mode 100644 tests/auto/api/testdata/timeout-js/timeout.qbs create mode 100644 tests/auto/api/testdata/timeout-process/main.cpp create mode 100644 tests/auto/api/testdata/timeout-process/timeout.qbs create mode 100644 tests/auto/api/testdata/tool-in-module/use-outside-project/modules/thetool/thetool.qbs create mode 100644 tests/auto/api/testdata/tool-in-module/use-outside-project/use-outside-project.qbs create mode 100644 tests/auto/api/testdata/tool-in-module/use-within-project/main.cpp create mode 100644 tests/auto/api/testdata/tool-in-module/use-within-project/tool-input.txt create mode 100644 tests/auto/api/testdata/tool-in-module/use-within-project/use-within-project.qbs create mode 100644 tests/auto/api/testdata/transformer-data/transformer-data.qbs create mode 100644 tests/auto/api/testdata/transformers/main.cpp create mode 100644 tests/auto/api/testdata/transformers/transformers.qbs create mode 100644 tests/auto/api/testdata/two-default-property-values/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/api/testdata/two-default-property-values/modules/myothermodule/myothermodule.qbs create mode 100644 tests/auto/api/testdata/two-default-property-values/test.txt create mode 100644 tests/auto/api/testdata/two-default-property-values/two-default-property-values.qbs create mode 100644 tests/auto/api/testdata/type-change/main.cpp create mode 100644 tests/auto/api/testdata/type-change/type-change.qbs create mode 100644 tests/auto/api/testdata/uic/bla.cpp create mode 100644 tests/auto/api/testdata/uic/bla.h create mode 100644 tests/auto/api/testdata/uic/ui.h create mode 100644 tests/auto/api/testdata/uic/ui.ui create mode 100644 tests/auto/api/testdata/uic/uic.qbs create mode 100644 tests/auto/api/tst_api.cpp create mode 100644 tests/auto/api/tst_api.h create mode 100644 tests/auto/auto.pri create mode 100644 tests/auto/auto.pro create mode 100644 tests/auto/auto.qbs create mode 100644 tests/auto/blackbox/CMakeLists.txt create mode 100644 tests/auto/blackbox/blackbox-android.pro create mode 100644 tests/auto/blackbox/blackbox-android.qbs create mode 100644 tests/auto/blackbox/blackbox-apple.pro create mode 100644 tests/auto/blackbox/blackbox-apple.qbs create mode 100644 tests/auto/blackbox/blackbox-baremetal.pro create mode 100644 tests/auto/blackbox/blackbox-baremetal.qbs create mode 100644 tests/auto/blackbox/blackbox-clangdb.pro create mode 100644 tests/auto/blackbox/blackbox-clangdb.qbs create mode 100644 tests/auto/blackbox/blackbox-examples.pro create mode 100644 tests/auto/blackbox/blackbox-examples.qbs create mode 100644 tests/auto/blackbox/blackbox-java.pro create mode 100644 tests/auto/blackbox/blackbox-java.qbs create mode 100644 tests/auto/blackbox/blackbox-joblimits.pro create mode 100644 tests/auto/blackbox/blackbox-joblimits.qbs create mode 100644 tests/auto/blackbox/blackbox-qt.pro create mode 100644 tests/auto/blackbox/blackbox-qt.qbs create mode 100644 tests/auto/blackbox/blackbox-windows.pro create mode 100644 tests/auto/blackbox/blackbox-windows.qbs create mode 100644 tests/auto/blackbox/blackbox.pro create mode 100644 tests/auto/blackbox/blackbox.qbs create mode 100644 tests/auto/blackbox/find/find-android.qbs create mode 100644 tests/auto/blackbox/find/find-jdk.qbs create mode 100644 tests/auto/blackbox/find/find-nodejs.qbs create mode 100644 tests/auto/blackbox/find/find-typescript.qbs create mode 100644 tests/auto/blackbox/find/find-xcode.qbs create mode 100644 tests/auto/blackbox/testdata-android/aidl/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/aidl/aidl.qbs create mode 100644 tests/auto/blackbox/testdata-android/aidl/io/qbs/aidltest/Interface1.aidl create mode 100644 tests/auto/blackbox/testdata-android/aidl/io/qbs/aidltest/Interface2.aidl create mode 100644 tests/auto/blackbox/testdata-android/aidl/io/qbs/aidltest/MainActivity.java create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/libdependency.so create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/minimal-native.qbs create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/src/main/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/src/main/java/my/minimal/MinimalNative.java create mode 100644 tests/auto/blackbox/testdata-android/minimal-native/src/main/native/native.c create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/multiple-apks-per-project.qbs create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/product1.qbs create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/src/main/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/src/main/java/io/qt/dummy1/Dummy.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/src/main/jni/lib1.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/src/main/jni/lib2.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product1/src/main/res/values/strings.xml create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/product2.qbs create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/src/main/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/src/main/java/io/qt/dummy2/Dummy.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/src/main/jni/lib1.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-apks-per-project/product2/src/main/jni/lib2.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/io/qbs/lib3/lib3.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/lib4.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/lib5.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/lib6.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/lib7.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/lib8.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/multiple-libs-per-apk.qbs create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/src/main/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/src/main/java/io/qt/dummy/Dummy.java create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/src/main/jni/lib1.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/src/main/jni/lib2.cpp create mode 100644 tests/auto/blackbox/testdata-android/multiple-libs-per-apk/src/main/res/values/strings.xml create mode 100644 tests/auto/blackbox/testdata-android/no-native/no-native.qbs create mode 100644 tests/auto/blackbox/testdata-android/qml-app/main.cpp create mode 100644 tests/auto/blackbox/testdata-android/qml-app/main.qml create mode 100644 tests/auto/blackbox/testdata-android/qml-app/qml-app.qbs create mode 100644 tests/auto/blackbox/testdata-android/qml-app/qml.qrc create mode 100644 tests/auto/blackbox/testdata-android/qml-app/src/main/AndroidManifest.xml create mode 100644 tests/auto/blackbox/testdata-android/qml-app/src/main/assets/dummyasset.txt create mode 100644 tests/auto/blackbox/testdata-android/qt-app/MainWindow.cpp create mode 100644 tests/auto/blackbox/testdata-android/qt-app/MainWindow.h create mode 100644 tests/auto/blackbox/testdata-android/qt-app/Test.java create mode 100644 tests/auto/blackbox/testdata-android/qt-app/TestQt6.java create mode 100644 tests/auto/blackbox/testdata-android/qt-app/main.cpp create mode 100644 tests/auto/blackbox/testdata-android/qt-app/qt-app.qbs create mode 100644 tests/auto/blackbox/testdata-android/qt-app/test.keystore create mode 100644 tests/auto/blackbox/testdata-android/teapot/teapot.qbs create mode 100644 tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/aggregateDependencyLinking.qbs create mode 100644 tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/app.c create mode 100644 tests/auto/blackbox/testdata-apple/aggregateDependencyLinking/lib.c create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/apple-dmg.qbs create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/de_DE.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/en_GB.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/en_US.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/fr_FR.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/hello.icns create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/hello.tif create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/ja_JP.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/ko_KR.lproj/eula.rtf create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/main.c create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/ru_RU.lproj/eula.txt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/white.iconset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/white.iconset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/zh_CN.lproj/eula.odt create mode 100644 tests/auto/blackbox/testdata-apple/apple-dmg/zh_TW.lproj/eula.docx create mode 100644 tests/auto/blackbox/testdata-apple/apple-multiconfig/app.c create mode 100644 tests/auto/blackbox/testdata-apple/apple-multiconfig/apple-multiconfig.qbs create mode 100644 tests/auto/blackbox/testdata-apple/apple-multiconfig/lib.c create mode 100644 tests/auto/blackbox/testdata-apple/bundle-structure/bundle-structure.qbs create mode 100644 tests/auto/blackbox/testdata-apple/bundle-structure/dummy.c create mode 100644 tests/auto/blackbox/testdata-apple/bundle-structure/dummy.h create mode 100644 tests/auto/blackbox/testdata-apple/bundle-structure/dummy_p.h create mode 100644 tests/auto/blackbox/testdata-apple/bundle-structure/resource.txt create mode 100644 tests/auto/blackbox/testdata-apple/codesign/app.cpp create mode 100644 tests/auto/blackbox/testdata-apple/codesign/codesign.qbs create mode 100644 tests/auto/blackbox/testdata-apple/deploymentTarget/deployment.qbs create mode 100644 tests/auto/blackbox/testdata-apple/deploymentTarget/main.c create mode 100644 tests/auto/blackbox/testdata-apple/embedInfoPlist/embedInfoPlist.qbs create mode 100644 tests/auto/blackbox/testdata-apple/embedInfoPlist/main.m create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/BaseResource create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/Widget.cpp create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/Widget.h create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/WidgetPrivate.h create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/en.lproj/EnglishResource create mode 100644 tests/auto/blackbox/testdata-apple/frameworkStructure/frameworkStructure.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/100.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/114.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/120.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/128.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/144.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/152.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/167.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/172.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/180.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/196.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/20.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/216.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/256.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/29.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/32.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/40.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/48.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/50.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/512.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/55.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/57.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/58.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/60.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/64.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/72.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/76.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/80.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/87.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/88.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/AppIconSet.xcassets/AppIcon.appiconset/Contents.json create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/appiconset.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/appiconset/main.c create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/EmptyStoryboard.storyboard create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/MainMenu.xib create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/Storyboard.storyboard create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/assetcatalogempty.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/empty.xcassets/empty.iconset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/empty.xcassets/empty.iconset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/empty.xcassets/other.imageset/Contents.json create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/empty.xcassets/other.imageset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/empty.xcassets/other.imageset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/assetcatalog/main.c create mode 100644 tests/auto/blackbox/testdata-apple/ib/empty-asset-catalogs/assetcatalog1.xcassets/.keep create mode 100644 tests/auto/blackbox/testdata-apple/ib/empty-asset-catalogs/assetcatalog2.xcassets/.keep create mode 100644 tests/auto/blackbox/testdata-apple/ib/empty-asset-catalogs/main.c create mode 100644 tests/auto/blackbox/testdata-apple/ib/empty-asset-catalogs/multiple-asset-catalogs.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconset/iconset.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconset/white.iconset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconset/white.iconset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconsetapp/iconsetapp.qbs create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconsetapp/main.c create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconsetapp/white.iconset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/iconsetapp/white.iconset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog1.xcassets/other.imageset/Contents.json create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog1.xcassets/other.imageset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog1.xcassets/other.imageset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog2.xcassets/other.imageset/Contents.json create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog2.xcassets/other.imageset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/assetcatalog2.xcassets/other.imageset/icon_16x16@2x.png create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/main.c create mode 100644 tests/auto/blackbox/testdata-apple/ib/multiple-asset-catalogs/multiple-asset-catalogs.qbs create mode 100644 tests/auto/blackbox/testdata-apple/infoPlistVariables/Info.plist create mode 100644 tests/auto/blackbox/testdata-apple/infoPlistVariables/infoPlistVariables.qbs create mode 100644 tests/auto/blackbox/testdata-apple/infoPlistVariables/main.c create mode 100644 tests/auto/blackbox/testdata-apple/infoplist/infoplist.qbs create mode 100644 tests/auto/blackbox/testdata-apple/infoplist/main.c create mode 100644 tests/auto/blackbox/testdata-apple/multiarch-helpers.js create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/arc.m create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/arc.mm create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/main.m create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/mrc.m create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/mrc.mm create mode 100644 tests/auto/blackbox/testdata-apple/objc-arc/objc-arc.qbs create mode 100644 tests/auto/blackbox/testdata-apple/overrideInfoPlist/Override-Info.plist create mode 100644 tests/auto/blackbox/testdata-apple/overrideInfoPlist/main.c create mode 100644 tests/auto/blackbox/testdata-apple/overrideInfoPlist/overrideInfoPlist.qbs create mode 100644 tests/auto/blackbox/testdata-apple/xcode/xcode-project.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/BareMetalApplication.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/BareMetalProduct.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/BareMetalStaticLibrary.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/app.c create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/compiler-defines-by-language.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/cpptest.cpp create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-defines-by-language/ctest.c create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-include-paths/compiler-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-include-paths/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-listing/compiler-listing.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-listing/fun.c create mode 100644 tests/auto/blackbox/testdata-baremetal/compiler-listing/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/cosmic.lkf create mode 100644 tests/auto/blackbox/testdata-baremetal/defines/defines.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/defines/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/distribution-include-paths/bar/bar.h create mode 100644 tests/auto/blackbox/testdata-baremetal/distribution-include-paths/distribution-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/distribution-include-paths/foo/foo.h create mode 100644 tests/auto/blackbox/testdata-baremetal/distribution-include-paths/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/external-static-libraries/external-static-libraries.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-a.c create mode 100644 tests/auto/blackbox/testdata-baremetal/external-static-libraries/lib-b.c create mode 100644 tests/auto/blackbox/testdata-baremetal/external-static-libraries/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/linker-map/linker-map.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/linker-map/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-application/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-application/one-object-application.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/78k-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/arm-cosmic.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/arm-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/arm-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/arm-keil.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/avr-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/avr-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/avr32-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/avr32-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/c166-keil.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/cr16-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/hcs12-cosmic.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/hcs12-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/hcs8-cosmic.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/hcs8-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/hcs8-sdcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m16c-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m32c-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m32c-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m32r-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m68k-cosmic.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m68k-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/m68k-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/mcs251-keil.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/mcs51-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/mcs51-keil.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/mcs51-sdcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/msp430-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/msp430-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/one-object-asm-application.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/r32c-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/rh850-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/riscv-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/riscv-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/rl78-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/rl78-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/rx-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/rx-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/sh-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/stm8-cosmic.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/stm8-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/stm8-sdcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/v850-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/v850-iar.s create mode 100644 tests/auto/blackbox/testdata-baremetal/one-object-asm-application/xtensa-gcc.s create mode 100644 tests/auto/blackbox/testdata-baremetal/preinclude-headers/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/preinclude-headers/preinclude-headers.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/preinclude-headers/preinclude.h create mode 100644 tests/auto/blackbox/testdata-baremetal/shared-libraries/app.c create mode 100644 tests/auto/blackbox/testdata-baremetal/shared-libraries/shared-libraries.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/shared-libraries/shared.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/a1.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/a2.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/app.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/b.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/c.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/d.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/e.c create mode 100644 tests/auto/blackbox/testdata-baremetal/static-library-dependencies/static-library-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/system-include-paths/bar/bar.h create mode 100644 tests/auto/blackbox/testdata-baremetal/system-include-paths/foo/foo.h create mode 100644 tests/auto/blackbox/testdata-baremetal/system-include-paths/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/system-include-paths/system-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/target-platform/target-platform.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/dmc.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/sdcc.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/toolchain-probe/probes/watcom.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/toolchain-probe/toolchain-probe.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/two-object-application/fun.c create mode 100644 tests/auto/blackbox/testdata-baremetal/two-object-application/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/two-object-application/two-object-application.qbs create mode 100644 tests/auto/blackbox/testdata-baremetal/user-include-paths/bar/bar.h create mode 100644 tests/auto/blackbox/testdata-baremetal/user-include-paths/foo/foo.h create mode 100644 tests/auto/blackbox/testdata-baremetal/user-include-paths/main.c create mode 100644 tests/auto/blackbox/testdata-baremetal/user-include-paths/user-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata-clangdb/project1/i like spaces.cpp create mode 100644 tests/auto/blackbox/testdata-clangdb/project1/project.qbs create mode 100644 tests/auto/blackbox/testdata-java/java/Car.java create mode 100644 tests/auto/blackbox/testdata-java/java/Car8.java create mode 100644 tests/auto/blackbox/testdata-java/java/HelloWorld.java create mode 100644 tests/auto/blackbox/testdata-java/java/HelloWorld8.java create mode 100644 tests/auto/blackbox/testdata-java/java/Jet.java create mode 100644 tests/auto/blackbox/testdata-java/java/Manifest.mf create mode 100644 tests/auto/blackbox/testdata-java/java/Manifest2.mf create mode 100644 tests/auto/blackbox/testdata-java/java/NoPackage.java create mode 100644 tests/auto/blackbox/testdata-java/java/RandomStuff.java create mode 100644 tests/auto/blackbox/testdata-java/java/Ship.java create mode 100644 tests/auto/blackbox/testdata-java/java/Vehicle.java create mode 100644 tests/auto/blackbox/testdata-java/java/Vehicles.java create mode 100644 tests/auto/blackbox/testdata-java/java/engine.c create mode 100644 tests/auto/blackbox/testdata-java/java/inner-class/InnerClass.java create mode 100644 tests/auto/blackbox/testdata-java/java/inner-class/inner-class.qbs create mode 100644 tests/auto/blackbox/testdata-java/java/vehicles.qbs create mode 100644 tests/auto/blackbox/testdata-joblimits/job-limits-init/job-limits-init.qbs create mode 100644 tests/auto/blackbox/testdata-joblimits/job-limits/job-limits.qbs create mode 100644 tests/auto/blackbox/testdata-joblimits/job-limits/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/add-qobject-macro-to-generated-cpp-file/add-qobject-macro-to-generated-cpp-file.qbs create mode 100644 tests/auto/blackbox/testdata-qt/add-qobject-macro-to-generated-cpp-file/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/add-qobject-macro-to-generated-cpp-file/object.cpp.in create mode 100644 tests/auto/blackbox/testdata-qt/add-qobject-macro-to-generated-cpp-file/object.h create mode 100644 tests/auto/blackbox/testdata-qt/auto-qrc/auto-qrc.qbs create mode 100644 tests/auto/blackbox/testdata-qt/auto-qrc/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/auto-qrc/qrc-base/resource1.txt create mode 100644 tests/auto/blackbox/testdata-qt/auto-qrc/qrc-base/subdir/resource2.txt create mode 100644 tests/auto/blackbox/testdata-qt/auto-qrc/qrc-base/subdir/resource3.txt create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/MainForm.ui.qml create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/cached-qml.qbs create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/main.qml create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/qml.qrc create mode 100644 tests/auto/blackbox/testdata-qt/cached-qml/stuff.js create mode 100644 tests/auto/blackbox/testdata-qt/combined-moc/combined-moc.qbs create mode 100644 tests/auto/blackbox/testdata-qt/combined-moc/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/combined-moc/theobject.h create mode 100644 tests/auto/blackbox/testdata-qt/create-project/dummy.txt create mode 100644 tests/auto/blackbox/testdata-qt/dbus-adaptors/THIS.IS.A.STRANGE.FILENAME.CAR.XML create mode 100644 tests/auto/blackbox/testdata-qt/dbus-adaptors/car.cpp create mode 100644 tests/auto/blackbox/testdata-qt/dbus-adaptors/car.h create mode 100644 tests/auto/blackbox/testdata-qt/dbus-adaptors/car.qbs create mode 100644 tests/auto/blackbox/testdata-qt/dbus-adaptors/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/car.xml create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.cpp create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.h create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.qbs create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/controller.ui create mode 100644 tests/auto/blackbox/testdata-qt/dbus-interfaces/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/forced-moc/createqtclass.h create mode 100644 tests/auto/blackbox/testdata-qt/forced-moc/forced-moc.qbs create mode 100644 tests/auto/blackbox/testdata-qt/forced-moc/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/forced-moc/myqtclass.h create mode 100644 tests/auto/blackbox/testdata-qt/included-moc-cpp/included-moc-cpp.qbs create mode 100644 tests/auto/blackbox/testdata-qt/included-moc-cpp/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/included-moc-cpp/myobject.cpp create mode 100644 tests/auto/blackbox/testdata-qt/included-moc-cpp/myobject.h create mode 100644 tests/auto/blackbox/testdata-qt/linker-variant/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/linker-variant/qt-linker-variant.qbs create mode 100644 tests/auto/blackbox/testdata-qt/lrelease/de.ts create mode 100644 tests/auto/blackbox/testdata-qt/lrelease/hu.ts create mode 100644 tests/auto/blackbox/testdata-qt/lrelease/lrelease.qbs create mode 100644 tests/auto/blackbox/testdata-qt/metatypes/metatypes.qbs create mode 100644 tests/auto/blackbox/testdata-qt/metatypes/mocableclass1.cpp create mode 100644 tests/auto/blackbox/testdata-qt/metatypes/mocableclass1.h create mode 100644 tests/auto/blackbox/testdata-qt/metatypes/mocableclass2.cpp create mode 100644 tests/auto/blackbox/testdata-qt/metatypes/unmocableclass.cpp create mode 100644 tests/auto/blackbox/testdata-qt/mixed-build-variants/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/mixed-build-variants/mixed-build-variants.qbs create mode 100644 tests/auto/blackbox/testdata-qt/moc-and-cxx-combining/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-and-cxx-combining/moc-and-cxx-combining.qbs create mode 100644 tests/auto/blackbox/testdata-qt/moc-and-cxx-combining/myobject.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-and-cxx-combining/myobject.h create mode 100644 tests/auto/blackbox/testdata-qt/moc-compiler-defines/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-compiler-defines/moc-compiler-defines.qbs create mode 100644 tests/auto/blackbox/testdata-qt/moc-compiler-defines/object.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-compiler-defines/object.h create mode 100644 tests/auto/blackbox/testdata-qt/moc-flags/blubb.h create mode 100644 tests/auto/blackbox/testdata-qt/moc-flags/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-flags/moc-flags.qbs create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/moc-same-file-name.qbs create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src1/someclass.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src1/someclass.h create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src1/somefile.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src2/someclass.cpp create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src2/someclass.h create mode 100644 tests/auto/blackbox/testdata-qt/moc-same-file-name/src2/somefile.cpp create mode 100644 tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.cpp create mode 100644 tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/lib.h create mode 100644 tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/no-relink-on-qdebug/symbols-test.qbs create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig-qt/dump-libpath.qbs create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig-qt/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig-qt/module-providers/dummyProvider.qbs create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig-qt/pkgconfig-qt.qbs create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/pkgconfig/pkgconfig.qbs create mode 100644 tests/auto/blackbox/testdata-qt/plugin-meta-data/app.cpp create mode 100644 tests/auto/blackbox/testdata-qt/plugin-meta-data/metadata.json create mode 100644 tests/auto/blackbox/testdata-qt/plugin-meta-data/plugin-meta-data.qbs create mode 100644 tests/auto/blackbox/testdata-qt/plugin-meta-data/theplugin.cpp create mode 100644 tests/auto/blackbox/testdata-qt/plugin-support/modules/m1/m1.qbs create mode 100644 tests/auto/blackbox/testdata-qt/plugin-support/modules/m2/m2.qbs create mode 100644 tests/auto/blackbox/testdata-qt/plugin-support/plugin-support-main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/plugin-support/plugin-support.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qml-debugging/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qml-debugging/qml-debugging.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qmltyperegistrar/example.qml create mode 100644 tests/auto/blackbox/testdata-qt/qmltyperegistrar/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qmltyperegistrar/person.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qmltyperegistrar/person.h create mode 100644 tests/auto/blackbox/testdata-qt/qmltyperegistrar/qmltyperegistrar.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qobject-in-mm/main.mm create mode 100644 tests/auto/blackbox/testdata-qt/qobject-in-mm/qobject-in-mm.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qrc/bla.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qrc/bla.qrc create mode 100644 tests/auto/blackbox/testdata-qt/qrc/i.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qrc/stuff.txt create mode 100644 tests/auto/blackbox/testdata-qt/qrc/subdir/dummy.txt create mode 100644 tests/auto/blackbox/testdata-qt/qrc/test.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qt-keywords/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qt-keywords/qt-keywords.qbs create mode 100644 tests/auto/blackbox/testdata-qt/qtscxml/dummystatemachine.scxml create mode 100644 tests/auto/blackbox/testdata-qt/qtscxml/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/qtscxml/qtscxml.qbs create mode 100644 tests/auto/blackbox/testdata-qt/quick-compiler/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/quick-compiler/qml.qrc create mode 100644 tests/auto/blackbox/testdata-qt/quick-compiler/qml/subdir/test.qml create mode 100644 tests/auto/blackbox/testdata-qt/quick-compiler/quick-compiler.qbs create mode 100644 tests/auto/blackbox/testdata-qt/remove-moc-header-from-file-list/file.cpp create mode 100644 tests/auto/blackbox/testdata-qt/remove-moc-header-from-file-list/file.h create mode 100644 tests/auto/blackbox/testdata-qt/remove-moc-header-from-file-list/remove-moc-header-from-file-list.qbs create mode 100644 tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/lib.cpp create mode 100644 tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/static-qt-plugin-linking/static-qt-plugin-linking.qbs create mode 100644 tests/auto/blackbox/testdata-qt/trackAddMocInclude/after/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/trackAddMocInclude/before/test.qbs create mode 100644 tests/auto/blackbox/testdata-qt/trackQObjChange/bla.cpp create mode 100644 tests/auto/blackbox/testdata-qt/trackQObjChange/bla_noqobject.h create mode 100644 tests/auto/blackbox/testdata-qt/trackQObjChange/bla_qobject.h create mode 100644 tests/auto/blackbox/testdata-qt/trackQObjChange/i.qbs create mode 100644 tests/auto/blackbox/testdata-qt/unmocable/foo.h create mode 100644 tests/auto/blackbox/testdata-qt/unmocable/main.cpp create mode 100644 tests/auto/blackbox/testdata-qt/unmocable/unmocable.qbs create mode 100644 tests/auto/blackbox/testdata-windows/codesign/app.cpp create mode 100644 tests/auto/blackbox/testdata-windows/codesign/codesign.qbs create mode 100644 tests/auto/blackbox/testdata-windows/innosetup/inc/qbsinc.iss create mode 100644 tests/auto/blackbox/testdata-windows/innosetup/innosetup.qbs create mode 100644 tests/auto/blackbox/testdata-windows/innosetup/test.iss create mode 100644 tests/auto/blackbox/testdata-windows/innosetupDependencies/innosetupDependencies.qbs create mode 100644 tests/auto/blackbox/testdata-windows/innosetupDependencies/main.c create mode 100644 tests/auto/blackbox/testdata-windows/innosetupDependencies/test.iss create mode 100644 tests/auto/blackbox/testdata-windows/wix/ExampleScript.bat create mode 100644 tests/auto/blackbox/testdata-windows/wix/QbsBootstrapper.wxs create mode 100644 tests/auto/blackbox/testdata-windows/wix/QbsSetup.wxs create mode 100644 tests/auto/blackbox/testdata-windows/wix/Qt.wxs create mode 100644 tests/auto/blackbox/testdata-windows/wix/WiXInstallers.qbs create mode 100644 tests/auto/blackbox/testdata-windows/wix/de.wxl create mode 100644 tests/auto/blackbox/testdata-windows/wixDependencies/QbsSetup.wxs create mode 100644 tests/auto/blackbox/testdata-windows/wixDependencies/main.c create mode 100644 tests/auto/blackbox/testdata-windows/wixDependencies/wixDependencies.qbs create mode 100644 tests/auto/blackbox/testdata/QTBUG-51237/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/blackbox/testdata/QTBUG-51237/qtbug-51237.qbs create mode 100644 tests/auto/blackbox/testdata/add-filetag-to-generated-artifact/add-filetag-to-generated-artifact.qbs create mode 100644 tests/auto/blackbox/testdata/add-filetag-to-generated-artifact/main.cpp create mode 100644 tests/auto/blackbox/testdata/allowed-values/allowed-values.qbs create mode 100644 tests/auto/blackbox/testdata/allowed-values/modules/a/a.qbs create mode 100644 tests/auto/blackbox/testdata/always-run/dummy.txt create mode 100644 tests/auto/blackbox/testdata/always-run/rule.qbs create mode 100644 tests/auto/blackbox/testdata/always-run/transformer.qbs create mode 100644 tests/auto/blackbox/testdata/archiver/archivable.qbs create mode 100644 tests/auto/blackbox/testdata/archiver/list.txt create mode 100644 tests/auto/blackbox/testdata/archiver/test.txt create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/artifact-scanning.qbs create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/external-indirect.h create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/external.h create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/p1.cpp create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/p2.cpp create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/p3.cpp create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/shared.h create mode 100644 tests/auto/blackbox/testdata/artifact-scanning/subdir/external2.h create mode 100644 tests/auto/blackbox/testdata/artifacts-map-change-tracking/artifacts-map-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/artifacts-map-change-tracking/dummy.in create mode 100644 tests/auto/blackbox/testdata/artifacts-map-change-tracking/main.cpp create mode 100644 tests/auto/blackbox/testdata/artifacts-map-change-tracking/test.cpp.in create mode 100644 tests/auto/blackbox/testdata/artifacts-map-change-tracking/test.txt create mode 100644 tests/auto/blackbox/testdata/artifacts-map-invalidation/artifacts-map-invalidation.qbs create mode 100644 tests/auto/blackbox/testdata/artifacts-map-invalidation/file.in create mode 100644 tests/auto/blackbox/testdata/artifacts-map-race-condition/artifacts-map-race-condition.qbs create mode 100644 tests/auto/blackbox/testdata/assembly/assembly.qbs create mode 100644 tests/auto/blackbox/testdata/assembly/testa.s create mode 100644 tests/auto/blackbox/testdata/assembly/testb.S create mode 100644 tests/auto/blackbox/testdata/assembly/testc.sx create mode 100644 tests/auto/blackbox/testdata/assembly/testd_x86.asm create mode 100644 tests/auto/blackbox/testdata/assembly/testd_x86_64.asm create mode 100644 tests/auto/blackbox/testdata/autotest-timeout/autotests-timeout.qbs create mode 100644 tests/auto/blackbox/testdata/autotest-timeout/test-main.cpp create mode 100644 tests/auto/blackbox/testdata/autotest-with-dependencies/autotest-with-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/autotest-with-dependencies/helper-main.cpp create mode 100644 tests/auto/blackbox/testdata/autotest-with-dependencies/test-main.cpp create mode 100644 tests/auto/blackbox/testdata/autotests/autotests.qbs create mode 100644 tests/auto/blackbox/testdata/autotests/test1/test1.cpp create mode 100644 tests/auto/blackbox/testdata/autotests/test1/test1.qbs create mode 100644 tests/auto/blackbox/testdata/autotests/test2/test2-resource.txt create mode 100644 tests/auto/blackbox/testdata/autotests/test2/test2.cpp create mode 100644 tests/auto/blackbox/testdata/autotests/test2/test2.qbs create mode 100644 tests/auto/blackbox/testdata/autotests/test3/test3.cpp create mode 100644 tests/auto/blackbox/testdata/autotests/test3/test3.qbs create mode 100644 tests/auto/blackbox/testdata/aux-inputs-from-deps/aux-inputs-from-deps.qbs create mode 100644 tests/auto/blackbox/testdata/aux-inputs-from-deps/main.cpp create mode 100644 tests/auto/blackbox/testdata/aux-inputs-from-deps/util.js create mode 100644 tests/auto/blackbox/testdata/badInterpreter/badInterpreter.qbs create mode 100644 tests/auto/blackbox/testdata/badInterpreter/qbs/modules/script-test/script-test.qbs create mode 100755 tests/auto/blackbox/testdata/badInterpreter/script-interp-missing create mode 100755 tests/auto/blackbox/testdata/badInterpreter/script-interp-noexec create mode 100644 tests/auto/blackbox/testdata/badInterpreter/script-noexec create mode 100755 tests/auto/blackbox/testdata/badInterpreter/script-ok create mode 100644 tests/auto/blackbox/testdata/bom-sources/bom-sources.qbs create mode 100644 tests/auto/blackbox/testdata/bom-sources/main.cpp create mode 100644 tests/auto/blackbox/testdata/bom-sources/theheader.h create mode 100644 tests/auto/blackbox/testdata/build-data-of-disabled-product/build-data-of-disabled-product.qbs create mode 100644 tests/auto/blackbox/testdata/build-data-of-disabled-product/main.cpp create mode 100644 tests/auto/blackbox/testdata/build-data-of-disabled-product/test.cpp create mode 100644 tests/auto/blackbox/testdata/build-directories/build-directories.qbs create mode 100644 tests/auto/blackbox/testdata/build-graph-versions/build-graph-versions.qbs create mode 100644 tests/auto/blackbox/testdata/build-graph-versions/main.cpp create mode 100644 tests/auto/blackbox/testdata/build-variant-defaults/build-variant-defaults.qbs create mode 100644 tests/auto/blackbox/testdata/build-variant-defaults/main.cpp create mode 100644 tests/auto/blackbox/testdata/buildenv-change/buildenv-change.qbs create mode 100644 tests/auto/blackbox/testdata/buildenv-change/file.c create mode 100644 tests/auto/blackbox/testdata/buildenv-change/main.cpp create mode 100644 tests/auto/blackbox/testdata/buildenv-change/subdir/theheader.h create mode 100644 tests/auto/blackbox/testdata/buildenv-change/subdir2/theheader.h create mode 100644 tests/auto/blackbox/testdata/capnproto/bar.capnp create mode 100644 tests/auto/blackbox/testdata/capnproto/baz.capnp create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.cpp create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_absolute_import.qbs create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_cpp.cpp create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_cpp.qbs create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_cpp_pkgconfig.qbs create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.cpp create mode 100644 tests/auto/blackbox/testdata/capnproto/capnproto_relative_import.qbs create mode 100644 tests/auto/blackbox/testdata/capnproto/foo.capnp create mode 100644 tests/auto/blackbox/testdata/capnproto/greeter-client.cpp create mode 100644 tests/auto/blackbox/testdata/capnproto/greeter-server.cpp create mode 100644 tests/auto/blackbox/testdata/capnproto/greeter.capnp create mode 100644 tests/auto/blackbox/testdata/capnproto/greeter_cpp.qbs create mode 100644 tests/auto/blackbox/testdata/capnproto/imports/foo.capnp create mode 100644 tests/auto/blackbox/testdata/change-in-disabled-product/change-in-disabled-product.qbs create mode 100644 tests/auto/blackbox/testdata/change-in-disabled-product/test1.txt create mode 100644 tests/auto/blackbox/testdata/change-in-disabled-product/test2.txt create mode 100644 tests/auto/blackbox/testdata/change-in-imported-file/change-in-imported-file.qbs create mode 100644 tests/auto/blackbox/testdata/change-in-imported-file/prepare.js create mode 100644 tests/auto/blackbox/testdata/change-in-imported-file/test.txt create mode 100644 tests/auto/blackbox/testdata/change-tracking-and-multiplexing/change-tracking-and-multiplexing.qbs create mode 100644 tests/auto/blackbox/testdata/change-tracking-and-multiplexing/lib.cpp create mode 100644 tests/auto/blackbox/testdata/changed-files/changed-files.qbs create mode 100644 tests/auto/blackbox/testdata/changed-files/file1.cpp create mode 100644 tests/auto/blackbox/testdata/changed-files/file2.cpp create mode 100644 tests/auto/blackbox/testdata/changed-files/main.cpp create mode 100644 tests/auto/blackbox/testdata/changed-inputs-from-dependencies/changed-inputs-from-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/changed-inputs-from-dependencies/input.txt create mode 100644 tests/auto/blackbox/testdata/changed-rule-inputs/changed-rule-inputs.qbs create mode 100644 tests/auto/blackbox/testdata/check-timestamps/check-timestamps.qbs create mode 100644 tests/auto/blackbox/testdata/check-timestamps/file.cpp create mode 100644 tests/auto/blackbox/testdata/check-timestamps/file.h create mode 100644 tests/auto/blackbox/testdata/check-timestamps/main.cpp create mode 100644 tests/auto/blackbox/testdata/choose-module-instance/choose-module-instance.qbs create mode 100644 tests/auto/blackbox/testdata/choose-module-instance/gerbil.txt.in create mode 100644 tests/auto/blackbox/testdata/choose-module-instance/modules/limerick/lord.qbs create mode 100644 tests/auto/blackbox/testdata/choose-module-instance/modules/limerick/ritchie.qbs create mode 100644 tests/auto/blackbox/testdata/choose-module-instance/other-searchpath/modules/limerick/generic.qbs create mode 100644 tests/auto/blackbox/testdata/clean/clean.qbs create mode 100644 tests/auto/blackbox/testdata/clean/dep.cpp create mode 100644 tests/auto/blackbox/testdata/clean/main.cpp create mode 100755 tests/auto/blackbox/testdata/cli/HelloWorld.cs create mode 100755 tests/auto/blackbox/testdata/cli/Libby.cs create mode 100755 tests/auto/blackbox/testdata/cli/Libby2.cs create mode 100644 tests/auto/blackbox/testdata/cli/Module.cs create mode 100755 tests/auto/blackbox/testdata/cli/Module.vb create mode 100644 tests/auto/blackbox/testdata/cli/dotnettest.qbs create mode 100644 tests/auto/blackbox/testdata/cli/fshello.fs create mode 100644 tests/auto/blackbox/testdata/cli/fshello.qbs create mode 100644 tests/auto/blackbox/testdata/combined-sources/combinable.cpp create mode 100644 tests/auto/blackbox/testdata/combined-sources/combined-sources.qbs create mode 100644 tests/auto/blackbox/testdata/combined-sources/main.cpp create mode 100644 tests/auto/blackbox/testdata/combined-sources/uncombinable.cpp create mode 100644 tests/auto/blackbox/testdata/command-file/command-file.qbs create mode 100644 tests/auto/blackbox/testdata/command-file/lib.cpp create mode 100644 tests/auto/blackbox/testdata/command-file/list.gcc create mode 100644 tests/auto/blackbox/testdata/command-file/list.msvc create mode 100644 tests/auto/blackbox/testdata/command-file/main.cpp create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/CppDefinesApp.qbs create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/app.c create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/compilerDefinesByLanguage.qbs create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/test.c create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/test.cpp create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/test.m create mode 100644 tests/auto/blackbox/testdata/compilerDefinesByLanguage/test.mm create mode 100644 tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile-probe-project.qbs create mode 100644 tests/auto/blackbox/testdata/conanfile-probe/testapp/conanfile.py create mode 100644 tests/auto/blackbox/testdata/conanfile-probe/testlib/conanfile.py create mode 100644 tests/auto/blackbox/testdata/concurrent-executor/concurrent-executor.qbs create mode 100644 tests/auto/blackbox/testdata/concurrent-executor/dummy1.input create mode 100644 tests/auto/blackbox/testdata/concurrent-executor/dummy2.input create mode 100644 tests/auto/blackbox/testdata/concurrent-executor/util.js create mode 100644 tests/auto/blackbox/testdata/conditional-export/conditional-export.qbs create mode 100644 tests/auto/blackbox/testdata/conditional-export/main.cpp create mode 100644 tests/auto/blackbox/testdata/conditional-filetagger/conditional-filetagger.qbs create mode 100644 tests/auto/blackbox/testdata/conditional-filetagger/main.custom create mode 100644 tests/auto/blackbox/testdata/configure/configure.qbs create mode 100644 tests/auto/blackbox/testdata/configure/main.cpp create mode 100644 tests/auto/blackbox/testdata/configure/modules/definition/module.qbs create mode 100644 tests/auto/blackbox/testdata/conflicting-artifacts/conflicting-artifacts.qbs create mode 100644 tests/auto/blackbox/testdata/conflicting-artifacts/main.cpp create mode 100644 tests/auto/blackbox/testdata/cpu-features/cpu-features.qbs create mode 100644 tests/auto/blackbox/testdata/cpu-features/main.cpp create mode 100644 tests/auto/blackbox/testdata/cxx-language-version/cxx-language-version.qbs create mode 100644 tests/auto/blackbox/testdata/cxx-language-version/main.cpp create mode 100644 tests/auto/blackbox/testdata/dependenciesProperty/dependenciesProperty.qbs create mode 100644 tests/auto/blackbox/testdata/dependenciesProperty/product2.cpp create mode 100644 tests/auto/blackbox/testdata/dependency-scanning-loop/dependency-scanning-loop.qbs create mode 100644 tests/auto/blackbox/testdata/dependency-scanning-loop/main.cpp create mode 100644 tests/auto/blackbox/testdata/deprecated-property/deprecated-property.qbs create mode 100644 tests/auto/blackbox/testdata/deprecated-property/modules/themodule/m.qbs create mode 100644 tests/auto/blackbox/testdata/disappeared-profile/disappeared-profile.qbs create mode 100644 tests/auto/blackbox/testdata/disappeared-profile/in1.txt create mode 100644 tests/auto/blackbox/testdata/disappeared-profile/in2.txt create mode 100644 tests/auto/blackbox/testdata/disappeared-profile/modules-dir/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/discard-unused-data/discard-unused-data.qbs create mode 100644 tests/auto/blackbox/testdata/discard-unused-data/main.cpp create mode 100644 tests/auto/blackbox/testdata/distribution-include-paths/distribution-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata/distribution-include-paths/main.cpp create mode 100644 tests/auto/blackbox/testdata/distribution-include-paths/subdir/gagagugu.h create mode 100644 tests/auto/blackbox/testdata/driver-linker-flags/driver-linker-flags.qbs create mode 100644 tests/auto/blackbox/testdata/driver-linker-flags/main.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/Dll.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/lib1.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/lib2.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/lib3.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/lib4.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/lib5.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/main.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/broken.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thelib/thelib.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/modules/theotherlib/theotherlib.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/modules/thethirdlib/thethirdlib.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/theapp.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-library-in-module/thelibs.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-project/dynamic-project.qbs create mode 100644 tests/auto/blackbox/testdata/dynamic-project/src/app/main.cpp create mode 100644 tests/auto/blackbox/testdata/dynamic-project/src/app2/main.cpp create mode 100644 tests/auto/blackbox/testdata/dynamicMultiplexRule/dynamicMultiplexRule.qbs create mode 100644 tests/auto/blackbox/testdata/dynamicMultiplexRule/one.txt create mode 100644 tests/auto/blackbox/testdata/dynamicMultiplexRule/three.txt create mode 100644 tests/auto/blackbox/testdata/dynamicMultiplexRule/two.txt create mode 100644 tests/auto/blackbox/testdata/dynamicRuleOutputs/after/numbers.l create mode 100644 tests/auto/blackbox/testdata/dynamicRuleOutputs/before/flexoptionsreader.js create mode 100644 tests/auto/blackbox/testdata/dynamicRuleOutputs/before/genlexer.qbs create mode 100644 tests/auto/blackbox/testdata/dynamicRuleOutputs/before/numbers.l create mode 100644 tests/auto/blackbox/testdata/empty-profile/empty-profile.qbs create mode 100644 tests/auto/blackbox/testdata/empty-profile/main.cpp create mode 100644 tests/auto/blackbox/testdata/enableExceptions/empty.m create mode 100644 tests/auto/blackbox/testdata/enableExceptions/empty.mm create mode 100644 tests/auto/blackbox/testdata/enableExceptions/emptymain.cpp create mode 100644 tests/auto/blackbox/testdata/enableExceptions/exceptions-objc.qbs create mode 100644 tests/auto/blackbox/testdata/enableExceptions/exceptions-objcpp-cpp.qbs create mode 100644 tests/auto/blackbox/testdata/enableExceptions/exceptions-objcpp.qbs create mode 100644 tests/auto/blackbox/testdata/enableExceptions/exceptions.qbs create mode 100644 tests/auto/blackbox/testdata/enableExceptions/main.cpp create mode 100644 tests/auto/blackbox/testdata/enableExceptions/main.m create mode 100644 tests/auto/blackbox/testdata/enableExceptions/none.qbs create mode 100644 tests/auto/blackbox/testdata/enableRtti/main.cpp create mode 100644 tests/auto/blackbox/testdata/enableRtti/rtti.qbs create mode 100644 tests/auto/blackbox/testdata/env-merging/env-merging.qbs create mode 100644 tests/auto/blackbox/testdata/env-merging/main.c create mode 100644 tests/auto/blackbox/testdata/env-normalization/env-normalization.qbs create mode 100644 tests/auto/blackbox/testdata/erroneous/nonexistentWorkingDir/nonexistentWorkingDir.qbs create mode 100644 tests/auto/blackbox/testdata/erroneous/outputArtifacts-missing-filePath/main.cpp create mode 100644 tests/auto/blackbox/testdata/erroneous/outputArtifacts-missing-filePath/outputArtifacts-missing-filePath.qbs create mode 100644 tests/auto/blackbox/testdata/erroneous/outputArtifacts-missing-fileTags/main.cpp create mode 100644 tests/auto/blackbox/testdata/erroneous/outputArtifacts-missing-fileTags/outputArtifacts-missing-fileTags.qbs create mode 100644 tests/auto/blackbox/testdata/erroneous/tag-mismatch/tag-mismatch.qbs create mode 100644 tests/auto/blackbox/testdata/erroneous/texttemplate-unknown-placeholder/boom.txt.in create mode 100644 tests/auto/blackbox/testdata/erroneous/texttemplate-unknown-placeholder/texttemplate-unknown-placeholder.qbs create mode 100644 tests/auto/blackbox/testdata/error-info/error-info.qbs create mode 100644 tests/auto/blackbox/testdata/error-info/helper.js create mode 100644 tests/auto/blackbox/testdata/escaped-linker-flags/escaped-linker-flags.qbs create mode 100644 tests/auto/blackbox/testdata/escaped-linker-flags/main.cpp create mode 100644 tests/auto/blackbox/testdata/explicitly-depends-on/explicitly-depends-on.qbs create mode 100644 tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module-fish.txt create mode 100644 tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module1.qbs create mode 100644 tests/auto/blackbox/testdata/explicitly-depends-on/step1.txt create mode 100644 tests/auto/blackbox/testdata/export-rule/blubber.cpp create mode 100644 tests/auto/blackbox/testdata/export-rule/export-rule.qbs create mode 100644 tests/auto/blackbox/testdata/export-rule/myapp.blubb create mode 100644 tests/auto/blackbox/testdata/export-to-outside-searchpath/export-to-outside-searchpath.qbs create mode 100644 tests/auto/blackbox/testdata/export-to-outside-searchpath/qbs-resources/modules/aModule/aModule.qbs create mode 100644 tests/auto/blackbox/testdata/exported-dependency-in-disabled-product/exported-dependency-in-disabled-product.qbs create mode 100644 tests/auto/blackbox/testdata/exported-dependency-in-disabled-product/main.cpp create mode 100644 tests/auto/blackbox/testdata/exported-dependency-in-disabled-product/modules/broken/broken.qbs create mode 100644 tests/auto/blackbox/testdata/exported-property-in-disabled-product/exported-property-in-disabled-product.qbs create mode 100644 tests/auto/blackbox/testdata/exported-property-in-disabled-product/main.cpp create mode 100644 tests/auto/blackbox/testdata/exported-property-in-disabled-product/modules/broken/broken.qbs create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib.pc create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/TheFirstLib_windows.pc create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/TheSecondLib.pc create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/boringstaticlib.cpp create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/exports-pkgconfig.qbs create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.cpp create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/firstlib.h create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper1/helper1.qbs create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper2/helper2.qbs create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/modules/helper3/helper3.qbs create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.cpp create mode 100644 tests/auto/blackbox/testdata/exports-pkgconfig/secondlib.h create mode 100644 tests/auto/blackbox/testdata/exports-qbs/consumer.cpp create mode 100644 tests/auto/blackbox/testdata/exports-qbs/consumer.qbs create mode 100644 tests/auto/blackbox/testdata/exports-qbs/exports-qbs-products.qbs create mode 100644 tests/auto/blackbox/testdata/exports-qbs/exports-qbs.qbs create mode 100644 tests/auto/blackbox/testdata/exports-qbs/helper.cpp.in create mode 100644 tests/auto/blackbox/testdata/exports-qbs/helper.js create mode 100644 tests/auto/blackbox/testdata/exports-qbs/imports/Helper2/helper2.js create mode 100644 tests/auto/blackbox/testdata/exports-qbs/lib.qbs create mode 100644 tests/auto/blackbox/testdata/exports-qbs/mylib.cpp create mode 100644 tests/auto/blackbox/testdata/exports-qbs/mylib.h create mode 100644 tests/auto/blackbox/testdata/exports-qbs/tool.cpp create mode 100644 tests/auto/blackbox/testdata/exports-qbs/tool.qbs create mode 100644 tests/auto/blackbox/testdata/external-libs/external-libs.qbs create mode 100644 tests/auto/blackbox/testdata/external-libs/lib1.cpp create mode 100644 tests/auto/blackbox/testdata/external-libs/lib2.cpp create mode 100644 tests/auto/blackbox/testdata/external-libs/main.cpp create mode 100644 tests/auto/blackbox/testdata/fallback-module-provider/fallback-module-provider.qbs create mode 100644 tests/auto/blackbox/testdata/fallback-module-provider/libdir/qbsmetatestmodule.pc create mode 100644 tests/auto/blackbox/testdata/fallback-module-provider/main.cpp create mode 100644 tests/auto/blackbox/testdata/fileDependencies/awesomelib/awesome.h create mode 100644 tests/auto/blackbox/testdata/fileDependencies/awesomelib/magnificent.h create mode 100644 tests/auto/blackbox/testdata/fileDependencies/fileDependencies.qbs create mode 100644 tests/auto/blackbox/testdata/fileDependencies/src/narf.cpp create mode 100644 tests/auto/blackbox/testdata/fileDependencies/src/narf.h create mode 100644 tests/auto/blackbox/testdata/fileDependencies/src/zort.cpp create mode 100644 tests/auto/blackbox/testdata/filetagsfilter-merging/MyApplication.qbs create mode 100644 tests/auto/blackbox/testdata/filetagsfilter-merging/filetagsfilter-merging.qbs create mode 100644 tests/auto/blackbox/testdata/filetagsfilter-merging/main.cpp create mode 100644 tests/auto/blackbox/testdata/find/find-cli.qbs create mode 100644 tests/auto/blackbox/testdata/freedesktop/freedesktop.qbs create mode 100644 tests/auto/blackbox/testdata/freedesktop/main.cpp create mode 100644 tests/auto/blackbox/testdata/freedesktop/myapp.appdata.xml create mode 100644 tests/auto/blackbox/testdata/freedesktop/myapp.desktop create mode 100644 tests/auto/blackbox/testdata/freedesktop/myapp.png create mode 100644 tests/auto/blackbox/testdata/generate-linker-map-file/generate-linker-map-file.qbs create mode 100644 tests/auto/blackbox/testdata/generate-linker-map-file/main.cpp create mode 100644 tests/auto/blackbox/testdata/generated-artifact-as-input-to-dynamic-rule/input.txt create mode 100644 tests/auto/blackbox/testdata/generated-artifact-as-input-to-dynamic-rule/p.qbs create mode 100644 tests/auto/blackbox/testdata/generator/generator.qbs create mode 100644 tests/auto/blackbox/testdata/generator/input.both.txt create mode 100644 tests/auto/blackbox/testdata/generator/input.file1.txt create mode 100644 tests/auto/blackbox/testdata/generator/input.file2.txt create mode 100644 tests/auto/blackbox/testdata/generator/input.none.txt create mode 100644 tests/auto/blackbox/testdata/generator/main.cpp create mode 100644 tests/auto/blackbox/testdata/group-condition-change/group-condition-change.qbs create mode 100644 tests/auto/blackbox/testdata/group-condition-change/input_kaputt.txt create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/groups-in-modules.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper/chunk.coal create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper/diamondc.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper/helper.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper2/helper2.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper3/helper3.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper4/helper4.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper5/helper5.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.c create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/modules/helper6/helper6.qbs create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/rock.coal create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/someotherfile.txt create mode 100644 tests/auto/blackbox/testdata/groups-in-modules/someotherfile2.txt create mode 100644 tests/auto/blackbox/testdata/grpc/grpc.cpp create mode 100644 tests/auto/blackbox/testdata/grpc/grpc.proto create mode 100644 tests/auto/blackbox/testdata/grpc/grpc_cpp.qbs create mode 100644 tests/auto/blackbox/testdata/host-os-properties/host-os-properties.qbs create mode 100644 tests/auto/blackbox/testdata/host-os-properties/main.cpp create mode 100644 tests/auto/blackbox/testdata/ico/dmg.iconset/icon_128x128.png create mode 100644 tests/auto/blackbox/testdata/ico/dmg.iconset/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata/ico/dmg.iconset/icon_256x256.png create mode 100644 tests/auto/blackbox/testdata/ico/dmg.iconset/icon_32x32.png create mode 100644 tests/auto/blackbox/testdata/ico/dmg.iconset/icon_512x512.png create mode 100644 tests/auto/blackbox/testdata/ico/ico.qbs create mode 100644 tests/auto/blackbox/testdata/ico/icon_16x16.png create mode 100644 tests/auto/blackbox/testdata/ico/icon_32x32.png create mode 100644 tests/auto/blackbox/testdata/import-assignment/import-assignment.qbs create mode 100644 tests/auto/blackbox/testdata/import-assignment/imports/MyImport/myimport.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/custom1command.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/custom1prepare1.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/custom1prepare2.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/custom2prepare/custom2prepare1.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/custom2prepare/custom2prepare2.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/import-change-tracking-product.qbs create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/import-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/imports/custom2command/custom2command1.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/imports/custom2command/custom2command2.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/input1.txt create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/input2.txt create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/irrelevant.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/probe1.js create mode 100644 tests/auto/blackbox/testdata/import-change-tracking/probe2.js create mode 100644 tests/auto/blackbox/testdata/import-in-properties-condition/import-in-properties-condition.qbs create mode 100644 tests/auto/blackbox/testdata/import-in-properties-condition/modules/amodule/m.qbs create mode 100644 tests/auto/blackbox/testdata/import-in-properties-condition/modules/depmodule/m.qbs create mode 100644 tests/auto/blackbox/testdata/import-searchpath/import-searchpath.qbs create mode 100644 tests/auto/blackbox/testdata/import-searchpath/qbs/imports/CppApplication.qbs create mode 100644 tests/auto/blackbox/testdata/import-searchpath/src/import-searchpath-app1.qbs create mode 100644 tests/auto/blackbox/testdata/import-searchpath/src/import-searchpath-app2.qbs create mode 100644 tests/auto/blackbox/testdata/import-searchpath/src/main.cpp create mode 100644 tests/auto/blackbox/testdata/import-searchpath/src/somefile.cpp create mode 100644 tests/auto/blackbox/testdata/importing-product/header.h.in create mode 100644 tests/auto/blackbox/testdata/importing-product/importing-product.qbs create mode 100644 tests/auto/blackbox/testdata/importing-product/main.cpp create mode 100644 tests/auto/blackbox/testdata/imports-conflict/imports-conflict.qbs create mode 100644 tests/auto/blackbox/testdata/imports-conflict/modules/themodule/m.qbs create mode 100644 tests/auto/blackbox/testdata/imports-conflict/modules/themodule/utils.js create mode 100644 tests/auto/blackbox/testdata/includeLookup/includeLookup.qbs create mode 100644 tests/auto/blackbox/testdata/includeLookup/main.cpp create mode 100644 tests/auto/blackbox/testdata/includeLookup/modules/definition/fakeopenssl/sha.h create mode 100644 tests/auto/blackbox/testdata/includeLookup/modules/definition/module.qbs create mode 100644 tests/auto/blackbox/testdata/input-tags-change-tracking/input-tags-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/input-tags-change-tracking/input.txt create mode 100644 tests/auto/blackbox/testdata/inputs-from-dependencies/file1.txt create mode 100644 tests/auto/blackbox/testdata/inputs-from-dependencies/file2.txt create mode 100644 tests/auto/blackbox/testdata/inputs-from-dependencies/file3.txt create mode 100644 tests/auto/blackbox/testdata/inputs-from-dependencies/file4.txt create mode 100644 tests/auto/blackbox/testdata/inputs-from-dependencies/inputs-from-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/install-duplicates-no-error/file1.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates-no-error/file2.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates-no-error/file3.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates-no-error/install-duplicates-no-error.qbs create mode 100644 tests/auto/blackbox/testdata/install-duplicates/dir1/file1.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates/dir1/file2.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates/dir2/file1.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates/dir2/file2.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates/dir2/file3.txt create mode 100644 tests/auto/blackbox/testdata/install-duplicates/install-duplicates.qbs create mode 100644 tests/auto/blackbox/testdata/install-locations/install-locations.qbs create mode 100644 tests/auto/blackbox/testdata/install-locations/main.cpp create mode 100644 tests/auto/blackbox/testdata/install-locations/thelib.cpp create mode 100644 tests/auto/blackbox/testdata/install-locations/theplugin.cpp create mode 100644 tests/auto/blackbox/testdata/install-root-from-project-file/file.txt create mode 100644 tests/auto/blackbox/testdata/install-root-from-project-file/install-root-from-project-file.qbs create mode 100644 tests/auto/blackbox/testdata/install-tree/data/foo.txt create mode 100644 tests/auto/blackbox/testdata/install-tree/data/subdir1/bar.txt create mode 100644 tests/auto/blackbox/testdata/install-tree/data/subdir2/baz.txt create mode 100644 tests/auto/blackbox/testdata/install-tree/install-tree.qbs create mode 100644 tests/auto/blackbox/testdata/install-tree/main.cpp create mode 100644 tests/auto/blackbox/testdata/installable-as-auxiliary-input/installable-as-auxiliary-input.qbs create mode 100644 tests/auto/blackbox/testdata/installable/installable.qbs create mode 100644 tests/auto/blackbox/testdata/installable/main.cpp create mode 100644 tests/auto/blackbox/testdata/installed-source-files/installed-source-files.qbs create mode 100644 tests/auto/blackbox/testdata/installed-source-files/main.cpp create mode 100644 tests/auto/blackbox/testdata/installed-source-files/readme.txt create mode 100644 tests/auto/blackbox/testdata/installed-transformer-output/qbs668.qbs create mode 100644 tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs create mode 100644 tests/auto/blackbox/testdata/installed_artifact/main.cpp create mode 100644 tests/auto/blackbox/testdata/installpackage/installpackage.qbs create mode 100644 tests/auto/blackbox/testdata/installpackage/lib.cpp create mode 100644 tests/auto/blackbox/testdata/installpackage/lib.h create mode 100644 tests/auto/blackbox/testdata/installpackage/main.cpp create mode 100644 tests/auto/blackbox/testdata/invalid-command-property/input.txt create mode 100644 tests/auto/blackbox/testdata/invalid-command-property/invalid-command-property.qbs create mode 100644 tests/auto/blackbox/testdata/invalid-extension-instantiation/invalid-extension-instantiation.qbs create mode 100644 tests/auto/blackbox/testdata/invalid-install-dir/invalid-install-dir.qbs create mode 100644 tests/auto/blackbox/testdata/invalid-install-dir/main.cpp create mode 100644 tests/auto/blackbox/testdata/invalid-library-names/invalid-library-names.qbs create mode 100644 tests/auto/blackbox/testdata/invalid-library-names/main.cpp create mode 100644 tests/auto/blackbox/testdata/jsextensions-binaryfile/binaryfile.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-file/file.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-fileinfo/fileinfo.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-host/host.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-process/main.cpp create mode 100644 tests/auto/blackbox/testdata/jsextensions-process/process.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-propertylist/propertylist.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-temporarydir/jsextensions-temporarydir.qbs create mode 100644 tests/auto/blackbox/testdata/jsextensions-textfile/textfile.qbs create mode 100644 tests/auto/blackbox/testdata/last-module-candidate-broken/last-module-candidate-broken.qbs create mode 100644 tests/auto/blackbox/testdata/last-module-candidate-broken/main.cpp create mode 100644 tests/auto/blackbox/testdata/last-module-candidate-broken/qbs/modules/Foo/Foo1.qbs create mode 100644 tests/auto/blackbox/testdata/last-module-candidate-broken/qbs/modules/Foo/Foo2.qbs create mode 100644 tests/auto/blackbox/testdata/ld/coreutils.cpp create mode 100644 tests/auto/blackbox/testdata/ld/coreutils.h create mode 100644 tests/auto/blackbox/testdata/ld/ld.qbs create mode 100644 tests/auto/blackbox/testdata/ld/main.cpp create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_outfile/lex_outfile.qbs create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_outfile/lexer.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_outfile/parser.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_outfile/types.h create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_prefix/lex_prefix.qbs create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_prefix/lexer.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_prefix/parser.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/lex_prefix/types.h create mode 100644 tests/auto/blackbox/testdata/lexyacc/modules/bisonhelper/bisonhelper.qbs create mode 100644 tests/auto/blackbox/testdata/lexyacc/one-grammar/lexer.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/one-grammar/one-grammar.qbs create mode 100644 tests/auto/blackbox/testdata/lexyacc/one-grammar/parser.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/one-grammar/types.h create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/g1.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/g1.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/g2.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/g2.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/main.c create mode 100644 tests/auto/blackbox/testdata/lexyacc/two-grammars/two-grammars.qbs create mode 100644 tests/auto/blackbox/testdata/lexyacc/unistd.h create mode 100644 tests/auto/blackbox/testdata/lexyacc/yacc_output/lexer.l create mode 100644 tests/auto/blackbox/testdata/lexyacc/yacc_output/parser.y create mode 100644 tests/auto/blackbox/testdata/lexyacc/yacc_output/types.h create mode 100644 tests/auto/blackbox/testdata/lexyacc/yacc_output/yacc_output.qbs create mode 100644 tests/auto/blackbox/testdata/linker-library-duplicates/lib1.cpp create mode 100644 tests/auto/blackbox/testdata/linker-library-duplicates/lib2.cpp create mode 100644 tests/auto/blackbox/testdata/linker-library-duplicates/lib3.cpp create mode 100644 tests/auto/blackbox/testdata/linker-library-duplicates/main.cpp create mode 100644 tests/auto/blackbox/testdata/linker-library-duplicates/setup-run-environment.qbs create mode 100644 tests/auto/blackbox/testdata/linker-module-definition/linker-module-definition.qbs create mode 100644 tests/auto/blackbox/testdata/linker-module-definition/testapp.cpp create mode 100644 tests/auto/blackbox/testdata/linker-module-definition/testlib.cpp create mode 100644 tests/auto/blackbox/testdata/linker-module-definition/testlib.def create mode 100644 tests/auto/blackbox/testdata/linker-variant/linker-variant.qbs create mode 100644 tests/auto/blackbox/testdata/linker-variant/main.cpp create mode 100644 tests/auto/blackbox/testdata/linkerMode/linkerMode.qbs create mode 100644 tests/auto/blackbox/testdata/linkerMode/main.c create mode 100644 tests/auto/blackbox/testdata/linkerMode/main.cpp create mode 100644 tests/auto/blackbox/testdata/linkerMode/main.m create mode 100644 tests/auto/blackbox/testdata/linkerMode/main.mm create mode 100644 tests/auto/blackbox/testdata/linkerMode/main.s create mode 100644 tests/auto/blackbox/testdata/linkerMode/staticlib.cpp create mode 100644 tests/auto/blackbox/testdata/linkerMode/staticmain.c create mode 100644 tests/auto/blackbox/testdata/linkerscripts/linkerscript1 create mode 100644 tests/auto/blackbox/testdata/linkerscripts/linkerscript2 create mode 100644 tests/auto/blackbox/testdata/linkerscripts/linkerscript_recursive create mode 100644 tests/auto/blackbox/testdata/linkerscripts/linkerscript_to_include create mode 100644 tests/auto/blackbox/testdata/linkerscripts/linkerscripts.qbs create mode 100644 tests/auto/blackbox/testdata/linkerscripts/scripts/linkerscript_in_directory create mode 100644 tests/auto/blackbox/testdata/linkerscripts/testlib.c create mode 100644 tests/auto/blackbox/testdata/list-products/list-products.qbs create mode 100644 tests/auto/blackbox/testdata/list-properties-with-outer/dummy.txt create mode 100644 tests/auto/blackbox/testdata/list-properties-with-outer/list-properties-with-outer.qbs create mode 100644 tests/auto/blackbox/testdata/list-properties-with-outer/modules/higher/higher.qbs create mode 100644 tests/auto/blackbox/testdata/list-properties-with-outer/modules/lower/lower.qbs create mode 100644 tests/auto/blackbox/testdata/list-property-order/dummy.txt create mode 100644 tests/auto/blackbox/testdata/list-property-order/modules/higher1/higher1.qbs create mode 100644 tests/auto/blackbox/testdata/list-property-order/modules/higher2/higher2.qbs create mode 100644 tests/auto/blackbox/testdata/list-property-order/modules/higher3/higher3.qbs create mode 100644 tests/auto/blackbox/testdata/list-property-order/modules/lower/lower.qbs create mode 100644 tests/auto/blackbox/testdata/list-property-order/product.qbs create mode 100644 tests/auto/blackbox/testdata/loadablemodule/exported.cpp create mode 100644 tests/auto/blackbox/testdata/loadablemodule/exported.h create mode 100644 tests/auto/blackbox/testdata/loadablemodule/loadablemodule.qbs create mode 100644 tests/auto/blackbox/testdata/loadablemodule/main.cpp create mode 100644 tests/auto/blackbox/testdata/localDeployment/localDeployment.qbs create mode 100644 tests/auto/blackbox/testdata/localDeployment/main.cpp create mode 100644 tests/auto/blackbox/testdata/makefile-generator/app.qbs create mode 100644 tests/auto/blackbox/testdata/makefile-generator/main.cpp create mode 100644 tests/auto/blackbox/testdata/maximum-c-language-version/main.c create mode 100644 tests/auto/blackbox/testdata/maximum-c-language-version/maximum-c-language-version.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-c-language-version/modules/newermodule/newermodule.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-c-language-version/modules/newestmodule/newestmodule.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-c-language-version/modules/oldmodule/oldmodule.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-cxx-language-version/main.cpp create mode 100644 tests/auto/blackbox/testdata/maximum-cxx-language-version/maximum-cxx-language-version.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-cxx-language-version/modules/newermodule/newermodule.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-cxx-language-version/modules/newestmodule/newestmodule.qbs create mode 100644 tests/auto/blackbox/testdata/maximum-cxx-language-version/modules/oldmodule/oldmodule.qbs create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/fakewindows.qbs create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/macappstore.qbs create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/main.cpp create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/main.mm create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/specific.qbs create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/unspecified-forced.qbs create mode 100644 tests/auto/blackbox/testdata/minimumSystemVersion/unspecified.qbs create mode 100644 tests/auto/blackbox/testdata/missing-dependency/main.cpp create mode 100644 tests/auto/blackbox/testdata/missing-dependency/missing-dependency.qbs create mode 100644 tests/auto/blackbox/testdata/missing-override-prefix/missing-override-prefix.qbs create mode 100644 tests/auto/blackbox/testdata/missing-project-file/ambiguous-dir/p1.qbs create mode 100644 tests/auto/blackbox/testdata/missing-project-file/ambiguous-dir/p2.qbs create mode 100644 tests/auto/blackbox/testdata/missing-project-file/ambiguous-dir/p3.qbs create mode 100644 tests/auto/blackbox/testdata/missing-project-file/empty-dir/irrelevant.txt create mode 100644 tests/auto/blackbox/testdata/missing-project-file/project-dir/file.cpp create mode 100644 tests/auto/blackbox/testdata/missing-project-file/project-dir/main.cpp create mode 100644 tests/auto/blackbox/testdata/missing-project-file/project-dir/missing-project-file.qbs create mode 100644 tests/auto/blackbox/testdata/module-conditions/module-conditions.qbs create mode 100644 tests/auto/blackbox/testdata/module-conditions/modules/m/m1.qbs create mode 100644 tests/auto/blackbox/testdata/module-conditions/modules/m/m2.qbs create mode 100644 tests/auto/blackbox/testdata/module-conditions/modules/m/m3.qbs create mode 100644 tests/auto/blackbox/testdata/module-conditions/modules/m/m4.qbs create mode 100644 tests/auto/blackbox/testdata/module-providers/main.cpp create mode 100644 tests/auto/blackbox/testdata/module-providers/module-providers.qbs create mode 100644 tests/auto/blackbox/testdata/module-providers/module-providers/mygenerator/provider.qbs create mode 100644 tests/auto/blackbox/testdata/module-providers/module-providers/othergenerator/provider.qbs create mode 100644 tests/auto/blackbox/testdata/moved-file-dependency/main.cpp create mode 100644 tests/auto/blackbox/testdata/moved-file-dependency/moved-file-dependency.qbs create mode 100644 tests/auto/blackbox/testdata/moved-file-dependency/subdir1/theheader.h create mode 100644 tests/auto/blackbox/testdata/multiple-changes/dummy.txt create mode 100644 tests/auto/blackbox/testdata/multiple-changes/multiple-changes.qbs create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/file.cpp create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/file.h create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/lib.cpp create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/lib.h create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/main.cpp create mode 100644 tests/auto/blackbox/testdata/multiple-configurations/multiple-configurations.qbs create mode 100644 tests/auto/blackbox/testdata/multiplexed-tool/multiplexed-tool.qbs create mode 100644 tests/auto/blackbox/testdata/multiplexed-tool/tool.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/file3.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/file3.h create mode 100644 tests/auto/blackbox/testdata/nested-groups/main.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/modules/themodule/themodule.qbs create mode 100644 tests/auto/blackbox/testdata/nested-groups/nested-groups.qbs create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/file1.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/file1.h create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/file2.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/file2.h create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/main2.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/main3.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/other.cpp create mode 100644 tests/auto/blackbox/testdata/nested-groups/subdir/other.h create mode 100644 tests/auto/blackbox/testdata/nested-properties/dummy.txt create mode 100644 tests/auto/blackbox/testdata/nested-properties/modules/higherlevel/higher-level.qbs create mode 100644 tests/auto/blackbox/testdata/nested-properties/modules/lowerlevel/lower-level.qbs create mode 100644 tests/auto/blackbox/testdata/nested-properties/product.qbs create mode 100644 tests/auto/blackbox/testdata/new-output-artifact/input.txt create mode 100644 tests/auto/blackbox/testdata/new-output-artifact/new-output-artifact.qbs create mode 100644 tests/auto/blackbox/testdata/no-exported-symbols/lib.cpp create mode 100644 tests/auto/blackbox/testdata/no-exported-symbols/lib.h create mode 100644 tests/auto/blackbox/testdata/no-exported-symbols/main.cpp create mode 100644 tests/auto/blackbox/testdata/no-exported-symbols/no-exported-symbols.qbs create mode 100644 tests/auto/blackbox/testdata/no-profile/no-profile.qbs create mode 100644 tests/auto/blackbox/testdata/no-such-profile/no-such-profile.qbs create mode 100644 tests/auto/blackbox/testdata/nodejs/hello.js create mode 100644 tests/auto/blackbox/testdata/nodejs/hello.qbs create mode 100644 tests/auto/blackbox/testdata/non-broken-files-in-broken-product/broken.cpp create mode 100644 tests/auto/blackbox/testdata/non-broken-files-in-broken-product/fine.cpp create mode 100644 tests/auto/blackbox/testdata/non-broken-files-in-broken-product/non-broken-files-in-broken-product.qbs create mode 100644 tests/auto/blackbox/testdata/non-default-product/main.cpp create mode 100644 tests/auto/blackbox/testdata/non-default-product/non-default-product.qbs create mode 100644 tests/auto/blackbox/testdata/not-always-updated/not-always-updated.qbs create mode 100644 tests/auto/blackbox/testdata/nsis/hello.bat create mode 100644 tests/auto/blackbox/testdata/nsis/hello.nsi create mode 100644 tests/auto/blackbox/testdata/nsis/hello.qbs create mode 100644 tests/auto/blackbox/testdata/nsisDependencies/hello.nsi create mode 100644 tests/auto/blackbox/testdata/nsisDependencies/main.c create mode 100644 tests/auto/blackbox/testdata/nsisDependencies/nsisDependencies.qbs create mode 100644 tests/auto/blackbox/testdata/out-of-date-marking/main.c create mode 100644 tests/auto/blackbox/testdata/out-of-date-marking/out-of-date-marking.qbs create mode 100644 tests/auto/blackbox/testdata/output-artifact-auto-tagging/broken.cpp.in create mode 100644 tests/auto/blackbox/testdata/output-artifact-auto-tagging/main.cpp.in create mode 100644 tests/auto/blackbox/testdata/output-artifact-auto-tagging/output-artifact-auto-tagging.qbs create mode 100644 tests/auto/blackbox/testdata/output-redirection/input.bin create mode 100644 tests/auto/blackbox/testdata/output-redirection/input.txt create mode 100644 tests/auto/blackbox/testdata/output-redirection/output-redirection.qbs create mode 100644 tests/auto/blackbox/testdata/output-redirection/output.bin create mode 100644 tests/auto/blackbox/testdata/output-redirection/output.txt create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/helper_lib.qbs create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/helperlib.cpp create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/main.cpp create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/main2.cpp create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/overrideProjectProperties.qbs create mode 100644 tests/auto/blackbox/testdata/overrideProjectProperties/project_using_helper_lib.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/BaseApp.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/super-tool.1 create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/tool create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/tool.1 create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/tool.2 create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/tool.3 create mode 100644 tests/auto/blackbox/testdata/path-probe/bin/tool.4 create mode 100644 tests/auto/blackbox/testdata/path-probe/candidate-filter.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/environment-paths.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/mult-files-common-suffixes.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/mult-files-mult-suffixes.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/mult-files-mult-variants.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/mult-files-suffixes.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/mult-files.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/name-filter.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/non-existent-selector.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/non-existent.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/single-file-mult-variants.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/single-file-selector-array.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/single-file-selector.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/single-file-suffixes.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/single-file.qbs create mode 100644 tests/auto/blackbox/testdata/path-probe/usr/bin/tool create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/header1.h create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/header2.cpp create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/header2.h create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/main.cpp create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/pch-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/pch-change-tracking/pch.h create mode 100644 tests/auto/blackbox/testdata/per-group-define-in-export-item/main.cpp create mode 100644 tests/auto/blackbox/testdata/per-group-define-in-export-item/per-group-define-in-export-item.qbs create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe-sysroot/modules/themodule/themodule.qbs create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe-sysroot/pkg-config.qbs create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot1/usr/share/pkgconfig/dummy.pc create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe-sysroot/sysroot2/usr/share/pkgconfig/dummy.pc create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe/dummy1/dummy1.pc create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe/dummy2/dummy2.pc create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe/modules/themodule/themodule.qbs create mode 100644 tests/auto/blackbox/testdata/pkg-config-probe/pkg-config.qbs create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/helper1.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/helper2.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/main.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/plugin-dependency.qbs create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/plugin1.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/plugin2.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/plugin3.cpp create mode 100644 tests/auto/blackbox/testdata/plugin-dependency/plugin4.cpp create mode 100644 tests/auto/blackbox/testdata/precompiled-and-prefix-headers/main.cpp create mode 100644 tests/auto/blackbox/testdata/precompiled-and-prefix-headers/pch.h create mode 100644 tests/auto/blackbox/testdata/precompiled-and-prefix-headers/precompiled-and-prefix-headers.qbs create mode 100644 tests/auto/blackbox/testdata/precompiled-and-prefix-headers/prefix.h create mode 100644 tests/auto/blackbox/testdata/precompiled-headers-and-redefine/file.cpp create mode 100644 tests/auto/blackbox/testdata/precompiled-headers-and-redefine/main.cpp create mode 100644 tests/auto/blackbox/testdata/precompiled-headers-and-redefine/pch.h create mode 100644 tests/auto/blackbox/testdata/precompiled-headers-and-redefine/precompiled-headers-and-redefine.qbs create mode 100644 tests/auto/blackbox/testdata/prevent-floating-point-values/prevent-floating-point-values.qbs create mode 100644 tests/auto/blackbox/testdata/probe-change-tracking/probe-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/dependee.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/dependency.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/modules/depmodule/depmodule.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/modules/myothermodule/myothermodule.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/probe-in-exported-module.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/test.in create mode 100644 tests/auto/blackbox/testdata/probe-in-exported-module/test2.in create mode 100644 tests/auto/blackbox/testdata/probe-in-module-provider/module-providers/provider_a.qbs create mode 100644 tests/auto/blackbox/testdata/probe-in-module-provider/probe-in-module-provider.qbs create mode 100644 tests/auto/blackbox/testdata/probeProperties/bin/tool create mode 100644 tests/auto/blackbox/testdata/probeProperties/main.c create mode 100644 tests/auto/blackbox/testdata/probeProperties/probeProperties.qbs create mode 100644 tests/auto/blackbox/testdata/probes-and-array-properties/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/blackbox/testdata/probes-and-array-properties/probes-and-array-properties.qbs create mode 100644 tests/auto/blackbox/testdata/probes-and-shadow-products/probes-and-shadow-products.qbs create mode 100644 tests/auto/blackbox/testdata/probes-in-nested-modules/modules/inner/inner.qbs create mode 100644 tests/auto/blackbox/testdata/probes-in-nested-modules/modules/outer/outer.qbs create mode 100644 tests/auto/blackbox/testdata/probes-in-nested-modules/probes-in-nested-modules.qbs create mode 100644 tests/auto/blackbox/testdata/product-dependencies-by-type/main.cpp create mode 100644 tests/auto/blackbox/testdata/product-dependencies-by-type/modules/myconfig/myconfig.qbs create mode 100644 tests/auto/blackbox/testdata/product-dependencies-by-type/product-dependencies-by-type.qbs create mode 100644 tests/auto/blackbox/testdata/product-in-exported-module/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/product-in-exported-module/product-in-exported-module.qbs create mode 100644 tests/auto/blackbox/testdata/productproperties/app.qbs create mode 100644 tests/auto/blackbox/testdata/productproperties/blubb_header.h.in create mode 100644 tests/auto/blackbox/testdata/productproperties/header.qbs create mode 100644 tests/auto/blackbox/testdata/productproperties/main.cpp create mode 100644 tests/auto/blackbox/testdata/productproperties/productproperties.qbs create mode 100644 tests/auto/blackbox/testdata/project_filepath_check/main.cpp create mode 100644 tests/auto/blackbox/testdata/project_filepath_check/main2.cpp create mode 100644 tests/auto/blackbox/testdata/project_filepath_check/project1.qbs create mode 100644 tests/auto/blackbox/testdata/project_filepath_check/project2.qbs create mode 100644 tests/auto/blackbox/testdata/proper quoting/main.cpp create mode 100644 tests/auto/blackbox/testdata/proper quoting/my static lib helper.cpp create mode 100644 tests/auto/blackbox/testdata/proper quoting/my static lib.cpp create mode 100644 tests/auto/blackbox/testdata/proper quoting/proper quoting.qbs create mode 100644 tests/auto/blackbox/testdata/proper quoting/some helper/some helper.cpp create mode 100644 tests/auto/blackbox/testdata/proper quoting/some helper/some helper.h create mode 100644 tests/auto/blackbox/testdata/properties-in-export-items/main1.cpp create mode 100644 tests/auto/blackbox/testdata/properties-in-export-items/main2.cpp create mode 100644 tests/auto/blackbox/testdata/properties-in-export-items/properties-in-export-items.qbs create mode 100644 tests/auto/blackbox/testdata/property-assignment-in-failed-module/main.cpp create mode 100644 tests/auto/blackbox/testdata/property-assignment-in-failed-module/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/property-assignment-in-failed-module/property-assignment-in-failed-module.qbs create mode 100644 tests/auto/blackbox/testdata/property-assignment-on-non-present-module/property-assignment-on-non-present-module.qbs create mode 100644 tests/auto/blackbox/testdata/property-evaluation-context/modules/base/base.qbs create mode 100644 tests/auto/blackbox/testdata/property-evaluation-context/modules/top/top.qbs create mode 100644 tests/auto/blackbox/testdata/property-evaluation-context/property-evaluation-context.qbs create mode 100644 tests/auto/blackbox/testdata/property-precedence/dep.qbs create mode 100644 tests/auto/blackbox/testdata/property-precedence/dummy.txt create mode 100644 tests/auto/blackbox/testdata/property-precedence/modules/leaf/leaf.qbs create mode 100644 tests/auto/blackbox/testdata/property-precedence/modules/nonleaf/nonleaf.qbs create mode 100644 tests/auto/blackbox/testdata/property-precedence/property-precedence.qbs create mode 100644 tests/auto/blackbox/testdata/propertyChanges/lib.cpp create mode 100644 tests/auto/blackbox/testdata/propertyChanges/modules/TestModule/module.qbs create mode 100644 tests/auto/blackbox/testdata/propertyChanges/propertyChanges.qbs create mode 100644 tests/auto/blackbox/testdata/propertyChanges/ruletest.qbs create mode 100644 tests/auto/blackbox/testdata/propertyChanges/source1.cpp create mode 100644 tests/auto/blackbox/testdata/propertyChanges/source2.cpp create mode 100644 tests/auto/blackbox/testdata/propertyChanges/source3.cpp create mode 100644 tests/auto/blackbox/testdata/propertyChanges/test.in create mode 100644 tests/auto/blackbox/testdata/protobuf-library-install/hello.proto create mode 100644 tests/auto/blackbox/testdata/protobuf-library-install/hello/world.proto create mode 100644 tests/auto/blackbox/testdata/protobuf-library-install/protobuf-library.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook.proto create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook_cpp.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.options create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.proto create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook_nanopb.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/addressbook_objc.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/create-proto-library.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/import-main.cpp create mode 100644 tests/auto/blackbox/testdata/protobuf/import.proto create mode 100644 tests/auto/blackbox/testdata/protobuf/import.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/main.cpp create mode 100644 tests/auto/blackbox/testdata/protobuf/main.m create mode 100644 tests/auto/blackbox/testdata/protobuf/main_nanopb.cpp create mode 100644 tests/auto/blackbox/testdata/protobuf/needs-import-dir-main.cpp create mode 100644 tests/auto/blackbox/testdata/protobuf/needs-import-dir.proto create mode 100644 tests/auto/blackbox/testdata/protobuf/needs-import-dir.qbs create mode 100644 tests/auto/blackbox/testdata/protobuf/subdir/myenum.proto create mode 100644 tests/auto/blackbox/testdata/providers-properties/module-providers/provider_a.qbs create mode 100644 tests/auto/blackbox/testdata/providers-properties/module-providers/provider_b.qbs create mode 100644 tests/auto/blackbox/testdata/providers-properties/providers-properties.qbs create mode 100644 tests/auto/blackbox/testdata/pseudo-multiplexing/pseudo-multiplexing.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_a.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-cli-override/module-providers/provider_b.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-cli-override/qbs-module-providers-cli-override.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/named_provider.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-compatibility/module-providers/qbsmetatestmodule/provider.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-compatibility/qbs-module-providers-compatibility.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers-helpers.js create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_a.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers/module-providers/provider_b.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-module-providers/qbs-module-providers.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-session/file1.cpp create mode 100644 tests/auto/blackbox/testdata/qbs-session/file2.cpp create mode 100644 tests/auto/blackbox/testdata/qbs-session/lib.cpp create mode 100644 tests/auto/blackbox/testdata/qbs-session/lib.h create mode 100644 tests/auto/blackbox/testdata/qbs-session/main.cpp create mode 100644 tests/auto/blackbox/testdata/qbs-session/modules/mymodule/mymodule.qbs create mode 100644 tests/auto/blackbox/testdata/qbs-session/qbs-session.qbs create mode 100644 tests/auto/blackbox/testdata/qbsVersion/qbs-version.qbs create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libdir/libA.pc create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.cpp create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libA.h create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/libs/libs.qbs create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/main.cpp create mode 100644 tests/auto/blackbox/testdata/qbspkgconfig-module-provider/qbspkgconfig-module-provider.qbs create mode 100644 tests/auto/blackbox/testdata/rad-after-incomplete-build/dummy.txt create mode 100644 tests/auto/blackbox/testdata/rad-after-incomplete-build/project_with_rule.qbs create mode 100644 tests/auto/blackbox/testdata/recursive_renaming/dir/subdir/blubb.txt create mode 100644 tests/auto/blackbox/testdata/recursive_renaming/dir/wasser.txt create mode 100644 tests/auto/blackbox/testdata/recursive_renaming/recursive_renaming.qbs create mode 100644 tests/auto/blackbox/testdata/recursive_wildcards/dir/file1.txt create mode 100644 tests/auto/blackbox/testdata/recursive_wildcards/dir/subdir/file2.txt create mode 100644 tests/auto/blackbox/testdata/recursive_wildcards/recursive_wildcards.qbs create mode 100644 tests/auto/blackbox/testdata/referenceErrorInExport/main.c create mode 100644 tests/auto/blackbox/testdata/referenceErrorInExport/referenceErrorInExport.qbs create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/MyStaticLib.qbs create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/main.c create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/provider.c create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/provider2.c create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/remove-duplicate-libs.qbs create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/requestor1.c create mode 100644 tests/auto/blackbox/testdata/remove-duplicate-libs/requestor2.c create mode 100644 tests/auto/blackbox/testdata/renameDependency/after/lib2.cpp create mode 100644 tests/auto/blackbox/testdata/renameDependency/after/lib2.h create mode 100644 tests/auto/blackbox/testdata/renameDependency/before/lib.cpp create mode 100644 tests/auto/blackbox/testdata/renameDependency/before/lib.h create mode 100644 tests/auto/blackbox/testdata/renameDependency/before/main.cpp create mode 100644 tests/auto/blackbox/testdata/renameDependency/before/renameDependency.qbs create mode 100644 tests/auto/blackbox/testdata/reproducible-build/file1.cpp create mode 100644 tests/auto/blackbox/testdata/reproducible-build/file2.cpp create mode 100644 tests/auto/blackbox/testdata/reproducible-build/main.cpp create mode 100644 tests/auto/blackbox/testdata/reproducible-build/reproducible-build.qbs create mode 100644 tests/auto/blackbox/testdata/require-deprecated/blubb.js create mode 100644 tests/auto/blackbox/testdata/require-deprecated/require.qbs create mode 100644 tests/auto/blackbox/testdata/require-deprecated/zort.js create mode 100644 tests/auto/blackbox/testdata/require/blubb.js create mode 100644 tests/auto/blackbox/testdata/require/require.qbs create mode 100644 tests/auto/blackbox/testdata/require/zort.js create mode 100644 tests/auto/blackbox/testdata/rescue-transformer-data/main.cpp create mode 100644 tests/auto/blackbox/testdata/rescue-transformer-data/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/rescue-transformer-data/transformer-data-rescue.qbs create mode 100644 tests/auto/blackbox/testdata/response-files/cat-response-file.cpp create mode 100644 tests/auto/blackbox/testdata/response-files/response-files.qbs create mode 100644 tests/auto/blackbox/testdata/retagged-output-artifact/retagged-output-artifact.qbs create mode 100644 tests/auto/blackbox/testdata/rule-connection-with-excluded-inputs/rule-connection-with-excluded-inputs.qbs create mode 100644 tests/auto/blackbox/testdata/rule-with-no-inputs/rule-with-no-inputs.qbs create mode 100644 tests/auto/blackbox/testdata/rule-with-non-required-inputs/a.inp create mode 100644 tests/auto/blackbox/testdata/rule-with-non-required-inputs/b.inp create mode 100644 tests/auto/blackbox/testdata/rule-with-non-required-inputs/c.inp create mode 100644 tests/auto/blackbox/testdata/rule-with-non-required-inputs/rule-with-non-required-inputs.qbs create mode 100644 tests/auto/blackbox/testdata/ruleConditions/foo.narf create mode 100644 tests/auto/blackbox/testdata/ruleConditions/main.cpp create mode 100644 tests/auto/blackbox/testdata/ruleConditions/modules/narfzort/narfzort.qbs create mode 100644 tests/auto/blackbox/testdata/ruleConditions/ruleConditions.qbs create mode 100644 tests/auto/blackbox/testdata/ruleConditions/templates/zorduct.qbs create mode 100644 tests/auto/blackbox/testdata/ruleCycle/happy.grass create mode 100644 tests/auto/blackbox/testdata/ruleCycle/ruleCycle.qbs create mode 100644 tests/auto/blackbox/testdata/sanitizer/sanitizer.cpp create mode 100644 tests/auto/blackbox/testdata/sanitizer/sanitizer.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/app/app.h create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/app/app.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/app/main.cpp create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/lib/lib.h create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/other/other.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-non-dependency/p.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/app/app.h create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/app/app.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/app/main.cpp create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/lib/lib.h create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/lib/lib.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/other/other.qbs create mode 100644 tests/auto/blackbox/testdata/scan-result-in-other-product/p.qbs create mode 100644 tests/auto/blackbox/testdata/scanner-item/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/scanner-item/scanner-item.qbs create mode 100644 tests/auto/blackbox/testdata/scanner-item/subdir1/file.inc create mode 100644 tests/auto/blackbox/testdata/scanner-item/subdir1/file1.in create mode 100644 tests/auto/blackbox/testdata/scanner-item/subdir2/file.inc create mode 100644 tests/auto/blackbox/testdata/scanner-item/subdir2/file2.in create mode 100644 tests/auto/blackbox/testdata/separate-debug-info/foo.cpp create mode 100644 tests/auto/blackbox/testdata/separate-debug-info/main.cpp create mode 100644 tests/auto/blackbox/testdata/separate-debug-info/separate-debug-info.qbs create mode 100644 tests/auto/blackbox/testdata/setup-build-environment/modules/buildenv/buildenv.qbs create mode 100644 tests/auto/blackbox/testdata/setup-build-environment/modules/m/m.qbs create mode 100644 tests/auto/blackbox/testdata/setup-build-environment/setup-build-environment.qbs create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/lib1.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/lib2.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/lib3.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/lib4.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/lib5.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/main.cpp create mode 100644 tests/auto/blackbox/testdata/setup-run-environment/setup-run-environment.qbs create mode 100644 tests/auto/blackbox/testdata/smart-relinking/lib.cpp create mode 100644 tests/auto/blackbox/testdata/smart-relinking/main.cpp create mode 100644 tests/auto/blackbox/testdata/smart-relinking/smart-relinking.qbs create mode 100644 tests/auto/blackbox/testdata/smart-relinking/staticlib.cpp create mode 100644 tests/auto/blackbox/testdata/source-artifact-changes/modules/module_with_files/main.cpp create mode 100644 tests/auto/blackbox/testdata/source-artifact-changes/modules/module_with_files/module_with_files.qbs create mode 100644 tests/auto/blackbox/testdata/source-artifact-changes/source-artifact-changes.qbs create mode 100644 tests/auto/blackbox/testdata/source-artifact-in-inputs-from-dependencies/header.h create mode 100644 tests/auto/blackbox/testdata/source-artifact-in-inputs-from-dependencies/source-artifact-in-inputs-from-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/soversion/lib.cpp create mode 100644 tests/auto/blackbox/testdata/soversion/soversion.qbs create mode 100644 tests/auto/blackbox/testdata/static-lib-without-sources/lib.cpp create mode 100644 tests/auto/blackbox/testdata/static-lib-without-sources/static-lib-without-sources.qbs create mode 100644 tests/auto/blackbox/testdata/subprofile-change-tracking/main1.cpp create mode 100644 tests/auto/blackbox/testdata/subprofile-change-tracking/main2.cpp create mode 100644 tests/auto/blackbox/testdata/subprofile-change-tracking/subprofile-change-tracking.qbs create mode 100644 tests/auto/blackbox/testdata/successive-changes/input.in create mode 100644 tests/auto/blackbox/testdata/successive-changes/successive-changes.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/copy-command.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/copy-eval.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/copy-prepare.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/copy-probe.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/direntries-command.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/direntries-eval.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/direntries-prepare.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/direntries-probe.qbs create mode 100644 tests/auto/blackbox/testdata/suspicious-calls/test.txt create mode 100644 tests/auto/blackbox/testdata/symbolLinkMode/indirect.cpp create mode 100644 tests/auto/blackbox/testdata/symbolLinkMode/lib.cpp create mode 100644 tests/auto/blackbox/testdata/symbolLinkMode/main.cpp create mode 100644 tests/auto/blackbox/testdata/symbolLinkMode/symbolLinkMode.qbs create mode 100644 tests/auto/blackbox/testdata/symlink-removal/symlink-removal.qbs create mode 100644 tests/auto/blackbox/testdata/system-include-paths/main.cpp create mode 100644 tests/auto/blackbox/testdata/system-include-paths/subdir/gagagugu.h create mode 100644 tests/auto/blackbox/testdata/system-include-paths/system-include-paths.qbs create mode 100644 tests/auto/blackbox/testdata/system-run-paths/lib.cpp create mode 100644 tests/auto/blackbox/testdata/system-run-paths/main.cpp create mode 100644 tests/auto/blackbox/testdata/system-run-paths/system-run-paths.qbs create mode 100644 tests/auto/blackbox/testdata/texttemplate/cdefgabc.txt.in create mode 100644 tests/auto/blackbox/testdata/texttemplate/expected/lalala.txt create mode 100644 tests/auto/blackbox/testdata/texttemplate/expected/output.txt create mode 100644 tests/auto/blackbox/testdata/texttemplate/output.txt.in create mode 100644 tests/auto/blackbox/testdata/texttemplate/texttemplatetest.qbs create mode 100644 tests/auto/blackbox/testdata/toplevel-searchpath/qbs-resources/imports/MyProduct.qbs create mode 100644 tests/auto/blackbox/testdata/toplevel-searchpath/toplevel-searchpath.qbs create mode 100644 tests/auto/blackbox/testdata/trackAddFile/after/main.cpp create mode 100644 tests/auto/blackbox/testdata/trackAddFile/after/trackAddFile.qbs create mode 100644 tests/auto/blackbox/testdata/trackAddFile/after/zort.cpp create mode 100644 tests/auto/blackbox/testdata/trackAddFile/after/zort.h create mode 100644 tests/auto/blackbox/testdata/trackAddFile/before/main.cpp create mode 100644 tests/auto/blackbox/testdata/trackAddFile/before/narf.cpp create mode 100644 tests/auto/blackbox/testdata/trackAddFile/before/narf.h create mode 100644 tests/auto/blackbox/testdata/trackAddFile/before/trackAddFile.qbs create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/environmentChange.cpp create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/fileList.js create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/hidden/hiddenheaderqbs.h create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/including.cpp create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/jsFileChange.cpp create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/main.cpp create mode 100644 tests/auto/blackbox/testdata/trackExternalProductChanges/trackExternalProductChanges.qbs create mode 100644 tests/auto/blackbox/testdata/trackFileTags/after/main.cpp create mode 100644 tests/auto/blackbox/testdata/trackFileTags/after/trackFileTags.qbs create mode 100644 tests/auto/blackbox/testdata/trackFileTags/before/main.cpp create mode 100644 tests/auto/blackbox/testdata/trackFileTags/before/trackFileTags.qbs create mode 100644 tests/auto/blackbox/testdata/trackProducts/after/product3.qbs create mode 100644 tests/auto/blackbox/testdata/trackProducts/after/trackProducts.qbs create mode 100644 tests/auto/blackbox/testdata/trackProducts/after/zoo.cpp create mode 100644 tests/auto/blackbox/testdata/trackProducts/before/bar.cpp create mode 100644 tests/auto/blackbox/testdata/trackProducts/before/foo.cpp create mode 100644 tests/auto/blackbox/testdata/trackProducts/before/product1.qbs create mode 100644 tests/auto/blackbox/testdata/trackProducts/before/product2.qbs create mode 100644 tests/auto/blackbox/testdata/trackProducts/before/trackProducts.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-invalid-dependencies/modules/a/a.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-invalid-dependencies/modules/b/b.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-invalid-dependencies/modules/c/c.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-invalid-dependencies/modules/d/d.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-invalid-dependencies/transitive-invalid-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-optional-dependencies/modules/a/a.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-optional-dependencies/modules/b/b.qbs create mode 100644 tests/auto/blackbox/testdata/transitive-optional-dependencies/transitive-optional-dependencies.qbs create mode 100644 tests/auto/blackbox/testdata/typescript/animals.ts create mode 100644 tests/auto/blackbox/testdata/typescript/extra.js create mode 100644 tests/auto/blackbox/testdata/typescript/foo.ts create mode 100644 tests/auto/blackbox/testdata/typescript/foo2.ts create mode 100644 tests/auto/blackbox/testdata/typescript/hello.ts create mode 100644 tests/auto/blackbox/testdata/typescript/main.ts create mode 100644 tests/auto/blackbox/testdata/typescript/typescript.qbs create mode 100644 tests/auto/blackbox/testdata/typescript/woosh/extra.ts create mode 100644 tests/auto/blackbox/testdata/undefined-target-platform/undefined-target-platform.qbs create mode 100644 tests/auto/blackbox/testdata/usings-as-sole-inputs-non-multiplexed/custom1.in create mode 100644 tests/auto/blackbox/testdata/usings-as-sole-inputs-non-multiplexed/custom2.in create mode 100644 tests/auto/blackbox/testdata/usings-as-sole-inputs-non-multiplexed/usings-as-sole-inputs-non-multiplexed.qbs create mode 100644 tests/auto/blackbox/testdata/variant-suffix/lib.cpp create mode 100644 tests/auto/blackbox/testdata/variant-suffix/variant-suffix.qbs create mode 100644 tests/auto/blackbox/testdata/vcs/main.cpp create mode 100644 tests/auto/blackbox/testdata/vcs/vcstest.qbs create mode 100644 tests/auto/blackbox/testdata/versioncheck/modules/higher/higher.qbs create mode 100644 tests/auto/blackbox/testdata/versioncheck/modules/lower/lower.qbs create mode 100644 tests/auto/blackbox/testdata/versioncheck/versioncheck.qbs create mode 100644 tests/auto/blackbox/testdata/versionscript/testlib.c create mode 100644 tests/auto/blackbox/testdata/versionscript/versionscript create mode 100644 tests/auto/blackbox/testdata/versionscript/versionscript.qbs create mode 100644 tests/auto/blackbox/testdata/whole-archive/dynamiclib.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/main1.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/main2.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/main3.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/main4.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/unused1.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/unused2.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/unused3.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/unused4.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/used.cpp create mode 100644 tests/auto/blackbox/testdata/whole-archive/whole-archive.qbs create mode 100644 tests/auto/blackbox/testdata/wildcard_renaming/pioniere.txt create mode 100644 tests/auto/blackbox/testdata/wildcard_renaming/wildcard_renaming.qbs create mode 100644 tests/auto/blackbox/testdata/wildcards-and-rules/input1.inp create mode 100644 tests/auto/blackbox/testdata/wildcards-and-rules/wildcards-and-rules.qbs create mode 100644 tests/auto/blackbox/tst_blackbox.cpp create mode 100644 tests/auto/blackbox/tst_blackbox.h create mode 100644 tests/auto/blackbox/tst_blackboxandroid.cpp create mode 100644 tests/auto/blackbox/tst_blackboxandroid.h create mode 100644 tests/auto/blackbox/tst_blackboxapple.cpp create mode 100644 tests/auto/blackbox/tst_blackboxapple.h create mode 100644 tests/auto/blackbox/tst_blackboxbaremetal.cpp create mode 100644 tests/auto/blackbox/tst_blackboxbaremetal.h create mode 100644 tests/auto/blackbox/tst_blackboxbase.cpp create mode 100644 tests/auto/blackbox/tst_blackboxbase.h create mode 100644 tests/auto/blackbox/tst_blackboxexamples.cpp create mode 100644 tests/auto/blackbox/tst_blackboxexamples.h create mode 100644 tests/auto/blackbox/tst_blackboxjava.cpp create mode 100644 tests/auto/blackbox/tst_blackboxjava.h create mode 100644 tests/auto/blackbox/tst_blackboxjoblimits.cpp create mode 100644 tests/auto/blackbox/tst_blackboxqt.cpp create mode 100644 tests/auto/blackbox/tst_blackboxqt.h create mode 100644 tests/auto/blackbox/tst_blackboxwindows.cpp create mode 100644 tests/auto/blackbox/tst_blackboxwindows.h create mode 100644 tests/auto/blackbox/tst_clangdb.cpp create mode 100644 tests/auto/blackbox/tst_clangdb.h create mode 100644 tests/auto/buildgraph/CMakeLists.txt create mode 100644 tests/auto/buildgraph/buildgraph.pro create mode 100644 tests/auto/buildgraph/buildgraph.qbs create mode 100644 tests/auto/buildgraph/tst_buildgraph.cpp create mode 100644 tests/auto/buildgraph/tst_buildgraph.h create mode 100644 tests/auto/cmdlineparser/CMakeLists.txt create mode 100644 tests/auto/cmdlineparser/cmdlineparser.pro create mode 100644 tests/auto/cmdlineparser/cmdlineparser.qbs create mode 100644 tests/auto/cmdlineparser/tst_cmdlineparser.cpp create mode 100644 tests/auto/dllexport.h create mode 100644 tests/auto/language/CMakeLists.txt create mode 100644 tests/auto/language/language.pro create mode 100644 tests/auto/language/language.qbs create mode 100644 tests/auto/language/testdata/Banana create mode 100644 tests/auto/language/testdata/MyProperties.qbs create mode 100644 tests/auto/language/testdata/ParentWithExport.qbs create mode 100644 tests/auto/language/testdata/aboutdialog.cpp create mode 100644 tests/auto/language/testdata/additional-product-types.qbs create mode 100644 tests/auto/language/testdata/base-validate/base-validate.qbs create mode 100644 tests/auto/language/testdata/base-validate/modules/m/MParent.qbs create mode 100644 tests/auto/language/testdata/base-validate/modules/m/m.qbs create mode 100644 tests/auto/language/testdata/baseproperty.qbs create mode 100644 tests/auto/language/testdata/baseproperty_base.qbs create mode 100644 tests/auto/language/testdata/broken-dependency-cycle1.qbs create mode 100644 tests/auto/language/testdata/broken-dependency-cycle2.qbs create mode 100644 tests/auto/language/testdata/buildconfigstringlistsyntax.qbs create mode 100644 tests/auto/language/testdata/builtinFunctionInSearchPathsProperty.qbs create mode 100644 tests/auto/language/testdata/canonicalArchitecture.qbs create mode 100644 tests/auto/language/testdata/chained-probes/chained-probes.qbs create mode 100644 tests/auto/language/testdata/chained-probes/modules/m/m.qbs create mode 100644 tests/auto/language/testdata/conditionaldepends.qbs create mode 100644 tests/auto/language/testdata/conditionaldepends_base.qbs create mode 100644 tests/auto/language/testdata/defaultvalue/egon.qbs create mode 100644 tests/auto/language/testdata/defaultvalue/modules/higher/higher.qbs create mode 100644 tests/auto/language/testdata/defaultvalue/modules/lower/lower.qbs create mode 100644 tests/auto/language/testdata/defaultvalue/test.txt create mode 100644 tests/auto/language/testdata/delayed-error/modules/m/m.qbs create mode 100644 tests/auto/language/testdata/delayed-error/nonexisting.qbs create mode 100644 tests/auto/language/testdata/delayed-error/validation.qbs create mode 100644 tests/auto/language/testdata/dependencyOnAllProfiles.qbs create mode 100644 tests/auto/language/testdata/derived-sub-project/DerivedSubProject.qbs create mode 100644 tests/auto/language/testdata/derived-sub-project/project.qbs create mode 100644 tests/auto/language/testdata/derived-sub-project/subproject.qbs create mode 100644 tests/auto/language/testdata/dirwithmultipleprojects/project.qbs create mode 100644 tests/auto/language/testdata/dirwithmultipleprojects/project2.qbs create mode 100644 tests/auto/language/testdata/dirwithnoprojects/.gitignore create mode 100644 tests/auto/language/testdata/dirwithoneproject/project.qbs create mode 100644 tests/auto/language/testdata/disabled-subproject.qbs create mode 100644 tests/auto/language/testdata/dotted-names/dotted-names.qbs create mode 100644 tests/auto/language/testdata/dotted-names/modules/x/y/xy.qbs create mode 100644 tests/auto/language/testdata/drawline.asm create mode 100644 tests/auto/language/testdata/dummy.txt create mode 100644 tests/auto/language/testdata/empty-js-file.js create mode 100644 tests/auto/language/testdata/empty-js-file.qbs create mode 100644 tests/auto/language/testdata/enum-project-props.qbs create mode 100644 tests/auto/language/testdata/environmentvariable.qbs create mode 100644 tests/auto/language/testdata/erroneous/ParentItem.qbs create mode 100644 tests/auto/language/testdata/erroneous/ParentWithExport.qbs create mode 100644 tests/auto/language/testdata/erroneous/ambiguous-multiplex-dependency.qbs create mode 100644 tests/auto/language/testdata/erroneous/conflicting-module-instances.qbs create mode 100644 tests/auto/language/testdata/erroneous/conflicting-properties-in-export-items.qbs create mode 100644 tests/auto/language/testdata/erroneous/conflicting_fileTagsFilter.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency-profile-mismatch-2.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency-profile-mismatch.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency_cycle.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency_cycle2.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency_cycle3.qbs create mode 100644 tests/auto/language/testdata/erroneous/dependency_cycle4.qbs create mode 100644 tests/auto/language/testdata/erroneous/duplicate-multiplex-value.qbs create mode 100644 tests/auto/language/testdata/erroneous/duplicate-multiplex-value2.qbs create mode 100644 tests/auto/language/testdata/erroneous/duplicate_sources.qbs create mode 100644 tests/auto/language/testdata/erroneous/duplicate_sources_wildcards.qbs create mode 100644 tests/auto/language/testdata/erroneous/importloop1.qbs create mode 100644 tests/auto/language/testdata/erroneous/importloop2.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid-parameter-rhs.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid-parameter-type.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid-property-option.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid-references.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid_child_item_type.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid_file.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid_property_type.qbs create mode 100644 tests/auto/language/testdata/erroneous/invalid_stringlist_element.qbs create mode 100644 tests/auto/language/testdata/erroneous/main.cpp create mode 100644 tests/auto/language/testdata/erroneous/mismatching-multiplex-dependency.qbs create mode 100644 tests/auto/language/testdata/erroneous/missing-colon.qbs create mode 100644 tests/auto/language/testdata/erroneous/misused-inherited-property.qbs create mode 100644 tests/auto/language/testdata/erroneous/module-depends-on-product.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/conflicting-instances/conflicting-instance1.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/conflicting-instances/conflicting-instance2.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module-a/module-a.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module-b/module-b.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module-with-invalid-original/module-with-invalid-original.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module-with-product-dependency/module-with-product-dependency.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module-with-wrong-property-option/m.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/module_with_parameters/module_with_parameters.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/no_such_property/no-such-property.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/prefix1/prefix1.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/prefix1/suffix/suffix.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/prefix2/prefix2.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/prefix2/suffix/suffix.qbs create mode 100644 tests/auto/language/testdata/erroneous/modules/readonly/readonly.qbs create mode 100644 tests/auto/language/testdata/erroneous/multiple_exports.qbs create mode 100644 tests/auto/language/testdata/erroneous/multiple_properties_in_subproject.qbs create mode 100644 tests/auto/language/testdata/erroneous/no-configure-in-probe.qbs create mode 100644 tests/auto/language/testdata/erroneous/nonexistentouter.qbs create mode 100644 tests/auto/language/testdata/erroneous/oldQbsVersion.qbs create mode 100644 tests/auto/language/testdata/erroneous/original-in-export-item.qbs create mode 100644 tests/auto/language/testdata/erroneous/original-in-export-item2.qbs create mode 100644 tests/auto/language/testdata/erroneous/original-in-export-item3.qbs create mode 100644 tests/auto/language/testdata/erroneous/original-in-module-prototype.qbs create mode 100644 tests/auto/language/testdata/erroneous/original-in-product-property.qbs create mode 100644 tests/auto/language/testdata/erroneous/overwrite-inherited-readonly-property.qbs create mode 100644 tests/auto/language/testdata/erroneous/overwrite-readonly-module-property.qbs create mode 100644 tests/auto/language/testdata/erroneous/properties-item-with-invalid-condition.qbs create mode 100644 tests/auto/language/testdata/erroneous/references_cycle.qbs create mode 100644 tests/auto/language/testdata/erroneous/references_cycle2.qbs create mode 100644 tests/auto/language/testdata/erroneous/references_cycle3.qbs create mode 100644 tests/auto/language/testdata/erroneous/reserved_name_in_import.qbs create mode 100644 tests/auto/language/testdata/erroneous/rule-without-output-tags.qbs create mode 100644 tests/auto/language/testdata/erroneous/same-module-prefix1.qbs create mode 100644 tests/auto/language/testdata/erroneous/same-module-prefix2.qbs create mode 100644 tests/auto/language/testdata/erroneous/subproject_cycle.qbs create mode 100644 tests/auto/language/testdata/erroneous/subproject_cycle2.qbs create mode 100644 tests/auto/language/testdata/erroneous/subproject_cycle3.qbs create mode 100644 tests/auto/language/testdata/erroneous/syntax-error-in-probe.qbs create mode 100644 tests/auto/language/testdata/erroneous/throw_in_property_binding.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared-parameter1.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared-parameter2.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_item.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_module_property_in_module.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property_in_Properties_item.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property_in_export_item.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property_in_export_item2.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property_in_export_item3.qbs create mode 100644 tests/auto/language/testdata/erroneous/undeclared_property_wrapper.qbs create mode 100644 tests/auto/language/testdata/erroneous/undefined_stringlist_element.qbs create mode 100644 tests/auto/language/testdata/erroneous/undefined_stringlist_element_in_probe.qbs create mode 100644 tests/auto/language/testdata/erroneous/unknown_item_type.qbs create mode 100644 tests/auto/language/testdata/erroneous/unknown_module.qbs create mode 100644 tests/auto/language/testdata/erroneous/wrong-toplevel-item.qbs create mode 100644 tests/auto/language/testdata/erroneous/wrongQbsVersionFormat.qbs create mode 100644 tests/auto/language/testdata/error-in-disabled-product.qbs create mode 100644 tests/auto/language/testdata/eval-error-in-non-present-module.qbs create mode 100644 tests/auto/language/testdata/exports.qbs create mode 100644 tests/auto/language/testdata/exports_product.qbs create mode 100644 tests/auto/language/testdata/file-in-product-and-module.qbs create mode 100644 tests/auto/language/testdata/filecontextproperties.qbs create mode 100644 tests/auto/language/testdata/filetags.qbs create mode 100644 tests/auto/language/testdata/getNativeSetting.qbs create mode 100644 tests/auto/language/testdata/groupconditions.qbs create mode 100644 tests/auto/language/testdata/groupname.qbs create mode 100644 tests/auto/language/testdata/homeDirectory.qbs create mode 100644 tests/auto/language/testdata/id-uniqueness.qbs create mode 100644 tests/auto/language/testdata/idusage.qbs create mode 100644 tests/auto/language/testdata/idusage_group.qbs create mode 100644 tests/auto/language/testdata/idusage_group2.qbs create mode 100644 tests/auto/language/testdata/idusagebase.qbs create mode 100644 tests/auto/language/testdata/idusagebasebase.qbs create mode 100644 tests/auto/language/testdata/import-collection/collection/file1.js create mode 100644 tests/auto/language/testdata/import-collection/collection/file2.js create mode 100644 tests/auto/language/testdata/import-collection/imports/Collection/file1.js create mode 100644 tests/auto/language/testdata/import-collection/imports/Collection/file2.js create mode 100644 tests/auto/language/testdata/import-collection/product.qbs create mode 100644 tests/auto/language/testdata/import-collection/project.qbs create mode 100644 tests/auto/language/testdata/inherited-properties-items/imports/DebugName.qbs create mode 100644 tests/auto/language/testdata/inherited-properties-items/imports/ReleaseName.qbs create mode 100644 tests/auto/language/testdata/inherited-properties-items/inherited-properties-items-product.qbs create mode 100644 tests/auto/language/testdata/inherited-properties-items/inherited-properties-items.qbs create mode 100644 tests/auto/language/testdata/invalid-overrides.qbs create mode 100644 tests/auto/language/testdata/invalidBindingInDisabledItem.qbs create mode 100644 tests/auto/language/testdata/jsextensions.js create mode 100644 tests/auto/language/testdata/jsimportsinmultiplescopes.js create mode 100644 tests/auto/language/testdata/jsimportsinmultiplescopes.qbs create mode 100644 tests/auto/language/testdata/main.cpp create mode 100644 tests/auto/language/testdata/module-merging-variant-values/module-merging-variant-values.qbs create mode 100644 tests/auto/language/testdata/module-merging-variant-values/modules/m1/m1.qbs create mode 100644 tests/auto/language/testdata/module-merging-variant-values/modules/m2/m2.qbs create mode 100644 tests/auto/language/testdata/module-prioritization-by-search-path/bar/modules/conflicting-instances/bar.qbs create mode 100644 tests/auto/language/testdata/module-prioritization-by-search-path/foo/modules/conflicting-instances/foo.qbs create mode 100644 tests/auto/language/testdata/module-prioritization-by-search-path/product.qbs create mode 100644 tests/auto/language/testdata/module-prioritization-by-search-path/project.qbs create mode 100644 tests/auto/language/testdata/module-property-overrides-per-product.qbs create mode 100644 tests/auto/language/testdata/moduleproperties.qbs create mode 100644 tests/auto/language/testdata/modulepropertiesingroups.qbs create mode 100644 tests/auto/language/testdata/modules.qbs create mode 100644 tests/auto/language/testdata/modules/broken/broken.qbs create mode 100644 tests/auto/language/testdata/modules/deepdummy/deep/moat/dummydeepmoat.qbs create mode 100644 tests/auto/language/testdata/modules/dummy/dummy.qbs create mode 100644 tests/auto/language/testdata/modules/dummy/dummy_base.qbs create mode 100644 tests/auto/language/testdata/modules/dummy2/dummy2.qbs create mode 100644 tests/auto/language/testdata/modules/dummy3/dummy3.qbs create mode 100644 tests/auto/language/testdata/modules/dummy3_loader/dummy3_loader.qbs create mode 100644 tests/auto/language/testdata/modules/dummyqt/core/dummycore.qbs create mode 100644 tests/auto/language/testdata/modules/dummyqt/gui/dummygui.qbs create mode 100644 tests/auto/language/testdata/modules/dummyqt/network/dummynetwork.qbs create mode 100644 tests/auto/language/testdata/modules/gmod/gmod1/gmod1.qbs create mode 100644 tests/auto/language/testdata/modules/gmod2/gmod2.qbs create mode 100644 tests/auto/language/testdata/modules/gmod3/qmod3.qbs create mode 100644 tests/auto/language/testdata/modules/gmod4/gmod4.qbs create mode 100644 tests/auto/language/testdata/modules/module-with-properties-item/module-with-properties-item.qbs create mode 100644 tests/auto/language/testdata/modules/module_with_file/module-with-file.qbs create mode 100644 tests/auto/language/testdata/modules/multiple_backends/backend1.qbs create mode 100644 tests/auto/language/testdata/modules/multiple_backends/backend2.qbs create mode 100644 tests/auto/language/testdata/modules/multiple_backends/backend3.qbs create mode 100644 tests/auto/language/testdata/modules/scopemod/scopemod.qbs create mode 100644 tests/auto/language/testdata/modulescope.qbs create mode 100644 tests/auto/language/testdata/modulescope_base.qbs create mode 100644 tests/auto/language/testdata/multiplexed-exports.qbs create mode 100644 tests/auto/language/testdata/multiplexing-by-profile/p1.qbs create mode 100644 tests/auto/language/testdata/multiplexing-by-profile/p2.qbs create mode 100644 tests/auto/language/testdata/multiplexing-by-profile/p3.qbs create mode 100644 tests/auto/language/testdata/multiplexing-by-profile/p4.qbs create mode 100644 tests/auto/language/testdata/narf create mode 100644 tests/auto/language/testdata/narf.zort create mode 100644 tests/auto/language/testdata/nativesettings.ini create mode 100644 tests/auto/language/testdata/non-applicable-module-property-in-profile.qbs create mode 100644 tests/auto/language/testdata/non-required-products.qbs create mode 100644 tests/auto/language/testdata/outerInGroup.qbs create mode 100644 tests/auto/language/testdata/overridden-properties-and-prototypes.qbs create mode 100644 tests/auto/language/testdata/overridden-variant-property.qbs create mode 100644 tests/auto/language/testdata/parameter-types.qbs create mode 100644 tests/auto/language/testdata/pathproperties.qbs create mode 100644 tests/auto/language/testdata/productconditions.qbs create mode 100644 tests/auto/language/testdata/productdirectories.qbs create mode 100644 tests/auto/language/testdata/profilevaluesandoverriddenvalues.qbs create mode 100644 tests/auto/language/testdata/properties-block-in-group.qbs create mode 100644 tests/auto/language/testdata/properties-item-in-module.qbs create mode 100644 tests/auto/language/testdata/propertiesblocks.qbs create mode 100644 tests/auto/language/testdata/propertiesblocks_base.qbs create mode 100644 tests/auto/language/testdata/property-assignment-in-exported-group.qbs create mode 100644 tests/auto/language/testdata/qbs-properties-in-project-condition.qbs create mode 100644 tests/auto/language/testdata/qbs-property-convenience-override.qbs create mode 100644 tests/auto/language/testdata/qbs1275.qbs create mode 100644 tests/auto/language/testdata/recursive-dependencies/recursive-dependencies.qbs create mode 100644 tests/auto/language/testdata/relaxed-error-mode/file1.txt create mode 100644 tests/auto/language/testdata/relaxed-error-mode/file2.txt create mode 100644 tests/auto/language/testdata/relaxed-error-mode/relaxed-error-mode.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/complicated.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/dependency-via-export.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/dependency-via-module.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/direct-dependencies.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/modules/failing-validation-indirect/failing-validation-indirect.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/modules/failing-validation/failing-validation.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/required-chain-export-indirect.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/required-chain-export.qbs create mode 100644 tests/auto/language/testdata/required-and-nonrequired-dependencies/required-chain-module.qbs create mode 100644 tests/auto/language/testdata/rfc1034identifier.qbs create mode 100644 tests/auto/language/testdata/subdir/exports-mylib.qbs create mode 100644 tests/auto/language/testdata/subdir/pathproperties_base.qbs create mode 100644 tests/auto/language/testdata/subdir2/exports-mylib2.qbs create mode 100644 tests/auto/language/testdata/suppressed-and-non-suppressed-errors.qbs create mode 100644 tests/auto/language/testdata/throwing-probe.qbs create mode 100644 tests/auto/language/testdata/use-internal-profile.qbs create mode 100644 tests/auto/language/testdata/versionCompare.qbs create mode 100644 tests/auto/language/testdata/zort create mode 100644 tests/auto/language/tst_language.cpp create mode 100644 tests/auto/language/tst_language.h create mode 100644 tests/auto/pkgconfig/CMakeLists.txt create mode 100644 tests/auto/pkgconfig/pkgconfig.qbs create mode 100644 tests/auto/pkgconfig/testdata/base.name.json create mode 100644 tests/auto/pkgconfig/testdata/base.name.pc create mode 100644 tests/auto/pkgconfig/testdata/empty-variable.json create mode 100644 tests/auto/pkgconfig/testdata/empty-variable.pc create mode 100644 tests/auto/pkgconfig/testdata/non-l-required.json create mode 100644 tests/auto/pkgconfig/testdata/non-l-required.pc create mode 100644 tests/auto/pkgconfig/testdata/private-dep.pc create mode 100644 tests/auto/pkgconfig/testdata/public-dep.pc create mode 100644 tests/auto/pkgconfig/testdata/requires-test-merged-static.json create mode 100644 tests/auto/pkgconfig/testdata/requires-test-merged.json create mode 100644 tests/auto/pkgconfig/testdata/requires-test.json create mode 100644 tests/auto/pkgconfig/testdata/requires-test.pc create mode 100644 tests/auto/pkgconfig/testdata/simple.json create mode 100644 tests/auto/pkgconfig/testdata/simple.pc create mode 100644 tests/auto/pkgconfig/testdata/special-flags.json create mode 100644 tests/auto/pkgconfig/testdata/special-flags.pc create mode 100644 tests/auto/pkgconfig/testdata/sysroot.json create mode 100644 tests/auto/pkgconfig/testdata/sysroot.pc create mode 100644 tests/auto/pkgconfig/testdata/system.json create mode 100644 tests/auto/pkgconfig/testdata/system.pc create mode 100644 tests/auto/pkgconfig/testdata/tilde.json create mode 100644 tests/auto/pkgconfig/testdata/tilde.pc create mode 100644 tests/auto/pkgconfig/testdata/variables.json create mode 100644 tests/auto/pkgconfig/testdata/variables.pc create mode 100644 tests/auto/pkgconfig/testdata/whitespace.json create mode 100644 tests/auto/pkgconfig/testdata/whitespace.pc create mode 100644 tests/auto/pkgconfig/tst_pkgconfig.cpp create mode 100644 tests/auto/pkgconfig/tst_pkgconfig.h create mode 100644 tests/auto/shared.h create mode 100644 tests/auto/tools/CMakeLists.txt create mode 100644 tests/auto/tools/tools.pro create mode 100644 tests/auto/tools/tools.qbs create mode 100644 tests/auto/tools/tst_tools.cpp create mode 100644 tests/auto/tools/tst_tools.h create mode 100644 tests/benchmarker/CMakeLists.txt create mode 100644 tests/benchmarker/activities.h create mode 100644 tests/benchmarker/benchmarker-main.cpp create mode 100644 tests/benchmarker/benchmarker.cpp create mode 100644 tests/benchmarker/benchmarker.h create mode 100644 tests/benchmarker/benchmarker.pro create mode 100644 tests/benchmarker/benchmarker.qbs create mode 100644 tests/benchmarker/commandlineparser.cpp create mode 100644 tests/benchmarker/commandlineparser.h create mode 100644 tests/benchmarker/exception.h create mode 100644 tests/benchmarker/runsupport.cpp create mode 100644 tests/benchmarker/runsupport.h create mode 100644 tests/benchmarker/valgrindrunner.cpp create mode 100644 tests/benchmarker/valgrindrunner.h create mode 100644 tests/fuzzy-test/CMakeLists.txt create mode 100644 tests/fuzzy-test/commandlineparser.cpp create mode 100644 tests/fuzzy-test/commandlineparser.h create mode 100644 tests/fuzzy-test/fuzzy-test.pro create mode 100644 tests/fuzzy-test/fuzzy-test.qbs create mode 100644 tests/fuzzy-test/fuzzytester.cpp create mode 100644 tests/fuzzy-test/fuzzytester.h create mode 100644 tests/fuzzy-test/main.cpp create mode 100644 tests/tests.pro create mode 100644 tests/tests.qbs diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..1ae91aaf --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,273 @@ +--- +Checks: > + -*, + bugprone-*, + cppcoreguidelines-interfaces-global-init, + cppcoreguidelines-pro-type-cstyle-cast, + cppcoreguidelines-pro-type-member-init, + cppcoreguidelines-slicing, + fuchsia-virtual-inheritance, + google-build-explicit-make-pair, + google-build-namespaces, + google-global-names-in-headers, + google-objc-*, + google-readability-casting, + google-readability-namespace-comments, + google-runtime-operator, + misc-definitions-in-headers, + misc-misplaced-const, + misc-new-delete-overloads, + misc-non-copyable-objects, + misc-redundant-expression, + misc-static-assert, + misc-uniqueptr-reset-release, + misc-unused-*, + modernize-avoid-bind, + modernize-deprecated-headers, + modernize-loop-convert, + modernize-make-*, + modernize-pass-by-value, + modernize-redundant-void-arg, + modernize-replace-*, + modernize-return-braced-init-list, + modernize-shrink-to-fit, + modernize-unary-static-assert, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-emplace, + modernize-use-equals-*, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-transparent-functors, + modernize-use-using, + performance-*, + readability-avoid-const-params-in-decls, + readability-container-size-empty, + readability-delete-null-pointer, + readability-deleted-default, + readability-identifier-naming, + readability-misleading-indentation, + readability-misplaced-array-index, + readability-non-const-parameter, + readability-redundant-*, + -readability-redundant-member-init, + readability-simplify-boolean-expr, + readability-static-definition-in-anonymous-namespace, + readability-uniqueptr-delete-release + +WarningsAsErrors: > + bugprone-*, + cppcoreguidelines-*, + google-*, + misc-unused-*, + modernize-*, + performance-*, + readability-*, + -readability-container-size-empty + +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +CheckOptions: + - key: bugprone-argument-comment.StrictMode + value: '0' + - key: bugprone-assert-side-effect.AssertMacros + value: assert + - key: bugprone-assert-side-effect.CheckFunctionCalls + value: '0' + - key: bugprone-dangling-handle.HandleClasses + value: 'std::basic_string_view;std::experimental::basic_string_view' + - key: bugprone-exception-escape.FunctionsThatShouldNotThrow + value: '' + - key: bugprone-exception-escape.IgnoredExceptions + value: '' + - key: bugprone-misplaced-widening-cast.CheckImplicitCasts + value: '0' + - key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant + value: '1' + - key: bugprone-sizeof-expression.WarnOnSizeOfConstant + value: '1' + - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression + value: '0' + - key: bugprone-sizeof-expression.WarnOnSizeOfThis + value: '1' + - key: bugprone-string-constructor.LargeLengthThreshold + value: '8388608' + - key: bugprone-string-constructor.WarnOnLargeLength + value: '1' + - key: bugprone-suspicious-enum-usage.StrictMode + value: '0' + - key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens + value: '5' + - key: bugprone-suspicious-missing-comma.RatioThreshold + value: '0.200000' + - key: bugprone-suspicious-missing-comma.SizeThreshold + value: '5' + - key: bugprone-suspicious-string-compare.StringCompareLikeFunctions + value: '' + - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison + value: '1' + - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison + value: '0' + - key: bugprone-unused-return-value.CheckedFunctions + value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty' + - key: cert-dcl16-c.NewSuffixes + value: 'L;LL;LU;LLU' + - key: cppcoreguidelines-no-malloc.Allocations + value: '::malloc;::calloc' + - key: cppcoreguidelines-no-malloc.Deallocations + value: '::free' + - key: cppcoreguidelines-no-malloc.Reallocations + value: '::realloc' + - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic + value: '1' + - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader + value: '' + - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle + value: '0' + - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays + value: '0' + - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions + value: '0' + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: '0' + - key: google-build-namespaces.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-global-names-in-headers.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.BranchThreshold + value: '4294967295' + - key: google-readability-function-size.LineThreshold + value: '4294967295' + - key: google-readability-function-size.NestingThreshold + value: '4294967295' + - key: google-readability-function-size.ParameterThreshold + value: '4294967295' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-function-size.VariableThreshold + value: '4294967295' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: '' + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: misc-definitions-in-headers.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: misc-definitions-in-headers.UseHeaderFileExtension + value: '1' + - key: misc-unused-parameters.StrictMode + value: '0' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-make-shared.IgnoreMacros + value: '1' + - key: modernize-make-shared.IncludeStyle + value: '0' + - key: modernize-make-shared.MakeSmartPtrFunction + value: 'std::make_shared' + - key: modernize-make-shared.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-make-unique.IgnoreMacros + value: '1' + - key: modernize-make-unique.IncludeStyle + value: '0' + - key: modernize-make-unique.MakeSmartPtrFunction + value: 'std::make_unique' + - key: modernize-make-unique.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-pass-by-value.ValuesOnly + value: '0' + - key: modernize-raw-string-literal.ReplaceShorterLiterals + value: '0' + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-replace-random-shuffle.IncludeStyle + value: llvm + - key: modernize-use-auto.MinTypeNameLength + value: '5' + - key: modernize-use-auto.RemoveStars + value: '0' + - key: modernize-use-emplace.ContainersWithPushBack + value: '::std::vector;::std::list;::std::deque' + - key: modernize-use-emplace.SmartPointers + value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + - key: modernize-use-emplace.TupleMakeFunctions + value: '::std::make_pair;::std::make_tuple' + - key: modernize-use-emplace.TupleTypes + value: '::std::pair;::std::tuple' + - key: modernize-use-equals-default.IgnoreMacros + value: '1' + - key: modernize-use-equals-delete.IgnoreMacros + value: '1' + - key: modernize-use-noexcept.ReplacementString + value: '' + - key: modernize-use-noexcept.UseNoexceptFalse + value: '1' + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: modernize-use-transparent-functors.SafeMode + value: '0' + - key: modernize-use-using.IgnoreMacros + value: '1' + - key: performance-faster-string-find.StringLikeClasses + value: 'std::basic_string' + - key: performance-for-range-copy.AllowedTypes + value: '' + - key: performance-for-range-copy.WarnOnAllAutoCopies + value: '0' + - key: performance-inefficient-string-concatenation.StrictMode + value: '0' + - key: performance-inefficient-vector-operation.VectorLikeClasses + value: '::std::vector' + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: '1' + - key: performance-move-constructor-init.IncludeStyle + value: llvm + - key: performance-type-promotion-in-math-fn.IncludeStyle + value: llvm + - key: performance-unnecessary-copy-initialization.AllowedTypes + value: '' + - key: performance-unnecessary-value-param.AllowedTypes + value: '' + - key: performance-unnecessary-value-param.IncludeStyle + value: llvm + - key: readability-function-size.BranchThreshold + value: '4294967295' + - key: readability-function-size.LineThreshold + value: '4294967295' + - key: readability-function-size.NestingThreshold + value: '4294967295' + - key: readability-function-size.ParameterThreshold + value: '4294967295' + - key: readability-function-size.StatementThreshold + value: '800' + - key: readability-function-size.VariableThreshold + value: '4294967295' + - key: readability-identifier-naming.IgnoreFailedSplit + value: '0' + - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros + value: '1' + - key: readability-inconsistent-declaration-parameter-name.Strict + value: '0' + - key: readability-redundant-smartptr-get.IgnoreMacros + value: '1' + - key: readability-simplify-boolean-expr.ChainedConditionalAssignment + value: '0' + - key: readability-simplify-boolean-expr.ChainedConditionalReturn + value: '0' +... + diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..a949bb5a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!docker/* +!scripts/* diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..71f59f08 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/.gitignore export-ignore +/.gitattributes export-ignore +/scripts/make-release-archive.sh export-ignore diff --git a/.github/actions/download-dm/action.yml b/.github/actions/download-dm/action.yml new file mode 100644 index 00000000..5d24da3e --- /dev/null +++ b/.github/actions/download-dm/action.yml @@ -0,0 +1,15 @@ +name: 'Download DigitalMars' +description: 'Downloads DigitalMars' +inputs: + version: + description: 'DigitalMars version' + required: false + default: '8.57' +runs: + using: "composite" + steps: + - name: Install DigitalMars + run: | + DM_DIR=$(./scripts/install-dm.sh -d $HOME/dm --version ${{ inputs.version }}) + (cygpath -w ${DM_DIR} 2>/dev/null || echo ${DM_DIR}) >> ${GITHUB_PATH} + shell: bash diff --git a/.github/actions/download-mingw/action.yml b/.github/actions/download-mingw/action.yml new file mode 100644 index 00000000..f8fb47f2 --- /dev/null +++ b/.github/actions/download-mingw/action.yml @@ -0,0 +1,19 @@ +name: 'Download MinGW' +description: 'Downloads MinGW' +inputs: + version: + description: 'MinGW version' + required: false + default: '8.1.0' + toolchain: + description: 'Toolchain' + required: false + default: 'win64_mingw' +runs: + using: "composite" + steps: + - name: Install MinGW + run: | + MINGW_DIR=$(./scripts/install-qt.sh -d $HOME/Qt --version ${{ inputs.version }} --toolchain ${{ inputs.toolchain }} mingw) + (cygpath -w ${MINGW_DIR} 2>/dev/null || echo ${MINGW_DIR}) >> ${GITHUB_PATH} + shell: bash diff --git a/.github/actions/download-ow/action.yml b/.github/actions/download-ow/action.yml new file mode 100644 index 00000000..a93a229c --- /dev/null +++ b/.github/actions/download-ow/action.yml @@ -0,0 +1,15 @@ +name: 'Download OpenWatcom' +description: 'Downloads OpenWatcom' +inputs: + version: + description: 'OpenWatcom version' + required: false + default: '2.0' +runs: + using: "composite" + steps: + - name: Install OpenWatcom + run: | + OW_DIR=$(./scripts/install-ow.sh -d $HOME/watcom --version ${{ inputs.version }}) + (cygpath -w ${OW_DIR} 2>/dev/null || echo ${OW_DIR}) >> ${GITHUB_PATH} + shell: bash diff --git a/.github/actions/download-qt/action.yml b/.github/actions/download-qt/action.yml new file mode 100644 index 00000000..e2735812 --- /dev/null +++ b/.github/actions/download-qt/action.yml @@ -0,0 +1,22 @@ +name: 'Download Qt' +description: 'Downloads Qt' +inputs: + version: + description: 'Qt version' + required: false + default: '5.15.2' + target: + description: 'Qt target (desktop, ios, android)' + required: false + default: 'desktop' + toolchain: + description: 'Qt toolchain' + required: true +runs: + using: "composite" + steps: + - name: Install Qt + run: | + QT_DIR=$(./scripts/install-qt.sh -d $HOME/Qt --version ${{ inputs.version }} --target ${{ inputs.target }} --toolchain ${{ inputs.toolchain }} qtbase qtdeclarative qttools qtscript qtscxml qt5compat) + (cygpath -w ${QTC_DIR} 2>/dev/null || echo ${QT_DIR}) >> ${GITHUB_PATH} + shell: bash diff --git a/.github/actions/download-qtc/action.yml b/.github/actions/download-qtc/action.yml new file mode 100644 index 00000000..292991b3 --- /dev/null +++ b/.github/actions/download-qtc/action.yml @@ -0,0 +1,15 @@ +name: 'Download Qt Creator' +description: 'Downloads Qt Creator' +inputs: + version: + description: 'Qt Creator version' + required: false + default: '5.0.3' +runs: + using: "composite" + steps: + - name: Install Qt Creator + run: | + QTC_DIR=$(./scripts/install-qt.sh -d $HOME/Qt --version ${{ inputs.version }} qtcreator) + (cygpath -w ${QTC_DIR} 2>/dev/null || echo ${QTC_DIR}) >> ${GITHUB_PATH} + shell: bash diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..248baf5f --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +name: Build and Qbs docs + +on: + push: + paths: + - 'doc/**' + - 'examples/**' + - 'scripts/build-qbs-doc.sh' + - 'VERSION' + +jobs: + build-docs: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build Qbs Docs', + options: '', + script: './scripts/build-qbs-doc.sh' + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Pull the Focal Image + run: docker-compose pull focal + - name: Build Qbs Docs + run: docker-compose run focal ${{ matrix.config.script }} + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-docs-${{ github.run_id }} + path: documentation/install-root/usr/local/share/doc/qbs/ diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..1c513cad --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,887 @@ +name: Build and test Qbs + +on: + push: + paths-ignore: + - 'changelogs/**' + - 'doc/**' + +jobs: + build-linux: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build on Linux (gcc)', + options: 'modules.cpp.compilerWrapper:ccache + modules.qbs.debugInformation:true + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-linux-${{ github.run_id }} + products.qbs_archive.includeTests:true', + script: './scripts/build-qbs-with-qbs.sh', + cacheid: 'gcc', + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache- + - name: Pull the Focal Image + run: docker-compose pull focal + - name: Print ccache stats + run: docker-compose run focal ccache -s + - name: Build Qbs + run: docker-compose run focal ${{ matrix.config.script }} + - name: Print ccache stats + run: docker-compose run focal ccache -s + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-linux-${{ github.run_id }}.tar.gz + path: release/qbs-linux-${{ github.run_id }}.tar.gz + + build-linux-extra: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build on Linux (clang_tidy)', + script: './scripts/run-analyzer.sh', + image: 'focal', + options: 'profile:qt-clang_64 modules.cpp.compilerWrapper:ccache', + cacheid: 'clang', + } + - { + name: 'Build on Linux (CMake)', + script: './scripts/build-qbs-with-cmake.sh', + image: 'focal-qt6', + cacheid: 'cmake', + } + - { + name: 'Build on Linux (QMake)', + script: './scripts/build-qbs-with-qmake.sh', + image: 'focal', + options: 'CONFIG+=ccache', + cacheid: 'qmake', + } + - { + name: 'Build on Linux (gcc, Qt 6)', + image: 'focal-qt6', + script: './scripts/build-qbs-with-qbs.sh', + options: 'modules.cpp.compilerWrapper:ccache + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbs.debugInformation:true + modules.qbsbuildconfig.enableBundledQt:true', + cacheid: 'gcc-qt6', + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + QTEST_FUNCTION_TIMEOUT: 9000000 + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache- + - name: Pull the Focal Image + run: docker-compose pull ${{ matrix.config.image }} + - name: Print ccache stats + run: docker-compose run ${{ matrix.config.image }} ccache -s + - name: Build Qbs + run: docker-compose run ${{ matrix.config.image }} ${{ matrix.config.script }} + - name: Print ccache stats + run: docker-compose run ${{ matrix.config.image }} ccache -s + + build-macos: + name: Build on macOS + runs-on: macos-11 + timeout-minutes: 60 + env: + BUILD_OPTIONS: | + modules.cpp.compilerWrapper:ccache + modules.qbs.debugInformation:true + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-macos-${{ github.run_id }} + products.qbs_archive.includeTests:true + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-ccache- + - name: Install required packages + run: | + brew install ccache p7zip + python3 -m pip install --user beautifulsoup4 lxml + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: clang_64 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt --detect + qbs config profiles.qt.baseProfile xcode-macosx-x86_64 + qbs config defaultProfile qt + qbs config --list + - name: Print ccache stats + run: ccache -s + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + - name: Print ccache stats + run: ccache -s + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-macos-${{ github.run_id }}.tar.gz + path: release/qbs-macos-${{ github.run_id }}.tar.gz + + build-windows: + name: Build on Windows + runs-on: windows-2022 + timeout-minutes: 60 + env: + BUILD_OPTIONS: | + modules.cpp.compilerWrapper:clcache + modules.qbs.debugInformation:true + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-windows-${{ github.run_id }} + products.qbs_archive.includeTests:true, + WITH_TESTS: 0 + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + steps: + - uses: actions/checkout@v1 + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + shell: bash + - name: clcache cache files + uses: actions/cache@v2 + with: + path: ~/clcache + key: ${{ runner.os }}-msvc-clcache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-msvc-clcache- + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install required packages + run: | + python -m pip install --upgrade pip + pip install beautifulsoup4 lxml + pip install git+https://github.com/frerich/clcache.git@cae73d8255d78db8ba11e23c51fd2c9a89e7475b + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: win64_msvc2019_64 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt $(which qmake).exe qt + qbs config defaultProfile qt + qbs config --list + shell: bash + - name: Print clcache stats + run: clcache -s + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + shell: bash + - name: Print clcache stats + run: clcache -s + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-windows-${{ github.run_id }}.zip + path: release/qbs-windows-${{ github.run_id }}.zip + + build-windows-mingw: + name: Build on Windows (MinGW) + runs-on: windows-2022 + timeout-minutes: 60 + env: + BUILD_OPTIONS: | + modules.cpp.compilerWrapper:ccache + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-windows-mingw-${{ github.run_id }} + products.qbs_archive.includeTests:true, + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + WITH_TESTS: 0 + CCACHE_DIR: ${{ github.workspace }}\ccache + steps: + - uses: actions/checkout@v1 + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + shell: bash + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ${{ github.workspace }}/ccache + key: ${{ runner.os }}-mingw-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-mingw-ccache- + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install required packages + run: | + choco install ccache + python -m pip install --upgrade pip + pip install beautifulsoup4 lxml + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: win64_mingw81 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + - name: Install MinGW + uses: ./.github/actions/download-mingw + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-toolchains --type mingw $(which g++).exe mingw-qt + qbs setup-qt $(which qmake).exe qt + qbs config profiles.qt.baseProfile mingw-qt + qbs config defaultProfile qt + qbs config --list + shell: bash + - name: Print ccache stats + run: ccache -s + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + shell: bash + - name: Print ccache stats + run: ccache -s + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-windows-mingw-${{ github.run_id }}.zip + path: release/qbs-windows-mingw-${{ github.run_id }}.zip + + test-linux: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: build-linux + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run Linux tests (gcc)', + image: 'focal', + profile: 'qt-gcc_64', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Linux tests (clang)', + image: 'focal', + profile: 'qt-clang_64', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Linux tests (gcc, Qt 6.0)', + image: 'focal-qt6', + profile: 'qt-gcc_64', + script: './scripts/test-qt.sh', + } + - { + name: 'Run Linux tests (gcc, Qt 6.3 static)', + image: 'focal-qt6-static', + profile: 'qt-gcc_64', + script: './scripts/test-qt.sh', + } + - { + name: 'Run Android tests (Qt 5.13)', + image: 'focal-android-513', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 5.14)', + image: 'focal-android-514', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 5.15)', + image: 'focal-android-515', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 6.0.0)', + image: 'focal-android-600', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 6.2.0)', + image: 'focal-android-620', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (Qt 6.3.0)', + image: 'focal-android-630', + profile: '', + script: './scripts/test-qt-for-android.sh', + } + - { + name: 'Run Android tests (ndk r19c)', + image: 'focal-android-ndk-r19c', + profile: '', + script: './scripts/test-for-android.sh', + } + - { + name: 'Run Android tests (ndk r21e)', + image: 'focal-android-ndk-r21e', + profile: '', + script: './scripts/test-for-android.sh', + } + - { + name: 'Run Android tests (ndk r23)', + image: 'focal-android-ndk-r23', + profile: '', + script: './scripts/test-for-android.sh', + } + - { + name: 'Run Linux tests (Qt 4.8.7)', + image: 'focal-qt4', + profile: '', + script: './scripts/test-qt4.sh', + } + + env: + QBS_TEST_SOURCE_ROOT: 'tests' + QBS_AUTOTEST_PROFILE: ${{ matrix.config.profile }} + QTEST_FUNCTION_TIMEOUT: 9000000 + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-linux-${{ github.run_id }}.tar.gz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xzf qbs-linux-${{ github.run_id }}.tar.gz -C release/install-root/ + - name: Pull the Docker Image + run: docker-compose pull ${{ matrix.config.image }} + - name: Run tests + run: docker-compose run ${{ matrix.config.image }} ${{ matrix.config.script }} release/install-root/usr/local/bin + + test-baremetal: + name: Run Baremetal tests (Linux) + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: build-linux + env: + QBS_TEST_SOURCE_ROOT: 'tests' + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-linux-${{ github.run_id }}.tar.gz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xzf qbs-linux-${{ github.run_id }}.tar.gz -C release/install-root/ + - name: Pull the Focal-Baremetal Image + run: docker-compose pull focal-baremetal + - name: arm-none-eabi-gcc-9_2 + run: QBS_AUTOTEST_PROFILE=arm-none-eabi-gcc-9_2 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: avr-gcc-5_4 + run: QBS_AUTOTEST_PROFILE=avr-gcc-5_4 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: msp430-gcc-4_6 + run: QBS_AUTOTEST_PROFILE=msp430-gcc-4_6 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: xtensa-lx106-elf-gcc-9_2 + run: QBS_AUTOTEST_PROFILE=xtensa-lx106-elf-gcc-9_2 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: riscv64-unknown-elf-gcc-9_3 + run: QBS_AUTOTEST_PROFILE=riscv64-unknown-elf-gcc-9_3 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: sdcc-3_8_0-mcs51 + run: QBS_AUTOTEST_PROFILE=sdcc-3_8_0-mcs51 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: sdcc-3_8_0-stm8 + run: QBS_AUTOTEST_PROFILE=sdcc-3_8_0-stm8 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + - name: sdcc-3_8_0-hcs8 + run: QBS_AUTOTEST_PROFILE=sdcc-3_8_0-hcs8 docker-compose run focal-baremetal scripts/test-baremetal.sh release/install-root/usr/local/bin + + test-baremetal-windows: + name: Run Baremetal tests (Windows) + runs-on: [self-hosted, windows, x64] + timeout-minutes: 30 + needs: build-windows + # baremetal VM is down, disable the workflow for now + if: 'false' + env: + QBS_TEST_SOURCE_ROOT: 'tests' + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + QTEST_FUNCTION_TIMEOUT: 9000000 + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-windows-${{ github.run_id }}.zip + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && unzip qbs-windows-${{ github.run_id }}.zip -d release/install-root/ + shell: bash + - name: keil-9_53_0-mcs51 + run: QBS_AUTOTEST_PROFILE=keil-9_53_0-mcs51 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: keil-5_60_0-mcs251 + run: QBS_AUTOTEST_PROFILE=keil-5_60_0-mcs251 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: keil-7_57_0-c166 + run: QBS_AUTOTEST_PROFILE=keil-7_57_0-c166 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: keil-5_30_0-arm + run: QBS_AUTOTEST_PROFILE=keil-5_30_0-arm scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: keil-llvm-5_30_0-arm + run: QBS_AUTOTEST_PROFILE=keil-5_30_0-arm scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-8_50_5-arm + run: QBS_AUTOTEST_PROFILE=iar-8_50_5-arm scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-10_30_1-mcs51 + run: QBS_AUTOTEST_PROFILE=iar-10_30_1-mcs51 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-7_30_1-avr + run: QBS_AUTOTEST_PROFILE=iar-7_30_1-avr scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-4_30_2-avr32 + run: QBS_AUTOTEST_PROFILE=iar-4_30_2-avr32 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-7_20_1-msp430 + run: QBS_AUTOTEST_PROFILE=iar-7_20_1-msp430 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-3_11_2_234-stm8 + run: QBS_AUTOTEST_PROFILE=iar-3_11_2_234-stm8 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-4_20_1-rx + run: QBS_AUTOTEST_PROFILE=iar-4_20_1-rx scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-4_20_1-rl78 + run: QBS_AUTOTEST_PROFILE=iar-4_20_1-rl78 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-5_10_1-v850 + run: QBS_AUTOTEST_PROFILE=iar-5_10_1-v850 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-2_21_1-rh850 + run: QBS_AUTOTEST_PROFILE=iar-2_21_1-rh850 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-2_30_1-sh + run: QBS_AUTOTEST_PROFILE=iar-2_30_1-sh scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-4_81_1-78k + run: QBS_AUTOTEST_PROFILE=iar-4_81_1-78k scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-4_10_1-hcs12 + run: QBS_AUTOTEST_PROFILE=iar-4_10_1-hcs12 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-1_40_2-r32c + run: QBS_AUTOTEST_PROFILE=iar-1_40_2-r32c scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-3_71_1-m16c + run: QBS_AUTOTEST_PROFILE=iar-3_71_1-m16c scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-1_21_1-riscv + run: QBS_AUTOTEST_PROFILE=iar-1_21_1-riscv scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: iar-3_30_1-cr16 + run: QBS_AUTOTEST_PROFILE=iar-3_30_1-cr16 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: sdcc-4_0_0-mcs51 + run: QBS_AUTOTEST_PROFILE=sdcc-4_0_0-mcs51 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: sdcc-4_0_0-stm8 + run: QBS_AUTOTEST_PROFILE=sdcc-4_0_0-stm8 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: sdcc-4_0_0-hcs8 + run: QBS_AUTOTEST_PROFILE=sdcc-4_0_0-hcs8 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: avr-gcc-4_6_2 + run: QBS_AUTOTEST_PROFILE=avr-gcc-4_6_2 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: avr32-gcc-4_4_3 + run: QBS_AUTOTEST_PROFILE=avr32-gcc-4_4_3 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: m32c-elf-gcc-4_7_3 + run: QBS_AUTOTEST_PROFILE=m32c-elf-gcc-4_7_3 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: m32r-elf-gcc-4_8_0 + run: QBS_AUTOTEST_PROFILE=m32r-elf-gcc-4_8_0 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: m68k-elf-gcc-4_8_0 + run: QBS_AUTOTEST_PROFILE=m68k-elf-gcc-4_8_0 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: msp430-elf-gcc-8_3_1 + run: QBS_AUTOTEST_PROFILE=msp430-elf-gcc-8_3_1 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: riscv64-unknown-elf-gcc-10_1_0 + run: QBS_AUTOTEST_PROFILE=riscv64-unknown-elf-gcc-10_1_0 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: v850-elf-gcc-4_7_2 + run: QBS_AUTOTEST_PROFILE=v850-elf-gcc-4_7_2 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: arm-none-eabi-gcc-9_3_1 + run: QBS_AUTOTEST_PROFILE=arm-none-eabi-gcc-9_3_1 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: xtensa-lx106-elf-gcc-5_2_0 + run: QBS_AUTOTEST_PROFILE=xtensa-lx106-elf-gcc-5_2_0 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: xtensa-esp32-elf-gcc-8_4_0 + run: QBS_AUTOTEST_PROFILE=xtensa-esp32-elf-gcc-8_4_0 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: rl78-elf-gcc-4_9_2_202002-GNURL78 + run: QBS_AUTOTEST_PROFILE=rl78-elf-gcc-4_9_2_202002-GNURL78 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: rx-elf-gcc-8_3_0_202004-GNURX + run: QBS_AUTOTEST_PROFILE=rx-elf-gcc-8_3_0_202004-GNURX scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: cosmic-4_3_11-arm + run: QBS_AUTOTEST_PROFILE=cosmic-4_3_11-arm scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: cosmic-4_5_2-stm8 + run: QBS_AUTOTEST_PROFILE=cosmic-4_5_2-stm8 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: cosmic-4_6_3-hcs8 + run: QBS_AUTOTEST_PROFILE=cosmic-4_6_3-hcs8 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: cosmic-4_8_11-hcs12 + run: QBS_AUTOTEST_PROFILE=cosmic-4_8_11-hcs12 scripts/test-baremetal.sh release/install-root/bin + shell: bash + - name: cosmic-4_1_0-m68k + run: QBS_AUTOTEST_PROFILE=cosmic-4_1_0-m68k scripts/test-baremetal.sh release/install-root/bin + shell: bash + + test-macos: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.runner }} + timeout-minutes: 60 + needs: build-macos + env: + QTEST_FUNCTION_TIMEOUT: 9000000 + QBS_AUTOTEST_PROFILE: 'qt' + QBS_TEST_SOURCE_ROOT: 'tests' + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run macOS tests (Xcode 13.4)', + runner: 'macos-12', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_13_4-macosx-x86_64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run macOS tests (Xcode 13.4, Qt 6.3)', + runner: 'macos-12', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_13_4-macosx-x86_64', + qtVersion: '6.3.1', + script: './scripts/test-qt.sh', + } + - { + name: 'Run iOS tests (Xcode 13.4)', + runner: 'macos-12', + target: 'ios', + toolchain: 'ios', + testProfile: 'xcode_13_4-iphoneos-arm64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run iOS-sim tests (Xcode 13.4)', + runner: 'macos-12', + target: 'ios', + toolchain: 'ios', + testProfile: 'xcode_13_4-iphonesimulator-x86_64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run macOS tests (Xcode 12.5)', + runner: 'macos-11.0', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_12_5_1-macosx-x86_64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run macOS tests (Xcode 11.7)', + runner: 'macos-11.0', + target: 'desktop', + toolchain: 'clang_64', + testProfile: 'xcode_11_7-macosx-x86_64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-macos-${{ github.run_id }}.tar.gz + path: ./ + - name: Unpack artifact + run: mkdir -p release/install-root/ && tar xzf qbs-macos-${{ github.run_id }}.tar.gz -C release/install-root/ + - name: Update PATH + run: echo "./release/install-root/usr/local/bin" >> $GITHUB_PATH + - name: Install required packages + run: brew install capnp ccache grpc icoutils makensis protobuf p7zip + - name: Install Qt + uses: ./.github/actions/download-qt + with: + target: ${{ matrix.config.target }} + toolchain: ${{ matrix.config.toolchain }} + version: ${{ matrix.config.qtVersion }} + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt $(which qmake) qt + qbs config profiles.qt.baseProfile ${{ matrix.config.testProfile }} + qbs config defaultProfile qt + qbs config --list + - name: Run Tests + run: | + sudo chmod g+w /cores + ulimit -c unlimited + ${{ matrix.config.script }} ./release/install-root/usr/local/bin + - name: Coredump on failure + if: ${{ failure() }} + run: | + for f in $(find /cores -maxdepth 1 -name 'core.*' -print); do + lldb --core $f --batch --one-line "bt" + done; + + test-windows: + name: ${{ matrix.config.name }} + runs-on: windows-2019 + timeout-minutes: 60 + needs: build-windows + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run Windows tests (MSVC 2019)', + target: 'desktop', + toolchain: 'win64_msvc2019_64', + testProfile: 'MSVC2019-x64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Windows tests (MSVC 2019, Qt 6.0.2)', + target: 'desktop', + toolchain: 'win64_msvc2019_64', + testProfile: 'MSVC2019-x64', + qtVersion: '6.0.2', + script: './scripts/test-qt.sh', + } + - { + name: 'Run Windows tests (clang-cl)', + target: 'desktop', + toolchain: 'win64_msvc2019_64', + testProfile: 'clang-cl-x86_64', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + - { + name: 'Run Windows tests (MinGW)', + target: 'desktop', + toolchain: 'win64_mingw81', + testProfile: 'mingw-qt', + qtVersion: '5.15.2', + script: './scripts/test-qbs.sh', + } + env: + QTEST_FUNCTION_TIMEOUT: 9000000 + QBS_AUTOTEST_PROFILE: 'qt' + QBS_TEST_SOURCE_ROOT: 'tests' + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-windows-${{ github.run_id }}.zip + path: ./ + - name: Unpack artifact + run: | + mkdir -p release/install-root + cd release/install-root + 7z x ../../qbs-windows-${{ github.run_id }}.zip + shell: bash + - name: Update PATH + run: echo "./release/install-root/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install required packages + run: choco install -y pkgconfiglite --download-checksum=6004df17818f5a6dbf19cb335cc92702 + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: ${{ matrix.config.toolchain }} + version: ${{ matrix.config.qtVersion }} + - name: Install MinGW + uses: ./.github/actions/download-mingw + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-toolchains --type mingw $(which g++).exe mingw-qt + qbs setup-qt $(which qmake).exe qt + qbs config profiles.qt.baseProfile ${{ matrix.config.testProfile }} + qbs config defaultProfile qt + qbs config --list + shell: bash + - name: Setup self-signed certificate + run: | + New-SelfSignedCertificate -DnsName qbs@community.test -Type CodeSigning -CertStoreLocation cert:\CurrentUser\My + Export-Certificate -Cert (Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert)[0] -FilePath qbs-code-signing.crt + Import-Certificate -FilePath .\qbs-code-signing.crt -CertStoreLocation Cert:\CurrentUser\TrustedPublisher + shell: powershell + - name: Run Tests + run: ${{ matrix.config.script }} ./release/install-root/bin + shell: bash + + test-windows-extra: + name: ${{ matrix.config.name }} + runs-on: windows-latest + timeout-minutes: 60 + needs: build-windows + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Run Windows tests (OpenWatcom DOS 32 bit)', + testProfile: 'watcom-2_0_0-dos-x86', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (OpenWatcom DOS 16 bit)', + testProfile: 'watcom-2_0_0-dos-x86_16', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (OpenWatcom OS/2 32 bit)', + testProfile: 'watcom-2_0_0-os2-x86', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (OpenWatcom OS/2 16 bit)', + testProfile: 'watcom-2_0_0-os2-x86_16', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (OpenWatcom Windows 32 bit)', + testProfile: 'watcom-2_0_0-windows-x86', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (OpenWatcom Windows 16 bit)', + testProfile: 'watcom-2_0_0-windows-x86_16', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (DigitalMars DOS 16 bit)', + testProfile: 'dmc-8_57_0-dos-x86_16', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (DigitalMars Windows 32 bit)', + testProfile: 'dmc-8_57_0-windows-x86', + script: './scripts/test-baremetal.sh', + } + - { + name: 'Run Windows tests (DigitalMars Windows 16 bit)', + testProfile: 'dmc-8_57_0-windows-x86_16', + script: './scripts/test-baremetal.sh', + } + env: + QTEST_FUNCTION_TIMEOUT: 9000000 + QBS_AUTOTEST_PROFILE: 'extra' + QBS_TEST_SOURCE_ROOT: 'tests' + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + steps: + - uses: actions/checkout@v1 + - name: Download artifact + uses: actions/download-artifact@v1 + with: + name: qbs-windows-${{ github.run_id }}.zip + path: ./ + - name: Unpack artifact + run: | + mkdir -p release/install-root + cd release/install-root + 7z x ../../qbs-windows-${{ github.run_id }}.zip + shell: bash + - name: Update PATH + run: echo "./release/install-root/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Install required packages + run: choco install -y pkgconfiglite --download-checksum=6004df17818f5a6dbf19cb335cc92702 + - name: Install OpenWatcom + uses: ./.github/actions/download-ow + - name: Install DigitalMars + uses: ./.github/actions/download-dm + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs config profiles.extra.baseProfile ${{ matrix.config.testProfile }} + qbs config defaultProfile extra + qbs config --list + shell: bash + - name: Run Tests + run: ${{ matrix.config.script }} ./release/install-root/bin + shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..6c99c35d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,246 @@ +name: Build release packages + +on: + push: + branches-ignore: + - 'gerrit/*' + tags: + - 'v*' + +jobs: + build-linux: + name: ${{ matrix.config.name }} + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + config: + - { + name: 'Build on Linux (gcc)', + options: 'qbs.installPrefix:"" + modules.cpp.compilerWrapper:ccache + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbsbuildconfig.enableUnitTests:false + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-linux-${{ github.run_id }}', + script: './scripts/build-qbs-with-qbs.sh', + cacheid: 'gcc-release', + } + env: + BUILD_OPTIONS: ${{ matrix.config.options }} + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: test + run: echo ${{ github.ref }} + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-${{ matrix.config.cacheid }}-ccache- + - name: Pull the Focal Image + run: docker-compose pull focal + - name: Print ccache stats + run: docker-compose run focal ccache -s + - name: Build Qbs + run: docker-compose run focal ${{ matrix.config.script }} + - name: Print ccache stats + run: docker-compose run focal ccache -s + - name: Get archive name + id: get-archive-name + run: echo ::set-output name=archive-name::$(git describe) + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-linux-${{ github.run_id }}.tar.gz + path: release/qbs-linux-${{ github.run_id }}.tar.gz + + build-macos: + name: Build on macOS + runs-on: macos-10.15 + timeout-minutes: 60 + env: + BUILD_OPTIONS: | + qbs.installPrefix:"" + modules.cpp.compilerWrapper:ccache + modules.qbsbuildconfig.enableUnitTests:false + modules.qbsbuildconfig.enableAddressSanitizer:false + modules.qbsbuildconfig.enableBundledQt:true + products.qbs_archive.targetName:qbs-macos-${{ github.run_id }} + WITH_TESTS: 0 + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + - name: ccache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-release-ccache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-release-ccache- + - name: Install required packages + run: | + brew install ccache p7zip + python3 -m pip install --user beautifulsoup4 lxml + - name: Install Qt + uses: ./.github/actions/download-qt + with: + toolchain: clang_64 + - name: Install Qt Creator + uses: ./.github/actions/download-qtc + with: + version: 5.0.3 + - name: Setup Qbs + run: | + qbs setup-toolchains --detect + qbs setup-qt --detect + qbs config profiles.qt.baseProfile xcode-macosx-x86_64 + qbs config defaultProfile qt + qbs config --list + - name: Print ccache stats + run: ccache -s + - name: Build Qbs + run: scripts/build-qbs-with-qbs.sh + - name: Print ccache stats + run: ccache -s + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-macos-${{ github.run_id }}.tar.gz + path: release/qbs-macos-${{ github.run_id }}.tar.gz + + build-windows-with-docker: + name: Build on Windows (Docker) + runs-on: windows-2019 + timeout-minutes: 60 + env: + WITH_TESTS: 0 + QT_ASSUME_STDERR_HAS_CONSOLE: 1 + CLCACHE_DIR: C:\.ccache + steps: + - uses: actions/checkout@v1 + - name: Create .ccache dir + run: mkdir -p ~/.ccache + shell: bash + - name: prepare timestamp + id: get-timestamp + run: echo ::set-output name=timestamp::$(date -u +"%Y-%m-%dT%H:%M:%SZ") + shell: bash + - name: clcache cache files + uses: actions/cache@v2 + with: + path: ~/.ccache + key: ${{ runner.os }}-release-msvc-docker-clcache-${{ steps.get-timestamp.outputs.timestamp }} + restore-keys: ${{ runner.os }}-release-msvc-docker-clcache- + - name: Pull the Windows Image + run: docker-compose pull windows + - name: Print clcache stats + run: docker-compose run --rm windows clcache -s + - name: Build Qbs + run: > + docker-compose run --rm windows qbs build + -p dist + qbs.buildVariant:release + modules.cpp.compilerWrapper:clcache + modules.qbsbuildconfig.enableBundledQt:true + modules.qbsbuildconfig.enableUnitTests:false + modules.cpp.treatWarningsAsErrors:true + project.withDocumentation:true + config:release-64 profile:qt64 + config:release profile:qt + - name: Print clcache stats + run: docker-compose run --rm windows clcache -s + - name: Get archive name + id: get-archive-name + run: echo ::set-output name=archive-name::$(git describe) + shell: bash + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-windows-${{ github.run_id }} + path: | + release/qbs.*.nupkg + release/qbs-windows-*.zip + release-64/qbs-windows-*.zip + + create-archives: + name: Create Archives + runs-on: ubuntu-latest + needs: [build-linux, build-windows-with-docker] + steps: + - uses: actions/checkout@v1 + with: + submodules: true + - name: Get version name + id: get-version-name + run: echo ::set-output name=version-name::$(cat VERSION) + - name: Create directories + run: | + mkdir release + mkdir tmp + - name: Copy sources + run: rsync -av --exclude='.git/' --exclude='tmp/' --exclude='src/shared/qtscript/.git' . ./tmp/qbs-src-${{ steps.get-version-name.outputs.version-name }} + - name: Zip Archive + run: | + cd tmp/ + zip -r ../release/qbs-src-${{ steps.get-version-name.outputs.version-name }}.zip qbs-src-${{ steps.get-version-name.outputs.version-name }} + - name: Tarball Archive + run: | + cd tmp/ + tar czf ../release/qbs-src-${{ steps.get-version-name.outputs.version-name }}.tar.gz qbs-src-${{ steps.get-version-name.outputs.version-name }} + - name: Download Linux artifacts + uses: actions/download-artifact@v1 + with: + name: qbs-linux-${{ github.run_id }}.tar.gz + path: ./tmp + - name: Repack Linux artifact + run: | + mkdir -p tmp/qbs-linux-x86_64-${{ steps.get-version-name.outputs.version-name }} + tar xzf ./tmp/qbs-linux-${{ github.run_id }}.tar.gz -C tmp/qbs-linux-x86_64-${{ steps.get-version-name.outputs.version-name }} + cd tmp/ + tar czf ../release/qbs-linux-x86_64-${{ steps.get-version-name.outputs.version-name }}.tar.gz qbs-linux-x86_64-${{ steps.get-version-name.outputs.version-name }} + - name: Download Windows artifacts + uses: actions/download-artifact@v1 + with: + name: qbs-windows-${{ github.run_id }} + path: ./tmp + - name: Copy Windows artifacts + run: | + cp ./tmp/release/qbs.*.nupkg ./release + cp ./tmp/release/qbs-windows-x86-*.zip ./release + cp ./tmp/release-64/qbs-windows-x86_64-*.zip ./release + - name: Copy changelog + run: cp changelogs/changes-${{ steps.get-version-name.outputs.version-name }}.md release || echo "changelog not found" + - name: Generate checksums + run: | + cd release/ + find . -type f -printf '%f\n' | grep -v .txt | xargs md5sum > md5sums.txt + find . -type f -printf '%f\n' | grep -v .txt | xargs sha256sum > sha256sums.txt + - name: Get archive name + id: get-archive-name + run: echo ::set-output name=archive-name::$(git describe) + - name: Upload artifacts + uses: 'actions/upload-artifact@v2' + with: + name: qbs-release-${{ steps.get-archive-name.outputs.archive-name }} + path: | + release/qbs-src-*.zip + release/qbs-src-*.tar.gz + release/qbs-linux-*.tar.gz + release/qbs.*.nupkg + release/qbs-windows-x86-*.zip + release/qbs-windows-x86_64-*.zip + release/changes-*.md + release/md5sums.txt + release/sha256sums.txt + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bd27569d --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +.qmake.cache +.qmake.stash +.qbs +.vscode* +build +*.dll +*.dylib +*.exe +*.exp +*.ilk +*.manifest +*.obj +*.pdb +*.pro.user* +*.qbs.user* +CMakeLists.txt.user* +*.xcodeproj/ +target_wrapper.sh +*~ +*.o +*.lib +*.so +moc_*.cpp +qrc_*.cpp +*.moc +*.qch +*.a +*.cpp.orig +ui_*.h + +Makefile* +debug/ +release/ +/tests/auto/blackbox/testWorkDir +/tests/auto/blackbox/tst_blackbox +/tests/auto/buildgraph/tst_buildgraph +/tests/auto/language/tst_language +/tests/auto/tools/tst_tools + +*.app/ +*_resource.rc +bin/* +doc/qbs/html/* +/lib diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..f2f854c1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "qtscript"] + path = src/shared/qtscript + url = ../../qt/qtscript.git diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..dc306c9f --- /dev/null +++ b/.mailmap @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..4129bc91 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 3.10) + +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") + cmake_policy(VERSION 3.15) +endif() + +## Add paths to check for cmake modules: +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(FeatureSummary) +include(QbsBuildConfig) +include(QbsDocumentation) + +file(STRINGS VERSION QBS_VERSION) +project(Qbs VERSION ${QBS_VERSION}) + +# Force C++ standard, do not fall back, do not use compiler extensions +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Set up Qt stuff: +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) + +if(WITH_TESTS) + enable_testing() + set(QT_TEST_COMPONENT Test) + set(IMPLICIT_DEPENDS Qt${QT_VERSION_MAJOR}::Test) +endif() + +find_package(Qt${QT_VERSION_MAJOR} + COMPONENTS Concurrent Core Gui Network Widgets Xml ${QT_TEST_COMPONENT} + REQUIRED + ) + +find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS Script QUIET) + +if (Qt6_FOUND) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core5Compat REQUIRED) + if(NOT TARGET Qt6Core5Compat) + set_property(TARGET Qt6::Core5Compat PROPERTY IMPORTED_GLOBAL TRUE) # hack for CMake < 1.18 + add_library(Qt6Core5Compat ALIAS Qt6::Core5Compat) + endif() +else() + if(NOT TARGET Qt6Core5Compat) + add_library(Qt6Core5Compat INTERFACE) + endif() + if (NOT QBS_USE_BUNDLED_QT_SCRIPT AND Qt5Script_FOUND) + add_library(qbsscriptengine INTERFACE) + target_link_libraries(qbsscriptengine INTERFACE Qt5::Script) + endif() +endif() + +if (QBS_INSTALL_HTML_DOCS OR QBS_INSTALL_QCH_DOCS) + find_package(Python3 COMPONENTS Interpreter) + if (Qt6_FOUND) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Tools REQUIRED) + else() + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Help REQUIRED) + endif() +endif() + +add_subdirectory(src) +add_subdirectory(doc) +add_subdirectory(share) +if(WITH_TESTS) + add_subdirectory(tests) +endif() diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..1a8a8877 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,102 @@ +# Contributing to Qbs + +The main source code repository is hosted at +[codereview.qt-project.org](https://codereview.qt-project.org/q/project:qbs/qbs). + +The Qbs source code is also mirrored on [code.qt.io](https://code.qt.io/cgit/qbs/qbs.git/) +and on [GitHub](https://github.com/qbs/qbs). Please note that those mirrors +are read-only and we do not accept pull-requests on GitHub. However, we gladly +accept contributions via [Gerrit](https://codereview.qt-project.org/q/project:qbs/qbs). + +This document briefly describes steps required to be able to propose changes +to the Qbs project. + +See the [Qt Contribution Guidelines](https://wiki.qt.io/Qt_Contribution_Guidelines) +page, [Setting up Gerrit](https://wiki.qt.io/Setting_up_Gerrit) and +[Gerrit Introduction](https://wiki.qt.io/Gerrit_Introduction) for more +details about how to upload patches to Gerrit. + +## Preparations + +* [Set up](https://wiki.qt.io/Setting_up_Gerrit#How_to_get_started_-_Gerrit_registration) +a Gerrit account +* Tweak your SSH config as instructed [here](https://wiki.qt.io/Setting_up_Gerrit#Local_Setup) +* Use the recommended Git settings, defined [here](https://wiki.qt.io/Setting_up_Gerrit#Configuring_Git) +* Get the source code as described below + +## Cloning Qbs + +Clone Qbs from the [code.qt.io](https://code.qt.io/cgit/qbs/qbs.git/) mirror +``` +git clone git://code.qt.io/qbs/qbs.git +``` +Alternatively, you can clone from the mirror on the [GitHub](https://github.com/qbs/qbs) +``` +git clone https://github.com/qbs/qbs.git +``` + +Set up the Gerrit remote +``` +git remote add gerrit ssh://@codereview.qt-project.org:29418/qbs/qbs +``` + +## Setting up git hooks + +Install the hook generating Commit-Id files into your top level project directory: +``` +gitdir=$(git rev-parse --git-dir); scp -p -P 29418 codereview.qt-project.org:hooks/commit-msg "${gitdir}/hooks/" +``` + +This hook automatically adds a "Change-Id: …" line to the commit message. Change-Id is used +to identify new Patch Sets for existing +[Changes](https://wiki.qt.io/Gerrit_Introduction#Terminology). + +## Making changes + +Commit your changes in the usual way you do in Git. + +After making changes, you might want to ensure that Qbs can be built and autotests pass: +``` +qbs build -p autotest-runner +``` +See ["Appendix A: Building Qbs"](http://doc.qt.io/qbs/building-qbs.html) for details. + +In case your changes might significantly affect performance (in either way), the +'qbs_benchmarker' tool can be used (Linux only, requires Valgrind to be installed): +``` +qbs_benchmarker -r -o -n -a -p +``` +Use 'qbs_benchmarker --help' for details. + +## Pushing your changes to Gerrit + +After committing your changes locally, push them to Gerrit + +``` +git push gerrit HEAD:refs/for/master +``` + +Gerrit will print a URL that can be used to access the newly created Change. + +## Adding reviewers + +Use the "ADD REVIEWER" button on the Change's web page to ask people to do the +review. To find possible reviewers, you can examine the Git history with +'git log' and/or 'git blame' or ask on the mailing list: qbs@qt-project.org + +## Modifying Commits + +During the review process, it might be necessary to do some changes to the commit. +To include you changes in the last commit, use +``` +git commit --amend +``` +This will edit the last commit instead of creating a new one. Make sure to preserve the +Change-Id footer when amending commits. For details, see +[Updating a Contribution With New Code](https://wiki.qt.io/Gerrit_Introduction#Updating_a_Contribution_With_New_Code) + +## Abandoning changes + +Changes which are inherently flawed or became inapplicable should be abandoned. You can do that +on the Change's web page with the "ABANDON" button. Make sure to remove the abandoned commit +from your working copy by using '[git reset](https://git-scm.com/docs/git-reset)'. diff --git a/LGPL_EXCEPTION.txt b/LGPL_EXCEPTION.txt new file mode 100644 index 00000000..918157a3 --- /dev/null +++ b/LGPL_EXCEPTION.txt @@ -0,0 +1,22 @@ +The Qt Company LGPL Exception version 1.1 + +As an additional permission to the GNU Lesser General Public License version +2.1, the object code form of a "work that uses the Library" may incorporate +material from a header file that is part of the Library. You may distribute +such object code under terms of your choice, provided that: + (i) the header files of the Library have not been modified; and + (ii) the incorporated material is limited to numerical parameters, data + structure layouts, accessors, macros, inline functions and + templates; and + (iii) you comply with the terms of Section 6 of the GNU Lesser General + Public License version 2.1. + +Moreover, you may apply this exception to a modified version of the Library, +provided that such modification does not involve copying material from the +Library into the modified Library's header files unless such material is +limited to (i) numerical parameters; (ii) data structure layouts; +(iii) accessors; and (iv) small macros, templates and inline functions of +five lines or less in length. + +Furthermore, you are not required to apply this additional permission to a +modified version of the Library. diff --git a/LICENSE.GPL3-EXCEPT b/LICENSE.GPL3-EXCEPT new file mode 100644 index 00000000..b1cb1bec --- /dev/null +++ b/LICENSE.GPL3-EXCEPT @@ -0,0 +1,704 @@ +This is the GNU General Public License version 3, annotated with The +Qt Company GPL Exception 1.0: + +------------------------------------------------------------------------- + +The Qt Company GPL Exception 1.0 + +Exception 1: + +As a special exception you may create a larger work which contains the +output of this application and distribute that work under terms of your +choice, so long as the work is not otherwise derived from or based on +this application and so long as the work does not in itself generate +output that contains the output from this application in its original +or modified form. + +Exception 2: + +As a special exception, you have permission to combine this application +with Plugins licensed under the terms of your choice, to produce an +executable, and to copy and distribute the resulting executable under +the terms of your choice. However, the executable must be accompanied +by a prominent notice offering all users of the executable the entire +source code to this application, excluding the source code of the +independent modules, but including any changes you have made to this +application, under the terms of this license. + + +------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/LICENSE.LGPLv21 b/LICENSE.LGPLv21 new file mode 100644 index 00000000..602bfc94 --- /dev/null +++ b/LICENSE.LGPLv21 @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3 new file mode 100644 index 00000000..509cc641 --- /dev/null +++ b/LICENSE.LGPLv3 @@ -0,0 +1,173 @@ + GNU LESSER GENERAL PUBLIC LICENSE + + The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. + Contact: http://www.qt.io/licensing + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + GNU Lesser General Public License version 3, which is displayed below. + +------------------------------------------------------------------------- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright © 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies of this +licensedocument, but changing it is not allowed. + +This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + +0. Additional Definitions. + + As used herein, “this License” refers to version 3 of the GNU Lesser +General Public License, and the “GNU GPL” refers to version 3 of the +GNU General Public License. + + “The Library” refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An “Application” is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A “Combined Work” is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the “Linked +Version”. + + The “Minimal Corresponding Source” for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The “Corresponding Application Code” for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + +1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + +2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort + to ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + +3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this + license document. + +4. Combined Works. + + You may convey a Combined Work under terms of your choice that, taken +together, effectively do not restrict modification of the portions of +the Library contained in the Combined Work and reverse engineering for +debugging such modifications, if you also do each of the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this + license document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of + this License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with + the Library. A suitable mechanism is one that (a) uses at run + time a copy of the Library already present on the user's + computer system, and (b) will operate properly with a modified + version of the Library that is interface-compatible with the + Linked Version. + + e) Provide Installation Information, but only if you would + otherwise be required to provide such information under section 6 + of the GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the Application + with a modified version of the Linked Version. (If you use option + 4d0, the Installation Information must accompany the Minimal + Corresponding Source and Corresponding Application Code. If you + use option 4d1, you must provide the Installation Information in + the manner specified by section 6 of the GNU GPL for conveying + Corresponding Source.) + +5. Combined Libraries. + + You may place library facilities that are a work based on the Library +side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities, conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of + it is a work based on the Library, and explaining where to find + the accompanying uncombined form of the same work. + +6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +as you received it specifies that a certain numbered version of the +GNU Lesser General Public License “or any later version” applies to +it, you have the option of following the terms and conditions either +of that published version or of any later version published by the +Free Software Foundation. If the Library as you received it does not +specify a version number of the GNU Lesser General Public License, +you may choose any version of the GNU Lesser General Public License +ever published by the Free Software Foundation. + +If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the Library. + diff --git a/README.md b/README.md new file mode 100644 index 00000000..c56d8c21 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Qbs + +Qbs is a build automation tool designed to conveniently manage the build +process of software projects across multiple platforms. Qbs can be used for any +software project, regardless of programming language, toolkit, or libraries used. + +## Documentation + +Qbs product documentation is available at [doc.qt.io/qbs](http://doc.qt.io/qbs/index.html) + +The project's homepage is [wiki.qt.io/qbs](http://wiki.qt.io/qbs) + +## Supported platforms + +Qbs binaries are available for Windows, macOS, Linux, and FreeBSD. + +For more information about how to install Qbs on your platform, see the +[Installing](https://doc.qt.io/qbs/installing.html) page in the documentation. + +Qbs allows to build applications for different platforms, for the list of +supported platforms and the details about each platform, see the +[Target Platforms](https://doc.qt.io/qbs/platforms.html) page. + +## Building Qbs + +For information about building Qbs from sources, see +["Appendix A: Building Qbs"](http://doc.qt.io/qbs/building-qbs.html). + +## Reporting Bugs + +Please report any bugs in our [bug tracker](https://bugreports.qt.io/browse/QBS). + +## Contributing + +See [Contributing to Qbs](CONTRIBUTING.md) + diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..49e0a31d --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.23.1 diff --git a/bin/ibmsvc.xml b/bin/ibmsvc.xml new file mode 100644 index 00000000..cea5990c --- /dev/null +++ b/bin/ibmsvc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/bin/ibqbs.bat b/bin/ibqbs.bat new file mode 100644 index 00000000..0e1cb2bd --- /dev/null +++ b/bin/ibqbs.bat @@ -0,0 +1 @@ +@xgConsole /profile=%~dp0\ibmsvc.xml /command="qbs -j 20 %*" diff --git a/changelogs/changes-1.10.0.md b/changelogs/changes-1.10.0.md new file mode 100644 index 00000000..ce4bf500 --- /dev/null +++ b/changelogs/changes-1.10.0.md @@ -0,0 +1,43 @@ +# General +* Added the `vcs` module to provide VCS repository information. + Git and Subversion are supported initially. +* Added initial support for the Universal Windows Platform. +* Improved a lot of error messages. + +# Language +* Profiles can now be defined within a project using the `Profile` item. +* Groups without a prefix now inherit the one of the parent group. +* Both the `Module` and the `FileTagger` item now have a `priority` property, allowing them to + override conflicting instances. +* It is now possible to add file tags to generated artifacts by setting the new `fileTags` property + in a group that has a `fileTagsFilter`. +* Added new open mode `TextFile.Append`. +* Added the `filePath` function to the `TextFile` class. +* `Process` and `TextFile` objects in rules, commands and configure scripts are now + closed automatically after script execution. + +# C/C++ Support +* Added the `cpufeatures` module for abstracting compiler flags related to CPU features such as SSE. +* Added property `cpp.discardUnusedData` abstracting linker options that strip unneeded symbols + or sections. +* Added property `cpp.variantSuffix` for making binary names unique when multiplexing products. +* Added property `cpp.compilerDefinesByLanguage` providing the compiler's pre-defined macros. + +# Android +* The deprecated `apkbuilder` tool is no longer used. + +# Qt +* Added support for the Qt Quick compiler. +* Added support for `qmlcachegen`. + +# Command-line interface +* Removed some non-applicable options from a number of tools. +* The `run` command can now deploy and run Android apps on devices, and deploy and run iOS and + tvOS apps on the simulator. +* Added new command `list-products`. + +# Documentation +* Added porting guide for qmake projects. +* Added in-depth descriptions of all command-line tools. +* Added "How-to" for creating modules for third-party libraries. +* Added a man page. diff --git a/changelogs/changes-1.10.1.md b/changelogs/changes-1.10.1.md new file mode 100644 index 00000000..d0f68a89 --- /dev/null +++ b/changelogs/changes-1.10.1.md @@ -0,0 +1,11 @@ +# Important bugfixes +* Fix assertion on project loading (QBS-1275). +* Fix crash when the "original" value is misused (QBS-1255). +* Fix qtquickcompiler support for qml files in subdirectories (QBS-1261). +* Fix constant rebuilding after moving an external header file (QBS-1285). +* Fix GCC support for "bare metal" systems (QBS-1263, QBS-1265). +* Fix using ids in Depends items (QBS-1264). +* Fix access to module instances in dependency parameters (QBS-1253). +* Fix race condition when creating Inno Setup, NSIS, or WiX installers. +* Fix release builds for Android with NDK r12 and above (QBS-1256). +* Fix parametrized dependencies in Export and Module items (QBS-1287). diff --git a/changelogs/changes-1.11.0.md b/changelogs/changes-1.11.0.md new file mode 100644 index 00000000..028db51d --- /dev/null +++ b/changelogs/changes-1.11.0.md @@ -0,0 +1,57 @@ +# General +* Added `qbs.targetPlatform` and `qbs.hostPlatform` properties which are scalar versions of + `qbs.targetOS` and `qbs.hostOS`. `qbs.targetPlatform` is a "write-only" property that can be used + to set the OS/platform that is being targeted, while `qbs.targetOS` and `qbs.hostOS` should + continue to be used to *read* the OS/platform that is being targeted. + `qbs.targetOS` is also now read-only. +* The "run" functionality as used by the command-line command of the same name now considers + an executable's library dependencies, that is, it adds the paths they are located in to the + respective environment variable (e.g. PATH on Windows). + +# Language +* Modules can now declare target artifacts using the new `filesAreTargets` property of the + `Group` item. +* The Module.setupRunEnvironment script now has a new parameter `config`. Users can set it via the + `--setup-run-env-config` option of the `run` command. The only value currently supported + is `ignore-lib-dependencies`, which turns off the abovementioned injection of library + dependencies' paths into the run environment. +* Module.setupBuildEnvironment and Module.setupRunEnvironment now have access to the `product` + and `project` variables. With regards to accessing module properties, these script now behave + like rules, rather than normal properties. +* Added the `BinaryFile` service for reading and writing binary data files. +* The `SubProject` item now has a condition property. + +# C/C++ Support +* Added property `cpp.rpathOrigin` which evaluates to `@loader_path` on Darwin and `$ORIGIN` + on other Unix-like platforms. +* Added the `qbs.toolchainType` property, which is a scalar version of the `qbs.toolchain` + property and is used to set the current toolchain. +* Added `cpp.driverLinkerFlags` for flags to be passed to the compiler driver only when linking. +* We now properly support `"c++17"` as a possible value of `cpp.cxxLanguageVersion`. +* The auto-detection mechanism for GCC-like compilers now considers typical mingw prefixes. + +# Qt Support +* Added the Qt.scxml.generateStateMethods property to back the --statemethods option. + +# Command-line interface +* Configuration names are now passed as "config:". +* Options do not have to precede property assignments anymore. +* Referencing a non-existing product in a property override now results in an error. + +# Documentation +* Major overhaul of the module and item reference for improved readability. +* Added a how-to on the topic of pre-compiled headers. +* Added documentation for the built-in XML support. +* Added documentation for qbs.Utilities. +* Added documentation on how to target specific platforms. + +# Important bug fixes +* Fixed some inconsistencies related to item ids (QBS-1016, QBS-1262). +* Fixed slow project resolving on macOS (QBS-1277). +* Fixed problems with qtquickcompiler support in Qt 5.11 (QBS-1299). +* Fixed race conditions in multi-configuration builds (QBS-1308). + +# Other +* The `InnoSetup`, `nsis`, and `wix` modules' rules now have a dependency on installable artifacts + of dependencies. +* Introduced the `ico` module for creating .ico and .cur files. diff --git a/changelogs/changes-1.11.1.md b/changelogs/changes-1.11.1.md new file mode 100644 index 00000000..e2851850 --- /dev/null +++ b/changelogs/changes-1.11.1.md @@ -0,0 +1,5 @@ +# Important bugfixes +* Speed up run environment setup (QTCREATORBUG-20175). +* Fix qbs command line generated by the Visual Studio project generator (QBS-1303). +* Install all required header files when building Qbs with qmake. +* Fix undefined behavior in the qbscore library where a reference to a temporary object was stored. diff --git a/changelogs/changes-1.12.0.md b/changelogs/changes-1.12.0.md new file mode 100644 index 00000000..6c88d35b --- /dev/null +++ b/changelogs/changes-1.12.0.md @@ -0,0 +1,41 @@ +# General +* Added new module `Exporter.qbs` for creating qbs modules from products. +* Added new module `Exporter.pkgconfig` for creating pkg-config metadata files. +* Introduced the concept of system-level qbs settings. +* Added a Makefile generator. +* All command descriptions now contain the product name. + +# Language +* The `explicitlyDependsOn` property of the `Rule` item no longer considers + target artifacts of product dependencies. The new property `explicitlyDependsOnFromDependencies` + can be used for that purpose. +* The `excludedAuxiliaryInputs` property of the `Rule` item has + been renamed to `excludedInputs`. The old name is now deprecated. +* Added a new property type `varList`. +* Added `FileInfo.suffix` and `FileInfo.completeSuffix`. +* The deprecated JS extensions `XmlDomDocument` and `XmlDomElement` + have been removed. Use `Xml.DomDocument` and `Xml.DomDocument` instead. + +# C/C++ Support +* For MSVC static libraries, compiler-generated PDB files are + now tagged as `debuginfo_cl` to make them installable. +* The `cxxLanguageVersion` property can now be set to different values in different modules, + and the highest value will be chosen. + +# Qt Support +* Amalgamation builds work properly now in the presence of "mocable" files. +* Fixed some redundancy on the linker command line. + +# Other modules +* Added support for `%option outfile` and `%output` to the `lex_yacc` module. +* The `vcs` module now creates the header file even if no repository is present. + +# Autotest support +* Added an `auxiliaryInputs` property to the `AutotestRunner` item for specifying run-time + dependencies of test executables. +* The `AutotestRunner` item now has a `workingDirectory` property. + By default, the respective test executable's location is used. + +# Important bug fixes +* Disabled products no longer cause their exported dependencies to get pulled into + the importing product (QBS-1250). diff --git a/changelogs/changes-1.12.1.md b/changelogs/changes-1.12.1.md new file mode 100644 index 00000000..d9f10594 --- /dev/null +++ b/changelogs/changes-1.12.1.md @@ -0,0 +1,8 @@ +# Important bugfixes +* Lifted the restriction that the -march option cannot appear in cpp.*Flags (QBS-1018). +* All required header files get installed now (QBS-1370). +* Fixed rpaths not ending up on the command line under certain circumstances (QBS-1372). +* Fixed possible crash when scanning qrc files (QBS-1375). +* Fixed spurious re-building of .pc and .qbs module files. +* Fixed possible crash on storing a build graph after re-resolving. +* Fixed possible assertion on input artifacts with alwaysUpdated == false. diff --git a/changelogs/changes-1.12.2.md b/changelogs/changes-1.12.2.md new file mode 100644 index 00000000..94ecc68e --- /dev/null +++ b/changelogs/changes-1.12.2.md @@ -0,0 +1,10 @@ +# Important bugfixes +* The Visual Studio 2017 Build Tools are properly supported now. +* Android NDK r18 is properly supported now. +* Removed invalid assertion that prevented deriving from the Properties item. +* Fixed build error on some BSD hosts (QBS-1395). +* setup-qt fixes: + * The QtWebkit module is now properly detected (QBS-1399). + * The case of the qtmain library being called "qt5main" is properly handled now (QBS-767). + * Building against a Qt that was built with sanitizing support + works out of the box now (QBS-1387). diff --git a/changelogs/changes-1.13.0.md b/changelogs/changes-1.13.0.md new file mode 100644 index 00000000..37e4da00 --- /dev/null +++ b/changelogs/changes-1.13.0.md @@ -0,0 +1,37 @@ +# General +* Added a lot more documentation. +* The `--show-progress` command line option is now supported on Windows. + +# Language +* Introduced module providers. +* The `Depends` item now falls back to `pkg-config` to locate dependencies whose names do not + correspond to a qbs module. +* Added the concept of job pools for limiting concurrent execution of commands by type. +* Added support for rules without output artifacts. +* Added `atEnd` function to the `Process` service. +* Added `canonicalPath` function to the `FileInfo` service. +* Removed the need to add "import qbs" at the head of project files. +* The `Application`, `DynamicLibrary` and `StaticLibrary` items now have properties for more + convenient installation of target binaries. + +# C/C++ Support +* Added recursive dependency scanning of GNU ld linkerscripts. +* Added new `cpp` property `linkerVariant` to force use of `gold`, `bfd` or `lld`. + +# Qt Support +* It is no longer required to call `setup-qt` before building Qt projects. +* Introduced the property `Qt.core.enableBigResources` for the creation of "big" Qt resources. +* Static builds now pull in the default set of plugins as specified by Qt, and the user can + specify the set of plugins by type. +* Files can be explicitly tagged as mocable now. + +# Other modules +* Added `protobuf` support for C++ and Objective-C. +* Introduced the `texttemplate` module, a facility similar to qmake's `SUBSTITUTES` feature. + +# Android Support +* The `AndroidApk` item was deprecated, a normal `Application` item can be used instead. +* Building Qt apps is properly supported now, by making use of the `androiddeployqt` tool. + +# Autotest support +* Introduced the `autotest` module. diff --git a/changelogs/changes-1.13.1.md b/changelogs/changes-1.13.1.md new file mode 100644 index 00000000..b2a315cd --- /dev/null +++ b/changelogs/changes-1.13.1.md @@ -0,0 +1,9 @@ +# Important bugfixes +* Qt support: Plugins are no longer linked into static libraries when building against + a static Qt (QBS-1441). +* Qt support: Fixed excessively long linker command lines (QBS-1441). +* Qt support: Host libraries are now looked up at the right location (QBS-1445). +* Qt support: Fixed failure to find Qt modules in Qt Creator when re-parsing a project that + hasn't been built yet. +* macOS: Properties in bundle.infoPlist are no longer overridden (QBS-1447). +* iOS: Fixed generation of default Info.plist (QBS-1447). diff --git a/changelogs/changes-1.14.0.md b/changelogs/changes-1.14.0.md new file mode 100644 index 00000000..860578a1 --- /dev/null +++ b/changelogs/changes-1.14.0.md @@ -0,0 +1,35 @@ +# Language +* The `PathProbe` item was extended to support looking for multiple files and filtering candidate + files. + +# C/C++ Support +* Added support for Visual Studio 2019. +* Added support for clang-cl. +* Various improvements for bare-metal toolchains, including new example projects and support for + the SDCC toolchain. + +# Qt Support +* Added the `Qt.android_support.extraLibs` property. + +# Other modules +* The `pkgconfig` module now has a `sysroot` property. +* Added gRPC support to the `protobuf.cpp` module. + +# Android Support +* Removed support for NDK < r19. +* Added new `Android.sdk` properties `versionCode` and `versionName`. + +# Infrastructure +* Added configuration files for Travis CI. +* Various fixes and improvements in the Debian Docker image; updated to to Qt 5.11.3. + +# Contributors +* BogDan Vatra +* Christian Kandeler +* Christian Stenger +* Davide Pesavento +* Denis Shienkov +* hjk +* Ivan Komissarov +* Joerg Bornemann +* Richard Weickelt diff --git a/changelogs/changes-1.14.1.md b/changelogs/changes-1.14.1.md new file mode 100644 index 00000000..695ee3c7 --- /dev/null +++ b/changelogs/changes-1.14.1.md @@ -0,0 +1,4 @@ +# Important bugfixes +* Qt support: Fix static builds on Windows (QBS-1465). +* Qt support: Fix static builds with Qt >= 5.13.1. +* Darwin: Adapt to Xcode 11. diff --git a/changelogs/changes-1.15.0.md b/changelogs/changes-1.15.0.md new file mode 100644 index 00000000..cc95011a --- /dev/null +++ b/changelogs/changes-1.15.0.md @@ -0,0 +1,44 @@ +# General +* Added a session command which offers a JSON-based API for interaction with + other tools via stdin/ stdout. This allows for proper Qbs support in IDEs that + do not use Qt or even C++. + +# Language +* Probes are now evaluated before Profile items and can be used to create + profiles on project level. +* AutotestRunner got a separate job pool. +* Added a timeout property to Command, JavaScriptCommand and AutotestRunner. + This allows to identify and kill stuck commands. + +# C/C++ Support +* Ensure proper support of Xcode 11. +* Linker map files can be generated with all toolchains. +* Bare metal toolchains can now generate listing files. +* Improve the command line output filtering of bare metal toolchains. +* Added support for clang in mingw mode on Windows. +* Added msp430 support to GCC and IAR. +* Added STM8 support to IAR and SDCC. +* Added IDE project generators for IAR Embedded Workbench for ARM, AVR, 8051, + MSP430, and STM8 architectures. +* Added IDE project generators for KEIL uVision v4 for ARM and 8051 + architectures. +* Added more bare metal project examples for various target platforms. +* The IAR, KEIL and SDCC toolchains are now found automatically in various. + locations by the setup-toolchains command and by probes if no installPath is + set in the profile. + +# Infrastructure +* Automated build and testing on Ubuntu, macOS and Windows. +* Added Ubuntu bionic Docker image which replaces Debian stretch. +* Updated Qt in the Ubuntu and Windows Docker images to 5.12. +* When building Qbs, Qt libraries can now be bundled on Linux, macOS and + Windows. + +# Contributors +* Alberto Mardegan +* Christian Kandeler +* Denis Shienkov +* Ivan Komissarov +* Jochen Ulrich +* Joerg Bornemann +* Richard Weickelt diff --git a/changelogs/changes-1.16.0.md b/changelogs/changes-1.16.0.md new file mode 100644 index 00000000..23628b90 --- /dev/null +++ b/changelogs/changes-1.16.0.md @@ -0,0 +1,126 @@ +# General + +* A new freedesktop module helps UNIX application developers to follow the + freedesktop.org guidelines. +* The Android module now allows resourcesDir, sourcesDir and assetsDir to be + specified as relative paths. +* A new ConanfileProbe allows better and more flexible integration of Qbs and + the Conan package manager. +* A new hostArchitecture property has been added to the qbs module. + + +# Language + +* List properties in modules are now merged according to inter-module + dependencies. This is important when flags like cpp.staticLibraries are + contributed by multiple modules with dependencies between each other. + (QBS-1517). +* Dependency matching of multiplexed products is now less strict and does not + require all multiplex properties to match. For instance, if product A is + multiplexed over qbs.architecture and qbs.buildVariant while product B is only + multiplexed over one of these axes, then Qbs no longer fails (QBS-1515). + + +# C/C++ Support + +* The Renesas RL78 architecture is now supported in GCC and IAR and the + toolchains are auto-detected by qbs-setup-toolchains. +* The Renesas RX as well as the RH850, V850, 78K are now supported in IAR and + the toolchains are auto-detected by qbs-setup-toolchains. +* The MPLAB X32 GCC-based toolchain is now auto-detected on Windows. +* Multiple occurrences of static libraries on the linker command line are now + pruned and the last instance always wins when using GCC or LLVM-based + toolchains. This avoids problems with excessively long linker command lines + (QBS-1273). +* Clang-cl and MSVC toolchains use the compiler frontend instead of the linker + when linking. The old behavior can be restored by setting cpp.linkerMode to + "manual". This allows to use sanitizers with clang-cl by passing + "-fsanitise=xxx" via cpp.driverFlags (QBS-1522). +* The clang-cl toolchain now uses "link.exe" as the default linker. + "lld-link.exe" can be explicitly selected by setting cpp.linkerVariant to + "lld" (QBS-1522). +* The MSVC, clang-cl and MinGW toolchains are now automatically detected if the + profile does not set an explicit installation location, for instance because + no profile was given. +* Installation of separate debug information can now be enabled and configured + by simply setting the installDebugInformation and debugInformationInstallDir + properties in the Application and Library convenience items. This works for + toolchains based upon GCC, MSVC or clang-cl. +* Xcode version 11.4 is now supported on macOS. + + +# Qt Support + +* Qbs now supports Qt 5.14 for Android which comes as a multi-architecture + package. The qbs-setup-android tool has been updated accordingly (QBS-1497). +* JSON metatype files generated by moc (Qt >= 5.15) are supported by setting + Qt.core.generateMetaTypesFile and Qt.core.metaTypesInstallDir (QBS-1531). +* Pure debug builds of Qt (>= 5.14) with MinGW are now properly supported. They + don't have the 'd' suffix (QTBUG-80792). +* The QML type declaration mechanism introduced in Qt 5.15 is now supported by + the Qt.qml module (QBS-1531). +* Generated qmltypes files are now named according to the product's targetName + property (QTBUG-82710). + + +# Documentation + +* The how-to chapter has been extended with sections about debugging Qbs files + and about building separate debug information in C++ projects. +* The item and module reference documentation has been improved for the + cpp.libraryPaths, cpp.dynamicLibraries (QBS-1516), qbs.toolchainType and + qbs.toolchain properties as well as the Export item and the Library + convenience item. +* Documentation for various path probes has been added (QBS-1187). +* The README was extended and a CONTRIBUTING file has been added which provides + useful information for potential contributors. This is important for people + looking at our github mirror. + + +# Infrastructure + +* The Debian Docker image has been removed. +* We are now using ccache and clcache in our CI pipelines to shrink the build + time. +* Clang-tidy is now used to identify potential problems in the code base and a + lot of action was taken upon a lot of findings. +* A Docker image for testing Qbs with Android and Qt has been added. + + +# Important Bug Fixes + +* Fix nullpointer access and heap-use-after-free error (QBS-1485). +* Select the right instance when Depends.profiles is used on a dependency with + an aggregator product (QBS-1513). +* Fix crash when specifying a non-existing profile in Depends.profiles + (QBS-1514). +* Try harder to detect GCC toolchains in qbs-setup-toolchains (QBS-1524). +* Code signing for Core Foundation Bundles on macOS has been fixed. +* Automatic artifact scanning now prefers artifacts from product dependencies if + multiple candidates are found. This improves dependency tracking in complex + projects (QBS-1532). +* The grpcIncludePath property in the probufcpp module has been fixed + (QBS-1542). +* Qbs does no longer crash when accessing a property of a non-existent module in + "IDE mode". + + +# Contributors + +* Alberto Mardegan +* Björn Schäpers +* BogDan Vatra +* Christian Kandeler +* Christian Stenger +* Denis Shienkov +* Ivan Komissarov +* Jochen Ulrich +* Joerg Bornemann +* Leon Buckel +* Marius Sincovici +* Maximilian Goldstein +* Mitch Curtis +* Oliver Wolff +* Orgad Shaneh +* Raphaël Cotty +* Richard Weickelt diff --git a/changelogs/changes-1.17.0.md b/changelogs/changes-1.17.0.md new file mode 100644 index 00000000..f34eebe7 --- /dev/null +++ b/changelogs/changes-1.17.0.md @@ -0,0 +1,98 @@ +# General + +* The lookup order in PathProbe changed to [environmentPaths, + searchPaths, platformEnvironmentPaths, platformSearchPaths]. +* The pathPrefix and platformPaths properties have been removed from the + PathProbe item. They were deprecated since Qbs 1.13. +* The protocBinary property in the protobuf module has been renamed to + compilerPath. +* A new module capnp for Cap'n Proto in C++ applications has been added. + Cap'n Proto is a serialization protocol similar to protobuf. +* The qbs-setup-android tool got a --system flag to install profiles + system-wide similar to qbs-setup-qt and qbs-setup-toolchains. + + +# Language + +* The product and project variables are now available on the + right-hand-side of moduleProvider expressions and the default scope is + product (QBS-1587). + + +# C/C++ Support + +* Lots of improvements have been made on toolchain support for + bare-metal devices in general. Bare-metal targets can be selected by + setting qbs.targetPlatform to 'none'. +* KEIL: The ARMCLANG, C166 and C251 toolchains are now supported. +* IAR: National's CR16, Microchip's AVR32, NXP's M68K, Renesas' + M8/16C/M32C/R32C/SuperH targets and RISC-V targets are now supported. +* GCC: National's CR16, NXP M68K, Renesas M32C/M32R/SuperH/V850 as well + as RISC-V and Xtensa targets are now supported. +* MSVC: Module definition files can now be used to provide the linker + with information about exports and attributes (QBS-571). +* MSVC: "/external:I" is now used to set system include paths (QBS-1573). +* MSVC: cpp.generateCompilerListingFiles is now supported to generate + assembler listings. +* Xcode: macOS framework paths on the command line are now automatically + deduplicated (QBS-1552). +* Xcode: Support for Xcode 12.0 has been added (QBS-1582). + + +# Qt Support + +* The Qt for Android modules have been cleaned up. Support for ARMv5, MIPS and + MIPS64 targets has been removed (QBS-1496). +* Initial support for Qt6 has been added. + + +# Android Support + +* A packageType property has been added to the Android.sdk module which + allows to create Android App bundles (aab) instead of apk packages + only. +* A aaptName property has been added to the Android.sdk module which + allows to use aapt2 (QBS-1562) since aapt has been deprecated. + + +# Documentation + +* New bare-metal examples have been added and existing examples have + been ported to more toolchains. +* A new how-to about cpp.rPaths has been added (QBS-1204). +* Various minor improvements have been made. + + +# Important Bug Fixes + +* Building Qt for Android applications as static libraries has been + fixed (QBS-1545). +* Trailing slashes are no longer removed from Visual Studio environment + variables (QBS-1551). +* The MSVC cpp module did not use the cpp.distributionIncludePaths + property (QBS-1572). +* The visual studio generator has been fixed to work with Visual Studio + 16.6 (QBS-1569). +* Fixed extraction of build information from CONFIG and QT_CONFIG + variables in Qt installations (QBS-1387). +* The version number is no longer appended to .so files on Android + (QBS-1578). +* Compiler defines are now correctly passed to moc when processing + header files (QBS-1592). + + +# Contributors + +* Alberto Mardegan +* Christian Gagneraud +* Christian Kandeler +* Christian Stenger +* Denis Shienkov +* Ivan Komissarov +* Jake Petroules +* Jochen Ulrich +* Mitch Curtis +* Oliver Wolff +* Raphaël Cotty +* Richard Weickelt +* Sergey Zhuravlev diff --git a/changelogs/changes-1.17.1.md b/changelogs/changes-1.17.1.md new file mode 100644 index 00000000..ef5a39f8 --- /dev/null +++ b/changelogs/changes-1.17.1.md @@ -0,0 +1,10 @@ +# Important bugfixes + +* Android: Fix support for Qt 5.15 (QBS-1580). +* Android: Allow exporting of Qt modules in Export items (QBS-1576) +* Darwin: Fix ios-simulator builds with XCode 12 + +# Contributors + +* Raphaël Cotty +* Ivan Komissarov diff --git a/changelogs/changes-1.18.0.md b/changelogs/changes-1.18.0.md new file mode 100644 index 00000000..38fb9afb --- /dev/null +++ b/changelogs/changes-1.18.0.md @@ -0,0 +1,84 @@ +# General + +* capnp: The outputDir property is now public and read-only. +* setup-toochains: Include the Xcode version into the profile name + profile when auto-detection an Xcode installation. +* innosetup module: Add support for InnoSetup v6 +* JSON API: Use the full display name of multiplexed products + in the dependencies array. This allows clients to for example to + properly update the search path for multiplexed dynamic libraries. + + +# Language + +* Deprecate the product variable inside Export items in favor of a new + exportingProduct variable. It will be removed in Qbs 1.20 (QBS-1576). +* Qbs now checks string and stringList values according to the + allowedValues property in the PropertyOptions item. + + +# Protocol Buffers Support (Protobuf Module) + +* The deprecated protocBinary property has been removed. Use compilerPath + instead. +* A nanopb submodule has been added. +* The outputDir property is now public and read-only. + +# C/C++ Support + +* baremetal: cpp.generateCompilerListingFiles has been implemented for + KEIL ARM Clang +* baremetal: cpp.enableDefinesByLanguage does now work with SDCC as well. + + +# Qt Support + +* Moc is now disabled when building aggregate products. + + +# Android Support + +* Support for the new directory layout of Qt6 has been added (QBS-1609). +* Input file generation for androiddeployqt has been improved (QBS-1613). +* Debugging experience of multi-architecture Android projects with Qbs and + Qt Creator has been improved. Binaries are now generated in a directory + layout that Qt Creator expects and debug information is no longer stripped + away. + +# Documentation + +* baremetal: A new WiFi access point example for the ESP8266 MCU using the + GCC toolchain has been added. +* baremetal: A new example for Nordic's pca10001 board has been + added. It supports GCC, KEIL and IAR. +* baremetal: The stm32f103 example supports IAR as well. +* A howto has been added showing how to easily disable compiler + warnings. +* Instructions for building Qbs with CMake have been added (QBS-1618). + +# Important Bug Fixes + +* Qt modules could not be used in Export item when building for Android + (QBS-1576). +* Variable substitution in Info.plist files was broken for + '@VAR@' syntax (QBS-1601). +* CppApplication failed to build for Android when using Qt > 5.14.0 + and multiplexing over multiple architectures (QBS-1608). +* Moc output was broken when including Boost project header files (QBS-1621). + +# Contributors + +* Alberto Mardegan +* André Pönitz +* Christian Kandeler +* Christian Stenger +* Cristian Adam +* Denis Shienkov +* Eike Ziller +* Ivan Komissarov +* Jochen Ulrich +* Kai Dohmen +* Mitch Curtis +* Orgad Shaneh +* Raphaël Cotty +* Richard Weickelt diff --git a/changelogs/changes-1.18.2.md b/changelogs/changes-1.18.2.md new file mode 100644 index 00000000..5019e491 --- /dev/null +++ b/changelogs/changes-1.18.2.md @@ -0,0 +1,41 @@ +# C/C++ Support + +* qbs-setup-toolchains is now able to detect clang-cl properly +* The Library and Include probes take more paths into account on Linux to better + support containerization systems such as Flatpak. +* Xcode autodetection now uses xcode-select to find Xcode on the system. + + +# Protocol Buffers Support (Protobuf Module) + +* A missing nanopb generator file extension on windows has been added. +* The problem that property _libraryName was incorrect when protobuf was not + found has been fixed. + + +# Android Support + +* An assertion when building Android applications using additional java classes + with native methods has been fixed (QBS-1628). + + +# Qt Support + +* A problem related to handling Qt6EntryPoint in the Qt module provider has been + fixed. + + +# Infrastructure + +* A Qt4 docker image for basic testing has been added. + + +# Contributors + +* Christian Kandeler +* Eike Ziller +* Ivan Komissarov +* Jan Blackquill +* Kai Dohmen +* Raphaël Cotty +* Richard Weickelt diff --git a/changelogs/changes-1.19.0.md b/changelogs/changes-1.19.0.md new file mode 100644 index 00000000..a981ea33 --- /dev/null +++ b/changelogs/changes-1.19.0.md @@ -0,0 +1,65 @@ +# General + +* New codesign module was added to implement code signing for Apple, Android and Windows + platforms (QBS-899, QBS-1546). +* It is now possible to build Qbs with Qt 6. +* Project files update API depending on the Qt.gui module was removed. This allows to enable + project files update API unconditionally when building Qbs. +* Convenience items such as Application, DynamicLibrary and StaticLibrary now properly install + artifacts when multiplexing. + +# C/C++ Support + +* Qbs now supports multiple MSVC compiler versions installed in one Visual Studio installation + (QBS-1498). Also, multiple compiler versions are properly detected by qbs setup-toolchains. +* It is now possible to specify Windows SDK version for the MSVC and clang-cl toolchains via the + new cpp.windowsSdkVersion property. +* baremetal: Fix generation of compiler listing files with custom extension for the SDCC compiler. +* baremetal: Fix generation of compiler listing files for the ARMCC compiler. +* baremetal: Fix detection for Keil toolchains. +* baremetal: Add support for HCS08 architectures to SDCC and IAR toolchains (QBS-1631, QBS-1629). +* baremetal: Add support for HCS12 architectures to GCC and IAR toolchains (QBS-1630, QBS-1550). + +# Qt Support + +* Fix possible command line length issue with qmlimportscanner (QBS-1633). +* Fix accessing binaries from libexec for Qt 6.1 and above (QBS-1636). + +# Android Support + +* Added a workaround for the Qt.Network module dependencies for 5.15.0 < Qt < 5.15.3 (QTBUG-87288) +* Fix aapt command invocation on Windows. +* Added support for ndk 22.1.7171670. + +# Documentation + +* Added How-To about codesigning on Apple platforms. +* Cocoa Touch Application example is brought up-to date to use modern Apple practices. +* Added example how to use the cpp.linkerVariant property. +* Added missing documentation for the cpp.toolchainInstallPath property. +* Added missing documentation for the supported 'bare-metal' architectures. + +# Important Bug Fixes + +* Added support for Xcode 12.5 (QBS-1644). +* Fix support for Python 3.9 for building Apple DMG images (QBS-1642). + +# Infrastructure + +* Ubuntu Focal image was updated to use Qt 5.15.2 and Qbs 1.17.1. +* Added automated tests for Qt 6 for macOS, Linux and Windows. +* Added a self-hosted runner to run 'bare-metal' tests on Windows. + +# Contributors + +* Andrey Filipenkov +* Denis Shienkov +* Christian Kandeler +* Jan Blackquill +* Jake Petroules +* Ivan Komissarov +* Max Bespalov +* Mitch Curtis +* Orgad Shaneh +* Raphaël Cotty +* Richard Weickelt diff --git a/changelogs/changes-1.19.1.md b/changelogs/changes-1.19.1.md new file mode 100644 index 00000000..c4cab506 --- /dev/null +++ b/changelogs/changes-1.19.1.md @@ -0,0 +1,12 @@ +# C/C++ Support + +* Fix system include support with MSVC >= 19.29.30037 + +# Qt Support + +* Fix possible command line length issue with qmlimportscanner when cross-compiling (QBS-1633). + +# Apple platforms + +* Fix stripping debug symbols in multiplexed products when cpp.separateDebugInformation + is false (QBS-1647) diff --git a/changelogs/changes-1.19.2.md b/changelogs/changes-1.19.2.md new file mode 100644 index 00000000..8f76b5a3 --- /dev/null +++ b/changelogs/changes-1.19.2.md @@ -0,0 +1,5 @@ +# Important Bug Fixes + +* codesign: Fix checking if product is a framework (QBS-1649) +* codesign: Add additional signing flags at end of command (QBS-1651) +* codesign: Add new codesign.timestampAlgorithm property (QBS-1651) diff --git a/changelogs/changes-1.20.0.md b/changelogs/changes-1.20.0.md new file mode 100644 index 00000000..1cf7819d --- /dev/null +++ b/changelogs/changes-1.20.0.md @@ -0,0 +1,62 @@ +# General + +* CMake and Qbs builds now fully support building with Qt6. +* Qbs now prints the old properties set when refusing to build a project with + changed properties. +* Added convenience command to qbs-config to add a profile in one go instead of + setting properties separately (QTCREATORBUG-25463). +* Added profiling timer for module providers. + +# C/C++ Support + +* Added support for the COSMIC COLDFIRE (also known as M68K) compiler (QBS-1648). +* Added support for the COSMIC HCS08 compiler (QBS-1641). +* Added support for the COSMIC HCS12 compiler (QBS-1640). +* Added support for the COSMIC STM8 compiler (QBS-1639). +* Added support for the COSMIC STM32 compiler (QBS-1638). +* Added support for the new Digital Mars toolchain (QBS-1636). +* The new cpp.enableCxxLanguageMacro property was added for the MSVC toolchain + that controls the /Zc:__cplusplus required for proper support of the new + C++ standards (QBS-1655). +* Added support for the "c++20" language version for the MSVC toolchain + which results in adding the /std:c++latest flag (QBS-1656). + +# Qt Support + +* Consider "external" modules +* Fix support for qml binaries that were moved to the libexec directory in Qt 6.2 (QBS-1636). + +# Android Support + +* Added option to use dex compiler d8 instead of dx. +* Ministro support was removed. +* Fix link with static stl on Android (QBS-1654) +* The default Android Asset Packaging Tool was change from aapt to aapt2. + +# Apple Support + +* Qbs now uses embedded build specs from Xcode 12.4 when bundle.useXcodeBuildSpecs is true + instead of older specs from Xcode 9.2. + +# Important Bug Fixes + +* Fix handling cpp.linkerWrapper with the MSVC toolchain (QBS-1653). + +# Infrastructure + +* Windows-only tests are moved to a separate tst_blackbox_windows binary. +* Qbs was updated to 1.18.2 in Docker images as well as in GitHub actions jobs. +* Added Qbs build and tests with the MinGW toolchain. +* Added CMake build with Qt6 on Linux. + +# Contributors + +* Christian Kandeler +* Denis Shienkov +* Eike Ziller +* Ivan Komissarov +* Jan Blackquill +* Mitch Curtis +* Oswald Buddenhagen +* Raphaël Cotty +* Richard Weickelt diff --git a/changelogs/changes-1.20.1.md b/changelogs/changes-1.20.1.md new file mode 100644 index 00000000..a33ed044 --- /dev/null +++ b/changelogs/changes-1.20.1.md @@ -0,0 +1,12 @@ +# General + +* Fixed target linker flags on FreeBSD (QBS-1312). +* Fixed file time precision on FreeBSD. +* Added additional logging to the Qt module provider when no qmakes were found. +* Some fixes to CMake build. +* Fixed incorrect usage of the qmlcachegen binary (QBS-1676). + +# Android Support + +* Added stripping for release builds. +* Fix generation of aab packages. diff --git a/changelogs/changes-1.21.0.md b/changelogs/changes-1.21.0.md new file mode 100644 index 00000000..f8c2dbd9 --- /dev/null +++ b/changelogs/changes-1.21.0.md @@ -0,0 +1,56 @@ +# General + +* A new qbsModuleProviders property was added to Project and Product items which allows + to specify which providers will be run (QBS-1604). +* Added a new library for reading *.pc files which allows to avoid launching multiple pkg-config + processes and also gives QBS more information about dependencies between *.pc files (QBS-1615). +* A new qbspkgconfig provider was added which will replace the fallback provider (QBS-1614). + This new provider uses the built-in library and is capable of setting Qt libraries as well. +* capnproto and protobuf modules can now use runtime provided by the qbspkgconfig provider. +* A new ConanfileProbe.verbose property was added which can be useful to debug problems with + Conan. +* Qbs no longer migrates the "profiles/" dir from earlier Qbs versions (QTCREATORBUG-26475). + Old directories might be cleaned up manually. +* FileInfo now always uses high-precision timer on all OSes. +* Fixed a problem with overriding stringList properties in ModuleProviders from command-line. + +# C/C++ Support + +* Added support for c++23. +* Add Elbrus E2K architecture for the GCC toolchain (QBS-1675). +* COSMIC cpp module now avoids using relative file paths as much as possible. +* Some refactoring was done in the cpp modules to share more code. + +# Android Support + +* Added Android.ndk.buildId property which allows to overwrite the default value (sha1) for + the --build-id linker flag. +* Fixed reading *.prl files with Qt >= 6.0. +* Fixed rcc path with Qt >= 6.2. + +# Documentation + +* Added a new page with the list of ModuleProviders. +* Qt provider now has its own page. +* Clarified that application won't be runnable by default, unless env or rpaths are set correctly. + +# Infrastructure + +* Added standalone job for building documentation. +* Xcode version was bumped to 12.5.1. +* Added OpenSUSE Leap docker image. +* Added Android tests with different NDK versions. +* Fixed QMake build with Qt 6. + +# Contributors + +* Christian Kandeler +* Christian Stenger +* Davide Pesavento +* Denis Shienkov +* Ivan Komissarov +* Kai Dohmen +* Orgad Shaneh +* Raphaël Cotty +* Richard Weickelt +* Thorbjørn Lindeijer diff --git a/changelogs/changes-1.22.0.md b/changelogs/changes-1.22.0.md new file mode 100644 index 00000000..5de8a1a2 --- /dev/null +++ b/changelogs/changes-1.22.0.md @@ -0,0 +1,31 @@ +# General +* A new Host service was introduced, providing information about the host system that + used to be available from the qbs module, but did not really belong there. + In addition, some more qbs module properties have moved to the FileInfo service. +* The product variable in Export items now points to the importing product, rather than + the exporting one. +* Probes are now also available in ModuleProvider items. + +# C/C++ Support +* Added support for the Open Watcom toolchain. +* Reduced unneeded re-linking on Linux by ignoring changes to weak symbols in library + dependencies by default. + +# Qt Support +* Android multi-arch packages are supported again wth Qt >= 6.3. +* We now use cpp.systemIncludePaths for Qt headers, so that building Qt applications + no longer triggers warnings from Qt headers unrelated to the user code. + +# Infrastructure +* Added coverage for Digital Mars compiler. +* Added coverage for static Qt builds. + +# Contributors +* Christian Kandeler +* Denis Shienkov +* Ivan Komissarov +* Jan Blackquill +* Leena Miettinen +* Marius Gripsgard +* Mitch Curtis +* Raphael Cotty diff --git a/changelogs/changes-1.22.1.md b/changelogs/changes-1.22.1.md new file mode 100644 index 00000000..34c58f2f --- /dev/null +++ b/changelogs/changes-1.22.1.md @@ -0,0 +1,16 @@ +# General + +* Adapted to changes in Xcode 13.3 (QBS-1693). +* Re-added several bugfixes from 1.21.1 that got lost in 1.22.0. + +# Qt Support + +* Fixed building against static Qt 6 (QBS-1692). + +# Android Support + +* Fixed wrong include path being added to the command line (QBS-1691). + +# Documentation + +* Fixed outdated use of "product" in Export items (QBS-1694). diff --git a/changelogs/changes-1.23.0.md b/changelogs/changes-1.23.0.md new file mode 100644 index 00000000..e8234e3f --- /dev/null +++ b/changelogs/changes-1.23.0.md @@ -0,0 +1,16 @@ +# C/C++ Support +* Added new module Sanitizers.address for simple cross-platform ASan configuration. + +# Qt Support +* Add the now-required /permissive- flag for MSVC automatically. + +# Android Support +* Support use of cmdline-tools in addition to SDK tools. +* Consider .jar files also in the product itself, not just in dependencies. + +# Contributors +* Christian Kandeler +* Dmitry Shachnev +* Ivan Komissarov +* Max Bespalov +* Orgad Shaneh diff --git a/changelogs/changes-1.23.1.md b/changelogs/changes-1.23.1.md new file mode 100644 index 00000000..65536bfe --- /dev/null +++ b/changelogs/changes-1.23.1.md @@ -0,0 +1,19 @@ +# C/C++ Support +* Added support for c17 and c2x values in cpp.cLanguageVersion. +* Added support for cpp.cLanguageVersion for the MSVC toolchain. +* Fix passing linker scripts to iar and keil toolchains (QBS-1704). + +# Qt Support +* Adapted to new location of qscxmlc in Qt 6.3. +* Adapted to new location of qhelpgenerator in Qt 6.3. +* Fixed setting up Qt 6.3 with qbspkgconfig. +* Added QtScript module to the source tarballs (QBS-1703). + +# Other modules +* Fixed protobuf linking on macOS 11. +* Fixed handling empty variables in qbspkgconfig (QBS-1702) + +# Contributors +* Christian Kandeler +* Ivan Komissarov +* Orgad Shaneh diff --git a/changelogs/changes-1.6.0 b/changelogs/changes-1.6.0 new file mode 100644 index 00000000..616be866 --- /dev/null +++ b/changelogs/changes-1.6.0 @@ -0,0 +1,16 @@ +* Added lex_yacc module. +* Introduced property cpp.systemRunPaths. +* Introduced the ability to check a module's version in a Depends item. +* Introduced cpp.driverFlags, which allows specifying flags to be + passed to the compiler driver (in any mode), but never the system linker. +* Introduced cpp.linkerMode property to allow selection of the + correct linker (C driver, C++ driver, or system linker) based on the + objects being linked. +* Added automatic escaping of arguments passed to the + cpp.linkerFlags and cpp.platformLinkerFlags properties using the -Wl + or -Xlinker syntaxes. To revert to the old behavior, + Project.minimumQbsVersion can be set to a version lower than 1.6. +* Each build configuration now requires a unique name, which + is specified on the command line in the same place that qbs.buildVariant + used to be specified. This allows building for multiple configurations + with the same variant. diff --git a/changelogs/changes-1.6.1 b/changelogs/changes-1.6.1 new file mode 100644 index 00000000..20899ade --- /dev/null +++ b/changelogs/changes-1.6.1 @@ -0,0 +1,6 @@ +Features: + * Added cpp.linkerWrapper property. +Important bug fixes: + * Fixed a number of bugs evaluating module properties (QBS-845, QBS-1005). + * Fixed x86_64 > x86 cross compiling (QBS-1028). + * Fixed dynamic rules with generated inputs (QBS-1029). diff --git a/changelogs/changes-1.7.0 b/changelogs/changes-1.7.0 new file mode 100644 index 00000000..341ebcd3 --- /dev/null +++ b/changelogs/changes-1.7.0 @@ -0,0 +1,23 @@ +Features: + * Added a generator for Visual Studio projects. + * The Group item is now nestable. + * Stricter type checking for properties. + * Added support for generating qrc files. + * Added full support for the QtScxml module. + * Introduced cpp.soVersion. + * Added support for building Inno Setup packages. + * Tentative support for Visual Studio 2017. + * We now assume UTF-8 encoding for project files. + * In Scanner items, input.fileName now contains + a filename rather than the full path. + * Warnings encountered during project resolving are now stored + and re-displayed when the project is loaded. + * Documentation was improved in several places, most + notably for the Rule item. + * Support for the deprecated Transformer item was removed. +Important bug fixes: + * Long paths on Windows are handled (QBS-1068). + * Cyclic module dependencies are detected (QBS-1044). + * The libqbscore soname now includes the minor version, + so that it will not stay the same across ABI changes + (QBS-1002). diff --git a/changelogs/changes-1.7.1 b/changelogs/changes-1.7.1 new file mode 100644 index 00000000..07262550 --- /dev/null +++ b/changelogs/changes-1.7.1 @@ -0,0 +1,5 @@ +Important bug fixes: + * Fixed race condition in qmake build (QBS-1091) + * Qt Creator no longer leaves empty build directories + behind after cancelled project loading (QTCREATORBUG-17543) + * Fixed an exception crossing the API boundary diff --git a/changelogs/changes-1.7.2 b/changelogs/changes-1.7.2 new file mode 100644 index 00000000..9f4385d7 --- /dev/null +++ b/changelogs/changes-1.7.2 @@ -0,0 +1,5 @@ +Important bug fixes: + * macOS: Fixed App Extension builds on older versions of Xcode/macOS + * Windows: Fixed handling of files on network shares + * Fixed syntax error in Qt module that occurred with static Qt builds + * Several fixes for the Visual Studio generator (QBS-1077, QBS-1100) diff --git a/changelogs/changes-1.8.0 b/changelogs/changes-1.8.0 new file mode 100644 index 00000000..5c4cec23 --- /dev/null +++ b/changelogs/changes-1.8.0 @@ -0,0 +1,33 @@ +Features: + * General: + * It is no longer strictly required to provide a profile. + * Sub-second timestamp resolutions are now supported on Unix + systems. + * Added a convenient replacement for + product.moduleProperty("module", "property"), namely + product.module.property. + * The loadFile and loadExtension functions are deprecated in + favor of the new require function, which accepts arguments of either + form accepted by the deprecated functions. + * Added new tool qbs-create-project to set up a new qbs + project from an existing source tree. + * FileTagger items can now have conditions. + * Probe items can now appear directly under a Project item. + * Cpp module: + * Added support for QNX and the QCC toolchain + * Added the cpp.useRPathLink property to control whether + to use the -rpath-link linker option. + * Provided the means to easily combine source files for the C + language family in order to support "amalgamation builds". + * Introduced cpp.treatSystemHeadersAsDependencies. + * Qt modules: + * Introduced property Qt.core.combineMocOutput. + * Introduced Qt.core.enableKeywords for simple disabling of + the "signals", "slots" and "emit" symbols. +Important bug fixes: + * Improved scalability of parallel builds on Linux by starting + Process commands via a dedicated launcher process. +Behavior changes: + * The base directory for source files changed from the product + source directory to the parent directory of the file where the files are + listed. diff --git a/changelogs/changes-1.8.1 b/changelogs/changes-1.8.1 new file mode 100644 index 00000000..aeebe92b --- /dev/null +++ b/changelogs/changes-1.8.1 @@ -0,0 +1,12 @@ +Important bug fixes: + * Qbs-specific build errors are now correctly linked + in Qt Creator's issues pane (QBS-1151). + * Fixed automatic base profile assignment for + MSVC Qt installations (QBS-1141) + * Various QNX fixes (QBS-1136, QBS-1137, QBS-1138, QBS-1139, QBS-1143). + +Behavior changes: + * Users now get early error messages if they forget + the "modules", "products" or "projects" prefix + in command line property overrides such as + "modules.cpp.enableExceptions:false". diff --git a/changelogs/changes-1.9.0.md b/changelogs/changes-1.9.0.md new file mode 100644 index 00000000..2e3cbfa0 --- /dev/null +++ b/changelogs/changes-1.9.0.md @@ -0,0 +1,58 @@ +# General +* Setting module property values from the command line can now + be done per product. +* Introduced new properties `qbs.architectures` and `qbs.buildVariants` + to allow product multiplexing by `qbs.architecture` and `qbs.buildVariant`, + respectively. +* When rebuilding a project, the environment, project file and property + values are taken from the existing build graph. + +# Language +* `Depends` items can now be parameterized to set special module parameters + for one particular product dependency. The new item type `Parameter` + is used to declare such parameters in a module. The new item type + `Parameters` is used to allow products to set default values for + such parameters in their `Export` item. +* The functions `loadExtension` and `loadFile` have been deprecated and + will be removed in a future version. Use the `require` function instead. + +# Custom Rules and Commands +* Artifacts corresponding to the `explicitlyDependsOn` property + are now available under this name in rules and commands. +* A rule's `auxiliaryInputs` and `explicitlyDependsOn` tags + are now also matched against rules of dependencies, if these rules are + creating target artifacts. +* Rules now have a property `requiresInputs`. If it is `false`, the rule will + be run even if no artifacts are present that match its input tags. +* Added a new property `relevantEnvironmentVariables` to the `Command` class. + Use it if the command runs an external tool whose behavior can be + influenced by special environment variables. + +# C/C++ Support +* Added the `cpp.link` parameter to enable library dependencies to be + excluded from linking. +* When pulling in static library products, the new `Depends` parameter + `cpp.linkWholeArchive` can now be specified to force all the library's + objects into the target binary. +* When pulling in library products, the new `Depends` parameter + `cpp.symbolLinkMode` can now be specified to control how the library + is linked into the target binary on Apple platforms: specifically, + whether the library is linked as weak, lazy, reexported, and/or + upward (see the `ld64` man page for more information). +* The property `cpp.useCxxPrecompiledHeader`, as well as the variants for the + other languages, now defaults to true. +* The property `cpp.cxxLanguageVersion` now gets mapped to MSVC's `/std` option, + if applicable. + +# Apple +* Added support for building macOS disk images. + +# Android +* Product multiplexing is no longer done via profiles, but via architecture, + employing the new `qbs.architectures` property (see above). As a result, + the `setup-android` command now sets up only one profile, rather than + one for each architecture. +* Added support for NDK Unified Headers. + +# Documentation +* Added a "How-to" section. diff --git a/changelogs/changes-1.9.1.md b/changelogs/changes-1.9.1.md new file mode 100644 index 00000000..59fc6908 --- /dev/null +++ b/changelogs/changes-1.9.1.md @@ -0,0 +1,4 @@ +# Important bugfixes +* Lower the response file threshold on Windows to fix build failures with mingw (QBS-1201). +* Fix explicitly specified build variant being ignored for Darwin targets (QBS-1202). +* Fix building for the AVR architecture (QBS-1203). diff --git a/cmake/QbsBuildConfig.cmake b/cmake/QbsBuildConfig.cmake new file mode 100644 index 00000000..a29f550f --- /dev/null +++ b/cmake/QbsBuildConfig.cmake @@ -0,0 +1,252 @@ +option(WITH_TESTS "Build Tests" ON) +option(WITH_UNIT_TESTS "Build Unit Tests" OFF) +option(INSTALL_PUBLIC_HEADERS "Whether to install public headers" ON) +option(QBS_ENABLE_RPATH "Whether to enable RPATH" ON) +option(QBS_USE_BUNDLED_QT_SCRIPT "Whether to use bundled QtScript module" OFF) + +set(QBS_APP_INSTALL_DIR "bin" CACHE STRING "Relative install location for Qbs binaries.") +# default paths +set(QBS_LIBDIR_NAME "lib") +if(WIN32) + set(_DEFAULT_LIB_INSTALL_DIR ${QBS_APP_INSTALL_DIR}) + set(_DEFAULT_LIBEXEC_INSTALL_DIR ${QBS_APP_INSTALL_DIR}) +else() + set(_DEFAULT_LIB_INSTALL_DIR ${QBS_LIBDIR_NAME}) + set(_DEFAULT_LIBEXEC_INSTALL_DIR "libexec/qbs") +endif() + +# path options +set(QBS_OUTPUT_PREFIX "" CACHE STRING "Qbs build output location relative to CMAKE_BINARY_DIR.") +set(QBS_LIB_INSTALL_DIR "${_DEFAULT_LIB_INSTALL_DIR}" CACHE STRING "Relative install location for Qbs libraries.") +set(QBS_DLL_INSTALL_DIR "${QBS_LIB_INSTALL_DIR}" CACHE STRING "Relative install location for Qbs DLLs.") +set(QBS_LIBEXEC_INSTALL_DIR "${_DEFAULT_LIBEXEC_INSTALL_DIR}" CACHE STRING "Relative install location for Qbs libexec.") +set(QBS_PLUGINS_INSTALL_BASE "${QBS_LIBDIR_NAME}" CACHE STRING "Relative install location for Qbs plugins.") +set(QBS_RESOURCES_INSTALL_BASE "." CACHE STRING "Relative install location for Qbs resources.") +set(QBS_HEADERS_INSTALL_DIR "include/qbs" CACHE STRING "Relative install location for Qbs headers.") +set(QBS_DOC_INSTALL_DIR "${QBS_RESOURCES_INSTALL_BASE}/share/doc/qbs" CACHE STRING "Relative install location for Qbs documentation.") + +set(QBS_PLUGINS_INSTALL_DIR "${QBS_PLUGINS_INSTALL_BASE}/qbs/plugins") +set(QBS_RESOURCES_INSTALL_DIR "${QBS_RESOURCES_INSTALL_BASE}/share") + +# rpaths +file(RELATIVE_PATH QBS_RELATIVE_LIBEXEC_RPATH "/${QBS_LIBEXEC_INSTALL_DIR}" "/${QBS_LIB_INSTALL_DIR}") +file(RELATIVE_PATH QBS_RELATIVE_APP_RPATH "/${QBS_APP_INSTALL_DIR}" "/${QBS_LIB_INSTALL_DIR}") +file(RELATIVE_PATH QBS_RELATIVE_PLUGINS_RPATH "/${QBS_PLUGINS_INSTALL_DIR}" "/${QBS_LIB_INSTALL_DIR}") + +if(WIN32 OR NOT QBS_ENABLE_RPATH) + set(QBS_MACOSX_RPATH OFF) + set(QBS_LIB_RPATH "") + set(QBS_LIBEXEC_RPATH "") + set(QBS_APP_RPATH "") + set(QBS_PLUGINS_RPATH "") +elseif(APPLE) + set(QBS_MACOSX_RPATH ON) + set(QBS_LIB_RPATH "@loader_path") + set(QBS_LIBEXEC_RPATH "@loader_path/${QBS_RELATIVE_LIBEXEC_RPATH}") + set(QBS_APP_RPATH "@loader_path/${QBS_RELATIVE_APP_RPATH}") + set(QBS_PLUGINS_RPATH "@loader_path/${QBS_RELATIVE_PLUGINS_RPATH}") +else() + set(QBS_MACOSX_RPATH OFF) + set(QBS_LIB_RPATH "\$ORIGIN") + set(QBS_LIBEXEC_RPATH "\$ORIGIN/${QBS_RELATIVE_LIBEXEC_RPATH}") + set(QBS_APP_RPATH "\$ORIGIN/${QBS_RELATIVE_APP_RPATH}") + set(QBS_PLUGINS_RPATH "\$ORIGIN/${QBS_RELATIVE_PLUGINS_RPATH}") +endif() + +function(get_update_path_command var) + if(WIN32) + get_target_property(_QTCORE_LIBRARY Qt${QT_VERSION_MAJOR}::Core IMPORTED_LOCATION_RELEASE) + if(NOT _QTCORE_LIBRARY) + get_target_property(_QTCORE_LIBRARY Qt${QT_VERSION_MAJOR}::Core IMPORTED_LOCATION_DEBUG) + endif() + get_filename_component(_QT_LIBRARY_PATH "${_QTCORE_LIBRARY}" DIRECTORY) + get_target_property(_QBS_LIBRARY_PATH qbscore LIBRARY_OUTPUT_DIRECTORY) + file(TO_NATIVE_PATH "${_QT_LIBRARY_PATH}\;${_QBS_LIBRARY_PATH}\;$ENV{PATH}" _NEW_PATH) + set(${var} "PATH=${_NEW_PATH}" PARENT_SCOPE) + else() + set(${var} "") + endif() +endfunction() + +if(WITH_UNIT_TESTS) + set(QBS_UNIT_TESTS_DEFINES "QBS_ENABLE_UNIT_TESTS") +else() + set(QBS_UNIT_TESTS_DEFINES "") +endif() + +file(RELATIVE_PATH QBS_RELATIVE_LIBEXEC_PATH "/${QBS_APP_INSTALL_DIR}" "/${QBS_LIBEXEC_INSTALL_DIR}") +file(RELATIVE_PATH QBS_RELATIVE_SEARCH_PATH "/${QBS_APP_INSTALL_DIR}" "/${QBS_RESOURCES_INSTALL_BASE}") +file(RELATIVE_PATH QBS_RELATIVE_PLUGINS_PATH "/${QBS_APP_INSTALL_DIR}" "/${QBS_PLUGINS_INSTALL_BASE}") + +set(DEFAULT_DEFINES "") +if(WIN32) + list(APPEND DEFAULT_DEFINES UNICODE _UNICODE _SCL_SECURE_NO_WARNINGS) +endif() + +# CMake 3.10 doesn't have list(TRANSFORM) +function(list_transform_prepend var prefix) + set(temp "") + foreach(f ${${var}}) + list(APPEND temp "${prefix}${f}") + endforeach() + set(${var} "${temp}" PARENT_SCOPE) +endfunction() + +function(add_qbs_app target_name) + cmake_parse_arguments(_arg + "" + "DESTINATION" + "DEFINES;PUBLIC_DEFINES;DEPENDS;PUBLIC_DEPENDS;INCLUDES;PUBLIC_INCLUDES;SOURCES;" + ${ARGN} + ) + + if (${_arg_UNPARSED_ARGUMENTS}) + message(FATAL_ERROR "add_qbs_app had unparsed arguments") + endif() + + set(_DESTINATION "${QBS_APP_INSTALL_DIR}") + if(_arg_DESTINATION) + set(_DESTINATION "${_arg_DESTINATION}") + endif() + + add_executable(${target_name} ${_arg_SOURCES}) + target_compile_definitions( + ${target_name} PRIVATE ${_arg_DEFINES} ${DEFAULT_DEFINES} PUBLIC ${_arg_PUBLIC_DEFINES}) + target_include_directories( + ${target_name} PRIVATE ${_arg_INCLUDES} PUBLIC ${_arg_PUBLIC_INCLUDES}) + target_link_libraries(${target_name} PRIVATE ${_arg_DEPENDS} PUBLIC ${_arg_PUBLIC_DEPENDS}) + + set_target_properties(${target_name} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${_DESTINATION} + BUILD_RPATH "${QBS_APP_RPATH}" + INSTALL_RPATH "${QBS_APP_RPATH}" + MACOSX_RPATH ${QBS_MACOSX_RPATH} + ) + install(TARGETS ${target_name} RUNTIME DESTINATION ${_DESTINATION}) +endfunction() + +function(add_qbs_library target_name) + cmake_parse_arguments(_arg + "STATIC" + "" + "DEFINES;PUBLIC_DEFINES;DEPENDS;PUBLIC_DEPENDS;INCLUDES;PUBLIC_INCLUDES;SOURCES;" + ${ARGN} + ) + + if (${_arg_UNPARSED_ARGUMENTS}) + message(FATAL_ERROR "add_qbs_library had unparsed arguments") + endif() + + set(library_type SHARED) + if (_arg_STATIC) + set(library_type STATIC) + endif() + + string(REGEX REPLACE "\\.[0-9]+$" "" _SOVERSION ${QBS_VERSION}) + + add_library(${target_name} ${library_type} ${_arg_SOURCES}) + target_compile_definitions( + ${target_name} + PRIVATE ${_arg_DEFINES} ${DEFAULT_DEFINES} + PUBLIC ${_arg_PUBLIC_DEFINES}) + target_include_directories( + ${target_name} + PRIVATE ${_arg_INCLUDES} + PUBLIC ${_arg_PUBLIC_INCLUDES} + INTERFACE $) + target_link_libraries(${target_name} PRIVATE ${_arg_DEPENDS} PUBLIC ${_arg_PUBLIC_DEPENDS}) + + set_target_properties(${target_name} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_LIB_INSTALL_DIR} + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_LIB_INSTALL_DIR} + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_DLL_INSTALL_DIR} + BUILD_RPATH "${QBS_LIB_RPATH}" + INSTALL_RPATH "${QBS_LIB_RPATH}" + MACOSX_RPATH ${QBS_MACOSX_RPATH} + SOVERSION ${_SOVERSION} + VERSION ${QBS_VERSION} + ) + if (NOT _arg_STATIC) + install(TARGETS ${target_name} + LIBRARY DESTINATION ${QBS_LIB_INSTALL_DIR} + RUNTIME DESTINATION ${QBS_DLL_INSTALL_DIR} + ) + endif() +endfunction() + +function(add_qbs_plugin target_name) + cmake_parse_arguments(_arg + "" + "" + "DEFINES;PUBLIC_DEFINES;DEPENDS;PUBLIC_DEPENDS;INCLUDES;PUBLIC_INCLUDES;SOURCES;" + ${ARGN} + ) + + if (${_arg_UNPARSED_ARGUMENTS}) + message(FATAL_ERROR "add_qbs_plugin had unparsed arguments") + endif() + + add_library(${target_name} SHARED ${_arg_SOURCES}) + target_compile_definitions( + ${target_name} PRIVATE ${_arg_DEFINES} ${DEFAULT_DEFINES} PUBLIC ${_arg_PUBLIC_DEFINES}) + target_include_directories( + ${target_name} PRIVATE ${_arg_INCLUDES} PUBLIC ${_arg_PUBLIC_INCLUDES}) + target_link_libraries(${target_name} PRIVATE ${_arg_DEPENDS} PUBLIC ${_arg_PUBLIC_DEPENDS}) + + set_target_properties(${target_name} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_PLUGINS_INSTALL_DIR} + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_PLUGINS_INSTALL_DIR} + BUILD_RPATH "${QBS_PLUGINS_RPATH}" + INSTALL_RPATH "${QBS_PLUGINS_RPATH}" + MACOSX_RPATH ${QBS_MACOSX_RPATH} + ) + install(TARGETS ${target_name} + LIBRARY DESTINATION ${QBS_PLUGINS_INSTALL_DIR} + RUNTIME DESTINATION ${QBS_PLUGINS_INSTALL_DIR} + ) +endfunction() + +function(add_qbs_test test_name) + cmake_parse_arguments(_arg + "" + "" + "DEFINES;PUBLIC_DEFINES;DEPENDS;PUBLIC_DEPENDS;INCLUDES;PUBLIC_INCLUDES;SOURCES;" + ${ARGN} + ) + + if (${_arg_UNPARSED_ARGUMENTS}) + message(FATAL_ERROR "add_qbs_test had unparsed arguments") + endif() + + set(target_name "tst_${test_name}") + + string(TOUPPER ${test_name} suite_name) # cmake is beatiful, here we have + string(REPLACE - _ suite_name ${suite_name}) # and here we have + + add_executable(${target_name} ${_arg_SOURCES}) + target_compile_definitions(${target_name} PRIVATE + "QBS_TEST_SUITE_NAME=\"${suite_name}\"" + "SRCDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" + ) + target_compile_definitions( + ${target_name} PRIVATE ${_arg_DEFINES} ${DEFAULT_DEFINES} PUBLIC ${_arg_PUBLIC_DEFINES}) + target_include_directories( + ${target_name} + PRIVATE ${_arg_INCLUDES} "${CMAKE_CURRENT_SOURCE_DIR}/../../../src" + PUBLIC ${_arg_PUBLIC_INCLUDES} + ) + target_link_libraries( + ${target_name} + PRIVATE ${_arg_DEPENDS} qbscore qbsconsolelogger Qt${QT_VERSION_MAJOR}::Test + PUBLIC ${_arg_PUBLIC_DEPENDS} + ) + + set_target_properties(${target_name} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_APP_INSTALL_DIR} + BUILD_RPATH "${QBS_APP_RPATH}" + INSTALL_RPATH "${QBS_APP_RPATH}" + MACOSX_RPATH ${QBS_MACOSX_RPATH} + ) + install(TARGETS ${target_name} RUNTIME DESTINATION ${QBS_APP_INSTALL_DIR}) + add_test(NAME ${target_name} COMMAND ${target_name}) +endfunction() diff --git a/cmake/QbsDocumentation.cmake b/cmake/QbsDocumentation.cmake new file mode 100644 index 00000000..a1ce4405 --- /dev/null +++ b/cmake/QbsDocumentation.cmake @@ -0,0 +1,307 @@ +# Options: +option(QBS_INSTALL_HTML_DOCS "Whether to install Qbs HTML Documentation" OFF) +option(QBS_INSTALL_QCH_DOCS "Whether to install Qbs QCH Documentation" OFF) + +# Get information on directories from qmake +# as this is not yet exported by cmake. +# Used for QT_INSTALL_DOCS +function(qt_query_qmake) + if (NOT TARGET Qt${QT_VERSION_MAJOR}::qmake) + message(FATAL_ERROR "Qmake was not found. Add find_package(Qt5 COMPONENTS Core) to CMake to enable.") + endif() + # dummy check for if we already queried qmake + if (QT_INSTALL_BINS) + return() + endif() + + get_target_property(_qmake_binary Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + execute_process(COMMAND "${_qmake_binary}" "-query" + TIMEOUT 10 + RESULT_VARIABLE _qmake_result + OUTPUT_VARIABLE _qmake_stdout + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (NOT "${_qmake_result}" STREQUAL "0") + message(FATAL_ERROR "Qmake did not execute successfully: ${_qmake_result}.") + endif() + + # split into lines: + string(REPLACE "\n" ";" _lines "${_qmake_stdout}") + + foreach(_line ${_lines}) + # split line into key/value pairs + string(REPLACE ":" ";" _parts "${_line}") + list(GET _parts 0 _key) + list(REMOVE_AT _parts 0) + string(REPLACE ";" ":" _value "${_parts}") + + set("${_key}" "${_value}" CACHE PATH "qmake import of ${_key}" FORCE) + endforeach() +endfunction() + +# Find programs: +function(_qbs_doc_find_program result_var) + if (NOT TARGET Qt${QT_VERSION_MAJOR}::qmake) + message(FATAL_ERROR "QDoc is only available in Qt projects") + endif() + + get_target_property(_qmake_binary Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) + get_filename_component(_qmake_dir "${_qmake_binary}" DIRECTORY) + find_program("_prg_${result_var}" ${ARGN} HINTS "${_qmake_dir}") + if ("_prg_${result_var}" STREQUAL "_prg_${result_var}-NOTFOUND") + set("_prg_${result_var}" "${result_var}-NOTFOUND") + message(WARNING "Could not find binary for ${result_var}") + endif() + + set(${result_var} "${_prg_${result_var}}" PARENT_SCOPE) +endfunction() + +function(_qbs_setup_doc_targets) + # Set up important targets: + if (NOT TARGET qbs_html_docs) + add_custom_target(qbs_html_docs COMMENT "Build HTML documentation") + endif() + if (NOT TARGET qbs_qch_docs) + add_custom_target(qbs_qch_docs COMMENT "Build QCH documentation") + endif() + if (NOT TARGET BuildQbsDocumentation) + add_custom_target( + BuildQbsDocumentation ALL COMMENT "Build Qbs documentation") + add_dependencies(BuildQbsDocumentation qbs_html_docs qbs_qch_docs) + endif() +endfunction() + +function(_find_python_module module) + string(TOUPPER ${module} module_upper) + if (NOT PY_${module_upper}) + if (ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED") + set(${module}_FIND_REQUIRED TRUE) + endif() + # A module's location is usually a directory, but for binary modules + # it's a .so file. + execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" + "import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))" + RESULT_VARIABLE _${module}_status + OUTPUT_VARIABLE _${module}_location + ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT _${module}_status) + set(PY_${module_upper} ${_${module}_location} CACHE STRING + "Location of Python module ${module}") + endif() + endif() + find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper}) +endfunction() + +function(_qbs_setup_qdoc_targets _qdocconf_file _retval) + cmake_parse_arguments(_arg "" "HTML_DIR;INSTALL_DIR;POSTFIX" + "INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS;SOURCES" ${ARGN}) + + foreach(_index ${_arg_INDEXES}) + list(APPEND _qdoc_index_args "-indexdir;${_index}") + endforeach() + + set(_env "") + foreach(_export ${_arg_ENVIRONMENT_EXPORTS}) + if (NOT DEFINED "${_export}") + message(FATAL_ERROR "${_export} is not known when trying to export it to qdoc.") + endif() + list(APPEND _env "${_export}=${${_export}}") + endforeach() + + set(_full_qdoc_command "${_qdoc}") + if (_env) + set(_full_qdoc_command "${CMAKE_COMMAND}" "-E" "env" ${_env} "${_qdoc}") + endif() + + if (_arg_HTML_DIR STREQUAL "") + set(_arg_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc") + endif() + + get_filename_component(_target "${_qdocconf_file}" NAME_WE) + + # message(${_target}) + # set(_html_outputdir "${_arg_HTML_DIR}/${_target}${_arg_POSTFIX}") + set(_html_outputdir "${_arg_HTML_DIR}") + file(MAKE_DIRECTORY "${_html_outputdir}") + + set(_qdoc_include_args "") + if (_arg_INCLUDE_DIRECTORIES OR _arg_FRAMEWORK_PATHS) + # pass include directories to qdoc via hidden @ option, since we need to generate a file + # to be able to resolve the generators inside the include paths + set(_qdoc_includes "${CMAKE_CURRENT_BINARY_DIR}/cmake/qdoc_${_target}.inc") + set(_qdoc_include_args "@${_qdoc_includes}") + set(_includes "") + if (_arg_INCLUDE_DIRECTORIES) + set(_includes "-I$\n") + endif() + set(_frameworks "") + if (_arg_FRAMEWORK_PATHS) + set(_frameworks "-F$\n") + endif() + file(GENERATE + OUTPUT "${_qdoc_includes}" + CONTENT "${_includes}${_frameworks}" + ) + endif() + + set(_html_artifact "${_html_outputdir}/index.html") + add_custom_command( + OUTPUT "${_html_artifact}" + COMMAND cmake -E remove_directory "${_html_outputdir}" + COMMAND ${_full_qdoc_command} -outputdir "${_html_outputdir}" "${_qdocconf_file}" + ${_qdoc_index_args} ${_qdoc_include_args} + DEPENDS "${_qdocconf_file}" ${_arg_SOURCES} + COMMENT "Build HTML documentation from ${_qdocconf_file}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM + ) + + if (NOT Python3_Interpreter_FOUND) + message(WARNING "Cannot find python3 binary. Qbs documentation will not be built.") + return() + endif() + _find_python_module(lxml) + _find_python_module(bs4) + if (NOT PY_LXML OR NOT PY_BS4) + message(WARNING "Cannot import lxml and bs4 python modules. Qbs documentation will not be built.") + return() + endif() + + set(_fixed_html_artifact "${CMAKE_CURRENT_BINARY_DIR}/qbsdoc.dummy") + set(_fix_qml_imports_script ${Qbs_SOURCE_DIR}/doc/fix-qmlimports.py) + add_custom_command( + OUTPUT "${_fixed_html_artifact}" + COMMAND ${Python3_EXECUTABLE} "${_fix_qml_imports_script}" ${_html_outputdir} + COMMAND cmake -E touch ${_fixed_html_artifact} + DEPENDS "${_html_artifact}" "${_fix_qml_imports_script}" + COMMENT "Fixing bogus QML import statements" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM + ) + + set(_html_target "qbs_html_docs_${_target}") + add_custom_target(${_html_target} DEPENDS "${_fixed_html_artifact}") + add_dependencies(qbs_html_docs "${_html_target}") + + set("${_retval}" "${_html_outputdir}" PARENT_SCOPE) +endfunction() + +function(_qbs_setup_qhelpgenerator_targets _qdocconf_file _html_outputdir) + cmake_parse_arguments(_arg "" "QCH_DIR;INSTALL_DIR" "" ${ARGN}) + if (_arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "qdoc_build_qdocconf_file has unknown arguments: ${_arg_UNPARSED_ARGUMENTS}.") + endif() + + if (NOT _arg_QCH_DIR) + set(_arg_QCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc") + endif() + + if (NOT TARGET Qt${QT_VERSION_MAJOR}::qhelpgenerator) + message(WARNING "qhelpgenerator missing: No QCH documentation targets were generated. Add find_package(Qt5 COMPONENTS Help) to CMake to enable.") + return() + endif() + + get_filename_component(_target "${_qdocconf_file}" NAME_WE) + + set(_html_target "qbs_html_docs_${_target}") + if (NOT TARGET ${_html_target}) + return() + endif() + + set(_qch_outputdir "${_arg_QCH_DIR}") + file(MAKE_DIRECTORY "${_qch_outputdir}") + + set(_fixed_html_artifact "${CMAKE_CURRENT_BINARY_DIR}/qbsdoc.dummy") + set(_qhp_artifact "${_html_outputdir}/${_target}.qhp") + set(_qch_artifact "${_qch_outputdir}/${_target}.qch") + add_custom_command( + OUTPUT "${_qch_artifact}" + COMMAND Qt${QT_VERSION_MAJOR}::qhelpgenerator "${_qhp_artifact}" -o "${_qch_artifact}" + DEPENDS "${_fixed_html_artifact}" + COMMENT "Build QCH documentation from ${_qdocconf_file}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM + ) + + set(_qch_target "qbs_qch_docs_${_target}") + add_custom_target("${_qch_target}" DEPENDS "${_qch_artifact}") + add_dependencies(qbs_qch_docs "${_qch_target}") + + install(FILES "${_qch_outputdir}/${_target}.qch" DESTINATION "${_arg_INSTALL_DIR}" + COMPONENT qbs_qch_docs) + install(DIRECTORY "${_qch_outputdir}/html" DESTINATION "${_arg_INSTALL_DIR}" + COMPONENT qbs_html_docs) +endfunction() + +# Helper functions: +function(_qbs_qdoc_build_qdocconf_file _qdocconf_file) + _qbs_setup_doc_targets() + + _qbs_doc_find_program(_qdoc NAMES qdoc qdoc-qt5) + if (_qdoc STREQUAL "_prg__qdoc-NOTFOUND") + message(WARNING "No qdoc binary found: No documentation targets were generated") + return() + endif() + + cmake_parse_arguments(_arg "QCH" "HTML_DIR;QCH_DIR;INSTALL_DIR;POSTFIX" + "INDEXES;INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;ENVIRONMENT_EXPORTS;SOURCES" ${ARGN}) + if (_arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "qdoc_build_qdocconf_file has unknown arguments: ${_arg_UNPARSED_ARGUMENTS}.") + endif() + + if (NOT _arg_INSTALL_DIR) + message(FATAL_ERROR "No INSTALL_DIR set when calling qdoc_build_qdocconf_file") + endif() + + _qbs_setup_qdoc_targets("${_qdocconf_file}" _html_outputdir + HTML_DIR "${_arg_HTML_DIR}" INSTALL_DIR "${_arg_INSTALL_DIR}" + INDEXES ${_arg_INDEXES} ENVIRONMENT_EXPORTS ${_arg_ENVIRONMENT_EXPORTS} + POSTFIX "${_arg_POSTFIX}" + INCLUDE_DIRECTORIES ${_arg_INCLUDE_DIRECTORIES} + FRAMEWORK_PATHS ${_arg_FRAMEWORK_PATHS} + SOURCES ${_arg_SOURCES} + ) + + if (_arg_QCH) + _qbs_setup_qhelpgenerator_targets("${_qdocconf_file}" "${_html_outputdir}" + QCH_DIR "${_arg_QCH_DIR}" INSTALL_DIR "${_arg_INSTALL_DIR}") + endif() + +endfunction() + +function(add_qbs_documentation qdocconf_file) + cmake_parse_arguments(_arg "" "" + "INCLUDE_DIRECTORIES;FRAMEWORK_PATHS;SOURCES" ${ARGN}) + if (_arg_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "add_qbs_documentation has unknown arguments: ${_arg_UNPARSED_ARGUMENTS}.") + endif() + + ### Skip docs setup if that is not needed! + if (NOT QBS_INSTALL_HTML_DOCS AND NOT QBS_INSTALL_QCH_DOCS) + return() + endif() + + qt_query_qmake() + set(SRCDIR "${Qbs_SOURCE_DIR}/doc") + + set(_qch_params) + if (QBS_INSTALL_QCH_DOCS) + set(_qch_params QCH QCH_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + set(_qdoc_params HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html") + list(APPEND _qdoc_params INSTALL_DIR "${QBS_DOC_INSTALL_DIR}") + + # Set up environment for qdoc: + string(REPLACE "." "" QBS_VERSION_TAG "${QBS_VERSION}") + + list(APPEND _qdoc_params ENVIRONMENT_EXPORTS + SRCDIR QBS_VERSION QBS_VERSION_TAG + QT_INSTALL_DOCS + ) + + _qbs_qdoc_build_qdocconf_file(${qdocconf_file} ${_qch_params} ${_qdoc_params} + INCLUDE_DIRECTORIES ${_arg_INCLUDE_DIRECTORIES} + FRAMEWORK_PATHS ${_arg_FRAMEWORK_PATHS} + SOURCES ${_arg_SOURCES} + ) +endfunction() diff --git a/dist/.gitignore b/dist/.gitignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/dist/.gitignore @@ -0,0 +1 @@ +* diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..5b8ac763 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,28 @@ +set(_DOC_SOURCES + ../README.md + ../CONTRIBUTING.md + classic.css + external-resources.qdoc + fixnavi.pl + howtos.qdoc + qbs.qdoc + qbs-online.qdocconf + config/style/qt5-sidebar.html + ) + +file(GLOB_RECURSE _DOC_APPENDIX_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/appendix/*") +file(GLOB_RECURSE _DOC_REFERENCE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/reference/*") +file(GLOB_RECURSE _DOC_TEMPLATES_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/templates/*") +file(GLOB_RECURSE _DOC_IMAGES_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/images/*") +file(GLOB_RECURSE _DOC_TARGETS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targets/*") + +add_qbs_documentation( + "qbs.qdocconf" + SOURCES + ${_DOC_SOURCES} + ${_DOC_APPENDIX_SOURCES} + ${_DOC_REFERENCE_SOURCES} + ${_DOC_TEMPLATES_SOURCES} + ${_DOC_IMAGES_SOURCES} + ${_DOC_TARGETS_SOURCES} + ) diff --git a/doc/appendix/json-api.qdoc b/doc/appendix/json-api.qdoc new file mode 100644 index 00000000..68bb644c --- /dev/null +++ b/doc/appendix/json-api.qdoc @@ -0,0 +1,811 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \previouspage porting-to-qbs.html + \nextpage attributions.html + \page json-api.html + + \title Appendix C: The JSON API + + This API is the recommended way to provide \QBS support to an IDE. + It is accessible via the \l{session} command. + + \section1 Packet Format + + All information is exchanged via \e packets, which have the following + structure: + \code + packet = "qbsmsg:" [] + \endcode + First comes a fixed string indentifying the start of a packet, followed + by the size of the actual data in bytes. After that, further meta data + might follow. There is none currently, but future extensions might add + some. A line feed character marks the end of the meta data section + and is followed immediately by the payload, which is a single JSON object + encoded in Base64 format. We call this object a \e message. + + \section1 Messages + + The message data is UTF8-encoded. + + Most messages are either \e requests or \e replies. Requests are messages + sent to \QBS via the session's standard input channel. Replies are messages + sent by \QBS via the session's standard output channel. A reply always + corresponds to one specific request. Every request (with the exception + of the \l{quit-message}{quit request}) expects exactly one reply. A reply implies + that the requested operation has finished. At the very least, it carries + information about whether the operation succeeded, and often contains + additional data specific to the respective request. + + Every message object has a \c type property, which is a string that uniquely + identifies the message type. + + All requests block the session for other requests, including those of the + same type. For instance, if client code wishes to restart building the + project with different parameters, it first has to send a + \l{cancel-message}{cancel} request, wait for the current build job's reply, + and only then can it request another build. The only other message beside + \l{cancel-message}{cancel} that can legally be sent while a request + is currently being handled is the \l{quit-message}{quit} message. + + A reply object may carry an \c error property, indicating that the respective + operation has failed. If this property is not present, the request was successful. + The format of the \c error property is described \l{ErrorInfo}{here}. + + In the remainder of this page, we describe the structure of all messages + that can be sent to and received from \QBS, respectively. The property + tables may have a column titled \e Mandatory, whose values indicate whether + the respective message property is always present. If this column is missing, + all properties of the respective message are mandatory, unless otherwise + noted. + + \section1 The \c hello Message + + This message is sent by \QBS exactly once, right after the session was started. + It is the only message from \QBS that is not a response to a request. + The value of the \c type property is \c "hello", the other properties are + as follows: + \table + \header \li Property \li Type + \row \li api-level \li int + \row \li api-compat-level \li int + \endtable + + The value of \c api-level is increased whenever the API is extended, for instance + by adding new messages or properties. + + The value of \c api-compat-level is increased whenever incompatible changes + are being done to this API. A tool written for API level \c n should refuse + to work with a \QBS version with an API compatibility level greater than \c n, + because it cannot guarantee proper behavior. This value will not change unless + it is absolutely necessary. + + The value of \c api-compat-level is always less than or equal to the + value of \c api-level. + + \section1 Resolving a Project + + To instruct \QBS to load a project from disk, a request of type + \c resolve-project is sent. The other properties are: + \table + \header \li Property \li Type \li Mandatory + \row \li build-root \li \l FilePath \li yes + \row \li configuration-name \li string \li no + \row \li data-mode \li \l DataMode \li no + \row \li dry-run \li bool \li no + \row \li environment \li \l Environment \li no + \row \li error-handling-mode \li string \li no + \row \li fallback-provider-enabled \li bool \li no + \row \li force-probe-execution \li bool \li no + \row \li log-time \li bool \li no + \row \li log-level \li \l LogLevel \li no + \row \li module-properties \li list of strings \li no + \row \li overridden-properties \li object \li no + \row \li project-file-path \li FilePath \li if resolving from scratch + \row \li restore-behavior \li string \li no + \row \li settings-directory \li string \li no + \row \li top-level-profile \li string \li no + \row \li wait-lock-build-graph \li bool \li no + \endtable + + The \c environment property defines the environment to be used for resolving + the project, as well as for all subsequent \QBS operations on this project. + + The \c error-handling-mode specifies how \QBS should deal with issues + in project files, such as assigning to an unknown property. The possible + values are \c "strict" and \c "relaxed". In strict mode, \QBS will + immediately abort and set the reply's \c error property accordingly. + In relaxed mode, \QBS will continue to resolve the project if possible. + A \l{warning-message}{warning message} will be emitted for every error that + was encountered, and the reply's \c error property will \e not be set. + The default error handling mode is \c "strict". + + If the \c log-time property is \c true, then \QBS will emit \l log-data messages + containing information about which part of the operation took how much time. + + The \c module-properties property lists the names of the module properties + which should be contained in the \l{ProductData}{product data} that + will be sent in the reply message. For instance, if the project to be resolved + is C++-based and the client code is interested in which C++ version the + code uses, then \c module-properties would contain \c{"cpp.cxxLanguageVersion"}. + + The \c overridden-properties property is used to override the values of + module, product or project properties. The possible ways to specify + keys are described \l{Overriding Property Values from the Command Line}{here}. + + The \c restore-behavior property specifies if and how to make use of + an existing build graph. The value \c "restore-only" indicates that + a build graph should be loaded from disk and used as-is. In this mode, + it is an error if the build graph file does not exist. + The value \c "resolve-only" indicates that the project should be resolved + from scratch and that an existing build graph should be ignored. In this mode, + it is an error if the \c "project-file-path" property is not present. + The default value is \c "restore-and-track-changes", which uses an + existing build graph if possible and re-resolves the project if no + build graph was found or if the parameters are different from the ones + used when the project was last resolved. + + The \c top-level-profile property specifies which \QBS profile to use + for resolving the project. It corresponds to the \c profile key when + using the \l resolve command. + + All other properties correspond to command line options of the \l resolve + command, and their semantics are described there. + + When the project has been resolved, \QBS will reply with a \c project-resolved + message. The possible properties are: + \table + \header \li Property \li Type \li Mandatory + \row \li error \li \l ErrorInfo \li no + \row \li project-data \li \l TopLevelProjectData \li no + \endtable + + The \c error-info property is present if and only if the operation + failed. The \c project-data property is present if and only if + the conditions stated by the request's \c data-mode property + are fulfilled. + + All other project-related requests need a resolved project to operate on. + If there is none, they will fail. + + There is at most one resolved project per session. If client code wants to + open several projects or one project in different configurations, it needs + to start additional sessions. + + \section1 Building a Project + + To build a project, a request of type \c build-project is sent. The other properties, + none of which are mandatory, are listed below: + \table + \header \li Property \li Type + \row \li active-file-tags \li string list + \row \li changed-files \li \l FilePath list + \row \li check-outputs \li bool + \row \li check-timestamps \li bool + \row \li clean-install-root \li bool + \row \li data-mode \li \l DataMode + \row \li dry-run \li bool + \row \li command-echo-mode \li string + \row \li enforce-project-job-limits \li bool + \row \li files-to-consider \li \l FilePath list + \row \li install \li bool + \row \li job-limits \li list of objects + \row \li keep-going \li bool + \row \li log-level \li \l LogLevel + \row \li log-time \li bool + \row \li max-job-count \li int + \row \li module-properties \li list of strings + \row \li products \li list of strings or \c "all" + \endtable + + All boolean properties except \c install default to \c false. + + The \c active-file-tags and \c files-to-consider are used to limit the + build to certain output tags and/or source files. + For instance, if only C/C++ object files should get built, then + \c active-file-tags would be set to \c "obj". + + The objects in a \c job-limits array consist of a string property \c pool + and an int property \c limit. + + If the \c log-time property is \c true, then \QBS will emit \l log-data messages + containing information about which part of the operation took how much time. + + If \c products is an array, the elements must correspond to the + \c full-display-name property of previously retrieved \l ProductData, + and only these products will get built. + If \c products is the string \c "all", then all products in the project will + get built. + If \c products is not present, then products whose + \l{Product::builtByDefault}{builtByDefault} property is \c false will + be skipped. + + The \c module-properties property has the same meaning as in the + \l{Resolving a Project}{resolve-project} request. + + All other properties correspond to options of the \l build command. + + When the build has finished, \QBS will reply with a \c project-built + message. The possible properties are: + \table + \header \li Property \li Type \li Mandatory + \row \li error \li \l ErrorInfo \li no + \row \li project-data \li \l TopLevelProjectData \li no + \endtable + + The \c error-info property is present if and only if the operation + failed. The \c project-data property is present if and only if + the conditions stated by the request's \c data-mode property + are fulfilled. + + Unless the \c command-echo-mode value is \c "silent", a message of type + \c command-description is emitted for every command to be executed. + It consists of two string properties \c highlight and \c message, + where \c message is the message to present to the user and \c highlight + is a hint on how to display the message. It corresponds to the + \l{Command and JavaScriptCommand}{Command} property of the same name. + + For finished process commands, a message of type \c process-result + might be emitted. The other properties are: + \table + \header \li Property \li Type + \row \li arguments \li list of strings + \row \li error \li string + \row \li executable-file-path \li \l FilePath + \row \li exit-code \li int + \row \li stderr \li list of strings + \row \li stdout \li list of strings + \row \li success \li bool + \row \li working-directory \li \l FilePath + \endtable + + The \c error string is one of \c "failed-to-start", \c "crashed", \c "timed-out", + \c "write-error", \c "read-error" and \c "unknown-error". + Its value is not meaningful unless \c success is \c false. + + The \c stdout and \c stderr properties describe the process's standard + output and standard error output, respectively, split into lines. + + The \c success property is \c true if the process finished without errors + and an exit code of zero. + + The other properties describe the exact command that was executed. + + This message is only emitted if the process failed or it has printed data + to one of the output channels. + + \section1 Cleaning a Project + + To remove a project's build artifacts, a request of type \c clean-project + is sent. The other properties are: + \table + \header \li Property \li Type + \row \li dry-run \li bool + \row \li keep-going \li bool + \row \li log-level \li \l LogLevel + \row \li log-time \li bool + \row \li products \li list of strings + \endtable + + The elements of the \c products array correspond to a \c full-display-name + of a \l ProductData. If this property is present, only the respective + products' artifacts are removed. + + If the \c log-time property is \c true, then \QBS will emit \l log-data messages + containing information about which part of the operation took how much time. + + All other properties correspond to options of the \l clean command. + + None of these properties are mandatory. + + After all artifacts have been removed, \QBS replies with a + \c project-cleaned message. If the operation was successful, this message + has no properties. Otherwise, a property \c error of type \l ErrorInfo + indicates what went wrong. + + \section1 Installing a Project + + Installing is normally part of the \l{Building a Project}{build} + process. To do it in a separate step, the \c install property + is set to \c false when building and a dedicated \c install-project + message is sent. The other properties are: + \table + \header \li Property \li Type + \row \li clean-install-root \li bool + \row \li dry-run \li bool + \row \li install-root \li \l FilePath + \row \li keep-going \li bool + \row \li log-level \li \l LogLevel + \row \li log-time \li bool + \row \li products \li list of strings + \row \li use-sysroot \li bool + \endtable + + The elements of the \c products array correspond to a \c full-display-name + of a \l ProductData. If this property is present, only the respective + products' artifacts are installed. + + If the \c log-time property is \c true, then \QBS will emit \l log-data messages + containing information about which part of the operation took how much time. + + If the \c use-sysroot property is \c true and \c install-root is not present, + then the install root will be \l{qbs::sysroot}{qbs.sysroot}. + + All other properties correspond to options of the \l install command. + + None of these properties are mandatory. + + \target cancel-message + \section1 Canceling an Operation + + Potentially long-running operations can be aborted using the \c cancel-job + request. This message does not have any properties. There is no dedicated + reply message; instead, the usual reply for the request associated with + the currently running operation will be sent, with the \c error property + set to indicate that it was canceled. + + If there is no operation in progress, this request will have no effect. + In particular, if it arrives after the operation that it was supposed to + cancel has already finished (i.e. there is a race condition), the reply + received by client code will not contain a cancellation-related error. + + \section1 Adding and Removing Source Files + + Source files can be added to and removed from \QBS project files with + the \c add-files and \c remove-files messages, respectively. These two + requests have the same set of properties: + \table + \header \li Property \li Type + \row \li files \li \l FilePath list + \row \li group \li string + \row \li product \li string + \endtable + + The \c files property specifies which files should be added or removed. + + The \c product property corresponds to the \c full-display-name of + a \l ProductData and specifies to which product to apply the operation. + + The \c group property corresponds to the \c name of a \l GroupData + and specifies to which group in the product to apply the operation. + + After the operation has finished, \QBS replies with a \c files-added + and \c files-removed message, respectively. Again, the properties are + the same: + \table + \header \li Property \li Type \li Mandatory + \row \li error \li \l ErrorInfo \li no + \row \li failed-files \li \l FilePath list \li no + \endtable + + If the \c error property is present, the operation has at least + partially failed and \c failed-files will list the files + that could not be added or removed. + + \section1 The \c get-run-environment Message + + This request retrieves the full run environment for a specific + executable product, taking into account the + \l{Module::setupRunEnvironment}{setupRunEnvironment} scripts + of all modules pulled in by the product. The properties are as follows: + \table + \header \li Property \li Type \li Mandatory + \row \li base-environment \li \l Environment \li no + \row \li config \li list of strings \li no + \row \li product \li string \li yes + \endtable + + The \c base-environment property defines the environment into which + the \QBS-specific values should be merged. + + The \c config property corresponds to the \l{--setup-run-env-config} + option of the \l run command. + + The \c product property specifies the product whose environment to + retrieve. The value must correspond to the \c full-display-name + of some \l ProductData in the project. + + \QBS will reply with a \c run-environment message. In case of failure, + it will contain a property \c error of type \l ErrorInfo, otherwise + it will contain a property \c full-environment of type \l Environment. + + \section1 The \c get-generated-files-for-sources Message + + This request allows client code to retrieve information about + which artifacts are generated from a given source file. + Its sole property is a list \c products, whose elements are objects + with the two properties \c full-display-name and \c requests. + The first identifies the product to which the requests apply, and + it must match the property of the same name in a \l ProductData + in the project. + The latter is a list of objects with the following properties: + \table + \header \li Property \li Type \li Mandatory + \row \li source-file \li \l FilePath \li yes + \row \li tags \li list of strings \li no + \row \li recursive \li bool \li no + \endtable + + The \c source-file property specifies a source file in the respective + product. + + The \c tags property constrains the possible file tags of the generated + files to be matched. This is relevant if a source files serves as input + to more than one rule or the rule generates more than one type of output. + + If the \c recursive property is \c true, files indirectly generated + from the source file will also be returned. The default is \c false. + For instance, íf this property is enabled for a C++ source file, + the final link target (e.g. a library or an application executable) + will be returned in addition to the object file. + + \QBS will reply with a \c generated-files-for-sources message, whose + structure is similar to the request. It also has a single object list + property \c products, whose elements consist of a string property + \c full-display-name and an object list property \c results. + The properties of these objects are: + \table + \header \li Property \li Type + \row \li source-file \li \l FilePath + \row \li generated-files \li \l FilePath list + \endtable + + The \c source-file property corresponds to an entry of the same name + in the request, and the \c generated-files are the files which are + generated by \QBS rules that take the source file as an input, + taking the constraints specified in the request into account. + + Source files for which the list would be empty are not listed. + Similarly, products for which the \c results list would be empty + are also omitted. + + \note The results may be incomplete if the project has not been fully built. + + \section1 Closing a Project + + A project is closed with a \c release-project message. This request has + no properties. + + \QBS will reply with a \c project-released message. If no project was open, + the reply will contain an \c error property of type \l ErrorInfo. + + \target quit-message + \section1 Closing the Session + + To close the session, a \c quit message is sent. This request has no + properties. + + \QBS will cancel all currently running operations and then close itself. + No reply will be sent. + + \section1 Progress Messages + + While a request is being handled, \QBS may emit progress information in order + to enable client code to display a progress bar. + + \target task-started + \section2 The \c task-started Message + + This is always the first progress-related message for a specific request. + It appears at most once per request. + It consists of a string property \c description, whose value can be displayed + to users, and an integer property \c max-progress that indicates which + progress value corresponds to 100 per cent. + + \target task-progress + \section2 The \c task-progress Message + + This message updates the progress via an integer property \c progress. + + \target new-max-progress + \section2 The \c new-max-progress Message + + This message is emitted if the original estimated maximum progress has + to be corrected. Its integer property \c max-progress updates the + value from a preceding \l task-started message. + + \section1 Messages for Users + + There are two types of messages that purely contain information to be + presented to users. + + \target log-data + \section2 The \c log-data Message + + This object has a string property \c message, which is the text to be + shown to the user. + + \target warning-message + \section2 The \c warning Message + + This message has a single property \c warning of type \l ErrorInfo. + + \section1 The \c protocol-error Message + + \QBS sends this message as a reply to a request with an unknown \c type. + It contains an \c error property of type \l ErrorInfo. + + \section1 Project Data + + If a request can alter the build graph data, the associated reply may contain + a \c project-data property whose value is of type \l TopLevelProjectData. + + \section2 TopLevelProjectData + + This data type represents the entire project. It has the same properties + as \l PlainProjectData. If it is part of a \c project-resolved message, + these additional properties are also present: + \table + \header \li Property \li Type + \row \li build-directory \li \l FilePath + \row \li build-graph-file-path \li \l FilePath + \row \li build-system-files \li \l FilePath list + \row \li overridden-properties \li object + \row \li profile-data \li object + \endtable + + The value of \c build-directory is the top-level build directory. + + The \c build-graph-file-path value is the path to the build graph file. + + The \c build-system-files value contains all \QBS project files, including + modules and JavaScript helper files. + + The value of \c overridden-properties is the one that was passed in when + the project was last \l{Resolving a Project}{resolved}. + + The \c profile-data property maps the names of the profiles used in the project + to the respective property maps. Unless profile multiplexing is used, this + object will contain exactly one property. + + \section2 PlainProjectData + + This data type describes a \l Project item. The properties are as follows: + \table + \header \li Property \li Type + \row \li is-enabled \li bool + \row \li location \li \l FilePath + \row \li name \li string + \row \li products \li \l ProductData list + \row \li sub-projects \li \l PlainProjectData list + \endtable + + The \c is-enabled property corresponds to the project's + \l{Project::condition}{condition}. + + The \c location property is the exact position in a \QBS project file + where the corresponding \l Project item was defined. + + The \c products and \c sub-projects are what the project has pulled in via + its \l{Project::references}{references} property. + + \section2 ProductData + + This data type describes a \l Product item. The properties are as follows: + \table + \header \li Property \li Type + \row \li build-directory \li \l FilePath + \row \li dependencies \li list of strings + \row \li full-display-name \li string + \row \li generated-artifacts \li \l ArtifactData list + \row \li groups \li \l GroupData list + \row \li is-enabled \li bool + \row \li is-multiplexed \li bool + \row \li is-runnable \li bool + \row \li location \li \l Location + \row \li module-properties \li \l ModulePropertiesData + \row \li multiplex-configuration-id \li string + \row \li name \li string + \row \li properties \li object + \row \li target-executable \li \l FilePath + \row \li target-name \li string + \row \li type \li list of strings + \row \li version \li string + \endtable + + The elements of the \c dependencies array correspond to the full-display-name + properties of the products that this product has pulled in via \l Depends items. + + The \c generated-artifacts are files that are created by the \l{Rule}{rules} + in this product. + + The \c groups list corresponds to the \l Group items in this product. + In addition, a "pseudo-group" is created for the \l{Product::files}{files} + property of the product itself. Its name is the same as the product's. + + The \c is-enabled property corresponds to the product's + \l{Product::condition}{condition}. A product may also get disabled + if it contains errors and \QBS was was instructed to operate in relaxed mode + when the project was \l{Resolving a Project}{resolved}. + + The \c is-multiplexed property is true if and only if the product is + \l{Multiplexing}{multiplexed} over one ore more properties. + + The \c is-runnable property indicates whether one of the product's + target artifacts is an executable file. + In that case, the file is available via the \c target-executable property. + + The \c location property is the exact position in a \QBS project file + where the corresponding \l Product item was defined. + + The \c module-properties object provides the values of the module properties + that were requested when the project was \l{Resolving a Project}{resolved}. + + The \c name property is the value given in the \l{Product::name}{Product item}, + whereas \c full-display-name is a name that uniquely identifies the + product in the entire project, even in the presence of multiplexing. + In the absence of multiplexing, it is the same as \c name. In either case, + it is suitable for being presented to users. + + See the \l Product item documentation for a description of the other + properties. + + \section2 GroupData + + This data type describes a \l Group item. The properties are: + \table + \header \li Property \li Type + \row \li is-enabled \li bool + \row \li location \li \l Location + \row \li module-properties \li \l ModulePropertiesData + \row \li name \li string + \row \li prefix \li string + \row \li source-artifacts \li \l ArtifactData list + \row \li source-artifacts-from-wildcards \li \l ArtifactData list + \endtable + + The \c is-enabled property corresponds to the groups's + \l{Group::condition}{condition}. However, if the group's product + is disabled, this property will always be \c false. + + The \c location property is the exact position in a \QBS project file + where the corresponding \l Group item occurs. + + The \c module-properties object provides the values of the module properties + that were requested when the project was \l{Resolving a Project}{resolved}. + If no module properties are set on the Group level and the value would therefore + be the same as in the group's product, then this property is omitted. + + The \c source-artifacts list corresponds the the files listed verbatim + in the group's \l{Group::files}{files} property. + + The \c source-artifacts-from-wildcards list represents the the files + expanded from wildcard entries in the group's \l{Group::files}{files} property. + + See the \l Group item documentation for a description of the other + properties. + + \section2 ArtifactData + + This data type represents files that occur in the project, either as sources + or as outputs of a rules. \QBS project files, on the other hand, are not + artifacts. The properties are: + \table + \header \li Property \li Type + \row \li file-path \li \l FilePath + \row \li file-tags \li list of strings + \row \li install-data \li object + \row \li is-executable \li bool + \row \li is-generated \li bool + \row \li is-target \li bool + \row \li module-properties \li \l ModulePropertiesData + \endtable + + The \c install-data property is an object whose \c is-installable property + indicates whether the artifact gets installed. If so, then the \l FilePath + properties \c install-file-path and \c install-root provide further + information. + + The \c is-target property is true if the artifact is a target artifact + of its product, that is, \c is-generated is true and \c file-tags + intersects with the \l{Product::type}{product type}. + + The \c module-properties object provides the values of the module properties + that were requested when the project was \l{Resolving a Project}{resolved}. + This property is only present for generated artifacts. For source artifacts, + the value can be retrieved from their \l{GroupData}{group}. + + The other properties should be self-explanatory. + + \section2 ModulePropertiesData + + This data type maps fully qualified module property names to their + respective values. + + \section1 Other Custom Data Types + + There are a number of custom data types that serve as building blocks in + various messages. They are described below. + + \section2 FilePath + + A \e FilePath is a string that describes a file or directory. FilePaths are + always absolute and use forward slashes for separators, regardless of + the host operating system. + + \section2 Location + + A \e Location is an object representing a file path and possibly also a position + within the respective file. It consists of the following properties: + \table + \header \li Property \li Type \li Mandatory + \row \li file-path \li \l FilePath \li yes + \row \li line \li int \li no + \row \li column \li int \li no + \endtable + + \section2 ErrorInfo + + An \e ErrorInfo is an object representing error information. Its sole property + \c items is an array of objects with the following structure: + \table + \header \li Property \li Type \li Mandatory + \row \li description \li string \li yes + \row \li location \li \l Location \li no + \endtable + + \section2 DataMode + + This is the type of the \c data-mode property in a + \l{Resolving a project}{resolve} or \l{Building a project}{build} + request. It is used to indicate under which circumstances + the reply message should include the project data. The possible + values have string type and are as follows: + \list + \li \c "never": Do not attach project data to the reply. + \li \c "always": Do attach project data to the reply. + \li \c "only-if-changed": Attach project data to the reply only + if it is different from the current + project data. + \endlist + The default value is \c "never". + + \section2 LogLevel + + This is the type of the \c log-level property that can occur + in various requests. It is used to indicate whether the client would like + to receive \l log-data and/or \l{warning-message}{warning} messages. + The possible values have string type and are as follows: + \list + \li "error": Do not log anything. + \li "warning": \QBS may emit \l{warning-message}{warnings}, but no + \l log-data messages. + \li "info": In addition to warnings, \QBS may emit informational + \l log-data messages. + \li "debug": \QBS may emit debug output. No messages will be generated; + instead, the standard error output channel will be used. + \endlist + The default value is \c "info". + + \section2 Environment + + This data type describes a set of environment variables. It is an object + whose keys are names of environment variables and whose values are + the values of these environment variables. + +*/ diff --git a/doc/appendix/qbs-porting.qdoc b/doc/appendix/qbs-porting.qdoc new file mode 100644 index 00000000..47e5f767 --- /dev/null +++ b/doc/appendix/qbs-porting.qdoc @@ -0,0 +1,503 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \previouspage building-qbs.html + \page porting-to-qbs.html + \nextpage json-api.html + + \title Appendix B: Migrating from Other Build Systems + + You can use the \l{create-project}{qbs create-project} command to + automatically generate \QBS project files from an arbitrary directory + structure. This is a useful starting point when migrating from other + build tools, such as qmake or CMake. + + To use the tool, switch to the project directory and run the + \c {qbs create-project} command, which is located in the \c bin directory of + the \QBS installation directory (or the Qt Creator installation directory). + + After generating the initial .qbs file, add the missing configuration + variables and functions to it, as described in the following sections. + + \section1 Migrating from qmake + + The following sections describe the \QBS equivalents of qmake variable + values. + + \section2 CONFIG + + Specify project configuration and compiler options. + + \section3 console + + Set the \l{Product::consoleApplication}{Product.consoleApplication} property + to \c true for the \l{Application}, \l{CppApplication},or \l{QtApplication} + item. For example: + + \code + Application { + name: "helloworld" + files: "main.cpp" + Depends { name: "cpp" } + consoleApplication: true + } + \endcode + + \section3 ordered + + This qmake variable has no direct equivalent in \QBS. Instead, the build + order is determined by implicit and explicit dependencies between products. + To add an explicit dependency, add a \l{Depends} item to a + \l{Product}{product}: + + \code + CppApplication { + name: "myapp" + Depends { name: "mylib" } + } + \endcode + + The \c myapp product depends on and links to the \c mylib product, and is + therefore built after it. + + \section3 qt + + In qmake, the Qt dependency is implicit, whereas in \QBS it is not. + If \c {CONFIG -= qt}, add a \l{Depends} item to specify that + the \l{Product}{product} depends on the \l{cpp} module: + + \code + Product { + Depends { name: "cpp" } + } + \endcode + + \section2 DEFINES + + Set the \l{cpp::defines}{cpp.defines} property for the \l{Product}{product}. + + \note To reference \c cpp.defines, you must specify a dependency on the + \l{cpp} module. + + \code + Product { + Depends { name: "cpp" } + cpp.defines: ["SUPPORT_MY_FEATURES"] + } + \endcode + + \section2 DESTDIR + + We recommend that you use the \l{Installing Files}{installation mechanism} + to specify the location of the target file: + + \code + Application { + Group { + name: "Runtime resources" + files: "*.qml" + qbs.install: true + qbs.installDir: "share/myproject" + } + Group { + name: "The App itself" + fileTagsFilter: "application" + qbs.install: true + qbs.installDir: "bin" + } + } + \endcode + + If that is not possible, you can use the \l{Product::}{destinationDirectory} + property: + + \code + DynamicLibrary { + name: "mydll" + destinationDirectory: "libDir" + } + \endcode + + \section2 HEADERS, SOURCES, FORMS, RESOURCES, OTHER_FILES + + Include header, source, form, and resource files as well as any + other files as values of a \l{Product::files}{Product.files} + or \l{Group::files}{Group.files} property: + + \code + QtApplication { + name: "myapp" + files: ["myapp.h", "myapp.cpp", "myapp.ui", "myapp.qrc", "readme.txt"] + } + \endcode + + \QBS uses \l{FileTagger}{file taggers} to figure out what kind of file + it is dealing with. + + \section2 ICON + + There is no direct equivalent in \QBS. If you add a \l{Depends} {dependency} + to the \l{ib} module and add the \c .xcassets directory as a value of the + \l{Product::files}{Product.files} property, \QBS takes care of setting the + application icon automatically when building for Apple platforms: + + \code + Application { + name: "myapp" + files [".xcassets"] + Depends { name: "ib" } + } + \endcode + + Alternatively, you can set the icon name as the value of the + \l{bundle::infoPlist}{bundle.infoPlist} parameter, specify a dependency to + the \l{ib} module, and add the application \c .icns file as a value of the + \l{Product::}{files} property: + + \code + Application { + name: "myapp" + files ["myapp.icns"] + Depends { name: "ib" } + bundle.infoPlist: ({"CFBundleIconFile": "myapp"}) + \endcode + + \section2 INCLUDEPATH + + Add the paths to the include files as values of the \l{cpp::includePaths} + {cpp.includePaths} property: + + \code + CppApplication { + cpp.includePaths: ["..", "some/other/dir"] + } + \endcode + + \section2 LIBS + + For libraries that are part of the project, use \l{Depends} items. + + To pull in external libraries, use the \l{cpp::libraryPaths} + {cpp.libraryPaths} property for the Unix \c -L (library path) flags and the + \l{cpp::dynamicLibraries}{cpp.dynamicLibraries} and \l{cpp::staticLibraries} + {cpp.staticLibraries} properties for the + \c -l (library) flags. + + For example, \c {LIBS += -L/usr/local/lib -lm} would become: + + \code + CppApplication { + cpp.libraryPaths: ["/usr/local/lib"] + cpp.dynamicLibraries: ["m"] + } + \endcode + + \section2 OUT_PWD + + Use the \l{Product::buildDirectory}{Product.buildDirectory} property + to refer to the base output directory of the generated artifacts. + + \section2 PWD + + Corresponds to the the file-scope variable \c path. + + \section2 _PRO_FILE_ + + Corresponds to the file-scope variable \c filePath when used in a + \l{Project}{project} or \l{Product}{product}. + + \section2 _PRO_FILE_PWD_ + + Corresponds to the \l{Project::sourceDirectory}{Project.sourceDirectory} or + \l{Product::sourceDirectory}{Product.sourceDirectory} property. + + \section2 QMAKE_ASSET_CATALOGS + + Add a \l{Depends}{dependency} to the \l{ib} module and add the \c .xcassets + directory as a value of the \l{Product::}{files} property: + + \code + Application { + name: "myapp" + files [".xcassets"] + Depends { name: "ib" } + } + \endcode + + \section2 QMAKE_BUNDLE_DATA + + For the time being, you can manually place files in the appropriate location + using the \l{Installing Files}{installation mechanism}. Better solutions are + under development. + + \section2 QMAKE_BUNDLE_EXTENSION + + Set the \l{bundle::extension}{bundle.extension} property. + + \note Unlike qmake, \QBS automatically prepends a period (.) to the property + value. + + \section2 QMAKE_{C,CXX,OBJECTIVE}_CFLAGS{_DEBUG,_RELEASE} + + Use the \l{cpp::commonCompilerFlags}{cpp.commonCompilerFlags} property or + the properties corresponding to each compiler flags variable: + + \table + \header + \li qmake Variable + \li cpp Module Property + \row + \li \c QMAKE_CFLAGS_DEBUG + + \c QMAKE_CFLAGS_RELEASE + \li \l{cpp::cFlags}{cpp.cFlags} + \row + \li \c QMAKE_CXXFLAGS_DEBUG + + \c QMAKE_CXXFLAGS_RELEASE + \li \l{cpp::cxxFlags}{cpp.cxxFlags} + \row + \li \c QMAKE_OBJECTIVE_CFLAGS + \li \l{cpp::objcFlags}{cpp.objcFlags} + + \l{cpp::objcxxFlags}{cpp.objcxxFlags} + \endtable + + Use \l{Properties} items or simple conditionals as values of the + \l{qbs::buildVariant}{qbs.buildVariant} property to simulate the \c _DEBUG + and \c _RELEASE variants of the qmake variables. + + \section2 QMAKE_FRAMEWORK_BUNDLE_NAME + + Set the \l{bundle::bundleName}{bundle.bundleName} property (which is derived + from \l{Product::targetName}{Product.targetName}) combined with + \l{bundle::extension}{bundle.extension}. + + \section2 QMAKE_FRAMEWORK_VERSION + + Set the \l{bundle::frameworkVersion}{bundle.frameworkVersion} property. + + \section2 QMAKE_INFO_PLIST + + Include the \c info.plist file as a value of \l{Product::}{files} property + and specify a dependency to the \l{bundle} module: + + \code + Application { + name: "myapp" + files ["info.plist"] + Depends { name: "bundle" } + } + \endcode + + \QBS will automatically add any necessary properties to your \c Info.plist + file. Typically, it determines the appropriate values from the other + properties in the project, and therefore you do not need to use the + \c {Info.plist.in > Info.plist} configuration mechanism. Further, you almost + never need to embed placeholders into the source \c Info.plist file. Set the + \l{bundle::processInfoPlist}{bundle.processInfoPlist} property to \c false + to disable this behavior: + + \code + \\ ... + bundle.processInfoPlist: false + \endcode + + In addition to, or instead of, using an actual \c Info.plist file, you can + add \c Info.plist properties using the \l{bundle::infoPlist} + {bundle.infoPlist} property. For example: + + \code + \\ ... + bundle.infoPlist: ({ + "NSHumanReadableCopyright": "Copyright (c) 2017 Bob Inc", + "Some other key", "Some other value, & XML special characters are no problem! >;) 非凡!" + }) + \endcode + + \section2 QMAKE_LFLAGS + + Set the \l{cpp::linkerFlags}{cpp.linkerFlags} property for the \l{Product} + {product}. + + \section2 QMAKE_{MACOSX,IOS,TVOS,WATCHOS}_DEPLOYMENT_TARGET + + For each qmake deployment target variable, use the corresponding property of + the \l{cpp} module: + + \table + \header + \li qmake Variable + \li cpp Module Property + \row + \li \c QMAKE_MACOSX_DEPLOYMENT_TARGET + \li \l{cpp::minimumMacosVersion}{cpp.minimumMacosVersion} + \row + \li \c QMAKE_IOS_DEPLOYMENT_TARGET + \li \l{cpp::minimumIosVersion}{cpp.minimumIosVersion} + \row + \li \c QMAKE_TVOS_DEPLOYMENT_TARGET + \li \l{cpp::minimumTvosVersion}{cpp.minimumTvosVersion} + \row + \li \c QMAKE_WATCHOS_DEPLOYMENT_TARGET + \li \l{cpp::minimumWatchosVersion}{cpp.minimumWatchosVersion} + \endtable + + \section2 QMAKE_RPATHDIR + + Set the \l{cpp::rpaths}{cpp.rpaths} property for the \l{Product}{product}. + + \section2 QMAKE_SONAME_PREFIX + + Use the \l{cpp::sonamePrefix}{cpp.sonamePrefix} property for the \l{Product} + {product}. + + \section2 QML_IMPORT_PATH + + Used only for Qt Creator QML syntax highlighting. Inside a \l{Product}, + \l{Application}, \l{CppApplication}, or \l{QtApplication}, create a + \c qmlImportPaths property: + + \code + Product { + name: "myProduct" + property stringList qmlImportPaths: [sourceDirectory + "/path/to/qml/"] + } + \endcode + + \section2 QT + + Add a \l{Depends} item to the \l{Product}{product} that specifies the + dependencies to \l{Qt} modules. For example: + + \code + QtApplication { + Depends { name: "Qt.widgets" } + } + \endcode + + You could also use the following form that is equivalent to the previous + one: + + \code + QtApplication { + Depends { name: "Qt"; submodules: "widgets" } + } + \endcode + + \section2 QTPLUGIN + + Building static applications often requires linking to static QPA plugins, + such as \c qminimal. You can use the following syntax to enable \QBS to + link to the required plugins: + + \code + QtApplication { + name: "myapp" + Depends { name: "Qt"; submodules: ["core", "gui", "widgets"] } + Depends { name: "Qt.qminimal"; condition: Qt.core.staticBuild } + } + \endcode + + \section2 RC_FILE + + Add Windows resource files to the value of the \l{Product::files} + {Product.files} property. + + \section2 TARGET + + Use the \l{Product::targetName}{Product.targetName} property to specify the + base file name of target artifacts. + + \section2 TEMPLATE + + \section3 app + + Use \l{Application} or \l{CppApplication} as the \l{Product}{product}: + + \code + CppApplication { + name: "helloworld" + files: "main.cpp" + } + \endcode + + This is roughly equivalent to: + + \code + Product { + name: "helloworld" + type: "application" + files: "main.cpp" + Depends { name: "cpp" } + } + \endcode + + \section3 lib + + Use either \l{DynamicLibrary} or \l{StaticLibrary} as the \l{Product} + {product}, depending on whether the value of \c CONFIG in the .pro file is + \c shared or \c static. For example, if the value is \c shared: + + \code + DynamicLibrary { + name: "mydll" + files: ["mySourceFile.cpp"] + Depends { name: "cpp" } + } + \endcode + + \section3 subdirs + + In a \l{Project} item, specify subdirectories as values of the + \l{Project::}{references} property: + + \code + Project { + references: [ + "app/app.qbs", + "lib/lib.qbs" + ] + } + \endcode + + \section2 message(), warning(), error(), log() + + You can use the \l{Console API} to print info, warning, error, and log messages to the console. + + \code + Product { + name: { + console.info("--> now evaluating the product name"); + return "theName"; + } + Depends { name: "cpp" } + cpp.includePath: { throw "An error occurred." } + } + \endcode +*/ diff --git a/doc/classic.css b/doc/classic.css new file mode 100644 index 00000000..f97bdbea --- /dev/null +++ b/doc/classic.css @@ -0,0 +1,295 @@ +BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { + font-family: Arial, Geneva, Helvetica, sans-serif; +} +H1 { + text-align: center; + font-size: 160%; +} +H2 { + font-size: 120%; +} +H3 { + font-size: 100%; +} + +h3.fn,span.fn +{ + background-color: #eee; + border-width: 1px; + border-style: solid; + border-color: #ddd; + font-weight: bold; + padding: 6px 0px 6px 10px; + margin: 42px 0px 0px 0px; +} + +hr { + border: 0; + color: #a0a0a0; + background-color: #ccc; + height: 1px; + width: 100%; + text-align: left; + margin: 34px 0px 34px 0px; +} + +table.valuelist { + border-width: 1px 1px 1px 1px; + border-style: solid; + border-color: #dddddd; + border-collapse: collapse; + background-color: #f0f0f0; +} + +table.indextable { + border-width: 1px 1px 1px 1px; + border-collapse: collapse; + background-color: #f0f0f0; + border-color:#555; + font-size: 110%; +} + +table td.largeindex { + border-width: 1px 1px 1px 1px; + border-collapse: collapse; + background-color: #f0f0f0; + border-color:#555; + font-size: 120%; +} + +table.valuelist th { + border-width: 1px 1px 1px 2px; + padding: 4px; + border-style: solid; + border-color: #666; + color:white; + background-color:#666; +} + +th.titleheader { + border-width: 1px 0px 1px 0px; + padding: 4px; + border-style: solid; + border-color: #444; + color:white; + background-color:#555555; + font-size: 110%; +} + +th.largeheader { + border-width: 1px 0px 1px 0px; + padding: 4px; + border-style: solid; + border-color: #444; + color:white; + background-color:#555555; + font-size: 120%; +} + +p { + + margin-left: 4px; + margin-top: 8px; + margin-bottom: 8px; +} + +a:link +{ + color: #0046ad; + text-decoration: none +} + +a:visited +{ + color: #672967; + text-decoration: none +} + +a.obsolete +{ + color: #661100; + text-decoration: none +} + +a.compat +{ + color: #661100; + text-decoration: none +} + +a.obsolete:visited +{ + color: #995500; + text-decoration: none +} + +a.compat:visited +{ + color: #995500; + text-decoration: none +} + +body +{ + background: #ffffff; + color: black +} + +table.generic, table.annotated +{ + border-width: 1px; + border-color:#bbb; + border-style:solid; + border-collapse:collapse; +} + +table td.memItemLeft { + width: 180px; + padding: 2px 0px 0px 8px; + margin: 4px; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; + font-size: 100%; + white-space: nowrap +} + +table td.memItemRight { + padding: 2px 8px 0px 8px; + margin: 4px; + border-width: 1px; + border-color: #E0E0E0; + border-style: none; + font-size: 100%; +} + +table tr.odd { + background: #f0f0f0; + color: black; +} + +table tr.even { + background: #e4e4e4; + color: black; +} + +table.annotated th { + padding: 3px; + text-align: left +} + +table.annotated td { + padding: 3px; +} + +table tr pre +{ + padding-top: 0px; + padding-bottom: 0px; + padding-left: 0px; + padding-right: 0px; + border: none; + background: none +} + +tr.qt-style +{ + background: #96E066; + color: black +} + +body pre +{ + padding: 0.2em; + border: #e7e7e7 1px solid; + background: #f1f1f1; + color: black +} + +table tr.qt-code pre +{ + padding: 0.2em; + border: #e7e7e7 1px solid; + background: #f1f1f1; + color: black +} + +span.preprocessor, span.preprocessor a +{ + color: darkblue; +} + +span.comment +{ + color: darkred; + font-style: italic +} + +span.string,span.char +{ + color: darkgreen; +} + +.title +{ + text-align: center +} + +.subtitle +{ + font-size: 0.8em +} + +.small-subtitle +{ + font-size: 0.65em +} + +.qmlitem { + padding: 0; +} + +.qmlname { + white-space: nowrap; + font-weight: bold; + font-size: 125%; +} + +.qmltype { + font-weight: bold; + font-size: 125%; +} + +.qmlproto, .qmldoc { + // border-top: 1px solid #84b0c7; +} + +.qmlproto { + padding: 0; + //background-color: #e4e4e4;//#d5e1e8; + //font-weight: bold; + //-webkit-border-top-left-radius: 8px; + //-webkit-border-top-right-radius: 8px; + //-moz-border-radius-topleft: 8px; + //-moz-border-radius-topright: 8px; +} + +.qmldoc { + border-top: 1px solid #e4e4e4; + //padding: 2px 5px; + //background-color: #eef3f5; + //border-top-width: 0; + //-webkit-border-bottom-left-radius: 8px; + //-webkit-border-bottom-right-radius: 8px; + //-moz-border-radius-bottomleft: 8px; + //-moz-border-radius-bottomright: 8px; +} + +.qmldoc p, .qmldoc dl, .qmldoc ul { + //margin: 6px 0; +} + +*.qmlitem p { + //margin-top: 0px; + //margin-bottom: 0px; +} diff --git a/doc/codeattributions.qdoc b/doc/codeattributions.qdoc new file mode 100644 index 00000000..cdd58b15 --- /dev/null +++ b/doc/codeattributions.qdoc @@ -0,0 +1,241 @@ +/*! + +\ingroup attributions-libs +\ingroup attributions-qbs +\page qbs-attribution-ds_store.html attribution +\target ds_store + +\title ds_store +\brief MIT License + +Manipulate Finder .DS_Store files from Python + +Used in the qbs dmg module for building Apple disk images. + +The sources can be found in src/3rdparty/python/lib/python2.7/site-packages/ds_store. + +\l{https://github.com/al45tair/ds_store}{Project Homepage}, upstream version: 1.1.2 + + +\badcode +Copyright (c) 2014 Alastair Houghton +\endcode + +\l{https://spdx.org/licenses/MIT.html}{MIT License}. + +\badcode +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +\endcode +*/ + +/*! + +\ingroup attributions-libs +\ingroup attributions-qbs +\page qbs-attribution-dmgbuild.html attribution +\target dmgbuild + +\title dmgbuild +\brief MIT License + +macOS command line utility to build disk images + +Used in the qbs dmg module for building Apple disk images. + +The sources can be found in src/3rdparty/python/lib/python2.7/site-packages/dmgbuild. + +\l{https://github.com/al45tair/dmgbuild}{Project Homepage}, upstream version: 1.3.1 + + +\badcode +Copyright (c) 2014 Alastair Houghton +\endcode + +\l{https://spdx.org/licenses/MIT.html}{MIT License}. + +\badcode +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +\endcode +*/ + +/*! + +\ingroup attributions-libs +\ingroup attributions-qbs +\page qbs-attribution-mac_alias.html attribution +\target mac_alias + +\title mac_alias +\brief MIT License + +Generate/parse Mac OS Alias records from Python + +Used in the qbs dmg module for building Apple disk images. + +The sources can be found in src/3rdparty/python/lib/python2.7/site-packages/mac_alias. + +\l{https://github.com/al45tair/mac_alias}{Project Homepage}, upstream version: 2.0.6 + + +\badcode +Copyright (c) 2014 Alastair Houghton +\endcode + +\l{https://spdx.org/licenses/MIT.html}{MIT License}. + +\badcode +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +\endcode +*/ + +/*! + +\ingroup attributions-libs +\ingroup attributions-qbs +\page qbs-attribution-biplist.html attribution +\target biplist + +\title biplist +\brief BSD 3-clause "New" or "Revised" License + +biplist is a library for reading/writing binary plists. + +Used in the qbs dmg module for building Apple disk images. + +The sources can be found in src/3rdparty/python/lib/python2.7/site-packages/biplist. + +\l{https://bitbucket.org/wooster/biplist}{Project Homepage}, upstream version: 1.0.2 + + +\badcode +Copyright (c) 2010, Andrew Wooster +\endcode + +\l{https://spdx.org/licenses/BSD-3-Clause.html}{BSD 3-clause "New" or "Revised" License}. + +\badcode +Copyright (c) 2010, Andrew Wooster +All rights reserved. + +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 biplist 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 HOLDER 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. +\endcode +*/ + +/*! + +\ingroup attributions-libs +\ingroup attributions-qbs +\page qbs-attribution-cppscanner.html attribution +\target cppscanner + +\title cppscanner +\brief MIT License + +The cpp scanner module is used to parse C/C++ files and to find includes +in them. + +The sources can be found in src/plugins/scanner/cpp. + +\badcode +Copyright (c) 2008 Roberto Raggi +\endcode + +\l{https://spdx.org/licenses/MIT.html}{MIT License}. + +\badcode +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +\endcode +*/ diff --git a/doc/config/macros.qdocconf b/doc/config/macros.qdocconf new file mode 100644 index 00000000..6811215c --- /dev/null +++ b/doc/config/macros.qdocconf @@ -0,0 +1,66 @@ +macro.QBS = "Qbs" +macro.qbsversion = $QBS_VERSION + +macro.defaultvalue = "Default:" +macro.nodefaultvalue = "Default: Undefined" +macro.appleproperty = "This property is specific to Apple platforms." +macro.androidproperty = "This property is specific to Android platforms." +macro.unixproperty = "This property is specific to Unix platforms." +macro.windowsproperty = "This property is specific to Windows." +macro.baremetalproperty = "This property is specific to bare-metal platforms." +macro.funsince.HTML = "

This function was introduced in version \1.

" + +macro.aacute.HTML = "á" +macro.Aring.HTML = "Å" +macro.aring.HTML = "å" +macro.Auml.HTML = "Ä" +macro.author = "\\b{Author:}" +macro.BR.HTML = "
" +macro.copyright.HTML = "©" +macro.eacute.HTML = "é" +macro.gui = "\\b" +macro.HR.HTML = "
" +macro.iacute.HTML = "í" +macro.key = "\\b" +macro.macos = "macOS" +macro.menu = "\\b" +macro.oslash.HTML = "ø" +macro.ouml.HTML = "ö" +macro.QA = "\\e{Qt Assistant}" +macro.QD = "\\e{Qt Designer}" +macro.QL = "\\e{Qt Linguist}" +macro.QQV = "\\e{Qt QML Viewer}" +macro.param = "\\e" +macro.raisedaster.HTML = "*" +macro.rarrow.HTML = "→" +macro.reg.HTML = "®" +macro.return = "Returns" +macro.starslash = "\\c{*/}" +macro.begincomment = "\\c{/*}" +macro.endcomment = "\\c{*/}" +macro.uuml.HTML = "ü" +macro.mdash.HTML = "—" +macro.pi.HTML = "Π" +macro.beginqdoc.HTML = "/*!" +macro.endqdoc.HTML = "*/" +macro.borderedimage = "\\div {class=\"border\"} \\image \1\n\\enddiv" + +macro.beginfloatleft.HTML = "
" +macro.beginfloatright.HTML = "
" +macro.endfloat.HTML = "
" +macro.clearfloat.HTML = "
" +macro.emptyspan.HTML = "" + +# Embed YouTube content by video ID - Example: \youtube dQw4w9WgXcQ +# Also requires a .jpg thumbnail for offline docs. In .qdocconf, add: +# +# HTML.extraimages += images/dQw4w9WgXcQ.jpg +# qhp.ProjectName.extraFiles += images/dQw4w9WgXcQ.jpg +# +macro.youtube.HTML = "
\n\n" \ + "
\n" diff --git a/doc/config/qbs-project.qdocconf b/doc/config/qbs-project.qdocconf new file mode 100644 index 00000000..bf5051c7 --- /dev/null +++ b/doc/config/qbs-project.qdocconf @@ -0,0 +1,40 @@ +include($QT_INSTALL_DOCS/global/qt-cpp-defines.qdocconf) +include($QT_INSTALL_DOCS/global/compat.qdocconf) +include($QT_INSTALL_DOCS/global/fileextensions.qdocconf) + +project = "Qbs" +description = "Qbs Manual" + +#Words to ignore for auto-linking +ignorewords += macOS + +headerdirs = +sourcedirs = .. +imagedirs = ../images ../templates/images +exampledirs = .. + +include(macros.qdocconf) +sources.fileextensions = "*.qdoc" + + +qhp.projects = Qbs +qhp.Qbs.file = qbs.qhp +qhp.Qbs.namespace = org.qt-project.qbs.$QBS_VERSION_TAG +qhp.Qbs.virtualFolder = doc +qhp.Qbs.indexTitle = Qbs +qhp.Qbs.filterAttributes = qbs $QBS_VERSION +qhp.Qbs.customFilters.Qbs.name = Qbs $QBS_VERSION +qhp.Qbs.customFilters.Qbs.filterAttributes = qbs $QBS_VERSION +qhp.Qbs.indexRoot = + +qhp.Qbs.subprojects = manual +qhp.Qbs.subprojects.manual.title = Qbs Manual +qhp.Qbs.subprojects.manual.indexTitle = Qbs Manual +qhp.Qbs.subprojects.manual.type = manual + +# Doxygen compatibility commands +macro.see = "\\sa" +macro.function = "\\fn" + +navigation.homepage = "Qbs Manual" +buildversion = "Qbs $QBS_VERSION" diff --git a/doc/config/style/qt5-sidebar.html b/doc/config/style/qt5-sidebar.html new file mode 100644 index 00000000..3df5d1bb --- /dev/null +++ b/doc/config/style/qt5-sidebar.html @@ -0,0 +1,18 @@ +
+
+ +

Qbs Manual

+
+ diff --git a/doc/doc.pri b/doc/doc.pri new file mode 100644 index 00000000..cd05a945 --- /dev/null +++ b/doc/doc.pri @@ -0,0 +1,18 @@ +include(../src/install_prefix.pri) + +include(doc_shared.pri) + +DOC_OUTDIR_POSTFIX = /html +DOC_HTML_INSTALLDIR = $$QBS_INSTALL_PREFIX/share/doc/qbs +DOC_QCH_OUTDIR = $$OUT_PWD/doc +DOC_QCH_INSTALLDIR = $$QBS_INSTALL_PREFIX/share/doc/qbs + +include(doc_targets.pri) + +fixnavi.commands = \ + cd $$shell_path($$PWD) && \ + perl fixnavi.pl -Dqcmanual -Dqtquick \ + qbs.qdoc +QMAKE_EXTRA_TARGETS += fixnavi + +include(man/man.pri) diff --git a/doc/doc.qbs b/doc/doc.qbs new file mode 100644 index 00000000..03c82e18 --- /dev/null +++ b/doc/doc.qbs @@ -0,0 +1,110 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes + +Project { + references: ["man/man.qbs"] + + Product { + name: "qbs documentation" + builtByDefault: false + type: Qt.core.config.contains("cross_compile") ? + ["qbsdoc.qdoc-html-fixed"] : [ "qbsdoc.qdoc-html-fixed", "qch"] + + property string fixedHtmlDir: FileInfo.joinPaths(buildDirectory, "qdoc-html-fixed") + Depends { name: "Qt.core" } + Depends { name: "qbsbuildconfig" } + Depends { name: "qbsversion" } + + Probes.BinaryProbe { + id: pythonProbe + names: ["python3", "python"] // on Windows, there's no python3 + } + property string pythonPath: pythonProbe.found ? pythonProbe.filePath : undefined + + files: [ + "../README.md", + "../CONTRIBUTING.md", + "classic.css", + "external-resources.qdoc", + "fixnavi.pl", + "howtos.qdoc", + "qbs.qdoc", + "qbs-online.qdocconf", + "config/*.qdocconf", + "config/style/qt5-sidebar.html", + "appendix/**/*", + "reference/**/*", + "templates/**/*", + "images/**", + "targets/**", + ] + Group { + name: "main qdocconf file" + files: "qbs.qdocconf" + fileTags: "qdocconf-main" + } + Group { + name: "fix-imports script" + files: ["fix-qmlimports.py"] + fileTags: ["qbsdoc.fiximports"] + } + + property string versionTag: qbsversion.version.replace(/\.|-/g, "") + Qt.core.qdocEnvironment: [ + "QBS_VERSION=" + qbsversion.version, + "SRCDIR=" + path, + "QT_INSTALL_DOCS=" + Qt.core.docPath, + "QBS_VERSION_TAG=" + versionTag + ] + + Rule { + inputs: ["qdoc-png"] + explicitlyDependsOn: ["qbsdoc.fiximports"] + multiplex: true + outputFileTags: ["qdoc-html", "qbsdoc.dummy"] // TODO: Hack. Rule injection to the rescue? + outputArtifacts: [{filePath: "dummy", fileTags: ["qbsdoc.dummy"]}] + prepare: { + if (!product.pythonPath) + throw "Python executable was not found"; + var scriptPath = explicitlyDependsOn["qbsdoc.fiximports"][0].filePath; + var htmlDir = FileInfo.path(FileInfo.path(inputs["qdoc-png"][0].filePath)); + var fixCmd = new Command(product.pythonPath, [scriptPath, htmlDir]); + fixCmd.description = "fixing bogus QML import statements"; + return [fixCmd]; + } + } + + Rule { + inputs: ["qdoc-html"] + Artifact { + filePath: FileInfo.joinPaths(product.fixedHtmlDir, input.fileName) + fileTags: ["qbsdoc.qdoc-html-fixed"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); } + return [cmd]; + } + } + + Group { + fileTagsFilter: ["qbsdoc.qdoc-html-fixed"] + qbs.install: qbsbuildconfig.installHtml + qbs.installDir: qbsbuildconfig.docInstallDir + qbs.installSourceBase: product.fixedHtmlDir + } + Group { + fileTagsFilter: ["qdoc-css", "qdoc-png"] + qbs.install: qbsbuildconfig.installHtml + qbs.installDir: qbsbuildconfig.docInstallDir + qbs.installSourceBase: Qt.core.qdocOutputDir + } + Group { + fileTagsFilter: ["qch"] + qbs.install: qbsbuildconfig.installQch + qbs.installDir: qbsbuildconfig.docInstallDir + } + } +} diff --git a/doc/doc_shared.pri b/doc/doc_shared.pri new file mode 100644 index 00000000..3e4eccf4 --- /dev/null +++ b/doc/doc_shared.pri @@ -0,0 +1,14 @@ +include(../qbs_version.pri) + +qbsdoc_version.name = QBS_VERSION +qbsdoc_version.value = $$QBS_VERSION +qbsdoc_versiontag.name = QBS_VERSION_TAG +qbsdoc_versiontag.value = $$replace(QBS_VERSION, "[-.]", ) +qbsdoc_qtdocs.name = QT_INSTALL_DOCS +qbsdoc_qtdocs.value = $$[QT_INSTALL_DOCS/src] +QDOC_ENV += qbsdoc_version qbsdoc_versiontag qbsdoc_qtdocs + +build_online_docs: \ + DOC_FILES += $$PWD/qbs-online.qdocconf +else: \ + DOC_FILES += $$PWD/qbs.qdocconf diff --git a/doc/doc_targets.pri b/doc/doc_targets.pri new file mode 100644 index 00000000..0636be2b --- /dev/null +++ b/doc/doc_targets.pri @@ -0,0 +1,86 @@ +# Creates targets for building documentation +# (adapted from qt_docs.prf) +# +# Usage: Define variables (details below) and include this pri file afterwards. +# +# QDOC_ENV - environment variables to set for the qdoc call (see example below) +# DOC_INDEX_PATHS - list of paths where qdoc should search for index files of dependent +# modules (Qt index path is included by default) +# DOC_FILES - list of qdocconf files +# DOC_OUTDIR_POSTFIX - html is generated in $$OUT_PWD/$$DOC_OUTDIR_POSTFIX +# DOC_HTML_INSTALLDIR - path were to install the directory of html files +# DOC_QCH_OUTDIR - path where to generated the qch files +# DOC_QCH_INSTALLDIR - path where to install the qch files +# DOC_TARGET_PREFIX - prefix for generated target names +# +# Example for QDOC_ENV: +# ver.name = VERSION +# ver.value = 1.0.2 +# foo.name = FOO +# foo.value = foo +# QDOC_ENV = ver foo + +isEmpty(DOC_FILES): error("Set DOC_FILES before including doc_targets.pri") +isEmpty(DOC_HTML_INSTALLDIR): error("Set DOC_HTML_INSTALLDIR before including doc_targets.pri") +isEmpty(DOC_QCH_OUTDIR): error("Set DOC_QCH_OUTDIR before including doc_targets.pri") +isEmpty(DOC_QCH_INSTALLDIR): error("Set DOC_QCH_INSTALLDIR before including doc_targets.pri") + +QT_TOOL_ENV = $$QDOC_ENV +qtPrepareTool(QDOC, qdoc) +QT_TOOL_ENV = + +!build_online_docs: qtPrepareTool(QHELPGENERATOR, qhelpgenerator) + +DOCS_BASE_OUTDIR = $$OUT_PWD/doc +DOC_INDEXES += -indexdir $$shell_quote($$[QT_INSTALL_DOCS]) +for (index_path, DOC_INDEX_PATHS): \ + DOC_INDEXES += -indexdir $$shell_quote($$index_path) + +DTP = $$DOC_TARGET_PREFIX +for (doc_file, DOC_FILES) { + !exists($$doc_file): error("Cannot find documentation specification file $$doc_file") + DOC_TARGET = $$replace(doc_file, ^(.*/)?(.*)\\.qdocconf$, \\2) + DOC_TARGETDIR = $$DOC_TARGET + DOC_OUTPUTDIR = $${DOCS_BASE_OUTDIR}/$${DOC_TARGETDIR}$${DOC_OUTDIR_POSTFIX} + + $${DTP}html_docs_$${DOC_TARGET}.commands = $$QDOC -outputdir $$shell_quote($$DOC_OUTPUTDIR) $$doc_file $$DOC_INDEXES + QMAKE_EXTRA_TARGETS += $${DTP}html_docs_$${DOC_TARGET} + + !isEmpty($${DTP}html_docs.commands): $${DTP}html_docs.commands += && + $${DTP}html_docs.commands += $$eval($${DTP}html_docs_$${DOC_TARGET}.commands) + + $${DTP}inst_html_docs.files += $$DOC_OUTPUTDIR + + !build_online_docs { + $${DTP}qch_docs_$${DOC_TARGET}.commands = $$QHELPGENERATOR $$shell_quote($$DOC_OUTPUTDIR/$${DOC_TARGET}.qhp) -o $$shell_quote($$DOC_QCH_OUTDIR/$${DOC_TARGET}.qch) + $${DTP}qch_docs_$${DOC_TARGET}.depends = $${DTP}html_docs_$${DOC_TARGET} + QMAKE_EXTRA_TARGETS += $${DTP}qch_docs_$${DOC_TARGET} + + !isEmpty($${DTP}qch_docs.commands): $${DTP}qch_docs.commands += && + $${DTP}qch_docs.commands += $$eval($${DTP}qch_docs_$${DOC_TARGET}.commands) + + $${DTP}inst_qch_docs.files += $$DOC_QCH_OUTDIR/$${DOC_TARGET}.qch + } +} + +!build_online_docs { + $${DTP}qch_docs.depends = $${DTP}html_docs + $${DTP}inst_qch_docs.path = $$DOC_QCH_INSTALLDIR + $${DTP}inst_qch_docs.CONFIG += no_check_exist no_default_install no_build + install_$${DTP}docs.depends = install_$${DTP}inst_qch_docs + $${DTP}docs.depends = $${DTP}qch_docs + INSTALLS += $${DTP}inst_qch_docs + QMAKE_EXTRA_TARGETS += $${DTP}qch_docs install_$${DTP}docs +} else { + $${DTP}docs.depends = $${DTP}html_docs +} + +$${DTP}inst_html_docs.path = $$DOC_HTML_INSTALLDIR +$${DTP}inst_html_docs.CONFIG += no_check_exist no_default_install directory +INSTALLS += $${DTP}inst_html_docs +install_$${DTP}docs.depends += install_$${DTP}inst_html_docs + +QMAKE_EXTRA_TARGETS += $${DTP}html_docs $${DTP}docs + +unset(DTP) + diff --git a/doc/external-resources.qdoc b/doc/external-resources.qdoc new file mode 100644 index 00000000..9d7aa3ae --- /dev/null +++ b/doc/external-resources.qdoc @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \externalpage https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html#//apple_ref/doc/uid/TP40012302-CH7-SW28 + \title Adopt the @2x Naming Convention +*/ + +/*! + \externalpage https://login.qt.io/ + \title Qt Account +*/ + +/*! + \externalpage https://www.qt.io/ide/ + \title Qt Creator +*/ + +/*! + \externalpage https://www.qt.io/download/ + \title Qt SDK +*/ + +/*! + \externalpage https://doc.qt.io/qt-5/licensing.html + \title Qt Licensing +*/ + +/*! + \externalpage https://www.gnu.org/licenses/gpl-2.0.html + \title GNU General Public License, version 2 +*/ + +/*! + \externalpage http://www.linfo.org/bsdlicense.html + \title BSD +*/ + +/*! + \externalpage https://chocolatey.org/packages/qbs + \title Chocolatey +*/ + +/*! + \externalpage https://www.macports.org/ports.php?by=name&substr=qbs + \title MacPorts +*/ + +/*! + \externalpage https://brew.sh/ + \title Homebrew +*/ + +/*! + \externalpage http://www.typescriptlang.org + \title TypeScript +*/ + +/*! + \externalpage http://www.typescriptlang.org/docs/handbook/compiler-options.html + \title Compiler Options +*/ + +/*! + \externalpage https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html + \title DYLD documentation +*/ + +/*! + \externalpage https://dmgbuild.readthedocs.io/en/latest/settings.html#background + \title dmgbuild - Settings +*/ + +/*! + \externalpage http://www.jrsoftware.org/isinfo.php + \title Inno Setup +*/ + +/*! + \externalpage http://nodejs.org + \title Node.js +*/ + +/*! + \externalpage http://wixtoolset.org + \title Windows Installer XML Toolset +*/ + +/*! + \externalpage https://clang.llvm.org/docs/JSONCompilationDatabase.html + \title JSON Compilation Database Format Specification +*/ + +/*! + \externalpage https://github.com/protocolbuffers/protobuf + \title protoc +*/ + +/*! + \externalpage https://github.com/nanopb/nanopb + \title nanopb +*/ + +/*! + \externalpage https://ccache.samba.org/ + \title ccache +*/ + +/*! + \externalpage https://ccache.samba.org/manual.html#_precompiled_headers + \title ccache documentation about precompiled headers +*/ diff --git a/doc/fix-qmlimports.py b/doc/fix-qmlimports.py new file mode 100755 index 00000000..bb022d25 --- /dev/null +++ b/doc/fix-qmlimports.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python3 +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +from __future__ import print_function +import os +import glob +import errno +import sys +import argparse +import shutil +import urllib +from subprocess import Popen, PIPE +import re +from collections import Counter + +import platform +useShell = (platform.system() == 'Windows') + +gotSoup = True +try: + from bs4 import BeautifulSoup +except ImportError: + print('Warning: Failed to import BeautifulSoup. Some functionality is disabled.', + file=sys.stderr) + gotSoup = False + +qmlTypeString = ' QML Type' + +# Modifies a QML Type reference page to look like a generic +# JavaScript reference - Removes the 'QML Type' strings from +# the titles as well as the import statement information. +# This is used in the Installer Framework docs, which contain +# JS reference documentation generated using commands specific +# to documenting QML code. +# +# Parameters: a Beautiful Soup object constructed with an opened +# html file to process. +# +# Returns True if the element tree was modified, False otherwise +def modifyQMLReference(soup): + pageTitle = soup.head.title.string + soup.head.title.string = pageTitle.replace(qmlTypeString, '') + for t in soup.find_all('h1', class_='title'): + t.string = t.string.replace(qmlTypeString, '') + + for table in soup.find_all('table'): + td = table.find('td') + if td and td.string: + if 'Import Statement:' in td.string: + td.parent.extract() + return True + return False + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description = """Removes bogus import statements from the offline docs""") + parser.add_argument('outputdir', + help = 'output directory of the generated html files') + args = parser.parse_args() + + if not gotSoup: + print('Error: This script requires the Beautiful Soup library.', file=sys.stderr) + sys.exit(1) + + if not os.path.isdir(args.outputdir): + print('Error: No such directory:', args.outputdir, file=sys.stderr) + sys.exit(1) + + # compile a list of all html files in the outputdir + htmlFiles = [] + for f in os.listdir(args.outputdir): + fullPath = os.path.join(args.outputdir, f) + if os.path.isdir(fullPath): + continue + if os.path.splitext(f)[1] == '.html': + htmlFiles.append(fullPath) + + sys.stdout.flush() + modified = {} + pre_blocks = {} + fileCount = 0 + progStep = max(16, len(htmlFiles)) / 16 + for html in htmlFiles: + fileCount += 1 + if not (fileCount % progStep): + print('.', end='') + sys.stdout.flush() + with open(html, 'r+', encoding='utf8') as file_: + try: + soup = BeautifulSoup(file_, 'lxml') + actions = [] + val = 0 + if modifyQMLReference(soup): + actions.append('Removed QML type info') + for a in actions: + modified[a] = modified.get(a, 0) + 1 + if actions: + file_.seek(0) + file_.write(str(soup)) + file_.truncate() + file_.close() + except (AttributeError, KeyError): + print('\nFailed to parse', html, ':', + sys.exc_info()[0], file=sys.stderr) + except IOError as e: + print('\nError:', e, file=sys.stderr) + except ValueError as e: + print('\nError:', e, file=sys.stderr) + if 'lxml' in str(e): + print('(If using pip, try \"pip install lxml\")', file=sys.stderr) + quit(1) + for k, v in modified.items(): + print ('\n\t', k, 'in %d files' % v, end='') + pb = pre_blocks.get(k, 0) + if pb: + print (' (', pb, '
 blocks)', sep='', end='')
+    print('\n')
diff --git a/doc/fixnavi.pl b/doc/fixnavi.pl
new file mode 100644
index 00000000..3c4dc134
--- /dev/null
+++ b/doc/fixnavi.pl
@@ -0,0 +1,182 @@
+#! /usr/bin/perl -w
+
+#############################################################################
+##
+## Copyright (C) 2016 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of Qbs.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+use strict;
+
+my @files = ();
+my %defines = ();
+for (@ARGV) {
+    if (/^-D(.*)$/) {
+        $defines{$1} = 1;
+    } elsif (/^-/) {
+        printf STDERR "Unknown option '".$_."'\n";
+        exit 1;
+    } else {
+        push @files, $_;
+    }
+}
+
+int(@files) or die "usage: $0 [-D]... \n";
+
+my @toc = ();
+my %title2page = ();
+my $doctitle = "";
+my $curpage = "";
+my $intoc = 0;
+my %prev_skips = ();
+my %next_skips = ();
+my %define_skips = ();
+my %polarity_skips = ();
+my $prev_skip = "";
+my $next_skip = "";
+my $define_skip = "";
+my $polarity_skip = 0;
+for my $file (@files) {
+    my $skipping = 0; # no nested ifs!
+    open FILE, $file or die "File $file cannot be opened.\n";
+    while () {
+        if (/^\h*\\if\h+defined\h*\(\h*(\H+)\h*\)/) {
+            $skipping = !defined($defines{$1});
+            if (!$intoc) {
+                $define_skip = $1;
+                $polarity_skip = $skipping;
+            }
+        } elsif (/^\h*\\else/) {
+            $skipping = 1 - $skipping;
+        } elsif (/^\h*\\endif/) {
+            $skipping = 0;
+        } elsif (keys(%title2page) == 1 && /^\h*\\list/) {
+            $intoc++;
+        } elsif (!$intoc) {
+            if ($skipping && /^\h*\\previouspage\h+(\H+)/) {
+                $prev_skip = $1;
+            } elsif ($skipping && /^\h*\\nextpage\h+(\H+)/) {
+                $next_skip = $1;
+            } elsif (/^\h*\\page\h+(\H+)/) {
+                $curpage = $1;
+            } elsif (/^\h*\\title\h+(.+)$/) {
+                if ($curpage eq "") {
+                    die "Title '$1' appears in no \\page.\n";
+                }
+                if (length($define_skip)) {
+                     $define_skips{$1} = $define_skip;
+                     $polarity_skips{$1} = $polarity_skip;
+                     $prev_skips{$1} = $prev_skip;
+                     $next_skips{$1} = $next_skip;
+                     $define_skip = $prev_skip = $next_skip = "";
+                }
+                $title2page{$1} = $curpage;
+                $doctitle = $1 if (!$doctitle);
+                $curpage = "";
+            }
+        } else {
+            if (/^\h*\\endlist/) {
+                $intoc--;
+            } elsif (!$skipping && /^\h*\\(?:o|li)\h+\\l\h*{(.*)}$/) {
+                push @toc, $1;
+            }
+        }
+    }
+    close FILE;
+}
+
+my %prev = ();
+my %next = ();
+my $last = $doctitle;
+for my $title (@toc) {
+    $next{$last} = $title2page{$title};
+    $prev{$title} = $title2page{$last};
+    $last = $title;
+}
+
+for my $file (@files) {
+    open IN, $file or die "File $file cannot be opened a second time?!\n";
+    open OUT, '>'.$file.".out" or die "File $file.out cannot be created.\n";
+    my $cutting = 0;
+    while () {
+        if (!$cutting) {
+            if (/^\h*\\contentspage/) {
+                $cutting = 1;
+            }
+        } else {
+            if (/^\h*\\title\h+(.+)$/) {
+                if (defined($define_skips{$1})) {
+                    print OUT "    \\if defined(".$define_skips{$1}.")\n";
+                    if ($polarity_skips{$1}) {
+                        print OUT "    \\previouspage ".$prev_skips{$1} if ($prev_skips{$1});
+                        print OUT "    \\else\n";
+                    }
+                }
+                print OUT "    \\previouspage ".$prev{$1} if ($prev{$1});
+                if (defined($define_skips{$1})) {
+                    if (!$polarity_skips{$1}) {
+                        print OUT "    \\else\n";
+                        print OUT "    \\previouspage ".$prev_skips{$1} if ($prev_skips{$1});
+                    }
+                    print OUT "    \\endif\n";
+                }
+                print OUT "    \\page ".$title2page{$1};
+                if (defined($define_skips{$1})) {
+                    print OUT "    \\if defined(".$define_skips{$1}.")\n";
+                    if ($polarity_skips{$1}) {
+                        print OUT "    \\nextpage ".$next_skips{$1} if ($next_skips{$1});
+                        print OUT "    \\else\n";
+                    }
+                }
+                print OUT "    \\nextpage ".$next{$1} if ($next{$1});
+                if (defined($define_skips{$1})) {
+                    if (!$polarity_skips{$1}) {
+                        print OUT "    \\else\n";
+                        print OUT "    \\nextpage ".$next_skips{$1} if ($next_skips{$1});
+                    }
+                    print OUT "    \\endif\n";
+                }
+                print OUT "\n";
+                $cutting = 0;
+            } else {
+                next;
+            }
+        }
+        print OUT $_;
+    }
+    close OUT;
+    close IN;
+    rename($file.".out", $file) or die "Cannot replace $file with new version.\n";
+}
diff --git a/doc/howtos.qdoc b/doc/howtos.qdoc
new file mode 100644
index 00000000..e21a2588
--- /dev/null
+++ b/doc/howtos.qdoc
@@ -0,0 +1,848 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+    \previouspage custom-modules.html
+    \nextpage reference.html
+    \page howtos.html
+
+    \title How-tos
+
+    This page provides concrete instructions for common scenarios.
+
+    \list
+    \li \l{How do I build a Qt-based project?}
+    \li \l{How do I make my app build against my library?}
+    \li \l{How do I build release with debug information?}
+    \li \l{How do I separate and install debugging symbols?}
+    \li \l{How do I use precompiled headers?}
+    \li \l{How do I make use of rpaths?}
+    \li \l{How do I make sure my generated sources are getting compiled?}
+    \li \l{How do I run my autotests?}
+    \li \l{How do I use ccache?}
+    \li \l{How do I create a module for a third-party library?}
+    \li \l{How do I build against libraries that provide pkg-config files?}
+    \li \l{How do I create application bundles and frameworks on iOS, macOS, tvOS, and watchOS?}
+    \li \l{How do I apply C/C++ preprocessor macros to only a subset of the files in my product?}
+    \li \l{How do I disable a compiler warning?}
+    \li \l{How do I make the state of my Git repository available to my source files?}
+    \li \l{How do I limit the number of concurrent jobs for the linker only?}
+    \li \l{How do I add QML files to a project?}
+    \li \l{How do I define a reusable Group of files that can be included in other \QBS files?}
+    \li \l{How do I access properties of a base type?}
+    \li \l{How do I print the value of a property?}
+    \li \l{How do I debug \QBS scripts?}
+    \li \l{How do I sign an application for an Apple platform?}
+    \endlist
+
+    \section1 How do I build a Qt-based project?
+
+    First of all, your project files need to declare \l{Depends}{dependencies}
+    on \l{Qt} modules.
+
+    To build the project, you need a matching \e profile. The following commands
+    set up and use a Qt-specific profile:
+    \code
+    $ qbs setup-qt /usr/bin/qmake qt
+    $ cd my_project
+    $ qbs profile:qt
+    \endcode
+    If you plan to use this profile a lot, consider making it the default one:
+    \code
+    $ qbs config defaultProfile qt
+    $ cd my_project
+    $ qbs
+    \endcode
+    See \l{Managing Qt Versions} for more details.
+    \note These instructions are only relevant for building from the command line.
+    If you use Qt Creator, profiles are set up automatically from the information in the Kit.
+
+    \section1 How do I make my app build against my library?
+
+    This is achieved by introducing a \e dependency between the two products using the
+    \l{Depends} item. Here is a simple, but complete example:
+    \code
+    Project {
+        CppApplication {
+            name : "the-app"
+            files : [ "main.cpp" ]
+            Depends { name: "the-lib" }
+        }
+        DynamicLibrary {
+            name: "the-lib"
+            Depends { name: "cpp" }
+            files: [
+                "lib.cpp",
+                "lib.h",
+            ]
+            Export {
+                Depends { name: "cpp" }
+                cpp.includePaths: [exportingProduct.sourceDirectory]
+           }
+        }
+    }
+    \endcode
+
+    The product \c the-lib is a dynamic library. It expects other products to build against it, and
+    for that purpose, it exports an include path (via an \l{Export} item), so that the
+    source files in these products can include the library's header file.
+
+    The product \c the-app is an application that expresses its intent to link against \c the-lib
+    by declaring a dependency on it. Now \c main.cpp can include \c lib.h (because of the exported
+    include path) and the application binary will link against the library (because the linker
+    \l{Rule}{rule} in the \l{cpp} module considers library dependencies as inputs).
+    \note In a non-trivial project, the two products would not be defined in the same file.
+          Instead, you would put them into files of their own and use the
+          \l{Project::references}{Project.references} property to pull them into the project.
+          The product definitions would stay exactly the same. In particular, their location
+          in the project tree is irrelevant to the relationship between them.
+
+    \section2 Choosing Between Dynamic and Statically-built Qt Projects
+
+    To build \c "the-lib" as either a dynamic or static library, depending on
+    how Qt was built, you can use the following code:
+
+    \code
+    Product {
+        name: "the-lib"
+        type: Qt.core.staticBuild ? "staticlibrary" : "dynamiclibrary"
+
+        Depends { name: "Qt.core" }
+        // ...
+    }
+    \endcode
+
+    \section1 How do I build release with debug information?
+
+    You can simply use the \c{"profiling"} \l{qbs::buildVariant}{qbs.buildVariant}:
+    \code
+    qbs build qbs.buildVariant:profiling
+    \endcode
+
+    \section1 How do I separate and install debugging symbols?
+
+    First, you need to set the \l{cpp::debugInformation}{cpp.debugInformation} and
+    \l{cpp::separateDebugInformation}{cpp.separateDebugInformation}
+    properties to \c true or use some conditional expression in your product:
+    \code
+    CppApplication {
+        // ...
+        cpp.debugInformation: qbs.buildVariant !== "release"
+        cpp.separateDebugInformation: true
+    }
+    \endcode
+
+    Now, you can install your \l{Application}{application}, \l{DynamicLibrary}{dynamic library}
+    or \l{LoadableModule}{loadable module} among with its debugging symbols as follows:
+    \code
+    CppApplication {
+        // ...
+        install: true
+        installDir: "bin"
+        installDebugInformation: true
+        debugInformationInstallDir: "bin"
+    }
+    \endcode
+
+    If you are not using \l{List of Convenience Items}{convenience items},
+    you can install debug symbols manually using the \l{Group} item. If the
+    \l{cpp::separateDebugInformation}{cpp.separateDebugInformation} property is set to \c true,
+    \QBS will create debugging symbols with the corresponding file tags
+    \c "debuginfo_app" (for an application), \c "debuginfo_dll" (for a dynamic library),
+    or \c "debuginfo_loadablemodule" (for a macOS plugin).
+
+    \code
+    Product {
+        type: "application"
+        Depends { name: "cpp" }
+        cpp.debugInformation: qbs.buildVariant !== "release"
+        cpp.separateDebugInformation: true
+        Group {
+            fileTagsFilter: cpp.separateDebugInformation ? ["debuginfo_app"] : []
+            qbs.install: true
+            qbs.installDir: "bin"
+            qbs.installSourceBase: buildDirectory
+        }
+    }
+    \endcode
+
+    If you're building a shared library, you need to use the \c "debuginfo_dll" tag instead:
+    \code
+    Product {
+        type: "dynamic_library"
+        // ...
+        Group {
+            fileTagsFilter: cpp.separateDebugInformation ? ["debuginfo_dll"] : []
+            qbs.install: true
+            qbs.installDir: "lib"
+            qbs.installSourceBase: buildDirectory
+        }
+    }
+    \endcode
+
+    If you're building a macOS plugin, you need to use the \c "debuginfo_loadablemodule"
+    tag instead:
+    \code
+    Product {
+        type: "loadablemodule"
+        // ...
+        Group {
+            fileTagsFilter: cpp.separateDebugInformation ? ["debuginfo_loadablemodule"] : []
+            qbs.install: true
+            qbs.installDir: "PlugIns"
+            qbs.installSourceBase: buildDirectory
+        }
+    }
+    \endcode
+
+    \section1 How do I use precompiled headers?
+
+    If you use a \l Group item to add a precompiled header file to a product
+    and mark it with the \l{filetags-cpp}{relevant file tag} (\c c_pch_src,
+    \c cpp_pch_src, \c objc_pch_src, or \c objcpp_pch_src), it is used
+    automatically.
+
+    Only one precompiled header is allowed per product and language.
+
+    For example:
+
+    \code
+    CppApplication {
+        name: "the-app"
+        files: ["main.cpp"]
+
+        Group {
+            files: ["precompiled-header.pch"]
+            fileTags: ["cpp_pch_src"]
+        }
+    }
+    \endcode
+
+    \section1 How do I make use of rpaths?
+
+    rpath designates the run-time search path used by the dynamic linker when loading
+    libraries on UNIX platforms. This concept does not apply to Windows.
+
+    Suppose you have a project with two dynamic library products \c LibraryA and \c LibraryB
+    and one dependent application product. Also, \c LibraryB depends on \c LibraryA. The
+    application is installed to the \c bin folder and the libraries are installed to the
+    \c lib folder next to the \c bin folder. You want the application to be able to find the
+    dependent libraries relative to its own location. This can be achieved by usage of the
+    \l{cpp::rpaths}{cpp.rpaths} property.
+
+    First, you need to set \l{cpp::rpaths}{cpp.rpaths} in your libraries so they can
+    find dependent libraries in the same folder where they are located. This can be
+    done as follows:
+
+    \snippet ../examples/rpaths/rpaths.qbs 0
+
+    We are setting \l{cpp::rpaths}{cpp.rpaths} to \l{cpp::rpathOrigin}{cpp.rpathOrigin} which
+    expands to \c "$ORIGIN" on Linux and to \c "@loader_path" on macOS.
+
+    On macOS you also need to set \l{cpp::sonamePrefix}{cpp.sonamePrefix} to \c "@rpath" to
+    tell the dynamic linker to use RPATHs when loading this library.
+
+    \c LibraryB looks exactly the same:
+
+    \snippet ../examples/rpaths/rpaths.qbs 1
+
+    In a real project, it might be a good idea to move common properties to some base item
+    and inherit it in library items.
+
+    The application item is a bit different. It sets \l{cpp::rpaths}{cpp.rpaths} to the
+    \c "lib" folder which is located one level up from the \c bin folder:
+
+    \snippet ../examples/rpaths/rpaths.qbs 2
+
+    \section1 How do I make sure my generated sources are getting compiled?
+
+    The rules in a \QBS project do not care whether its inputs are actual source files
+    listed on the right-hand side of a \l{Product::files}{files} property or artifacts
+    that were generated by another rule. For instance, the C++ compiler rule considers
+    all input files of type "cpp", no matter how they got into the product. The following
+    example project demonstrates this. One of its source files exists in the repository,
+    the other one is generated at build time. Both are getting compiled the same way.
+    \note Do not try to add the generated files to a \c files property. Declaring them
+    as rule outputs is all that is needed to make \QBS know about them.
+    \code
+    import qbs.TextFile
+    CppApplication {
+        files: ["impl.cpp", "impl.h"]
+        cpp.includePaths: sourceDirectory
+        Rule {
+            multiplex: true
+            Artifact { filePath: "main.cpp"; fileTags: "cpp" }
+            prepare: {
+                var cmd = new JavaScriptCommand();
+                cmd.description = "generating " + output.fileName;
+                cmd.sourceCode = function() {
+                    var f = new TextFile(output.filePath, TextFile.WriteOnly);
+                    f.writeLine("#include ");
+                    f.writeLine("int main()");
+                    f.writeLine("{");
+                    f.writeLine("    return functionFromImpl();");
+                    f.writeLine("}");
+                    f.close();
+                };
+                return cmd;
+            }
+        }
+    }
+    \endcode
+
+    \section1 How do I run my autotests?
+
+    There are two simple things you need to do in your project. Firstly, you
+    mark your test executables as such. This is done by adding the tag \c{"autotest"}
+    to the product type:
+    \code
+    CppApplication {
+        name: "test1"
+        type: base.concat("autotest")
+        // ...
+    }
+    \endcode
+    The second step is to instantiate an \l AutotestRunner product in your project:
+    \code
+    Project {
+        // ...
+        AutotestRunner { name: "run_my_tests" }
+    }
+    \endcode
+    Building an AutotestRunner product does not produce artifacts, but triggers execution of all
+    applications whose products are tagged as autotests:
+    \code
+    $ qbs -p run_my_tests
+    test1: PASS
+    test2: PASS
+    test3: FAIL
+    ...
+    \endcode
+    See the \l{AutotestRunner}{AutotestRunner documentation} for how to fine-tune the behavior.
+
+    \section1 How do I use ccache?
+
+    \l ccache is a popular C/C++ compiler cache on Unix to speed up compiling the
+    same content multiple times.
+
+    \QBS excels at tracking dependencies and avoiding needless recompilations, so
+    for linear development of one project and configuration using ccache
+    has little benefit. But if you switch between revisions of a project,
+    or build the same project with different configurations, a global cache like
+    ccache can speed up compilations significantly.
+
+    ccache can be used by setting up symbolic links to compiler executables
+    (such as \c g++, \c gcc) in the file system. In this setup, the use of ccache is
+    transparent to \QBS. If you prefer to call ccache explicitly, you should
+    set \l{cpp::compilerWrapper}{cpp.compilerWrapper} to \c ccache.
+
+    \note Using precompiled headers might prevent ccache from actually
+    using cached results. To work around this, you can set
+    \c{sloppiness=pch_defines,time_macros} in your local ccache options.
+    See the \l{ccache documentation about precompiled headers} for further details.
+
+    \section1 How do I create a module for a third-party library?
+
+    If you have pre-built binary files in your source tree, you can create
+    modules for them and then introduce dependencies between your project and
+    the modules to pull in the functionality of a third-party library.
+
+    Create the following folder structure to store the module files:
+
+    \code
+    $projectroot/modules/ThirdParty
+    \endcode
+
+    Then create a file in the directory that specifies the module properties
+    for each supported toolchain. The filename must have the \c .qbs extension.
+    The module will be pulled in if a product declares a dependency on it.
+
+    In the following example, \c lib1.dylib is a multi-architecture library
+    containing both 32-bit and 64-bit code.
+
+    \code
+    ---ThirdParty.qbs---
+
+    Module {
+        Depends { name: "cpp" }
+        cpp.includePaths: ["/somewhere/include"]
+        Properties {
+            condition: qbs.targetOS.contains("android")
+            cpp.dynamicLibraries: ["/somewhere/android/" + Android.ndk.abi + "/lib1.so"]
+        }
+        Properties {
+            condition: qbs.targetOS.contains("macos")
+            cpp.dynamicLibraries: ["/somewhere/macos/lib1.dylib"]
+        }
+        Properties {
+            condition: qbs.targetOS.contains("windows") && qbs.architecture === "x86"
+            cpp.dynamicLibraries: ["/somewhere/windows_x86/lib1.lib"]
+        }
+        Properties {
+            condition: qbs.targetOS.contains("windows") && qbs.architecture === "x86_64"
+            cpp.dynamicLibraries: ["/somewhere/windows_x86_64/lib1.lib"]
+        }
+    }
+    \endcode
+
+    Finally, declare dependencies on \c ThirdParty in your project:
+
+    \code
+    CppApplication {
+        name: "the-app"
+        files: ["main.cpp"]
+        Depends { name: "ThirdParty" }
+    }
+    \endcode
+
+    \section1 How do I create application bundles and frameworks on iOS, macOS, tvOS, and watchOS?
+
+    Creating an application bundle or framework is achieved by introducing a
+    dependency on the \l{bundle} module and setting the \l{bundle::isBundle}
+    {bundle.isBundle} property to \c true.
+
+    Here is a simple example for an application:
+
+    \code
+    Application {
+        Depends { name: "cpp" }
+        Depends { name: "bundle" }
+        bundle.isBundle: true
+        name: "the-app"
+        files: ["main.cpp"]
+    }
+    \endcode
+
+    and for a framework:
+
+    \code
+    DynamicLibrary {
+        Depends { name: "cpp" }
+        Depends { name: "bundle" }
+        bundle.isBundle: true
+        name: "the-lib"
+        files: ["lib.cpp", "lib.h"]
+    }
+    \endcode
+
+    \QBS also supports building static frameworks. You can create one by
+    replacing the \l{DynamicLibrary} item with a \l{StaticLibrary} item in the
+    example above.
+
+    \note When using the \l{Application} item (or convenience items, such as
+    \l{CppApplication}, \l{DynamicLibrary}, and \l{StaticLibrary}), your
+    products will be built as bundles on Apple platforms by default (this
+    behavior is subject to change in a future release).
+
+    To explicitly control whether your product is built as a bundle, set the \c bundle.isBundle
+    property. Setting the \l{Product::}{consoleApplication} property of your
+    product will also influence whether your product is built as a bundle.
+
+    Building your application against your framework is the same as linking a normal dynamic or
+    static library; see the \l{How do I make my app build against my library?} section for an
+    example.
+
+    \section1 How do I build against libraries that provide pkg-config files?
+
+    Just add a \l Depends item that matches the name of the pkg-config module, and \QBS
+    will automatically employ \l{https://www.freedesktop.org/wiki/Software/pkg-config}{pkg-config}
+    to find the headers and libraries if no matching \QBS module can be found. For instance,
+    to build against the OpenSSL library, you would write this:
+    \code
+    Depends { name: "openssl" }
+    \endcode
+    That's it. The pkg-config behavior can be fine-tuned via the \l pkgconfig module,
+    but normally you will not need to pull it in explicitly.
+
+    Internally, this functionality is implemented via \l {Module Providers}
+
+    \section1 How do I apply C/C++ preprocessor macros to only a subset of the files in my product?
+
+    Use a \l{Group} item to define a subset of project files. To add
+    macros within the group, you need to use the \c outer.concat property,
+    because you are adding macros to those specified in the outer scope.
+
+    In the following example, \c MACRO_EVERYWHERE is defined for all files in
+    the \l{Product} unless a Group overrides the macro, whereas
+    \c MACRO_GROUP is only defined for \c groupFile.cpp.
+
+    \code
+    Product {
+        Depends { name: "cpp" }
+        cpp.defines: ["MACRO_EVERYWHERE"]
+        Group {
+            cpp.defines: outer.concat("MACRO_GROUP")
+            files: "groupFile.cpp"
+        }
+    }
+    \endcode
+
+    The \c cpp.defines statements inside a \c Group only apply to the files in
+    that \c Group, and therefore you cannot use a \c Group to include a bunch of
+    files and globally visible macros. The macros must be specified in a
+    \l{Properties} item at the same level as the \c Group if
+    they need to be visible to files outside the \c Group:
+
+    \code
+    Product {
+        Depends { name: "cpp" }
+        Group {
+            condition: project.supportMyFeature
+            files: "myFile.cpp"
+        }
+
+        property stringList commonDefines: ["ONE", "TWO"]
+
+        Properties {
+            condition: project.supportMyFeature
+            cpp.defines: commonDefines.concat("MYFEATURE_SUPPORTED")
+        }
+    }
+    \endcode
+
+    \section1 How do I disable a compiler warning?
+
+    You can use the \l {cpp::commonCompilerFlags}{cpp.commonCompilerFlags} property
+    to pass flags to the compiler. For example, to disable deprecation warnings:
+
+    \code
+    CppApplication {
+        // ...
+
+        readonly property bool isMsvc: qbs.toolchain.contains("msvc")
+
+        cpp.commonCompilerFlags: isMsvc ? "/wd4996" : "-Wno-deprecated-declarations"
+    }
+    \endcode
+
+    It is also possible to disable all warnings at once by setting the
+    \l {cpp::commonCompilerFlags}{cpp.warningLevel} property to \c "none".
+    Usually this approach is discouraged, but it can be useful in some cases,
+    such as when compiling third party code:
+
+    \code
+    Group {
+        cpp.warningLevel: "none"
+
+        files: [
+            "3rdparty.h",
+            "3rdparty.cpp"
+        ]
+    }
+    \endcode
+
+    \section1 How do I make the state of my Git repository available to my source files?
+
+    Add a dependency to the \l{vcs} module to your product:
+    \code
+    CppApplication {
+        // ...
+        Depends { name: "vcs" }
+        // ...
+    }
+    \endcode
+    Your source files will now have access to a macro whose value is a string representing the
+    current Git or Subversion HEAD:
+    \code
+    #include 
+    #include 
+
+    int main()
+    {
+        std::cout << "I was built from " << VCS_REPO_STATE << std::endl;
+    }
+    \endcode
+
+    This value is also available via the \l{vcs::repoState}{vcs.repoState}
+    property.
+
+    \section1 How do I limit the number of concurrent jobs for the linker only?
+    \target job-pool-howto
+
+    While it is usually desirable to run as many compiler jobs as there are CPU cores,
+    the same is not true for linker jobs. The reason is that linkers are typically
+    I/O bound rather than CPU bound. When building large libraries, they also tend
+    to use up enormous amounts of memory. Therefore, we'd like to make sure that
+    only a few linkers are running at the same time without limiting other types
+    of jobs. In \QBS, this is achieved via \e{job pools}. There are several ways
+    to make use of them.
+
+    Firstly, you can provide a limit via the command line:
+    \code
+    $ qbs --job-limits linker:4
+    \endcode
+    The above call instructs \QBS to run at most four linker instances at the same
+    time, while leaving the general number of concurrent jobs at the default
+    value, which is derived from the number of CPU cores.
+    The \c linker string on the command line refers to the job pool of the same
+    name, which the \l{cpp-job-pools}{cpp module} assigns to all its commands that
+    invoke a linker.
+
+    Secondly, you can set a limit via the settings, either generally
+    or for a specific profile:
+    \code
+    $ qbs config preferences.jobLimit.linker 4
+    $ qbs config profiles.myprofile.preferences.jobLimit.linker 2
+    \endcode
+
+    And finally, you can also set the limit per project or per product, using a
+    \l JobLimit item:
+    \code
+    Product {
+        name: "my_huge_library"
+        JobLimit {
+            jobPool: "linker"
+            jobCount: 1
+        }
+        // ...
+    }
+    \endcode
+    The above construct ensures that this specific library is never linked at
+    the same time as any other binary in the project.
+
+    Job limits set on the command line override those from the settings, which in turn
+    override the ones defined within a project. Use the \c{--enforce-project-job-limits}
+    option to give the job limits defined via \c JobLimit items maximum precedence.
+
+    \section1 How do I add QML files to a project?
+
+    The simplest way to add QML files to a project is to add them to a
+    \l {https://doc.qt.io/qt/resources.html}{Qt resource file}:
+
+    \code
+    QtGuiApplication {
+        // ...
+
+        files: "main.cpp"
+
+        Group {
+            prefix: "qml/"
+            files: ["main.qml", "HomePage.qml"]
+            fileTags: ["qt.qml.qml", "qt.core.resource_data"]
+        }
+    }
+    \endcode
+
+    In the example above, we declare each QML file as having the
+    \l {filetags-qtcore}{"qt.core.resource_data"} file tag. This ensures
+    that it is added to a generated resource file.
+
+    \section1 How do I define a reusable Group of files that can be included in other \QBS files?
+
+    Suppose you have an application and tests for that application, and that
+    the project is structured in the following way:
+
+    \badcode
+    ├── app
+    │   ├── app.qbs
+    │   ├── ...
+    │   └── qml
+    │       └── ui
+    │           ├── AboutPopup.qml
+    │           └── ...
+    ├── my-project.qbs
+    └── tests
+        ├── tst_app.cpp
+        ├── ...
+        └── tests.qbs
+    \endcode
+
+    Both projects need access to the QML files used by the
+    application. To demonstrate how this can be done, we'll create a file
+    named \c qml-ui.qbs and put it in the \c app/qml/ui directory:
+
+    \code
+    Group {
+        prefix: path + "/"
+        fileTags: ["qt.qml.qml", "qt.core.resource_data"]
+        files: [
+            "AboutPopup.qml",
+            // ...
+        ]
+    }
+    \endcode
+
+    This Group is a variation of the one in the
+    \l {How do I add QML files to a project?}{section above}.
+
+    If no prefix is specified, the file names listed in the \c files property
+    are resolved relative to the \e importing product's (e.g. \c app.qbs)
+    directory. For that reason, we set the prefix to inform \QBS that the file
+    names should be resolved relative to the \e imported item instead:
+    \c qml-ui.qbs. Conveniently, this also means that we don't need to specify
+    the path prefix for each file.
+
+    The application can then import the file like so:
+
+    \code
+    import "qml/ui/qml-ui.qbs" as QmlUiFiles
+
+    QtGuiApplication {
+        // ...
+
+        files: "main.cpp"
+
+        QmlUiFiles {}
+    }
+    \endcode
+
+    The tests can use a relative path to import the file:
+
+    \code
+    import "../app/qml/ui/qml-ui.qbs" as QmlUiFiles
+
+    QtGuiApplication {
+        // ...
+
+        files: "tst_app.cpp"
+
+        QmlUiFiles {}
+    }
+    \endcode
+
+    \section1 How do I access properties of a base type?
+
+    You can use the \l base property. For example, to append to a list of files
+    that come from the base type, you can use \c {base.concat()}:
+
+    \code
+    // TestBase.qbs
+
+    QtGuiApplication {
+        files: [
+            "TestCaseBase.h",
+            "TestCaseBase.cpp"
+        ]
+    }
+    \endcode
+
+    \code
+    // tst_stuff.qbs
+    TestBase {
+        files: base.concat(["tst_stuff.cpp"])
+    }
+    \endcode
+
+    See \l {Special Property Values} for more details.
+
+    \section1 How do I print the value of a property?
+
+    Use the \l {Console API}{console API}. For example, suppose your project
+    is not built the way you expect it to be, and you suspect that
+    \c qbs.targetOS has the wrong value:
+
+    \code
+    readonly property bool unix: qbs.targetOS.contains("unix")
+    \endcode
+
+    To find out the value of \c qbs.targetOS, use \c {console.info()}:
+
+    \code
+    readonly property bool unix: {
+        console.info("qbs.targetOS: " + qbs.targetOS)
+        return qbs.targetOS.contains("unix")
+    }
+    \endcode
+
+    It is also possible to throw an exception with the text saying what is wrong - this might
+    be useful if the property contains invalid or unsupported value:
+    \code
+    readonly property bool unix: {
+        if (qbs.targetOS.contains("darwin"))
+            throw "Apple platforms are not supported";
+        return qbs.targetOS.contains("unix")
+    }
+    \endcode
+
+    \section1 How do I debug \QBS scripts?
+
+    To debug the value of a specific property, see the \l{How do I print the value of a property}
+    section.
+
+    Similar debugging techniques could be used within \l{Rule}{Rules} or \c .js files.
+
+    It is also possible to increase \QBS' logging level using the \c --more-verbose (\c -v) option
+    of the \c{qbs build} command:
+
+    \code
+    qbs build -v config:release
+    \endcode
+
+    \QBS uses the Qt Categorized Logging system which allows to configure logging categories
+    in \l{https://doc.qt.io/qt-5/qloggingcategory.html#configuring-categories}{multiple ways}. For
+    example, to enable debug logging for the \c moduleloader category, use the following command:
+    \code
+    QT_LOGGING_RULES="qbs.moduleloader.debug=true" qbs resolve
+    \endcode
+
+    To list all the files in the project directory and show whether they are known to qbs in the
+    respective configuration, use the \c{qbs status} command:
+    \code
+    qbs status config:release
+    \endcode
+
+    \section1 How do I sign an application for an Apple platform?
+
+    To sign an application for an Apple platform, you need to use the \l{codesign} module.
+
+    \code
+        Depends { name: "codesign" }
+    \endcode
+
+    Several properties should be set to do signing as shown below.
+
+    Make sure that bundle and team indentifiers match the one used for signing:
+
+    \code
+        bundle.identifierPrefix: "com.johndoe"
+        codesign.teamIdentifier: "John Doe"
+    \endcode
+
+    It is also possible to use an ID of the team identifier instead of a name:
+    \code
+        codesign.teamIdentifier: "1234ABCDEF"
+    \endcode
+
+    \QBS will then try to find the matching signing identity and provisioning profile based on
+    \l{codesign::signingType}{codesign.signingType}.
+
+    It is also possible to specify \l{codesign::signingIdentity}{codesign.signingIdentity}
+    manually:
+
+    \code
+        codesign.signingIdentity: "Apple Development: johndoe@apple.com (ABCDEF1234)"
+    \endcode
+
+    It is also possible to use an ID of the signing identity instead of a name:
+    \code
+        codesign.signingIdentity: "ABCDEF1234567890ABCDEF1234567890ABCDEF12"
+    \endcode
+
+    If \QBS cannot find the suitable provisioning profile, you can specify it manually as well:
+    \code
+        codesign.provisioningProfile: "abcdef12-1234-5678-1111-abcdef123456"
+    \endcode
+*/
diff --git a/doc/images/qbs-build-process.png b/doc/images/qbs-build-process.png
new file mode 100644
index 0000000000000000000000000000000000000000..960108e146a5e7287cdf8c1b6b6c134a889f3aa2
GIT binary patch
literal 5335
zcmZu#2UJtdw#I^pfJjk55D*RtN)x08M5-iosftLKD!oeyy@*l{O`4!ILAnq?z(^4Y
zp-7P$2uNt6gkGfN#rOaBu6y76*P3(Io;kD2*|TSVdnQ&_TaE6*)e9696m$r_C{-tMr*E*w%i|WuQ%C2nw|Jtp58*cOSXDTxB0@VbYWF)u&M-Di!Q9i4c3wX
z!;)JW4BHJGCpUsZMixPOx1d
zH`xx8WSW(R}1sarngh=*jW~Tuow&ZX(t#5u1>>(4DwRO2;?k&b1U1+A9~k
zQCM9R)(thDfLbU+Ep($62&hdGibSek=|`^)cdbnftj~;X5vIo7rp6Pd7Rar8YLhUv
zNtz;&@H;C@`$XdJ?Y-mQq=f|1W*KR-o3u$Fk-AAF@|y%;s@o_im^=_FiUxj@zj9~-
zCZ(@LsrrJyP)*p1hd7^S?ZDHl-dY>wG#gtuT=thu$kz!;oYMId63Hr3#FUXqPy+^&
zRvQ@Ruhu#^GJ(O;ynsceLZ5H$uht0Chf5V19U-6WbgOUn7423!NYZ;224^BrTZUDS
zVAWSw`21ZIM;l*zW*ULvrtI5A&l=6t5k{q-eGT#2P|Oy`zO!>q5lCn~weOshqK6Q}
zpGKFvNTvcGrni4%s_^HL#wsA35y681Vu2(8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f7)X^|$v7pzr&
zJ$TWC)PODr?P0yY$h+E5{Aso()e`$&qxr%?6Q348F$6B6N+bQYF!grJ*VPDvg;?<}
ze;w8<55k?Q5>lNQ%+w1J4%U~n3C>8d%-yF?WW8y*p_vnAW9%-l($=c|Qqbk=w}4+C
z+Ou0WHa1$ajsGl-7+?Oo^ygkz=as1|tNZuwU%j%uy>#!&%Iv
z_Ks+{l`yoc3!>uCIAp{+?E~pQH2LQvdA0Tlp{b#jn
zYb7k<-)7b6&qF6J{rT+fH{E}_YirY+oML?EJ3`kO9`a6^K+art$NsL53fwY`%vXCz
zUBz~7cpGH|;x1&J##(hXyX=FSv1Z-I-e7txSU)9~q8o>;^5o5iuinVoZV@a^{mJnq
n+!2`J&TS?G}fW5%h3

literal 0
HcmV?d00001

diff --git a/doc/images/qbs-settings-gui.png b/doc/images/qbs-settings-gui.png
new file mode 100644
index 0000000000000000000000000000000000000000..197340882b7997d8384adc5bb653097cb7455741
GIT binary patch
literal 31364
zcmaI7cU%))*EMWMML|VGx=NQ4rAoIWM7n^~D7_=SC7>uEU23FD2}qaFTd+|B1PHx%
z2)zbKNb*hey6)$>zxVyU^GA}Ib7tnunSIt?d+(JH4K<~U=UL7lJ9g}%^0UWU$Bvz_
zICkuK|Jf735k(B^=VQlwz{-ywyzm-XOZ9~^SfD6nwab@ZTzcb)LCY^L9+Et>O)lxm
z!x4;cnD(ozZ~@4=%9-`FehqiT+hPqyYrSY)5mm&gj5xdMm&Nl}PH|o0j|TH!L1ufFbVHyKTFzGjDh8d#A}kwDtA%ZESEM416jo
zDs&uj2R%xhu&+qHUlR%P4#Vsb#=ua&S1G-adU7E6)3J8%^QpF=xyPbhhtWdH#o|4b
zNKQq+sqgRd^KU=66rlRx>fg=fR$}zgvjlFvq}G((pO9I~OgmHhpufp}RV~I=@zDe7
zb|}JxyeS>s@yw4K93!Zz6v?J}3yleEJfs8#{Mk%}=9G}!HNB5V3W+g1$P-;3-rV~seP_V!VZXLrbq
zN5`+DyT+D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Wn_cycZ>0N;fvT$SP6ck1bHl*Ahd0RB2+$o
zevz&Gbj!R1
z)bJ~m2pdD|3Kbym$T->!vB^ZQDnU@Xce+
z)V(C|#X^70My-MyngjQ;Qzz7tY}A16ijcE?OZJb4*wMLb*FRB6n!HB)m+YkuiA|kv
zz1-*gL-vAdRn%4tW~$J~jMzo%wQ`-p3B@K}tFg(rcLAc8P4jj0V9;-xG_d5r>dUoT
zSFRlqh9wNQV6|{dXDOvkjUtE)%|7GAZPsjB`#ECim+8pUNva<8PK;7e6CBtwW7?rR
z>X!RW#QfWyhmR*{aS|N}8E^bg=1xN?%y8;jYAtT~{9DTAo3*gATeKyb#zD%pQC2i=STR!4^;+{P+-nn+SL!wKq;5J{2
zg2P?0&(9SA8@0u-Y8#e~VjGKdkGYy7a66!Vu5?}oNYP(MdXe0gzy@e&x9vG>n%_Ay
z{2#j&=R#_|0L3w&8_+GW=-*o%b;W+=XM^n6?TU?Mv0LWySdSPN4KFkR8=J9_wpOj9
zk2?g{t9J)^d;+2qgPI_(r`OFoKI9ejBNQ{Ivd)30G!oV>pUu}
zH=o~3BT2jCKoEIj*x&pu?1{z$-teSmRbv(hQbf>+Bq= 1.9 required";
+            var qbsApp;
+            for (var i = 0; i < explicitlyDependsOn.application.length; ++i) {
+                var artifact = explicitlyDependsOn.application[i];
+                if (artifact.product.name === "qbs_app")
+                    qbsApp = ModUtils.artifactInstalledFilePath(artifact);
+            }
+            var args = [qbsApp, "-o", output.filePath,
+                        "--no-info", "--name=the Qbs build tool"];
+            var sections = inputs ? inputs["man.section"] : [];
+            for (var i = 0; i < sections.length; ++i)
+                args.push("--include=" + sections[i].filePath);
+            var help2ManCmd = new Command(help2ManExe, args);
+            help2ManCmd.description = "creating man page";
+            var copyCmd = new JavaScriptCommand();
+            copyCmd.silent = true;
+            copyCmd.sourceCode = function() {
+                File.copy(output.filePath,
+                          FileInfo.joinPaths(product.sourceDirectory, output.fileName));
+            }
+            return [help2ManCmd, copyCmd];
+        }
+    }
+
+    Probes.BinaryProbe {
+        id: help2ManProbe
+        names: ["help2man"]
+    }
+}
diff --git a/doc/man/qbs.1 b/doc/man/qbs.1
new file mode 100644
index 00000000..b11beeef
--- /dev/null
+++ b/doc/man/qbs.1
@@ -0,0 +1,79 @@
+.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.47.7.
+.TH QBS "1" "December 2018" "qbs 1.12.3" "User Commands"
+.SH NAME
+qbs \- the Qbs build tool
+.SH SYNOPSIS
+.B qbs
+[\fI\,command\/\fR] [\fI\,command parameters\/\fR]
+.SH DESCRIPTION
+Qbs 1.12.3, a cross\-platform build tool.
+.SS "Built-in commands:"
+.TP
+build
+Build (parts of) a project. This is the default command.
+.TP
+clean
+Remove the files generated during a build.
+.TP
+dump\-nodes\-tree
+Dumps the nodes in the build graph to stdout.
+.TP
+generate
+Generate project files for another build tool.
+.TP
+help
+Show general or command\-specific help.
+.TP
+install
+Install (parts of) a project.
+.TP
+list\-products
+Lists all products in the project, including sub\-projects.
+.TP
+resolve
+Resolve a project without building it.
+.TP
+run
+Run an executable generated by building a project.
+.TP
+shell
+Open a shell with a product's environment.
+.TP
+show\-version
+Print the Qbs version number to stdout.
+.TP
+status
+Show the status of files in the project directory.
+.TP
+update\-timestamps
+Mark the build as up to date.
+.SS "Auxiliary commands:"
+.TP
+config
+This tool manages qbs settings.
+.TP
+config\-ui
+This tool displays qbs settings in a GUI.
+.TP
+create\-project
+This tool creates a qbs project from an existing source tree.
+.TP
+setup\-android
+This tool creates qbs profiles from Android SDK and NDK installations.
+.TP
+setup\-qt
+This tool creates qbs profiles from Qt versions.
+.TP
+setup\-toolchains
+This tool creates qbs profiles from toolchains.
+.SH "SEE ALSO"
+For detailed help on a command, use the
+.B help
+command. For instance:
+.IP
+qbs help build
+.PP
+
+The full documentation for
+.B qbs
+is available at .
diff --git a/doc/man/see-also.h2m b/doc/man/see-also.h2m
new file mode 100644
index 00000000..7de95809
--- /dev/null
+++ b/doc/man/see-also.h2m
@@ -0,0 +1,11 @@
+[SEE ALSO]
+For detailed help on a command, use the
+.B help
+command. For instance:
+.IP
+qbs help build
+.PP
+
+The full documentation for
+.B qbs
+is available at .
diff --git a/doc/qbs-hugo.qdocconf b/doc/qbs-hugo.qdocconf
new file mode 100644
index 00000000..66ba0548
--- /dev/null
+++ b/doc/qbs-hugo.qdocconf
@@ -0,0 +1,6 @@
+include(config/qbs-project.qdocconf)
+
+syntaxhighlighting = true
+
+HTML.prologue = "
" +HTML.footer += "
" diff --git a/doc/qbs-online.qdocconf b/doc/qbs-online.qdocconf new file mode 100644 index 00000000..e7f05e3b --- /dev/null +++ b/doc/qbs-online.qdocconf @@ -0,0 +1,19 @@ +include(config/qbs-project.qdocconf) + +HTML.footer = \ + "
\n" \ + "

\n" \ + " © 2022 The Qt Company Ltd.\n" \ + " Documentation contributions included herein are the copyrights of\n" \ + " their respective owners. " \ + " The documentation provided herein is licensed under the terms of the" \ + " GNU Free Documentation" \ + " License version 1.3 as published by the Free Software Foundation. " \ + " Qt and respective logos are trademarks of The Qt Company Ltd " \ + " in Finland and/or other countries worldwide. All other trademarks are property\n" \ + " of their respective owners.

\n" + +include($QT_INSTALL_DOCS/global/qt-html-templates-online.qdocconf) + +# Add an .html file with sidebar content, used in the online style +HTML.stylesheets += config/style/qt5-sidebar.html diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc new file mode 100644 index 00000000..7fcc7e68 --- /dev/null +++ b/doc/qbs.qdoc @@ -0,0 +1,2111 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ********************************************************************** +// NOTE: the sections are not ordered by their logical order to avoid +// reshuffling the file each time the index order changes (i.e., often). +// Run the fixnavi.pl script to adjust the links to the index order. +// ********************************************************************** + + +/*! + \page index.html + \nextpage overview.html + + \title Qbs Manual + + \section1 Version \qbsversion + + \QBS is a tool that helps simplify the build process for + developing projects across multiple platforms. \QBS can be used for any + software project, regardless of programming language, toolkit, or libraries used. + + + \note Please report bugs and suggestions to the + \l{http://bugreports.qt.io/}{Qt Bug Tracker}. + + \list + \li \l{Introduction} + \li \l{Setup} + \list + \li \l{Installing} + \li \l{Configuring Profiles and Preferences} + \li \l{Managing Qt Versions} + \endlist + \li \l{Usage} + \list + \li \l{Language Introduction} + \li \l{Building Applications} + \li \l{Running Applications} + \li \l{Installing Files} + \li \l{Target Platforms} + \li \l{Using the Shell} + \li \l{Generators} + \li \l{Multiplexing} + \li \l{Custom Modules and Items} + \li \l{Module Providers} + \endlist + \li \l{How-tos} + \li \l{Reference} + \list + \li \l{List of All Items} + \list + \li \l{List of Language Items} + \li \l{List of Convenience Items} + \li \l{List of Probes} + \endlist + \li \l{List of Built-in Services} + \li \l{Command-Line Interface} + \li \l{List of Modules} + \li \l{List of Module Providers} + \li \l{Command and JavaScriptCommand} + \endlist + + \li \l{Appendix A: Building Qbs} + \li \l{Appendix B: Migrating from Other Build Systems} + \li \l{Appendix C: The JSON API} + \li \l{Appendix D: Licenses and Code Attributions} + \endlist +*/ + + +/*! + \previouspage index.html + \page overview.html + \nextpage setup.html + + \title Introduction + + \QBS is a build automation tool designed to conveniently manage the build + process of software projects across multiple platforms. + + \section1 Features + + \QBS provides the following benefits: + + \list + \li Declarative paradigm + \li Well-defined language + \li Platform and programming language independence + \li Correct and fast incremental builds + \li Extensible architecture + \li Easy integration to IDEs + \endlist + + \section2 Declarative Paradigm + + When writing a project, it is important to describe the build tasks and + dependencies between them, rather than the build order. It is difficult to + determine the correct build order in complex projects, especially during + parallel builds. The build tool should bear that burden, not the developer. + + With a declarative language, \QBS enables you to express intent rather than + specifying single build steps. This provides the appropriate level of + abstraction for a build system. For example, \e dependencies can be created + between \e products, such that the target \e artifacts of the dependency + can be used as input to the build \e rules in the context of the depending + product. In addition, you can \e export dependencies and \e properties to + other products. + + \QBS is modular with clean interfaces between modules. A \e module is a + collection of properties and \e {language items} that are used for + building a product if the product depends on the module. The properties + that can be set for a module are used to control the behavior of the + toolchain used to build the module. + + \QBS itself knows nothing about file types or extensions, and therefore all + source files in a product are handled equally. However, you can assign + \e {file tags} to an artifact to act as markers or to specify a file type. + \QBS applies a rule to the source files of the project and chooses the + ones that match the input file tags specified by the rule. It then creates + artifacts in the build graph that have other filenames and file tags. + + Products and projects can contain \e probes that are run prior to building, + for instance to locate dependent headers, libraries, and other files outside + the project directory. + + \section2 Well-Defined Language + + \QBS projects are specified in a QML dialect. QML is a concise, easy to + learn, and intuitive language that is used successfully in the Qt project. + Its core is declarative, but it can be extended with JavaScript snippets + for extra flexibility. + + \QBS builds applications based on the information in a project file. Each + project file specifies one \l{Project}{project} that can contain + several \l{Product}{products}. You specify the type of the product, + such as an \e application, and the dependencies the product has on other + products. + + The product type determines the set of \l{Rule}{rules} that \QBS + applies to produce artifacts from input files. The input files can be + divided into \l{Group}{groups} according to their type or purpose, for + example. A group can also be used to attach \l{Properties}{properties} + to products. + + The following is an example of a minimal project file that specifies the + product type, application name, source file, and a dependency on the + \l{cpp} module: + + \code + Application { + name: "helloworld" + files: "main.cpp" + Depends { name: "cpp" } + } + \endcode + + For more information, see \l{Language Introduction}. + + \section2 Platform and Programming Language Independence + + \QBS can be used for any software project, regardless of programming + language, toolkit, or libraries used. \QBS has built-in support for + building applications for Windows, Linux, macOS, Android, iOS, tvOS, + watchOS, QNX, and FreeBSD, as well as for cross-compilation. It can be + easily extended to support further platforms. + + Invoking \l{build}{qbs build} from the command line automatically builds the + project for the current host platform using the best available toolchain and + settings, unless a default profile is set. You can configure additional + profiles for each toolchain you want to use and select the profile to use + at build time. + + For example, to build applications for Android devices, you would need to + set up a profile for the Android toolchain and select it when you build the + application. If you name the profile \e Android, you would then enter the + following command: + + \code + qbs build profile:Android + \endcode + + For more information, see \l{Building Applications}. + + Platform and programming language support is implemented as a set of + \l{List of Modules}{modules} that your product depends on. In the language + example above, the dependency on the \l{cpp} module determines + that the C++ sources are compiled and linked into a binary. + + Alternatively, you could use the \l{CppApplication} + convenience item that implies a dependency on the \l{cpp} module: + + \code + CppApplication { + name: "helloworld" + files: "main.cpp" + } + \endcode + + Additionally, if the sources use Qt, you need a dependency to the + \l{Qt.core} module, and so on. + + In addition to building projects, \QBS can install the build artifacts to + a location from where they can be run on the desktop or on a device. \QBS + modules can be used to create installers for the end users of the + applications. For example, the \l{dmg} module contains + properties and rules for building Apple Disk Images, which are typically + used to distribute applications and installers on macOS. The + \l{innosetup}, \l{nsis}, and \l{wix} modules contain properties and rules + for building installers for Windows platforms. + + \section2 Correct and Fast Incremental Builds + + \QBS is an all-in-one tool that generates a build graph from a high-level + project description (like qmake or CMake) and additionally undertakes the + task of executing the commands in the low-level build graph (like make). + + \QBS automatically takes advantage of multi-processor and multi-core systems + to achieve maximum build parallelization. By default, running \c qbs without + any arguments is roughly equivalent to running \c {make -j} where \c n is + the number of CPU cores. Similarly, \QBS allows the number of concurrent + jobs to be explicitly specified using its own \c -j option. + + \QBS has knowledge about the whole project, and therefore builds remain + correct even when you build sub-projects, because \QBS ensures that all + dependencies are built too. This virtually eliminates the need for clean + builds. + + \QBS uses dynamic build graphs with build rules that can generate a variable + number of files and that are executed only when needed. When figuring out + which rules to execute, \QBS starts at the product type and then looks for + a way to produce artifacts with matching file tags from source files, using + a chain of rules that are connected by their respective input and output + tags. For an example of how rules are applied when building products, see + \l{Rules and Product Types}. + + The \QBS build rules can produce a variable number of outputs. + If the input changes, only the required rules are applied at build time. + If a rule is applied, all the dependent rules are applied as well, but only + those. This feature ensures the correctness of the build graph after source + code changes without having to re-configure the whole project. + + Changing properties that do not affect the build, because they are not used + by rules, will not cause the project to be rebuilt. The use of properties is + tracked. Generated artifacts that cease to exist are deleted to avoid + picking outdated generated artifacts and indefinitely increasing the size of + the build directory. + + Fast incremental builds are crucial for a fast edit-build-run cycle. + Instead of retrieving the timestamps of generated files, \QBS uses the time + stamps stored in the build graph. This is especially important on Windows, + where file system operations are slow. + + If the project files were not changed, the build graph is loaded from disk. + It is stored in a binary format that can be loaded much faster than the real + project files. The project files are parsed only if they were changed. + + \section2 Extensible Architecture + + You can create your own custom \l{List of Modules}{modules} and + \l{List of Language Items}{items} and make \QBS aware of them. + + You store the custom modules and items in a subdirectory of the project + directory and specify the path to the subdirectory as a value of the + \l{Project::}{qbsSearchPaths} property. For example, if the custom module is + located at \c my-modules/modules/modulename/modulename.qbs, you would + specify it in the project file as follows: + + \code + Project { + qbsSearchPaths: "my-modules" + \endcode + + For more information, see \l{Custom Modules and Items}. + + \section2 IDE Integration + + \QBS can be used not only from the command line, but also in combination + with an IDE, such as Qt Creator or Visual Studio Code. These IDEs directly + support \QBS projects using the new \QBS \l{session} feature. Thus, these IDEs + can retrieve all the information required to build a single file or project + through a session's JSON protocol \l{Appendix C: The JSON API}{API}. + + In addition, \QBS can generate projects for Visual Studio, IAR EW, and + Keil uVision, but it still is an experimental option. For more information, + see \l {Generators}. + + \section3 Qt Creator + + \l{http://doc.qt.io/qtcreator/index.html}{Qt Creator} provides accurate + information about the build progress and displays a project tree that + reflects the logical structure of the project, instead of presenting low-level + information, such as the file system structure. Adding or removing source + files keeps the existing project file structure intact. + + For more information about using \QBS to build projects from Qt Creator, see + \l{http://doc.qt.io/qtcreator/creator-project-qbs.html}{Setting Up Qbs}. + + \section3 Visual Studio Code + + \l{https://code.visualstudio.com/}{Visual Studio Code} provides the + \l{https://marketplace.visualstudio.com/items?itemName=qbs-community.qbs-tools} + {qbs-community} plugin that provides accurate information about the build progress + and displays a project tree that reflects the logical structure of the project. + Also, it can provide low-level information, such as the file system structure. + + For more information about using \QBS to build projects from Visual Studio Code, + see \l{https://github.com/denis-shienkov/vscode-qbs/blob/master/docs/how-to.md} + {How To}. + + \section1 Build Process + + \image qbs-build-process.png + + The build process of a product starts by examining the \l{Product::}{type} + property of the product. It contains a list of \e {file tags} that are + similar to MIME types. + + The following example product contains one file tag, \e application: + + \code + Product { + Depends { name: "cpp" } + type: ["application"] + files: ["main.cpp", "class.cpp", "class.h"] + } + \endcode + + \QBS then searches through all \e rules available in the context, meaning + rules that are defined in the project or those that are made available + through the dependency on a module, such as the compiler and linker rules + pulled in from the \c cpp dependency in the example. + + When \QBS finds a rule that produces one or more artifacts with the relevant + file tag, it looks at the depencencies of that rule and finds out that it + produces artifacts tagged \c obj. It then finds a rule that produces \c obj + artifacts that takes \c .cpp artifacts as input. + + \code + Module { + // ... + Rule { + inputs: ["cpp"] + Artifact { + filePath: input.fileName + ".o" + fileTags: ["obj"] + } + prepare: { + // g++ -c main.cpp -o main.o ... + } + } + //... + } + \endcode + + There is no rule in the current context that produces \c .cpp files, but + we have defined \c .cpp files as inputs for the product. When we added a + dependency on the \l{cpp} module, that dependency also pulled in another \QBS + primitive called the \l{FileTagger}{file tagger}. The file tagger + looked for files matching the pattern \c *.cpp, and then applied the \c cpp + tag to those input files: + + \code + Module { + // ... + FileTagger { + patterns: "*.cpp" + fileTags: ["cpp"] + } + //... + } + \endcode + + Since the \c .cpp files are input files, they by definition have no other + dependencies, and we can go back the opposite way in the tree starting with + the compiler rule described above. + + This design works well for generated files. The \c .cpp artifacts could come + from another rule that produced them by processing some other input, either + instead of or in addition to the raw files listed in the product. + + The compiler rule will be invoked twice, once for each \c .cpp file, + producing a separate object file for each one. Then the linker rule will be + invoked. Its \c multiplex property is set to \c true, which means that + instead of producing one output per input and invoking the rule multiple + times, all input will be collected before invoking the rule only once to + produce the final application object. + + The standard versus multiplex rules map well to the compiler and linker + processes. The compiler takes one input file to produce one output file, + whereas the linker takes multiple input files to produce one output file. + + Finally, after the linker rule has been invoked, it produces an artifact + tagged \c application. Because the product's type property did not contain + other file tags, the build process is now complete. +*/ + + +/*! + \previouspage overview.html + \page setup.html + \nextpage installing.html + + \title Setup + + \list + \li \l{Installing} + \li \l{Configuring Profiles and Preferences} + \li \l{Managing Qt Versions} + \endlist +*/ + +/*! + \previouspage reference.html + \page building-qbs.html + \nextpage porting-to-qbs.html + + \title Appendix A: Building Qbs + + \QBS can be \l{Installing}{installed from binary packages} or built from + sources, as described in this appendix. In addition, this appendix describes + how to use Docker images for developing \QBS. + + \section1 Supported Platforms + + \QBS can be installed and run on the following platforms: + + \list + \li Windows 7, or later + \li Linux (tested on Debian 8 and 9, Ubuntu 16.04, OpenSuSE 13.2, and + Arch Linux) + \li macOS 10.7, or later + \endlist + + \section1 System Requirements + + To build \QBS from the source, you need: + + \list + \li Qt 5.14, or later + \li Windows: MinGW with GCC 4.9 or Microsoft Visual Studio 2015, + or later + \li Linux: GCC 4.9, or later, or Clang 3.9.0, or later + \li macOS: Xcode 6.2, or later + \endlist + + An installed toolchain has to match the one that Qt was compiled with. + + \section2 Documentation + + Building the \QBS documentation requires Python 2.7 or 3.2 or above, + as well as some third party Python modules. These can be installed via \c pip: + + \code + pip install beautifulsoup4 lxml + \endcode + + Regenerating the man page requires the \c help2man tool. + + \section1 Building \QBS with СMake + + To build \QBS, enter the following commands: + + \code + mkdir build && cd build + cmake -DQt5_DIR=${QT_DIR}/lib/cmake/Qt5/ .. + make + \endcode + + Where \c ${QT_DIR} is the directory where Qt is installed. Passing the \c Qt5_DIR option + is not necessary if \c qmake is present in \c PATH. + + Depending on your platform, you might use \c mingw32-make, \c nmake, or + \c jom instead of \c make. + + Alternatively, you can use the + \l{https://cmake.org/cmake/help/latest/generator/Ninja.html}{Ninja} generator: + \code + cmake -GNinja -DQt5_DIR=${QT_DIR}/lib/cmake/Qt5/ .. + ninja + \endcode + + \section2 CMake Configure Options + + \QBS recognizes the following CMake options (passed to CMake in the form of \c{-DOPTION=value}) + to customize the build: + + \table + \header \li Option \li Notes \li Default value + \row \li WITH_TESTS \li Enable autotests. \li \c ON + \row \li WITH_UNIT_TESTS \li Enable additional autotests. \li \c OFF + \li \c OFF + \row \li INSTALL_PUBLIC_HEADERS \li Whether to install public headers. \li \c ON + \endtable + + \section2 Using ccache with CMake + + To enable using \l{https://ccache.dev}{ccache} when building \QBS, pass the following options + to CMake: + \code + cmake -DQt5_DIR=${QT_DIR}/lib/cmake/Qt5/ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. + \endcode + + \section1 Building \QBS with QMake + + To build \QBS, enter the following command: + + \code + qmake -r qbs.pro && make + \endcode + + Depending on your platform, you might use \c mingw32-make, \c nmake, or + \c jom instead of \c make. + + Installation by using \c {make install} is usually not needed. It is however + possible, by entering the following command. + + \code + make install INSTALL_ROOT=$INSTALL_DIRECTORY + \endcode + + \section2 QMake Configure Options + + \QBS recognizes the following qmake CONFIG options to customize the build: + + \table + \header \li Option \li Notes + \row \li qbs_enable_unit_tests \li Enable additional autotests. + \row \li qbs_disable_rpath \li Disable the use of rpath. This can be used when packaging + \QBS for distributions which do not permit the use of rpath, + such as Fedora. + \row \li qbs_no_dev_install \li Exclude header files from installation, that is, perform a + non-developer build. + \row \li qbs_no_man_install \li Exclude the man page from installation. + \row \li qbs_use_bundled_qtscript \li Use the bundled QtScript library. + \endtable + + In addition, you can set the \c QBS_SYSTEM_SETTINGS_DIR environment variable + before running qmake to specify a custom location for \QBS to look for its + system-level settings. + + \section1 Building \QBS with \QBS + + It is also possible to build \QBS with the previously installed \QBS version. + To build \QBS, enter the following command in the source directory: + \code + qbs + \endcode + This will use the \c defaultProfile or pick up the Qt version and the toolchain from the \c PATH + if the \c defaultProfile is not set. See \l {Configuring Profiles and Preferences} for details + about profiles. + + To run automatic tests, the \c autotest-runner product should be built: + \code + qbs build -p autotest-runner + \endcode + \QBS will use an empty profile when running tests which means it will try to autodetect + toolchains, Qt versions and other things based on the system environment. + It is possible to specify which profile should be used during the test-run by passing the + \c QBS_AUTOTEST_PROFILE environment variable. + This variable should be set prior to building \QBS itself; otherwise the \c resolve command + should be used to update the environment stored in the buildgraph: + \code + export QBS_AUTOTEST_PROFILE=qt + qbs resolve + qbs build -p autotest-runner + \endcode + + It is also possible to set up a separate profile for a particular testsuite. + A profile for the \c tst_blackbox_android suite can be set up as follows: + \code + qbs setup-android pie + export QBS_AUTOTEST_PROFILE_BLACKBOX_ANDROID=pie + \endcode + + It might be useful to set up the directory with the \QBS settings to isolate the test + environment: + \code + export QBS_AUTOTEST_SETTINGS_DIR=~/path/to/qbs/settings + \endcode + + \section2 \QBS Build Options + + The \c qbsbuildconfig module can be used to customize the build. + Properties of that module can be passed using command line as follows: + \code + qbs build modules.qbsbuildconfig.enableAddressSanitizer:true + \endcode + + \QBS recognizes the following properties: + \table + \header + \li Property + \li Default value + \li Notes + \row + \li enableAddressSanitizer + \li \c false + \li Whether to use address sanitizer or not. Enabling this option will add the + -fsanitize=address flag. + \row + \li enableUnitTests + \li \c false + \li Enable additional autotests. Enabling this option will export some symbols that would + otherwise be private. + \row + \li enableRPath + \li \c true + \li Use this property to disable the use of rpath. This can be used when packaging \QBS + for distributions which do not permit the use of rpath, such as Fedora. + \row + \li installApiHeaders + \li \c true + \li Holds whether to install the header files for the \QBS libraries or not. This option + is required to build against the \QBS libraries. + \row + \li enableBundledQt + \li \c false + \li Holds whether the Qt libraries that \QBS depends on will be bundled with \QBS during + the \c install step. This option is only implemented on macOS. + \row + \li useBundledQtScript + \li \c false + \li Use the bundled QtScript module instead of the one shipped with Qt. In that case, + QtScript should be checked out as a git submodule. + \row + \li libDirName + \li \c "lib" + \li Directory name used by \c libInstallDir and \c importLibInstallDir properties. + \row + \li appInstallDir + \li \c "bin" + \li Relative directory path under the install prefix path to put application binaries. + \row + \li libInstallDir + \li \c "bin" on Windows, \c libDirName otherwise + \li Relative directory path under the install prefix path where to put shared libraries + (excluding plugins, see the \c relativePluginsPath property). + \row + \li importLibInstallDir + \li \c libDirName + \li Relative directory path under the install prefix path where to put import libs. + \row + \li libexecInstallDir + \li \c appInstallDir on Windows, \c "libexec/qbs" otherwise + \li Relative directory path under the install prefix path where to put auxiliary binaries + executed by the \QBS libraries. + \row + \li systemSettingsDir + \li \c undefined + \li Directory that will be used by \QBS to store its settings. If not specified, a default + platform-dependent directory is used. + \row + \li installManPage + \li \c true on Unix, \c false otherwise + \li Whether to install man pages. + \row + \li installHtml + \li \c true + \li Whether to install HTML help pages. + \row + \li installQch + \li \c false + \li Whether to install qch files. See + \l{https://doc.qt.io/qt-5/qthelp-framework.html}{The Qt Help Framework} for details + about qch files. + \row + \li generatePkgConfigFiles + \li auto-detected + \li Whether to generate files for pkg-config. + \row + \li generateQbsModules + \li auto-detected + \li Whether to generate \QBS modules for the exported \QBS libraries. Use this when + building another product against \QBS libraries using \QBS as build system. + \row + \li docInstallDir + \li \c "share/doc/qbs/html" + \li Relative directory path under the install prefix path where to put documentation. + \row + \li pkgConfigInstallDir + \li \c libDirName + \c "/pkgconfig" + \li Relative directory path under the install prefix path where to put pkg-config files. + \row + \li qbsModulesBaseDir + \li \c libDirName + \c "/qbs/modules" + \li Relative directory path under the install prefix path where to put \QBS modules. + Applies only when \c generateQbsModules is \c true. + \row + \li relativeLibexecPath + \li \c "../" + \c libexecInstallDir + \li Path to the auxiliary binaries relative to the application binary. + \row + \li relativePluginsPath + \li \c "../" + \c libDirName + \li Path to plugin libraries relative to the application binary. + \row + \li relativeSearchPath + \li \c ".." + \li Relative path to the directory where to look for \QBS development modules and items. + \row + \li libRPaths + \li auto-detected + \li List of rpaths. + \row + \li resourcesInstallDir + \li \c "" + \li Relative directory path under the install prefix path where to put shared resources + like documentation, \QBS user modules and items. + \row + \li pluginsInstallDir + \li \c libDirName + \c "/qbs/plugins" + \li Relative path to the directory where to put plugins to. + \endtable + + \section1 Using Docker + + A set of Docker images for developing \QBS (which are maintained by the \QBS team) is available + \l{https://hub.docker.com/u/qbsbuild/}{on Docker Hub}. + Both Windows 10 and Debian Linux container types are available. + + \note The source code for the \QBS development Docker images is located in the \c{docker/} + directory of the \QBS source tree, if you wish to build them yourself. + + \section2 Linux Containers + + The easiest way to get started is to build \QBS using a Linux container. These types of + containers are supported out of the box on all the supported host platforms: Windows, macOS, + and Linux. + + The images provide everything that is necessary to build and test \QBS: + + \list + \li Qt SDK for building \QBS with \c qmake + \li Latest stable release of \QBS for building \QBS with \QBS + \endlist + + We are using docker-compose for building and running the Docker images because it simplifies + the Docker command line and ensures that the correct image tag is used. All available images + are listed in the \c docker-compose.yml file in the project root directory. + + Run the following command to download the \QBS development image based on Ubuntu 20.04 + \e Focal: + + \code + docker-compose pull focal + \endcode + + You can then create a new container with the \QBS source directory mounted from your host + machine's file system, by running: + + \code + docker-compose run --rm focal + \endcode + + You will now be in an interactive Linux shell where you can develop and build \QBS. + + \section2 Windows Containers + + To build \QBS for Windows using Windows containers, your host OS must be running Windows 10 Pro + and have Hyper-V enabled. \l{https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers}{Switch your Docker environment to use Windows containers}. + + We are using docker-compose for building and running the Docker images because it simplifies + the Docker command line and ensures that the correct image tag is used. All available images + are listed in the \c docker-compose.yml file in the project root directory. + + Run the following command to download the \QBS development image based on Windows 10: + + \code + docker-compose pull windows + \endcode + + You can then create a new container with the \QBS source directory mounted from your host + machine's file system, by running: + + \code + docker-compose run --rm windows + \endcode + + If you want to use Windows containers on a macOS or Linux host, you will have to create a + virtual machine running Windows 10 and register it with \c{docker-machine}. There is at least + \l{https://github.com/StefanScherer/windows-docker-machine}{one Open Source project} + that helps to facilitate this by using using Packer, Vagrant, and VirtualBox. + + The \c{docker run} command to spawn a Windows container on a Unix host will look slightly + different (assuming \c windows is the name of the Docker machine associated with the Windows + container hosting VM): + + \code + eval $(docker-machine env windows) + docker-compose run --rm windows + \endcode + + \section2 Building Release Packages + + Release packages for \QBS for Windows can be built using the following command on Windows: + + \code + docker-compose run --rm windows cmd /c scripts\make-release-archives + \endcode + + For building release packages for Windows on macOS or Linux: + + \code + eval $(docker-machine env windows) + docker-compose run --rm windows cmd /c scripts\\make-release-archives + \endcode +*/ + + +/*! + \previouspage setup.html + \page installing.html + \nextpage configuring.html + + \title Installing + + \QBS binaries are available for Windows, macOS, Linux, and FreeBSD. + + On all platforms, \QBS binaries are part of the \l{Qt Creator} and \l{Qt SDK} + installers. You can find the \c qbs executable in the \c bin directory of + Qt Creator, or within the application bundle's \c MacOS directory on macOS. + + \QBS can also be built locally from sources. For more information, see + \l{Appendix A: Building Qbs}. + + \section1 Windows + + The Qt Project provides prebuilt binaries for Windows (x86 and x64) at + \l{https://download.qt.io/official_releases/qbs/}. For commercial customers of + The Qt Company, the binaries are available in the \l {Qt Account}. + The binaries are packaged in a .zip folder that can be extracted to a location + of your choice. + + \QBS is also available as a \l Chocolatey package, which can be installed in + the usual way: + + \code + choco install qbs + \endcode + + The \c .nupkg file can also be downloaded directly from + \l{https://download.qt.io/official_releases/qbs/} for + \l{https://chocolatey.org/security#organizational-use-of-chocolatey}{offline installation}. + + \section1 macOS + + \QBS can be conveniently installed on macOS with the \l{MacPorts} or \l{Homebrew} + package managers: + + \code + brew install qbs + \endcode + + or + + \code + port install qbs + \endcode + + \section1 Linux and FreeBSD + + \QBS is \l{https://repology.org/metapackage/qbs/versions}{available via the + package management systems} of Linux distributions, and FreeBSD. +*/ + +/*! + \previouspage installing.html + \page configuring.html + \nextpage qt-versions.html + + \title Configuring Profiles and Preferences + + Profiles contain properties that apply to one or more projects. They are + stored independently of the project files and are usually not shared between + build hosts. Typically, profiles contain module properties, such as + installation paths of tools or libraries on the host computer. This approach + has the following advantages, among others: + + \list + \li Team members with different computer setups can work together + smoothly because no host-specific settings end up in the project + files. + \li Different versions of a tool or library can be used to build the + same project without affecting each other. + \endlist + + For example, a profile for building C++ applications contains at least the + installation path and the type of the compiler toolchain. A profile for + building Qt applications contains the toolchain-specific properties as well + as \l{Qt::qmakeFilePaths}{the path to the Qt installation}. + + This topic describes profiles stored in the \QBS settings. In some cases it + might be beneficial to keep profiles explicitly in the project sources. This + can be achieved with the \l{Profile} item. + + \section1 Setting Up Toolchain Profiles + + \QBS comes with a helper tool \l{setup-toolchains} that can + create profiles for many toolchains. Open a terminal window and type: + + \code + qbs setup-toolchains --detect + \endcode + + This will automatically set up a profile for each detected toolchain on your + computer. You can list the existing profiles by running: + + \code + qbs config --list profiles + \endcode + + Some toolchains, especially for bare-metal targets, may require additional + module properties. Those can be added with the \l{config} or the + \l{config-ui} tools. Now you should be ready to build your first project + with \QBS. Go into examples/helloworld-minimal and type: + + \code + qbs build profile: + \endcode + + You have successfully built your first \QBS project. If you want to build + projects that use Qt, additional steps might be necessary. Please refer to + \l{Managing Qt Versions} for more information. + + \section1 Global Preferences + + In addition to profiles, \QBS provides some global preferences such as \c + qbsSearchPaths and \c defaultProfile. + + \section1 Managing Profiles and Preferences + + You can use the \l{config} command to manage all \QBS configuration + settings, such as profiles and global preferences from the command line, + for example: + + \code + qbs config profiles..qbs.architecture arm + \endcode + + For convenience, \QBS provides a tool \l{config-ui} where you can manage the + settings in a hierarchical view. + + \image qbs-settings-gui.png + + \QBS Settings displays the keys in the specified settings directory and + their values. To expand all keys, select \uicontrol View > + \uicontrol {Expand All} (\key Ctrl+E or \key Cmd+E on macOS). To collapse + all keys, select \uicontrol {Collapse All} (\key Ctrl+C or \key Cmd+C). + + To change the value of a key, double-click it and enter the new value. + + To save your changes, select \uicontrol File > \uicontrol Save. + + To refresh the settings from the settings directory, select \uicontrol File + > \uicontrol Reload. + +*/ + +/*! + \previouspage configuring.html + \page qt-versions.html + \nextpage usage.html + + \title Managing Qt Versions + + \section1 Introduction + + If your environment has the right \c qmake binary in its \c PATH and is also set up + properly for a matching toolchain, then you do not necessarily need a profile + to build projects with a Qt dependency. Otherwise, you should create one: + + \code + qbs setup-qt /usr/bin/qmake myqt + \endcode + + This will create the \c myqt profile which can then be used on + the command line: + + \code + qbs profile:myqt + \endcode + + \note If the \c setup-toolchains command has found more than one toolchain, you will need + to manually link your Qt profile to one of them, like this: + \code + qbs config profiles.myqt.baseProfile + \endcode + + + \section1 Multiple Qt Builds + + To support multiple Qt builds, or in fact any combination of related settings, you need to + create several profiles. The following example illustrates how to set up + three different profiles, each for a different Qt build: + + \code + qbs setup-qt ~/dev/qt/4.7/bin/qmake qt47 + qbs setup-qt ~/dev/qt/4.8/bin/qmake qt48 + qbs setup-qt ~/dev/qt/5.0/qtbase/bin/qmake qt5 + \endcode + + You can set the default Qt build like this: + + \code + qbs config defaultProfile qt5 + \endcode + + To choose a Qt build that is different from the default, use: + + \code + qbs build profile:qt48 + \endcode + + You can set other properties in a profile (not just Qt ones), in the same way + you override them from the command line. For example: + + \code + qbs setup-qt C:\Qt\5.0.0\qtbase\bin\qmake.exe qt5 + qbs config profiles.qt5.qbs.architecture x86_64 + qbs config profiles.qt5.baseProfile msvc2010 + \endcode + + The last example uses the inheritance feature of profiles. All settings in the profile + set as \c baseProfile are known in the derived profile as well. + They can of course be overridden there. +*/ + +/*! + \previouspage qt-versions.html + \page usage.html + \nextpage language-introduction.html + + \title Usage + + \list + \li \l{Language Introduction} + \li \l{Building Applications} + \li \l{Running Applications} + \li \l{Installing Files} + \li \l{Target Platforms} + \li \l{Using the Shell} + \li \l{Generators} + \li \l{Multiplexing} + \li \l{Custom Modules and Items} + \li \l{Module Providers} + \endlist + +*/ + + +/*! + \previouspage usage.html + \page language-introduction.html + \nextpage building-applications.html + + \title Language Introduction + + \QBS uses project files (*.qbs) to describe the contents of a project. + A project contains one or more \l{Product}{products}. A product is the target of a build + process, typically an application, library or maybe a tar ball. + \note \QBS source files are assumed to be UTF-8 encoded. + + \section1 The Obligatory Hello World Example + + \QBS project files are written using a QML dialect. + A very simple C++ hello world project looks like this: + \code + ---helloworld.qbs--- + Application { + name: "helloworld" + files: "main.cpp" + Depends { name: "cpp" } + } + \endcode + + \a Application describes the product we want to build. In this case, an + application. This is just a shortcut for writing + \code + Product { + type: "application" + // ... + } + \endcode + + The \a name is the name of the product. In this case it is also the + name of the produced executable (on Windows, the ".exe" extension is added by default). + + In the property \a files, we specify the source files for our product. + Unlike QML, the right-hand side can be either a string or a string list. + A single string is converted to a stringlist containing just one element. + So we could have also written + + \code + files: [ "main.cpp" ] + \endcode + + \a Depends adds the dependency to the \l{cpp} module. This is necessary to + let \QBS know that we have a C++ project and want to compile main.cpp with a + C++ compiler. For more information about \QBS modules, see \l{Modules}. + + + \section1 Reusing Project File Code + QML-like inheritance works also in \QBS. + + \code + ---CrazyProduct.qbs--- + Product { + property string craziness: "low" + + files: [ + "Crazy.h", + "Crazy.cpp" + ] + } + + ---hellocrazyworld.qbs--- + import "CrazyProduct.qbs" as CrazyProduct + + CrazyProduct { + craziness: "enormous" + name: "hellocrazyworld" + files: base.concat(["main.cpp"]) + // ... + } + \endcode + + You can put JS code into separate \c{.js} files and then import them. + \code + ---helpers.js--- + function planetsCorrectlyAligned() + { + // implementation + } + + ---myproject.qbs--- + import "helpers.js" as Helpers + + Product { + name: "myproject" + Group { + condition: Helpers.planetsCorrectlyAligned() + file: "magic_hack.cpp" + } + // ... + } + \endcode + + See \l {Special Property Values} for more details about the \l base property. + + \section1 Modules + + A \e module is a collection of properties and language items that are used for + building a product if the product depends on (or loads) the module. + + For example, the \a cpp module looks like this (simplified): + \code + Module { + name: "cpp" + property string warningLevel + property string optimization + property bool debugInformation + property pathList includePaths + // ... + FileTagger { + patterns: "*.cpp" + fileTags: ["cpp"] + } + Rule {...} // compiler + Rule {...} // application linker + Rule {...} // static lib linker + Rule {...} // dynamic lib linker + } + \endcode + + The properties that can be set for the \a cpp module are used to control the behavior of + your C++ toolchain. + In addition, you can use FileTaggers and Rules that are explained later. + + As soon as your product depends on a module, it can set the properties of the + module. You specify the optimization level for your product (and all build variants) like this: + + \code ---helloworld.qbs--- + Application { + name: "helloworld" + files: ["main.cpp"] + cpp.optimization: "ludicrousSpeed" + Depends { name: "cpp" } + } + \endcode + + A module can implicitly depend on other modules. For example, the + \l{Qt.core} module depends on the \l{cpp} module. However, to set the + properties of a module, you must make the dependency explicit. + + \code + // THIS DOES NOT WORK + Application { + name: "helloworld" + files: ["main.cpp"] + Depends { name: "Qt.core" } + cpp.optimization: "ludicrousSpeed" + // ERROR! We do not know about "cpp" here, + // though "Qt.core" depends on "cpp". + } + + // THIS WORKS + Application { + name: "helloworld" + files: ["main.cpp"] + Depends { name: "Qt.core" } + Depends { name: "cpp" } + cpp.optimization: "ludicrousSpeed" + } + \endcode + + \section2 Different Properties for a Single File + + Not only the product, but all the source files of the product can have their own + set of module properties. For example, assume you have some files that are known to crash + your compiler if you turn on optimizations. You want to turn off + optimizations for just these files and this is how you do it: + + \code + Application { + name: "helloworld" + files: "main.cpp" + Group { + files: ["bad_file.cpp", "other_bad_file.cpp"] + cpp.optimization: "none" + } + Depends { name: "cpp" } + } + \endcode + + \section2 Selecting Files by Properties + + Sometimes you have a file that is only going to be compiled on a certain platform. + This is how you do it: + \code + Group { + condition: qbs.targetOS.contains("windows") + files: [ + "harddiskdeleter_win.cpp", + "blowupmonitor_win.cpp", + "setkeyboardonfire_win.cpp" + ] + } + Group { + condition: qbs.targetOS.contains("linux") + files: [ + "harddiskdeleter_linux.cpp", + "blowupmonitor_linux.cpp", + "setkeyboardonfire_linux.cpp" + ] + } + \endcode + + In the above example, \l{qbs::targetOS}{qbs.targetOS} is a property of the + target of the the \l{qbs} module. The \c qbs module is always implicitly + loaded. Its main properties are: + + \list + \li \l{qbs::}{buildVariant} that specifies the name of the build variant + for the current build. + \li \l{qbs::}{hostOS} that is set by \QBS internally and specifies the + operating system \QBS is running on. + \li \l{qbs::}{targetOS} that specifies the operating system you want to + build the project for. + \endlist + + You can set these properties on the command line or by using a profile. + + \code + $ qbs # qbs.buildVariant:debug, profile: (or profile:none, if no default profile exists) + $ qbs config:release # qbs.buildVariant:release, profile: + $ qbs config:debug config:release # builds two configurations of the project + $ qbs profile:none # all module properties have their default values + \endcode + + To select files by build variant: + \code + Group { + condition: qbs.buildVariant == "debug" + files: "debughelper.cpp" + } + \endcode + + To set properties for a build variant: + \code + Properties { + condition: qbs.buildVariant == "debug" + cpp.debugInformation: true + cpp.optimization: "none" + } + \endcode + Or, to use a more QML-like style: + \code + cpp.debugInformation: qbs.buildVariant == "debug" ? true : false + cpp.optimization: qbs.buildVariant == "debug" ? "none" : "fast" + \endcode + + \section1 Property Types + + While properties in \QBS generally work the same way as in QML, the set of possible property + types has been adapted to reflect the specific needs of a build tool. The supported types + are as follows: + + \table + \header + \li Property type + \li Example + \li Description + \row + \li \c bool + \li \c{property bool someBoolean: false} + \li The usual boolean values. + \row + \li \c int + \li \c{property int theAnswer: 42} + \li Integral numbers. + \row + \li \c path + \li \c{property path aFile: "file.txt"} + \li File paths resolved relative to the directory the product they are associated with + is located in. + \row + \li \c pathList + \li \c{property pathList twoFiles: ["file1.txt", "./file2.txt"]} + \li A list of \c path values. + \row + \li \c string + \li \c{property string parentalAdvisory: "explicit lyrics"} + \li JavaScript strings. + \row + \li \c stringList + \li \c{property stringList realWorldExample: ["no", "not really"]} + \li A list of JavaScript strings. + \row + \li \c var + \li \c{property var aMap: ({ key1: "value1", key2: "value2" })} + \li Generic data, as in QML. + \row + \li \c varList + \li \c{property var aMapList: [{ key1: "value1", key2: "value2" }, { key1: "value3" }]} + \li A list of generic data, typically JavaScript objects. + \endtable + + + \section1 Overriding Property Values from the Command Line + + Property values set in project files or profiles can be overridden on the command line. + The syntax is \c{.:}. The following command lines + demonstrate how to set different kinds of properties: + \code + $ qbs projects.someProject.projectProperty:false # set a property of a project + $ qbs products.someProduct.productProperty:false # set a property of a product + $ qbs modules.cpp.treatWarningsAsErrors:true # set a module property for all products + $ qbs products.someProduct.cpp.treatWarningsAsErrors:true # set a module property for one product + \endcode + + Property values on the command line can also be expressed in JavaScript form, the same way + as you would write them in a project file. Make sure to take care of proper + quoting, so that the shell does not interpret any of the values itself. Properties of type + \c stringList can also be provided as comma-separated values, if none of the strings contain + special characters: + \code + $ qbs projects.someProject.listProp:'["a", "b", "c"]' + $ qbs projects.someProject.listProp:a,b,c # same as above + $ qbs projects.someProject.listProp:'["a b", "c"]' # no CSV equivalent + \endcode + + \section1 File Tags and Taggers + + \QBS itself knows nothing about C++ files or file extensions. All source files + in a product are handled equally. However, you can assign \a{file tags} to an artifact + to act as a marker or to specify a file type. + + An artifact can have multiple file tags. + For example, you can use the \a Group item to group files with the same file tags (or a set of + properties). + + \code + Product { + Group { + files: ["file1.cpp", "file2.cpp"] + fileTags: ["cpp"] + } + Group { + files: "mydsl_scanner.l" + fileTags: ["flex", "foobar"] + } + // ... + } + \endcode + + When you load the \a cpp module, you also load the following item: + \code + FileTagger { + patterns: "*.cpp" + fileTags: ["cpp"] + } + \endcode + This construct means that each source file that matches the pattern \c{*.cpp} (and + has not explicitly set a file tag) gets the file tag \c{cpp}. + + The above example can be simplified to + \code + Product { + Depends: "cpp" + files: ["file1.cpp", "file2.cpp"] + Group { + files: "mydsl_scanner.l" + fileTags: ["flex", "foobar"] + } + // ... + } + \endcode + + The \a FileTagger from the \a cpp module automatically assigns the \c cpp + file tag to the source files. Groups that just contain the \a files + property can be more simply expressed by using the \a files property of the product. + + File tags are used by \a rules to transform one type of artifact into + another. For instance, the C++ compiler rule transforms artifacts with the file tag + \c cpp to artifacts with the file tag \c{obj}. + + In addition, it is possible to use file taggers to tag files and specify custom file tags: + \code + Product { + Depends: "cpp" + Group { + overrideTags: false // The overrideTags property defaults to true. + fileTags: ["foobar"] + files: ["main.cpp"] // Gets the file tag "cpp" through a FileTagger item and + // "foobar" from this group's fileTags property. + } + // ... + } + \endcode + + \section1 Rules + + \QBS applies a \e rule to a pool of artifacts (in the beginning it is just the set of + source files of the project) and chooses the ones that match the input file + tags specified by the rule. Then it creates output artifacts in the build graph that have other + filenames and file tags. It also creates a script that transforms the input artifacts into the + output artifacts. Artifacts created by one rule can (and typically do) serve as inputs to + another rule. In this way, rules are connected to one another via their input and output + file tags. + + For examples of rules, see the share/qbs/modules directory in the \QBS + repository. + + You can define rules in your own module to be provided along with + your project. Or you can put a rule directly into your project file. + + For more information, see \l{Rule}. +*/ + + +/*! + \previouspage language-introduction.html + \page building-applications.html + \nextpage running-applications.html + + \title Building Applications + + This section assumes that \QBS is present in \c PATH. For the details how to install \QBS, see + the \l{Installing} page. + + To build applications from the command line, enter the following commands: + + \code + cd examples/collidingmice + qbs + \endcode + + By default, \QBS uses all the CPU cores available to achieve maximum build + parallelization. To explicitly specify the number of concurrent jobs, use + the \c -j option. For example, to run 4 concurrent jobs, enter the following + command: + + \code + qbs -j4 + \endcode + + The application is built using the default build profile that is set up + in your \QBS configuration. + + You can use the \l{config} command to set the max number of jobs per profile. + For example, to set four jobs as the default option for a profile named + \e Android, enter the following command: + + \code + qbs config profiles.Android.preferences.jobs 4 + \endcode + + To build with other profiles than the default one, specify options for the + \l{build} command. For example, to build debug and release configurations with + the \e Android profile, enter the following command: + + \code + qbs build profile:Android config:debug config:release + \endcode + + The position of the property assignment is important. In the example + above, the profile property is set for all build configurations that come + afterwards. + + To set a property just for one build configuration, place the assignment after + the build configuration name. + In the following example, the property \l{cpp::treatWarningsAsErrors} + {cpp.treatWarningsAsErrors} is set to \c true for debug only and + \l{cpp::optimization}{cpp.optimization} is set to \c small for release only. + + \code + qbs build config:debug modules.cpp.treatWarningsAsErrors:true config:release modules.cpp.optimization:small + \endcode + + Projects are built in the debug build configuration by default. +*/ + +/*! + \previouspage running-applications.html + \page installing-files.html + \nextpage {Target Platforms} + + \title Installing Files + + To install your project, specify the necessary information in the project file: + + \code + Application { + Group { + name: "Runtime resources" + files: "*.qml" + qbs.install: true + qbs.installDir: "share/myproject" + } + Group { + name: "The App itself" + fileTagsFilter: "application" + qbs.install: true + qbs.installDir: "bin" + } + } + \endcode + + In this example, we want to install a couple of QML files and an executable. + + When building, \QBS installs artifacts into the default root folder, namely + \c{/install-root}. The \l{qbs::installPrefix}{qbs.installPrefix} and + \l{qbs::installDir}{qbs.installDir} properties are appended to the root folder. + \code + qbs build qbs.installPrefix:/usr + \endcode + In this example, the executable will be installed into the \c{/install-root/usr/bin} + folder and the QML files will be installed into the + \c{/install-root/usr/share/myproject} folder. + + To skip installation during the build, use the \c --no-install option. + + To override the default location, use the \c --install-root option of the \c{qbs install} + command: + \code + qbs build --no-install qbs.installPrefix:/usr + sudo qbs install --no-build --install-root / + \endcode + In this example, artifacts will be installed directly into the \c /usr folder. Since the + \c{qbs install} command implies \c build, we use the \c --no-build parameter to ensure that + we do not accidentally rebuild the project, thereby changing the artifacts' owner to \c root. + + Sometimes, it makes sense to install the application into a temporary root folder, keeping the + same folder structure within that root folder as in the examples above; for instance, + when building a Linux package such as \c deb or \c rmp. To install the application into the + \c /tmp/myProjectRoot folder, use the following command: + + \code + $ qbs install --install-root /tmp/myProjectRoot + \endcode + + In this example, the executable will be installed into the \c{/tmp/myProjectRoot/usr/bin} folder + and QML files will be installed into the \c{/tmp/myProjectRoot/usr/share/myproject} folder. + + To remove all files from the install root prior to installing, use the \c --clean-install-root + parameter: + + \code + qbs install --clean-install-root --install-root /tmp/myProjectRoot + \endcode + + For more information about how the installation path is constructed, see + \l {Installation Properties}. +*/ + +/*! + \previouspage building-applications.html + \page running-applications.html + \nextpage installing-files.html + + \title Running Applications + + Qbs has the convenience \l{run}{qbs run} command that simplifies running applications. + + For example, entering the following command runs the Qt Creator application: + + \code + qbs run --products qtcreator + \endcode + + By default, running an application also builds it and installs it to a + location from where it can be run on the desktop or on a device. Also, this command + \l{Module::setupRunEnvironment}{sets up} the environment so that the application can find + dependent libraries. + + This is not the case when running the binary manually - you'll have to make sure that the + app will find its dependencies and/or is relocatable. You can achieve that by + \l{How do I make use of rpaths?}{configuring rpaths} properly or setting the appropriate + environment variable for the respective host system. + +*/ + +/*! + \previouspage {Target Platforms} + \page shell.html + \nextpage generators.html + + \title Using the Shell + + To use the \QBS shell, enter the following command: + + \code + qbs shell + \endcode + + This is mainly a debugging tool. It opens a shell with the same environment + that \QBS uses when building the project, so you can, for example, inspect + which environment variables will be set up. + +*/ + +/*! + \previouspage multiplexing.html + \page custom-modules.html + \nextpage module-providers.html + + \title Custom Modules and Items + + Users of \QBS are not limited to the pre-defined \l{List of Modules}{modules} and + \l{List of Language Items}{items}, they can also create their own. Here we describe how + to set up custom modules and items so that \QBS will find them. + + \section1 File System Layout + + Items and modules are located under a common base directory, whose name and location is + completely arbitrary. We will refer to it as \c search-path here. This directory has two + subdirectories \c modules and \c imports, which contain \QBS modules and items, respectively. + + + \section1 Custom Modules + + To introduce a custom module \c mymodule, create a directory \c{search-path/modules/mymodule/}. + \note Module names are case-sensitive, and this also goes for the corresponding directory name. + + Then, put a file containing an instance of the \l{Module} in there and give it the \c{.qbs} + extension. This module will be pulled in if a + \l{Product}{product} declares a \l{Depends}{dependency} on \c mymodule. + + + \section1 Custom Items + + To introduce a custom item \c MyItem, create the file \c{search-path/imports/MyItem.qbs}. + + \note Item file names must start with a capital letter due to the fact that type names can + only start with a capital letter. Otherwise, the file will be silently ignored. + + \section1 Making \QBS Aware of Custom Modules and Items + + To be able to use your custom modules and items, you need to make them known to \QBS. You can + do this per project or globally. + + \section2 Project-specific Modules and Items + + Let's assume you have a project that is located in \c{project_dir} and you have created some + modules in \c{project_dir/custom-stuff/modules/} as well as some items in + \c{project_dir/custom-stuff/imports/} that you want to use in the project. + To achieve this, your top-level project file should look like this: + \code + // ... + Project { + // .. + qbsSearchPaths: "custom-stuff" + // .. + } + \endcode + \note For technical reasons, the custom modules and items will not be + available in the file that contains the \l{Project::qbsSearchPaths} + {Project.qbsSearchPaths} property. Any product that wants to make use of + them needs to be in a different file that is pulled in via the + \l{Project::references}{Project.references} property, for example. + This is not a serious limitation, since every well-structured project will + be split up in this manner. + + \section2 Making Custom Modules and Items Available Across Projects + + What if your modules and items are generally useful and you want to access them in several + projects? In this case, it is best to add the location to your preferences. + For example: + \code + qbs config preferences.qbsSearchPaths /usr/local/share/custom-qbs-extensions + \endcode + +*/ + +/*! + \previouspage custom-modules.html + \page module-providers.html + \nextpage howtos.html + + \title Module Providers + + There are use cases for which a pre-defined module is not flexible enough. + For instance, the overall set of modules related to a certain task might depend + on some information present on the local platform. + + \note Module providers are an advanced concept that you will rarely need to use directly. + Reading this section is not required for most people's everyday work. + + \section1 How \QBS Uses Module Providers + + If \QBS encounters a \l Depends item whose name does not match a known module, + it checks whether such a module can be generated. This procedure works as follows: + \list 1 + \li If the \l{Product::qbsModuleProviders}{qbsModuleProviders} property is not + \c undefined, for each provider name in the list, all + \l{Project::qbsSearchPaths}{search paths} are scanned for a file called + \c {module-providers/.qbs} or \c {module-providers//provider.qbs}. + \li If the \l{Product::qbsModuleProviders}{qbsModuleProviders} property is \c undefined, + \l{Project::qbsSearchPaths}{search paths} are scanned for a file called + \c {module-providers//provider.qbs}, where \c is the name of the dependency + as specified in the \c Depends item. Multi-component names such as "a.b" are turned + into nested directories, and each of them is scanned, starting with the deepest path. + For instance, if the dependency's name is \c {a.b}, then \QBS will look for + \c {a/b/provider.qbs} and then \c {a/provider.qbs}. + \li If such a file is found, it needs to contain a \l ModuleProvider item. This item + is instantiated, which potentially leads to the creation of one or more modules, + and \QBS retrieves the search paths to find these modules from the item. + The details are described in the \l ModuleProvider documentation. + \li If a matching module provider was found and provided new search paths, + a second attempt will be made to locate the dependency using the new paths. + The search for a matching module provider ends as soon as one was found, regardless + of whether it created any modules or not. + \li If no matching module provider was found in any of the search paths, \QBS will fall back + to a generic module provider, which creates a module that attempts to locate the + dependency via \c pkg-config. + This fallback mechanism can be disabled in the respective + \l{Depends::enableFallback}{Depends} item or globally via the + \l{no-fallback-module-provider}{--no-fallback-module-provider} option. + \endlist + + \section1 Selecting Module Providers + + As described above, it is possible to select which providers to run using the + \l{Product::qbsModuleProviders}{qbsModuleProviders} property. Providers contribute to the + \l{Product::}{qbsSearchPaths} in the order specified by this property, so modules generated + by providers specified earlier are prioritized. This property can be set on the + Product as well as the \l{Project::qbsModuleProviders}{Project} level: + + \code + $ qbs resolve project.qbsModuleProviders:providerA \ # sets property globally for the Project + projects.SomeProject.qbsModuleProviders:providerB \ # overrides property for the specific Project + products.SomeProduct.qbsModuleProviders:providerC \ # overrides property for the specific Product + \endcode + + \section1 Parameterizing Module Providers + + You can pass information to module providers from the command line, via profiles or + from within a product, in a similar way as you would do for modules. For instance, the + following invocation of \QBS passes information to two module providers \c a and \c b: + \code + $ qbs moduleProviders.a.p1:true moduleProviders.a.p2:true moduleProviders.b.p:false + \endcode + \QBS will set the properties of the respective module providers accordingly. + In the above example, module provider \c a needs to declare two boolean properties \c p1 + and \c p2, and they will be set to \c true and \c false, respectively. + +*/ + +/*! + \previouspage shell.html + \page generators.html + \nextpage multiplexing.html + + \title Generators + + Generators are a \QBS sub-tool and set of APIs that enable arbitrary + processing to be performed on the build graph. Currently, they are used to + integrate \QBS with popular IDEs, such as Microsoft Visual Studio, and to + generate Clang compilation databases. + + \section1 Generating Microsoft Visual Studio Projects + + To generate a project for another build system, such as Microsoft Visual + Studio, use the \l{generate}{qbs generate} command and specify a generator + using the \l{generate-generator}{-g} option. For example: + + \code + # For Visual Studio + qbs generate -g visualstudio2015 + \endcode + + \QBS will then generate a series of files in the current directory, based on the generator that + was chosen. The resulting project files can be opened in the respective IDE + and all work can be performed there. + + The project files will expose as much information as possible to the IDE and will use \QBS to + perform the actual build. + + \note You cannot modify build system files and expect the changes + to be reflected in \QBS. You must edit your \QBS project files and re-run + \l{generate}{qbs generate} in order for the changes to be reflected in your + IDE. + + \section1 Generating IAR Embedded Workbench Projects + + To generate a project for \l{https://www.iar.com/iar-embedded-workbench/} + {IAR Embedded Workbench}, use the \l{generate}{qbs generate} command and specify + a generator using the \l{generate-generator}{-g} option. For example: + + \code + # For IAREW v8xxxx + qbs generate -g iarew8 profile: + qbs generate -g iarew8 -d -f profile: + \endcode + + \note You need to specify a specific QBS profile, which is required for a generator + to fetch a target architecture to generate the project. + + \note IAR EW generator creates a native target project. + + Supported IAR EW generators are listed in a table below: + + \table + \header \li Generator \li IAR EW Version \li Target Architecture + \row \li iarew8 \li All 8.x.y versions \li ARM + \row \li iarew7 \li All 7.x.y versions \li AVR, MSP430 + \row \li iarew10 \li All 10.x.y versions \li 8051 (aka MCS51) + \row \li iarew3 \li All 3.x.y versions \li STM8 + \endtable + + \section1 KEIL uVision Projects + + To generate a project for \l{https://www2.keil.com/mdk5/uvision/} + {KEIL uVision}, use the \l{generate}{qbs generate} command and specify + a generator using the \l{generate-generator}{-g} option. For example: + + \code + # For KEIL UV5 + qbs generate -g keiluv5 profile: + qbs generate -g keiluv5 -d -f profile: + \endcode + + \note You need to specify a specific QBS profile, which is required for a generator + to fetch a target architecture to generate the project. + + \note KEIL UV generator creates a native target project. + + Supported KEIL UV generators are listed in a table below: + + \table + \header \li Generator \li KEIL UV Version \li Target Architecture + \row \li keiluv5 \li All 5.x.y versions \li 8051 (aka MCS51), ARM + \endtable + + \section1 Generating Clang Compilation Databases + + To generate a \l{JSON Compilation Database Format Specification} + {Clang compilation database (clangdb)}, use the following command: + + \code + qbs generate --generator clangdb + \endcode + + \section1 Generating Makefiles + + To generate a Makefile, use the following command: + \code + qbs generate --generator makefile + \endcode + + \section2 Targets + + The generated Makefile will contain targets for all output artifacts known to \QBS. + + In addition, the following targets are created for every product: + \list + \li \c {} to build the product + \li \c {clean-} to remove all files generated by the above target + \li \c {install-} to install the product's artifacts that have + \c{qbs.install} set + \endlist + In the above list, the placeholder \c{} stands for the product's name with + all characters that are not ASCII letters, digits, dots or underscores replaced + with underscore characters. + + The special target \c all builds all products whose \l{Product::builtByDefault}{builtByDefault} + property is enabled. This is the default target. It is complemented by \c install and \c clean. + + \note The Makefile will not be able to build artifacts created by + \l{JavaScriptCommand}{JavaScriptCommands}, because there is no command line to run for them. + + \section2 Pre-defined Variables + + The build directory and the install root are set to whatever you specified when calling the + generator. If you did not specify anything, \QBS' default values are used. You can override + these values when invoking the \c make tool by explicitly setting the \c{BUILD_ROOT} + and \c{INSTALL_ROOT} variables, respectively. For instance: + \code + $ qbs generate -g makefile config:make modules.qbs.installRoot:/opt/mydir + $ make -f make/Makefile # Will install to /opt/mydir + $ make -f make/Makefile INSTALL_ROOT=/opt/myotherdir # Will install to /opt/myotherdir + \endcode + + \section2 Spaces in Directory Names + + Due to the difficulties involved in making this work correctly, \QBS will refuse to generate + a Makefile if the source, build or install root directories contain spaces. It will + try to handle spaces in file names of output artifacts, though. + + \section2 Platform-specific Differences in Format + + \QBS assumes that the Makefile will be invoked on the current host platform, so that + platform's tools will be used for copying and removing files, and path separators will + be converted to backslashes on Windows. When dealing with spaces in artifact names, + on Unix-like systems compatibility with GNU make is assumed with regards to quoting. + + \section1 Limitations + + Due to the high flexibility of the \QBS project format and build engine, some projects may be too + complex to produce an equivalent project file for another build system. + + This list of limitations aims to be as small as possible, but one of the most notable (at least + for the Microsoft Visual Studio generator) is that certain properties must contain the same + value across all build configurations. For example, the following is not allowed: + + \code + Product { + // ERROR: 'name' property cannot have different values based on the configuration + name: qbs.configuration === "debug" + ? "MyProduct_debug" + : "MyProduct" + } + \endcode + + \note This limitation only applies when property values are varied on the configuration + name. For example, the following is OK (as long as the value of xyz itself does not vary across + configurations): + + \code + Product { + // OK + property bool isDebug: + name: isDebug ? "MyProduct_debug" : "MyProduct" + } + \endcode + + The properties to which the limitation applies includes but is not limited to: + + \list + \li \l{Product::name}{Product.name} + \li \l{bundle::isBundle}{bundle.isBundle} + \endlist + + If a simple workaround is possible in a particular case (for example, + varying \l{Product::targetName}{Product.targetName} across configuration + instead of \l{Product::name}{Product.name}, the generator will typically + suggest it in the error message. +*/ + +/*! + \previouspage generators.html + \page multiplexing.html + \nextpage custom-modules.html + + \title Multiplexing + + Multiplexing is an advanced \QBS feature that allows a product to be + transparently built in multiple \e passes along with an optional, final + \e aggregate pass that allows the output artifacts of the initial passes + to be combined or otherwise operated on in some way. + + The multiplexing feature is used to implement certain platform-specific + behavior: specifically, it allows applications and libraries on Apple + platforms to be compiled into \e fat binaries containing multiple CPU + architectures, the creation of Apple frameworks containing multiple + \e variants (for example, combined debug and release builds), and the + creation of Android application and library packages containing native + code built for multiple Android ABIs. + + A product can be multiplexed over the \l{qbs::architectures} + {qbs.architectures} property (which maps to \l{qbs::architecture} + {qbs.architecture}), \l{qbs::buildVariants}{qbs.buildVariants} property + (which maps to \l{qbs::buildVariant}{qbs.buildVariant}), and \l{qbs::profiles} + {qbs.profiles} (which maps to \l{Project::profile}{Project.profile}). + + For example, to build a "fat" \c iOS binary containing two architectures, use the following + command: + \code + qbs build modules.qbs.targetPlatform:ios modules.qbs.architectures:arm64,armv7a + \endcode + + \note The implementation details around multiplexing are subject to change. + + Product multiplexing works by examining the + \l{Product::multiplexByQbsProperties}{Product.multiplexByQbsProperties} + property, which can + be set to the list of properties your product should multiplex over. For + example, \c multiplexByQbsProperties might contain two strings, + \c "architectures" and \c "buildVariants". \QBS evaluates the values of + \c qbs.architectures and \c qbs.buildVariants, which in turn might contain + the values \c ["x86", "x86_64"] and \c ["debug", "release"]. \QBS will build + all the possible configurations of the product: \c {(x86, debug)}, + \c {(x86, release)}, \c {(x86_64, debug)}, and \c {(x86_64, release)}. + + If the \l{Product::aggregate}{Product.aggregate} property is \c true, the + product will also be + built a fifth time, with the values of the multiplexed properties left + undefined. The aggregate product will have an automatic dependency on the + original four instances of the product, allowing it to collect their output + artifacts and to operate on them. + + The aggregate product is used in situations where the target artifacts of + the individually multiplexed instances must be combined into one final + aggregate artifact that makes up the overall product. + Bundle products on Apple platforms use the aggregate product to create the + bundle artifacts (such as \c Info.plist and \c PkgInfo) that are independent + of a particular architecture or build variant. In addition, they use the + \c lipo tool to join together the built native code for different + architectures (such as \c x86 and \c x86_64) into the final, + multi-architecture fat binary that the app bundle contains. +*/ + +/*! + \previouspage json-api.html + \page attributions.html + + \title Appendix D: Licenses and Code Attributions + + \section1 Licenses + + The \QBS library and tools are available under commercial licenses from + \l{Qt Licensing}{The Qt Company}. In addition, they are available under + \l{GNU Lesser General Public License, Version 3} (LGPL version 3) and + \l{GNU General Public License, version 2} (GPL version 2). + + Shared functionality, which might be pulled in by user build scripts, is + available under commercial licenses, + \l{GNU Lesser General Public License, Version 2.1} (LGPL version 2.1) with + \l{The Qt Company LGPL Exception version 1.1}, and LGPL version 3. + + Autotests are available under commercial licenses and + \l{GNU General Public License Version 3, Annotated with The Qt Company GPL Exception 1.0}. + + Examples are available under commercial licenses and \l{BSD}. + + \section2 GNU Lesser General Public License, Version 3 + + \quotefile ../LICENSE.LGPLv3 + + \section2 GNU General Public License Version 3, Annotated with The Qt Company GPL Exception 1.0 + + \quotefile ../LICENSE.GPL3-EXCEPT + + \section2 GNU Lesser General Public License, Version 2.1 + + \quotefile ../LICENSE.LGPLv21 + + \section2 The Qt Company LGPL Exception version 1.1 + + \quotefile ../LGPL_EXCEPTION.txt + + \section1 Third-Party Attibutions + + \QBS contains third-party code, which we gratefully acknowledge: + \generatelist{groupsbymodule attributions-qbs} +*/ diff --git a/doc/qbs.qdocconf b/doc/qbs.qdocconf new file mode 100644 index 00000000..9a1b2f6a --- /dev/null +++ b/doc/qbs.qdocconf @@ -0,0 +1,2 @@ +include(config/qbs-project.qdocconf) +include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf) diff --git a/doc/reference/cli/builtin/cli-build.qdoc b/doc/reference/cli/builtin/cli-build.qdoc new file mode 100644 index 00000000..683b1ebb --- /dev/null +++ b/doc/reference/cli/builtin/cli-build.qdoc @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-build.html + \ingroup cli + + \title build + \brief Builds a project. + + \section1 Synopsis + + \code + qbs build [options] [[config:configuration-name] [property:value] ...] + \endcode + + \section1 Description + + Builds projects in one or more configurations. + + You can specify \l{Project}{project}, \l{Product}{product}, or + \l{List of Modules}{module} properties, as well as a \l{Profile} + {profile} separately for each configuration. + + This is the default command. + + If the build directory does not exist, it will be created. + + For more information, see \l{Building Applications}. + + \section1 Options + + \target build-all-products + \include cli-options.qdocinc all-products + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc changed-files + \include cli-options.qdocinc check-outputs + \include cli-options.qdocinc check-timestamps + \include cli-options.qdocinc clean_install_root + \include cli-options.qdocinc command-echo-mode + \include cli-options.qdocinc dry-run + \include cli-options.qdocinc project-file + \target build-force-probe-execution + \include cli-options.qdocinc force-probe-execution + \include cli-options.qdocinc jobs + \include cli-options.qdocinc job-limits + \include cli-options.qdocinc keep-going + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc no-install + \target build-products + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc show-progress + \target no-fallback-module-provider + \include cli-options.qdocinc no-fallback-module-provider + \include cli-options.qdocinc wait-lock + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples + + Builds the application specified by the \c .qbs file in the current + directory using the default profile: + + \code + qbs + \endcode + + Builds the application using four concurrent build jobs: + + \code + qbs -j 4 + \endcode + + Builds the default configuration of an application using the profile called + \c Android: + + \code + qbs build profile:Android + \endcode + + Builds the application using different \l{cpp} module properties + for debug and release configurations. For the debug configuration, warnings + will cause the build to fail, whereas for the release configuration, the + size of the build artifacts will be optimized. Both configurations are built + with a profile named \c{"qt"}: + + \code + qbs build profile:qt config:debug modules.cpp.treatWarningsAsErrors:true config:release modules.cpp.optimization:small + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-clean.qdoc b/doc/reference/cli/builtin/cli-clean.qdoc new file mode 100644 index 00000000..901ac2f3 --- /dev/null +++ b/doc/reference/cli/builtin/cli-clean.qdoc @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-clean.html + \ingroup cli + + \title clean + \brief Removes the files generated during a build. + + \section1 Synopsis + + \code + qbs clean [options] [config:configuration-name] + \endcode + + \section1 Description + + Removes build \l{Artifact}{artifacts} for the specified build + configuration. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc dry-run + \include cli-options.qdocinc keep-going + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc show-progress + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + + \section1 Examples + + Removes the build artifacts in the current directory for the default build + configuration: + + \code + qbs clean + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-dump-nodes-tree.qdoc b/doc/reference/cli/builtin/cli-dump-nodes-tree.qdoc new file mode 100644 index 00000000..270927cc --- /dev/null +++ b/doc/reference/cli/builtin/cli-dump-nodes-tree.qdoc @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-dump-nodes-tree.html + \ingroup cli + + \title dump-nodes-tree + \brief Dumps the nodes in the build graph to \c stdout. + + \section1 Synopsis + + \code + qbs dump-nodes-tree [options] [config:configuration-name] + \endcode + + \section1 Description + + Dumps the nodes in the build graph to \c stdout. + + This is an internal command that is used for debugging purposes only. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + + \section1 Examples + + Dumps the nodes tree into a file called \c nodes-tree.log: + + \code + qbs dump-nodes-tree >nodes-tree.log + \endcode + +*/ diff --git a/doc/reference/cli/builtin/cli-generate.qdoc b/doc/reference/cli/builtin/cli-generate.qdoc new file mode 100644 index 00000000..c7c14fc8 --- /dev/null +++ b/doc/reference/cli/builtin/cli-generate.qdoc @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-generate.html + \ingroup cli + + \title generate + \brief Invokes a project generator, for example to create project files for + another build tool. + + \section1 Synopsis + + \code + qbs generate [options] [[config:configuration-name] [property:value] ...] + \endcode + + \section1 Description + + Invokes a project generator, for example to create project files for another + build tool. + + For more information, see \l{Generators}. + + \section1 Options + + \target generate-generator + \include cli-options.qdocinc generator + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc project-file + \include cli-options.qdocinc install-root + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc show-progress + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples + + Generates a project for Microsoft Visual Studio: + + \code + qbs generate -g visualstudio2015 + \endcode + + Generates a \l{https://clang.llvm.org/docs/JSONCompilationDatabase.html} + {Clang compilation database (clangdb)}: + + \code + qbs generate --generator clangdb + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-help.qdoc b/doc/reference/cli/builtin/cli-help.qdoc new file mode 100644 index 00000000..da19fda1 --- /dev/null +++ b/doc/reference/cli/builtin/cli-help.qdoc @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-help.html + \ingroup cli + + \title help + \brief Shows general or command-specific help. + + \section1 Synopsis + + \code + qbs help [] + \endcode + + \section1 Description + + Shows a list of available commands with descriptions. Specify a command + name to list the options that the command takes with descriptions. + + \section1 Options + + This command takes no options. + + \section1 Examples + + Shows an overview of all commands: + + \code + qbs help + \endcode + + Lists the options that the \c build command takes: + + \code + qbs help build + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-install.qdoc b/doc/reference/cli/builtin/cli-install.qdoc new file mode 100644 index 00000000..92fad06a --- /dev/null +++ b/doc/reference/cli/builtin/cli-install.qdoc @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-install.html + \ingroup cli + + \title install + \brief Installs a project. + + \section1 Synopsis + + \code + qbs install [options] [[config:configuration-name] [property:value] ...] + \endcode + + \section1 Description + + Install all files marked as installable to their respective destinations. + The project is built first, if necessary, unless the \c --no-build option is + given. + + For more information, see \l{Installing Files}. + + \section1 Options + + \include cli-options.qdocinc all-products + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc changed-files + \include cli-options.qdocinc check-outputs + \include cli-options.qdocinc check-timestamps + \include cli-options.qdocinc clean_install_root + \include cli-options.qdocinc command-echo-mode + \include cli-options.qdocinc dry-run + \include cli-options.qdocinc project-file + \include cli-options.qdocinc force-probe-execution + \include cli-options.qdocinc install-root + \include cli-options.qdocinc jobs + \include cli-options.qdocinc keep-going + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc no-build + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc wait-lock + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples + +*/ diff --git a/doc/reference/cli/builtin/cli-list-products.qdoc b/doc/reference/cli/builtin/cli-list-products.qdoc new file mode 100644 index 00000000..583029a7 --- /dev/null +++ b/doc/reference/cli/builtin/cli-list-products.qdoc @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-list-products.html + \ingroup cli + + \title list-products + \brief Lists all products in the given project. + + \section1 Synopsis + + \code + qbs list-products [options] [config:configuration-name] + \endcode + + \section1 Description + + Lists all products that exist in a project. + + \section1 Options + + \include cli-options.qdocinc project-file + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc settings-dir + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + + \section1 Examples + + To list all products for the project in the current directory: + + \code + qbs list-products + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-resolve.qdoc b/doc/reference/cli/builtin/cli-resolve.qdoc new file mode 100644 index 00000000..273ce840 --- /dev/null +++ b/doc/reference/cli/builtin/cli-resolve.qdoc @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-resolve.html + \ingroup cli + + \title resolve + \brief Resolves a project without building it. + + \section1 Synopsis + + \code + qbs resolve [options] [[config:configuration-name] [property:value] ...] + \endcode + + \section1 Description + + Resolves a \l{Project}{project} in one or more configurations. Run this + command to change the properties of an existing build. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc dry-run + \include cli-options.qdocinc project-file + \include cli-options.qdocinc force-probe-execution + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc show-progress + \include cli-options.qdocinc no-fallback-module-provider + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples + + Resolves the default configuration of the project in the current directory: + + \code + qbs resolve + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-run.qdoc b/doc/reference/cli/builtin/cli-run.qdoc new file mode 100644 index 00000000..a0d3adee --- /dev/null +++ b/doc/reference/cli/builtin/cli-run.qdoc @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-run.html + \ingroup cli + + \title run + \brief Runs an executable generated by building a project. + + \section1 Synopsis + + \code + qbs run [options] [config:configuration-name] [property:value] ... [ -- ] + \endcode + + \section1 Description + + Runs the specified product's executable with the specified \c . + If the project has only one product, the \c --products option may be + omitted. + + The product will be built if it is not up to date, unless the \c --no-build + option is specified. For more information, see \l{build}. + + For more information about running applications, see + \l{Running Applications}. + + \section1 Options + + \include cli-options.qdocinc all-products + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc changed-files + \include cli-options.qdocinc check-outputs + \include cli-options.qdocinc check-timestamps + \include cli-options.qdocinc clean_install_root + \include cli-options.qdocinc command-echo-mode + \include cli-options.qdocinc dry-run + \include cli-options.qdocinc project-file + \include cli-options.qdocinc force-probe-execution + \include cli-options.qdocinc install-root + \include cli-options.qdocinc jobs + \include cli-options.qdocinc keep-going + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc log-time + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc no-build + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc setup-run-env-config + \include cli-options.qdocinc wait-lock + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Arguments + + \include cli-parameters.qdocinc arguments + + \section1 Examples + + Runs the Qt Creator application: + + \code + qbs run --products qtcreator + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-session.qdoc b/doc/reference/cli/builtin/cli-session.qdoc new file mode 100644 index 00000000..85367423 --- /dev/null +++ b/doc/reference/cli/builtin/cli-session.qdoc @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-session.html + \ingroup cli + + \title session + \brief Starts a session for interacting with an IDE + + \section1 Synopsis + + \code + qbs session + \endcode + + \section1 Description + + Starts a session, communicating via standard input and standard output. + + In this mode, \QBS takes commands from standard input and sends replies + to standard output, using a \l{Appendix C: The JSON API}{JSON-based API}. + + This is the recommended \QBS interface for IDEs. It can be used to retrieve + information about a project and interact with it in various ways, such + as building it, collecting the list of executables, adding new source files + and so on. + +*/ diff --git a/doc/reference/cli/builtin/cli-shell.qdoc b/doc/reference/cli/builtin/cli-shell.qdoc new file mode 100644 index 00000000..f024fc33 --- /dev/null +++ b/doc/reference/cli/builtin/cli-shell.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-shell.html + \ingroup cli + + \title shell + \brief Opens a shell with a product's environment. + + \section1 Synopsis + + \code + qbs shell [options] [config:configuration-name] [property:value] + \endcode + + \section1 Description + + Opens a shell in the environment that a build with the specified parameters + would use. + + For more information, see \l{Using the Shell}. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc project-file + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings-dir + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples + + Opens a shell with the same environment that \QBS uses when building the + project: + + \code + qbs shell + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-status.qdoc b/doc/reference/cli/builtin/cli-status.qdoc new file mode 100644 index 00000000..16bea519 --- /dev/null +++ b/doc/reference/cli/builtin/cli-status.qdoc @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-status.html + \ingroup cli + + \title status + \brief Shows the status of files in the project directory. + + \section1 Synopsis + + \code + qbs status [options] [config:configuration-name] + \endcode + + \section1 Description + + Lists all the files in the project directory and shows whether they are + known to \QBS in the respective configuration. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc settings-dir + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + + \section1 Examples + + To list the files in the project directory and view their status: + + \code + qbs status + \endcode +*/ diff --git a/doc/reference/cli/builtin/cli-update-timestamps.qdoc b/doc/reference/cli/builtin/cli-update-timestamps.qdoc new file mode 100644 index 00000000..8d66071b --- /dev/null +++ b/doc/reference/cli/builtin/cli-update-timestamps.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-update-timestamps.html + \ingroup cli + + \title update-timestamps + \brief Marks the build as up-to-date. + + \section1 Synopsis + + \code + qbs update-timestamps [options] [config:configuration-name] ... + \endcode + + \section1 Description + + Updates the timestamps of all build \l{Artifact}{artifacts}, causing + the next builds of the \l{Project}{project} to do nothing until source + files are updated again. + + This command is useful if you know that the current changes to source files + are irrelevant to the build. + + \note Using this command causes a discrepancy between the actual state of + source files and the information in the build graph, so be careful. + + \section1 Options + + \include cli-options.qdocinc build-directory + \include cli-options.qdocinc less-verbose + \include cli-options.qdocinc log-level + \include cli-options.qdocinc more-verbose + \include cli-options.qdocinc products-specified + \include cli-options.qdocinc settings + + \section1 Parameters + + \include cli-parameters.qdocinc configuration-name + \include cli-parameters.qdocinc property + + \section1 Examples +*/ diff --git a/doc/reference/cli/builtin/cli-version.qdoc b/doc/reference/cli/builtin/cli-version.qdoc new file mode 100644 index 00000000..f4dab3cb --- /dev/null +++ b/doc/reference/cli/builtin/cli-version.qdoc @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-version.html + \ingroup cli + + \title show-version + \brief Prints the \QBS version. + + \section1 Synopsis + + \code + qbs show-version + \endcode + + \section1 Description + + Prints the version of \QBS to stdout. + + \section1 Options + + This command takes no options. + +*/ diff --git a/doc/reference/cli/cli-options.qdocinc b/doc/reference/cli/cli-options.qdocinc new file mode 100644 index 00000000..db8eeae4 --- /dev/null +++ b/doc/reference/cli/cli-options.qdocinc @@ -0,0 +1,540 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + +//! [all-products] + + \section2 \c --all-products + + Processes all \l{Product}{products}, even if their \c builtByDefault + property is \c false. + +//! [all-products] + +//! [blacklist] + + \section2 \c {--blacklist } + + Ignores files whose names match the patterns specified by \c . + The list entries can contain wildcards and are separated by commas. + + By default, no files are ignored. + +//! [blacklist] + +//! [build-directory] + + \section2 \c {--build-directory|-d } + + Specifies a \c where build artifacts are stored. + + The default value is the current directory unless + \c preferences.defaultBuildDirectory is set. + + Relative paths will be interpreted relative to the current directory. + + You can use the following special values as placeholders: + + \list + \li \c @project is expanded to the name of the project file excluding + the extension \c .qbs. + \li \c @path is expanded to the name of the directory containing the + project file. + \endlist + +//! [build-directory] + +//! [changed-files] + + \section2 \c {--changed-files [,...]} + + Assumes that the files specified by \c , and only those files, have + changed. + +//! [changed-files] + +//! [check-outputs] + + \section2 \c --check-outputs + + Forces transformer output \l{Artifact}{artifact} checks. + + Verifies that the output artifacts declared by \l{Rule}{rules} in the + \l{Project}{project} are actually created. + +//! [check-outputs] + +//! [check-timestamps] + + \section2 \c --check-timestamps + + Forces timestamp checks. + + Retrieves the timestamps from the file system, instead of using the file + timestamps that are stored in the build graph. + +//! [check-timestamps] + +//! [clean_install_root] + + \section2 \c --clean-install-root + + Removes the installation base directory before installing. + +//! [clean_install_root] + +//! [command-echo-mode] + + \section2 \c {--command-echo-mode } + + Determines what kind of output to show when executing commands. + + Possible values of \c are: + + \list + \li \c silent + \li \c summary (default value) + \li \c command-line + \li \c command-line-with-environment + \endlist + +//! [command-echo-mode] + +//! [detect-qt-versions] + + \section2 \c --detect + + Attempts to auto-detect all known Qt versions, looking them up in the PATH + environment variable. + +//! [detect-qt-versions] + +//! [detect-toolchains] + + \section2 \c --detect + + Attempts to auto-detect all known toolchains, looking them up in the PATH + environment variable. + +//! [detect-toolchains] + +//! [dry-run] + + \section2 \c --dry-run|-n + + Performs a dry run. No commands will be executed and no permanent changes to + the build graph will be done. + +//! [dry-run] + +//! [export] + + \section2 \c {--export } + + Exports settings to the specified \c . + +//! [export] + +//! [project-file] + + \section2 \c {[--file|-f ]} + + Uses \c as the project file. If \c is a directory and it + contains a single file with the extension \c .qbs, that file will be used. + + If this option is not given at all, the behavior is the same as for + \c{-f }. + +//! [project-file] + +//! [flat] + + \section2 \c --flat + + Does not create nested project files, even if there are subdirectories and + the top-level directory does not contain any files. + +//! [flat] + +//! [force-probe-execution] + + \section2 \c --force-probe-execution + + Forces re-execution of all \l{Probe} items' configure scripts, + rather than using the cached data. + +//! [force-probe-execution] + +//! [generator] + + \section2 \c {--generator|-g } + + Uses the specified build system generator. + + Possible values of \c include: + + \list + \li \c clangdb + \li \c visualstudio2015 + \li \c iarew8 + \endlist + + The available generators are listed if you run the \c {qbs generate} command + without passing a generator to it. + +//! [generator] + +//! [help] + + \section2 \c {--help|-h|-?} + + Displays help for the command. + +//! [help] + +//! [import] + + \section2 \c {--import } + + Imports settings from the specified \c . + +//! [import] + +//! [install-root] + + \section2 \c {--install-root } + + Installs into the specified \c . If the directory does not exist, + it will be created. + + The default value is \c /install-root. + + Use the special value \c @sysroot to install into the \c sysroot. That is, + the value of the \l{qbs::sysroot}{qbs.sysroot} property. + +//! [install-root] + +//! [jobs] + + \section2 \c {--jobs|-j } + + Uses \c concurrent build jobs, where \c must be an integer greater + than zero. + + The default is the number of logical cores. + +//! [jobs] + +//! [job-limits] + + \section2 \c {--job-limits :[,:...]} + + Sets pool-specific job limits. See \l{job-pool-howto}{here} for more information on + job pools. + + \section2 \c {--enforce-project-job-limits} + + Normally, job limits defined in project files via the \l JobLimit item get overridden + by those set on the command line. If this option is passed, they get maximum priority + instead. Use it if there are product-specific limits that make more sense for + that part of the code base than the generic ones you'd like to apply globally. + +//! [job-limits] + +//! [keep-going] + + \section2 \c --keep-going|-k + + Keeps going when errors occur, if at all possible. + +//! [keep-going] + +//! [less-verbose] + + \section2 \c --less-verbose|-q + + Becomes more quiet by decreasing the log level by one. This option can be + given more than once. Excessive occurrences have no effect. + + If the option \c --log-level appears anywhere on the command line in + addition to this option, its value is taken as the base for the decrease. + +//! [less-verbose] + +//! [list-root] + + \section2 \c {--list [ ...]} + + Lists keys under the key \c or all keys if the root is not specified. + + Possible values are: + + \list + \li \c defaultProfile is the default \l{Profile}{profile} to use + if a profile is not specified + \li \c preferences accepts build preferences as second-level keys + \li \c profiles accepts profile names as second-level keys + + \endlist + +//! [list-root] + +//! [config-user] + + \section2 \c {--user} + + Causes read operations to display only the user-level settings, + while the system-level settings are ignored. + Write operations will target the user-level settings, which is also the default. + +//! [config-user] + +//! [config-system] + + \section2 \c {--system} + + Read and write operations will consider only the system-level settings. + +//! [config-system] + +//! [config-ui-system] + + \section2 \c {--system} + + Instructs the tool to work on the system-level settings. Otherwise, + the user-level settings are presented. + +//! [config-ui-system] + +//! [log-level] + + \section2 \c {--log-level } + + Uses the specified log level. + + Possible values of \c are: + + \list + \li \c error + \li \c warning + \li \c info (default value) + \li \c debug + \li \c trace + \endlist + +//! [log-level] + +//! [log-time] + + \section2 \c --log-time + + Logs the time that the operations involved in this command take. + + This option is implied in log levels \c debug and higher. + + This option is mutually exclusive with \c --show-progress. + +//! [log-time] + +//! [more-verbose] + + \section2 \c --more-verbose|-v + + Becomes more verbose by increasing the log level by one. This option can be + given more than once. Excessive occurrences have no effect. + + If the option \c --log-level appears anywhere on the command line in + addition to this option, its value is taken as the base for the increase. + +//! [more-verbose] + +//! [ndk-dir] + + \section2 \c {--ndk-dir } + + Specifies a \c that contains an Android NDK. + +//! [ndk-dir] + +//! [no-build] + + \section2 \c --no-build + + Does not re-build the project before installing or running it. + +//! [no-build] + +//! [no-install] + + \section2 \c --no-install + + Does not install any artifacts as part of the build process. + +//! [no-install] + +//! [products-specified] + + \section2 \c {--products|-p [,...]} + + Takes only the \l{Product}{products} specified by \c and their + dependencies into account. + +//! [products-specified] + +//! [qt-dir] + + \section2 \c {--qt-dir } + + Specifies a \c that contains a Qt version. + +//! [qt-dir] + +//! [sdk-dir] + + \section2 \c {--sdk-dir } + + Specifies a \c that contains an Android SDK. + +//! [sdk-dir] + +//! [settings-dir] + + \section2 \c {--settings-dir } + + Reads all settings (such as \l{Profile}{profile} information) from the + specified \c . If the directory does not exist, it will be + created. + + The default value is system-specific. For example: + + \list + \li Linux: \c $HOME/.config/QtProject/qbs + \li Windows: \c %APPDATA%\QtProject\qbs + \li macOS: \c $HOME/Library/Preferences/qbs + \endlist + +//! [settings-dir] + +//! [setup-run-env-config] + + \target --setup-run-env-config + \section2 \c --setup-run-env-config + + A comma-separated list of strings. They will show up in the \c config + parameter of all \l{Module::}{setupRunEnvironment} scripts. + +//! [setup-run-env-config] + + +//! [show-progress] + + \section2 \c --show-progress + + Shows how command execution is progressing. + + This option is mutually exclusive with \c --log-time. + +//! [show-progress] + +//! [no-fallback-module-provider] + + \section2 \c --no-fallback-module-provider + + If this option is set, then \QBS will not fall back to a pkg-config based + \l{Module Providers}{module provider} if a dependency is not found. + +//! [no-fallback-module-provider] + + +//! [setup-tools-system] + + \section2 \c {--system} + + If this option is given, the profile(s) created by this tool will end up + in the system-level settings and thus be available to all users. + Otherwise, they go into the user-level settings. + +//! [setup-tools-system] + +//! [type] + + \section2 \c {--type } + + Specifies the type of the toolchain. Needed if \QBS cannot determine the + compiler from the name of the executable file located in the specified + directory. + + Possible values include: + + \list + \li \c clang + \li \c gcc + \li \c mingw + \li \c msvc + \li \c iar + \li \c keil + \li \c sdcc + \li \c cosmic + \li \c dmc + \li \c watcom + \endlist + +//! [type] + +//! [unset] + + \section2 \c {--unset } + + Removes the specified \c . + +//! [unset] + +//! [wait-lock] + + \section2 \c --wait-lock + + Waits indefinitely for other processes to release the build graph lock. + + This option is typically used by \l{Generators}{generators}, which may + re-invoke multiple \QBS processes on the same project simultaneously. + +//! [wait-lock] + +//! [whitelist] + + \section2 \c {--whitelist } + + Considers only files whose names match the patterns specified by + \c . The list entries can contain wildcards and are separated by + commas. + + By default, all files are considered. + +//! [whitelist] + +*/ diff --git a/doc/reference/cli/cli-parameters.qdocinc b/doc/reference/cli/cli-parameters.qdocinc new file mode 100644 index 00000000..36bb0864 --- /dev/null +++ b/doc/reference/cli/cli-parameters.qdocinc @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + +//! [arguments] + + \section2 \c -- + + Command-line arguments to be passed to the program to be run. + +//! [arguments] + + +//! [configuration-name] + + \section2 \c config:configuration-name + + Specifies the build configuration to use. + + \QBS can build a project for one or multiple configurations at once, each + having a different set of parameters. The \c config parameter has a + special function: with each occurrence a new configuration instance begins + and all subsequent parameters until the next \c config are assigned to this + instance. Parameter assignments before the first occurrence of \c config are + applied to all build configurations. Inside products and modules, the + current active build configuration can be retrieved via + \l{qbs::configurationName}{qbs.configurationName}. + + In the following snippet, a profile \c clang is applied to all + configurations while \c cpp.optimization is different for \c debug and + \c release: + + \code + profile:clang config:debug cpp.optimization:none config:release cpp.optimization:small + \endcode + + The value of \c config determines the name of the build folder and affects + the default value of the \l{qbs::buildVariant}{qbs.buildVariant} property. + \QBS knows the \c config values \c{"debug"} and \c{"release"}, but in + general any name can be chosen. When naming configurations created for + special purposes, follow the rules for legal names generally used in + programming languages: + + \list + \li The first character must be a letter (a-z), an underscore (_), or a + dollar sign ($). + \li Subsequent characters may be letters, digits, underscores, or dollar + signs. + \endlist + +//! [configuration-name] + +//! [key] + + \section2 \c + + Typically, a \c consists of several levels separated by periods. The + first level shows a \e root value, such as \e preferences or \e profiles. + The root determines whether the second-level keys are build preferences or + profile names. The lower level keys consist of a module name, followed by a + property name. + +//! [key] + +//! [property] + + \section2 \c {property:value} + + Property values set in project files or profiles can be overridden on the + command line. The syntax is: + + \code + .: + \endcode + + For more information, see + \l{Overriding Property Values from the Command Line}. + +//! [property] +*/ diff --git a/doc/reference/cli/cli.qdoc b/doc/reference/cli/cli.qdoc new file mode 100644 index 00000000..ccc67373 --- /dev/null +++ b/doc/reference/cli/cli.qdoc @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \group cli + + \title Command-Line Interface + \brief A list of available command-line commands. + + The \c qbs command-line commands can be invoked as \c{qbs }. + + This reference summarizes the command-line commands. The authoritative + source of up-to-date information is the respective help screen, which you + get by calling \c{qbs help }. + + Some commands are described in context in the \l{Usage} section of the + manual. +*/ diff --git a/doc/reference/cli/tools/cli-config-ui.qdoc b/doc/reference/cli/tools/cli-config-ui.qdoc new file mode 100644 index 00000000..ed2287c1 --- /dev/null +++ b/doc/reference/cli/tools/cli-config-ui.qdoc @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-config-ui.html + \ingroup cli + + \title config-ui + \brief Opens a GUI application for managing \QBS settings, such as + preferences and profiles. + + \section1 Synopsis + + \code + qbs config-ui [--settings-dir ] [--system] + \endcode + + \section1 Description + + Opens the \QBS Settings application for managing \QBS settings, such as + preferences and profiles, in a hierarchical view. This makes it easier to + manage a large number of settings than using the \l{config} command from + the command line. + + \image qbs-settings-gui.png + + For more information, see \l{Configuring Profiles and Preferences}. + + \section1 Options + + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc config-ui-system + \include cli-options.qdocinc help + + \section1 Examples + + Opens \QBS Settings: + + \code + qbs config-ui + \endcode + +*/ diff --git a/doc/reference/cli/tools/cli-config.qdoc b/doc/reference/cli/tools/cli-config.qdoc new file mode 100644 index 00000000..6758dce6 --- /dev/null +++ b/doc/reference/cli/tools/cli-config.qdoc @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-config.html + \ingroup cli + + \title config + \brief Manages \QBS settings, such as preferences and profiles. + + \section1 Synopsis + + \code + qbs config [--settings-dir ] [--user|--system] [--list [ ...]] + [--unset ] [--export ] [--import ] + qbs config [--settings-dir ] [--user|--system] + qbs config [--settings-dir ] [--user|--system] + \endcode + + \section1 Description + + Manages \QBS settings, such as preferences and profiles. You can list all + keys and remove the specified key, as well as import settings from a file + or export them to a file. + + The second form of this command displays the specified \c . + + The third form sets the specified \c with the specified \c . + + There are two sets of settings: The system-level settings affect all users, + while the user-level settings are specific to the current user. + By default, the read operations consider both sources. If the same key is + present in both settings, then for list values, the system value is + appended to the user value, while for other types of values the user-level + one takes precedence. Write operations go to the user-level settings by default. + Use the \c {--user} and \c {--system} options to change this behavior. + \note It is conceivable that the default system value of the + \c {preferences.qbsSearchPaths} setting could pull in unwanted \QBS modules, + in particular when doing cross-builds. In such a case, you can set + \c {preferences.ignoreSystemSearchPaths} to exclude the search paths coming + from the system settings. You'll typically do this for a specific profile: + \code + $ qbs config profiles.myprofile.preferences.ignoreSystemSearchPaths true + \endcode + + You can use the \l{config-ui} command to open the Qbs Settings tool for + managing settings in a hierarchical view. + + For more information, see \l{Configuring Profiles and Preferences}, \l{Managing Qt Versions}, + \l{Modules}, \l {List of Modules}, and \l{Custom Modules and Items}. + + \section1 Options + + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc list-root + \include cli-options.qdocinc unset + \include cli-options.qdocinc export + \include cli-options.qdocinc import + \include cli-options.qdocinc config-user + \include cli-options.qdocinc config-system + \include cli-options.qdocinc help + + \section1 Parameters + + \include cli-parameters.qdocinc key + + \section1 Examples + + Lists the existing profiles: + + \code + qbs config --list profiles + \endcode + + Shows the default profile: + + \code + qbs config defaultProfile + \endcode + + \note If no output is shown, the default profile used is the built-in + profile \c none, which sets no properties. + + Sets the profile called \c gcc as the base profile of the Qt profile called + \c myqt: + + \code + qbs config profiles.myqt.baseProfile gcc + \endcode + + Adds the location of a custom module to your preferences, to make the module + accessible in several projects: + + \code + qbs config preferences.qbsSearchPaths /usr/local/share/custom-qbs-extensions + \endcode +*/ diff --git a/doc/reference/cli/tools/cli-create-project.qdoc b/doc/reference/cli/tools/cli-create-project.qdoc new file mode 100644 index 00000000..c78d8fb8 --- /dev/null +++ b/doc/reference/cli/tools/cli-create-project.qdoc @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-create-project.html + \ingroup cli + + \title create-project + \brief Creates a \QBS project from an existing set of source files. + + \section1 Synopsis + + \code + qbs create-project [--blacklist ] [--whitelist ] + [--flat] + \endcode + + \section1 Description + + Automatically generates \QBS project files from an arbitrary directory + structure. You can filter the files to add to the project by blacklisting + or whitelisting them. The command creates nested project files, unless you + use the \c --flat option. + + This is a useful starting point when migrating from other build tools, such + as qmake or CMake. + + \note Run this command from the project directory. + + After generating the initial .qbs files, add the missing configuration + variables and functions to them. + + \section1 Options + + \include cli-options.qdocinc blacklist + \include cli-options.qdocinc whitelist + \include cli-options.qdocinc flat + \include cli-options.qdocinc help + + \section1 Examples + + Creates \c .qbs files in the project directory when run from there: + + \code + qbs create-project + \endcode +*/ diff --git a/doc/reference/cli/tools/cli-setup-android.qdoc b/doc/reference/cli/tools/cli-setup-android.qdoc new file mode 100644 index 00000000..357d4270 --- /dev/null +++ b/doc/reference/cli/tools/cli-setup-android.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-setup-android.html + \ingroup cli + + \title setup-android + \brief Creates \QBS profiles for Android SDK and NDK installations. + + \section1 Synopsis + + \code + qbs setup-android [--settings-dir ] [--ndk-dir ] + [--sdk-dir ] [--qt-dir ] + + \endcode + + \section1 Description + + Creates \QBS profiles for Android SDK and NDK installations. + + If a Qt path is given, these additional profiles will be suitable for + building Qt binaries for the respective architecture, if the Qt + installation has support for it. + + \section1 Options + + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc ndk-dir + \include cli-options.qdocinc sdk-dir + \include cli-options.qdocinc qt-dir + \include cli-options.qdocinc help + + \section1 Examples + + Creates a profile with the name \c oreo that specifies the target platforms' + \l{qbs::}{architectures} and operating systems, as well as the + toolchains available: + + \code + qbs setup-android oreo + \endcode +*/ diff --git a/doc/reference/cli/tools/cli-setup-qt.qdoc b/doc/reference/cli/tools/cli-setup-qt.qdoc new file mode 100644 index 00000000..c5034814 --- /dev/null +++ b/doc/reference/cli/tools/cli-setup-qt.qdoc @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-setup-qt.html + \ingroup cli + + \title setup-qt + \brief Creates \QBS profiles for Qt installations. + + \section1 Synopsis + + \code + qbs setup-qt [--settings-dir ] [--system] --detect + qbs setup-qt [--settings-dir ] [--system] + \endcode + + \section1 Description + + Creates \QBS profiles for Qt installations. + + The first form tries to auto-detect all known Qt versions, looking them up + via the PATH variable. + + The second form creates a profile with the name \c {} for the + Qt version located at \c {}. + + For more information, see \l{Managing Qt Versions}. + + \section1 Options + + \include cli-options.qdocinc detect-qt-versions + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc setup-tools-system + \include cli-options.qdocinc help + + \section1 Examples + + Looks up Qt versions in the PATH and creates profiles for them: + + \code + qbs setup-qt --detect + \endcode + + Creates a profile called \c myqt for the Qt version located in + \c /usr/bin/qmake: + + \code + qbs setup-qt /usr/bin/qmake myqt + \endcode +*/ diff --git a/doc/reference/cli/tools/cli-setup-toolchains.qdoc b/doc/reference/cli/tools/cli-setup-toolchains.qdoc new file mode 100644 index 00000000..97f9c023 --- /dev/null +++ b/doc/reference/cli/tools/cli-setup-toolchains.qdoc @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page cli-setup-toolchains.html + \ingroup cli + + \title setup-toolchains + \brief Creates \QBS profiles for toolchains, such as GCC or MSVC. + + \section1 Synopsis + + \code + qbs setup-toolchains [--settings-dir ] [--system] --detect + qbs setup-toolchains [--settings-dir ] [--system] [--type ] + + \endcode + + \section1 Description + + The first form tries to auto-detect all known toolchains, looking them up + via the PATH variable. + + The second form creates a profile with the name \c {} for the + toolchain located at \c {}. It will attempt to + determine the toolchain type automatically based on the file name or the + compiler executable. If that fails, you need to provide the compiler type as + a value of the \c --type option. + + For more information, see \l{Configuring Profiles and Preferences}. + + \section1 Options + + \include cli-options.qdocinc settings-dir + \include cli-options.qdocinc setup-tools-system + \include cli-options.qdocinc detect-toolchains + \include cli-options.qdocinc type + \include cli-options.qdocinc help + + \section1 Examples + + Looks up toolchains via the PATH variable and creates profiles for them: + + \code + qbs setup-toolchains --detect + \endcode + + Creates a profile called \c mingw for the toolchain located in + \c C:\mingw530_32\bin on Windows: + + \code + qbs setup-toolchains C:\mingw530_32\bin\g++.exe mingw + \endcode + + Creates a profile called \c g++-mingw-w64 for the toolchain located in + \c /usr/bin/x86_64-w64-mingw32-g++ g++-mingw-w64 on Ubuntu: + + \code + qbs setup-toolchains /usr/bin/x86_64-w64-mingw32-g++ g++-mingw-w64 + \endcode +*/ diff --git a/doc/reference/commands.qdoc b/doc/reference/commands.qdoc new file mode 100644 index 00000000..3f542e1d --- /dev/null +++ b/doc/reference/commands.qdoc @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// TODO: "\c" markup is used for all properties in table due to QTBUG-35505. + +/*! + \page commands.html + + \title Command and JavaScriptCommand + \brief Types of commands to be used in rules + + A \e command is what \QBS executes at build time. It is represented in the language by an object + of type \c Command, which runs a process, or \c JavaScriptCommand, which executes arbitrary + JavaScript code. A command is always created in the prepare script of a \c Rule. + + \section1 Command + + A \c Command represents a process that will be invoked at build time. Its constructor + arguments are the binary to run and a list of command-line arguments. For instance: + \code + var insaneCommand = new Command("rm", ["-r", "/"]); + \endcode + The \l{Rule} item documentation shows a \c Command in context. + + \section1 JavaScriptCommand + + A \c JavaScriptCommand represents a chunk of JavaScript code that is run at build time. + For instance: + \code + var cmd = new JavaScriptCommand(); + cmd.apology = "Sorry."; + cmd.sourceCode = function() { + console.info("I'm a rather pointless command."); + console.info(apology); + }; + \endcode + + Within the source code, the special identifiers \c project and \c product + (giving access to project and product properties, respectively) as well as \c inputs and + \c outputs are available. As the example shows, arbitrary properties can be set on the command + object and then used within the source code. This technique is typically used to forward values + from the prepare script to the command. + The \l{Rule} item documentation shows a \c JavaScriptCommand in context. + + \section1 Properties + + \section2 Common Properties + The following properties are available in both \c Command and \c JavaScriptCommand. + + \table + \header + \li Property + \li Type + \li Default + \li Description + \row + \li \c description + \li string + \li empty + \li A message that is displayed when the command is executed. + \row + \li \c extendedDescription + \li string + \li empty + \li A detailed description that is displayed when the command is executed. + \row + \li \c highlight + \li string + \li empty + \li A tag that can be used to influence how the \c description is displayed. In principle, + the values are arbitrary. The \QBS command-line tool understands the following values and + maps them to different colors if the output device is a terminal: + \list + \li "compiler" indicates that the command processes source code + \li "linker" indicates that the command links objects + \li "codegen" indicates that the command generates source code + \li "filegen" indicates that the command creates arbitrary files + \endlist + All other values are mapped to the default color. + \row + \li \c jobPool + \li string + \li empty + \li Determines which job pool the command will use. An empty + string, which is the default, stands for the global job pool. + See \l{JobLimit}{here} and \l{job-pool-howto}{here} for more information on job pools. + \row + \li \c silent + \li bool + \li false + \li A flag that controls whether the \c description is printed. Set it to \c true for commands that + users need not know about. \note If this property is \c false, then \c description must + not be empty. + \row + \li \c timeout + \li int + \li -1 + \li Time limit for the command execution in seconds. If the command does not finish within + the timeout, it is cancelled. In case of a \c Command, the process is requested to + terminate. If it does not terminate within three seconds, it is killed. A value below + or equal to 0 means no timeout. \br + This property was introduced in Qbs 1.15. + \endtable + + + \section2 Command Properties + + \table + \header + \li Property + \li Type + \li Default + \li Description + \row + \li \c arguments + \li stringList + \li empty + \li The list of arguments to invoke the command with. Explicitly setting this property + overrides an argument list provided when instantiating the object. + \row + \li \c environment + \li stringList + \li empty + \li A list of environment variables that are added to the common build environment. + They are provided as a list of strings in the form "varName=value". + \row + \li \c maxExitCode + \li int + \li 0 + \li The maximum exit code from the process to interpret as success. Setting this should + rarely be necessary, as all well-behaved applications use values other than zero + to indicate failure. + \row + \li \c program + \li string + \li undefined + \li The binary to invoke. Explicitly setting this property overrides a path provided when + instantiating the object. + \row + \li \c relevantEnvironmentVariables + \li stringList + \li undefined + \li Names of environment variables that the invoked binary considers. + If one of these variables changes in the build environment, the command will be + re-run even if the input files are still up to date. + \row + \li \c responseFileThreshold + \li int + \li 32000 on Windows, -1 elsewhere + \li If this value is greater than zero and less than the length of the full command line, + and if \c responseFileUsagePrefix is not empty, the contents of the command line are + moved to a temporary file, whose path becomes the entire contents of the + argument list. The program is then supposed to read the full argument list from that + file. This mechanism is mainly useful to work around Windows limitations regarding + the maximum length of the command line and will only work with programs that explicitly + support it. + \row + \li \c responseFileArgumentIndex + \li int + \li 0 + \li Index of the first argument to include in the response file. For example this may be + used in conjunction with a compiler wrapper where the first argument (the path to the + compiler) must be included on the raw command line. + \row + \li \c responseFileUsagePrefix + \li string + \li empty + \li The prefix that informs \c program that the rest of the argument + is a path to a file containing the actual command line. + \row + \li \c stderrFilterFunction + \li function + \li undefined + \li A function that takes as input the command's actual standard error output and returns a string + that is presented to the user as the command's standard error output. + If it is not set, the output is shown unfiltered. + \row + \li \c stdoutFilterFunction + \li function + \li undefined + \li A function that takes as input the command's actual standard output and returns a string + that is presented to the user as the command's standard output. + If it is not set, the output is shown unfiltered. + \row + \li \c workingDirectory + \li string + \li empty + \li The program's working directory. + \row + \li \c stdoutFilePath + \li string + \li undefined + \li Redirects the filtered standard output content to \c stdoutFilePath. If \c stdoutFilePath is undefined, + the filtered standard output is forwarded to \QBS, possibly to be printed to the console. + \row + \li \c stderrFilePath + \li string + \li undefined + \li Redirects the filtered standard error output content to \c stderrFilePath. If \c stderrFilePath is undefined, + the filtered standard error output is forwarded to \QBS, possibly to be printed to the console. + \endtable + + \section2 JavaScriptCommand Properties + + \table + \header + \li Property + \li Type + \li Default + \li Description + \row + \li \c sourceCode + \li function + \li undefined + \li The JavaScript function to execute. + \endtable +*/ diff --git a/doc/reference/items/convenience/appleapplicationdiskimage.qdoc b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc new file mode 100644 index 00000000..8db7bc4d --- /dev/null +++ b/doc/reference/items/convenience/appleapplicationdiskimage.qdoc @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \nextpage AppleDiskImage + \qmltype AppleApplicationDiskImage + \since Qbs 1.9 + \inherits AppleDiskImage + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.AppleApplicationDiskImage + + \brief Apple application drag 'n' drop disk image installer. + + An AppleApplicationDiskImage item is a \l{Product}{product} of the + \l{Product::}{type} \c{"dmg.dmg"} that has a dependency on the + \l{dmg} module. In addition, it has rules and properties + specific to building drag 'n' drop disk image installers with an application + bundle and symbolic link to the \c /Applications directory. + + Any artifacts of product dependencies that are tagged \c{"installable"} will + be copied into the disk image, provided their file paths are relative to the + path specified by the \l{sourceBase} property (that is, are located in that + directory). Any artifacts tagged \c{"installable"} that are not relative to + \l{sourceBase} will be ignored. + + Here is what the project file could look like for a simple DMG installer: + \code + AppleApplicationDiskImage { + Depends { name: "myapp" } + name: "My App" + dmg.volumeName: name + dmg.iconSize: 128 + dmg.windowWidth: 640 + dmg.windowHeight: 280 + dmg.iconPositions: [ + {"path": "Applications", "x": 128, "y": 128}, + {"path": "My App.app", "x": 256, "y": 128} + ] + files: ["background.tiff", "volume-icon.icns"] + Group { + files: ["*.lproj/**"] // licenses + fileTags: ["dmg.license.input"] + } + } + \endcode + + For plain disk images whose contents are not a single application bundle, consider the base + \l{AppleDiskImage} item instead. +*/ + +/*! + \qmlproperty string AppleApplicationDiskImage::sourceBase + + The base directory from which artifacts installed into the disk image will be copied. + This directory is always considered to be relative to \l{qbs::installRoot} + {qbs.installRoot}. + For example, if the application Example.app exists at + \c{qbs.installRoot/Applications/Example.app}, and the value of this property + is \c{"/Applications"}, the application will be located at\c{/Example.app} + relative to the disk image root. Therefore, its full path when the disk + image is mounted would be something like \c{/Volumes/Example-1.0/Example.app}. + + \defaultvalue \c{"/Applications"} +*/ + +/*! + \qmlproperty stringList AppleApplicationDiskImage::symlinks + + List of symlinks to create in the disk image. This is specified as a list of strings, + each string containing two file paths separated by a colon. The first path is the + symlink target, and the second path is the name of the symlink relative to the root of + the disk image. + + \defaultvalue \c{["/Applications:Applications"]} +*/ diff --git a/doc/reference/items/convenience/applediskimage.qdoc b/doc/reference/items/convenience/applediskimage.qdoc new file mode 100644 index 00000000..16fec266 --- /dev/null +++ b/doc/reference/items/convenience/applediskimage.qdoc @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage AppleApplicationDiskImage + \nextpage Application + \qmltype AppleDiskImage + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.AppleDiskImage + + \brief Apple disk image. + + An AppleDiskImage item is a is a \l{Product}{product} of the \l{Product::} + {type} \c{"dmg.dmg"} that has a dependency on the \l{dmg} module. + + For single-application drag 'n' drop disk image installers, you will + probably want to use the \l{AppleApplicationDiskImage} item instead. +*/ diff --git a/doc/reference/items/convenience/application.qdoc b/doc/reference/items/convenience/application.qdoc new file mode 100644 index 00000000..15b05515 --- /dev/null +++ b/doc/reference/items/convenience/application.qdoc @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage AppleDiskImage + \nextpage ApplicationExtension + \qmltype Application + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.Application + + \brief Product of the type application. + + An Application item is a \l{Product} representing an application. + + The target artifact of this type of product is usually an executable binary + tagged \c "application". + However, on Android, unless you set \l{Product::}{consoleApplication} to \c true, + the application target will be an APK or an AAB package tagged \c "android.package" + according to the \l{Android.sdk}{packageType} property. A dependency to the \l{Android.sdk} + module is automatically added to the product. +*/ + +/*! + \qmlproperty bool Application::install + + If \c{true}, the executable that is produced when building the application will be installed + to \l{Application::installDir}{installDir}. + + \defaultvalue \c false + \since Qbs 1.13 +*/ + +/*! + \qmlproperty string Application::installDir + + Where to install the executable that is produced when building the application, if + \l{Application::install}{install} is enabled. + + The value is appended to \l{qbs::installPrefix}{qbs.installPrefix} + when constructing the actual installation directory. + + \defaultvalue \c Applications if the app is a \l{bundle::isBundle}{bundle}, \c bin otherwise. + \since Qbs 1.13 +*/ + +/*! + \qmlproperty bool Application::installDebugInformation + + If \c{true}, the debug information will be installed to + \l{Application::debugInformationInstallDir}{debugInformationInstallDir}. + + \defaultvalue \c false + \since Qbs 1.16 + \sa{How do I separate and install debugging symbols?} +*/ + +/*! + \qmlproperty string Application::debugInformationInstallDir + + Where to install the debug information if \l installDebugInformation is enabled. + + The value is appended to \l{qbs::installPrefix}{qbs.installPrefix} + when constructing the actual installation directory. + + \defaultvalue \l installDir. + \since Qbs 1.16 + + \sa{How do I separate and install debugging symbols?} +*/ diff --git a/doc/reference/items/convenience/applicationextension.qdoc b/doc/reference/items/convenience/applicationextension.qdoc new file mode 100644 index 00000000..9ff0101f --- /dev/null +++ b/doc/reference/items/convenience/applicationextension.qdoc @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Application + \nextpage AutotestRunner + \qmltype ApplicationExtension + \inherits XPCService + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.ApplicationExtension + + \brief Application Extension for iOS, macOS, tvOS, or watchOS. + + An ApplicationExtension item is a \l{Product} based on the \l{XPCService} + item that sets some properties required for iOS, macOS, tvOS, or watchOS + Application Extensions. +*/ diff --git a/doc/reference/items/convenience/autotestrunner.qdoc b/doc/reference/items/convenience/autotestrunner.qdoc new file mode 100644 index 00000000..c9fb217e --- /dev/null +++ b/doc/reference/items/convenience/autotestrunner.qdoc @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage ApplicationExtension + \nextpage CppApplication + \qmltype AutotestRunner + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.AutotestRunner + + \brief Product that runs all autotests in the project. + + An AutotestRunner has a dependency on all \l{Product}{products} with the + \l{Product::}{type} \c "autotest". Building the AutotestRunner product + will then run the respective executables. The \l{Product::}{builtByDefault} + property is set to \c false by default, so running the autotests + has to be explicitly requested. The default name of the product is + \c "autotest-runner". + + To use this feature: + + \list 1 + \li Attach the \c "autotest" type to your autotests: + \code + CppApplication { + name: "tst_mytest" + type: ["application", "autotest"] + // ... + } + \endcode + \li Instantiate exactly one AutotestRunner in your project, typically at + the top level: + \code + Project { + // ... + AutotestRunner { } + // ... + } + \endcode + \li Trigger the autotest execution by building the product: + \code + qbs build -p autotest-runner + \endcode + \endlist + + + \section2 Setting Properties for individual Tests + \target autotestrunner-autotest-module + + To control the behavior of individual tests, some properties of the \c AutotestRunner + can be overridden by depending on the \l autotest module and setting its properties: + + \code + CppApplication { + name: "tst_mytest" + type: ["application", "autotest"] + + Depends { name: "autotest" } + + autotest.timeout: 60 + + // ... + } + \endcode + + + \section2 Relevant Job Pools + \target autotestrunner-job-pools + + \table + \header + \li Pool + \li Since + \li Description + \row + \li \c{"autotest-runner"} + \li 1.15 + \li The job pool used to run the tests. + \endtable + +*/ + +/*! + \qmlproperty stringList AutotestRunner::arguments + + The list of arguments to invoke the autotest with. + A test can override this by setting the \l{autotest::arguments}{arguments} property + of the \l autotest module. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty stringList AutotestRunner::auxiliaryInputs + + This property can contain arbitrary file tags. The AutotestRunner will get dependencies + on all products whose type matches at least one of these tags, and invocation of the + test executables will happen only after all of the respective artifacts have been built. + Set this property if your test executables have run-time dependencies on other products. + + \nodefaultvalue + \since Qbs 1.12 +*/ + +/*! + \qmlproperty stringList AutotestRunner::environment + + A list of environment variables that are added to the run environment. + They are provided as a list of strings in the form \c "varName=value". + + \defaultvalue DYLD_LIBRARY_PATH, DYLD_FRAMEWORK_PATH, and DYLD_ROOT_PATH + are set on macOS, or an empty list for other platforms. +*/ + +/*! + \qmlproperty bool AutotestRunner::limitToSubProject + + By default, only those autotests are considered that are in the same sub-project that + AutotestRunner was instantiated in. If you want to run all autotests regardless + of their location in the project hierarchy, set this property to \c false. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string AutotestRunner::workingDir + + If this property is set, it will be the working directory for all invoked test executables. + Otherwise, the working directory will the the parent directory of the respective executable. + A test can override this by setting the \l{autotest::workingDir}{workingDir} property + of the \l autotest module. + + \nodefaultvalue + \since Qbs 1.12 +*/ + +/*! + \qmlproperty stringList AutotestRunner::wrapper + + Wrapper binary and its arguments for wrapping autotest calls. + This is useful for tools like Valgrind and alike. + + \defaultvalue empty +*/ + +/*! + \qmlproperty int AutotestRunner::timeout + + Time limit for the execution of the individual tests. If a test does not finish within + the time limit, the test is cancelled and considered failed. A value below or equal to 0 + means no timeout. + A test can override this by setting the \l{autotest::timeout}{timeout} property + of the \l autotest module. + + \defaultvalue -1 + \since Qbs 1.15 +*/ diff --git a/doc/reference/items/convenience/cppapplication.qdoc b/doc/reference/items/convenience/cppapplication.qdoc new file mode 100644 index 00000000..3518ba1e --- /dev/null +++ b/doc/reference/items/convenience/cppapplication.qdoc @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage AutotestRunner + \nextpage DynamicLibrary + \qmltype CppApplication + \inherits Application + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.CppApplication + + \brief C++ application. + + A CppApplication is an \l{Application}{application} that has a dependency on the + \l{cpp} module. It is entirely equivalent to the following: + + \code + Application { + Depends { name: "cpp" } + } + \endcode +*/ diff --git a/doc/reference/items/convenience/dynamiclibrary.qdoc b/doc/reference/items/convenience/dynamiclibrary.qdoc new file mode 100644 index 00000000..861d0509 --- /dev/null +++ b/doc/reference/items/convenience/dynamiclibrary.qdoc @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage CppApplication + \nextpage InnoSetup + \qmltype DynamicLibrary + \inherits Library + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.DynamicLibrary + + + \brief Dynamic library. + + A DynamicLibrary item is a \l{Library}{library} of the \l{Product::}{type} + \c "dynamiclibrary". + + For Android targets, the following applies: + \list + \li The \l{Product::type}{Product.type} property value contains + \c "android.nativelibrary" in addition to \c "dynamiclibrary". + \li There is a dependency on the \l{cpp} and \l{Android.ndk} modules. + \endlist +*/ diff --git a/doc/reference/items/convenience/innosetup.qdoc b/doc/reference/items/convenience/innosetup.qdoc new file mode 100644 index 00000000..0f66243e --- /dev/null +++ b/doc/reference/items/convenience/innosetup.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage DynamicLibrary + \nextpage InstallPackage + \qmltype InnoSetup + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.InnoSetup + + \brief Inno Setup installer executable. + + A InnoSetup item is a \l{Product}{product} of the \l{Product::}{type} + \c{"innosetup.exe"} that has a dependency on the \l{innosetup} module. +*/ diff --git a/doc/reference/items/convenience/installpackage.qdoc b/doc/reference/items/convenience/installpackage.qdoc new file mode 100644 index 00000000..7c5e8ec9 --- /dev/null +++ b/doc/reference/items/convenience/installpackage.qdoc @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage InnoSetup + \nextpage JavaClassCollection + \qmltype InstallPackage + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.InstallPackage + + \brief Archive of an installed project. + + An InstallPackage item is a \l{Product}{product} of the \l{Product::}{type} + \c{archiver.archive} that has a \l{Depends}{dependency} on the \l{archiver} + module. It is used to produce an archive from a set of installable files. + + Consider the following example project: + + \code + Project { + CppApplication { + name: "myapp" + Depends { name: "mylib" } + files: ["main.cpp"] + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: "bin" + } + } + DynamicLibrary { + name: "mylib" + files: ["mylib.cpp"] + Group { + name: "public headers" + files: ["mylib.h"] + qbs.install: true + qbs.installDir: "include" + } + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: "lib" + } + } + + InstallPackage { + archiver.type: "tar" + name: "tar-package" + Depends { name: "myapp" } + Depends { name: "mylib" } + } + } + \endcode + + Building the product \c "tar-package" on a Unix system will result in a tar + file with these contents: + + \code + include/mylib.h + lib/libmylib.so + bin/myapp + \endcode +*/ diff --git a/doc/reference/items/convenience/javaclasscollection.qdoc b/doc/reference/items/convenience/javaclasscollection.qdoc new file mode 100644 index 00000000..ae060135 --- /dev/null +++ b/doc/reference/items/convenience/javaclasscollection.qdoc @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage InstallPackage + \nextpage JavaJarFile + \qmltype JavaClassCollection + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.JavaClassCollection + + \brief Collection of Java class files not bundled in a jar file. + + A JavaClassCollection item is a \l{Product}{product} of the \l{Product::} + {type} \c{"java.class"} that has a dependency on the \l{java} module. + If the files should end up in a jar file, you should use \l{JavaJarFile} + instead. +*/ diff --git a/doc/reference/items/convenience/javajarfile.qdoc b/doc/reference/items/convenience/javajarfile.qdoc new file mode 100644 index 00000000..97c775f1 --- /dev/null +++ b/doc/reference/items/convenience/javajarfile.qdoc @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage JavaClassCollection + \nextpage Library + \qmltype JavaJarFile + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.JavaJarFile + + \brief Collection of Java class files bundled in a jar file. + + A JavaJarFile item is a \l{Product}{product} of the \l{Product::}{type} + \c{java.jar}. It is used to produce a jar archive from a set of Java + sources. +*/ + +/*! + \qmlproperty string JavaJarFile::entryPoint + + The entry point for an executable jar file. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/convenience/library.qdoc b/doc/reference/items/convenience/library.qdoc new file mode 100644 index 00000000..409af3f1 --- /dev/null +++ b/doc/reference/items/convenience/library.qdoc @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \previouspage JavaJarFile + \nextpage LoadableModule + \qmltype Library + \since Qbs 1.4 + \inherits Product + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.NativeBinary + + \brief Generic library. + + A Library item is a base item for native libraries and can have \l{Product::}{type} set to + one of the following values: \c "dynamiclibrary", \c "staticlibrary", \c "loadablemodule". + + The default \l{Product::}{type} value is \c "dynamiclibrary" except for iOS prior to + version 8, in which case the default value is \c "staticlibrary". + + This item can automatically install the library target (and library symlinks on Unix) and + separated debug information. + + For Android targets, the following applies: + \list + \li The \l{Product::type}{Product.type} property value contains + \c "android.nativelibrary" in addition to \c "dynamiclibrary". + \li There is a dependency on the \l{cpp} and \l{Android.ndk} modules. + \endlist +*/ + +/*! + \qmlproperty bool Library::install + + If \c{true}, the library will be installed to \l{Library::installDir}{installDir}. + + \defaultvalue \c false + \since Qbs 1.13 +*/ + +/*! + \qmlproperty string Library::installDir + + Where to install the library, if \l{Library::install}{install} is enabled. On Unix, + the symbolic links are also installed to this location. + + The value is appended to \l{qbs::installPrefix}{qbs.installPrefix} + when constructing the actual installation directory. + + \defaultvalue \c Library/Frameworks if the library is a \l{bundle::isBundle}{bundle}, + otherwise \c bin for Windows and \c lib for Unix-like targets. + \since Qbs 1.13 +*/ + +/*! + \qmlproperty bool Library::installDebugInformation + + If \c{true}, the debug information will be installed to + \l{Library::debugInformationInstallDir}{debugInformationInstallDir}. + + \defaultvalue \c false + \since Qbs 1.16 + \sa{How do I separate and install debugging symbols?} +*/ + +/*! + \qmlproperty string Library::debugInformationInstallDir + + Where to install the debug information if \l installDebugInformation is enabled. + + The value is appended to \l{qbs::installPrefix}{qbs.installPrefix} + when constructing the actual installation directory. + + \defaultvalue \l installDir. + \since Qbs 1.16 + + \sa{How do I separate and install debugging symbols?} +*/ + +/*! + \qmlproperty bool Library::installImportLib + + If \c{true}, the import library will be installed to \l importLibInstallDir. + This property is only relevant for Windows targets. + Enable it if you want to create a development package. + + \defaultvalue \c false + \since Qbs 1.13 +*/ + +/*! + \qmlproperty string Library::importLibInstallDir + + Where to install the import library, if \l installImportLib is enabled. + + The value is appended to \l{qbs::installPrefix}{qbs.installPrefix} + when constructing the actual installation directory. + + This property is only relevant for Windows targets. + + \defaultvalue \c lib + \since Qbs 1.13 +*/ + diff --git a/doc/reference/items/convenience/loadablemodule.qdoc b/doc/reference/items/convenience/loadablemodule.qdoc new file mode 100644 index 00000000..2921051f --- /dev/null +++ b/doc/reference/items/convenience/loadablemodule.qdoc @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Library + \nextpage QtApplication + \qmltype LoadableModule + \inherits Library + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.LoadableModule + + \brief Loadable module. + + A LoadableModule item is a \l{Product}{product} of the \l{Product::}{type} + \c{"loadablemodule"}. It exists for the convenience of project file authors. +*/ diff --git a/doc/reference/items/convenience/qtapplication.qdoc b/doc/reference/items/convenience/qtapplication.qdoc new file mode 100644 index 00000000..0cef3080 --- /dev/null +++ b/doc/reference/items/convenience/qtapplication.qdoc @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage LoadableModule + \nextpage QtGuiApplication + \qmltype QtApplication + \inherits CppApplication + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.QtApplication + + \brief Application with a dependency on the Qt Core module. + + A QtApplication is a \l{CppApplication}{C++ application} that has a + \l{Depends}{dependency} on the \l{Qt.core} module. It is entirely + equivalent to the following: + + \code + CppApplication { + Depends { name: "Qt.core" } + } + \endcode + +*/ diff --git a/doc/reference/items/convenience/qtguiapplication.qdoc b/doc/reference/items/convenience/qtguiapplication.qdoc new file mode 100644 index 00000000..62fb5cee --- /dev/null +++ b/doc/reference/items/convenience/qtguiapplication.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage QtApplication + \nextpage StaticLibrary + \qmltype QtGuiApplication + \inherits QtApplication + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.QtGuiApplication + + \brief Application with a dependency on the Qt GUI module. + + A QtGuiApplication is an application that extends the \l{QtApplication} item + by loading the \l{Qt.gui} module. +*/ diff --git a/doc/reference/items/convenience/staticlibrary.qdoc b/doc/reference/items/convenience/staticlibrary.qdoc new file mode 100644 index 00000000..c2ff1e63 --- /dev/null +++ b/doc/reference/items/convenience/staticlibrary.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage QtGuiApplication + \nextpage XPCService + \qmltype StaticLibrary + \inherits Library + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.StaticLibrary + + \brief Static library. + + A StaticLibrary item is a \l{Library}{library} of the \l{Product::}{type} + \c "staticlibrary". +*/ diff --git a/doc/reference/items/convenience/xpcservice.qdoc b/doc/reference/items/convenience/xpcservice.qdoc new file mode 100644 index 00000000..682d161b --- /dev/null +++ b/doc/reference/items/convenience/xpcservice.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage StaticLibrary + \qmltype XPCService + \inherits Application + \inqmlmodule QbsConvenienceItems + \ingroup list-of-items + \keyword QML.XPCService + + \brief XPC service for macOS, iOS, tvOS, or watchOS. + + An XPCService item is a convenience item based on \l Application that + sets some properties required for macOS, iOS, tvOS, or watchOS XPC services. +*/ diff --git a/doc/reference/items/language/artifact.qdoc b/doc/reference/items/language/artifact.qdoc new file mode 100644 index 00000000..6a6d80cd --- /dev/null +++ b/doc/reference/items/language/artifact.qdoc @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \nextpage Depends + \ingroup list-of-language-items + \qmltype Artifact + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Artifact + + \brief Describes a file produced by a Rule. + + An Artifact represents a single file produced by a \l{Rule}. + + For example, if a rule produces three files, it needs to contain three + Artifact items. + + In addition to Artifact properties, you can set module properties within an + Artifact item, as follows: + + \code + Artifact { + filePath: "somefile.cpp" + fileTags: ["cpp"] + cpp.cxxLanguageVersion: "c++11" + // ... + } + \endcode + + \note The code on the right-hand side of Artifact properties has access to + the set of input artifacts. That is, it can refer to the \c inputs map and, + if the rule is not a multiplex rule, the \c input variable. +*/ + +/*! + \qmlproperty bool Artifact::alwaysUpdated + + Setting this property to \c false means the file is not necessarily always + written to by any command run by the rule. + If all artifacts of a rule have this property set to \c false, the commands + of the rule are only executed if all of them are out of date compared to the inputs. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Artifact::filePath + + The file path of the target artifact. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Artifact::fileTags + + A list of tags to attach to the target file. These can then be matched by a + \l{Rule}. + + \defaultvalue An empty list +*/ diff --git a/doc/reference/items/language/depends.qdoc b/doc/reference/items/language/depends.qdoc new file mode 100644 index 00000000..0adba147 --- /dev/null +++ b/doc/reference/items/language/depends.qdoc @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Artifact + \nextpage Export + \qmltype Depends + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Depends + + \brief Represents dependencies between products and modules. + + A Depends item can appear inside a \l{Product} or \l{Module} item. + + For example, the following product will load the \l{cpp} module. In + addition, it will try to load modules that may or may not exist, and + pass this information on to the compiler. + + \code + Product { + Depends { name: "cpp" } + Depends { + name: "optional_module" + versionAtLeast: "2.0" + required: false + } + + Properties { + condition: optional_module.present + cpp.defines: "HAS_OPTIONAL_MODULE" + } + + // ... + } + \endcode + + + \section1 Dependency Parameters + + Sometimes it is desirable to have certain dependencies handled differently + than others. For example, one might want to depend on a dynamic library + without linking it. + + This can be done by setting the \l{dependency-parameters-cpp}{cpp.link} + dependency parameter to \c{true} in the dynamic library dependency: + + \code + Product { + Depends { name: "cpp" } + Depends { name: "some_dynamic_lib"; cpp.link: false } + + // ... + } + \endcode + + Dependency parameters are a special type of property that can only be set + within Depends and \l [QML] {Parameters} items. Dependency parameters are + declared in the modules they belong to. + + In the example above, the \l{cpp} module declares the parameter \c{link}. + The Depends item for \c{some_dynamic_lib} sets \c{cpp.link} to + \c{false}, which tells the linker rule to ignore this particular dependency. +*/ + +/*! + \qmlproperty bool Depends::condition + + Determines whether the dependency will actually be applied. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Depends::versionAtLeast + + The minimum value that the dependency's \c version property needs to have. + If the actual version is lower than that, loading the dependency will fail. + The value consists of integers separated by dots. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Depends::versionBelow + + A value that the dependency's \c version property must be lower than. If the + actual version is equal to or higher than that, loading the dependency will + fail. The value consists of integers separated by dots. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Depends::productTypes + + A list of product types. Any enabled product in the project that has a + matching type will become a dependency of the product containing the Depends + item. + + This property is mutually exclusive with the \l name and \l submodules + properties. + + The \l required and \l profiles properties are ignored if this property is + set. + + Product types attached via Module::additionalProductTypes are not considered. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Depends::required + + Setting this property to \c false creates a \e{soft dependency}, meaning + that it is not considered an error if the given module cannot be found. + In such a case, an instance of the respective module will be created, but + only the \l{Module::present}{Module.present} property will be available for + querying, and it will be set to \c false. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Depends::name + + The name of the dependent product or module. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Depends::profiles + + A list of profiles. + + If the dependency is on a product and that product is going to be built for + more than one profile, you can specify here which instance of the product + the dependency is on. + + See the \l{qbs::profiles}{qbs.profiles} property for more information. + An empty list means a dependency on all instances of the product with the given name, + regardless of their profile. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Depends::limitToSubProject + + If \l productTypes is set and this property is \c true, only products that + are in the same sub-project as the product containing the Depends item are + considered. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty stringList Depends::submodules + + A list of submodules of the module to depend on, if applicable. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Depends::enableFallback + + Whether to fall back to a pkg-config based \l{Module Providers}{module provider} + if the dependency is not found. + + \defaultvalue \c true +*/ diff --git a/doc/reference/items/language/export.qdoc b/doc/reference/items/language/export.qdoc new file mode 100644 index 00000000..96abde2e --- /dev/null +++ b/doc/reference/items/language/export.qdoc @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Depends + \nextpage FileTagger + \qmltype Export + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Export + + \brief Exports dependencies and properties to other products. + + An Export item can appear inside a \l{Product} item. It defines a \l{Module} + with the product's name that can be depended on by other products. + The properties attached to the Export item will take effect in all products + that depend on the product inside which the Export item is defined. + As an example, consider these two products: + \code + Product { + name: "A" + Export { + Depends { name: "cpp" } + cpp.includePaths: exportingProduct.sourceDirectory + cpp.defines: ["USING_" + exportingProduct.name.toUpperCase()] + } + } + + Product { + name: "B" + Depends { name: "A" } + } + \endcode + + The sources in product B will be able to use headers from product A without specifying + the full path to them, because the include path has been made known to the compiler via + A's Export item. Additionally, product B will be compiled with the define \c{USING_A}. + + The dependent \l{Product}'s modules are not exported unless explicitly specified within the + \l{Export} item: + \code + Product { + name: "B-Exporting-A" + Depends { name: "A" } + Export { + Depends { name: "A" } + } + } + \endcode + + The relationship of the exported dependencies is transitive. A product C depending on a + product B-Exporting-A will also get a direct dependency on A and thus inherit include + paths and preprocessor macros exported by A. + + \code + Product { + name: "C" + Depends { name: "B-Exporting-A" } + } + \endcode + + Within an Export item, you can use the \c exportingProduct variable to refer to + the product which defines the Export item. Use the \c{importingProduct} variable + to refer to the product that pulls in the resulting module: + \code + Product { + name: "D" + Export { + Depends { name: "cpp" } + cpp.includePaths: [exportingProduct.sourceDirectory, importingProduct.buildDirectory] + } + } + \endcode +*/ + +/*! + \qmlproperty var Export::prefixMapping + + This property allows to provide a translation of exported values between non-deployed and + deployed contexts. It is an array of objects with properties \c prefix and \c replacement. + The array's elements get applied to all other properties set in this item such that if the + property's value start with \c prefix, that prefix gets replaced with \c replacement. + It is typically used for C/C++ include paths. For instance, in a library that provides + header files for inclusion both directly from its source directory (when building it + as part of a bigger project) and from some installed location (when building an unrelated + project against it), you would write something like the following: + \code + Export { + Depends { name: cpp" } + cpp.includePaths: [exportingProduct.sourceDirectory] + prefixMapping: [{ + prefix: exportingProduct.sourceDirectory, + replacement: FileInfo.joinPaths(qbs.installPrefix, "include") + }] + } + \endcode + + \defaultvalue \c undefined + \see Exporter.qbs + \see Exporter.pkgconfig + \since 1.12 +*/ diff --git a/doc/reference/items/language/filetagger.qdoc b/doc/reference/items/language/filetagger.qdoc new file mode 100644 index 00000000..5b2b4cb1 --- /dev/null +++ b/doc/reference/items/language/filetagger.qdoc @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Export + \nextpage Group + \qmltype FileTagger + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.FileTagger + + \brief Assigns file tags to files. + + This item assigns file tags to files. + The FileTagger item can appear in \l{Product} items or \l{Module} items. + + For every source artifact that has no file tag, \QBS will search for a + FileTagger with a pattern that matches the file name of the source + artifact. If a matching file tagger is found, then the file tags specified + in the FileTagger item are assigned to the source artifact. + + If there is more than one matching FileTagger, all file taggers with the + same highest priority are taken into account and their file tags are + accumulated. + + The FileTagger item can be attached to a product or a module. In the latter + case, its effect is the same as if it had been attached to all products + having a dependency on the respective module. For instance, the + \l{cpp} module of \QBS has, among others, the following file tagger: + + \code + FileTagger { + patterns: "*.cpp" + fileTags: ["cpp"] + } + \endcode + + As a result, the \c "cpp" tag is automatically attached to all files ending + with \c ".cpp" in products depending on the \c cpp module. This causes them + to be compiled, because a C++ compiler rule has \c "cpp" in its list of + matching input tags. + + File taggers are disabled if file tags are set explicitly in a \l{Product} + {product} or \l{Group}{group}. For example, the \c "cpp" tag is not attached + to the \c .cpp files in the following product: + + \code + Product { + Depends { name: "cpp" } + Group { + files: "*.cpp" + fileTags: "other" + } + } + \endcode +*/ + +/*! + \qmlproperty stringList FileTagger::patterns + \since Qbs 1.0 + + A list of patterns to match against. Supports the usual wildcards '*', '?' + and '[]'. + + Neither the list itself nor any of its elements may be empty. +*/ + +/*! + \qmlproperty list FileTagger::fileTags + \since Qbs 1.0 + + Tags to attach to a product's files. These can then be matched by a rule. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty int FileTagger::priority + \since Qbs 1.10 + + The priority of the FileTagger. A higher numerical value means a higher + priority. + + \defaultvalue 0 +*/ diff --git a/doc/reference/items/language/group.qbs b/doc/reference/items/language/group.qbs new file mode 100644 index 00000000..752916c0 --- /dev/null +++ b/doc/reference/items/language/group.qbs @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Project { + Product { +//! [0] + Group { + name: "Word processing documents" + files: ["*.doc", "*.rtf"] + prefix: "**/" + qbs.install: true + qbs.installDir: "share" + excludeFiles: "do_not_install_this_file.*" + } +//! [0] + } +} diff --git a/doc/reference/items/language/group.qdoc b/doc/reference/items/language/group.qdoc new file mode 100644 index 00000000..a1676676 --- /dev/null +++ b/doc/reference/items/language/group.qdoc @@ -0,0 +1,205 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \previouspage FileTagger + \nextpage JobLimit + \qmltype Group + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Group + + \brief Groups files in a product. + + This item is attached to a \l{Product}{product} and used to group files that + have something in common. + + For example: + + \code + Application { + Group { + name: "common files" + files: ["myclass.h", "myclass_common_impl.cpp"] + } + Group { + name: "Windows files" + condition: qbs.targetOS.contains("windows") + files: "myclass_win_impl.cpp" + } + Group { + name: "Unix files" + condition: qbs.targetOS.contains("unix") + files: "unixhelper.cpp" + Group { + name: "Linux files" + condition: qbs.targetOS.contains("linux") + files: "myclass_linux_impl.cpp" + } + Group { + name: "FreeBSD files" + condition: qbs.targetOS.contains("freebsd") + files: "myclass_freebsd_impl.cpp" + } + } + Group { + name: "Files to install" + qbs.install: true + qbs.installDir: "share" + files: "runtime_resource.txt" + } + } + \endcode + When specifying files, you can use the wildcards "*", "?" and "[]", which have their usual meaning. + By default, matching files are only picked up directly from the parent directory, but you can tell \QBS to + consider the whole directory tree. It is also possible to exclude certain files from the list. + The pattern ** used in a pathname expansion context will match all files and zero or more + directories and subdirectories. + For example: + \snippet reference/items/language/group.qbs 0 + + A group can also be used to attach properties to build artifacts such as executables or + libraries. In the following example, an application is installed to "/bin". + \code + Application { + Group { + fileTagsFilter: "application" + qbs.install: true + qbs.installDir: "bin" + } + } + \endcode + + Groups may also appear in \l{Module}{modules}, which causes the respective + sources to be added to the products depending on the said module, unless + the \l{filesAreTargets} property is set. + + Groups can be nested. In this case, child groups inherit the module + properties and \l{FileTagger}{file tags} as well as the prefix of their + parent group. The \l{condition} of a child group gets logically + ANDed with the one of its parent group. +*/ + +/*! + \qmlproperty string Group::name + + The name of the group. Not used internally; mainly useful for IDEs. + + \defaultvalue "Group x", where x is a unique number among all the + groups in the product. +*/ + +/*! + \qmlproperty list Group::files + + The files in the group. Mutually exclusive with \l{fileTagsFilter}. + Relative paths are resolved using the parent directory of the file + that contains the Group item. However, if the \l{prefix} property is set to + an absolute path, then that one becomes the base directory. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty bool Group::filesAreTargets + + If this property is \c true and the group is in a \l{Module}, the files in the + group will not become source artifacts of the product that depends on the module. + Instead, they are treated like target artifacts of products. That is, they will be + matched against the \l{Rule::inputsFromDependencies}{inputsFromDependencies} + file tag list of \l{Rule}{rules} in products that depend on the module. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty string Group::prefix + + A string to prepend to all files. Slashes are allowed and have directory + semantics. + + \defaultvalue The prefix of the parent group if one exists, otherwise empty. +*/ + +/*! + \qmlproperty list Group::fileTagsFilter + + List of \l{Artifact::fileTags}{artifact.fileTags} to match. Any properties + set in this group will be applied to the product's artifacts whose file tags + match the ones listed here. + + The file tags that the group's \l{fileTags} property specifies will + be added to the matching artifacts. + + This property is mutually exclusive with \l{files}. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty bool Group::condition + + Determines whether the files in the group are actually considered part of + the project. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty list Group::fileTags + + A list of file tags to attach to the group's files. These can then be + matched by a \l{Rule}{rule}. + + \note \l{FileTagger}{File taggers} are never applied to a file that has this + property set. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty bool Group::overrideTags + + Determines how tags on files that are listed both at the top level of + a product (or the parent group, if there is one) and a group are handled. + If this property is \c true, then the \l{FileTagger}{file tags} set via the + group replace the ones set via the product or parent group. + If it is \c false, the \e {group tags} are added to the \e {parent tags}. + + This property is ignored if \l{fileTagsFilter} is set. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty list Group::excludeFiles + + A list of files that are \e subtracted from the files list. Useful when + using wildcards. + + \defaultvalue An empty list +*/ diff --git a/doc/reference/items/language/joblimit.qdoc b/doc/reference/items/language/joblimit.qdoc new file mode 100644 index 00000000..5ac3689e --- /dev/null +++ b/doc/reference/items/language/joblimit.qdoc @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Group + \nextpage Module + \qmltype JobLimit + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.JobLimit + + \brief Restricts concurrent execution of jobs in a given pool. + + In addition to the global limit on concurrently running commands, a project might + want to restrict concurrent execution of certain types of commands even further, + for instance because they are not well-suited to share certain types of resources. + + In the following example, we define a rule that runs a tool of which at most one + instance can be running for the same project at any given time: + \code + Rule { + // ... + prepare: { + var cmd = new Command("my-exclusive-tool", [project.buildDirectory]); + cmd.description = "running the exclusive tool"; + cmd.jobPool = "exclusive_tool"; + return cmd; + } + } + JobLimit { + jobPool: "exclusive_tool" + jobCount: 1 + } + \endcode + + \c JobLimit items can appear inside \l Product, \l Project and \l Module items. + In the case of collisions, that is, items matching the same job pool but setting + different values, the ones defined inside products have the highest precedence, + and the ones inside modules have the lowest. Items defined in sub-projects have + higher precedence than those defined in parent projects. For items with the same + precedence level, the most restrictive one is chosen, that is, the one with the + lowest job number greater than zero. + + \see {How do I limit the number of concurrent jobs for the linker only?} +*/ + +/*! + \qmlproperty bool JobLimit::condition + + Determines whether the job limit is active. + + If this property is set to \c false, the job limit is ignored. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty int JobLimit::jobCount + + The maximum number of commands in the given \l{jobPool}{job pool} that can run + concurrently. + + A value of zero means "unlimited", negative values are not allowed. + + \note The global job limit always applies: For instance, if you set this + property to 100 for some job pool, and "-j 8" was given on the + command line, then no more than eight instances of commands from + the respective job pool will run at any time. + + This property must always be set. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string JobLimit::jobPool + + The job pool to which apply the limit. + + This property must always be set to a non-empty value. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/language/module.qdoc b/doc/reference/items/language/module.qdoc new file mode 100644 index 00000000..f630f60f --- /dev/null +++ b/doc/reference/items/language/module.qdoc @@ -0,0 +1,356 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage JobLimit + \nextpage ModuleProvider + \qmltype Module + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Module + + \brief Represents a collection of properties and items that can be loaded into a product. + + A Module item is a collection of properties and language items. It + contributes to building a product if the product has a + \l{Depends}{dependency} on the module. Modules may contain the following + items: + + \list + \li \l{Depends} + \li \l{FileTagger} + \li \l{Group} + \li \l{JobLimit} + \li \l{Parameter} + \li \l{Probe} + \li \l{PropertyOptions} + \li \l{Rule} + \li \l{Scanner} + \endlist + + When a product expresses a dependency on a module, \QBS will create an + instance of the module item in the scope of the product. The product can + then read and write properties from and to the loaded module, respectively. + + Modules in different products are isolated from each other, just as products + cannot access each other's properties. However, products can use the + \l{Export} item to pass dependencies and properties of modules to other + dependent products. + + The following (somewhat artificial) module pre-processes text files by removing certain + characters from them. The module's name is \c{txt_processor}. + + \qml + import qbs.FileInfo + import qbs.TextFile + + Module { + property stringList unwantedCharacters: [] + + FileTagger { + patterns: ["*.raw"] + fileTags: ["raw-txt"] + } + + Rule { + inputs: ["raw-txt"] + + Artifact { + filePath: FileInfo.relativePath(input.filePath, product.sourceDirectory) + + "/" + input.fileName + ".processed" + fileTags: ["processed-txt"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Processing " + input.fileName; + cmd.sourceCode = function() { + var inFile = new TextFile(input.filePath, TextFile.ReadOnly); + var content = inFile.readAll(); + inFile.close(); + var unwantedChars = input.txt_processor.unwantedCharacters; + for (var c in unwantedChars) + content = content.replace(unwantedChars[c], ""); + var outFile = new TextFile(output.filePath, TextFile.WriteOnly); + outFile.write(content); + outFile.close(); + }; + return cmd; + } + } + } + \endqml + + And this is how a \l{Product} would use the module: + + \qml + Product { + type: "processed-txt" + Depends { name: "txt_processor" } + txt_processor.unwantedCharacters: ["\r"] + files: [ + "file1.raw", + "file2.raw" + ] + } + \endqml + + The resulting files are tagged with \c{processed-txt} and might be consumed + by a rule in another module. That is possible if another rule has + \c{processed-txt} in its \l{Rule::inputs}{inputs} property. + + For more information about how you make your own modules available to \QBS, + see \l{Custom Modules and Items}. + + \section1 Accessing Product and Module Properties + + When defining a property in a module item, the right-hand side expression is + a binding. Bindings may reference other properties of: + + \list + \li the current module + \li other modules that this module depends on + \li the dependent product + \endlist + + Please note that this applies to bindings in modules only. Property access + in rules and other nested items is different. + + \section2 Accessing Properties of the Current Module + + Sibling properties in the same module can be accessed directly by their name: + + \qml + Module { + property stringList windowsDefaults: ["\r"] + property stringList unwantedCharacters: windowsDefaults + } + \endqml + + \section2 Properties of the Dependent Modules + + When a module loads another module through a \l{Depends} element, it can + access properties of the other module through its name. Assuming there was a + module \c OtherModule with a property \c otherProperty, such an access would + look like this: + + \qml + Module { + Depends { name: "OtherModule" } + property string myProperty: "something-" + OtherModule.otherProperty + } + \endqml + + \section2 Accessing Properties of the Dependent Product + + \qml + Module { + property bool featureEnabled: + (product.type.contains("application")) ? true : false + } + \endqml + + \section1 Special Property Values + + For every property defined in a module, \QBS provides the following special + built-in values: + + \list + \li \l base + \li \l original + \li \l outer + \endlist + + \section2 \c base + This value is useful when making use of inheritance. It stands for the value of the respective + property in the item one level up in the inheritance chain. For instance: + \code + Product { // defined in MyProduct.qbs + Depends { name: "mymodule" } + mymodule.someProperty: ["value1"] + } + ------ some other file ------ + MyProduct { + mymodule.someProperty: base.concat(["value2"]) // => ["value1", "value2"] + } + \endcode + + \section2 \c original + This is the value of the property in the module itself (possibly overridden from a profile or + the command line). Use it to set a module property conditionally: + \code + Module { // This is mymodule + property string aProperty: "z" + } + ---------- + Product { + Depends { name: "mymodule" } + Depends { name: "myothermodule" } + mymodule.aProperty: myothermodule.anotherProperty === "x" ? "y" : original // => "y" if myothermodule.anotherProperty is "x", "z" otherwise + \endcode + + \section2 \c outer + This value is used in nested items, where it refers to the value of the respective property + in the surrounding item. It is only valid in \l{Group} and \l{Properties} items: + \code + Product { + Depends { name: "mymodule" } + mymodule.someProperty: ["value1"] + Group { + name: "special files" + files: ["somefile1", "somefile2"] + mymodule.someProperty: outer.concat(["value"]) // => ["value1", "value2"] + } + } + \endcode + + + \section1 Dependency Parameters + + Modules can declare dependency parameters. Those parameters can be set + within \l{Depends} items. \l{Rule}{Rules} of the module can read the + parameters of dependencies and act accordingly. + + In the following example, the module \e{foo} declares the parameter + \c{ignore}. A dependency to \c{bar} then sets the parameter \c{foo.ignore} + to \c{true}. A rule in \c{foo} ignores all dependencies that have + \c{foo.ignore} set to true. + + \code + Module { // Definition of module 'foo'. + Parameter { property bool ignore } + Rule { + ... + prepare: { + for (i in product.dependencies) { + var dep = product.dependencies[i]; + if (dep.foo.ignore) + continue; + // Do something with the dependency. + } + } + } + ... + } + ---------- + Product { + Depends { name: "foo" } + Depends { name: "bar"; foo.ignore: true } + } + \endcode +*/ + +/*! + \qmlproperty stringList Module::additionalProductTypes + + A list of elements that will be added to the \l{Product::type}{type} + property of a product that has a dependency on the module. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty bool Module::condition + + Whether the module is enabled. If this property is \c false, the + surrounding Module item will not be considered in the module look-up. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool Module::present + \readonly + + This property is \c false if and only if the respective \l{Depends} item had + its \l{Depends::required}{required} property set to \c false and the module + was not found. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty int Module::priority + + The priority of this module instance. If there is more than one module + instance available for a module name, the module with the highest priority + is chosen. + + \defaultvalue 0 +*/ + +/*! + \qmlproperty script Module::setupBuildEnvironment + + A script for setting up the environment in which a product is built. + + The code in this script is treated as a function with the signature + \c{function(project, product)}. + + Use the \l{Environment Service}{Environment} functions to alter the + environment. + + The return value of this script is ignored. + + \nodefaultvalue +*/ + +/*! + \qmlproperty script Module::setupRunEnvironment + + A script for setting up the environment in which a product is run. + + The code in this script is treated as a function with the signature + \c{function(project, product, config)}. + + The \c config parameter is a list of arbitrary strings that can be passed + via the \l{run} command. The values supported by specific modules are + listed in their respective documentation. + + Use the \l{Environment Service}{Environment} functions to alter the + environment. + + The return value of this script is ignored. + + \nodefaultvalue +*/ + +/*! + \qmlproperty script Module::validate + + A script that is run after the module is loaded. It can be used to check + property values and throw errors in unexpected cases. The return value is + ignored. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Module::version + + The module's version. It consists of integer values separated by dots. You + can check for specific values of this property in a \l{Depends} item. +*/ diff --git a/doc/reference/items/language/moduleprovider.qdoc b/doc/reference/items/language/moduleprovider.qdoc new file mode 100644 index 00000000..81a09a66 --- /dev/null +++ b/doc/reference/items/language/moduleprovider.qdoc @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Module + \nextpage Parameter + \qmltype ModuleProvider + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.ModuleProvider + + \brief Creates modules on demand. + + The \c ModuleProvider item implements the module creation part of the procedure described + in the \l {Module Providers} overview. It is always located in a file called \c provider.qbs. + + The actual module creation is done on the right-hand side of the + \l{ModuleProvider::relativeSearchPaths}{relativeSearchPaths} property. + + A ModuleProvider item may contain \l{Probe} items. + + Here is a complete minimal example of a module provider. It just creates an empty module. + If you put this item into the file \c {module-providers/mymodule/provider.qbs} + in your project source directory, you will be able to successfully build a product which + contains a dependency on the module \c mymodule. + \code + import qbs.File + import qbs.FileInfo + import qbs.TextFile + + ModuleProvider { + relativeSearchPaths: { + var moduleDir = FileInfo.joinPaths(outputBaseDir, "modules", name); + File.makePath(moduleDir); + var moduleFilePath = FileInfo.joinPaths(moduleDir, name + ".qbs"); + var moduleFile = new TextFile(moduleFilePath, TextFile.WriteOnly); + moduleFile.writeLine("Module {"); + moduleFile.writeLine("}"); + moduleFile.close(); + return ""; + } + } + \endcode +*/ + +/*! + \qmlproperty string ModuleProvider::name + + The name of the module provider. + + This property is set by \QBS. + + If provider is \l{How \QBS Uses Module Providers}{requested} via the + \l{Product::qbsModuleProviders}{qbsModuleProviders} property, it is the name specified in this + property and matches the provider file name, without the \c .qbs extension. + Otherwise, it is the name of the directory the provider was found in, relative to + the particular module-providers base directory. For instance, if the dependency is \c {x.m1} and + the provider was found in \c {module-providers/x/m1/provider.qbs}, then \c name is \c {x.m1}. + If the provider was found in \c {module-providers/x/provider.qbs}, then \c name is \c x. +*/ + +/*! + \qmlproperty string ModuleProvider::outputBaseDir + + The path under which the new modules should be created when \l relativeSearchPaths + is evaluated. The path is unique for the current provider in the given configuration. + + This property is set by \QBS. +*/ + +/*! + \qmlproperty stringList ModuleProvider::relativeSearchPaths + + This property gets evaluated by \QBS to retrieve new search paths with which + to re-attempt the module look-up. + + It is here where you need to put the code that creates the new module files. + Use the directory structure explained in \l {Custom Modules and Items}. + That is, the file for a module called \c m will be located in a directory \c {modules/m/}, + anchored at \l outputBaseDir. + + The return value is the list of search paths required to find the new module, + relative to \l outputBaseDir. In most cases, only a single search path will be required, + in which case a single-element list containing an empty string should be returned + (or just the empty string, because of \QBS' auto-conversion feature). + + The returned list can also be empty, which means that the module provider was not able + to generate any modules in this environment. +*/ diff --git a/doc/reference/items/language/parameter.qdoc b/doc/reference/items/language/parameter.qdoc new file mode 100644 index 00000000..9a1b0345 --- /dev/null +++ b/doc/reference/items/language/parameter.qdoc @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Module + \nextpage Parameters + \qmltype Parameter + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Parameter + + \brief Declares a dependency parameter. + + The Parameter item declares a dependency parameter. It can appear only + within \l{Module} and \l{Export} items. + + The Parameter item contains exactly one property declaration. + + Example: + \code + Module { + Parameter { property string extra } + } + \endcode + + For more information about dependency parameters, see + \l{Module#dependency-parameters}{Module - Dependency Parameters}. +*/ diff --git a/doc/reference/items/language/parameters.qdoc b/doc/reference/items/language/parameters.qdoc new file mode 100644 index 00000000..325f1680 --- /dev/null +++ b/doc/reference/items/language/parameters.qdoc @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Parameter + \nextpage Probe + \qmltype Parameters + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Parameters + + \brief Defines default values for dependency parameters within Export items. + + The Parameters item defines default values for dependency parameters within + \l{Export} items. + + Example: + \code + DynamicLibrary { + name: "foo" + ... + Export { + ... + Parameters { + cpp.link: false + } + } + } + \endcode + + Every dependency on \e{foo} has the parameter \l{dependency-parameters-cpp} + {cpp.link} set to \c{false} by default. + + This can be overridden explicitly: + \code + Depends { name: "foo"; cpp.link: true } + \endcode + + The Parameters item contains a number of property bindings where + each property must be a properly declared dependency parameter. + For more information, see \l{Parameter} and + \l{Module#dependency-parameters}{Module - Dependency Parameters}. +*/ diff --git a/doc/reference/items/language/probe.qdoc b/doc/reference/items/language/probe.qdoc new file mode 100644 index 00000000..8e31d882 --- /dev/null +++ b/doc/reference/items/language/probe.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Parameters + \nextpage Product + \qmltype Probe + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \ingroup list-of-probes + \keyword QML.Probe + + \brief Locates files outside the project. + + Probe items can appear inside \l{Product}, \l{Project} and \l{ModuleProvider} items. + They are run prior to building, for instance to locate dependent headers, libraries, and other + files outside the project directory whose locations are not known ahead of time. + Probes can be parameterized via their properties and typically store results in + properties as well. These results are then retrieved via the Probe's id, which is mandatory: + \code + Product { + Probe { + id: valueCalculator + property string parameter: "whatever" + property int value + configure: { + value = Utils.calculateValue(parameter); // Expensive operation + found = true; + } + } + property int theValue: valueCalculator.value + } + \endcode + + \note Because Probes often invoke external processes, which is relatively expensive compared + to evaluating normal properties, their results are cached. To force re-evaluation + of a Probe, you can supply the \l{build-force-probe-execution} + {--force-probe-execution} command-line option to the \l{build} command. +*/ + +/*! + \qmlproperty bool Probe::condition + + Determines whether the probe will actually be run. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool Probe::found + + Indicates whether the probe was run successfully. Set by \l{configure}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty script Probe::configure + + A script that is executed when the probe is run. +*/ diff --git a/doc/reference/items/language/product.qdoc b/doc/reference/items/language/product.qdoc new file mode 100644 index 00000000..1ae29741 --- /dev/null +++ b/doc/reference/items/language/product.qdoc @@ -0,0 +1,297 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Probe + \nextpage Profile + \qmltype Product + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Product + + \brief Represents the result of a build process. + + A Product typically represents the result of a build process. It specifies a set of + input and output files and a way to transform the former into the latter. For example, the + following product sets up a very simple C++ application: + \code + Product { + name: "helloworld" + type: "application" + files: "main.cpp" + Depends { name: "cpp" } + } + \endcode + The \l{type} property specifies what will be built (an executable). The + \l{files} property specifies the input files (one C++ source file), and the + \l{Depends} item pulls in the logic from the \l{cpp} module + about how to do the necessary transformations. + For some often-used types of products, \QBS pre-defines special derived items that save + users some typing. These are: + \list + \li \l{Application} + \li \l{CppApplication} + \li \l{DynamicLibrary} + \li \l{StaticLibrary} + \endlist + Therefore, the above example could also be written like this: + \code + CppApplication { + name: "helloworld" + files: "main.cpp" + } + \endcode + Any property \c prop attached to this item is available in sub-items as \c product.prop, as + well as in modules that are loaded from this product. + + \section1 Multiplexing Properties + + The following properties are relevant for product multiplexing only. + Unless multiplexing is desired, they can be left at their default values: + + \list + \li \l{aggregate} + \li \l{multiplexedType} + \li \l{multiplexByQbsProperties} + \endlist + + \note We do not promise backwards compatibility for multiplexing properties + as they are likely to change in future \QBS versions. + + \section1 Read-Only Properties + + The following properties are automatically set by \QBS and cannot be + changed by the user: + + \list + \li \l{buildDirectory} + \li \l{sourceDirectory} + \endlist +*/ + +/*! + \qmlproperty bool Product::builtByDefault + + Determines whether the product will be built. + + If \c false, the product will only be built if this is explicitly requested, + either by listing the product name as an argument to the + \l{build-products}{--products} option or by using the + \l{build-all-products}{--all-products} option of the \l{build} command. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool Product::condition + + Determines whether the product will be built. + + If \c false, the product will not be built. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Product::name + + The name of the product. Used to identify the product in a \l{Depends} item, for + example. The value of this property must be a simple JavaScript expression that + does not depend on module properties or values that are non-local to this product. + + \code + CppApplication { + name: "hello" + "world" + // valid + } + CppApplication { + name: "app_" + qbs.targetOS.join("_") + // invalid + } + \endcode + + To change the name of your product's target artifact, modify \l{targetName} + instead. + + \defaultvalue An empty string +*/ + +/*! + \qmlproperty stringList Product::type + + The file tags matching the product's target artifacts. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty string Product::targetName + + The base file name of the product's target artifacts. + + \defaultvalue The value of \l{name} with illegal file name characters + replaced by underscores. +*/ + +/*! + \qmlproperty string Product::destinationDirectory + + The directory where the target artifacts will be located. If a relative path + is given, the base directory will be \l{Project::buildDirectory} + {project.buildDirectory}. + + \defaultvalue \c{product.buildDirectory} +*/ + +/*! + \qmlproperty stringList Product::files + + A list of source files. Syntactic sugar to save a \l{Group} item for simple + products. + + Relative paths are resolved using the parent directory of the project file + that sets the property. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty stringList Product::excludeFiles + + A list of source files not to include. Useful with wildcards. + For more information, see \l{Group}. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty bool Product::consoleApplication + + On Windows, determines whether a console or GUI application is generated. + + If \c true, a console application is generated. If \c false, a GUI + application is generated. + + On Apple platforms, influences the default application type. + + If \c true, a normal executable is generated. + If \c false, an application bundle is generated. + + \defaultvalue Linker-dependent +*/ + +/*! + \qmlproperty stringList Product::qbsSearchPaths + + A list of paths that are searched for imports, modules and module providers. + + The value set here will be merged with the value of + \l{Project::qbsSearchPaths}{project.qbsSearchPaths}. + + For the details about how to add custom items, see the \l{Custom Modules and Items} page. + + \defaultvalue \l{Project::qbsSearchPaths}{project.qbsSearchPaths} +*/ + +/*! + \qmlproperty string Product::version + + The version number of the product. Used in shared library filenames and generated + Info.plist files in Apple application and framework bundles, for example. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Product::aggregate + + If \c{true}, an aggregate product will be created that has dependencies on all + multiplex instances of this product. + + \note If you do not want to do multiplexing, you can use the default value + \c{undefined}. +*/ + +/*! + \qmlproperty stringList Product::multiplexedType + + Specifies the product type for the multiplexed product instances. + + \note If you do not want to do multiplexing, you can use the default value + \c{undefined}. +*/ + +/*! + \qmlproperty stringList Product::multiplexByQbsProperties + + Specifies which properties of the \l{qbs} module will be used for product + multiplexing: + + \list + \li \l{qbs::architectures}{architectures} + \li \l{qbs::buildVariants}{buildVariants} + \li \l{qbs::profiles}{profiles} + \endlist + + The value must be a subset of the above values. + + \note If you do not want to do multiplexing, you can use the default value + \c{["profiles"]}. +*/ + +/*! + \qmlproperty path Product::buildDirectory + \readonly + + The build directory for this product. This is the directory where generated + files are placed. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ + +/*! + \qmlproperty path Product::sourceDirectory + \readonly + + The source directory for this product. This is the directory of the file + where this product is defined. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ + +/*! + \qmlproperty stringList Product::qbsModuleProviders + + The list of \l{Module Providers} to use for this product. + + Overrides \l{Project::qbsModuleProviders}{Project.qbsModuleProviders}. + + \sa Project::qbsModuleProviders + + \since Qbs 1.21 +*/ diff --git a/doc/reference/items/language/profile.qdoc b/doc/reference/items/language/profile.qdoc new file mode 100644 index 00000000..3c41b312 --- /dev/null +++ b/doc/reference/items/language/profile.qdoc @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Product + \nextpage Project + \qmltype Profile + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Profile + + \brief Creates a profile within the project. + + The profiles used by \QBS are normally set up on a user's machine and are then available + to all projects. See \l{Configuring Profiles and Preferences} for information on how + to set up and use profiles on the command line. + In some rare cases, however, the creator of a project has complete knowledge about the system + on which that project is to be built. Then it can make sense to integrate the profile into + the project: + + \code + Product { + // ... + Profile { + name: "my-special-profile" + qbs.toolchainType: "gcc" + qbs.targetPlatform: "linux" + qbs.architecture: "armv7a" + cpp.toolchainInstallPath: "/opt/special-gcc/bin" + cpp.toolchainPrefix: "arm-linux-gnueabi-" + } + qbs.profiles: ["my-special-profile"] + // ... + } + \endcode + + The project in the above example can be built in a particular well-known environment + without any additional setup. + + \c Profile items can appear inside \l{Product} and \l{Project} items. +*/ + +/*! + \qmlproperty string Profile::baseProfile + + The name of a profile from which this profile inherits. If the same property is + set in both this profile and the base profile, the value from this profile + takes precedence. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Profile::condition + + Determines whether this profile can be used. + + If this property is set to \c false, the profile cannot be used. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Profile::name + + The name under which the profile can be referenced later. Setting this property + is required. The value must be unique among all profiles in an entire project. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/language/project.qdoc b/doc/reference/items/language/project.qdoc new file mode 100644 index 00000000..b1dc6e9d --- /dev/null +++ b/doc/reference/items/language/project.qdoc @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Profile + \nextpage Properties + \qmltype Project + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Project + + \brief Represents a collection of products and properties. + + A Project item represents a collection of of products. In a + non-trivial project, these products are typically defined in their own files and + referenced in the main project file: + \code + Project { + references: [ + "product1/product1.qbs", + "product2/product2.qbs" + ] + } + \endcode + Any property \c prop attached to this item is available in sub-items as \c project.prop. + + While the root of the item hierarchy is always a Project, this kind of item + can also appear further down the hierarchy. Such sub-projects are usually + introduced to group products. See \l{SubProject} for details. + + \note If your project consists of only one product, the Project item can be + omitted. +*/ + +/*! + \qmlproperty path Project::buildDirectory + \readonly + + The build directory of the top-level project. +*/ + +/*! + \qmlproperty string Project::name + + The project name. Only relevant when displaying a project tree in an IDE, + for example. + + \defaultvalue The basename of the file that defines the project. +*/ + +/*! + \qmlproperty string Project::profile + \readonly + + The top-level \l{Profile}{profile} for building the project. This property + is set by \QBS when the project is being set up. +*/ + +/*! + \qmlproperty bool Project::condition + + Whether the project is enabled. If \c false, no \l{Product}{products} or + sub-projects will be collected. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty stringList Project::qbsSearchPaths + + A list of paths that are searched for imports, modules and module providers in addition to the + ones listed in \c{preferences.qbsSearchPaths}. The value set here is merged with the value + inherited from the parent project, if there is one. The result is inherited by + all products in the project. + + For the details about how to add custom items, see the \l{Custom Modules and Items} page. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty pathList Project::references + + A list of files from which to import products. This is equivalent to defining + the respective \l{Product} items directly under this Project item. + + \defaultvalue An empty list +*/ + +/*! + \qmlproperty path Project::sourceDirectory + \readonly + + The directory where the file containing the top-level Project item is + located. +*/ + +/*! + \qmlproperty string Project::minimumQbsVersion + + The minimum version of \QBS that is needed to build this project. + + \defaultvalue \c "1.3.0" +*/ + +/*! + \qmlproperty stringList Project::qbsModuleProviders + + The list of \l{Module Providers} to use for this project. + + Providers contribute to the \l{Product::}{qbsSearchPaths} in the order specified here, so + modules generated by providers specified earlier are prioritized. + Currently, this order also corresponds with the actual execution order of the providers, but + this should not be relied upon. + + \sa Product::qbsModuleProviders + + \since Qbs 1.21 +*/ + diff --git a/doc/reference/items/language/properties.qdoc b/doc/reference/items/language/properties.qdoc new file mode 100644 index 00000000..6e235d92 --- /dev/null +++ b/doc/reference/items/language/properties.qdoc @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Project + \nextpage PropertyOptions + \qmltype Properties + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Properties + + \brief Provides conditional setting of properties. + + \note This topic documents the Properties item in the context of \l{Product} + {products}. For more information about using it in sub-projects, see + \l{SubProject}. + + The Properties item is an auxiliary item for setting multiple property values conditionally. + + In the following example, two properties are set if the project is built for Windows: + \code + Product { + Properties { + condition: qbs.targetOS.contains("windows") + cpp.defines: ["ON_WINDOWS"] + cpp.includePaths: ["extraWindowsIncludes"] + } + } + \endcode + + Multiple Properties items can be specified to set properties dependent on different + conditions. The order of appearance is important. Semantics are similar to if-else-chains. + The following example + \code + Product { + Properties { + condition: qbs.targetOS.contains("windows") + cpp.defines: ["ON_WINDOWS"] + cpp.includePaths: ["myWindowsIncludes"] + } + Properties { + condition: qbs.targetOS.contains("linux") + cpp.defines: ["ON_LINUX"] + cpp.includePaths: ["myLinuxIncludes"] + } + cpp.defines: ["ON_UNKNOWN_PLATFORM"] + } + \endcode + is equivalent to + \code + Product { + cpp.defines: { + if (qbs.targetOS.contains("windows")) + return ["ON_WINDOWS"]; + if (qbs.targetOS.contains("linux")) + return ["ON_LINUX"]; + return ["ON_UNKNOWN_PLATFORM"]; + } + cpp.includePaths: { + if (qbs.targetOS.contains("windows")) + return ["myWindowsIncludes"]; + if (qbs.targetOS.contains("linux")) + return ["myLinuxIncludes"]; + return base; + } + } + \endcode + + In Properties items, one can access the \l{Module#outer}{outer value} of a + property. + \code + Product { + Properties { + condition: qbs.targetOS.contains("windows") + cpp.defines: outer.concat("ON_WINDOWS") // === ["FOO", "ON_WINDOWS"] + } + Properties { + condition: qbs.targetOS.contains("linux") + cpp.defines: ["ON_LINUX"] // === ["ON_LINUX"] + } + cpp.defines: ["FOO"] + } + \endcode + + We suggest to use the Properties item for mutually exclusive conditions only. It is + especially useful if there are several properties to set, based on the same condition. +*/ + +/*! + \qmlproperty bool Properties::condition + + The condition to be used for the other bindings in this item. + + This is a mandatory property that has no default value. +*/ + +/*! + \qmlproperty bool Properties::overrideListProperties + + List properties set within this item will override the values coming from + modules, rather than getting merged with them, which is the default behavior. + Use this in the rare case that a module you depend on inserts a value into + a list property that is problematic for some product. + + \defaultvalue \c false +*/ diff --git a/doc/reference/items/language/propertyoptions.qdoc b/doc/reference/items/language/propertyoptions.qdoc new file mode 100644 index 00000000..afbba710 --- /dev/null +++ b/doc/reference/items/language/propertyoptions.qdoc @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Properties + \nextpage Rule + \inqmlmodule QbsLanguageItems + \qmltype PropertyOptions + \ingroup list-of-items + \keyword QML.PropertyOptions + + \brief Provides inline documentation for properties within product and module items. + + A PropertyOptions item can appear inside a \l{Product} or \l{Module} item to + provide inline documentation for properties. +*/ + +/*! + \qmlproperty stringList PropertyOptions::allowedValues + + A list of the values permitted by the property. + + The default value, \c{undefined}, indicates that any value is permitted. +*/ + +/*! + \qmlproperty string PropertyOptions::description + + A brief description of the property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PropertyOptions::name + + The name of the property to document. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/language/rule.qdoc b/doc/reference/items/language/rule.qdoc new file mode 100644 index 00000000..ec586544 --- /dev/null +++ b/doc/reference/items/language/rule.qdoc @@ -0,0 +1,348 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage PropertyOptions + \nextpage Scanner + \qmltype Rule + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Rule + + \brief Creates transformers for input tags. + + In \QBS, rules create \e transformers that produce output files from input files. + The term \e transformer refers to a list of \l{Command and JavaScriptCommand}{commands}. + These commands are created in a rule's \l{prepare} script. They do the actual work, either + directly or by executing external commands. + + \section1 A Simple Example + + The following rule takes text files and replaces Windows-style line endings with their + Unix-style counterparts. We will look at it one piece at a time. + + \quotefromfile ../examples/rule/rule.qbs + + \skipto Rule + \printuntil multiplex: false + + A \e {multiplex rule} creates one transformer that takes all input artifacts with the + matching input file tag and creates one or more output artifacts. We are setting the + respective property to \c false here, indicating that we want to create one transformer + per input file. + \note This is actually the default, so the above assignment is not required. + + \printuntil inputs: ["txt_input"] + + Here we are specifying that our rule is interested in input files that have the tag + \c "txt_input". Such files could be source files, in which case you would tag them + using a \l{Group}. Or they could in turn get generated by a different rule, + in which case that rule would assign the file tag. + The files matching the tag will be available in the \l{prepare} script under the name + \c inputs (see \l{inputs and outputs}{The inputs and outputs Variables}). + + \printuntil } + + Here we are specifying that for every input file, we want to create one output file + whose name is the same as the input file, but with an additional extension. Because we are + giving a relative path, \QBS will prepend that path by the product's build directory. + + In addition, we tell \QBS that the output files should get the file tag \c "txt_output". This + enables other rules to use these files as inputs. You must always assign suitable file tags + to your output artifacts, or the rule will not be run. + See \l{Rules and Product Types} for details. + + If you want to create more than one output file per input file, you simply provide multiple + \l Artifact items. The set of output artifacts will be available in the prepare script + under the name \c outputs (see \l{inputs and outputs}{The inputs and outputs Variables}). + + \printuntil /^\s{4}\}/ + + The prepare script shown above puts everything together by creating the command that does + the actual transformation of the file contents, employing the help of the + \l{TextFile Service}{TextFile} class. + + As you can see, the return value is an array, meaning you can provide several commands to + implement the rule's functionality. For instance, if we had provided two \c Artifact items, + we might have also provided two commands, each of them creating one output file. + + For the \c input and \c output variables used in the code, see the next section. + + \target inputs and outputs + \section1 The \c inputs and \c outputs Variables + + We already mentioned that the input and output artifacts are available in the prepare script + via the variables \c inputs and \c outputs, respectively. These variables are JavaScript + objects whose property keys are file tags and whose property values are lists of objects + representing the artifacts matching these tags. In our example, the \c inputs variable + has a single property \c txt_input, whose value is a list with one element. Similarly, the + \c outputs variable also has one single property \c txt_output, again with a list containing + one element. + + The actual artifact objects have the following properties: + \table + \header + \li Property + \li Description + \row + \li \c baseName + \li The file name without any extension. + \row + \li \c completeBaseName + \li The file name without the last extension. + \row + \li \c fileName + \li The name of the file (that is, \c filePath without any directory components). + \row + \li \c filePath + \li The full file path. + \row + \li \c fileTags + \li The list of the artifact's file tags. + \endtable + + The artifact object contains a property for every module that is used in the product. That can + be used to access the module's properties. For instance, for an artifact in a C++ product, + \c{artifact.cpp.defines} is the list of defines that will be passed when compiling the + respective file. + + But what about the variables \c input and \c output that appeared in our example? These + are simply convenience variables which are available in the case that the \c inputs + and \c outputs variables contain only one artifact, respectively. So in our example, instead + of \c input we also could have written \c {inputs.txt_input[0]}, which is considerably + more verbose. + + \section1 Rules and Product Types + + It is important to know that when figuring out which rules to execute, \QBS starts at the + product type and then looks for a way to produce artifacts with matching file tags from + source files, using a chain of rules that are connected by their respective input and output + tags. For instance, consider this simple C++ project: + \code + Product { + type: ["application"] + Depends { name: "cpp" } + files: ["main.cpp"] + } + \endcode + Here's how this product is built: + \list 1 + \li \QBS looks for a rule that can produce artifacts with the file tag + \c{"application"}. Such a rule is found in the \l{cpp} module + (namely, the rule that invokes the linker). + \li Since the rule found in the previous step takes inputs of type \c{"obj"}, \QBS now + looks for a rule that produces artifacts of that type. Again, such a rule is found in + the \c cpp module (the rule that runs the compiler). + \li The rule found in the previous step takes inputs of type \c{"cpp"}. No rule is found + that creates such artifacts, but we do have a source file with a matching type (because + the \c cpp module contains a \l{FileTagger} which attached that type + to \c{"main.cpp"} due to its file extension). + \li Now that there is a chain of rules leading from a source file tag to the product type, + the commands of these rules are executed one after the other until we end up with + our executable. + \endlist + + \section1 A Complete Example + + The following code snippet shows a single \l{Rule} within a \l{Product} and summarizes the + previous sections. + + \note The product's type is set up to the \c "txt_output" file tag to tell \QBS that the + product depends on output artifacts produced by the custom rule. Otherwise the rule would not + be executed. + + \quotefile ../examples/rule/rule.qbs +*/ + +/*! + \qmlproperty bool Rule::multiplex + + Determines whether this is a multiplex rule. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty stringList Rule::inputs + + A list of file tags the input artifacts must match. + + All output artifacts will depend on all artifacts in the product with + the given input file tags. Also, these artifacts are available in the + \c inputs variable of the \l{prepare} script. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Rule::auxiliaryInputs + + A list of file tags. This rule will be dependent on every other rule that + produces artifacts that are compatible with the value of this property. + + Unlike \l{inputs}, this property has no effect on the content of the + \c inputs variable of the \l{prepare} script. + + All rules in this product and rules of product dependencies that produce + target artifacts are considered. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Rule::excludedInputs + + A list of file tags. Connections to rules that produce these file tags are + prevented. + + \nodefaultvalue + \since Qbs 1.12 +*/ + +/*! + \qmlproperty stringList Rule::inputsFromDependencies + + A list of file tags that the artifacts of product dependencies must match. + + For example, the product \a foo might appear as follows in the current + product: + + \code + Depends { + name: "foo" + } + \endcode + + All artifacts of \a foo that match the given file tags will appear in the + \c inputs variable of the \l{prepare} script. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var Rule::outputArtifacts + + An array of output artifacts, specified as JavaScript objects. + + For example: + + \code + outputArtifacts: [{ + filePath: "myfile.cpp", + fileTags: ["cpp"], + cpp: { cxxLanguageVersion: "c++11" } + }] + \endcode + + For a description of the possible properties, see the documentation of the + \l{Artifact} item. + + Output artifacts can be specified either by this property or by \l{Artifact} + items. Use this property if the set of outputs is not fixed but depends the + input's content. If no file tags are provided, \QBS will apply all + \l{FileTagger}{file taggers} known in the current context to the output file + name. + + The user may set the property \c{explicitlyDependsOn} on artifact objects, which is + similar to \l{Rule::explicitlyDependsOn}{Rule.explicitlyDependsOn}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Rule::outputFileTags + + If output artifacts are specified by \l{outputArtifacts}, this property must + specify a list of file tags that the rule potentially produces. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Rule::condition + + If \c true, the rule is enabled, otherwise it does nothing. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty stringList Rule::explicitlyDependsOn + + A list of file tags. Each artifact that matches the file tags is added to + the dependencies of each output node. All artifacts in the current product + are considered. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Rule::explicitlyDependsOnFromDependencies + + A list of file tags. Each artifact that matches the file tags is added to + the dependencies of each output node. Only target artifacts of products that this product + depends on are considered. + + \nodefaultvalue + \since Qbs 1.12 +*/ + +/*! + \qmlproperty script Rule::prepare + + A script that prepares the commands to transform the inputs to outputs. + + The code in this script is treated as a function with the signature + \c{function(project, product, inputs, outputs, input, output, explicitlyDependsOn)}. + + The argument \c{input} is \c{undefined} if there's more than one input + artifact for this rule. Similarly, \c{output} is only defined if there is + exactly one output artifact. + + \nodefaultvalue + +*/ + +/*! + \qmlproperty bool Rule::requiresInputs + + Specifies whether a rule's commands should be created even if no inputs are + available. + + Enabling this property can be useful if you are not sure whether input + files exist, and you want \QBS to create an output file even if they do not. + + Set to \c true if the rule declares any inputs, \c false otherwise. +*/ + +/*! + \qmlproperty bool Rule::alwaysRun + + If \c true, the rule's commands are always executed, even if all output + artifacts are up to date. + + \defaultvalue \c false +*/ diff --git a/doc/reference/items/language/scanner.qdoc b/doc/reference/items/language/scanner.qdoc new file mode 100644 index 00000000..d3758ef6 --- /dev/null +++ b/doc/reference/items/language/scanner.qdoc @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Rule + \nextpage SubProject + \qmltype Scanner + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.Scanner + + \brief Creates custom dependency scanners in modules. + + A Scanner item can appear inside a \l{Module} item, and allows to extract + dependencies for artifacts from the artifacts' file contents. + For example, this is what a scanner for "qrc" files might look like: + \code + import qbs.Xml + + Module { + Scanner { + inputs: 'qrc' + scan: { + var xml = new Xml.DomDocument(input.filePath); + dependencies = []; + // retrieve entries from the XML document + return dependencies; + } + } + } + \endcode +*/ + +/*! + \qmlproperty bool Scanner::condition + + If \c true, the scanner is enabled, otherwise it does nothing. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty stringList Scanner::inputs + + A list of \l{FileTagger}{file tags} the input artifacts must match. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Scanner::recursive + + Determines whether to scan the returned dependencies using + the same scanner. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty script Scanner::searchPaths + + A script that returns the paths where to look for dependencies. + + The code in this script is treated as a function with the signature + \c{function(project, product, input)}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty script Scanner::scan + + A script that reads the input artifact and returns a string list with + dependencies. + + The code in this script is treated as a function with the signature + \c{function(project, product, input, filePath)}, where \c input is + the artifact at which the scan originated, and \c filePath is the + currently scanned file. For non-recursive scans, \c filePath is + always equal to \c{input.filePath}. + + + \nodefaultvalue +*/ diff --git a/doc/reference/items/language/subproject.qdoc b/doc/reference/items/language/subproject.qdoc new file mode 100644 index 00000000..d2bf018a --- /dev/null +++ b/doc/reference/items/language/subproject.qdoc @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage Scanner + \qmltype SubProject + \inqmlmodule QbsLanguageItems + \ingroup list-of-items + \keyword QML.SubProject + + \brief Adds a project from a different file. + + A SubProject item is used to add a sub-project that is defined in + a separate file. Additionally, properties of the sub-project can + be set without modifying the separate project file. + + The following example adds a sub-project defined in + \c{subdir/project.qbs} and overrides its name. + + \code + Project { + SubProject { + filePath: "subdir/project.qbs" + Properties { + name: "A sub-project" + } + } + ... + } + \endcode + + A typical use case for SubProject items is to conditionally + include sub-projects. The following example pulls in the \e{tests} + sub-project if and only if the \c{withTests} property is \c{true}. + + \code + Project { + property bool withTests: false + SubProject { + filePath: "tests/tests.qbs" + Properties { + condition: parent.withTests + } + } + ... + } + \endcode + + If you do not need to set any properties on the sub-project, you can also + use the \l{Project::references}{Project.references} property, the same way + you would for a product. + + \code + Project { + references: "subdir/project.qbs" + } + \endcode + + is equivalent with + + \code + Project { + SubProject { + filePath: "subdir/project.qbs" + } + } + \endcode + + It is also possible to nest \l{Project} items directly in the same file. +*/ + +/*! + \qmlproperty bool SubProject::condition + + Whether the sub-project is added. If \c false, the sub-project is not + included. + + Setting this property has the same effect as setting the \c{condition} + property within a \l{Properties} item. If both this property and the + \c{condition} property within a \l{Properties} item are defined, the + sub-project is included only if both properties evaluate to \c{true}. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty path SubProject::filePath + + The file path of the project to add as a sub-project. If the top-level item + in this file is a \l{Product}, it gets wrapped automatically in a new project. + + \defaultvalue empty +*/ + +/*! + \qmlproperty bool SubProject::inheritProperties + + Determines whether the sub-project should inherit the properties of the + surrounding \l{Project}. You can use this feature to share global + settings between projects and sub-projects. + + \defaultvalue \c true +*/ diff --git a/doc/reference/items/probe/binary-probe.qdoc b/doc/reference/items/probe/binary-probe.qdoc new file mode 100644 index 00000000..7c8cd2f4 --- /dev/null +++ b/doc/reference/items/probe/binary-probe.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype BinaryProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.BinaryProbe + \inherits PathProbe + + \brief Locates executable files outside the project. + + Finds executable files that have the specified file names. + + BinaryProbe searches for executable files within directories specified by the PATH environment + variable. + + \note On Unix, also searches in the \c /usr/bin and \c /usr/local/bin directories by default. + Override \l {PathProbe::platformSearchPaths}{PathProbe.platformSearchPaths} to change this + behavior. + + \note On Windows, only files that have \e .com, \e .exe, \e .bat, \e .cmd extensions are + considered \e executables. Override \l {PathProbe::nameSuffixes}{PathProbe.nameSuffixes} to + change this behavior. + + For example, BinaryProbe can be used to search for a protobuf compiler executable as follows: + + \code + import qbs.File + import qbs.Probes + + Module { + // search for a protoc executable + Probes.BinaryProbe { + id: protocProbe + names: "protoc" + } + property string executableFilePath: protocProbe.filePath + + validate: { + if (!File.exists(executableFilePath)) + throw "The executable '" + executableFilePath + "' does not exist."; + } + + // use the found executable + Rule { + // rule input/outputs here... + + // run executable + prepare: { + var args = // initialize arguments... + var cmd = new Command(executableFilePath, args); + cmd.highlight = "codegen"; + cmd.description = "generating protobuf files for " + input.fileName; + return [cmd]; + } + } + } + \endcode +*/ diff --git a/doc/reference/items/probe/conanfile-probe.qdoc b/doc/reference/items/probe/conanfile-probe.qdoc new file mode 100644 index 00000000..cc91b923 --- /dev/null +++ b/doc/reference/items/probe/conanfile-probe.qdoc @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Richard Weickelt +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype ConanfileProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.ConanfileProbe + + \brief Extracts information about dependencies from a Conan recipe file. + + The \c ConanfileProbe interfaces \QBS to the \l{https://conan.io/}{Conan + package manager}. It runs + \l{https://docs.conan.io/en/latest/reference/commands/consumer/install.html}{conan + install} on a Conan recipe file such as \c conanfile.py or \c conanfile.txt + and extracts all available meta information about package dependencies using + the \l{https://docs.conan.io/en/latest/reference/generators/json.html}{json + generator}. The output may be used to set up \l{Profile} items or module + properties in products. \c ConanfileProbe can also be used to run other + Conan generators and to retrieve their output. + + \section1 Examples + + In the following examples we assume that our project contains a \c conanfile.py. + This file describes all dependencies of our project. The dependency packages are + expected to export meta information to be consumed by our project. + + \section2 Including Files Generated by Conan + + Conan has a built-in + \l{https://docs.conan.io/en/latest/reference/generators/qbs.html}{qbs + generator} that creates a project file containing dummy products. This is + the easiest way to access dependencies, but also the least flexible one. It + requires each Conan package to export correct meta information and works only + if the dependency is a library. + + \qml + import qbs.Probes + + Project { + Probes.ConanfileProbe { + id: conan + conanfilePath: project.sourceDirectory + "/conanfile.py" + generators: "qbs" + } + + references: conan.generatedFilesPath + "/conanbuildinfo.qbs" + + CppApplication { + type: "application" + files: "main.cpp" + Depends { name: "mylib" } + } + } + \endqml + + \section2 Setting Module Properties in Products + + When a product depends on a Conan package that does not have a + dedicated \l{List of Modules}{module}, package meta information may be + directly fed into the \l{cpp} module. + + This approach is very flexible. + + \qml + import qbs.Probes + + CppApplication { + Probes.ConanfileProbe { + id: conan + conanfilePath: product.sourceDirectory + "/conanfile.py" + options: ({opt1: "True"; opt2: "TheValue"}) + } + cpp.includePaths: conan.dependencies["myLib"].include_paths + cpp.libraryPaths: conan.dependencies["myLib"].lib_paths + cpp.dynamicLibraries: conan.dependencies["mylib"].libs + } + \endqml + + \section2 Setting Up a Profile + + When multiple products depend on one or more Conan packages, the dependency + information may be combined in a \l{Profile}. This is especially useful when + \QBS modules are available for some of the packages, but some of their + properties need to be initialized. Otherwise, it would have to be done + manually in global profiles. + + \qml + import qbs.Probes + + Project { + Probes.ConanfileProbe { + id: conan + conanfilePath: project.sourceDirectory + "/conanfile.py" + } + Profile { + name: "arm-gcc" + cpp.toolchainInstallPath: conan.dependencies["arm-none-eabi-gcc"].rootpath + "/bin" + cpp.toolchainPrefix: "arm-linux-gnueabi-" + qbs.toolchainType: "gcc" + } + } + \endqml + + This allows fully automated dependency management, including compiler + toolchains and is very useful when teams work in heterougeneous + environments. + +*/ + +/*! + \qmlproperty stringList ConanfileProbe::additionalArguments + + Additional command line arguments that are appended to the \c{conan install} + command. + + \defaultvalue [] +*/ + +/*! + \qmlproperty path ConanfileProbe::conanfilePath + + Path to a \c conanfile.py or \c conanfile.txt that is used by this probe. + + This property cannot be set at the same time as \l{ConanfileProbe::}{packageReference}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var ConanfileProbe::dependencies + + This property contains the same information as + \l{ConanfileProbe::}{json}.dependencies, but instead of an array, \c + dependencies is a map with package names as keys for convenient access. + + \readonly + \nodefaultvalue +*/ + +/*! + \qmlproperty path ConanfileProbe::executable + + The name of or the path to the Conan executable. + + \defaultvalue "conan.exe" on Windows, "conan" otherwise +*/ + +/*! + \qmlproperty path ConanfileProbe::generatedFilesPath + + The path of the folder where Conan generators store their files. Each + instance of this probe creates a unique folder under + \l{Project::buildDirectory}{Project.buildDirectory}. The folder name is a + hash of the arguments supplied to \c{conan install}. + + \readonly + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList ConanfileProbe::generators + + Conan generators to be executed by this probe. The + \l{https://docs.conan.io/en/latest/reference/generators/json.html}{JSON + generator} is always enabled. Generated files are written to the + \l{ConanfileProbe::generatedFilesPath}{generatedFilesPath} folder. + + \sa {https://docs.conan.io/en/latest/reference/generators.html}{Available + generators} + + \defaultvalue ["json"] +*/ + +/*! + \qmlproperty var ConanfileProbe::json + + The parsed output of Conan's + \l{https://docs.conan.io/en/latest/reference/generators/json.html}{JSON + generator} as a JavaScript object. + + \readonly + \nodefaultvalue +*/ + +/*! + \qmlproperty var ConanfileProbe::options + + Options applied to \c{conan install} via the \c{-o} flag. + This property is an object in the form \c{key:value}. + + Example: + \qml + options: ({someOpt: "True", someOtherOpt: "TheValue"}) + \endqml + + \nodefaultvalue +*/ + +/*! + \qmlproperty string ConanfileProbe::packageReference + + Reference of a Conan package in the form \c{name/version@user/channel}. + Use this property if you want to probe an existing package in the local + cache or on a remote. + + This property cannot be set at the same time as \l{ConanfileProbe::}{conanfilePath}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var ConanfileProbe::settings + + Settings applied to \c{conan install} via the \c{-s} flag. + This property is an object in the form \c{key:value}. + + Example: + \qml + settings: ({os: "Linux", compiler: "gcc"}) + \endqml + + \nodefaultvalue +*/ + +/*! + \qmlproperty var ConanfileProbe::verbose + + Set to \c{true} to print all output of `conan install`. + If this property is \c{false} only error output will be printed. + + \defaultvalue \c{false} +*/ diff --git a/doc/reference/items/probe/dmc-probe.qdoc b/doc/reference/items/probe/dmc-probe.qdoc new file mode 100644 index 00000000..36d99cf9 --- /dev/null +++ b/doc/reference/items/probe/dmc-probe.qdoc @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype DmcProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.DmcProbe + \inherits PathProbe + \brief Collects Digital Mars toolchain compiler information. + \since Qbs 1.13 + \internal + + Detects the version, supported architecture, the platform + endianness, and other stuff for the specified compiler executable + from the \l{https://www.digitalmars.com/}{Digital Mars} toolchain. +*/ + +/*! + \qmlproperty string DmcProbe::compilerFilePath + + An input property which is a full path to the Digital Mars compiler + executable. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string DmcProbe::architecture + + Detected architecture of the target platform's processor. + + The possible values are \c "x86" and \c "x86_16". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string DmcProbe::targetPlatform + + Detected target platform. + + The possible values are \c "windows" and \c "dos". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int DmcProbe::versionMajor + + Detected major compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int DmcProbe::versionMinor + + Detected minor compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int DmcProbe::versionPatch + + Detected patch compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList DmcProbe::includePaths + + Detected compiler include paths. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var DmcProbe::compilerDefinesByLanguage + + Detected set of compiler pre-defined macros depending + on the \c "C" or \c "C++" language. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/probe/framework-probe.qdoc b/doc/reference/items/probe/framework-probe.qdoc new file mode 100644 index 00000000..89986f48 --- /dev/null +++ b/doc/reference/items/probe/framework-probe.qdoc @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype FrameworkProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.FrameworkProbe + \inherits PathProbe + + \brief Locates \macos frameworks outside the project. + + Finds \macos frameworks that have the specified file names. + + By default, FrameworkProbe searches for frameworks in \c ~/Library/Frameworks, + \c /usr/local/lib, \c /Library/Frameworks, and in \c /System/Library/Frameworks. + + Also, if \l {qbs::sysroot}{qbs.sysroot} is specified (for example, when compiling using XCode + SDK), the probe searches in the \c sysroot/System/Library/Frameworks folder first. + + For example, a simple FrameworkProbe that searches for the Foundation framework can be used as + follows: + + \code + import qbs.Probes + Product { + Depends { name: "cpp"; } + Probes.FrameworkProbe { + id: foundationProbe + names: ["Foundation"] + } + cpp.frameworkPaths: foundationProbe.found ? [foundationProbe.path] : [] + } + \endcode +*/ diff --git a/doc/reference/items/probe/iar-probe.qdoc b/doc/reference/items/probe/iar-probe.qdoc new file mode 100644 index 00000000..387e70b8 --- /dev/null +++ b/doc/reference/items/probe/iar-probe.qdoc @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \qmltype IarProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.IarProbe + \inherits PathProbe + \brief Collects IAR toolchain compiler information. + \since Qbs 1.13 + \internal + + Detects the version, supported architecture and the platform + endianness of the specified compiler executable file from the + \l{https://www.iar.com/}{IAR} toolchain. +*/ + +/*! + \qmlproperty string IarProbe::compilerFilePath + + An input property which is a full path to the IAR compiler executable file. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string IarProbe::architecture + + Detected architecture of the target platform's processor. + + The possible values are \c "arm", \c "mcs51", \c "avr", \c "avr32", + \c "stm8", \c "riscv", \c "rl78", \c "rx", \c "rh850", \c "v850", + \c "78k", \c "sh", \c "r32c", \c "m32c", \c "m16c", \c "msp430", + \c "hcs12", \c "hcs8", \c "m68k", and \c "cr16". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string IarProbe::endianness + + Detected endianness of the target platform's processor architecture. + + The possible values are \c "big" or \c "little". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int IarProbe::versionMajor + + Detected major compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int IarProbe::versionMinor + + Detected minor compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int IarProbe::versionPatch + + Detected patch compiler version. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/probe/include-probe.qdoc b/doc/reference/items/probe/include-probe.qdoc new file mode 100644 index 00000000..eb8fcf8b --- /dev/null +++ b/doc/reference/items/probe/include-probe.qdoc @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype IncludeProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.IncludeProbe + \inherits PathProbe + + \brief Locates header files outside the project. + + This is the convenience item that searches for files in "include" directories. + + For example, IncludeProbe can be used to search for a zlib header as follows: + + \code + import qbs.Probes + + CppApplication { + Probes.IncludeProbe { + id: zlibProbe + names: "zlib.h" + } + cpp.includePaths: zlibProbe.found ? [zlibProbe.path] : [] + files: 'main.cpp' + } + \endcode +*/ diff --git a/doc/reference/items/probe/keil-probe.qdoc b/doc/reference/items/probe/keil-probe.qdoc new file mode 100644 index 00000000..b4b56e0a --- /dev/null +++ b/doc/reference/items/probe/keil-probe.qdoc @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \qmltype KeilProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.KeilProbe + \inherits PathProbe + \brief Collects KEIL toolchain compiler information. + \since Qbs 1.13 + \internal + + Detects the version, supported architecture and the platform + endianness of the specified compiler executable file from the + \l{https://www.keil.com/}{KEIL} toolchain. +*/ + +/*! + \qmlproperty string KeilProbe::compilerFilePath + + An input property which is a full path to the KEIL compiler executable file. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string KeilProbe::architecture + + Detected architecture of the target platform's processor. + + The possible values are \c "arm", \c "mcs51", \c "mcs251" and \c "c166". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string KeilProbe::endianness + + Detected endianness of the target platform's processor architecture. + + The possible values are \c "big" or \c "little". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int KeilProbe::versionMajor + + Detected major compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int KeilProbe::versionMinor + + Detected minor compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int KeilProbe::versionPatch + + Detected patch compiler version. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/probe/library-probe.qdoc b/doc/reference/items/probe/library-probe.qdoc new file mode 100644 index 00000000..458e3679 --- /dev/null +++ b/doc/reference/items/probe/library-probe.qdoc @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype LibraryProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.IncludeProbe + \inherits PathProbe + + \brief Locates library files outside the project. + + On Windows, searches for library files within directories specified by the \c PATH environment + variable. + + On Unix, searches for library files within directories specified by the \c LIBRARY_PATH + environment variable, as well as in \c "/usr/lib" and \c "/usr/local/lib". + + On Linux, also searches in platform-specific directories, such as \c "/usr/lib64" and + \c "/usr/lib/x86_64-linux-gnu". + + For example, LibraryProbe can be used to search for a \c zlib library as follows: + + \code + import qbs.Probes + + CppApplication { + Probes.LibraryProbe { + id: zlibProbe + names: "z" + } + cpp.libraryPaths: zlibProbe.found ? [zlibProbe.path] : [] + cpp.dynamicLibraries: zlibProbe.found ? [zlibProbe.names] : [] + files: 'main.cpp' + } + \endcode +*/ diff --git a/doc/reference/items/probe/path-probe.qdoc b/doc/reference/items/probe/path-probe.qdoc new file mode 100644 index 00000000..729f11dd --- /dev/null +++ b/doc/reference/items/probe/path-probe.qdoc @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \qmltype PathProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.PathProbe + + \brief Locates files outside the project. + + Finds files that have the specified file name suffix, such as \e .exe, from the specified + locations. + + PathProbe takes as input lists of paths to search files from and file name patterns. The paths + are specified by using the environmentPaths, searchPaths, platformEnvironmentPaths and + platformSearchPaths properties; the path are searched in the same order as listed. The file + name patterns are specified by the \l names and nameSuffixes properties. Returns the first file + that matches the file name patterns. If no such file is found, the + \l {Probe::found}{probe.found} property is set to \c false. + + For example, a simple PathProbe that searches for the stdio.h header can be used as follows: + + \code + Product { + Depends { name: "cpp" } + PathProbe { + id: probe + pathSuffixes: ["include"] + names: ["stdio.h"] + } + cpp.includePaths: probe.found ? [probe.path] : [] + } + \endcode +*/ + +/*! + \qmlproperty varList PathProbe::allResults + + This property contains the list of objects, each object representing a single found file: + \code + { + found: true, + candidatePaths: ["path1/to/file", "path2/to/file", ...] + filePath: "path/to/file" + fileName: "file" + path: "path/to" + } + \endcode + \sa {PathProbe::filePath}{filePath}, {PathProbe::fileName}{fileName}, + {PathProbe::path}{path} +*/ + +/*! + \qmlproperty var PathProbe::candidateFilter + + This property holds the function that can be used to filter out unsuitable candidates. + For example, when searching for a library, it might be necessary to check its architecture: + \code + PathProbe { + pathSuffixes: [".so", ".dll", ".dylib"] + candidateFilter: { + function getLibraryArchitecture(file) { ... } + return function(file) { + return Utilities.isSharedLibrary(file) + && getLibraryArchitecture(file) == qbs.architecture; + } + } + } + \endcode +*/ + +/*! + \qmlproperty stringList PathProbe::names + + The list of file names to search for. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PathProbe::nameSuffixes + + The list of file suffixes to search for. These suffixes are appended to every file name passed + via the \l names property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty script PathProbe::nameFilter + + A script that is executed for each file name before prepending file suffixes. Can be used to + transform file names. +*/ + +/*! + \qmlproperty pathList PathProbe::searchPaths + + The list of paths where to search files. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList PathProbe::platformSearchPaths + + The list of platform paths where to search files. + + \defaultvalue \c {['/usr', '/usr/local']} on Unix hosts, empty otherwise +*/ + +/*! + \qmlproperty stringList PathProbe::pathSuffixes + + A list of relative paths that are appended to each path where PathProbe searches for files. + That is, the file should be located within one of the subfolders passed using this + property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PathProbe::environmentPaths + + The list of environment variables that contains paths where to search files. Paths in the + environment variable should be separated using + \l{pathListSeparator}{FileInfo.pathListSeparator()}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PathProbe::platformEnvironmentPaths + + The list of platform environment variables that contains paths where to search files. Paths in + the environment variable should be separated using + \l{pathListSeparator}{FileInfo.pathListSeparator()}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PathProbe::candidatePaths + + This property contains the result list of all paths that were checked before a file was found + (including the file names). + + This property is set even if the Probe didn't find anything and can be used to give the user + a hint what went wrong: + \code + Module { + Probes.BinaryProbe { + id: pythonProbe + names: "python" + } + validate: { + if (!pythonProbe.found) { + throw ModUtils.ModuleError( + "Could not find python binary at any of the following locations:\n\t" + + pythonProbe.candidatePaths.join("\n\t")); + } + } + } + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PathProbe::path + + This property contains the full path where the found file is located + (that is, the file directory). + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PathProbe::filePath + + This property contains the full path to the found file, including the file name. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PathProbe::fileName + + This property contains the found file's name (excluding the path). + + \nodefaultvalue +*/ + +/*! + \qmlproperty varList PathProbe::selectors + + This property should be used to search for multiple files. It contains the list of selectors + each of which describes a single file to search for. A selector can be either a string, a + stringList, or a dictionary. + + The following example searches for three files and illustrates different ways to specify + selectors: + \code + selectors: [ + // 1st file with a single name + "header.h", + // 2nd file with possible name variants + ["config.h", "foo-config.h", "bar-config.h"], + // 3rd file with possible name and suffix variants + {names: ["footk", "footk-version"], nameSuffixes: [".h", ".hpp"]} + ] + \endcode +*/ diff --git a/doc/reference/items/probe/pkgconfig-probe.qdoc b/doc/reference/items/probe/pkgconfig-probe.qdoc new file mode 100644 index 00000000..22fd510a --- /dev/null +++ b/doc/reference/items/probe/pkgconfig-probe.qdoc @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype PkgConfigProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.PkgConfigProbe + + \brief Retrieves the information about installed packages using the pkg-config binary. + + This probe takes the package name or the list of package names as input and returns the + information that is required to compile and link using those packages. + + Usually, you can simply use a Depends item as described in + \l{How do I build against libraries that provide pkg-config files?}. + + Alternatively, the probe can be used directly as follows: + + \code + CppApplication { + name: project.name + Probes.PkgConfigProbe { + id: pkgConfig + name: "QtCore" + minVersion: '4.0.0' + maxVersion: '5.99.99' + } + files: 'main.cpp' + cpp.cxxFlags: pkgConfig.cflags + cpp.linkerFlags: pkgConfig.libs + } + \endcode +*/ + +/*! + \qmlproperty string PkgConfigProbe::sysroot + + This property sets the value of the \c PKG_CONFIG_SYSROOT_DIR environment variable passed to + the \c pkg-config binary. This variable modifies -I and -L flags to use the directories located + in target sysroot. + + This property is useful when cross-compiling packages that use \c pkg-config to determine CFLAGS + and LDFLAGS. For example, if \c sysroot is set to \c /var/target, a \c -I/usr/include/libfoo + will become \c -I/var/target/usr/include/libfoo. + + \defaultvalue \c qbs.sysroot +*/ + +/*! + \qmlproperty string PkgConfigProbe::executable + + The name of or the path to the pkg-config executable. + + \defaultvalue "pkg-config" +*/ + +/*! + \qmlproperty string PkgConfigProbe::name + + The name this probe. This property is used as + \l{PkgConfigProbe::packageNames}{PkgConfigProbe.packageNames} value by default. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::packageNames + + The list of package names to pass to the pkg-config executable. For each package, pkg-config + will return the information required to compile and link to this package. + + \defaultvalue [\l{PkgConfigProbe::name}{PkgConfigProbe.name}] +*/ + +/*! + \qmlproperty string PkgConfigProbe::minVersion + + The minimum version of the required package. If set, pkg-config will ignore packages with + version less than the value of this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PkgConfigProbe::exactVersion + + The exact version of the required package. If set, pkg-config will ignore packages with + version that is not equal to the value of this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string PkgConfigProbe::maxVersion + + The maximum version of the required package. If set, pkg-config will ignore packages with + version greater than the value of this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool PkgConfigProbe::forStaticBuild + + If \c true, pkg-config will return linker flags for a static linking instead of dynamic. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::libDirs + + List of full, non-sysrooted paths where pkg-config should search for .pc files. This overrides + the built-in path (which is usually /usr/lib/pkgconfig). + + This property sets the value of the \c PKG_CONFIG_LIBDIR environment variable passed to + the \c pkg-config binary. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::cflags + + \internal + + This property contains the unparsed output from "pkg-config --cflags" call. Usually, you should + use \l{PkgConfigProbe::defines}{PkgConfigProbe.defines}, + \l{PkgConfigProbe::includePaths}{PkgConfigProbe.includePaths} and + \l{PkgConfigProbe::compilerFlags}{PkgConfigProbe.compilerFlags} properties instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::libs + + \internal + + This property contains the unparsed output from "pkg-config --libs" call. Usually, you should + use \l{PkgConfigProbe::libraries}{PkgConfigProbe.libraries}, + \l{PkgConfigProbe::libraryPaths}{PkgConfigProbe.libraryPaths} and + \l{PkgConfigProbe::linkerFlags}{PkgConfigProbe.linkerFlags} properties instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::defines + + This output property contains the list of defines that should be passed to a compiler when + using requested package. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::libraries + + This output property contains the list of library names that should be passed to a linker when + using requested package. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::libraryPaths + + This output property contains the list of library paths that should be passed to a linker when + using requested package. + + This property sets the value of the PKG_CONFIG_LIBDIR environment variable passed to + the \c pkg-config binary. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::includePaths + + This output property contains the list of include paths that should be passed to a compiler when + using requested package. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::compilerFlags + + This output property contains the list of flags that should be passed to a compiler when + using requested package. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::linkerFlags + + This output property contains the list of flags that should be passed to a linker when + using requested package. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList PkgConfigProbe::modversion + + This output property contains the version of the found package. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/probe/sdcc-probe.qdoc b/doc/reference/items/probe/sdcc-probe.qdoc new file mode 100644 index 00000000..06cb0689 --- /dev/null +++ b/doc/reference/items/probe/sdcc-probe.qdoc @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \qmltype SdccProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.SdccProbe + \inherits PathProbe + \brief Collects SDCC toolchain compiler information. + \since Qbs 1.14 + \internal + + Detects the version, supported architecture and the platform + endianness of the specified compiler executable file from the + \l{http://sdcc.sourceforge.net/}{SDCC} toolchain. +*/ + +/*! + \qmlproperty string SdccProbe::compilerFilePath + + An input property which is a full path to the SDCC compiler executable file. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string SdccProbe::architecture + + Detected architecture of the target platform's processor. + + The possible values are \c "mcs51", \c "stm8", and \c "hcs8". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string SdccProbe::endianness + + Detected endianness of the target platform's processor architecture. + + The possible values are \c "little". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int SdccProbe::versionMajor + + Detected major compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int SdccProbe::versionMinor + + Detected minor compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int SdccProbe::versionPatch + + Detected patch compiler version. + + \nodefaultvalue +*/ diff --git a/doc/reference/items/probe/watcom-probe.qdoc b/doc/reference/items/probe/watcom-probe.qdoc new file mode 100644 index 00000000..8f06be97 --- /dev/null +++ b/doc/reference/items/probe/watcom-probe.qdoc @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype WatcomProbe + \inqmlmodule QbsProbes + \ingroup list-of-items + \keyword QML.WatcomProbe + \inherits PathProbe + \brief Collects Oopen Watcom toolchain compiler information. + \since Qbs 1.22 + \internal + + Detects the version, supported architecture, the platform + endianness, and other stuff for the specified compiler executable + from the \l{https://github.com/open-watcom}{Open Watcom} toolchain. +*/ + +/*! + \qmlproperty string WatcomProbe::compilerFilePath + + An input property which is a full path to the Digital Mars compiler + executable. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string WatcomProbe::architecture + + Detected architecture of the target platform's processor. + + The possible values are \c "x86" and \c "x86_16". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string WatcomProbe::endianness + + Detected endianness of the target platform's processor architecture. + + The possible values are \c "big" and \c "little". + + \nodefaultvalue +*/ + +/*! + \qmlproperty string WatcomProbe::targetPlatform + + Detected target platform. + + The possible values are \c "windows", \c "linux", \c "os2" and \c "dos". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int WatcomProbe::versionMajor + + Detected major compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int WatcomProbe::versionMinor + + Detected minor compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int WatcomProbe::versionPatch + + Detected patch compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList WatcomProbe::includePaths + + Detected compiler include paths. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var WatcomProbe::compilerDefinesByLanguage + + Detected set of compiler pre-defined macros depending + on the \c "C" or \c "C++" language. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var WatcomProbe::environment + + Detected compiler run environment. + + \nodefaultvalue +*/ diff --git a/doc/reference/jsextensions/jsextension-binaryfile.qdoc b/doc/reference/jsextensions/jsextension-binaryfile.qdoc new file mode 100644 index 00000000..c8c3bd4b --- /dev/null +++ b/doc/reference/jsextensions/jsextension-binaryfile.qdoc @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Sergey Belyashov +** Copyright (C) 2017 Denis Shienkov +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-binaryfile.html + \ingroup list-of-builtin-services + + \title BinaryFile Service + \brief Provides read and write operations on binary files. + + The \c BinaryFile service allows you to read from and write into binary files. + + \section1 Related Declarations + + \section2 BinaryFile.OpenMode + \code + enum BinaryFile.OpenMode { ReadOnly, WriteOnly, ReadWrite } + \endcode + List of modes that a file may be opened in. + + The OpenMode values can be combined with the bitwise or operator. + + \section1 Available operations + + \section2 Constructor + \code + BinaryFile(filePath: string, openMode: OpenMode = BinaryFile.ReadOnly) + \endcode + Opens the file at \c filePath in the given mode and returns the object representing the file. + \note The mode influences which of the operations listed below can actually be used on the file. + + \section2 atEof + \code + atEof(): boolean + \endcode + Returns \c{true} if no more data can be read from the file, \c{false} otherwise. + + \section2 close + \code + close(): void + \endcode + Closes the file. It is recommended to always call this function as soon as you are finished + with the file, in order to keep the number of in-flight file descriptors as low as possible. + + \section2 filePath + \code + filePath(): string + \endcode + The absolute path of the file represented by this object. + + \section2 size + \code + size(): number + \endcode + Returns the size of the file (in bytes). + + \section2 resize + \code + resize(size: number): void + \endcode + Sets the file \c size (in bytes). If \c size is larger than the file currently is, the new + bytes will be set to 0; if \c size is smaller, the file is truncated. + + \section2 pos + \code + pos(): number + \endcode + Returns the position that data is written to or read from. + + \section2 seek + \code + seek(pos: number): void + \endcode + Sets the current position to \c pos. + + \section2 read + \code + read(size: number): number[] + \endcode + Reads at most \c size bytes of data from the file and returns it as an array. + + \section2 write + \code + write(data: number[]): void + \endcode + Writes \c data into the file at the current position. +*/ diff --git a/doc/reference/jsextensions/jsextension-environment.qdoc b/doc/reference/jsextensions/jsextension-environment.qdoc new file mode 100644 index 00000000..465a157a --- /dev/null +++ b/doc/reference/jsextensions/jsextension-environment.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-environment.html + \ingroup list-of-builtin-services + + \title Environment Service + \brief Provides operations on the system environment. + + The \c Environment service offers access to the system environment or process environment. + + \section1 Available Operations + + \section2 currentEnv + \code + Environment.currentEnv(): { [key: string]: string; } + \endcode + Returns the environment of \QBS in the current context as an object whose properties are + the environment variables. + + \section2 getEnv + \code + Environment.getEnv(key: string): string + \endcode + Tries to find a variable with the given name in the current context's environment and returns + its value. If no such variable could be found, \c undefined is returned. + + \section2 putEnv + \code + Environment.putEnv(key: string, value: string): void + \endcode + Sets the value of the environment variable with the given name in the build or run environment. + This method is only available in the \c Module.setupBuildEnvironment and + \c Module.setupRunEnvironment scripts. + + \section2 unsetEnv + \code + Environment.unsetEnv(key: string): void + \endcode + Unsets the environment variable with the given name from the build or run environment. + This method is only available in the \c Module.setupBuildEnvironment and + \c Module.setupRunEnvironment scripts. +*/ diff --git a/doc/reference/jsextensions/jsextension-file.qdoc b/doc/reference/jsextensions/jsextension-file.qdoc new file mode 100644 index 00000000..f0405559 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-file.qdoc @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-file.html + \ingroup list-of-builtin-services + + \title File Service + \brief Provides operations on the file system. + + The \c File service offers limited access to the file system for operations such as copying + or removing files. + + \section1 Available Operations + + \section2 copy + \code + File.copy(sourceFilePath: string, targetFilePath: string): boolean + \endcode + Copies \c sourceFilePath to \c targetFilePath. Any directory components in \c targetFilePath + that do not yet exist will be created. If \c sourceFilePath is a directory, a recursive + copy will be made. If an error occurs, a JavaScript exception will be thrown. + \note \c targetFilePath must be the counterpart of \c sourceFilePath at the new location, + \b{not} the new parent directory. This allows the copy to have a different name and is true + even if \c sourceFilePath is a directory. + \note The file is not copied if the source file timestamp is older than the destination file + timestamp. If you want to replace the newer file, you need to remove it first via + File.remove(). + + \section2 exists + \code + File.exists(filePath: string): boolean + \endcode + Returns true if and only if there is a file at \c filePath. + + \section2 directoryEntries + \code + File.directoryEntries(path: string, filter: File.Filter): string[] + \endcode + Returns a sorted list of the directory \c{path}'s contents non-recursively, + filtered by \c filter. The values of \c filter are equivalent to Qt's \c QDir::Filter. + + \section2 lastModified + \code + File.lastModified(filePath: string): number + \endcode + Returns the time of last modification for the file at \c filePath. The concrete semantics of the + returned value are platform-specific. You should only rely on the property that a smaller value + indicates an older timestamp. + + \section2 makePath + \code + File.makePath(path: string): boolean + \endcode + Makes the directory at \c path, creating intermediate directories if necessary. + Conceptually equivalent to \c{mkdir -p} + + \section2 move + \code + File.move(oldPath: string, newPath: string, overwrite: boolean = true): boolean + \endcode + Renames the file \c oldPath to \c newPath. + Returns \c true if successful; otherwise returns \c false. + If a file with the name \c newPath already exists, and \c overwrite is \c false, + \c move() returns \c false (that is, the file will not be overwritten). + + \section2 remove + \code + File.remove(filePath: string): boolean + \endcode + Removes the file at \c filePath. In case of a directory, it will be removed recursively. +*/ diff --git a/doc/reference/jsextensions/jsextension-fileinfo.qdoc b/doc/reference/jsextensions/jsextension-fileinfo.qdoc new file mode 100644 index 00000000..cb0eb7c4 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-fileinfo.qdoc @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-fileinfo.html + \ingroup list-of-builtin-services + + \title FileInfo Service + \brief Provides operations on file paths. + + The \c FileInfo service offers various operations on file paths, such as turning absolute + paths into relative ones, splitting a path into its components, and so on. + + \section1 Available Operations + + \section2 baseName + \code + FileInfo.baseName(filePath: string): string + \endcode + Returns the file name of \c filePath up to (but not including) the first '.' character. + + \section2 canonicalPath + \code + FileInfo.canonicalPath(filePath: string): string + \endcode + Returns a canonicalized \c filePath, i.e. an absolute path without symbolic + links or redundant "." or ".." elements. + On Windows, drive substitutions are also resolved. + + It is recommended to use \c{canonicalPath} in only those cases where + canonical paths are really necessary. In most cases, \c{cleanPath} should + be enough. + + \section2 cleanPath + \code + FileInfo.cleanPath(filePath: string): string + \endcode + Returns \c filePath without redundant separators and with resolved occurrences of + \c{.} and \c{..} components. For instance, \c{/usr/local//../bin/} becomes \c{/usr/bin}. + + \section2 completeBaseName + \code + FileInfo.completeBaseName(filePath: string): string + \endcode + Returns the file name of \c filePath up to (but not including) the last '.' character. + + \section2 completeSuffix + \code + FileInfo.completeSuffix(filePath: string): string + \endcode + Returns the file suffix of \c filePath from (but not including) the last '.' character. + \funsince 1.12 + + \section2 fileName + \code + FileInfo.fileName(filePath: string): string + \endcode + Returns the last component of \c filePath, that is, everything after the + last '/' character. + + \section2 fromNativeSeparators + \code + FileInfo.fromNativeSeparators(filePath: string): string + \endcode + On Windows hosts, this function behaves the same as \l fromWindowsSeparators. On other + operating systems, it returns the input unmodified. + + \section2 fromWindowsSeparators + \code + FileInfo.fromWindowsSeparators(filePath: string): string + \endcode + Returns \c filePath with all '\\' characters replaced by '/'. + + \section2 isAbsolutePath + \code + FileInfo.isAbsolutePath(filePath: string, hostOS?: string[]): boolean + \endcode + Returns true if \c filePath is an absolute path and false if it is a relative one. + If \c hostOS is specified, treats \c filePath as a file path of the kind found on that platform. + This parameter defaults to the host OS on which \QBS is running and should normally be omitted. + + \section2 joinPaths + \code + FileInfo.joinPaths(...paths: string[]): string + \endcode + Concatenates the given paths using the '/' character. + + \section2 path + \code + FileInfo.path(filePath: string, hostOS?: string[]): string + \endcode + Returns the part of \c filePath that is not the file name, that is, + everything up to + (but not including) the last '/' character. If \c filePath is just a file name, then '.' + is returned. If \c filePath ends with a '/' character, then the file name is assumed to be empty + for the purpose of the above definition. + If \c hostOS is specified, treats \c filePath as a file path of the kind found on that platform. + This parameter defaults to the host OS on which \QBS is running and should normally be omitted. + + \section2 relativePath + \code + FileInfo.relativePath(dirPath: string, filePath: string): string + \endcode + Returns a relative path so that joining \c dirPath and the returned path results in \c filePath. + If necessary, '..' components are inserted. + The function assumes \c dirPath and \c filePath to be absolute paths and \c dirPath to + be a directory. + + \section2 suffix + \code + FileInfo.suffix(filePath: string): string + \endcode + Returns the file suffix of \c filePath from (but not including) the first '.' character. + \funsince 1.12 + + \section2 toNativeSeparators + \code + FileInfo.toNativeSeparators(filePath: string): string + \endcode + On Windows hosts, this function behaves the same as \l toWindowsSeparators. On other + operating systems, it returns the input unmodified. + + \section2 toWindowsSeparators + \code + FileInfo.toWindowsSeparators(filePath: string): string + \endcode + Returns \c filePath with all '/' characters replaced by '\\'. + + \section2 pathListSeparator + \code + FileInfo.pathListSeparator(): string + \endcode + Returns the host operating system separator for a path list that is used in environment + variables or other contexts. + \funsince 1.22 + + \section2 pathSeparator + \code + FileInfo.pathSeparator(): string + \endcode + Returns the host operating system path separator. + \funsince 1.22 +*/ diff --git a/doc/reference/jsextensions/jsextension-host.qdoc b/doc/reference/jsextensions/jsextension-host.qdoc new file mode 100644 index 00000000..1dda85d1 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-host.qdoc @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Raphaël Cotty +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-host.html + \ingroup list-of-builtin-services + + \title Host Service + \brief Provides host information. + + The \c Host service offers various information about the host environment, such as operating + system names, platform name. + + \section1 Available Operations + + \section2 architecture + \code + Host.architecture(): string + \endcode + Returns the host operating system architecture. + + See \l{qbs::architecture}{qbs.architecture} for the target-specific equivalent property. + architecture. + \funsince 1.22 + + \section2 os + \code + Host.os(): string[] + \endcode + Returns the host operating system names. + + See the \l{qbs::targetOS}{qbs.targetOS} for the target-specific equivalent property. + \funsince 1.22 + + \section2 platform + \code + Host.platform(): string[] + \endcode + Returns the host operating system platform. + + See the \l{qbs::targetPlatform}{qbs.targetPlatform} for the target-specific equivalent property. + \funsince 1.22 + + + \section2 osVersion + \code + Host.osVersion(): string + \endcode + Returns the host operating system version. Currently, only defined for Windows and Apple + platforms. + + Consists of two or three numbers separated by dots. For example, \c "10.9" or \c "6.3.9600". + \funsince 1.22 + + \section2 osBuildVersion + \code + Host.osBuildVersion(): string + \endcode + Returns the host operating system build version. Currently, only defined for Windows and Apple + platforms. + + On Windows, this is the 4 or 5 digit Windows build number and is equivalent + to \l{qbs::}{versionPatch}. On Apple platforms, this is a standard build number in the Apple + versioning scheme. For example, \c "13C64". + \funsince 1.22 + + \section2 osVersionParts + \code + Host.osVersionParts(): string[] + \endcode + Returns the host operating system version as a list. + + For example, Windows 8.1 (version 6.3.9600) would correspond to a value of \c[6, 3, 9600]. + \funsince 1.22 + + \section2 osVersionMajor + \code + Host.osVersionMajor(): string[] + \endcode + Returns the host operating system major version. + \funsince 1.22 + + \section2 osVersionMinor + \code + Host.osVersionMinor(): string[] + \endcode + Returns the host operating system minor version. + \funsince 1.22 + + \section2 osVersionPatch + \code + Host.osVersionPatch(): string[] + \endcode + Returns the host operating system patch level. + \funsince 1.22 + + \section2 nullDevice + \code + Host.nullDevice(): string[] + \endcode + Returns the platform-specific file path corresponding to the null device. + \funsince 1.22 +*/ diff --git a/doc/reference/jsextensions/jsextension-process.qdoc b/doc/reference/jsextensions/jsextension-process.qdoc new file mode 100644 index 00000000..49b47f4b --- /dev/null +++ b/doc/reference/jsextensions/jsextension-process.qdoc @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-process.html + \ingroup list-of-builtin-services + + \title Process Service + \brief Allows you to start external processes. + + The \c Process service allows you to start processes, track their output, + and so on. + + \section1 Available Operations + + \section2 Constructor + \code + Process() + \endcode + Allocates and returns a new Process object. + + \section2 close + \code + close(): void + \endcode + Frees the resources associated with the process. It is recommended to always call this function as + soon as you are finished with the process. + + \section2 closeWriteChannel + \code + closeWriteChannel(): void + \endcode + Schedules the stdin channel of process to be closed. The channel will close once all data has been + written to the process. After calling this function, any attempts to write to the process will do + nothing. See \c QProcess::closeWriteChannel() for more details. + + \section2 exec + \code + exec(filePath: string, arguments: string[], throwOnError: boolean): number + \endcode + Executes the program at \c filePath with the given argument list and blocks until the + process is finished. If an error occurs (for example, there is no executable + file at \c filePath) + and \c throwOnError is true, then a JavaScript exception will be thrown. Otherwise + (the default), -1 will be returned in case of an error. The normal return code is the exit code + of the process. + + \section2 exitCode + \code + exitCode(): number + \endcode + Returns the exit code of the process. This is needed for retrieving the exit code from + processes started via \c start(), rather than \c exec(). + + \section2 getEnv + \code + getEnv(varName: string): string + \endcode + Returns the value of the variable \c varName in the process' environment. + + \section2 kill + \code + kill(): void + \endcode + Kills the process, causing it to exit immediately. + + \section2 readLine + \code + readLine(): string + \endcode + Reads and returns one line of text from the process output, without the newline character(s). + + \section2 atEnd + \code + atEnd(): boolean + \endcode + Returns true if there is no more data to be read from the process output, otherwise + returns false. + + \section2 readStdErr + \code + readStdErr(): string + \endcode + Reads and returns all data from the process' standard error channel. + + \section2 readStdOut + \code + readStdOut(): string + \endcode + Reads and returns all data from the process' standard output channel. + + \section2 setCodec + \code + setCodec(codec) + \endcode + Sets the text codec to \c codec. The codec is used for reading and writing from and to + the process, respectively. The supported codecs are the same as for \c QTextCodec, for example: + "UTF-8", "UTF-16", and "ISO 8859-1". + + \section2 setEnv + \code + setEnv(varName: string, varValue: string): string + \endcode + Sets the value of variable \c varName to \c varValue in the process environment. + This only has an effect if called before the process is started. + + \section2 setWorkingDirectory + \code + setWorkingDirectory(path: string): void + \endcode + Sets the directory the process will be started in. + This only has an effect if called before the process is started. + + \section2 start + \code + start(filePath: string, arguments: string[]): boolean + \endcode + Starts the program at \c filePath with the given list of arguments. Returns \c{true} if the + process could be started and \c{false} otherwise. + \note This call returns right after starting the process and should be used only if you need + to interact with the process while it is running. Most of the time, you want to use \c exec() + instead. + + \section2 terminate + \code + terminate(): void + \endcode + Tries to terminate the process. This is not guaranteed to make the process exit immediately; + if you need that, use \c kill(). + + \section2 waitForFinished + \code + waitForFinished(timeout: number): boolean + \endcode + Blocks until the process has finished or \c timeout milliseconds have passed (default is 30000). + Returns true if the process has finished and false if the operation has timed out. + Calling this function only makes sense for processes started via \c start() (as opposed to + \c exec()). + + \section2 workingDirectory + \code + workingDirectory(): string + \endcode + Returns the directory the process will be started in. + + \section2 write + \code + write(data: string): void + \endcode + Writes \c data into the process' input channel. + + \section2 writeLine + \code + writeLine(data: string): void + \endcode + Writes \c data, followed by the newline character(s), into the process' input channel. +*/ diff --git a/doc/reference/jsextensions/jsextension-propertylist.qdoc b/doc/reference/jsextensions/jsextension-propertylist.qdoc new file mode 100644 index 00000000..e1dad6e3 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-propertylist.qdoc @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-propertylist.html + \ingroup list-of-builtin-services + + \title PropertyList Service + \brief Provides read, write and convert operations on property list files. + + The \c PropertyList service allows you to read and write property list files in + all formats supported by the Core Foundation API: XML, binary, JSON, and OpenStep (read-only). + + This service is only available on Darwin platforms such as iOS, macOS, tvOS, and watchOS. + + \section1 Available operations + + \section2 Constructor + \code + PropertyList() + \endcode + Allocates and returns a new PropertyList object. + + \section2 clear + \code + clear(): void + \endcode + Voids the property list by deleting its internal object reference. + + \section2 isEmpty + \code + isEmpty(): boolean + \endcode + Returns true if the property list has no internal object reference set, otherwise false. + + \section2 format + \code + format(): string + \endcode + Returns the data format that the property list data was deserialized from. This property is set + after calling \c readFromString or \c readFromFile. + Possible return values include: \c "binary1", \c "json", \c "openstep", and \c "xml1". + If the property list object is empty or the input format could not be determined, + returns \c undefined. + + \section2 readFromFile + \code + readFromFile(filePath: string): void + \endcode + Parses the file and stores the result in the property list. + Throws an exception if an I/O error occurs or the input is in an invalid format. + + \section2 readFromObject + \code + readFromObject(obj: any): void + \endcode + Sets the given object as the property list's internal object. + \c format() will return \c undefined as this method does not deserialize a storage format. + + \section2 readFromString + \code + readFromString(input: string): void + \endcode + Parses \c input and stores the result in the property list. + This is most useful for initializing a property list object from the result of a + \c JSON.stringify call. + Throws an exception if the input is in an invalid format. + + \section2 toObject + \code + toObject(): any + \endcode + Returns an object representing the property list. + + \section2 toJSON + \code + toJSON(style: string = "compact"): string + \endcode + Returns a string representation of the property list in JSON format. + Possible values for \c style include \c "pretty" and \c "compact". The default is compact. + + \section2 toString + \code + toString(format: string): string + \endcode + Returns a string representation of the property list in the specified format. + Possible values for \c format include: \c "json" (compact), \c "json-compact", \c "json-pretty", + and \c "xml1". Currently, the OpenStep format is not supported. + Throws an exception if the object cannot be written in the given format. + + \section2 toXMLString + \code + toXMLString(): string + \endcode + Returns a string representation of the property list in XML format. + This function is a synonym for \c toString("xml1"). + + \section2 writeToFile + \code + writeToFile(filePath: string, format: string): void + \endcode + Writes the property list to the file in the given format. + Possible values for \c format include: \c "binary1", \c "json" (compact), \c "json-compact", + \c "json-pretty", and \c "xml1". Currently, the OpenStep format is not supported for writing. + Throws an exception if an I/O error occurs or the object cannot be written in the given format. +*/ diff --git a/doc/reference/jsextensions/jsextension-temporarydir.qdoc b/doc/reference/jsextensions/jsextension-temporarydir.qdoc new file mode 100644 index 00000000..29f62725 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-temporarydir.qdoc @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-temporarydir.html + \ingroup list-of-builtin-services + + \title TemporaryDir Service + \brief Creates a unique directory for temporary use. + + The \c TemporaryDir service creates a unique directory for temporary use. + + \section1 Available Operations + + \section2 Constructor + \code + TemporaryDir() + \endcode + Allocates and returns a new TemporaryDir object. + This method creates the temporary directory. + + \section2 isValid + \code + isValid(): boolean + \endcode + Returns \c true if the temporary directory was created successfully. + + \section2 path + \code + path(): string + \endcode + Returns the path to the temporary directory. + Empty if the temporary directory could not be created. + + \section2 remove + \code + remove(): boolean + \endcode + Removes the temporary directory, including all its contents. + Returns \c true if removing was successful. + It is recommended to always call this function as soon as you are finished with the temporary + directory. The directory will not be removed automatically. +*/ diff --git a/doc/reference/jsextensions/jsextension-textfile.qdoc b/doc/reference/jsextensions/jsextension-textfile.qdoc new file mode 100644 index 00000000..b2cf2c72 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-textfile.qdoc @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-textfile.html + \ingroup list-of-builtin-services + + \title TextFile Service + \brief Provides read and write operations on text files. + + The \c TextFile service allows you to read from and write into text files. + + \section1 Related Declarations + + \section2 TextFile.OpenMode + \code + enum TextFile.OpenMode { ReadOnly, WriteOnly, ReadWrite, Append } + \endcode + List of modes that a file may be opened in. + + The OpenMode values can be combined with the bitwise or operator. + + \section1 Available operations + + \section2 Constructor + \code + TextFile(filePath: string, openMode: OpenMode = TextFile.ReadOnly) + \endcode + Opens the file at \c filePath in the given mode and returns the object representing the file. + \note The mode influences which of the operations listed below can actually be used on the file. + + \section2 atEof + \code + atEof(): boolean + \endcode + Returns \c{true} if no more data can be read from the file, \c{false} otherwise. + + \section2 close + \code + close(): void + \endcode + Closes the file. It is recommended to always call this function as soon as you are finished + with the file, in order to keep the number of in-flight file descriptors as low as possible. + + \section2 filePath + \code + filePath(): string + \endcode + The absolute path of the file represented by this object. + + \section2 readAll + \code + readAll(): string + \endcode + Reads all data from the file and returns it. + + \section2 readLine + \code + readLine(): string + \endcode + Reads one line of text from the file and returns it. The returned string does not contain + the newline characters. + + \section2 setCodec + \code + setCodec(codec: string): void + \endcode + Sets the text codec to \c codec. The supported codecs are the same as for \c QTextCodec, + for example: "UTF-8", "UTF-16", and "ISO 8859-1". + + \section2 truncate + \code + truncate(): void + \endcode + Truncates the file, that is, gives it the size of zero, removing all content. + + \section2 write + \code + write(data: string): void + \endcode + Writes \c data into the file at the current position. + + \section2 writeLine + \code + writeLine(data: string): void + \endcode + Writes \c data into the file at the current position and appends the newline character(s). +*/ diff --git a/doc/reference/jsextensions/jsextension-utilities.qdoc b/doc/reference/jsextensions/jsextension-utilities.qdoc new file mode 100644 index 00000000..686e17a9 --- /dev/null +++ b/doc/reference/jsextensions/jsextension-utilities.qdoc @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-utilities.html + \ingroup list-of-builtin-services + + \title Utilities Service + \brief Provides miscellaneous operations. + + The \c Utilities service offers miscellaneous operations. + + \section1 Available Operations + + \section2 cStringQuote + + \badcode + Utilities.cStringQuote(str: string): string + \endcode + + Takes a string and escapes special characters in a way that the result is + suitable for use as a C/C++ string literal. This function is typically used + to specify values for \l{cpp::defines}{cpp.defines}. + + \section2 getHash + + \badcode + Utilities.getHash(key: string): string + \endcode + + Calculates a 16-byte hash of the input and returns it. + Rules in modules should use this function to find unique locations for output + artifacts in the build directory without duplicating the whole directory structure of + the respective input file (to deal with the case of two files with the same name in different + subdirectories of the same product). + + \section2 rfc1034Identifier + + \badcode + Utilities.rfc1034Identifier(str: string): string + \endcode + + Returns an RFC-1034 compliant identifier based on the given string by replacing each character + that is not Latin alphanumeric or \c{.} with \c{-}. + + \section2 versionCompare + + \badcode + Utilities.versionCompare(version1: string, version2: string): number + \endcode + + Interprets the two arguments as version numbers and returns a number that + is smaller than, equal to, or greater than zero if \c version1 is smaller + than, equal to, or greater than \c version2, respectively. + + The version strings consist of up to three numbers separated by dots. +*/ diff --git a/doc/reference/jsextensions/jsextension-xml.qdoc b/doc/reference/jsextensions/jsextension-xml.qdoc new file mode 100644 index 00000000..26e2e6de --- /dev/null +++ b/doc/reference/jsextensions/jsextension-xml.qdoc @@ -0,0 +1,341 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page jsextension-xml.html + \ingroup list-of-builtin-services + + \title Xml Service + \brief Provides a DOM parser and generator to JavaScript. + + The \c Xml service enables you to access and manipulate XML Document + Object Model (DOM) documents. The entire document is a \e {document node}, + each XML element is an \e {element node}, the text paragraphs in the XML + elements are \e {text nodes}, and each attribute is an \e {attribute node}. + + XML DOM presents documents as tree structures. The contents of the nodes + can be accessed in the tree. They can be modified or deleted, and new + nodes can be created. + + The nodes in the node tree have a hierarchical relationship to each other. + The top node is called the \e root. Each node, except the root, has exactly + one \e parent node, while it can have any number of \e children. Nodes with + the same parent are called \e siblings. + + \section1 XML DOM Document Node Operations + + A document node represents an entire document. That is, the root of the DOM + tree. + + \section2 Constructor + + \badcode + Xml.DomDocument() + \endcode + + Creates an XML DOM root node that can contain one element. + + \section2 createCDATASection + + \badcode + Xml.DomDocument.createCDATASection(value: string) + \endcode + + Creates a CDATA section that is not parsed by a parser. It can be used to + include XML fragments without having to escape the delimiters, for example. + Tags inside the section are not treated as markup nor are entities expanded. + + \section2 createElement + + \badcode + Xml.DomDocument.createElement(tagName: string) + \endcode + + Creates an element that can contain other elements, CDATA sections, and text + nodes. + + \section2 createTextNode + + \badcode + Xml.DomDocument.createTextNode(value: string) + \endcode + + Creates a text node that represents textual content in an element or + attribute. + + \section2 documentElement + + \badcode + Xml.DomDocument.documentElement() + \endcode + + Returns the document element. + + \section2 load + + \badcode + Xml.DomDocument.load(filePath: string): void + \endcode + + Loads the document specified by \c filePath. + + \section2 save + + \badcode + Xml.DomDocument.save(filePath: string, indentation: int): void + \endcode + + Saves the document at the location specified by \c filePath with the + indentation specified by \c int. + + \section2 setContent + + \badcode + Xml.DomDocument.setContent(content: string) + \endcode + + Returns the content of the document. + + \section2 toString + + \badcode + Xml.DomDocument.toString(indentation: int) + \endcode + + Converts the document to a string with the indentation specified by \c int. + + \section1 XML DOM Node Operations + + A node represents a single node in the document tree. There are several + different types of nodes, such as element, attribute, and text nodes. + + All objects inherit the node properties for handling parents and children, + even if they cannot have parents or children. For example, attempting to add + children to text nodes results in a DOM error. + + \section2 Constructor + + \badcode + Xml.DomNode() + \endcode + + Creates an XML DOM node. + + \section2 appendChild + + \badcode + Xml.DomNode.appendChild(tagName: string) + \endcode + + Appends a new child node to the end of the list of children of a node. + + \section2 attribute + + \badcode + Xml.DomNode.attribute(name: string, defaultValue: string) + \endcode + + Returns the name and default value of the attribute. + + \section2 clear + + \badcode + Xml.DomNode.clear() + \endcode + + Clears the contents of the node. + + \section2 data + + \badcode + Xml.DomNode.data() + \endcode + + Returns the contents of the text node, CDATA section, or character data + node. + + \section2 firstChild + + \badcode + Xml.DomNode.firstChild(tagName: string) + \endcode + + Returns the first child of a node. + + \section2 hasAttribute + + \badcode + Xml.DomNode.hasAttribute(name: string) boolean + \endcode + + Returns \c true if the node has the specified attribute. + + \section2 hasAttributes + + \badcode + Xml.DomNode.hasAttributes() boolean + \endcode + + Returns \c true if the node has attributes. + + \section2 hasChildNodes + + \badcode + Xml.DomNode.hasChildNodes() boolean + \endcode + + Returns \c true if the node has children. + + \section2 insertAfter + + \badcode + Xml.DomNode.insertAfter(newChild: tagName, refChild: tagName) + \endcode + + Inserts a new child node after the child node specified by \c refChild. + + \section2 insertBefore + + \badcode + Xml.DomNode.insertBefore(newChild: tagName, refChild: tagName) + \endcode + + Inserts a new child node before the child node specified by \c refChild. + + \section2 isCDATASection + + \badcode + Xml.DomNode.isCDATASection() boolean + \endcode + + Returns \c true if this is a CDATA section. + + \section2 isElement + + \badcode + Xml.DomNode.isElement() boolean + \endcode + + Returns \c true if this is an element. + + \section2 isText + + \badcode + Xml.DomNode.isText() boolean + \endcode + + Returns \c true if this is a text node. + + \section2 lastChild + + \badcode + Xml.DomNode.lastChild(tagName: string) + \endcode + + Returns the last child of a node. + + \section2 nextSibling + + \badcode + Xml.DomNode.nextSibling(tagName: string) + \endcode + + Returns the node immediately following a node. + + \section2 parentNode + + \badcode + Xml.DomNode.parentNode() + \endcode + + Returns the parent of the node. + + \section2 previousSibling + + \badcode + Xml.DomNode.previousSibling(tagName: string) + \endcode + + Returns the node before a node. + + \section2 removeChild + + \badcode + Xml.DomNode.removeChild(tagName: string) + \endcode + + Removes the child node. + + \section2 replaceChild + + \badcode + Xml.DomNode.replaceChild(newChild: tagName, oldChild: tagName) + \endcode + + Replaces a child node with another one. + + \section2 setAttribute + + \badcode + Xml.DomNode.setAttribute(name: string, value: string) + \endcode + + Sets the name and value of an attribute. + + \section2 setData + + \badcode + Xml.DomNode.setData(value: string): void + \endcode + + Sets the data of the node to a text node, CDATA section, or character data + node. + + \section2 setTagName + + \badcode + Xml.DomNode.setTagName(tagName: string) + \endcode + + Sets the tag name of the node. + + \section2 tagName + + \badcode + Xml.DomNode.tagName() + \endcode + + Returns the tag name of the node. + + \section2 text + + \badcode + Xml.DomNode.text() + \endcode + + Returns the text of the node. +*/ diff --git a/doc/reference/jsextensions/jsextensions-general.qdoc b/doc/reference/jsextensions/jsextensions-general.qdoc new file mode 100644 index 00000000..eb5bbd94 --- /dev/null +++ b/doc/reference/jsextensions/jsextensions-general.qdoc @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page jsextensions-general.html + \ingroup list-of-builtin-services + + \title General Services + \brief Provides various operations. + + These are operations that do not fit into any of the other categories. + They are automatically available in any \QBS project file or JavaScript file. + + \section1 Available Operations + + \section2 require + \code + require(identifier: string): any + \endcode + Loads an extension and returns an object representing the extension. + If \a identifier is a relative or absolute file path, this function will load a JavaScript file + and return an object containing the evaluated context of that file. Otherwise, loads a \QBS + extension named \a identifier and returns an object that contains the extension's context. + This function is only available in JavaScript files and is designed to behave similarly to the + CommonJS/RequireJS/Node.js module resolution systems. + \code + var MyFunctions = require("./myfunctions.js"); + MyFunctions.doSomething(); + var FileInfo = require("qbs.FileInfo"); + var fileName = FileInfo.fileName(filePath); + \endcode + + + \section1 Extensions to JavaScript Built-in Objects + + \section2 Array.contains + \code + Array.contains(e: any): boolean + \endcode + Returns \c{true} if the array contains the element \c{e}. Returns \c{false} otherwise. + + \section2 Array.containsAll + \code + Array.containsAll(other: any[]): boolean + \endcode + Returns \c{true} if the array contains every element in the \c{other} array. + Returns \c{false} otherwise. + + \section2 Array.containsAny + \code + Array.containsAny(other: any[]): boolean + \endcode + Returns \c{true} if the array contains some element(s) in the \c{other} array. + Returns \c{false} otherwise. + + \section2 Array.uniqueConcat + \code + Array.uniqueConcat(other: any[]): any[] + \endcode + Returns a copy of this array joined with the array \c{other}. + Duplicates that would originate from the concatenation are removed. + The order of elements is preserved. + + \section2 String.contains + \code + String.contains(s: string): boolean + \endcode + Returns \c{true} if the string contains the substring \c{s}. Returns \c{false} otherwise. + + \section2 startsWith + \code + String.startsWith(s: string): boolean + \endcode + Returns \c{true} if the string starts with the substring \c{s}. Returns \c{false} otherwise. + + \section2 endsWith + \code + String.endsWith(s: string): boolean + \endcode + Returns \c{true} if the string ends with the substring \c{s}. Returns \c{false} otherwise. + + + \section1 Console API + + \QBS provides a subset of the non-standard Console API available in most ECMAScript runtimes. + + The output of each of these functions will only be displayed if the logging level is at least + the level which the function outputs at. Logging levels from lowest to highest are: + 'error', 'warning', 'info', 'debug', and 'trace'. The default is 'info'. + + \warning The contents of this section are subject to change in order to align with future + \l{https://www.w3.org/2011/08/browser-testing-charter.html}{standardization} + \l{https://github.com/DeveloperToolsWG/console-object/blob/master/api.md}{processes}. + + \section2 console.debug + \code + console.debug(s: string): void + \endcode + This method is an alias for \c{console.log()}. + + \section2 console.error + \code + console.error(s: string): void + \endcode + Logs an \c{error} level message. + Outputs to stderr when the logger output is a terminal. + The string will be prefixed with \c{"ERROR: "} and colored red when the logger output is a + color-capable terminal. + + \section2 console.info + \code + console.info(s: string): void + \endcode + Logs an \c{info} level message. + Outputs to stdout when the logger output is a terminal. + + \section2 console.log + \code + console.log(s: string): void + \endcode + Logs a \c{debug} level message. + Outputs to stderr when the logger output is a terminal. + + \section2 console.warn + \code + console.warn(s: string): void + \endcode + Logs a \c{warning} level message. + Outputs to stderr when the logger output is a terminal. + The string will be prefixed with \c{"WARNING: "} and colored yellow when the logger output is a + color-capable terminal. +*/ diff --git a/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc b/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc new file mode 100644 index 00000000..debaa599 --- /dev/null +++ b/doc/reference/module-providers/qbspkgconfig-module-provider.qdoc @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype qbspkgconfig + \inqmlmodule QbsModuleProviders + \since 1.20 + + \brief Module provider based on the qbspkg-config library. + + \QBS uses a built-in parser of the \c{*.pc} files and does not require the presence of the + \c pkg-config tool in the system. However, if the \c pkg-config tool is present, \QBS will + use the same libDirs as the system pkg-config uses by default; otherwise, a built-in list of + paths is used. + + In order to enable usage of this provider in your Product, set the + \l{Product::qbsModuleProviders}{qbsModuleProviders} property as shown in the example below: + \snippet ../examples/pkgconfig-provider/pkgconfig-provider.qbs 0 +*/ + +/*! + \qmlproperty string qbspkgconfig::executableFilePath + + The path to the \c {pkg-config} executable. If not set, the pkg-config from PATH is used. + + \defaultvalue undefined +*/ + +/*! + \qmlproperty stringList qbspkgconfig::libDirs + + Set this if you need to overwrite the default search directories. + \note You do not need to set this for cross-compilation in order to point + to the sysroot. \QBS does that for you. + + This property is the equivalent of the \c{PKG_CONFIG_LIBDIR} variable + for the \c{pkg-config} tool. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList qbspkgconfig::extraPaths + + Set this if you need to add extra search directories. + + This property is the equivalent of the \c{PKG_CONFIG_PATH} variable + for the \c{pkg-config} tool. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool qbspkgconfig::staticMode + + If this property is \c true, then \QBS will include "private" libs and dependencies of the + package. This property is the equivalent of the + \c{--static} option for the \c{pkg-config} tool. + + Set this if your product is to be linked statically. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty path qbspkgconfig::sysroot + + Set this property if you need to overwrite the default search sysroot path used by + \c pkg-config. + + This can be useful if \c pkg-config files are located in the directory other than qbs.sysroot. + This is the case on macOS platform - all XCode profiles are sysrooted to the SDK + directory, but \c pkg-config is typically intalled using Brew and resides in the + \c /usr/local directory. + + Setting this property to \c undefined or empty (\c "") value will use pkg-config's default + search paths: + \code + qbs build module-providers.pkgconfig.sysroot:undefined + \endcode + + This property is the equivalent of the \c{PKG_CONFIG_SYSROOT_DIR} variable for the + \c{pkg-config} tool. + + \defaultvalue \c "" on macOS, \c qbs.sysroot on other platforms +*/ + +/*! + \qmlproperty bool qbspkgconfig::mergeDependencies + + Holds whether dependencies should be merged by pkg-config or \QBS. + + If set to true, dependencies are merged by pkg-config meaning each generated module + is self-contained and does not depend on other modules. If set to false, generated modules + may depend on other modules and property merging is done by \QBS. The latter approach gives + \QBS more information about dependencies, but may have performance implications during resolve + phase, e.g. when using ABSEIL library. + + \defaultvalue \c true +*/ diff --git a/doc/reference/module-providers/qt-module-provider.qdoc b/doc/reference/module-providers/qt-module-provider.qdoc new file mode 100644 index 00000000..cd77a0d1 --- /dev/null +++ b/doc/reference/module-providers/qt-module-provider.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt + \inqmlmodule QbsModuleProviders + + \brief Module provider that generates Qt modules. + + Looking up a Qt installation happens via a \l{Module Providers}{module provider}. + By default, if a dependency to a Qt module is encountered, \QBS collects all Qt installations + it can find. This lookup happens by searching for \c qmake executables in the \c PATH + environment variable. Alternatively, you can explicitly tell \QBS which Qt + installations it should consider by setting the qmakeFilePaths + module provider \l{Parameterizing Module Providers}{property}. In that case, + the environment will be ignored. For instance, with the following Linux command line, + \QBS will build the project against a custom Qt instead of the standard one in \c{/usr/bin}: + \code + $ qbs moduleProviders.Qt.qmakeFilePaths:/opt/myqt/bin/qmake + \endcode + You can also set the module provider property in a profile. The simplest way to do + this is via the \l setup-qt tool. For examples of how to use this tool, see the + \l{Managing Qt Versions} section. + + This provider is activated automatically when encountering a dependency on the Qt + module and the \l{Product::qbsModuleProviders}{qbsModuleProviders} property + is \c undefined: + \code + CppApplication { + Depends { name: "Qt.core" } + files: "main.cpp" + } + \endcode + + Alternatively, you can activate this provider explicitly via the + \l{Product::qbsModuleProviders}{qbsModuleProviders} property: + \code + CppApplication { + Depends { name: "Qt.core" } + files: "main.cpp" + qbsModuleProviders: "Qt" + } + \endcode +*/ + +/*! + \qmlproperty stringList Qt::qmakeFilePaths + + List of paths to \c qmake executables. + + \defaultvalue undefined +*/ diff --git a/doc/reference/modules/android-ndk-module.qdoc b/doc/reference/modules/android-ndk-module.qdoc new file mode 100644 index 00000000..d3b16e2b --- /dev/null +++ b/doc/reference/modules/android-ndk-module.qdoc @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Android.ndk + \inqmlmodule QbsModules + \since Qbs 1.4 + + \brief Provides support for building native Android libraries. + + The \c Android.ndk module contains the properties and rules to create native libraries + for use in Android applications. + + Normally, you will not use this module directly, but instead work + with the \l{DynamicLibrary}, \l{StaticLibrary} and \l Application items + that \QBS provides. + + Here is what the project file for the \c hello-jni example that comes with + the NDK could look like: + + \code + CppApplication { + name: "HelloJni" + Android.sdk.packageName: "com.example.hellojni" + qbs.architectures: ["arm", "x86"] + files: "app/src/main/jni/hello-jni.c" + } + \endcode + + \section2 Relevant File Tags + \target filetags-android-ndk + + \table + \header + \li Tag + \li Since + \li Description + \row + \li \c{"android.nativelibrary"} + \li 1.4.0 + \li Attached to dynamic libraries that will end up in APK packages. + You do not normally need to use the tag explicitly, as it is the + default type of the \l{DynamicLibrary} item for Android targets. + \endtable +*/ + +/*! + \qmlproperty string Android.ndk::abi + + The ABI name as it appears under \c "lib/" in the application package. + Corresponds to \c APP_ABI in \c Android.mk. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Android.ndk::buildId + + Value to pass to the --build-id linker flag. + Plain --build-id option is used when buildId property is empty. + + \since Qbs 1.21 + + \defaultvalue \c "sha1" +*/ + +/*! + \qmlproperty string Android.ndk::appStl + + The library to use for C++. The possible values are: + + \list + \li \c "c++_shared" + \li \c "c++_static" + \endlist + + \defaultvalue \c{"c++_shared"} +*/ + +/*! + \qmlproperty path Android.ndk::ndkDir + + The NDK base directory. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Android.ndk::platform + + The versioned platform name. + + \defaultvalue \c{"android-16"} for 32 bit arm ABIs + and \c{"android-21"} for all 64 bit ABIs and x86. + x86 ABI has broken wstring support in android-16 to android-19. +*/ diff --git a/doc/reference/modules/android-sdk-module.qdoc b/doc/reference/modules/android-sdk-module.qdoc new file mode 100644 index 00000000..ce27b630 --- /dev/null +++ b/doc/reference/modules/android-sdk-module.qdoc @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Android.sdk + \inqmlmodule QbsModules + \since Qbs 1.4 + + \brief Provides support for building Android packages. + + The Android.sdk module contains the properties and rules to create Android + application packages from Java sources, resources, and so on. + It is usually pulled in indirectly by declaring an \l Application product. + + \section2 Relevant File Tags + \target filetags-android-sdk + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"android.aidl"} + \li \c{*.aidl} + \li 1.4.0 + \li Attached to Android AIDL files. One Java source file will be + generated for each such file. + \row + \li \c{"android.assets"} + \li - + \li 1.4.0 + \li Attached to Android assets, which are typically located in an + \c{assets/} subdirectory. These files are tagged automatically + if the \l automaticSources property is enabled. + \row + \li \c{"android.manifest"} + \li \c{AndroidManifest.xml} + \li 1.4.0 + \li Attached to the Android manifest. There must be one such file for + every Android app. + \row + \li \c{"android.resources"} + \li - + \li 1.4.0 + \li Attached to Android resources, which are typically located in a + \c{res/} subdirectory. These files are tagged automatically + if the \l automaticSources property is enabled. + \endtable +*/ + +/*! + \qmlproperty string Android.sdk::buildToolsVersion + + The version of the build tools such as \c aapt and \c dx. + + \defaultvalue Highest build tools version version available in the SDK. +*/ + +/*! + \qmlproperty string Android.sdk::ndkDir + + The NDK base directory, if an NDK is present. + + \defaultvalue Determined automatically based on standard search paths. +*/ + +/*! + \qmlproperty string Android.sdk::platform + + The versioned platform name (for example, \c "android-21"). + + \defaultvalue Highest build tools version version available in the SDK. +*/ + +/*! + \qmlproperty string Android.sdk::sdkDir + + The SDK base directory. + + \defaultvalue Determined automatically based on standard search paths. +*/ + +/*! + \qmlproperty bool Android.sdk::embedJar + \since Qbs 1.10 + + If \c true, then if the dependency is a JAR file, its classes and the + classes of its dependencies (if \c{embedJar} is also true for them) will + be recursively processed by \c{dex} and included in the final APK. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty path Android.sdk::assetsDir + + The base directory for Android assets in the respective product. + + \note Android requires that the file name of this directory is always + \c "assets". + + \defaultvalue \c "src/main/assets" in the product source directory +*/ + +/*! + \qmlproperty bool Android.sdk::automaticSources + + If \c true, Java sources as well as Android resources, assets, and the + manifest file will be automatically included in the respective product + via wildcards. Set this property to \c false if you want to specify + these files manually. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string Android.sdk::manifestFile + + The file path to the Android manifest file. + This property is only relevant if \l automaticSources is enabled. + + \note Android requires that the file name is always "AndroidManifest.xml". + + \defaultvalue \c "src/main/AndroidManifest.xml" in the product source directory +*/ + +/*! + \qmlproperty string Android.sdk::packageName + + The package name of the respective product. The \c package attribute in the manifest file + will be set to this value automatically. + + \defaultvalue \c name +*/ + +/*! + \qmlproperty string Android.sdk::versionCode + + The Android Manifest version code of the respective product. The \c android:versionCode + attribute in the manifest file will be set to this value if not undefined. + + In the following example we provide an architecture-specific value + for \c android:versionCode: + + \code + // ... + property int _version: 1 + property int _patchVersion: 0 + Android.sdk.versionCode: { + switch (Android.ndk.abi) { + case "armeabi-v7a": + return 132000000 | _version * 10 + _patchVersion; + case "arm64-v8a": + return 164000000 | _version * 10 + _patchVersion; + case "x86": + return 232000000 | _version * 10 + _patchVersion; + case "x86_64": + return 264000000 | _version * 10 + _patchVersion; + } + throw "Unknown architecture"; + } + \endcode + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Android.sdk::versionName + + The Android Manifest version name of the respective product. The \c android:versionName + attribute in the manifest file will be set to this value if not undefined. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty path Android.sdk::resourcesDir + + The base directory for Android resources in the respective product. + + \note Android requires that the file name of this directory is always + \c "res". + + \defaultvalue \c "src/main/res" in the product source directory +*/ + +/*! + \qmlproperty path Android.sdk::sourcesDir + + The base directory for Java sources. This property is only relevant if + \l automaticSources is enabled. + + \defaultvalue \c "src/main/java" in the product source directory +*/ + +/*! + \qmlproperty string Android.sdk::apkBaseName + + The base name of the APK file to to be built, that is, the file name + without the ".apk" extension. + + \defaultvalue \l packageName +*/ + +/*! + \qmlproperty stringList Android.sdk::aidlSearchPaths + Search paths for import statements to pass to the \c aidl tool via the \c{-I} option. +*/ + +/*! + \qmlproperty string Android.sdk::aaptName + \since Qbs 1.17 + + Name of the aapt binary. Allowed options: "aapt" and "aapt2". + + \defaultvalue \c "aapt2" +*/ + +/*! + \qmlproperty string Android.sdk::packageType + \since Qbs 1.17 + + Type of the package. Allowed options: "apk" and "aab". + Type "apk" generates a runnable package whereas "aab" generates a package for Google Play. + + \defaultvalue \c "apk" +*/ + +/*! + \qmlproperty string Android.sdk::dexCompilerName + \since Qbs 1.20 + + Name of the dex compiler binary. Allowed options: "dx" and "d8". + + \defaultvalue \c "d8" +*/ + +/*! + \qmlproperty string Android.sdk::minimumVersion + \since Qbs 1.17 + + Minimum API Level required for the application to run. + + \defaultvalue \c "21" +*/ + +/*! + \qmlproperty string Android.sdk::targetVersion + \since Qbs 1.17 + + API Level that the application targets. + + \defaultvalue \c platformVersion +*/ diff --git a/doc/reference/modules/archiver-module.qdoc b/doc/reference/modules/archiver-module.qdoc new file mode 100644 index 00000000..9a6c59ba --- /dev/null +++ b/doc/reference/modules/archiver-module.qdoc @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype archiver + \inqmlmodule QbsModules + \since Qbs 1.4 + + \brief Provides support for building archives. + + The \c archiver module contains the properties and rules for creating (compressed) archives. + The output artifact has the file tag \c "archiver.archive". The sole input artifact is a text file + containing the list of files to package, with one file path per line. The paths can be + relative, in which case they will be looked for in \l{archiver::}{workingDirectory}. The file tag + of this input artifact is \c "archiver.input-list". +*/ + +/*! + \qmlproperty stringList archiver::flags + + Custom options not covered by any of the other properties. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string archiver::archiveBaseName + + The base name of the archive file. That is, the file name without any + extensions. + + \defaultvalue \l{Product::targetName}{product.targetName} +*/ + +/*! + \qmlproperty string archiver::compressionLevel + + How much effort to put into the compression of a \c 7-Zip or \c zip archive. + + Possible values for zip are: + + \list + \li \c undefined + \li \c "0" + \li \c "1" + \li \c "2" + \li \c "3" + \li \c "4" + \li \c "5" + \li \c "6" + \li \c "7" + \li \c "8" + \li \c "9" + \endlist + + 7-Zip only supports 0 and the odd numbers above. + + Higher numbers result in a smaller archive, but the compression process will + take more time. + + If the value is left undefined, the default compression level is used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string archiver::compressionType + + How to compress a \c tar or \c zip archive. + + Possible options are: + + \list + \li \c "bz2" + \li \c "deflate" + \li \c "gz" + \li \c "none" + \li \c "store" + \li \c undefined, which uses the archiver's default compression type. + \li \c "xz" + \li \c "Z" + \endlist + + \defaultvalue \c{"gz"} for \c tar archives, otherwise \c undefined. +*/ + +/*! + \qmlproperty string archiver::outputDirectory + + Where to put the archive file. + + \defaultvalue \l{Product::destinationDirectory} + {product.destinationDirectory} +*/ + +/*! + \qmlproperty string archiver::type + + Which kind of archiver to use. + + The currently supported values are: + + \list + \li \c "7zip" + \li \c "tar" + \li \c "zip" + \endlist + + \nodefaultvalue +*/ + +/*! + \qmlproperty string archiver::workingDirectory + + The directory in which to execute the archiver tool specified by + \l{archiver::}{command}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string archiver::command + + The path to the executable used to create the archive. + + This is usually the native tool corresponding to the archive type being + produced, but may fall back to another tool also capable of producing that + archive type if the native tool is not installed on the host system. + This behavior is especially useful on platforms such as Windows, where the + native tools for producing \c tar and \c zip archives in particular are + much less likely to be installed. + + The following table lists the supported \l{archiver::type}{archive types} + and the tools capable of producing them, listed in search order from left to + right: + + \table + \header + \li Type + \li Supported tools + \row + \li 7zip + \li 7z + \row + \li tar + \li tar, 7z + \row + \li zip + \li zip \e (Info-Zip), 7z, jar \e (from Java JDK) + \endtable + + \defaultvalue Depends on \l{archiver::}{type}. +*/ diff --git a/doc/reference/modules/asan-module.qdoc b/doc/reference/modules/asan-module.qdoc new file mode 100644 index 00000000..6f6ee66c --- /dev/null +++ b/doc/reference/modules/asan-module.qdoc @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Sanitizers.address + \inqmlmodule QbsModules + \brief Provides AddressSanitizer support. + + Provides support for the \l{https://clang.llvm.org/docs/AddressSanitizer.html}{AddressSanitizer} + tool, which uses compiler instrumentation to detect memory corruption bugs at runtime. +*/ + + +/*! + \qmlproperty string Sanitizers.address::detectUseAfterReturn + + Controls whether support for detecting problems with stack use after returning + from a function should be built into the application. + + The possible values are: + \list + \li \c "always": Check for this type of problem unconditionally. + \li \c "runtime": Build with this capability, but only do the respective checks if they + are explicitly requested at runtime. + \li \c "never": Do not build with support for this check. + \endlist + + \note Only the clang compiler (starting at 13.0) supports the full set of values. + With GCC and MSVC, "runtime" maps to "always". + + \defaultvalue \c "always" +*/ + +/*! + \qmlproperty bool Sanitizers.address::detectUseAfterScope + + Controls whether to detect bugs relating the use of variables after they've gone out of scope. + + \note This property has no effect when building with with GCC and MSVC. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool Sanitizers.address::enabled + + Controls whether to enable AddressSanitizer. + + \note You do not need to check if the current toolchain supports AddressSanitizer: + If \QBS detects that it doesn't, this property has no effect. + + \defaultvalue \c true +*/ diff --git a/doc/reference/modules/autotest-module.qdoc b/doc/reference/modules/autotest-module.qdoc new file mode 100644 index 00000000..730f2c3b --- /dev/null +++ b/doc/reference/modules/autotest-module.qdoc @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype autotest + \inqmlmodule QbsModules + \since Qbs 1.13 + + \brief Allows to fine-tune autotest execution. + + The \c autotest module provides properties that allow autotest applications to specify + how exactly they should be run. +*/ + +/*! + \qmlproperty bool autotest::allowFailure + + Autotests for which this property is \c true can return a non-zero exit code without + causing the entire \l AutotestRunner to fail. Use this for tests that are known + to be unreliable. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty stringList autotest::arguments + + The list of arguments to invoke the autotest with. If not specified, then + the \l{AutotestRunner::arguments}{arguments} property of the + \l AutotestRunner that invokes the autotest is used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string autotest::workingDir + + The working directory for running the autotest. If not specified, then + the \l{AutotestRunner::workingDir}{workingDir} property of the + \l AutotestRunner that invokes the autotest is used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int autotest::timeout + + The time limit for the execution of the autotest. If not specified, the + \l{AutotestRunner::timeout}{timeout} property of the \l AutotestRunner + that invokes the autotest is used. + + \nodefaultvalue + \since Qbs 1.15 +*/ + diff --git a/doc/reference/modules/bundle-module.qdoc b/doc/reference/modules/bundle-module.qdoc new file mode 100644 index 00000000..4184672b --- /dev/null +++ b/doc/reference/modules/bundle-module.qdoc @@ -0,0 +1,477 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype bundle + \inqmlmodule QbsModules + \since Qbs 1.4 + + \brief Provides Core Foundation bundle support. + + The \c bundle module contains properties and rules for building and working with + Core Foundation bundles on Apple platforms (commonly known as CFBundles or simply \e bundles), + directories with a standardized hierarchical structure that hold executable code and resources. + Examples include applications, frameworks, and plugins. + + This module is available on all platforms but is currently only useful on Apple platforms. + + \note Core Foundation bundles are not to be confused with Mach-O loadable modules, which are + also referred to as (loadable) \e bundles in Apple parlance. + In \QBS, Core Foundation bundles are referred to as \e bundles, + while Mach-O loadable bundles are referred to as \e {loadable modules}. + + \section2 Relevant File Tags + \target filetags-bundle + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"bundle.content"} + \li - + \li 1.8 + \li Attached to the output artifacts of the rule that produces the + bundle. + \row + \li \c{"infoplist"} + \li \c{Info.plist}, \c{*-Info.plist} + \li 1.5 + \li Source files with this tag are Info property lists files or fragments that are merged + into the bundle's final \c Info.plist. + \endtable +*/ + +/*! + \qmlproperty bool bundle::isBundle + + Whether the product should actually be packaged as a bundle as opposed to a + flat file. This allows a product indirectly dependent on the \c{bundle} + module to retain control of whether it should actually be built as a bundle. + + \defaultvalue \c{true} for applications and dynamic libraries on Apple + platforms, \c{false} otherwise. +*/ + +/*! + \qmlproperty bool bundle::isShallow + \readonly + + Whether the bundle directory tree is \e shallow. That is, whether it lacks a + \c Contents subdirectory. This is the default on all platforms other than + macOS. + + \defaultvalue \c{false} on macOS, otherwise \c{true}. +*/ + +/*! + \qmlproperty string bundle::identifierPrefix + + A prefix for the product's bundle identifier. If \l{bundle::}{identifier} + is left unset, the bundle identifier will be a concatenation of this value + and the \l{Product::targetName}{Product.targetName} property formatted as + an RFC-1034 identifier, separated by a period (.). This corresponds to the + organization identifier in Xcode. + + \defaultvalue \c{org.example} +*/ + +/*! + \qmlproperty string bundle::identifier + + The bundle's identifier. If left unset, the bundle identifier will be a + concatenation of the \l{bundle::}{identifierPrefix} value and the + \l{Product::targetName}{Product.targetName} propertyy formatted as an + RFC-1034 identifier, separated by a period (.). + + \defaultvalue A combination of \l{bundle::}{identifierPrefix} and the + product's target name formatted as an RFC-1034 identifier. +*/ + +/*! + \qmlproperty string bundle::extension + + The extension of the bundle's wrapper directory, without the leading period + (.). + + This property should not normally need to be set unless creating a custom + bundle type. + + \defaultvalue \c{"app"} for \c{"APPL"} packages, \c{"framework"} for + \c{"FMWK"} packages, and \c{"bundle"} for \c{"BNDL"} and custom packages. +*/ + +/*! + \qmlproperty string bundle::packageType + + The four-letter file type code of the bundle, specified in the bundle's + \c PkgInfo file and in the bundle's \c Info.plist as the value for the + \c CFBundlePackageType key. + + This property should almost never need to be changed, even though specifying + an alternative package type for custom bundles is allowed. + + \defaultvalue \c{"APPL"} for applications, \c{"FMWK"} for frameworks, and + \c{"BNDL"} for custom bundles. +*/ + +/*! + \qmlproperty bool bundle::generatePackageInfo + \since Qbs 1.5 + + Whether to generate a \c PkgInfo file for the bundle. + + This property should almost never need to be changed, even though enabling + it when specifying an alternative package type for custom bundles using + \l{bundle::}{packageType} is allowed. + + \defaultvalue \c{true} for applications, otherwise \c{false}. +*/ + +/*! + \qmlproperty string bundle::signature + + The four-letter signature specific to the bundle, also known as the creator + code, specified in the bundle's \c PkgInfo file and in the bundle's + \c Info.plist as the value for the \c CFBundleSignature key. + + This property should normally never need to be set. + + \defaultvalue \c{"????"} +*/ + +/*! + \qmlproperty string bundle::bundleName + + The file name of the bundle's wrapper directory. + + This property should not normally need to be changed. + + \defaultvalue A combination of the product's \l{Product::}{targetName} and + bundle's \l{bundle::}{extension}. +*/ + +/*! + \qmlproperty string bundle::frameworkVersion + + For framework bundles, the version of the framework. Not used for other + package types. + + \defaultvalue \c{"A"} +*/ + +/*! + \qmlproperty pathList bundle::publicHeaders + + A list of public header files to copy to a framework bundle's \c Headers + subdirectory. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList bundle::privateHeaders + + A list of private header files to copy to a framework bundle's + \c PrivateHeaders subdirectory + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList bundle::resources + + A list of resources to copy to a bundle's \c Resources subdirectory. Files + will automatically be copied into \c lproj subdirectories corresponding to + the input files' paths. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var bundle::infoPlist + + A dictionary of key-value pairs to add to the bundle's \c Info.plist. + + The contents of this property will be aggregated with the values from any + \c plist files. If this property and any \c plist files contain the same + key, this property will take precedence. However, it might be overridden + during postprocessing (see \l{bundle::}{processInfoPlist}). + + If \c undefined, will not be taken into account. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool bundle::processInfoPlist + + Whether to perform post-processing on the aggregated \c Info.plist contents. + + If this property is \c{true}, various post-processing operations will be + applied to the bundle's property list dictionary after it has been + aggregated from the contents of any \c plist files on disk, and the + \l{bundle::}{infoPlist} property. + + First, values from a list of defaults will be added to the dictionary if + they were not already present. Second, values from the \c AdditionalInfo key + of the platform SDK's \c Info.plist file will be added to the dictionary if + they were not already present, as well as some other miscellaneous keys, + such as \c BuildMachineOSBuild and \c UIDeviceFamily (on iOS). Finally, + variable expansions will be performed such that substrings of the form + \c $(VAR) or \c ${VAR} will be replaced with their corresponding environment + variables. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool bundle::embedInfoPlist + + Whether to create a \c{__TEXT} section in the product's executable + containing the processed \c Info.plist. + + Only applies to command line applications. + + \defaultvalue \c{true} if the product is a command line tool, otherwise + \c{false}. +*/ + +/*! + \qmlproperty string bundle::infoPlistFormat + + The file format to write the product's resulting \c Info.plist in. + + Possible values are: + + \list + \li \c{"binary1"} + \li \c{"json"} + \li \c{"same-as-input"} + \li \c{"xml1"} + \endlist + + \defaultvalue \c{"binary1"} for iOS, \c{"same-as-input"} or \c{"xml1"} + for macOS depending on whether a \c plist file is used, and \c{undefined} + for all other operating systems. +*/ + +/*! + \qmlproperty string bundle::infoPlistPath + \readonly + + The path that the \c Info.plist file will be written to. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::infoStringsPath + \readonly + \since Qbs 1.5 + + The path that the \c InfoPlist.strings file will be written to. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::pkgInfoPath + \readonly + + The path that the \c PkgInfo file will be written to. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::versionPlistPath + \readonly + + The path that the \c version.plist file will be written to. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::executablePath + \readonly + + The path that the main executable file will be written to. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::contentsFolderPath + \readonly + + The path of the bundle's \c Contents subdirectory. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::documentationFolderPath + \readonly + \since Qbs 1.5 + + The path of the directory where documentation will be written. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::executableFolderPath + \readonly + + The path of the directory where the main exectuable will be written. + + The path is relative to the directory that contains the bundle. + + Not to be confused with \l{bundle::}{executablesFolderPath}. +*/ + +/*! + \qmlproperty string bundle::executablesFolderPath + \readonly + + The path of the directory where auxiliary executables will be copied. + + The path is relative to the directory that contains the bundle. + + Not to be confused with \l{bundle::}{executableFolderPath}. +*/ + +/*! + \qmlproperty string bundle::frameworksFolderPath + \readonly + + The path of the directory where internal frameworks will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::javaFolderPath + \readonly + \since Qbs 1.5 + + The path of the directory where Java content will be written. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::localizedResourcesFolderPath + \readonly + \since Qbs 1.5 + + The path of the directory where localized resource files will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::pluginsFolderPath + \readonly + + The path of the directory where plugins will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::privateHeadersFolderPath + \readonly + + The path of the directory where private header files will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::publicHeadersFolderPath + \readonly + + The path of the directory where public headers files will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::scriptsFolderPath + \readonly + + The path of the directory where script files will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::sharedFrameworksFolderPath + \readonly + + The path of the directory where shared frameworks will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::sharedSupportFolderPath + \readonly + + The path of the directory where shared support files will be copied. + + The path is relative to the directory that contains the bundle. +*/ + +/*! + \qmlproperty string bundle::unlocalizedResourcesFolderPath + \readonly + + The path of the directory where non-localized resource files will be copied. + + The path is relative to the directory that contains the bundle. + + This is the same as the base resources path. +*/ + +/*! + \qmlproperty string bundle::versionsFolderPath + \readonly + \since Qbs 1.5 + + The path of the bundle's \c Versions subdirectory. + + The path is relative to the directory that contains the bundle. + + This is only relevant for (non-shallow) framework bundles. +*/ diff --git a/doc/reference/modules/capnprotocpp-module.qdoc b/doc/reference/modules/capnprotocpp-module.qdoc new file mode 100644 index 00000000..c3c8660c --- /dev/null +++ b/doc/reference/modules/capnprotocpp-module.qdoc @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype capnproto.cpp + \inqmlmodule QbsModules + \since Qbs 1.17 + + \brief Provides support for Cap'n Proto for the C++ language. + + The \c capnproto.cpp module provides support for generating C++ headers + and sources from proto definition files using the \c capnpc tool. + + A simple qbs file that uses Cap'n Proto can be written as follows: + \code + CppApplication { + Depends { name: "capnproto.cpp" } + files: ["foo.capnp", "main.cpp"] + } + \endcode + A generated header now can be included in the C++ sources: + \code + #include + + int main(int argc, char* argv[]) { + ::capnp::MallocMessageBuilder message; + + auto foo = message.initRoot(); + foo.setAnswer(42); + return 0; + } + \endcode + + \section2 Relevant File Tags + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"capnproto.input"} + \li \c{*.capnp} + \li 1.17.0 + \li Source files with this tag are considered inputs to the \c capnpc compiler. + \endtable + + \section2 Dependencies + This module depends on the \c capnp module and on the \c capnp-rpc module if + \l{capnproto.cpp::useRpc}{useRpc} property is \c true. These modules are created by the + \l{Module Providers} via the \c pkg-config tool. +*/ + +/*! + \qmlproperty string capnproto.cpp::compilerName + + The name of the capnp binary. + + \defaultvalue \c "capnpc" +*/ + +/*! + \qmlproperty string capnproto.cpp::compilerPath + + The path to the protoc binary. + + Use this property to override the auto-detected location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty pathList capnproto.cpp::importPaths + + The list of import paths that are passed to the \c capnpc tool via the \c --import-path option. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string capnproto.cpp::outputDir + \readonly + + The directory where the \c capnpc compiler generated files are placed. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ + +/*! + \qmlproperty bool capnproto.cpp::useRpc + + Use this property to enable support for the RPC framework. + + A simple qbs file that uses rpc can be written as follows: + + \quotefile ../examples/capnproto/calculator_cpp/calculator_cpp.qbs + + \defaultvalue \c false +*/ diff --git a/doc/reference/modules/codesign-module.qdoc b/doc/reference/modules/codesign-module.qdoc new file mode 100644 index 00000000..45e247a6 --- /dev/null +++ b/doc/reference/modules/codesign-module.qdoc @@ -0,0 +1,395 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype codesign + \inqmlmodule QbsModules + \since Qbs 1.19 + + \brief Provides code signing support. + + The \c codesign module contains properties and rules for code signing on Apple and Android + platforms. + + \section2 Relevant File Tags + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"codesign.entitlements"} + \li \c{*.entitlements} + \li 1.19.0 + \li \l{https://developer.apple.com/documentation/bundleresources/entitlements}{Xcode entitlements} + \row + \li \c{"codesign.provisioningprofile"} + \li \c{*.mobileprovision, *.provisionprofile} + \li 1.19.0 + \li Xcode provisioning profiles + \row + \li \c{"codesign.signed_artifact"} + \li n/a + \li 1.19.0 + \li This tag is attached to all signed artifacts such as applications or libraries + \endtable +*/ + +/*! + \qmlproperty string codesign::signingTimestamp + + URL of the timestamp authority RFC 3161 server to be contacted to authenticate code signing. + \c undefined or \c empty indicates that a system-specific default should be used; + \c{"none"} explicitly disables the use of timestamp services on Apple platforms. + + \since Qbs 1.19 + + \defaultvalue \c "none" on Apple, \c undefined otherwise +*/ + +/*! + \qmlproperty stringList codesign::codesignFlags + + Additional flags passed to the \c{codesign} tool. + + \since Qbs 1.19 + + \nodefaultvalue +*/ + +/*! + \qmlproperty string codesign::codesignName + + The name of the \c{codesign} binary. + + \since Qbs 1.19 + + \defaultvalue Determined automatically +*/ + +/*! + \qmlproperty string codesign::codesignPath + + Path to the \c{codesign} tool. + + \since Qbs 1.19 + + \defaultvalue Determined automatically +*/ + +/*! + \qmlproperty bool codesign::enableCodeSigning + + Whether to actually perform code signing. + + \since Qbs 1.19 + + \defaultvalue \c false +*/ + +/*! + \qmlproperty string codesign::provisioningProfile + + Name or UUID of the provisioning profile to embed in the product. + Typically this should be left blank to allow \QBS to use automatic provisioning. + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \appleproperty +*/ + +/*! + \qmlproperty path codesign::provisioningProfilesPath + + Path to directory containing provisioning profiles installed on the system. + This should not normally need to be changed. + + \since Qbs 1.19 + + \defaultvalue \c{"~/Library/MobileDevice/Provisioning Profiles"} + + \appleproperty +*/ + +/*! + \qmlproperty string codesign::signingIdentity + + Search string used to find the certificate to sign the product. This does not have to be + a full certificate name like "Mac Developer: John Doe (XXXXXXXXXX)", and can instead be + a partial string like "Mac Developer" or the certificate's SHA1 fingerprint. + The search string should generally be one of the following: + \list + \li 3rd Party Mac Developer Application + \li 3rd Party Mac Developer Installer + \li Developer ID Application + \li Developer ID Installer + \li iPhone Developer + \li iPhone Distribution + \li Mac Developer + \endlist + + It is also possible to use the special \c "-" value to use the ad-hoc signing. + + See \l{https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW41}{Maintaining Your Signing Identities and Certificates} + for complete documentation on the existing certificate types. + In general you should use \l{codesign::signingType}{signingType} instead. + + \since Qbs 1.19 + + \defaultvalue Determined by \l{codesign::signingType}{signingType} + + \appleproperty +*/ + +/*! + \qmlproperty string codesign::signingType + + Type of code signing to use. This should generally be used in preference to an explicit + signing identity like "Mac Developer: John Doe (XXXXXXXXXX)" since it is not user + specific and can be set in a project file. + Possible values include: \c{"app-store"}, \c{"apple-id"}, \c{"ad-hoc"}, which sign for + the App Store or Mac App Store, Developer ID, and Ad-hoc code signing, respectively. + + \section1 Relation between the signingType and signingIdentity + + The following table shows how the signingIdentity's default value is calculated. + + \table + \header + \li \c qbs.targetOS + \li \c codesign.signingType + \li \c qbs.buildVariant + \li \c codesign.signingIdentity + \row + \li {1, 4} \c "macos" + \li \c "ad-hoc" + \li any + \li \c "-" + \row + \li {1, 2} \c "app-store" + \li \c "debug", \c "profiling" + \li \c "Mac Developer" + \row + \li \c "release" + \li \c "3rd Party Mac Developer Application" + \row + \li \c "apple-id" + \li any + \li \c "Developer ID Application" + \row + \li {1, 2} \c "ios", \c "tvos", \c "watchos" + \li {1, 2} \c "app-store" + \li \c "debug", \c "profiling" + \li \c "iPhone Developer" + \row + \li \c "release" + \li \c "iPhone Distribution" + \endtable + + \since Qbs 1.19 + + \defaultvalue Determined automatically + + \appleproperty +*/ + +/*! + \qmlproperty string codesign::teamIdentifier + + Human readable name or 10-digit identifier of the Apple development team that the + signing identity belongs to. This is used to disambiguate between multiple certificates + of the same type in different teams. Typically this can be left blank if the development + machine is only signed in to a single development team, and should be set in a profile + otherwise. + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \appleproperty +*/ + +/*! + \qmlproperty bool codesign::useApksigner + + If \c true, the package is signed using apksignerFilePath binary. + Set this property to \c false to use the jarsignerFilePath one. + Set by the Android.sdk module. + + \since Qbs 1.19 + + \defaultvalue \c true + + \androidproperty +*/ + +/*! + \qmlproperty string codesign::keystorePath + + The absolute path to the keystore file. + + \since Qbs 1.19 + + \defaultvalue \c "${HOME}/.android/debug.keystore" + + \androidproperty +*/ + +/*! + \qmlproperty string codesign::keystorePassword + + The keystore password. + + \since Qbs 1.19 + + \defaultvalue \c "android" + + \androidproperty +*/ + +/*! + \qmlproperty string codesign::keyPassword + + The key password. + + \since Qbs 1.19 + + \defaultvalue \c "android" + + \androidproperty +*/ + +/*! + \qmlproperty string codesign::keyAlias + + The key alias. + + \since Qbs 1.19 + + \defaultvalue \c "androiddebugkey" + + \androidproperty +*/ + +/*! + \qmlproperty string codesign::subjectName + + Specifies the name of the subject of the signing certificate. + This value can be a substring of the entire subject name. + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::rootSubjectName + + Specifies the name of the subject of the root certificate that + the signing certificate must chain to. This value may be a substring + of the entire subject name of the root certificate. + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::hashAlgorithm + + Specifies the default hash algorithm used on the signing certificate. + The possible values are \c sha1, \c sha256, \c sha384, and \c sha512. + + \note Only available in Windows 10 kit builds 20236 and later. + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::timestampAlgorithm + + Specifies the default timestamp algorithm used together with the + \c signingTimestamp property. The possible values are \c sha1, \c sha256. + + \note If this value is not set, then the default sha1 algorithm + will be used. + + \since Qbs 1.19.2 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::certificatePath + + Specifies the full path to the signing certificate file (*.pfx). + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::certificatePassword + + Specifies the password to use when opening a signing certificate file (*.pfx). + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ + +/*! + \qmlproperty string codesign::crossCertificatePath + + Specifies the full path to the additional certificate file (*.cer). + + \since Qbs 1.19 + + \defaultvalue \c undefined + + \windowsproperty +*/ diff --git a/doc/reference/modules/cpp-module.qdoc b/doc/reference/modules/cpp-module.qdoc new file mode 100644 index 00000000..54051613 --- /dev/null +++ b/doc/reference/modules/cpp-module.qdoc @@ -0,0 +1,1942 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype cpp + \inqmlmodule QbsModules + \since Qbs 1.0 + + \brief Provides C/C++ support. + + The \c cpp module contains the properties and rules for toolchains of the C/C++ family. + On Apple platforms, this includes support for Objective-C/C++. + + \section2 Setting Up the Run Environment + + When running an application that has dependencies on dynamic libraries, the + script specified by \l{Module::setupRunEnvironment}{Module.setupRunEnvironment} + automatically adds the locations of the libraries to the environment. + That is, to \c PATH on Windows, \c DYLD_LIBRARY_PATH on macOS, + and \c LD_LIBRARY_PATH on Linux and other Unix platforms. If the value + \c{"ignore-lib-dependencies"} shows up in the \c config array, this behavior + is disabled. Users can set the value via the \l run command. + + \target dependency-parameters-cpp + \section2 Dependency Parameters + + \table + \header + \li Parameter + \li Type + \li Since + \li Default + \li Description + \row + \li \c{link} + \li \c{bool} + \li 1.9 + \li undefined + \li If \c{false}, the dependency will not be linked, even if + it is a valid input for a linker rule. This property + affects library dependencies only. + \row + \li \c{linkWholeArchive} + \li \c{bool} + \li 1.9 + \li undefined + \li If \c{true}, then if the dependency is a static library, all of its objects + will be pulled into target binary, even if their symbols do not appear to be used. + This parameter is mainly useful when creating a dynamic library from static libraries. + \row + \li \c{symbolLinkMode} + \li \c{string} + \li 1.9 + \li undefined + \li Attribute specifying how the library or framework will be linked. + May contain the values: "weak", "lazy", "reexport", and "upward"; refer to the Apple + ld64 man page for full details. \c{undefined} uses normal linking. + Currently only applies when linking for Apple platforms. + \endtable + + \section2 Relevant File Tags + \target filetags-cpp + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"application"} + \li n/a + \li 1.0.1 + \li The rule that creates executable files (typically via a linker) attaches this tag + to its output artifact. + \row + \li \c{"asm"} + \li \c{*.s} (for GCC-like toolchains), \c{*.asm} (for MSVC) + \li 1.1.0 + \li Source files with this tag serve as inputs to a rule invoking the toolchain's + assembler. One object file is generated for each such file. + \row + \li \c{"asm_cpp"} + \li \c{*.S}, \c{*.sx} + \li 1.1.0 + \li Like \c{"asm"}, but for source files that need preprocessing. This tag only has an + effect with GCC-like toolchains. + \row + \li \c{"c"} + \li \c{*.c} (if \c combineCSources is not enabled) + \li 1.0.1 + \li Source files with this tag serve as inputs to a rule invoking the toolchain's + C compiler. One object file is generated for each such file. + \row + \li \c{"c.combine"} + \li \c{*.c} (if \c combineCSources is enabled) + \li 1.8 + \li Source files with this tag serve as inputs to a rule combining them into + a single C file, which will then be compiled. + \row + \li \c{"cpp"} + \li \c{*.C}, \c{*.cpp}, \c{*.cxx}, \c{*.c++}, \c{*.cc} + (if \c combineCxxSources is not enabled) + \li 1.0.1 + \li Source files with this tag serve as inputs to a rule invoking the toolchain's + C++ compiler. One object file is generated for each such file. + \row + \li \c{"cpp.combine"} + \li \c{*.C}, \c{*.cpp}, \c{*.cxx}, \c{*.c++}, \c{*.cc} + (if \c combineCxxSources is enabled) + \li 1.8 + \li Source files with this tag serve as inputs to a rule combining them into + a single C++ file, which will then be compiled. + \row + \li \c{"c_pch_src"}, \c{"cpp_pch_src"}, \c{"objc_pch_src"}, \c{"objcpp_pch_src"} + \li - + \li 1.5 + \li Files with this tag will be turned into precompiled headers for C, C++, Objective-C + and Objective-C++, respectively. There can be only one such file per product and + language. + \row + \li \c{"def"} + \li - + \li 1.17.0 + \li This tag is used for a module-definition file (.def) to be passed to the linker. + Such a file provides the linker with information about exports, attributes, + and other information about the program to be linked. This file tag only has + an effect with the MSVC toolchain. + \row + \li \c{"dynamiclibrary"} + \li n/a + \li 1.0.1 + \li The rule that creates dynamic libraries (typically via a linker) attaches this tag + to its output artifact. + \row + \li \c{"dynamiclibrary_import"} + \li n/a + \li 1.0.0 + \li This tag is used for import libraries of dynamic libraries. For + example, the MSVC linker rule creates a \c{dynamiclibrary_import} + artifact \c{foo.lib} in addition to a \c{dynamiclibrary} artifact + \c{foo.dll}. + \row + \li \c{"hpp"} + \li \c{*.h}, \c{*.H}, \c{*.hpp}, \c{*.hxx}, \c{*.h++} + \li 1.0.1 + \li This tag is used for header files (C, C++, Objective-C and Objective-C++). No rule + in this module generates output artifacts from such files directly, but the compiler + rule will have a dependency on all rules that create such files. + \row + \li \c{"linkerscript"} + \li - + \li 1.5.0 + \li This tag is used for \c ld linker scripts. You can provide such a file if you need + to replace the default linker script. + This file tag only has an effect with GCC-like toolchains. The linker needs to be + \c{ld}-compatible. + \row + \li \c{"obj"} + \li n/a + \li 1.0.1 + \li The rule that creates object files (typically via a compiler) attaches this tag + to its output artifacts. Such files are usually intermediate artifacts of the build + process and rarely need to be referenced in project files. + \row + \li \c{"objc"} + \li \c{*.m} (if \c combineObjcSources is not enabled) + \li 1.1.0 + \li Source files with this tag serve as inputs to a rule invoking the toolchain's + Objective-C compiler. One object file is generated for each such file. + \row + \li \c{"objc.combine"} + \li \c{*.m} (if \c combineObjcSources is enabled) + \li 1.8 + \li Source files with this tag serve as inputs to a rule combining them into + a single Objective-C file, which will then be compiled. + \row + \li \c{"objcpp"} + \li \c{*.mm} (if \c combineObjcxxSources is not enabled) + \li 1.1.0 + \li Source files with this tag serve as inputs to a rule invoking the toolchain's + Objective-C++ compiler. One object file is generated for each such file. + \row + \li \c{"objcpp.combine"} + \li \c{*.mm} (if \c combineObjcxxSources is enabled) + \li 1.8 + \li Source files with this tag serve as inputs to a rule combining them into + a single Objective-C++ file, which will then be compiled. + \row + \li \c{"rc"} + \li \c{*.rc} + \li 1.1.0 + \li Files with this tag serve as inputs to the Windows resource compiler. One object file + is generated for each such file. The tag has no effect on target platforms other than + Windows. + \row + \li \c{"staticlibrary"} + \li n/a + \li 1.0.1 + \li The rule that creates static libraries (typically via a linker) attaches this tag + to its output artifact. + \row + \li \c{"versionscript"} + \li - + \li 1.5.0 + \li This tag is used for \c ld linker scripts. You can provide such a file if you need + fine-grained control over the symbols present in a shared library. + This file tag only has an effect with GCC-like toolchains. The linker needs to be + \c{ld}-compatible. + \endtable + + \section2 Relevant Job Pools + \target cpp-job-pools + + \table + \header + \li Pool + \li Since + \li Description + \row + \li \c{"assembler"} + \li 1.13 + \li The job pool used by rules that run the toolchain's assembler. This is only + relevant for direct invocations of the assembler binary, not for running it + indirectly via the compiler. + \row + \li \c{"compiler"} + \li 1.13 + \li The job pool used by rules that run a compiler. All language variants use + the same pool. + \row + \li \c{"linker"} + \li 1.13 + \li The job pool used by rules that run a linker. + \endtable +*/ + +/*! + \qmlproperty bool cpp::allowUnresolvedSymbols + \since Qbs 1.2 + + Set to \c true if you want the linking step to succeed even if the resulting + binary contains unresolved symbols. Normally, this makes little sense, but + in special cases it is possible that the respective symbols will be + available at load time even if they are not present during linking. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::architecture + + The target architecture. + + \defaultvalue \l{qbs::architecture}{qbs.architecture} +*/ + +/*! + \qmlproperty string cpp::endianness + \since Qbs 1.9 + + Specifies the endianness of the target platform's processor architecture + (\c{"big"} or \c{"little"}). + + The value is automatically detected from the compiler's default values, but + can also be manually set in order to select a specific endianness when + targeting bi-endian architectures like MIPS and PowerPC. + + \defaultvalue Compiler default value. +*/ + +/*! + \qmlproperty bool cpp::debugInformation + + Whether to generate debug information. + + \defaultvalue \l{qbs::debugInformation}{qbs.debugInformation} +*/ + +/*! + \qmlproperty bool cpp::combineCSources + \since Qbs 1.8 + + Enabling this property on a \l{Product}{product} instructs the + \l{FileTagger}{file tagger} to attach the tag \c{"c.combine"} to C sources, + rather than \c{"c"}. As a result, all C sources of the product will be + combined into a single file, which is then compiled. + + This can speed up initial compilation significantly, but is of course + detrimental in the context of incremental builds. Also, perfectly legal code + may fail to compile with this option due to the merging of translation + units. + + To enable this property in a product that has sources that cannot be merged, + put the sources into a dedicated \l{Group} and set their \l{Group::} + {fileTags} property to \c{"c"}, overriding the file tagger. + + \note Module properties set on specific source files (that is, at the Group + level) will not be taken into account when building the combined file. You + either need to set these properties at the product level or prevent the + respective files from getting combined via the mechanism described above. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty bool cpp::combineCxxSources + \since Qbs 1.8 + + Like \l{cpp::}{combineCSources}, but for C++. The \l{filetags-cpp} + {relevant file tags} are \c{"cpp"} and \c{"cpp.combine"}. + + \defaultvalue \c false + + \sa combineCSources +*/ + +/*! + \qmlproperty bool cpp::combineObjcSources + \since Qbs 1.8 + + Like \l{cpp::}{combineCSources}, but for Objective-C. The \l{filetags-cpp} + {relevant file tags} are \c{"objc"} and \c{"objc.combine"}. + + \defaultvalue \c false + + \sa combineCSources +*/ + +/*! + \qmlproperty bool cpp::combineObjcxxSources + \since Qbs 1.8 + + Like \l{cpp::}{combineCSources}, but for Objective-C++. The \l{filetags-cpp} + {relevant file tags} are \c{"objcpp"} and \c{"objcpp.combine"}. + + \defaultvalue \c false + + \sa combineCSources +*/ + +/*! + \qmlproperty bool cpp::createSymlinks + \unixproperty + + Whether to create version alias symlinks when building a dynamic library. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool cpp::discardUnusedData + \since Qbs 1.10 + + If this property is \c true, the linker will discard data from objects that + it determines to be unused. With MSVC and on Apple platforms, the + granularity is per symbol, elsewhere it is per section. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::separateDebugInformation + \since Qbs 1.4 + + Whether to store debug information in an external file or bundle instead of + within the binary. + + The type of files that will be generated when this property is \c{true} is + dependent on the compiler and target platform: + + \list + \li With MSVC, this property controls the generation of + \c{.pdb} (Program Debug Database) files. + \li On Apple platforms with GCC or Clang, this property controls the + generation of \c{.dSYM} (DWARF Symbol) bundles or, if + \l{cpp::}{dsymutilFlags} contains the \c{-f} or \c{--flat} flags, + \c{.dwarf} symbol files. + \li On other platforms with GCC or Clang (including Windows/MinGW), this + property controls the generation of \c{.debug} symbol files. + \endlist + + \defaultvalue \c{true} for MSVC and with GCC or Clang on Apple platforms, + otherwise \c{false}. + + \sa debugInformation, {How do I separate and install debugging symbols?} +*/ + +/*! + \qmlproperty stringList cpp::defines + + A list of preprocessor macros that gets passed to the compiler. + + To set macro values, use the following syntax: + + \code + cpp.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"'] + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::platformDefines + + A list of preprocessor macros that are used for all projects that are built + for the current target platform. User project files usually do not set this + property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::includePaths + + A list of include paths. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::systemIncludePaths + + A list of include paths that are passed as system include paths to the + compiler. + + For header files in those paths, warnings will be ignored. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::systemRunPaths + \since Qbs 1.6 + + The paths the dynamic linker uses on process start-up to locate dynamic + libraries. + + \defaultvalue Auto-detected for host builds on Linux via \c ldconfig, + \c{["/lib", "/usr/lib"]} otherwise on Unix, \c [] on Windows. +*/ + +/*! + \qmlproperty pathList cpp::libraryPaths + + A list of library search paths. + + The paths will be passed to the linker in the appropriate way. For + example, the \c {-L} argument will be used when using \c {ld}-like + linkers. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue + + \sa dynamicLibraries, {How do I create a module for a third-party library?} +*/ + +/*! + \qmlproperty stringList cpp::dynamicLibraries + + A List of dynamic libraries to be linked. + + If the library is part of your project, consider using a \l{Depends} item + instead. + + Each library can be specified in one of two ways: + + \list + \li An absolute file path (for example, \c "/foo/bar.lib"), in which case + it is passed directly to the linker, ignoring \l libraryPaths. + \li A library basename (for example, \c "bar"), in which case + the directory that contains the library must be provided via + \l libraryPaths. + \endlist + + Relative paths (\c "foo/bar.lib") are not allowed. + + \nodefaultvalue + + \sa libraryPaths, {How do I create a module for a third-party library?} +*/ + +/*! + \qmlproperty stringList cpp::staticLibraries + + A list of static libraries to be linked. + + If the library is part of your project, consider using a \l{Depends} item + instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::executablePrefix + + A string to prepend to the executable file \l{Product::targetName}{name}. + + \defaultvalue \c "" +*/ + +/*! + \qmlproperty string cpp::dynamicLibraryPrefix + + A string to prepend to the dynamic library file \l{Product::targetName}{name}. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c "" or \c "lib" +*/ + +/*! + \qmlproperty string cpp::loadableModulePrefix + \appleproperty + + A string to prepend to the Darwin loadable module file \l{Product::targetName}{name}. + + \defaultvalue \c "" +*/ + +/*! + \qmlproperty string cpp::staticLibraryPrefix + + A string to prepend to the static library file \l{Product::targetName}{name}. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c "" or \c "lib" +*/ + +/*! + \qmlproperty string cpp::executableSuffix + + A string to append to the executable file \l{Product::targetName}{name}. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c "" or \c ".exe" +*/ + +/*! + \qmlproperty string cpp::dynamicLibrarySuffix + + A string to append to the dynamic library file \l{Product::targetName}{name}. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c ".so", \c ".dll" + or \c "dylib" +*/ + +/*! + \qmlproperty string cpp::dynamicLibraryImportSuffix + \windowsproperty + + A string to append to the dynamic library import file \l{Product::targetName}{name}. + + \defaultvalue \c ".lib" +*/ + +/*! + \qmlproperty string cpp::loadableModuleSuffix + \appleproperty + + A string to append to the Darwin loadable module file \l{Product::targetName}{name}. + + \defaultvalue \c ".bundle" +*/ + +/*! + \qmlproperty string cpp::staticLibrarySuffix + + A string to append to the executable file \l{Product::targetName}{name}. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c ".a" or \c ".lib" +*/ + +/*! + \qmlproperty string cpp::debugInfoSuffix + + A string to append to the debug information file name. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c ".debug", + \c ".pdb" or \c ".dwarf" +*/ + +/*! + \qmlproperty string cpp::debugInfoBundleSuffix + \appleproperty + + A string to append to the debug information bundle name. + + \defaultvalue \c ".dSYM" +*/ + +/*! + \qmlproperty string cpp::objectSuffix + + A string to append to the generated object files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c ".o" or \c ".obj" +*/ + +/*! + \qmlproperty string cpp::linkerMapSuffix + + A string to append to the generated linker memory map files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".map" +*/ + +/*! + \qmlproperty string cpp::compilerListingSuffix + + A string to append to the generated compiler listing files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".lst" +*/ + +/*! + \qmlproperty string cpp::assemblerListingSuffix + + A string to append to the generated assembler listing files. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical value is \c ".lst" +*/ + +/*! + \qmlproperty pathList cpp::prefixHeaders + \since Qbs 1.0.1 + + A list of files to automatically include at the beginning of each source + file in the \l{Product}{product}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::optimization + + The optimization level. + + \defaultvalue \l{qbs::optimization}{qbs.optimization} +*/ + +/*! + \qmlproperty bool cpp::treatWarningsAsErrors + + Whether warnings will be handled as errors and cause the build to fail. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool cpp::useCPrecompiledHeader + \since Qbs 1.5 + + Whether to use a precompiled header for compiling C sources if one is + present. + + Set this property to \c false in a \l Group item to disable precompiled + headers for some sources even though a precompiled header is present in the + product. + + See \l{filetags-cpp}{Relevant File Tags} for the associated file tags. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool cpp::useCxxPrecompiledHeader + \since Qbs 1.5 + + Like \l useCPrecompiledHeader, but for C++. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool cpp::useObjcPrecompiledHeader + \since Qbs 1.5 + + Like \l useCPrecompiledHeader, but for Objective-C. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool cpp::useObjcxxPrecompiledHeader + \since Qbs 1.5 + + Like \l useCPrecompiledHeader, but for Objective-C++. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string cpp::warningLevel + + The warning level for the compiler: \c{"none"} or \c{"all"}. + + \defaultvalue \c{"all"} +*/ + +/*! + \qmlproperty stringList cpp::driverFlags + \since Qbs 1.6 + + A list of flags that are added to all compilation and linking commands + performed by the compiler driver, independently of the language. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::driverLinkerFlags + \since Qbs 1.11 + + A list of flags that are added to all linking commands performed by the + compiler driver, independently of the language. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::commonCompilerFlags + \since Qbs 1.0.1 + + A list of flags that are added to all compilation commands independently of + the language. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::compilerVersion + + Compiler version string consisting of major, minor and patch numbers, + separated by a dot. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int cpp::compilerVersionMajor + \since Qbs 1.4 + + The major version of the compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int cpp::compilerVersionMinor + \since Qbs 1.4 + + The minor version of the compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int cpp::compilerVersionPatch + \since Qbs 1.4 + + The patch level component of the compiler version. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::assemblerFlags + \since Qbs 1.5 + + A list of additional flags for the assembler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::cppFlags + + A list of additional flags for the C preprocessor. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::cFlags + + A list of additional flags for the C compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::cxxFlags + + A list of additional flags for the C++ compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::cLanguageVersion + \since Qbs 1.4 + + The version of the C standard with which the code must comply. + + If this property is set, the corresponding compiler and linker flags will be + added, depending on the toolchain. + + If the value is left undefined, the compiler default will be used. + If the list contains more than one value, the highest version is chosen. + + Possible values include: \c{"c89"}, \c{"c99"}, \c{"c11"}, \c{"c17"}, \c{"c2x"}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::cxxLanguageVersion + \since Qbs 1.4 + + The version of the C++ standard with which the code must comply. + + If this property is set, the corresponding compiler and linker flags will be + added, depending on the toolchain. + + If the value is left undefined, the compiler default will be used. + If the list contains more than one value, the highest version is chosen. + + Possible values include: \c{"c++98"}, \c{"c++11"}, \c{"c++14"}, \c{"c++17"}, \c{"c++20"}, + \c{"c++23"}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::useLanguageVersionFallback + \since Qbs 1.11 + + Whether to explicitly use the language standard version fallback values in + compiler command line invocations. + + By default, \QBS will automatically substitute fallback values for the C and + C++ language standard versions specified by the \l cLanguageVersion and + \l cxxLanguageVersion properties, which are passed to the \c{-std=} compiler + command line option with GNU-compatible toolchains, if it detects that you + are using an older toolchain which does not support the standard values. The + substitutions are made as follows: + + \table + \header + \li Value + \li Substitute + \row + \li c++11 + \li c++0x + \row + \li c11 + \li c1x + \row + \li c++14 + \li c++1y + \row + \li c++17 + \li c++1z + \endtable + + If this property is explicitly set to \c true, \QBS will always use the + fallback values. + + If this property is explicitly set to \c false, \QBS will never use the + fallback values. + + This property has no effect with the Microsoft Visual C++ compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::cxxStandardLibrary + \since Qbs 1.4 + + The C++ standard library to link to. + + If this property is set, the corresponding compiler and linker flags will be + added, assuming the value is valid for the current toolchain. + + If the value is left undefined, the compiler default will be used. + + Possible values include: \c{"libstdc++"}, \c{"libc++"}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::objcFlags + + A list of additional flags for the Objective-C compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::objcxxFlags + + A list of additional flags for the Objective-C++ compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::linkerFlags + + A list of additional flags for the linker. + + These flags should \e not be escaped using the \c -Wl or \c -Xlinker + syntaxes, as \QBS will do this automatically based on the linker being used. + + \sa linkerMode + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::assemblerName + \since Qbs 1.5 + + The name of the assembler binary. This property is set in the build profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::toolchainInstallPath + + The directory path where the toolchain is installed. This property is set + in the build profile. + + This is usually the base property from which all compiler and tool paths + are automatically derived. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::assemblerPath + \since Qbs 1.5 + + The full path of the assembler binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::compilerName + + The name of the main compiler binary. This property is set in the build profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::compilerPath + + The full path of the main compiler binary. This property is set in the build profile. + + If the toolchain provides different compilers for different languages, + \l{cpp::}{compilerPathByLanguage} is used. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty var cpp::compilerPathByLanguage + \since Qbs 1.3 + + A \c{string} to \c{string} map that maps file tags to full paths of compiler + binaries. This property is set in the build profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty stringList cpp::compilerWrapper + \since Qbs 1.1 + + A wrapper binary and its arguments for wrapping compiler calls. + This is useful for compiler wrappers, such as \c ccache. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::linkerName + \since Qbs 1.1.1 + + The name of the linker binary. This property is set in the build profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::linkerPath + \since Qbs 1.1.1 + + The full path of the linker binary. This property is set in the build profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty stringList cpp::linkerWrapper + \since Qbs 1.6.2 + + A wrapper binary and its arguments for wrapping linker calls. + This is useful for linker wrappers as needed by Bullseye Coverage, for + example. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::entryPoint + \since Qbs 1.3 + + The name of the entry point of an executable or dynamic library. + + If this property is left undefined, the toolchain's default is used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::runtimeLibrary + \since Qbs 1.3.3 + + The type of the runtime library used. + + Accepted values are \c{"static"} and \c{"dynamic"}. + + If this property is set to \c{undefined}, the default runtime library of the + toolchain is used. + + \note This property is only functional for MSVC and MinGW. + + \defaultvalue \c{"dynamic"} for MSVC and MinGW, \c{undefined} for other compilers. +*/ + +/*! + \qmlproperty bool cpp::enableExceptions + \since Qbs 1.5 + + Whether to enable exceptions in C++ code. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool cpp::enableSuspiciousLinkerFlagWarnings + \since Qbs 1.8 + + Whether to print warnings about escaped linker flags (such as \c -Xlinker and \c -Wl). + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string cpp::exceptionHandlingModel + \since Qbs 1.5 + + The exception handling model to use. + + For MSVC, this can be \c{"default"}, \c{"seh"} or \c{"externc"}. For all + other compilers, \c{"default"} indicates the default or the only exception + handling model. + + \defaultvalue \c{"default"} +*/ + +/*! + \qmlproperty bool cpp::enableRtti + \since Qbs 1.5 + + Whether to enable runtime type information in C++ code. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::enableReproducibleBuilds + \since Qbs 1.5 + + Whether the compiler should try to generate reproducible object files. + + Some compilers (notably GCC) use random numbers for generating symbol names + that have to be different in every compilation unit. This is avoided by + setting this property to \c{true}. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool cpp::treatSystemHeadersAsDependencies + \since Qbs 1.8 + + Whether included header files found via \l{cpp::}{systemIncludePaths}, + \l{cpp::}{distributionIncludePaths}, or \l{cpp::}{compilerIncludePaths} + will be added to the dependencies of the respective object file. + + This means that modification of such header files (or any of the headers + they include) will cause recompilation. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty stringList cpp::dsymutilFlags + \since Qbs 1.4.1 + + \appleproperty + + Additional flags for the \c dsymutil tool. + + \note If this property contains the \c{-f} or \c{--flat} options, this will + cause \QBS to generate "flat" (single-file) \c{.dwarf} debug symbol files + instead of \c{.dSYM} bundles (directories) when + \l{cpp::}{separateDebugInformation} is set to \c{true}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::dsymutilPath + \since Qbs 1.4 + + \appleproperty + + The full path of the \c dsymutil binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::lipoPath + \since Qbs 1.9 + + \appleproperty + + The full path of the \c lipo binary. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty pathList cpp::frameworkPaths + + \appleproperty + + A list of framework search paths. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::systemFrameworkPaths + + \appleproperty + + A list of framework search paths. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. Header files in frameworks in those paths will not cause + warnings. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::frameworks + + \appleproperty + + A list of frameworks to be linked. + + If the framework is part of your project, consider using a \l{Depends} item + instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::weakFrameworks + + \appleproperty + + A list of frameworks to be weakly linked. + + If the framework is part of your project, consider using a \l{Depends} item + instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::automaticReferenceCounting + \since Qbs 1.4 + + \appleproperty + + Whether to enable Automatic Reference Counting (ARC) for Objective-C and + Objective-C++ source code. + + If left undefined, uses the compiler default (probably \c{false}). + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::requireAppExtensionSafeApi + \since Qbs 1.4 + + \appleproperty + + Whether to enforce the use of only app-extension-safe APIs on Apple + platforms. This is necessary for building Application Extensions in OS X + Yosemite and iOS 8 and above. + + If left undefined, uses the compiler and linker defaults (probably + \c{false}). + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::minimumIosVersion + + \appleproperty + + A version number in the format \c{[major].[minor]} indicating the earliest + version of iOS that the product should run on. + + Passes \c{-miphoneos-version-min=} to the compiler. + + If set to undefined, compiler defaults will be used. + + \note \QBS sets minimum version to \c "6.0" for \c armv7a because earlier iOS versions are + broken in recent XCode installations. + + \defaultvalue \c "6.0" for \c armv7a, \c undefined otherwise +*/ + +/*! + \qmlproperty string cpp::minimumOsxVersion + \obsolete + + \appleproperty + + Deprecated in \QBS 1.5.2. Use \l{cpp::minimumMacosVersion} instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::minimumMacosVersion + \since Qbs 1.5.2 + + \appleproperty + + A version number in the format \c{[major].[minor]}indicating the earliest + version of macOS that the product should run on. + + Passes \c{-mmacosx-version-min=} to the compiler. + + If left undefined, compiler defaults will be used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::minimumWatchosVersion + + \appleproperty + + A version number in the format \c{[major].[minor]} indicating the earliest + version of Apple watchOS that the product should run on. + + If left undefined, compiler defaults will be used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::minimumTvosVersion + \since Qbs 1.5 + + \appleproperty + + A version number in the format \c{[major].[minor]} indicating the earliest + version of Apple tvOS that the product should run on. + + If left undefined, compiler defaults will be used. + + \note \QBS sets the minimum version to \c "6.0", because earlier tvOS + versions are not supported by recent XCode installations by default. + + \defaultvalue \c "6.0 +*/ + +/*! + \qmlproperty string cpp::archiverName + + \unixproperty + + The name of the archiver binary. This property is set in the build profile. + + \defaultvalue \c{"ar"} +*/ + +/*! + \qmlproperty string cpp::archiverPath + + \unixproperty + + The full path of the archiver binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::exportedSymbolsCheckMode + \since Qbs 1.4.1 + + \unixproperty + + Controls how \QBS determines whether an updated dynamic library causes + relinking of dependents. + + The default value is \c "ignore-undefined", which means that undefined + symbols being added or removed do not cause any relinking. If that should + happen, for example because dependent products are linked with an option + such as \c "--no-undefined", this property can be set to \c "strict". + + \defaultvalue \c "ignore-undefined" +*/ + +/*! + \qmlproperty string cpp::linkerMode + \since Qbs 1.6 + + Controls whether to automatically use an appropriate compiler frontend + instead of the system linker when linking binaries. + + The default is \c{"automatic"}, which chooses either the C++ compiler, C + compiler, or system linker specified by the \l{cpp::}{linkerName} and + \l{cpp::}{linkerPath} properties, depending on the type of object files + present on the linker command line. + + Set this property to \c{"manual"} to explicitly specify the linker using the + \l{cpp::}{linkerName} and \l{cpp::}{linkerPath} properties. + + \defaultvalue \c "automatic" +*/ + +/*! + \qmlproperty string cpp::linkerVariant + \since Qbs 1.13 + + Set this property to force the use of a specific linker. A non-empty value + will result in the \c {-fuse-ld} option being emitted when linking with \c gcc, + \c clang or \c clang-cl. Other toolchains do not support this property. + + The possible values for \c clang and \c gcc are \c "bfd", \c "gold" and \c "lld", + the possible values for \c clang-cl are \c "link" and \c "lld". + + The following example demonstrates how to change the linker for different toolchains: + + \code + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.linkerVariant: "gold" + } + Properties { + condition: qbs.toolchain.contains("clang-cl") + cpp.linkerVariant: "lld" + } + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::nmName + \since Qbs 1.2 + + \unixproperty + + The name of the \c nm binary. This property is set in the build profile. + + \defaultvalue \c{"nm"} +*/ + +/*! + \qmlproperty string cpp::nmPath + \since Qbs 1.2 + + \unixproperty + + The full path of the \c nm binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::objcopyName + \since Qbs 1.4 + + \unixproperty + + The name of the \c objcopy binary. This property is set in the build + profile. + + \defaultvalue \c{"objcopy"} +*/ + +/*! + \qmlproperty string cpp::objcopyPath + \since Qbs 1.4 + + \unixproperty + + The full path of the \c objcopy binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty string cpp::stripName + \since Qbs 1.4 + + \unixproperty + + The name of the \c strip binary. This property is set in the build profile. + + \defaultvalue \c{"strip"} +*/ + +/*! + \qmlproperty string cpp::stripPath + \since Qbs 1.4 + + \unixproperty + + The full path of the \c strip binary. This property is set in the build + profile. + + \defaultvalue Determined by \l{setup-toolchains}{qbs setup-toolchains}. +*/ + +/*! + \qmlproperty bool cpp::positionIndependentCode + + \unixproperty + + Whether to generate position-independent code. + + If this property is left undefined, position-independent code is generated + for libraries, but not for applications. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::rpathOrigin + \since Qbs 1.11 + + \unixproperty + + A placeholder value used in an \c rpath string to refer to the directory + containing the referring executable or shared library. + + \defaultvalue \c{"@loader_path"} on Mach-O based platforms (macOS, iOS, + tvOS, watchOS); \c{"$ORIGIN"} on ELF based platforms (Linux and most other + Unix-like platforms). +*/ + +/*! + \qmlproperty stringList cpp::rpaths + + \unixproperty + + A list of \c rpaths that are passed to the linker. Paths that also appear in + \l{cpp::}{systemRunPaths} are ignored. + + \nodefaultvalue + + \sa{How do I make use of rpaths?} +*/ + +/*! + \qmlproperty string cpp::sonamePrefix + \since Qbs 1.5 + + \unixproperty + + A library name or full library path. + + If defined, the value of this property is used as a path to be prepended to + the built shared library's \c SONAME identifier. The \c SONAME + (\c LC_ID_DYLIB on Apple platforms, \c DT_SONAME on other Unix-like + platforms) is the identifier that the dynamic linker will later use to + reference the library. + + On Apple platforms, the path may contain the following placeholders: + + \list + \li \c @rpath - + Expands to paths defined by \c LC_RPATH Mach-O commands in + the current process executable or the referring libraries. + \li \c @executable_path - + Expands to the current process executable location. + \li \c @loader_path - + Expands to the referring executable or library location. + \endlist + + In most cases, using \c @rpath is sufficient and recommended. + However, the prefix may be also specified using different placeholders, or + an absolute path. + + For more information, see the \l{DYLD documentation} on dynamic library + install names. + + \nodefaultvalue + + \sa{How do I make use of rpaths?} +*/ + +/*! + \qmlproperty string cpp::soVersion + \since Qbs 1.7 + + \unixproperty + + The version number to be appended to the soname in ELF shared libraries. + + \defaultvalue The major part of \l{Product::version}{product.version} if a + version is set, otherwise \c []. +*/ + +/*! + \qmlproperty bool cpp::useRPaths + \since Qbs 1.3 + + \unixproperty + + If \c{false}, prevents the linker from writing \c rpaths to the binary. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool cpp::useRPathLink + \since Qbs 1.8 + + \unixproperty + + Whether to use the \c{-rpath-link} linker option for transitive shared + objects. + + \defaultvalue \c{true} on non-Darwin Unix platforms or when targeting + macOS 10.4.x and older. +*/ + +/*! + \qmlproperty string cpp::rpathLinkFlag + \since Qbs 1.9 + + The rpath link flag used by the linker. + + \defaultvalue \l{qbs::toolchain}{toolchain}-dependent, typical values are \c "-rpath-link=" + or \c "-L" +*/ + +/*! + \qmlproperty string cpp::variantSuffix + \since Qbs 1.10 + + A suffix to add to a product's target name if that product is of the + \l{Product::type}{type} \c staticlibrary or \c dynamiclibrary. + + On Darwin platforms, applications and loadable modules are also affected. + + By default, this property is left empty on all platforms unless the product + is multiplexed over the \l{qbs::buildVariants}{qbs.buildVariants} property. + In that case, for the debug variant of the product, the default value + is \c{"d"} on Windows and \c{"_debug"} on Darwin platforms, such as macOS. + On all other platforms and in release mode, the default value is \c []. + + For example, building a dynamic library called \c MyLib that is multiplexed + over the \l{qbs::buildVariants}{qbs.buildVariants} property with MSVC will + produce files called \c{MyLib.dll} (for the release version of the product) + and \c{MyLibd.dll} (for the debug version). + + \defaultvalue Platform-specific. +*/ + +/*! + \qmlproperty string cpp::visibility + + \unixproperty + + The visibility level for exported symbols. + + Possible values include: \c{"default"}, \c{"hidden"}, \c{"hiddenInlines"}, + and \c{"minimal"}, which combines \c{"hidden"} and \c{"hiddenInlines"}. + + \defaultvalue \c{"default"} +*/ + +/*! + \qmlproperty bool cpp::generateManifestFile + \since Qbs 1.5.0 + + \windowsproperty + + Whether to auto-generate a manifest file and include it in the binary. + + Set this property to \c false if you provide your own \c rc file. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string cpp::windowsApiCharacterSet + \since Qbs 1.0.1 + + \windowsproperty + + + The character set used in the Win32 API. + + The value \c "unicode" defines the preprocessor symbols \c UNICODE and + \c _UNICODE, \c "mbcs" defines \c _MBCS, and setting the value to + \c undefined will use the default character set. + + \defaultvalue \c{"unicode"} +*/ + +/*! + \qmlproperty string cpp::windowsApiFamily + \since Qbs 1.10 + + \windowsproperty + + + The Windows API family that the application or library is targeting. + + This value is used when building Universal Windows Platform applications. + + Possible values include: \c{"desktop"}, \c{"pc"}, \c{"phone"}, \c{"server"}, + and \c{"system"}, which are mapped to the corresponding set of possible + values for the \c WINAPI_FAMILY preprocessor define in the Windows SDK. + + \defaultvalue Undefined, which lets the Windows SDK headers determine the + default. +*/ + +/*! + \qmlproperty stringList cpp::windowsApiAdditionalPartitions + \since Qbs 1.10 + + \windowsproperty + + A list of additional Windows API partitions to enable in addition to the + ones implicitly enabled by the value of \l{cpp::}{windowsApiFamily} + (\c WINAPI_FAMILY). + + This value is used when building Windows Store applications. For example, + setting \l{cpp::}{windowsApiFamily} to \c{"pc"} and this property to + \c{["phone"]} will allow you to create Windows Store applications that + target all Universal Windows Platform device families (\c "Universal" apps). + + Possible values include: \c{"app"}, \c{"desktop"}, \c{"pc"}, \c{"phone"}, + \c{"server"}, and \c{"system"}, which are mapped to the corresponding set of + possible \c WINAPI_PARTITION_* preprocessor defines in the Windows SDK. + + \defaultvalue Undefined, which lets the Windows SDK headers determine + the default partitions based on the value of \c WINAPI_FAMILY. + + \sa windowsApiFamily +*/ + +/*! + \qmlproperty bool cpp::requireAppContainer + \since Qbs 1.10 + + \windowsproperty + + Whether the generated executable or dynamic-link library \e requires an + AppContainer execution environment. Set to \c true when creating + Universal Windows Platform applications. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::minimumWindowsVersion + + \windowsproperty + + A version number in the format \c{[major].[minor]} indicating the earliest + version of Windows that the product should run on. + + Defines \c WINVER, \c _WIN32_WINNT, and \c _WIN32_WINDOWS, and applies a + version number to the linker flags \c /SUBSYSTEM and \c /OSVERSION for + MSVC or \c --major-subsystem-version, \c --minor-subsystem-version, + \c --major-os-version, and \c --minor-os-version for MinGW. + + If left undefined, compiler defaults will be used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::alwaysUseLipo + \since Qbs 1.9 + + Whether to always use \c lipo when combining Mach-O output files on + Apple platforms, even if there is only one CPU architecture. This value + should not normally need to be changed. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty var cpp::compilerDefinesByLanguage + \since Qbs 1.10 + + A \c{string} to \c{string} to \c{string} map of language tags to list of + preprocessor macros that are used for all projects that are using the + current toolchain. + + User project files usually do not set this property. + + \note This property will not be usable without also setting + \l{cpp::}{enableCompilerDefinesByLanguage}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::compilerIncludePaths + \since Qbs 1.6 + + A list of \c #include search paths that are used for all projects that are + using the current toolchain. + + User project files usually do not set this property. + + \defaultvalue Determined automatically by probing the compiler. +*/ + +/*! + \qmlproperty pathList cpp::compilerFrameworkPaths + \since Qbs 1.6 + + A list of framework search paths that are used for all projects that are + using the current toolchain. + + User project files usually do not set this property. + + \defaultvalue Determined automatically by probing the compiler. +*/ + +/*! + \qmlproperty pathList cpp::compilerLibraryPaths + \since Qbs 1.6 + + A list of library search paths that are used for all projects that are using + the current toolchain. + + User project files usually do not set this property. + + \defaultvalue Determined automatically by probing the compiler. +*/ + +/*! + \qmlproperty pathList cpp::distributionFrameworkPaths + \since Qbs 1.8 + + A list of distribution-specific framework search paths, prioritized after + \l{cpp::}{systemFrameworkPaths}. + + Intended for use by module authors implementing support for new operating + systems or distributions. + + User project files should not set this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::distributionIncludePaths + \since Qbs 1.8 + + A list of distribution-specific include paths that are passed as system + include paths to the compiler, prioritized after + \l{cpp::}{systemIncludePaths}. + + Intended for use by module authors implementing support for new operating + systems or distributions. + + User project files should not set this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList cpp::distributionLibraryPaths + \since Qbs 1.8 + + A list of distribution-specific library search paths. + + Intended for use by module authors implementing support for new operating + systems or distributions. + + User project files should not set this property. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList cpp::enableCompilerDefinesByLanguage + \since Qbs 1.10 + + A list of languages (one or more of \c{"c"}, \c{"cpp"}, \c{"objc"}, + \c{"objcpp"}) to extract the list of default compiler defines for in + \l{cpp::}{compilerDefinesByLanguage}. + + Because this has performance implications, no languages are enabled by + default. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpp::generateLinkerMapFile + \since Qbs 1.13 + + Whether to auto-generate a linker map file. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool cpp::generateCompilerListingFiles + \since Qbs 1.15 + + Whether to auto-generate compiler listing files. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool cpp::generateAssemblerListingFiles + \since Qbs 1.15 + + \baremetalproperty + + Whether to auto-generate an assembler listing files. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool cpp::removeDuplicateLibraries + \since Qbs 1.16 + + Whether the list of the objects and libraries is reduced to a + list of unique values before being passed to the linker. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string cpp::windowsSdkVersion + \since Qbs 1.19 + + Which Windows SDK version should be used with MSVC toolchain. By default, + the latest SDK is used. + + \windowsproperty + \nodefaultvalue +*/ + +/*! + \qmlproperty string cpp::enableCxxLanguageMacro + \since Qbs 1.20 + + Whether to set the \c{/Zc:__cplusplus} macro + (\l{https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus}) + + This property only applies to MSVC toolchain. clang-cl also supports + this option, but it has no effect. + + \windowsproperty + \defaultvalue \c{true} for MSVC, \c{false} for clang-cl +*/ diff --git a/doc/reference/modules/cpufeatures-module.qdoc b/doc/reference/modules/cpufeatures-module.qdoc new file mode 100644 index 00000000..c2358e38 --- /dev/null +++ b/doc/reference/modules/cpufeatures-module.qdoc @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype cpufeatures + \inqmlmodule QbsModules + \since Qbs 1.10 + + \brief Provides support for fine-tuning CPU features. + + The \c cpufeatures module offers properties for enabling or disabling specific CPU features. + Use it if you want to override the compiler defaults for a given platform. + + The compiler rules in the \l{cpp} module evaluate this module's properties + and generate matching compiler flags. + All properties in this module are of type \c bool and have the following semantics: + \list + \li The default value \c undefined has no effect on the compiler command line. + \li If the value is \c true and the compiler has a flag to enable the feature, that flag + is added to the command line if it is applicable to the current architecture. + For example, enabling the property \c x86_sse2 would result in the GCC option \c{-msse2}. + \li If the value is \c false and the compiler has a flag to disable the feature, + that flag is added to the command line if it is applicable to the current architecture. + For example, disabling the property \c x86_sse2 would result in the GCC option + \c{-no-msse2}. + \endlist +*/ + +/*! + \qmlproperty bool cpufeatures::arm_neon + + Whether to use NEON instructions in ARM binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::arm_vfpv4 + + Whether to use VFPv4 instructions in ARM binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::mips_dsp + + Whether to use DSP instructions in MIPS binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::mips_dspr2 + + Whether to use DSPr2 instructions in MIPS binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx + + Whether to use AVX instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx2 + + Whether to use AVX2 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512bw + + Whether to use AVX-512-BW instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512cd + + Whether to use AVX-512-CD instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512dq + + Whether to use AVX-512-DQ instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512er + + Whether to use AVX-512-ER instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512f + + Whether to use AVX-512 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512ifma + + Whether to use AVX-512-IFMA instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512pf + + Whether to use AVX-512-PF instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512vbmi + + Whether to use AVX-512-VBMI instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_avx512vl + + Whether to use AVX-512-VL instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_f16c + + Whether to use F16C instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_sse2 + + Whether to use SSE2 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_sse3 + + Whether to use SSE3 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_ssse3 + + Whether to use SSSE3 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_sse4_1 + + Whether to use SSE4.1 instructions in x86 binaries. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool cpufeatures::x86_sse4_2 + + Whether to use SSE4.2 instructions in x86 binaries. + + \nodefaultvalue +*/ diff --git a/doc/reference/modules/dmg-module.qdoc b/doc/reference/modules/dmg-module.qdoc new file mode 100644 index 00000000..5d18621a --- /dev/null +++ b/doc/reference/modules/dmg-module.qdoc @@ -0,0 +1,421 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype dmg + \inqmlmodule QbsModules + \since Qbs 1.9 + + \brief Provides support for building Apple Disk Images. + + The \c dmg module contains properties and rules for building Apple Disk Images, which are + typically used to distribute applications and installers on macOS. + + This module is only available on Apple platforms. + + \QBS enables you to build macOS disk images with custom backgrounds and icon + layouts. Most applications on macOS are installed via a \c .dmg file, which + is usually customized by using a custom image background and icon layout. + Unfortunately, it is challenging to construct such DMG files correctly, + because the layout relies on several undocumented proprietary file formats, + some of which date back to the Mac OS Classic days, and which are even + nested within one another. + + Most of the existing tools to create DMG files do so by using AppleScript to + manipulate the Finder graphically to generate the appropriate icon layout, + which is both unstable and incompatible with headless build servers, because + the necessary OS services to launch graphical applications may not be + running at all. Many projects create the primary \c .DS_Store + file manually, and commit the result to their source repository. This binary + blob is difficult to inspect and edit, and might not be backwards compatible + with older versions of the OS, depending on how it was generated. + + \QBS takes a different approach. It generates the necessary files + programmatically, in an entirely reproducible manner. There are no external + dependencies that need to be separately installed nor do any binary blobs + need to be committed to your source repository. + + \section2 Appearance Properties + + Appearance properties are used to control the contents of the .DS_Store file + and its embedded Alias and Bookmark records, that will be generated by \QBS + in order to control the appearance of the disk image when mounted in Finder. + + \section2 License Properties + + License properties are used to control the content and appearance of the + license prompt displayed when a user attempts to mount the resulting disk + image via Finder. + + \section2 Relevant File Tags + \target filetags-dmg + + The file tags determine how the tagged files are handled. + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"dmg.input"} + \li n/a + \li 1.9 + \li Tagged files are copied into the disk image. The + \l{dmg::}{sourceBase} property controls the destination directory + and hierarchy of copied files within the disk image. + \row + \li \c{"dmg.license.input"} + \li \c{*.txt}, \c{*.rtf}, \c{*.html}, \c{*.doc}, \c{*.docx}, \c{*.odt}, \c{*.xml}, + \c{*.webarchive} + \li 1.9 + \li Tagged files are converted into rich text and used for the license + prompt when mounting the DMG. + \row + \li \c{"icns"} + \li \c{*.icns} + \li 1.3 + \li The tagged file is added as the Apple Disk Image volume icon, which + will show up in the Finder as an overlay on the file icon. + \row + \li \c{"tiff"} + \li \c{*.tif}, \c{*.tiff} + \li 1.9 + \li The tagged file is used as the background image of the directory as + shown in Finder when the DMG file is mounted. + \endtable +*/ + +/*! + \qmlproperty string dmg::volumeName + + The name of the disk image that is displayed in Finder when the DMG is + mounted. + + \defaultvalue \l{Product::targetName}{product.targetName} +*/ + +/*! + \qmlproperty bool dmg::badgeVolumeIcon + + Whether to render the user-supplied icon (\l{filetags-dmg}{"icns"}) on top + of the default volume icon instead of using it directly. This generally + gives the disk image icon a better and more consistent appearance. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string dmg::format + + The format to create the disk image in. + + Allowed values include but are not limited to \c{"UDZO"}, \c{"UDBZ"}, and + \c{"ULFO"}. + + \defaultvalue \c{"UDBZ"} +*/ + +/*! + \qmlproperty int dmg::compressionLevel + + The \c zlib, \c bzip2, or \c lzfse compression level for UDZO, UDBZ, or ULFO + disk images. + + \defaultvalue \c 9 in release mode, otherwise \c undefined. +*/ + +/*! + \qmlproperty string dmg::sourceBase + + The base directory of the files that are going to be embedded in the DMG + (\l{filetags-dmg}{"dmg.input"}). The source base directory + is omitted from the target directory path of the DMG directory. + + \defaultvalue The directory of the current file to be embedded, relative to + the product's source directory. +*/ + +/*! + \qmlproperty string dmg::backgroundColor + + The background color of the disk image as seen when mounted in Finder. + + For the full list of supported color names and formats, see the + \l{dmgbuild - Settings} documentation. + + For more information about how to use an image for the background instead, + see \l{filetags-dmg}{"tiff"}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int dmg::iconSize + + The width and height of the file icons as seen when the disk image is + mounted in Finder. + + \defaultvalue \c{128} +*/ + +/*! + \qmlproperty int dmg::windowX + + The x position of the Finder window that displays the disk image contents + when it is mounted. + + \defaultvalue \c{100} +*/ + +/*! + \qmlproperty int dmg::windowY + + The y position of the Finder window that displays the disk image contents + when it is mounted. + + \defaultvalue \c{100} +*/ + +/*! + \qmlproperty int dmg::windowWidth + + The width of the Finder window that displays the disk image contents + when it is mounted. + + \defaultvalue \c{640} +*/ + +/*! + \qmlproperty int dmg::windowHeight + + The height of the Finder window that displays the disk image contents when + it is mounted. + + \note The window height includes the height of the standard macOS title bar + (22 points). + + \defaultvalue \c{480} +*/ + +/*! + \qmlproperty list dmg::iconPositions + + A list of objects containing the \c{path}, \c{x}, and \c{y} properties, + which correspond to disk image-relative file paths and visual coordinates of + file icons in the disk image as seen when it is mounted in Finder. + + For example: + + \code + dmg.iconPositions: [ + {"path": "Applications", "x": 128, "y": 128}, + {"path": "Foo Bar.app", "x": 256, "y": 128} + ] + \endcode + + This property is useful for specifying the positions of files where you do + not have direct control over the corresponding \QBS artifact, or there is no + corresponding \QBS artifact (for example, "Foo Bar.app" is a directory, + which has no equivalent artifact in the build graph). + + For files to which you are directly applying the \l{filetags-dmg}{dmg.input} + file tag, you should use the \l{dmg::}{iconX} and \l{dmg::}{iconY} + properties instead. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int dmg::iconX + + The x position of the file icon in the Finder window that displayed the disk + image contents when it is mounted. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.input}. It cannot be used at the product level to affect all files. + + If you do not have access to the artifact corresponding to the file whose + position you want to set, use the \l{dmg::}{iconPositions} property instead. + + \defaultvalue \c{windowWidth / 2} +*/ + +/*! + \qmlproperty int dmg::iconY + + The y position of the file icon in the Finder window that displayed the disk + image contents when it is mounted. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.input}. It cannot be used at the product level to affect all files. + + If you do not have access to the artifact corresponding to the file whose + position you want to set, use the \l{dmg::}{iconPositions} property instead. + + \defaultvalue \c{windowHeight / 2} +*/ + +/*! + \qmlproperty string dmg::defaultLicenseLocale + + The locale of the default license to display when there is no license whose + locale matches the system locale. + + \defaultvalue \c{"en_US"} +*/ + +/*! + \qmlproperty string dmg::licenseLocale + + The locale of the license file. + + Defaults to a value guessed from the file path, specifically the base name + of any \c .lproj directory found in the file's path. If the locale could not + be determined from the file path and this property is not set, an error will + be emitted. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string dmg::licenseLanguageName + + The name of the language associated with the license file, localized to that + language. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"English"} +*/ + +/*! + \qmlproperty string dmg::licenseAgreeButtonText + + The text shown on the \e Agree button associated with the license file, + localized to the value of \l{dmg::}{licenseLanguageName}. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"Agree"} +*/ + +/*! + \qmlproperty string dmg::licenseDisagreeButtonText + + The text shown on the \c Disagree button associated with the license file, + localized to the value of \l{dmg::}{licenseLanguageName}. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"Disagree"} +*/ + +/*! + \qmlproperty string dmg::licensePrintButtonText + + The text shown on the \c Print button associated with the license file, + localized to the value of \l{dmg::}{licenseLanguageName}. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"Print"} +*/ + +/*! + \qmlproperty string dmg::licenseSaveButtonText + + The text shown on the \e Save button associated with the license file, + localized to the value of \l{dmg::}{licenseLanguageName}. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"Save"} +*/ + +/*! + \qmlproperty string dmg::licenseInstructionText + + An instruction text associated with the license file that will be shown on + the license dialog, localized to the value of + \l{dmg::}{licenseLanguageName}. + + This property is only useful with artifacts tagged \l{filetags-dmg} + {dmg.license.input}. It cannot be used at the product level to affect all + files. + + \defaultvalue \c{"If you agree with the terms of this license, press + \"Agree\" to install the software. If you do not agree, press + \"Disagree\"."} +*/ + +/*! + \qmlproperty string dmg::dmgSuffix + + The file extension for disk images. + + This should not normally need to be changed. + + \defaultvalue \c{".dmg"} +*/ + +/*! + \qmlproperty string dmg::hdiutilPath + + The path to the \c hdiutil binary used to perform disk image related + operations. + + This should not normally need to be changed. + + \defaultvalue \c{"/usr/bin/hdiutil"} +*/ + +/*! + \qmlproperty string dmg::textutilPath + + The path to the \c textutil binary used to convert license agreement files + to rich text format. + + This should not normally need to be changed. + + \defaultvalue \c{"/usr/bin/textutil"} +*/ diff --git a/doc/reference/modules/exporter-pkgconfig-module.qdoc b/doc/reference/modules/exporter-pkgconfig-module.qdoc new file mode 100644 index 00000000..1dce5ffd --- /dev/null +++ b/doc/reference/modules/exporter-pkgconfig-module.qdoc @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Exporter.pkgconfig + \inqmlmodule QbsModules + \since Qbs 1.12 + + \brief Provides support for generating pkg-config files. + + The \c Exporter.pkgconfig module contains the properties and rules to create a + \l{https://www.freedesktop.org/wiki/Software/pkg-config}{pkg-config} + metadata (\c{.pc}) file for a \l Product. + + By default, \QBS will attempt to derive some of the \c {.pc} file's contents from + the product's \l Export item. This behavior can be suppressed by setting the + \l autoDetect property to \c false. + + \section2 Relevant File Tags + \target filetags-exporter-pkgconfig + + \table + \header + \li Tag + \li Since + \li Description + \row + \li \c{"Exporter.pkgconfig.pc"} + \li 1.12.0 + \li This tag is attached to the generated \c{.pc} file. + \endtable +*/ + +/*! + \qmlproperty bool Exporter.pkgconfig::autoDetect + + If this property is enabled, then \QBS will try to derive various \c {.pc} file + entries from the contents of the product's \l Export item, including the dependencies + declared therein. Values for these fields can still be explicitly provided via the + respective properties, in which case they will be concatenated with the auto-detected ones. + If an exported dependency is known to correspond to a pkg-config module (either by + pulling in the \c{Exporter.pkgconfig} module or by appearing in the \l requiresEntry + property), it will end up in the \c Requires field of the \c{.pc} file, otherwise + its exported \l cpp properties will be collected for use in the \c Cflags and \c Libs fields. + The \l excludedDependencies property can be used to ignore specific products altogether. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::cflagsEntry + + The value of the \c Cflags field in the \c {.pc} file. + + If \l autoDetect is enabled, then this value will be appended to the flags derived from + the product's \l Export item and the dependencies declared therein. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::conflictsEntry + + The value of the \c Conflicts field in the \c {.pc} file. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::excludedDependencies + + If \l autoDetect is enabled, the entries of this property will be matched against + the product's exported dependencies. In case such a dependency's name is present in the array, + \QBS will not traverse that dependency to collect entries for the + \c Cflags, \c Libs, \c Requires and \c {Requires.private} fields. + + This list must not contain any values that are present in \l requiresEntry. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Exporter.pkgconfig::fileName + + The file name of the generated pkg-config metadata file. + + \defaultvalue \c {product.targetName + ".pc"} +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::libsEntry + + The value of the \c Libs field in the \c {.pc} file. + + If \l autoDetect is enabled, then this value will be appended to the flags derived from + the product's \l Export item and the dependencies declared therein. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::libsPrivateEntry + + The value of the \c Libs.Private field in the \c {.pc} file. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty string Exporter.pkgconfig::nameEntry + + The value of the \c Name field in the \c {.pc} file. + + \defaultvalue \c {product.name} +*/ + + +/*! + \qmlproperty stringList Exporter.pkgconfig::requiresEntry + + The value of the \c Requires field in the \c {.pc} file. + + If \l autoDetect is enabled, then those of the product's exported dependencies + that pull in the \c {Exporter.pkgconfig} module will also end up in the + \c Requires field, provided they are not listed in \l excludedDependencies. + + If an exported dependency matches an entry of this array, \QBS will not traverse that + dependency to gather \l cpp properties for use in the \l cflagsEntry and \l libsEntry values, + as pkg-config takes care of that itself. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty stringList Exporter.pkgconfig::requiresPrivateEntry + + The value of the \c Requires.private field in the \c {.pc} file. + + If \l autoDetect is enabled, then those of the product's non-exported dependencies + that pull in the \c {Exporter.pkgconfig} module will also end up in the + \c Requires.private field, provided they are not listed in \l excludedDependencies. + + \defaultvalue \c {[]} +*/ + +/*! + \qmlproperty var Exporter.pkgconfig::transformFunction + + A function with the signature + \c {function(product, moduleName, propertyName, value)}. + This can be useful to "fine-tune" property values if \l autoDetect is enabled, in case + they need amending for the purpose of pkg-config. + The \c product parameter represents the exporting product, the remaining parameters describe + the module property. The modified value of the module property shall be returned. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Exporter.pkgconfig::urlEntry + + The value of the \c URL field in the \c {.pc} file. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Exporter.pkgconfig::versionEntry + + The value of the \c Version field in the \c {.pc} file. + + \defaultvalue \c {product.version} +*/ + +/*! + \qmlproperty string Exporter.pkgconfig::customVariables + + Use this property to add arbitrary variable assignments into the \c .pc file. + The property is a map that will produce one assignment per entry. + The keys and values of the map represent the left-hand sides and right-hand + sides of these assignments, respectively. The values are strings that will + be written into the file verbatim. + + \nodefaultvalue +*/ diff --git a/doc/reference/modules/exporter-qbs-module.qdoc b/doc/reference/modules/exporter-qbs-module.qdoc new file mode 100644 index 00000000..cea5aad7 --- /dev/null +++ b/doc/reference/modules/exporter-qbs-module.qdoc @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Exporter.qbs + \inqmlmodule QbsModules + \since Qbs 1.12 + + \brief Provides support for generating \QBS modules from products. + + The Exporter.qbs module contains the properties and rules to create a \QBS module from + the \l Export item of a \l Product. + + Such a module acts as your product's interface to other projects written in \QBS. + For instance, suppose you are creating a library. To allow other products both within + and outside of your project to make use of it, you would write something like the following: + \code + DynamicLibrary { + name: "mylibrary" + qbs.installPrefix: "/opt/mylibrary" + Depends { name: "Exporter.qbs" } + property string headersInstallDir: "include" + // ... + Group { + name: "API headers" + files: ["mylib.h"] + qbs.install: true + qbs.installDir: headersInstallDir + } + Group { + fileTagsFilter: ["Exporter.qbs.module"] + qbs.installDir: "qbs/modules/mylibrary" + } + Export { + Depends { name: "cpp" } + cpp.includePaths: [exportingProduct.sourceDirectory] + prefixMapping: [{ + prefix: exportingProduct.sourceDirectory, + replacement: FileInfo.joinPaths(exportingProduct.qbs.installPrefix, + exportingProduct.headersInstallDir) + }] + } + } + \endcode + To build against this library, from within your project or any other one, you simply + declare a \l{Depends}{dependency}: + \code + Depends { name: "mylibrary" } + \endcode + + \section2 Relevant File Tags + \target filetags-exporter-qbs + + \table + \header + \li Tag + \li Since + \li Description + \row + \li \c{"Exporter.qbs.module"} + \li 1.12.0 + \li This tag is attached to the generated module file. + \endtable +*/ + +/*! + \qmlproperty stringList Exporter.qbs::artifactTypes + + Artifacts that match these tags will become \l{Group::filesAreTargets}{target artifacts} + of the generated module, so they can get picked up by the rules of depending products. + + If you do not specify anything here, all installed artifacts of the product are considered. + \note You can only limit the default set of artifacts by setting this property, but you + cannot extend it, because only artifacts that are to be installed are considered. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Exporter.qbs::additionalContent + + The value of this property will be copied verbatim into the generated module. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty stringList Exporter.qbs::excludedDependencies + + Normally, all \l Depends items in the \l Export item are copied into the generated + module. However, if there are any exported dependencies that only make sense for + products in the same project, then you can enter their names into this array, and they + will get filtered out. + \note You should strive to structure your projects in such a way that you do not need to set + this property. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty string Exporter.qbs::fileName + + The name of the generated module file. + + \defaultvalue \c {product.targetName + ".qbs"} +*/ diff --git a/doc/reference/modules/freedesktop-module.qdoc b/doc/reference/modules/freedesktop-module.qdoc new file mode 100644 index 00000000..6c9d4a7f --- /dev/null +++ b/doc/reference/modules/freedesktop-module.qdoc @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Alberto Mardegan +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype freedesktop + \inqmlmodule QbsModules + \since Qbs 1.16 + + \brief Provides support for some freedesktop.org specifications. + + The \c freedesktop module contains properties and rules for building and working with + applications compliant to freedesktop.org specifications on UNIX platforms. + The areas in which this module can be of use include: + + \list + \li Creation or post-processing of + \l{https://specifications.freedesktop.org/desktop-entry-spec/latest/}{\c{.desktop} + files} + \li Installation of \l{https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html}{AppStream} metadata + \li Defining the location for + \l{https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#directory_layout} + {application icons} + \endlist + + This module is available on all platforms but is currently only useful on UNIX platforms. + + \section2 Example usage + \target example-freedesktop + + \code + Application { + ... + Depends { name: "freedesktop" } + + Group { + files: [ + ... + + // Declare the desktop and appstream files + "data/my-app.desktop", + "data/my-app.metainfo.xml", + ] + } + + // Add/change some fields in the desktop file + freedesktop.desktopKeys: ({ + 'Exec': FileInfo.joinPaths(qbs.installPrefix, + product.installDir, + product.targetName) + ' --argument', + 'X-Application-Version': product.version, + }) + + // Declare the application icon + Group { + files: "icons/my-application.svg" + fileTags: "freedesktop.appIcon" + } + } + \endcode + + \section2 Relevant File Tags + \target filetags-freedesktop + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"freedesktop.desktopfile_source"} + \li \c{*.desktop} + \li 1.16 + \li A source file with this tag is a \c{.desktop} file or fragment that + will be merged into the application's final \c{.desktop} file. + \row + \li \c{"freedesktop.desktopfile"} + \li - + \li 1.16 + \li Attached to the output artifacts of the rule that produces the + merged \c{.desktop} file. + \row + \li \c{"freedesktop.appstream"} + \li \c{*.metainfo.xml}, \c{*.appdata.xml} + \li 1.16 + \li Source files with this tag are AppStream metadata files which will + be installed under \l{qbs::}{installPrefix}\c{/share/metainfo} + \row + \li \c{"freedesktop.appIcon"} + \li - + \li 1.16 + \li Source files with this tag are application icons and will be + installed under \l{qbs::}{installPrefix}\c{/share/icons/hicolor/scalable/apps} + \endtable +*/ + +/*! + \qmlproperty string freedesktop::name + + The display name of the application which will be stored in the \c{.desktop} file. + + \defaultvalue \l{Product::name}{product.name} +*/ + +/*! + \qmlproperty var freedesktop::desktopKeys + + A dictionary of key-value pairs to add to the application's \c{.desktop} + file. + + The contents of this property will be aggregated with the values from any + \c{.desktop} file. If this property and any \c{.desktop} files contain the + same key, this property will take precedence. + + \nodefaultvalue +*/ diff --git a/doc/reference/modules/ib-module.qdoc b/doc/reference/modules/ib-module.qdoc new file mode 100644 index 00000000..b85f87c7 --- /dev/null +++ b/doc/reference/modules/ib-module.qdoc @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype ib + \inqmlmodule QbsModules + \since Qbs 1.1 + + \brief Provides support for Apple Interface Builder and related tools and file types. + + The \c ib module contains properties and rules for building Interface Builder documents, + storyboards, asset catalogs, and icon sets. + + This module is only available on Apple platforms. + + \section2 Relevant File Tags + \target filetags-ib + + The file tags determine how the tagged directories and files are handled. + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"assetcatalog"} + \li \c{*.xcassets} + \li 1.3 + \li Tagged directories are compiled into compiled asset catalog + archives (\c .car files) on supported platforms, or a collection of + loose resource files. The resulting files will be automatically + tagged \l{filetags-bundle}{bundle.input}. If the current product is + a bundle, the files will be included in the bundle's resources + directory. + \row + \li \c{"iconset"} + \li \c{*.iconset} + \li 1.3 + \li Tagged directories are compiled into Apple ICNS files. The resulting + files will be automatically tagged \l{filetags-bundle} + {bundle.input}. If the current product is a bundle, the files will + be included in the bundle's resources directory. + \row + \li \c{"nib"} + \li \c{*.nib}, \c{*.xib} + \li 1.1 + \li Tagged "NIB" and "XIB" files will be compiled. The output may be a + flat file or a bundle (directory structure). The resulting + files will be automatically tagged \l{filetags-bundle} + {bundle.input}. If the current product is a bundle, the files will + be included in the bundle's resources directory. + \row + \li \c{"png"} + \li \c{*.png} + \li 1.9 + \li Tagged PNG files may be converted into multi-resolution TIFFs. + Source files should adopt the \l{Adopt the @2x Naming Convention} + {@2x naming convention} in order to be properly grouped. The + resulting files will be given the \l{filetags-dmg}{tiff} file tag. + \row + \li \c{"storyboard"} + \li \c{*.storyboard} + \li 1.3 + \li Tagged storyboard files will be compiled. The output may be a flat + file or a bundle (directory structure). The resulting + files will be automatically tagged \l{filetags-bundle} + {bundle.input}. If the current product is a bundle, the files will + be included in the bundle's resources directory. + \endtable +*/ + +/*! + \qmlproperty bool ib::warnings + + Whether to print warnings when compiling. + + Does not apply to icon sets. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool ib::errors + + Whether to print errors when compiling. + + Does not apply to icon sets. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool ib::notices + + Whether to print notifications when compiling. + + Does not apply to icon sets. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty stringList ib::flags + + Additional flags to pass to the underlying tool (\c ibtool, \c actool, + \c iconutil). + + \nodefaultvalue + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string ib::ibtoolName + \since Qbs 1.3 + + The name of the \c ibtool binary used to compile NIBs and storyboards. + + This property should not normally need to be changed. + + \defaultvalue \c{"ibtool"} +*/ + +/*! + \qmlproperty string ib::ibtoolPath + \since Qbs 1.3 + + The directory where the \c ibtool binary is located. + + This property should not normally need to be changed. + + \defaultvalue \c{ibtoolName} +*/ + +/*! + \qmlproperty bool ib::flatten + + Compiles XIBs and storyboards into flattened (non-wrapper) files. + + Set to \c{false} to preserve editability of the resulting NIB and storyboard + bundles in Interface Builder. + + This property should not normally need to be changed. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string ib::module + \since Qbs 1.3 + + Sets the name of the module that the NIB or storyboard is a part of. + + Requires Xcode 6 or newer. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool ib::autoActivateCustomFonts + \since Qbs 1.3 + + Instructs the \c ibtool compiler to add custom fonts to the application's + \c Info.plist when compiling XIBs and storyboards, which will cause the + fonts to activate upon application launch. + + Requires Xcode 6 or newer. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string ib::actoolName + \since Qbs 1.3 + + The name of the \c actool binary used to compile asset catalogs. + + This property should not normally need to be changed. + + \defaultvalue \c{"actool"} +*/ + +/*! + \qmlproperty string ib::actoolPath + \since Qbs 1.3 + + The directory where the \c actool binary is located. + + This property should not normally need to be changed. + + \defaultvalue \c{actoolName} +*/ + +/*! + \qmlproperty string ib::appIconName + \since Qbs 1.3 + + The name of the resource in the asset catalog that will be used as the + application's icon. + + Used to generate the partial \c Info.plist which will be merged into the + resulting app. + + If this property is \c{undefined}, no application icon will be specified. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string ib::launchImageName + \since Qbs 1.3 + + The name of the resource in the asset catalog that will be used as the + application's launch image. + + Used to generate the partial \c Info.plist which will be merged into the + resulting app. + + If this property is \c{undefined}, no launch image will be specified. + + This property is specific to iOS. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool ib::compressPngs + \since Qbs 1.3 + + Whether to compress PNG image files when building asset catalogs. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string ib::iconutilName + \since Qbs 1.3 + + The name of the \c iconutil binary used to compile icon sets. + + This property should not normally need to be changed. + + \defaultvalue \c{"iconutil"} +*/ + +/*! + \qmlproperty string ib::iconutilPath + \since Qbs 1.3 + + The directory where the \c iconutil binary is located. + + This property should not normally need to be changed. + + \defaultvalue \c{iconutilName} +*/ diff --git a/doc/reference/modules/ico-module.qdoc b/doc/reference/modules/ico-module.qdoc new file mode 100644 index 00000000..60e4e295 --- /dev/null +++ b/doc/reference/modules/ico-module.qdoc @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype ico + \inqmlmodule QbsModules + \since Qbs 1.11 + + \brief Provides support for building ICO (.ico) and CUR (.cur) files. + + The \c ico module contains properties and rules for building + Microsoft Windows Icon (.ico) and Microsoft Windows Cursor (.cur) files. + + \note This module relies on the \c icotool command-line tool from the + \c icotools package, which must be installed separately and found in the + \c PATH or an appropriate system binaries directory for your system (for + example, \c /usr/bin or \c /usr/local/bin). + + \section2 Relevant File Tags + \target filetags-ico + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"cur"} + \li n/a + \li 1.11 + \li The rule that creates cursor (.cur) files + attaches this tag to its output artifact. + \row + \li \c{"ico"} + \li n/a + \li 1.11 + \li The rule that creates icon (.ico) files + attaches this tag to its output artifact. + \row + \li \c{"png"} + \li \c{"*.png"} + \li 1.11 + \li Source files with this tag indicate PNG files + which are used as inputs to create icon or cursor files. + \endtable +*/ + +/*! + \qmlproperty int ico::cursorHotspotX + + The cursor hotspot x coordinate. Only relevant when building .cur files. + + This property must be set individually for each input PNG file. + + \note \c icoutils version 0.32 or greater is required to set the + hotspot in cursor files with multiple images. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int ico::cursorHotspotY + + The cursor hotspot y coordinate. Only relevant when building .cur files. + + This property must be set individually for each input PNG file. + + \note \c icoutils version 0.32 or greater is required to set the + hotspot in cursor files with multiple images. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool ico::raw + + Whether to store the input file as a raw PNG, as supported in Windows Vista. + + Only relevant when building .ico files. + + This property must be set individually for each input PNG file. + + It is recommended to set this value only for icon sizes larger than or equal + to 256x256. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string ico::icotoolFilePath + + The full path of the \c icotool binary. + + This property should not normally need to be changed if \QBS was able to + automatically detect it. + + \defaultvalue Determined automatically. +*/ diff --git a/doc/reference/modules/innosetup-module.qdoc b/doc/reference/modules/innosetup-module.qdoc new file mode 100644 index 00000000..fe75ecf0 --- /dev/null +++ b/doc/reference/modules/innosetup-module.qdoc @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype innosetup + \inqmlmodule QbsModules + \since Qbs 1.7 + + \brief Provides Inno Setup support. + + The \c innosetup module contains properties and rules for building EXE + setup packages with \l{Inno Setup}. Inno Setup 5 and above are supported. + + \note A typical Inno Setup Script includes an \c OutputBaseFilename command + to set the filename of the generated installer executable. However, \QBS + overrides any \c OutputBaseFilename commands found in the script by passing + the \c /F option to the ISCC compiler, and therefore, you must use + the \l{Product::targetName}{Product.targetName} property to set the + filename. \QBS also overrides any \c Output commands by passing the \c /O + option to the ISCC compiler. + + \section2 Relevant File Tags + \target filetags-innosetup + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"innosetup.iss"} + \li \c{"*.iss"} + \li 1.7 + \li Source files with this tag identify Inno Setup Script files, which serve as inputs + to a rule invoking the Inno Setup Script Compiler. + \row + \li \c{"innosetup.exe"} + \li n/a + \li 1.7 + \li The rule that creates Inno Setup executable files attaches this tag + (as well as the \l{filetags-cpp}{"application"} tag) to its output + artifact. + \endtable +*/ + +/*! + \qmlproperty stringList innosetup::defines + + A list of preprocessor macros that get passed to the compiler. + + To set macro values, use the following syntax: + + \badcode + innosetup.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"'] + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty pathList innosetup::includePaths + + A list of include paths. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool innosetup::verboseOutput + + Whether to display verbose output from the Inno Setup compiler. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty stringList innosetup::compilerFlags + + A list of additional flags for the Inno Setup compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string innosetup::version + + The Inno Setup version. + + Consists of three numbers separated by dots, for instance \c {"5.5.9"}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty int innosetup::versionMajor + + The Inno Setup major version. + + \defaultvalue \c{versionParts[0]} +*/ + +/*! + \qmlproperty int innosetup::versionMinor + + The Inno Setup minor version. + + \defaultvalue \c{versionParts[1]} +*/ + +/*! + \qmlproperty list innosetup::versionParts + + The Inno Setup version as a list. + + For instance, Inno Setup version 5.5.9 would correspond to a value of + \c[5, 5, 9]. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty int innosetup::versionPatch + + The Inno Setup patch level. + + \defaultvalue \c{versionParts[2]} +*/ + +/*! + \qmlproperty path innosetup::toolchainInstallPath + + The Inno Setup installation directory. + + Determined by searching the registry for the latest version. + + This property should not normally need to be changed. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string innosetup::compilerName + + The name of the compiler binary. + + This property should not normally need to be changed. + + \defaultvalue \c{"ISCC.exe"} +*/ + +/*! + \qmlproperty string innosetup::compilerPath + + The full path of the compiler binary. + + This property should not normally need to be changed. + + \defaultvalue \c{compilerName} +*/ diff --git a/doc/reference/modules/java-module.qdoc b/doc/reference/modules/java-module.qdoc new file mode 100644 index 00000000..02ad3227 --- /dev/null +++ b/doc/reference/modules/java-module.qdoc @@ -0,0 +1,244 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype java + \inqmlmodule QbsModules + \since Qbs 1.4 + + \brief Provides Java support. + + The \c java module contains the properties and rules for building Java projects. + + \section2 Relevant File Tags + \target filetags-java + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"java.class"} + \li - + \li 1.4 + \li This tag is attached to the output artifacts of the rule that runs the + \c javac tool. + \row + \li \c{"java.jar"} + \li - + \li 1.4 + \li This tag is attached to the output artifacts of the rule that runs the + \c jar tool. + \row + \li \c{"java.java"} + \li \c{*.java} + \li 1.4 + \li Source files with this tag serve as inputs to the rule running the \c javac tool. + \row + \li \c{"java.manifest"} + \li \c{*.mf} + \li 1.8 + \li The contents of files with this tag will be aggregated with the + values in \l{java::}{manifest}. + \endtable +*/ + +/*! + \qmlproperty stringList java::additionalClassPaths + + The locations beside this product's class output path to consider when + compiling. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList java::additionalCompilerFlags + + A list of compiler flags not covered by any of the properties in this + module. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList java::additionalJarFlags + + A list of archiver flags not covered by any of the properties in this + module. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList java::bootClassPaths + + A list of non-standard bootstrap class files. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string java::compilerFilePath + + The command to invoke when compiling Java sources. + + \defaultvalue \l compilerName, prefixed by \l jdkPath if it is defined. +*/ + +/*! + \qmlproperty string java::compilerName + + The file name of the Java compiler. + + \defaultvalue \c{"javac"} +*/ + +/*! + \qmlproperty bool java::enableWarnings + + Whether warnings are emitted when compiling Java sources. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty string java::interpreterFilePath + + The command to invoke when executing Java code. + + \defaultvalue \l interpreterName, prefixed by \l jdkPath if it is defined. +*/ + +/*! + \qmlproperty string java::interpreterName + + The file name of the Java interpreter. + + \defaultvalue \c{"java"} +*/ + +/*! + \qmlproperty string java::jarFilePath + + The command to run when creating or extracting \c jar files. + + \defaultvalue \l jarName, prefixed by \l jdkPath if it is defined. +*/ + +/*! + \qmlproperty string java::jarName + + The file name of the \c jar tool. + + \defaultvalue \c{"jar"} +*/ + +/*! + \qmlproperty pathList java::jdkIncludePaths + \since Qbs 1.4.1 + + A list of include paths for native header files. + + Applications using JNI to interface with native code should add these paths + to \l{cpp::includePaths}{cpp.includePaths}. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string java::jdkPath + + The base path of the Java Development Kit (JDK). + + This is equivalent to the \c JAVA_HOME environment variable, and by default + will be determined automatically from one of the following: + + \list + \li \c JAVA_HOME environment variable (all platforms) + \li Registry (Windows) + \li \c java_home tool (macOS) + \li Known JDK paths (other Unix platforms) + \endlist + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string java::languageVersion + + The Java language version to interpret source code as. + + If left undefined, the compiler will use its default. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string java::runtimeVersion + + The version of the Java runtime to generate compatible bytecode for. + + If left undefined, the compiler will use its default. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var java::manifest + \since Qbs 1.4.2 + + The properties to add to the manifest file when building a JAR. + + The contents of this property will be aggregated with the values from any + files tagged \l{filetags-java}{"java.manifest"}. + + If this property and a manifest file contain the same key, this property + will take precedence. If left undefined, this property will not be taken + into account. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList java::manifestClassPath + + A list of entries to add to the manifest's Class-Path when building a JAR. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool java::warningsAsErrors + + If this property is \c true, the compiler will abort where it would normally + emit a warning. + + \defaultvalue \c false +*/ diff --git a/doc/reference/modules/lexyacc-module.qdoc b/doc/reference/modules/lexyacc-module.qdoc new file mode 100644 index 00000000..002e90f0 --- /dev/null +++ b/doc/reference/modules/lexyacc-module.qdoc @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype lex_yacc + \inqmlmodule QbsModules + \since Qbs 1.6 + + \brief Provides support for the \c lex and \c yacc tools. + + The \c lex_yacc module allows you to create scanners and parsers via the POSIX tools \c lex + and \c yacc, respectively. These tools are closely related and share a number of properties, + which is why they are represented by a single module. + + \section2 Relevant File Tags + \target filetags-lexyacc + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"lex.input"} + \li \c{*.l} + \li 1.6 + \li Source files with this tag serve as inputs to the \c lex tool. + \row + \li \c{"yacc.input"} + \li \c{*.y} + \li 1.6 + \li Source files with this tag serve as inputs to the \c yacc tool. + \endtable +*/ + +/*! + \qmlproperty bool lex_yacc::enableCompilerWarnings + \since Qbs 1.8 + + Whether compiler warnings are displayed. + + Because \c lex and \c yacc are known to produce files that will trigger + compiler warnings, such warnings are suppressed by default. Set this + property to \c true if you want to see them. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string lex_yacc::lexBinary + + The file path of the \c lex tool. + + \defaultvalue \c{"lex"} +*/ + +/*! + \qmlproperty stringList lex_yacc::lexFlags + + Additional command-line options for the \c lex tool. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string lex_yacc::lexOutputFilePath + + The output file for the \c lex tool. + + This corresponds to \c{%option outfile} in the .l file. + If \c{%option outfile} is set in the .l file then this property is ignored. + + \defaultvalue \c undefined + \since 1.12 +*/ + +/*! + \qmlproperty string lex_yacc::outputTag + + The file tag for the generated scanner and parser sources. + + Use \l{filetags-cpp}{"cpp"} if you want to use a C++ compiler on them. + + \defaultvalue \l{filetags-cpp}{"c"} +*/ + +/*! + \qmlproperty bool lex_yacc::uniqueSymbolPrefix + + If this property is \c true, the prefix \c yy normally used for the + generated lexer and parser functions is replaced by the base name of the + file provided as input to \c lex and \c yacc, respectively. + + Enable this property if you want to use more than one lexer or parser in a + single product. + + \note Enabling this property requires that the associated lexer and scanner + source files have the same base name. It also assumes a variant of \c lex + that supports the non-POSIX option \c{-P}, such as \c flex. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string lex_yacc::yaccBinary + + The file path of the \c yacc tool. + + \defaultvalue \c{"yacc"} +*/ + +/*! + \qmlproperty stringList lex_yacc::yaccFlags + + Additional command-line options for the \c yacc tool. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string lex_yacc::yaccOutputFilePath + + Main output file for the \c yacc tool. + + This corresponds to \c{%output} in the .y file. + If \c{%output} is set in the .y file then this property is ignored. + + \defaultvalue \c undefined + \since 1.12 +*/ diff --git a/doc/reference/modules/nodejs-module.qdoc b/doc/reference/modules/nodejs-module.qdoc new file mode 100644 index 00000000..8b3166a8 --- /dev/null +++ b/doc/reference/modules/nodejs-module.qdoc @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype nodejs + \inqmlmodule QbsModules + \since Qbs 1.3 + + \brief Provides Node.js support. + + The \c nodejs module contains support for running \l{Node.js} applications + from \QBS. +*/ + +/*! + \qmlproperty path Node.js::applicationFile + + The input JavaScript file whose corresponding output will be executed when + running the Node.js application. If this property is \c{undefined}, the + product will not be runnable. + + \nodefaultvalue +*/ diff --git a/doc/reference/modules/nsis-module.qdoc b/doc/reference/modules/nsis-module.qdoc new file mode 100644 index 00000000..d2b979ea --- /dev/null +++ b/doc/reference/modules/nsis-module.qdoc @@ -0,0 +1,227 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype nsis + \inqmlmodule QbsModules + \since Qbs 1.2 + + \brief Provides Nullsoft Scriptable Install System support. + + The \c nsis module contains properties and rules for building EXE installers + for Windows using the Nullsoft Scriptable Install System (NSIS). + + This module is available on all platforms. + + \note A typical NSIS script includes an \c OutFile command to set the + filename of the generated installer executable. However, \QBS overrides any + \c OutFile commands found in the script, and therefore, you must use the + \l{Product::targetName}{product.targetName} property to set the filename. + + \section2 Relevant File Tags + \target filetags-nsis + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"nsh"} + \li \c{*.nsh} + \li 1.2 + \li This tag is attached to NSIS header files. + \row + \li \c{"nsi"} + \li \c{*.nsi} + \li 1.2 + \li This tag is attached to NSIS script files. + \row + \li \c{"nsissetup"} + \li - + \li 1.2 + \li The rule that creates the NSIS setup executable attaches this tag to its output + artifact. + \endtable +*/ + +/*! + \qmlproperty stringList nsis::defines + + A list of preprocessor macros that get passed to the compiler. + + To set macro values, use the following syntax: + + \badcode + cpp.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"'] + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool nsis::disableConfig + + Whether to exclude \c nsisconf.nsh. + + Generally, you do not need to set this property. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool nsis::enableQbsDefines + + Whether to define preprocessor macros corresponding to the values from the + \l{Project}{project} and \l{Product}{product} objects. + + When building a 64-bit package, the preprocessor variable \c{Win64} will + also be defined. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty string nsis::warningLevel + + The severity of the warnings to emit. The higher the level, the more + warnings will be shown. + + The levels \c{none}, \c{errors}, \c{warnings}, \c{info}, and \c{all} + correspond to the NSIS verbosity levels 0 through 4, inclusive. \c{normal} + corresponds to the default level. + + \defaultvalue \c{"normal"} +*/ + +/*! + \qmlproperty stringList nsis::compilerFlags + + A list of additional flags for the NSIS compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string nsis::compressor + + The compression algorithm used to compress files and data in the installer. + + Setting this property overrides any \c SetCompressor command in the NSI file + being compiled. + + Possible values include: \c{"default"}, \c{"zlib"}, \c{"zlib-solid"}, + \c{"bzip2"}, \c{"bzip2-solid"}, \c{"lzma"}, \c{"lzma-solid"}. + + \defaultvalue \c{"default"} +*/ + +/*! + \qmlproperty string nsis::version + + The NSIS version. Consists of four numbers separated by dots. For example, + \c "2.46.0.0". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int nsis::versionMajor + + The NSIS major version. + + \defaultvalue \c{versionParts[0]} +*/ + +/*! + \qmlproperty int nsis::versionMinor + + The NSIS minor version. + + \defaultvalue \c{versionParts[1]} +*/ + +/*! + \qmlproperty list nsis::versionParts + + The NSIS version as a list. + + For example, the NSIS version 2.46.0.0 would correspond to a value of + \c[2, 46, 0, 0]. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty int nsis::versionPatch + + The NSIS patch level. + + \defaultvalue \c{versionParts[2]} +*/ + +/*! + \qmlproperty int nsis::versionBuild + + The fourth NSIS version number component. + + \defaultvalue \c{versionParts[3]} +*/ + +/*! + \qmlproperty path nsis::toolchainInstallPath + + The NSIS installation directory. + + Determined by searching from the known registry keys and known installation + paths until a match is found. + + This property should not normally need to be changed. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string nsis::compilerName + + The name of the compiler binary. + + This property should not normally need to be changed. + + \defaultvalue \c{"makensis"} +*/ + +/*! + \qmlproperty string nsis::compilerPath + + The directory where the compiler binary is located. + + This property should not normally need to be changed. + + \defaultvalue \l{nsis::}{compilerName} +*/ diff --git a/doc/reference/modules/pkgconfig-module.qdoc b/doc/reference/modules/pkgconfig-module.qdoc new file mode 100644 index 00000000..cd24257f --- /dev/null +++ b/doc/reference/modules/pkgconfig-module.qdoc @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype pkgconfig + \inqmlmodule QbsModules + \since 1.13 + + \brief Allows to configure the pkg-config tool. + + The \c pkgconfig module is used to fine-tune the behavior of the \c {pkg-config} tool, + which is + \l{How do I build against libraries that provide pkg-config files?}{potentially employed} + when looking up dependencies. +*/ + +/*! + \qmlproperty string pkgconfig::executableFilePath + + The path to the \c {pkg-config} executable. + + \defaultvalue auto-detected +*/ + +/*! + \qmlproperty stringList pkgconfig::libDirs + + Set this if you need to overwrite the default search directories. The values + given here will be forwarded to the tool via the \c PKG_CONFIG_LIBDIR environment + variable. + \note You do not need to set this for cross-compilation in order to point + \c {pkg-config} to the sysroot. \QBS does that for you. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool pkgconfig::staticMode + + If this property is \c true, then calls to \c{pkg-config} will include the + \c{--static} option. Set this if your product is to be linked statically. + + \defaultvalue \c false +*/ + +/*! + \qmlproperty path pkgconfig::sysroot + + This property controls the value of the \l{PkgConfigProbe::sysroot}{PkgConfigProbe.sysroot} + property. + + Set this property if you need to overwrite the default search sysroot path used by + \c pkg-config. + + This can be useful if \c pkg-config files are located in the directory other than qbs.sysroot. + This is the case on macOS platform - all XCode profiles are sysrooted to the SDK + directory, but \c pkg-config is typically intalled using Brew and resides in the + \c /usr/local directory. + + Setting this property to \c undefined or empty (\c "") value will use pkg-config's default + search paths: + \code + qbs build modules.pkgconfig.sysroot:undefined + \endcode + + \defaultvalue \c "" on macOS, \c qbs.sysroot on other platforms +*/ diff --git a/doc/reference/modules/protobufcpp-module.qdoc b/doc/reference/modules/protobufcpp-module.qdoc new file mode 100644 index 00000000..85851c4a --- /dev/null +++ b/doc/reference/modules/protobufcpp-module.qdoc @@ -0,0 +1,223 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype protobuf.cpp + \inqmlmodule QbsModules + \since Qbs 1.13 + + \brief Provides support for protocol buffers for the C++ language. + + The \c protobuf.cpp module provides support for generating C++ headers + and sources from proto definition files using the \l protoc tool. + + A simple qbs file that uses protobuf can be written as follows: + \code + CppApplication { + Depends { name: "protobuf.cpp" } + files: ["foo.proto", "main.cpp"] + } + \endcode + A generated header now can be included in the C++ sources: + \code + #include + + int main(int argc, char* argv[]) { + Foo bar; + bar.set_answer(42); + google::protobuf::ShutdownProtobufLibrary(); + return 0; + } + \endcode + + \section2 Relevant File Tags + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"protobuf.input"} + \li \c{*.proto} + \li 1.13.0 + \li Source files with this tag are considered inputs to the \c protoc compiler. + \row + \li \c{"protobuf.grpc"} + \li + \li 1.14.0 + \li Source files with this tag are considered as gRPC files. + \row + \li \c{"protobuf.hpp"} + \li + \li 1.18.0 + \li This tag is attached to the header files generated by \c protoc compiler. + \endtable +*/ + +/*! + \qmlproperty string protobuf.cpp::compilerName + + The name of the protoc binary. + + \since Qbs 1.17 + \defaultvalue \c "protoc" +*/ + +/*! + \qmlproperty string protobuf.cpp::compilerPath + + The path to the protoc binary. + + Use this property to override the auto-detected location. + + \since Qbs 1.17 + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.cpp::grpcIncludePath + + The path where grpc++ headers are located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.cpp::grpcLibraryPath + + The path where the grpc++ library is located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty pathList protobuf.cpp::importPaths + + The list of imports that are passed to the \c protoc tool via the \c --proto_path option. + These imports should contain the proto files. They are used to determine + the relative structure of the generated files. + \note The paths are passed to \c protoc in the same order as specified in this property and + \c protoc output may differ depending on that order. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string protobuf.cpp::includePath + + The path where protobuf C++ headers are located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.cpp::libraryPath + + The path where the protobuf C++ library is located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.cpp::outputDir + \readonly + + The directory where the \c protoc compiler generated files are placed. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ + +/*! + \qmlproperty bool protobuf.cpp::useGrpc + + Whether to use gRPC framework. + + Use this property to enable support for the modern open source high performance RPC + framework by Google, gRPC (\l{https://www.grpc.io}). + + A simple qbs file that uses grpc can be written as follows: + \code + CppApplication { + Depends { name: "protobuf.cpp" } + protobuf.cpp.useGrpc: true + files: ["main.cpp"] + Group { + files: "grpc.proto" + fileTags: "protobuf.grpc" + } + } + \endcode + + \note that \c protobuf.grpc tag should be assigned manually because gRPC uses same \c *.proto + files and \QBS can't detect whether to generate gRPC or \c protobuf. + + The following \c grpc.proto file... + \code + syntax = "proto3"; + + package Qbs; + + message Request { + string name = 1; + } + + message Response { + string name = 1; + } + + service Grpc { + rpc doWork(Request) returns (Response) {} + } + \endcode + + ...can be used in the C++ sources as follows: + \code + #include + + class Service final : public Qbs::Grpc::Service + { + grpc::Status doWork( + grpc::ServerContext* context, + const Qbs::Request* request, + Qbs::Response* reply) override + { + (void)context; + reply->set_name(request->name()); + return grpc::Status::OK; + } + }; + \endcode + + \defaultvalue \c false +*/ diff --git a/doc/reference/modules/protobufnanopb-module.qdoc b/doc/reference/modules/protobufnanopb-module.qdoc new file mode 100644 index 00000000..75c87ba5 --- /dev/null +++ b/doc/reference/modules/protobufnanopb-module.qdoc @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype protobuf.nanopb + \inqmlmodule QbsModules + \since Qbs 1.18 + + \brief Provides support for protocol buffers for embedded systems. + + The \c protobuf.nanopb module provides support for generating nanopb C headers + and sources from proto definition files using the \l nanopb plugin for the + \l protoc tool suitable for embedded systems. + + A simple qbs file that uses protobuf can be written as follows: + \code + CppApplication { + Depends { name: "protobuf.nanopb" } + files: ["foo.proto", "main.cpp"] + } + \endcode + A generated header now can be included in the C++ sources: + \code + #include + + int main(int argc, char* argv[]) { + Foo bar; + bar.has_answer = true; + bar.answer = 42; + return 0; + } + \endcode + + Nanopb .options files to define nanopb specific proto options are supported. + + \section2 Relevant File Tags + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"protobuf.input"} + \li \c{*.proto} + \li 1.13.0 + \li Source files with this tag are considered inputs to the \c protoc compiler. + \row + \li \c{"protobuf.hpp"} + \li + \li 1.18.0 + \li This tag is attached to the header files generated by \c protoc compiler. + \endtable +*/ + +/*! + \qmlproperty string protobuf.nanopb::compilerName + + The name of the protoc binary. + + \defaultvalue \c "protoc" +*/ + +/*! + \qmlproperty string protobuf.nanopb::compilerPath + + The path to the protoc binary. + + Use this property to override the auto-detected location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty pathList protobuf.nanopb::importPaths + + The list of imports that are passed to the \c protoc tool via the \c --proto_path option. + These imports should contain the proto files. They are used to determine + the relative structure of the generated files. + \note The paths are passed to \c protoc in the same order as specified in this property and + \c protoc output may differ depending on that order. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string protobuf.nanopb::includePath + + The path where protobuf nanopb C headers are located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.nanopb::libraryPath + + The path where the protobuf nanopb runtime library is located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.nanopb::outputDir + \readonly + + The directory where the \c protoc compiler generated files are placed. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ + +/*! + \qmlproperty string protobuf.nanopb::pluginName + + The name of the nanopb protoc plugin. + + \defaultvalue \c "protoc-gen-nanopb" +*/ + +/*! + \qmlproperty string protobuf.nanopb::pluginPath + + The path to the nanopb protoc plugin. + + Use this property to override the auto-detected location. + + \defaultvalue \c auto-detected +*/ diff --git a/doc/reference/modules/protobufobjc-module.qdoc b/doc/reference/modules/protobufobjc-module.qdoc new file mode 100644 index 00000000..3666cdb8 --- /dev/null +++ b/doc/reference/modules/protobufobjc-module.qdoc @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype protobuf.objc + \inqmlmodule QbsModules + \since Qbs 1.13 + + \brief Provides support for protocol buffers for the Objective-C language. + + The \c protobuf.objc module provides support for generating Objective-C + headers and sources from proto definition files using the \l protoc tool. + + \section2 Relevant File Tags + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"protobuf.input"} + \li \c{*.proto} + \li 1.13.0 + \li Source files with this tag are considered inputs to the \c protoc compiler. + \row + \li \c{"protobuf.hpp"} + \li + \li 1.18.0 + \li This tag is attached to the header files generated by \c protoc compiler. + \endtable +*/ + +/*! + \qmlproperty string protobuf.objc::compilerName + + The name of the protoc binary. + + \since Qbs 1.17 + \defaultvalue \c "protoc" +*/ + +/*! + \qmlproperty string protobuf.objc::compilerPath + + The path to the protoc binary. + + Use this property to override the auto-detected location. + + \since Qbs 1.17 + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty pathList protobuf.objc::importPaths + + The list of imports that are passed to the \c protoc tool via the \c --proto_path option. + These imports should contain the proto files. They are used to determine + the relative structure of the generated files. + \note The paths are passed to \c protoc in the same order as specified in this property and + \c protoc output may differ depending on that order. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string protobuf.objc::includePath + + The path where protobuf Objective-C headers are located. Set this property + to override the default location. + + \note If frameworkPath is specified, this property has no effect. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.objc::libraryPath + + \note If frameworkPath is specified, this property has no effect. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.objc::frameworkPath + + The path where \c Protobuf.framework is located. Set this property to override the + default location. + + \defaultvalue \c auto-detected +*/ + +/*! + \qmlproperty string protobuf.objc::outputDir + \readonly + + The directory where the \c protoc compiler generated files are placed. + + The value of this property is automatically set by \QBS and cannot be + changed by the user. +*/ diff --git a/doc/reference/modules/qbs-module.qdoc b/doc/reference/modules/qbs-module.qdoc new file mode 100644 index 00000000..7ab8fd50 --- /dev/null +++ b/doc/reference/modules/qbs-module.qdoc @@ -0,0 +1,819 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype qbs + \inqmlmodule QbsModules + \since Qbs 1.0 + + \brief Comprises general properties. + + The \c qbs module is implicitly loaded in every product. It contains properties of the current + build environment, independent of the used programming languages and toolchains. + + \section2 Installation Properties + + Typically, you use \l{Group} items to specify the target directories for + installing files. To install a group of files, set the \l{qbs::install} + {qbs.install} property of the Group to \c true. The value of + \l{qbs::installDir}{qbs.installDir} specifies the path to the directory + where the files will be installed. You can specify a base directory for all + installation directories as the value of \l{qbs::installPrefix} + {qbs.installPrefix}. + + For example, the following properties specify where a set of QML files and + an application executable are installed on Windows and Linux: + + \badcode + Application { + name: "myapp" + Group { + name: "Runtime resources" + files: "*.qml" + qbs.install: true + qbs.installDir: condition: qbs.targetOS.contains("unix") + ? "share/myapp" : "resources" + } + Group { + name: "The App itself" + fileTagsFilter: "application" + qbs.install: true + qbs.installDir: "bin" + } + qbs.installPrefix: condition: qbs.targetOS.contains("unix") + ? "usr/local" : "MyApp" + } + \endcode + + On Windows, the QML files will ultimately get installed in + \c{MyApp\resources} and the application executable in \c MyApp\bin, + for instance under \c{C:\Program Files}. On Linux, the QML files will be + installed in \c /usr/local/share/myapp and the executable in + \c /usr/local/bin. + + By default, \l{qbs::installRoot}{qbs.installRoot} creates the + \c install-root directory in the build directory for packaging the binaries + before installation. It is a temporary directory that is usually not + available when the application is run, and it should therefore not be set in + the project files. You can override the default value from the command line, + as described in \l{Installing Files}. + + \section2 Multiplexing Properties + + The following properties are specific to \l{Multiplexing} + {product multiplexing}: + + \list + \li \l{qbs::}{architectures} + \li \l{qbs::}{buildVariants} + \li \l{qbs::}{profiles} + \endlist +*/ + +/*! + \qmlproperty string qbs::configurationName + \since Qbs 1.6 + \readonly + + The name of the current build configuration. + + The build configuration is set via the command line parameter \c + config. For more information, see \l{build}{build}. + + \defaultvalue \c{"default"} +*/ + +/*! + \qmlproperty string qbs::buildVariant + + The name of the build variant for the current build. + + Possible values are \c{"debug"}, \c{"release"} and \c{"profiling"}. + A debug build usually contains additional debug symbols that are needed for + debugging the application and has optimizations turned off. A profiling + build usually contains debug symbols and has optimizations turned on. This + is useful for profiling tools or when you need to retain debug symbols + in a release build. A release build is a build without debug information and + with optimizations enabled. + + \defaultvalue \c{"release"} if + \l{qbs::configurationName}{qbs.configurationName} is \c{"release"}. Otherwise + \c{"debug"} +*/ + +/*! + \qmlproperty bool qbs::debugInformation + + Whether to generate debug information. + + \defaultvalue \c{true} if \l{qbs::buildVariant}{qbs.buildVariant} is \c{"debug"} or + \c{"profiling"}. Otherwise \c{false}. +*/ + +/*! + \qmlproperty bool qbs::enableDebugCode + + Whether to enable debug functionality in the product. Not to be confused + with generation of debug symbols or the code optimization level. + + The property changes the following things when enabled: + \list + \li Passes a flag to the Windows linker to link against a debug + Windows CRT (common runtime) library + (for example /MTd instead of /MT) + \endlist + + The property changes the following things when disabled: + \list + \li Passes the \c{NDEBUG} define to the compiler + \endlist + + Typically, this property is enabled for debug builds and disabled for + release or profiling builds. + + \defaultvalue \c{true} for debug builds, \c{false} otherwise. +*/ + +/*! + \qmlproperty string qbs::optimization + + The general type of optimization that should be performed by all toolchains. + + Allowed values are: + + \list + \li \c{"fast"} + \li \c{"none"} + \li \c{"small"} + \endlist + + \defaultvalue \c{"none"} if \l{qbs::buildVariant}{qbs.buildVariant} is \c{"debug"}. + Otherwise \c{"fast"}. +*/ + +/*! + \qmlproperty string qbs::targetPlatform + \since 1.11 + + The OS you want to build the project for. + + This property is typically set in a profile or for a particular product + where the target OS is always known (such as an Apple Watch app written in + native code). + + For example, a profile used for building for the iOS Simulator platform will have this + property set to the \c ios-simulator value: + \code + profiles.xcode-iphonesimulator.qbs.targetPlatform: "ios-simulator" + \endcode + + You should generally treat this property as \e{write-only} and avoid using + it to test for the current target OS. Instead, use the \l{qbs::}{targetOS} + property for conditionals. + + \section2 Relation between targetPlatform and targetOS + + This table describes the possible values and matching between the \c targetPlatform + and the \l{qbs::}{targetOS} properties: + \table + \header + \li Target Platform + \li Target OS + \row + \li \c{"aix"} + \li \c{["aix", "unix"]} + \row + \li \c{"android"} + \li \c{["android", "linux", "unix"]} + \row + \li \c{"dos"} + \li \c{["dos"]} + \row + \li \c{"freebsd"} + \li \c{["freebsd", "bsd", "unix"]} + \row + \li \c{"haiku"} + \li \c{["haiku"]} + \row + \li \c{"hpux"} + \li \c{["hpux", "unix"]} + \row + \li \c{"hurd"} + \li \c{["hurd", "unix"]} + \row + \li \c{"integrity"} + \li \c{["integrity", "unix"]} + \row + \li \c{"ios"} + \li \c{["ios", "darwin", "bsd", "unix"]} + \row + \li \c{"ios-simulator"} + \li \c{["ios-simulator", "ios", "darwin", "bsd", "unix"]} + \row + \li \c{"linux"} + \li \c{["linux", "unix"]} + \row + \li \c{"lynx"} + \li \c{["lynx"]} + \row + \li \c{"macos"} + \li \c{["macos", "darwin", "bsd", "unix"]} + \row + \li \c{"netbsd"} + \li \c{["netbsd", "bsd", "unix"]} + \row + \li \c{"openbsd"} + \li \c{["openbsd", "bsd", "unix"]} + \row + \li \c{"os2"} + \li \c{["os2"]} + \row + \li \c{"qnx"} + \li \c{["qnx", "unix"]} + \row + \li \c{"solaris"} + \li \c{["solaris", "unix"]} + \row + \li \c{"tvos"} + \li \c{["tvos", "darwin", "bsd", "unix"]} + \row + \li \c{"tvos-simulator"} + \li \c{["tvos-simulator", "tvos", "darwin", "bsd", "unix"]} + \row + \li \c{"unix"} + \li \c{["unix"]} + \row + \li \c{"vxworks"} + \li \c{["vxworks"]} + \row + \li \c{"watchos"} + \li \c{["watchos", "darwin", "bsd", "unix"]} + \row + \li \c{"watchos-simulator"} + \li \c{["watchos-simulator", "watchos", "darwin", "bsd", "unix"]} + \row + \li \c{"windows"} + \li \c{["windows"]} + \row + \li \c{"none"} + \li \c{["none"]} + \row + \li \c{undefined} + \li \c{[]} + \endtable + + \note The "none" value is usually used for a bare-metal platforms. + + \sa {Target Platforms} + + \defaultvalue \l{platform}{Host.platform()} +*/ + +/*! + \qmlproperty string qbs::architecture + + The target platform's processor architecture. + + \c{undefined} indicates that the target platform is architecture-independent + (for example the CLR or JVM). + + This property is typically set in a profile. + + Commonly used values are: \c{"x86"}, \c{"x86_64"}, and \c{"arm"}. + + \section2 Supported Processor Architectures + + This table describes the possible values of the \l{qbs::}{architecture} property: + \table + \header + \li Architecture + \li Description + \row + \li \c{"78k"} + \li 16- and 8-bit accumulator-based register-bank CISC architecture + microcontroller family manufactured by Renesas Electronics + \row + \li \c{"arm"} + \li 32-bit RISC architecture for computer processors + developed by Acorn RISC Machine + \note There are a lot of sub-variants of the ARM architecture. + Some specialized \QBS modules differentiate between them, + making use of values such as \c "armv7a". Please consult the + respective module-specific documentation for information + on what kind of value to use. + \row + \li \c{"arm64"} + \li 64-bit RISC architecture for computer processors + developed by Acorn RISC Machine + \row + \li \c{"avr"} + \li 8-bit modified Harvard RISC architecture microcontroller + family manufactured by Microchip Technology + \row + \li \c{"avr32"} + \li 32-bit RISC architecture microcontroller family developed by Atmel + \row + \li \c{"c166"} + \li 16-bit architecture microcontroller family developed by Infineon + \row + \li \c{"cr16"} + \li 16-bit compact RISC architecture microcontroller family + developed by National Semiconductor + \row + \li \c{"e2k"} + \li 512-bit Russian wide VLIW microprocessor developed by Moscow Center + of SPARC Technologies (MCST) and fabricated by TSMC + \row + \li \c{"hcs8"} + \li 8-bit HC08 and S08 microcontroller family from Freescale Semiconductor + \row + \li \c{"hcs12"} + \li 16-bit HC12 and S12 microcontroller family from Freescale Semiconductor + \row + \li \c{"ia64"} + \li 64-bit ISA architecture of the Itanium family processors + developed by Intel + \row + \li \c{"m16c"} + \li 16-bit CISC microcontrollers featuring high ROM code + efficiency manufactured by Renesas Electronics + \row + \li \c{"m32c"} + \li 32- and 16-bit CISC microcontrollers featuring high ROM code + efficiency manufactured by Renesas Electronics + \row + \li \c{"m32r"} + \li 32-bit RISC microcontrollers for general industrial and + car-mounted systems, digital AV equipment, digital imaging + equipment manufactured by Renesas Electronics + \row + \li \c{"m68k"} + \li 16- and 32-bit CISC microprocessor, developed by Motorola + Semiconductor Products Sector, and further improved as ColdFire + architecture developed by NXP + \row + \li \c{"mcs251"} + \li 8-, 16-, and 32-bit microcontroller family which is a next binary + compatible generation for the \c "mcs51" family + \row + \li \c{"mcs51"} + \li 8-bit Harvard architecture microcontroller family developed by Intel + \row + \li \c{"mips"} + \li 32-bit RISC microprocessor without interlocked pipelined stages + architecture developed by MIPS Computer Systems + \row + \li \c{"mips64"} + \li 64-bit RISC microprocessor without interlocked pipelined stages + architecture developed by MIPS Computer Systems + \row + \li \c{"msp430"} + \li 16-bit mixed-signal microcontroller family manufactured + by Texas Instruments + \row + \li \c{"ppc"} + \li 32-bit RISC architecture processor family developed by + Apple–IBM–Motorola alliance + \row + \li \c{"ppc64"} + \li 64-bit RISC architecture processor family developed by + Apple–IBM–Motorola alliance + \row + \li \c{"r32c"} + \li 32-bit CISC microcontrollers with improved code efficiency + and processing performance manufactured by Renesas Electronics + \row + \li \c{"rh850"} + \li 32-bit automotive microcontroller family manufactured + by Renesas Electronics + \row + \li \c{"riscv"} + \li Open and free standard instruction set architecture based on established + RISC principles + \row + \li \c{"rl78"} + \li 16- and 8-bit accumulator-based register-bank CISC architecture + with 3-stage instruction pipelining microcontroller family manufactured + by Renesas Electronics + \row + \li \c{"rx"} + \li High performance 32-bit CISC microcontroller family manufactured + by Renesas Electronics + \row + \li \c{"s390x"} + \li 64- and 32-bit System/390 processor architecture developed by IBM + \row + \li \c{"sh"} + \li 32-bit RISC architecture processor family developed by Hitachi and + currently manufactured by Renesas Electronics + \row + \li \c{"sparc"} + \li 32-bit RISC architecture processor family developed by + Sun Microsystems and Fujitsu + \row + \li \c{"sparc64"} + \li 64-bit RISC architecture processor family developed by + Sun Microsystems and Fujitsu + \row + \li \c{"stm8"} + \li 8-bit microcontroller family manufactured by STMicroelectronics + \row + \li \c{"v850"} + \li 32-bit RISC microcontroller family manufactured by Renesas Electronics + \row + \li \c{"x86"} + \li 32-bit ISA architecture processor family developed by Intel + \row + \li \c{"x86_16"} + \li 16-bit ISA architecture processor family developed by Intel + \row + \li \c{"x86_64"} + \li 64-bit ISA architecture processor family developed by AMD + \row + \li \c{"xtensa"} + \li 32-bit architecture with a compact 16- and 24-bit instruction set + developed by Tensilica + \endtable + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList qbs::toolchain + + Contains the list of string values describing the toolchain and toolchain + family that is used to build a project. + + This property is deduced from the \l{qbs::}{toolchainType} property and is typically + used to test for a particular toolchain or toolchain family in conditionals: + + \code + Properties { + // flags for GCC + condition: qbs.toolchain.contains("gcc") + cpp.commonCompilerFlags: ... + } + Properties { + // flags for MSVC + condition: qbs.toolchain.contains("msvc") + cpp.commonCompilerFlags: ... + } + \endcode + + Unlike \l{qbs::}{toolchainType}, which contains a single value, \c qbs.toolchain + is a string list which also contains the toolchain family. This allows to make + conditions and checks simpler. For example, instead of: + + \code + (qbs.toolchainType === "xcode" || qbs.toolchainType === "clang" || qbs.toolchainType === "gcc") + \endcode + + use: + + \code + qbs.toolchain.contains("gcc") + \endcode + + since XCode, GCC and Clang belong to the \c "gcc" family. + + \section2 Relation between toolchainType and toolchain + + This table describes the possible values and matching between the \l{qbs::}{toolchainType} + and the \c toolchain properties: + \table + \header + \li Toolchain Type + \li Toolchain + \row + \li \c{"clang"} + \li \c{["clang", "llvm", "gcc"]} + \row + \li \c{"clang-cl"} + \li \c{["clang-cl", "msvc"]} + \row + \li \c{"cosmic"} + \li \c{["cosmic"]} + \row + \li \c{"dmc"} + \li \c{["dmc"]} + \row + \li \c{"gcc"} + \li \c{["gcc"]} + \row + \li \c{"iar"} + \li \c{["iar"]} + \row + \li \c{"keil"} + \li \c{["keil"]} + \row + \li \c{"llvm"} + \li \c{["llvm", "gcc"]} + \row + \li \c{"mingw"} + \li \c{["mingw", "gcc"]} + \row + \li \c{"msvc"} + \li \c{["msvc"]} + \row + \li \c{"qcc"} + \li \c{["qcc"]} + \row + \li \c{"sdcc"} + \li \c{["sdcc"]} + \row + \li \c{"watcom"} + \li \c{["watcom"]} + \row + \li \c{"xcode"} + \li \c{["xcode", "clang", "llvm", "gcc"]} + \endtable + + \nodefaultvalue +*/ + +/*! + \qmlproperty string qbs::toolchainType + \since Qbs 1.11 + + The toolchain that is going to be used for this build. + + For example, to build a project using the \c "clang" toolchain, simply do + \code + qbs build qbs.toolchainType:clang + \endcode + + You should generally treat this property as \e{write-only} and avoid using + it to test for the current toolchain. Instead, use the \l{qbs::}{toolchain} + property for conditionals. + + Typical values include: \c{"gcc"}, \c{"clang"}, \c{"clang-cl"}, \c{"mingw"}, + \c{"msvc"}, and \c{"xcode"}. Also see \l{Relation between toolchainType and toolchain}. + + By default, \c qbs.toolchainType is automatically detected based on the + \l{qbs::}{targetOS} property: + \table + \header + \li Target OS + \li Toolchain + \row + \li \c{"darwin"} + \li \c{"xcode"} + \row + \li \c{"freebsd"} + \li \c{"clang"} + \row + \li \c{"haiku"} + \li \c{"gcc"} + \row + \li \c{"qnx"} + \li \c{"qcc"} + \row + \li \c{"unix"} + \li \c{"gcc"} + \row + \li \c{"vxworks"} + \li \c{"gcc"} + \row + \li \c{"windows"} + \li \c{"msvc"} + \endtable + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string qbs::sysroot + + The \c sysroot of the target platform. + + This property is typically set in a profile for cross-compiling. + + \nodefaultvalue +*/ + +/*! + \qmlproperty path qbs::shellPath + \since Qbs 1.5 + + The platform-specific file path corresponding to the command line + interpreter. + + On Windows, this is the path to \c{cmd.exe}, which is held in the + \c{COMSPEC} environment variable (typically, + \c{C:/Windows/System32/cmd.exe}), + On Unix-like platforms, this is \c{/bin/sh}. + + \defaultvalue \c{"%COMSPEC%"} on Windows, \c{"/bin/sh"} on Unix +*/ + +/*! + \qmlproperty stringList qbs::targetOS + \readonly + + Contains the list of string values describing the OS and OS family that is + used to build a project. + + This property is calculated based on the \l{qbs::}{targetPlatform} property and is typically + used to test for a particular OS or OS family in conditionals: + \code + Group { + // Includes all Unix-like platforms, such as: Linux, BSD, Apple platforms and others. + condition: qbs.targetOS.contains("unix") + files: ... + } + Group { + // Includes all Apple platforms, such as macOS, iOS, and iOS Simulator. + condition: qbs.targetOS.contains("darwin") + files: ... + } + Group { + // Includes only macOS + condition: qbs.targetOS.contains("macos") + files: ... + } + \endcode + Avoid using \l{qbs::}{targetPlatform} for this purpose. For example, instead of: + + \code + qbs.targetPlatform === "macos" || qbs.targetPlatform === "ios" || qbs.targetPlatform === "tvos" || qbs.targetPlatform === "watchos" + \endcode + + use + + \code + qbs.targetOS.contains("darwin") + + \endcode + + However, in some cases using \l{qbs::}{targetPlatform} would be acceptable, such as + when the resulting condition would be simpler while still being correct: + + \code + qbs.targetPlatform === "linux" + \endcode + + versus + \code + qbs.targetOS.contains("linux") && !qbs.targetOS.contains("android") + \endcode + + For the complete list of possible values, see + \l{Relation between targetPlatform and targetOS}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string qbs::version + \readonly + \since Qbs 1.4.1 + + The version number of \QBS as a string. For example, \c "1.4.1". +*/ + +/*! + \qmlproperty int qbs::versionMajor + \readonly + \since Qbs 1.4.1 + + The major version number of \QBS. +*/ + +/*! + \qmlproperty int qbs::versionMinor + \readonly + \since Qbs 1.4.1 + + The minor version number of \QBS. +*/ + +/*! + \qmlproperty int qbs::versionPatch + \readonly + \since Qbs 1.4.1 + + The patch version number of \QBS. +*/ + +/*! + \qmlproperty bool qbs::install + + Whether to install a certain set of files. + + This property is typically set in a \l{Group} item to mark a number of files + as installable. + + \note Artifacts for which this property is enabled automatically receive the + file tag \c "installable". This is useful for writing packaging-related + rules. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string qbs::installSourceBase + \since Qbs 1.4 + + The base directory of the local files that are going to be installed. The + source base directory is omitted from the target directory path specified in + \l{qbs::}{installDir}. + + \defaultvalue The directory of the current file to be installed, relative to + the product's source directory. +*/ + +/*! + \qmlproperty string qbs::installDir + + The installation directory for the files of a \l{Product}{product} or a + \l{Group}. + + The value of this property is a path that is relative to \l{qbs::} + {installPrefix}. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string qbs::installPrefix + \since Qbs 1.1 + + The global installation prefix. It is implicitly prepended to all values of + \l{qbs::}{installDir}. + + The value of this property itself is relative to the \l{qbs::}{installRoot} + in the context of installation. + + \defaultvalue \c "/usr/local" on Unix, \c "" otherwise +*/ + +/*! + \qmlproperty string qbs::installRoot + \since Qbs 1.4 + + The global installation root. It is implicitly prepended to all values + of \l{qbs::}{installPrefix} in the context of installation. + + \note This property is fundamentally different from \l{qbs::}{installDir} + and \l{qbs::}{installPrefix} in that it must not be visible to the code + being built. In fact, the install root is often just a temporary location + used to package the binaries, which should therefore not assume they will be + in that location at run-time. For the same reason, this property + is usually not set from within project files. + + \defaultvalue \c{/install-root} +*/ + +/*! + \qmlproperty stringList qbs::architectures + \since Qbs 1.9 + + The architectures the product will be built for. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList qbs::buildVariants + \since Qbs 1.9 + + The build variants the product will be built for. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList qbs::profiles + \since Qbs 1.9 + + The profiles for which the product should be built. + + For each profile listed here, one instance of the product will be built + according to the properties set in the respective profile. + + \defaultvalue \l{Project::profile}{[project.profile]} +*/ diff --git a/doc/reference/modules/qnx-module.qdoc b/doc/reference/modules/qnx-module.qdoc new file mode 100644 index 00000000..a8ba7571 --- /dev/null +++ b/doc/reference/modules/qnx-module.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype qnx + \inqmlmodule QbsModules + \since Qbs 1.8 + + \brief Provides support for building QNX applications using the QNX SDK. + + The \c qnx module contains properties and rules for QNX development. + It has been tested with the QNX 6.5, 6.6, and 7.0 SDKs. +*/ + +/*! + \qmlproperty string qnx::sdkDir + + The SDK base directory. + + \defaultvalue Determined automatically if the QNX SDK is installed at one of + the standard locations, such as \c ~/qnx700, \c /opt/qnx700, or + \c C:\\qnx700. +*/ + +/*! + \qmlproperty string qnx::configurationDir + + The QNX configuration directory. + + Equivalent to the \c{QNX_CONFIGURATION} environment variable. + + \defaultvalue \c{~/.qnx} +*/ + +/*! + \qmlproperty string qnx::hostDir + + The QNX host directory. + + Equivalent to the \c{QNX_HOST} environment variable. + + You should not normally need to set this property as it will be set to an + appropriate value based on your host operating system and the installed + QNX SDK in \l{qnx::}{sdkDir}. + + \defaultvalue Determined automatically. +*/ + +/*! + \qmlproperty string qnx::targetDir + + The QNX target directory. + + Equivalent to the \c{QNX_TARGET} environment variable. + + You should not normally need to set this property as it will be set to an + appropriate value based on the installed QNX SDK in \l{qnx::}{sdkDir}. + + \defaultvalue Determined automatically. +*/ diff --git a/doc/reference/modules/qt-android_support-module.qdoc b/doc/reference/modules/qt-android_support-module.qdoc new file mode 100644 index 00000000..01d43ab9 --- /dev/null +++ b/doc/reference/modules/qt-android_support-module.qdoc @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.android_support + \inqmlmodule QbsModules + \brief Provides Qt support for the Android platform. + + The \c Qt.android_support module provides the glue for \QBS' + Qt and Android support. + It is automatically pulled in by \c Qt.core, so you do not need to + add an explicit dependency to it in your product, unless you want + to set one of its properties. +*/ + +/*! + \qmlproperty string Qt.android_support::qmlRootDir + + The root directory of the product's QML files. This information is passed to + the \c androiddeployqt tool, which will use it to decide which resources to + include in the APK file. + + \defaultvalue \c product.sourceDirectory +*/ + +/*! + \qmlproperty stringList Qt.android_support::deploymentDependencies + + Use this property to completely override the Qt deployment dependencies + of your app. Corresponds to qmake's ANDROID_DEPLOYMENT_DEPENDENCIES. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty stringList Qt.android_support::extraPlugins + + Additional non-asset files to be packaged. Corresponds to qmake's ANDROID_EXTRA_PLUGINS. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty stringList Qt.android_support::extraLibs + + Additional libs to be packaged and loaded on start-up (mind the order). + Corresponds to qmake's ANDROID_EXTRA_LIBS. + + \defaultvalue \c undefined +*/ + +/*! + \qmlproperty stringList Qt.android_support::qmlImportPaths + + Additional directories to search for QML imports. + + \defaultvalue \c undefined + \since 1.22 +*/ + +/*! + \qmlproperty bool Qt.android_support::verboseAndroidDeployQt + + Enable this property if you want verbose output from the + \c androiddeployqt tool. + + \defaultvalue \c false +*/ diff --git a/doc/reference/modules/qt-core-module.qdoc b/doc/reference/modules/qt-core-module.qdoc new file mode 100644 index 00000000..afc4a0f1 --- /dev/null +++ b/doc/reference/modules/qt-core-module.qdoc @@ -0,0 +1,470 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.core + \inqmlmodule QbsModules + \brief Provides Qt Core support. + + All other Qt modules have a dependency on the Qt.core module, and therefore + you do not need to list it in your dependencies if you depend on at least + one other \l{Qt Modules}{Qt module}. + + Some of the Qt.core properties only need to be defined if the respective + installation of Qt was built in some unusual way, for instance by setting + non-default \c configure flags. + + \section2 Relevant File Tags + \target filetags-qtcore + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"qch"} + \li n/a + \li 1.1 + \li This tag is attached to the output artifacts of the rule that runs the + \c qhelpgenerator tool. + \row + \li \c{"qdoc"} + \li \c{*.qdoc} + \li 1.1 + \li Source files with this tag trigger a re-execution of the rule running the \c qdoc + tool when their timestamp changes. + \row + \li \c{"qdocconf"} + \li \c{*.qdocconf} + \li 1.1 + \li Source files with this tag trigger a re-execution of the rule running the \c qdoc + tool when their timestamp changes. + \row + \li \c{"qdocconf-main"} + \li - + \li 1.1 + \li Source files with this tag serve as inputs to the rule running the \c qdoc tool. + \row + \li \c{"qdoc-output"} + \li n/a + \li 1.5 + \li Use this tag to match all \c qdoc outputs, for instance in a \l{Group} + using the \l{Group::fileTagsFilter}{group.fileTagsFilter} property. + \row + \li \c{"qhp"} + \li \c{*.qhp} + \li 1.1 + \li Files with this tag serve as inputs to the rule running the \c qhelpgenerator tool. + Such files are created by \c qdoc, but can also appear as source files. + \row + \li \c{"qm"} + \li n/a + \li 1.1 + \li This tag is attached to the output artifacts of the rule that runs the \c lrelease tool. + \row + \li \c{"qrc"} + \li \c{*.qrc} + \li 1.0 + \li Files with this tag serve as inputs to the rule running the \c rcc tool. + \row + \li \c{"qt_plugin_metadata"} + \li - + \li 1.0 + \li Source files with this tag trigger a re-execution of the rule running the \c moc + tool when their timestamp changes. + \row + \li \c{"qt.core.metatypes"} + \li n/a + \li 1.16 + \li This tag is attached to the JSON files that are potentially created if + \l{Qt.core::generateMetaTypesFile}{generateMetaTypesFile} is enabled. + \row + \li \c{"qt.core.resource_data"} + \li - + \li 1.7 + \li Source files with this tag serve as inputs to the rule creating \c qrc files. + \row + \li \c{"ts"} + \li \c{*.ts} + \li 1.0 + \li Files with this tag serve as inputs to the rule running the \c lrelease tool. + \row + \li \c{"mocable"} + \li - + \li 1.13 + \li Use this tag to force \QBS to run \c moc on the respective files, even though + they do not contain \c Q_OBJECT or a related macro. + \row + \li \c{"unmocable"} + \li - + \li 1.2 + \li Use this tag for files that \QBS should not run \c moc on, even though they contain + \c Q_OBJECT or a related macro. + \endtable +*/ + +/*! + \qmlproperty stringList Qt.core::availableBuildVariants + + The build variants that this Qt installation offers. + + \defaultvalue Set by \l{setup-qt}. +*/ + +/*! + \qmlproperty path Qt.core::binPath + + The path in which Qt tools such as \c qmake, \c moc, and so on are located. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Qt.core::combineMocOutput + + Whether the C++ sources created by \c moc are combined into a single C++ + file per product. For projects where many header files are to be handled by + \c moc, this can speed up compilation considerably. However, side effects + may occur as a result of merging translation units. + + \defaultvalue \l{cpp::combineCxxSources}{cpp.combineCxxSources} +*/ + +/*! + \qmlproperty bool Qt.core::enableBigResources + + Whether the Qt resource compiler is run in a two-pass fashion that supports + the creation of big resources. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty stringList Qt.core::config + + Corresponds to the default value of qmake's \c CONFIG variable. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty path Qt.core::docPath + + The path in which the Qt documentation is located. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Qt.core::enableKeywords + + Set this property to \c false if you do not want Qt to define the symbols + \c {signals}, \c {slots}, and \c {emit}. This can be necessary if your + project interacts with code that also defines such symbols. + + \defaultvalue \c true +*/ + +/*! + \qmlproperty bool Qt.core::frameworkBuild + + Whether Qt was built as a framework. This is only relevant for Darwin + systems. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Qt.core::generateMetaTypesFile + + If this property is enabled, a JSON file tagged as \c "qt.core.metatypes" will potentially + be generated from metatype information collected by \c moc. + + \nodefaultvalue + \since Qbs 1.16 +*/ + +/*! + \qmlproperty bool Qt.core::metaTypesInstallDir + + The directory to install the metatypes file into. If this property is empty or undefined, + the metatypes file will not be installed. If the + \l{Qt.core::generateMetaTypesFile}{generateMetaTypesFile} property is not \c true, then + this property has no effect. + + \nodefaultvalue + \since Qbs 1.16 +*/ + +/*! + \qmlproperty path Qt.core::incPath + + The base path of the Qt headers. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.core::libInfix + + The library infix can be set at Qt build time to change the name of Qt's + libraries. + + For example, if the infix is \c "Test", on Unix systems, the Qt Core library + will be in a file called \c{libQt5CoreTest.so} instead of the default + \c{libQt5Core.so}. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty path Qt.core::libPath + + The path in which the Qt libraries are located. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool Qt.core::lreleaseMultiplexMode + + If this property is \c true, \c lrelease will merge all \c .ts files into + one \c .qm file. Otherwise, one \c .qm file will be created for each \c .ts + file. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string Qt.core::lreleaseName + + The base name of the \c lrelease tool. Set this if your system uses a name + such as \c "lrelease-qt4". + + \defaultvalue \c{"lrelease"} +*/ + +/*! + \qmlproperty path Qt.core::mkspecPath + + The path in which the Qt \c mkspecs are located. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Qt.core::mocFlags + + A list of additional flags to \c moc. + + You will rarely need to set this property. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty string Qt.core::mocName + + The base name of the \c moc tool. + + Set this if your system uses a name such as \c "moc-qt4". + + \defaultvalue \c{"moc"} +*/ + +/*! + \qmlproperty string Qt.core::namespace + + The Qt namespace that can be set at build time via the \c configure script. + + By default, Qt is not built in a namespace. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Qt.core::pluginMetaData + + A list of additional plugin metadata. + + The elements of the list are key-value pairs separated by the \c = + character. + + A possible use case is to set the plugin URI when building a static QML + plugin: + + \badcode + Qt.core.pluginMetaData: ["uri=thePlugin"] + \endcode + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty path Qt.core::pluginPath + + The path in which the Qt plugins are located. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Qt.core::qdocEnvironment + + The environment for calls to \c qdoc. Typically, you will need to set some + variables here when running \c qdoc to build your project documentation. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.core::qdocName + + The base name of the \c qdoc tool. + + \defaultvalue \c{"qdoc3"} for Qt 4, \c{"qdoc"} otherwise. +*/ + +/*! + \qmlproperty string Qt.core::qmBaseName + + The base name of the \c .qm file to be built from the \c .ts files in the + product. + + This property is ignored if \l{Qt.core::}{lreleaseMultiplexMode} is \c false. + + \defaultvalue \l{Product::targetName}{product.targetName} +*/ + +/*! + \qmlproperty string Qt.core::qtBuildVariant + + Specifies the type of Qt libraries to build against: \c "debug" or + \c "release". + + \note On some systems, it is not possible to link code built in debug mode + against libraries built in release mode and vice versa. + + \defaultvalue The build variant of the code linking against Qt. If Qt does + not offer that build variant, the build variant offered by Qt is chosen + instead. +*/ + +/*! + \qmlproperty stringList Qt.core::qtConfig + + Corresponds to the default value of qmake's \c QT_CONFIG variable. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty path Qt.core::resourceSourceBase + + For files tagged as \l{filetags-qtcore}{qt.core.resource_data}, this + property determines which part of their path will end up in the generated + \c .qrc file. If this property is set to \c undefined, only the file name is + used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.core::resourcePrefix + + For files tagged as \l{filetags-qtcore}{qt.core.resource_data}, this + property determines the prefix under which they will be available in the + generated \c .qrc file. + + \defaultvalue \c{"/"} +*/ + +/*! + \qmlproperty string Qt.core::resourceFileBaseName + + For files tagged as \l{filetags-qtcore}{qt.core.resource_data}, this + property determines the base name of the generated \c .qrc file. + + If this property needs to be changed, it must be set in the corresponding + \l{Product}{product} rather than in a \l{Group}. + + \defaultvalue \l{Product::targetName}{product.targetName} +*/ + +/*! + \qmlproperty bool Qt.core::staticBuild + + Whether Qt was built statically. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.core::version + + The Qt version. + + Consists of three numbers separated by dots. For example "5.9.1". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int Qt.core::versionMajor + + The Qt major version. + + \defaultvalue \c{versionParts[0]} +*/ + +/*! + \qmlproperty int Qt.core::versionMinor + + The Qt minor version. + + \defaultvalue \c{versionParts[1]} +*/ + +/*! + \qmlproperty list Qt.core::versionParts + + The Qt version as a list. + + For example, Qt version 5.9.1 would correspond to a value of \c[5, 9, 1]. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty int Qt.core::versionPatch + + The Qt patch level. + + \defaultvalue \c{versionParts[2]} +*/ diff --git a/doc/reference/modules/qt-dbus-module.qdoc b/doc/reference/modules/qt-dbus-module.qdoc new file mode 100644 index 00000000..32e84f95 --- /dev/null +++ b/doc/reference/modules/qt-dbus-module.qdoc @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.dbus + \inqmlmodule QbsModules + \brief Provides Qt D-Bus support. + + The Qt.dbus module provides support for the Qt D-Bus module, which contains + classes for inter-process communication over the D-Bus protocol. + + \section2 Relevant File Tags + \target filetags-debus + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"qt.dbus.adaptor"} + \li - + \li 1.5 + \li Source files with this tag serve as inputs to the rule running the + \c qdbusxml2cpp tool, which will create an adaptor class. + \row + \li \c{"qt.dbus.interface"} + \li - + \li 1.5 + \li Source files with this tag serve as inputs to the rule running the + \c qdbusxml2cpp tool, which will create an interface class. + \endtable +*/ + +/*! + \qmlproperty string Qt.dbus::xml2cppName + + The base name of the \c qdbusxml2cpp tool. + + Set this property if your system uses a name different from the default + value. + + \defaultvalue \c{"qdbusxml2cpp"} +*/ + +/*! + \qmlproperty stringList Qt.dbus::xml2CppHeaderFlags + + A list of additional flags when running the \c qdbusxml2cpp tool to create + header files. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty stringList Qt.dbus::xml2CppSourceFlags + + A list of additional flags when running the \c qdbusxml2cpp tool to create + source files. + + \defaultvalue \c [] +*/ diff --git a/doc/reference/modules/qt-declarative-module.qdoc b/doc/reference/modules/qt-declarative-module.qdoc new file mode 100644 index 00000000..f247f334 --- /dev/null +++ b/doc/reference/modules/qt-declarative-module.qdoc @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.declarative + \inqmlmodule QbsModules + \brief Provides Qt Quick 1 support. + + The Qt.declarative module provides support for Qt Quick 1. + + \sa Qt.quick, Qt.qml +*/ + +/*! + \qmlproperty bool Qt.declarative::qmlDebugging + + Whether QML debugging support is compiled into your binaries. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string Qt.declarative::qmlImportsPath + + The absolute path to the directory where Qt's QML imports are installed. + + \defaultvalue Determined by \l{setup-qt}. +*/ + +/*! + \qmlproperty string Qt.declarative::qmlPath + + The absolute path to the directory where Qt's QML files are installed. + This property is left undefined for Qt 4. + + \defaultvalue Determined by \l{setup-qt}. +*/ diff --git a/doc/reference/modules/qt-gui-module.qdoc b/doc/reference/modules/qt-gui-module.qdoc new file mode 100644 index 00000000..ace3cce0 --- /dev/null +++ b/doc/reference/modules/qt-gui-module.qdoc @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.gui + \inqmlmodule QbsModules + \brief Provides Qt GUI support. + + The Qt.gui module provides support for the Qt GUI module, which contains + base classes for graphical user interface (GUI) components. + + \section2 Relevant File Tags + \target filetags-gui + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"ui"} + \li \c{*.ui} + \li 1.0 + \li Source files with this tag serve as inputs to the rule running the + \c uic tool. + \endtable +*/ + +/*! + \qmlproperty string Qt.gui::uicName + + The base name of the \c uic tool. + + Set this property if your system uses a name such as \c uic-qt4. + + \defaultvalue \c{"uic"} +*/ diff --git a/doc/reference/modules/qt-modules.qdoc b/doc/reference/modules/qt-modules.qdoc new file mode 100644 index 00000000..e3fee3c7 --- /dev/null +++ b/doc/reference/modules/qt-modules.qdoc @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qt-modules.html + \inmodule qbs-modules + + \title Qt Modules + + \brief Provides Qt support. + + The \c{Qt.*} modules contain properties and rules for Qt. + + Qt modules are generated by the \l[QML]{Qt} module provider. + + \section1 Creating Dependencies to Qt Modules + + The Qt modules are grouped using the prefix \c Qt. If your product depends + on the Qt.core and Qt.network modules, you could write: + + \code + Depends { name: "Qt.core" } + Depends { name: "Qt.network" } + \endcode + + Or, alternatively: + + \code + Depends { name: "Qt"; submodules: [ "core", "network" ] } + \endcode + + The Qt modules that have properties and relevant file tags are described in + separate topics. + + \section1 List of Submodules + + \table + \header + \li Submodule Name + \li Qt Module Name + \li Notes + \row + \li axcontainer + \li QAxContainer + \li This module is only available on Windows. + \row + \li axserver + \li QAxServer + \li This module is only available on Windows. + \row + \li concurrent + \li Qt Concurrent + \li + \row + \li \l{Qt.core}{core} + \li Qt Core + \li For more information, see \l{Qt.core}. + \row + \li \l{Qt.dbus}{dbus} + \li Qt D-Bus + \li For more information, see \l{Qt.dbus}. + \row + \li \l{Qt.declarative}{declarative} + \li Qt Quick 1 + \li Provides the \c{Qt Quick 1} module. For more information, see + \l{Qt.declarative}. + \row + \li designer + \li Qt Designer + \li + \row + \li enginio + \li Qt Enginio + \li + \row + \li \l{Qt.gui}{gui} + \li Qt GUI + \li For more information, see \l {Qt.gui}. + \row + \li help + \li Qt Help + \li You do not need this module for building \c qdoc documentation, + because that functionality is part of the Qt.core module. This + module is for using Qt classes such as \c QHelpEngine. + \row + \li multimedia + \li Qt Multimedia + \li + \row + \li multimediawidgets + \li Qt Multimedia Widgets + \li + \row + \li network + \li Qt Network + \li + \row + \li opengl + \li Qt OpenGL + \li + \row + \li phonon + \li Phonon (Qt 4 only) + \li + \row + \li printsupport + \li Qt Print Support + \li + \row + \li \l{Qt.quick}{quick} + \li Qt Quick 2 + \li Provides the \c{Qt Quick} module (Qt Quick 2). For more information, + see \l{Qt.quick}. + \row + \li quickcontrols2 + \li Qt Quick Controls 2 + \row + \li \l{Qt.qml}{qml} + \li Qt QML + \li For more information, see \l{Qt.qml}. + \row + \li qmltest + \li Qt Quick Test + \li + \row + \li script + \li Qt Script + \li + \row + \li \l{Qt.scxml}{scxml} + \li Qt Scxml + \li For more information, see \l {Qt.scxml}. + \row + \li sql + \li Qt SQL + \li + \row + \li svg + \li Qt SVG + \li + \row + \li testlib + \li Qt Test + \li + \row + \li webkit + \li Qt WebKit + \li + \row + \li webkitwidgets + \li Qt WebKit Widgets + \li + \row + \li widgets + \li Qt Widgets + \li + \row + \li xml + \li Qt XML + \li You do not need this module for the \c QXmlStreamReader and + \c QXmlStreamWriter classes, because those classes are a part of the + \c Qt.core module. This module provides the deprecated DOM and SAX + classes. + \row + \li xmlpatterns + \li Qt XML Patterns + \li + \li + \endtable +*/ diff --git a/doc/reference/modules/qt-plugin_support-module.qdoc b/doc/reference/modules/qt-plugin_support-module.qdoc new file mode 100644 index 00000000..05729182 --- /dev/null +++ b/doc/reference/modules/qt-plugin_support-module.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.plugin_support + \inqmlmodule QbsModules + \since Qbs 1.13.0 + \brief Allows to fine-tune which Qt plugins get pulled in. + + The \c Qt.plugin_support module provides properties that allow users to control + which Qt plugins to pull into a product. + This is mostly relevant if Qt was built statically, in which case the respective + plugins are static libraries that get linked into your application or library. +*/ + +/*! + \qmlproperty varList Qt.plugin_support::pluginsByType + + Set this property if you want to override the set of plugins for a certain + plugin type. For instance, to disable all image plugins except the JPEG + one: + \code + Qt.plugin_support.pluginsByType: ({imageformats: "qjpeg"}) + \endcode + For plugin types that are not specifically overridden like this, the value in + defaultPluginsByType is used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty var Qt.plugin_support::allPluginsByType + + Provides the complete set of plugins in a statically built Qt. + The value is a map. The keys are the plugin types, and the values + are lists of plugin names. + + \readonly +*/ + +/*! + \qmlproperty var Qt.plugin_support::defaultPluginsByType + + Provides the set of plugins that your application or library will + link to if you do not set pluginsByType. + The value is a map. The keys are the plugin types, and the values + are lists of plugin names. + The value depends on the Qt modules your product pulls in. + + \readonly +*/ + +/*! + \qmlproperty bool Qt.plugin_support::linkPlugins + + Controls whether plugins of a statically built Qt should be linked into the product. + + \defaultvalue \c true if the product is an application or shared library, \c false otherwise. + +*/ diff --git a/doc/reference/modules/qt-qml-module.qdoc b/doc/reference/modules/qt-qml-module.qdoc new file mode 100644 index 00000000..57b3661f --- /dev/null +++ b/doc/reference/modules/qt-qml-module.qdoc @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.qml + \inqmlmodule QbsModules + \brief Provides Qt QML support. + + The Qt.qml module provides support for the Qt QML module, which contains + classes for QML and JavaScript languages. + + \note If the current value of \l{qbs::architecture}{qbs.architecture} is not + supported by \c qmlcachegen, the QML cache file generator rule is disabled. + + \sa Qt.quick, Qt.declarative + + \section2 Relevant File Tags + \target filetags-qml + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"qt.qml.js"} + \li \c{*.js} + \li 1.10 + \li QML companion JavaScript files. Source files with this tag serve as + input for the QML cache file generator. + \row + \li \c{"qt.qml.qml"} + \li \c{*.qml} + \li 1.8 + \li Source files with this tag serve as inputs to the QML plugin + scanner. + \row + \li \c{"qt.qml.types"} + \li n/a + \li 1.16 + \li This tag is attached to the files created by the \c qmltyperegistrar + tool if the \l importName property is set. + \endtable +*/ + +/*! + \qmlproperty string Qt.qml::importName + + Setting this value triggers QML type registration via the \c qmltyperegistrar tool, + which results in the creation of a file with the tag \c{"qt.qml.types"}. + The given string is the name under which the registered types can be imported + by QML code that wants to use them. + + \note This functionality is only available with Qt 5.15 or later. + + \since Qbs 1.16 + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.qml::importVersion + + Specifies the version of the types to be registered. + Values consist of a major and an optional minor number, separated by dots. + This property has no effect if \l importName is not set. + + \since Qbs 1.16 + \defaultvalue \l {Product::version}{The product version} +*/ + +/*! + \qmlproperty string Qt.qml::typesFileName + + Specifies the name of the file that declares the types registered for this product. + For applications, the default value is \c{.qmltypes}, + where \c{} is the product's \l{Product::targetName}{target name}. + Otherwise, the default value is "plugins.qmltypes". + \note The naming conventions are still in flux. + When in doubt, consult the Qt documentation. + + This property has no effect if \l importName is not set. + + \since Qbs 1.16 +*/ + +/*! + \qmlproperty string Qt.qml::typesInstallDir + + The directory to install the qmltypes file into. If this property is empty or undefined, + the file will not be installed. + This property has no effect if \l importName is not set. + + \since Qbs 1.16 + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList Qt.qml::extraMetaTypesFiles + + Specifies extra metatypes files to pass to the \c qmltyperegistrar tool + via the \c{--foreign-types} option when registering QML types. + \note This property is only needed for external libraries, not products or modules + pulled via \c Depends items. In particular, you don't need to (and should not) + use it to collect the metatypes files of Qt modules. These are found automatically. + This property has no effect if \l importName is not set. + + \since Qbs 1.16 + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.qml::qmlImportScannerName + + The base name of the QML import scanner. + + Set this value if your system uses a name different from the default value. + + \defaultvalue \c{"qmlimportscanner"} +*/ + +/*! + \qmlproperty string Qt.qml::qmlPath + + The absolute path to the directory where Qt's QML files are installed. + + \defaultvalue Determined by \l{setup-qt}. +*/ + +/*! + \qmlproperty bool Qt.qml::generateCacheFiles + + Whether QML cache files are generated. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool Qt.qml::cachingEnabled + \readonly + + This property is \c true if \l{Qt.qml::}{generateCacheFiles} is \c{true} + and the platform supports QML cache generation. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string Qt.qml::qmlCacheGenPath + + The absolute path to the \c qmlcachegen executable. + + \defaultvalue Determined by \l{setup-qt}. +*/ + +/*! + \qmlproperty string Qt.qml::cacheFilesInstallDir + + The path to the directory where the cache files are installed. + + If this property is set, QML cache files are automatically installed. + + \nodefaultvalue +*/ diff --git a/doc/reference/modules/qt-quick-module.qdoc b/doc/reference/modules/qt-quick-module.qdoc new file mode 100644 index 00000000..5e6fa694 --- /dev/null +++ b/doc/reference/modules/qt-quick-module.qdoc @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.quick + \inqmlmodule QbsModules + \brief Provides Qt Quick 2 support. + + The Qt.quick module provides support for Qt Quick 2. + + \sa Qt.qml, Qt.declarative + + \section2 Relevant File Tags + \target filetags-quick + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"qt.quick.qrc"} + \li \c{*.qrc} + \li 1.10 + \li Qt resource files with this file tag will be picked up by the + Qt Quick compiler rule, and all QML files in the resource will be + compiled. + + This file tag will only be added automatically if the Qt Quick + compiler is available. + \endtable +*/ + +/*! + \qmlproperty bool Qt.quick::compilerAvailable + + Whether the Qt installation contains the Qt Quick compiler. + + \defaultvalue auto-detected + \since 1.10 +*/ + +/*! + \qmlproperty bool Qt.quick::useCompiler + + Whether to make use of the Qt Quick compiler. + + \defaultvalue \l compilerAvailable + \since 1.11 +*/ + +/*! + \qmlproperty bool Qt.quick::qmlDebugging + + Whether QML debugging support should be compiled into your binaries. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string Qt.quick::qmlImportsPath + + The absolute path to the directory where Qt's QML imports are installed. + + \defaultvalue Determined by \l{setup-qt}. +*/ + +/*! + \qmlproperty string Qt.quick::qmlPath + + The absolute path to the directory where Qt's QML files are installed. + + This property is left undefined for Qt 4. + + \defaultvalue Determined by \l{setup-qt}. +*/ diff --git a/doc/reference/modules/qt-scxml-module.qdoc b/doc/reference/modules/qt-scxml-module.qdoc new file mode 100644 index 00000000..b0092ae6 --- /dev/null +++ b/doc/reference/modules/qt-scxml-module.qdoc @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype Qt.scxml + \inqmlmodule QbsModules + \brief Provides Qt SCXML support. + + The Qt.scxml module provides support for the Qt SCXML module, which enables + creating state machines from SCXML files. + + \section2 Relevant File Tags + \target filetags-scxml + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"qt.scxml.compilable"} + \li - + \li 1.7 + \li Source files with this tag serve as inputs to the rule running the + Qt SCXML compiler, which will create a C++ class representing a + state machine. + \endtable +*/ + +/*! + \qmlproperty string Qt.scxml::className + + The class name of the generated state machine. + + By default, the compiler will use the \c name attribute of the input file's + \c{} tag. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.scxml::generateStateMethods + + If this property is \c true, the Qt SCXML compiler will generate read and notify methods + for states. + + \defaultvalue \c false + \since 1.11 +*/ + +/*! + \qmlproperty string Qt.scxml::namespace + + The C++ namespace in which to put the generated class. + + By default, the compiler will place the class in the global namespace. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string Qt.scxml::qscxmlcName + + The base name of the Qt SCXML compiler. + + Set this value if your system uses a name different from the default value. + + \defaultvalue \c{"qscxmlc"} +*/ diff --git a/doc/reference/modules/texttemplate-module.qdoc b/doc/reference/modules/texttemplate-module.qdoc new file mode 100644 index 00000000..4c354b26 --- /dev/null +++ b/doc/reference/modules/texttemplate-module.qdoc @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype texttemplate + \inqmlmodule QbsModules + \since Qbs 1.13 + + \brief Provides support for text template files. + + The \c texttemplate module provides support for text template files. + + \section2 Example + + Consider the following text file \e{greeting.txt.in}. + + \code + ${greeting} ${name}! + \endcode + + This can be used in a project like this: + + \code + Product { + type: ["text"] + files: ["greeting.txt.in"] + Depends { name: "texttemplate" } + texttemplate.dict: ({ + greeting: "Hello", + name: "World" + }) + } + \endcode + + Which will create the file \e{greeting.txt}. + + \code + Hello World! + \endcode + + + \section2 Placeholder Syntax + + A placeholder \c{${foo}} is replaced by its corresponding value in + \e{texttemplate.dict}. + Placeholder names consist of alphanumeric characters only. + + The placeholder \c{${$}} is always replaced with \c{$}. + If you need a literal \c{${foo}} in your template, use \c{${$}{foo}}. + + Placeholders that are not defined in the dictionary will produce an error. + + + \section2 Relevant File Tags + \target filetags-texttemplate + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"texttemplate.input"} + \li \c{*.in} + \li 1.13.0 + \li Source files with this tag serve as inputs for the text template rule. + \endtable +*/ + +/*! + \qmlproperty var texttemplate::dict + + The dictionary containing values for all keys used in the template file. + + \defaultvalue \c{{}} +*/ + +/*! + \qmlproperty string texttemplate::outputFileName + + The output file name that is assigned to produced artifacts. + + \defaultvalue Complete base name of the input file +*/ + +/*! + \qmlproperty string texttemplate::outputTag + + The output tag that is assigned to produced artifacts. + + \defaultvalue \c{"text"} +*/ diff --git a/doc/reference/modules/typescript-module.qdoc b/doc/reference/modules/typescript-module.qdoc new file mode 100644 index 00000000..f0f96774 --- /dev/null +++ b/doc/reference/modules/typescript-module.qdoc @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype typescript + \inqmlmodule QbsModules + \since Qbs 1.3 + + \brief Provides TypeScript support. + + The \c typescript module contains properties and rules for building + \l{TypeScript} applications and may be used in combination with the + \l{nodejs} module to run the applications directly from \QBS. +*/ + +/*! + \qmlproperty string typescript::warningLevel + + The severity of warnings to emit. The higher the level, the more warnings + will be shown. + + \c{pedantic} causes the TypeScript to emit warnings on expressions and + declarations with an implied \e any type. + + \defaultvalue \c{"normal"} +*/ + +/*! + \qmlproperty string typescript::targetVersion + + The ECMAScript target version for generated JavaScript code. + + If left undefined, the TypeScript \l{Compiler Options}{compiler default} is + used. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string typescript::moduleLoader + + If TypeScript modules are being used, the JavaScript module loading + mechanism to use in the generated JavaScript code. + + If left undefined, modules are not used. + + See \l{Compiler Options} for a list of possible values. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool typescript::stripComments + + Whether to remove comments from the generated JavaScript files. + + \defaultvalue \l{qbs::debugInformation}{!qbs.debugInformation} +*/ + +/*! + \qmlproperty bool typescript::generateDeclarations + + Whether to generate the corresponding \c .d.ts files during compilation. + These are TypeScript's equivalent of header files. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty bool typescript::generateSourceMaps + + Whether to generate the corresponding \c .map files during compilation. + + \defaultvalue \l{qbs::debugInformation}{qbs.debugInformation} +*/ + +/*! + \qmlproperty stringList typescript::compilerFlags + + A list of additional flags for the TypeScript compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool typescript::singleFile + + Whether to compile all TypeScript source files to a single JavaScript output + file. + + The default is to compile each TypeScript file to a corresponding JavaScript + file. This property is incompatible with \l{typescript}{moduleLoader}. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string typescript::version + + The TypeScript version. + + Consists of four numbers separated by dots. For example, "1.0.0.0". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int typescript::versionMajor + + The TypeScript major version. + + \defaultvalue \c{versionParts[0]} +*/ + +/*! + \qmlproperty int typescript::versionMinor + + The TypeScript minor version. + + \defaultvalue \c{versionParts[1]} +*/ + +/*! + \qmlproperty list typescript::versionParts + + The TypeScript version as a list. + + For example, TypeScript version 1.0 would correspond to a value of + \c[1, 0, 0, 0]. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty int typescript::versionPatch + + The TypeScript patch level. + + \defaultvalue \c{versionParts[2]} +*/ + +/*! + \qmlproperty int typescript::versionBuild + + The fourth TypeScript version number component. + + \defaultvalue \c{versionParts[3]} +*/ + +/*! + \qmlproperty path typescript::toolchainInstallPath + + The TypeScript installation directory. + + This property should not normally need to be changed if \c{tsc} is available + by searching the PATH environment variable. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string typescript::compilerName + + The name of the compiler binary. + + This property should not normally need to be changed. + + \defaultvalue \c{"tsc"} +*/ + +/*! + \qmlproperty string typescript::compilerPath + + The directory where the compiler binary is located. + + This property should not normally need to be changed. + + \defaultvalue \c{compilerName} +*/ diff --git a/doc/reference/modules/vcs-module.qdoc b/doc/reference/modules/vcs-module.qdoc new file mode 100644 index 00000000..fac0979a --- /dev/null +++ b/doc/reference/modules/vcs-module.qdoc @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype vcs + \inqmlmodule QbsModules + \since Qbs 1.10 + + \brief Provides support for version control systems. + + The \c vcs module provides the current state of the project's repository via + the \l{vcs::}{repoState} property. By default, a \c C header is also + generated, allowing for simple retrieval of the repository state directly + from within your C/C++ sources. This is useful to embed information into + binaries about the exact state of the repository from which they were built. + + For example: + + \code + #include + #include + + int main() + { + std::cout << "I was built from " << VCS_REPO_STATE << std::endl; + } + \endcode + + Above, a header file called \c{vcs-repo-state.h} is created, defining a + macro called \c VCS_REPO_STATE, which expands to a character constant + describing the current state of the repository. For Git, this would be the + current HEAD's commit hash. +*/ + +/*! + \qmlproperty string vcs::headerFileName + + The name of the C header file to be created. + + Set this to \c undefined if you do not want a header file to be generated. + + \defaultvalue \c{"vcs-repo-state.h"} +*/ + +/*! + \qmlproperty string vcs::repoDir + + The root directory of the repository. + + \defaultvalue The top-level project directory (\l{Project::sourceDirectory} + {project.sourceDirectory}). +*/ + +/*! + \qmlproperty string vcs::repoState + + The current state of the repository. + + For example, in Git this is the commit hash of the current HEAD. + + \nodefaultvalue +*/ + +/*! + \qmlproperty string vcs::toolFilePath + + Set this property if the tool has an unusual name in your local + installation, or if it is located in a directory that is not in the build + environment's \c PATH. + + \defaultvalue The file name of the version control tool corresponding to + \l{vcs::type}{type}. +*/ + +/*! + \qmlproperty string vcs::type + + The version control system used in the project. + + Currently, the supported values are \c{"git"} and \c{"svn"}. + + \defaultvalue auto-detected +*/ diff --git a/doc/reference/modules/wix-module.qdoc b/doc/reference/modules/wix-module.qdoc new file mode 100644 index 00000000..ab6a7497 --- /dev/null +++ b/doc/reference/modules/wix-module.qdoc @@ -0,0 +1,342 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmltype wix + \inqmlmodule QbsModules + \since Qbs 1.2 + + \brief Provides Windows Installer XML Toolset support. + + The \c wix module contains properties and rules for building MSI and + EXE setup packages with the \l{Windows Installer XML Toolset}. + + This module is available on all platforms. + + \section2 Relevant File Tags + \target filetags-wix + + \table + \header + \li Tag + \li Auto-tagged File Names + \li Since + \li Description + \row + \li \c{"msi"} + \li - + \li 1.2 + \li The rule that creates the Microsoft Installer setup file attaches this tag to its output + artifact. + \row + \li \c{"wixpdb"} + \li - + \li 1.2 + \li The rule that creates the Microsoft Installer setup file or WiX setup executable + attaches this tag to the associated debug symbol file. + \row + \li \c{"wixsetup"} + \li - + \li 1.2 + \li The rule that creates the WiX setup executable attaches this tag to its output artifact. + \row + \li \c{"wxi"} + \li \c{*.wxi} + \li 1.2 + \li This tag is attached to WiX include files. + \row + \li \c{"wxl"} + \li \c{*.wxl} + \li 1.2 + \li This tag is attached to WiX localization files. + \row + \li \c{"wxs"} + \li \c{*.wxs} + \li 1.2 + \li This tag is attached to WiX source files. + Each source file will be compiled into one WiX object file. + \endtable +*/ + +/*! + \qmlproperty bool wix::debugInformation + + Whether to generate debug information. + + \sa {qbs::debugInformation}{qbs.debugInformation} + + \defaultvalue \l{qbs::debugInformation}{qbs.debugInformation} +*/ + +/*! + \qmlproperty stringList wix::defines + + A list of preprocessor macros that get passed to the compiler. + + To set macro values, use the following syntax: + + \badcode + wix.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"'] + \endcode + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool wix::enableQbsDefines + + Whether to define preprocessor macros corresponding to values from the + project and product objects. + + When building a 64-bit package, the preprocessor variable \c{Win64} will + also be defined. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty bool wix::visualStudioCompatibility + + Whether to pass most of the same preprocessor macros to the compiler as + Visual Studio does. + + This allows easier authoring of WiX files that are compatible with both + \QBS and MSBuild. + + \defaultvalue \c{true} +*/ + +/*! + \qmlproperty pathList wix::includePaths + + A list of include paths. + + Relative paths are considered to be relative to the \c .qbs product file + they are used in. + + \nodefaultvalue +*/ + +/*! + \qmlproperty bool wix::treatWarningsAsErrors + + Whether warnings will be handled as errors and cause the build to fail. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty string wix::warningLevel + + The severity of warnings to emit. + + The higher the level, the more warnings will be shown. + + Possible values include: \c{"none"}, \c{"normal"}, \c{"pedantic"} + + \defaultvalue \c{"normal"} +*/ + +/*! + \qmlproperty bool wix::verboseOutput + + Whether to display verbose output from the compiler and linker. + + \defaultvalue \c{false} +*/ + +/*! + \qmlproperty stringList wix::compilerFlags + + A list of additional flags for the Candle compiler. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList wix::linkerFlags + + A list of additional flags for the Light linker. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList wix::cultures + + A list of localizations to include in the MSI. + + If left undefined, includes all localizations. + + \nodefaultvalue +*/ + +/*! + \qmlproperty stringList wix::extensions + + A list of extension assemblies to link into the output. + + Possible values include: + + \list + \li custom assemblies + \li \c{"WixBalExtension"} + \li \c{"WixComPlusExtension"} + \li \c{"WixDependencyExtension"} + \li \c{"WixDifxAppExtension"} + \li \c{"WixDirectXExtension"} + \li \c{"WixFirewallExtension"} + \li \c{"WixGamingExtension"} + \li \c{"WixIisExtension"} + \li \c{"WixMsmqExtension"} + \li \c{"WixNetFxExtension"} + \li \c{"WixPSExtension"} + \li \c{"WixSqlExtension"} + \li \c{"WixTagExtension"} + \li \c{"WixUIExtension"} + \li \c{"WixUtilExtension"} + \li \c{"WixVSExtension"} + \endlist + + \defaultvalue \c{["WixBalExtension"]} if the product type is an EXE setup + application, otherwise \c{undefined}. +*/ + +/*! + \qmlproperty string wix::version + + The WiX version. + + Consists of four numbers separated by dots. For example, "3.7.1224.0". + + \nodefaultvalue +*/ + +/*! + \qmlproperty int wix::versionMajor + + The WiX major version. + + \defaultvalue \c{versionParts[0]} +*/ + +/*! + \qmlproperty int wix::versionMinor + + The WiX minor version. + + \defaultvalue \c{versionParts[1]} +*/ + +/*! + \qmlproperty list wix::versionParts + + The WiX version as a list. + + For example, WiX version 3.7.1224.0 would correspond to a value of + \c[3, 7, 1224, 0]. + + \defaultvalue \c [] +*/ + +/*! + \qmlproperty int wix::versionPatch + + The WiX patch level. + + \defaultvalue \c{versionParts[2]} +*/ + +/*! + \qmlproperty int wix::versionBuild + + The fourth WiX version number component. + + \defaultvalue \c{versionParts[3]} +*/ + +/*! + \qmlproperty path wix::toolchainInstallPath + + The WiX installation directory. + + This property should not normally need to be changed. + + \defaultvalue Determined automatically by searching the registry for the + latest version. +*/ + +/*! + \qmlproperty path wix::toolchainInstallRoot + + The WiX binaries directory. + + This property should not normally need to be changed. + + \defaultvalue Determined automatically by searching the registry for the + latest version. +*/ + +/*! + \qmlproperty string wix::compilerName + + The name of the compiler binary. + + This property should not normally need to be changed. + + \defaultvalue \c{"candle.exe"} +*/ + +/*! + \qmlproperty string wix::compilerPath + + The directory where the compiler binary is located. + + This property should not normally need to be changed. + + \defaultvalue \l{wix::}{compilerName} +*/ + +/*! + \qmlproperty string wix::linkerName + + The name of the linker binary. + + This property should not normally need to be changed. + + \defaultvalue \c{"light.exe"} +*/ + +/*! + \qmlproperty string wix::linkerPath + + The directory where the linker binary is located. + + This property should not normally need to be changed. + + \defaultvalue \l{wix::}{linkerName} +*/ diff --git a/doc/reference/modules/xcode-module.qdoc b/doc/reference/modules/xcode-module.qdoc new file mode 100644 index 00000000..748226c0 --- /dev/null +++ b/doc/reference/modules/xcode-module.qdoc @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \qmltype xcode + \inqmlmodule QbsModules + \since Qbs 1.5 + + \brief Provides Xcode support. + + The \c xcode module contains properties and rules for Xcode-based development. + This module provides the foundation for several other modules on Apple + platforms, including the \l{cpp} and \l{ib} modules. +*/ + +/*! + \qmlproperty path xcode::developerPath + + The developer directory of the Xcode installation. + + Corresponds to the \c DEVELOPER_DIR environment variable. + + \defaultvalue The developer directory of the Xcode installation at its + default location in \c /Applications. For example, + \c{"/Applications/Xcode.app/Contents/Developer"}. + +*/ + +/*! + \qmlproperty string xcode::sdk + + The version of the Xcode SDK used to build products. + + This can be specified as a full canonical SDK name (\c{"macosx10.10"}), a + platform version number (\c{"10.10"}), or a platform identifier + (\c{"macosx"}), in which case the latest SDK available for that platform + will be used. + + \defaultvalue The latest SDK available in the Xcode installation for the + current platform. Determined by \l{qbs::targetOS}{qbs.targetOS}. +*/ + +/*! + \qmlproperty stringList xcode::targetDevices + + A list of the Apple devices targeted by this product. + + For macOS, watchOS, and tvOS, this should always be \c "mac", \c "watch", + and \c "tv", respectively. For iOS, this can be one or both of \c "iphone" + and \c "ipad". + + \defaultvalue The list of all device types supported by the current + platform. Determined by \l{qbs::targetOS}{qbs.targetOS}. +*/ + +/*! + \qmlproperty string xcode::sdkName + \readonly + + The canonical name of the SDK used to build products. + + For example, \c macosx10.9. + + \defaultvalue \l{xcode::}{sdk} +*/ + +/*! + \qmlproperty string xcode::sdkVersion + \readonly + + The version number of the SDK used to build products. + + For example, 10.9. + + \defaultvalue \l{xcode::}{sdk} +*/ + +/*! + \qmlproperty string xcode::latestSdkName + \readonly + + The canonical name of the latest SDK available in the Xcode installation. + + For example, \c {macosx10.10}. + + \defaultvalue \l{xcode::}{developerPath} +*/ + +/*! + \qmlproperty string xcode::latestSdkVersion + \readonly + + The version number of the latest SDK available in the Xcode installation. + + For example, 10.10. + + \defaultvalue \l{xcode::}{developerPath} +*/ + +/*! + \qmlproperty stringList xcode::availableSdkNames + \readonly + + The canonical names of all SDKs available in the Xcode installation for the + current platform. + + For example, \c {[macosx10.9, macosx10.10]}. + + \defaultvalue \l{xcode::}{developerPath} +*/ + +/*! + \qmlproperty stringList xcode::availableSdkVersions + \readonly + + The version numbers of all SDK available in the Xcode installation for the + current platform. + + For example, \c {[10.9, 10.10]}. + + \defaultvalue \l{xcode::}{developerPath} +*/ + +/*! + \qmlproperty path xcode::platformPath + \readonly + + The path of the platform directory containing \l{xcode::}{sdkPath}. + + \defaultvalue \l{xcode::}{developerPath} +*/ + +/*! + \qmlproperty path xcode::sdkPath + \readonly + + The path of the SDK used to build products. Equivalent to + \l{qbs::sysroot}{qbs.sysroot}. + + \defaultvalue Determined by \l{xcode::}{developerPath} and \l{xcode::}{sdk}. +*/ diff --git a/doc/reference/reference.qdoc b/doc/reference/reference.qdoc new file mode 100644 index 00000000..f2992b28 --- /dev/null +++ b/doc/reference/reference.qdoc @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage howtos.html + \page reference.html + \nextpage building-qbs.html + + \title Reference + + \list + \li \l{List of All Items} + \list + \li \l{List of Language Items} + \li \l{List of Convenience Items} + \li \l{List of Probes} + \endlist + \li \l{List of Built-in Services} + \li \l{Command-Line Interface} + \li \l{List of Modules} + \li \l{Command and JavaScriptCommand} + \endlist +*/ + +/*! + \group list-of-builtin-services + \title List of Built-in Services + \QBS provides the following built-in JavaScript extensions to simplify operations that + are expected to be needed often in project files. + + To gain access to the operations provided by a particular Service - for example, + the File service - use the following statement at the top of your \QBS project file: + \code + import qbs.File + \endcode + + If you instead need to access the service from a JavaScript file, import it using the following + statement at the top of your JavaScript file: + \code + var File = require("qbs.File"); + \endcode +*/ + +/*! + \qmlmodule QbsModules + \title List of Modules + These are the modules shipped with \QBS. + + For a list of \QBS modules that provide support for Qt modules, see + \l{Qt Modules}. Only the Qt modules that have properties and relevant file + tags are described in separate topics. +*/ + +/*! + \qmlmodule QbsModuleProviders + \title List of Module Providers + These are the module providers shipped with \QBS. +*/ + +/*! + \group list-of-items + \title List of All Items + + \QBS provides the following \l{List of Language Items}{built-in}, + \l{List of Convenience Items}{convenience}, and \l{List of Probes}{probe} + items to define projects. +*/ + +/*! + \qmlmodule QbsLanguageItems + \title List of Language Items + + \QBS provides the following built-in QML items to define projects. + These are the primitives upon which all other \QBS items are built. +*/ + +/*! + \qmlmodule QbsConvenienceItems + \title List of Convenience Items + + \QBS provides the following QML items for convenience. +*/ + +/*! + \qmlmodule QbsProbes + \title List of Probes + + These are the probes shipped with \QBS. + + Probes are used to retrieve information from the system prior to building. Typically, probes + call external processes to get the required information. For details, see \l{Probe}{Probe} page. +*/ diff --git a/doc/targets/qbs-target-android.qdoc b/doc/targets/qbs-target-android.qdoc new file mode 100644 index 00000000..b306a0ea --- /dev/null +++ b/doc/targets/qbs-target-android.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-android.html + \ingroup platforms + + \title Building for Android + \brief Platform notes for Android. + + To develop applications for Android, you need development tools provided by + the Android SDK from Google, and (optionally) a C/C++ toolchain provided by + the Android NDK. + + \note \QBS does not yet support the Kotlin programming language. + + \section1 Creating Android Application Packages + + On Android, applications are distributed in a specially structured type of + ZIP package called an APK. The following files should be created and bundled + into an APK: + + \list + \li Android assets. + \li Android resource files. + \li AndroidManifest.xml, which provides meta-information about your + application. + \li Compiled Java code, which serves as the entry point into your + application and that automatically executes the native code in your + application (if there is any). + \li Shared libraries containing native code. + \endlist + + You can use the \l{Application} item to build application + packages for Android. + + If the \l{qbs::targetPlatform}{target platform} is \c{"android"}, then the Application item has + a dependency on the \l{Android.sdk} module, which + contains the properties and rules to create Android application packages + from source files. + + You can use the \l{DynamicLibrary} item to build native + Android libraries that are bundled into the APK. The \c qbs.architectures + property specifies the architectures to build for, with the default value + \c armv7a. + If you have only one native library, you can simply list its sources + within the main Application item, and it will get built and packaged + automatically. + + The \l{DynamicLibrary} item, as well as the \l CppApplication item, + has a dependency on the \l{Android.ndk} module, + and contains the properties and rules to create native libraries. +*/ diff --git a/doc/targets/qbs-target-apple-common.qdocinc b/doc/targets/qbs-target-apple-common.qdocinc new file mode 100644 index 00000000..9b49d155 --- /dev/null +++ b/doc/targets/qbs-target-apple-common.qdocinc @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + +//! [xcode] + + \note \QBS does not yet support the Swift programming language. + + The \l{xcode} module contains properties and rules for Xcode-based + development. + +//! [xcode] + +//! [building user interfaces] + + \section1 Building User Interfaces + + The \l{ib} module contains properties and rules for building + Interface Builder documents, storyboards, asset catalogs, and icon sets. + +//! [building user interfaces] + +//! [creating app bundles] + + \section1 Creating App Bundles + + The \l{bundle} module contains properties and rules for + building and working with Core Foundation bundles (application bundles and + frameworks) on Apple platforms. + + To build an application product as a bundle, or a dynamic or static library + product as a framework, add a dependency on the bundle module and set the + \l{bundle::isBundle}{bundle.isBundle} property to \c true: + + \code + Depends { name: "bundle" } + bundle.isBundle: true + \endcode + + \QBS also provides a number of powerful features to assist in creating the + Info.plist file that is part of your bundle. In fact, you do not need to + provide an Info.plist file at all. Instead, \QBS will generate one + automatically with the necessary keys, based on the values of module + properties set in the product. + + If you do specify an Info.plist file, \QBS may still inject additional keys + into the final output from other sources. One notable source of Info.plist + keys are \e partial Info.plist files which are generated as a result of + compiling other resources like asset catalogs, XIBs/NIBs, and storyboards. + + You may also use the \c bundle.infoPlist property to apply a set of + key-value pairs to be added to the final Info.plist. This can be used + instead of or in addition to an actual Info.plist file on disk. + +//! [creating app bundles] + +//! [architectures and variants] + + \section1 Multiple Architectures and Build Variants + + \QBS uses \l{Multiplexing}{multiplexing} to create multi-architecture + \e fat binaries and multi-variant frameworks, where a single framework can + contain both a release and debug build of a library on Apple platforms. + + You can set the \c qbs.architectures property to a list of CPU architectures + (such as \c x86, \c x86_64, \c armv7a, \c armv7k, and \c arm64), and the + \c qbs.buildVariants property to a list of build variants (such as \c debug + and \c release), and \QBS will transparently perform the necessary steps to + produce the various artifacts and combine them into a single bundle. + + Since the individual build configurations are completely independent of one + another, you can continue to use conditional branches in your projects such + as the following: + + \code + Properties { + condition: qbs.buildVariant === "release" + cpp.optimization: "small" + } + \endcode + +//! [architectures and variants] + +*/ diff --git a/doc/targets/qbs-target-integrity.qdoc b/doc/targets/qbs-target-integrity.qdoc new file mode 100644 index 00000000..bef92ee8 --- /dev/null +++ b/doc/targets/qbs-target-integrity.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-integrity.html + \ingroup platforms + + \title Building for INTEGRITY + \brief Platform notes for INTEGRITY. + + The Green Hills INTEGRITY RTOS is not yet supported but is planned for a + future release. + + For more information about developing applications for the Green Hills + INTEGRITY RTOS, see the \l{https://www.ghs.com/products/rtos/integrity.html} + {INTEGRITY Product Documentation}. +*/ diff --git a/doc/targets/qbs-target-ios.qdoc b/doc/targets/qbs-target-ios.qdoc new file mode 100644 index 00000000..56908f01 --- /dev/null +++ b/doc/targets/qbs-target-ios.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-ios.html + \ingroup platforms + + \title Building for iOS + \brief Platform notes for iOS. + + This topic describes the \QBS features specific to iOS. + + \include qbs-target-apple-common.qdocinc xcode + \include qbs-target-apple-common.qdocinc building user interfaces + \include qbs-target-apple-common.qdocinc creating app bundles + \include qbs-target-apple-common.qdocinc architectures and variants +*/ diff --git a/doc/targets/qbs-target-linux.qdoc b/doc/targets/qbs-target-linux.qdoc new file mode 100644 index 00000000..025c7790 --- /dev/null +++ b/doc/targets/qbs-target-linux.qdoc @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-linux.html + \ingroup platforms + + \title Building for Linux + \brief Platform notes for Linux. + + To develop applications for Linux, you need a GCC or Clang toolchain + installed on your host machine. +*/ diff --git a/doc/targets/qbs-target-macos.qdoc b/doc/targets/qbs-target-macos.qdoc new file mode 100644 index 00000000..82fa6ee3 --- /dev/null +++ b/doc/targets/qbs-target-macos.qdoc @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-macos.html + \ingroup platforms + + \title Building for macOS + \brief Platform notes for macOS. + + This topic describes the \QBS features specific to macOS. + + \include qbs-target-apple-common.qdocinc xcode + \include qbs-target-apple-common.qdocinc building user interfaces + \include qbs-target-apple-common.qdocinc creating app bundles + \include qbs-target-apple-common.qdocinc architectures and variants + + \section1 Building macOS Disk Images + + The \l{AppleDiskImage} and \l{AppleApplicationDiskImage} items have a + dependency on the \l{dmg} module. The former represents a + product that is a basic Apple disk image, while the latter extends the + former to create a drag 'n' drop disk image installer used for installing + single application bundles. + + For example, the following code snippet creates a macOS disk image with a + custom background and icon layout: + + \code + AppleApplicationDiskImage { + targetName: "cocoa-application-" + version + version: "1.0" + + files: [ + "CocoaApplication/dmg.iconset", + "CocoaApplication/en_US.lproj/LICENSE", + // comment out the following line to use a solid-color background + // (see dmg.backgroundColor below) + "CocoaApplication/background*" + ] + + dmg.backgroundColor: "#41cd52" + dmg.badgeVolumeIcon: true + dmg.iconPositions: [ + {"x": 200, "y": 200, "path": "Cocoa Application.app"}, + {"x": 400, "y": 200, "path": "Applications"} + ] + dmg.windowX: 420 + dmg.windowY: 250 + dmg.windowWidth: 600 + dmg.windowHeight: 422 // this includes the macOS title bar height of 22 + dmg.iconSize: 64 + } + \endcode + + \image qbs-dmg.png + + In addition, \QBS supports multi-language license agreement prompts that + appear when the DMG is opened, with full Unicode and rich-text formatting + support. +*/ diff --git a/doc/targets/qbs-target-platforms.qdoc b/doc/targets/qbs-target-platforms.qdoc new file mode 100644 index 00000000..92fc7b1f --- /dev/null +++ b/doc/targets/qbs-target-platforms.qdoc @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \previouspage installing-files.html + \group platforms + \nextpage shell.html + + \title Target Platforms + + \QBS has built-in support for building applications for all major platforms. + Platform support is implemented as a set of \l{List of Modules}{modules} + that products depend on. The following topics describe the features specific + to a particular platform, point out things to look out for, and provide tips + for fully benefiting from the \QBS functions. + + In addition to the platforms explicitly listed below, \QBS should generally + work on other UNIX and Unix-like platforms but these are not regularly + tested or officially supported. + + \QBS recognizes the existence of at least AIX, HP-UX, Solaris, FreeBSD, + NetBSD, OpenBSD, GNU Hurd, and Haiku, but provides no explicit support + (except some minimal support for FreeBSD). + + For instructions on how to setup the target platform, see the + \l {qbs::targetPlatform}{qbs.targetPlatform} property. +*/ diff --git a/doc/targets/qbs-target-qnx.qdoc b/doc/targets/qbs-target-qnx.qdoc new file mode 100644 index 00000000..a4d75de2 --- /dev/null +++ b/doc/targets/qbs-target-qnx.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-qnx.html + \ingroup platforms + + \title Building for QNX + \brief Platform notes for QNX. + + To develop applications for the QNX Neutrino RTOS, you need to install the + QNX Software Development Platform (SDP) on a Linux, macOS, or Windows + development host. You can deploy the QNX Neutrino RTOS on a target system, + such as embedded hardware, a virtual machine, or a PC. + + \QBS automatically determines the location of the SDP base directory if the + SDP is installed at one of the standard locations, such as \c ~/qnx700, + \c /opt/qnx700, or \c C:\qnx700. In addition, \QBS uses the SDP and the + information it has about the host operating system to determine the location + of the QNX host and target directories. + + If the QNX SDP path could not be determined automatically, you must add a + dependency to the \l{qnx} module to your application and set the + \l{qnx::sdkDir}{qnx.sdkDir} property: + + \code + Application { + name: "helloworld" + files: "main.cpp" + Depends { name: "cpp" } + + Depends { name: "qnx" } + qnx.sdkDir: "/path/to/qnx700" + } + \endcode + + Alternatively, you can set the \c qnx.sdkDir property in a profile or on + the command line. + + \QBS supports QNX SDP version 6.5 and above. + + For more information about developing applications for the QNX Neutrino + RTOS, see the \l{http://www.qnx.com/developers/docs/} + {QNX Product Documentation}. +*/ diff --git a/doc/targets/qbs-target-tvos.qdoc b/doc/targets/qbs-target-tvos.qdoc new file mode 100644 index 00000000..6529663a --- /dev/null +++ b/doc/targets/qbs-target-tvos.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-tvos.html + \ingroup platforms + + \title Building for tvOS + \brief Platform notes for tvOS. + + This topic describes the \QBS features specific to tvOS. + + \include qbs-target-apple-common.qdocinc xcode + \include qbs-target-apple-common.qdocinc building user interfaces + \include qbs-target-apple-common.qdocinc creating app bundles + \include qbs-target-apple-common.qdocinc architectures and variants +*/ diff --git a/doc/targets/qbs-target-vxworks.qdoc b/doc/targets/qbs-target-vxworks.qdoc new file mode 100644 index 00000000..299f4fe7 --- /dev/null +++ b/doc/targets/qbs-target-vxworks.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-vxworks.html + \ingroup platforms + + \title Building for VxWorks + \brief Platform notes for VxWorks. + + The Wind River VxWorks RTOS is not yet supported but is planned for a + future release. + + For more information about developing applications for the WindRiver VxWorks + RTOS, see the \l{https://www.windriver.com/products/vxworks/} + {VxWorks Product Documentation}. +*/ diff --git a/doc/targets/qbs-target-watchos.qdoc b/doc/targets/qbs-target-watchos.qdoc new file mode 100644 index 00000000..f0997b1c --- /dev/null +++ b/doc/targets/qbs-target-watchos.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-watchos.html + \ingroup platforms + + \title Building for watchOS + \brief Platform notes for watchOS. + + This topic describes the \QBS features specific to watchOS. + + \include qbs-target-apple-common.qdocinc xcode + \include qbs-target-apple-common.qdocinc building user interfaces + \include qbs-target-apple-common.qdocinc creating app bundles + \include qbs-target-apple-common.qdocinc architectures and variants +*/ diff --git a/doc/targets/qbs-target-windows.qdoc b/doc/targets/qbs-target-windows.qdoc new file mode 100644 index 00000000..8bd78887 --- /dev/null +++ b/doc/targets/qbs-target-windows.qdoc @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qbs-target-windows.html + \ingroup platforms + + \title Building for Windows + \brief Platform notes for Windows. + + This topic describes the \QBS features specific to Windows. + + \note \QBS does not currently support building applications using .NET + technologies and languages such as C#, F#, and Visual Basic. At this time we + recommend that you use MSBuild and the tools shipped with the various + implementations of the .NET platform. + + \section1 Windows Resources + + The \l{ico} module contains rules and properties for building + Windows icon (.ico) and cursor (.cur) files from a set of raw PNGs. + + \section1 Universal Windows Platform + + Building applications for the Universal Windows Platform is currently only + partially supported. Notably, support for building APPX packages is missing, + but will be added in a future release. + + Relevant properties include: + + \list + \li \l{cpp::windowsApiFamily}{cpp.windowsApiFamily} + \li \l{cpp::windowsApiAdditionalPartitions} + {cpp.windowsApiAdditionalPartitions} + \li \l{cpp::requireAppContainer}{cpp.requireAppContainer} + \endlist + + See the \l{cpp} module for more information. + + \note \QBS does not (and will not) support building Windows Runtime + applications targeting Windows 8 or Windows 8.1. We encourage users to + instead build desktop applications for older versions of Windows, or migrate + to Windows 10 and the Universal Windows Platform. + + \section1 Building Windows Installers + + The following modules contain properties and rules for building Windows + installers using a number of different technologies: + + \list + \li \l{innosetup} - Inno Setup + \li \l{nsis} - Nullsoft Scriptable Install System + \li \l{wix} - Windows Installer XML Toolset + \endlist +*/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..19ea817d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,196 @@ +version: "3.7" + +x-default-service: &linux + working_dir: /qbs + environment: + - BUILD_OPTIONS + - QTEST_FUNCTION_TIMEOUT + - QBS_AUTOTEST_PROFILE + - QBS_TEST_SOURCE_ROOT + - WITH_ARCHIVE + - WITH_TESTS + - CLCACHE_DIR + volumes: + - .:/qbs + - ~/.ccache:/home/devel/.ccache + network_mode: bridge + cap_add: + - SYS_PTRACE + +services: + focal: + << : *linux + hostname: focal + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-5.15.2_1.20.1-1 + build: + dockerfile: docker/focal/Dockerfile + context: . + args: + QT_VERSION: 5.15.2 + QTCREATOR_VERSION: 5.0.3 + + focal-qt6: + << : *linux + hostname: focal-qt6 + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-qt6-6.2.0_1.20.1-1 + build: + dockerfile: docker/focal/Dockerfile + context: . + args: + QT_VERSION: 6.2.0 + QTCREATOR_VERSION: 5.0.3 + + focal-qt6-static: + << : *linux + hostname: focal-qt6-static + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-qt6-static-6.3.1_1.20.1-0 + build: + dockerfile: docker/focal/test-qt6-static.Dockerfile + context: . + args: + QT_VERSION: 6.3.1 + QTCREATOR_VERSION: 5.0.3 + + focal-android-513: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-5.13.2-4 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 5.13.2 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-514: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-5.14.0-4 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 5.14.0 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-515: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-5.15.1-4 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 5.15.1 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-600: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-6.0.0-4 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 6.0.0 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-620: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-6.2.0-4 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 6.2.0 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-630: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-6.3.0-0 + build: + dockerfile: docker/focal/test-android.Dockerfile + context: . + args: + QT_VERSION: 6.3.0 + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-android-ndk-r19c: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-ndk-r19c-0 + build: + dockerfile: docker/focal/test-android-no-qt.Dockerfile + context: . + args: + ANDROID_NDK_VERSION: 19.2.5345600 + + focal-android-ndk-r21e: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-ndk-r21e-0 + build: + dockerfile: docker/focal/test-android-no-qt.Dockerfile + context: . + args: + ANDROID_NDK_VERSION: 21.4.7075529 + + focal-android-ndk-r23: + << : *linux + hostname: focal-android + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-android-ndk-r23-0 + build: + dockerfile: docker/focal/test-android-no-qt.Dockerfile + context: . + args: + ANDROID_NDK_VERSION: 23.0.7599858 + + focal-baremetal: + << : *linux + hostname: focal-baremetal + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-baremetal-4 + build: + dockerfile: docker/focal/test-baremetal.Dockerfile + context: . + + focal-qt4: + << : *linux + hostname: focal-qt4 + image: ${DOCKER_USER:-qbsbuild}/qbsdev:focal-qt4-0 + build: + dockerfile: docker/focal/test-qt4.Dockerfile + context: . + + leap: + << : *linux + hostname: leap + image: ${DOCKER_USER:-qbsbuild}/qbsdev:leap-5.15.2_1.20.1-1 + build: + dockerfile: docker/leap/Dockerfile + context: . + args: + QT_VERSION: 5.15.2 + QTCREATOR_VERSION: 5.0.3 + + windows: + image: ${DOCKER_USER:-qbsbuild}/qbsdev:windowsservercore-5.15.0_1.18.2-0 + build: + dockerfile: docker/windowsservercore/Dockerfile + context: . + args: + QT_VERSION: 5.15.0 + QBS_VERSION: 1.18.2 + working_dir: 'C:/qbs' + environment: + - BUILD_OPTIONS + - WITH_DOCS + volumes: + - type: bind + source: . + target: C:\qbs + - type: bind + source: ~/.ccache + target: C:\.ccache + network_mode: nat diff --git a/docker/docker.qbs b/docker/docker.qbs new file mode 100644 index 00000000..513a5fd8 --- /dev/null +++ b/docker/docker.qbs @@ -0,0 +1,8 @@ + +// This is a convenience product to be able to use Qt Creator for editing the docker files. +// For building and managing the images, use docker-compose as explained in +// https://doc.qt.io/qbs/building-qbs.html#using-docker. +Product { + name: "docker" + files: "**" +} diff --git a/docker/focal/Dockerfile b/docker/focal/Dockerfile new file mode 100644 index 00000000..df687f3a --- /dev/null +++ b/docker/focal/Dockerfile @@ -0,0 +1,109 @@ +# +# Install Qt and Qbs for Linux +# +FROM ubuntu:focal +LABEL Description="Ubuntu development environment for Qbs with Qt and various dependencies for testing Qbs modules and functionality" +ARG QT_VERSION +ARG QTCREATOR_VERSION + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Qbs build dependencies +RUN apt-get update -qq && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -qq -y --no-install-recommends \ + bison \ + build-essential \ + ca-certificates \ + capnproto \ + ccache \ + clang-8 \ + clang-tidy-8 \ + cmake \ + curl \ + flex \ + git \ + help2man \ + icoutils \ + libcapnp-dev \ + libdbus-1-3 \ + libfreetype6 \ + libfontconfig1 \ + libgl1-mesa-dev \ + libgl1-mesa-glx \ + libnanopb-dev \ + libprotobuf-dev \ + libgrpc++-dev \ + libxkbcommon-x11-0 \ + nanopb \ + ninja-build \ + nsis \ + pkg-config \ + protobuf-compiler \ + protobuf-compiler-grpc \ + psmisc \ + python3-pip \ + python3-setuptools \ + p7zip-full \ + subversion \ + unzip \ + zip && \ + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100 && \ + update-alternatives --install /usr/bin/clang-check clang-check /usr/bin/clang-check-8 100 && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 100 && \ + pip install beautifulsoup4 lxml protobuf pyyaml + +ENV LLVM_INSTALL_DIR=/usr/lib/llvm-8 + + +# +# Install Qt and Qbs for Linux from qt.io +# +COPY scripts/install-qt.sh install-qt.sh + +RUN ./install-qt.sh --version ${QT_VERSION} qtbase qtdeclarative qtscript qttools qtx11extras qtscxml qt5compat icu && \ + ./install-qt.sh --version ${QTCREATOR_VERSION} qtcreator && \ + echo "export PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:\${PATH}" > /etc/profile.d/qt.sh + +ENV PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:${PATH} + + +# Configure Qbs +USER $USER_NAME +RUN qbs-setup-toolchains /usr/bin/g++ gcc && \ + qbs-setup-toolchains /usr/bin/clang clang && \ + qbs-setup-qt /opt/Qt/${QT_VERSION}/gcc_64/bin/qmake qt-gcc_64 && \ + qbs config profiles.qt-gcc_64.baseProfile gcc && \ + qbs-setup-qt /opt/Qt/${QT_VERSION}/gcc_64/bin/qmake qt-clang_64 && \ + qbs config profiles.qt-clang_64.baseProfile clang && \ + qbs config defaultProfile qt-gcc_64 + +# Switch back to root user for the entrypoint script. +USER root + +# Work-around for QTBUG-79020 +RUN echo "export QT_NO_GLIB=1" >> /etc/profile.d/qt.sh diff --git a/docker/focal/entrypoint.sh b/docker/focal/entrypoint.sh new file mode 100755 index 00000000..40bc5acb --- /dev/null +++ b/docker/focal/entrypoint.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +set -e + +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +# +# Entrypoint script when starting the container. The script checks the current +# working directory and changes the uid/gid of developer/users to match whatever +# is found in the working directory. This is useful to match the user and group +# of mounted volumes into the container + +# +# If not root, re-run script as root to fix ids +# +if [ "$(id -u)" != "0" ]; then + exec gosu root /sbin/entrypoint.sh "$@" +fi + +# +# Try to determine the uid of the working directory and adjust the current +# user's uid/gid accordingly. +# +USER_GID=${USER_GID:-$(stat -c "%g" .)} +USER_UID=${USER_UID:-$(stat -c "%u" .)} +USER_NAME=${USER_NAME:-devel} +USER_GROUP=${USER_GROUP:-devel} +EXEC="" +export HOME=/home/${USER_NAME} + +# +# This is a problem on Linux hosts when we mount a folder from the +# user file system and write artifacts into that. Thus, we downgrade +# the current user and make sure that the uid and gid matches the one +# of the mounted project folder. +# +# This work-around is not needed on Windows hosts as Windows doesn't +# have such a concept. +# +if [ "${USER_UID}" != "0" ]; then + if [ "$(id -u ${USER_NAME})" != "${USER_UID}" ]; then + usermod -o -u ${USER_UID} ${USER_NAME} + # After changing the user's uid, all files in user's home directory + # automatically get the new uid. + fi + current_gid=$(id -g ${USER_NAME}) + if [ "$(id -g ${USER_NAME})" != "${USER_GID}" ]; then + groupmod -o -g ${USER_GID} ${USER_GROUP} + # Set the new gid on all files in the home directory that still have the + # old gid. + find /home/${USER_NAME} -gid "${current_gid}" ! -type l -exec chgrp ${USER_GID} {} \; + fi +fi +EXEC="exec gosu ${USER_NAME}:${USER_GROUP}" + +if [ -z "$1" ]; then + ${EXEC} bash -l +else + ${EXEC} bash -l -c "$*" +fi diff --git a/docker/focal/test-android-no-qt.Dockerfile b/docker/focal/test-android-no-qt.Dockerfile new file mode 100644 index 00000000..e1622043 --- /dev/null +++ b/docker/focal/test-android-no-qt.Dockerfile @@ -0,0 +1,105 @@ +# +# Android SDK/NDK for testing Qbs +# +FROM ubuntu:focal +LABEL Description="Ubuntu test environment for Qbs for Android" + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Qbs build dependencies +RUN apt-get update -qq && \ + apt-get install -qq -y --no-install-recommends \ + ca-certificates \ + curl \ + libasan5 \ + libglib2.0-0 \ + openjdk-8-jdk-headless \ + p7zip-full \ + unzip + +ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +RUN echo "export JAVA_HOME=${JAVA_HOME}" > /etc/profile.d/android.sh && \ + echo "export PATH=${JAVA_HOME}/bin:\${PATH}" >> /etc/profile.d/android.sh + +ARG ANDROID_NDK_VERSION + +ENV ANDROID_HOME="/home/${USER_NAME}/android" +ENV ANDROID_SDK_ROOT=${ANDROID_HOME} +ENV ANDROID_NDK_ROOT=${ANDROID_HOME}/"ndk"/${ANDROID_NDK_VERSION} +ENV PATH="${JAVA_HOME}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/cmdline-tools/bin:$PATH" +RUN echo "export ANDROID_HOME=/home/${USER_NAME}/android" >> /etc/profile.d/android.sh && \ + echo "export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" >> /etc/profile.d/android.sh && \ + echo "export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}" >> /etc/profile.d/android.sh && \ + echo "export PATH=${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/cmdline-tools/bin:\$PATH" >> /etc/profile.d/android.sh + +# +# We ned to run the following steps as the target user +# +USER ${USER_NAME} +RUN mkdir ${ANDROID_HOME} + +# Get Android command line tools +ARG COMMAND_LINE_TOOLS_VERSION="6858069" +RUN curl -s https://dl.google.com/android/repository/commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip > ${ANDROID_HOME}/commandlinetools.zip && \ + unzip ${ANDROID_HOME}/commandlinetools.zip -d ${ANDROID_HOME} && \ + rm -v ${ANDROID_HOME}/commandlinetools.zip + +# Accept SDK license +ARG ANDROID_PLATFORM="android-29" +ARG BUILD_TOOLS="29.0.2" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" --verbose --licenses && \ + sdkmanager "--sdk_root=${ANDROID_HOME}" --update && \ + sdkmanager "--sdk_root=${ANDROID_HOME}" "platforms;${ANDROID_PLATFORM}" + +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "build-tools;${BUILD_TOOLS}" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "platform-tools" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "tools" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "ndk;${ANDROID_NDK_VERSION}" + +RUN /usr/lib/jvm/java-8-openjdk-amd64/bin/keytool -genkey -keystore /home/${USER_NAME}/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname 'CN=Android Debug,O=Android,C=US' + +# Install ndk samples in ${ANDROID_NDK_ROOT}/samples +RUN cd ${ANDROID_NDK_ROOT} && \ + curl -sLO https://github.com/android/ndk-samples/archive/master.zip && \ + unzip -q master.zip && \ + rm -v master.zip && \ + mv ndk-samples-master samples + +# Install android-BasicMediaDecoder in ${ANDROID_SDK_ROOT}/samples +RUN mkdir ${ANDROID_SDK_ROOT}/samples && \ + cd ${ANDROID_SDK_ROOT}/samples && \ + curl -sLO https://github.com/googlearchive/android-BasicMediaDecoder/archive/master.zip && \ + unzip -q master.zip && \ + rm -v master.zip && \ + mv android-BasicMediaDecoder-master android-BasicMediaDecoder + +# Download buildtool to generate aab packages in ${ANDROID_SDK_ROOT} +RUN cd ${ANDROID_SDK_ROOT} && \ + curl -sLO https://github.com/google/bundletool/releases/download/1.3.0/bundletool-all-1.3.0.jar + +USER root + diff --git a/docker/focal/test-android.Dockerfile b/docker/focal/test-android.Dockerfile new file mode 100644 index 00000000..31f4eb77 --- /dev/null +++ b/docker/focal/test-android.Dockerfile @@ -0,0 +1,129 @@ +# +# Android SDK/NDK + Qt for Android for testing Qbs +# +FROM ubuntu:focal +LABEL Description="Ubuntu test environment for Qbs and Qt for Android" + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Qbs build dependencies +RUN apt-get update -qq && \ + apt-get install -qq -y --no-install-recommends \ + ca-certificates \ + curl \ + libasan5 \ + libglib2.0-0 \ + openjdk-8-jdk-headless \ + p7zip-full \ + unzip + +ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +RUN echo "export JAVA_HOME=${JAVA_HOME}" > /etc/profile.d/android.sh && \ + echo "export PATH=${JAVA_HOME}/bin:\${PATH}" >> /etc/profile.d/android.sh + +ARG ANDROID_NDK_VERSION + +ENV ANDROID_HOME="/home/${USER_NAME}/android" +ENV ANDROID_SDK_ROOT=${ANDROID_HOME} +ENV ANDROID_NDK_ROOT=${ANDROID_HOME}/"ndk"/${ANDROID_NDK_VERSION} +ENV PATH="${JAVA_HOME}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/cmdline-tools/bin:$PATH" +RUN echo "export ANDROID_HOME=/home/${USER_NAME}/android" >> /etc/profile.d/android.sh && \ + echo "export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" >> /etc/profile.d/android.sh && \ + echo "export ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT}" >> /etc/profile.d/android.sh && \ + echo "export PATH=${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/cmdline-tools/bin:\$PATH" >> /etc/profile.d/android.sh + +# +# We ned to run the following steps as the target user +# +USER ${USER_NAME} +RUN mkdir ${ANDROID_HOME} + +# Get Android command line tools +ARG COMMAND_LINE_TOOLS_VERSION="6858069" +RUN curl -s https://dl.google.com/android/repository/commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip > ${ANDROID_HOME}/commandlinetools.zip && \ + unzip ${ANDROID_HOME}/commandlinetools.zip -d ${ANDROID_HOME} && \ + rm -v ${ANDROID_HOME}/commandlinetools.zip + +# Accept SDK license +ARG ANDROID_PLATFORM="android-30" +ARG BUILD_TOOLS="29.0.2" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" --verbose --licenses && \ + sdkmanager "--sdk_root=${ANDROID_HOME}" --update && \ + sdkmanager "--sdk_root=${ANDROID_HOME}" "platforms;${ANDROID_PLATFORM}" + +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "build-tools;${BUILD_TOOLS}" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "platform-tools" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "tools" +RUN yes | sdkmanager "--sdk_root=${ANDROID_HOME}" "ndk;${ANDROID_NDK_VERSION}" + +RUN /usr/lib/jvm/java-8-openjdk-amd64/bin/keytool -genkey -keystore /home/${USER_NAME}/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname 'CN=Android Debug,O=Android,C=US' + +# Install ndk samples in ${ANDROID_NDK_ROOT}/samples +RUN cd ${ANDROID_NDK_ROOT} && \ + curl -sLO https://github.com/android/ndk-samples/archive/master.zip && \ + unzip -q master.zip && \ + rm -v master.zip && \ + mv ndk-samples-master samples + +# Install android-BasicMediaDecoder in ${ANDROID_SDK_ROOT}/samples +RUN mkdir ${ANDROID_SDK_ROOT}/samples && \ + cd ${ANDROID_SDK_ROOT}/samples && \ + curl -sLO https://github.com/googlearchive/android-BasicMediaDecoder/archive/master.zip && \ + unzip -q master.zip && \ + rm -v master.zip && \ + mv android-BasicMediaDecoder-master android-BasicMediaDecoder + +# Download buildtool to generate aab packages in ${ANDROID_SDK_ROOT} +RUN cd ${ANDROID_SDK_ROOT} && \ + curl -sLO https://github.com/google/bundletool/releases/download/1.3.0/bundletool-all-1.3.0.jar + +USER root + +# +# Install Qt and Qbs for Linux from qt.io +# +ARG QT_VERSION +COPY scripts/install-qt.sh install-qt.sh +RUN if [ "${QT_VERSION}" \< "5.14" ] || [ ! "${QT_VERSION}" \< "6.0.0" ]; then \ + QT_ABIS="android_armv7 android_arm64_v8a android_x86 android_x86_64"; \ + else \ + QT_ABIS="any"; \ + fi; \ + if [ ! "${QT_VERSION}" \< "6.0.0" ]; then \ + ./install-qt.sh --version ${QT_VERSION} qtbase qtdeclarative icu; \ + if [ "${QT_VERSION}" \< "6.1.0" ]; then \ + QT_COMPONENTS="qtbase qtdeclarative qttools qtquickcontrols2 qtquicktimeline svg"; \ + else \ + QT_COMPONENTS="qtbase qtdeclarative qttools qtquicktimeline svg"; \ + fi; \ + else \ + QT_COMPONENTS="qtbase qtdeclarative qttools qtimageformats"; \ + fi; \ + for abi in ${QT_ABIS}; do \ + ./install-qt.sh --version ${QT_VERSION} --target android --toolchain ${abi} ${QT_COMPONENTS}; \ + done && \ + echo "export QT_VERSION=${QT_VERSION}" >> /etc/profile.d/qt.sh diff --git a/docker/focal/test-baremetal.Dockerfile b/docker/focal/test-baremetal.Dockerfile new file mode 100644 index 00000000..5bef208c --- /dev/null +++ b/docker/focal/test-baremetal.Dockerfile @@ -0,0 +1,50 @@ +# +# Baremetal toolchains for testing Qbs +# +FROM ubuntu:focal +LABEL Description="Ubuntu baremetal test environment for Qbs" + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Install baremetal toolchains and Qbs runtime dependencies. +RUN apt-get update -qq && \ + apt-get install -qq -y \ + libasan5 \ + libglib2.0-0 \ + libgssapi-krb5-2 \ + libgl1-mesa-glx \ + gcc-arm-none-eabi \ + gcc-avr \ + avr-libc \ + gcc-msp430 \ + sdcc \ + binutils-xtensa-lx106 \ + gcc-xtensa-lx106 \ + gcc-riscv64-unknown-elf + +# Work-around for QTBUG-79020. +RUN echo "export QT_NO_GLIB=1" >> /etc/profile.d/qt.sh diff --git a/docker/focal/test-qt4.Dockerfile b/docker/focal/test-qt4.Dockerfile new file mode 100644 index 00000000..c23a664d --- /dev/null +++ b/docker/focal/test-qt4.Dockerfile @@ -0,0 +1,40 @@ +# +# Testing Qbs with qt4 +# +FROM ubuntu:focal +LABEL Description="Ubuntu qt4 test environment for Qbs" + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + software-properties-common \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Install baremetal toolchains and Qbs runtime dependencies. +RUN sudo add-apt-repository ppa:gezakovacs/ppa -y && \ + apt-get update -qq && \ + apt-get install -qq -y \ + build-essential \ + libqt4-dev + diff --git a/docker/focal/test-qt6-static.Dockerfile b/docker/focal/test-qt6-static.Dockerfile new file mode 100644 index 00000000..61316e37 --- /dev/null +++ b/docker/focal/test-qt6-static.Dockerfile @@ -0,0 +1,218 @@ +# +# Testing Qbs with static qt6 +# +FROM ubuntu:focal +LABEL Description="Ubuntu static qt6 test environment for Qbs" +ARG QT_VERSION +ARG QTCREATOR_VERSION + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + wget \ + ca-certificates \ + gosu \ + software-properties-common \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null +RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | tee /etc/apt/sources.list.d/kitware.list >/dev/null +RUN cat /etc/apt/sources.list.d/kitware.list + +RUN apt-get update -qq && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -qq -y --no-install-recommends \ + build-essential \ + git \ + perl \ + cmake \ + python \ + zlib1g-dev \ + libzstd-dev \ + libdbus-1-dev \ + libglib2.0-dev \ + libssl-dev \ + libdrm-dev \ + libegl-dev \ + libwayland-dev \ + libvulkan-dev \ + libicu-dev \ + libb2-dev \ + libsystemd-dev \ + libfontconfig1-dev \ + libfreetype6-dev \ + libx11-dev \ + libx11-xcb-dev \ + libxext-dev \ + libxfixes-dev \ + libxi-dev \ + libxrender-dev \ + libxcb1-dev \ + libxcb-glx0-dev \ + libxcb-keysyms1-dev \ + libxcb-image0-dev \ + libxcb-shm0-dev \ + libxcb-icccm4-dev \ + libxcb-sync0-dev \ + libxcb-xfixes0-dev \ + libxcb-shape0-dev \ + libxcb-randr0-dev \ + libxcb-render-util0-dev \ + libxcb-xinerama0-dev \ + libxkbcommon-dev \ + libxkbcommon-x11-dev \ + libxcb-xinput-dev \ + ninja-build \ + libudev-dev \ + libxcb-cursor-dev \ + libxcb-composite0-dev \ + libxcb-dri2-0-dev \ + libxcb-dri3-dev \ + libxcb-ewmh-dev \ + libxcb-present-dev \ + libxcb-present-dev \ + libxcb-record0-dev \ + libxcb-res0-dev \ + libxcb-screensaver0-dev \ + libxcb-sync-dev \ + libxcb-util-dev \ + libxcb-xf86dri0-dev \ + libxcb-xtest0-dev \ + libxcb-xv0-dev \ + libxcb-xvmc0-dev \ + libxcb-damage0-dev \ + libxcb-dpms0-dev \ + libgstreamer1.0-dev \ + apt-transport-https + +ENV QT_HOME="/home/${USER_NAME}/qt" +USER ${USER_NAME} +RUN mkdir ${QT_HOME} + +RUN cd ${QT_HOME} && git clone https://code.qt.io/qt/qt5.git + +RUN cd ${QT_HOME}/qt5 && git checkout v${QT_VERSION} && perl init-repository + +RUN mkdir ${QT_HOME}/static-build && cd ${QT_HOME}/static-build && ../qt5/configure -prefix /opt/Qt/${QT_VERSION}/gcc_64 + +RUN cd ${QT_HOME}/static-build && cmake --build . --parallel + +USER root + +RUN cd ${QT_HOME}/static-build && cmake --install . + +FROM ubuntu:focal +LABEL Description="Ubuntu static qt6 test environment for Qbs" +ARG QT_VERSION +ARG QTCREATOR_VERSION + +RUN mkdir -p /opt/Qt +COPY --from=0 /opt/Qt/${QT_VERSION} /opt/Qt/${QT_VERSION} + +# Allow colored output on command line. +ENV TERM=xterm-color +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN apt-get update -qq && \ + apt-get install -qq -y \ + ca-certificates \ + gosu \ + software-properties-common \ + sudo && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G sudo ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/focal/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# Qbs build dependencies +RUN apt-get update -qq && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -qq -y --no-install-recommends \ + bison \ + build-essential \ + ca-certificates \ + capnproto \ + ccache \ + clang-8 \ + clang-tidy-8 \ + cmake \ + curl \ + flex \ + git \ + help2man \ + icoutils \ + libcapnp-dev \ + libdbus-1-3 \ + libfreetype6 \ + libfontconfig1 \ + libgl1-mesa-dev \ + libgl1-mesa-glx \ + libnanopb-dev \ + libprotobuf-dev \ + libgrpc++-dev \ + libxkbcommon-x11-0 \ + nanopb \ + ninja-build \ + nsis \ + pkg-config \ + protobuf-compiler \ + protobuf-compiler-grpc \ + psmisc \ + python3-pip \ + python3-setuptools \ + p7zip-full \ + subversion \ + unzip \ + zip \ + libb2-1 \ + libpcre++ && \ + update-alternatives --install /usr/bin/clang clang /usr/bin/clang-8 100 && \ + update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-8 100 && \ + update-alternatives --install /usr/bin/clang-check clang-check /usr/bin/clang-check-8 100 && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 100 && \ + pip install beautifulsoup4 lxml protobuf pyyaml + +ENV LLVM_INSTALL_DIR=/usr/lib/llvm-8 + +# +# Install Qbs for Linux from qt.io +# +COPY scripts/install-qt.sh install-qt.sh + +RUN ./install-qt.sh --version ${QTCREATOR_VERSION} qtcreator && \ + echo "export PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:\${PATH}" > /etc/profile.d/qt.sh + +ENV PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:${PATH} + +# Configure Qbs +USER $USER_NAME +RUN qbs-setup-toolchains /usr/bin/g++ gcc && \ + qbs-setup-qt /opt/Qt/${QT_VERSION}/gcc_64/bin/qmake qt-gcc_64 && \ + qbs config profiles.qt-gcc_64.baseProfile gcc && \ + qbs config defaultProfile qt-gcc_64 + +# Switch back to root user for the entrypoint script. +USER root + +# Work-around for QTBUG-79020 +RUN echo "export QT_NO_GLIB=1" >> /etc/profile.d/qt.sh diff --git a/docker/leap/Dockerfile b/docker/leap/Dockerfile new file mode 100644 index 00000000..308f854a --- /dev/null +++ b/docker/leap/Dockerfile @@ -0,0 +1,96 @@ +# +# Install Qt and Qbs for Linux +# +FROM opensuse/leap:15.3 +LABEL Description="OpenSUSE development environment for Qbs with Qt and various dependencies for testing Qbs modules and functionality" +ARG QT_VERSION +ARG QTCREATOR_VERSION + +# Allow colored output on command line. +ENV TERM=xterm-color + +# +# Make it possible to change UID/GID in the entrypoint script. The docker +# container usually runs as root user on Linux hosts. When the Docker container +# mounts a folder on the host and creates files there, those files would be +# owned by root instead of the current user. Thus we create a user here who's +# UID will be changed in the entrypoint script to match the UID of the current +# host user. +# +ARG USER_UID=1000 +ARG USER_NAME=devel +RUN zypper in -y \ + ca-certificates \ + sudo \ + system-user-mail \ + system-group-wheel && \ + groupadd -g ${USER_UID} ${USER_NAME} && \ + useradd -s /bin/bash -u ${USER_UID} -g ${USER_NAME} -o -c "" -m ${USER_NAME} && \ + usermod -a -G wheel ${USER_NAME} && \ + echo "%devel ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers + +COPY docker/leap/entrypoint.sh /sbin/entrypoint.sh +ENTRYPOINT ["/sbin/entrypoint.sh"] + +# # Qbs build dependencies +RUN zypper install -y \ + bison \ + capnproto \ + ccache \ + cmake \ + command-not-found \ + curl \ + gcc10 \ + gcc10-c++ \ + glibc-devel-static \ + flex \ + fontconfig \ + git \ + gzip \ + help2man \ + icoutils \ + libcapnp-devel \ + libgthread-2_0-0 \ + libfreetype6 \ + Mesa-libGL-devel \ + Mesa-libGL1 \ + nanopb-devel \ + ninja \ + perl \ + pkg-config \ + psmisc \ + python3-pip \ + p7zip-full \ + subversion \ + tar \ + unzip \ + which \ + zip && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 && \ + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100 && \ + pip install --upgrade pip && \ + pip install beautifulsoup4 lxml + +# +# Install Qt and Qbs for Linux from qt.io +# +COPY scripts/install-qt.sh install-qt.sh + +RUN ./install-qt.sh --version ${QT_VERSION} qtbase qtdeclarative qtscript qttools qtx11extras qtscxml qt5compat icu && \ + ./install-qt.sh --version ${QTCREATOR_VERSION} qtcreator && \ + echo "export PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:\${PATH}" > /etc/profile.d/qt.sh + +ENV PATH=/opt/Qt/${QT_VERSION}/gcc_64/bin:/opt/Qt/Tools/QtCreator/bin:${PATH} + +# Configure Qbs +USER $USER_NAME +RUN qbs-setup-toolchains /usr/bin/g++ gcc && \ + qbs-setup-qt /opt/Qt/${QT_VERSION}/gcc_64/bin/qmake qt-gcc_64 && \ + qbs config profiles.qt-gcc_64.baseProfile gcc && \ + qbs config defaultProfile qt-gcc_64 + +# Switch back to root user for the entrypoint script. +USER root + +# Work-around for QTBUG-79020 +RUN echo "export QT_NO_GLIB=1" >> /etc/profile.d/qt.sh diff --git a/docker/leap/entrypoint.sh b/docker/leap/entrypoint.sh new file mode 100755 index 00000000..a34926ca --- /dev/null +++ b/docker/leap/entrypoint.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +set -e + +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +# +# Entrypoint script when starting the container. The script checks the current +# working directory and changes the uid/gid of developer/users to match whatever +# is found in the working directory. This is useful to match the user and group +# of mounted volumes into the container + +# +# If not root, re-run script as root to fix ids +# +if [ "$(id -u)" != "0" ]; then + exec sudo -i /sbin/entrypoint.sh "$@" +fi + +# +# Try to determine the uid of the working directory and adjust the current +# user's uid/gid accordingly. +# +USER_GID=${USER_GID:-$(stat -c "%g" .)} +USER_UID=${USER_UID:-$(stat -c "%u" .)} +USER_NAME=${USER_NAME:-devel} +USER_GROUP=${USER_GROUP:-devel} +EXEC="" +export HOME=/home/${USER_NAME} + +# +# This is a problem on Linux hosts when we mount a folder from the +# user file system and write artifacts into that. Thus, we downgrade +# the current user and make sure that the uid and gid matches the one +# of the mounted project folder. +# +# This work-around is not needed on Windows hosts as Windows doesn't +# have such a concept. +# +if [ "${USER_UID}" != "0" ]; then + if [ "$(id -u ${USER_NAME})" != "${USER_UID}" ]; then + usermod -o -u ${USER_UID} ${USER_NAME} + # After changing the user's uid, all files in user's home directory + # automatically get the new uid. + fi + current_gid=$(id -g ${USER_NAME}) + if [ "$(id -g ${USER_NAME})" != "${USER_GID}" ]; then + groupmod -o -g ${USER_GID} ${USER_GROUP} + # Set the new gid on all files in the home directory that still have the + # old gid. + find /home/${USER_NAME} -gid "${current_gid}" ! -type l -exec chgrp ${USER_GID} {} \; + fi +fi +EXEC="exec sudo -u ${USER_NAME} -g ${USER_GROUP}" + +if [ -z "$1" ]; then + ${EXEC} bash -l +else + ${EXEC} bash -l -c "$*" +fi diff --git a/docker/windowsservercore/Dockerfile b/docker/windowsservercore/Dockerfile new file mode 100644 index 00000000..50a1400e --- /dev/null +++ b/docker/windowsservercore/Dockerfile @@ -0,0 +1,54 @@ + +FROM mcr.microsoft.com/windows/servercore:1809 +LABEL Description="Windows Server Core development environment for Qbs with Qt, Chocolatey and various dependencies for testing Qbs modules and functionality" + +# Disable crash dialog for release-mode runtimes +RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v Disabled /t REG_DWORD /d 1 /f +RUN reg add "HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d 1 /f + +# Install VS from the website since chocolatey has broken .NET 4.8 (dotnetfx package) which is a +# dependency for the visualstudio2019buildtools package +RUN powershell -NoProfile -ExecutionPolicy Bypass -Command \ + Invoke-WebRequest "https://aka.ms/vs/16/release/vs_community.exe" \ + -OutFile "%TEMP%\vs_community.exe" -UseBasicParsing + +RUN "%TEMP%\vs_community.exe" --quiet --wait --norestart --noUpdateInstaller \ + --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \ + --add Microsoft.VisualStudio.Component.Windows10SDK.18362 + +RUN powershell -NoProfile -ExecutionPolicy Bypass -Command \ + $Env:chocolateyVersion = '0.10.15' ; \ + $Env:chocolateyUseWindowsCompression = 'false' ; \ + "[Net.ServicePointManager]::SecurityProtocol = \"tls12, tls11, tls\"; iex ((New-Object System.Net.WebClient).DownloadString('http://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" + +ARG QBS_VERSION +RUN choco install -y python && \ + choco install -y 7zip --version 19.0 && \ + choco install -y git --version 2.24.0 --params "/GitAndUnixToolsOnPath" && \ + choco install -y qbs --version %QBS_VERSION% + +# for building the documentation +RUN pip install beautifulsoup4 lxml + +# clcache for speeding up MSVC builds +ENV CLCACHE_DIR="C:/.ccache" +RUN certutil -generateSSTFromWU roots.sst && \ + certutil -addstore -f root roots.sst && \ + del roots.sst && \ + pip install --trusted-host=pypi.org \ + git+https://github.com/frerich/clcache.git@cae73d8255d78db8ba11e23c51fd2c9a89e7475b + +########### Install Qt ############# +ARG QT_VERSION +COPY scripts/install-qt.sh install-qt.sh + +RUN bash -c "./install-qt.sh -d /c/Qt --version ${QT_VERSION} --toolchain win64_msvc2019_64 qtbase qtdeclarative qttools qtscript" +ENV QTDIR64=C:\\Qt\\${QT_VERSION}\\msvc2019_64 + +RUN bash -c "./install-qt.sh -d /c/Qt --version ${QT_VERSION} --toolchain win32_msvc2019 qtbase qtdeclarative qttools qtscript" +ENV QTDIR=C:\\Qt\\${QT_VERSION}\\msvc2019 + +RUN qbs setup-toolchains --detect && \ + qbs setup-qt %QTDIR64%/bin/qmake.exe qt64 && \ + qbs setup-qt %QTDIR%/bin/qmake.exe qt && \ + qbs config defaultProfile qt64 diff --git a/examples/app-and-lib/app-and-lib.qbs b/examples/app-and-lib/app-and-lib.qbs new file mode 100644 index 00000000..8170f37a --- /dev/null +++ b/examples/app-and-lib/app-and-lib.qbs @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + references: [ + "app/app.qbs", + "lib/lib.qbs" + ] +} + diff --git a/examples/app-and-lib/app/app.qbs b/examples/app-and-lib/app/app.qbs new file mode 100644 index 00000000..dcb9e7af --- /dev/null +++ b/examples/app-and-lib/app/app.qbs @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Application { + consoleApplication: true + files : [ "main.cpp" ] + Depends { name: "cpp" } + Depends { name: "mylib" } +} + diff --git a/examples/app-and-lib/app/main.cpp b/examples/app-and-lib/app/main.cpp new file mode 100644 index 00000000..dc02fa8e --- /dev/null +++ b/examples/app-and-lib/app/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include + +int main() +{ + std::puts("Now calling a function from mylib:"); + return bla(); +} diff --git a/examples/app-and-lib/lib/lib.cpp b/examples/app-and-lib/lib/lib.cpp new file mode 100644 index 00000000..a1b30a0d --- /dev/null +++ b/examples/app-and-lib/lib/lib.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include + +#ifndef CRUCIAL_DEFINE +# error CRUCIAL_DEFINE not defined +#endif + +int bla() +{ + std::puts("Hello World!"); + return 2; +} diff --git a/examples/app-and-lib/lib/lib.h b/examples/app-and-lib/lib/lib.h new file mode 100644 index 00000000..21d83e35 --- /dev/null +++ b/examples/app-and-lib/lib/lib.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef LIB_H +#define LIB_H + +int bla(); + +#endif // LIB_H diff --git a/examples/app-and-lib/lib/lib.qbs b/examples/app-and-lib/lib/lib.qbs new file mode 100644 index 00000000..a5fbc6fb --- /dev/null +++ b/examples/app-and-lib/lib/lib.qbs @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +StaticLibrary { + name: "mylib" + files: [ + "lib.cpp", + "lib.h", + ] + Depends { name: 'cpp' } + cpp.defines: ['CRUCIAL_DEFINE'] + + Export { + Depends { name: "cpp" } + cpp.includePaths: [exportingProduct.sourceDirectory] + } +} + diff --git a/examples/baremetal/at90can128olimex/at90can128olimex.qbs b/examples/baremetal/at90can128olimex/at90can128olimex.qbs new file mode 100644 index 00000000..2c206f7c --- /dev/null +++ b/examples/baremetal/at90can128olimex/at90can128olimex.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for Olimex AVR-CAN board" + references: [ + "redblink/redblink.qbs" + ] +} diff --git a/examples/baremetal/at90can128olimex/redblink/README.md b/examples/baremetal/at90can128olimex/redblink/README.md new file mode 100644 index 00000000..cbf51898 --- /dev/null +++ b/examples/baremetal/at90can128olimex/redblink/README.md @@ -0,0 +1,9 @@ +This example demonstrates how to build a bare-metal application using +different AVR toolchains. It is designed for the OLIMEX AVR-CAN target +board (based on at90can128 chip) and simply flashes the red LED on the +board. + +The following toolchains are supported: + + * GCC + * IAR Embedded Workbench diff --git a/examples/baremetal/at90can128olimex/redblink/gpio.c b/examples/baremetal/at90can128olimex/redblink/gpio.c new file mode 100644 index 00000000..543e31a8 --- /dev/null +++ b/examples/baremetal/at90can128olimex/redblink/gpio.c @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#if defined(__GNUC__) +#include +#elif defined (__ICCAVR__) +#include +#else +#error "Unsupported toolchain" +#endif + +// LED pin number. +#define GPIO_RED_LED_PIN_POS (4u) +// LED port direction. +#define GPIO_RED_LED_PORT_DIR (DDRE) +// LED output port. +#define GPIO_RED_LED_PORT_OUT (PORTE) + +void gpio_init_red_led(void) +{ + GPIO_RED_LED_PORT_DIR = 0xFF; +} + +void gpio_toggle_red_led(void) +{ + GPIO_RED_LED_PORT_OUT ^= (1u << GPIO_RED_LED_PIN_POS); +} diff --git a/examples/baremetal/at90can128olimex/redblink/gpio.h b/examples/baremetal/at90can128olimex/redblink/gpio.h new file mode 100644 index 00000000..246eab86 --- /dev/null +++ b/examples/baremetal/at90can128olimex/redblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_red_led(void); +void gpio_toggle_red_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/at90can128olimex/redblink/main.c b/examples/baremetal/at90can128olimex/redblink/main.c new file mode 100644 index 00000000..d62f9035 --- /dev/null +++ b/examples/baremetal/at90can128olimex/redblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + gpio_init_red_led(); + + while (1) { + gpio_toggle_red_led(); + some_delay(100000u); + } +} diff --git a/examples/baremetal/at90can128olimex/redblink/redblink.qbs b/examples/baremetal/at90can128olimex/redblink/redblink.qbs new file mode 100644 index 00000000..afdbe46f --- /dev/null +++ b/examples/baremetal/at90can128olimex/redblink/redblink.qbs @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("avr")) + return false; + return qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("iar") + } + name: "at90can128olimex-redblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // GCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.driverFlags: ["-mmcu=at90can128"] + } + + // Note: We implicitly use the startup file and the linker script + // which are already linked into the avr-gcc toolchain runtime. + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.driverFlags: ["--cpu=can128", "-ms"] + cpp.entryPoint: "__program_start" + cpp.driverLinkerFlags: [ + "-D_..X_HEAP_SIZE=0", + "-D_..X_NEAR_HEAP_SIZE=20", + "-D_..X_CSTACK_SIZE=20", + "-D_..X_RSTACK_SIZE=20", + "-D_..X_FLASH_CODE_END=1FFFF", + "-D_..X_FLASH_BASE=_..X_INTVEC_SIZE", + "-D_..X_EXT_SRAM_BASE=_..X_SRAM_END", + "-D_..X_EXT_ROM_BASE=_..X_SRAM_END", + "-D_..X_EXT_NV_BASE=_..X_SRAM_END", + "-D_..X_CSTACK_BASE=_..X_SRAM_BASE", + "-D_..X_CSTACK_END=_..X_SRAM_END", + "-D_..X_RSTACK_BASE=_..X_SRAM_BASE", + "-D_..X_RSTACK_END=_..X_SRAM_END", + "-h'1895'(CODE)0-(_..X_INTVEC_SIZE-1)", + ] + cpp.staticLibraries: [ + // Explicitly link with the runtime dlib library (which contains + // all required startup code and other stuff). + cpp.toolchainInstallPath + "/../lib/dlib/dlAVR-3s-ec_mul-n.r90" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Linker Script" + prefix: cpp.toolchainInstallPath + "/../src/template/" + fileTags: ["linkerscript"] + // Explicitly use the default linker scripts for current target. + files: ["cfg3soim.xcl", "cfgcan128.xcl"] + } + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/baremetal.qbs b/examples/baremetal/baremetal.qbs new file mode 100644 index 00000000..0d71968b --- /dev/null +++ b/examples/baremetal/baremetal.qbs @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "BareMetal" + references: [ + "stm32f4discovery/stm32f4discovery.qbs", + "at90can128olimex/at90can128olimex.qbs", + "cc2540usbdongle/cc2540usbdongle.qbs", + "stm8s103f3/stm8s103f3.qbs", + "msp430f5529/msp430f5529.qbs", + "cy7c68013a/cy7c68013a.qbs", + "stm32f103/stm32f103.qbs", + "pca10040/pca10040.qbs", + "pca10001/pca10001.qbs", + "esp8266/esp8266.qbs", + ] +} diff --git a/examples/baremetal/cc2540usbdongle/cc2540usbdongle.qbs b/examples/baremetal/cc2540usbdongle/cc2540usbdongle.qbs new file mode 100644 index 00000000..6cb99e6a --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/cc2540usbdongle.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for cc2540usbdongle board" + references: [ + "greenblink/greenblink.qbs" + ] +} diff --git a/examples/baremetal/cc2540usbdongle/greenblink/README.md b/examples/baremetal/cc2540usbdongle/greenblink/README.md new file mode 100644 index 00000000..4e90293e --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/README.md @@ -0,0 +1,9 @@ +This example demonstrates how to build a bare-metal application using +different MCS-51 toolchains. It is designed for the CC2540 usb dongle +target board (based on Texas Instruments CC2540 wireless MCU) and +simply flashes the green LED on the board. + +The following toolchains are supported: + + * IAR Embedded Workbench + * KEIL uVision diff --git a/examples/baremetal/cc2540usbdongle/greenblink/gpio.c b/examples/baremetal/cc2540usbdongle/greenblink/gpio.c new file mode 100644 index 00000000..a0947146 --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/gpio.c @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#define GPIO_GREEN_LED_PIN_POS (1u) + +void gpio_init_green_led(void) +{ + P0SEL = 0; // Choose the port. + P0DIR = 0x01; // Set pin0 to output mode. +} + +void gpio_toggle_green_led(void) +{ + P0 ^= GPIO_GREEN_LED_PIN_POS; +} diff --git a/examples/baremetal/cc2540usbdongle/greenblink/gpio.h b/examples/baremetal/cc2540usbdongle/greenblink/gpio.h new file mode 100644 index 00000000..ddeccad0 --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_green_led(void); +void gpio_toggle_green_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/cc2540usbdongle/greenblink/greenblink.qbs b/examples/baremetal/cc2540usbdongle/greenblink/greenblink.qbs new file mode 100644 index 00000000..d1d3281a --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/greenblink.qbs @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("mcs51")) + return false; + return qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil") + || qbs.toolchain.contains("sdcc") + } + name: "cc2540usbdongle-greenblink" + cpp.positionIndependentCode: false + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.commonCompilerFlags: ["-e"] + cpp.driverLinkerFlags: [ + "-D_IDATA_STACK_SIZE=0x40", + "-D_PDATA_STACK_SIZE=0x00", + "-D_XDATA_STACK_SIZE=0x00", + "-D_XDATA_HEAP_SIZE=0x00", + "-D_EXTENDED_STACK_SIZE=0", + "-D_EXTENDED_STACK_START=0" + ] + cpp.staticLibraries: [ + cpp.toolchainInstallPath + "/../lib/clib/cl-pli-nsid-1e16x01" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Linker Script" + prefix: cpp.toolchainInstallPath + "/../config/devices/_generic/" + fileTags: ["linkerscript"] + files: ["lnk51ew_8051.xcl"] + } + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.driverLinkerFlags: [ + "RAMSIZE(256)", + "CODE(0x0000-0xFFFF)" + ] + } + + // + // SDCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("sdcc") + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/cc2540usbdongle/greenblink/main.c b/examples/baremetal/cc2540usbdongle/greenblink/main.c new file mode 100644 index 00000000..88fae04a --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +static void some_delay(unsigned long counts) +{ + unsigned long index = 0u; + for (index = 0u; index < counts; ++index) + system_nop(); +} + +int main(void) +{ + gpio_init_green_led(); + + while (1) { + gpio_toggle_green_led(); + some_delay(20000u); + } +} diff --git a/examples/baremetal/cc2540usbdongle/greenblink/system.h b/examples/baremetal/cc2540usbdongle/greenblink/system.h new file mode 100644 index 00000000..4f105dbd --- /dev/null +++ b/examples/baremetal/cc2540usbdongle/greenblink/system.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__ICC8051__) +#include +# define system_nop() __no_operation() +# define DEFINE_SFR(name,addr) __sfr __no_init volatile unsigned char name @ addr; +#elif defined (__C51__) +#include +# define system_nop() _nop_() +# define DEFINE_SFR(name, addr) sfr name = addr; +#elif defined (__SDCC_mcs51) +#include +# define DEFINE_SFR(name, addr) __sfr __at(addr) name; +# ifndef NOP +# define NOP() __asm NOP __endasm +# endif +# define system_nop() NOP() +#else +#error "Unsupported toolchain" +#endif + +DEFINE_SFR(P0 , 0x80u) // Port 0. +DEFINE_SFR(P0SEL, 0xF3u) // Port 0 function select. +DEFINE_SFR(P0DIR, 0xFDu) // Port 0 direction select. + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/cy7c68013a/cy7c68013a.qbs b/examples/baremetal/cy7c68013a/cy7c68013a.qbs new file mode 100644 index 00000000..dca261d7 --- /dev/null +++ b/examples/baremetal/cy7c68013a/cy7c68013a.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for cy7c68013a board" + references: [ + "nes-gamepads/nes-gamepads.qbs" + ] +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/README.md b/examples/baremetal/cy7c68013a/nes-gamepads/README.md new file mode 100644 index 00000000..06d1fc77 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/README.md @@ -0,0 +1,42 @@ +This example demonstrates how to build a bare-metal application using +different 8051 toolchains. It is designed for the target board +based on Cypress FX2 cy7c68013a chip. + +It is possible to use the official development kit from the Cypress: + +* https://www.cypress.com/documentation/development-kitsboards/cy3684-ez-usb-fx2lp-development-kit + +but, a better solution is to buy the China's analogs or replacements, +e.g. on Aliexpress. + +It implements a USB HID device that connects two 8-buttons NES +(Dendy) gamepads to a PC. The gamepads are connected to the +cy7c68013a chip as follows: + +1. CLK - it is an output clock signal which generates by chip from + the port A, pin 0 (PA0). This pin should be connected to the CLK + inputs for both gamepads. + +2. DATA1 - it is an input data signal which comes to chip on the + the port A, pin 2 (PA2). This pin should be connected to the DATA + output from the gamepad #1. + +3. DATA2 - it is an input data signal which comes to chip on the + the port A, pin 4 (PA4). This pin should be connected to the DATA + output from the gamepad #2. + +4. LATCH - it is an output clock signal which generates by chip from + the port A, pin 6 (PA6). This pin should be connected to the LATCH + inputs for both gamepads. + +Actual schematic and pinouts depends on an used gamepads (with 7, 9 +or other pins connectors) and a development boards. + +Also, do not forget to connect the +3.3V and GND wires to the gamepads. +Then it is possible to play 8-bit NES games using various PC simulators. + +The following toolchains are supported: + + * IAR Embedded Workbench + * SDCC + * KEIL C51 diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/core.c b/examples/baremetal/cy7c68013a/nes-gamepads/core.c new file mode 100644 index 00000000..17a9661e --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/core.c @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "core.h" +#include "regs.h" + +enum cpu_freq_clk { + CPU_CLK_12M = 0, + CPU_CLK_24M, + CPU_CLK_48M +}; + +#define cpu_freq_clk_get() \ + ((CPUCS & bmCLKSPD) >> 3) + +#define cpu_freq_clk_set(freq_clk) \ + CPUCS = (CPUCS & ~bmCLKSPD) | (freq_clk << 3) + +void core_init(void) +{ + // Set CPU clock to 48MHz. + cpu_freq_clk_set(CPU_CLK_48M); + sync_delay(); + // Set stretch to 0. + CKCON = ((CKCON & (~bmSTRETCH)) | bmFW_STRETCH1); + sync_delay(); + // Clear breakpoint register. + BREAKPT = 0; + sync_delay(); + // Set all 8051 interrupts to low priority + IP = 0; + sync_delay(); + // Clear interrupt enable bits. + EIE = 0; + sync_delay(); + // Clear all external interrupt flags. + EXIF = 0; + sync_delay(); +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/core.h b/examples/baremetal/cy7c68013a/nes-gamepads/core.h new file mode 100644 index 00000000..a53ad2a4 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/core.h @@ -0,0 +1,298 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_HW_H +#define FX2_HW_H + +#include "defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Allowed range: 5000 - 48000. +#ifndef CORE_IFREQ +# define CORE_IFREQ 48000 // IFCLK frequency in kHz. +#endif + +// Allowed values: 48000, 24000, or 12000. +#ifndef CORE_CFREQ +# define CORE_CFREQ 48000 // CLKOUT frequency in kHz. +#endif + +#if (CORE_IFREQ < 5000) +# error "CORE_IFREQ too small! Valid range: 5000 - 48000." +#endif + +#if (CORE_IFREQ > 48000) +# error "CORE_IFREQ too large! Valid range: 5000 - 48000." +#endif + +#if (CORE_CFREQ != 48000) +# if (CORE_CFREQ != 24000) +# if (CORE_CFREQ != 12000) +# error "CORE_CFREQ invalid! Valid values: 48000, 24000, 12000." +# endif +# endif +#endif + +// Calculate synchronization delay. +#define CORE_SCYCL (3 * (CORE_CFREQ) + 5 * (CORE_IFREQ) - 1) / (2 * (CORE_IFREQ)) + +#if (CORE_SCYCL == 1) +# define sync_delay() {\ + NOP(); } +#endif + +#if (CORE_SCYCL == 2) +# define sync_delay() {\ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 3) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 4) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 5) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 6) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 7) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 8) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 9) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 10) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 11) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 12) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 13) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 14) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 15) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#if (CORE_SCYCL == 16) +# define sync_delay() {\ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); \ + NOP(); } +#endif + +#define code_all_irq_disable() (IE = 0) +#define code_all_irq_enable() (IE = 1) + +void core_init(void); + +#ifdef __cplusplus +} +#endif + +#endif // FX2_HW_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/defs.h b/examples/baremetal/cy7c68013a/nes-gamepads/defs.h new file mode 100644 index 00000000..7fb36fee --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/defs.h @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_DEFS_H +#define FX2_DEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +enum bit_mask { + bmBIT0 = 0x01, + bmBIT1 = 0x02, + bmBIT2 = 0x04, + bmBIT3 = 0x08, + bmBIT4 = 0x10, + bmBIT5 = 0x20, + bmBIT6 = 0x40, + bmBIT7 = 0x80 +}; + +enum boolean { + FALSE = 0, + TRUE +}; + +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef unsigned long DWORD; +typedef unsigned char BOOL; + +#ifndef NULL +#define NULL (void *)0 +#endif + +#if defined(__ICC8051__) + +#include + +# define NOP() __no_operation() + +# define XDATA __xdata +# define CODE __code +# define AT __at + +# define SFR __sfr +# define SBIT __bit + +# define XDATA_REG(reg_name, reg_addr) \ + XDATA __no_init volatile BYTE reg_name @ reg_addr; + +# define SPEC_FUN_REG(reg_name, reg_addr) \ + SFR __no_init volatile BYTE reg_name @ reg_addr; + +# define SPEC_FUN_REG_BIT(bit_name, reg_addr, bit_num) \ + SBIT __no_init volatile _Bool bit_name @ (reg_addr+bit_num); + +# define _PPTOSTR_(x) #x +# define _PPARAM_(address) _PPTOSTR_(vector=address * 8 + 3) +# define INTERRUPT(isr_name, vector) \ + _Pragma(_PPARAM_(vector)) __interrupt void isr_name(void) + +#elif defined (__C51__) + +# include + +# define NOP() _nop_() + +# define XDATA xdata +# define CODE code +# define AT _at_ + +# define SFR sfr +# define SBIT sbit + +# if defined(DEFINE_REGS) +# define XDATA_REG(reg_name, reg_addr) \ + XDATA volatile BYTE reg_name AT reg_addr; +# else +# define XDATA_REG(reg_name, reg_addr) \ + extern XDATA volatile BYTE reg_name; +# endif + +# define SPEC_FUN_REG(reg_name, reg_addr) \ + SFR reg_name = reg_addr; + +# define SPEC_FUN_REG_BIT(bit_name, reg_addr, bit_num) \ + sbit bit_name = reg_addr + bit_num; + +# define INTERRUPT(isr_name, num) \ + void isr_name (void) interrupt num + +#elif defined (__SDCC_mcs51) + +# define NOP() __asm nop __endasm + +# define XDATA __xdata +# define CODE __code +# define AT __at + +# define SFR __sfr +# define SBIT __sbit + +# define XDATA_REG(reg_name, reg_addr) \ + XDATA AT reg_addr volatile BYTE reg_name; + +# define SPEC_FUN_REG(reg_name, reg_addr) \ + SFR AT reg_addr reg_name; + +# define SPEC_FUN_REG_BIT(bit_name, reg_addr, bit_num) \ + SBIT AT reg_addr + bit_num bit_name; + +# define INTERRUPT(isr_name, num) \ + void isr_name (void) __interrupt num + +#else + +#error "Unsupported toolchain" + +#endif + +#ifdef __cplusplus +} +#endif + +#endif // FX2_DEFS_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/gpio.c b/examples/baremetal/cy7c68013a/nes-gamepads/gpio.c new file mode 100644 index 00000000..d7a74b3e --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/gpio.c @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "core.h" +#include "gpio.h" +#include "hid.h" +#include "regs.h" + +static WORD g_counter = 0; + +// We use this empirical value to make a GPIO polling +// every ~10 msec (rough). It is a simplest way, because +// instead we need to use a timers with interrupts callbacks. +enum { POLLING_COUNTER = 580 }; + +// Pins on the port A. +enum gpio_pins { + GPIO_CLK_PIN = bmBIT0, + GPIO_DATA1_PIN = bmBIT2, + GPIO_DATA2_PIN = bmBIT4, + GPIO_LATCH_PIN = bmBIT6, +}; + +static struct { + const BYTE pin; + BYTE buttons; +} g_reports[HID_REPORTS_COUNT] = { + {GPIO_DATA1_PIN, 0}, + {GPIO_DATA2_PIN, 0} +}; + +// Pulse width around ~1 usec. +static void gpio_latch_pulse(void) +{ + IOA |= GPIO_LATCH_PIN; + sync_delay(); + sync_delay(); + sync_delay(); + IOA &= ~GPIO_LATCH_PIN; + sync_delay(); +} + +// Pulse width around ~1 usec. +static void gpio_clk_pulse(void) +{ + IOA |= GPIO_CLK_PIN; + sync_delay(); + sync_delay(); + sync_delay(); + IOA &= ~GPIO_CLK_PIN; + sync_delay(); +} + +static void gpio_reports_clean(void) +{ + BYTE index = 0; + for (index = 0; index < HID_REPORTS_COUNT; ++index) + g_reports[index].buttons = 0; +} + +static void gpio_reports_send(void) +{ + BYTE index = 0; + for (index = 0; index < HID_REPORTS_COUNT; ++index) + hid_ep1_report_update(index, g_reports[index].buttons); +} + +static void gpio_poll(void) +{ + BYTE pos = 0; + + // Cleanup reports. + gpio_reports_clean(); + + // Send latch pulse. + gpio_latch_pulse(); + + for (pos = 0; pos < HID_REPORT_BITS_COUNT; ++pos) { + // TODO: Add some nops here? + + BYTE index = 0; + for (index = 0; index < HID_REPORTS_COUNT; ++index) { + // Low state means that a button is pressed. + const BOOL v = (IOA & g_reports[index].pin) ? 0 : 1; + g_reports[index].buttons |= (v << pos); + } + + // Send clock pulse. + gpio_clk_pulse(); + } + + gpio_reports_send(); +} + +void gpio_init(void) +{ + // Set interface to ports. + IFCONFIG = (IFCONFIG & (~bmIFCFG)) | bmIFPORTS; + sync_delay(); + + // Initialize the CLK and LATCH pins as output. + OEA = GPIO_CLK_PIN | GPIO_LATCH_PIN; + sync_delay(); +} + +void gpio_task(void) +{ + if (g_counter < POLLING_COUNTER) { + ++g_counter; + } else { + g_counter = 0; + gpio_poll(); + } +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/gpio.h b/examples/baremetal/cy7c68013a/nes-gamepads/gpio.h new file mode 100644 index 00000000..d2568fd7 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_GPIO_H +#define FX2_GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init(void); +void gpio_task(void); + +#ifdef __cplusplus +} +#endif + +#endif // FX2_GPIO_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/hid.c b/examples/baremetal/cy7c68013a/nes-gamepads/hid.c new file mode 100644 index 00000000..cca4edab --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/hid.c @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" +#include "core.h" +#include "usb.h" + +void hid_init(void) +{ + // Disable end point 1 output. + EP1OUTCFG = bmEP_DISABLE; + sync_delay(); + // Enable end point 1 input in interrupt mode. + EP1INCFG = bmEP_ENABLE | bmEP_INT; + sync_delay(); + // Disable end point 2. + EP2CFG = bmEP_DISABLE; + sync_delay(); + // Disable end point 4. + EP4CFG = bmEP_DISABLE; + sync_delay(); + // Disable end point 6. + EP6CFG = bmEP_DISABLE; + sync_delay(); + // Disable end point 8. + EP8CFG = bmEP_DISABLE; + sync_delay(); + + // Reset all FIFOs. + FIFORESET = bmNAKALL; // NAK all host transfers. + sync_delay(); + FIFORESET = 0x00; + sync_delay(); + + // Enable dual autopointer(s). + AUTOPTRSETUP |= bmAPTREN; + sync_delay(); +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/hid.h b/examples/baremetal/cy7c68013a/nes-gamepads/hid.h new file mode 100644 index 00000000..c51b8737 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/hid.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_HID_H +#define FX2_HID_H + +#include "usb.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum hid_constants { + HID_CONFIG_NUMBER = 1, // Number of valid configuration. + HID_IFACE_NUMBER = 0, // Number of valid interface. + HID_ALT_IFACE_NUMBER = 0, // Number of valid alternate interface. + HID_EP_IN = 0x81 // Active end point address. +}; + +enum hid_gamepad_id { + HID_REPORT_ID_GAMEPAD1 = 1, + HID_REPORT_ID_GAMEPAD2 = 2 +}; + +enum { + HID_REPORTS_COUNT = 2, + HID_REPORT_BITS_COUNT = 8 +}; + +void hid_init(void); + +void hid_ep0_init(void); +void hid_ep0_setup_task(void); + +const BYTE CODE *hid_ep0_std_desc_get(void); +const BYTE CODE *hid_ep0_report_desc_get(WORD *length); + +void hid_ep1_task(void); +void hid_ep1_report_update(BYTE index, BYTE buttons); + +#ifdef __cplusplus +} +#endif + +#endif // FX2_HID_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/hiddesc.c b/examples/baremetal/cy7c68013a/nes-gamepads/hiddesc.c new file mode 100644 index 00000000..74601f24 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/hiddesc.c @@ -0,0 +1,345 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" + +enum usb_bcd_version { + USB_SPEC_BCD_VERSION = 0x0200, + USB_DEVICE_BCD_VERSION = 0x1234, + USB_HID_BCD_VERSION = 0x0111 +}; + +enum usb_ids { + USB_DEVICE_VID = 0xFFFF, + USB_DEVICE_PID = 0xFFFF +}; + +enum usb_lang_id { + USB_LANG_ID = 0x0409 +}; + +enum usb_descriptor_string_index { + USB_DESC_LANGID_STRING_INDEX = 0, + USB_DESC_MFG_STRING_INDEX, + USB_DESC_PRODUCT_STRING_INDEX, + USB_DESC_SERIAL_STRING_INDEX +}; + +enum usb_descr_length { + // Standard length. + USB_DESC_DEVICE_LEN = 18, + USB_DESC_DEVICE_QUAL_LEN = 10, + USB_DESC_CONF_LEN = 9, + USB_DESC_OTHER_SPEED_CONF_LEN = 9, + USB_DESC_INTERFACE_LEN = 9, + USB_DESC_HID_LEN = 9, + USB_DESCR_HID_REP_LEN = 56, + USB_DESC_ENDPOINT_LEN = 7, + + // Total length. + USB_DESC_DEVICE_TOTAL_LEN = USB_DESC_DEVICE_LEN, + USB_DESC_DEVICE_QUAL_TOTAL_LEN = USB_DESC_DEVICE_QUAL_LEN, + + USB_DESC_CONF_TOTAL_LEN = USB_DESC_CONF_LEN + + USB_DESC_INTERFACE_LEN + + USB_DESC_HID_LEN + USB_DESC_ENDPOINT_LEN, + + USB_DESC_OTHER_SPEED_CONF_TOTAL_LEN = USB_DESC_OTHER_SPEED_CONF_LEN + + USB_DESC_INTERFACE_LEN, +}; + +enum usb_descr_attributes { + // Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu). + USB_DESC_ATTRIBUTES = 0xA0, + // 100 mA (div 2). + USB_DESC_POWER_CONSUMPTION = 50 +}; + +enum usb_descr_numbers { + USB_DESC_CONFIG_COUNT = 1 +}; + +static const BYTE CODE +g_hid_report_desc[USB_DESCR_HID_REP_LEN] = { + // Pad #1 configuration. + 0x05, 0x01, // Usage page (Generic Desktop). + 0x09, 0x05, // Usage (Game Pad). + 0xa1, 0x01, // Collection (Application). + 0xa1, 0x00, // Collection (Physical). + 0x85, HID_REPORT_ID_GAMEPAD1, // Report id (1). + 0x05, 0x09, // Usage page (Button). + 0x19, 0x01, // Usage minimum (Button 1). + 0x29, 0x08, // Usage maximum (Button 8). + 0x15, 0x00, // Logical minimum (0). + 0x25, 0x01, // Logical maximum (1). + 0x95, HID_REPORT_BITS_COUNT, // Report count (8). + 0x75, 0x01, // Report size (1). + 0x81, 0x02, // Input (Data,Var,Abs). + 0xc0, // End collection. + 0xc0, // End collection. + // Pad #2 configuration. + 0x05, 0x01, // Usage page (Generic Desktop). + 0x09, 0x05, // Usage (Game Pad). + 0xa1, 0x01, // Collection (Application). + 0xa1, 0x00, // Collection (Physical). + 0x85, HID_REPORT_ID_GAMEPAD2, // Report id (2). + 0x05, 0x09, // Usage page (Button). + 0x19, 0x01, // Usage minimum (Button 1). + 0x29, 0x08, // Usage maximum (Button 8). + 0x15, 0x00, // Logical minimum (0). + 0x25, 0x01, // Logical maximum (1). + 0x95, HID_REPORT_BITS_COUNT, // Report count (8). + 0x75, 0x01, // Report size (1). + 0x81, 0x02, // Input (Data,Var,Abs). + 0xc0, // End collection + 0xc0 // End collection. +}; + +static const BYTE CODE +g_device_desc[USB_DESC_DEVICE_TOTAL_LEN] = { + USB_DESC_DEVICE_LEN, // Descriptor length. + USB_DESC_DEVICE, // Descriptor type. + usb_word_lsb_get(USB_SPEC_BCD_VERSION), // USB BCD version, lo. + usb_word_msb_get(USB_SPEC_BCD_VERSION), // USB BCD version, hi. + 0x00, // Device class. + 0x00, // Device sub-class. + 0x00, // Device protocol. + MAX_EP0_SIZE, // Maximum packet size (ep0 size). + usb_word_lsb_get(USB_DEVICE_VID), // Vendor ID, lo. + usb_word_msb_get(USB_DEVICE_VID), // Vendor ID, hi. + usb_word_lsb_get(USB_DEVICE_PID), // Product ID, lo. + usb_word_msb_get(USB_DEVICE_PID), // Product ID, hi. + usb_word_lsb_get(USB_DEVICE_BCD_VERSION), // Device BCD version, lo. + usb_word_msb_get(USB_DEVICE_BCD_VERSION), // Device BCD version, hi. + USB_DESC_MFG_STRING_INDEX, + USB_DESC_PRODUCT_STRING_INDEX, + USB_DESC_SERIAL_STRING_INDEX, + USB_DESC_CONFIG_COUNT // Configurations count. +}; + +static const BYTE CODE +g_device_qual_desc[USB_DESC_DEVICE_QUAL_TOTAL_LEN] = { + USB_DESC_DEVICE_QUAL_LEN, // Descriptor length. + USB_DESC_DEVICE_QUAL, // Descriptor type. + usb_word_lsb_get(USB_SPEC_BCD_VERSION), // USB BCD version, lo. + usb_word_msb_get(USB_SPEC_BCD_VERSION), // USB BCD version, hi. + 0x00, // Device class. + 0x00, // Device sub-class. + 0x00, // Device protocol. + MAX_EP0_SIZE, // Maximum packet size (ep0 size). + USB_DESC_CONFIG_COUNT, // Configurations count. + 0x00 // Reserved. +}; + +static const BYTE CODE +g_config_desc[USB_DESC_CONF_TOTAL_LEN] = { + USB_DESC_CONF_LEN, // Descriptor length. + USB_DESC_CONF, // Descriptor type. + usb_word_lsb_get(USB_DESC_CONF_TOTAL_LEN), // Total length, lo. + usb_word_msb_get(USB_DESC_CONF_TOTAL_LEN), // Total length, hi. + 0x01, // Interfaces count. + HID_CONFIG_NUMBER, // Configuration number. + 0x00, // Configuration string index. + USB_DESC_ATTRIBUTES, // Attributes. + USB_DESC_POWER_CONSUMPTION, // Power consumption. + + // Interface descriptor. + USB_DESC_INTERFACE_LEN, // Descriptor length. + USB_DESC_INTERFACE, // Descriptor type. + HID_IFACE_NUMBER, // Zero-based index of this interfacce. + HID_ALT_IFACE_NUMBER, // Alternate setting. + 0x01, // End points count (ep1 in). + 0x03, // Class code (HID). + 0x00, // Subclass code (boot). + 0x00, // Protocol code (none). + 0x00, // Interface string descriptor index. + + // HID descriptor. + USB_DESC_HID_LEN, // Descriptor length. + USB_DESC_HID, // Descriptor type. + usb_word_lsb_get(USB_HID_BCD_VERSION), // HID class BCD version, lo. + usb_word_msb_get(USB_HID_BCD_VERSION), // HID class BCD version, hi. + 0x00, // Country code (HW country code). + 0x01, // Number of HID class descriptors to follow. + USB_DESC_REPORT, // Repord descriptor type (HID). + usb_word_lsb_get(USB_DESCR_HID_REP_LEN), // Report descriptor total length, lo. + usb_word_msb_get(USB_DESCR_HID_REP_LEN), // Report descriptor total length, hi. + + // End point descriptor. + USB_DESC_ENDPOINT_LEN, // Descriptor length. + USB_DESC_ENDPOINT, // Descriptor type. + HID_EP_IN, // End point address (ep1 in). + 0x03, // End point type (interrupt). + usb_word_lsb_get(MAX_EP1_SIZE), // Maximum packet size, lo (ep1 size). + usb_word_msb_get(MAX_EP1_SIZE), // Maximum packet size, hi (ep1 size). + 0x01 // Polling interval (1 ms). +}; + +static const BYTE CODE +g_other_config_desc[USB_DESC_OTHER_SPEED_CONF_TOTAL_LEN] = { + USB_DESC_OTHER_SPEED_CONF_LEN, // Descriptor length. + USB_DESC_OTHER_SPEED_CONF, // Descriptor type. + usb_word_lsb_get(USB_DESC_OTHER_SPEED_CONF_TOTAL_LEN), // Total length, lo. + usb_word_msb_get(USB_DESC_OTHER_SPEED_CONF_TOTAL_LEN), // Total length, hi. + 0x01, // Interfaces number. + 0x01, // Configuration number. + 0x00, // Configuration string index. + USB_DESC_ATTRIBUTES, // Attributes. + USB_DESC_POWER_CONSUMPTION, // Power consumption. + + // Interface descriptor. + USB_DESC_INTERFACE_LEN, // Descriptor length. + USB_DESC_INTERFACE, // Descriptor type. + 0x00, // Zero-based index of this interfacce. + 0x00, // Alternate setting. + 0x00, // End points number (only ep0). + 0x00, // Class code. + 0x00, // Subclass code.USB_DESC_OTHER_SPEED_CONFIGURATION + 0x00, // Protocol code. + 0x00 // Interface string descriptor index. +}; + +static const BYTE CODE +g_lang_id_desc[] = { + 0x04, // Descriptor length. + USB_DESC_STRING, // Descriptor type. + usb_word_lsb_get(USB_LANG_ID), // Language id, lo. + usb_word_msb_get(USB_LANG_ID) // Language id, hi. +}; + +static const BYTE CODE +g_manuf_str_desc[] = { + 0x18, // Descriptor length. + USB_DESC_STRING, // Descriptor type. + // Unicode string: + 'Q', 0, 'B', 0, 'S', 0, ' ', 0, + 'e', 0, 'x', 0, 'a', 0, 'm', 0, 'p', 0, 'l', 0, 'e', 0 +}; + +static const BYTE CODE +g_product_str_desc[] = { + 0x1A, // Descriptor length. + USB_DESC_STRING, // Descriptor type. + // Unicode string: + 'N', 0, 'E', 0, 'S', 0, ' ', 0, + 'G', 0, 'a', 0, 'm', 0, 'e', 0, + 'P', 0, 'a', 0, 'd', 0, 's', 0 +}; + +static const BYTE CODE +g_serialno_str_desc[] = { + 0x1A, // Descriptor length. + USB_DESC_STRING, // Descriptor type. + // Unicode string: + '0', 0 ,'1', 0, '0', 0, '2', 0, '0', 0, '3', 0, + '0', 0, '4', 0, '0', 0, '5', 0, '0', 0, '6', 0 +}; + +static const BYTE CODE *ep0_string_desc_get(void) +{ + switch (SETUPDAT[2]) { + case USB_DESC_LANGID_STRING_INDEX: + return g_lang_id_desc; + case USB_DESC_MFG_STRING_INDEX: + return g_manuf_str_desc; + case USB_DESC_PRODUCT_STRING_INDEX: + return g_product_str_desc; + case USB_DESC_SERIAL_STRING_INDEX: + return g_serialno_str_desc; + default: + break; + } + + return NULL; +} + +static const BYTE CODE *ep0_config_desc_get(BOOL other) +{ + if (!other) { + if (SETUPDAT[2] == 0) { + return usb_is_high_speed() ? g_config_desc + : g_other_config_desc; + } + } else { + return usb_is_high_speed() ? g_other_config_desc + : g_config_desc; + } + + return NULL; +} + +const BYTE CODE *hid_ep0_std_desc_get(void) +{ + switch (SETUPDAT[3]) { + case USB_DESC_DEVICE: + return g_device_desc; + case USB_DESC_CONF: + return ep0_config_desc_get(FALSE); + case USB_DESC_STRING: + return ep0_string_desc_get(); + case USB_DESC_DEVICE_QUAL: + return g_device_qual_desc; + case USB_DESC_OTHER_SPEED_CONF: + return ep0_config_desc_get(TRUE); + case USB_DESC_HID: + return &g_config_desc[USB_DESC_CONF_LEN + + USB_DESC_INTERFACE_LEN]; + default: + break; + } + + return NULL; +} + +const BYTE CODE *hid_ep0_report_desc_get(WORD *length) +{ + *length = sizeof(g_hid_report_desc); + return g_hid_report_desc; +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/hidep0.c b/examples/baremetal/cy7c68013a/nes-gamepads/hidep0.c new file mode 100644 index 00000000..8648f625 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/hidep0.c @@ -0,0 +1,377 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" +#include "core.h" +#include "usb.h" + +static BOOL g_rwuen = FALSE; +static BOOL g_selfpwr = FALSE; + +static void ep0_ep1in_reset(void) +{ + EP1INCS &= ~bmEPBUSY; + sync_delay(); + usp_ep_reset_toggle(HID_EP_IN); + sync_delay(); +} + +// Get status handle. + +static BYTE *ep_address_get(BYTE ep) +{ + const BYTE ep_num = ep & ~bmSETUP_DIR; + switch (ep_num) { + case 0: + return (BYTE *)&EP0CS; + case 1: + return (ep & bmSETUP_DIR) + ? (BYTE *)&EP1INCS + : (BYTE *)&EP1OUTCS; + default: + break; + } + return NULL; +} + +static BOOL ep0_dev_status_get(void) +{ + BYTE status = 0; + if (g_selfpwr) + status |= USB_STATUS_SELF_POWERED; + if (g_rwuen) + status |= USB_STATUS_REMOTE_WAKEUP; + EP0BUF[0] = status; + EP0BUF[1] = 0; + EP0BCH = 0; + EP0BCL = 2; + return TRUE; +} + +static BOOL ep0_iface_status_get(void) +{ + EP0BUF[0] = 0; + EP0BUF[1] = 0; + EP0BCH = 0; + EP0BCL = 2; + return TRUE; +} + +static BOOL ep0_ep_status_get(void) +{ + const volatile BYTE XDATA *pep = + (BYTE XDATA *)ep_address_get(SETUPDAT[4]); + if (pep) { + EP0BUF[0] = *pep & bmEPSTALL ? 1 : 0; + EP0BUF[1] = 0; + EP0BCH = 0; + EP0BCL = 2; + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_get_status_proc(void) +{ + if ((SETUPDAT[0] & bmSETUP_TO_HOST) == 0) + return FALSE; + + switch (SETUPDAT[0] & bmSETUP_RECIPIENT) { + case bmSETUP_DEVICE: + return ep0_dev_status_get(); + case bmSETUP_IFACE: + return ep0_iface_status_get(); + case bmSETUP_EP: + return ep0_ep_status_get(); + default: + break; + } + + return FALSE; +} + +// Clear feature handle. + +static BOOL ep0_dev_feature_clear(void) +{ + if (SETUPDAT[2] == USB_FEATURE_REMOTE_WAKEUP) { + g_rwuen = FALSE; + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_ep_feature_clear(void) +{ + if (SETUPDAT[2] == USB_FEATURE_STALL) { + volatile BYTE XDATA *pep = + (BYTE XDATA *)ep_address_get(SETUPDAT[4]); + if (!pep) + return FALSE; + *pep &= ~bmEPSTALL; + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_clear_feature_proc(void) +{ + switch (SETUPDAT[0] & bmSETUP_RECIPIENT) { + case bmSETUP_DEVICE: + return ep0_dev_feature_clear(); + case bmSETUP_EP: + return ep0_ep_feature_clear(); + default: + break; + } + + return FALSE; +} + +// Set feature handle. + +static BOOL ep0_dev_feature_set(void) +{ + switch (SETUPDAT[2]) { + case USB_FEATURE_REMOTE_WAKEUP: + g_rwuen = TRUE; + return TRUE; + case USB_FEATRUE_TEST_MODE: + // This is "test mode", just return the handshake. + return TRUE; + default: + break; + } + + return FALSE; +} + +static BOOL ep0_ep_feature_set(void) +{ + if (SETUPDAT[2] == USB_FEATURE_STALL) { + volatile BYTE XDATA *pep = + (BYTE XDATA *)ep_address_get(SETUPDAT[4]); + if (!pep) + return FALSE; + *pep |= bmEPSTALL; + usp_ep_reset_toggle(SETUPDAT[4]); + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_set_feature_proc(void) +{ + switch (SETUPDAT[0] & bmSETUP_RECIPIENT) { + case bmSETUP_DEVICE: + return ep0_dev_feature_set(); + case bmSETUP_EP: + return ep0_ep_feature_set(); + default: + break; + } + + return FALSE; +} + +// Get descriptor handle. + +static BOOL ep0_std_descriptor_proc(void) +{ + const BYTE XDATA *pdesc = + (BYTE XDATA *)hid_ep0_std_desc_get(); + if (pdesc) { + SUDPTRH = usb_word_msb_get(pdesc); + SUDPTRL = usb_word_lsb_get(pdesc); + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_report_descriptor_proc(void) +{ + WORD i = 0; + WORD length = 0; + const BYTE XDATA *pdesc = + (BYTE XDATA *)hid_ep0_report_desc_get(&length); + if (pdesc) { + AUTOPTRH1 = usb_word_msb_get(pdesc); + AUTOPTRL1 = usb_word_lsb_get(pdesc); + + for (i = 0; i < length; ++i) + EP0BUF[i] = XAUTODAT1; + + EP0BCH = usb_word_msb_get(length); + EP0BCL = usb_word_lsb_get(length); + return TRUE; + } + + return FALSE; +} + +static BOOL ep0_get_descriptor_proc(void) +{ + switch (SETUPDAT[3]) { + case USB_DESC_DEVICE: + case USB_DESC_CONF: + case USB_DESC_STRING: + case USB_DESC_DEVICE_QUAL: + case USB_DESC_OTHER_SPEED_CONF: + case USB_DESC_HID: + return ep0_std_descriptor_proc(); + case USB_DESC_REPORT: + return ep0_report_descriptor_proc(); + } + + return FALSE; +} + +// Get configuration handle. + +static BOOL ep0_get_config_proc(void) +{ + // We only support configuration 1. + EP0BUF[0] = HID_CONFIG_NUMBER; + EP0BCH = 0; + EP0BCL = 1; + return TRUE; +} + +// Set configuration handle. + +static BOOL ep0_set_config_proc(void) +{ + // We only support configuration 1. + if (SETUPDAT[2] != HID_CONFIG_NUMBER) + return FALSE; + + return TRUE; +} + +// Get interface handle. + +static BOOL ep0_get_iface_proc(void) +{ + if (SETUPDAT[4] != HID_IFACE_NUMBER) + return FALSE; + + EP0BUF[0] = HID_ALT_IFACE_NUMBER; + EP0BCH = 0; + EP0BCL = 1; + return TRUE; +} + +// Set interface handle. + +static BOOL ep0_set_iface_proc(void) +{ + if (SETUPDAT[4] != HID_IFACE_NUMBER) + return FALSE; + + if (SETUPDAT[2] != HID_ALT_IFACE_NUMBER) + return FALSE; + + ep0_ep1in_reset(); + return TRUE; +} + +static BOOL ep0_std_proc(void) +{ + switch (SETUPDAT[1]) { + case USB_SETUP_GET_STATUS: + return ep0_get_status_proc(); + case USB_SETUP_CLEAR_FEATURE: + return ep0_clear_feature_proc(); + case USB_SETUP_SET_FEATURE: + return ep0_set_feature_proc(); + case USB_SETUP_SET_ADDRESS: + // Handles automatically by FX2. + return TRUE; + case USB_SETUP_GET_DESCRIPTOR: + return ep0_get_descriptor_proc(); + case USB_SETUP_GET_CONFIGURATION: + return ep0_get_config_proc(); + case USB_SETUP_SET_CONFIGURATION: + return ep0_set_config_proc(); + case USB_SETUP_GET_INTERFACE: + return ep0_get_iface_proc(); + case USB_SETUP_SET_INTERFACE: + return ep0_set_iface_proc(); + default: + break; + } + + return FALSE; +} + +static BOOL ep0_setup(void) +{ + switch (SETUPDAT[0] & bmSETUP_TYPE) { + case bmSETUP_STANDARD: + return ep0_std_proc(); + default: + break; + } + + return FALSE; +} + +void hid_ep0_setup_task(void) +{ + if (!ep0_setup()) + usb_ep0_stall(); + + usb_ep0_hsnack(); +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/hidep1.c b/examples/baremetal/cy7c68013a/nes-gamepads/hidep1.c new file mode 100644 index 00000000..79031114 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/hidep1.c @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" + +struct hid_report { + const BYTE id; + BYTE buttons; + BYTE ready; +}; + +static struct hid_report g_reports[HID_REPORTS_COUNT] = { + {HID_REPORT_ID_GAMEPAD1, 0, FALSE}, + {HID_REPORT_ID_GAMEPAD2, 0, FALSE} +}; + +static void ep1_report_send(BYTE index) +{ + if (!g_reports[index].ready) + return; + + if (EP1INCS & bmEPBUSY) + return; + + EP1INBUF[0] = g_reports[index].id; + EP1INBUF[1] = g_reports[index].buttons; + EP1INBC = 2; + g_reports[index].ready = FALSE; +} + +void hid_ep1_task(void) +{ + BYTE index = 0; + for (index = 0; index < HID_REPORTS_COUNT; ++index) + ep1_report_send(index); +} + +void hid_ep1_report_update(BYTE index, BYTE buttons) +{ + g_reports[index].buttons = buttons; + g_reports[index].ready = TRUE; +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/irqs.h b/examples/baremetal/cy7c68013a/nes-gamepads/irqs.h new file mode 100644 index 00000000..4b5f9683 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/irqs.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_IRQS_H +#define FX2_IRQS_H + +#ifdef __cplusplus +extern "C" { +#endif + +// Standard interrupt numbers. +#define INT0_IRQ 0 // External interrupt 0. +#define TMR0_IRQ 1 // Timer 0 interrupt. +#define INT1_IRQ 2 // External interrupt 1. +#define TMR1_IRQ 3 // Timer 1 interrupt. +#define COM0_IRQ 4 // Serial port 0 transmit or receive interrupt. +#define TMR2_IRQ 5 // Timer 2 interrupt. +#define WKUP_IRQ 6 // Resume interrupt. +#define COM1_IRQ 7 // Serial port 1 transmit or receive interrupt. +#define USB_IRQ 8 // USB interrupt. +#define I2C_IRQ 9 // I2C bus interrupt. +#define INT4_IRQ 10 // External interrupt 4. +#define INT5_IRQ 11 // External interrupt 5. +#define INT6_IRQ 12 // External interrupt 6. + +#ifdef __cplusplus +} +#endif + +#endif // FX2_IRQS_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/main.c b/examples/baremetal/cy7c68013a/nes-gamepads/main.c new file mode 100644 index 00000000..71d5b924 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/main.c @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +// Allocate all registers once here (only for C51 compiler). +#define DEFINE_REGS +#include "regs.h" + +#include "core.h" +#include "gpio.h" +#include "usb.h" + +static void hw_init(void) +{ + usb_disconnect(); + code_all_irq_disable(); + + core_init(); + gpio_init(); + usb_init(); + + usb_connect(); + code_all_irq_enable(); +} + +static void hw_loop_exec(void) +{ + while (TRUE) { + gpio_task(); + usb_task(); + } +} + +int main(void) +{ + hw_init(); + hw_loop_exec(); + return 0; +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/nes-gamepads.qbs b/examples/baremetal/cy7c68013a/nes-gamepads/nes-gamepads.qbs new file mode 100644 index 00000000..81566ff9 --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/nes-gamepads.qbs @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("mcs51")) + return false; + return qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil") + || qbs.toolchain.contains("sdcc") + } + name: "cy7c68013a-nes-gamepads" + cpp.positionIndependentCode: false + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.commonCompilerFlags: ["-e"] + cpp.staticLibraries: [ + cpp.toolchainInstallPath + "/../lib/clib/cl-pli-nsid-1e16x01" + ] + cpp.driverLinkerFlags: [ + "-D_IDATA_STACK_SIZE=0x40", + "-D_PDATA_STACK_SIZE=0x80", + "-D_XDATA_STACK_SIZE=0xEFF", + "-D_XDATA_HEAP_SIZE=0xFF", + "-D_EXTENDED_STACK_SIZE=0", + "-D_EXTENDED_STACK_START=0" + ] + } + + Group { + name: "IAR Linker Script" + condition: qbs.toolchain.contains("iar") + prefix: cpp.toolchainInstallPath + "/../config/devices/cypress/" + fileTags: ["linkerscript"] + files: ["lnk51ew_CY7C68013A.xcl"] + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.driverLinkerFlags: [ + "RAMSIZE(256)", + "CODE(0x80)", + "XDATA(0x1000)" + ] + } + + // + // SDCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("sdcc") + cpp.driverLinkerFlags: [ + "--code-loc", "0x80", + "--xram-loc", "0x1000" + ] + } + + // + // Common code. + // + + files: [ + "core.c", + "core.h", + "defs.h", + "gpio.c", + "gpio.h", + "hid.c", + "hid.h", + "hiddesc.c", + "hidep0.c", + "hidep1.c", + "irqs.h", + "main.c", + "regs.h", + "usb.c", + "usb.h", + ] +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/regs.h b/examples/baremetal/cy7c68013a/nes-gamepads/regs.h new file mode 100644 index 00000000..98e40f0a --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/regs.h @@ -0,0 +1,779 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_REGS_H +#define FX2_REGS_H + +#include "defs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// +// XDATA registers. +// + +XDATA_REG(GPIF_WAVE_DATA, 0xE400) // GPIF waveform descriptor. +XDATA_REG(RES_WAVEDATA_END, 0xE480) // Reserved. + +// General configuration. + +XDATA_REG(CPUCS, 0xE600) // Control & status. +XDATA_REG(IFCONFIG, 0xE601) // Interface configuration. +XDATA_REG(PINFLAGSAB, 0xE602) // FIFO FLAGA and FLAGB assignments. +XDATA_REG(PINFLAGSCD, 0xE603) // FIFO FLAGC and FLAGD assignments. +XDATA_REG(FIFORESET, 0xE604) // Restore FIFOS to default state. +XDATA_REG(BREAKPT, 0xE605) // Breakpoint. +XDATA_REG(BPADDRH, 0xE606) // Breakpoint address H. +XDATA_REG(BPADDRL, 0xE607) // Breakpoint address L. +XDATA_REG(UART230, 0xE608) // 230 Kbaud clock for T0,T1,T2. +XDATA_REG(FIFOPINPOLAR, 0xE609) // FIFO polarities. +XDATA_REG(REVID, 0xE60A) // Chip revision. +XDATA_REG(REVCTL, 0xE60B) // Chip revision control. + +// Endpoint configuration. + +XDATA_REG(EP1OUTCFG, 0xE610) // Endpoint 1-out configuration. +XDATA_REG(EP1INCFG, 0xE611) // Endpoint 1-in configuration. +XDATA_REG(EP2CFG, 0xE612) // Endpoint 2 configuration. +XDATA_REG(EP4CFG, 0xE613) // Endpoint 4 configuration. +XDATA_REG(EP6CFG, 0xE614) // Endpoint 6 configuration. +XDATA_REG(EP8CFG, 0xE615) // Endpoint 8 configuration. +XDATA_REG(EP2FIFOCFG, 0xE618) // Endpoint 2 FIFO configuration. +XDATA_REG(EP4FIFOCFG, 0xE619) // Endpoint 4 FIFO configuration. +XDATA_REG(EP6FIFOCFG, 0xE61A) // Endpoint 6 FIFO configuration. +XDATA_REG(EP8FIFOCFG, 0xE61B) // Endpoint 8 FIFO configuration. +XDATA_REG(EP2AUTOINLENH, 0xE620) // Endpoint 2 packet length H (in only). +XDATA_REG(EP2AUTOINLENL, 0xE621) // Endpoint 2 packet length L (in only). +XDATA_REG(EP4AUTOINLENH, 0xE622) // Endpoint 4 packet length H (in only). +XDATA_REG(EP4AUTOINLENL, 0xE623) // Endpoint 4 packet length L (in only). +XDATA_REG(EP6AUTOINLENH, 0xE624) // Endpoint 6 packet length H (in only). +XDATA_REG(EP6AUTOINLENL, 0xE625) // Endpoint 6 packet length L (in only). +XDATA_REG(EP8AUTOINLENH, 0xE626) // Endpoint 8 packet length H (in only). +XDATA_REG(EP8AUTOINLENL, 0xE627) // Endpoint 8 packet length L (in only). +XDATA_REG(EP2FIFOPFH, 0xE630) // EP2 programmable flag trigger H. +XDATA_REG(EP2FIFOPFL, 0xE631) // EP2 programmable flag trigger L. +XDATA_REG(EP4FIFOPFH, 0xE632) // EP4 programmable flag trigger H. +XDATA_REG(EP4FIFOPFL, 0xE633) // EP4 programmable flag trigger L. +XDATA_REG(EP6FIFOPFH, 0xE634) // EP6 programmable flag trigger H. +XDATA_REG(EP6FIFOPFL, 0xE635) // EP6 programmable flag trigger L. +XDATA_REG(EP8FIFOPFH, 0xE636) // EP8 programmable flag trigger H. +XDATA_REG(EP8FIFOPFL, 0xE637) // EP8 programmable flag trigger L. +XDATA_REG(EP2ISOINPKTS, 0xE640) // EP2 (if ISO) in packets per frame (1-3). +XDATA_REG(EP4ISOINPKTS, 0xE641) // EP4 (if ISO) in packets per frame (1-3). +XDATA_REG(EP6ISOINPKTS, 0xE642) // EP6 (if ISO) in packets per frame (1-3). +XDATA_REG(EP8ISOINPKTS, 0xE643) // EP8 (if ISO) in packets per frame (1-3). +XDATA_REG(INPKTEND, 0xE648) // Force in packet end. +XDATA_REG(OUTPKTEND, 0xE649) // Force out packet end. + +// Interrupts. + +XDATA_REG(EP2FIFOIE, 0xE650) // Endpoint 2 flag interrupt enable. +XDATA_REG(EP2FIFOIRQ, 0xE651) // Endpoint 2 flag interrupt request. +XDATA_REG(EP4FIFOIE, 0xE652) // Endpoint 4 flag interrupt enable. +XDATA_REG(EP4FIFOIRQ, 0xE653) // Endpoint 4 flag interrupt request. +XDATA_REG(EP6FIFOIE, 0xE654) // Endpoint 6 flag interrupt enable. +XDATA_REG(EP6FIFOIRQ, 0xE655) // Endpoint 6 flag interrupt request. +XDATA_REG(EP8FIFOIE, 0xE656) // Endpoint 8 flag interrupt enable. +XDATA_REG(EP8FIFOIRQ, 0xE657) // Endpoint 8 flag interrupt request. +XDATA_REG(IBNIE, 0xE658) // IN-BULK-NAK interrupt enable. +XDATA_REG(IBNIRQ, 0xE659) // IN-BULK-NAK interrupt request. +XDATA_REG(NAKIE, 0xE65A) // Endpoint ping NAK interrupt enable. +XDATA_REG(NAKIRQ, 0xE65B) // Endpoint ping NAK interrupt request. +XDATA_REG(USBIE, 0xE65C) // USB Int enables. +XDATA_REG(USBIRQ, 0xE65D) // USB interrupt requests. +XDATA_REG(EPIE, 0xE65E) // Endpoint interrupt enables. +XDATA_REG(EPIRQ, 0xE65F) // Endpoint interrupt requests. +XDATA_REG(GPIFIE, 0xE660) // GPIF interrupt enable. +XDATA_REG(GPIFIRQ, 0xE661) // GPIF interrupt request. +XDATA_REG(USBERRIE, 0xE662) // USB error interrupt enables. +XDATA_REG(USBERRIRQ, 0xE663) // USB error interrupt requests. +XDATA_REG(ERRCNTLIM, 0xE664) // USB error counter and limit. +XDATA_REG(CLRERRCNT, 0xE665) // Clear error counter EC[3..0]. +XDATA_REG(INT2IVEC, 0xE666) // Interrupt 2 (USB) autovector. +XDATA_REG(INT4IVEC, 0xE667) // Interrupt 4 (FIFOS & GPIF) autovector. +XDATA_REG(INTSETUP, 0xE668) // interrupt 2 & 4 setup. + +// Input/Output. + +XDATA_REG(PORTACFG, 0xE670) // I/O PORTA alternate configuration. +XDATA_REG(PORTCCFG, 0xE671) // I/O PORTC alternate configuration. +XDATA_REG(PORTECFG, 0xE672) // I/O PORTE alternate configuration. +XDATA_REG(I2CS, 0xE678) // Bus control & status. +XDATA_REG(I2DAT, 0xE679) // Bus data. +XDATA_REG(I2CTL, 0xE67A) // Bus control. +XDATA_REG(XAUTODAT1, 0xE67B) // Autoptr1 movx access. +XDATA_REG(XAUTODAT2, 0xE67C) // Autoptr2 movx access. + +// USB Control. + +XDATA_REG(USBCS, 0xE680) // USB control & status. +XDATA_REG(SUSPEND, 0xE681) // Put chip into suspend. +XDATA_REG(WAKEUPCS, 0xE682) // Wakeup source and polarity. +XDATA_REG(TOGCTL, 0xE683) // Toggle control. +XDATA_REG(USBFRAMEH, 0xE684) // USB frame count H. +XDATA_REG(USBFRAMEL, 0xE685) // USB frame count L. +XDATA_REG(MICROFRAME, 0xE686) // Microframe count, 0-7. +XDATA_REG(FNADDR, 0xE687) // USB function address. + +// Endpoints. + +XDATA_REG(EP0BCH, 0xE68A) // Endpoint 0 byte count H. +XDATA_REG(EP0BCL, 0xE68B) // Endpoint 0 byte count L. +XDATA_REG(EP1OUTBC, 0xE68D) // Endpoint 1 out byte count. +XDATA_REG(EP1INBC, 0xE68F) // Endpoint 1 in byte count. +XDATA_REG(EP2BCH, 0xE690) // Endpoint 2 byte count H. +XDATA_REG(EP2BCL, 0xE691) // Endpoint 2 byte count L. +XDATA_REG(EP4BCH, 0xE694) // Endpoint 4 byte count H. +XDATA_REG(EP4BCL, 0xE695) // Endpoint 4 byte count L. +XDATA_REG(EP6BCH, 0xE698) // Endpoint 6 byte count H. +XDATA_REG(EP6BCL, 0xE699) // Endpoint 6 byte count L. +XDATA_REG(EP8BCH, 0xE69C) // Endpoint 8 byte count H. +XDATA_REG(EP8BCL, 0xE69D) // Endpoint 8 byte count L. +XDATA_REG(EP0CS, 0xE6A0) // Endpoint control and status. +XDATA_REG(EP1OUTCS, 0xE6A1) // Endpoint 1 out control and status. +XDATA_REG(EP1INCS, 0xE6A2) // Endpoint 1 in control and status. +XDATA_REG(EP2CS, 0xE6A3) // Endpoint 2 control and status. +XDATA_REG(EP4CS, 0xE6A4) // Endpoint 4 control and status. +XDATA_REG(EP6CS, 0xE6A5) // Endpoint 6 control and status. +XDATA_REG(EP8CS, 0xE6A6) // Endpoint 8 control and status. +XDATA_REG(EP2FIFOFLGS, 0xE6A7) // Endpoint 2 flags. +XDATA_REG(EP4FIFOFLGS, 0xE6A8) // Endpoint 4 flags. +XDATA_REG(EP6FIFOFLGS, 0xE6A9) // Endpoint 6 flags. +XDATA_REG(EP8FIFOFLGS, 0xE6AA) // Endpoint 8 flags. +XDATA_REG(EP2FIFOBCH, 0xE6AB) // EP2 FIFO total byte count H. +XDATA_REG(EP2FIFOBCL, 0xE6AC) // EP2 FIFO total byte count L. +XDATA_REG(EP4FIFOBCH, 0xE6AD) // EP4 FIFO total byte count H. +XDATA_REG(EP4FIFOBCL, 0xE6AE) // EP4 FIFO total byte count L. +XDATA_REG(EP6FIFOBCH, 0xE6AF) // EP6 FIFO total byte count H. +XDATA_REG(EP6FIFOBCL, 0xE6B0) // EP6 FIFO total byte count L. +XDATA_REG(EP8FIFOBCH, 0xE6B1) // EP8 FIFO total byte count H. +XDATA_REG(EP8FIFOBCL, 0xE6B2) // EP8 FIFO total byte count L. +XDATA_REG(SUDPTRH, 0xE6B3) // Setup data pointer high address byte. +XDATA_REG(SUDPTRL, 0xE6B4) // Setup data pointer low address byte. +XDATA_REG(SUDPTRCTL, 0xE6B5) // Setup data pointer auto mode. +XDATA_REG(SETUPDAT[8], 0xE6B8) // 8 bytes of setup data. + +// GPIF. + +XDATA_REG(GPIFWFSELECT, 0xE6C0) // Waveform selector. +XDATA_REG(GPIFIDLECS, 0xE6C1) // GPIF done, GPIF idle drive mode. +XDATA_REG(GPIFIDLECTL, 0xE6C2) // Inactive bus, ctl states. +XDATA_REG(GPIFCTLCFG, 0xE6C3) // CTL out pin drive. +XDATA_REG(GPIFADRH, 0xE6C4) // GPIF address H. +XDATA_REG(GPIFADRL, 0xE6C5) // GPIF address L. + +XDATA_REG(GPIFTCB3, 0xE6CE) // GPIF transaction count byte 3. +XDATA_REG(GPIFTCB2, 0xE6CF) // GPIF transaction count byte 2. +XDATA_REG(GPIFTCB1, 0xE6D0) // GPIF transaction count byte 1. +XDATA_REG(GPIFTCB0, 0xE6D1) // GPIF transaction count byte 0. + +XDATA_REG(EP2GPIFFLGSEL, 0xE6D2) // EP2 GPIF flag select. +XDATA_REG(EP2GPIFPFSTOP, 0xE6D3) // Stop GPIF EP2 transaction on prog flag. +XDATA_REG(EP2GPIFTRIG, 0xE6D4) // EP2 FIFO trigger. +XDATA_REG(EP4GPIFFLGSEL, 0xE6DA) // EP4 GPIF flag select. +XDATA_REG(EP4GPIFPFSTOP, 0xE6DB) // Stop GPIF EP4 transaction on prog flag. +XDATA_REG(EP4GPIFTRIG, 0xE6DC) // EP4 FIFO trigger. +XDATA_REG(EP6GPIFFLGSEL, 0xE6E2) // EP6 GPIF Flag select. +XDATA_REG(EP6GPIFPFSTOP, 0xE6E3) // Stop GPIF EP6 transaction on prog flag. +XDATA_REG(EP6GPIFTRIG, 0xE6E4) // EP6 FIFO trigger. +XDATA_REG(EP8GPIFFLGSEL, 0xE6EA) // EP8 GPIF flag select. +XDATA_REG(EP8GPIFPFSTOP, 0xE6EB) // Stop GPIF EP8 transaction on prog flag. +XDATA_REG(EP8GPIFTRIG, 0xE6EC) // EP8 FIFO trigger. +XDATA_REG(XGPIFSGLDATH, 0xE6F0) // GPIF data H (16-bit mode only). +XDATA_REG(XGPIFSGLDATLX, 0xE6F1) // Read/write GPIF data L & trigger transac. +XDATA_REG(XGPIFSGLDATLNOX, 0xE6F2) // Read GPIF data L, no transac trigger. +XDATA_REG(GPIFREADYCFG, 0xE6F3) // Internal RDY,Sync/Async, RDY5CFG. +XDATA_REG(GPIFREADYSTAT, 0xE6F4) // RDY pin states. +XDATA_REG(GPIFABORT, 0xE6F5) // Abort GPIF cycles. + +// UDMA. + +XDATA_REG(FLOWSTATE, 0xE6C6) // Defines GPIF flow state. +XDATA_REG(FLOWLOGIC, 0xE6C7) // Defines flow/hold decision criteria. +XDATA_REG(FLOWEQ0CTL, 0xE6C8) // CTL states during active flow state. +XDATA_REG(FLOWEQ1CTL, 0xE6C9) // CTL states during hold flow state. +XDATA_REG(FLOWHOLDOFF, 0xE6CA) // Holdoff configuration. +XDATA_REG(FLOWSTB, 0xE6CB) // CTL/RDY signal to use as master data strobe. +XDATA_REG(FLOWSTBEDGE, 0xE6CC) // Defines active master strobe edge. +XDATA_REG(FLOWSTBHPERIOD, 0xE6CD) // Half period of output master strobe. +XDATA_REG(GPIFHOLDAMOUNT, 0xE60C) // Data delay shift. +XDATA_REG(UDMACRCH, 0xE67D) // CRC upper byte. +XDATA_REG(UDMACRCL, 0xE67E) // CRC lower byte. +XDATA_REG(UDMACRCQUAL, 0xE67F) // UDMA in only, host terminated use only. + +// Endpoint buffers. +#define MAX_EP0_SIZE 64 +#define MAX_EP1_SIZE 64 +#define MAX_EP2468_SIZE 1024 + +XDATA_REG(EP0BUF[MAX_EP0_SIZE], 0xE740) // EP0 buffer (in or out). +XDATA_REG(EP1OUTBUF[MAX_EP1_SIZE], 0xE780) // EP1 buffer (out only). +XDATA_REG(EP1INBUF[MAX_EP1_SIZE], 0xE7C0) // EP1 buffer (in only). +XDATA_REG(EP2FIFOBUF[MAX_EP2468_SIZE], 0xF000) // 512/1024-byte EP2 buffer (in or out). +XDATA_REG(EP4FIFOBUF[MAX_EP2468_SIZE], 0xF400) // 512 byte EP4 buffer (in or out). +XDATA_REG(EP6FIFOBUF[MAX_EP2468_SIZE], 0xF800) // 512/1024-byte EP6 buffer (in or out). +XDATA_REG(EP8FIFOBUF[MAX_EP2468_SIZE], 0xFC00) // 512 byte EP8 buffer (in or out). + +// Error correction code (ECC) registers (FX2LP/FX1 only). + +XDATA_REG(ECCCFG, 0xE628) // ECC configuration. +XDATA_REG(ECCRESET, 0xE629) // ECC reset. +XDATA_REG(ECC1B0, 0xE62A) // ECC1 byte 0. +XDATA_REG(ECC1B1, 0xE62B) // ECC1 byte 1. +XDATA_REG(ECC1B2, 0xE62C) // ECC1 byte 2. +XDATA_REG(ECC2B0, 0xE62D) // ECC2 byte 0. +XDATA_REG(ECC2B1, 0xE62E) // ECC2 byte 1. +XDATA_REG(ECC2B2, 0xE62F) // ECC2 byte 2. + +// Feature registers(FX2LP/FX1 only). + +XDATA_REG(GPCR2, 0xE50D) // Chip features. + +// +// SFR registers. +// + +SPEC_FUN_REG(IOA, 0x80) // Port A. +SPEC_FUN_REG_BIT(PA0, 0x80, 0) +SPEC_FUN_REG_BIT(PA1, 0x80, 1) +SPEC_FUN_REG_BIT(PA2, 0x80, 2) +SPEC_FUN_REG_BIT(PA3, 0x80, 3) +SPEC_FUN_REG_BIT(PA4, 0x80, 4) +SPEC_FUN_REG_BIT(PA5, 0x80, 5) +SPEC_FUN_REG_BIT(PA6, 0x80, 6) +SPEC_FUN_REG_BIT(PA7, 0x80, 7) + +SPEC_FUN_REG(SP, 0x81) // Stack pointer. +SPEC_FUN_REG(DPL, 0x82) // Data pointer 0 L. +SPEC_FUN_REG(DPH, 0x83) // Data pointer 0 H. +SPEC_FUN_REG(DPL1, 0x84) // Data pointer 1 L. +SPEC_FUN_REG(DPH1, 0x85) // Data pointer 1 L. +SPEC_FUN_REG(DPS, 0x86) // Data pointer 0/1 select. +SPEC_FUN_REG(PCON, 0x87) // Power control. + +SPEC_FUN_REG(TCON, 0x88) // Timer/counter control. +SPEC_FUN_REG_BIT(IT0, 0x88, 0) +SPEC_FUN_REG_BIT(IE0, 0x88, 1) +SPEC_FUN_REG_BIT(IT1, 0x88, 2) +SPEC_FUN_REG_BIT(IE1, 0x88, 3) +SPEC_FUN_REG_BIT(TR0, 0x88, 4) +SPEC_FUN_REG_BIT(TF0, 0x88, 5) +SPEC_FUN_REG_BIT(TR1, 0x88, 6) +SPEC_FUN_REG_BIT(TF1, 0x88, 7) + +SPEC_FUN_REG(TMOD, 0x89) // Timer/counter mode control. +SPEC_FUN_REG(TL0, 0x8A) // Timer 0 reload L. +SPEC_FUN_REG(TL1, 0x8B) // Timer 1 reload L. +SPEC_FUN_REG(TH0, 0x8C) // Timer 0 reload H. +SPEC_FUN_REG(TH1, 0x8D) // Timer 1 reload H. +SPEC_FUN_REG(CKCON, 0x8E) // Clock control. + +SPEC_FUN_REG(IOB, 0x90) // Port B. +SPEC_FUN_REG_BIT(PB0, 0x90, 0) +SPEC_FUN_REG_BIT(PB1, 0x90, 1) +SPEC_FUN_REG_BIT(PB2, 0x90, 2) +SPEC_FUN_REG_BIT(PB3, 0x90, 3) +SPEC_FUN_REG_BIT(PB4, 0x90, 4) +SPEC_FUN_REG_BIT(PB5, 0x90, 5) +SPEC_FUN_REG_BIT(PB6, 0x90, 6) +SPEC_FUN_REG_BIT(PB7, 0x90, 7) + +SPEC_FUN_REG(EXIF, 0x91) // External interrupt flag. +SPEC_FUN_REG(MPAGE, 0x92) // Upper address page of movx. + +SPEC_FUN_REG(SCON0, 0x98) // Serial port 0 control. +SPEC_FUN_REG_BIT(RI, 0x98, 0) +SPEC_FUN_REG_BIT(TI, 0x98, 1) +SPEC_FUN_REG_BIT(RB8, 0x98, 2) +SPEC_FUN_REG_BIT(TB8, 0x98, 3) +SPEC_FUN_REG_BIT(REN, 0x98, 4) +SPEC_FUN_REG_BIT(SM2, 0x98, 5) +SPEC_FUN_REG_BIT(SM1, 0x98, 6) +SPEC_FUN_REG_BIT(SM0, 0x98, 7) + +SPEC_FUN_REG(SBUF0, 0x99) // Serial port 0 data buffer. + +SPEC_FUN_REG(AUTOPTRH1, 0x9A) // Auto-pointer 1 address H. +SPEC_FUN_REG(AUTOPTRL1, 0x9B) // Auto-pointer 1 address L. +SPEC_FUN_REG(AUTOPTRH2, 0x9D) // Auto-pointer 2 address H. +SPEC_FUN_REG(AUTOPTRL2, 0x9E) // Auto-pointer 2 address L. + +SPEC_FUN_REG(IOC, 0xA0) // Port C. +SPEC_FUN_REG_BIT(PC0, 0xA0, 0) +SPEC_FUN_REG_BIT(PC1, 0xA0, 1) +SPEC_FUN_REG_BIT(PC2, 0xA0, 2) +SPEC_FUN_REG_BIT(PC3, 0xA0, 3) +SPEC_FUN_REG_BIT(PC4, 0xA0, 4) +SPEC_FUN_REG_BIT(PC5, 0xA0, 5) +SPEC_FUN_REG_BIT(PC6, 0xA0, 6) +SPEC_FUN_REG_BIT(PC7, 0xA0, 7) + +SPEC_FUN_REG(INT2CLR, 0xA1) // Interrupt 2 clear. +SPEC_FUN_REG(INT4CLR, 0xA2) // Interrupt 4 clear. + +SPEC_FUN_REG(IE, 0xA8) // Interrupt enable. +SPEC_FUN_REG_BIT(EX0, 0xA8, 0) +SPEC_FUN_REG_BIT(ET0, 0xA8, 1) +SPEC_FUN_REG_BIT(EX1, 0xA8, 2) +SPEC_FUN_REG_BIT(ET1, 0xA8, 3) +SPEC_FUN_REG_BIT(ES0, 0xA8, 4) +SPEC_FUN_REG_BIT(ET2, 0xA8, 5) +SPEC_FUN_REG_BIT(ES1, 0xA8, 6) +SPEC_FUN_REG_BIT(EA, 0xA8, 7) + +SPEC_FUN_REG(EP2468STAT, 0xAA) // Endpoint 2,4,6,8 status flags. +SPEC_FUN_REG(EP24FIFOFLGS, 0xAB) // Endpoint 2,4 slave FIFO status flags. +SPEC_FUN_REG(EP68FIFOFLGS, 0xAC) // Endpoint 6,8 slave FIFO status flags. +SPEC_FUN_REG(AUTOPTRSETUP, 0xAF) // Auto-pointer 1,2 setup. + +SPEC_FUN_REG(IOD, 0xB0) // Port D. +SPEC_FUN_REG_BIT(PD0, 0xB0, 0) +SPEC_FUN_REG_BIT(PD1, 0xB0, 1) +SPEC_FUN_REG_BIT(PD2, 0xB0, 2) +SPEC_FUN_REG_BIT(PD3, 0xB0, 3) +SPEC_FUN_REG_BIT(PD4, 0xB0, 4) +SPEC_FUN_REG_BIT(PD5, 0xB0, 5) +SPEC_FUN_REG_BIT(PD6, 0xB0, 6) +SPEC_FUN_REG_BIT(PD7, 0xB0, 7) + +SPEC_FUN_REG(IOE, 0xB1) // Port E. + +SPEC_FUN_REG(OEA, 0xB2) // Port A out enable. +SPEC_FUN_REG(OEB, 0xB3) // Port B out enable. +SPEC_FUN_REG(OEC, 0xB4) // Port C out enable. +SPEC_FUN_REG(OED, 0xB5) // Port D out enable. +SPEC_FUN_REG(OEE, 0xB6) // Port E out enable. + +SPEC_FUN_REG(IP, 0xB8) // Interrupt prority. +SPEC_FUN_REG_BIT(PX0, 0xB8, 0) +SPEC_FUN_REG_BIT(PT0, 0xB8, 1) +SPEC_FUN_REG_BIT(PX1, 0xB8, 2) +SPEC_FUN_REG_BIT(PT1, 0xB8, 3) +SPEC_FUN_REG_BIT(PS0, 0xB8, 4) +SPEC_FUN_REG_BIT(PT2, 0xB8, 5) +SPEC_FUN_REG_BIT(PS1, 0xB8, 6) + +SPEC_FUN_REG(EP01STAT, 0xBA) // Endpoint 0,1 status. +SPEC_FUN_REG(GPIFTRIG, 0xBB) // Endpoint 2,4,6,8 GPIF slave FIFO trigger. + +SPEC_FUN_REG(GPIFSGLDATH, 0xBD) // GPIF data H. +SPEC_FUN_REG(GPIFSGLDATLX, 0xBE) // GPIF data L with trigger. +SPEC_FUN_REG(GPIFSGLDATLNOX, 0xBF) // GPIF data L without trigger. + +SPEC_FUN_REG(SCON1, 0xC0) // Serial port 1 control. +SPEC_FUN_REG_BIT(RI1, 0xC0, 0) +SPEC_FUN_REG_BIT(TI1, 0xC0, 1) +SPEC_FUN_REG_BIT(RB81, 0xC0, 2) +SPEC_FUN_REG_BIT(TB81, 0xC0, 3) +SPEC_FUN_REG_BIT(REN1, 0xC0, 4) +SPEC_FUN_REG_BIT(SM21, 0xC0, 5) +SPEC_FUN_REG_BIT(SM11, 0xC0, 6) +SPEC_FUN_REG_BIT(SM01, 0xC0, 7) + +SPEC_FUN_REG(SBUF1, 0xC1) // Serial port 1 data buffer. + +SPEC_FUN_REG(T2CON, 0xC8) // Timer/counter 2 control. +SPEC_FUN_REG_BIT(CP_RL2, 0xC8, 0) +SPEC_FUN_REG_BIT(C_T2, 0xC8, 1) +SPEC_FUN_REG_BIT(TR2, 0xC8, 2) +SPEC_FUN_REG_BIT(EXEN2, 0xC8, 3) +SPEC_FUN_REG_BIT(TCLK, 0xC8, 4) +SPEC_FUN_REG_BIT(RCLK, 0xC8, 5) +SPEC_FUN_REG_BIT(EXF2, 0xC8, 6) +SPEC_FUN_REG_BIT(TF2, 0xC8, 7) + +SPEC_FUN_REG(RCAP2L, 0xCA) // Capture for timer 2 auto-reload up-counter L. +SPEC_FUN_REG(RCAP2H, 0xCB) // Capture for timer 2 auto-reload up-counter H. +SPEC_FUN_REG(TL2, 0xCC) // Timer 2 reload L. +SPEC_FUN_REG(TH2, 0xCD) // Timer 2 reload H. + +SPEC_FUN_REG(PSW, 0xD0) // Program status word. +SPEC_FUN_REG_BIT(P, 0xD0, 0) +SPEC_FUN_REG_BIT(FL, 0xD0, 1) +SPEC_FUN_REG_BIT(OV, 0xD0, 2) +SPEC_FUN_REG_BIT(RS0, 0xD0, 3) +SPEC_FUN_REG_BIT(RS1, 0xD0, 4) +SPEC_FUN_REG_BIT(F0, 0xD0, 5) +SPEC_FUN_REG_BIT(AC, 0xD0, 6) +SPEC_FUN_REG_BIT(CY, 0xD0, 7) + +SPEC_FUN_REG(EICON, 0xD8) // External interrupt control. +SPEC_FUN_REG_BIT(INT6, 0xD8, 3) +SPEC_FUN_REG_BIT(RESI, 0xD8, 4) +SPEC_FUN_REG_BIT(ERESI, 0xD8, 5) +SPEC_FUN_REG_BIT(SMOD1, 0xD8, 7) + +SPEC_FUN_REG(ACC, 0xE0) // Accumulator. + +SPEC_FUN_REG(EIE, 0xE8) // External interrupt enable. +SPEC_FUN_REG_BIT(EUSB, 0xE8, 0) +SPEC_FUN_REG_BIT(EI2C, 0xE8, 1) +SPEC_FUN_REG_BIT(EIEX4, 0xE8, 2) +SPEC_FUN_REG_BIT(EIEX5, 0xE8, 3) +SPEC_FUN_REG_BIT(EIEX6, 0xE8, 4) + +SPEC_FUN_REG(B, 0xF0) // B + +SPEC_FUN_REG(EIP, 0xF8) // External interrupt priority control. +SPEC_FUN_REG_BIT(PUSB, 0xF8, 0) +SPEC_FUN_REG_BIT(PI2C, 0xF8, 1) +SPEC_FUN_REG_BIT(EIPX4, 0xF8, 2) +SPEC_FUN_REG_BIT(EIPX5, 0xF8, 3) +SPEC_FUN_REG_BIT(EIPX6, 0xF8, 4) + +// +// Register bit masks. +// + +// CPU control & status register (CPUCS). +enum cpucs_bits { + bmPRTCSTB = bmBIT5, + bmCLKSPD = bmBIT4 | bmBIT3, + bmCLKSPD1 = bmBIT4, + bmCLKSPD0 = bmBIT3, + bmCLKINV = bmBIT2, + bmCLKOE = bmBIT1, + bm8051RES = bmBIT0 +}; + +// Port A (PORTACFG). +enum portacfg_bits { + bmFLAGD = bmBIT7, + bmINT1 = bmBIT1, + bmINT0 = bmBIT0 +}; + +// Port C (PORTCCFG). +enum portccfg_bits { + bmGPIFA7 = bmBIT7, + bmGPIFA6 = bmBIT6, + bmGPIFA5 = bmBIT5, + bmGPIFA4 = bmBIT4, + bmGPIFA3 = bmBIT3, + bmGPIFA2 = bmBIT2, + bmGPIFA1 = bmBIT1, + bmGPIFA0 = bmBIT0 +}; + +// Port E (PORTECFG). +enum portecfg_bits { + bmGPIFA8 = bmBIT7, + bmT2EX = bmBIT6, + bmINT6 = bmBIT5, + bmRXD1OUT = bmBIT4, + bmRXD0OUT = bmBIT3, + bmT2OUT = bmBIT2, + bmT1OUT = bmBIT1, + bmT0OUT = bmBIT0 +}; + +// I2C control & status register (I2CS). +enum i2cs_bits { + bmSTART = bmBIT7, + bmSTOP = bmBIT6, + bmLASTRD = bmBIT5, + bmID = bmBIT4 | bmBIT3, + bmBERR = bmBIT2, + bmACK = bmBIT1, + bmDONE = bmBIT0 +}; + +// I2C control register (I2CTL). +enum i2ctl_bits { + bmSTOPIE = bmBIT1, + bm400KHZ = bmBIT0 +}; + +// Interrupt 2 (USB) autovector register (INT2IVEC). +enum int2ivec_bits { + bmIV4 = bmBIT6, + bmIV3 = bmBIT5, + bmIV2 = bmBIT4, + bmIV1 = bmBIT3, + bmIV0 = bmBIT2 +}; + +// USB interrupt request & enable registers (USBIE/USBIRQ). +enum usbieirq_bits { + bmEP0ACK = bmBIT6, + bmHSGRANT = bmBIT5, + bmURES = bmBIT4, + bmSUSP = bmBIT3, + bmSUTOK = bmBIT2, + bmSOF = bmBIT1, + bmSUDAV = bmBIT0 +}; + +// End point interrupt request & enable registers (EPIE/EPIRQ). +enum epieirq_bits { + bmEP8 = bmBIT7, + bmEP6 = bmBIT6, + bmEP4 = bmBIT5, + bmEP2 = bmBIT4, + bmEP1OUT = bmBIT3, + bmEP1IN = bmBIT2, + bmEP0OUT = bmBIT1, + bmEP0IN = bmBIT0 +}; + +// Breakpoint register (BREAKPT). +enum breakpt_bits { + bmBREAK = bmBIT3, + bmBPPULSE = bmBIT2, + bmBPEN = bmBIT1 +}; + +// Interrupt 2 & 4 setup (INTSETUP). +enum intsetup_bits { + bmAV2EN = bmBIT3, + bmINT4SRC = bmBIT1, + bmAV4EN = bmBIT0 +}; + +// USB control & status register (USBCS). +enum usbcs_bits { + bmHSM = bmBIT7, + bmDISCON = bmBIT3, + bmNOSYNSOF = bmBIT2, + bmRENUM = bmBIT1, + bmSIGRESUME = bmBIT0 +}; + +// Wakeup control and status register (WAKEUPCS). +enum wakeupcs_bits { + bmWU2 = bmBIT7, + bmWU = bmBIT6, + bmWU2POL = bmBIT5, + bmWUPOL = bmBIT4, + bmDPEN = bmBIT2, + bmWU2EN = bmBIT1, + bmWUEN = bmBIT0 +}; + +// End point 0 control & status register (EP0CS). +enum ep0cs_bits { + bmHSNAK = bmBIT7 +}; + +// End point 0-1 control & status registers +// (EP0CS/EP1OUTCS/EP1INCS). +enum ep01cs_bits { + bmEPBUSY = bmBIT1, + bmEPSTALL = bmBIT0 +}; + +// End point 2-8 Control & status registers +// (EP2CS/EP4CS/EP6CS/EP8CS). +enum ep2468cs_bits { + MSK_EP2468CS_NPAK = bmBIT6 | bmBIT5 | bmBIT4, + MSK_EP2468CS_EPFULL = bmBIT3, + MSK_EP2468CS_EPEMPTY = bmBIT2 +}; + +// End point status SFR bits (EP2468STAT). +enum ep2468stat_bits { + bmEP8FULL = bmBIT7, + bmEP8EMPTY = bmBIT6, + bmEP6FULL = bmBIT5, + bmEP6EMPTY = bmBIT4, + bmEP4FULL = bmBIT3, + bmEP4EMPTY = bmBIT2, + bmEP2FULL = bmBIT1, + bmEP2EMPTY = bmBIT0 +}; + +// End point 0,1 status bits (EP01STAT). +enum ep01stat_bits { + bmEP1INBSY = bmBIT2, + bmEP1OUTBSY = bmBIT1, + bmEP0BSY = bmBIT0 +}; + +// Setup data pointer auto mode (SUDPTRCTL). +enum sudptrctl_bits { + bmSDPAUTO = bmBIT0 +}; + +// End point data toggle control (TOGCTL). +enum togctl_bits { + bmQUERYTOGGLE = bmBIT7, + bmSETTOGGLE = bmBIT6, + bmRESETTOGGLE = bmBIT5, + bmTOGCTLEPMASK = bmBIT3 | bmBIT2 | bmBIT1 | bmBIT0 +}; + +// In bulk NAK enable and request bits (IBNIE/IBNIRQ). +enum ibnieirq_bits { + bmEP8IBN = bmBIT5, + bmEP6IBN = bmBIT4, + bmEP4IBN = bmBIT3, + bmEP2IBN = bmBIT2, + bmEP1IBN = bmBIT1, + bmEP0IBN = bmBIT0 +}; + +// Ping NAK enable and request bits (NAKIE/NAKIRQ). +enum nakieirq_bits { + bmEP8PING = bmBIT7, + bmEP6PING = bmBIT6, + bmEP4PING = bmBIT5, + bmEP2PING = bmBIT4, + bmEP1PING = bmBIT3, + bmEP0PING = bmBIT2, + bmIBN = bmBIT0 +}; + +// Interface configuration bits (IFCONFIG). +enum ifconfig_bits { + bmIFCLKSRC = bmBIT7, + bm3048MHZ = bmBIT6, + bmIFCLKOE = bmBIT5, + bmIFCLKPOL = bmBIT4, + bmASYNC = bmBIT3, + bmGSTATE = bmBIT2, + bmIFCFG = bmBIT0 | bmBIT1 +}; + +// IFCFG field of IFCONFIG register. +enum ifcfg_bits { + bmIFPORTS = 0, + bmIFRESERVED = bmBIT0, + bmIFGPIF = bmBIT1, + bmIFSLAVEFIFO = bmBIT0 | bmBIT1 +}; + +// End point 2,4,6,8 FIFO configuration bits +// (EP2FIFOCFG,EP4FIFOCFG,EP6FIFOCFG,EP8FIFOCFG). +enum ep2468fifocfg_bits { + bmINFM = bmBIT6, + bmOEP = bmBIT5, + bmAUTOOUT = bmBIT4, + bmAUTOIN = bmBIT3, + bmZEROLENIN = bmBIT2, + bmWORDWIDE = bmBIT0 +}; + +// Chip revision control bits (REVCTL). +enum revctl_bits { + bmNOAUTOARM = bmBIT1, + bmSKIPCOMMIT = bmBIT0 +}; + +// Fifo reset bits (FIFORESET). +enum fiforeset_bits { + bmNAKALL = bmBIT7, + bmFREP3 = bmBIT3, + bmFREP2 = bmBIT2, + bmFREP1 = bmBIT1, + bmFREP0 = bmBIT0 +}; + +// Chip feature register (GPCR2). +enum gpcr2_bits { + bmFULLSPEEDONLY = bmBIT4 +}; + +// Clock control register (CKCON). +// Note: a RevE errata states that stretch must=0 +// to set OUTxBC. +enum ckcon_bits { + bmT2M = bmBIT5, + bmT1M = bmBIT4, + bmT0M = bmBIT3, + bmSTRETCH = bmBIT0 | bmBIT1 | bmBIT2 +}; + +enum data_mem_stretch { + bmFW_STRETCH1 = 0, // Movx: 2 cycles, R/W strobe: 2 cycles... + bmFW_STRETCH2 = 1, // Movx: 3 cycles, R/W strobe: 4 cycles... + bmFW_STRETCH3 = 2, // Movx: 4 cycles, R/W strobe: 8 cycles... + bmFW_STRETCH4 = 3, // Movx: 5 cycles, R/W strobe: 12 cycles... + bmFW_STRETCH5 = 4, // Movx: 6 cycles, R/W strobe: 16 cycles... + bmFW_STRETCH6 = 5, // Movx: 7 cycles, R/W strobe: 20 cycles... + bmFW_STRETCH7 = 6, // Movx: 8 cycles, R/W strobe: 24 cycles... + bmFW_STRETCH8 = 7 // Movx: 9 cycles, R/W strobe: 28 cycles... +}; + +// External interrupt flags (EXIF). +enum exif_bits { + bmIE5 = bmBIT7, + bmIE4 = bmBIT6, + bmI2CINT = bmBIT5, + bmUSBNT = bmBIT4 +}; + +// External interrupt control (EICON). +enum eicon_bits { + bmSMOD1 = bmBIT7, + bmERESI = bmBIT5, + bmRESI = bmBIT4, + //bmINT6 = bmBIT3 +}; + +// Power control (PCON). +enum pcon_bits { + bmSMOD0 = bmBIT7, + bmIDLE = bmBIT0 +}; + +// Autopointer 1 & 2 setup (AUTOPTRSETUP). +enum autoptrsetup_bits { + bmAPTR2INC = bmBIT2, + bmAPTR1INC = bmBIT1, + bmAPTREN = bmBIT0 +}; + +#ifdef __cplusplus +} +#endif + +#endif // FX2_REGS_H diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/usb.c b/examples/baremetal/cy7c68013a/nes-gamepads/usb.c new file mode 100644 index 00000000..59a008de --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/usb.c @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "core.h" +#include "hid.h" +#include "usb.h" + +void usb_init(void) +{ + // Disable all USB interrupts. + USBIE = 0; + sync_delay(); + // Disable all end point interrupts. + EPIE = 0; + sync_delay(); + // Disable all end point ping-nak interrupts. + NAKIE = 0; + sync_delay(); + // Disable all USB error interrupts. + USBERRIE = 0; + sync_delay(); + // Disable USB && GPIF autovectoring. + INTSETUP = 0; + sync_delay(); + // Clear USB interrupt requests. + USBIRQ = bmSUDAV | bmSOF | bmSUTOK | bmSUSP + | bmURES | bmHSGRANT | bmEP0ACK; + sync_delay(); + // Clear end point interrupt requests. + EPIRQ = bmEP0IN | bmEP0OUT | bmEP1IN | bmEP1OUT + | bmEP2 | bmEP4 | bmEP6 | bmEP8; + sync_delay(); + // Set USB interrupt to high priority. + PUSB = 1; + sync_delay(); + // Enable USB interrupts. + EUSB = 1; + sync_delay(); + // As we use SOFs to detect disconnect we have + // to disable SOF synthesizing. + USBCS |= bmNOSYNSOF; + sync_delay(); + + hid_init(); + + // Disable FX2-internal enumeration support. + USBCS |= bmRENUM; + sync_delay(); +} + +void usb_task(void) +{ + if (USBIRQ & bmSUDAV) { + USBIRQ = bmSUDAV; + hid_ep0_setup_task(); + } + + if (USBIRQ & bmEP0ACK) { + USBIRQ = bmEP0ACK; + } + + if (USBIRQ & bmURES) { + USBIRQ = bmURES; + } + + if (USBIRQ & bmSUSP) { + USBIRQ = bmSUSP; + } + + hid_ep1_task(); +} diff --git a/examples/baremetal/cy7c68013a/nes-gamepads/usb.h b/examples/baremetal/cy7c68013a/nes-gamepads/usb.h new file mode 100644 index 00000000..67877a4b --- /dev/null +++ b/examples/baremetal/cy7c68013a/nes-gamepads/usb.h @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FX2_USB_H +#define FX2_USB_H + +#include "regs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum usb_setup_bmreq_bits { + bmSETUP_DIR = bmBIT7, + bmSETUP_TYPE = bmBIT5 | bmBIT6, + bmSETUP_RECIPIENT = bmBIT0 | bmBIT1 | bmBIT2 | bmBIT3 | bmBIT4 +}; + +// Setup request direction. +enum usb_setup_req_direction_bits { + bmSETUP_TO_DEVICE = 0, // From host to sevice direction. + bmSETUP_TO_HOST = bmBIT7 // From device to host direction. +}; + +// Setup request type. +enum usb_setup_req_type_bits { + bmSETUP_STANDARD = 0, // Standard request. + bmSETUP_CLASS = bmBIT5, // Class request. + bmSETUP_VENDOR = bmBIT6, // Vendor request. +}; + +// Setup request recipient. +enum usb_setup_req_recipient_bits { + bmSETUP_DEVICE = 0, // Device recipient. + bmSETUP_IFACE = bmBIT0, // Interface recipient. + bmSETUP_EP = bmBIT1, // End point recipient. + bmSETUP_OTHER = bmBIT0 | bmBIT1 // Other recipient. +}; + +// Setup request code. +enum usb_setup_req_code { + USB_SETUP_GET_STATUS = 0x00, // Get status code. + USB_SETUP_CLEAR_FEATURE = 0x01, // Clear feature code. + USB_SETUP_RESERVED1 = 0x02, // Reserved code. + USB_SETUP_SET_FEATURE = 0x03, // Set feature code. + USB_SETUP_RESERVED2 = 0x04, // Reserved code. + USB_SETUP_SET_ADDRESS = 0x05, // Set address code. + USB_SETUP_GET_DESCRIPTOR = 0x06, // Get descriptor code. + USB_SETUP_SET_DESCRIPTOR = 0x07, // Set descriptor code. + USB_SETUP_GET_CONFIGURATION = 0x08, // Get configuration code. + USB_SETUP_SET_CONFIGURATION = 0x09, // Set configuration code. + USB_SETUP_GET_INTERFACE = 0x0A, // Get interface code. + USB_SETUP_SET_INTERFACE = 0x0B, // Set interface code. + USB_SETUP_SYNC_FRAME = 0x0C, // Sync frame code. + USB_SETUP_ANCHOR_LOAD = 0xA0 // Anchor load code. +}; + +// Standard status responses. +enum usb_setup_status_code { + USB_STATUS_SELF_POWERED = 0x01, + USB_STATUS_REMOTE_WAKEUP = 0x02 +}; + +// Standard feature selectors. +enum usb_setup_feature_selector { + USB_FEATURE_STALL = 0x00, + USB_FEATURE_REMOTE_WAKEUP = 0x01, + USB_FEATRUE_TEST_MODE = 0x02 +}; + +// Get descriptor codes. +enum usb_setup_get_descriptor_code { + USB_DESC_DEVICE = 0x01, // Device descriptor. + USB_DESC_CONF = 0x02, // Configuration descriptor. + USB_DESC_STRING = 0x03, // String descriptor. + USB_DESC_INTERFACE = 0x04, // Interface descriptor. + USB_DESC_ENDPOINT = 0x05, // End point descriptor. + USB_DESC_DEVICE_QUAL = 0x06, // Device qualifier descriptor. + USB_DESC_OTHER_SPEED_CONF = 0x07, // Other configuration descriptor. + USB_DESC_INTERFACE_POWER = 0x08, // Interface power descriptor. + USB_DESC_OTG = 0x09, // OTG descriptor. + USB_DESC_DEBUG = 0x0A, // Debug descriptor. + USB_DESC_INTERFACE_ASSOC = 0x0B, // Interface association descriptor. + USB_DESC_HID = 0x21, // Get HID descriptor. + USB_DESC_REPORT = 0x22 // Get report descriptor. +}; + +// End point configuration (EP1INCFG/EP1OUTCFG/EP2/EP4/EP6/EP8). +enum epcfg_bits { + bmEP_VALID = bmBIT7, + bmEP_DIR = bmBIT6, // Only for EP2-EP8! + bmEP_TYPE = bmBIT5 | bmBIT4, + bmEP_SIZE = bmBIT3, // Only for EP2-EP8! + bmEP_BUF = bmBIT1 | bmBIT0 // Only for EP2-EP8! +}; + +enum ep_valid_bits { + bmEP_DISABLE = 0, + bmEP_ENABLE = bmBIT7 +}; + +// Only for EP2-EP8! +enum ep_direction { + bmEP_OUT = 0, + bmEP_IN = bmBIT6 +}; + +enum ep_type { + bmEP_ISO = bmBIT4, // Only for EP2-EP8! + bmEP_BULK = bmBIT5, // Default value. + bmEP_INT = bmBIT4 | bmBIT5 +}; + +// Only for EP2-EP8! +enum ep_size { + EP_512 = 0, + EP_1024 = bmBIT3 // Except EP4/EP8. +}; + +// Only for EP2-EP8! +enum ep_buf { + EP_QUAD = 0, + EP_DOUBLE = bmBIT1, // Default value. + EP_TRIPLE = bmBIT0 | bmBIT1 +}; + +struct ep0_buf { + BYTE *dat; + WORD len; +}; + +#define usb_disconnect() (USBCS |= bmDISCON) +#define usb_connect() (USBCS &= ~bmDISCON) + +#define usb_is_high_speed() \ + (USBCS & bmHSM) + +#define usp_ep_reset_toggle(ep) \ + TOGCTL = (((ep & 0x80) >> 3) + (ep & 0x0F)); \ + TOGCTL |= bmRESETTOGGLE + +#define usb_ep0_stall() \ + EP0CS |= bmEPSTALL + +#define usb_ep0_hsnack() \ + EP0CS |= bmHSNAK + +#define usb_word_msb_get(word) \ + (BYTE)(((WORD)(word) >> 8) & 0xFF) +#define usb_word_lsb_get(word) \ + (BYTE)((WORD)(word) & 0xFF) + +#define usb_word_swap(x) \ + ((((WORD)((x) & 0x00FF)) << 8) | \ + (((WORD)((x) & 0xFF00)) >> 8)) + +#define usb_dword_swap(x) \ + ((((DWORD)((x) & 0x000000FFul)) << 24) | \ + (((DWORD)((x) & 0x0000FF00ul)) << 8) | \ + (((DWORD)((x) & 0x00FF0000ul)) >> 8) | \ + (((DWORD)((x) & 0xFF000000ul)) >> 24)) + +void usb_init(void); +void usb_task(void); + +#ifdef __cplusplus +} +#endif + +#endif // FX2_USB_H diff --git a/examples/baremetal/esp8266/README.md b/examples/baremetal/esp8266/README.md new file mode 100644 index 00000000..a9b4ef92 --- /dev/null +++ b/examples/baremetal/esp8266/README.md @@ -0,0 +1,34 @@ +This example demonstrates how to build a bare-metal application using +GCC toolchain for Espressif ESP8266-WROOM02 MCU. + +An application is designed to be flashed on the external SPI FLASH +with the following parameters: + + * SPI FLASH size: 16 MBit (2048 + 2048 KBytes) + * SPI FLASH mode: DIO + * SPI FLASH clock: 40 MHz + * SPI FLASH map type: 5 + +An application is running as WiFi access point that discards all +connection attempts, and has the following WiFi parameters: + * SSID: "HELLO FROM QBS" + * Authentication mode: "open" + * Beacon interval: 1000 milliseconds + * Channel number: 3 + +An application requires the ESP8266 NON-OS SDK: + + * https://github.com/espressif/ESP8266_NONOS_SDK + +the path to which should be set via the ESP8266_NON_OS_SDK_ROOT +environment variable. + +To convert the ELF application to the final binary image (and also for +re-program the ESP8266 MCU), you can use the open source 'esptool' +utility (using the SPI FLASH parameters, provided above): + + * https://github.com/espressif/esptool + +The following toolchains are supported: + + * GNU ESP8266 Toolchain diff --git a/examples/baremetal/esp8266/access-point/access-point.qbs b/examples/baremetal/esp8266/access-point/access-point.qbs new file mode 100644 index 00000000..e9b06c34 --- /dev/null +++ b/examples/baremetal/esp8266/access-point/access-point.qbs @@ -0,0 +1,28 @@ +CppApplication { + condition: qbs.toolchain.contains("gcc") && qbs.architecture === "xtensa" + + Depends { name: "esp8266_sdk" } + + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // This required because ESP8266 SDK includes this 'user_config.h' internally. + cpp.includePaths: ["."] + + cpp.staticLibraries: [ + "c", + "crypto", + "gcc", + "lwip", + "main", + "net80211", + "phy", + "pp", + "wpa" + ] + + files: [ + "user_config.h", + "user_main.c" + ] +} diff --git a/examples/baremetal/esp8266/access-point/user_config.h b/examples/baremetal/esp8266/access-point/user_config.h new file mode 100644 index 00000000..307f93dd --- /dev/null +++ b/examples/baremetal/esp8266/access-point/user_config.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef ESP8266_USER_CONFIG_H +#define ESP8266_USER_CONFIG_H + +// From ESP8266 SDK. +#include + +#define ESP_SSID_CFG "HELLO FROM QBS\0" +#define ESP_AUTO_MODE_CFG (AUTH_OPEN) +#define ESP_BEACON_INTERVAL_MS_CFG (1000) +#define ESP_CHANNEL_NO_CFG (3) + +#endif // ESP8266_USER_CONFIG_H diff --git a/examples/baremetal/esp8266/access-point/user_main.c b/examples/baremetal/esp8266/access-point/user_main.c new file mode 100644 index 00000000..be2a8e92 --- /dev/null +++ b/examples/baremetal/esp8266/access-point/user_main.c @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "user_config.h" + +// From ESP8266 SDK. +#include + +static const partition_item_t esp_partitions[] = { + {SYSTEM_PARTITION_BOOTLOADER, ESP_PART_BL_ADDR, ESP_PART_BOOTLOADER_SIZE}, + {SYSTEM_PARTITION_OTA_1, ESP_PART_APP1_ADDR, ESP_PART_APPLICATION_SIZE}, + {SYSTEM_PARTITION_OTA_2, ESP_PART_APP2_ADDR, ESP_PART_APPLICATION_SIZE}, + {SYSTEM_PARTITION_RF_CAL, ESP_PART_RF_CAL_ADDR, ESP_PART_RF_CAL_SIZE}, + {SYSTEM_PARTITION_PHY_DATA, ESP_PART_PHY_DATA_ADDR, ESP_PART_PHY_DATA_SIZE}, + {SYSTEM_PARTITION_SYSTEM_PARAMETER, ESP_PART_SYS_PARAM_ADDR, ESP_PART_SYS_PARAM_SIZE} +}; + +enum { + ESP_PART_COUNT = sizeof(esp_partitions) / sizeof(esp_partitions[0]) +}; + +LOCAL void ICACHE_FLASH_ATTR user_init_done(void) +{ + os_printf("esp: initialization completed\n"); +} + +void ICACHE_FLASH_ATTR user_pre_init(void) +{ + const bool ok = system_partition_table_regist(esp_partitions, ESP_PART_COUNT, SPI_FLASH_SIZE_MAP); + if (!ok) { + os_printf("esp: partitions registration failed\n"); + while (true); + } +} + +void ICACHE_FLASH_ATTR user_init(void) +{ + os_printf("esp: SDK version: %s\n", system_get_sdk_version()); + os_printf("esp: reset reason: %u\n", system_get_rst_info()->reason); + + const bool ok = wifi_set_opmode(SOFTAP_MODE); + if (!ok) { + os_printf("esp: set softap mode failed\n"); + } else { + struct softap_config ap_cfg = {0}; + ap_cfg.authmode = ESP_AUTO_MODE_CFG; + ap_cfg.beacon_interval = ESP_BEACON_INTERVAL_MS_CFG; + ap_cfg.channel = ESP_CHANNEL_NO_CFG; + ap_cfg.max_connection = 0; + ap_cfg.ssid_hidden = false; + os_memcpy(&ap_cfg.ssid, ESP_SSID_CFG, sizeof(ESP_SSID_CFG)); + const bool ok = wifi_softap_set_config(&ap_cfg); + if (!ok) + os_printf("esp: set softap configuration failed\n"); + } + + system_init_done_cb(user_init_done); +} diff --git a/examples/baremetal/esp8266/esp8266.qbs b/examples/baremetal/esp8266/esp8266.qbs new file mode 100644 index 00000000..faa74434 --- /dev/null +++ b/examples/baremetal/esp8266/esp8266.qbs @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for esp8266-wroom-02 board" + qbsSearchPaths: "qbs" + references: [ + "access-point/access-point.qbs" + ] +} diff --git a/examples/baremetal/esp8266/qbs/imports/Esp8266SdkProbe.qbs b/examples/baremetal/esp8266/qbs/imports/Esp8266SdkProbe.qbs new file mode 100644 index 00000000..faa8b1ef --- /dev/null +++ b/examples/baremetal/esp8266/qbs/imports/Esp8266SdkProbe.qbs @@ -0,0 +1,25 @@ +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Probes + +Probes.PathProbe { + // Inputs. + environmentPaths: Environment.getEnv("ESP8266_NON_OS_SDK_ROOT") + // Outputs. + property string includesPath; + property string libsPath; + property string linkerScriptsPath; + configure: { + for (var i in environmentPaths) { + var rootPath = environmentPaths[i]; + if (!File.exists(rootPath)) + continue; + includesPath = FileInfo.joinPaths(rootPath, "include"); + libsPath = FileInfo.joinPaths(rootPath, "lib"); + linkerScriptsPath = FileInfo.joinPaths(rootPath, "ld"); + found = true; + return; + } + } +} diff --git a/examples/baremetal/esp8266/qbs/modules/esp8266_sdk/Esp8266SdkModule.qbs b/examples/baremetal/esp8266/qbs/modules/esp8266_sdk/Esp8266SdkModule.qbs new file mode 100644 index 00000000..57e1f857 --- /dev/null +++ b/examples/baremetal/esp8266/qbs/modules/esp8266_sdk/Esp8266SdkModule.qbs @@ -0,0 +1,66 @@ +Module { + Depends { name: "cpp" } + + Esp8266SdkProbe { id: esp_sdk_probe } + + validate: { + if (!esp_sdk_probe.found) + throw "ESP8266 NON OS SDK not found. Please set the ESP8266_NON_OS_SDK_ROOT env variable." + } + + cpp.systemIncludePaths: [esp_sdk_probe.includesPath] + cpp.libraryPaths: [esp_sdk_probe.libsPath] + cpp.driverFlags: ["-nostdlib"] + + cpp.cFlags: [ + "-Wpointer-arith", + "-Wundef", + "-fno-inline-functions", + "-mlongcalls", + "-mtext-section-literals", + "-ffunction-sections", + "-fdata-sections", + "-fno-builtin-printf", + "-fno-guess-branch-probability", + "-freorder-blocks-and-partition", + "-fno-cse-follow-jumps" + ] + + cpp.linkerFlags: [ + "--no-check-sections", + "--gc-sections", + "--start-group" + ] + + cpp.defines: [ + "ICACHE_FLASH", + "USE_OPTIMIZE_PRINTF", + + // Target specific defines for the external 40MHz DIO + // SPI 16 Mbit FLASH (2048 KByte + 2048 KByte) FOTA. + "SPI_FLASH_SIZE_MAP=5", + "ESP_PART_BL_ADDR=0x000000", + "ESP_PART_APP1_ADDR=0x001000", + "ESP_PART_APP2_ADDR=0x101000", + "ESP_PART_RF_CAL_ADDR=0x1FB000", + "ESP_PART_PHY_DATA_ADDR=0x1FC000", + "ESP_PART_SYS_PARAM_ADDR=0x1FD000", + "ESP_PART_BOOTLOADER_SIZE=0x001000", + "ESP_PART_APPLICATION_SIZE=0x0E0000", + "ESP_PART_RF_CAL_SIZE=0x001000", + "ESP_PART_PHY_DATA_SIZE=0x001000", + "ESP_PART_SYS_PARAM_SIZE=0x003000" + ] + + property string _linker_scripts_path: esp_sdk_probe.linkerScriptsPath + "/" + + Group { + name: "ESP8266 Linker Scripts" + prefix: esp8266_sdk._linker_scripts_path + "/" + fileTags: ["linkerscript"] + files: [ + "eagle.rom.addr.v6.ld", + "eagle.app.v6.new.2048.ld" + ] + } +} diff --git a/examples/baremetal/msp430f5529/msp430f5529.qbs b/examples/baremetal/msp430f5529/msp430f5529.qbs new file mode 100644 index 00000000..64e62dd5 --- /dev/null +++ b/examples/baremetal/msp430f5529/msp430f5529.qbs @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for msp430f5529 board" + references: [ + "redblink/redblink.qbs", + "nes-gamepads/nes-gamepads.qbs" + ] +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/README.md b/examples/baremetal/msp430f5529/nes-gamepads/README.md new file mode 100644 index 00000000..442bb587 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/README.md @@ -0,0 +1,36 @@ +This example demonstrates how to build a bare-metal application using +different MSP430 toolchains. It is designed for the MSP-EXP430F5529LP +target board (based on msp430f5529 chip): + +* http://www.ti.com/tool/MSP-EXP430F5529LP + +It implements a USB HID device that connects two 8-buttons NES +(Dendy) gamepads to a PC. The gamepads are connected to the +msp430f5529 chip as follows: + +1. CLK - it is an output clock signal which generates by chip from + the port 6, pin 0 (P6.0). This pin should be connected to the CLK + inputs for both gamepads. + +2. DATA1 - it is an input data signal which comes to chip on the + the port 6, pin 1 (P6.1). This pin should be connected to the DATA + output from the gamepad #1. + +3. DATA2 - it is an input data signal which comes to chip on the + the port 6, pin 2 (P6.2). This pin should be connected to the DATA + output from the gamepad #2. + +4. LATCH - it is an output clock signal which generates by chip from + the port 6, pin 3 (P6.3). This pin should be connected to the LATCH + inputs for both gamepads. + +Actual schematic and pinouts depends on an used gamepads (with 7, 9 +or other pins connectors) and a development boards. + +Also, do not forget to connect the +3.3V and GND wires to the gamepads. +Then it is possible to play 8-bit NES games using various PC simulators. + +The following toolchains are supported: + + * IAR Embedded Workbench + * GCC diff --git a/examples/baremetal/msp430f5529/nes-gamepads/gamepads.ld b/examples/baremetal/msp430f5529/nes-gamepads/gamepads.ld new file mode 100644 index 00000000..a3906a47 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/gamepads.ld @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +g_setupdat = 0x2380; /* Setup packet block address. */ + +g_ep0 = 0x0920; /* Input ep0 configuration address. */ +g_ep0_in_buf = 0x2378; /* Input ep0 buffer address. */ + +g_ep1_in = 0x23C8; /* Input ep1 configuration address. */ +g_ep1_in_xbuf = 0x1C80; /* Ep1 X-buffer address. */ diff --git a/examples/baremetal/msp430f5529/nes-gamepads/gpio.c b/examples/baremetal/msp430f5529/nes-gamepads/gpio.c new file mode 100644 index 00000000..b5e58bc7 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/gpio.c @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hwdefs.h" +#include "gpio.h" + +enum { INVALID_ADDRESS = 0xFFFF }; + +static uint16_t gpio_port_address_get(enum gpio_port port) +{ + switch (port) { + case GPIO_PORT_P1: + return P1_BASE; + case GPIO_PORT_P2: + return P2_BASE; + case GPIO_PORT_P3: + return P3_BASE; + case GPIO_PORT_P4: + return P4_BASE; + case GPIO_PORT_P5: + return P5_BASE; + case GPIO_PORT_P6: + return P6_BASE; + case GPIO_PORT_P7: + return P7_BASE; + case GPIO_PORT_P8: + return P8_BASE; + case GPIO_PORT_PJ: + return PJ_BASE; + default: + break; + } + return INVALID_ADDRESS; +} + +static uint16_t gpio_pins_adjust(enum gpio_port port, uint16_t pins) +{ + if ((port & 1) ^ 1) + pins <<= 8; + return pins; +} + +void gpio_pins_set_as_out(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PASEL) &= ~pins; + HWREG16(base_address + OFS_PADIR) |= pins; +} + +void gpio_pins_set_as_in(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PASEL) &= ~pins; + HWREG16(base_address + OFS_PADIR) &= ~pins; + HWREG16(base_address + OFS_PAREN) &= ~pins; +} + +void gpio_pins_set_as_pf_out(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PADIR) |= pins; + HWREG16(base_address + OFS_PASEL) |= pins; +} + +void gpio_pins_set_as_pf_in(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PADIR) &= ~pins; + HWREG16(base_address + OFS_PASEL) |= pins; +} + +void gpio_pins_set_high(enum gpio_port port, + uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PAOUT) |= pins; +} + +void gpio_pins_set_low(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PAOUT) &= ~pins; +} + +void gpio_pins_toggle(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return; + pins = gpio_pins_adjust(port, pins); + HWREG16(base_address + OFS_PAOUT) ^= pins; +} + +enum gpio_pin_status gpio_pin_get(enum gpio_port port, uint16_t pins) +{ + const uint16_t base_address = gpio_port_address_get(port); + if (base_address == INVALID_ADDRESS) + return GPIO_INPUT_PIN_LOW; + pins = gpio_pins_adjust(port, pins); + const uint16_t value = HWREG16(base_address + OFS_PAIN) & pins; + return (value > 0) ? GPIO_INPUT_PIN_HIGH : GPIO_INPUT_PIN_LOW; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/gpio.h b/examples/baremetal/msp430f5529/nes-gamepads/gpio.h new file mode 100644 index 00000000..d69a543b --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/gpio.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_GPIO_H +#define MSP430_GPIO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum gpio_port { + GPIO_PORT_P1 = 1, + GPIO_PORT_P2 = 2, + GPIO_PORT_P3 = 3, + GPIO_PORT_P4 = 4, + GPIO_PORT_P5 = 5, + GPIO_PORT_P6 = 6, + GPIO_PORT_P7 = 7, + GPIO_PORT_P8 = 8, + GPIO_PORT_PJ = 13, +}; + +enum gpio_pin { + GPIO_PIN0 = 0x0001, + GPIO_PIN1 = 0x0002, + GPIO_PIN2 = 0x0004, + GPIO_PIN3 = 0x0008, + GPIO_PIN4 = 0x0010, + GPIO_PIN5 = 0x0020, + GPIO_PIN6 = 0x0040, + GPIO_PIN7 = 0x0080, + GPIO_PIN8 = 0x0100, + GPIO_PIN9 = 0x0200, + GPIO_PIN10 = 0x0400, + GPIO_PIN11 = 0x0800, + GPIO_PIN12 = 0x1000, + GPIO_PIN13 = 0x2000, + GPIO_PIN14 = 0x4000, + GPIO_PIN15 = 0x8000, +}; + +enum gpio_pin_status { + GPIO_INPUT_PIN_HIGH = 0x01, + GPIO_INPUT_PIN_LOW = 0x00 +}; + +void gpio_pins_set_as_out(enum gpio_port port, uint16_t pins); +void gpio_pins_set_as_in(enum gpio_port port, uint16_t pins); +void gpio_pins_set_as_pf_out(enum gpio_port port, uint16_t pins); +void gpio_pins_set_as_pf_in(enum gpio_port port, uint16_t pins); +void gpio_pins_set_high(enum gpio_port port, uint16_t pins); +void gpio_pins_set_low(enum gpio_port port, uint16_t pins); +void gpio_pins_toggle(enum gpio_port port, uint16_t pins); + +enum gpio_pin_status gpio_pin_get(enum gpio_port port, uint16_t pins); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_GPIO_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/hid.h b/examples/baremetal/msp430f5529/nes-gamepads/hid.h new file mode 100644 index 00000000..1307301d --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/hid.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_HID_H +#define MSP430_HID_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum hid_constants { + HID_CONFIG_NUMBER = 1, // Number of valid configuration. + HID_IFACE_NUMBER = 0, // Number of valid interface. + HID_ALT_IFACE_NUMBER = 0, // Number of valid alternate interface. + HID_EP_IN = 0x81 // Active end point address. +}; + +enum hid_gamepad_id { + HID_REPORT_ID_GAMEPAD1 = 1, + HID_REPORT_ID_GAMEPAD2 = 2 +}; + +enum { + HID_REPORTS_COUNT = 2, + HID_REPORT_BITS_COUNT = 8 +}; + +void hid_ep0_init(void); + +// Called only in interrupt context. +void hid_ep0_setup_handler(void); +void hid_ep0_in_handler(void); + +void hid_ep0_in_nak(void); +void hid_ep0_in_stall(void); +void hid_ep0_in_clear(void); +bool hid_ep0_in_is_stalled(void); + +void hid_ep0_out_nak(void); +void hid_ep0_out_stall(void); +void hid_ep0_out_clear(void); + +const uint8_t *hid_ep0_desc_get(uint8_t type, uint16_t *length); + +uint8_t hid_ep0_setup_bm_request_type_get(void); +uint8_t hid_ep0_setup_request_get(void); +uint8_t hid_ep0_setup_lvalue_get(void); +uint8_t hid_ep0_setup_hvalue_get(void); +uint8_t hid_ep0_setup_lindex_get(void); +uint8_t hid_ep0_setup_hindex_get(void); + +void hid_ep0_enumerated_set(bool enumerated); +bool hid_ep0_is_enumerated(void); + +void hid_ep1_init(void); +void hid_ep1_task(void); + +void hid_ep1_in_stall(void); +void hid_ep1_in_unstall(void); +bool hid_ep1_in_is_stalled(void); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_HID_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/hiddesc.c b/examples/baremetal/msp430f5529/nes-gamepads/hiddesc.c new file mode 100644 index 00000000..eb391d6c --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/hiddesc.c @@ -0,0 +1,303 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" +#include "usb.h" + +#include + +#define usb_word_msb_get(word) \ + (uint8_t)(((uint16_t)(word) >> 8) & 0xFF) +#define usb_word_lsb_get(word) \ + (uint8_t)((uint16_t)(word) & 0xFF) + +enum usb_bcd_version { + SPEC_BCD_VERSION = 0x0200, + DEVICE_BCD_VERSION = 0x1234, + HID_BCD_VERSION = 0x0111 +}; + +enum usb_ids { + DEVICE_VID = 0xFFFF, + DEVICE_PID = 0xFFFF +}; + +enum usb_lang_id { + LANG_ID = 0x0409 +}; + +enum usb_descriptor_string_index { + DESC_LANGID_STRING_INDEX = 0, + DESC_MFG_STRING_INDEX, + DESC_PRODUCT_STRING_INDEX, + DESC_SERIAL_STRING_INDEX +}; + +enum usb_descr_length { + // Standard length. + DESC_DEVICE_LEN = 18, + DESC_DEVICE_QUAL_LEN = 10, + DESC_CONF_LEN = 9, + DESC_OTHER_SPEED_CONF_LEN = 9, + DESC_INTERFACE_LEN = 9, + DESC_HID_LEN = 9, + DESCR_HID_REP_LEN = 56, + DESC_ENDPOINT_LEN = 7, + + // Total length. + DESC_DEVICE_TOTAL_LEN = DESC_DEVICE_LEN, + DESC_DEVICE_QUAL_TOTAL_LEN = DESC_DEVICE_QUAL_LEN, + DESC_CONF_TOTAL_LEN = DESC_CONF_LEN + DESC_INTERFACE_LEN + DESC_HID_LEN + DESC_ENDPOINT_LEN, + DESC_OTHER_SPEED_CONF_TOTAL_LEN = DESC_OTHER_SPEED_CONF_LEN + DESC_INTERFACE_LEN, + DESCR_HID_REP_TOTAL_LEN = DESCR_HID_REP_LEN +}; + +enum usb_descr_attributes { + // Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu). + USB_DESC_ATTRIBUTES = 0xA0, + // 100 mA (div 2). + USB_DESC_POWER_CONSUMPTION = 50 +}; + +enum usb_descr_numbers { + USB_DESC_CONFIG_COUNT = 1 +}; + +static const uint8_t g_hid_report_desc[DESCR_HID_REP_TOTAL_LEN] = { + // Pad #1 configuration. + 0x05, 0x01, // Usage page (Generic Desktop). + 0x09, 0x05, // Usage (Game Pad). + 0xa1, 0x01, // Collection (Application). + 0xa1, 0x00, // Collection (Physical). + 0x85, HID_REPORT_ID_GAMEPAD1, // Report id (1). + 0x05, 0x09, // Usage page (Button). + 0x19, 0x01, // Usage minimum (Button 1). + 0x29, 0x08, // Usage maximum (Button 8). + 0x15, 0x00, // Logical minimum (0). + 0x25, 0x01, // Logical maximum (1). + 0x95, HID_REPORT_BITS_COUNT, // Report count (8). + 0x75, 0x01, // Report size (1). + 0x81, 0x02, // Input (Data,Var,Abs). + 0xc0, // End collection. + 0xc0, // End collection. + // Pad #2 configuration. + 0x05, 0x01, // Usage page (Generic Desktop). + 0x09, 0x05, // Usage (Game Pad). + 0xa1, 0x01, // Collection (Application). + 0xa1, 0x00, // Collection (Physical). + 0x85, HID_REPORT_ID_GAMEPAD2, // Report id (2). + 0x05, 0x09, // Usage page (Button). + 0x19, 0x01, // Usage minimum (Button 1). + 0x29, 0x08, // Usage maximum (Button 8). + 0x15, 0x00, // Logical minimum (0). + 0x25, 0x01, // Logical maximum (1). + 0x95, HID_REPORT_BITS_COUNT, // Report count (8). + 0x75, 0x01, // Report size (1). + 0x81, 0x02, // Input (Data,Var,Abs). + 0xc0, // End collection + 0xc0 // End collection. +}; + +static const uint8_t g_device_desc[DESC_DEVICE_TOTAL_LEN] = { + DESC_DEVICE_LEN, // Descriptor length. + DESC_DEVICE, // Descriptor type. + usb_word_lsb_get(SPEC_BCD_VERSION), // USB BCD version, lo. + usb_word_msb_get(SPEC_BCD_VERSION), // USB BCD version, hi. + 0x00, // Device class. + 0x00, // Device sub-class. + 0x00, // Device protocol. + EP0_MAX_PACKET_SIZE, // Maximum packet size (ep0 size). + usb_word_lsb_get(DEVICE_VID), // Vendor ID, lo. + usb_word_msb_get(DEVICE_VID), // Vendor ID, hi. + usb_word_lsb_get(DEVICE_PID), // Product ID, lo. + usb_word_msb_get(DEVICE_PID), // Product ID, hi. + usb_word_lsb_get(DEVICE_BCD_VERSION), // Device BCD version, lo. + usb_word_msb_get(DEVICE_BCD_VERSION), // Device BCD version, hi. + DESC_MFG_STRING_INDEX, + DESC_PRODUCT_STRING_INDEX, + DESC_SERIAL_STRING_INDEX, + USB_DESC_CONFIG_COUNT // Configurations count. +}; + +static const uint8_t g_device_qual_desc[DESC_DEVICE_QUAL_TOTAL_LEN] = { + DESC_DEVICE_QUAL_LEN, // Descriptor length. + DESC_DEVICE_QUAL, // Descriptor type. + usb_word_lsb_get(SPEC_BCD_VERSION), // USB BCD version, lo. + usb_word_msb_get(SPEC_BCD_VERSION), // USB BCD version, hi. + 0x00, // Device class. + 0x00, // Device sub-class. + 0x00, // Device protocol. + EP0_MAX_PACKET_SIZE, // Maximum packet size (ep0 size). + USB_DESC_CONFIG_COUNT, // Configurations count. + 0x00 // Reserved. +}; + +static const uint8_t g_config_desc[DESC_CONF_TOTAL_LEN] = { + DESC_CONF_LEN, // Descriptor length. + DESC_CONF, // Descriptor type. + usb_word_lsb_get(DESC_CONF_TOTAL_LEN), // Total length, lo. + usb_word_msb_get(DESC_CONF_TOTAL_LEN), // Total length, hi. + 0x01, // Interfaces count. + HID_CONFIG_NUMBER, // Configuration number. + 0x00, // Configuration string index. + USB_DESC_ATTRIBUTES, // Attributes. + USB_DESC_POWER_CONSUMPTION, // Power consumption. + + // Interface descriptor. + DESC_INTERFACE_LEN, // Descriptor length. + DESC_INTERFACE, // Descriptor type. + HID_IFACE_NUMBER, // Zero-based index of this interfacce. + HID_ALT_IFACE_NUMBER, // Alternate setting. + 0x01, // End points count (ep1 in). + 0x03, // Class code (HID). + 0x00, // Subclass code (boot). + 0x00, // Protocol code (none). + 0x00, // Interface string descriptor index. + + // HID descriptor. + DESC_HID_LEN, // Descriptor length. + DESC_HID, // Descriptor type. + usb_word_lsb_get(HID_BCD_VERSION), // HID class BCD version, lo. + usb_word_msb_get(HID_BCD_VERSION), // HID class BCD version, hi. + 0x00, // Country code (HW country code). + 0x01, // Number of HID class descriptors to follow. + DESC_REPORT, // Repord descriptor type (HID). + usb_word_lsb_get(DESCR_HID_REP_LEN), // Report descriptor total length, lo. + usb_word_msb_get(DESCR_HID_REP_LEN), // Report descriptor total length, hi. + + // End point descriptor. + DESC_ENDPOINT_LEN, // Descriptor length. + DESC_ENDPOINT, // Descriptor type. + HID_EP_IN, // End point address (ep1 in). + 0x03, // End point type (interrupt). + usb_word_lsb_get(EP_MAX_PACKET_SIZE), // Maximum packet size, lo (ep1 size). + usb_word_msb_get(EP_MAX_PACKET_SIZE), // Maximum packet size, hi (ep1 size). + 0x01 // Polling interval (1 ms). +}; + +static const uint8_t g_lang_id_desc[] = { + 0x04, // Descriptor length. + DESC_STRING, // Descriptor type. + usb_word_lsb_get(LANG_ID), // Language id, lo. + usb_word_msb_get(LANG_ID) // Language id, hi. +}; + +static const uint8_t g_manuf_str_desc[] = { + 0x18, // Descriptor length. + DESC_STRING, // Descriptor type. + // Unicode string: + 'Q', 0, 'B', 0, 'S', 0, ' ', 0, + 'e', 0, 'x', 0, 'a', 0, 'm', 0, 'p', 0, 'l', 0, 'e', 0 +}; + +static const uint8_t g_product_str_desc[] = { + 0x1A, // Descriptor length. + DESC_STRING, // Descriptor type. + // Unicode string: + 'N', 0, 'E', 0, 'S', 0, ' ', 0, + 'G', 0, 'a', 0, 'm', 0, 'e', 0, + 'P', 0, 'a', 0, 'd', 0, 's', 0 +}; + +static const uint8_t g_serialno_str_desc[] = { + 0x1A, // Descriptor length. + DESC_STRING, // Descriptor type. + // Unicode string: + '0', 0 ,'1', 0, '0', 0, '2', 0, '0', 0, '3', 0, + '0', 0, '4', 0, '0', 0, '5', 0, '0', 0, '6', 0 +}; + +static const uint8_t *ep0_string_desc_get(uint16_t *length) +{ + const uint8_t index = hid_ep0_setup_lvalue_get(); + switch (index) { + case DESC_LANGID_STRING_INDEX: + *length = sizeof(g_lang_id_desc); + return g_lang_id_desc; + case DESC_MFG_STRING_INDEX: + *length = sizeof(g_manuf_str_desc); + return g_manuf_str_desc; + case DESC_PRODUCT_STRING_INDEX: + *length = sizeof(g_product_str_desc); + return g_product_str_desc; + case DESC_SERIAL_STRING_INDEX: + *length = sizeof(g_serialno_str_desc); + return g_serialno_str_desc; + default: + break; + } + return 0; +} + +const uint8_t *hid_ep0_desc_get(uint8_t type, uint16_t *length) +{ + switch (type) { + case DESC_DEVICE: + *length = DESC_DEVICE_TOTAL_LEN; + return g_device_desc; + case DESC_CONF: + *length = DESC_CONF_TOTAL_LEN; + return g_config_desc; + case DESC_STRING: + return ep0_string_desc_get(length); + case DESC_DEVICE_QUAL: + *length = DESC_DEVICE_QUAL_TOTAL_LEN; + return g_device_qual_desc; + case DESC_HID: + *length = DESC_HID_LEN; + return &g_config_desc[DESC_CONF_LEN + DESC_INTERFACE_LEN]; + case DESC_REPORT: + *length = DESCR_HID_REP_TOTAL_LEN; + return g_hid_report_desc; + default: + break; + } + return 0; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/hidep0.c b/examples/baremetal/msp430f5529/nes-gamepads/hidep0.c new file mode 100644 index 00000000..c4a267a5 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/hidep0.c @@ -0,0 +1,554 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hid.h" +#include "hwdefs.h" +#include "usb.h" + +enum usb_ep0_action { + STATUS_ACTION_NOTHING, + STATUS_ACTION_DATA_IN +}; + +struct usb_ep0 { + uint8_t IEPCNFG; // Input ep0 configuration register. + uint8_t IEPBCNT; // Input ep0 buffer byte count. + uint8_t OEPCNFG; // Output ep0 configuration register. + uint8_t OEPBCNT; // Output ep0 buffer byte count. +}; + +struct usb_ep0_data { + uint8_t data[EP_MAX_FIFO_SIZE]; + uint16_t length; + uint16_t offset; + enum usb_ep0_action action; + bool host_ask_more_data_than_available; +}; + +#if defined(__ICC430__) +#pragma location = 0x0920 // Input ep0 configuration address. +__no_init struct usb_ep0 __data16 g_ep0; +#pragma location = 0x2378 // Input ep0 buffer address. +__no_init uint8_t __data16 g_ep0_in_buf[EP0_MAX_PACKET_SIZE]; +#pragma location = 0x2380 // Setup packet block address. +__no_init uint8_t __data16 g_setupdat[EP0_MAX_PACKET_SIZE]; +#elif defined(__GNUC__) +extern struct usb_ep0 g_ep0; +extern uint8_t g_ep0_in_buf[EP0_MAX_PACKET_SIZE]; +extern uint8_t g_setupdat[EP0_MAX_PACKET_SIZE]; +#endif + +static volatile bool g_enumerated = false; +static bool g_rwuen = false; +static bool g_selfpwr = false; +static struct usb_ep0_data g_ep0_response; + +static bool ep0_in_response_create(const uint8_t *data, uint16_t length) +{ + if (sizeof(g_ep0_response.data) < length) + return false; + + for (uint16_t i = 0; i < length; ++i) + g_ep0_response.data[i] = data[i]; + + g_ep0_response.length = length; + g_ep0_response.offset = 0; + + const uint16_t setup_length = (g_setupdat[7] << 8) | g_setupdat[6]; + if (g_ep0_response.length >= setup_length) { + g_ep0_response.length = setup_length; + g_ep0_response.host_ask_more_data_than_available = false; + } else { + g_ep0_response.host_ask_more_data_than_available = true; + } + + return true; +} + +void ep0_in_frame_send(void) +{ + uint8_t frame_size = 0; + + if (g_ep0_response.length != EP_NO_MORE_DATA) { + if (g_ep0_response.length > EP0_MAX_PACKET_SIZE) { + frame_size = EP0_MAX_PACKET_SIZE; + g_ep0_response.length -= EP0_MAX_PACKET_SIZE; + g_ep0_response.action = STATUS_ACTION_DATA_IN; + } else if (g_ep0_response.length < EP0_MAX_PACKET_SIZE) { + frame_size = g_ep0_response.length; + g_ep0_response.length = EP_NO_MORE_DATA; + g_ep0_response.action = STATUS_ACTION_NOTHING; + } else { + frame_size = EP0_MAX_PACKET_SIZE; + if (g_ep0_response.host_ask_more_data_than_available) { + g_ep0_response.length = 0; + g_ep0_response.action = STATUS_ACTION_DATA_IN; + } else { + g_ep0_response.length = EP_NO_MORE_DATA; + g_ep0_response.action = STATUS_ACTION_NOTHING; + } + } + + for (uint8_t i = 0; i < frame_size; ++i) { + g_ep0_in_buf[i] = g_ep0_response.data[g_ep0_response.offset]; + ++g_ep0_response.offset; + } + + g_ep0.IEPBCNT = frame_size; + } else { + g_ep0_response.action = STATUS_ACTION_NOTHING; + } +} + +static bool ep0_dev_status_get(void) +{ + uint16_t status = 0; + if (g_selfpwr) + status |= STATUS_SELF_POWERED; + if (g_rwuen) + status |= STATUS_REMOTE_WAKEUP; + ep0_in_response_create((uint8_t *)&status, sizeof(status)); + return true; +} + +static bool ep0_iface_status_get(void) +{ + uint16_t status = 0; + ep0_in_response_create((uint8_t *)&status, sizeof(status)); + return true; +} + +static bool ep0_ep_status_get(void) +{ + uint16_t status = 0; + const uint8_t ep = hid_ep0_setup_lindex_get(); + const uint8_t ep_num = ep & ~SETUP_DIR; + if (ep_num == 0) { + status = hid_ep0_in_is_stalled() ? 1 : 0; + } else if ((ep_num == 1) && (ep & SETUP_DIR) == SETUP_INPUT) { + // We support only one input ep1 in. + status = hid_ep1_in_is_stalled() ? 1 : 0; + } else { + return false; + } + + ep0_in_response_create((uint8_t *)&status, sizeof(status)); + return true; +} + +static bool ep0_get_status_proc(void) +{ + const uint8_t bm_req_type = hid_ep0_setup_bm_request_type_get(); + if ((bm_req_type & SETUP_DIR) != SETUP_INPUT) + return false; + const uint8_t recipient = bm_req_type & SETUP_RECIPIENT; + switch (recipient) { + case SETUP_DEVICE: + return ep0_dev_status_get(); + case SETUP_IFACE: + return ep0_iface_status_get(); + case SETUP_EP: + return ep0_ep_status_get(); + default: + break; + } + return false; +} + +static bool ep0_dev_feature_clear(void) +{ + const uint8_t feature = hid_ep0_setup_lvalue_get(); + if (feature != FEATURE_REMOTE_WAKEUP) + return false; + g_rwuen = false; + return true; +} + +static bool ep0_ep_feature_clear(void) +{ + const uint8_t feature = hid_ep0_setup_lvalue_get(); + if (feature != FEATURE_STALL) + return false; + const uint8_t ep = hid_ep0_setup_lindex_get(); + const uint8_t ep_num = ep & ~SETUP_DIR; + if (ep_num == 0) { + // Do nothing. + } else if ((ep_num == 1) && (ep & SETUP_DIR) == SETUP_INPUT) { + // We support only one input ep1 in. + hid_ep1_in_unstall(); + } else { + return false; + } + + hid_ep0_in_clear(); + return true; +} + +static bool ep0_clear_feature_proc(void) +{ + const uint8_t bm_req_type = hid_ep0_setup_bm_request_type_get(); + if ((bm_req_type & SETUP_DIR) != SETUP_INPUT) + return false; + const uint8_t recipient = bm_req_type & SETUP_RECIPIENT; + switch (recipient) { + case SETUP_DEVICE: + return ep0_dev_feature_clear(); + case SETUP_EP: + return ep0_ep_feature_clear(); + default: + break; + } + return false; +} + +static bool ep0_dev_feature_set(void) +{ + const uint8_t feature = hid_ep0_setup_lvalue_get(); + switch (feature) { + case FEATURE_REMOTE_WAKEUP: + g_rwuen = true; + return true; + case FEATURE_TEST_MODE: + // This is "test mode", just return the handshake. + return true; + default: + break; + } + return false; +} + +static bool ep0_ep_feature_set(void) +{ + const uint8_t feature = hid_ep0_setup_lvalue_get(); + if (feature != FEATURE_STALL) + return false; + const uint8_t ep = hid_ep0_setup_lindex_get(); + const uint8_t ep_num = ep & ~SETUP_DIR; + if (ep_num == 0) { + // Do nothing. + } else if ((ep_num == 1) && (ep & SETUP_DIR) == SETUP_INPUT) { + // We support only one input ep1 in. + hid_ep1_in_stall(); + } else { + return false; + } + hid_ep0_in_clear(); + return true; +} + +static bool ep0_set_feature_proc(void) +{ + const uint8_t bm_req_type = hid_ep0_setup_bm_request_type_get(); + switch (bm_req_type & SETUP_RECIPIENT) { + case SETUP_DEVICE: + return ep0_dev_feature_set(); + case SETUP_EP: + return ep0_ep_feature_set(); + default: + break; + } + return false; +} + +static bool ep0_set_address_proc(void) +{ + hid_ep0_out_stall(); + const uint8_t address = hid_ep0_setup_lvalue_get(); + if (address >= 128) + return false; + USBFUNADR = address; + hid_ep0_in_clear(); + return true; +} + +static bool ep0_descriptor_proc(uint8_t type) +{ + uint16_t length = 0; + const uint8_t *pdesc = hid_ep0_desc_get(type, &length); + if (!pdesc) + return false; + ep0_in_response_create(pdesc, length); + return true; +} + +static bool ep0_get_descriptor_proc(void) +{ + const uint8_t descr_type = hid_ep0_setup_hvalue_get(); + switch (descr_type) { + case DESC_DEVICE: + case DESC_CONF: + case DESC_STRING: + case DESC_DEVICE_QUAL: + case DESC_OTHER_SPEED_CONF: + case DESC_HID: + case DESC_REPORT: + return ep0_descriptor_proc(descr_type); + } + return false; +} + +static bool ep0_get_config_proc(void) +{ + // We only support configuration 1. + const uint8_t cfg_num = HID_CONFIG_NUMBER; + ep0_in_response_create(&cfg_num, sizeof(cfg_num)); + return true; +} + +static bool ep0_set_config_proc(void) +{ + const uint8_t cfg_num = hid_ep0_setup_lvalue_get(); + // We only support configuration 1. + const bool is_valid = (cfg_num & HID_CONFIG_NUMBER); + hid_ep0_enumerated_set(is_valid); + return is_valid; +} + +static bool ep0_get_iface_proc(void) +{ + const uint8_t iface_num = hid_ep0_setup_lindex_get(); + if (iface_num != HID_IFACE_NUMBER) + return false; + ep0_in_response_create(&iface_num, sizeof(iface_num)); + return true; +} + +static bool ep0_set_iface_proc(void) +{ + const uint8_t iface_num = hid_ep0_setup_lindex_get(); + if (iface_num != HID_IFACE_NUMBER) + return false; + + const uint8_t alt_iface_num = hid_ep0_setup_lvalue_get(); + if (alt_iface_num != HID_ALT_IFACE_NUMBER) + return false; + + hid_ep0_out_stall(); + hid_ep0_in_clear(); + return true; +} + +static bool ep0_std_proc(void) +{ + const uint8_t request_code = hid_ep0_setup_request_get(); + switch (request_code) { + case SETUP_GET_STATUS: + return ep0_get_status_proc(); + case SETUP_CLEAR_FEATURE: + return ep0_clear_feature_proc(); + case SETUP_SET_FEATURE: + return ep0_set_feature_proc(); + case SETUP_SET_ADDRESS: + return ep0_set_address_proc(); + case SETUP_GET_DESCRIPTOR: + return ep0_get_descriptor_proc(); + case SETUP_GET_CONFIGURATION: + return ep0_get_config_proc(); + case SETUP_SET_CONFIGURATION: + return ep0_set_config_proc(); + case SETUP_GET_INTERFACE: + return ep0_get_iface_proc(); + case SETUP_SET_INTERFACE: + return ep0_set_iface_proc(); + default: + break; + } + return false; +} + +static bool ep0_setup(void) +{ + const uint8_t bm_req_type = hid_ep0_setup_bm_request_type_get(); + const uint8_t setup_type = bm_req_type & SETUP_TYPE; + switch (setup_type) { + case SETUP_STANDARD: + return ep0_std_proc(); + default: + break; + } + return false; +} + +static bool ep0_has_another_setup(void) +{ + if ((USBIFG & STPOWIFG) != 0) { + USBIFG &= ~(STPOWIFG | SETUPIFG); + return true; + } + return false; +} + +void hid_ep0_init(void) +{ + hid_ep0_in_nak(); + hid_ep0_out_nak(); + + g_ep0.IEPCNFG = UBME | STALL | USBIIE; + g_ep0.OEPCNFG = UBME | STALL | USBIIE; + + // Enable only ep0in interrupts. + USBIEPIE |= BIT0; +} + +void hid_ep0_setup_handler(void) +{ + USBCTL |= FRSTE; + + g_ep0_response.length = 0; + g_ep0_response.offset = 0; + g_ep0_response.action = STATUS_ACTION_NOTHING; + g_ep0_response.host_ask_more_data_than_available = false; + + for (;;) { + const uint8_t bm_req_type = hid_ep0_setup_bm_request_type_get(); + if ((bm_req_type & SETUP_INPUT) == SETUP_INPUT) + USBCTL |= DIR; + else + USBCTL &= ~DIR; + + const bool success = ep0_setup(); + if (success) { + hid_ep0_out_clear(); + ep0_in_frame_send(); + } else { + hid_ep0_in_stall(); + } + + if (!ep0_has_another_setup()) + return; + } +} + +void hid_ep0_in_handler(void) +{ + USBCTL |= FRSTE; + hid_ep0_out_clear(); + if (g_ep0_response.action == STATUS_ACTION_DATA_IN) + ep0_in_frame_send(); + else + hid_ep0_in_stall(); +} + +void hid_ep0_in_nak(void) +{ + g_ep0.IEPBCNT = NAK; +} + +void hid_ep0_in_stall(void) +{ + g_ep0.IEPCNFG |= STALL; +} + +void hid_ep0_in_clear(void) +{ + g_ep0_response.length = EP_NO_MORE_DATA; + g_ep0_response.action = STATUS_ACTION_NOTHING; + g_ep0.IEPBCNT = 0; +} + +bool hid_ep0_in_is_stalled(void) +{ + return (g_ep0.IEPCNFG & STALL); +} + +void hid_ep0_out_nak(void) +{ + g_ep0.OEPBCNT = NAK; +} + +void hid_ep0_out_stall(void) +{ + g_ep0.OEPCNFG |= STALL; +} + +void hid_ep0_out_clear(void) +{ + g_ep0.OEPBCNT = 0; +} + +uint8_t hid_ep0_setup_bm_request_type_get(void) +{ + return g_setupdat[0]; +} + +uint8_t hid_ep0_setup_request_get(void) +{ + return g_setupdat[1]; +} + +uint8_t hid_ep0_setup_lvalue_get(void) +{ + return g_setupdat[2]; +} + +uint8_t hid_ep0_setup_hvalue_get(void) +{ + return g_setupdat[3]; +} + +uint8_t hid_ep0_setup_lindex_get(void) +{ + return g_setupdat[4]; +} + +uint8_t hid_ep0_setup_hindex_get(void) +{ + return g_setupdat[5]; +} + +void hid_ep0_enumerated_set(bool enumerated) +{ + g_enumerated = enumerated; +} + +bool hid_ep0_is_enumerated(void) +{ + return g_enumerated; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/hidep1.c b/examples/baremetal/msp430f5529/nes-gamepads/hidep1.c new file mode 100644 index 00000000..2d29490e --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/hidep1.c @@ -0,0 +1,214 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "hid.h" +#include "hwdefs.h" +#include "usb.h" + +// We use this empirical value to make a GPIO polling +// every ~10 msec (rough). It is a simplest way, because +// instead we need to use a timers with interrupts callbacks. +enum { POLLING_COUNTER = 888 }; + +// Pins on the port 6. +enum gpio_pins { + GPIO_CLK_PIN = BIT0, + GPIO_DATA1_PIN = BIT1, + GPIO_DATA2_PIN = BIT2, + GPIO_LATCH_PIN = BIT3, +}; + +struct usb_ep { + uint8_t EPCNF; // Endpoint configuration. + uint8_t EPBBAX; // Endpoint X buffer base address. + uint8_t EPBCTX; // Endpoint X Buffer byte count. + uint8_t SPARE0; // No used. + uint8_t SPARE1; // No used. + uint8_t EPBBAY; // Endpoint Y buffer Base address. + uint8_t EPBCTY; // Endpoint Y buffer byte count. + uint8_t EPSIZXY; // Endpoint XY buffer size. +}; + +#if defined(__ICC430__) +#pragma location = 0x23C8 // Input ep1 configuration address. +__no_init struct usb_ep __data16 g_ep1_in; + +#pragma location = 0x1C80 // Input ep1 X-buffer address. +__no_init uint8_t __data16 g_ep1_in_xbuf[EP_MAX_PACKET_SIZE]; +#elif defined(__GNUC__) +extern struct usb_ep g_ep1_in; +extern uint8_t g_ep1_in_xbuf[EP_MAX_PACKET_SIZE]; +#endif + +static struct { + const uint8_t data_pin; + const uint8_t id; + uint8_t buttons; + bool ready; +} g_reports[HID_REPORTS_COUNT] = { + {GPIO_DATA1_PIN, HID_REPORT_ID_GAMEPAD1, 0, false}, + {GPIO_DATA2_PIN, HID_REPORT_ID_GAMEPAD2, 0, false} +}; + +static uint16_t g_poll_counter = 0; + +// Pulse width around ~10 usec. +static void ep1_latch_pulse(void) +{ + gpio_pins_set_high(GPIO_PORT_P6, GPIO_LATCH_PIN); + gpio_pins_set_low(GPIO_PORT_P6, GPIO_LATCH_PIN); +} + +// Pulse width around ~10 usec. +static void ep1_clk_pulse(void) +{ + gpio_pins_set_high(GPIO_PORT_P6, GPIO_CLK_PIN); + gpio_pins_set_low(GPIO_PORT_P6, GPIO_CLK_PIN); +} + +static void ep1_reports_clean(void) +{ + for (uint8_t index = 0; index < HID_REPORTS_COUNT; ++index) { + g_reports[index].buttons = 0; + g_reports[index].ready = false; + } +} + +static void ep1_reports_update(void) +{ + for (uint8_t index = 0; index < HID_REPORTS_COUNT; ++index) + g_reports[index].ready = true; +} + +static void ep1_gamepads_poll(void) +{ + ep1_reports_clean(); + + ep1_latch_pulse(); + + for (uint8_t pos = 0; pos < HID_REPORT_BITS_COUNT; ++pos) { + // TODO: Add some nops here? + + for (uint8_t index = 0; index < HID_REPORTS_COUNT; ++index) { + const uint8_t pin = g_reports[index].data_pin; + const enum gpio_pin_status st = gpio_pin_get(GPIO_PORT_P6, pin); + // Low state means that a button is pressed. + const bool v = (st == GPIO_INPUT_PIN_LOW); + g_reports[index].buttons |= (v << pos); + } + + ep1_clk_pulse(); + } + + ep1_reports_update(); +} + +static void ep1_report_send(uint8_t report_index) +{ + if (!g_reports[report_index].ready) + return; + + if ((g_ep1_in.EPBCTX & NAK) == 0) + return; + + g_ep1_in_xbuf[0] = g_reports[report_index].id; + g_ep1_in_xbuf[1] = g_reports[report_index].buttons; + g_ep1_in.EPBCTX = 2; + + g_reports[report_index].ready = false; +} + +void hid_ep1_init(void) +{ + enum { + USBSTABUFF_ADDRESS = 0x1C00, // Start of buffer space address. + USBIEPBBAX_1_ADDRESS = 0x1C80 // Input ep1 X-buffer address. + }; + + g_ep1_in.EPCNF = UBME | USBIIE; + g_ep1_in.EPBBAX = ((USBIEPBBAX_1_ADDRESS - USBSTABUFF_ADDRESS) >> 3) & 0x00FF; + g_ep1_in.EPBCTX = NAK; + g_ep1_in.EPSIZXY = EP_MAX_PACKET_SIZE; + + gpio_pins_set_as_out(GPIO_PORT_P6, GPIO_CLK_PIN | GPIO_LATCH_PIN); + gpio_pins_set_as_in(GPIO_PORT_P6, GPIO_DATA1_PIN | GPIO_DATA2_PIN); +} + +void hid_ep1_task(void) +{ + if (!hid_ep0_is_enumerated()) + return; + + for (uint8_t index = 0; index < HID_REPORTS_COUNT; ++index) + ep1_report_send(index); + + if (g_poll_counter <= POLLING_COUNTER) { + ++g_poll_counter; + } else { + g_poll_counter = 0; + ep1_gamepads_poll(); + } +} + +void hid_ep1_in_stall(void) +{ + g_ep1_in.EPCNF |= STALL; +} + +void hid_ep1_in_unstall(void) +{ + g_ep1_in.EPCNF &= ~(STALL | TOGGLE); +} + +bool hid_ep1_in_is_stalled(void) +{ + return (g_ep1_in.EPCNF & STALL); +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/hwdefs.h b/examples/baremetal/msp430f5529/nes-gamepads/hwdefs.h new file mode 100644 index 00000000..89dbcf5a --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/hwdefs.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_HW_DEFS_H +#define MSP430_HW_DEFS_H + +#include +#include + +#if defined(__ICC430__) +# define _PPTOSTR_(x) #x +# define _PPARAM_(address) _PPTOSTR_(vector=address) +# define INTERRUPT(isr_name, vector) \ + _Pragma(_PPARAM_(vector)) __interrupt void isr_name(void) +#elif defined(__GNUC__) +# define INTERRUPT(isr_name, vector) \ + void __attribute__ ((interrupt(vector))) isr_name(void) +#else +# error "Unsupported toolchain" +#endif + +#include +#include + +#define HWREG8(x) \ + (*((volatile uint8_t *)((uint16_t)x))) + +#define HWREG16(x) \ + (*((volatile uint16_t *)((uint16_t)x))) + +#define HWREG32(x) \ + (*((volatile uint32_t *)((uint16_t)x))) + +#endif // MSP430_HW_DEFS_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/main.c b/examples/baremetal/msp430f5529/nes-gamepads/main.c new file mode 100644 index 00000000..97c499ee --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/main.c @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hwdefs.h" +#include "pmm.h" +#include "ucs.h" +#include "usb.h" +#include "wdt_a.h" + +static void hw_clocks_init(uint32_t mclk_freq) +{ + ucs_init(UCS_FLLREF, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1); + ucs_init(UCS_ACLK, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1); + ucs_fll_settle_init(mclk_freq / 1000, mclk_freq / 32768); + + // Use REFO for FLL and ACLK. + UCSCTL3 = (UCSCTL3 & ~SELREF_7) | SELREF__REFOCLK; + UCSCTL4 = (UCSCTL4 & ~SELA_7) | SELA__REFOCLK; +} + +static void hw_init(void) +{ + __disable_interrupt(); + + wdt_a_stop(); + pmm_voltage_init(PMM_VOLTAGE_1_85V); + hw_clocks_init(8000000); + usb_init(); + + __enable_interrupt(); +} + +static void hw_loop_exec(void) +{ + for (;;) { + usb_task(); + } +} + +int main(void) +{ + hw_init(); + hw_loop_exec(); + return 0; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/nes-gamepads.qbs b/examples/baremetal/msp430f5529/nes-gamepads/nes-gamepads.qbs new file mode 100644 index 00000000..a06cfc6a --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/nes-gamepads.qbs @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("msp430")) + return false; + return qbs.toolchain.contains("iar") + || qbs.toolchain.contains("gcc") + } + name: "msp430f5529-nes-gamepads" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + + property path dlibIncludePath: cpp.toolchainInstallPath + "/../lib/dlib/dl430xssfn.h" + property path dlibRuntimePath: cpp.toolchainInstallPath + "/../lib/dlib/dl430xssfn.r43" + + cpp.entryPoint: "__program_start" + + cpp.defines: ["__MSP430F5529__"] + + cpp.driverFlags: [ + "-e", + "--core=430X", + "--data_model=small", + "--code_model=small", + "--dlib_config", dlibIncludePath + ] + + cpp.driverLinkerFlags: [ + "-D_STACK_SIZE=A0", + "-D_DATA16_HEAP_SIZE=A0", + "-D_DATA20_HEAP_SIZE=50" + ] + + cpp.staticLibraries: [ + // Explicitly link with the runtime dlib library (which contains + // all required startup code and other stuff). + dlibRuntimePath + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR Linker Script" + prefix: cpp.toolchainInstallPath + "/../config/linker/" + fileTags: ["linkerscript"] + // Explicitly use the default linker scripts for current target. + files: ["lnk430f5529.xcl"] + } + + // + // GCC-specific properties and soucres. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + property path supportFilesPath + // A path to the MSP430 support files, which are + // provided by the Texas Instruments separately: + // e.g. 'c:/msp430-gcc-support-files/include/' + cpp.includePaths: supportFilesPath + cpp.libraryPaths: supportFilesPath + cpp.driverFlags: ["-mmcu=msp430f5529"] + } + + Group { + condition: qbs.toolchain.contains("gcc") + name: "GCC Linker Script" + fileTags: ["linkerscript"] + files: ["gamepads.ld"] + } + + files: [ + "gpio.c", + "gpio.h", + "hid.h", + "hiddesc.c", + "hidep0.c", + "hidep1.c", + "hwdefs.h", + "main.c", + "pmm.c", + "pmm.h", + "ucs.c", + "ucs.h", + "usb.c", + "usb.h", + "wdt_a.c", + "wdt_a.h", + ] +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/pmm.c b/examples/baremetal/msp430f5529/nes-gamepads/pmm.c new file mode 100644 index 00000000..b588e7ad --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/pmm.c @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hwdefs.h" +#include "pmm.h" + +#define PMMCTL0_H_ADDRESS (PMM_BASE + OFS_PMMCTL0_H) +#define PMMCTL0_L_ADDRESS (PMM_BASE + OFS_PMMCTL0_L) +#define PMMRIE_ADDRESS (PMM_BASE + OFS_PMMRIE) +#define PMMIFG_ADDRESS (PMM_BASE + OFS_PMMIFG) +#define SVSMHCTL_ADDRESS (PMM_BASE + OFS_SVSMHCTL) +#define SVSMLCTL_ADDRESS (PMM_BASE + OFS_SVSMLCTL) + +#define PMM_OTHER_BITSL \ + (SVSLRVL0 | SVSLRVL1 | SVSMLRRL0 | SVSMLRRL1 | SVSMLRRL2) + +#define PMM_OTHER_BITSH \ + (SVSHRVL0 | SVSHRVL1 | SVSMHRRL0 | SVSMHRRL1 | SVSMHRRL2) + +#define PMM_CLEANUP_FLAGS \ + (SVMHVLRIFG | SVMHIFG | SVSMHDLYIFG | SVMLVLRIFG | SVMLIFG | SVSMLDLYIFG) + +static void pmm_write_access_allow(bool allow) +{ + HWREG8(PMMCTL0_H_ADDRESS) = allow ? PMMPW_H : 0; +} + +static void pmm_interrupt_flags_clear(uint16_t flags) +{ + HWREG16(PMMIFG_ADDRESS) &= ~flags; +} + +static void pmm_interrupt_flags_wait(uint16_t flags) +{ + while ((HWREG16(PMMIFG_ADDRESS) & flags) == 0) { + ; + } +} + +static uint8_t pmm_level_mask(enum ppm_voltage voltage) +{ + switch (voltage) { + case PMM_VOLTAGE_1_35V: + return PMMCOREV_0; + case PMM_VOLTAGE_1_55V: + return PMMCOREV_1; + case PMM_VOLTAGE_1_75V: + return PMMCOREV_2; + case PMM_VOLTAGE_1_85V: + return PMMCOREV_3; + default: + break; + } + return PMMCOREV_0; +} + +static bool pmm_voltage_set_up(uint8_t level) +{ + pmm_write_access_allow(true); + + // Disable interrupts and backup all registers. + uint16_t pmmrie_backup = HWREG16(PMMRIE_ADDRESS); + HWREG16(PMMRIE_ADDRESS) &= ~(SVMHVLRPE | SVSHPE | SVMLVLRPE | SVSLPE + | SVMHVLRIE | SVMHIE | SVSMHDLYIE | SVMLVLRIE + | SVMLIE | SVSMLDLYIE); + uint16_t svsmhctl_backup = HWREG16(SVSMHCTL_ADDRESS); + uint16_t svsmlctl_backup = HWREG16(SVSMLCTL_ADDRESS); + + // Clear all interrupt flags. + pmm_interrupt_flags_clear(0xFFFF); + + // Set SVM high side to new level and check if voltage increase is possible. + HWREG16(SVSMHCTL_ADDRESS) = SVMHE | SVSHE | (SVSMHRRL0 * level); + pmm_interrupt_flags_wait(SVSMHDLYIFG); + pmm_interrupt_flags_clear(SVSMHDLYIFG); + + // Check if a voltage increase is possible. + if ((HWREG16(PMMIFG_ADDRESS) & SVMHIFG) == SVMHIFG) { + // Vcc is too low for a voltage increase, recover the previous settings. + HWREG16(PMMIFG_ADDRESS) &= ~SVSMHDLYIFG; + HWREG16(SVSMHCTL_ADDRESS) = svsmhctl_backup; + pmm_interrupt_flags_wait(SVSMHDLYIFG); + pmm_interrupt_flags_clear(PMM_CLEANUP_FLAGS); + // Restore interrupt enable register. + HWREG16(PMMRIE_ADDRESS) = pmmrie_backup; + pmm_write_access_allow(false); + return false; + } + + // Set SVS high side to new level. + HWREG16(SVSMHCTL_ADDRESS) |= (SVSHRVL0 * level); + pmm_interrupt_flags_wait(SVSMHDLYIFG); + pmm_interrupt_flags_clear(SVSMHDLYIFG); + + // Set new voltage level. + HWREG8(PMMCTL0_L_ADDRESS) = PMMCOREV0 * level; + + // Set SVM, SVS low side to new level. + HWREG16(SVSMLCTL_ADDRESS) = SVMLE | (SVSMLRRL0 * level) + | SVSLE | (SVSLRVL0 * level); + pmm_interrupt_flags_wait(SVSMLDLYIFG); + pmm_interrupt_flags_clear(SVSMLDLYIFG); + + // Restore low side settings and clear all other bits. + HWREG16(SVSMLCTL_ADDRESS) &= PMM_OTHER_BITSL; + // Clear low side level settings in backup register and keep all other bits. + svsmlctl_backup &= ~PMM_OTHER_BITSL; + // Restore low side SVS monitor settings. + HWREG16(SVSMLCTL_ADDRESS) |= svsmlctl_backup; + + // Restore high side settings and clear all other bits. + HWREG16(SVSMHCTL_ADDRESS) &= PMM_OTHER_BITSH; + // Clear high side level settings in backup register and keep all other bits. + svsmhctl_backup &= ~PMM_OTHER_BITSH; + // Restore high side SVS monitor settings. + HWREG16(SVSMHCTL_ADDRESS) |= svsmhctl_backup; + + pmm_interrupt_flags_wait(SVSMLDLYIFG | SVSMHDLYIFG); + pmm_interrupt_flags_clear(PMM_CLEANUP_FLAGS); + + // Restore interrupt enable register. + HWREG16(PMMRIE_ADDRESS) = pmmrie_backup; + pmm_write_access_allow(false); + + return true; +} + +static uint16_t pmm_voltage_set_down(uint8_t level) +{ + pmm_write_access_allow(true); + + // Disable interrupts and backup all registers. + uint16_t pmmrie_backup = HWREG16(PMMRIE_ADDRESS); + HWREG16(PMMRIE_ADDRESS) &= ~(SVMHVLRPE | SVSHPE | SVMLVLRPE | + SVSLPE | SVMHVLRIE | SVMHIE | + SVSMHDLYIE | SVMLVLRIE | SVMLIE | + SVSMLDLYIE + ); + uint16_t svsmhctl_backup = HWREG16(SVSMHCTL_ADDRESS); + uint16_t svsmlctl_backup = HWREG16(SVSMLCTL_ADDRESS); + + pmm_interrupt_flags_clear(SVMHIFG | SVSMHDLYIFG | SVMLIFG | SVSMLDLYIFG); + + // Set SVM, SVS high & low side to new settings in normal mode. + HWREG16(SVSMHCTL_ADDRESS) = SVMHE | (SVSMHRRL0 * level) | SVSHE | (SVSHRVL0 * level); + HWREG16(SVSMLCTL_ADDRESS) = SVMLE | (SVSMLRRL0 * level) | SVSLE | (SVSLRVL0 * level); + + pmm_interrupt_flags_wait(SVSMHDLYIFG | SVSMLDLYIFG); + pmm_interrupt_flags_clear(SVSMHDLYIFG | SVSMLDLYIFG); + + // Set new voltage level. + HWREG8(PMMCTL0_L_ADDRESS) = PMMCOREV0 * level; + + // Restore low side settings and clear all other bits. + HWREG16(SVSMLCTL_ADDRESS) &= PMM_OTHER_BITSL; + // Clear low side level settings in backup register and keep all other bits. + svsmlctl_backup &= ~PMM_OTHER_BITSL; + //Restore low side SVS monitor settings. + HWREG16(SVSMLCTL_ADDRESS) |= svsmlctl_backup; + + // Restore high side settings and clear all other bits. + HWREG16(SVSMHCTL_ADDRESS) &= PMM_OTHER_BITSH; + // Clear high side level settings in backup register and keep all other bits. + svsmhctl_backup &= ~PMM_OTHER_BITSH; + // Restore high side SVS monitor settings. + HWREG16(SVSMHCTL_ADDRESS) |= svsmhctl_backup; + + pmm_interrupt_flags_wait(SVSMLDLYIFG | SVSMHDLYIFG); + pmm_interrupt_flags_clear(PMM_CLEANUP_FLAGS); + + // Restore interrupt enable register. + HWREG16(PMMRIE_ADDRESS) = pmmrie_backup; + pmm_write_access_allow(false); + + return true; +} + +bool pmm_voltage_init(enum ppm_voltage voltage) +{ + const uint8_t exp_level = pmm_level_mask(voltage) & PMMCOREV_3; + uint8_t act_level = (HWREG16(PMM_BASE + OFS_PMMCTL0) & PMMCOREV_3); + bool result = true; + while ((exp_level != act_level) && result) { + if (exp_level > act_level) + result = pmm_voltage_set_up(++act_level); + else + result = pmm_voltage_set_down(--act_level); + } + return result; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/pmm.h b/examples/baremetal/msp430f5529/nes-gamepads/pmm.h new file mode 100644 index 00000000..049fddc6 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/pmm.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_PMM_H +#define MSP430_PMM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum ppm_voltage { + PMM_VOLTAGE_1_35V, + PMM_VOLTAGE_1_55V, + PMM_VOLTAGE_1_75V, + PMM_VOLTAGE_1_85V +}; + +bool pmm_voltage_init(enum ppm_voltage voltage); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_PMM_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/ucs.c b/examples/baremetal/msp430f5529/nes-gamepads/ucs.c new file mode 100644 index 00000000..a4e17b8a --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/ucs.c @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hwdefs.h" +#include "ucs.h" + +#if defined(__GNUC__) +#define __delay_cycles(x) \ + ({ \ + for (uint16_t j = 0; j < x; j++) { \ + __no_operation(); \ + } \ + }) +#endif + +static uint16_t ucs_source_mask(enum ucs_source source) +{ + switch (source) { + case UCS_XT1CLK_SELECT: + return SELM__XT1CLK; + case UCS_VLOCLK_SELECT: + return SELM__VLOCLK; + case UCS_REFOCLK_SELECT: + return SELM__REFOCLK; + case UCS_DCOCLK_SELECT: + return SELM__DCOCLK; + case UCS_DCOCLKDIV_SELECT: + return SELM__DCOCLKDIV; + case UCS_XT2CLK_SELECT: + return SELM__XT2CLK; + default: + break; + } + return SELM__XT1CLK; +} + +static uint16_t ucs_divider_mask(enum ucs_divider divider) +{ + switch (divider) { + case UCS_CLOCK_DIVIDER_1: + return DIVM__1; + case UCS_CLOCK_DIVIDER_2: + return DIVM__2; + case UCS_CLOCK_DIVIDER_4: + return DIVM__4; + case UCS_CLOCK_DIVIDER_8: + return DIVM__8; + case UCS_CLOCK_DIVIDER_12: + return DIVM__32; + case UCS_CLOCK_DIVIDER_16: + return DIVM__16; + case UCS_CLOCK_DIVIDER_32: + return DIVM__32; + default: + break; + } + return DIVM__1; +} + +static void ucs_fll_init(uint16_t fsystem, uint16_t ratio) +{ + const uint16_t sr_reg_backup = __get_SR_register() & SCG0; + + uint16_t mode = 0; + uint16_t d = ratio; + if (fsystem > 16000) { + d >>= 1; + mode = 1; + } else { + fsystem <<= 1; + } + + uint16_t dco_div_bits = FLLD__2; + while (d > 512) { + dco_div_bits = dco_div_bits + FLLD0; + d >>= 1; + } + + // Disable FLL. + __bis_SR_register(SCG0); + // Set DCO to lowest tap. + HWREG8(UCS_BASE + OFS_UCSCTL0_H) = 0; + // Reset FN bits. + HWREG16(UCS_BASE + OFS_UCSCTL2) &= ~(0x03FF); + HWREG16(UCS_BASE + OFS_UCSCTL2) = dco_div_bits | (d - 1); + + if (fsystem <= 630) { // fsystem < 0.63MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_0; + } else if (fsystem < 1250) { // 0.63MHz < fsystem < 1.25MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_1; + } else if (fsystem < 2500) { // 1.25MHz < fsystem < 2.5MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_2; + } else if (fsystem < 5000) { // 2.5MHz < fsystem < 5MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_3; + } else if (fsystem < 10000) { // 5MHz < fsystem < 10MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_4; + } else if (fsystem < 20000) { // 10MHz < fsystem < 20MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_5; + } else if (fsystem < 40000) { // 20MHz < fsystem < 40MHz + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_6; + } else { + HWREG8(UCS_BASE + OFS_UCSCTL1) = DCORSEL_7; + } + + // Re-enable FLL. + __bic_SR_register(SCG0); + + while (HWREG8(UCS_BASE + OFS_UCSCTL7_L) & DCOFFG) { + // Clear OSC fault flags. + HWREG8(UCS_BASE + OFS_UCSCTL7_L) &= ~(DCOFFG); + // Clear OFIFG fault flag. + HWREG8(SFR_BASE + OFS_SFRIFG1) &= ~OFIFG; + } + + // Restore previous SCG0. + __bis_SR_register(sr_reg_backup); + + if (mode == 1) { + // Select DCOCLK because fsystem > 16000. + HWREG16(UCS_BASE + OFS_UCSCTL4) &= ~(SELM_7 + SELS_7); + HWREG16(UCS_BASE + OFS_UCSCTL4) |= SELM__DCOCLK + SELS__DCOCLK; + } else { + // Select DCODIVCLK. + HWREG16(UCS_BASE + OFS_UCSCTL4) &= ~(SELM_7 + SELS_7); + HWREG16(UCS_BASE + OFS_UCSCTL4) |= SELM__DCOCLKDIV + SELS__DCOCLKDIV; + } +} + +void ucs_init(enum ucs_signal signal, + enum ucs_source source, + enum ucs_divider divider) +{ + uint16_t source_msk = ucs_source_mask(source); + uint16_t divider_msk = ucs_divider_mask(divider); + + switch (signal) { + case UCS_ACLK: + HWREG16(UCS_BASE + OFS_UCSCTL4) &= ~SELA_7; + source_msk |= source_msk << 8; + HWREG16(UCS_BASE + OFS_UCSCTL4) |= source_msk; + HWREG16(UCS_BASE + OFS_UCSCTL5) &= ~DIVA_7; + divider_msk = divider_msk << 8; + HWREG16(UCS_BASE + OFS_UCSCTL5) |= divider_msk; + break; + case UCS_SMCLK: + HWREG16(UCS_BASE + OFS_UCSCTL4) &= ~SELS_7; + source_msk = source_msk << 4; + HWREG16(UCS_BASE + OFS_UCSCTL4) |= source_msk; + HWREG16(UCS_BASE + OFS_UCSCTL5) &= ~DIVS_7; + divider_msk = divider_msk << 4; + HWREG16(UCS_BASE + OFS_UCSCTL5) |= divider_msk; + break; + case UCS_MCLK: + HWREG16(UCS_BASE + OFS_UCSCTL4) &= ~SELM_7; + HWREG16(UCS_BASE + OFS_UCSCTL4) |= source_msk; + HWREG16(UCS_BASE + OFS_UCSCTL5) &= ~DIVM_7; + HWREG16(UCS_BASE + OFS_UCSCTL5) |= divider_msk; + break; + case UCS_FLLREF: + HWREG8(UCS_BASE + OFS_UCSCTL3) &= ~SELREF_7; + source_msk = source_msk << 4; + HWREG8(UCS_BASE + OFS_UCSCTL3) |= source_msk; + HWREG8(UCS_BASE + OFS_UCSCTL3) &= ~FLLREFDIV_7; + + switch (divider) { + case UCS_CLOCK_DIVIDER_12: + HWREG8(UCS_BASE + OFS_UCSCTL3) |= FLLREFDIV__12; + break; + case UCS_CLOCK_DIVIDER_16: + HWREG8(UCS_BASE + OFS_UCSCTL3) |= FLLREFDIV__16; + break; + default: + HWREG8(UCS_BASE + OFS_UCSCTL3) |= divider_msk; + break; + } + break; + default: + break; + } +} + +bool ucs_xt2_blocking_turn_on(uint16_t drive, uint16_t timeout) +{ + // Check if drive value is expected one. + if ((HWREG16(UCS_BASE + OFS_UCSCTL6) & XT2DRIVE_3) != drive) { + // Clear XT2 drive field. + HWREG16(UCS_BASE + OFS_UCSCTL6) &= ~XT2DRIVE_3; + HWREG16(UCS_BASE + OFS_UCSCTL6) |= drive; + } + + HWREG16(UCS_BASE + OFS_UCSCTL6) &= ~XT2BYPASS; + // Switch on XT2 oscillator. + HWREG16(UCS_BASE + OFS_UCSCTL6) &= ~XT2OFF; + + do { + // Clear OSC fault Flags. + HWREG8(UCS_BASE + OFS_UCSCTL7) &= ~XT2OFFG; + // Clear OFIFG fault flag. + HWREG8(SFR_BASE + OFS_SFRIFG1) &= ~OFIFG; + } while ((HWREG8(UCS_BASE + OFS_UCSCTL7) & XT2OFFG) && --timeout); + + return timeout > 0; +} + +void ucs_xt2_turn_off(void) +{ + HWREG16(UCS_BASE + OFS_UCSCTL6) |= XT2OFF; +} + +void ucs_fll_settle_init(uint16_t fsystem, uint16_t ratio) +{ + volatile uint16_t x = ratio * 32; + ucs_fll_init(fsystem, ratio); + while (x--) { + __delay_cycles(30); + } +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/ucs.h b/examples/baremetal/msp430f5529/nes-gamepads/ucs.h new file mode 100644 index 00000000..1741c37f --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/ucs.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_UCS_H +#define MSP430_UCS_H + +#ifdef __cplusplus +extern "C" { +#endif + +enum ucs_signal { + UCS_ACLK = 0x01, + UCS_MCLK = 0x02, + UCS_SMCLK = 0x04, + UCS_FLLREF = 0x08 +}; + +enum ucs_source { + UCS_XT1CLK_SELECT, + UCS_VLOCLK_SELECT, + UCS_REFOCLK_SELECT, + UCS_DCOCLK_SELECT, + UCS_DCOCLKDIV_SELECT, + UCS_XT2CLK_SELECT +}; + +enum ucs_divider { + UCS_CLOCK_DIVIDER_1, + UCS_CLOCK_DIVIDER_2, + UCS_CLOCK_DIVIDER_4, + UCS_CLOCK_DIVIDER_8, + UCS_CLOCK_DIVIDER_12, + UCS_CLOCK_DIVIDER_16, + UCS_CLOCK_DIVIDER_32 +}; + +enum ucs_fault_flag { + UCS_XT2OFFG, + UCS_XT1HFOFFG, + UCS_XT1LFOFFG, + UCS_DCOFFG +}; + +void ucs_clocks_init(void); + +void ucs_init(enum ucs_signal signal, + enum ucs_source source, + enum ucs_divider divider); + +bool ucs_xt2_blocking_turn_on(uint16_t drive, uint16_t timeout); + +void ucs_xt2_turn_off(void); +void ucs_fll_settle_init(uint16_t fsystem, uint16_t ratio); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_UCS_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/usb.c b/examples/baremetal/msp430f5529/nes-gamepads/usb.c new file mode 100644 index 00000000..2a648580 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/usb.c @@ -0,0 +1,317 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "hid.h" +#include "hwdefs.h" +#include "ucs.h" +#include "usb.h" + +static uint16_t usb_khz_freq_get(void) +{ + uint16_t freq = 0; + const uint8_t selm_curr = (UCSCTL4_L & SELM_7); + if (selm_curr <= 4) { + uint16_t fll_ref_freq = 33; // It is 32.768 kHz. + if ((UCSCTL3_L & SELREF_7) >= 0x50) + fll_ref_freq = (4.0) * 1000; + + uint16_t flln_curr = (UCSCTL2 & 0x03FF) + 1; + if (selm_curr == SELM_3) { + uint16_t flld_curr = (UCSCTL2 & FLLD_7); + flld_curr >>= 12; + flln_curr <<= flld_curr; + } + + const uint8_t fll_ref_div = (UCSCTL3_L & FLLREFDIV_7); + if (fll_ref_div == 0) + freq = flln_curr * (fll_ref_freq / 1); + else if (fll_ref_div == 1) + freq = flln_curr * (fll_ref_freq / 2); + else if (fll_ref_div == 2) + freq = flln_curr * (fll_ref_freq / 4); + else if (fll_ref_div == 3) + freq = flln_curr * (fll_ref_freq / 8); + else if (fll_ref_div == 4) + freq = flln_curr * (fll_ref_freq / 12); + else if (fll_ref_div == 5) + freq = flln_curr * (fll_ref_freq / 16); + } else { + freq = (4.0) * 1000; + } + return freq >> (UCSCTL5_L & DIVM_7); +} + +static uint16_t usb_delay_250us_get(void) +{ + const uint16_t mclk_freq = usb_khz_freq_get(); + const uint16_t delay_250us = ((mclk_freq >> 6) | (mclk_freq >> 7) + | (mclk_freq >> 9)); + return delay_250us; +} + +static void usb_cfg_access_allow(bool allow) +{ + enum { ALLOW_KEY = 0x9628, DENIED_KEY = 0x9600 }; + USBKEYPID = allow ? ALLOW_KEY : DENIED_KEY; +} + +static bool usb_pll_enable(void) +{ + if (!(USBPWRCTL & USBBGVBV)) + return false; + + if ((USBCNF & USB_EN) && (USBPLLCTL & UPLLEN)) + return true; + + gpio_pins_set_as_pf_out(GPIO_PORT_P5, GPIO_PIN2); + gpio_pins_set_as_pf_out(GPIO_PORT_P5, GPIO_PIN3); + + usb_cfg_access_allow(true); + + if (!ucs_xt2_blocking_turn_on(XT2DRIVE_0, 50000)) + return false; + + USBPLLDIVB = USBPLL_SETCLK_4_0; + USBPLLCTL = UPFDEN | UPLLEN; + + const uint16_t delay_250us = usb_delay_250us_get(); + uint8_t j = 0; + do { + USBPLLIR = 0; + for (uint8_t k = 0; k < 2; ++k) { + for (uint16_t i = 0; i < delay_250us; ++i) { + __no_operation(); + } + } + + if (j++ > 10) { + usb_cfg_access_allow(false); + return false; + } + } while (USBPLLIR != 0); + + USBCNF |= USB_EN; + usb_cfg_access_allow(false); + return true; +} + +static void usb_reset(void) +{ + usb_cfg_access_allow(true); + + hid_ep0_enumerated_set(false); + + USBCTL = 0; + USBFUNADR = 0; + USBOEPIE = 0; + USBIEPIE = 0; + + hid_ep0_init(); + hid_ep1_init(); + + USBCTL = FEN; + USBIFG = 0; + USBIE = SETUPIE | RSTRIE | SUSRIE; + usb_cfg_access_allow(false); +} + +static void usb_connect(void) +{ + usb_cfg_access_allow(true); + USBCNF |= PUR_EN; + USBPWRCTL |= VBOFFIE; + usb_cfg_access_allow(false); +} + +static void usb_pwr_vbus_wait(void) +{ + const uint16_t delay_250us = usb_delay_250us_get(); + for (uint8_t j = 0; j < 4; ++j) { + for (uint16_t i = 0; i < delay_250us; ++i) { + __no_operation(); + } + } +} + +static void usb_pwr_vbus_on_handler(void) +{ + usb_pwr_vbus_wait(); + + if (USBPWRCTL & USBBGVBV) { + usb_cfg_access_allow(true); + USBPWRCTL |= VBOFFIE; + USBPWRCTL &= ~ (VBONIFG + VBOFFIFG); + usb_cfg_access_allow(false); + } +} + +static void usb_pwr_vbus_off_handler(void) +{ + usb_pwr_vbus_wait(); + + if (!(USBPWRCTL & USBBGVBV)) { + usb_cfg_access_allow(true); + USBCNF = 0; + USBPLLCTL &= ~UPLLEN; + USBPWRCTL &= ~(VBOFFIE + VBOFFIFG + SLDOEN); + usb_cfg_access_allow(false); + } +} + +void usb_suspend(void) +{ + usb_cfg_access_allow(true); + USBCTL |= FRSTE; + USBIFG &= ~SUSRIFG; + USBPLLCTL &= ~UPLLEN; + ucs_xt2_turn_off(); + USBIE = RESRIE; + usb_cfg_access_allow(false); +} + +void usb_resume(void) +{ + usb_pll_enable(); + USBIFG &= ~(RESRIFG | SUSRIFG); + USBIE = SETUPIE | RSTRIE | SUSRIE; +} + +void usb_init(void) +{ + const uint16_t gie_backup = (__get_SR_register() & GIE); + + usb_cfg_access_allow(true); + USBPHYCTL = PUSEL; + USBPWRCTL = VUSBEN | SLDOAON; + + const uint16_t delay_250us = usb_delay_250us_get(); + for (uint8_t j = 0; j < 20; ++j) { + for (uint16_t i = 0; i < delay_250us; ++i) { + __no_operation(); + } + } + + USBPWRCTL |= VBONIE; + usb_cfg_access_allow(false); + + __bis_SR_register(gie_backup); + + if (USBPWRCTL & USBBGVBV) { + if (usb_pll_enable()) { + usb_reset(); + usb_connect(); + } + } +} + +void usb_task(void) +{ + hid_ep1_task(); +} + +INTERRUPT(usb_ubm_isr, USB_UBM_VECTOR) +{ + bool wake_up = false; + + if (USBIFG & SETUPIFG) { + hid_ep0_setup_handler(); + USBIFG &= ~SETUPIFG; + } + + switch (__even_in_range(USBVECINT & 0x3F, USBVECINT_OUTPUT_ENDPOINT7)) { + case USBVECINT_PWR_DROP: + __no_operation(); + break; + case USBVECINT_PLL_RANGE: + wake_up = true; + break; + case USBVECINT_PWR_VBUSOn: + usb_pwr_vbus_on_handler(); + if (usb_pll_enable()) { + usb_reset(); + usb_connect(); + } + wake_up = true; + break; + case USBVECINT_PWR_VBUSOff: + usb_pwr_vbus_off_handler(); + ucs_xt2_turn_off(); + wake_up = true; + break; + case USBVECINT_INPUT_ENDPOINT0: + hid_ep0_in_handler(); + break; + case USBVECINT_RSTR: + usb_reset(); + wake_up = true; + break; + case USBVECINT_SUSR: + usb_suspend(); + wake_up = true; + break; + case USBVECINT_RESR: + usb_resume(); + wake_up = true; + break; + case USBVECINT_SETUP_PACKET_RECEIVED: + hid_ep0_in_nak(); + hid_ep0_out_nak(); + hid_ep0_setup_handler(); + break; + default: + break; + } + + if (wake_up) { + __bic_SR_register_on_exit(LPM3_bits); + __no_operation(); + } +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/usb.h b/examples/baremetal/msp430f5529/nes-gamepads/usb.h new file mode 100644 index 00000000..503f3cf0 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/usb.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_USB_H +#define MSP430_USB_H + +#ifdef __cplusplus +extern "C" { +#endif + +enum usb_setup_bmreq_bits { + SETUP_DIR = 0x80, + SETUP_TYPE = 0x60, + SETUP_RECIPIENT = 0x1F +}; + +// Setup request direction. +enum usb_setup_req_direction_bits { + SETUP_OUTPUT = 0, // From host to device direction. + SETUP_INPUT = 0x80 // From device to host direction. +}; + +// Setup request type. +enum usb_setup_req_type_bits { + SETUP_STANDARD = 0, // Standard request. + SETUP_CLASS = 0x20, // Class request. + SETUP_VENDOR = 0x40 // Vendor request. +}; + +// Setup request recipient. +enum usb_setup_req_recipient_bits { + SETUP_DEVICE = 0, // Device recipient. + SETUP_IFACE = 0x01, // Interface recipient. + SETUP_EP = 0x02, // End point recipient. + SETUP_OTHER = 0x03 // Other recipient. +}; + +// Setup request code. +enum usb_setup_req_code { + SETUP_GET_STATUS = 0x00, // Get status code. + SETUP_CLEAR_FEATURE = 0x01, // Clear feature code. + SETUP_RESERVED1 = 0x02, // Reserved code. + SETUP_SET_FEATURE = 0x03, // Set feature code. + SETUP_RESERVED2 = 0x04, // Reserved code. + SETUP_SET_ADDRESS = 0x05, // Set address code. + SETUP_GET_DESCRIPTOR = 0x06, // Get descriptor code. + SETUP_SET_DESCRIPTOR = 0x07, // Set descriptor code. + SETUP_GET_CONFIGURATION = 0x08, // Get configuration code. + SETUP_SET_CONFIGURATION = 0x09, // Set configuration code. + SETUP_GET_INTERFACE = 0x0A, // Get interface code. + SETUP_SET_INTERFACE = 0x0B, // Set interface code. + SETUP_SYNC_FRAME = 0x0C, // Sync frame code. + SETUP_ANCHOR_LOAD = 0xA0 // Anchor load code. +}; + +// Standard status responses. +enum usb_setup_status_code { + STATUS_SELF_POWERED = 0x01, + STATUS_REMOTE_WAKEUP = 0x02 +}; + +// Standard feature selectors. +enum usb_setup_feature_selector { + FEATURE_STALL = 0x00, + FEATURE_REMOTE_WAKEUP = 0x01, + FEATURE_TEST_MODE = 0x02 +}; + +// Get descriptor codes. +enum usb_setup_get_descriptor_code { + DESC_DEVICE = 0x01, // Device descriptor. + DESC_CONF = 0x02, // Configuration descriptor. + DESC_STRING = 0x03, // String descriptor. + DESC_INTERFACE = 0x04, // Interface descriptor. + DESC_ENDPOINT = 0x05, // End point descriptor. + DESC_DEVICE_QUAL = 0x06, // Device qualifier descriptor. + DESC_OTHER_SPEED_CONF = 0x07, // Other configuration descriptor. + DESC_INTERFACE_POWER = 0x08, // Interface power descriptor. + DESC_OTG = 0x09, // OTG descriptor. + DESC_DEBUG = 0x0A, // Debug descriptor. + DESC_INTERFACE_ASSOC = 0x0B, // Interface association descriptor. + DESC_HID = 0x21, // Get HID descriptor. + DESC_REPORT = 0x22 // Get report descriptor. +}; + + +enum usb_ep_size { + EP0_MAX_PACKET_SIZE = 8, + EP_MAX_PACKET_SIZE = 64, + EP_MAX_FIFO_SIZE = 256, + EP_NO_MORE_DATA = 0xFFFF +}; + +void usb_init(void); +void usb_task(void); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_USB_H diff --git a/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.c b/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.c new file mode 100644 index 00000000..5adf3c36 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.c @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "hwdefs.h" +#include "wdt_a.h" + +#define WDT_CONTROL_ADDRESS (WDT_A_BASE + OFS_WDTCTL) + +void wdt_a_stop(void) +{ + const uint8_t st = (HWREG16(WDT_CONTROL_ADDRESS) & 0x00FF) | WDTHOLD; + HWREG16(WDT_CONTROL_ADDRESS) = WDTPW + st; +} diff --git a/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.h b/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.h new file mode 100644 index 00000000..3a5e5b40 --- /dev/null +++ b/examples/baremetal/msp430f5529/nes-gamepads/wdt_a.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MSP430_WDT_A_H +#define MSP430_WDT_A_H + +#ifdef __cplusplus +extern "C" { +#endif + +void wdt_a_stop(void); + +#ifdef __cplusplus +} +#endif + +#endif // MSP430_WDT_A_H diff --git a/examples/baremetal/msp430f5529/redblink/README.md b/examples/baremetal/msp430f5529/redblink/README.md new file mode 100644 index 00000000..2f63b234 --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/README.md @@ -0,0 +1,9 @@ +This example demonstrates how to build a bare-metal application using +different MSP430 toolchains. It is designed for the MSP-EXP430F5529LP +target board (based on msp430f5529 chip) and simply flashes the red +LED on the board. + +The following toolchains are supported: + + * IAR Embedded Workbench + * GCC diff --git a/examples/baremetal/msp430f5529/redblink/gpio.c b/examples/baremetal/msp430f5529/redblink/gpio.c new file mode 100644 index 00000000..3e7f181a --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/gpio.c @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#if defined(__ICC430__) +#include +#elif defined(__GNUC__) +#include +#else +#error "Unsupported toolchain" +#endif + +// LED pin number. +#define GPIO_RED_LED_PIN_POS (0u) +// LED port direction. +#define GPIO_RED_LED_PORT_DIR (P1DIR) +// LED output port. +#define GPIO_RED_LED_PORT_OUT (P1OUT) + +void gpio_init_red_led(void) +{ + GPIO_RED_LED_PORT_DIR |= (1u << GPIO_RED_LED_PIN_POS); +} + +void gpio_toggle_red_led(void) +{ + GPIO_RED_LED_PORT_OUT ^= (1u << GPIO_RED_LED_PIN_POS); +} diff --git a/examples/baremetal/msp430f5529/redblink/gpio.h b/examples/baremetal/msp430f5529/redblink/gpio.h new file mode 100644 index 00000000..246eab86 --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_red_led(void); +void gpio_toggle_red_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/msp430f5529/redblink/main.c b/examples/baremetal/msp430f5529/redblink/main.c new file mode 100644 index 00000000..f1ad54ad --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/main.c @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + system_init(); + + gpio_init_red_led(); + + while (1) { + gpio_toggle_red_led(); + some_delay(10000u); + } +} diff --git a/examples/baremetal/msp430f5529/redblink/redblink.qbs b/examples/baremetal/msp430f5529/redblink/redblink.qbs new file mode 100644 index 00000000..d89d307a --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/redblink.qbs @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("msp430")) + return false; + return qbs.toolchain.contains("iar") + || qbs.toolchain.contains("gcc") + } + name: "msp430f5529-redblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.driverFlags: ["--core=430X"] + cpp.entryPoint: "__program_start" + cpp.driverLinkerFlags: [ + "-D_STACK_SIZE=A0", + "-D_DATA16_HEAP_SIZE=A0", + "-D_DATA20_HEAP_SIZE=50", + ] + cpp.staticLibraries: [ + // Explicitly link with the runtime dlib library (which contains + // all required startup code and other stuff). + cpp.toolchainInstallPath + "/../lib/dlib/dl430xlsfn.r43" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Linker Script" + prefix: cpp.toolchainInstallPath + "/../config/linker/" + fileTags: ["linkerscript"] + // Explicitly use the default linker scripts for current target. + files: ["lnk430f5529.xcl", "multiplier32.xcl"] + } + } + + // + // GCC-specific properties and soucres. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + property path supportFilesPath + // A path to the MSP430 support files, which are + // provided by the Texas Instruments separately: + // e.g. 'c:/msp430-gcc-support-files/include/' + cpp.includePaths: supportFilesPath + cpp.libraryPaths: supportFilesPath + cpp.driverFlags: ["-mmcu=msp430f5529"] + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.c", "system.h"] + } + + files: [ + "main.c", + ] +} diff --git a/examples/baremetal/msp430f5529/redblink/system.c b/examples/baremetal/msp430f5529/redblink/system.c new file mode 100644 index 00000000..0e0e6901 --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/system.c @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "system.h" + +#if defined(__ICC430__) +#include +#elif defined(__GNUC__) +#include +#else +#error "Unsupported toolchain" +#endif + +void system_init(void) +{ + // Stop watchdog timer. + WDTCTL = WDTPW + WDTHOLD; +} diff --git a/examples/baremetal/msp430f5529/redblink/system.h b/examples/baremetal/msp430f5529/redblink/system.h new file mode 100644 index 00000000..468ef108 --- /dev/null +++ b/examples/baremetal/msp430f5529/redblink/system.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +void system_init(void); + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/pca10001/greenblink/README.md b/examples/baremetal/pca10001/greenblink/README.md new file mode 100644 index 00000000..0abfa46e --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/README.md @@ -0,0 +1,10 @@ +This example demonstrates how to build a bare-metal application using +different ARM toolchains. It is designed for the Nordic pca100001/pca100024 +evaluation kit (based on nRF51822 MCU) and simply flashes the green +LED on the board. + +The following toolchains are supported: + + * GNU Arm Embedded Toolchain + * IAR Embedded Workbench + * KEIL Microcontroller Development Kit diff --git a/examples/baremetal/pca10001/greenblink/gcc/flash.ld b/examples/baremetal/pca10001/greenblink/gcc/flash.ld new file mode 100644 index 00000000..d65ee146 --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/gcc/flash.ld @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +ENTRY(reset_handler) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x40000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 +} + +SECTIONS { + .text : { + KEEP(*(.isr_vector)) + *(.text*) + KEEP(*(.init)) + KEEP(*(.fini)) + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + *(.rodata*) + *(.eh_frame*) + . = ALIGN(4); + } > FLASH + + .ARM.extab : { + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } > FLASH + + _start_of_exidx_section = .; + .ARM.exidx : { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + . = ALIGN(4); + } > FLASH + _end_of_exidx_section = .; + + _end_of_code_section = .; + + .data : AT (_end_of_code_section) { + _start_of_data_section = .; + *(vtable) + *(.data*) + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN(__preinit_array_start = .); + *(.preinit_array) + PROVIDE_HIDDEN(__preinit_array_end = .); + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN(__init_array_start = .); + *(SORT(.init_array.*)) + *(.init_array) + PROVIDE_HIDDEN(__init_array_end = .); + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN(__fini_array_start = .); + *(SORT(.fini_array.*)) + *(.fini_array) + PROVIDE_HIDDEN(__fini_array_end = .); + *(.jcr) + . = ALIGN(4); + /* All data end */ + _end_of_data_section = .; + } > RAM + + .bss : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): { + __end__ = .; + end = __end__; + *(.heap*) + _heap_limit = .; + } > RAM + + .stack_dummy (COPY): { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by size of stack_dummy section. */ + _end_of_stack = ORIGIN(RAM) + LENGTH(RAM); + _stack_limit = _end_of_stack - SIZEOF(.stack_dummy); + PROVIDE(__stack = _end_of_stack); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(_stack_limit >= _heap_limit, "region RAM overflowed with stack") +} diff --git a/examples/baremetal/pca10001/greenblink/gcc/startup.s b/examples/baremetal/pca10001/greenblink/gcc/startup.s new file mode 100644 index 00000000..ec433ac0 --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/gcc/startup.s @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +.syntax unified +.arch armv7e-m +.thumb + +// Define the stack. +.section .stack +.align 3 +.equ _size_of_stack, 2048 +.globl _end_of_stack +.globl _stack_limit +_stack_limit: +.space _size_of_stack +.size _stack_limit, . - _stack_limit +_end_of_stack: +.size _end_of_stack, . - _end_of_stack + +// Define the heap. +.section .heap +.align 3 +.equ _size_of_heap, 2048 +.globl _end_of_heap +.globl _heap_limit +_end_of_heap: +.space _size_of_heap +.size _end_of_heap, . - _end_of_heap +_heap_limit: +.size _heap_limit, . - _heap_limit + +// Define the empty vectors table. +.section .isr_vector, "ax" +.align 2 +.globl _vectors_table +_vectors_table: + // Generic interrupts offset. + .word _end_of_stack // Initial stack pointer value. + .word reset_handler // Reset. + .word 0 // NMI. + .word 0 // Hard fault. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // SVC. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // PendSV. + .word 0 // SysTick. + + // External interrupts offset. + .word 0 // POWER CLOCK. + .word 0 // RADIO. + .word 0 // UART0 + .word 0 // SPI0/TWI0. + .word 0 // SPI1/TWI1. + .word 0 // Reserved. + .word 0 // GPIOTE. + .word 0 // ADC. + .word 0 // TIMER0. + .word 0 // TIMER1. + .word 0 // TIMER2. + .word 0 // RTC0. + .word 0 // TEMP. + .word 0 // RNG. + .word 0 // ECB. + .word 0 // CCM_AAR. + .word 0 // WDT. + .word 0 // RTC1. + .word 0 // QDEC. + .word 0 // LPCOMP. + .word 0 // SWI0. + .word 0 // SWI1. + .word 0 // SWI2. + .word 0 // SWI3. + .word 0 // SWI4. + .word 0 // SWI5. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. +.size _vectors_table, . - _vectors_table + +// Define the 'reset_handler' function, which is an entry point. +.text +.thumb +.thumb_func +.align 1 +.globl reset_handler +.type reset_handler, %function +reset_handler: + // Loop to copy data from read only memory to RAM. + ldr r1, =_end_of_code_section + ldr r2, =_start_of_data_section + ldr r3, =__bss_start__ + subs r3, r3, r2 + ble _copy_data_init_done +_copy_data_init: + subs r3, r3, #4 + ldr r0, [r1,r3] + str r0, [r2,r3] + bgt _copy_data_init +_copy_data_init_done: + // Zero fill the bss segment. + ldr r1, =__bss_start__ + ldr r2, =__bss_end__ + movs r0, 0 + subs r2, r2, r1 + ble _loop_fill_zero_bss_done + +_loop_fill_zero_bss: + subs r2, r2, #4 + str r0, [r1, r2] + bgt _loop_fill_zero_bss + +_loop_fill_zero_bss_done: + // Call the application's entry point. + bl main + bx lr +.size reset_handler, . - reset_handler diff --git a/examples/baremetal/pca10001/greenblink/gpio.c b/examples/baremetal/pca10001/greenblink/gpio.c new file mode 100644 index 00000000..5fc910e5 --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/gpio.c @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#define GPIO_GREEN_LED_PIN_POS (18u) +#define GPIO_GREEN_LED_PIN (1u << GPIO_GREEN_LED_PIN_POS) + +// Pin direction attributes. +#define GPIO_PIN_CNF_DIR_POS (0u) // Position of DIR field. +#define GPIO_PIN_CNF_DIR_OUT (1u) // Configure pin as an output pin. +#define GPIO_PIN_CNF_DIR_MSK (GPIO_PIN_CNF_DIR_OUT << GPIO_PIN_CNF_DIR_POS) + +// Pin input buffer attributes. +#define GPIO_PIN_CNF_INPUT_POS (1u) // Position of INPUT field. +#define GPIO_PIN_CNF_INPUT_OFF (1u) // Disconnect input buffer. +#define GPIO_PIN_CNF_INPUT_MSK (GPIO_PIN_CNF_INPUT_OFF << GPIO_PIN_CNF_INPUT_POS) + +// Pin pull attributes. +#define GPIO_PIN_CNF_PULL_POS (2u) // Position of PULL field. +#define GPIO_PIN_CNF_PULL_OFF (0u) // No pull. +#define GPIO_PIN_CNF_PULL_MSK (GPIO_PIN_CNF_PULL_OFF << GPIO_PIN_CNF_PULL_POS) + +// Pin drive attributes. +#define GPIO_PIN_CNF_DRIVE_POS (8u) // Position of DRIVE field. +#define GPIO_PIN_CNF_DRIVE_S0S1 (0u) // Standard '0', standard '1'. +#define GPIO_PIN_CNF_DRIVE_MSK (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_POS) + +// Pin sense attributes. +#define GPIO_PIN_CNF_SENSE_POS (16u) // Position of SENSE field. +#define GPIO_PIN_CNF_SENSE_OFF (0u) // Disabled. +#define GPIO_PIN_CNF_SENSE_MSK (GPIO_PIN_CNF_SENSE_OFF << GPIO_PIN_CNF_SENSE_POS) + +void gpio_init_green_led(void) +{ + GPIOD_REGS_MAP->PIN_CNF[GPIO_GREEN_LED_PIN_POS] = (GPIO_PIN_CNF_DIR_MSK + | GPIO_PIN_CNF_INPUT_MSK + | GPIO_PIN_CNF_PULL_MSK + | GPIO_PIN_CNF_DRIVE_MSK + | GPIO_PIN_CNF_SENSE_MSK); +} + +void gpio_toggle_green_led(void) +{ + const uint32_t gpio_state = GPIOD_REGS_MAP->OUT; + GPIOD_REGS_MAP->OUTSET = (GPIO_GREEN_LED_PIN & ~gpio_state); + GPIOD_REGS_MAP->OUTCLR = (GPIO_GREEN_LED_PIN & gpio_state); +} diff --git a/examples/baremetal/pca10001/greenblink/gpio.h b/examples/baremetal/pca10001/greenblink/gpio.h new file mode 100644 index 00000000..9e931b71 --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_green_led(void); +void gpio_toggle_green_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/pca10001/greenblink/greenblink.qbs b/examples/baremetal/pca10001/greenblink/greenblink.qbs new file mode 100644 index 00000000..1a4dabde --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/greenblink.qbs @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.startsWith("arm")) + return false; + return (qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil")) + && !qbs.toolchain.contains("xcode") + } + name: "pca10001-greenblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // GCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.assemblerFlags: [ + "-mcpu=cortex-m0", + ] + cpp.driverFlags: [ + "-mcpu=cortex-m0", + "-specs=nosys.specs" + ] + } + + Group { + condition: qbs.toolchain.contains("gcc") + name: "GCC" + prefix: "gcc/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.ld"] + } + } + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.assemblerFlags: [ + "--cpu", "cortex-m0" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m0" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.icf"] + } + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.assemblerFlags: [ + "--cpu", "cortex-m0" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m0" + ] + } + + Group { + condition: qbs.toolchain.contains("keil") + name: "KEIL" + prefix: "keil/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.sct"] + } + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/pca10001/greenblink/iar/flash.icf b/examples/baremetal/pca10001/greenblink/iar/flash.icf new file mode 100644 index 00000000..8d1ef63f --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/iar/flash.icf @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +define symbol _start_of_intvec_section = 0x00000000; + +define symbol _start_of_ram_section = 0x20000000; +define symbol _end_of_ram_section = 0x20003FFF; +define symbol _start_of_flash_section = 0x00000000; +define symbol _end_of_flash_section = 0x0003FFFF; + +define symbol _min_stack_size = 0x800; +define symbol _min_heap_size = 0x800; + +define memory mem with size = 4G; +define region flash_section = mem:[from _start_of_flash_section to _end_of_flash_section]; +define region ram_section = mem:[from _start_of_ram_section to _end_of_ram_section]; + +define block CSTACK with alignment = 8, size = _min_stack_size { }; +define block HEAP with alignment = 8, size = _min_heap_size { }; + +initialize by copy { readwrite }; + +place at address mem:_start_of_intvec_section { readonly section .intvec }; + +place in flash_section { readonly }; +place in ram_section { readwrite, block CSTACK, block HEAP }; diff --git a/examples/baremetal/pca10001/greenblink/iar/startup.s b/examples/baremetal/pca10001/greenblink/iar/startup.s new file mode 100644 index 00000000..d8041c5c --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/iar/startup.s @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + + MODULE ?cstartup + + SECTION CSTACK:DATA:NOROOT(3) + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + + PUBLIC _vectors_table + DATA + +_vectors_table + ;; Generic interrupts offset. + DCD sfe(CSTACK) ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Power clock. + DCD 0 ; Radio. + DCD 0 ; UART0. + DCD 0 ; SPI0/TWI0 + DCD 0 ; SPI1/TWI1 + DCD 0 ; Reserved + DCD 0 ; GPIOTE + DCD 0 ; ADC + DCD 0 ; TIMER0 + DCD 0 ; TIMER1 + DCD 0 ; TIMER2 + DCD 0 ; RTC0 + DCD 0 ; TEMP + DCD 0 ; RNG + DCD 0 ; ECB + DCD 0 ; CCM/AAR + DCD 0 ; WDT + DCD 0 ; RTC1 + DCD 0 ; QDEC + DCD 0 ; LPCOMP + DCD 0 ; SWI0 + DCD 0 ; SWI1 + DCD 0 ; SWI2 + DCD 0 ; SWI3 + DCD 0 ; SWI4 + DCD 0 ; SWI5 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + + ;; Reset handler. + THUMB + PUBWEAK reset_handler + SECTION .text:CODE:REORDER:NOROOT(2) +reset_handler + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + END + + diff --git a/examples/baremetal/pca10001/greenblink/keil/flash.sct b/examples/baremetal/pca10001/greenblink/keil/flash.sct new file mode 100644 index 00000000..6d5a1e42 --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/keil/flash.sct @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +;; Load region size_region. +LR_IROM1 0x00000000 0x00040000 { + ;; Load address = execution address. + ER_IROM1 0x00000000 0x00040000 { + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + + ; RW data. + RW_IRAM1 0x20000000 0x00004000 { + .ANY (+RW +ZI) + } +} diff --git a/examples/baremetal/pca10001/greenblink/keil/startup.s b/examples/baremetal/pca10001/greenblink/keil/startup.s new file mode 100644 index 00000000..4b63519d --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/keil/startup.s @@ -0,0 +1,134 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) 2020 Denis Shienkov +;; Contact: https://www.qt.io/licensing/ +;; +;; This file is part of the examples of Qbs. +;; +;; $QT_BEGIN_LICENSE:BSD$ +;; Commercial License Usage +;; Licensees holding valid commercial Qt licenses may use this file in +;; accordance with the commercial license agreement provided with the +;; Software or, alternatively, in accordance with the terms contained in +;; a written agreement between you and The Qt Company. For licensing terms +;; and conditions see https://www.qt.io/terms-conditions. For further +;; information use the contact form at https://www.qt.io/contact-us. +;; +;; BSD License Usage +;; Alternatively, 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$ +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +_size_of_stack EQU 0x800 +_size_of_heap EQU 0x800 + +;; Stack configuration. + AREA STACK, NOINIT, READWRITE, ALIGN=3 +_start_of_stack SPACE _size_of_stack +_end_of_stack + +;; Heap configuration. + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +_start_of_heap SPACE _size_of_heap +_end_of_heap + + PRESERVE8 + THUMB + +;; Define the empty vectors table. + AREA RESET, DATA, READONLY +_vectors_table + ;; Generic interrupts offset. + DCD _end_of_stack ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Power clock. + DCD 0 ; Radio. + DCD 0 ; UART0. + DCD 0 ; SPI0/TWI0 + DCD 0 ; SPI1/TWI1 + DCD 0 ; Reserved + DCD 0 ; GPIOTE + DCD 0 ; ADC + DCD 0 ; TIMER0 + DCD 0 ; TIMER1 + DCD 0 ; TIMER2 + DCD 0 ; RTC0 + DCD 0 ; TEMP + DCD 0 ; RNG + DCD 0 ; ECB + DCD 0 ; CCM/AAR + DCD 0 ; WDT + DCD 0 ; RTC1 + DCD 0 ; QDEC + DCD 0 ; LPCOMP + DCD 0 ; SWI0 + DCD 0 ; SWI1 + DCD 0 ; SWI2 + DCD 0 ; SWI3 + DCD 0 ; SWI4 + DCD 0 ; SWI5 + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved +_end_of_vectors_table + +_size_of_vectors_table EQU _end_of_vectors_table - _vectors_table + + AREA |.text|, CODE, READONLY +;; Reset handler. +reset_handler PROC + EXPORT reset_handler [WEAK] + IMPORT main + LDR R0, =main + BX R0 + ENDP + ALIGN + + END diff --git a/examples/baremetal/pca10001/greenblink/main.c b/examples/baremetal/pca10001/greenblink/main.c new file mode 100644 index 00000000..89d3daeb --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + gpio_init_green_led(); + + while (1) { + gpio_toggle_green_led(); + some_delay(1000000u); + } +} diff --git a/examples/baremetal/pca10001/greenblink/system.h b/examples/baremetal/pca10001/greenblink/system.h new file mode 100644 index 00000000..37e6ad8e --- /dev/null +++ b/examples/baremetal/pca10001/greenblink/system.h @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define __IO volatile + +struct gpio_regs_map { + uint32_t RESERVED0[321u]; + __IO uint32_t OUT; + __IO uint32_t OUTSET; + __IO uint32_t OUTCLR; + __IO uint32_t IN; + __IO uint32_t DIR; + __IO uint32_t DIRSET; + __IO uint32_t DIRCLR; + uint32_t RESERVED1[120u]; + __IO uint32_t PIN_CNF[32u]; +}; + +#define GPIO_REGS_ADDRESS (0x50000000u) +#define GPIOD_REGS_MAP ((struct gpio_regs_map *)GPIO_REGS_ADDRESS) + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/pca10001/pca10001.qbs b/examples/baremetal/pca10001/pca10001.qbs new file mode 100644 index 00000000..db130326 --- /dev/null +++ b/examples/baremetal/pca10001/pca10001.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for pca10001/pca10024 boards" + references: [ + "greenblink/greenblink.qbs" + ] +} diff --git a/examples/baremetal/pca10040/greenblink/README.md b/examples/baremetal/pca10040/greenblink/README.md new file mode 100644 index 00000000..7d759839 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/README.md @@ -0,0 +1,10 @@ +This example demonstrates how to build a bare-metal application using +different ARM toolchains. It is designed for the Nordic pca10040 +evaluation kit (based on nRF52832 MCU) and simply flashes the green +LED on the board. + +The following toolchains are supported: + + * GNU Arm Embedded Toolchain + * IAR Embedded Workbench + * KEIL Microcontroller Development Kit diff --git a/examples/baremetal/pca10040/greenblink/gcc/flash.ld b/examples/baremetal/pca10040/greenblink/gcc/flash.ld new file mode 100644 index 00000000..b998618a --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/gcc/flash.ld @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +ENTRY(reset_handler) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x80000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000 + CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x10000 +} + +SECTIONS { + .text : { + KEEP(*(.isr_vector)) + *(.text*) + KEEP(*(.init)) + KEEP(*(.fini)) + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + *(.rodata*) + *(.eh_frame*) + . = ALIGN(4); + } > FLASH + + .ARM.extab : { + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } > FLASH + + _start_of_exidx_section = .; + .ARM.exidx : { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + . = ALIGN(4); + } > FLASH + _end_of_exidx_section = .; + + _end_of_code_section = .; + + .data : AT (_end_of_code_section) { + _start_of_data_section = .; + *(vtable) + *(.data*) + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN(__preinit_array_start = .); + *(.preinit_array) + PROVIDE_HIDDEN(__preinit_array_end = .); + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN(__init_array_start = .); + *(SORT(.init_array.*)) + *(.init_array) + PROVIDE_HIDDEN(__init_array_end = .); + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN(__fini_array_start = .); + *(SORT(.fini_array.*)) + *(.fini_array) + PROVIDE_HIDDEN(__fini_array_end = .); + *(.jcr) + . = ALIGN(4); + /* All data end */ + _end_of_data_section = .; + } > RAM + + .bss : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + .heap (COPY): { + __end__ = .; + end = __end__; + *(.heap*) + _heap_limit = .; + } > RAM + + .stack_dummy (COPY): { + *(.stack*) + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by size of stack_dummy section. */ + _end_of_stack = ORIGIN(RAM) + LENGTH(RAM); + _stack_limit = _end_of_stack - SIZEOF(.stack_dummy); + PROVIDE(__stack = _end_of_stack); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(_stack_limit >= _heap_limit, "region RAM overflowed with stack") +} diff --git a/examples/baremetal/pca10040/greenblink/gcc/startup.s b/examples/baremetal/pca10040/greenblink/gcc/startup.s new file mode 100644 index 00000000..d1fe7e9d --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/gcc/startup.s @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +.syntax unified +.arch armv7e-m +.thumb + +// Define the stack. +.section .stack +.align 3 +.equ _size_of_stack, 8192 +.globl _end_of_stack +.globl _stack_limit +_stack_limit: +.space _size_of_stack +.size _stack_limit, . - _stack_limit +_end_of_stack: +.size _end_of_stack, . - _end_of_stack + +// Define the heap. +.section .heap +.align 3 +.equ _size_of_heap, 8192 +.globl _end_of_heap +.globl _heap_limit +_end_of_heap: +.space _size_of_heap +.size _end_of_heap, . - _end_of_heap +_heap_limit: +.size _heap_limit, . - _heap_limit + +// Define the empty vectors table. +.section .isr_vector, "ax" +.align 2 +.globl _vectors_table +_vectors_table: + // Generic interrupts offset. + .word _end_of_stack // Initial stack pointer value. + .word reset_handler // Reset. + .word 0 // NMI. + .word 0 // Hard fault. + .word 0 // Memory management fault. + .word 0 // Bus fault. + .word 0 // Usage fault. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // SVC. + .word 0 // Debug monitor. + .word 0 // Reserved. + .word 0 // PendSV. + .word 0 // SysTick. + + // External interrupts offset. + .word 0 // POWER CLOCK. + .word 0 // RADIO. + .word 0 // UARTE0/UART0 + .word 0 // SPIM0/SPIS0/TWIM0/TWIS0/SPI0/TWI0. + .word 0 // SPIM1/SPIS1/TWIM1/TWIS1/SPI1/TWI1. + .word 0 // NFCT. + .word 0 // GPIOTE. + .word 0 // SAADC. + .word 0 // TIMER0. + .word 0 // TIMER1. + .word 0 // TIMER2. + .word 0 // RTC0. + .word 0 // TEMP. + .word 0 // RNG. + .word 0 // ECB. + .word 0 // CCM_AAR. + .word 0 // WDT. + .word 0 // RTC1. + .word 0 // QDEC. + .word 0 // COMP_LPCOMP. + .word 0 // SWI0_EGU0. + .word 0 // SWI1_EGU1. + .word 0 // SWI2_EGU2. + .word 0 // SWI3_EGU3. + .word 0 // SWI4_EGU4. + .word 0 // SWI5_EGU5. + .word 0 // TIMER3. + .word 0 // TIMER4. + .word 0 // PWM0. + .word 0 // PDM. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // MWU. + .word 0 // PWM1. + .word 0 // PWM2. + .word 0 // SPIM2/SPIS2/SPI2. + .word 0 // RTC2. + .word 0 // I2S. + .word 0 // FPU. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. +.size _vectors_table, . - _vectors_table + +// Define the 'reset_handler' function, which is an entry point. +.text +.thumb +.thumb_func +.align 1 +.globl reset_handler +.type reset_handler, %function +reset_handler: + // Loop to copy data from read only memory to RAM. + ldr r1, =_end_of_code_section + ldr r2, =_start_of_data_section + ldr r3, =__bss_start__ + subs r3, r3, r2 + ble _copy_data_init_done +_copy_data_init: + subs r3, r3, #4 + ldr r0, [r1,r3] + str r0, [r2,r3] + bgt _copy_data_init +_copy_data_init_done: + // Zero fill the bss segment. + ldr r1, =__bss_start__ + ldr r2, =__bss_end__ + movs r0, 0 + subs r2, r2, r1 + ble _loop_fill_zero_bss_done + +_loop_fill_zero_bss: + subs r2, r2, #4 + str r0, [r1, r2] + bgt _loop_fill_zero_bss + +_loop_fill_zero_bss_done: + // Call the application's entry point. + bl main + bx lr +.size reset_handler, . - reset_handler diff --git a/examples/baremetal/pca10040/greenblink/gpio.c b/examples/baremetal/pca10040/greenblink/gpio.c new file mode 100644 index 00000000..c86f6ac5 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/gpio.c @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#define GPIO_GREEN_LED_PIN_POS (17u) +#define GPIO_GREEN_LED_PIN (1u << GPIO_GREEN_LED_PIN_POS) + +// Pin direction attributes. +#define GPIO_PIN_CNF_DIR_POS (0u) // Position of DIR field. +#define GPIO_PIN_CNF_DIR_OUT (1u) // Configure pin as an output pin. +#define GPIO_PIN_CNF_DIR_MSK (GPIO_PIN_CNF_DIR_OUT << GPIO_PIN_CNF_DIR_POS) + +// Pin input buffer attributes. +#define GPIO_PIN_CNF_INPUT_POS (1u) // Position of INPUT field. +#define GPIO_PIN_CNF_INPUT_OFF (1u) // Disconnect input buffer. +#define GPIO_PIN_CNF_INPUT_MSK (GPIO_PIN_CNF_INPUT_OFF << GPIO_PIN_CNF_INPUT_POS) + +// Pin pull attributes. +#define GPIO_PIN_CNF_PULL_POS (2u) // Position of PULL field. +#define GPIO_PIN_CNF_PULL_OFF (0u) // No pull. +#define GPIO_PIN_CNF_PULL_MSK (GPIO_PIN_CNF_PULL_OFF << GPIO_PIN_CNF_PULL_POS) + +// Pin drive attributes. +#define GPIO_PIN_CNF_DRIVE_POS (8u) // Position of DRIVE field. +#define GPIO_PIN_CNF_DRIVE_S0S1 (0u) // Standard '0', standard '1'. +#define GPIO_PIN_CNF_DRIVE_MSK (GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_POS) + +// Pin sense attributes. +#define GPIO_PIN_CNF_SENSE_POS (16u) // Position of SENSE field. +#define GPIO_PIN_CNF_SENSE_OFF (0u) // Disabled. +#define GPIO_PIN_CNF_SENSE_MSK (GPIO_PIN_CNF_SENSE_OFF << GPIO_PIN_CNF_SENSE_POS) + +void gpio_init_green_led(void) +{ + GPIOD_REGS_MAP->PIN_CNF[GPIO_GREEN_LED_PIN_POS] = (GPIO_PIN_CNF_DIR_MSK + | GPIO_PIN_CNF_INPUT_MSK + | GPIO_PIN_CNF_PULL_MSK + | GPIO_PIN_CNF_DRIVE_MSK + | GPIO_PIN_CNF_SENSE_MSK); +} + +void gpio_toggle_green_led(void) +{ + const uint32_t gpio_state = GPIOD_REGS_MAP->OUT; + GPIOD_REGS_MAP->OUTSET = (GPIO_GREEN_LED_PIN & ~gpio_state); + GPIOD_REGS_MAP->OUTCLR = (GPIO_GREEN_LED_PIN & gpio_state); +} diff --git a/examples/baremetal/pca10040/greenblink/gpio.h b/examples/baremetal/pca10040/greenblink/gpio.h new file mode 100644 index 00000000..9e931b71 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_green_led(void); +void gpio_toggle_green_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/pca10040/greenblink/greenblink.qbs b/examples/baremetal/pca10040/greenblink/greenblink.qbs new file mode 100644 index 00000000..2ae3dc2a --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/greenblink.qbs @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.startsWith("arm")) + return false; + return (qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil")) + && !qbs.toolchain.contains("xcode") + } + name: "pca10040-greenblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // GCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.assemblerFlags: [ + "-mcpu=cortex-m4", + "-mfloat-abi=hard", + "-mfpu=fpv4-sp-d16", + ] + cpp.driverFlags: [ + "-mcpu=cortex-m4", + "-mfloat-abi=hard", + "-mfpu=fpv4-sp-d16", + "-specs=nosys.specs" + ] + } + + Group { + condition: qbs.toolchain.contains("gcc") + name: "GCC" + prefix: "gcc/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.ld"] + } + } + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.assemblerFlags: [ + "--cpu", "cortex-m4", + "--fpu", "vfpv4_sp" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m4", + "--fpu", "vfpv4_sp" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.icf"] + } + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.assemblerFlags: [ + "--cpu", "cortex-m4.fp.sp" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m4.fp.sp" + ] + } + + Group { + condition: qbs.toolchain.contains("keil") + name: "KEIL" + prefix: "keil/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.sct"] + } + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/pca10040/greenblink/iar/flash.icf b/examples/baremetal/pca10040/greenblink/iar/flash.icf new file mode 100644 index 00000000..d1964029 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/iar/flash.icf @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +define symbol _start_of_intvec_section = 0x00000000; + +define symbol _start_of_irom1_section = 0x00000000; +define symbol _end_of_irom1_section = 0x0007FFFF; +define symbol _start_of_irom2_section = 0x0; +define symbol _end_of_irom2_section = 0x0; +define symbol _start_of_erom1_section = 0x0; +define symbol _end_of_erom1_section = 0x0; +define symbol _start_of_erom2_section = 0x0; +define symbol _end_of_erom2_section = 0x0; +define symbol _start_of_erom3_section = 0x0; +define symbol _end_of_erom3_section = 0x0; +define symbol _start_of_iram1_section = 0x20000000; +define symbol _end_of_iram1_section = 0x2000FFFF; +define symbol _start_of_iram2_section = 0x0; +define symbol _end_of_iram2_section = 0x0; +define symbol _start_of_eram1_section = 0x0; +define symbol _end_of_eram1_section = 0x0; +define symbol _start_of_eram2_section = 0x0; +define symbol _end_of_eram2_section = 0x0; +define symbol _start_of_eram3_section = 0x0; +define symbol _end_of_eram3_section = 0x0; + +define symbol _min_stack_size = 0x2000; +define symbol _min_proc_stack_size = 0x0; +define symbol _min_heap_size = 0x2000; + +define memory mem with size = 4G; +define region irom_section = mem:[from _start_of_irom1_section to _end_of_irom1_section] + | mem:[from _start_of_irom2_section to _end_of_irom2_section]; +define region erom_section = mem:[from _start_of_erom1_section to _end_of_erom1_section] + | mem:[from _start_of_erom2_section to _end_of_erom2_section] + | mem:[from _start_of_erom3_section to _end_of_erom3_section]; +define region iram_section = mem:[from _start_of_iram1_section to _end_of_iram1_section] + | mem:[from _start_of_iram2_section to _end_of_iram2_section]; +define region eram_section = mem:[from _start_of_eram1_section to _end_of_eram1_section] + | mem:[from _start_of_eram2_section to _end_of_eram2_section] + | mem:[from _start_of_eram3_section to _end_of_eram3_section]; + + +define block CSTACK with alignment = 8, size = _min_stack_size { }; +define block PROC_STACK with alignment = 8, size = _min_proc_stack_size { }; +define block HEAP with alignment = 8, size = _min_heap_size { }; + +initialize by copy { readwrite }; + +place at address mem:_start_of_intvec_section { readonly section .intvec }; + +place in irom_section { readonly }; +place in erom_section { readonly section application_specific_ro }; +place in iram_section { readwrite, block CSTACK, block HEAP, block PROC_STACK }; +place in eram_section { readwrite section application_specific_rw }; diff --git a/examples/baremetal/pca10040/greenblink/iar/startup.s b/examples/baremetal/pca10040/greenblink/iar/startup.s new file mode 100644 index 00000000..209322ac --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/iar/startup.s @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + + MODULE ?cstartup + + SECTION CSTACK:DATA:NOROOT(3) + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + + PUBLIC _vectors_table + DATA + +_vectors_table + ;; Generic interrupts offset. + DCD sfe(CSTACK) ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Memory management fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; POWER CLOCK. + DCD 0 ; RADIO. + DCD 0 ; UARTE0/UART0 + DCD 0 ; SPIM0/SPIS0/TWIM0/TWIS0/SPI0/TWI0. + DCD 0 ; SPIM1/SPIS1/TWIM1/TWIS1/SPI1/TWI1. + DCD 0 ; NFCT. + DCD 0 ; GPIOTE. + DCD 0 ; SAADC. + DCD 0 ; TIMER0. + DCD 0 ; TIMER1. + DCD 0 ; TIMER2. + DCD 0 ; RTC0. + DCD 0 ; TEMP. + DCD 0 ; RNG. + DCD 0 ; ECB. + DCD 0 ; CCM_AAR. + DCD 0 ; WDT. + DCD 0 ; RTC1. + DCD 0 ; QDEC. + DCD 0 ; COMP_LPCOMP. + DCD 0 ; SWI0_EGU0. + DCD 0 ; SWI1_EGU1. + DCD 0 ; SWI2_EGU2. + DCD 0 ; SWI3_EGU3. + DCD 0 ; SWI4_EGU4. + DCD 0 ; SWI5_EGU5. + DCD 0 ; TIMER3. + DCD 0 ; TIMER4. + DCD 0 ; PWM0. + DCD 0 ; PDM. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; MWU. + DCD 0 ; PWM1. + DCD 0 ; PWM2. + DCD 0 ; SPIM2/SPIS2/SPI2. + DCD 0 ; RTC2. + DCD 0 ; I2S. + DCD 0 ; FPU. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + + ;; Reset handler. + THUMB + PUBWEAK reset_handler + SECTION .text:CODE:REORDER:NOROOT(2) +reset_handler + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + END diff --git a/examples/baremetal/pca10040/greenblink/keil/flash.sct b/examples/baremetal/pca10040/greenblink/keil/flash.sct new file mode 100644 index 00000000..29843331 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/keil/flash.sct @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +;; Load region size_region. +LR_IROM1 0x00000000 0x00080000 { + ;; Load address = execution address. + ER_IROM1 0x00000000 0x00080000 { + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + + ; RW data. + RW_IRAM1 0x20000000 0x00008000 { + .ANY (+RW +ZI) + } +} diff --git a/examples/baremetal/pca10040/greenblink/keil/startup.s b/examples/baremetal/pca10040/greenblink/keil/startup.s new file mode 100644 index 00000000..369ca96f --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/keil/startup.s @@ -0,0 +1,215 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) 2020 Denis Shienkov +;; Contact: https://www.qt.io/licensing/ +;; +;; This file is part of the examples of Qbs. +;; +;; $QT_BEGIN_LICENSE:BSD$ +;; Commercial License Usage +;; Licensees holding valid commercial Qt licenses may use this file in +;; accordance with the commercial license agreement provided with the +;; Software or, alternatively, in accordance with the terms contained in +;; a written agreement between you and The Qt Company. For licensing terms +;; and conditions see https://www.qt.io/terms-conditions. For further +;; information use the contact form at https://www.qt.io/contact-us. +;; +;; BSD License Usage +;; Alternatively, 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$ +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +_size_of_stack EQU 0x2000 +_size_of_heap EQU 0x2000 + +;; Stack configuration. + AREA STACK, NOINIT, READWRITE, ALIGN=3 +_start_of_stack SPACE _size_of_stack +_end_of_stack + +;; Heap configuration. + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +_start_of_heap SPACE _size_of_heap +_end_of_heap + + PRESERVE8 + THUMB + +;; Define the empty vectors table. + AREA RESET, DATA, READONLY +_vectors_table + ;; Generic interrupts offset. + DCD _end_of_stack ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Memory management fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Debug monitor. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Power clock. + DCD 0 ; Radio. + DCD 0 ; UARTE0/UART0. + DCD 0 ; SPIM0/SPIS0/TWIM0/TWIS0/SPI0/TWI0. + DCD 0 ; SPIM1/SPIS1/TWIM1/TWIS1/SPI1/TWI1. + DCD 0 ; NFCT. + DCD 0 ; GPIOTE. + DCD 0 ; SAADC. + DCD 0 ; TIMER0. + DCD 0 ; TIMER1. + DCD 0 ; TIMER2. + DCD 0 ; RTC0. + DCD 0 ; TEMP. + DCD 0 ; RNG. + DCD 0 ; ECB. + DCD 0 ; CCM/AAR. + DCD 0 ; WDT. + DCD 0 ; RTC1. + DCD 0 ; QDEC. + DCD 0 ; COMP/LPCOMP. + DCD 0 ; SWI0/EGU0. + DCD 0 ; SWI1/EGU1. + DCD 0 ; SWI2/EGU2. + DCD 0 ; SWI3/EGU3. + DCD 0 ; SWI4/EGU4. + DCD 0 ; SWI5/EGU5. + DCD 0 ; TIMER3. + DCD 0 ; TIMER4. + DCD 0 ; PWM0. + DCD 0 ; PDM. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; MWU. + DCD 0 ; PWM1. + DCD 0 ; PWM2. + DCD 0 ; SPIM2/SPIS2/SPI2. + DCD 0 ; RTC2. + DCD 0 ; I2S. + DCD 0 ; FPU. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + +_end_of_vectors_table + +_size_of_vectors_table EQU _end_of_vectors_table - _vectors_table + + AREA |.text|, CODE, READONLY +;; Reset handler. +reset_handler PROC + EXPORT reset_handler [WEAK] + IMPORT main + LDR R0, =main + BX R0 + ENDP + ALIGN + + END diff --git a/examples/baremetal/pca10040/greenblink/main.c b/examples/baremetal/pca10040/greenblink/main.c new file mode 100644 index 00000000..89d3daeb --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + gpio_init_green_led(); + + while (1) { + gpio_toggle_green_led(); + some_delay(1000000u); + } +} diff --git a/examples/baremetal/pca10040/greenblink/system.h b/examples/baremetal/pca10040/greenblink/system.h new file mode 100644 index 00000000..bf9e4b35 --- /dev/null +++ b/examples/baremetal/pca10040/greenblink/system.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define __IO volatile + +struct gpio_regs_map { + uint32_t RESERVED0[321u]; + __IO uint32_t OUT; + __IO uint32_t OUTSET; + __IO uint32_t OUTCLR; + __IO uint32_t IN; + __IO uint32_t DIR; + __IO uint32_t DIRSET; + __IO uint32_t DIRCLR; + __IO uint32_t LATCH; + __IO uint32_t DETECTMODE; + uint32_t RESERVED1[118u]; + __IO uint32_t PIN_CNF[32u]; +}; + +#define GPIO_REGS_ADDRESS (0x50000000u) +#define GPIOD_REGS_MAP ((struct gpio_regs_map *)GPIO_REGS_ADDRESS) + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/pca10040/pca10040.qbs b/examples/baremetal/pca10040/pca10040.qbs new file mode 100644 index 00000000..e5e516c3 --- /dev/null +++ b/examples/baremetal/pca10040/pca10040.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for pca10040 board" + references: [ + "greenblink/greenblink.qbs" + ] +} diff --git a/examples/baremetal/stm32f103/greenblink/README.md b/examples/baremetal/stm32f103/greenblink/README.md new file mode 100644 index 00000000..8d19ac73 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/README.md @@ -0,0 +1,10 @@ +This example demonstrates how to build a bare-metal application using +different ARM toolchains. It is designed for the stm32f103 "Blue Pill" +evaluation kit (based on stm32f103c8 MCU) and simply flashes the green +LED on the board. + +The following toolchains are supported: + + * GNU Arm Embedded Toolchain + * IAR Embedded Workbench + * KEIL Microcontroller Development Kit diff --git a/examples/baremetal/stm32f103/greenblink/gcc/flash.ld b/examples/baremetal/stm32f103/greenblink/gcc/flash.ld new file mode 100644 index 00000000..3fe5c156 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/gcc/flash.ld @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +/* Entry point (defined in assembled file). */ +ENTRY(reset_handler) + +/* End of RAM, it is the user mode stack pointer address. */ +_end_of_stack = 0x20005000; + +/* Generate a link error if heap and stack don't fit into RAM. */ +_size_of_heap = 0x200; /* Required amount of heap. */ +_size_of_stack = 0x400; /* Required amount of stack. */ + +MEMORY { + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K + FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 64K +} + +SECTIONS { + /* The vectors table goes into FLASH. */ + .isr_vector : { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code. */ + . = ALIGN(4); + } > FLASH + + /* The program code and other data goes into FLASH. */ + .text : { + . = ALIGN(4); + *(.text) + *(.text*) + *(.glue_7) /* Glue arm to thumb code. */ + *(.glue_7t) /* Glue thumb to arm code. */ + *(.eh_frame) + KEEP(*(.init)) + KEEP(*(.fini)) + . = ALIGN(4); + _end_of_text_section = .; /* Export global symbol at end of code. */ + } > FLASH + + /* Constant data goes into FLASH. */ + .rodata : { + . = ALIGN(4); + *(.rodata) + *(.rodata*) + . = ALIGN(4); + } > FLASH + + .ARM.extab : { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } > FLASH + + .preinit_array : { + PROVIDE_HIDDEN(__preinit_array_start = .); + KEEP(*(.preinit_array*)) + PROVIDE_HIDDEN(__preinit_array_end = .); + } > FLASH + + .init_array : { + PROVIDE_HIDDEN(__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array*)) + PROVIDE_HIDDEN(__init_array_end = .); + } > FLASH + + .fini_array : { + PROVIDE_HIDDEN(__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array*)) + PROVIDE_HIDDEN(__fini_array_end = .); + } > FLASH + + _start_of_init_data_section = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code. */ + .data : { + . = ALIGN(4); + _start_of_data_section = .; /* Export global symbol at data start. */ + *(.data) + *(.data*) + . = ALIGN(4); + _end_of_data_section = .; /* Export global symbol at data end. */ + } > RAM AT > FLASH + + /* Uninitialized data section. */ + . = ALIGN(4); + .bss : { + /* This is used by the startup in order to initialize the .bss secion. */ + _start_of_bss_section = .; /* Export global symbol at bss start. */ + __bss_start__ = _start_of_bss_section; + *(.bss) + *(.bss*) + *(COMMON) + . = ALIGN(4); + _end_of_bss_section = .; /* Export global symbol at bss end. */ + __bss_end__ = _end_of_bss_section; + } > RAM + + /* Used to check that there is enough RAM left. */ + ._user_heap_stack : { + . = ALIGN(4); + PROVIDE(end = .); + PROVIDE(_end = .); + . = . + _size_of_heap; + . = . + _size_of_stack; + . = ALIGN(4); + } > RAM + + /* Remove information from the standard libraries. */ + /DISCARD/ : { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { + *(.ARM.attributes) + } +} diff --git a/examples/baremetal/stm32f103/greenblink/gcc/startup.s b/examples/baremetal/stm32f103/greenblink/gcc/startup.s new file mode 100644 index 00000000..5bb262f1 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/gcc/startup.s @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +.syntax unified +.cpu cortex-m3 +.fpu softvfp +.thumb + +// These symbols are exported from the linker script. +.word _start_of_init_data_section +.word _start_of_data_section +.word _end_of_data_section +.word _start_of_bss_section +.word _end_of_bss_section + +.equ _boot_ram, 0xF108F85F + +.section .text.reset_handler +.weak reset_handler +.type reset_handler, %function +reset_handler: + // Copy the data segment initializers from flash to SRAM. + movs r1, #0 + b _loop_copy_data_init +_copy_data_init: + ldr r3, =_start_of_init_data_section + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 +_loop_copy_data_init: + ldr r0, =_start_of_data_section + ldr r3, =_end_of_data_section + adds r2, r0, r1 + cmp r2, r3 + bcc _copy_data_init + ldr r2, =_start_of_bss_section + b _loop_fill_zero_bss + + // Zero fill the bss segment. +_fill_zero_bss: + movs r3, #0 + str r3, [r2], #4 +_loop_fill_zero_bss: + ldr r3, = _end_of_bss_section + cmp r2, r3 + bcc _fill_zero_bss + + // Call the static constructors. + bl __libc_init_array + + // Call the application entry point. + bl main + bx lr +.size reset_handler, .-reset_handler + +// Define the empty vectors table. +.section .isr_vector,"a",%progbits +.type _vectors_table, %object +.size _vectors_table, .-_vectors_table +_vectors_table: + // Generic interrupts offset. + .word _end_of_stack // Initial stack pointer value. + .word reset_handler // Reset. + .word 0 // NMI. + .word 0 // Hard fault. + .word 0 // Memory management fault. + .word 0 // Bus fault. + .word 0 // Usage fault. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // SVC. + .word 0 // Debug monitor. + .word 0 // Reserved. + .word 0 // PendSV. + .word 0 // SysTick. + + // External interrupts offset. + .word 0 // Window watchdog. + .word 0 // PVD through EXTI Line detection. + .word 0 // Tamper and timestamps through the EXTI line. + .word 0 // RTC wakeup through the EXTI line. + .word 0 // FLASH. + .word 0 // RCC. + .word 0 // EXTI line0. + .word 0 // EXTI line1. + .word 0 // EXTI line2. + .word 0 // EXTI line3. + .word 0 // EXTI line4. + .word 0 // DMA1 stream 0. + .word 0 // DMA1 stream 1. + .word 0 // DMA1 stream 2. + .word 0 // DMA1 stream 3. + .word 0 // DMA1 stream 4. + .word 0 // DMA1 stream 5. + .word 0 // DMA1 stream 6. + .word 0 // ADC1/2. + .word 0 // USB HP/CAN1 TX. + .word 0 // USB LP / CAN1 RX0. + .word 0 // CAN1 RX1. + .word 0 // CAN1 SCE. + .word 0 // EXTI line [9:5]s. + .word 0 // TIM1 break. + .word 0 // TIM1 update. + .word 0 // TIM1 trigger and communication. + .word 0 // TIM1 capture compare. + .word 0 // TIM2. + .word 0 // TIM3. + .word 0 // TIM4. + .word 0 // I2C1 event. + .word 0 // I2C1 error. + .word 0 // I2C2 event. + .word 0 // I2C2 error. + .word 0 // SPI1. + .word 0 // SPI2. + .word 0 // USART1. + .word 0 // USART2. + .word 0 // USART3. + .word 0 // EXTI line [15:10]s. + .word 0 // RTC alarm. + .word 0 // USB wakeup. + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word 0 + .word _boot_ram // Boot RAM mode for stm32f10x medium density devices. diff --git a/examples/baremetal/stm32f103/greenblink/gpio.c b/examples/baremetal/stm32f103/greenblink/gpio.c new file mode 100644 index 00000000..84c87a2b --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/gpio.c @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#define GPIO_GREEN_LED_PIN_POS (13u) +#define GPIO_GREEN_LED_PIN (1u << GPIO_GREEN_LED_PIN_POS) + +// Bit definition for RCC_APB2ENR register. +#define RCC_APB2ENR_IOPCEN_POS (4u) +#define RCC_APB2ENR_IOPCEN (0x1u << RCC_APB2ENR_IOPCEN_POS) + +// Bit definition for GPIO_CRL register. +#define GPIO_CRL_MODE_POS (0u) // MODE field position. +#define GPIO_CRL_MODE_MSK (0x3u << GPIO_CRL_MODE_POS) // MODE field mask. +#define GPIO_CRL_MODE_OUT_FREQ_LOW (0x2u << GPIO_CRL_MODE_POS) // As output with low frequency. + +#define GPIO_CRL_CNF_POS (2u) // CNF field position. +#define GPIO_CRL_CNF_MSK (0x3u << GPIO_CRL_CNF_POS) // CNF field mask. +#define GPIO_CRL_CNF_OUTPUT_PP (0x00000000u) // General purpose output push-pull. + +void gpio_init_green_led(void) +{ + // Enable RCC clock on GPIOC port. + RCC_REGS_MAP->APB2ENR |= RCC_APB2ENR_IOPCEN; + // Configure GPIOC pin #13. + const uint32_t offset = ((GPIO_GREEN_LED_PIN_POS - 8u) << 2u); + GPIOC_REGS_MAP->CRH &= ~((GPIO_CRL_MODE_MSK | GPIO_CRL_CNF_MSK) << offset); + GPIOC_REGS_MAP->CRH |= ((GPIO_CRL_MODE_OUT_FREQ_LOW | GPIO_CRL_CNF_OUTPUT_PP) << offset); +} + +void gpio_toggle_green_led(void) +{ + GPIOC_REGS_MAP->ODR ^= GPIO_GREEN_LED_PIN; +} diff --git a/examples/baremetal/stm32f103/greenblink/gpio.h b/examples/baremetal/stm32f103/greenblink/gpio.h new file mode 100644 index 00000000..9e931b71 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_green_led(void); +void gpio_toggle_green_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/stm32f103/greenblink/greenblink.qbs b/examples/baremetal/stm32f103/greenblink/greenblink.qbs new file mode 100644 index 00000000..18fe8e53 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/greenblink.qbs @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.startsWith("arm")) + return false; + return (qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil")) + && !qbs.toolchain.contains("xcode") + } + name: "stm32f103-greenblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // GCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.assemblerFlags: [ + "-mcpu=cortex-m3" + ] + cpp.driverFlags: [ + "-mcpu=cortex-m3", + "-specs=nosys.specs" + ] + } + + Group { + condition: qbs.toolchain.contains("gcc") + name: "GCC" + prefix: "gcc/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.ld"] + } + } + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.assemblerFlags: [ + "--cpu", "cortex-m3", + "--fpu", "none" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m3", + "--fpu", "none" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.icf"] + } + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.assemblerFlags: [ + "--cpu", "cortex-m3" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m3" + ] + } + + Group { + condition: qbs.toolchain.contains("keil") + name: "KEIL" + prefix: "keil/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.sct"] + } + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/stm32f103/greenblink/iar/flash.icf b/examples/baremetal/stm32f103/greenblink/iar/flash.icf new file mode 100644 index 00000000..1b424d29 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/iar/flash.icf @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +define symbol _start_of_intvec_section = 0x08000000; + +define symbol _start_of_flash_section = 0x08000000; +define symbol _end_of_flash_section = 0x0801FFFF; +define symbol _start_of_ram_section = 0x20000000; +define symbol _end_of_ram_section = 0x20004FFF; + +define symbol _min_stack_size = 0x400; +define symbol _min_heap_size = 0x200; + +define memory mem with size = 4G; +define region flash_section = mem:[from _start_of_flash_section to _end_of_flash_section]; +define region ram_section = mem:[from _start_of_ram_section to _end_of_ram_section]; + +define block CSTACK with alignment = 8, size = _min_stack_size { }; +define block HEAP with alignment = 8, size = _min_heap_size { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:_start_of_intvec_section { readonly section .intvec }; + +place in flash_section { readonly }; +place in ram_section { readwrite, block CSTACK, block HEAP }; diff --git a/examples/baremetal/stm32f103/greenblink/iar/startup.s b/examples/baremetal/stm32f103/greenblink/iar/startup.s new file mode 100644 index 00000000..cda2a4e7 --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/iar/startup.s @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + + MODULE ?cstartup + + SECTION CSTACK:DATA:NOROOT(3) + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + + PUBLIC _vectors_table + DATA +_vectors_table + ;; Generic interrupts offset. + DCD sfe(CSTACK) ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; MPU fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Debug monitor. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Window watchdog. + DCD 0 ; PVD through EXTI line detection. + DCD 0 ; Tamper. + DCD 0 ; RTC. + DCD 0 ; Flash. + DCD 0 ; RCC. + DCD 0 ; EXTI line 0. + DCD 0 ; EXTI line 1. + DCD 0 ; EXTI line 2. + DCD 0 ; EXTI line 3. + DCD 0 ; EXTI line 4. + DCD 0 ; DMA1 channel 1. + DCD 0 ; DMA1 channel 2. + DCD 0 ; DMA1 channel 3. + DCD 0 ; DMA1 channel 4. + DCD 0 ; DMA1 channel 5. + DCD 0 ; DMA1 channel 6. + DCD 0 ; DMA1 channel 7. + DCD 0 ; ADC1/2. + DCD 0 ; USB high priority or CAN1 TX. + DCD 0 ; USB low priority or CAN1 RX0. + DCD 0 ; CAN1 RX1. + DCD 0 ; CAN1 SCE. + DCD 0 ; EXTI line 9..5. + DCD 0 ; TIM1 break. + DCD 0 ; TIM1 update. + DCD 0 ; TIM1 trigger and commutation. + DCD 0 ; TIM1 capture compare. + DCD 0 ; TIM2. + DCD 0 ; TIM3. + DCD 0 ; TIM4. + DCD 0 ; I2C1 event. + DCD 0 ; I2C1 error. + DCD 0 ; I2C2 event. + DCD 0 ; I2C2 error. + DCD 0 ; SPI1. + DCD 0 ; SPI2. + DCD 0 ; USART1. + DCD 0 ; USART2. + DCD 0 ; USART3. + DCD 0 ; EXTI line 15..10. + DCD 0 ; RTC alarm through EXTI line. + DCD 0 ; USB wakeup from suspend. + + ;; Reset handler. + THUMB + PUBWEAK reset_handler + SECTION .text:CODE:REORDER:NOROOT(2) +reset_handler + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + END diff --git a/examples/baremetal/stm32f103/greenblink/keil/flash.sct b/examples/baremetal/stm32f103/greenblink/keil/flash.sct new file mode 100644 index 00000000..3547ca2c --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/keil/flash.sct @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +;; Load region size_region. +LR_IROM1 0x08000000 0x00010000 { + ;; Load address = execution address. + ER_IROM1 0x08000000 0x00010000 { + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + + ; RW data. + RW_IRAM1 0x20000000 0x00005000 { + .ANY (+RW +ZI) + } +} diff --git a/examples/baremetal/stm32f103/greenblink/keil/startup.s b/examples/baremetal/stm32f103/greenblink/keil/startup.s new file mode 100644 index 00000000..d80de94c --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/keil/startup.s @@ -0,0 +1,145 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) 2020 Denis Shienkov +;; Contact: https://www.qt.io/licensing/ +;; +;; This file is part of the examples of Qbs. +;; +;; $QT_BEGIN_LICENSE:BSD$ +;; Commercial License Usage +;; Licensees holding valid commercial Qt licenses may use this file in +;; accordance with the commercial license agreement provided with the +;; Software or, alternatively, in accordance with the terms contained in +;; a written agreement between you and The Qt Company. For licensing terms +;; and conditions see https://www.qt.io/terms-conditions. For further +;; information use the contact form at https://www.qt.io/contact-us. +;; +;; BSD License Usage +;; Alternatively, 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$ +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +_size_of_stack EQU 0x400 +_size_of_heap EQU 0x200 + +;; Stack configuration. + AREA STACK, NOINIT, READWRITE, ALIGN=3 +_start_of_stack SPACE _size_of_stack +_end_of_stack + +;; Heap configuration. + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +_start_of_heap SPACE _size_of_heap +_end_of_heap + + PRESERVE8 + THUMB + +;; Define the empty vectors table. + AREA RESET, DATA, READONLY +_vectors_table + ;; Generic interrupts offset. + DCD _end_of_stack ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Memory management fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Debug monitor. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Window watchdog. + DCD 0 ; PVD through EXTI line detection. + DCD 0 ; Tamper and TimeStamps through the EXTI line. + DCD 0 ; RTC wakeup through the EXTI line. + DCD 0 ; FLASH. + DCD 0 ; RCC. + DCD 0 ; EXTI line0. + DCD 0 ; EXTI line1. + DCD 0 ; EXTI line2. + DCD 0 ; EXTI line3. + DCD 0 ; EXTI line4. + DCD 0 ; DMA1 channel 1. + DCD 0 ; DMA1 channel 2. + DCD 0 ; DMA1 channel 3. + DCD 0 ; DMA1 channel 4. + DCD 0 ; DMA1 channel 5. + DCD 0 ; DMA1 channel 6. + DCD 0 ; DMA1 channel 7. + DCD 0 ; ADC1/2. + DCD 0 ; USB high priority or CAN1 TX. + DCD 0 ; USB low priority or CAN1 RX0. + DCD 0 ; CAN1 RX1. + DCD 0 ; CAN1 SCE. + DCD 0 ; EXTI line 9..5. + DCD 0 ; TIM1 break. + DCD 0 ; TIM1 update. + DCD 0 ; TIM1 trigger and commutation. + DCD 0 ; IM1 capture compare. + DCD 0 ; TIM2. + DCD 0 ; TIM3. + DCD 0 ; TIM4. + DCD 0 ; I2C1 event. + DCD 0 ; I2C1 error. + DCD 0 ; I2C2 event. + DCD 0 ; I2C2 error. + DCD 0 ; SPI1. + DCD 0 ; SPI2. + DCD 0 ; USART1. + DCD 0 ; USART2. + DCD 0 ; USART3. + DCD 0 ; EXTI line 15..10. + DCD 0 ; RTC alarm through EXTI line. + DCD 0 ; USB wakeup from suspend. +_end_of_vectors_table + +_size_of_vectors_table EQU _end_of_vectors_table - _vectors_table + + AREA |.text|, CODE, READONLY +;; Reset handler. +reset_handler PROC + EXPORT reset_handler [WEAK] + IMPORT main + LDR R0, =main + BX R0 + ENDP + ALIGN + + END diff --git a/examples/baremetal/stm32f103/greenblink/main.c b/examples/baremetal/stm32f103/greenblink/main.c new file mode 100644 index 00000000..21bc5bad --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + gpio_init_green_led(); + + while (1) { + gpio_toggle_green_led(); + some_delay(100000u); + } +} diff --git a/examples/baremetal/stm32f103/greenblink/system.h b/examples/baremetal/stm32f103/greenblink/system.h new file mode 100644 index 00000000..d18854be --- /dev/null +++ b/examples/baremetal/stm32f103/greenblink/system.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define __IO volatile + +// General purpose input/output registers map. +struct gpio_regs_map { + __IO uint32_t CRL; + __IO uint32_t CRH; + __IO uint32_t IDR; + __IO uint32_t ODR; + __IO uint32_t BSRR; + __IO uint32_t BRR; + __IO uint32_t LCKR; +}; + +// Reset and clock control registers map. +struct rcc_regs_map { + __IO uint32_t CR; + __IO uint32_t CFGR; + __IO uint32_t CIR; + __IO uint32_t APB2RSTR; + __IO uint32_t APB1RSTR; + __IO uint32_t AHBENR; + __IO uint32_t APB2ENR; + __IO uint32_t APB1ENR; + __IO uint32_t BDCR; + __IO uint32_t CSR; +}; + +#define PERIPH_ADDRESS (0x40000000u) + +#define APB2PERIPH_ADDRESS (PERIPH_ADDRESS + 0x00010000u) +#define AHBPERIPH_ADDRESS (PERIPH_ADDRESS + 0x00020000u) + +#define GPIOC_REGS_ADDRESS (APB2PERIPH_ADDRESS + 0x00001000u) +#define RCC_REGS_ADDRESS (AHBPERIPH_ADDRESS + 0x00001000u) + +#define GPIOC_REGS_MAP ((struct gpio_regs_map *)GPIOC_REGS_ADDRESS) +#define RCC_REGS_MAP ((struct rcc_regs_map *)RCC_REGS_ADDRESS) + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/stm32f103/stm32f103.qbs b/examples/baremetal/stm32f103/stm32f103.qbs new file mode 100644 index 00000000..705502c5 --- /dev/null +++ b/examples/baremetal/stm32f103/stm32f103.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for stm32f103 board" + references: [ + "greenblink/greenblink.qbs" + ] +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/README.md b/examples/baremetal/stm32f4discovery/blueblink/README.md new file mode 100644 index 00000000..d15e1251 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/README.md @@ -0,0 +1,10 @@ +This example demonstrates how to build a bare-metal application using +different ARM toolchains. It is designed for the stm32f4discovery +evaluation kit (based on stm32f407vg MCU) and simply flashes the blue +LED on the board. + +The following toolchains are supported: + + * GNU Arm Embedded Toolchain + * IAR Embedded Workbench + * KEIL Microcontroller Development Kit diff --git a/examples/baremetal/stm32f4discovery/blueblink/blueblink.qbs b/examples/baremetal/stm32f4discovery/blueblink/blueblink.qbs new file mode 100644 index 00000000..f2e1dfcc --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/blueblink.qbs @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.startsWith("arm")) + return false; + return (qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("iar") + || qbs.toolchain.contains("keil")) + && !qbs.toolchain.contains("xcode") + } + name: "stm32f4discovery-blueblink" + cpp.cLanguageVersion: "c99" + cpp.positionIndependentCode: false + + // + // GCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.assemblerFlags: [ + "-mcpu=cortex-m4", + "-mfloat-abi=hard", + "-mfpu=fpv4-sp-d16", + ] + cpp.driverFlags: [ + "-mcpu=cortex-m4", + "-mfloat-abi=hard", + "-mfpu=fpv4-sp-d16", + "-specs=nosys.specs" + ] + } + + Group { + condition: qbs.toolchain.contains("gcc") + name: "GCC" + prefix: "gcc/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.ld"] + } + } + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.assemblerFlags: [ + "--cpu", "cortex-m4", + "--fpu", "vfpv4_sp" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m4", + "--fpu", "vfpv4_sp" + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.icf"] + } + } + + // + // KEIL-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("keil") + cpp.assemblerFlags: [ + "--cpu", "cortex-m4.fp" + ] + cpp.driverFlags: [ + "--cpu", "cortex-m4.fp" + ] + } + + Group { + condition: qbs.toolchain.contains("keil") + name: "KEIL" + prefix: "keil/" + Group { + name: "Startup" + fileTags: ["asm"] + files: ["startup.s"] + } + Group { + name: "Linker Script" + fileTags: ["linkerscript"] + files: ["flash.sct"] + } + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/gcc/flash.ld b/examples/baremetal/stm32f4discovery/blueblink/gcc/flash.ld new file mode 100644 index 00000000..2e1896f3 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/gcc/flash.ld @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +/* Entry point (defined in assembled file). */ +ENTRY(reset_handler) + +/* End of RAM, it is the user mode stack pointer address. */ +_end_of_stack = 0x20020000; + +/* Generate a link error if heap and stack don't fit into RAM. */ +_size_of_heap = 0x200; /* Required amount of heap. */ +_size_of_stack = 0x400; /* Required amount of stack. */ + +MEMORY { + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K + CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K + FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K +} + +SECTIONS { + /* The vectors table goes into FLASH. */ + .isr_vector : { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code. */ + . = ALIGN(4); + } > FLASH + + /* The program code and other data goes into FLASH. */ + .text : { + . = ALIGN(4); + *(.text) + *(.text*) + *(.glue_7) /* Glue arm to thumb code. */ + *(.glue_7t) /* Glue thumb to arm code. */ + *(.eh_frame) + KEEP(*(.init)) + KEEP(*(.fini)) + . = ALIGN(4); + _end_of_text_section = .; /* Export global symbol at end of code. */ + } > FLASH + + /* Constant data goes into FLASH. */ + .rodata : { + . = ALIGN(4); + *(.rodata) + *(.rodata*) + . = ALIGN(4); + } > FLASH + + .ARM.extab : { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } > FLASH + + .preinit_array : { + PROVIDE_HIDDEN(__preinit_array_start = .); + KEEP(*(.preinit_array*)) + PROVIDE_HIDDEN(__preinit_array_end = .); + } > FLASH + + .init_array : { + PROVIDE_HIDDEN(__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array*)) + PROVIDE_HIDDEN(__init_array_end = .); + } > FLASH + + .fini_array : { + PROVIDE_HIDDEN(__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array*)) + PROVIDE_HIDDEN(__fini_array_end = .); + } > FLASH + + _start_of_init_data_section = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code. */ + .data : { + . = ALIGN(4); + _start_of_data_section = .; /* Export global symbol at data start. */ + *(.data) + *(.data*) + . = ALIGN(4); + _end_of_data_section = .; /* Export global symbol at data end. */ + } > RAM AT > FLASH + + _start_of_iccm_ram_section = LOADADDR(.ccmram); + + /* CCM-RAM section. */ + .ccmram : { + . = ALIGN(4); + _start_of_ccmram_section = .; /* Export global symbol at ccmram start. */ + *(.ccmram) + *(.ccmram*) + . = ALIGN(4); + _end_of_ccmram_section = .; /* Export global symbol at ccmram end. */ + } > CCMRAM AT > FLASH + + /* Uninitialized data section. */ + . = ALIGN(4); + .bss : { + /* This is used by the startup in order to initialize the .bss secion. */ + _start_of_bss_section = .; /* Export global symbol at bss start. */ + __bss_start__ = _start_of_bss_section; + *(.bss) + *(.bss*) + *(COMMON) + . = ALIGN(4); + _end_of_bss_section = .; /* Export global symbol at bss end. */ + __bss_end__ = _end_of_bss_section; + } > RAM + + /* Used to check that there is enough RAM left. */ + ._user_heap_stack : { + . = ALIGN(4); + PROVIDE(end = .); + PROVIDE(_end = .); + . = . + _size_of_heap; + . = . + _size_of_stack; + . = ALIGN(4); + } > RAM + + /* Remove information from the standard libraries. */ + /DISCARD/ : { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { + *(.ARM.attributes) + } +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/gcc/startup.s b/examples/baremetal/stm32f4discovery/blueblink/gcc/startup.s new file mode 100644 index 00000000..d6a2104d --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/gcc/startup.s @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +.syntax unified +.cpu cortex-m4 +.fpu softvfp +.thumb + +// These symbols are exported from the linker script. +.word _start_of_init_data_section +.word _start_of_data_section +.word _end_of_data_section +.word _start_of_bss_section +.word _end_of_bss_section +.word _end_of_stack + +// Define the 'reset_handler' function, which is an entry point. +.section .text.reset_handler +.weak reset_handler +.type reset_handler, %function +reset_handler: + // Set the stack pointer. + ldr sp, =_end_of_stack + + // Copy the data segment initializers from flash to SRAM. + movs r1, #0 + b _loop_copy_data_init +_copy_data_init: + ldr r3, =_start_of_init_data_section + ldr r3, [r3, r1] + str r3, [r0, r1] + adds r1, r1, #4 +_loop_copy_data_init: + ldr r0, =_start_of_data_section + ldr r3, =_end_of_data_section + adds r2, r0, r1 + cmp r2, r3 + bcc _copy_data_init + ldr r2, =_start_of_bss_section + b _loop_fill_zero_bss + + // Zero fill the bss segment. +_fill_zero_bss: + movs r3, #0 + str r3, [r2], #4 +_loop_fill_zero_bss: + ldr r3, = _end_of_bss_section + cmp r2, r3 + bcc _fill_zero_bss + + // Call the static constructors. + bl __libc_init_array + + // Call the application's entry point. + bl main + bx lr +.size reset_handler, .-reset_handler + +// Define the empty vectors table. +.section .isr_vector,"a",%progbits +.type _vectors_table, %object +.size _vectors_table, .-_vectors_table +_vectors_table: + // Generic interrupts offset. + .word _end_of_stack // Initial stack pointer value. + .word reset_handler // Reset. + .word 0 // NMI. + .word 0 // Hard fault. + .word 0 // Memory management fault. + .word 0 // Bus fault. + .word 0 // Usage fault. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // Reserved. + .word 0 // SVC. + .word 0 // Debug monitor. + .word 0 // Reserved. + .word 0 // PendSV. + .word 0 // SysTick. + + // External interrupts offset. + .word 0 // Window WatchDog. + .word 0 // PVD through EXTI Line detection. + .word 0 // Tamper and TimeStamps through the EXTI line. + .word 0 // RTC Wakeup through the EXTI line. + .word 0 // FLASH. + .word 0 // RCC. + .word 0 // EXTI Line0. + .word 0 // EXTI Line1. + .word 0 // EXTI Line2. + .word 0 // EXTI Line3. + .word 0 // EXTI Line4. + .word 0 // DMA1 Stream 0. + .word 0 // DMA1 Stream 1. + .word 0 // DMA1 Stream 2. + .word 0 // DMA1 Stream 3. + .word 0 // DMA1 Stream 4. + .word 0 // DMA1 Stream 5. + .word 0 // DMA1 Stream 6. + .word 0 // ADC1, ADC2 and ADC3s. + .word 0 // CAN1 TX. + .word 0 // CAN1 RX0. + .word 0 // CAN1 RX1. + .word 0 // CAN1 SCE. + .word 0 // External Line[9:5]s. + .word 0 // TIM1 Break and TIM9. + .word 0 // TIM1 Update and TIM10. + .word 0 // TIM1 Trigger and Commutation and TIM11. + .word 0 // TIM1 Capture Compare. + .word 0 // TIM2. + .word 0 // TIM3. + .word 0 // TIM4. + .word 0 // I2C1 Event. + .word 0 // I2C1 Error. + .word 0 // I2C2 Event. + .word 0 // I2C2 Error. + .word 0 // SPI1. + .word 0 // SPI2. + .word 0 // USART1. + .word 0 // USART2. + .word 0 // USART3. + .word 0 // External Line[15:10]s. + .word 0 // RTC Alarm (A and B) through EXTI Line. + .word 0 // USB OTG FS Wakeup through EXTI line. + .word 0 // TIM8 Break and TIM12. + .word 0 // TIM8 Update and TIM13. + .word 0 // TIM8 Trigger and Commutation and TIM14. + .word 0 // TIM8 Capture Compare. + .word 0 // DMA1 Stream7. + .word 0 // FSMC. + .word 0 // SDIO. + .word 0 // TIM5. + .word 0 // SPI3. + .word 0 // UART4. + .word 0 // UART5. + .word 0 // TIM6 and DAC1&2 underrun errors. + .word 0 // TIM7. + .word 0 // DMA2 Stream 0. + .word 0 // DMA2 Stream 1. + .word 0 // DMA2 Stream 2. + .word 0 // DMA2 Stream 3. + .word 0 // DMA2 Stream 4. + .word 0 // Ethernet. + .word 0 // Ethernet Wakeup through EXTI line. + .word 0 // CAN2 TX. + .word 0 // CAN2 RX0. + .word 0 // CAN2 RX1. + .word 0 // CAN2 SCE. + .word 0 // USB OTG FS. + .word 0 // DMA2 Stream 5. + .word 0 // DMA2 Stream 6. + .word 0 // DMA2 Stream 7. + .word 0 // USART6. + .word 0 // I2C3 event. + .word 0 // I2C3 error. + .word 0 // USB OTG HS End Point 1 Out. + .word 0 // USB OTG HS End Point 1 In. + .word 0 // USB OTG HS Wakeup through EXTI. + .word 0 // USB OTG HS. + .word 0 // DCMI. + .word 0 // CRYP crypto. + .word 0 // Hash and Rng. + .word 0 // FPU. diff --git a/examples/baremetal/stm32f4discovery/blueblink/gpio.c b/examples/baremetal/stm32f4discovery/blueblink/gpio.c new file mode 100644 index 00000000..e337f8d2 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/gpio.c @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +#define GPIO_BLUE_LED_PIN_POS (15u) +#define GPIO_BLUE_LED_PIN (1u << GPIO_BLUE_LED_PIN_POS) + +// Output push pull mode. +#define GPIO_MODE_OUTPUT_PP (0x00000001u) + +// Bit definition for RCC_AHB1ENR register. +#define RCC_AHB1ENR_GPIODEN (0x00000008u) +// Bits definition for GPIO_MODER register. +#define GPIO_MODER_MODE0 (0x00000003u) + +void gpio_init_blue_led(void) +{ + // Enable RCC clock on GPIOD port. + RCC_REGS_MAP->AHB1ENR |= RCC_AHB1ENR_GPIODEN; + // Configure GPIO pin #15 as an output. + uint32_t value = GPIOD_REGS_MAP->MODER; + value &= ~(GPIO_MODER_MODE0 << (GPIO_BLUE_LED_PIN_POS * 2u)); + value |= (GPIO_MODE_OUTPUT_PP << (GPIO_BLUE_LED_PIN_POS * 2u)); + GPIOD_REGS_MAP->MODER = value; +} + +void gpio_toggle_blue_led(void) +{ + GPIOD_REGS_MAP->ODR ^= GPIO_BLUE_LED_PIN; +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/gpio.h b/examples/baremetal/stm32f4discovery/blueblink/gpio.h new file mode 100644 index 00000000..560dcbac --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_blue_led(void); +void gpio_toggle_blue_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/stm32f4discovery/blueblink/iar/flash.icf b/examples/baremetal/stm32f4discovery/blueblink/iar/flash.icf new file mode 100644 index 00000000..04cff04c --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/iar/flash.icf @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +define symbol _start_of_intvec_section = 0x08000000; + +define symbol _start_of_ram_section = 0x20000000; +define symbol _end_of_ram_section = 0x2001FFFF; +define symbol _start_of_ccmram_section = 0x10000000; +define symbol _end_of_ccmram_section = 0x1000FFFF; +define symbol _start_of_flash_section = 0x08000000; +define symbol _end_of_flash_section = 0x080FFFFF; + +define symbol _min_stack_size = 0x400; +define symbol _min_heap_size = 0x200; + +define memory mem with size = 4G; +define region flash_section = mem:[from _start_of_flash_section to _end_of_flash_section]; +define region ram_section = mem:[from _start_of_ram_section to _end_of_ram_section]; +define region ccmram_section = mem:[from _start_of_ccmram_section to _end_of_ccmram_section]; + +define block CSTACK with alignment = 8, size = _min_stack_size { }; +define block HEAP with alignment = 8, size = _min_heap_size { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:_start_of_intvec_section { readonly section .intvec }; + +place in flash_section { readonly }; +place in ram_section { readwrite, block CSTACK, block HEAP }; diff --git a/examples/baremetal/stm32f4discovery/blueblink/iar/startup.s b/examples/baremetal/stm32f4discovery/blueblink/iar/startup.s new file mode 100644 index 00000000..fe88e6bc --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/iar/startup.s @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + + MODULE ?cstartup + + SECTION CSTACK:DATA:NOROOT(3) + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + + PUBLIC _vectors_table + DATA +_vectors_table + ;; Generic interrupts offset. + DCD sfe(CSTACK) ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Memory management fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Debug monitor. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Window WatchDog. + DCD 0 ; PVD through EXTI Line detection. + DCD 0 ; Tamper and TimeStamps through the EXTI line. + DCD 0 ; RTC Wakeup through the EXTI line. + DCD 0 ; FLASH. + DCD 0 ; RCC. + DCD 0 ; EXTI Line0. + DCD 0 ; EXTI Line1. + DCD 0 ; EXTI Line2. + DCD 0 ; EXTI Line3. + DCD 0 ; EXTI Line4. + DCD 0 ; DMA1 Stream 0. + DCD 0 ; DMA1 Stream 1. + DCD 0 ; DMA1 Stream 2. + DCD 0 ; DMA1 Stream 3. + DCD 0 ; DMA1 Stream 4. + DCD 0 ; DMA1 Stream 5. + DCD 0 ; DMA1 Stream 6. + DCD 0 ; ADC1, ADC2 and ADC3s. + DCD 0 ; CAN1 TX. + DCD 0 ; CAN1 RX0. + DCD 0 ; CAN1 RX1. + DCD 0 ; CAN1 SCE. + DCD 0 ; External Line[9:5]s. + DCD 0 ; TIM1 Break and TIM9. + DCD 0 ; TIM1 Update and TIM10. + DCD 0 ; TIM1 Trigger and Commutation and TIM11. + DCD 0 ; TIM1 Capture Compare. + DCD 0 ; TIM2. + DCD 0 ; TIM3. + DCD 0 ; TIM4. + DCD 0 ; I2C1 Event. + DCD 0 ; I2C1 Error. + DCD 0 ; I2C2 Event. + DCD 0 ; I2C2 Error. + DCD 0 ; SPI1. + DCD 0 ; SPI2. + DCD 0 ; USART1. + DCD 0 ; USART2. + DCD 0 ; USART3. + DCD 0 ; External Line[15:10]s. + DCD 0 ; RTC Alarm (A and B) through EXTI Line. + DCD 0 ; USB OTG FS Wakeup through EXTI line. + DCD 0 ; TIM8 Break and TIM12. + DCD 0 ; TIM8 Update and TIM13. + DCD 0 ; TIM8 Trigger and Commutation and TIM14. + DCD 0 ; TIM8 Capture Compare. + DCD 0 ; DMA1 Stream7. + DCD 0 ; FSMC. + DCD 0 ; SDIO. + DCD 0 ; TIM5. + DCD 0 ; SPI3. + DCD 0 ; UART4. + DCD 0 ; UART5. + DCD 0 ; TIM6 and DAC1&2 underrun errors. + DCD 0 ; TIM7. + DCD 0 ; DMA2 Stream 0. + DCD 0 ; DMA2 Stream 1. + DCD 0 ; DMA2 Stream 2. + DCD 0 ; DMA2 Stream 3. + DCD 0 ; DMA2 Stream 4. + DCD 0 ; Ethernet. + DCD 0 ; Ethernet Wakeup through EXTI line. + DCD 0 ; CAN2 TX. + DCD 0 ; CAN2 RX0. + DCD 0 ; CAN2 RX1. + DCD 0 ; CAN2 SCE. + DCD 0 ; USB OTG FS. + DCD 0 ; DMA2 Stream 5. + DCD 0 ; DMA2 Stream 6. + DCD 0 ; DMA2 Stream 7. + DCD 0 ; USART6. + DCD 0 ; I2C3 event. + DCD 0 ; I2C3 error. + DCD 0 ; USB OTG HS End Point 1 Out. + DCD 0 ; USB OTG HS End Point 1 In. + DCD 0 ; USB OTG HS Wakeup through EXTI. + DCD 0 ; USB OTG HS. + DCD 0 ; DCMI. + DCD 0 ; CRYP crypto. + DCD 0 ; Hash and RNG. + DCD 0 ; FPU. + + ;; Reset handler. + THUMB + PUBWEAK reset_handler + SECTION .text:CODE:REORDER:NOROOT(2) +reset_handler + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + END diff --git a/examples/baremetal/stm32f4discovery/blueblink/keil/flash.sct b/examples/baremetal/stm32f4discovery/blueblink/keil/flash.sct new file mode 100644 index 00000000..7a550018 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/keil/flash.sct @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +;; Load region size_region. +LR_IROM1 0x08000000 0x00100000 { + ;; Load address = execution address. + ER_IROM1 0x08000000 0x00100000 { + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + + ; RW data. + RW_IRAM1 0x20000000 0x00020000 { + .ANY (+RW +ZI) + } +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/keil/startup.s b/examples/baremetal/stm32f4discovery/blueblink/keil/startup.s new file mode 100644 index 00000000..38e5b505 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/keil/startup.s @@ -0,0 +1,184 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Copyright (C) 2019 Denis Shienkov +;; Contact: https://www.qt.io/licensing/ +;; +;; This file is part of the examples of Qbs. +;; +;; $QT_BEGIN_LICENSE:BSD$ +;; Commercial License Usage +;; Licensees holding valid commercial Qt licenses may use this file in +;; accordance with the commercial license agreement provided with the +;; Software or, alternatively, in accordance with the terms contained in +;; a written agreement between you and The Qt Company. For licensing terms +;; and conditions see https://www.qt.io/terms-conditions. For further +;; information use the contact form at https://www.qt.io/contact-us. +;; +;; BSD License Usage +;; Alternatively, 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$ +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +_size_of_stack EQU 0x400 +_size_of_heap EQU 0x200 + +;; Stack configuration. + AREA STACK, NOINIT, READWRITE, ALIGN=3 +_start_of_stack SPACE _size_of_stack +_end_of_stack + +;; Heap configuration. + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +_start_of_heap SPACE _size_of_heap +_end_of_heap + + PRESERVE8 + THUMB + +;; Define the empty vectors table. + AREA RESET, DATA, READONLY +_vectors_table + ;; Generic interrupts offset. + DCD _end_of_stack ; Initial stack pointer value. + DCD reset_handler ; Reset. + DCD 0 ; NMI. + DCD 0 ; Hard fault. + DCD 0 ; Memory management fault. + DCD 0 ; Bus fault. + DCD 0 ; Usage fault. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; Reserved. + DCD 0 ; SVC. + DCD 0 ; Debug monitor. + DCD 0 ; Reserved. + DCD 0 ; PendSV. + DCD 0 ; SysTick. + ;; External interrupts offset. + DCD 0 ; Window WatchDog. + DCD 0 ; PVD through EXTI Line detection. + DCD 0 ; Tamper and TimeStamps through the EXTI line. + DCD 0 ; RTC Wakeup through the EXTI line. + DCD 0 ; FLASH. + DCD 0 ; RCC. + DCD 0 ; EXTI Line0. + DCD 0 ; EXTI Line1. + DCD 0 ; EXTI Line2. + DCD 0 ; EXTI Line3. + DCD 0 ; EXTI Line4. + DCD 0 ; DMA1 Stream 0. + DCD 0 ; DMA1 Stream 1. + DCD 0 ; DMA1 Stream 2. + DCD 0 ; DMA1 Stream 3. + DCD 0 ; DMA1 Stream 4. + DCD 0 ; DMA1 Stream 5. + DCD 0 ; DMA1 Stream 6. + DCD 0 ; ADC1, ADC2 and ADC3s. + DCD 0 ; CAN1 TX. + DCD 0 ; CAN1 RX0. + DCD 0 ; CAN1 RX1. + DCD 0 ; CAN1 SCE. + DCD 0 ; External Line[9:5]s. + DCD 0 ; TIM1 Break and TIM9. + DCD 0 ; TIM1 Update and TIM10. + DCD 0 ; TIM1 Trigger and Commutation and TIM11. + DCD 0 ; TIM1 Capture Compare. + DCD 0 ; TIM2. + DCD 0 ; TIM3. + DCD 0 ; TIM4. + DCD 0 ; I2C1 Event. + DCD 0 ; I2C1 Error. + DCD 0 ; I2C2 Event. + DCD 0 ; I2C2 Error. + DCD 0 ; SPI1. + DCD 0 ; SPI2. + DCD 0 ; USART1. + DCD 0 ; USART2. + DCD 0 ; USART3. + DCD 0 ; External Line[15:10]s. + DCD 0 ; RTC Alarm (A and B) through EXTI Line. + DCD 0 ; USB OTG FS Wakeup through EXTI line. + DCD 0 ; TIM8 Break and TIM12. + DCD 0 ; TIM8 Update and TIM13. + DCD 0 ; TIM8 Trigger and Commutation and TIM14. + DCD 0 ; TIM8 Capture Compare. + DCD 0 ; DMA1 Stream7. + DCD 0 ; FMC. + DCD 0 ; SDIO. + DCD 0 ; TIM5. + DCD 0 ; SPI3. + DCD 0 ; UART4. + DCD 0 ; UART5. + DCD 0 ; TIM6 and DAC1&2 underrun errors. + DCD 0 ; TIM7. + DCD 0 ; DMA2 Stream 0. + DCD 0 ; DMA2 Stream 1. + DCD 0 ; DMA2 Stream 2. + DCD 0 ; DMA2 Stream 3. + DCD 0 ; DMA2 Stream 4. + DCD 0 ; Ethernet. + DCD 0 ; Ethernet Wakeup through EXTI line. + DCD 0 ; CAN2 TX. + DCD 0 ; CAN2 RX0. + DCD 0 ; CAN2 RX1. + DCD 0 ; CAN2 SCE. + DCD 0 ; USB OTG FS. + DCD 0 ; DMA2 Stream 5. + DCD 0 ; DMA2 Stream 6. + DCD 0 ; DMA2 Stream 7. + DCD 0 ; USART6. + DCD 0 ; I2C3 event. + DCD 0 ; I2C3 error. + DCD 0 ; USB OTG HS End Point 1 Out. + DCD 0 ; USB OTG HS End Point 1 In. + DCD 0 ; USB OTG HS Wakeup through EXTI. + DCD 0 ; USB OTG HS. + DCD 0 ; DCMI. + DCD 0 ; Reserved. + DCD 0 ; Hash and Rng. + DCD 0 ; FPU. +_end_of_vectors_table + +_size_of_vectors_table EQU _end_of_vectors_table - _vectors_table + + AREA |.text|, CODE, READONLY +;; Reset handler. +reset_handler PROC + EXPORT reset_handler [WEAK] + IMPORT main + LDR R0, =main + BX R0 + ENDP + ALIGN + + END diff --git a/examples/baremetal/stm32f4discovery/blueblink/main.c b/examples/baremetal/stm32f4discovery/blueblink/main.c new file mode 100644 index 00000000..ef69fc8e --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" + +#include + +static void some_delay(uint32_t counts) +{ + for (uint32_t index = 0u; index < counts; ++index) + __asm("nop"); +} + +int main(void) +{ + gpio_init_blue_led(); + + while (1) { + gpio_toggle_blue_led(); + some_delay(100000u); + } +} diff --git a/examples/baremetal/stm32f4discovery/blueblink/system.h b/examples/baremetal/stm32f4discovery/blueblink/system.h new file mode 100644 index 00000000..6e719002 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/blueblink/system.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define __IO volatile + +// General purpose input/output registers map. +struct gpio_regs_map { + __IO uint32_t MODER; + __IO uint32_t OTYPER; + __IO uint32_t OSPEEDR; + __IO uint32_t PUPDR; + __IO uint32_t IDR; + __IO uint32_t ODR; + __IO uint32_t BSRR; + __IO uint32_t LCKR; + __IO uint32_t AFR[2u]; +}; + +// Reset and clock control registers map. +struct rcc_regs_map { + __IO uint32_t CR; + __IO uint32_t PLLCFGR; + __IO uint32_t CFGR; + __IO uint32_t CIR; + __IO uint32_t AHB1RSTR; + __IO uint32_t AHB2RSTR; + __IO uint32_t AHB3RSTR; + uint32_t RESERVED0; + __IO uint32_t APB1RSTR; + __IO uint32_t APB2RSTR; + uint32_t RESERVED1[2u]; + __IO uint32_t AHB1ENR; + __IO uint32_t AHB2ENR; + __IO uint32_t AHB3ENR; + uint32_t RESERVED2; + __IO uint32_t APB1ENR; + __IO uint32_t APB2ENR; + uint32_t RESERVED3[2u]; + __IO uint32_t AHB1LPENR; + __IO uint32_t AHB2LPENR; + __IO uint32_t AHB3LPENR; + uint32_t RESERVED4; + __IO uint32_t APB1LPENR; + __IO uint32_t APB2LPENR; + uint32_t RESERVED5[2u]; + __IO uint32_t BDCR; + __IO uint32_t CSR; + uint32_t RESERVED6[2u]; + __IO uint32_t SSCGR; + __IO uint32_t PLLI2SCFGR; +}; + +#define PERIPH_ADDRESS (0x40000000u) + +#define APB2PERIPH_ADDRESS (PERIPH_ADDRESS + 0x00010000u) +#define AHB1PERIPH_ADDRESS (PERIPH_ADDRESS + 0x00020000u) + +// APB2 peripherals. +#define SYSCFG_REGS_ADDRESS (APB2PERIPH_ADDRESS + 0x3800u) +#define EXTI_REGS_ADDRESS (APB2PERIPH_ADDRESS + 0x3C00u) + +// AHB1 peripherals. +#define GPIOD_REGS_ADDRESS (AHB1PERIPH_ADDRESS + 0x0C00u) +#define RCC_REGS_ADDRESS (AHB1PERIPH_ADDRESS + 0x3800u) + +#define GPIOD_REGS_MAP ((struct gpio_regs_map *)GPIOD_REGS_ADDRESS) +#define RCC_REGS_MAP ((struct rcc_regs_map *)RCC_REGS_ADDRESS) + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/stm32f4discovery/stm32f4discovery.qbs b/examples/baremetal/stm32f4discovery/stm32f4discovery.qbs new file mode 100644 index 00000000..cbb3bdc3 --- /dev/null +++ b/examples/baremetal/stm32f4discovery/stm32f4discovery.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for stm32f4discovery board" + references: [ + "blueblink/blueblink.qbs" + ] +} diff --git a/examples/baremetal/stm8s103f3/redblink/README.md b/examples/baremetal/stm8s103f3/redblink/README.md new file mode 100644 index 00000000..2c76e918 --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/README.md @@ -0,0 +1,8 @@ +This example demonstrates how to build a bare-metal application using +different STM8 toolchains. It is designed for the STM8 target board +(based on STMicroelectronics stm8s103f3 MCU) and simply flashes the +red LED on the board. + +The following toolchains are supported: + + * IAR Embedded Workbench diff --git a/examples/baremetal/stm8s103f3/redblink/gpio.c b/examples/baremetal/stm8s103f3/redblink/gpio.c new file mode 100644 index 00000000..cc68c732 --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/gpio.c @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +// A LED is connected to the pin #5 of Port B. +#define GPIO_RED_LED_PIN_POS (0x20u) + +void gpio_init_red_led(void) +{ + PB_ODR = 0x00; // Turn off all pins. + PB_DDR = GPIO_RED_LED_PIN_POS; // Configure Pin as output. + PB_CR1 = GPIO_RED_LED_PIN_POS; // Set Pin to Push-Pull. + PB_CR2 = GPIO_RED_LED_PIN_POS; // Set Pin to Push-Pull. +} + +void gpio_toggle_red_led(void) +{ + PB_ODR ^= GPIO_RED_LED_PIN_POS; +} diff --git a/examples/baremetal/stm8s103f3/redblink/gpio.h b/examples/baremetal/stm8s103f3/redblink/gpio.h new file mode 100644 index 00000000..246eab86 --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/gpio.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef GPIO_H +#define GPIO_H + +#ifdef __cplusplus +extern "C" { +#endif + +void gpio_init_red_led(void); +void gpio_toggle_red_led(void); + +#ifdef __cplusplus +} +#endif + +#endif // GPIO_H diff --git a/examples/baremetal/stm8s103f3/redblink/main.c b/examples/baremetal/stm8s103f3/redblink/main.c new file mode 100644 index 00000000..63c1c0ae --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/main.c @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "gpio.h" +#include "system.h" + +static void some_delay(unsigned long counts) +{ + unsigned long index = 0u; + for (index = 0u; index < counts; ++index) + system_nop(); +} + +int main(void) +{ + gpio_init_red_led(); + + while (1) { + gpio_toggle_red_led(); + some_delay(20000u); + } +} diff --git a/examples/baremetal/stm8s103f3/redblink/redblink.qbs b/examples/baremetal/stm8s103f3/redblink/redblink.qbs new file mode 100644 index 00000000..c01f323c --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/redblink.qbs @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + condition: { + if (!qbs.architecture.contains("stm8")) + return false; + return qbs.toolchain.contains("iar") + || qbs.toolchain.contains("sdcc") + } + name: "stm8s103f3-redblink" + cpp.positionIndependentCode: false + + // + // IAR-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("iar") + cpp.commonCompilerFlags: ["-e"] + cpp.driverLinkerFlags: [ + "--config_def", "_CSTACK_SIZE=0x100", + "--config_def", "_HEAP_SIZE=0x100", + ] + } + + Group { + condition: qbs.toolchain.contains("iar") + name: "IAR" + prefix: "iar/" + Group { + name: "Linker Script" + prefix: cpp.toolchainInstallPath + "/../config/" + fileTags: ["linkerscript"] + files: ["lnkstm8s103f3.icf"] + } + } + + // + // SDCC-specific properties and sources. + // + + Properties { + condition: qbs.toolchain.contains("sdcc") + } + + // + // Common code. + // + + Group { + name: "Gpio" + files: ["gpio.c", "gpio.h"] + } + + Group { + name: "System" + files: ["system.h"] + } + + files: ["main.c"] +} diff --git a/examples/baremetal/stm8s103f3/redblink/system.h b/examples/baremetal/stm8s103f3/redblink/system.h new file mode 100644 index 00000000..463123ce --- /dev/null +++ b/examples/baremetal/stm8s103f3/redblink/system.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SYSTEM_H +#define SYSTEM_H + +#ifdef __cplusplus +extern "C" { +#endif + +// Define required registers of Port B (where the LED is connected): +// * PB_ODR - Output Data Register. +// * PB_DDR - Data Direction Register. +// * PB_CR1 - Control Register #1. +// * PB_CR2 - Control Register #2. + +#if defined(__ICCSTM8__) +# define system_nop() __asm("nop") +__near __no_init volatile unsigned char PB_ODR @ 0x5005; +__near __no_init volatile unsigned char PB_DDR @ 0x5007; +__near __no_init volatile unsigned char PB_CR1 @ 0x5008; +__near __no_init volatile unsigned char PB_CR2 @ 0x5009; +#elif defined (__SDCC_stm8) +# define system_nop() __asm nop __endasm +#define PB_ODR *(volatile unsigned char *)0x5005 +#define PB_DDR *(volatile unsigned char *)0x5007 +#define PB_CR1 *(volatile unsigned char *)0x5008 +#define PB_CR2 *(volatile unsigned char *)0x5009 +#else +#error "Unsupported toolchain" +#endif + +#ifdef __cplusplus +} +#endif + +#endif // SYSTEM_H diff --git a/examples/baremetal/stm8s103f3/stm8s103f3.qbs b/examples/baremetal/stm8s103f3/stm8s103f3.qbs new file mode 100644 index 00000000..cfbfc87a --- /dev/null +++ b/examples/baremetal/stm8s103f3/stm8s103f3.qbs @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + name: "Examples for stm8s103f3 board" + references: [ + "redblink/redblink.qbs" + ] +} diff --git a/examples/capnproto/addressbook_cpp/addressbook.capnp b/examples/capnproto/addressbook_cpp/addressbook.capnp new file mode 100644 index 00000000..1a6c6093 --- /dev/null +++ b/examples/capnproto/addressbook_cpp/addressbook.capnp @@ -0,0 +1,55 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0x9eb32e19f86ee174; + +using Cxx = import "/capnp/c++.capnp"; +$Cxx.namespace("addressbook"); + +struct Person { + id @0 :UInt32; + name @1 :Text; + email @2 :Text; + phones @3 :List(PhoneNumber); + + struct PhoneNumber { + number @0 :Text; + type @1 :Type; + + enum Type { + mobile @0; + home @1; + work @2; + } + } + + employment :union { + unemployed @4 :Void; + employer @5 :Text; + school @6 :Text; + selfEmployed @7 :Void; + # We assume that a person is only one of these. + } +} + +struct AddressBook { + people @0 :List(Person); +} diff --git a/examples/capnproto/addressbook_cpp/addressbook.cpp b/examples/capnproto/addressbook_cpp/addressbook.cpp new file mode 100644 index 00000000..b2bece94 --- /dev/null +++ b/examples/capnproto/addressbook_cpp/addressbook.cpp @@ -0,0 +1,288 @@ +// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +// Licensed under the MIT License: +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// This sample code appears in the documentation for the C++ implementation. +// +// If Cap'n Proto is installed, build the sample like: +// capnp compile -oc++ addressbook.capnp +// c++ -std=c++14 -Wall addressbook.c++ addressbook.capnp.c++ `pkg-config --cflags --libs capnp` -o addressbook +// +// If Cap'n Proto is not installed, but the source is located at $SRC and has been +// compiled in $BUILD (often both are simply ".." from here), you can do: +// $BUILD/capnp compile -I$SRC/src -o$BUILD/capnpc-c++ addressbook.capnp +// c++ -std=c++14 -Wall addressbook.c++ addressbook.capnp.c++ -I$SRC/src -L$BUILD/.libs -lcapnp -lkj -o addressbook +// +// Run like: +// ./addressbook write | ./addressbook read +// Use "dwrite" and "dread" to use dynamic code instead. + +// TODO(test): Needs cleanup. + +#include "addressbook.capnp.h" +#include +#include +#include + +using addressbook::Person; +using addressbook::AddressBook; + +void writeAddressBook(int fd) { + ::capnp::MallocMessageBuilder message; + + AddressBook::Builder addressBook = message.initRoot(); + ::capnp::List::Builder people = addressBook.initPeople(2); + + Person::Builder alice = people[0]; + alice.setId(123); + alice.setName("Alice"); + alice.setEmail("alice@example.com"); + // Type shown for explanation purposes; normally you'd use auto. + ::capnp::List::Builder alicePhones = + alice.initPhones(1); + alicePhones[0].setNumber("555-1212"); + alicePhones[0].setType(Person::PhoneNumber::Type::MOBILE); + alice.getEmployment().setSchool("MIT"); + + Person::Builder bob = people[1]; + bob.setId(456); + bob.setName("Bob"); + bob.setEmail("bob@example.com"); + auto bobPhones = bob.initPhones(2); + bobPhones[0].setNumber("555-4567"); + bobPhones[0].setType(Person::PhoneNumber::Type::HOME); + bobPhones[1].setNumber("555-7654"); + bobPhones[1].setType(Person::PhoneNumber::Type::WORK); + bob.getEmployment().setUnemployed(); + + writePackedMessageToFd(fd, message); +} + +void printAddressBook(int fd) { + ::capnp::PackedFdMessageReader message(fd); + + AddressBook::Reader addressBook = message.getRoot(); + + for (Person::Reader person : addressBook.getPeople()) { + std::cout << person.getName().cStr() << ": " + << person.getEmail().cStr() << std::endl; + for (Person::PhoneNumber::Reader phone: person.getPhones()) { + const char* typeName = "UNKNOWN"; + switch (phone.getType()) { + case Person::PhoneNumber::Type::MOBILE: typeName = "mobile"; break; + case Person::PhoneNumber::Type::HOME: typeName = "home"; break; + case Person::PhoneNumber::Type::WORK: typeName = "work"; break; + } + std::cout << " " << typeName << " phone: " + << phone.getNumber().cStr() << std::endl; + } + Person::Employment::Reader employment = person.getEmployment(); + switch (employment.which()) { + case Person::Employment::UNEMPLOYED: + std::cout << " unemployed" << std::endl; + break; + case Person::Employment::EMPLOYER: + std::cout << " employer: " + << employment.getEmployer().cStr() << std::endl; + break; + case Person::Employment::SCHOOL: + std::cout << " student at: " + << employment.getSchool().cStr() << std::endl; + break; + case Person::Employment::SELF_EMPLOYED: + std::cout << " self-employed" << std::endl; + break; + } + } +} + +#if !CAPNP_LITE + +#include "addressbook.capnp.h" +#include +#include +#include +#include +#include + +using ::capnp::DynamicValue; +using ::capnp::DynamicStruct; +using ::capnp::DynamicEnum; +using ::capnp::DynamicList; +using ::capnp::List; +using ::capnp::Schema; +using ::capnp::StructSchema; +using ::capnp::EnumSchema; + +using ::capnp::Void; +using ::capnp::Text; +using ::capnp::MallocMessageBuilder; +using ::capnp::PackedFdMessageReader; + +void dynamicWriteAddressBook(int fd, StructSchema schema) { + // Write a message using the dynamic API to set each + // field by text name. This isn't something you'd + // normally want to do; it's just for illustration. + + MallocMessageBuilder message; + + // Types shown for explanation purposes; normally you'd + // use auto. + DynamicStruct::Builder addressBook = + message.initRoot(schema); + + DynamicList::Builder people = + addressBook.init("people", 2).as(); + + DynamicStruct::Builder alice = + people[0].as(); + alice.set("id", 123); + alice.set("name", "Alice"); + alice.set("email", "alice@example.com"); + auto alicePhones = alice.init("phones", 1).as(); + auto phone0 = alicePhones[0].as(); + phone0.set("number", "555-1212"); + phone0.set("type", "mobile"); + alice.get("employment").as() + .set("school", "MIT"); + + auto bob = people[1].as(); + bob.set("id", 456); + bob.set("name", "Bob"); + bob.set("email", "bob@example.com"); + + // Some magic: We can convert a dynamic sub-value back to + // the native type with as()! + List::Builder bobPhones = + bob.init("phones", 2).as>(); + bobPhones[0].setNumber("555-4567"); + bobPhones[0].setType(Person::PhoneNumber::Type::HOME); + bobPhones[1].setNumber("555-7654"); + bobPhones[1].setType(Person::PhoneNumber::Type::WORK); + bob.get("employment").as() + .set("unemployed", ::capnp::VOID); + + writePackedMessageToFd(fd, message); +} + +void dynamicPrintValue(DynamicValue::Reader value) { + // Print an arbitrary message via the dynamic API by + // iterating over the schema. Look at the handling + // of STRUCT in particular. + + switch (value.getType()) { + case DynamicValue::VOID: + std::cout << ""; + break; + case DynamicValue::BOOL: + std::cout << (value.as() ? "true" : "false"); + break; + case DynamicValue::INT: + std::cout << value.as(); + break; + case DynamicValue::UINT: + std::cout << value.as(); + break; + case DynamicValue::FLOAT: + std::cout << value.as(); + break; + case DynamicValue::TEXT: + std::cout << '\"' << value.as().cStr() << '\"'; + break; + case DynamicValue::LIST: { + std::cout << "["; + bool first = true; + for (auto element: value.as()) { + if (first) { + first = false; + } else { + std::cout << ", "; + } + dynamicPrintValue(element); + } + std::cout << "]"; + break; + } + case DynamicValue::ENUM: { + auto enumValue = value.as(); + KJ_IF_MAYBE(enumerant, enumValue.getEnumerant()) { + std::cout << + enumerant->getProto().getName().cStr(); + } else { + // Unknown enum value; output raw number. + std::cout << enumValue.getRaw(); + } + break; + } + case DynamicValue::STRUCT: { + std::cout << "("; + auto structValue = value.as(); + bool first = true; + for (auto field: structValue.getSchema().getFields()) { + if (!structValue.has(field)) continue; + if (first) { + first = false; + } else { + std::cout << ", "; + } + std::cout << field.getProto().getName().cStr() + << " = "; + dynamicPrintValue(structValue.get(field)); + } + std::cout << ")"; + break; + } + default: + // There are other types, we aren't handling them. + std::cout << "?"; + break; + } +} + +void dynamicPrintMessage(int fd, StructSchema schema) { + PackedFdMessageReader message(fd); + dynamicPrintValue(message.getRoot(schema)); + std::cout << std::endl; +} + +#endif // !CAPNP_LITE + +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cerr << "Missing arg." << std::endl; + return 1; + } else if (strcmp(argv[1], "write") == 0) { + writeAddressBook(1); + } else if (strcmp(argv[1], "read") == 0) { + printAddressBook(0); +#if !CAPNP_LITE + } else if (strcmp(argv[1], "dwrite") == 0) { + StructSchema schema = Schema::from(); + dynamicWriteAddressBook(1, schema); + } else if (strcmp(argv[1], "dread") == 0) { + StructSchema schema = Schema::from(); + dynamicPrintMessage(0, schema); +#endif + } else { + std::cerr << "Invalid arg: " << argv[1] << std::endl; + return 1; + } + return 0; +} diff --git a/examples/capnproto/addressbook_cpp/addressbook_cpp.qbs b/examples/capnproto/addressbook_cpp/addressbook_cpp.qbs new file mode 100644 index 00000000..33f78d5a --- /dev/null +++ b/examples/capnproto/addressbook_cpp/addressbook_cpp.qbs @@ -0,0 +1,11 @@ +CppApplication { + Depends { name: "capnproto.cpp"; required: false } + condition: capnproto.cpp.present && qbs.targetPlatform === qbs.hostPlatform + consoleApplication: true + cpp.minimumMacosVersion: "10.8" + + files: [ + "addressbook.capnp", + "addressbook.cpp" + ] +} diff --git a/examples/capnproto/calculator_cpp/calculator-client.cpp b/examples/capnproto/calculator_cpp/calculator-client.cpp new file mode 100644 index 00000000..5d845292 --- /dev/null +++ b/examples/capnproto/calculator_cpp/calculator-client.cpp @@ -0,0 +1,367 @@ +// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +// Licensed under the MIT License: +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "calculator.capnp.h" +#include +#include +#include +#include + +class PowerFunction final: public Calculator::Function::Server { + // An implementation of the Function interface wrapping pow(). Note that + // we're implementing this on the client side and will pass a reference to + // the server. The server will then be able to make calls back to the client. + +public: + kj::Promise call(CallContext context) { + auto params = context.getParams().getParams(); + KJ_REQUIRE(params.size() == 2, "Wrong number of parameters."); + context.getResults().setValue(pow(params[0], params[1])); + return kj::READY_NOW; + } +}; + +int main(int argc, const char* argv[]) { + if (argc != 2) { + std::cerr << "usage: " << argv[0] << " HOST:PORT\n" + "Connects to the Calculator server at the given address and " + "does some RPCs." << std::endl; + return 1; + } + + capnp::EzRpcClient client(argv[1]); + Calculator::Client calculator = client.getMain(); + + // Keep an eye on `waitScope`. Whenever you see it used is a place where we + // stop and wait for the server to respond. If a line of code does not use + // `waitScope`, then it does not block! + auto& waitScope = client.getWaitScope(); + + { + // Make a request that just evaluates the literal value 123. + // + // What's interesting here is that evaluate() returns a "Value", which is + // another interface and therefore points back to an object living on the + // server. We then have to call read() on that object to read it. + // However, even though we are making two RPC's, this block executes in + // *one* network round trip because of promise pipelining: we do not wait + // for the first call to complete before we send the second call to the + // server. + + std::cout << "Evaluating a literal... "; + std::cout.flush(); + + // Set up the request. + auto request = calculator.evaluateRequest(); + request.getExpression().setLiteral(123); + + // Send it, which returns a promise for the result (without blocking). + auto evalPromise = request.send(); + + // Using the promise, create a pipelined request to call read() on the + // returned object, and then send that. + auto readPromise = evalPromise.getValue().readRequest().send(); + + // Now that we've sent all the requests, wait for the response. Until this + // point, we haven't waited at all! + auto response = readPromise.wait(waitScope); + KJ_ASSERT(response.getValue() == 123); + + std::cout << "PASS" << std::endl; + } + + { + // Make a request to evaluate 123 + 45 - 67. + // + // The Calculator interface requires that we first call getOperator() to + // get the addition and subtraction functions, then call evaluate() to use + // them. But, once again, we can get both functions, call evaluate(), and + // then read() the result -- four RPCs -- in the time of *one* network + // round trip, because of promise pipelining. + + std::cout << "Using add and subtract... "; + std::cout.flush(); + + Calculator::Function::Client add = nullptr; + Calculator::Function::Client subtract = nullptr; + + { + // Get the "add" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::ADD); + add = request.send().getFunc(); + } + + { + // Get the "subtract" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::SUBTRACT); + subtract = request.send().getFunc(); + } + + // Build the request to evaluate 123 + 45 - 67. + auto request = calculator.evaluateRequest(); + + auto subtractCall = request.getExpression().initCall(); + subtractCall.setFunction(subtract); + auto subtractParams = subtractCall.initParams(2); + subtractParams[1].setLiteral(67); + + auto addCall = subtractParams[0].initCall(); + addCall.setFunction(add); + auto addParams = addCall.initParams(2); + addParams[0].setLiteral(123); + addParams[1].setLiteral(45); + + // Send the evaluate() request, read() the result, and wait for read() to + // finish. + auto evalPromise = request.send(); + auto readPromise = evalPromise.getValue().readRequest().send(); + + auto response = readPromise.wait(waitScope); + KJ_ASSERT(response.getValue() == 101); + + std::cout << "PASS" << std::endl; + } + + { + // Make a request to evaluate 4 * 6, then use the result in two more + // requests that add 3 and 5. + // + // Since evaluate() returns its result wrapped in a `Value`, we can pass + // that `Value` back to the server in subsequent requests before the first + // `evaluate()` has actually returned. Thus, this example again does only + // one network round trip. + + std::cout << "Pipelining eval() calls... "; + std::cout.flush(); + + Calculator::Function::Client add = nullptr; + Calculator::Function::Client multiply = nullptr; + + { + // Get the "add" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::ADD); + add = request.send().getFunc(); + } + + { + // Get the "multiply" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::MULTIPLY); + multiply = request.send().getFunc(); + } + + // Build the request to evaluate 4 * 6 + auto request = calculator.evaluateRequest(); + + auto multiplyCall = request.getExpression().initCall(); + multiplyCall.setFunction(multiply); + auto multiplyParams = multiplyCall.initParams(2); + multiplyParams[0].setLiteral(4); + multiplyParams[1].setLiteral(6); + + auto multiplyResult = request.send().getValue(); + + // Use the result in two calls that add 3 and add 5. + + auto add3Request = calculator.evaluateRequest(); + auto add3Call = add3Request.getExpression().initCall(); + add3Call.setFunction(add); + auto add3Params = add3Call.initParams(2); + add3Params[0].setPreviousResult(multiplyResult); + add3Params[1].setLiteral(3); + auto add3Promise = add3Request.send().getValue().readRequest().send(); + + auto add5Request = calculator.evaluateRequest(); + auto add5Call = add5Request.getExpression().initCall(); + add5Call.setFunction(add); + auto add5Params = add5Call.initParams(2); + add5Params[0].setPreviousResult(multiplyResult); + add5Params[1].setLiteral(5); + auto add5Promise = add5Request.send().getValue().readRequest().send(); + + // Now wait for the results. + KJ_ASSERT(add3Promise.wait(waitScope).getValue() == 27); + KJ_ASSERT(add5Promise.wait(waitScope).getValue() == 29); + + std::cout << "PASS" << std::endl; + } + + { + // Our calculator interface supports defining functions. Here we use it + // to define two functions and then make calls to them as follows: + // + // f(x, y) = x * 100 + y + // g(x) = f(x, x + 1) * 2; + // f(12, 34) + // g(21) + // + // Once again, the whole thing takes only one network round trip. + + std::cout << "Defining functions... "; + std::cout.flush(); + + Calculator::Function::Client add = nullptr; + Calculator::Function::Client multiply = nullptr; + Calculator::Function::Client f = nullptr; + Calculator::Function::Client g = nullptr; + + { + // Get the "add" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::ADD); + add = request.send().getFunc(); + } + + { + // Get the "multiply" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::MULTIPLY); + multiply = request.send().getFunc(); + } + + { + // Define f. + auto request = calculator.defFunctionRequest(); + request.setParamCount(2); + + { + // Build the function body. + auto addCall = request.getBody().initCall(); + addCall.setFunction(add); + auto addParams = addCall.initParams(2); + addParams[1].setParameter(1); // y + + auto multiplyCall = addParams[0].initCall(); + multiplyCall.setFunction(multiply); + auto multiplyParams = multiplyCall.initParams(2); + multiplyParams[0].setParameter(0); // x + multiplyParams[1].setLiteral(100); + } + + f = request.send().getFunc(); + } + + { + // Define g. + auto request = calculator.defFunctionRequest(); + request.setParamCount(1); + + { + // Build the function body. + auto multiplyCall = request.getBody().initCall(); + multiplyCall.setFunction(multiply); + auto multiplyParams = multiplyCall.initParams(2); + multiplyParams[1].setLiteral(2); + + auto fCall = multiplyParams[0].initCall(); + fCall.setFunction(f); + auto fParams = fCall.initParams(2); + fParams[0].setParameter(0); + + auto addCall = fParams[1].initCall(); + addCall.setFunction(add); + auto addParams = addCall.initParams(2); + addParams[0].setParameter(0); + addParams[1].setLiteral(1); + } + + g = request.send().getFunc(); + } + + // OK, we've defined all our functions. Now create our eval requests. + + // f(12, 34) + auto fEvalRequest = calculator.evaluateRequest(); + auto fCall = fEvalRequest.initExpression().initCall(); + fCall.setFunction(f); + auto fParams = fCall.initParams(2); + fParams[0].setLiteral(12); + fParams[1].setLiteral(34); + auto fEvalPromise = fEvalRequest.send().getValue().readRequest().send(); + + // g(21) + auto gEvalRequest = calculator.evaluateRequest(); + auto gCall = gEvalRequest.initExpression().initCall(); + gCall.setFunction(g); + gCall.initParams(1)[0].setLiteral(21); + auto gEvalPromise = gEvalRequest.send().getValue().readRequest().send(); + + // Wait for the results. + KJ_ASSERT(fEvalPromise.wait(waitScope).getValue() == 1234); + KJ_ASSERT(gEvalPromise.wait(waitScope).getValue() == 4244); + + std::cout << "PASS" << std::endl; + } + + { + // Make a request that will call back to a function defined locally. + // + // Specifically, we will compute 2^(4 + 5). However, exponent is not + // defined by the Calculator server. So, we'll implement the Function + // interface locally and pass it to the server for it to use when + // evaluating the expression. + // + // This example requires two network round trips to complete, because the + // server calls back to the client once before finishing. In this + // particular case, this could potentially be optimized by using a tail + // call on the server side -- see CallContext::tailCall(). However, to + // keep the example simpler, we haven't implemented this optimization in + // the sample server. + + std::cout << "Using a callback... "; + std::cout.flush(); + + Calculator::Function::Client add = nullptr; + + { + // Get the "add" function from the server. + auto request = calculator.getOperatorRequest(); + request.setOp(Calculator::Operator::ADD); + add = request.send().getFunc(); + } + + // Build the eval request for 2^(4+5). + auto request = calculator.evaluateRequest(); + + auto powCall = request.getExpression().initCall(); + powCall.setFunction(kj::heap()); + auto powParams = powCall.initParams(2); + powParams[0].setLiteral(2); + + auto addCall = powParams[1].initCall(); + addCall.setFunction(add); + auto addParams = addCall.initParams(2); + addParams[0].setLiteral(4); + addParams[1].setLiteral(5); + + // Send the request and wait. + auto response = request.send().getValue().readRequest() + .send().wait(waitScope); + KJ_ASSERT(response.getValue() == 512); + + std::cout << "PASS" << std::endl; + } + + return 0; +} diff --git a/examples/capnproto/calculator_cpp/calculator-server.cpp b/examples/capnproto/calculator_cpp/calculator-server.cpp new file mode 100644 index 00000000..c2593be3 --- /dev/null +++ b/examples/capnproto/calculator_cpp/calculator-server.cpp @@ -0,0 +1,215 @@ +// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +// Licensed under the MIT License: +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "calculator.capnp.h" +#include +#include +#include +#include + +typedef unsigned int uint; + +kj::Promise readValue(Calculator::Value::Client value) { + // Helper function to asynchronously call read() on a Calculator::Value and + // return a promise for the result. (In the future, the generated code might + // include something like this automatically.) + + return value.readRequest().send() + .then([](capnp::Response result) { + return result.getValue(); + }); +} + +kj::Promise evaluateImpl( + Calculator::Expression::Reader expression, + capnp::List::Reader params = capnp::List::Reader()) { + // Implementation of CalculatorImpl::evaluate(), also shared by + // FunctionImpl::call(). In the latter case, `params` are the parameter + // values passed to the function; in the former case, `params` is just an + // empty list. + + switch (expression.which()) { + case Calculator::Expression::LITERAL: + return expression.getLiteral(); + + case Calculator::Expression::PREVIOUS_RESULT: + return readValue(expression.getPreviousResult()); + + case Calculator::Expression::PARAMETER: { + KJ_REQUIRE(expression.getParameter() < params.size(), + "Parameter index out-of-range."); + return params[expression.getParameter()]; + } + + case Calculator::Expression::CALL: { + auto call = expression.getCall(); + auto func = call.getFunction(); + + // Evaluate each parameter. + kj::Array> paramPromises = + KJ_MAP(param, call.getParams()) { + return evaluateImpl(param, params); + }; + + // Join the array of promises into a promise for an array. + kj::Promise> joinedParams = + kj::joinPromises(kj::mv(paramPromises)); + + // When the parameters are complete, call the function. + return joinedParams.then([KJ_CPCAP(func)](kj::Array&& paramValues) mutable { + auto request = func.callRequest(); + request.setParams(paramValues); + return request.send().then( + [](capnp::Response&& result) { + return result.getValue(); + }); + }); + } + + default: + // Throw an exception. + KJ_FAIL_REQUIRE("Unknown expression type."); + } +} + +class ValueImpl final: public Calculator::Value::Server { + // Simple implementation of the Calculator.Value Cap'n Proto interface. + +public: + ValueImpl(double value): value(value) {} + + kj::Promise read(ReadContext context) { + context.getResults().setValue(value); + return kj::READY_NOW; + } + +private: + double value; +}; + +class FunctionImpl final: public Calculator::Function::Server { + // Implementation of the Calculator.Function Cap'n Proto interface, where the + // function is defined by a Calculator.Expression. + +public: + FunctionImpl(uint paramCount, Calculator::Expression::Reader body) + : paramCount(paramCount) { + this->body.setRoot(body); + } + + kj::Promise call(CallContext context) { + auto params = context.getParams().getParams(); + KJ_REQUIRE(params.size() == paramCount, "Wrong number of parameters."); + + return evaluateImpl(body.getRoot(), params) + .then([KJ_CPCAP(context)](double value) mutable { + context.getResults().setValue(value); + }); + } + +private: + uint paramCount; + // The function's arity. + + capnp::MallocMessageBuilder body; + // Stores a permanent copy of the function body. +}; + +class OperatorImpl final: public Calculator::Function::Server { + // Implementation of the Calculator.Function Cap'n Proto interface, wrapping + // basic binary arithmetic operators. + +public: + OperatorImpl(Calculator::Operator op): op(op) {} + + kj::Promise call(CallContext context) { + auto params = context.getParams().getParams(); + KJ_REQUIRE(params.size() == 2, "Wrong number of parameters."); + + double result; + switch (op) { + case Calculator::Operator::ADD: result = params[0] + params[1]; break; + case Calculator::Operator::SUBTRACT:result = params[0] - params[1]; break; + case Calculator::Operator::MULTIPLY:result = params[0] * params[1]; break; + case Calculator::Operator::DIVIDE: result = params[0] / params[1]; break; + default: + KJ_FAIL_REQUIRE("Unknown operator."); + } + + context.getResults().setValue(result); + return kj::READY_NOW; + } + +private: + Calculator::Operator op; +}; + +class CalculatorImpl final: public Calculator::Server { + // Implementation of the Calculator Cap'n Proto interface. + +public: + kj::Promise evaluate(EvaluateContext context) override { + return evaluateImpl(context.getParams().getExpression()) + .then([KJ_CPCAP(context)](double value) mutable { + context.getResults().setValue(kj::heap(value)); + }); + } + + kj::Promise defFunction(DefFunctionContext context) override { + auto params = context.getParams(); + context.getResults().setFunc(kj::heap( + params.getParamCount(), params.getBody())); + return kj::READY_NOW; + } + + kj::Promise getOperator(GetOperatorContext context) override { + context.getResults().setFunc(kj::heap( + context.getParams().getOp())); + return kj::READY_NOW; + } +}; + +int main(int argc, const char* argv[]) { + if (argc != 2) { + std::cerr << "usage: " << argv[0] << " ADDRESS[:PORT]\n" + "Runs the server bound to the given address/port.\n" + "ADDRESS may be '*' to bind to all local addresses.\n" + ":PORT may be omitted to choose a port automatically." << std::endl; + return 1; + } + + // Set up a server. + capnp::EzRpcServer server(kj::heap(), argv[1]); + + // Write the port number to stdout, in case it was chosen automatically. + auto& waitScope = server.getWaitScope(); + uint port = server.getPort().wait(waitScope); + if (port == 0) { + // The address format "unix:/path/to/socket" opens a unix domain socket, + // in which case the port will be zero. + std::cout << "Listening on Unix socket..." << std::endl; + } else { + std::cout << "Listening on port " << port << "..." << std::endl; + } + + // Run forever, accepting connections and handling requests. + kj::NEVER_DONE.wait(waitScope); +} diff --git a/examples/capnproto/calculator_cpp/calculator.capnp b/examples/capnproto/calculator_cpp/calculator.capnp new file mode 100644 index 00000000..adc8294e --- /dev/null +++ b/examples/capnproto/calculator_cpp/calculator.capnp @@ -0,0 +1,118 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0x85150b117366d14b; + +interface Calculator { + # A "simple" mathematical calculator, callable via RPC. + # + # But, to show off Cap'n Proto, we add some twists: + # + # - You can use the result from one call as the input to the next + # without a network round trip. To accomplish this, evaluate() + # returns a `Value` object wrapping the actual numeric value. + # This object may be used in a subsequent expression. With + # promise pipelining, the Value can actually be used before + # the evaluate() call that creates it returns! + # + # - You can define new functions, and then call them. This again + # shows off pipelining, but it also gives the client the + # opportunity to define a function on the client side and have + # the server call back to it. + # + # - The basic arithmetic operators are exposed as Functions, and + # you have to call getOperator() to obtain them from the server. + # This again demonstrates pipelining -- using getOperator() to + # get each operator and then using them in evaluate() still + # only takes one network round trip. + + evaluate @0 (expression :Expression) -> (value :Value); + # Evaluate the given expression and return the result. The + # result is returned wrapped in a Value interface so that you + # may pass it back to the server in a pipelined request. To + # actually get the numeric value, you must call read() on the + # Value -- but again, this can be pipelined so that it incurs + # no additional latency. + + struct Expression { + # A numeric expression. + + union { + literal @0 :Float64; + # A literal numeric value. + + previousResult @1 :Value; + # A value that was (or, will be) returned by a previous + # evaluate(). + + parameter @2 :UInt32; + # A parameter to the function (only valid in function bodies; + # see defFunction). + + call :group { + # Call a function on a list of parameters. + function @3 :Function; + params @4 :List(Expression); + } + } + } + + interface Value { + # Wraps a numeric value in an RPC object. This allows the value + # to be used in subsequent evaluate() requests without the client + # waiting for the evaluate() that returns the Value to finish. + + read @0 () -> (value :Float64); + # Read back the raw numeric value. + } + + defFunction @1 (paramCount :Int32, body :Expression) + -> (func :Function); + # Define a function that takes `paramCount` parameters and returns the + # evaluation of `body` after substituting these parameters. + + interface Function { + # An algebraic function. Can be called directly, or can be used inside + # an Expression. + # + # A client can create a Function that runs on the server side using + # `defFunction()` or `getOperator()`. Alternatively, a client can + # implement a Function on the client side and the server will call back + # to it. However, a function defined on the client side will require a + # network round trip whenever the server needs to call it, whereas + # functions defined on the server and then passed back to it are called + # locally. + + call @0 (params :List(Float64)) -> (value :Float64); + # Call the function on the given parameters. + } + + getOperator @2 (op :Operator) -> (func :Function); + # Get a Function representing an arithmetic operator, which can then be + # used in Expressions. + + enum Operator { + add @0; + subtract @1; + multiply @2; + divide @3; + } +} diff --git a/examples/capnproto/calculator_cpp/calculator_cpp.qbs b/examples/capnproto/calculator_cpp/calculator_cpp.qbs new file mode 100644 index 00000000..a884117b --- /dev/null +++ b/examples/capnproto/calculator_cpp/calculator_cpp.qbs @@ -0,0 +1,28 @@ +import qbs.Host + +Project { + CppApplication { + Depends { name: "capnproto.cpp"; required: false } + name: "server" + condition: capnproto.cpp.present && qbs.targetPlatform === Host.platform() + consoleApplication: true + capnproto.cpp.useRpc: true + + files: [ + "calculator.capnp", + "calculator-server.cpp" + ] + } + CppApplication { + Depends { name: "capnproto.cpp"; required: false } + name: "client" + condition: capnproto.cpp.present && qbs.targetPlatform === Host.platform() + consoleApplication: true + capnproto.cpp.useRpc: true + + files: [ + "calculator.capnp", + "calculator-client.cpp" + ] + } +} diff --git a/examples/cocoa-application/CocoaApplication.xcodeproj/project.pbxproj b/examples/cocoa-application/CocoaApplication.xcodeproj/project.pbxproj new file mode 100644 index 00000000..a284a776 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication.xcodeproj/project.pbxproj @@ -0,0 +1,309 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 14ABF7A71717761200140DA2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14ABF7A61717761200140DA2 /* Cocoa.framework */; }; + 14ABF7B11717761200140DA2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 14ABF7AF1717761200140DA2 /* InfoPlist.strings */; }; + 14ABF7B31717761200140DA2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 14ABF7B21717761200140DA2 /* main.m */; }; + 14ABF7B71717761200140DA2 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 14ABF7B51717761200140DA2 /* Credits.rtf */; }; + 14ABF7BA1717761200140DA2 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 14ABF7B91717761200140DA2 /* AppDelegate.m */; }; + 14ABF7BD1717761300140DA2 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14ABF7BB1717761300140DA2 /* MainMenu.xib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 14ABF7A31717761200140DA2 /* Cocoa Application.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cocoa Application.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 14ABF7A61717761200140DA2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + 14ABF7A91717761200140DA2 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; + 14ABF7AA1717761200140DA2 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; + 14ABF7AB1717761200140DA2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 14ABF7AE1717761200140DA2 /* CocoaApplication-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CocoaApplication-Info.plist"; sourceTree = ""; }; + 14ABF7B01717761200140DA2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 14ABF7B21717761200140DA2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 14ABF7B41717761200140DA2 /* CocoaApplication-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CocoaApplication-Prefix.pch"; sourceTree = ""; }; + 14ABF7B61717761200140DA2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; + 14ABF7B81717761200140DA2 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 14ABF7B91717761200140DA2 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 14ABF7BC1717761300140DA2 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 14ABF7A01717761200140DA2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 14ABF7A71717761200140DA2 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 14ABF79A1717761200140DA2 = { + isa = PBXGroup; + children = ( + 14ABF7AC1717761200140DA2 /* CocoaApplication */, + 14ABF7A51717761200140DA2 /* Frameworks */, + 14ABF7A41717761200140DA2 /* Products */, + ); + sourceTree = ""; + }; + 14ABF7A41717761200140DA2 /* Products */ = { + isa = PBXGroup; + children = ( + 14ABF7A31717761200140DA2 /* Cocoa Application.app */, + ); + name = Products; + sourceTree = ""; + }; + 14ABF7A51717761200140DA2 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 14ABF7A61717761200140DA2 /* Cocoa.framework */, + 14ABF7A81717761200140DA2 /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + 14ABF7A81717761200140DA2 /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 14ABF7A91717761200140DA2 /* AppKit.framework */, + 14ABF7AA1717761200140DA2 /* CoreData.framework */, + 14ABF7AB1717761200140DA2 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 14ABF7AC1717761200140DA2 /* CocoaApplication */ = { + isa = PBXGroup; + children = ( + 14ABF7B81717761200140DA2 /* AppDelegate.h */, + 14ABF7B91717761200140DA2 /* AppDelegate.m */, + 14ABF7BB1717761300140DA2 /* MainMenu.xib */, + 14ABF7AD1717761200140DA2 /* Supporting Files */, + ); + path = CocoaApplication; + sourceTree = ""; + }; + 14ABF7AD1717761200140DA2 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 14ABF7AE1717761200140DA2 /* CocoaApplication-Info.plist */, + 14ABF7AF1717761200140DA2 /* InfoPlist.strings */, + 14ABF7B21717761200140DA2 /* main.m */, + 14ABF7B41717761200140DA2 /* CocoaApplication-Prefix.pch */, + 14ABF7B51717761200140DA2 /* Credits.rtf */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 14ABF7A21717761200140DA2 /* Cocoa Application */ = { + isa = PBXNativeTarget; + buildConfigurationList = 14ABF7C01717761300140DA2 /* Build configuration list for PBXNativeTarget "Cocoa Application" */; + buildPhases = ( + 14ABF79F1717761200140DA2 /* Sources */, + 14ABF7A01717761200140DA2 /* Frameworks */, + 14ABF7A11717761200140DA2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Cocoa Application"; + productName = CocoaApplication; + productReference = 14ABF7A31717761200140DA2 /* Cocoa Application.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 14ABF79B1717761200140DA2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = "Petroules Corporation"; + }; + buildConfigurationList = 14ABF79E1717761200140DA2 /* Build configuration list for PBXProject "CocoaApplication" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 14ABF79A1717761200140DA2; + productRefGroup = 14ABF7A41717761200140DA2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 14ABF7A21717761200140DA2 /* Cocoa Application */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 14ABF7A11717761200140DA2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14ABF7B11717761200140DA2 /* InfoPlist.strings in Resources */, + 14ABF7B71717761200140DA2 /* Credits.rtf in Resources */, + 14ABF7BD1717761300140DA2 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 14ABF79F1717761200140DA2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14ABF7B31717761200140DA2 /* main.m in Sources */, + 14ABF7BA1717761200140DA2 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 14ABF7AF1717761200140DA2 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 14ABF7B01717761200140DA2 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 14ABF7B51717761200140DA2 /* Credits.rtf */ = { + isa = PBXVariantGroup; + children = ( + 14ABF7B61717761200140DA2 /* en */, + ); + name = Credits.rtf; + sourceTree = ""; + }; + 14ABF7BB1717761300140DA2 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 14ABF7BC1717761300140DA2 /* en */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 14ABF7BE1717761300140DA2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 14ABF7BF1717761300140DA2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.8; + SDKROOT = macosx; + }; + name = Release; + }; + 14ABF7C11717761300140DA2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CocoaApplication/CocoaApplication-Prefix.pch"; + INFOPLIST_FILE = "CocoaApplication/CocoaApplication-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 14ABF7C21717761300140DA2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CocoaApplication/CocoaApplication-Prefix.pch"; + INFOPLIST_FILE = "CocoaApplication/CocoaApplication-Info.plist"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 14ABF79E1717761200140DA2 /* Build configuration list for PBXProject "CocoaApplication" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14ABF7BE1717761300140DA2 /* Debug */, + 14ABF7BF1717761300140DA2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 14ABF7C01717761300140DA2 /* Build configuration list for PBXNativeTarget "Cocoa Application" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14ABF7C11717761300140DA2 /* Debug */, + 14ABF7C21717761300140DA2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 14ABF79B1717761200140DA2 /* Project object */; +} diff --git a/examples/cocoa-application/CocoaApplication/AppDelegate.h b/examples/cocoa-application/CocoaApplication/AppDelegate.h new file mode 100644 index 00000000..563a1b2f --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/AppDelegate.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#import + +@interface AppDelegate : NSObject + +@property (nonatomic, assign) IBOutlet NSWindow *window; + +@end diff --git a/examples/cocoa-application/CocoaApplication/AppDelegate.m b/examples/cocoa-application/CocoaApplication/AppDelegate.m new file mode 100644 index 00000000..8fd5c49c --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/AppDelegate.m @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import "AppDelegate.h" + +@implementation AppDelegate + +@synthesize window = _window; + +- (void)dealloc +{ + [super dealloc]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *) __unused aNotification +{ + // Insert code here to initialize your application +} + +@end diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication-Info.plist b/examples/cocoa-application/CocoaApplication/CocoaApplication-Info.plist new file mode 100644 index 00000000..136a7b5e --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/CocoaApplication-Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + org.example.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSHumanReadableCopyright + Copyright © 2014 Petroules Corporation. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication-Prefix.pch b/examples/cocoa-application/CocoaApplication/CocoaApplication-Prefix.pch new file mode 100644 index 00000000..d7206045 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/CocoaApplication-Prefix.pch @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifdef __OBJC__ + #import +#endif diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/Contents.json b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..7cd4f8e1 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "icon_16x16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "icon_16x16@2x.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "icon_32x32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "icon_32x32@2x.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "icon_128x128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "icon_128x128@2x.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "icon_256x256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "icon_256x256@2x.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "icon_512x512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "icon_512x512@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..6c556a8356d0a818c45a42ca845502a8b2e460a7 GIT binary patch literal 5256 zcmb7IXE+>8w4Pmy)uJQ>QKN>aK}208M080cdT-IAEvu{$qSxpVB_fF+SQ2%$5Ya=# zBHHRDR?n)}cYoc#_s4r?p68r7GiT;~o_A(q4D>W3^b6h>U#sB!btzYO9SnaNh6p6TcZUGqu=!`>-qUB>&CA z^kM#Cf8g1mPyS|}Yt0R#xA#)6-;KTU|LiPqG1hc^W0dbZSQ@N^akkz`_R$(>>nyn< z|IK##xwBFT2VAvR+bcB6hjc*9tD=j@H}H#5{#(|Ut9Q=heOz)Lzab5$QyMa5qMi2Y zC!fKhR(Rfxhb--yy!xby7K0+-oJ%cinA1&0-BRH;6H2tzv(Su;U-K<6XfvS<+x)3V zhfk^(LSS8vl^RsCBi(C1C%t-hlTSPe%-+r`8moBGfF-FRtb(&lE$As z^%AT_E`@yrvyja&oLQJ4O!jm>I3wury3dQhiVcHB6@Q%+Q_l;5b@)N%TWII{^gkZW z*T=UTQ&4FpcTtt!J|{;GT7+`k3StEY&-;`q>1Y&)-O>rJ9d!%plKMlxrd&75@L@G< zV2l0e-v@wj5kg4qjdDiCOa(fK?ehK!MdrTX+poF;bY-36xh;H}GE!Oq??e`mAwVyGc$Bf`FDc&-!Vb#Eh+m-ME zuSMJyz?+{^*Xs3bYsZ0GYFj(A+cLKv=jFzm%CB6Gb7F34sGuj=6%noWQ-I5wXHt$wVd(7Bf)u+8S+_dN5K~lhV zM7ZZf3V6;A_5?d(ncV9N2g;KF6*{3lH5goLNKto6Kyi%Q{|%0I50QG9#(Jz1J@G5b zQ*wgf3KS$SNEF=)FcNuE`cZ-x5P+P~NDn?vFG-7PPo^&)ocIU~n88ZW zNo7=8EMe$});0en`7aE5lz;;ux{DPR^U2PtdVH(rnvHk(8UC9OksB#`5vvp?EZ}|; zXeZ#cUGnR{%xGoyzs?L~mQ}t#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rhuXn|>)I@W3grYgyuME<<%l`0z z3djoJ1DcfVzbEU49POEm*SSwtHF=Yi`l^g5S1;D)wl!-09pND#7N03y3A3KNQ!TPVFZA-2P=XrXB z`|BYvSh#&uZ>mX!j%t|(G_vQ6k7Cb({ddvf)1lg5D>aV<-$o3*;j`j-LNWbCL?wB% z+p@dbo-v=t;303gagln$?EO7U(uO*=kUFUZJ}O1TMVJcL5j%;Nv&xk;@-*?b!IiJ+ zyep}7oY)Ql0|8$?q%sI^=I917+RUGWb-m@Gk5vzS5MSGsw9jd$BJQQ#jEH-5@xutT M?&_&ms9Hb&A3*vBzW@LL literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_128x128@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..4442d3eb27fa4973c50d3cab6069e933d9e7c02d GIT binary patch literal 11304 zcmd6Ng{(uE(;3IZxTG{3g1!nQe=N|iW^pc93Oswul0SON_tkI|#eUa` zL48!&CpnNSg^BNkp$oa?H|? z{YZ9|I@$iCGbEUd|3v6%9s~dI;fY|ExajjI$D;k=S~-QLpZHVMFd1DZCT6v7gYKNT z$b+ervrR$;-JW7QU1?gk3U}7$c(q2wQ->Uc8gAxM^21R_af+O=!E1{Tat|YJh6(~x zj4YCKpcb&F6khuKS&N;`7p{;gtz0TN*|wZmiG|TV*zPX=nc;UbJigf^#CxSUWLS%v z8s0NND_8;k7bplU#6yO(dm)RxIU&Eaa;cS#u718#wru1l3Uybe>9zjQt4FQ|;Dw%R z^psIKy8~p{i0u zvBfXTj$|#dB?0a|HwsQ#^weQusy(Y;AhFZItkFG~Pcha63*HItIYAlDIlc+bDW}kO zrvrl>1Z-Z;$o}8h4y>W2Tm z9mmBe?LWjA)*WwIr@o?2|8>`YSg{#uQN%ukD?K!spx^Yl~et5dy zq*7*I!+Uz)$B`E2Ws3y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1TAKK~E`GX58zYwgiusz#hvq)XKDjv?bWll=YUsHidNcz7$U+Q*NO%gH4Dw?n!Ra$IpwJ>xjUr( zA=cILzs60haUn#nu<&ZMs6UEc@l=1P(QVd|SgW@!S(SLB>Y&tNU2a_2@zIw;kzLk( zu37iX146leKDgja>|e0V)7%l|%0q&|q(>pu=C}bLSz&cq<@tuQQkW21*G8G1K0qUz zmp4O}s$T`nym`tT9&=piDk%9w<2nybO_kJud1?gS{JLvs!=pE}mQ%{O;LuybQ_gu@ z1mm+D-+M1$8lmTD1B>OQJ1tt$Xzy{C@NZO3Ir(m9)WXT$(ji2M*SJHuXhe%*0I!t| z!IiR-_{vx_w{j8Hwujf(j0Tilgx^CTCO<6qLF2#xs_#B=IZT}>f7xiWkal^K}E_z)8l!*^LVhhA5 z$x=bA2LF2UqopPa9tpmx@hHSetJB^TuPC_@9M-k?#W-ke(-}p&q(bWDOrB=W{8l0J zXsgpE?u{4&+1-3fb==DnSB)IKU_u+6NSpiN-JnRVJcd=NcpWyfXB<8e(Vqfo);|nS zIiHdyt4UG{&@FX${`pQ|&CefOyut@`GKe$%zu(<5E)sx#?=F6yb3mH-1u&qkuB%q{ I&?fSK0D}4Yvj6}9 literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_16x16.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..2adcdb5f49180b2c150612ec2849e152da141eb5 GIT binary patch literal 487 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbMfs{o%6S0MfW|Ns5__pe*GZriqP zE@wiMkLGROym{-^ty{Ki*|lpIkg@CF?wvb#9zA*#NIISk0-}=Rb*E09I(YElkt0Wd zT&J_aKBr>*PR06Pj1M>!A8;`t=1NxVm7L@g`N`J`Q?39g*(_V9@qwCnj-Ul<5 zo?5x`%(^WHw(dQ-|G?$L$BrF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NS3Pd;RPg-p@4vTYw=yPIzuXAB@;RfOJqIge_a5aDJQ?%cDO&>8{ z|M*xr0_IU&cm47jI1IfUeBEVvNrkrl#mfPfd4I>H&`+)Q_y||)-TYO_xfl<3exTzj zPep0kn~)0y_~73!Zr(H&U`uy2bY6)LU{mt!lCz!9lsXXEVM*!z+hT9;a7?NkjS^*c zt#19M^`=*Yd&UzbV;&n57v@gjFZ+YBCUx7E%14V1Rn^t&xh>WB8Nbf4&#{$m6{EYo z4I)_M+ao_|kP|t`+=JdN>%Mea;o<5$TbNnN&eP?Zs&Tdc`)hu~-DZhW3Wi;nO~2y8 z&HfHODx;lp`YZoLX472xtP`UBBF|eX^g8E;e9H38HQl_fT40rGkQdU#BS_U9I$6&R z-5q~AXirTf99axz((cvT2Z&9<_aKUNA4pL#$B8X>R$OvDBCGa?1YX`Mn=3#Ebr7WR z+)VPukd0rzrZn9=8A9DkY`dGBjX=yjtc|F^Jr8}7pAdDvV>l-xIz_YR=%l)ssUVS8 zWAg&YM<>>5eVwrKdsW|&^i@eK2m&$DG97!41a*oMmp#5JXhs=k62rVsPr+Y>X)vD& wjK@)N3b?;}i`cZyBjDLf^m*=4H{S}`eCQSP!Jku`-~9s7yD+Gx@bt@n103|2K>z>% literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256.png new file mode 100644 index 0000000000000000000000000000000000000000..4442d3eb27fa4973c50d3cab6069e933d9e7c02d GIT binary patch literal 11304 zcmd6Ng{(uE(;3IZxTG{3g1!nQe=N|iW^pc93Oswul0SON_tkI|#eUa` zL48!&CpnNSg^BNkp$oa?H|? z{YZ9|I@$iCGbEUd|3v6%9s~dI;fY|ExajjI$D;k=S~-QLpZHVMFd1DZCT6v7gYKNT z$b+ervrR$;-JW7QU1?gk3U}7$c(q2wQ->Uc8gAxM^21R_af+O=!E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2fE7Xs+Ci0I>_G@YvHQUw&jo6K{ zU`?KSrwIbv#V{%+o)N$}N&IWEmL{H8RJv=t6O*A~r~y@UNNACQZL@7ei80kf!&j<( zFBj`ND-Un4={mS#&i5z=u5w5D-u*q`ywa|FfgZ0ng2k^Nusv<%ZSPF%)hlWMKGUj5 z#In~G`McjGe@R73GjZF3JWIkc3ynPT&JRISnqY8JVsfhMC-U0duu`f++aArQL*p*3 z*3V-&z@bhXV)<949KYUJ`(CW2BWAzpWL4Ex z`g6oO*puRh3~#h4M8AmQxFdBCBank?F>7$q8{BErtWA~*syLUmUpw7>sszg#IHS1TAKK~E`GX58zYwgiusz#hvq)XKDjv?bWll=YUsHidNcz7$U+Q*NO%gH4Dw?n!Ra$IpwJ>xjUr( zA=cILzs60haUn#nu<&ZMs6UEc@l=1P(QVd|SgW@!S(SLB>Y&tNU2a_2@zIw;kzLk( zu37iX146leKDgja>|e0V)7%l|%0q&|q(>pu=C}bLSz&cq<@tuQQkW21*G8G1K0qUz zmp4O}s$T`nym`tT9&=piDk%9w<2nybO_kJud1?gS{JLvs!=pE}mQ%{O;LuybQ_gu@ z1mm+D-+M1$8lmTD1B>OQJ1tt$Xzy{C@NZO3Ir(m9)WXT$(ji2M*SJHuXhe%*0I!t| z!IiR-_{vx_w{j8Hwujf(j0Tilgx^CTCO<6qLF2#xs_#B=IZT}>f7xiWkal^K}E_z)8l!*^LVhhA5 z$x=bA2LF2UqopPa9tpmx@hHSetJB^TuPC_@9M-k?#W-ke(-}p&q(bWDOrB=W{8l0J zXsgpE?u{4&+1-3fb==DnSB)IKU_u+6NSpiN-JnRVJcd=NcpWyfXB<8e(Vqfo);|nS zIiHdyt4UG{&@FX${`pQ|&CefOyut@`GKe$%zu(<5E)sx#?=F6yb3mH-1u&qkuB%q{ I&?fSK0D}4Yvj6}9 literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_256x256@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..069b5c050245260272c21e9839b43593124370e5 GIT binary patch literal 26984 zcmeFZRX~*Q6F<63qokC8xF84!BBda?goGjuQUcN?prAA?DAG!IEYgj%3ne4+-?Y+O=>zK>> zNXzHh5)Djq=Thqu>pu4aspLr5{_l_fvt%$uwRnGFKb1=E$p0xnm@oig1Q>y*^9}A> zXy03MBt7!NGQYavNH*AHAXS*;SC9f5rJp-Bc8`>e799tLc(Kb+lT7aO#jH)a44NU(AZUAlj;2)wvjqmuk?3Qf8S0$=a#TA=U5>BkmrSgIE7~W{94GIC6o@79{n~@=cQ>S1N9_dC_U^z zEae#3m>L+GUizA-$&ply%lL*qwl>G>-y1&^Kp$}YTrzzZaxo~m-CH>vpLpPMOD=?u zaHLL=$NK2w_kO$~5P>$DrueF2%`__%7i(jzIiaC&$Q2khMkbR*`orj)vWYDdd{B46 zg)n_Xb-B-g8F0NcHa?3ss}{vAUDpSDU<3MqPo>_l|JyM_ zCQ}tmF7vL#R20-nd=D0a`-!E60k-jysI{LU@D`K*LI})d1t!)Br;;1_1L9!vPwMg2 z=Lk#(5u!1~T4=^g8aZWaVNlQXtHvu)a?qhZ8Zy~|Yivpjq>9nR*Ld?DN|DQ$2_{Lo zh|IqL)&`OLM=wasi9NZs0?E)old^Fjg+bPwthd%685er!E6wYVikXuB+B_81BPtyY(d=EK&rMYkGr{8yMMpS9o_!# z!2=UDe3|QS{g;YY zC(hkIb{$h602RZGwuYY;s(2ofRR5k#39ByW3BguoeOe~B<&@`{{GU}^o0l-?7kK=L zA+kwBZ3Fh0KZsC3QB)P({OYksSKel2nT3UkNpO8v|H+Au&BLc~erdoMmPw$OzU;!S zWHSC6`9%9ZzEj9P(I6P#da1W8p5o?I`?t7!UEfwIqr1^=Pm)3`kBMj(M{a%xA9!-M z_L5M+-@nG$9U)Jlao_KM_7v0t)li#if4r4X_SB@z=9bBZH5~7X zg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a?1YX`Mn=3#Ebr7WR z+)VPukd0rzrZn9=8A9DkY`dGBjX=yjtc|F^Jr8}7pAdDvV>l-xIz_YR=%l)ssUVS8 zWAg&YM<>>5eVwrKdsW|&^i@eK2m&$DG97!41a*oMmp#5JXhs=k62rVsPr+Y>X)vD& wjK@)N3b?;}i`cZyBjDLf^m*=4H{S}`eCQSP!Jku`-~9s7yD+Gx@bt@n103|2K>z>% literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_32x32@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c5e458164974ccedc45d8f686c1cbc5ecb3646b1 GIT binary patch literal 2423 zcmV--35fQIP)OP}II-HMiDGqRVn7K((pDbE8mrN^lrgbriaKdb zYf3;A4XrfWbSVP7J|8!KIdq-ht66W-YzLd`_ZjB#sMQJiXI2Ki7N8I0xd1=n^ET2I z`Lp^$o(u3I!@`FVKyS%&0bXKw;z0#4)@Sk$D}XVtpn6OGVFkb%YOyl-^)nCh#p|-S z(%!NU=xEJJ@@Y6nC+pA9N7bK_OY!@9Apiz{i{ZKHe&HK=zoqc@Xu3N(NE2D-aF-+s zM4IS6e<(XhryI|!@i+un!0^I!zHEEpE{UABmf4?2HaQL&?-ke_tQh;NEW1Z804}ng zPRQ2|HYg_DfA0<@bSKk)TS6$f^%AA^X43H3uwo3NMH>NL%eH?k0=%T{7kygiub6Oh zPdaVNb-HhybK&o)Zm>~3Ze(nP-Y(odr2vzq%d8Nfl}RFbM^BN)(@q z_Yqx40d0%oBM|^qUf9s+kX92zl*ny&>0c%-f{&vQ&{}}dwn+6vd+zmVH8J;+0}6tF zEceo10j_k!sVCYs+@saRb`5eXCyvwN`8GB-mH`0) z>vYry{B6>Tt_f#ZXD19z)cD3m$D5(=aN;=M_@2AF`_IF|!qVN`++NU$01gH2ipioc znChC;-VF8lhN0$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yO?=Rq_=gNrdHTm&E p7;|FczvP(6e#uqI!dxe${|}^_Xq3Q%8$kd7002ovPDHLkV1fiMq&)xt literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_512x512.png b/examples/cocoa-application/CocoaApplication/CocoaApplication.xcassets/AppIcon.appiconset/icon_512x512.png new file mode 100644 index 0000000000000000000000000000000000000000..069b5c050245260272c21e9839b43593124370e5 GIT binary patch literal 26984 zcmeFZRX~*Q6F<63qokC8xF84!BBda?goGjuQUcN?prAA?DAG!IEYgj%3ne4+-?Y+O=>zK>> zNXzHh5)Djq=Thqu>pu4aspLr5{_l_fvt%$uwRnGFKb1=E$p0xnm@oig1Q>y*^9}A> zXy03MBt7!NGQYavNH*AHAXS*;SC9f5rJp-Bc8`>e799tLc(Kb+lT7aO#jH)a44NU(AZUAlj;2)wvjqmuk?3Qf8S0$=a#TA=U5>BkmrSgIE7~W{94GIC6o@79{n~@=cQ>S1N9_dC_U^z zEae#3m>L+GUizA-$&ply%lL*qwl>G>-y1&^Kp$}YTrzzZaxo~m-CH>vpLpPMOD=?u zaHLL=$NK2w_kO$~5P>$DrueF2%`__%7i(jzIiaC&$Q2khMkbR*`orj)vWYDdd{B46 zg)n_Xb-B-g8F0NcHa?3ss}{vAUDpSDU<3MqPo>_l|JyM_ zCQ}tmF7vL#R20-nd=D0a`-!E60k-jysI{LU@D`K*LI})d1t!)Br;;1_1L9!vPwMg2 z=Lk#(5u!1~T4=^g8aZWaVNlQXtHvu)a?qhZ8Zy~|Yivpjq>9nR*Ld?DN|DQ$2_{Lo zh|IqL)&`OLM=wasi9NZs0?E)old^Fjg+bPwthd%685er!E6wYVikXuB+B_81BPtyY(d=EK&rMYkGr{8yMMpS9o_!# z!2=UDe3|QS{g;YY zC(hkIb{$h602RZGwuYY;s(2ofRR5k#39ByW3BguoeOe~B<&@`{{GU}^o0l-?7kK=L zA+kwBZ3Fh0KZsC3QB)P({OYksSKel2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0E{Dv{ z?!C&YE~gL;(+K)*vGSucR zu(E#7G1f$cM@%NmpS4e~7o>7rwCAtCAK@R7oRl@|wn&Km+^`N?&E69DwFrKR@TL zycdxjW8^3fw9?C`TS1d>|1PdEL_}q|%FB18a=1$T&b<+jwNYe)Sk8 zFP`Q_>r*B`+0?BzGNKpSM_+&a^%rm6yva5Cf?mfc4{7=fJus{F;D^3-h#zga@+LD3 zq_@6P{`4i#DWKZ4i)`|g2(M{d>X>VB44}ymuM3<@Uz{owI^`#BUF{qEq?Kmx|K5KC zGvnVI=Ypf6YdpY_99BIu8v(;d71@A@AbBctQ?XU4|be{27B zY}6K|Gla&~CHJ(o|1)*g{=e3m_5arYTmOI7l0QNJ|M3ni3xQoh9MLWY_r;-xXB}3? zdGcpHIgkmQ;{Y?I$>MW?C*>tgey>|bomqG${`?nNd7+=qBm(#_Ipo|6Sj9{onPUo`~&o(-HK;IV>858UOr5~&z>;HExot5NI c-2eao0kHb23z*ElZ~y=R07*qoM6N<$f>XccZvX%Q literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..6c556a8356d0a818c45a42ca845502a8b2e460a7 GIT binary patch literal 5256 zcmb7IXE+>8w4Pmy)uJQ>QKN>aK}208M080cdT-IAEvu{$qSxpVB_fF+SQ2%$5Ya=# zBHHRDR?n)}cYoc#_s4r?p68r7GiT;~o_A(q4D>W3^b6h>U#sB!btzYO9SnaNh6p6TcZUGqu=!`>-qUB>&CA z^kM#Cf8g1mPyS|}Yt0R#xA#)6-;KTU|LiPqG1hc^W0dbZSQ@N^akkz`_R$(>>nyn< z|IK##xwBFT2VAvR+bcB6hjc*9tD=j@H}H#5{#(|Ut9Q=heOz)Lzab5$QyMa5qMi2Y zC!fKhR(Rfxhb--yy!xby7K0+-oJ%cinA1&0-BRH;6H2tzv(Su;U-K<6XfvS<+x)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hP2jGS^3pn@$ki?xu)2CO_;iZ?z;P(DZbpKc;8wqR= zO7#-(7A@r;CLX8hgt<5zm6HShgIdF44Ux7^J8bht{AxL{RFfdjSBgwpC#B;0N(p~R zu}vL(@{l8=u2kL3owBA^Xk?2Nw2~()KEqKW?lsXBmk-h@F*B(-J_g}$UUXx9SAX`& z`K<-3aL<&bR|<-KJGph(e`Vm!igbh6-OTND=@gZ7@N{xeS0bAp#p)D zpqaOBR(EUvqR4^Y@!^)Tkv-G_AQ0n;36$KQBCIdYSs2|K(rKfokSc3YW?U|sN(fUK zS=F-K}Vlwgp zR&XpVE!Iu>LHnU42XNi!6*0xYFPk;fCGEB+kF}7_sX1HohQM+ms$>z?H+fVEzQL|? z*kyyzE#tbTv)JD~8&v(7ilL-{78JQcMb0ILcHZHAN z9M8GU#Y3a6CLMa02OE|8+Agc*k891cYo>jjrJp$;&iIm9sq~5VMG)inIVz*}!%H#z zSBKaCk%_@|5slLRlWQ+lZu;nA+XvU;R>#UGZ~mR-#vG4lJRVjHKEL)eC@VPKzgMd; zpP}VyIeNwK)4f$=jA=;gowt_FLCwf@KiTt-ukNrhuXn|>)I@W3grYgyuME<<%l`0z z3djoJ1DcfVzbEU49POEm*SSwtHF=Yi`l^g5S1;D)wl!-09pND#7N03y3A3KNQ!TPVFZA-2P=XrXB z`|BYvSh#&uZ>mX!j%t|(G_vQ6k7Cb({ddvf)1lg5D>aV<-$o3*;j`j-LNWbCL?wB% z+p@dbo-v=t;303gagln$?EO7U(uO*=kUFUZJ}O1TMVJcL5j%;Nv&xk;@-*?b!IiJ+ zyep}7oY)Ql0|8$?q%sI^=I917+RUGWb-m@Gk5vzS5MSGsw9jd$BJQQ#jEH-5@xutT M?&_&ms9Hb&A3*vBzW@LL literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128@2x.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_128x128@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..4442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XsgpE?u{4&+1-3fb==DnSB)IKU_u+6NSpiN-JnRVJcd=NcpWyfXB<8e(Vqfo);|nS zIiHdyt4UG{&@FX${`pQ|&CefOyut@`GKe$%zu(<5E)sx#?=F6yb3mH-1u&qkuB%q{ I&?fSK0D}4Yvj6}9 literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_16x16.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..2adcdb5f49180b2c150612ec2849e152da141eb5 GIT binary patch literal 487 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbMfs{o%6S0MfW|Ns5__pe*GZriqP zE@wiMkLGROym{-^ty{Ki*|lpIkg@CF?wvb#9zA*#NIISk0-}=Rb*E09I(YElkt0Wd zT&J_aKBr>*PR06Pj1M>!A8;`t=1NxVm7L@g`N`J`Q?39g*(_V9@qwCnj-Ul<5 zo?5x`%(^WHw(dQ-|G?$L$BrF4e*E}}6DNRXo&kc(XU?8Id+z+X^FZ+F%H_}3uL8lB z8`pr~`nBsfuHX22`^MKhw{G3K{q5czAh>(y&bRw_f#BPN`#|vh(Sz@gA3l8e=+UFc zj~~By@#4*|cR)Wbj#25*2v(A_%|1a%S=)w9*qa^JpqxbPr@Sb)*jz~HT)z8QTN zYU1eV)XcK3sFJdf-h7bd$QGHHuV-~D1A3JC7Ip6y}-}9d5J>U7B?|j$x zVs=BpZeS1y1dWbDVS&2--CDT}$S6WF4Fvk&&%H4TyMXQgiXhTIlEAtMK)95bCIk{u z|1qkptPJQvp-?;?4`2)i)6mdBB9ZLv?O7~VettgC?e6Y|Kp;g$MN4z~`}+|H1b_j_ z5)&5}S65fJgx|{q0)fF`Bqk>Qn{R1pxpnInzyP4Wz8(gH0l2ZTv8JZR)6)~c_wU~a z&Va+=z~Fax6&xI#k&%&=m6el|bKt-MKR-W!d@sV-*htR4C~oq3$u-%W+-9>)&TH=~ z9-a^vELs;eW*t%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ssUVS8 zWAg&YM<>>5eVwrKdsW|&^i@eK2m&$DG97!41a*oMmp#5JXhs=k62rVsPr+Y>X)vD& wjK@)N3b?;}i`cZyBjDLf^m*=4H{S}`eCQSP!Jku`-~9s7yD+Gx@bt@n103|2K>z>% literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256.png new file mode 100644 index 0000000000000000000000000000000000000000..4442d3eb27fa4973c50d3cab6069e933d9e7c02d GIT binary patch literal 11304 zcmd6Ng{(uE(;3IZxTG{3g1!nQe=N|iW^pc93Oswul0SON_tkI|#eUa` zL48!&CpnNSg^BNkp$oa?H|? z{YZ9|I@$iCGbEUd|3v6%9s~dI;fY|ExajjI$D;k=S~-QLpZHVMFd1DZCT6v7gYKNT z$b+ervrR$;-JW7QU1?gk3U}7$c(q2wQ->Uc8gAxM^21R_af+O=!E1{Tat|YJh6(~x zj4YCKpcb&F6khuKS&N;`7p{;gtz0TN*|wZmiG|TV*zPX=nc;UbJigf^#CxSUWLS%v z8s0NND_8;k7bplU#6yO(dm)RxIU&Eaa;cS#u718#wru1l3Uybe>9zjQt4FQ|;Dw%R z^psIKy8~p{i0u zvBfXTj$|#dB?0a|HwsQ#^weQusy(Y;AhFZItkFG~Pcha63*HItIYAlDIlc+bDW}kO zrvrl>1Z-Z;$o}8h4y>W2Tm z9mmBe?LWjA)*WwIr@o?2|8>`YSg{#uQN%ukD?K!spx^Yl~et5dy zq*7*I!+Uz)$B`E2Ws3y*CJ_Rf{=B}!x{p&QWjr|-Wjb3&tOSEfq>;K*%9&IEaedeA zSFF8l+9{#bu3XK2$mCt`?8gbyZ?5 zY}BhS!!2JSm1f?e3Q(6KNn-)1l(oW|ORX*9_uw^e?7Gj7Bq#TpuwN^$)wOmew5YDc`}Iz^cSB=~@n3RB9Ia%uqM@eQVe_!_Re91oR_R zg__u#=M2l&J04D`Az4mK`@$5IuxHYC=bUSvZOp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w<2nybO_kJud1?gS{JLvs!=pE}mQ%{O;LuybQ_gu@ z1mm+D-+M1$8lmTD1B>OQJ1tt$Xzy{C@NZO3Ir(m9)WXT$(ji2M*SJHuXhe%*0I!t| z!IiR-_{vx_w{j8Hwujf(j0Tilgx^CTCO<6qLF2#xs_#B=IZT}>f7xiWkal^K}E_z)8l!*^LVhhA5 z$x=bA2LF2UqopPa9tpmx@hHSetJB^TuPC_@9M-k?#W-ke(-}p&q(bWDOrB=W{8l0J zXsgpE?u{4&+1-3fb==DnSB)IKU_u+6NSpiN-JnRVJcd=NcpWyfXB<8e(Vqfo);|nS zIiHdyt4UG{&@FX${`pQ|&CefOyut@`GKe$%zu(<5E)sx#?=F6yb3mH-1u&qkuB%q{ I&?fSK0D}4Yvj6}9 literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256@2x.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_256x256@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..069b5c050245260272c21e9839b43593124370e5 GIT binary patch literal 26984 zcmeFZRX~*Q6F<63qokC8xF84!BBda?goGjuQUcN?prAA?DAG!IEYgj%3ne4+-?Y+O=>zK>> zNXzHh5)Djq=Thqu>pu4aspLr5{_l_fvt%$uwRnGFKb1=E$p0xnm@oig1Q>y*^9}A> zXy03MBt7!NGQYavNH*AHAXS*;SC9f5rJp-Bc8`>e799tLc(Kb+lT7aO#jH)a44NU(AZUAlj;2)wvjqmuk?3Qf8S0$=a#TA=U5>BkmrSgIE7~W{94GIC6o@79{n~@=cQ>S1N9_dC_U^z zEae#3m>L+GUizA-$&ply%lL*qwl>G>-y1&^Kp$}YTrzzZaxo~m-CH>vpLpPMOD=?u zaHLL=$NK2w_kO$~5P>$DrueF2%`__%7i(jzIiaC&$Q2khMkbR*`orj)vWYDdd{B46 zg)n_Xb-B-g8F0NcHa?3ss}{vAUDpSDU<3MqPo>_l|JyM_ zCQ}tmF7vL#R20-nd=D0a`-!E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b|Yw9S4Ez z^wFrW1Q%C9S1cNS3Pd;RPg-p@4vTYw=yPIzuXAB@;RfOJqIge_a5aDJQ?%cDO&>8{ z|M*xr0_IU&cm47jI1IfUeBEVvNrkrl#mfPfd4I>H&`+)Q_y||)-TYO_xfl<3exTzj zPep0kn~)0y_~73!Zr(H&U`uy2bY6)LU{mt!lCz!9lsXXEVM*!z+hT9;a7?NkjS^*c zt#19M^`=*Yd&UzbV;&n57v@gjFZ+YBCUx7E%14V1Rn^t&xh>WB8Nbf4&#{$m6{EYo z4I)_M+ao_|kP|t`+=JdN>%Mea;o<5$TbNnN&eP?Zs&Tdc`)hu~-DZhW3Wi;nO~2y8 z&HfHODx;lp`YZoLX472xtP`UBBF|eX^g8E;e9H38HQl_fT40rGkQdU#BS_U9I$6&R z-5q~AXirTf99axz((cvT2Z&9<_aKUNA4pL#$B8X>R$OvDBCGa?1YX`Mn=3#Ebr7WR z+)VPukd0rzrZn9=8A9DkY`dGBjX=yjtc|F^Jr8}7pAdDvV>l-xIz_YR=%l)ssUVS8 zWAg&YM<>>5eVwrKdsW|&^i@eK2m&$DG97!41a*oMmp#5JXhs=k62rVsPr+Y>X)vD& wjK@)N3b?;}i`cZyBjDLf^m*=4H{S}`eCQSP!Jku`-~9s7yD+Gx@bt@n103|2K>z>% literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_32x32@2x.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_32x32@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..c5e458164974ccedc45d8f686c1cbc5ecb3646b1 GIT binary patch literal 2423 zcmV--35fQIP)OP}II-HMiDGqRVn7K((pDbE8mrN^lrgbriaKdb zYf3;A4XrfWbSVP7J|8!KIdq-ht66W-YzLd`_ZjB#sMQJiXI2Ki7N8I0xd1=n^ET2I z`Lp^$o(u3I!@`FVKyS%&0bXKw;z0#4)@Sk$D}XVtpn6OGVFkb%YOyl-^)nCh#p|-S z(%!NU=xEJJ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_a)&Wu9K=E`@bmM_kadJ}XN3S0;r$y2CGuFpkmEHq zHIe}J_4SG<5NUwVA|fKB@nW193!oNk*|OyTxB_eFdl#yLJ$hKWg8bY8R1b81$e!32rcJ@x&<(CoOmF+O-d!6J8WifMUnCuu@LrZ!|hUPEL*_hFlN`6dD@Z zziQPgH~x6sx3%f|9=Ab&r*`h#xgQZA!Wjaf*sKl{ z`~8fE{=C^vUI<|6;^MLg{k{+YVz5Fc;sf!NFadH*Y@3?z4)oS|aa_^hJR0 zE?KhVRp#+A5CX8&0ceZ>AqHO2-eNgqAwTTx?Hy-jW#z~#z7=0tRQf_*JdcQeV+E_; z1uT?DaEb$<(?e7M_#5xB)nJevau$1dczm^N*|Ht%x?l2wXTd$MSLEegCqnm?g$oyM zWj($%&ilqt_?vIu~$ai}?QCoWCyO?=Rq_=gNrdHTm&E p7;|FczvP(6e#uqI!dxe${|}^_Xq3Q%8$kd7002ovPDHLkV1fiMq&)xt literal 0 HcmV?d00001 diff --git a/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_512x512.png b/examples/cocoa-application/CocoaApplication/dmg.iconset/icon_512x512.png new file mode 100644 index 0000000000000000000000000000000000000000..069b5c050245260272c21e9839b43593124370e5 GIT binary patch literal 26984 zcmeFZRX~*Q6F<63qokC8xF84!BBda?goGjuQUcN?prAA?DAG!IEYgj%3ne4+-?Y+O=>zK>> zNXzHh5)Djq=Thqu>pu4aspLr5{_l_fvt%$uwRnGFKb1=E$p0xnm@oig1Q>y*^9}A> zXy03MBt7!NGQYavNH*AHAXS*;SC9f5rJp-Bc8`>e799tLc(Kb+lT7aO#jH)a44NU(AZUAlj;2)wvjqmuk?3Qf8S0$=a#TA=U5>BkmrSgIE7~W{94GIC6o@79{n~@=cQ>S1N9_dC_U^z zEae#3m>L+GUizA-$&ply%lL*qwl>G>-y1&^Kp$}YTrzzZaxo~m-CH>vpLpPMOD=?u zaHLL=$NK2w_kO$~5P>$DrueF2%`__%7i(jzIiaC&$Q2khMkbR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6-E{|h_fST112Y5pj?XK{e^MLV3C9u*mG7sL&(SE`w^18)l!!gJ$3!#Ua)`UV8(EalPlAI z6D6^Q?JlJaU2Hfn)e4c72S*G>Jx(oX#~>kOCwHQ3^m*JH-X=`Bn@1)`lf$}5jWro< z@bFW#$$m)fgKp4|@|Kl?WtpF%>zI+_618U688xkObOiSUa5XuU1}}X}E3j;oGI?bG z*t<^xSg4l!)3{v9+1?bW=u8dBoC{-?E1c>{cKfEQ&C-cEiz)V92&)B^zgs!pF)4zP zIkWmX+ermPWwyFY@nWoO5>@-K4Z@kYY27bZGljv z20jwp)9;3|$p>q2r$6E{5LQDKrVXS$z;Ad3W}hB1rAk+A`g14k&O31k+N=Y$;=%ZG zmFPdtcy|{c6CFfwl{`>xS?hpzGq#!E##snnBWKoh%EoV=a6QZZ{66lZKN6Y}W6PhqA@_WPrVo^!0p9iFJ1$E>S-?48hBw$xsV zx$oLQT#iW9Ug~e|<@kqqS5MP;2nkW+{A+*@+=DwfAN-g64v|TLiYKt3LRh&7d^2b}wG2 z+@^jnY=NwD)u08D55g(RgRyy$a&4Bf`ur4&9AfmN71uCXP+y2*9IIf|e#`)Zs2_j` z05naZ4v5jg#fSL0)Mp$&x?72CnnHk?s}=&!giPcM|97z2WsdB5LM z + + + 1080 + 11D50 + 2457 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 2457 + + + NSWindowTemplate + NSView + NSMenu + NSMenuItem + NSCustomObject + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + + + CocoaApplication + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + CocoaApplication + + + + About CocoaApplication + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide CocoaApplication + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit CocoaApplication + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save… + s + 1048576 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find and Replace… + f + 1572864 + 2147483647 + + + 12 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + + + Show Spelling and Grammar + : + 1048576 + 2147483647 + + + + + + Check Document Now + ; + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + Correct Spelling Automatically + + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + + + Show Substitutions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Dashes + + 2147483647 + + + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + Text Replacement + + 2147483647 + + + + + + + + + Transformations + + 2147483647 + + + submenuAction: + + Transformations + + + + Make Upper Case + + 2147483647 + + + + + + Make Lower Case + + 2147483647 + + + + + + Capitalize + + 2147483647 + + + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + Format + + 2147483647 + + + submenuAction: + + Format + + + + Font + + 2147483647 + + + submenuAction: + + Font + + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Bold + b + 1048576 + 2147483647 + + + 2 + + + + Italic + i + 1048576 + 2147483647 + + + 1 + + + + Underline + u + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Bigger + + + 1048576 + 2147483647 + + + 3 + + + + Smaller + - + 1048576 + 2147483647 + + + 4 + + + + YES + YES + + + 2147483647 + + + + + + Kern + + 2147483647 + + + submenuAction: + + Kern + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Tighten + + 2147483647 + + + + + + Loosen + + 2147483647 + + + + + + + + + Ligatures + + 2147483647 + + + submenuAction: + + Ligatures + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Use All + + 2147483647 + + + + + + + + + Baseline + + 2147483647 + + + submenuAction: + + Baseline + + + + Use Default + + 2147483647 + + + + + + Superscript + + 2147483647 + + + + + + Subscript + + 2147483647 + + + + + + Raise + + 2147483647 + + + + + + Lower + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Colors + C + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Copy Style + c + 1572864 + 2147483647 + + + + + + Paste Style + v + 1572864 + 2147483647 + + + + + _NSFontMenu + + + + + Text + + 2147483647 + + + submenuAction: + + Text + + + + Align Left + { + 1048576 + 2147483647 + + + + + + Center + | + 1048576 + 2147483647 + + + + + + Justify + + 2147483647 + + + + + + Align Right + } + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Writing Direction + + 2147483647 + + + submenuAction: + + Writing Direction + + + + YES + Paragraph + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + YES + Selection + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Ruler + + 2147483647 + + + + + + Copy Ruler + c + 1310720 + 2147483647 + + + + + + Paste Ruler + v + 1310720 + 2147483647 + + + + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + + + CocoaApplication Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + 15 + 2 + {{335, 390}, {480, 360}} + 1954021376 + CocoaApplication + NSWindow + + + + + 256 + {480, 360} + + {{0, 0}, {2560, 1418}} + {10000000000000, 10000000000000} + YES + + + AppDelegate + + + NSFontManager + + + + + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + saveDocument: + + + + 362 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + raiseBaseline: + + + + 426 + + + + lowerBaseline: + + + + 427 + + + + copyFont: + + + + 428 + + + + subscript: + + + + 429 + + + + superscript: + + + + 430 + + + + tightenKerning: + + + + 431 + + + + underline: + + + + 432 + + + + orderFrontColorPanel: + + + + 433 + + + + useAllLigatures: + + + + 434 + + + + loosenKerning: + + + + 435 + + + + pasteFont: + + + + 436 + + + + unscript: + + + + 437 + + + + useStandardKerning: + + + + 438 + + + + useStandardLigatures: + + + + 439 + + + + turnOffLigatures: + + + + 440 + + + + turnOffKerning: + + + + 441 + + + + toggleAutomaticSpellingCorrection: + + + + 456 + + + + orderFrontSubstitutionsPanel: + + + + 458 + + + + toggleAutomaticDashSubstitution: + + + + 461 + + + + toggleAutomaticTextReplacement: + + + + 463 + + + + uppercaseWord: + + + + 464 + + + + capitalizeWord: + + + + 467 + + + + lowercaseWord: + + + + 468 + + + + pasteAsPlainText: + + + + 486 + + + + performFindPanelAction: + + + + 487 + + + + performFindPanelAction: + + + + 488 + + + + performFindPanelAction: + + + + 489 + + + + showHelp: + + + + 493 + + + + alignCenter: + + + + 518 + + + + pasteRuler: + + + + 519 + + + + toggleRuler: + + + + 520 + + + + alignRight: + + + + 521 + + + + copyRuler: + + + + 522 + + + + alignJustified: + + + + 523 + + + + alignLeft: + + + + 524 + + + + makeBaseWritingDirectionNatural: + + + + 525 + + + + makeBaseWritingDirectionLeftToRight: + + + + 526 + + + + makeBaseWritingDirectionRightToLeft: + + + + 527 + + + + makeTextWritingDirectionNatural: + + + + 528 + + + + makeTextWritingDirectionLeftToRight: + + + + 529 + + + + makeTextWritingDirectionRightToLeft: + + + + 530 + + + + performFindPanelAction: + + + + 535 + + + + addFontTrait: + + + + 421 + + + + addFontTrait: + + + + 422 + + + + modifyFont: + + + + 423 + + + + orderFrontFontPanel: + + + + 424 + + + + modifyFont: + + + + 425 + + + + window + + + + 532 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + + + + + + + + + + + + 19 + + + + + + + + 56 + + + + + + + + 217 + + + + + + + + 83 + + + + + + + + 81 + + + + + + + + + + + + + + + + + 75 + + + + + 78 + + + + + 72 + + + + + 82 + + + + + 124 + + + + + + + + 77 + + + + + 73 + + + + + 79 + + + + + 112 + + + + + 74 + + + + + 125 + + + + + + + + 126 + + + + + 205 + + + + + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + + + + + + 216 + + + + + + + + 200 + + + + + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 57 + + + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + + + + + + 296 + + + + + + + + + 297 + + + + + 298 + + + + + 211 + + + + + + + + 212 + + + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + + + + + + 349 + + + + + + + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 371 + + + + + + + + 372 + + + + + 375 + + + + + + + + 376 + + + + + + + + + 377 + + + + + + + + 388 + + + + + + + + + + + + + + + + + + + + + + + 389 + + + + + 390 + + + + + 391 + + + + + 392 + + + + + 393 + + + + + 394 + + + + + 395 + + + + + 396 + + + + + 397 + + + + + + + + 398 + + + + + + + + 399 + + + + + + + + 400 + + + + + 401 + + + + + 402 + + + + + 403 + + + + + 404 + + + + + 405 + + + + + + + + + + + + 406 + + + + + 407 + + + + + 408 + + + + + 409 + + + + + 410 + + + + + 411 + + + + + + + + + + 412 + + + + + 413 + + + + + 414 + + + + + 415 + + + + + + + + + + + 416 + + + + + 417 + + + + + 418 + + + + + 419 + + + + + 420 + + + + + 450 + + + + + + + + 451 + + + + + + + + + + 452 + + + + + 453 + + + + + 454 + + + + + 457 + + + + + 459 + + + + + 460 + + + + + 462 + + + + + 465 + + + + + 466 + + + + + 485 + + + + + 490 + + + + + + + + 491 + + + + + + + + 492 + + + + + 494 + + + + + 496 + + + + + + + + 497 + + + + + + + + + + + + + + + + + 498 + + + + + 499 + + + + + 500 + + + + + 501 + + + + + 502 + + + + + 503 + + + + + + + + 504 + + + + + 505 + + + + + 506 + + + + + 507 + + + + + 508 + + + + + + + + + + + + + + + + 509 + + + + + 510 + + + + + 511 + + + + + 512 + + + + + 513 + + + + + 514 + + + + + 515 + + + + + 516 + + + + + 517 + + + + + 534 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{380, 496}, {480, 360}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 535 + + + + + ABCardController + NSObject + + id + id + id + id + id + id + id + + + + addCardViewField: + id + + + copy: + id + + + cut: + id + + + doDelete: + id + + + find: + id + + + paste: + id + + + saveChanges: + id + + + + ABCardView + NSButton + NSManagedObjectContext + NSSearchField + NSTextField + NSWindow + + + + mCardView + ABCardView + + + mEditButton + NSButton + + + mManagedObjectContext + NSManagedObjectContext + + + mSearchField + NSSearchField + + + mStatusTextField + NSTextField + + + mWindow + NSWindow + + + + IBProjectSource + ./Classes/ABCardController.h + + + + ABCardView + NSView + + id + id + + + + commitAndSave: + id + + + statusImageClicked: + id + + + + NSObjectController + NSImageView + NSView + ABNameFrameView + NSView + NSImage + ABImageView + + + + mBindingsController + NSObjectController + + + mBuddyStatusImage + NSImageView + + + mHeaderView + NSView + + + mNameView + ABNameFrameView + + + mNextKeyView + NSView + + + mUserImage + NSImage + + + mUserImageView + ABImageView + + + + IBProjectSource + ./Classes/ABCardView.h + + + + ABImageView + NSImageView + + id + id + id + id + + + + copy: + id + + + cut: + id + + + delete: + id + + + paste: + id + + + + IBProjectSource + ./Classes/ABImageView.h + + + + DVTBorderedView + DVTLayoutView_ML + + contentView + NSView + + + contentView + + contentView + NSView + + + + IBProjectSource + ./Classes/DVTBorderedView.h + + + + DVTDelayedMenuButton + NSButton + + IBProjectSource + ./Classes/DVTDelayedMenuButton.h + + + + DVTGradientImageButton + NSButton + + IBProjectSource + ./Classes/DVTGradientImageButton.h + + + + DVTImageAndTextCell + NSTextFieldCell + + IBProjectSource + ./Classes/DVTImageAndTextCell.h + + + + DVTImageAndTextColumn + NSTableColumn + + IBProjectSource + ./Classes/DVTImageAndTextColumn.h + + + + DVTLayoutView_ML + NSView + + IBProjectSource + ./Classes/DVTLayoutView_ML.h + + + + DVTOutlineView + NSOutlineView + + IBProjectSource + ./Classes/DVTOutlineView.h + + + + DVTSplitView + NSSplitView + + IBProjectSource + ./Classes/DVTSplitView.h + + + + DVTStackView_ML + DVTLayoutView_ML + + IBProjectSource + ./Classes/DVTStackView_ML.h + + + + DVTTableView + NSTableView + + IBProjectSource + ./Classes/DVTTableView.h + + + + DVTViewController + NSViewController + + IBProjectSource + ./Classes/DVTViewController.h + + + + HFController + NSObject + + selectAll: + id + + + selectAll: + + selectAll: + id + + + + IBProjectSource + ./Classes/HFController.h + + + + HFRepresenterTextView + NSView + + selectAll: + id + + + selectAll: + + selectAll: + id + + + + IBProjectSource + ./Classes/HFRepresenterTextView.h + + + + IBEditor + NSObject + + id + id + id + id + id + + + + changeFont: + id + + + performCopy: + id + + + performCut: + id + + + selectAll: + id + + + sizeSelectionToFit: + id + + + + IBProjectSource + ./Classes/IBEditor.h + + + + IDECapsuleListView + DVTStackView_ML + + dataSource + id + + + dataSource + + dataSource + id + + + + IBProjectSource + ./Classes/IDECapsuleListView.h + + + + IDEDMArrayController + NSArrayController + + IBProjectSource + ./Classes/IDEDMArrayController.h + + + + IDEDMEditor + IDEEditor + + DVTBorderedView + NSView + IDEDMEditorSourceListController + DVTSplitView + + + + bottomToolbarBorderView + DVTBorderedView + + + sourceListSplitViewPane + NSView + + + sourceListViewController + IDEDMEditorSourceListController + + + splitView + DVTSplitView + + + + IBProjectSource + ./Classes/IDEDMEditor.h + + + + IDEDMEditorController + IDEViewController + + IBProjectSource + ./Classes/IDEDMEditorController.h + + + + IDEDMEditorSourceListController + IDEDMEditorController + + DVTBorderedView + IDEDMEditor + DVTImageAndTextColumn + DVTOutlineView + NSTreeController + + + + borderedView + DVTBorderedView + + + parentEditor + IDEDMEditor + + + primaryColumn + DVTImageAndTextColumn + + + sourceListOutlineView + DVTOutlineView + + + sourceListTreeController + NSTreeController + + + + IBProjectSource + ./Classes/IDEDMEditorSourceListController.h + + + + IDEDMHighlightImageAndTextCell + DVTImageAndTextCell + + IBProjectSource + ./Classes/IDEDMHighlightImageAndTextCell.h + + + + IDEDataModelBrowserEditor + IDEDMEditorController + + IDEDataModelPropertiesTableController + IDECapsuleListView + NSArrayController + IDEDataModelPropertiesTableController + IDEDataModelEntityContentsEditor + IDEDataModelPropertiesTableController + + + + attributesTableViewController + IDEDataModelPropertiesTableController + + + capsuleView + IDECapsuleListView + + + entityArrayController + NSArrayController + + + fetchedPropertiesTableViewController + IDEDataModelPropertiesTableController + + + parentEditor + IDEDataModelEntityContentsEditor + + + relationshipsTableViewController + IDEDataModelPropertiesTableController + + + + IBProjectSource + ./Classes/IDEDataModelBrowserEditor.h + + + + IDEDataModelConfigurationEditor + IDEDMEditorController + + IDECapsuleListView + IDEDataModelEditor + IDEDataModelConfigurationTableController + + + + capsuleListView + IDECapsuleListView + + + parentEditor + IDEDataModelEditor + + + tableController + IDEDataModelConfigurationTableController + + + + IBProjectSource + ./Classes/IDEDataModelConfigurationEditor.h + + + + IDEDataModelConfigurationTableController + IDEDMEditorController + + NSArrayController + NSArrayController + IDEDataModelConfigurationEditor + XDTableView + + + + configurationsArrayController + NSArrayController + + + entitiesArrayController + NSArrayController + + + parentEditor + IDEDataModelConfigurationEditor + + + tableView + XDTableView + + + + IBProjectSource + ./Classes/IDEDataModelConfigurationTableController.h + + + + IDEDataModelDiagramEditor + IDEDMEditorController + + XDDiagramView + IDEDataModelEntityContentsEditor + + + + diagramView + XDDiagramView + + + parentEditor + IDEDataModelEntityContentsEditor + + + + IBProjectSource + ./Classes/IDEDataModelDiagramEditor.h + + + + IDEDataModelEditor + IDEDMEditor + + DVTDelayedMenuButton + DVTDelayedMenuButton + NSSegmentedControl + IDEDataModelConfigurationEditor + IDEDataModelEntityContentsEditor + IDEDataModelFetchRequestEditor + NSSegmentedControl + NSTabView + + + + addEntityButton + DVTDelayedMenuButton + + + addPropertyButton + DVTDelayedMenuButton + + + browserDiagramSegmentControl + NSSegmentedControl + + + configurationViewController + IDEDataModelConfigurationEditor + + + entityContentsViewController + IDEDataModelEntityContentsEditor + + + fetchRequestViewController + IDEDataModelFetchRequestEditor + + + hierarchySegmentControl + NSSegmentedControl + + + tabView + NSTabView + + + + IBProjectSource + ./Classes/IDEDataModelEditor.h + + + + IDEDataModelEntityContentsEditor + IDEDMEditorController + + IDEDataModelBrowserEditor + IDEDataModelDiagramEditor + IDEDataModelEditor + NSTabView + + + + browserViewController + IDEDataModelBrowserEditor + + + diagramViewController + IDEDataModelDiagramEditor + + + parentEditor + IDEDataModelEditor + + + tabView + NSTabView + + + + IBProjectSource + ./Classes/IDEDataModelEntityContentsEditor.h + + + + IDEDataModelFetchRequestEditor + IDEDMEditorController + + NSArrayController + IDEDataModelEditor + IDECapsuleListView + + + + entityController + NSArrayController + + + parentEditor + IDEDataModelEditor + + + tableView + IDECapsuleListView + + + + IBProjectSource + ./Classes/IDEDataModelFetchRequestEditor.h + + + + IDEDataModelPropertiesTableController + IDEDMEditorController + + IDEDMArrayController + NSTableColumn + NSArrayController + IDEDataModelBrowserEditor + IDEDMHighlightImageAndTextCell + XDTableView + + + + arrayController + IDEDMArrayController + + + entitiesColumn + NSTableColumn + + + entityArrayController + NSArrayController + + + parentEditor + IDEDataModelBrowserEditor + + + propertyNameAndImageCell + IDEDMHighlightImageAndTextCell + + + tableView + XDTableView + + + + IBProjectSource + ./Classes/IDEDataModelPropertiesTableController.h + + + + IDEDocDownloadsTableViewController + NSObject + + NSButtonCell + DVTTableView + IDEDocViewingPrefPaneController + + + + _downloadButtonCell + NSButtonCell + + + _tableView + DVTTableView + + + prefPaneController + IDEDocViewingPrefPaneController + + + + IBProjectSource + ./Classes/IDEDocDownloadsTableViewController.h + + + + IDEDocSetOutlineView + NSOutlineView + + IBProjectSource + ./Classes/IDEDocSetOutlineView.h + + + + IDEDocSetOutlineViewController + NSObject + + id + id + id + id + id + + + + getDocSetAction: + id + + + showProblemInfoForUpdate: + id + + + subscribeToPublisherAction: + id + + + unsubscribeFromPublisher: + id + + + updateDocSetAction: + id + + + + docSetOutlineView + IDEDocSetOutlineView + + + docSetOutlineView + + docSetOutlineView + IDEDocSetOutlineView + + + + IBProjectSource + ./Classes/IDEDocSetOutlineViewController.h + + + + IDEDocViewingPrefPaneController + IDEViewController + + id + id + id + id + id + id + id + id + id + id + id + + + + addSubscription: + id + + + checkForAndInstallUpdatesNow: + id + + + deleteDocSet: + id + + + downloadAction: + id + + + minimumFontSizeComboBoxAction: + id + + + minimumFontSizeEnabledAction: + id + + + showHelp: + id + + + showSubscriptionSheet: + id + + + subscriptionCancelAction: + id + + + toggleAutoCheckForAndInstallUpdates: + id + + + toggleDocSetInfo: + id + + + + DVTGradientImageButton + DVTGradientImageButton + DVTGradientImageButton + NSSplitView + NSView + NSView + DVTBorderedView + DVTBorderedView + NSButton + NSTextView + IDEDocSetOutlineViewController + IDEDocDownloadsTableViewController + NSComboBox + NSTextField + NSButton + NSTextField + NSWindow + NSButton + + + + _addButton + DVTGradientImageButton + + + _deleteButton + DVTGradientImageButton + + + _showInfoAreaButton + DVTGradientImageButton + + + _splitView + NSSplitView + + + _splitViewDocSetInfoSubview + NSView + + + _splitViewDocSetsListSubview + NSView + + + borderedViewAroundSplitView + DVTBorderedView + + + borderedViewBelowTable + DVTBorderedView + + + checkAndInstallNowButton + NSButton + + + docSetInfoTextView + NSTextView + + + docSetOutlineViewController + IDEDocSetOutlineViewController + + + downloadsTableViewController + IDEDocDownloadsTableViewController + + + minimumFontSizeControl + NSComboBox + + + noUpdatesAvailableMessage + NSTextField + + + showInfoButton + NSButton + + + subscriptionTextField + NSTextField + + + subscriptionWindow + NSWindow + + + validateAddSubscriptionButton + NSButton + + + + IBProjectSource + ./Classes/IDEDocViewingPrefPaneController.h + + + + IDEEditor + IDEViewController + + IBProjectSource + ./Classes/IDEEditor.h + + + + IDEViewController + DVTViewController + + IBProjectSource + ./Classes/IDEViewController.h + + + + IKImageView + + id + id + id + id + + + + copy: + id + + + crop: + id + + + cut: + id + + + paste: + id + + + + IBProjectSource + ./Classes/IKImageView.h + + + + NSDocument + + id + id + id + id + id + id + + + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + IBProjectSource + ./Classes/NSDocument.h + + + + NSResponder + + _insertFindPattern: + id + + + _insertFindPattern: + + _insertFindPattern: + id + + + + IBProjectSource + ./Classes/NSResponder.h + + + + QLPreviewBubble + NSObject + + id + id + + + + hide: + id + + + show: + id + + + + parentWindow + NSWindow + + + parentWindow + + parentWindow + NSWindow + + + + IBProjectSource + ./Classes/QLPreviewBubble.h + + + + QTMovieView + + id + id + id + id + id + + + + showAll: + id + + + showCustomButton: + id + + + toggleLoops: + id + + + zoomIn: + id + + + zoomOut: + id + + + + IBProjectSource + ./Classes/QTMovieView.h + + + + WebView + + id + id + id + id + + + + reloadFromOrigin: + id + + + resetPageZoom: + id + + + zoomPageIn: + id + + + zoomPageOut: + id + + + + IBProjectSource + ./Classes/WebView.h + + + + XDDiagramView + NSView + + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + _graphLayouterMenuItemAction: + id + + + _zoomPopUpButtonAction: + id + + + alignBottomEdges: + id + + + alignCentersHorizontallyInContainer: + id + + + alignCentersVerticallyInContainer: + id + + + alignHorizontalCenters: + id + + + alignLeftEdges: + id + + + alignRightEdges: + id + + + alignTopEdges: + id + + + alignVerticalCenters: + id + + + bringToFront: + id + + + collapseAllCompartments: + id + + + copy: + id + + + cut: + id + + + delete: + id + + + deleteBackward: + id + + + deleteForward: + id + + + deselectAll: + id + + + diagramZoomIn: + id + + + diagramZoomOut: + id + + + expandAllCompartments: + id + + + flipHorizontally: + id + + + flipVertically: + id + + + layoutGraphicsConcentrically: + id + + + layoutGraphicsHierarchically: + id + + + lock: + id + + + makeSameHeight: + id + + + makeSameWidth: + id + + + moveDown: + id + + + moveDownAndModifySelection: + id + + + moveLeft: + id + + + moveLeftAndModifySelection: + id + + + moveRight: + id + + + moveRightAndModifySelection: + id + + + moveUp: + id + + + moveUpAndModifySelection: + id + + + paste: + id + + + rollDownAllCompartments: + id + + + rollUpAllCompartments: + id + + + selectAll: + id + + + sendToBack: + id + + + sizeToFit: + id + + + toggleGridShown: + id + + + toggleHiddenGraphicsShown: + id + + + togglePageBreaksShown: + id + + + toggleRuler: + id + + + toggleSnapsToGrid: + id + + + unlock: + id + + + + _diagramController + IDEDataModelDiagramEditor + + + _diagramController + + _diagramController + IDEDataModelDiagramEditor + + + + IBProjectSource + ./Classes/XDDiagramView.h + + + + XDTableView + NSTableView + + showAllTableColumns: + id + + + showAllTableColumns: + + showAllTableColumns: + id + + + + IBProjectSource + ./Classes/XDTableView.h + + + + AppDelegate + NSObject + + id + id + + + + applicationShouldTerminate: + id + + + applicationWillFinishLaunching: + id + + + + IBProjectSource + ./Classes/AppDelegate.h + + + + + 0 + IBCocoaFramework + YES + 3 + + {11, 11} + {10, 3} + + YES + + diff --git a/examples/cocoa-application/CocoaApplication/en_US.lproj/Credits.rtf b/examples/cocoa-application/CocoaApplication/en_US.lproj/Credits.rtf new file mode 100644 index 00000000..9caf316e --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/en_US.lproj/Credits.rtf @@ -0,0 +1,29 @@ +{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;} +{\colortbl;\red255\green255\blue255;} +\paperw9840\paperh8400 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\b\fs24 \cf0 Engineering: +\b0 \ + Some people\ +\ + +\b Human Interface Design: +\b0 \ + Some other people\ +\ + +\b Testing: +\b0 \ + Hopefully not nobody\ +\ + +\b Documentation: +\b0 \ + Whoever\ +\ + +\b With special thanks to: +\b0 \ + Mom\ +} diff --git a/examples/cocoa-application/CocoaApplication/en_US.lproj/InfoPlist.strings b/examples/cocoa-application/CocoaApplication/en_US.lproj/InfoPlist.strings new file mode 100644 index 00000000..b92732c7 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/en_US.lproj/InfoPlist.strings @@ -0,0 +1 @@ +/* Localized versions of Info.plist keys */ diff --git a/examples/cocoa-application/CocoaApplication/en_US.lproj/LICENSE b/examples/cocoa-application/CocoaApplication/en_US.lproj/LICENSE new file mode 100644 index 00000000..44650fe7 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/en_US.lproj/LICENSE @@ -0,0 +1,27 @@ +Copyright (C) 2017 The Qt Company Ltd. + +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 and its Subsidiary(-ies) 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. diff --git a/examples/cocoa-application/CocoaApplication/en_US.lproj/MainMenu.xib b/examples/cocoa-application/CocoaApplication/en_US.lproj/MainMenu.xib new file mode 100644 index 00000000..faedd463 --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/en_US.lproj/MainMenu.xib @@ -0,0 +1,4666 @@ + + + + 1080 + 11D50 + 2457 + 1138.32 + 568.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 2457 + + + NSWindowTemplate + NSView + NSMenu + NSMenuItem + NSCustomObject + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + AMainMenu + + + + CocoaApplication + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + CocoaApplication + + + + About CocoaApplication + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Services + + 1048576 + 2147483647 + + + submenuAction: + + Services + + _NSServicesMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Hide CocoaApplication + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Quit CocoaApplication + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 1048576 + 2147483647 + + + submenuAction: + + File + + + + New + n + 1048576 + 2147483647 + + + + + + Open… + o + 1048576 + 2147483647 + + + + + + Open Recent + + 1048576 + 2147483647 + + + submenuAction: + + Open Recent + + + + Clear Menu + + 1048576 + 2147483647 + + + + + _NSRecentDocumentsMenu + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + Save… + s + 1048576 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Page Setup... + P + 1179648 + 2147483647 + + + + + + + Print… + p + 1048576 + 2147483647 + + + + + + + + + Edit + + 1048576 + 2147483647 + + + submenuAction: + + Edit + + + + Undo + z + 1048576 + 2147483647 + + + + + + Redo + Z + 1179648 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Cut + x + 1048576 + 2147483647 + + + + + + Copy + c + 1048576 + 2147483647 + + + + + + Paste + v + 1048576 + 2147483647 + + + + + + Paste and Match Style + V + 1572864 + 2147483647 + + + + + + Delete + + 1048576 + 2147483647 + + + + + + Select All + a + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Find + + 1048576 + 2147483647 + + + submenuAction: + + Find + + + + Find… + f + 1048576 + 2147483647 + + + 1 + + + + Find and Replace… + f + 1572864 + 2147483647 + + + 12 + + + + Find Next + g + 1048576 + 2147483647 + + + 2 + + + + Find Previous + G + 1179648 + 2147483647 + + + 3 + + + + Use Selection for Find + e + 1048576 + 2147483647 + + + 7 + + + + Jump to Selection + j + 1048576 + 2147483647 + + + + + + + + + Spelling and Grammar + + 1048576 + 2147483647 + + + submenuAction: + + Spelling and Grammar + + + + Show Spelling and Grammar + : + 1048576 + 2147483647 + + + + + + Check Document Now + ; + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Check Spelling While Typing + + 1048576 + 2147483647 + + + + + + Check Grammar With Spelling + + 1048576 + 2147483647 + + + + + + Correct Spelling Automatically + + 2147483647 + + + + + + + + + Substitutions + + 1048576 + 2147483647 + + + submenuAction: + + Substitutions + + + + Show Substitutions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Smart Copy/Paste + f + 1048576 + 2147483647 + + + 1 + + + + Smart Quotes + g + 1048576 + 2147483647 + + + 2 + + + + Smart Dashes + + 2147483647 + + + + + + Smart Links + G + 1179648 + 2147483647 + + + 3 + + + + Text Replacement + + 2147483647 + + + + + + + + + Transformations + + 2147483647 + + + submenuAction: + + Transformations + + + + Make Upper Case + + 2147483647 + + + + + + Make Lower Case + + 2147483647 + + + + + + Capitalize + + 2147483647 + + + + + + + + + Speech + + 1048576 + 2147483647 + + + submenuAction: + + Speech + + + + Start Speaking + + 1048576 + 2147483647 + + + + + + Stop Speaking + + 1048576 + 2147483647 + + + + + + + + + + + + Format + + 2147483647 + + + submenuAction: + + Format + + + + Font + + 2147483647 + + + submenuAction: + + Font + + + + Show Fonts + t + 1048576 + 2147483647 + + + + + + Bold + b + 1048576 + 2147483647 + + + 2 + + + + Italic + i + 1048576 + 2147483647 + + + 1 + + + + Underline + u + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Bigger + + + 1048576 + 2147483647 + + + 3 + + + + Smaller + - + 1048576 + 2147483647 + + + 4 + + + + YES + YES + + + 2147483647 + + + + + + Kern + + 2147483647 + + + submenuAction: + + Kern + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Tighten + + 2147483647 + + + + + + Loosen + + 2147483647 + + + + + + + + + Ligatures + + 2147483647 + + + submenuAction: + + Ligatures + + + + Use Default + + 2147483647 + + + + + + Use None + + 2147483647 + + + + + + Use All + + 2147483647 + + + + + + + + + Baseline + + 2147483647 + + + submenuAction: + + Baseline + + + + Use Default + + 2147483647 + + + + + + Superscript + + 2147483647 + + + + + + Subscript + + 2147483647 + + + + + + Raise + + 2147483647 + + + + + + Lower + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Colors + C + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Copy Style + c + 1572864 + 2147483647 + + + + + + Paste Style + v + 1572864 + 2147483647 + + + + + _NSFontMenu + + + + + Text + + 2147483647 + + + submenuAction: + + Text + + + + Align Left + { + 1048576 + 2147483647 + + + + + + Center + | + 1048576 + 2147483647 + + + + + + Justify + + 2147483647 + + + + + + Align Right + } + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Writing Direction + + 2147483647 + + + submenuAction: + + Writing Direction + + + + YES + Paragraph + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + YES + Selection + + 2147483647 + + + + + + CURlZmF1bHQ + + 2147483647 + + + + + + CUxlZnQgdG8gUmlnaHQ + + 2147483647 + + + + + + CVJpZ2h0IHRvIExlZnQ + + 2147483647 + + + + + + + + + YES + YES + + + 2147483647 + + + + + + Show Ruler + + 2147483647 + + + + + + Copy Ruler + c + 1310720 + 2147483647 + + + + + + Paste Ruler + v + 1310720 + 2147483647 + + + + + + + + + + + + View + + 1048576 + 2147483647 + + + submenuAction: + + View + + + + Show Toolbar + t + 1572864 + 2147483647 + + + + + + Customize Toolbar… + + 1048576 + 2147483647 + + + + + + + + + Window + + 1048576 + 2147483647 + + + submenuAction: + + Window + + + + Minimize + m + 1048576 + 2147483647 + + + + + + Zoom + + 1048576 + 2147483647 + + + + + + YES + YES + + + 1048576 + 2147483647 + + + + + + Bring All to Front + + 1048576 + 2147483647 + + + + + _NSWindowsMenu + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + + + CocoaApplication Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + 15 + 2 + {{335, 390}, {480, 360}} + 1954021376 + CocoaApplication + NSWindow + + + + + 256 + {480, 360} + + {{0, 0}, {2560, 1418}} + {10000000000000, 10000000000000} + YES + + + AppDelegate + + + NSFontManager + + + + + + + terminate: + + + + 449 + + + + orderFrontStandardAboutPanel: + + + + 142 + + + + delegate + + + + 495 + + + + performMiniaturize: + + + + 37 + + + + arrangeInFront: + + + + 39 + + + + print: + + + + 86 + + + + runPageLayout: + + + + 87 + + + + clearRecentDocuments: + + + + 127 + + + + performClose: + + + + 193 + + + + toggleContinuousSpellChecking: + + + + 222 + + + + undo: + + + + 223 + + + + copy: + + + + 224 + + + + checkSpelling: + + + + 225 + + + + paste: + + + + 226 + + + + stopSpeaking: + + + + 227 + + + + cut: + + + + 228 + + + + showGuessPanel: + + + + 230 + + + + redo: + + + + 231 + + + + selectAll: + + + + 232 + + + + startSpeaking: + + + + 233 + + + + delete: + + + + 235 + + + + performZoom: + + + + 240 + + + + performFindPanelAction: + + + + 241 + + + + centerSelectionInVisibleArea: + + + + 245 + + + + toggleGrammarChecking: + + + + 347 + + + + toggleSmartInsertDelete: + + + + 355 + + + + toggleAutomaticQuoteSubstitution: + + + + 356 + + + + toggleAutomaticLinkDetection: + + + + 357 + + + + saveDocument: + + + + 362 + + + + revertDocumentToSaved: + + + + 364 + + + + runToolbarCustomizationPalette: + + + + 365 + + + + toggleToolbarShown: + + + + 366 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + newDocument: + + + + 373 + + + + openDocument: + + + + 374 + + + + raiseBaseline: + + + + 426 + + + + lowerBaseline: + + + + 427 + + + + copyFont: + + + + 428 + + + + subscript: + + + + 429 + + + + superscript: + + + + 430 + + + + tightenKerning: + + + + 431 + + + + underline: + + + + 432 + + + + orderFrontColorPanel: + + + + 433 + + + + useAllLigatures: + + + + 434 + + + + loosenKerning: + + + + 435 + + + + pasteFont: + + + + 436 + + + + unscript: + + + + 437 + + + + useStandardKerning: + + + + 438 + + + + useStandardLigatures: + + + + 439 + + + + turnOffLigatures: + + + + 440 + + + + turnOffKerning: + + + + 441 + + + + toggleAutomaticSpellingCorrection: + + + + 456 + + + + orderFrontSubstitutionsPanel: + + + + 458 + + + + toggleAutomaticDashSubstitution: + + + + 461 + + + + toggleAutomaticTextReplacement: + + + + 463 + + + + uppercaseWord: + + + + 464 + + + + capitalizeWord: + + + + 467 + + + + lowercaseWord: + + + + 468 + + + + pasteAsPlainText: + + + + 486 + + + + performFindPanelAction: + + + + 487 + + + + performFindPanelAction: + + + + 488 + + + + performFindPanelAction: + + + + 489 + + + + showHelp: + + + + 493 + + + + alignCenter: + + + + 518 + + + + pasteRuler: + + + + 519 + + + + toggleRuler: + + + + 520 + + + + alignRight: + + + + 521 + + + + copyRuler: + + + + 522 + + + + alignJustified: + + + + 523 + + + + alignLeft: + + + + 524 + + + + makeBaseWritingDirectionNatural: + + + + 525 + + + + makeBaseWritingDirectionLeftToRight: + + + + 526 + + + + makeBaseWritingDirectionRightToLeft: + + + + 527 + + + + makeTextWritingDirectionNatural: + + + + 528 + + + + makeTextWritingDirectionLeftToRight: + + + + 529 + + + + makeTextWritingDirectionRightToLeft: + + + + 530 + + + + performFindPanelAction: + + + + 535 + + + + addFontTrait: + + + + 421 + + + + addFontTrait: + + + + 422 + + + + modifyFont: + + + + 423 + + + + orderFrontFontPanel: + + + + 424 + + + + modifyFont: + + + + 425 + + + + window + + + + 532 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + + + + + + + + + + + + 19 + + + + + + + + 56 + + + + + + + + 217 + + + + + + + + 83 + + + + + + + + 81 + + + + + + + + + + + + + + + + + 75 + + + + + 78 + + + + + 72 + + + + + 82 + + + + + 124 + + + + + + + + 77 + + + + + 73 + + + + + 79 + + + + + 112 + + + + + 74 + + + + + 125 + + + + + + + + 126 + + + + + 205 + + + + + + + + + + + + + + + + + + + + + + 202 + + + + + 198 + + + + + 207 + + + + + 214 + + + + + 199 + + + + + 203 + + + + + 197 + + + + + 206 + + + + + 215 + + + + + 218 + + + + + + + + 216 + + + + + + + + 200 + + + + + + + + + + + + + 219 + + + + + 201 + + + + + 204 + + + + + 220 + + + + + + + + + + + + + 213 + + + + + 210 + + + + + 221 + + + + + 208 + + + + + 209 + + + + + 57 + + + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 24 + + + + + + + + + + + 92 + + + + + 5 + + + + + 239 + + + + + 23 + + + + + 295 + + + + + + + + 296 + + + + + + + + + 297 + + + + + 298 + + + + + 211 + + + + + + + + 212 + + + + + + + + + 195 + + + + + 196 + + + + + 346 + + + + + 348 + + + + + + + + 349 + + + + + + + + + + + + + + 350 + + + + + 351 + + + + + 354 + + + + + 371 + + + + + + + + 372 + + + + + 375 + + + + + + + + 376 + + + + + + + + + 377 + + + + + + + + 388 + + + + + + + + + + + + + + + + + + + + + + + 389 + + + + + 390 + + + + + 391 + + + + + 392 + + + + + 393 + + + + + 394 + + + + + 395 + + + + + 396 + + + + + 397 + + + + + + + + 398 + + + + + + + + 399 + + + + + + + + 400 + + + + + 401 + + + + + 402 + + + + + 403 + + + + + 404 + + + + + 405 + + + + + + + + + + + + 406 + + + + + 407 + + + + + 408 + + + + + 409 + + + + + 410 + + + + + 411 + + + + + + + + + + 412 + + + + + 413 + + + + + 414 + + + + + 415 + + + + + + + + + + + 416 + + + + + 417 + + + + + 418 + + + + + 419 + + + + + 420 + + + + + 450 + + + + + + + + 451 + + + + + + + + + + 452 + + + + + 453 + + + + + 454 + + + + + 457 + + + + + 459 + + + + + 460 + + + + + 462 + + + + + 465 + + + + + 466 + + + + + 485 + + + + + 490 + + + + + + + + 491 + + + + + + + + 492 + + + + + 494 + + + + + 496 + + + + + + + + 497 + + + + + + + + + + + + + + + + + 498 + + + + + 499 + + + + + 500 + + + + + 501 + + + + + 502 + + + + + 503 + + + + + + + + 504 + + + + + 505 + + + + + 506 + + + + + 507 + + + + + 508 + + + + + + + + + + + + + + + + 509 + + + + + 510 + + + + + 511 + + + + + 512 + + + + + 513 + + + + + 514 + + + + + 515 + + + + + 516 + + + + + 517 + + + + + 534 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{380, 496}, {480, 360}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 535 + + + + + ABCardController + NSObject + + id + id + id + id + id + id + id + + + + addCardViewField: + id + + + copy: + id + + + cut: + id + + + doDelete: + id + + + find: + id + + + paste: + id + + + saveChanges: + id + + + + ABCardView + NSButton + NSManagedObjectContext + NSSearchField + NSTextField + NSWindow + + + + mCardView + ABCardView + + + mEditButton + NSButton + + + mManagedObjectContext + NSManagedObjectContext + + + mSearchField + NSSearchField + + + mStatusTextField + NSTextField + + + mWindow + NSWindow + + + + IBProjectSource + ./Classes/ABCardController.h + + + + ABCardView + NSView + + id + id + + + + commitAndSave: + id + + + statusImageClicked: + id + + + + NSObjectController + NSImageView + NSView + ABNameFrameView + NSView + NSImage + ABImageView + + + + mBindingsController + NSObjectController + + + mBuddyStatusImage + NSImageView + + + mHeaderView + NSView + + + mNameView + ABNameFrameView + + + mNextKeyView + NSView + + + mUserImage + NSImage + + + mUserImageView + ABImageView + + + + IBProjectSource + ./Classes/ABCardView.h + + + + ABImageView + NSImageView + + id + id + id + id + + + + copy: + id + + + cut: + id + + + delete: + id + + + paste: + id + + + + IBProjectSource + ./Classes/ABImageView.h + + + + DVTBorderedView + DVTLayoutView_ML + + contentView + NSView + + + contentView + + contentView + NSView + + + + IBProjectSource + ./Classes/DVTBorderedView.h + + + + DVTDelayedMenuButton + NSButton + + IBProjectSource + ./Classes/DVTDelayedMenuButton.h + + + + DVTGradientImageButton + NSButton + + IBProjectSource + ./Classes/DVTGradientImageButton.h + + + + DVTImageAndTextCell + NSTextFieldCell + + IBProjectSource + ./Classes/DVTImageAndTextCell.h + + + + DVTImageAndTextColumn + NSTableColumn + + IBProjectSource + ./Classes/DVTImageAndTextColumn.h + + + + DVTLayoutView_ML + NSView + + IBProjectSource + ./Classes/DVTLayoutView_ML.h + + + + DVTOutlineView + NSOutlineView + + IBProjectSource + ./Classes/DVTOutlineView.h + + + + DVTSplitView + NSSplitView + + IBProjectSource + ./Classes/DVTSplitView.h + + + + DVTStackView_ML + DVTLayoutView_ML + + IBProjectSource + ./Classes/DVTStackView_ML.h + + + + DVTTableView + NSTableView + + IBProjectSource + ./Classes/DVTTableView.h + + + + DVTViewController + NSViewController + + IBProjectSource + ./Classes/DVTViewController.h + + + + HFController + NSObject + + selectAll: + id + + + selectAll: + + selectAll: + id + + + + IBProjectSource + ./Classes/HFController.h + + + + HFRepresenterTextView + NSView + + selectAll: + id + + + selectAll: + + selectAll: + id + + + + IBProjectSource + ./Classes/HFRepresenterTextView.h + + + + IBEditor + NSObject + + id + id + id + id + id + + + + changeFont: + id + + + performCopy: + id + + + performCut: + id + + + selectAll: + id + + + sizeSelectionToFit: + id + + + + IBProjectSource + ./Classes/IBEditor.h + + + + IDECapsuleListView + DVTStackView_ML + + dataSource + id + + + dataSource + + dataSource + id + + + + IBProjectSource + ./Classes/IDECapsuleListView.h + + + + IDEDMArrayController + NSArrayController + + IBProjectSource + ./Classes/IDEDMArrayController.h + + + + IDEDMEditor + IDEEditor + + DVTBorderedView + NSView + IDEDMEditorSourceListController + DVTSplitView + + + + bottomToolbarBorderView + DVTBorderedView + + + sourceListSplitViewPane + NSView + + + sourceListViewController + IDEDMEditorSourceListController + + + splitView + DVTSplitView + + + + IBProjectSource + ./Classes/IDEDMEditor.h + + + + IDEDMEditorController + IDEViewController + + IBProjectSource + ./Classes/IDEDMEditorController.h + + + + IDEDMEditorSourceListController + IDEDMEditorController + + DVTBorderedView + IDEDMEditor + DVTImageAndTextColumn + DVTOutlineView + NSTreeController + + + + borderedView + DVTBorderedView + + + parentEditor + IDEDMEditor + + + primaryColumn + DVTImageAndTextColumn + + + sourceListOutlineView + DVTOutlineView + + + sourceListTreeController + NSTreeController + + + + IBProjectSource + ./Classes/IDEDMEditorSourceListController.h + + + + IDEDMHighlightImageAndTextCell + DVTImageAndTextCell + + IBProjectSource + ./Classes/IDEDMHighlightImageAndTextCell.h + + + + IDEDataModelBrowserEditor + IDEDMEditorController + + IDEDataModelPropertiesTableController + IDECapsuleListView + NSArrayController + IDEDataModelPropertiesTableController + IDEDataModelEntityContentsEditor + IDEDataModelPropertiesTableController + + + + attributesTableViewController + IDEDataModelPropertiesTableController + + + capsuleView + IDECapsuleListView + + + entityArrayController + NSArrayController + + + fetchedPropertiesTableViewController + IDEDataModelPropertiesTableController + + + parentEditor + IDEDataModelEntityContentsEditor + + + relationshipsTableViewController + IDEDataModelPropertiesTableController + + + + IBProjectSource + ./Classes/IDEDataModelBrowserEditor.h + + + + IDEDataModelConfigurationEditor + IDEDMEditorController + + IDECapsuleListView + IDEDataModelEditor + IDEDataModelConfigurationTableController + + + + capsuleListView + IDECapsuleListView + + + parentEditor + IDEDataModelEditor + + + tableController + IDEDataModelConfigurationTableController + + + + IBProjectSource + ./Classes/IDEDataModelConfigurationEditor.h + + + + IDEDataModelConfigurationTableController + IDEDMEditorController + + NSArrayController + NSArrayController + IDEDataModelConfigurationEditor + XDTableView + + + + configurationsArrayController + NSArrayController + + + entitiesArrayController + NSArrayController + + + parentEditor + IDEDataModelConfigurationEditor + + + tableView + XDTableView + + + + IBProjectSource + ./Classes/IDEDataModelConfigurationTableController.h + + + + IDEDataModelDiagramEditor + IDEDMEditorController + + XDDiagramView + IDEDataModelEntityContentsEditor + + + + diagramView + XDDiagramView + + + parentEditor + IDEDataModelEntityContentsEditor + + + + IBProjectSource + ./Classes/IDEDataModelDiagramEditor.h + + + + IDEDataModelEditor + IDEDMEditor + + DVTDelayedMenuButton + DVTDelayedMenuButton + NSSegmentedControl + IDEDataModelConfigurationEditor + IDEDataModelEntityContentsEditor + IDEDataModelFetchRequestEditor + NSSegmentedControl + NSTabView + + + + addEntityButton + DVTDelayedMenuButton + + + addPropertyButton + DVTDelayedMenuButton + + + browserDiagramSegmentControl + NSSegmentedControl + + + configurationViewController + IDEDataModelConfigurationEditor + + + entityContentsViewController + IDEDataModelEntityContentsEditor + + + fetchRequestViewController + IDEDataModelFetchRequestEditor + + + hierarchySegmentControl + NSSegmentedControl + + + tabView + NSTabView + + + + IBProjectSource + ./Classes/IDEDataModelEditor.h + + + + IDEDataModelEntityContentsEditor + IDEDMEditorController + + IDEDataModelBrowserEditor + IDEDataModelDiagramEditor + IDEDataModelEditor + NSTabView + + + + browserViewController + IDEDataModelBrowserEditor + + + diagramViewController + IDEDataModelDiagramEditor + + + parentEditor + IDEDataModelEditor + + + tabView + NSTabView + + + + IBProjectSource + ./Classes/IDEDataModelEntityContentsEditor.h + + + + IDEDataModelFetchRequestEditor + IDEDMEditorController + + NSArrayController + IDEDataModelEditor + IDECapsuleListView + + + + entityController + NSArrayController + + + parentEditor + IDEDataModelEditor + + + tableView + IDECapsuleListView + + + + IBProjectSource + ./Classes/IDEDataModelFetchRequestEditor.h + + + + IDEDataModelPropertiesTableController + IDEDMEditorController + + IDEDMArrayController + NSTableColumn + NSArrayController + IDEDataModelBrowserEditor + IDEDMHighlightImageAndTextCell + XDTableView + + + + arrayController + IDEDMArrayController + + + entitiesColumn + NSTableColumn + + + entityArrayController + NSArrayController + + + parentEditor + IDEDataModelBrowserEditor + + + propertyNameAndImageCell + IDEDMHighlightImageAndTextCell + + + tableView + XDTableView + + + + IBProjectSource + ./Classes/IDEDataModelPropertiesTableController.h + + + + IDEDocDownloadsTableViewController + NSObject + + NSButtonCell + DVTTableView + IDEDocViewingPrefPaneController + + + + _downloadButtonCell + NSButtonCell + + + _tableView + DVTTableView + + + prefPaneController + IDEDocViewingPrefPaneController + + + + IBProjectSource + ./Classes/IDEDocDownloadsTableViewController.h + + + + IDEDocSetOutlineView + NSOutlineView + + IBProjectSource + ./Classes/IDEDocSetOutlineView.h + + + + IDEDocSetOutlineViewController + NSObject + + id + id + id + id + id + + + + getDocSetAction: + id + + + showProblemInfoForUpdate: + id + + + subscribeToPublisherAction: + id + + + unsubscribeFromPublisher: + id + + + updateDocSetAction: + id + + + + docSetOutlineView + IDEDocSetOutlineView + + + docSetOutlineView + + docSetOutlineView + IDEDocSetOutlineView + + + + IBProjectSource + ./Classes/IDEDocSetOutlineViewController.h + + + + IDEDocViewingPrefPaneController + IDEViewController + + id + id + id + id + id + id + id + id + id + id + id + + + + addSubscription: + id + + + checkForAndInstallUpdatesNow: + id + + + deleteDocSet: + id + + + downloadAction: + id + + + minimumFontSizeComboBoxAction: + id + + + minimumFontSizeEnabledAction: + id + + + showHelp: + id + + + showSubscriptionSheet: + id + + + subscriptionCancelAction: + id + + + toggleAutoCheckForAndInstallUpdates: + id + + + toggleDocSetInfo: + id + + + + DVTGradientImageButton + DVTGradientImageButton + DVTGradientImageButton + NSSplitView + NSView + NSView + DVTBorderedView + DVTBorderedView + NSButton + NSTextView + IDEDocSetOutlineViewController + IDEDocDownloadsTableViewController + NSComboBox + NSTextField + NSButton + NSTextField + NSWindow + NSButton + + + + _addButton + DVTGradientImageButton + + + _deleteButton + DVTGradientImageButton + + + _showInfoAreaButton + DVTGradientImageButton + + + _splitView + NSSplitView + + + _splitViewDocSetInfoSubview + NSView + + + _splitViewDocSetsListSubview + NSView + + + borderedViewAroundSplitView + DVTBorderedView + + + borderedViewBelowTable + DVTBorderedView + + + checkAndInstallNowButton + NSButton + + + docSetInfoTextView + NSTextView + + + docSetOutlineViewController + IDEDocSetOutlineViewController + + + downloadsTableViewController + IDEDocDownloadsTableViewController + + + minimumFontSizeControl + NSComboBox + + + noUpdatesAvailableMessage + NSTextField + + + showInfoButton + NSButton + + + subscriptionTextField + NSTextField + + + subscriptionWindow + NSWindow + + + validateAddSubscriptionButton + NSButton + + + + IBProjectSource + ./Classes/IDEDocViewingPrefPaneController.h + + + + IDEEditor + IDEViewController + + IBProjectSource + ./Classes/IDEEditor.h + + + + IDEViewController + DVTViewController + + IBProjectSource + ./Classes/IDEViewController.h + + + + IKImageView + + id + id + id + id + + + + copy: + id + + + crop: + id + + + cut: + id + + + paste: + id + + + + IBProjectSource + ./Classes/IKImageView.h + + + + NSDocument + + id + id + id + id + id + id + + + + printDocument: + id + + + revertDocumentToSaved: + id + + + runPageLayout: + id + + + saveDocument: + id + + + saveDocumentAs: + id + + + saveDocumentTo: + id + + + + IBProjectSource + ./Classes/NSDocument.h + + + + NSResponder + + _insertFindPattern: + id + + + _insertFindPattern: + + _insertFindPattern: + id + + + + IBProjectSource + ./Classes/NSResponder.h + + + + QLPreviewBubble + NSObject + + id + id + + + + hide: + id + + + show: + id + + + + parentWindow + NSWindow + + + parentWindow + + parentWindow + NSWindow + + + + IBProjectSource + ./Classes/QLPreviewBubble.h + + + + QTMovieView + + id + id + id + id + id + + + + showAll: + id + + + showCustomButton: + id + + + toggleLoops: + id + + + zoomIn: + id + + + zoomOut: + id + + + + IBProjectSource + ./Classes/QTMovieView.h + + + + WebView + + id + id + id + id + + + + reloadFromOrigin: + id + + + resetPageZoom: + id + + + zoomPageIn: + id + + + zoomPageOut: + id + + + + IBProjectSource + ./Classes/WebView.h + + + + XDDiagramView + NSView + + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + _graphLayouterMenuItemAction: + id + + + _zoomPopUpButtonAction: + id + + + alignBottomEdges: + id + + + alignCentersHorizontallyInContainer: + id + + + alignCentersVerticallyInContainer: + id + + + alignHorizontalCenters: + id + + + alignLeftEdges: + id + + + alignRightEdges: + id + + + alignTopEdges: + id + + + alignVerticalCenters: + id + + + bringToFront: + id + + + collapseAllCompartments: + id + + + copy: + id + + + cut: + id + + + delete: + id + + + deleteBackward: + id + + + deleteForward: + id + + + deselectAll: + id + + + diagramZoomIn: + id + + + diagramZoomOut: + id + + + expandAllCompartments: + id + + + flipHorizontally: + id + + + flipVertically: + id + + + layoutGraphicsConcentrically: + id + + + layoutGraphicsHierarchically: + id + + + lock: + id + + + makeSameHeight: + id + + + makeSameWidth: + id + + + moveDown: + id + + + moveDownAndModifySelection: + id + + + moveLeft: + id + + + moveLeftAndModifySelection: + id + + + moveRight: + id + + + moveRightAndModifySelection: + id + + + moveUp: + id + + + moveUpAndModifySelection: + id + + + paste: + id + + + rollDownAllCompartments: + id + + + rollUpAllCompartments: + id + + + selectAll: + id + + + sendToBack: + id + + + sizeToFit: + id + + + toggleGridShown: + id + + + toggleHiddenGraphicsShown: + id + + + togglePageBreaksShown: + id + + + toggleRuler: + id + + + toggleSnapsToGrid: + id + + + unlock: + id + + + + _diagramController + IDEDataModelDiagramEditor + + + _diagramController + + _diagramController + IDEDataModelDiagramEditor + + + + IBProjectSource + ./Classes/XDDiagramView.h + + + + XDTableView + NSTableView + + showAllTableColumns: + id + + + showAllTableColumns: + + showAllTableColumns: + id + + + + IBProjectSource + ./Classes/XDTableView.h + + + + AppDelegate + NSObject + + id + id + + + + applicationShouldTerminate: + id + + + applicationWillFinishLaunching: + id + + + + IBProjectSource + ./Classes/AppDelegate.h + + + + + 0 + IBCocoaFramework + YES + 3 + + {11, 11} + {10, 3} + + YES + + diff --git a/examples/cocoa-application/CocoaApplication/main.m b/examples/cocoa-application/CocoaApplication/main.m new file mode 100644 index 00000000..18b23e7a --- /dev/null +++ b/examples/cocoa-application/CocoaApplication/main.m @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import + +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **)argv); +} diff --git a/examples/cocoa-application/app.qbs b/examples/cocoa-application/app.qbs new file mode 100644 index 00000000..67558e8a --- /dev/null +++ b/examples/cocoa-application/app.qbs @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +import qbs.Utilities + +CppApplication { + Depends { condition: product.condition; name: "ib" } + condition: qbs.targetOS.contains("macos") + name: "Cocoa Application" + + cpp.useObjcPrecompiledHeader: true + cpp.minimumMacosVersion: "10.8" + cpp.frameworks: ["Cocoa"] + + Group { + prefix: "CocoaApplication/" + files: [ + "AppDelegate.h", + "AppDelegate.m", + "CocoaApplication-Info.plist", + "CocoaApplication.xcassets", + "main.m" + ] + } + + Group { + name: "Supporting Files" + prefix: "CocoaApplication/en.lproj/" + files: [ + "Credits.rtf", + "InfoPlist.strings", + "MainMenu.xib" + ] + } + + Group { + name: "Xcode Project" + files: [ + "CocoaApplication.xcodeproj/project.pbxproj" + ] + } + + Group { + files: ["CocoaApplication/CocoaApplication-Prefix.pch"] + fileTags: ["objc_pch_src"] + } + + Group { + fileTagsFilter: ["bundle.content"] + qbs.install: true + qbs.installDir: "Applications" + qbs.installSourceBase: product.destinationDirectory + } + + ib.appIconName: "AppIcon" + + Properties { + // codesign module only present starting from 1.19 + condition: Utilities.versionCompare(qbs.version, "1.19") >= 0 + codesign.enableCodeSigning: true + codesign.signingType: "ad-hoc" + } +} diff --git a/examples/cocoa-application/cocoa-application.qbs b/examples/cocoa-application/cocoa-application.qbs new file mode 100644 index 00000000..9c1ad137 --- /dev/null +++ b/examples/cocoa-application/cocoa-application.qbs @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +import qbs.Utilities + +Project { + references: [ + "app.qbs" + ] + + SubProject { + filePath: "dmg.qbs" + Properties { + condition: Utilities.versionCompare(qbs.version, "1.9") >= 0 + } + } +} diff --git a/examples/cocoa-application/dmg.qbs b/examples/cocoa-application/dmg.qbs new file mode 100644 index 00000000..0ae68b29 --- /dev/null +++ b/examples/cocoa-application/dmg.qbs @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +AppleApplicationDiskImage { + condition: qbs.targetOS.contains("macos") + name: "Cocoa Application DMG" + targetName: "cocoa-application-" + version + version: "1.0" + builtByDefault: false + + Depends { name: "Cocoa Application" } + Depends { name: "ib" } + + files: [ + "CocoaApplication/dmg.iconset", + "CocoaApplication/en_US.lproj/LICENSE", + ] + + // set to false to use a solid-color background (see dmg.backgroundColor below) + property bool useImageBackground: true + Group { + condition: useImageBackground + files: ["CocoaApplication/background*"] + } + + dmg.backgroundColor: "#41cd52" + dmg.badgeVolumeIcon: true + dmg.iconPositions: [ + {"x": 200, "y": 200, "path": "Cocoa Application.app"}, + {"x": 400, "y": 200, "path": "Applications"} + ] + dmg.windowX: 420 + dmg.windowY: 250 + dmg.windowWidth: 600 + dmg.windowHeight: 422 // this *includes* the macOS title bar height of 22 + dmg.iconSize: 64 +} diff --git a/examples/cocoa-touch-application/CocoaTouchApplication.xcodeproj/project.pbxproj b/examples/cocoa-touch-application/CocoaTouchApplication.xcodeproj/project.pbxproj new file mode 100644 index 00000000..62d4425c --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication.xcodeproj/project.pbxproj @@ -0,0 +1,384 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 14E3FEAA175FB2E800C857C6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14E3FEA9175FB2E800C857C6 /* UIKit.framework */; }; + 14E3FEAC175FB2E800C857C6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14E3FEAB175FB2E800C857C6 /* Foundation.framework */; }; + 14E3FEAE175FB2E800C857C6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14E3FEAD175FB2E800C857C6 /* CoreGraphics.framework */; }; + 14E3FEB4175FB2E800C857C6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 14E3FEB2175FB2E800C857C6 /* InfoPlist.strings */; }; + 14E3FEB6175FB2E800C857C6 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 14E3FEB5175FB2E800C857C6 /* main.m */; }; + 14E3FEBA175FB2E800C857C6 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 14E3FEB9175FB2E800C857C6 /* AppDelegate.m */; }; + 14E3FEC3175FB2E800C857C6 /* MasterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14E3FEC2175FB2E800C857C6 /* MasterViewController.m */; }; + 14E3FEC6175FB2E900C857C6 /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14E3FEC5175FB2E900C857C6 /* DetailViewController.m */; }; + 14E3FEC9175FB2E900C857C6 /* MasterViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14E3FEC7175FB2E900C857C6 /* MasterViewController_iPhone.xib */; }; + 14E3FECC175FB2E900C857C6 /* MasterViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14E3FECA175FB2E900C857C6 /* MasterViewController_iPad.xib */; }; + 14E3FECF175FB2E900C857C6 /* DetailViewController_iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14E3FECD175FB2E900C857C6 /* DetailViewController_iPhone.xib */; }; + 14E3FED2175FB2E900C857C6 /* DetailViewController_iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 14E3FED0175FB2E900C857C6 /* DetailViewController_iPad.xib */; }; + AC83486F258674C900A9CBBB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AC83486E258674C900A9CBBB /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 14E3FEA6175FB2E800C857C6 /* Cocoa Touch Application.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cocoa Touch Application.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 14E3FEA9175FB2E800C857C6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 14E3FEAB175FB2E800C857C6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 14E3FEAD175FB2E800C857C6 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 14E3FEB1175FB2E800C857C6 /* CocoaTouchApplication-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CocoaTouchApplication-Info.plist"; sourceTree = ""; }; + 14E3FEB3175FB2E800C857C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 14E3FEB5175FB2E800C857C6 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 14E3FEB7175FB2E800C857C6 /* CocoaTouchApplication-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CocoaTouchApplication-Prefix.pch"; sourceTree = ""; }; + 14E3FEB8175FB2E800C857C6 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 14E3FEB9175FB2E800C857C6 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 14E3FEC1175FB2E800C857C6 /* MasterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MasterViewController.h; sourceTree = ""; }; + 14E3FEC2175FB2E800C857C6 /* MasterViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MasterViewController.m; sourceTree = ""; }; + 14E3FEC4175FB2E800C857C6 /* DetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; + 14E3FEC5175FB2E900C857C6 /* DetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = ""; }; + 14E3FEC8175FB2E900C857C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MasterViewController_iPhone.xib; sourceTree = ""; }; + 14E3FECB175FB2E900C857C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MasterViewController_iPad.xib; sourceTree = ""; }; + 14E3FECE175FB2E900C857C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DetailViewController_iPhone.xib; sourceTree = ""; }; + 14E3FED1175FB2E900C857C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/DetailViewController_iPad.xib; sourceTree = ""; }; + AC83486E258674C900A9CBBB /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 14E3FEA3175FB2E800C857C6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 14E3FEAA175FB2E800C857C6 /* UIKit.framework in Frameworks */, + 14E3FEAC175FB2E800C857C6 /* Foundation.framework in Frameworks */, + 14E3FEAE175FB2E800C857C6 /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 14E3FE9D175FB2E800C857C6 = { + isa = PBXGroup; + children = ( + 14E3FEAF175FB2E800C857C6 /* CocoaTouchApplication */, + 14E3FEA8175FB2E800C857C6 /* Frameworks */, + 14E3FEA7175FB2E800C857C6 /* Products */, + ); + sourceTree = ""; + }; + 14E3FEA7175FB2E800C857C6 /* Products */ = { + isa = PBXGroup; + children = ( + 14E3FEA6175FB2E800C857C6 /* Cocoa Touch Application.app */, + ); + name = Products; + sourceTree = ""; + }; + 14E3FEA8175FB2E800C857C6 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 14E3FEA9175FB2E800C857C6 /* UIKit.framework */, + 14E3FEAB175FB2E800C857C6 /* Foundation.framework */, + 14E3FEAD175FB2E800C857C6 /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 14E3FEAF175FB2E800C857C6 /* CocoaTouchApplication */ = { + isa = PBXGroup; + children = ( + 14E3FEB8175FB2E800C857C6 /* AppDelegate.h */, + 14E3FEB9175FB2E800C857C6 /* AppDelegate.m */, + 14E3FEC1175FB2E800C857C6 /* MasterViewController.h */, + 14E3FEC2175FB2E800C857C6 /* MasterViewController.m */, + 14E3FEC4175FB2E800C857C6 /* DetailViewController.h */, + 14E3FEC5175FB2E900C857C6 /* DetailViewController.m */, + 14E3FEC7175FB2E900C857C6 /* MasterViewController_iPhone.xib */, + 14E3FECA175FB2E900C857C6 /* MasterViewController_iPad.xib */, + 14E3FECD175FB2E900C857C6 /* DetailViewController_iPhone.xib */, + 14E3FED0175FB2E900C857C6 /* DetailViewController_iPad.xib */, + 14E3FEB0175FB2E800C857C6 /* Supporting Files */, + AC83486E258674C900A9CBBB /* LaunchScreen.storyboard */, + ); + path = CocoaTouchApplication; + sourceTree = ""; + }; + 14E3FEB0175FB2E800C857C6 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 14E3FEB1175FB2E800C857C6 /* CocoaTouchApplication-Info.plist */, + 14E3FEB2175FB2E800C857C6 /* InfoPlist.strings */, + 14E3FEB5175FB2E800C857C6 /* main.m */, + 14E3FEB7175FB2E800C857C6 /* CocoaTouchApplication-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 14E3FEA5175FB2E800C857C6 /* Cocoa Touch Application */ = { + isa = PBXNativeTarget; + buildConfigurationList = 14E3FED5175FB2E900C857C6 /* Build configuration list for PBXNativeTarget "Cocoa Touch Application" */; + buildPhases = ( + 14E3FEA2175FB2E800C857C6 /* Sources */, + 14E3FEA3175FB2E800C857C6 /* Frameworks */, + 14E3FEA4175FB2E800C857C6 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Cocoa Touch Application"; + productName = CocoaTouchApplication; + productReference = 14E3FEA6175FB2E800C857C6 /* Cocoa Touch Application.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 14E3FE9E175FB2E800C857C6 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1220; + ORGANIZATIONNAME = io.qbs; + }; + buildConfigurationList = 14E3FEA1175FB2E800C857C6 /* Build configuration list for PBXProject "CocoaTouchApplication" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + English, + en, + ); + mainGroup = 14E3FE9D175FB2E800C857C6; + productRefGroup = 14E3FEA7175FB2E800C857C6 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 14E3FEA5175FB2E800C857C6 /* Cocoa Touch Application */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 14E3FEA4175FB2E800C857C6 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AC83486F258674C900A9CBBB /* LaunchScreen.storyboard in Resources */, + 14E3FEB4175FB2E800C857C6 /* InfoPlist.strings in Resources */, + 14E3FEC9175FB2E900C857C6 /* MasterViewController_iPhone.xib in Resources */, + 14E3FECC175FB2E900C857C6 /* MasterViewController_iPad.xib in Resources */, + 14E3FECF175FB2E900C857C6 /* DetailViewController_iPhone.xib in Resources */, + 14E3FED2175FB2E900C857C6 /* DetailViewController_iPad.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 14E3FEA2175FB2E800C857C6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14E3FEB6175FB2E800C857C6 /* main.m in Sources */, + 14E3FEBA175FB2E800C857C6 /* AppDelegate.m in Sources */, + 14E3FEC3175FB2E800C857C6 /* MasterViewController.m in Sources */, + 14E3FEC6175FB2E900C857C6 /* DetailViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 14E3FEB2175FB2E800C857C6 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 14E3FEB3175FB2E800C857C6 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 14E3FEC7175FB2E900C857C6 /* MasterViewController_iPhone.xib */ = { + isa = PBXVariantGroup; + children = ( + 14E3FEC8175FB2E900C857C6 /* en */, + ); + name = MasterViewController_iPhone.xib; + sourceTree = ""; + }; + 14E3FECA175FB2E900C857C6 /* MasterViewController_iPad.xib */ = { + isa = PBXVariantGroup; + children = ( + 14E3FECB175FB2E900C857C6 /* en */, + ); + name = MasterViewController_iPad.xib; + sourceTree = ""; + }; + 14E3FECD175FB2E900C857C6 /* DetailViewController_iPhone.xib */ = { + isa = PBXVariantGroup; + children = ( + 14E3FECE175FB2E900C857C6 /* en */, + ); + name = DetailViewController_iPhone.xib; + sourceTree = ""; + }; + 14E3FED0175FB2E900C857C6 /* DetailViewController_iPad.xib */ = { + isa = PBXVariantGroup; + children = ( + 14E3FED1175FB2E900C857C6 /* en */, + ); + name = DetailViewController_iPad.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 14E3FED3175FB2E900C857C6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 14E3FED4175FB2E900C857C6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 14E3FED6175FB2E900C857C6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CocoaTouchApplication/CocoaTouchApplication-Prefix.pch"; + INFOPLIST_FILE = "CocoaTouchApplication/CocoaTouchApplication-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "io.qbs.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + 14E3FED7175FB2E900C857C6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "CocoaTouchApplication/CocoaTouchApplication-Prefix.pch"; + INFOPLIST_FILE = "CocoaTouchApplication/CocoaTouchApplication-Info.plist"; + PRODUCT_BUNDLE_IDENTIFIER = "io.qbs.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 14E3FEA1175FB2E800C857C6 /* Build configuration list for PBXProject "CocoaTouchApplication" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14E3FED3175FB2E900C857C6 /* Debug */, + 14E3FED4175FB2E900C857C6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 14E3FED5175FB2E900C857C6 /* Build configuration list for PBXNativeTarget "Cocoa Touch Application" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14E3FED6175FB2E900C857C6 /* Debug */, + 14E3FED7175FB2E900C857C6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 14E3FE9E175FB2E800C857C6 /* Project object */; +} diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.h b/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.h new file mode 100644 index 00000000..a4b05b98 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#import + +@interface AppDelegate : UIResponder +{ + UIWindow *_window; + UINavigationController *_navigationController; + UISplitViewController *_splitViewController; +} + +@property (nonatomic, retain) UIWindow *window; + +@property (nonatomic, retain) UINavigationController *navigationController; + +@property (nonatomic, retain) UISplitViewController *splitViewController; + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.m b/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.m new file mode 100644 index 00000000..b93bcf2c --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/AppDelegate.m @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import "AppDelegate.h" + +#import "MasterViewController.h" + +#import "DetailViewController.h" + +@implementation AppDelegate + +@synthesize window = _window; +@synthesize navigationController = _navigationController; +@synthesize splitViewController = _splitViewController; + +- (BOOL)application:(UIApplication *) __unused application didFinishLaunchingWithOptions:(NSDictionary *) __unused launchOptions +{ + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + // Override point for customization after application launch. + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController_iPhone" bundle:nil]; + self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; + self.window.rootViewController = self.navigationController; + } else { + MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController_iPad" bundle:nil]; + UINavigationController *masterNavigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController]; + + DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController_iPad" bundle:nil]; + UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController]; + + masterViewController.detailViewController = detailViewController; + + self.splitViewController = [[UISplitViewController alloc] init]; + self.splitViewController.delegate = detailViewController; + self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil]; + + self.window.rootViewController = self.splitViewController; + } + [self.window makeKeyAndVisible]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *) __unused application +{ + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *) __unused application +{ + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *) __unused application +{ + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *) __unused application +{ + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *) __unused application +{ + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Info.plist b/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Info.plist new file mode 100644 index 00000000..8075a9d9 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Info.plist @@ -0,0 +1,57 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${PRODUCT_NAME} + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleDefault + Translucent + + + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Prefix.pch b/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Prefix.pch new file mode 100644 index 00000000..6a90a06f --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/CocoaTouchApplication-Prefix.pch @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import + +#ifndef __IPHONE_4_0 +#warning "This project uses features only available in iOS SDK 4.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.h b/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.h new file mode 100644 index 00000000..fd057606 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#import + +@interface DetailViewController : UIViewController +{ + id _detailItem; + UILabel *_detailDescriptionLabel; + UIPopoverController *_masterPopoverController; +} + +@property (nonatomic, retain) id detailItem; + +@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel; + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.m b/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.m new file mode 100644 index 00000000..dbe82165 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/DetailViewController.m @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import "DetailViewController.h" + +@interface DetailViewController () +@property (nonatomic, retain) UIPopoverController *masterPopoverController; +- (void)configureView; +@end + +@implementation DetailViewController + +@synthesize detailItem = _detailItem; +@synthesize detailDescriptionLabel = _detailDescriptionLabel; +@synthesize masterPopoverController = _masterPopoverController; + +#pragma mark - Managing the detail item + +- (void)setDetailItem:(id)newDetailItem +{ + if (_detailItem != newDetailItem) { + _detailItem = newDetailItem; + + // Update the view. + [self configureView]; + } + + if (self.masterPopoverController != nil) { + [self.masterPopoverController dismissPopoverAnimated:YES]; + } +} + +- (void)configureView +{ + // Update the user interface for the detail item. + + if (self.detailItem) { + self.detailDescriptionLabel.text = [self.detailItem description]; + } +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. + [self configureView]; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.title = NSLocalizedString(@"Detail", @"Detail"); + } + return self; +} + +#pragma mark - Split view + +- (void)splitViewController:(UISplitViewController *) __unused splitController willHideViewController:(UIViewController *) __unused viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController +{ + barButtonItem.title = NSLocalizedString(@"Master", @"Master"); + [self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES]; + self.masterPopoverController = popoverController; +} + +- (void)splitViewController:(UISplitViewController *) __unused splitController willShowViewController:(UIViewController *) __unused viewController invalidatingBarButtonItem:(UIBarButtonItem *) __unused barButtonItem +{ + // Called when the view is shown again in the split view, invalidating the button and popover controller. + [self.navigationItem setLeftBarButtonItem:nil animated:YES]; + self.masterPopoverController = nil; +} + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/LaunchScreen.storyboard b/examples/cocoa-touch-application/CocoaTouchApplication/LaunchScreen.storyboard new file mode 100644 index 00000000..344bbca5 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/LaunchScreen.storyboard @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.h b/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.h new file mode 100644 index 00000000..27758ce3 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#import + +@class DetailViewController; + +@interface MasterViewController : UITableViewController +{ + NSMutableArray *_objects; + DetailViewController *_detailViewController; +} + +@property (nonatomic, retain) DetailViewController *detailViewController; + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.m b/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.m new file mode 100644 index 00000000..fe8afba0 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/MasterViewController.m @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#import "MasterViewController.h" + +#import "DetailViewController.h" + +@implementation MasterViewController + +@synthesize detailViewController = _detailViewController; + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.title = NSLocalizedString(@"Master", @"Master"); + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { + self.clearsSelectionOnViewWillAppear = NO; + self.preferredContentSize = CGSizeMake(320.0, 600.0); + } + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view, typically from a nib. + self.navigationItem.leftBarButtonItem = self.editButtonItem; + + UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; + self.navigationItem.rightBarButtonItem = addButton; +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)insertNewObject:(id) __unused sender +{ + if (!_objects) { + _objects = [[NSMutableArray alloc] init]; + } + [_objects insertObject:[NSDate date] atIndex:0]; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; + [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; +} + +#pragma mark - Table View + +- (NSInteger)numberOfSectionsInTableView:(UITableView *) __unused tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *) __unused tableView numberOfRowsInSection:(NSInteger) __unused section +{ + return _objects.count; +} + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + } + } + + + NSDate *object = [_objects objectAtIndex:indexPath.row]; + cell.textLabel.text = [object description]; + return cell; +} + +- (BOOL)tableView:(UITableView *) __unused tableView canEditRowAtIndexPath:(NSIndexPath *) __unused indexPath +{ + // Return NO if you do not want the specified item to be editable. + return YES; +} + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (editingStyle == UITableViewCellEditingStyleDelete) { + [_objects removeObjectAtIndex:indexPath.row]; + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. + } +} + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath +{ +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath +{ + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +- (void)tableView:(UITableView *) __unused tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSDate *object = [_objects objectAtIndex:indexPath.row]; + if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { + if (!self.detailViewController) { + self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController_iPhone" bundle:nil]; + } + self.detailViewController.detailItem = object; + [self.navigationController pushViewController:self.detailViewController animated:YES]; + } else { + self.detailViewController.detailItem = object; + } +} + +@end diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPad.xib b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPad.xib new file mode 100644 index 00000000..884dc206 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPad.xib @@ -0,0 +1,223 @@ + + + + 1536 + 12A206j + 2519 + 1172.1 + 613.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1856 + + + IBNSLayoutConstraint + IBProxyObject + IBUILabel + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 274 + + + + 298 + {{20, 495}, {728, 18}} + + + + 3 + MQA + + YES + NO + IBIPadFramework + + 1 + 10 + Detail view content goes here + + 1 + MCAwIDAAA + + 1 + + 1 + 4 + + + Helvetica + 14 + 16 + + + + {{0, 20}, {768, 1004}} + + + + NO + + 2 + + IBIPadFramework + + + + + + + view + + + + 12 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 8 + + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + + + + 81 + + + + + + 94 + + + + + 97 + + + + + 98 + + + + + + + DetailViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 98 + + + 0 + IBIPadFramework + YES + 3 + YES + 1856 + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPhone.xib b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPhone.xib new file mode 100644 index 00000000..6c380252 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/DetailViewController_iPhone.xib @@ -0,0 +1,253 @@ + + + + 1536 + 12A269 + 2835 + 1187 + 624.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1919 + + + IBNSLayoutConstraint + IBProxyObject + IBUILabel + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + + + + 298 + {{20, 265}, {280, 18}} + + + + + 3 + MQA + + YES + NO + IBCocoaTouchFramework + Detail view content goes here + + 1 + MCAwIDAAA + darkTextColor + + + 1 + 10 + 1 + + 1 + 4 + + + Helvetica + 14 + 16 + + + + {{0, 20}, {320, 548}} + + + + + 3 + MQA + + 2 + + + + + IBUIScreenMetrics + + YES + + + + + + {320, 568} + {568, 320} + + + IBCocoaTouchFramework + Retina 4 Full Screen + 2 + + IBCocoaTouchFramework + + + + + + + view + + + + 3 + + + + detailDescriptionLabel + + + + 6 + + + + + + 0 + + + + + + 1 + + + + + 10 + 0 + + 10 + 1 + + 0.0 + + 1000 + + 5 + 22 + 2 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + + + + -1 + + + File's Owner + + + -2 + + + + + 4 + + + + + 7 + + + + + 9 + + + + + 11 + + + + + + + DetailViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 11 + + + 0 + IBCocoaTouchFramework + YES + 3 + YES + 1919 + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/InfoPlist.strings b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/InfoPlist.strings new file mode 100644 index 00000000..b92732c7 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/InfoPlist.strings @@ -0,0 +1 @@ +/* Localized versions of Info.plist keys */ diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPad.xib b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPad.xib new file mode 100644 index 00000000..2b4dba21 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPad.xib @@ -0,0 +1,152 @@ + + + + 1536 + 12A206j + 2519 + 1172.1 + 613.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1856 + + + IBProxyObject + IBUITableView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + 274 + {{0, 20}, {320, 832}} + + + + 3 + MQA + + YES + + 2 + + + IBUISplitViewMasterSimulatedSizeMetrics + + YES + + + + + + {320, 852} + {320, 768} + + + IBIPadFramework + Master + IBUISplitViewController + + IBUISplitViewControllerContentSizeLocation + IBUISplitViewControllerContentSizeLocationMaster + + + IBIPadFramework + YES + 1 + 0 + YES + 44 + 22 + 22 + + + + + + + view + + + + 3 + + + + dataSource + + + + 4 + + + + delegate + + + + 5 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + MasterViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 5 + + + 0 + IBIPadFramework + YES + 3 + YES + 1856 + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPhone.xib b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPhone.xib new file mode 100644 index 00000000..1000ecf2 --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/en.lproj/MasterViewController_iPhone.xib @@ -0,0 +1,147 @@ + + + + 1536 + 12A269 + 2835 + 1187 + 624.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1919 + + + IBProxyObject + IBUITableView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {{0, 20}, {320, 548}} + + + + + 3 + MQA + + YES + + + IBUIScreenMetrics + + YES + + + + + + {320, 568} + {568, 320} + + + IBCocoaTouchFramework + Retina 4 Full Screen + 2 + + IBCocoaTouchFramework + YES + 1 + 0 + YES + 44 + 22 + 22 + + + + + + + view + + + + 3 + + + + dataSource + + + + 4 + + + + delegate + + + + 5 + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + MasterViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 5 + + + 0 + IBCocoaTouchFramework + YES + 3 + YES + 1919 + + diff --git a/examples/cocoa-touch-application/CocoaTouchApplication/main.m b/examples/cocoa-touch-application/CocoaTouchApplication/main.m new file mode 100644 index 00000000..0d92018b --- /dev/null +++ b/examples/cocoa-touch-application/CocoaTouchApplication/main.m @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#import + +#import "AppDelegate.h" + +int main(int argc, char *argv[]) +{ + @autoreleasepool + { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/examples/cocoa-touch-application/cocoa-touch-application.qbs b/examples/cocoa-touch-application/cocoa-touch-application.qbs new file mode 100644 index 00000000..ec199d4a --- /dev/null +++ b/examples/cocoa-touch-application/cocoa-touch-application.qbs @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + Depends { name: "xcode"; required: false } + Depends { condition: product.condition; name: "ib" } + condition: qbs.hostOS.contains("macos") && xcode.present && qbs.targetPlatform.contains("ios") + name: "Cocoa Touch Application" + install: true + + bundle.identifierPrefix: "io.qbs" + bundle.infoPlist: ({"UILaunchStoryboardName": "LaunchScreen"}) + + cpp.useObjcPrecompiledHeader: true + cpp.minimumIosVersion: "9.0" + cpp.automaticReferenceCounting: true + cpp.frameworks: [ "UIKit", "Foundation", "CoreGraphics" ] + + Group { + prefix: "CocoaTouchApplication/" + files: [ + "AppDelegate.h", + "AppDelegate.m", + "CocoaTouchApplication-Info.plist", + "DetailViewController.h", + "DetailViewController.m", + "MasterViewController.h", + "MasterViewController.m", + "main.m" + ] + } + + Group { + name: "Supporting Files" + prefix: "CocoaTouchApplication/en.lproj/" + files: [ + "DetailViewController_iPad.xib", + "DetailViewController_iPhone.xib", + "MasterViewController_iPad.xib", + "MasterViewController_iPhone.xib" + ] + } + + Group { + id: bundle_resources + files: [ + "CocoaTouchApplication/LaunchScreen.storyboard", + "CocoaTouchApplication/en.lproj/InfoPlist.strings" + ] + } + + bundle.resources: bundle_resources.files + + Group { + name: "Xcode Project" + files: [ + "CocoaTouchApplication.xcodeproj/project.pbxproj" + ] + } + + Group { + files: ["CocoaTouchApplication/CocoaTouchApplication-Prefix.pch"] + fileTags: ["objc_pch_src"] + } +} diff --git a/examples/code-generator/code-generator.qbs b/examples/code-generator/code-generator.qbs new file mode 100644 index 00000000..4d664c0e --- /dev/null +++ b/examples/code-generator/code-generator.qbs @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + // A code generator that outputs a "Hello World" C++ program. + CppApplication { + name: "hwgen" + consoleApplication: true + files: ["hwgen.cpp"] + Properties { + condition: qbs.toolchain.contains("gcc") || qbs.toolchain.contains("clang-cl") + cpp.cxxFlags: ["-Wno-deprecated-declarations"] + } + } + + // Generate and build a hello-world application. + CppApplication { + condition: qbs.targetOS === qbs.hostOS + name: "hello-world" + Depends { name: "hwgen" } + Rule { + inputsFromDependencies: ["application"] + Artifact { + filePath: "main.cpp" + fileTags: ["cpp"] + } + prepare: { + var hwgen = inputs["application"][0].filePath; + var cmd = new Command(hwgen, [output.filePath]); + cmd.description = "generating C++ source"; + return cmd; + } + } + } +} diff --git a/examples/code-generator/hwgen.cpp b/examples/code-generator/hwgen.cpp new file mode 100644 index 00000000..90f2eadf --- /dev/null +++ b/examples/code-generator/hwgen.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include + +int main(int argc, char **argv) +{ + if (argc < 2) + return 1; + std::FILE *f = std::fopen(argv[1], "w"); + if (!f) + return 2; + std::fprintf(f, "#include \n\n" + "int main()\n" + "{\n std::printf(\"Hello World!\\n\");\n return 0;\n}\n"); + std::fclose(f); + return 0; +} diff --git a/examples/collidingmice/collidingmice.qbs b/examples/collidingmice/collidingmice.qbs new file mode 100644 index 00000000..8f93a323 --- /dev/null +++ b/examples/collidingmice/collidingmice.qbs @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + name : "CollidingMice" + Depends { name: "Qt.widgets" } + property bool isBundle: qbs.targetOS.contains("darwin") && bundle.isBundle + files : [ + "images/cheese.jpg", + "main.cpp", + "mouse.cpp", + "mouse.h", + "mice.qrc" + ] + Group { + fileTagsFilter: isBundle ? ["bundle.content"] : ["application"] + qbs.install: true + qbs.installDir: isBundle ? "Applications" : (qbs.targetOS.contains("windows") ? "" : "bin") + qbs.installSourceBase: product.buildDirectory + } +} diff --git a/examples/collidingmice/images/cheese.jpg b/examples/collidingmice/images/cheese.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dea5795fd0b7a4dfa46bf7274d068885d700914e GIT binary patch literal 3029 zcmaKtcU03$7RP_7bYf^qkzS;UAXO4Np@=|e0s_*4QWPoDrAzNkil7t;hyo%V0g*^m zX_1a-02Llx-~~{!dG4OweShqJ=bStD&Yd~ub7$t9OPQv822L4b3@`u)3Or7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*u-d}w|+QjA*P20>#yl`}ti73FL zQCB|)t|MD`Yxqhug5O&*X%fkyB=A*syyjFbZ-Vx#TawaDm?f{5oGwbk-384`m(mMy z3DJ|2rOrBkXaMSoD#=-aN=l4CAIoJvsU!^7*`mAK!%~C`{MQ8HhvjVMby3&`rbN7l zo74{n)QaU|FEJe}GXRHWfQjj5;? zWaK;@aP`E!V`&CVGBzn_HngoWz?A)3IxYER@?-TuUoaHDUY;^squvw{lvzxV2Kl2k z1sm0tgfZ*jHqExPci5UA-?3y2Sd5s8%h-y?r(+}6ANZ00`Cd-`_=4cxVb8l&qBU$@ zpPHa6ffAoV=Ig#Tdq1&D>HWh89P6Al<5*ivTr9qZnG~Hr+?Pz3U=(0B_dio)x!k(}F@}Zit~99y zXX905#&$NzdroRx3l6hu^BK4aHY3RaVWL)8;IiIg?!(z|$r4r71^uX_@HdHi()X@~ z=88Qs%@gmccFmjo5^-;}y<=y~e5i5f@!(RyLy<2!7==!6i9Z6nyCRvK`H=(zHFsAC Vi6{N-mmDs<0OvLl=N>_s`3L5NTuJ}{ literal 0 HcmV?d00001 diff --git a/examples/collidingmice/main.cpp b/examples/collidingmice/main.cpp new file mode 100644 index 00000000..2d051442 --- /dev/null +++ b/examples/collidingmice/main.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "mouse.h" + +#include +#include +#include +#include +#include + +#include + +static const int MouseCount = 7; + +//! [0] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); +//! [0] + +//! [1] + QGraphicsScene scene; + scene.setSceneRect(-300, -300, 600, 600); +//! [1] //! [2] + scene.setItemIndexMethod(QGraphicsScene::NoIndex); +//! [2] + +//! [3] + for (int i = 0; i < MouseCount; ++i) { + const auto mouse = new Mouse; + mouse->setPos(::sin((i * 6.28) / MouseCount) * 200, + ::cos((i * 6.28) / MouseCount) * 200); + scene.addItem(mouse); + } +//! [3] + +//! [4] + QGraphicsView view(&scene); + view.setRenderHint(QPainter::Antialiasing); + view.setBackgroundBrush(QPixmap(":/images/cheese.jpg")); +//! [4] //! [5] + view.setCacheMode(QGraphicsView::CacheBackground); + view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + view.setDragMode(QGraphicsView::ScrollHandDrag); +//! [5] //! [6] + view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice")); + view.resize(400, 300); + view.show(); + + QTimer timer; + QObject::connect(&timer, &QTimer::timeout, &scene, &QGraphicsScene::advance); + timer.start(1000 / 33); + + return app.exec(); +} +//! [6] diff --git a/examples/collidingmice/mice.qrc b/examples/collidingmice/mice.qrc new file mode 100644 index 00000000..accdb4d0 --- /dev/null +++ b/examples/collidingmice/mice.qrc @@ -0,0 +1,5 @@ + + + images/cheese.jpg + + diff --git a/examples/collidingmice/mouse.cpp b/examples/collidingmice/mouse.cpp new file mode 100644 index 00000000..bbc71864 --- /dev/null +++ b/examples/collidingmice/mouse.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "mouse.h" + +#include +#include +#include + +#include + +static const double Pi = 3.14159265358979323846264338327950288419717; +static double TwoPi = 2.0 * Pi; + +static qreal normalizeAngle(qreal angle) +{ + while (angle < 0) + angle += TwoPi; + while (angle > TwoPi) + angle -= TwoPi; + return angle; +} + +//! [0] +Mouse::Mouse() + : angle(0), speed(0), mouseEyeDirection(0), + color(m_rand.generate() % 256, m_rand.generate() % 256, m_rand.generate() % 256) +{ + setRotation(m_rand.generate() % (360 * 16)); +} +//! [0] + +//! [1] +QRectF Mouse::boundingRect() const +{ + qreal adjust = 0.5; + return {-18 - adjust, -22 - adjust, 36 + adjust, 60 + adjust}; +} +//! [1] + +//! [2] +QPainterPath Mouse::shape() const +{ + QPainterPath path; + path.addRect(-10, -20, 20, 40); + return path; +} +//! [2] + +//! [3] +void Mouse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) +{ + // Body + painter->setBrush(color); + painter->drawEllipse(-10, -20, 20, 40); + + // Eyes + painter->setBrush(Qt::white); + painter->drawEllipse(-10, -17, 8, 8); + painter->drawEllipse(2, -17, 8, 8); + + // Nose + painter->setBrush(Qt::black); + painter->drawEllipse(QRectF(-2, -22, 4, 4)); + + // Pupils + painter->drawEllipse(QRectF(-8.0 + mouseEyeDirection, -17, 4, 4)); + painter->drawEllipse(QRectF(4.0 + mouseEyeDirection, -17, 4, 4)); + + // Ears + painter->setBrush(scene()->collidingItems(this).isEmpty() ? Qt::darkYellow : Qt::red); + painter->drawEllipse(-17, -12, 16, 16); + painter->drawEllipse(1, -12, 16, 16); + + // Tail + QPainterPath path(QPointF(0, 20)); + path.cubicTo(-5, 22, -5, 22, 0, 25); + path.cubicTo(5, 27, 5, 32, 0, 30); + path.cubicTo(-5, 32, -5, 42, 0, 35); + painter->setBrush(Qt::NoBrush); + painter->drawPath(path); +} +//! [3] + +//! [4] +void Mouse::advance(int step) +{ + if (!step) + return; +//! [4] + // Don't move too far away +//! [5] + QLineF lineToCenter(QPointF(0, 0), mapFromScene(0, 0)); + if (lineToCenter.length() > 150) { + qreal angleToCenter = ::acos(lineToCenter.dx() / lineToCenter.length()); + if (lineToCenter.dy() < 0) + angleToCenter = TwoPi - angleToCenter; + angleToCenter = normalizeAngle((Pi - angleToCenter) + Pi / 2); + + if (angleToCenter < Pi && angleToCenter > Pi / 4) { + // Rotate left + angle += (angle < -Pi / 2) ? 0.25 : -0.25; + } else if (angleToCenter >= Pi && angleToCenter < (Pi + Pi / 2 + Pi / 4)) { + // Rotate right + angle += (angle < Pi / 2) ? 0.25 : -0.25; + } + } else if (::sin(angle) < 0) { + angle += 0.25; + } else if (::sin(angle) > 0) { + angle -= 0.25; +//! [5] //! [6] + } +//! [6] + + // Try not to crash with any other mice +//! [7] + const QList dangerMice = scene()->items(QPolygonF() + << mapToScene(0, 0) + << mapToScene(-30, -50) + << mapToScene(30, -50)); + for (QGraphicsItem *item : dangerMice) { + if (item == this) + continue; + + QLineF lineToMouse(QPointF(0, 0), mapFromItem(item, 0, 0)); + qreal angleToMouse = ::acos(lineToMouse.dx() / lineToMouse.length()); + if (lineToMouse.dy() < 0) + angleToMouse = TwoPi - angleToMouse; + angleToMouse = normalizeAngle((Pi - angleToMouse) + Pi / 2); + + if (angleToMouse >= 0 && angleToMouse < Pi / 2) { + // Rotate right + angle += 0.5; + } else if (angleToMouse <= TwoPi && angleToMouse > (TwoPi - Pi / 2)) { + // Rotate left + angle -= 0.5; +//! [7] //! [8] + } +//! [8] //! [9] + } +//! [9] + + // Add some random movement +//! [10] + if (dangerMice.size() > 1 && (m_rand.generate() % 10) == 0) { + if (m_rand.generate() % 1) + angle += (m_rand.generate() % 100) / 500.0; + else + angle -= (m_rand.generate() % 100) / 500.0; + } +//! [10] + +//! [11] + speed += (-50 + m_rand.generate() % 100) / 100.0; + + qreal dx = ::sin(angle) * 10; + mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5; + + setRotation(rotation() + dx); + setPos(mapToParent(0, -(3 + sin(speed) * 3))); +} +//! [11] diff --git a/examples/collidingmice/mouse.h b/examples/collidingmice/mouse.h new file mode 100644 index 00000000..23b9faad --- /dev/null +++ b/examples/collidingmice/mouse.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef MOUSE_H +#define MOUSE_H + +#include +#include + +//! [0] +class Mouse : public QGraphicsItem +{ +public: + Mouse(); + + QRectF boundingRect() const override; + QPainterPath shape() const override; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget) override; + +protected: + void advance(int step) override; + +private: + QRandomGenerator m_rand = QRandomGenerator::securelySeeded(); + qreal angle; + qreal speed; + qreal mouseEyeDirection; + QColor color; +}; +//! [0] + +#endif diff --git a/examples/compiled-qml/MainForm.ui.qml b/examples/compiled-qml/MainForm.ui.qml new file mode 100644 index 00000000..0b1653eb --- /dev/null +++ b/examples/compiled-qml/MainForm.ui.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +import QtQuick 2.3 + +Rectangle { + property alias mouseArea: mouseArea + + width: 360 + height: 360 + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + Image { + anchors.centerIn: parent + source: "cheese.jpg" + } +} diff --git a/examples/compiled-qml/cheese.jpg b/examples/compiled-qml/cheese.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dea5795fd0b7a4dfa46bf7274d068885d700914e GIT binary patch literal 3029 zcmaKtcU03$7RP_7bYf^qkzS;UAXO4Np@=|e0s_*4QWPoDrAzNkil7t;hyo%V0g*^m zX_1a-02Llx-~~{!dG4OweShqJ=bStD&Yd~ub7$t9OPQv822L4b3@`u)3Or7X3xUF*e+dSM{T3WfLqkhL1E-^-r>CQ1{JTI9 z2m}U&(ZS(#O!Rd0ObBMG5QyKK{xvcFGy40ve@B$p0FoAP030A7BmhQ&AV?5p0e}LG z6auJ>ib(_dOH}8#pfCs+4gzRs>F60iRCvgLXQ>NRcKGk)DF94G14F@Z8VJ>Z{Xk#{ z5(>ZsSY$P^a8@TlpC~rD%u*Wm7g|C+W@BG2ayV}b`$q4GXv>>tl{L8dy;0B+%PxPZ zc-q3%zjvHOD;h&be}*$QM;BAkXfbAj|)kBF(hPECdNrg|_ zhi2D~sO5vHlrZXb!lASf$SrC;NC@;VVi=Z64EKr3lq-F)&DJyaMM#U?%-MJ6qOiPn zG)I=XNSRB+8ydfH1(Ht8X^U*??VRBhRn+AYbM?1W+AV+Cdro{}=|^l%MdRO*F;@S9 z{-4bM2bnSpFhYJ~A^~;aSaZU=EWRJ5l(Py3@W3|19|XV_#NE7m=ivbY~VGswbngP#v%wyeF0m9Kl7b{seu z$9LB40QPONY$KJkl#{EWTasboYa)gyS9T>N?_j zIZ}CGoDs*NFM_%j!Dyu9ApM9kdVJ}ae)Ec_(RMv=skijeZ65*oR-{AGvgw35KJA-` z$L#2)KBOO-Yiz^9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index 00000000..5d5dd3a8 --- /dev/null +++ b/examples/compiled-qml/compiled-qml.qbs @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + Depends { name: "Qt.quick" } + + files: [ + "cheese.jpg", + "main.cpp", + "qml.qrc" + ] + + Group { + name: "QML Files" + files: ["*.qml"] + } +} diff --git a/examples/compiled-qml/main.cpp b/examples/compiled-qml/main.cpp new file mode 100644 index 00000000..27074068 --- /dev/null +++ b/examples/compiled-qml/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} diff --git a/examples/compiled-qml/main.qml b/examples/compiled-qml/main.qml new file mode 100644 index 00000000..4b7c4dc7 --- /dev/null +++ b/examples/compiled-qml/main.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Window 2.2 + +Window { + visible: true + MainForm { + anchors.fill: parent + mouseArea.onClicked: { + Qt.quit(); + } + } +} diff --git a/examples/compiled-qml/qml.qrc b/examples/compiled-qml/qml.qrc new file mode 100644 index 00000000..deb314e5 --- /dev/null +++ b/examples/compiled-qml/qml.qrc @@ -0,0 +1,7 @@ + + + main.qml + MainForm.ui.qml + cheese.jpg + + diff --git a/examples/examples.qbs b/examples/examples.qbs new file mode 100644 index 00000000..d457b8a8 --- /dev/null +++ b/examples/examples.qbs @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + references: [ + "app-and-lib/app-and-lib.qbs", + "cocoa-application/cocoa-application.qbs", + "cocoa-touch-application/cocoa-touch-application.qbs", + "code-generator/code-generator.qbs", + "collidingmice/collidingmice.qbs", + "compiled-qml/compiled-qml.qbs", + "grpc/grpc.qbs", + "helloworld-complex/helloworld-complex.qbs", + "helloworld-minimal/helloworld-minimal.qbs", + "helloworld-qt/helloworld-qt.qbs", + "install-bundle/install-bundle.qbs", + // these examples are broken because of the bug in the protobuf modules + // "protobuf/addressbook_cpp/addressbook_cpp.qbs", + // "protobuf/addressbook_objc/addressbook_objc.qbs", + "baremetal/baremetal.qbs", + "rule/rule.qbs", + "rpaths/rpaths.qbs", + ] +} diff --git a/examples/grpc/client.cpp b/examples/grpc/client.cpp new file mode 100644 index 00000000..e6af8e5e --- /dev/null +++ b/examples/grpc/client.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif // __GNUC__ + +#include + +#include +#include +#include +#include + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +#include +#include +#include + +class Client +{ +public: + Client(const std::shared_ptr &channel) + : m_stub(PP::MyApi::NewStub(channel)) {} + + int ping(int count) { + PP::Ping request; + request.set_count(count); + PP::Pong reply; + grpc::ClientContext context; + + const auto status = m_stub->pingPong(&context, request, &reply); + if (status.ok()) { + return reply.count(); + } else { + throw std::runtime_error("invalid status"); + } + } + +private: + std::unique_ptr m_stub; +}; + +int main(int, char**) +{ + Client client( + grpc::CreateCustomChannel( + "localhost:50051", + grpc::InsecureChannelCredentials(), + grpc::ChannelArguments())); + + for (int i = 0; i < 1000; ++i) { + std::cout << "Sending ping " << i << "... "; + int result = client.ping(i); + if (result != i) { + std::cerr << "Invalid pong " << result << " for ping" << i << std::endl; + continue; + } + std::cout << "got pong " << result << std::endl; + } + + return 0; +} + diff --git a/examples/grpc/grpc.qbs b/examples/grpc/grpc.qbs new file mode 100644 index 00000000..c4f146ec --- /dev/null +++ b/examples/grpc/grpc.qbs @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Utilities + +Project { + condition: Utilities.versionCompare(qbs.version, "1.14") >= 0 + + Application { + Depends { name: "cpp" } + Depends { name: "protobuf.cpp"; required: false } + condition: protobuf.cpp.present && qbs.targetOS === qbs.hostOS + protobuf.cpp.useGrpc: true + consoleApplication: true + cpp.cxxLanguageVersion: "c++17" + cpp.minimumMacosVersion: "10.8" + name: "client" + files: "client.cpp" + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.cxxFlags: "-Wno-deprecated-declarations" + } + Group { + files: "ping-pong-grpc.proto" + fileTags: "protobuf.grpc" + } + } + + Application { + Depends { name: "cpp" } + Depends { name: "protobuf.cpp"; required: false } + condition: protobuf.cpp.present && qbs.targetOS === qbs.hostOS + protobuf.cpp.useGrpc: true + consoleApplication: true + cpp.cxxLanguageVersion: "c++17" + cpp.minimumMacosVersion: "10.8" + name: "server" + files: "server.cpp" + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.cxxFlags: "-Wno-deprecated-declarations" + } + Group { + files: "ping-pong-grpc.proto" + fileTags: "protobuf.grpc" + } + } +} diff --git a/examples/grpc/ping-pong-grpc.proto b/examples/grpc/ping-pong-grpc.proto new file mode 100644 index 00000000..da6d9490 --- /dev/null +++ b/examples/grpc/ping-pong-grpc.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package PP; + +message Ping { + int32 count = 1; +} + +message Pong { + int32 count = 1; +} + +service MyApi { + rpc pingPong(Ping) returns (Pong) {} +} diff --git a/examples/grpc/server.cpp b/examples/grpc/server.cpp new file mode 100644 index 00000000..74460d29 --- /dev/null +++ b/examples/grpc/server.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif // __GNUC__ + +#include + +#include +#include +#include +#include +#include + +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ + +#include +#include +#include + +class Service final : public PP::MyApi::Service +{ + grpc::Status pingPong( + grpc::ServerContext* context, + const PP::Ping* request, + PP::Pong* reply) override + { + (void)context; + reply->set_count(request->count()); + return grpc::Status::OK; + } +}; + +int main(int, char**) +{ + std::string server_address("0.0.0.0:50051"); + Service service; + + grpc::ServerBuilder builder; + builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); + builder.RegisterService(&service); + std::unique_ptr server(builder.BuildAndStart()); + std::cout << "Server listening on " << server_address << std::endl; + server->Wait(); + return 0; +} + diff --git a/examples/helloworld-complex/helloworld-complex.qbs b/examples/helloworld-complex/helloworld-complex.qbs new file mode 100644 index 00000000..fab3fd51 --- /dev/null +++ b/examples/helloworld-complex/helloworld-complex.qbs @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +Project { + property bool hasSpecialFeature: true + Application { + name: 'HelloWorld-Complex' + + Depends { name: 'cpp' } + cpp.defines: ['SOMETHING'] + + + files: [ + "src/foo.h", + "src/foo.cpp" + ] + + Group { + condition: project.hasSpecialFeature + prefix: "src/" + files: ["specialfeature.cpp", "specialfeature.h"] + } + + Group { + cpp.defines: { + var defines = outer.concat([ + 'HAVE_MAIN_CPP', + cpp.debugInformation ? 'HAS_DEBUG' : 'HAS_RELEASE' + ]); + if (project.hasSpecialFeature) + defines.push("HAS_SPECIAL_FEATURE"); + return defines; + } + prefix: "src/" + files: [ + 'main.cpp' + ] + } + } +} diff --git a/examples/helloworld-complex/src/foo.cpp b/examples/helloworld-complex/src/foo.cpp new file mode 100644 index 00000000..74c5bf7b --- /dev/null +++ b/examples/helloworld-complex/src/foo.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SOMETHING +# error missing define SOMETHING +#endif + +int someUsefulFunction() +{ + return 156; +} + diff --git a/examples/helloworld-complex/src/foo.h b/examples/helloworld-complex/src/foo.h new file mode 100644 index 00000000..abeef38b --- /dev/null +++ b/examples/helloworld-complex/src/foo.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef FOO_H +#define FOO_H + +int someUsefulFunction(); + +#endif + diff --git a/examples/helloworld-complex/src/main.cpp b/examples/helloworld-complex/src/main.cpp new file mode 100644 index 00000000..54e215d1 --- /dev/null +++ b/examples/helloworld-complex/src/main.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "foo.h" + +#ifdef HAS_SPECIAL_FEATURE +#include "specialfeature.h" +#endif + +#include + +#ifndef HAVE_MAIN_CPP +# error missing define HAVE_MAIN_CPP +#endif + +#ifndef SOMETHING +# error missing define SOMETHING +#endif + +int main() +{ + someUsefulFunction(); +#if defined(HAS_DEBUG) + std::puts("Hello World! (debug version)"); +#elif defined(HAS_RELEASE) + std::puts("Hello World! (release version)"); +#endif +#ifdef HAS_SPECIAL_FEATURE + bragAboutSpecialFeature(); +#endif +} + diff --git a/examples/helloworld-complex/src/specialfeature.cpp b/examples/helloworld-complex/src/specialfeature.cpp new file mode 100644 index 00000000..63f5fd76 --- /dev/null +++ b/examples/helloworld-complex/src/specialfeature.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "specialfeature.h" + +#include + +void bragAboutSpecialFeature() +{ + std::cout << "I have a special feature!" << std::endl; +} diff --git a/examples/helloworld-complex/src/specialfeature.h b/examples/helloworld-complex/src/specialfeature.h new file mode 100644 index 00000000..9e1cfaaa --- /dev/null +++ b/examples/helloworld-complex/src/specialfeature.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef HELLO_SPECIAL_FEATURE +#define HELLO_SPECIAL_FEATURE + +void bragAboutSpecialFeature(); + +#endif diff --git a/examples/helloworld-minimal/helloworld-minimal.qbs b/examples/helloworld-minimal/helloworld-minimal.qbs new file mode 100644 index 00000000..40149d01 --- /dev/null +++ b/examples/helloworld-minimal/helloworld-minimal.qbs @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +CppApplication { + name: "HelloWorld-minimal" + files: "main.cpp" +} diff --git a/examples/helloworld-minimal/main.cpp b/examples/helloworld-minimal/main.cpp new file mode 100644 index 00000000..6d8ac039 --- /dev/null +++ b/examples/helloworld-minimal/main.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include + +int main() +{ + std::cout << "Hello, World!" << std::endl; +} diff --git a/examples/helloworld-qt/helloworld-qt.qbs b/examples/helloworld-qt/helloworld-qt.qbs new file mode 100644 index 00000000..8d8b6e49 --- /dev/null +++ b/examples/helloworld-qt/helloworld-qt.qbs @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +QtApplication { + name: "HelloWorld-Qt" + files: "main.cpp" +} diff --git a/examples/helloworld-qt/main.cpp b/examples/helloworld-qt/main.cpp new file mode 100644 index 00000000..e1e82259 --- /dev/null +++ b/examples/helloworld-qt/main.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include + +#include + +int main() +{ + QTextStream ts(stdout); + ts << QCoreApplication::translate("hello", "Hello, World!\n"); + ts.flush(); +} diff --git a/examples/install-bundle/MainMenu.xib b/examples/install-bundle/MainMenu.xib new file mode 100644 index 00000000..14312411 --- /dev/null +++ b/examples/install-bundle/MainMenu.xib @@ -0,0 +1,680 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/install-bundle/Storyboard.storyboard b/examples/install-bundle/Storyboard.storyboard new file mode 100644 index 00000000..06aef2bc --- /dev/null +++ b/examples/install-bundle/Storyboard.storyboard @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/install-bundle/assetcatalog1.xcassets/other.imageset/Contents.json b/examples/install-bundle/assetcatalog1.xcassets/other.imageset/Contents.json new file mode 100644 index 00000000..4b1cfb1f --- /dev/null +++ b/examples/install-bundle/assetcatalog1.xcassets/other.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x", + "filename" : "icon_16x16.png" + }, + { + "idiom" : "universal", + "scale" : "2x", + "filename" : "icon_16x16@2x.png" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/install-bundle/assetcatalog1.xcassets/other.imageset/icon_16x16.png b/examples/install-bundle/assetcatalog1.xcassets/other.imageset/icon_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..60365798f18a376a1193bca9e6044cc778c6042a GIT binary patch literal 649 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z81_maE%#etZ2wxwolpi<;HsXMd|v6mX?>t*GR!IU;uq7Dc2xlVci@>1|NgPQZ$Q4%pMVYC< z00ISrouQ3Bh8R@6jXo%hkirZSAz)EpjM#D6=)+^zj!XI29Z;fC@^o+tIX_n~F(p4KRj(qq0H~UQ!KT6r$jnVGNmQuF&B-ga zs<2f8tFQvHLBje<3ScEA*|tg%z5xo(`9-M;rg|oN21<5Z3JMA~MJZ`kK`w4k?LeNb zQbtKhft9{~d3m{Bxv^e;QM$gNrKP35fswwEkuFe$ZgFK^Nn(X=Ua>O75STeGsl~}f znFS@8`FRQ;a}$&DOG|8(lt3220mPlD6`2T|@`|C}0(wv%B%^PrXP}QwTS;ab4s9SA zh&HglAlBJ{46_QztVqp?bji$3%_{~v&CbLIYzc-q!kI|=B5>$K5=YVpa)p(DQD!PI zfIz`uXK163AqG`%qYnxrq%ea-2v`&tBX(Ri`taDb<5E6$2b5@xJY5_^A~@e(aO7oR z;9xd9us>a4#)Hd}JC@$uT@houP5&(eBNGdUfPzBlpi<;HsXMd|v6mX?>t*GR!IU;uq7Dc2xlVci@>1|NgPQZ$Q4%pMVYC< z00ISrouQ3Bh8R@6jXo%hkirZSAz)EpjM#D6=)+^zj!XI29Z;fC@^o+tIX_n~F(p4KRj(qq0H~UQ!KT6r$jnVGNmQuF&B-ga zs<2f8tFQvHLBje<3ScEA*|tg%z5xo(`9-M;rg|oN21<5Z3JMA~MJZ`kK`w4k?LeNb zQbtKhft9{~d3m{Bxv^e;QM$gNrKP35fswwEkuFe$ZgFK^Nn(X=Ua>O75STeGsl~}f znFS@8`FRQ;a}$&DOG|8(lt3220mPlD6`2T|@`|C}0(wv%B%^PrXP}QwTS;ab4s9SA zh&HglAlBJ{46_QztVqp?bji$3%_{~v&CbLIYzc-q!kI|=B5>$K5=YVpa)p(DQD!PI zfIz`uXK163AqG`%qYnxrq%ea-2v`&tBX(Ri`taDb<5E6$2b5@xJY5_^A~@e(aO7oR z;9xd9us>a4#)Hd}JC@$uT@houP5&(eBNGdUfPzB +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + QWidget window; + window.show(); + return app.exec(); +} diff --git a/examples/install-bundle/white.iconset/icon_16x16.png b/examples/install-bundle/white.iconset/icon_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..60365798f18a376a1193bca9e6044cc778c6042a GIT binary patch literal 649 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z81_maE%#etZ2wxwolpi<;HsXMd|v6mX?>t*GR!IU;uq7Dc2xlVci@>1|NgPQZ$Q4%pMVYC< z00ISrouQ3Bh8R@6jXo%hkirZSAz)EpjM#D6=)+^zj!XI29Z;fC@^o+tIX_n~F(p4KRj(qq0H~UQ!KT6r$jnVGNmQuF&B-ga zs<2f8tFQvHLBje<3ScEA*|tg%z5xo(`9-M;rg|oN21<5Z3JMA~MJZ`kK`w4k?LeNb zQbtKhft9{~d3m{Bxv^e;QM$gNrKP35fswwEkuFe$ZgFK^Nn(X=Ua>O75STeGsl~}f znFS@8`FRQ;a}$&DOG|8(lt3220mPlD6`2T|@`|C}0(wv%B%^PrXP}QwTS;ab4s9SA zh&HglAlBJ{46_QztVqp?bji$3%_{~v&CbLIYzc-q!kI|=B5>$K5=YVpa)p(DQD!PI zfIz`uXK163AqG`%qYnxrq%ea-2v`&tBX(Ri`taDb<5E6$2b5@xJY5_^A~@e(aO7oR z;9xd9us>a4#)Hd}JC@$uT@houP5&(eBNGdUfPzB +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + int res; + + if (argc < 2) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + + char* fname = argv[1]; + + struct stat file_stat; + res = stat(fname, &file_stat); + if (res == -1) + { + fprintf(stderr, "stat(...) failed, errno = %d\n", errno); + return 1; + } + + size_t temp_file_size = (size_t)file_stat.st_size; + if (temp_file_size >= INT_MAX) + { + fprintf(stderr, "Error: filze_size >= INT_MAX (%d)\n", INT_MAX); + return 1; + } + + int file_size = (int)temp_file_size; + int buff_size = file_size + 1; + void* file_buff = malloc(buff_size); + if (file_buff == NULL) + { + fprintf(stderr, "malloc(buff_size) failed, buff_size = %d\n", + file_size); + return 1; + } + + int fid = open(fname, O_RDONLY); + if (fid == -1) + { + fprintf(stderr, "open(...) failed, errno = %d\n", errno); + free(file_buff); + return 1; + } + + if (read(fid, file_buff, file_size) != file_size) + { + fprintf(stderr, "read(...) failed, errno = %d\n", errno); + free(file_buff); + close(fid); + return 1; + } + + close(fid); + + uLongf compress_buff_size = compressBound(file_size); + void* compress_buff = malloc(compress_buff_size); + if (compress_buff == NULL) + { + fprintf(stderr, + "malloc(compress_buff_size) failed, " + "compress_buff_size = %lu\n", + compress_buff_size); + free(file_buff); + return 1; + } + + uLongf compressed_size = compress_buff_size; + res = compress(compress_buff, &compressed_size, file_buff, file_size); + if (res != Z_OK) + { + fprintf(stderr, "compress(...) failed, res = %d\n", res); + free(compress_buff); + free(file_buff); + return 1; + } + + memset(file_buff, 0, buff_size); + uLongf decompressed_size = (uLongf)file_size; + res = uncompress(file_buff, &decompressed_size, + compress_buff, compressed_size); + if (res != Z_OK) + { + fprintf(stderr, "uncompress(...) failed, res = %d\n", res); + free(compress_buff); + free(file_buff); + return 1; + } + + printf( + "%s\n----------------\n" + "File size: %d, compress_buff_size: %lu, compressed_size: %lu, " + "decompressed_size: %lu\n", + (char*)file_buff, file_size, compress_buff_size, compressed_size, + decompressed_size); + + free(compress_buff); + free(file_buff); +} diff --git a/examples/pkgconfig-provider/pkgconfig-provider.qbs b/examples/pkgconfig-provider/pkgconfig-provider.qbs new file mode 100644 index 00000000..34ba32d0 --- /dev/null +++ b/examples/pkgconfig-provider/pkgconfig-provider.qbs @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +//! [0] +CppApplication { + consoleApplication: true + Depends { name: "zlib"; required: false } + condition: zlib.present + name: "PkgConfigProviderExample" + files: "main.c" + qbsModuleProviders: ["qbspkgconfig"] +} +//! [0] diff --git a/examples/protobuf/addressbook_cpp/README.md b/examples/protobuf/addressbook_cpp/README.md new file mode 100644 index 00000000..f0e1b1a9 --- /dev/null +++ b/examples/protobuf/addressbook_cpp/README.md @@ -0,0 +1,13 @@ +### Addressbook c++ example + +This example shows how to build a cpp application that uses Google protobuf. + +In order to build this example, you'll need to have a protobuf headers and library installed in the system in locations where QBS can find them. + +On Linux, you can install a package to the system. + +On macOS, you can use brew or compile and install protobuf manually: +- to /usr/local/ +- to any folder, say /Users//protobuf. Then you'll need to set protobuf.libraryPath: "/Users//protobuf/lib" and protobuf.includePath: "/Users//protobuf/include" + +On Windows, you have to compile and install protobuf manually to any folder and use libraryPath and includePath as shown above diff --git a/examples/protobuf/addressbook_cpp/addressbook_cpp.qbs b/examples/protobuf/addressbook_cpp/addressbook_cpp.qbs new file mode 100644 index 00000000..667b3022 --- /dev/null +++ b/examples/protobuf/addressbook_cpp/addressbook_cpp.qbs @@ -0,0 +1,18 @@ +import qbs.Host + +CppApplication { + consoleApplication: true + condition: protobuf.cpp.present && qbs.targetPlatform === Host.platform() + + Depends { name: "cpp" } + cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" + + Depends { name: "protobuf.cpp"; required: false } + + files: [ + "../shared/addressbook.proto", + "main.cpp", + "README.md", + ] +} diff --git a/examples/protobuf/addressbook_cpp/main.cpp b/examples/protobuf/addressbook_cpp/main.cpp new file mode 100644 index 00000000..31baba3d --- /dev/null +++ b/examples/protobuf/addressbook_cpp/main.cpp @@ -0,0 +1,179 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// 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 Google Inc. 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. + +#include +#include +#include +#include + +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-parameter" +# include +# pragma GCC diagnostic pop +#else +# include +#endif // __GNUC__ + +#include "addressbook.pb.h" + +using google::protobuf::util::TimeUtil; + +int printUsage(char *argv0) +{ + std::cerr << "Usage: " << argv0 << "add|list ADDRESS_BOOK_FILE" << std::endl; + return -1; +} + +std::string readString(const std::string &promt) +{ + std::string result; + std::cout << promt; + std::getline(std::cin, result); + return result; +} + +// This function fills in a Person message based on user input. +void promptForAddress(tutorial::Person* person) +{ + std::cout << "Enter person ID number: "; + int id; + std::cin >> id; + person->set_id(id); + std::cin.ignore(256, '\n'); + + *person->mutable_name() = readString("Enter name: "); + + const auto email = readString("Enter email address (blank for none): "); + if (!email.empty()) + person->set_email(email); + + while (true) { + const auto number = readString("Enter a phone number (or leave blank to finish): "); + if (number.empty()) + break; + + tutorial::Person::PhoneNumber *phone_number = person->add_phones(); + phone_number->set_number(number); + + const auto type = readString("Is this a mobile, home, or work phone? "); + if (type == "mobile") + phone_number->set_type(tutorial::Person::MOBILE); + else if (type == "home") + phone_number->set_type(tutorial::Person::HOME); + else if (type == "work") + phone_number->set_type(tutorial::Person::WORK); + else + std::cout << "Unknown phone type. Using default." << std::endl; + } + *person->mutable_last_updated() = TimeUtil::SecondsToTimestamp(time(NULL)); +} + +// Iterates though all people in the AddressBook and prints info about them. +void listPeople(const tutorial::AddressBook& address_book) +{ + for (int i = 0; i < address_book.people_size(); i++) { + const tutorial::Person& person = address_book.people(i); + + std::cout << "Person ID: " << person.id() << std::endl; + std::cout << " Name: " << person.name() << std::endl; + if (!person.email().empty()) { + std::cout << " E-mail address: " << person.email() << std::endl; + } + + for (int j = 0; j < person.phones_size(); j++) { + const tutorial::Person::PhoneNumber& phone_number = person.phones(j); + + switch (phone_number.type()) { + case tutorial::Person::MOBILE: + std::cout << " Mobile phone #: "; + break; + case tutorial::Person::HOME: + std::cout << " Home phone #: "; + break; + case tutorial::Person::WORK: + std::cout << " Work phone #: "; + break; + default: + std::cout << " Unknown phone #: "; + break; + } + std::cout << phone_number.number() << std::endl; + } + if (person.has_last_updated()) { + std::cout << " Updated: " << TimeUtil::ToString(person.last_updated()) << std::endl; + } + } +} + +int main(int argc, char* argv[]) { + // Verify that the version of the library that we linked against is + // compatible with the version of the headers we compiled against. + GOOGLE_PROTOBUF_VERIFY_VERSION; + + if (argc != 3) + return printUsage(argv[0]); + + tutorial::AddressBook address_book; + + // Read the existing address book. + std::fstream input(argv[2], std::ios::in | std::ios::binary); + if (!input) { + std::cout << argv[2] << ": File not found." << std::endl; + } else if (!address_book.ParseFromIstream(&input)) { + std::cerr << "Failed to parse address book." << std::endl; + return -1; + } + + const std::string mode(argv[1]); + if (mode == "add") { + // Add an address. + promptForAddress(address_book.add_people()); + + if (!input) + std::cout << "Creating a new file." << std::endl; + + // Write the new address book back to disk. + std::fstream output(argv[2], std::ios::out | std::ios::trunc | std::ios::binary); + if (!address_book.SerializeToOstream(&output)) { + std::cerr << "Failed to write address book." << std::endl; + return -1; + } + } else if (mode == "list") { + listPeople(address_book); + } else { + return printUsage(argv[0]); + } + + // Optional: Delete all global objects allocated by libprotobuf. + google::protobuf::ShutdownProtobufLibrary(); + + return 0; +} diff --git a/examples/protobuf/addressbook_objc/README.md b/examples/protobuf/addressbook_objc/README.md new file mode 100644 index 00000000..c0fc7c0e --- /dev/null +++ b/examples/protobuf/addressbook_objc/README.md @@ -0,0 +1,5 @@ +### Addressbook objc example + +This example shows how to build an objective-c application that uses Google protobuf. + +In order to build this example, you'll need to have a ProtocolBuffers library or framework installed in the system. diff --git a/examples/protobuf/addressbook_objc/addressbook_objc.qbs b/examples/protobuf/addressbook_objc/addressbook_objc.qbs new file mode 100644 index 00000000..a573b901 --- /dev/null +++ b/examples/protobuf/addressbook_objc/addressbook_objc.qbs @@ -0,0 +1,13 @@ +CppApplication { + consoleApplication: true + condition: protobuf.objc.present && qbs.targetOS.contains("macos") + + Depends { name: "cpp" } + Depends { name: "protobuf.objc"; required: false } + + Group { + cpp.automaticReferenceCounting: true + files: "main.m" + } + files: "../shared/addressbook.proto" +} diff --git a/examples/protobuf/addressbook_objc/main.m b/examples/protobuf/addressbook_objc/main.m new file mode 100644 index 00000000..5e21fa06 --- /dev/null +++ b/examples/protobuf/addressbook_objc/main.m @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#import "Addressbook.pbobjc.h" + +#import + +int printUsage(char *argv0) +{ + NSString *programName = [[NSString alloc] initWithUTF8String:argv0]; + NSLog(@"Usage: %@ add|list ADDRESS_BOOK_FILE", programName); + return -1; +} + +NSString *readString(NSString *promt) +{ + NSLog(@"%@", promt); + NSFileHandle *inputFile = [NSFileHandle fileHandleWithStandardInput]; + NSData *inputData = [inputFile availableData]; + NSString *result = [[NSString alloc] initWithData:inputData encoding:NSUTF8StringEncoding]; + result = [result stringByTrimmingCharactersInSet: + [NSCharacterSet whitespaceAndNewlineCharacterSet]]; + return result; +} + +// This function fills in a Person message based on user input. +void promptForAddress(Person* person) +{ + person.id_p = [readString(@"Enter person ID number:") intValue]; + person.name = readString(@"Enter name:"); + + NSString *email = readString(@"Enter email address (blank for none):"); + if ([email length] != 0) + person.email = email; + + while (true) { + NSString *number = readString(@"Enter a phone number (or leave blank to finish):"); + if ([number length] == 0) + break; + + Person_PhoneNumber* phoneNumber = [[Person_PhoneNumber alloc] init]; + phoneNumber.number = number; + + NSString *type = readString(@"Is this a mobile, home, or work phone?:"); + NSLog(@"\"%@\"", type); + if ([type compare:@"mobile"] == NSOrderedSame) + phoneNumber.type = Person_PhoneType_Mobile; + else if ([type compare:@"home"] == NSOrderedSame) + phoneNumber.type = Person_PhoneType_Home; + else if ([type compare:@"work"] == NSOrderedSame) + phoneNumber.type = Person_PhoneType_Work; + else + NSLog(@"Unknown phone type. Using default."); + + [person.phonesArray addObject:phoneNumber]; + } +} + +// Iterates though all people in the AddressBook and prints info about them. +void listPeople(AddressBook *addressBook) +{ + for (Person *person in addressBook.peopleArray) { + NSLog(@"Person ID: %d", person.id_p); + NSLog(@"Person name: %@", person.name); + + if ([person.email length] != 0) { + NSLog(@"E-mail address: %@", person.email); + } + + for (Person_PhoneNumber *phoneNumber in person.phonesArray) { + NSString *phonePrefix; + + switch (phoneNumber.type) { + case Person_PhoneType_Mobile: + phonePrefix = @"Mobile phone"; + break; + case Person_PhoneType_Home: + phonePrefix = @"Home phone"; + break; + case Person_PhoneType_Work: + phonePrefix = @"Work phone"; + break; + default: + phonePrefix = @"Unknown phone"; + break; + } + + NSLog(@" %@ #: %@", phonePrefix, phoneNumber.number); + } + printf("\n"); + } +} + +int main(int argc, char *argv[]) +{ + if (argc != 3) + return printUsage(argv[0]); + + @autoreleasepool + { + AddressBook *addressBook; + NSString *filePath = [[NSString alloc] initWithUTF8String:argv[2]]; + + // Read the existing address book. + NSData *data = [NSData dataWithContentsOfFile:filePath]; + if (!data) { + NSLog(@"%@ : File not found.", filePath); + addressBook = [[AddressBook alloc] init]; + } else { + NSError *error; + addressBook = [AddressBook parseFromData:data error:&error]; + if (!addressBook) { + NSLog(@"Failed to parse address book."); + return -1; + } + } + + if (strcmp(argv[1], "add") == 0) { + // Add an address. + Person *person = [[Person alloc] init]; + promptForAddress(person); + [addressBook.peopleArray addObject:person]; + + if (!data) { + NSLog(@"Creating a new file."); + } + [[addressBook data] writeToFile:filePath atomically:YES]; + } else if (strcmp(argv[1], "list") == 0) { + listPeople(addressBook); + } else { + return printUsage(argv[0]); + } + + return 0; + } +} diff --git a/examples/protobuf/shared/addressbook.proto b/examples/protobuf/shared/addressbook.proto new file mode 100644 index 00000000..b4b33b4c --- /dev/null +++ b/examples/protobuf/shared/addressbook.proto @@ -0,0 +1,51 @@ +// See README.txt for information and build instructions. +// +// Note: START and END tags are used in comments to define sections used in +// tutorials. They are not part of the syntax for Protocol Buffers. +// +// To get an in-depth walkthrough of this file and the related examples, see: +// https://developers.google.com/protocol-buffers/docs/tutorials + +// [START declaration] +syntax = "proto3"; +package tutorial; + +import "google/protobuf/timestamp.proto"; +// [END declaration] + +// [START java_declaration] +option java_package = "com.example.tutorial"; +option java_outer_classname = "AddressBookProtos"; +// [END java_declaration] + +// [START csharp_declaration] +option csharp_namespace = "Google.Protobuf.Examples.AddressBook"; +// [END csharp_declaration] + +// [START messages] +message Person { + string name = 1; + int32 id = 2; // Unique ID number for this person. + string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + string number = 1; + PhoneType type = 2; + } + + repeated PhoneNumber phones = 4; + + google.protobuf.Timestamp last_updated = 5; +} + +// Our address book file is just one of these. +message AddressBook { + repeated Person people = 1; +} +// [END messages] diff --git a/examples/rpaths/main.cpp b/examples/rpaths/main.cpp new file mode 100644 index 00000000..b1b9a6d2 --- /dev/null +++ b/examples/rpaths/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "objecta.h" +#include "objectb.h" + +#include + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + std::cout << ObjectA::className() << std::endl; + std::cout << ObjectB::className() << std::endl; + + ObjectB b; + std::cout << b.getA().name() << std::endl; + + return 0; +} diff --git a/examples/rpaths/objecta.cpp b/examples/rpaths/objecta.cpp new file mode 100644 index 00000000..7fbce6d7 --- /dev/null +++ b/examples/rpaths/objecta.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "objecta.h" + +ObjectA::ObjectA(std::string name) : + m_name(std::move(name)) +{ +} + +std::string ObjectA::className() +{ + return "ObjectA"; +} + +const std::string &ObjectA::name() const +{ + return m_name; +} + +void ObjectA::setName(std::string name) +{ + m_name = std::move(name); +} diff --git a/examples/rpaths/objecta.h b/examples/rpaths/objecta.h new file mode 100644 index 00000000..e2bf145e --- /dev/null +++ b/examples/rpaths/objecta.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef OBJECTA_H +#define OBJECTA_H + +#include + +class ObjectA +{ +public: + explicit ObjectA(std::string name); + + static std::string className(); + + const std::string &name() const; + void setName(std::string name); + +private: + std::string m_name; +}; + +#endif // OBJECTA_H diff --git a/examples/rpaths/objectb.cpp b/examples/rpaths/objectb.cpp new file mode 100644 index 00000000..228a68b0 --- /dev/null +++ b/examples/rpaths/objectb.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "objectb.h" + +ObjectB::ObjectB() = default; + +std::string ObjectB::className() +{ + return "ObjectB"; +} + +const ObjectA &ObjectB::getA() const +{ + return objectA; +} + diff --git a/examples/rpaths/objectb.h b/examples/rpaths/objectb.h new file mode 100644 index 00000000..7c0602a1 --- /dev/null +++ b/examples/rpaths/objectb.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of Qbs. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef OBJECTB_H +#define OBJECTB_H + +#include + +#include "objecta.h" + +class ObjectB +{ +public: + ObjectB(); + + static std::string className(); + + const ObjectA &getA() const; + +private: + ObjectA objectA{"A"}; +}; + +#endif // OBJECTB_H diff --git a/examples/rpaths/rpaths.qbs b/examples/rpaths/rpaths.qbs new file mode 100644 index 00000000..59d48174 --- /dev/null +++ b/examples/rpaths/rpaths.qbs @@ -0,0 +1,61 @@ +import qbs.FileInfo + +Project { + condition: qbs.targetOS.contains("unix") + + //! [0] + DynamicLibrary { + Depends { name: "cpp" } + Depends { name: "bundle" } + name: "LibraryA" + bundle.isBundle: false + cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined + cpp.rpaths: cpp.rpathOrigin + cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" + files: [ + "objecta.cpp", + "objecta.h", + ] + install: true + installDir: "examples/lib" + } + //! [0] + + //! [1] + DynamicLibrary { + Depends { name: "cpp" } + Depends { name: "bundle" } + Depends { name: "LibraryA" } + name: "LibraryB" + bundle.isBundle: false + cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" + cpp.sonamePrefix: qbs.targetOS.contains("macos") ? "@rpath" : undefined + cpp.rpaths: cpp.rpathOrigin + files: [ + "objectb.cpp", + "objectb.h", + ] + install: true + installDir: "examples/lib" + } + //! [1] + + //! [2] + CppApplication { + Depends { name: "bundle" } + Depends { name: "LibraryA" } + Depends { name: "LibraryB" } + name: "rpaths-app" + files: "main.cpp" + consoleApplication: true + bundle.isBundle: false + cpp.rpaths: FileInfo.joinPaths(cpp.rpathOrigin, "..", "lib") + cpp.cxxLanguageVersion: "c++11" + cpp.minimumMacosVersion: "10.8" + install: true + installDir: "examples/bin" + } + //! [2] +} diff --git a/examples/rule/lorem_ipsum.txt b/examples/rule/lorem_ipsum.txt new file mode 100644 index 00000000..2901fbce --- /dev/null +++ b/examples/rule/lorem_ipsum.txt @@ -0,0 +1,4 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer accumsan laoreet magna vitae +elementum. Duis semper ex pellentesque nibh ullamcorper lacinia. Suspendisse sed diam magna. +Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In id +maximus turpis, mattis commodo mauris. Sed bibendum accumsan leo. Nulla placerat. diff --git a/examples/rule/rule.qbs b/examples/rule/rule.qbs new file mode 100644 index 00000000..f462a370 --- /dev/null +++ b/examples/rule/rule.qbs @@ -0,0 +1,36 @@ +import qbs.TextFile + +Product { + type: "txt_output" + + Group { + name: "lorem_ipsum" + files: "lorem_ipsum.txt" + fileTags: "txt_input" + } + + //![1] + Rule { + multiplex: false + inputs: ["txt_input"] + Artifact { + filePath: input.fileName + ".out" + fileTags: ["txt_output"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating" + output.fileName + " from " + input.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var file = new TextFile(input.filePath); + var content = file.readAll(); + file.close() + content = content.toUpperCase(); + file = new TextFile(output.filePath, TextFile.WriteOnly); + file.write(content); + file.close(); + } + return [cmd]; + } + } +} diff --git a/qbs-resources/imports/QbsApp.qbs b/qbs-resources/imports/QbsApp.qbs new file mode 100644 index 00000000..5aad2865 --- /dev/null +++ b/qbs-resources/imports/QbsApp.qbs @@ -0,0 +1,18 @@ +import qbs.FileInfo + +QbsProduct { + Depends { name: "qbscore" } + Depends { name: "qbsversion" } + Depends { name: "qbsconsolelogger" } + type: ["application", "qbsapplication"] + version: qbsversion.version + consoleApplication: true + Group { + fileTagsFilter: product.type + .concat(qbs.debugInformation ? ["debuginfo_app"] : []) + qbs.install: true + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: qbsbuildconfig.appInstallDir +} diff --git a/qbs-resources/imports/QbsAutotest.qbs b/qbs-resources/imports/QbsAutotest.qbs new file mode 100644 index 00000000..8624f65e --- /dev/null +++ b/qbs-resources/imports/QbsAutotest.qbs @@ -0,0 +1,28 @@ +import qbs.FileInfo +import qbs.Utilities + +QbsProduct { + type: ["application", "autotest"] + consoleApplication: true + property string testName + name: "tst_" + testName + property string targetInstallDir: qbsbuildconfig.appInstallDir + Depends { name: "Qt.testlib" } + Depends { name: "qbscore" } + Depends { name: "qbsbuildconfig" } + cpp.defines: [ // deliberately override base defines + "QBS_TEST_SUITE_NAME=" + Utilities.cStringQuote(testName.toUpperCase().replace("-", "_")) + ] + cpp.includePaths: [ + "../../../src", + ] + + qbs.commonRunEnvironment: ({ + "QBS_INSTALL_DIR": FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix) + }) + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: targetInstallDir + } +} diff --git a/qbs-resources/imports/QbsLibrary.qbs b/qbs-resources/imports/QbsLibrary.qbs new file mode 100644 index 00000000..f0769dd6 --- /dev/null +++ b/qbs-resources/imports/QbsLibrary.qbs @@ -0,0 +1,75 @@ +import qbs.FileInfo +import qbs.Utilities + +QbsProduct { + Depends { name: "cpp" } + Depends { name: "Exporter.pkgconfig"; condition: generatePkgConfigFile } + Depends { name: "Exporter.qbs"; condition: generateQbsModule } + Depends { name: "cpp" } + + property string visibilityType: staticBuild ? "static" : "dynamic" + property string headerInstallPrefix: "/include/qbs" + property bool hasExporter: Utilities.versionCompare(qbs.version, "1.12") >= 0 + property bool generatePkgConfigFile: qbsbuildconfig.generatePkgConfigFiles && hasExporter + property bool generateQbsModule: install && qbsbuildconfig.generateQbsModules && hasExporter + property bool staticBuild: Qt.core.staticBuild || qbsbuildconfig.staticBuild + property stringList libType: [staticBuild ? "staticlibrary" : "dynamiclibrary"] + + version: qbsversion.version + type: libType + targetName: (qbs.enableDebugCode && qbs.targetOS.contains("windows")) ? (name + 'd') : name + cpp.visibility: "minimal" + cpp.defines: base.concat(visibilityType === "static" ? ["QBS_STATIC_LIB"] : ["QBS_LIBRARY"]) + cpp.sonamePrefix: qbs.targetOS.contains("darwin") ? "@rpath" : undefined + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.soVersion: version.replace(/\.\d+$/, '') + } + + Group { + fileTagsFilter: libType.concat("dynamiclibrary_symlink") + .concat(qbs.debugInformation ? ["debuginfo_dll"] : []) + qbs.install: install + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: qbsbuildconfig.libInstallDir + Group { + fileTagsFilter: ["dynamiclibrary_import"] + qbs.install: install + qbs.installDir: qbsbuildconfig.importLibInstallDir + } + Group { + fileTagsFilter: "Exporter.pkgconfig.pc" + qbs.install: install + qbs.installDir: qbsbuildconfig.pkgConfigInstallDir + } + Group { + fileTagsFilter: "Exporter.qbs.module" + qbs.install: install + qbs.installDir: FileInfo.joinPaths(qbsbuildconfig.qbsModulesBaseDir, product.name) + } + + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + cpp.linkerFlags: ["-compatibility_version", cpp.soVersion] + } + + Export { + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["core"] } + + Properties { + condition: exportingProduct.hasExporter + prefixMapping: [{ + prefix: exportingProduct.sourceDirectory, + replacement: FileInfo.joinPaths(exportingProduct.qbs.installPrefix, + exportingProduct.headerInstallPrefix) + }] + } + + cpp.includePaths: [exportingProduct.sourceDirectory] + cpp.defines: exportingProduct.visibilityType === "static" ? ["QBS_STATIC_LIB"] : [] + } +} diff --git a/qbs-resources/imports/QbsProduct.qbs b/qbs-resources/imports/QbsProduct.qbs new file mode 100644 index 00000000..5df694dd --- /dev/null +++ b/qbs-resources/imports/QbsProduct.qbs @@ -0,0 +1,23 @@ +Product { + Depends { name: "qbsbuildconfig" } + Depends { name: "qbsversion" } + Depends { name: "Qt.core"; versionAtLeast: minimumQtVersion } + property string minimumQtVersion: "5.14.0" + property bool install: true + property string targetInstallDir + cpp.defines: { + var res = [ + "QT_NO_CAST_FROM_ASCII", + "QT_NO_CAST_FROM_BYTEARRAY", + "QT_NO_PROCESS_COMBINED_ARGUMENT_START" + ]; + if (qbs.toolchain.contains("msvc")) + res.push("_SCL_SECURE_NO_WARNINGS"); + if (qbs.enableDebugCode) + res.push("QT_STRICT_ITERATORS"); + return res; + } + cpp.cxxLanguageVersion: "c++17" + cpp.enableExceptions: true + cpp.rpaths: qbsbuildconfig.libRPaths +} diff --git a/qbs-resources/imports/QbsStaticLibrary.qbs b/qbs-resources/imports/QbsStaticLibrary.qbs new file mode 100644 index 00000000..6fa9fde3 --- /dev/null +++ b/qbs-resources/imports/QbsStaticLibrary.qbs @@ -0,0 +1,9 @@ +QbsProduct { + type: "staticlibrary" + Export { + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["core"] } + + cpp.includePaths: [exportingProduct.sourceDirectory] + } +} diff --git a/qbs-resources/imports/QbsUnittest.qbs b/qbs-resources/imports/QbsUnittest.qbs new file mode 100644 index 00000000..5b54b9a5 --- /dev/null +++ b/qbs-resources/imports/QbsUnittest.qbs @@ -0,0 +1,21 @@ +import qbs.FileInfo +import qbs.Utilities + +QbsAutotest { + Depends { + name: "Qt.core5compat"; + condition: Utilities.versionCompare(Qt.core.version, "6.0.0") >= 0 + } + Depends { + name: "Qt.script" + condition: !qbsbuildconfig.useBundledQtScript + required: false + } + Depends { + name: "qbsscriptengine" + condition: qbsbuildconfig.useBundledQtScript || !Qt.script.present + } + property stringList bundledQtScriptIncludes: qbsbuildconfig.useBundledQtScript + || !Qt.script.present ? qbsscriptengine.includePaths : [] + cpp.includePaths: base.concat(bundledQtScriptIncludes) +} diff --git a/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs b/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs new file mode 100644 index 00000000..28104b55 --- /dev/null +++ b/qbs-resources/modules/qbsbuildconfig/qbsbuildconfig.qbs @@ -0,0 +1,87 @@ +import qbs.FileInfo +import qbs.Utilities + +Module { + Depends { + condition: project.withCode + name: "cpp" + } + property bool enableAddressSanitizer: false + property bool enableUbSanitizer: false + property bool enableThreadSanitizer: false + property bool enableUnitTests: false + property bool enableProjectFileUpdates: true + property bool enableRPath: true + property bool installApiHeaders: true + property bool enableBundledQt: false + property bool useBundledQtScript: false + property bool staticBuild: false + property string libDirName: "lib" + property string appInstallDir: "bin" + property string libInstallDir: qbs.targetOS.contains("windows") ? "bin" : libDirName + property string importLibInstallDir: libDirName + property string libexecInstallDir: qbs.targetOS.contains("windows") ? appInstallDir + : "libexec/qbs" + property string systemSettingsDir + property bool installManPage: qbs.targetOS.contains("unix") + property bool installHtml: true + property bool installQch: false + property bool generatePkgConfigFiles: installApiHeaders && qbs.targetOS.contains("unix") + && !qbs.targetOS.contains("darwin") + property bool generateQbsModules: installApiHeaders + property string docInstallDir: "share/doc/qbs/html" + property string pkgConfigInstallDir: FileInfo.joinPaths(libDirName, "pkgconfig") + property string qbsModulesBaseDir: FileInfo.joinPaths(libDirName, "qbs", "modules") + property string relativeLibexecPath: "../" + libexecInstallDir + property string relativePluginsPath: "../" + libDirName + property string relativeSearchPath: ".." + property stringList libRPaths: { + if (enableRPath && project.withCode && cpp.rpathOrigin && product.targetInstallDir) { + return [FileInfo.joinPaths(cpp.rpathOrigin, FileInfo.relativePath( + FileInfo.joinPaths('/', product.targetInstallDir), + FileInfo.joinPaths('/', libDirName)))]; + } + return []; + } + property string resourcesInstallDir: "" + property string pluginsInstallDir: libDirName + "/qbs/plugins" + property string qmlTypeDescriptionsInstallDir: FileInfo.joinPaths(resourcesInstallDir, + "share/qbs/qml-type-descriptions") + + Properties { + condition: project.withCode && qbs.toolchain.contains("gcc") + cpp.cxxFlags: { + var flags = []; + if (enableAddressSanitizer) + flags.push("-fno-omit-frame-pointer"); + function isClang() { return qbs.toolchain.contains("clang"); } + function versionAtLeast(v) { + return Utilities.versionCompare(cpp.compilerVersion, v) >= 0; + }; + if (isClang()) + flags.push("-Wno-constant-logical-operand"); + if ((!isClang() && versionAtLeast("9")) + || (isClang() && !qbs.hostOS.contains("darwin") && versionAtLeast("10"))) { + flags.push("-Wno-deprecated-copy"); + } + return flags; + } + cpp.driverFlags: { + var flags = []; + if (enableAddressSanitizer) + flags.push("-fsanitize=address"); + if (enableUbSanitizer) + flags.push("-fsanitize=undefined"); + if (enableThreadSanitizer) + flags.push("-fsanitize=thread"); + return flags; + } + } + Properties { + condition: project.withCode && qbs.toolchain.contains("msvc") && product.Qt + && Utilities.versionCompare(Qt.core.version, "6.3") >= 0 + && Utilities.versionCompare(cpp.compilerVersion, "19.10") >= 0 + && Utilities.versionCompare(qbs.version, "1.23") < 0 + cpp.cxxFlags: "/permissive-" + } +} diff --git a/qbs-resources/modules/qbsversion/qbsversion.qbs b/qbs-resources/modules/qbsversion/qbsversion.qbs new file mode 100644 index 00000000..2e9a2ae4 --- /dev/null +++ b/qbs-resources/modules/qbsversion/qbsversion.qbs @@ -0,0 +1,23 @@ +import qbs.File +import qbs.FileInfo +import qbs.TextFile + +Module { + Probe { + id: qbsVersionProbe + property var lastModified: File.lastModified(versionFilePath) + property string versionFilePath: FileInfo.joinPaths(path, "..", "..", "..", "VERSION") + property string version + configure: { + var tf = new TextFile(versionFilePath, TextFile.ReadOnly); + try { + version = tf.readAll().trim(); + found = !!version; + } finally { + tf.close(); + } + } + } + + version: qbsVersionProbe.version +} diff --git a/qbs.pro b/qbs.pro new file mode 100644 index 00000000..9777615f --- /dev/null +++ b/qbs.pro @@ -0,0 +1,77 @@ +requires(!cross_compile) +include(src/lib/bundledlibs.pri) + +defineTest(minQtVersion) { + maj = $$1 + min = $$2 + patch = $$3 + isEqual(QT_MAJOR_VERSION, $$maj) { + isEqual(QT_MINOR_VERSION, $$min) { + isEqual(QT_PATCH_VERSION, $$patch) { + return(true) + } + greaterThan(QT_PATCH_VERSION, $$patch) { + return(true) + } + } + greaterThan(QT_MINOR_VERSION, $$min) { + return(true) + } + } + greaterThan(QT_MAJOR_VERSION, $$maj) { + return(true) + } + return(false) +} + +!minQtVersion(5, 14, 0) { + message("Cannot build qbs with Qt version $${QT_VERSION}.") + error("Use at least Qt 5.14.0.") +} + +TEMPLATE = subdirs +pkgconfig.file = src/lib/pkgconfig/pkgconfig.pro +corelib.file = src/lib/corelib/corelib.pro +corelib.depends = pkgconfig +msbuildlib.subdir = src/lib/msbuild +msbuildlib.depends = corelib +src_app.subdir = src/app +src_app.depends = corelib +CONFIG(static, static|shared): src_app.depends += src_plugins +src_libexec.subdir = src/libexec +src_plugins.subdir = src/plugins +CONFIG(shared, static|shared): src_plugins.depends = corelib +src_plugins.depends += msbuildlib +tests.depends = static_res +static_res.file = static-res.pro +static_res.depends = src_app src_libexec src_plugins static.pro +qbs_use_bundled_qtscript { + scriptenginelib.file = src/lib/scriptengine/scriptengine.pro + corelib.depends += scriptenginelib + SUBDIRS += scriptenginelib +} +SUBDIRS += \ + pkgconfig \ + corelib\ + msbuildlib\ + src_app\ + src_libexec\ + src_plugins\ + static.pro\ + static_res + +!CONFIG(nomake_tests): SUBDIRS += tests + +OTHER_FILES += \ + doc/*.qdoc \ + doc/reference/*.qdoc \ + doc/reference/items/convenience/*.qdoc \ + doc/reference/items/language/*.qdoc \ + doc/reference/jsextensions/*.qdoc \ + doc/reference/modules/*.qdoc \ + doc/targets/*.qdoc* \ + doc/qbs.qdocconf \ + doc/config/qbs-project.qdocconf + +include(qbs_version.pri) +include(doc/doc.pri) diff --git a/qbs.qbs b/qbs.qbs new file mode 100644 index 00000000..abe0f6cb --- /dev/null +++ b/qbs.qbs @@ -0,0 +1,68 @@ +Project { + minimumQbsVersion: "1.6" + qbsSearchPaths: ["qbs-resources"] + property bool withCode: true + property bool withDocumentation: true + property bool withExamples: false + property bool withTests: withCode + property stringList autotestArguments: [] + property stringList autotestWrapper: [] + + references: [ + "docker/docker.qbs", + "share/share.qbs", + "scripts/scripts.qbs", + ] + + SubProject { + filePath: "doc/doc.qbs" + Properties { + condition: parent.withDocumentation + } + } + + SubProject { + filePath: "examples/examples.qbs" + Properties { + condition: parent.withExamples + } + } + + SubProject { + filePath: "src/src.qbs" + Properties { + condition: parent.withCode + } + } + + SubProject { + filePath: "tests/tests.qbs" + Properties { + condition: parent.withTests + } + } + + Product { + name: "version" + files: ["VERSION"] + } + + Product { + name: "qmake project files for qbs" + files: ["**/*.pr[io]"] + } + + Product { + name: "cmake project files for qbs" + files: ["**/CMakeLists.txt"] + } + + Product { + name: "continuous integration files" + files: [ + ".clang-tidy", + "docker-compose.yml", + ".github/**/*.yml", + ] + } +} diff --git a/qbs_version.pri b/qbs_version.pri new file mode 100644 index 00000000..97c4c799 --- /dev/null +++ b/qbs_version.pri @@ -0,0 +1,4 @@ +QBS_VERSION = $$cat($$PWD/VERSION) +QBS_VERSION_MAJ = $$section(QBS_VERSION, ., 0, 0) +QBS_VERSION_MIN = $$section(QBS_VERSION, ., 1, 1) +DEFINES += QBS_VERSION=\\\"$$QBS_VERSION\\\" diff --git a/scripts/address-sanitizer-suppressions.txt b/scripts/address-sanitizer-suppressions.txt new file mode 100644 index 00000000..f3e1980b --- /dev/null +++ b/scripts/address-sanitizer-suppressions.txt @@ -0,0 +1,3 @@ +leak:libQt5Script.so.5 +leak:QThreadPrivate::QThreadPrivate +leak:QArrayData::allocate diff --git a/scripts/build-qbs-doc.sh b/scripts/build-qbs-doc.sh new file mode 100755 index 00000000..82a84269 --- /dev/null +++ b/scripts/build-qbs-doc.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com). +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -e + +if [ -z "${QBS_BUILD_PROFILE}" ]; then + QBS_BUILD_PROFILE=$(qbs config defaultProfile | cut -d: -f2 | tr -d '[:space:]') +fi +if [ -z "${QBS_BUILD_PROFILE}" ]; then + echo "Either QBS_BUILD_PROFILE or a defaultProfile must be set." + exit 1 +fi + +# +# Additional build options +# +BUILD_OPTIONS="\ + profile:${QBS_BUILD_PROFILE} \ + ${BUILD_OPTIONS} \ + config:documentation \ +" + +qbs build -p "qbs documentation" ${BUILD_OPTIONS} diff --git a/scripts/build-qbs-with-cmake.sh b/scripts/build-qbs-with-cmake.sh new file mode 100755 index 00000000..820f3030 --- /dev/null +++ b/scripts/build-qbs-with-cmake.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com). +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -e + +# +# It might be desired to keep settings for Qbs testing +# in a separate folder. +# +export QBS_AUTOTEST_SETTINGS_DIR="${QBS_AUTOTEST_SETTINGS_DIR:-/tmp/qbs-settings}" + +BUILD_OPTIONS="\ + -DWITH_UNIT_TESTS=1 \ + -DQBS_INSTALL_HTML_DOCS=1 \ + -DQBS_INSTALL_QCH_DOCS=1 \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + ${BUILD_OPTIONS} \ +" + +QMAKE_PATH="${QMAKE_PATH:-$(which qmake)}" +QT_DIR=$(dirname ${QMAKE_PATH})/../ + +# Use shadow build +mkdir -p build +pushd build + +# +# Build all default products of Qbs +# +cmake -GNinja -DQt5_DIR=${QT_DIR}/lib/cmake/Qt5/ ${BUILD_OPTIONS} .. +cmake --build . +cmake --install . --prefix "install-root" + +# +# Set up profiles for the freshly built Qbs if not +# explicitly specified otherwise +# +if [ -z "${QBS_AUTOTEST_PROFILE}" ]; then + + export QBS_AUTOTEST_PROFILE=autotestprofile + RUN_OPTIONS="\ + --settings-dir ${QBS_AUTOTEST_SETTINGS_DIR} \ + " + + ./bin/qbs setup-toolchains \ + ${RUN_OPTIONS} \ + --detect + + ./bin/qbs setup-qt \ + ${RUN_OPTIONS} \ + "${QMAKE_PATH}" ${QBS_AUTOTEST_PROFILE} + + ./bin/qbs config \ + ${RUN_OPTIONS} \ + ${QBS_AUTOTEST_PROFILE}.baseProfile gcc + +fi + +# +# Run all autotests with QBS_AUTOTEST_PROFILE. Some test cases might run for +# over 10 minutes. Output an empty line every 9:50 minutes to prevent a 10min +# timeout on Travis CI. +# +(while true; do echo "" && sleep 590; done) & +trap "kill $!; wait $! 2>/dev/null || true; killall sleep || true" EXIT +ctest -j $(nproc --all) + +popd diff --git a/scripts/build-qbs-with-qbs.sh b/scripts/build-qbs-with-qbs.sh new file mode 100755 index 00000000..42d02c3c --- /dev/null +++ b/scripts/build-qbs-with-qbs.sh @@ -0,0 +1,145 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -e + +# +# Qbs is built with the address sanitizer enabled. +# Suppress findings in some parts of Qbs / dependencies. +# +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +if [ -z "${QBS_BUILD_PROFILE}" ]; then + QBS_BUILD_PROFILE=$(qbs config defaultProfile | cut -d: -f2 | tr -d '[:space:]') +fi +if [ -z "${QBS_BUILD_PROFILE}" ]; then + echo "Either QBS_BUILD_PROFILE or a defaultProfile must be set." + exit 1 +fi + +# +# Additional build options +# +BUILD_OPTIONS="\ + profile:${QBS_BUILD_PROFILE} \ + modules.qbsbuildconfig.enableAddressSanitizer:true \ + modules.qbsbuildconfig.enableUnitTests:true \ + modules.cpp.treatWarningsAsErrors:true \ + modules.cpp.separateDebugInformation:true \ + ${BUILD_OPTIONS} \ + config:release \ +" + +# +# Build all default products of Qbs +# +qbs resolve ${BUILD_OPTIONS} +qbs build ${BUILD_OPTIONS} + +WITH_DOCS=${WITH_DOCS:-1} +if [ "$WITH_DOCS" -ne 0 ]; then + qbs build -p "qbs documentation" ${BUILD_OPTIONS} +fi + +WITH_ARCHIVE=${WITH_ARCHIVE:-1} +if [ "$WITH_ARCHIVE" -ne 0 ]; then + qbs build -p "qbs_archive" ${BUILD_OPTIONS} +fi + +WITH_TESTS=${WITH_TESTS:-1} +if [ "$WITH_TESTS" -eq 0 ]; then + exit 0 +fi + +QMAKE_PATH=${QMAKE_PATH:-$(which qmake)} + +# +# Set up profiles for the freshly built Qbs if not +# explicitly specified otherwise +# +if [ -z "${QBS_AUTOTEST_PROFILE}" ]; then + + export QBS_AUTOTEST_PROFILE=autotestprofile + export QBS_AUTOTEST_SETTINGS_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'qbs-settings'` + + QBS_AUTOTEST_QMAKE_PATH=${QBS_AUTOTEST_QMAKE_PATH:-${QMAKE_PATH}} + + RUN_OPTIONS="\ + --settings-dir ${QBS_AUTOTEST_SETTINGS_DIR} \ + " + + qbs run -p qbs_app ${BUILD_OPTIONS} -- setup-toolchains \ + ${RUN_OPTIONS} \ + --detect + + qbs run -p qbs_app ${BUILD_OPTIONS} -- setup-qt \ + ${RUN_OPTIONS} \ + "${QBS_AUTOTEST_QMAKE_PATH}" ${QBS_AUTOTEST_PROFILE} + + # Make sure that the Qt profile uses the same toolchain profile + # that was used for building in case a custom QBS_BUILD_PROFILE + # was set. Otherwise setup-qt automatically uses the default + # toolchain profile. + if [ -z "${QBS_AUTOTEST_BASE_PROFILE}" ]; then + QBS_AUTOTEST_BASE_PROFILE=$(qbs config profiles.${QBS_BUILD_PROFILE}.baseProfile | cut -d: -f2) + fi + if [ ! -z "${QBS_AUTOTEST_BASE_PROFILE}" ]; then + echo "Setting base profile for ${QBS_AUTOTEST_PROFILE} to ${QBS_AUTOTEST_BASE_PROFILE}" + qbs run -p qbs_app ${BUILD_OPTIONS} -- config \ + ${RUN_OPTIONS} \ + profiles.${QBS_AUTOTEST_PROFILE}.baseProfile ${QBS_AUTOTEST_BASE_PROFILE} + fi + + qbs run -p qbs_app ${BUILD_OPTIONS} -- config \ + ${RUN_OPTIONS} \ + --list + + # QBS_AUTOTEST_PROFILE has been added to the environment + # which requires a resolve step + qbs resolve ${BUILD_OPTIONS} +fi + +# +# Run all autotests with QBS_AUTOTEST_PROFILE. Some test cases might run for +# over 10 minutes. Output an empty line every 9:50 minutes to prevent a 10min +# timeout on Travis CI. +# +(while true; do echo "" && sleep 590; done) & +trap "kill $!; wait $! 2>/dev/null || true; killall sleep || true" EXIT +qbs build -p "autotest-runner" ${BUILD_OPTIONS} diff --git a/scripts/build-qbs-with-qmake.sh b/scripts/build-qbs-with-qmake.sh new file mode 100755 index 00000000..69ea75a2 --- /dev/null +++ b/scripts/build-qbs-with-qmake.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -e + +# +# It might be desired to keep settings for Qbs testing +# in a separate folder. +# +export QBS_AUTOTEST_SETTINGS_DIR="${QBS_AUTOTEST_SETTINGS_DIR:-/tmp/qbs-settings}" + +# +# Build all default products of Qbs +# +qmake -r qbs.pro \ + CONFIG+=qbs_enable_unit_tests \ + ${BUILD_OPTIONS} +make -j $(nproc --all) +make docs + +# +# Set up profiles for the freshly built Qbs if not +# explicitly specified otherwise +# +if [ -z "${QBS_AUTOTEST_PROFILE}" ]; then + + export QBS_AUTOTEST_PROFILE=autotestprofile + RUN_OPTIONS="\ + --settings-dir ${QBS_AUTOTEST_SETTINGS_DIR} \ + " + + ./bin/qbs setup-toolchains \ + ${RUN_OPTIONS} \ + --detect + + ./bin/qbs setup-qt \ + ${RUN_OPTIONS} \ + "${QMAKE_PATH:-$(which qmake)}" ${QBS_AUTOTEST_PROFILE} + + ./bin/qbs config \ + ${RUN_OPTIONS} \ + ${QBS_AUTOTEST_PROFILE}.baseProfile gcc + +fi + + +make check -j $(nproc --all) diff --git a/scripts/cpu-count.sh b/scripts/cpu-count.sh new file mode 100755 index 00000000..ce6b1c82 --- /dev/null +++ b/scripts/cpu-count.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2020 Ivan Komissarov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +NPROC=`which nproc` +SYSCTL=`which sysctl` +CPU_COUNT=2 +if [ ! -z "$NPROC" ]; then # Linux + CPU_COUNT=`$NPROC --all` +elif [ ! -z "$SYSCTL" ]; then # macOS + CPU_COUNT=`$SYSCTL -n hw.physicalcpu_max` +fi + +echo $CPU_COUNT diff --git a/scripts/install-dm.sh b/scripts/install-dm.sh new file mode 100644 index 00000000..a13c8c8e --- /dev/null +++ b/scripts/install-dm.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2022 Denis Shienkov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -eu + +function show_help() { + cat < + Root directory where to install the components. + Maps to c:/dm on Windows by default. + + --version + The desired toolchain version. + Currently supported only 8.57 version. + +EOF +} + +VERSION="8.57" +INSTALL_DIR="/c/dm" + +while [ $# -gt 0 ]; do + case "$1" in + --directory|-d) + INSTALL_DIR="$2" + shift + ;; + --version) + VERSION="$2" + shift + ;; + --help|-h) + show_help + exit 0 + ;; + *) + ;; + esac + shift +done + +if [ -z "${INSTALL_DIR}" ]; then + echo "No --directory specified or auto-detection failed." >&2 + exit 1 +fi + +if [ -z "${VERSION}" ]; then + echo "No --version specified." >&2 + exit 1 +fi + +DOWNLOAD_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'dm-tmp'` + +DM_URL="http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm${VERSION//./}c.zip" +UTILS_URL="http://ftp.digitalmars.com/bup.zip" +DOS_LIBS_URL="http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm850dos.zip" +DOSX_LIBS_URL="http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm831x.zip" + +DM_ZIP="${DOWNLOAD_DIR}/dm.zip" +UTILS_ZIP="${DOWNLOAD_DIR}/utils.zip" +DOS_LIBS_ZIP="${DOWNLOAD_DIR}/doslibs.zip" +DOSX_LIBS_ZIP="${DOWNLOAD_DIR}/dosxlibs.zip" + +echo "Downloading compiler from ${DM_URL}..." >&2 +curl --progress-bar -L -o ${DM_ZIP} ${DM_URL} >&2 + +echo "Downloading utils from ${UTILS_URL}..." >&2 +curl --progress-bar -L -o ${UTILS_ZIP} ${UTILS_URL} >&2 + +echo "Downloading DOS libs from ${DOS_LIBS_URL}..." >&2 +curl --progress-bar -L -o ${DOS_LIBS_ZIP} ${DOS_LIBS_URL} >&2 + +echo "Downloading DOSX libs from ${DOSX_LIBS_URL}..." >&2 +curl --progress-bar -L -o ${DOSX_LIBS_ZIP} ${DOSX_LIBS_URL} >&2 + +echo "Unpacking compiler to ${INSTALL_DIR}..." >&2 +7z x -y -o${INSTALL_DIR} ${DM_ZIP} >/dev/null 2>&1 + +echo "Unpacking utils to ${INSTALL_DIR}..." >&2 +7z x -y -o${INSTALL_DIR} ${UTILS_ZIP} >/dev/null 2>&1 + +echo "Unpacking DOS libs to ${INSTALL_DIR}..." >&2 +7z x -y -o${INSTALL_DIR} ${DOS_LIBS_ZIP} >/dev/null 2>&1 + +echo "Unpacking DOSX libs to ${INSTALL_DIR}..." >&2 +7z x -y -o${INSTALL_DIR} ${DOSX_LIBS_ZIP} >/dev/null 2>&1 + +echo "${INSTALL_DIR}/dm/bin" + +rm -f ${DM_ZIP} +rm -f ${UTILS_ZIP} +rm -f ${DOS_LIBS_ZIP} +rm -f ${DOSX_LIBS_ZIP} diff --git a/scripts/install-ow.sh b/scripts/install-ow.sh new file mode 100755 index 00000000..6b123fab --- /dev/null +++ b/scripts/install-ow.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2022 Denis Shienkov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -eu + +function show_help() { + cat < + Root directory where to install the components. + Maps to c:/watcom on Windows, /opt/watcom on Linux + by default. + + --version + The desired toolchain version. + Currently supported only 2.0 version. + +EOF +} + +VERSION=2.0 +INSTALL_DIR= +BIN_DIR= + +if [[ "$OSTYPE" =~ "linux" ]]; then + INSTALL_DIR="/opt/watcom" + if [[ "$HOSTTYPE" == "x86_64" ]]; then + BIN_DIR="binl64" + elif [[ "$HOSTTYPE" == "x86" ]]; then + BIN_DIR="binl" + fi +elif [[ "$OSTYPE" == "msys" ]]; then + INSTALL_DIR="/c/watcom" + if [[ "$HOSTTYPE" == "x86_64" ]]; then + BIN_DIR="binnt64" + elif [[ "$HOSTTYPE" == "x86" ]]; then + BIN_DIR="binnt" + fi +fi + +while [ $# -gt 0 ]; do + case "$1" in + --directory|-d) + INSTALL_DIR="$2" + shift + ;; + --version) + VERSION="$2" + shift + ;; + --help|-h) + show_help + exit 0 + ;; + *) + ;; + esac + shift +done + +if [ -z "${INSTALL_DIR}" ]; then + echo "No --directory specified or auto-detection failed." >&2 + exit 1 +fi + +if [ -z "${VERSION}" ]; then + echo "No --version specified." >&2 + exit 1 +fi + +DOWNLOAD_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'ow-tmp'` + +VERSION_MAJOR=`echo $VERSION | cut -d. -f1` +VERSION_MINOR=`echo $VERSION | cut -d. -f2` + +OW_URL="https://github.com/open-watcom/open-watcom-v${VERSION_MAJOR}/releases/download/Current-build/ow-snapshot.tar.gz" +OW_TARGZ="${DOWNLOAD_DIR}/ow.tar.gz" + +echo "Downloading compiler from ${OW_URL}..." >&2 +curl --progress-bar -L -o ${OW_TARGZ} ${OW_URL} >&2 + +echo "Unpacking compiler to ${INSTALL_DIR}..." >&2 +7z x "${OW_TARGZ}" -so | 7z x -aoa -si -ttar -o"${INSTALL_DIR}" >/dev/null 2>&1 + +echo "${INSTALL_DIR}/${BIN_DIR}" + +rm -f ${OW_TARGZ} diff --git a/scripts/install-qt.sh b/scripts/install-qt.sh new file mode 100755 index 00000000..2cc895e0 --- /dev/null +++ b/scripts/install-qt.sh @@ -0,0 +1,394 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# +set -eu + +function help() { + cat < + Root directory where to install the components. + Maps to C:/Qt on Windows, /opt/Qt on Linux, /usr/local/Qt on Mac + by default. + + -f, --force + Force download and do not attempt to re-use an existing installation. + + --host + The host operating system. Can be one of linux_x64, mac_x64, + windows_x86. Auto-detected by default. + + --target + The desired target platform. Can be one of desktop, android, ios. + The default value is desktop. + + --toolchain + The toolchain that has been used to build the binaries. + Possible values depend on --host and --target, respectively: + + linux_x64 + android + any, android_armv7, android_arm64_v8a + desktop + gcc_64 (default) + + mac_x64 + android + any, android_armv7, android_arm64_v8a + desktop + clang_64 (default) + ios + ios + + windows_x86 + android + any, android_armv7, android_arm64_v8a + desktop + win64_mingw73, win64_msvc2017_64 (default) + + --version + The desired Qt version. Currently supported are all versions + above 5.9.0. + +EOF +} + +TARGET_PLATFORM=desktop +COMPONENTS= +VERSION= +FORCE_DOWNLOAD=false +MD5_TOOL=md5sum + +case "$OSTYPE" in + *linux*) + HOST_OS=linux_x64 + INSTALL_DIR=/opt/Qt + TOOLCHAIN=gcc_64 + ;; + *darwin*) + HOST_OS=mac_x64 + INSTALL_DIR=/usr/local/Qt + TOOLCHAIN=clang_64 + MD5_TOOL="md5 -r" + ;; + msys) + HOST_OS=windows_x86 + INSTALL_DIR=/c/Qt + TOOLCHAIN=win64_msvc2015_64 + ;; + *) + HOST_OS= + INSTALL_DIR= + ;; +esac + +while [ $# -gt 0 ]; do + case "$1" in + --directory|-d) + INSTALL_DIR="$2" + shift + ;; + --force|-f) + FORCE_DOWNLOAD=true + ;; + --host) + HOST_OS="$2" + shift + ;; + --target) + TARGET_PLATFORM="$2" + shift + ;; + --toolchain) + TOOLCHAIN=$(echo $2 | tr '[A-Z]' '[a-z]') + shift + ;; + --version) + VERSION="$2" + shift + ;; + --help|-h) + help + exit 0 + ;; + *) + COMPONENTS="${COMPONENTS} $1" + ;; + esac + shift +done + +if [ -z "${HOST_OS}" ]; then + echo "No --host specified or auto-detection failed." >&2 + exit 1 +fi + +if [ -z "${INSTALL_DIR}" ]; then + echo "No --directory specified or auto-detection failed." >&2 + exit 1 +fi + +if [ -z "${VERSION}" ]; then + echo "No --version specified." >&2 + exit 1 +fi + +if [ -z "${COMPONENTS}" ]; then + echo "No components specified." >&2 + exit 1 +fi + +case "$TARGET_PLATFORM" in + android) + ;; + ios) + ;; + desktop) + ;; + *) + echo "Error: TARGET_PLATFORM=${TARGET_PLATFORM} is not valid." >&2 + exit 1 + ;; +esac + +HASH=$(echo "${OSTYPE} ${TARGET_PLATFORM} ${TOOLCHAIN} ${VERSION} ${INSTALL_DIR}" | ${MD5_TOOL} | head -c 16) +HASH_FILEPATH="${INSTALL_DIR}/${HASH}.manifest" +INSTALLATION_IS_VALID=false +if ! ${FORCE_DOWNLOAD} && [ -f "${HASH_FILEPATH}" ]; then + INSTALLATION_IS_VALID=true + while read filepath; do + if [ ! -e "${filepath}" ]; then + INSTALLATION_IS_VALID=false + break + fi + done <"${HASH_FILEPATH}" +fi + +if ${INSTALLATION_IS_VALID}; then + echo "Already installed. Skipping download." >&2 + exit 0 +fi + +MIRRORS="\ + http://ftp.acc.umu.se/mirror/qt.io/qtproject \ + http://ftp.fau.de/qtproject \ + http://download.qt.io \ +" + +for MIRROR in ${MIRRORS}; do + if curl "${MIRROR}/online" -s -f -o /dev/null; then + break; + else + echo "Server ${MIRROR} not availabe. Trying next alternative..." >&2 + MIRROR="" + fi +done + +DOWNLOAD_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'install-qt'` + +# +# The repository structure is a mess. Try different URL variants +# +function compute_url(){ + local COMPONENT=$1 + local CURL="curl -s -L" + local BASE_URL="${MIRROR}/online/qtsdkrepository/${HOST_OS}/${TARGET_PLATFORM}" + local ANDROID_ARCH=$(echo ${TOOLCHAIN##android_}) + + if [[ "${COMPONENT}" =~ "qtcreator" ]]; then + + if [[ "${HOST_OS}" == "windows_x86" ]]; then + # newer QtC versions do not supported x86 version anymore + HOST_OS="windows_x64" + fi + + SHORT_VERSION=${VERSION%??} + BASE_URL="${MIRROR}/official_releases/qtcreator" + REMOTE_PATH="${SHORT_VERSION}/${VERSION}/installer_source/${HOST_OS}/qtcreator.7z" + echo "${BASE_URL}/${REMOTE_PATH}" + return 0 + elif [[ "${COMPONENT}" =~ "mingw" ]]; then + REMOTE_BASE="tools_mingw/qt.tools.${TOOLCHAIN}${VERSION//./}" + + REMOTE_PATH="$(${CURL} ${BASE_URL}/${REMOTE_BASE}/ | grep -o -E "[[:alnum:]_.\-]*7z" | grep -v "meta" | head -1)" + if [ ! -z "${REMOTE_PATH}" ]; then + echo "${BASE_URL}/${REMOTE_BASE}/${REMOTE_PATH}" + return 0 + fi + else + REMOTE_BASES=( + # New repository format (>=6.0.0) + "qt6_${VERSION//./}/qt.qt6.${VERSION//./}.${TOOLCHAIN}" + "qt6_${VERSION//./}/qt.qt6.${VERSION//./}.${COMPONENT}.${TOOLCHAIN}" + "qt6_${VERSION//./}_${ANDROID_ARCH}/qt.qt6.${VERSION//./}.${TOOLCHAIN}" + "qt6_${VERSION//./}_${ANDROID_ARCH}/qt.qt6.${VERSION//./}.${COMPONENT}.${TOOLCHAIN}" + # New repository format (>=5.9.6) + "qt5_${VERSION//./}/qt.qt5.${VERSION//./}.${TOOLCHAIN}" + "qt5_${VERSION//./}/qt.qt5.${VERSION//./}.${COMPONENT}.${TOOLCHAIN}" + # Multi-abi Android since 5.14 + "qt5_${VERSION//./}/qt.qt5.${VERSION//./}.${TARGET_PLATFORM}" + "qt5_${VERSION//./}/qt.qt5.${VERSION//./}.${COMPONENT}.${TARGET_PLATFORM}" + # Older repository format (<5.9.0) + "qt5_${VERSION//./}/qt.${VERSION//./}.${TOOLCHAIN}" + "qt5_${VERSION//./}/qt.${VERSION//./}.${COMPONENT}.${TOOLCHAIN}" + ) + + for REMOTE_BASE in ${REMOTE_BASES[*]}; do + REMOTE_PATH="$(${CURL} ${BASE_URL}/${REMOTE_BASE}/ | grep -o -E "[[:alnum:]_.\-]*7z" | grep "${COMPONENT}" | tail -1)" + if [ ! -z "${REMOTE_PATH}" ]; then + echo "${BASE_URL}/${REMOTE_BASE}/${REMOTE_PATH}" + return 0 + fi + done + fi + + echo "Could not determine a remote URL for ${COMPONENT} with version ${VERSION}">&2 + exit 1 +} + +function version { + echo "$@" | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; +} + +mkdir -p ${INSTALL_DIR} +rm -f "${HASH_FILEPATH}" + +for COMPONENT in ${COMPONENTS}; do + + if [[ "${COMPONENT}" =~ "qtcreator" ]] && [[ "${HOST_OS}" != "mac_x64" ]]; then + UNPACK_DIR="${INSTALL_DIR}/Tools/QtCreator" + mkdir -p ${UNPACK_DIR} + else + UNPACK_DIR="${INSTALL_DIR}" + fi + + if [ "$(version "${VERSION}")" -ge "$(version "6.0.0")" ]; then + if [[ "${COMPONENT}" =~ "qtscript" ]] || [[ "${COMPONENT}" =~ "qtscxml" ]] || [[ "${COMPONENT}" =~ "qtx11extras" ]]; then + echo "Component ${COMPONENT} was removed in Qt6, skipping" >&2 + continue + fi + else + if [[ "${COMPONENT}" =~ "qt5compat" ]]; then + echo "Component ${COMPONENT} is not present in Qt ${VERSION}, skipping" >&2 + continue + fi + fi + + URL="$(compute_url ${COMPONENT})" + echo "Downloading ${COMPONENT} ${URL}..." >&2 + curl --progress-bar -L -o ${DOWNLOAD_DIR}/package.7z ${URL} >&2 + 7z x -y -o${UNPACK_DIR} ${DOWNLOAD_DIR}/package.7z >/dev/null 2>&1 + 7z l -ba -slt -y ${DOWNLOAD_DIR}/package.7z | tr '\\' '/' | sed -n -e "s|^Path\ =\ |${UNPACK_DIR}/|p" >> "${HASH_FILEPATH}" 2>/dev/null + rm -f ${DOWNLOAD_DIR}/package.7z + + # + # conf file is needed for qmake + # + if [ "${COMPONENT}" == "qtbase" ]; then + if [[ "${TOOLCHAIN}" =~ "win64_mingw" ]]; then + SUBDIR="${TOOLCHAIN/win64_/}_64" + elif [[ "${TOOLCHAIN}" =~ "win32_mingw" ]]; then + SUBDIR="${TOOLCHAIN/win32_/}_32" + elif [[ "${TOOLCHAIN}" =~ "win64_msvc" ]]; then + SUBDIR="${TOOLCHAIN/win64_/}" + elif [[ "${TOOLCHAIN}" =~ "win32_msvc" ]]; then + SUBDIR="${TOOLCHAIN/win32_/}" + elif [[ "${TOOLCHAIN}" =~ "any" ]] && [[ "${TARGET_PLATFORM}" == "android" ]]; then + SUBDIR="android" + elif [[ "${HOST_OS}" == "mac_x64" ]] && [[ ! "${VERSION}" < "6.1.2" ]] && [[ "${TARGET_PLATFORM}" == "desktop" ]]; then + SUBDIR="macos" + else + SUBDIR="${TOOLCHAIN}" + fi + + if [ "${TARGET_PLATFORM}" == "android" ] && [ ! "${VERSION}" \< "6.0.0" ]; then + CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/target_qt.conf" + sed -i "s|target|../$TOOLCHAIN|g" "${CONF_FILE}" + sed -i "/HostPrefix/ s|$|gcc_64|g" "${CONF_FILE}" + ANDROID_QMAKE_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qmake" + QMAKE_FILE="${UNPACK_DIR}/${VERSION}/gcc_64/bin/qmake" + sed -i "s|\/home\/qt\/work\/install\/bin\/qmake|$QMAKE_FILE|g" "${ANDROID_QMAKE_FILE}" + else + CONF_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/bin/qt.conf" + echo "[Paths]" > ${CONF_FILE} + echo "Prefix = .." >> ${CONF_FILE} + fi + + # Adjust the license to be able to run qmake + # sed with -i requires intermediate file on Mac OS + PRI_FILE="${UNPACK_DIR}/${VERSION}/${SUBDIR}/mkspecs/qconfig.pri" + sed -i.bak 's/Enterprise/OpenSource/g' "${PRI_FILE}" + sed -i.bak 's/licheck.*//g' "${PRI_FILE}" + rm "${PRI_FILE}.bak" + + # Print the directory so that the caller can + # adjust the PATH variable. + echo $(dirname "${CONF_FILE}") + elif [[ "${COMPONENT}" =~ "mingw" ]]; then + if [[ "${TOOLCHAIN}" =~ "win64_mingw" ]]; then + echo "${UNPACK_DIR}/Tools/mingw${VERSION//./}_64/bin" + elif [[ "${TOOLCHAIN}" =~ "win32_mingw" ]]; then + echo "${UNPACK_DIR}/Tools/mingw${VERSION//./}_32/bin" + fi + elif [[ "${COMPONENT}" =~ "qtcreator" ]]; then + if [ "${HOST_OS}" == "mac_x64" ]; then + echo "${UNPACK_DIR}/Qt Creator.app/Contents/MacOS" + else + echo "${UNPACK_DIR}/bin" + fi + fi + +done diff --git a/scripts/make-release-archives.bat b/scripts/make-release-archives.bat new file mode 100644 index 00000000..ce889a9c --- /dev/null +++ b/scripts/make-release-archives.bat @@ -0,0 +1,77 @@ +@echo off + +REM Copyright (C) 2017 The Qt Company Ltd. +REM Contact: https://www.qt.io/licensing/ +REM +REM This file is part of Qbs. +REM +REM $QT_BEGIN_LICENSE:LGPL$ +REM Commercial License Usage +REM Licensees holding valid commercial Qt licenses may use this file in +REM accordance with the commercial license agreement provided with the +REM Software or, alternatively, in accordance with the terms contained in +REM a written agreement between you and The Qt Company. For licensing terms +REM and conditions see https://www.qt.io/terms-conditions. For further +REM information use the contact form at https://www.qt.io/contact-us. +REM +REM GNU Lesser General Public License Usage +REM Alternatively, this file may be used under the terms of the GNU Lesser +REM General Public License version 3 as published by the Free Software +REM Foundation and appearing in the file LICENSE.LGPL3 included in the +REM packaging of this file. Please review the following information to +REM ensure the GNU Lesser General Public License version 3 requirements +REM will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +REM +REM GNU General Public License Usage +REM Alternatively, this file may be used under the terms of the GNU +REM General Public License version 2.0 or (at your option) the GNU General +REM Public license version 3 or any later version approved by the KDE Free +REM Qt Foundation. The licenses are as published by the Free Software +REM Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +REM included in the packaging of this file. Please review the following +REM information to ensure the GNU General Public License requirements will +REM be met: https://www.gnu.org/licenses/gpl-2.0.html and +REM https://www.gnu.org/licenses/gpl-3.0.html. +REM +REM $QT_END_LICENSE$ + +setlocal enabledelayedexpansion || exit /b +if not exist VERSION ( echo This script must be run from the qbs source directory 1>&2 && exit /b 1 ) +for /f %%j in (VERSION) do ( set "version=!version!%%j," ) +set "version=%version:~0,-1%" + +set builddir=%TEMP%\qbs-release-%version% +if exist "%builddir%" ( del /s /q "%builddir%" || exit /b ) + +qbs setup-toolchains --settings-dir "%builddir%\.settings" --detect || exit /b + +if exist "%QTDIR%" ( + qbs setup-qt --settings-dir "%builddir%\.settings"^ + "%QTDIR%\bin\qmake.exe" qt || exit /b +) else ( + echo QTDIR environment variable not set or does not exist: %QTDIR% + exit /b 1 +) +if exist "%QTDIR64%" ( + qbs setup-qt --settings-dir "%builddir%\.settings"^ + "%QTDIR64%\bin\qmake.exe" qt64 || exit /b +) else ( + echo QTDIR64 environment variable not set or does not exist: %QTDIR64% + exit /b 1 +) + +REM Work around QBS-1142, where symlinks to UNC named paths aren't resolved +REM properly, for example if this command is being run in a Docker container +REM where the current directory is a symlink +subst Q: "%CD%" && Q: + +qbs build --settings-dir "%builddir%\.settings"^ + -f qbs.qbs -d "%builddir%\build"^ + -p dist qbs.buildVariant:release project.withDocumentation:false products.qbs_archive.includeTopLevelDir:true^ + modules.qbsbuildconfig.enableBundledQt:true^ + config:release "qbs.installRoot:%builddir%\qbs-windows-x86-%version%" profile:qt^ + config:release-64 "qbs.installRoot:%builddir%\qbs-windows-x86_64-%version%" profile:qt64 || exit /b + +copy /y "%builddir%\build\release\qbs.%version%.nupkg" dist || exit /b +copy /y "%builddir%\build\release\qbs-windows-x86-%version%.zip" dist || exit /b +copy /y "%builddir%\build\release-64\qbs-windows-x86_64-%version%.zip" dist || exit /b diff --git a/scripts/make-release-archives.sh b/scripts/make-release-archives.sh new file mode 100755 index 00000000..c3a0771e --- /dev/null +++ b/scripts/make-release-archives.sh @@ -0,0 +1,50 @@ +#!/bin/sh +set -e + +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +test $# -eq 1 || { echo "Usage: $(basename "$0") " >&2; exit 1; } + +tag=${1} +version=${tag#v} +dir_name=qbs-src-${version} + +git archive --format=tar.gz "--prefix=${dir_name}/" -o "dist/${dir_name}.tar.gz" "${tag}" +git archive --format=zip "--prefix=${dir_name}/" -o "dist/${dir_name}.zip" "${tag}" diff --git a/scripts/run-analyzer.sh b/scripts/run-analyzer.sh new file mode 100755 index 00000000..4293883a --- /dev/null +++ b/scripts/run-analyzer.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR:-""} + +# on Debian, it might be necessary to setup which version of clang-tidy and run-clang-tidy.py +# is desired: +# update-alternatives --install /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-4.0.py 1 + +CLANG_TIDY=`which clang-tidy` +RUN_CLANG_TIDY=`which run-clang-tidy.py` + +if [ -z "$RUN_CLANG_TIDY" ] || [ -z "$CLANG_TIDY" ]; then + if [ ! -z "$LLVM_INSTALL_DIR" ]; then + CLANG_TIDY="$LLVM_INSTALL_DIR/bin/clang-tidy" + RUN_CLANG_TIDY="$LLVM_INSTALL_DIR/share/clang/run-clang-tidy.py" + else + echo "Can't find clang-tidy and/or run-clang-tidy.py in PATH, try setting LLVM_INSTALL_DIR" + exit 1 + fi +fi + +CPU_COUNT=$("$(dirname "$0")"/cpu-count.sh) + +BUILD_OPTIONS="\ + ${QBS_BUILD_PROFILE:+profile:${QBS_BUILD_PROFILE}} \ + modules.cpp.treatWarningsAsErrors:true \ + modules.qbs.buildVariant:release \ + project.withTests:false \ + ${BUILD_OPTIONS} \ + config:analyzer +" + +QBS_SRC_DIR=${QBS_SRC_DIR:-`pwd`} + +if [ ! -f "$QBS_SRC_DIR/qbs.qbs" ]; then + echo "Can't find qbs.qbs in $QBS_SRC_DIR, try setting QBS_SRC_DIR" + exit 1 +fi + +set -e +set -o pipefail + +qbs resolve -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS +qbs build -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS +qbs generate -g clangdb -f "$QBS_SRC_DIR/qbs.qbs" $BUILD_OPTIONS + +SCRIPT=" +import json +import os +import sys + +dbFile = sys.argv[1] +blacklist = ['json.cpp', 'qmljsgrammar.cpp'] +seenFiles = set() +patched_db = [] +with open(dbFile, 'r') as f: + db = json.load(f) + for item in db: + file = item['file'] + if (os.path.basename(file) not in blacklist) and (file not in seenFiles): + seenFiles.add(file) + patched_db.append(item) + +with open(dbFile, 'w') as f: + f.write(json.dumps(patched_db, indent=2)) +" +python3 -c "${SCRIPT}" analyzer/compile_commands.json + +RUN_CLANG_TIDY+=" -p analyzer -clang-tidy-binary ${CLANG_TIDY} -j ${CPU_COUNT} -header-filter=\".*qbs.*\.h$\" -quiet" +${RUN_CLANG_TIDY} 2>/dev/null | tee results.txt +echo "$(grep -c 'warning:' results.txt) warnings in total" diff --git a/scripts/scripts.qbs b/scripts/scripts.qbs new file mode 100644 index 00000000..8c6f77a6 --- /dev/null +++ b/scripts/scripts.qbs @@ -0,0 +1,7 @@ +Product { + name: "qbs dev scripts" + files: [ + "*.bat", + "*.sh", + ] +} diff --git a/scripts/test-baremetal.sh b/scripts/test-baremetal.sh new file mode 100755 index 00000000..985a5eac --- /dev/null +++ b/scripts/test-baremetal.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -eu + +############################################################################# +## +## Copyright (C) 2020 Denis Shienkov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +export PATH="$1:$PATH" +export QBS_AUTOTEST_ALWAYS_LOG_STDERR=true + +echo "Auto-detecting the Qbs profiles." +qbs-setup-toolchains --detect +qbs-config --list profiles + +echo "Testing the Qbs toolchains." +export QBS_AUTOTEST_PROFILE=${QBS_AUTOTEST_PROFILE:-arm-none-eabi-gcc-9_2} +tst_blackbox-baremetal diff --git a/scripts/test-for-android.sh b/scripts/test-for-android.sh new file mode 100755 index 00000000..34a7c052 --- /dev/null +++ b/scripts/test-for-android.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +set -eu + +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +export PATH="$1:$PATH" + +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +# +# These are set outside of this script, for instance in the Docker image +# +echo "Android SDK installed at ${ANDROID_SDK_ROOT}" +echo "Android NDK installed at ${ANDROID_NDK_ROOT}" + +# Cleaning profiles +qbs config --unset profiles.qbs_autotests-android + +# Setting auto test profiles +qbs setup-android --ndk-dir ${ANDROID_NDK_ROOT} --sdk-dir ${ANDROID_HOME} qbs_autotests-android + +export QBS_AUTOTEST_PROFILE=qbs_autotests-android +export QBS_AUTOTEST_ALWAYS_LOG_STDERR=true +export QTEST_FUNCTION_TIMEOUT=9000000 + +qbs config --list + +tst_blackbox-android + diff --git a/scripts/test-qbs.sh b/scripts/test-qbs.sh new file mode 100755 index 00000000..55dc6524 --- /dev/null +++ b/scripts/test-qbs.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2020 Ivan Komissarov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +set -eu + +# +# Qbs is built with the address sanitizer enabled. +# Suppress findings in some parts of Qbs / dependencies. +# +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +export PATH="$1:$PATH" + +CPUS=$("$(dirname "$0")"/cpu-count.sh) + +export QBS_AUTOTEST_PROFILE=${QBS_AUTOTEST_PROFILE:-qt} +echo "Running Qbs tests (${CPUS} jobs in parallel)." +find $1 -name "tst_*" \ + | grep -v tst_blackbox-joblimits \ + | xargs -I{} -n1 -P${CPUS} bash -c \ + 'export LOG=$(mktemp) ; $({} > ${LOG} 2>&1) ; export RESULT=$? ; cat ${LOG} ; exit ${RESULT}' +tst_blackbox-joblimits diff --git a/scripts/test-qt-for-android.sh b/scripts/test-qt-for-android.sh new file mode 100755 index 00000000..dcc52bc2 --- /dev/null +++ b/scripts/test-qt-for-android.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +set -eu + +############################################################################# +## +## Copyright (C) 2019 Richard Weickelt. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +export PATH="$1:$PATH" + +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +# +# These are set outside of this script, for instance in the Docker image +# +QT_INSTALL_DIR=/opt/Qt/${QT_VERSION} +echo "Android SDK installed at ${ANDROID_SDK_ROOT}" +echo "Android NDK installed at ${ANDROID_NDK_ROOT}" +echo "Qt installed at ${QT_INSTALL_DIR}" + +# Cleaning profiles +qbs config --unset profiles.qbs_autotests-android +qbs config --unset profiles.qbs_autotests-android-qt + +# Setting auto test profiles +qbs setup-android --ndk-dir ${ANDROID_NDK_ROOT} --sdk-dir ${ANDROID_SDK_ROOT} qbs_autotests-android +qbs setup-android --ndk-dir ${ANDROID_NDK_ROOT} --sdk-dir ${ANDROID_SDK_ROOT} --qt-dir ${QT_INSTALL_DIR} qbs_autotests-android-qt + +export QBS_AUTOTEST_PROFILE=qbs_autotests-android +export QBS_AUTOTEST_ALWAYS_LOG_STDERR=true +export QTEST_FUNCTION_TIMEOUT=9000000 + +if [ ! "${QT_VERSION}" \< "5.14.0" ] && [ "${QT_VERSION}" \< "6.0.0" ]; then + echo "Using multi-arch data sets for qml tests (only for qt version >= 5.14 and < 6.0.0) with all architectures" + qbs config --list + tst_blackbox-android +fi; + +if [ ! "${QT_VERSION}" \< "6.3.0" ]; then + echo "Using multi-arch data sets for qml tests (only for qt version >= 6.3.0) with all architectures" + qbs config --list + tst_blackbox-android +fi; + +echo "Using single-arch (armv7a) data sets for qml tests" +qbs config --unset profiles.qbs_autotests-android-qt.qbs.architectures +qbs config profiles.qbs_autotests-android-qt.qbs.architecture armv7a + +qbs config --list + +tst_blackbox-android + diff --git a/scripts/test-qt.sh b/scripts/test-qt.sh new file mode 100755 index 00000000..944d8941 --- /dev/null +++ b/scripts/test-qt.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +############################################################################# +## +## Copyright (C) 2021 Ivan Komissarov +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +set -eu + +# +# Qbs is built with the address sanitizer enabled. +# Suppress findings in some parts of Qbs / dependencies. +# +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +export PATH="$1:$PATH" + +export QBS_AUTOTEST_PROFILE=${QBS_AUTOTEST_PROFILE:-qt} + +tst_blackbox-qt diff --git a/scripts/test-qt4.sh b/scripts/test-qt4.sh new file mode 100755 index 00000000..b4b0078e --- /dev/null +++ b/scripts/test-qt4.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +set -eu + +############################################################################# +## +## Copyright (C) 2020 Raphael Cotty. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +export PATH="$1:$PATH" + +export LSAN_OPTIONS="suppressions=$( cd "$(dirname "$0")" ; pwd -P )/address-sanitizer-suppressions.txt:print_suppressions=0" + +# Creating the qt4 profile + +qbs-setup-toolchains /usr/bin/g++ gcc +qbs-setup-qt /usr/lib/x86_64-linux-gnu/qt4/bin/qmake qt4 +# To avoid warnings due to qt4 include files +qbs config profiles.gcc.cpp.cxxFlags "-Wno-deprecated-copy" +qbs config profiles.qt4.baseProfile gcc +qbs config --list + +export QBS_AUTOTEST_PROFILE=qt4 + +tst_blackbox-qt diff --git a/scripts/thread-sanitizer-suppressions.txt b/scripts/thread-sanitizer-suppressions.txt new file mode 100644 index 00000000..9b2a9baa --- /dev/null +++ b/scripts/thread-sanitizer-suppressions.txt @@ -0,0 +1 @@ +called_from_lib:libtsan.so diff --git a/scripts/update-dmgbuild.sh b/scripts/update-dmgbuild.sh new file mode 100755 index 00000000..ba4c2c82 --- /dev/null +++ b/scripts/update-dmgbuild.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +python_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../src/3rdparty/python" +repos=(biplist.git@v1.0.3 dmgbuild.git@v1.3.2 ds_store@v1.1.2 mac_alias.git@v2.0.7) +for repo in "${repos[@]}" ; do + pip install -U --isolated "--prefix=$python_dir" --no-binary :all: --no-compile --no-deps \ + "git+git://github.com/qbs/$repo" +done +rm "$python_dir/lib/python2.7/site-packages/dmgbuild/resources/"*.tiff diff --git a/scripts/update-xcspecs.sh b/scripts/update-xcspecs.sh new file mode 100755 index 00000000..2c046f38 --- /dev/null +++ b/scripts/update-xcspecs.sh @@ -0,0 +1,53 @@ +#!/bin/bash +set -e + +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of Qbs. +## +## $QT_BEGIN_LICENSE:LGPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU Lesser General Public License Usage +## Alternatively, this file may be used under the terms of the GNU Lesser +## General Public License version 3 as published by the Free Software +## Foundation and appearing in the file LICENSE.LGPL3 included in the +## packaging of this file. Please review the following information to +## ensure the GNU Lesser General Public License version 3 requirements +## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 2.0 or (at your option) the GNU General +## Public license version 3 or any later version approved by the KDE Free +## Qt Foundation. The licenses are as published by the Free Software +## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-2.0.html and +## https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +# Update build specs from Xcode - this script should be run when new Xcode releases are made. +specs_dir="$(xcrun --sdk macosx --show-sdk-platform-path)/Developer/Library/Xcode/Specifications" +specs_out_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../share/qbs/modules/bundle" +spec_files=("MacOSX Package Types.xcspec" "MacOSX Product Types.xcspec") +for spec_file in "${spec_files[@]}" ; do + printf "%s\\n" "$(plutil -convert json -r -o - "$specs_dir/$spec_file")" > \ + "$specs_out_dir/${spec_file// /-}" +done +xcode_version="$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' \ + "$(xcode-select --print-path)/../Info.plist")" +echo "Updated build specs from Xcode $xcode_version" diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt new file mode 100644 index 00000000..2891f727 --- /dev/null +++ b/share/CMakeLists.txt @@ -0,0 +1,114 @@ +if(WIN32) + install( + FILES ../bin/ibmsvc.xml ../bin/ibqbs.bat + DESTINATION "${QBS_APP_INSTALL_DIR}" + ) +endif() + +# below we copy some files that are required to run qbs from the build directory +# emulating the same layout we will have after the installation + +# copy & install dmgbuild +install( + PROGRAMS ../src/3rdparty/python/bin/dmgbuild + DESTINATION "${QBS_LIBEXEC_INSTALL_DIR}" + ) +set(_DMGBUILD_INSTALL_PATH ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_LIBEXEC_INSTALL_DIR}/dmgbuild) +add_custom_command( + OUTPUT ${_DMGBUILD_INSTALL_PATH} + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/../src/3rdparty/python/bin/dmgbuild + ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_LIBEXEC_INSTALL_DIR} + COMMENT "Copying dmgbuild script" + ) + +# copy & install python packages +set(_SITE_PACKAGES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src/3rdparty/python/lib/python2.7/site-packages/) +file(GLOB_RECURSE _SITE_PACKAGES_RELATIVE RELATIVE "${_SITE_PACKAGES_DIR}" "${_SITE_PACKAGES_DIR}/*.py") + +set(_SITE_PACKAGES_SRC ${_SITE_PACKAGES_RELATIVE}) +list_transform_prepend(_SITE_PACKAGES_SRC "${_SITE_PACKAGES_DIR}/") + +set(_SITE_PACKAGES_DST ${_SITE_PACKAGES_RELATIVE}) +list_transform_prepend(_SITE_PACKAGES_DST "${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_RESOURCES_INSTALL_DIR}/qbs/python/") + +add_custom_command( + OUTPUT ${_SITE_PACKAGES_DST} + DEPENDS ${_SITE_PACKAGES_SRC} + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${_SITE_PACKAGES_DIR}" + ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_RESOURCES_INSTALL_DIR}/qbs/python + COMMENT "Copying Python packages" + ) +install( + # trailing slash avoid copying the 'site-packages' dir and only copies its content + DIRECTORY "${_SITE_PACKAGES_DIR}" + DESTINATION "${QBS_RESOURCES_INSTALL_DIR}/qbs/python" + FILES_MATCHING PATTERN "*.py" + ) + +# copy & install the "share/qbs" dir +file(GLOB_RECURSE _QBS_RESOURCES_RELATIVE RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/qbs/*") + +set(_QBS_RESOURCES_SRC ${_QBS_RESOURCES_RELATIVE}) +list_transform_prepend(_QBS_RESOURCES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/") + +set(_QBS_RESOURCES_DST ${_QBS_RESOURCES_RELATIVE}) +list_transform_prepend(_QBS_RESOURCES_DST "${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_RESOURCES_INSTALL_DIR}/") + +add_custom_command( + OUTPUT ${_QBS_RESOURCES_DST} + DEPENDS ${_QBS_RESOURCES_SRC} + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/qbs + ${CMAKE_BINARY_DIR}/${QBS_OUTPUT_PREFIX}${QBS_RESOURCES_INSTALL_DIR}/qbs + COMMENT "Copying QBS resources" + ) +install( + DIRECTORY qbs + DESTINATION "${QBS_RESOURCES_INSTALL_DIR}") + +# install examples dir +install( + DIRECTORY ../examples + DESTINATION "${QBS_RESOURCES_INSTALL_DIR}/qbs" + ) + +set(_QMLTYPES_INSTALL_PATH "${PROJECT_BINARY_DIR}/resources-build/install-root/share/qbs/qml-type-descriptions/qbs.qmltypes") +get_update_path_command(UPDATE_PATH_COMMAND) +get_target_property(_QBS_OUTPUT_DIR qbs RUNTIME_OUTPUT_DIRECTORY) +add_custom_command( + OUTPUT "${_QMLTYPES_INSTALL_PATH}" + COMMAND ${CMAKE_COMMAND} -E env "${UPDATE_PATH_COMMAND}" ${_QBS_OUTPUT_DIR}/qbs + resolve + --settings-dir ${PROJECT_BINARY_DIR}/settings + -f ${PROJECT_SOURCE_DIR}/qbs.qbs + -d ${PROJECT_BINARY_DIR}/ + config:resources-build + qbs.installPrefix:undefined + project.withCode:false + project.withDocumentation:false + profile:none + COMMAND ${CMAKE_COMMAND} -E env "${UPDATE_PATH_COMMAND}" ${_QBS_OUTPUT_DIR}/qbs + build + --settings-dir ${PROJECT_BINARY_DIR}/settings + -f ${PROJECT_SOURCE_DIR}/qbs.qbs + -d ${PROJECT_BINARY_DIR}/ + config:resources-build + -p "qbs resources" + DEPENDS qbs "${_QBS_RESOURCES_DST}" qbs_processlauncher + ) + +add_custom_target( + BuildQbsResources ALL + DEPENDS + "${_DMGBUILD_INSTALL_PATH}" + ${_SITE_PACKAGES_DST} + ${_QBS_RESOURCES_DST} + "${_QMLTYPES_INSTALL_PATH}" + ) + +install( + DIRECTORY ${PROJECT_BINARY_DIR}/resources-build/install-root/share/qbs/qml-type-descriptions + DESTINATION "${QBS_RESOURCES_INSTALL_DIR}/qbs" + ) diff --git a/share/qbs/imports/qbs/BundleTools/bundle-tools.js b/share/qbs/imports/qbs/BundleTools/bundle-tools.js new file mode 100644 index 00000000..275f410c --- /dev/null +++ b/share/qbs/imports/qbs/BundleTools/bundle-tools.js @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var DarwinTools = require("qbs.DarwinTools"); +var PropertyList = require("qbs.PropertyList"); + +function destinationDirectoryForResource(product, input) { + var path = product.destinationDirectory; + var inputFilePath = FileInfo.joinPaths(input.baseDir, input.fileName); + var key = DarwinTools.localizationKey(inputFilePath); + if (key) { + path = FileInfo.joinPaths(path, localizedResourcesFolderPath(product, key)); + var subPath = DarwinTools.relativeResourcePath(inputFilePath); + if (subPath && subPath !== '.') + path = FileInfo.joinPaths(path, subPath); + } else { + path = FileInfo.joinPaths(path, product.moduleProperty("bundle", "unlocalizedResourcesFolderPath")); + } + return path; +} + +function localizedResourcesFolderPath(product, key) { + return FileInfo.joinPaths(product.moduleProperty("bundle", "unlocalizedResourcesFolderPath"), key + product.moduleProperty("bundle", "localizedResourcesFolderSuffix")); +} + +function infoPlistContents(infoPlistFilePath) { + if (infoPlistFilePath === undefined) + return undefined; + + var plist = new PropertyList(); + try { + plist.readFromFile(infoPlistFilePath); + return plist.toObject(); + } finally { + plist.clear(); + } +} + +function infoPlistFormat(infoPlistFilePath) { + if (infoPlistFilePath === undefined) + return undefined; + + var plist = new PropertyList(); + try { + plist.readFromFile(infoPlistFilePath); + return plist.format(); + } finally { + plist.clear(); + } +} diff --git a/share/qbs/imports/qbs/DarwinTools/darwin-tools.js b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js new file mode 100644 index 00000000..15f2c54e --- /dev/null +++ b/share/qbs/imports/qbs/DarwinTools/darwin-tools.js @@ -0,0 +1,271 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var Utilities = require("qbs.Utilities"); + +var _deviceMap = { + "mac": undefined, // only devices have an ID + "iphone": 1, + "ipad": 2, + "tv": 3, + "watch": 4, + "car": 5 +}; + +var _platformMap = { + "ios": "iPhone", + "macos": "MacOSX", + "tvos": "AppleTV", + "watchos": "Watch" +}; + +var _platformDeviceMap = { + "ios": ["iphone", "ipad"], + "macos": ["mac"], + "tvos": ["tv"], + "watchos": ["watch"] +} + +/** + * Returns the numeric identifier corresponding to an Apple device name + * (i.e. for use by TARGETED_DEVICE_FAMILY). + */ +function appleDeviceNumber(deviceName) { + return _deviceMap[deviceName]; +} + +/** + * Returns the list of target devices available for the given qbs target OS list. + */ +function targetDevices(targetOS) { + for (var key in _platformDeviceMap) { + if (targetOS.contains(key)) + return _platformDeviceMap[key]; + } +} + +/** + * Returns the TARGETED_DEVICE_FAMILY string given a list of target device names. + */ +function targetedDeviceFamily(deviceNames) { + return deviceNames.map(function (deviceName) { + return appleDeviceNumber(deviceName); + }); +} + +/** + * Returns the most appropriate Apple platform name given a targetOS list. + */ +function applePlatformName(targetOSList, platformType) { + return applePlatformDirectoryName(targetOSList, platformType).toLowerCase(); +} + +/** + * Returns the most appropriate Apple platform directory name given a targetOS list and version. + */ +function applePlatformDirectoryName(targetOSList, platformType, version, throwOnError) { + var suffixMap = { + "device": "OS", + "simulator": "Simulator" + }; + + for (var key in _platformMap) { + if (targetOSList.contains(key)) { + // there are no MacOSXOS or MacOSXSimulator platforms + var suffix = (key !== "macos") ? (suffixMap[platformType] || "") : ""; + return _platformMap[key] + suffix + (version || ""); + } + } + + if (throwOnError || throwOnError === undefined) + throw("No Apple platform corresponds to target OS list: " + targetOSList); +} + +/** + * Returns the localization of the resource at the given path, + * or undefined if the path does not contain an {xx}.lproj path segment. + */ +function localizationKey(path) { + return _resourceFileProperties(path)[0]; +} + +/** + * Returns the path of a localized resource at the given path, + * relative to its containing {xx}.lproj directory, or '.' + * if the resource is unlocalized (not contained in an lproj directory). + */ +function relativeResourcePath(path) { + return _resourceFileProperties(path)[1]; +} + +function _resourceFileProperties(path) { + var lprojKey = ".lproj/"; + var lproj = path.indexOf(lprojKey); + if (lproj >= 0) { + // The slash preceding XX.lproj + var slashIndex = path.slice(0, lproj).lastIndexOf('/'); + if (slashIndex >= 0) { + var localizationKey = path.slice(slashIndex + 1, lproj); + var relativeResourcePath = FileInfo.path(path.slice(lproj + lprojKey.length)); + return [ localizationKey, relativeResourcePath ]; + } + } + + return [ undefined, '.' ]; +} + +var PropertyListVariableExpander = (function () { + function PropertyListVariableExpander() { + } + /** + * Recursively perform variable replacements in an environment dictionary. + */ + PropertyListVariableExpander.prototype.expand = function (obj, env) { + var $this = this; + + // Possible syntaxes for wrapping an environment variable name + var syntaxes = [ + {"open": "${", "close": "}"}, + {"open": "$(", "close": ")"}, + {"open": "@", "close": "@"} + ]; + + /** + * Finds the first index of a replacement starting with one of the supported syntaxes + * This is needed so we don't do recursive substitutions + */ + function indexOfReplacementStart(syntaxes, str) { + var syntax; + var idx = -1; + for (var i in syntaxes) { + var j; + // normal case - we search for the last occurrence to do a correct replacement + // for nested variables, e.g. ${VAR1_${VAR2}}. This doesn't work in case + // when start == end, e.g. @VAR@ - in that case we search from the start + if (syntaxes[i].open !== syntaxes[i].close) + j = str.lastIndexOf(syntaxes[i].open); + else + j = str.indexOf(syntaxes[i].open); + if (j > idx) { + syntax = syntaxes[i]; + idx = j; + } + } + return { "syntax": syntax, "index": idx }; + } + + function expandString(key, str, env) { + if (!str) + return str; + var repl = indexOfReplacementStart(syntaxes, str); + var i = repl.index; + while (i !== -1) { + var j = str.indexOf(repl.syntax.close, i + repl.syntax.open.length); + if (j === -1) + return str; + var varParts = str.slice(i + repl.syntax.open.length, j).split(':'); + var varName = varParts[0]; + var varFormatter = varParts[1]; + var varValue = expandString(key, env[varName], env); + if (undefined === varValue) { + // skip replacement + if ($this.undefinedVariableFunction) + $this.undefinedVariableFunction(key, varName); + varValue = ""; + } + varValue = String(varValue); + if (varFormatter !== undefined) { + // TODO: XCode supports multiple formatters separated by a comma + var varFormatterLower = varFormatter.toLowerCase(); + if (varFormatterLower === "rfc1034identifier" || varFormatterLower === "identifier") + varValue = Utilities.rfc1034Identifier(varValue); + if (varValue === "" && varFormatterLower.startsWith("default=")) + varValue = varFormatter.split("=")[1]; + } + str = str.slice(0, i) + varValue + str.slice(j + repl.syntax.close.length); + repl = indexOfReplacementStart(syntaxes, str); + i = repl.index; + } + return str; + } + + function expandRecursive(obj, env, checked) { + checked.push(obj); + for (var key in obj) { + var value = obj[key]; + var type = typeof(value); + if (type === "object") { + if (checked.indexOf(value) !== -1) + continue; + expandRecursive(value, env, checked); + } + if (type !== "string") + continue; + var expandedValue = expandString(key, value, env); + if (expandedValue !== value) + obj[key] = expandedValue; + } + } + expandRecursive(obj, env, []); + return obj; + }; + return PropertyListVariableExpander; +}()); + +/** + * JSON.stringify(expandPlistEnvironmentVariables({a:"$(x)3$$(y)",b:{t:"%$(y) $(k)"}}, + * {x:"X",y:"Y"}, true)) + * Warning undefined variable k in variable expansion + * => {"a":"X3$Y","b":{"t":"%Y $(k)"}} + */ +function expandPlistEnvironmentVariables(obj, env, warn) { + var expander = new PropertyListVariableExpander(); + expander.undefinedVariableFunction = function (key, varName) { + if (warn) + console.warn("undefined variable " + varName + " in variable expansion"); + }; + return expander.expand(obj, env); +} + +/** + * Recursively removes any undefined, null, or empty string values from the property list. + */ +function cleanPropertyList(plist) { + if (typeof(plist) !== "object") + return; + + for (var key in plist) { + if (plist[key] === undefined || plist[key] === null || plist[key] === "") + delete plist[key]; + else + cleanPropertyList(plist[key]); + } +} diff --git a/share/qbs/imports/qbs/ModUtils/utils.js b/share/qbs/imports/qbs/ModUtils/utils.js new file mode 100644 index 00000000..dfb1f763 --- /dev/null +++ b/share/qbs/imports/qbs/ModUtils/utils.js @@ -0,0 +1,649 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function mergeCFiles(inputs, outputFilePath) +{ + var f = new TextFile(outputFilePath, TextFile.WriteOnly); + try { + for (var i = 0; i < inputs.length; ++i) + f.writeLine('#include ' + Utilities.cStringQuote(inputs[i].filePath)); + } finally { + f.close(); + } +} + +function sanitizedList(list, product, fullPropertyName) { + if (!(list instanceof Array)) + return list; + var filterFunc = function(elem) { + if (typeof elem === "string" && elem.length === 0) { + var msg = "Removing empty string from value of property '" + fullPropertyName + "'"; + // product might actually be a module + if (product.name) + msg += " in product '" + product.name + "'."; + console.warn(msg); + return false; + } + return true; + } + return list.filter(filterFunc); +} + +function checkCompatibilityMode(project, minimumQbsVersion, message) { + if (Utilities.versionCompare(project.minimumQbsVersion || "1.3", minimumQbsVersion) < 0) { + console.warn([message || "", + "This message can be silenced by setting your Project's " + + "minimumQbsVersion to " + minimumQbsVersion + + " (and the new behavior will take effect)."].join(" ")); + return true; + } + + return false; +} + +function artifactInstalledFilePath(artifact) { + var relativeInstallDir = artifact.moduleProperty("qbs", "installDir"); + var installPrefix = artifact.moduleProperty("qbs", "installPrefix"); + var installSourceBase = artifact.moduleProperty("qbs", "installSourceBase"); + var targetDir = FileInfo.joinPaths(artifact.moduleProperty("qbs", "installRoot"), + installPrefix, relativeInstallDir); + if (installSourceBase) { + if (!FileInfo.isAbsolutePath(installSourceBase)) + throw "installSourceBase is not an absolute path"; + if (!artifact.filePath.startsWith(installSourceBase)) + throw "artifact file path doesn't start with the value of qbs.installSourceBase"; + return FileInfo.joinPaths(targetDir, artifact.filePath.substr(installSourceBase.length)); + } + return FileInfo.joinPaths(targetDir, artifact.fileName); +} + +/** + * Given a list of file tags, returns the file tag (one of [c, cpp, objc, objcpp]) + * corresponding to the C-family language the file should be compiled as. + * + * If no such tag is found, undefined is returned. If more than one match is + * found, an exception is thrown. + */ +function fileTagForTargetLanguage(fileTags) { + var srcTags = ["c", "cpp", "objc", "objcpp", "asm", "asm_cpp"]; + var pchTags = ["c_pch", "cpp_pch", "objc_pch", "objcpp_pch"]; + + var canonicalTag = undefined; + var foundTagCount = 0; + for (var i = 0; i < fileTags.length; ++i) { + var idx = srcTags.indexOf(fileTags[i]); + if (idx === -1) + idx = pchTags.indexOf(fileTags[i]); + + if (idx !== -1) { + canonicalTag = srcTags[idx]; + if (++foundTagCount > 1) + break; + } + } + + if (foundTagCount > 1) + throw ("source files cannot be identified as more than one language"); + + return foundTagCount == 1 ? canonicalTag : undefined; +} + +/** + * Returns the name of a language-specific property given the file tag + * for that property, and the base property name. + * + * If \a fileTag is undefined, the language-agnostic property name is returned. + */ +function languagePropertyName(propertyName, fileTag) { + if (!fileTag) + fileTag = "common"; + + var asm = { + "flags": "assemblerFlags", + "platformFlags": "platformAssemblerFlags" + }; + + var map = { + "c": { + "flags": "cFlags", + "platformFlags": "platformCFlags", + "usePrecompiledHeader": "useCPrecompiledHeader" + }, + "cpp": { + "flags": "cxxFlags", + "platformFlags": "platformCxxFlags", + "usePrecompiledHeader": "useCxxPrecompiledHeader" + }, + "objc": { + "flags": "objcFlags", + "platformFlags": "platformObjcFlags", + "usePrecompiledHeader": "useObjcPrecompiledHeader" + }, + "objcpp": { + "flags": "objcxxFlags", + "platformFlags": "platformObjcxxFlags", + "usePrecompiledHeader": "useObjcxxPrecompiledHeader" + }, + "common": { + "flags": "commonCompilerFlags", + "platformFlags": "platformCommonCompilerFlags" + }, + "asm": asm, + "asm_cpp": asm + }; + + var lang = map[fileTag]; + if (!lang) + return propertyName; + + return lang[propertyName] || propertyName; +} + +function modulePropertiesFromArtifacts(product, artifacts, moduleName, propertyName, langFilter) { + var result = product.moduleProperty( + moduleName, languagePropertyName(propertyName, langFilter)) || []; + for (var i in artifacts) { + var artifactProp = artifacts[i].moduleProperty( + moduleName, languagePropertyName(propertyName, langFilter)); + if (artifactProp) + result = result.concat(artifactProp); + } + return sanitizedList(result, product, moduleName + "." + propertyName); +} + +function moduleProperty(product, propertyName, langFilter) +{ + return sanitizedModuleProperty(product, product.moduleName, propertyName, langFilter); +} + +function sanitizedModuleProperty(obj, moduleName, propertyName, langFilter) { + return sanitizedList(obj.moduleProperty(moduleName, + languagePropertyName(propertyName, langFilter)), + obj, moduleName + "." + propertyName); +} + +/** + * Returns roughly the same value as moduleProperty for a product, but ensures that all of the + * given input artifacts share the same value of said property, as a sort of sanity check. + * + * This allows us to verify that users do not, for example, try to set different values on input + * artifacts for which the value is input specific (not product specific), but which must be the + * same for all inputs. + */ +function modulePropertyFromArtifacts(product, artifacts, moduleName, propertyName, langFilter) { + var values = [product.moduleProperty(moduleName, languagePropertyName(propertyName, langFilter))]; + for (var i in artifacts) { + var value = artifacts[i].moduleProperty(moduleName, languagePropertyName(propertyName, langFilter)); + if (!values.contains(value)) { + values.push(value); + } + } + + if (values.length !== 1) { + throw "The value of " + [moduleName, propertyName].join(".") + + " must be identical for the following input artifacts: " + + artifacts.map(function (artifact) { return artifact.filePath; }); + } + + return values[0]; +} + +function concatAll() { + var result = []; + for (var i = 0; i < arguments.length; ++i) { + var arg = arguments[i]; + if (arg === undefined) + continue; + else if (arg instanceof Array) + result = result.concat(arg); + else + result.push(arg); + } + return result; +} + +function allFileTags(fileTaggers) { + var tags = []; + for (var ext in fileTaggers) + tags = tags.uniqueConcat(fileTaggers[ext]); + return tags; +} + +/** + * Flattens a dictionary (string keys to strings) + * into a string list containing items like \c key=value1 + */ +function flattenDictionary(dict, separator) { + separator = separator || "="; + var list = []; + for (var i in dict) { + var value = i; + if (dict[i] !== undefined) // allow differentiation between undefined and empty string + value += separator + dict[i]; + list.push(value); + } + return list; +} + +function ModuleError(message) { + var e = new Error(message); + e.fileName = ""; + return e; +} + +var EnvironmentVariable = (function () { + function EnvironmentVariable(name, separator, convertPathSeparators) { + if (!name) + throw "EnvironmentVariable c'tor needs a name as first argument."; + this.name = name; + this.value = Environment.getEnv(name) || ""; + this.separator = separator || ""; + this.convertPathSeparators = convertPathSeparators || false; + } + EnvironmentVariable.prototype.prepend = function (v) { + if (this.value.length > 0 && this.value.charAt(0) !== this.separator) + this.value = this.separator + this.value; + if (this.convertPathSeparators) + v = FileInfo.toWindowsSeparators(v); + this.value = v + this.value; + }; + + EnvironmentVariable.prototype.append = function (v) { + if (this.value.length > 0) + this.value += this.separator; + if (this.convertPathSeparators) + v = FileInfo.toWindowsSeparators(v); + this.value += v; + }; + + EnvironmentVariable.prototype.set = function () { + Environment.putEnv(this.name, this.value); + }; + + EnvironmentVariable.prototype.unset = function () { + Environment.unsetEnv(this.name); + }; + + return EnvironmentVariable; +})(); + +var PropertyValidator = (function () { + function PropertyValidator(moduleName) { + this.requiredProperties = {}; + this.propertyValidators = []; + if (!moduleName) + throw "PropertyValidator c'tor needs a module name as a first argument."; + this.moduleName = moduleName; + } + PropertyValidator.prototype.setRequiredProperty = function (propertyName, propertyValue, message) { + this.requiredProperties[propertyName] = { propertyValue: propertyValue, message: message }; + }; + + PropertyValidator.prototype.addRangeValidator = function (propertyName, propertyValue, min, max, allowFloats) { + var message = []; + if (min !== undefined) + message.push(">= " + min); + if (max !== undefined) + message.push("<= " + max); + + this.addCustomValidator(propertyName, propertyValue, function (value) { + if (typeof value !== "number") + return false; + if (!allowFloats && value % 1 !== 0) + return false; + if (min !== undefined && value < min) + return false; + if (max !== undefined && value > max) + return false; + return true; + }, "must be " + (!allowFloats ? "an integer " : "") + message.join(" and ") + + ", actual value: " + propertyValue); + }; + + PropertyValidator.prototype.addVersionValidator = function (propertyName, propertyValue, minComponents, maxComponents, allowSuffixes) { + if (minComponents !== undefined && (typeof minComponents !== "number" || minComponents % 1 !== 0 || minComponents < 1)) + throw "minComponents must be at least 1"; + if (maxComponents !== undefined && (typeof maxComponents !== "number" || maxComponents % 1 !== 0 || maxComponents < minComponents)) + throw "maxComponents must be >= minComponents"; + + this.addCustomValidator(propertyName, propertyValue, function (value) { + if (typeof value !== "string") + return false; + return value && value.match("^[0-9]+(\\.[0-9]+){" + ((minComponents - 1) || 0) + "," + ((maxComponents - 1) || "") + "}" + (!allowSuffixes ? "$" : "")) !== null; + }, "must be a version number with " + (minComponents === maxComponents + ? minComponents : (minComponents + " to " + maxComponents)) + + (minComponents === maxComponents && minComponents === 1 + ? " component" : " components") + ", actual value: " + propertyValue); + }; + + PropertyValidator.prototype.addFileNameValidator = function (propertyName, propertyValue) { + this.addCustomValidator(propertyName, propertyValue, function (value) { + return !/[/?<>\\:*|"\u0000-\u001f\u0080-\u009f]/.test(propertyValue) + && propertyValue !== "." && propertyValue !== ".."; + }, "cannot contain reserved or control characters and cannot be \".\" or \"..\""); + }; + + PropertyValidator.prototype.addCustomValidator = function (propertyName, propertyValue, validator, message) { + this.propertyValidators.push({ + propertyName: propertyName, + propertyValue: propertyValue, + validator: validator, + message: message + }); + }; + + PropertyValidator.prototype.validate = function (throwOnError) { + var i; + var lines; + + // Find any missing properties + var missingProperties = {}; + for (i in this.requiredProperties) { + var propValue = this.requiredProperties[i].propertyValue; + if (propValue === undefined || propValue === null || propValue === "") { + missingProperties[i] = this.requiredProperties[i]; + } + } + + // Find any properties that don't satisfy their validator function + var invalidProperties = {}; + for (var j = 0; j < this.propertyValidators.length; ++j) { + var v = this.propertyValidators[j]; + if (!v.validator(v.propertyValue)) { + var messages = invalidProperties[v.propertyName] || []; + messages.push(v.message); + invalidProperties[v.propertyName] = messages; + } + } + + var errorMessage = ""; + if (Object.keys(missingProperties).length > 0) { + errorMessage += "The following properties are not set. Set them in your profile or product:\n"; + lines = []; + for (i in missingProperties) { + var obj = missingProperties[i]; + lines.push(this.moduleName + "." + i + ((obj && obj.message) ? (": " + obj.message) : "")); + } + errorMessage += lines.join("\n"); + } + + if (Object.keys(invalidProperties).length > 0) { + if (errorMessage) + errorMessage += "\n"; + errorMessage += "The following properties have invalid values:\n"; + lines = []; + for (i in invalidProperties) { + for (j = 0; j < invalidProperties[i].length; ++j) { + lines.push(this.moduleName + "." + i + ": " + invalidProperties[i][j]); + } + } + errorMessage += lines.join("\n"); + } + + if (throwOnError !== false && errorMessage.length > 0) + throw errorMessage; + + return errorMessage.length == 0; + }; + return PropertyValidator; +})(); + +var BlackboxOutputArtifactTracker = (function () { + function BlackboxOutputArtifactTracker() { + } + BlackboxOutputArtifactTracker.prototype.artifacts = function (outputDirectory) { + var process; + var fakeOutputDirectory; + try { + fakeOutputDirectory = new TemporaryDir(); + if (!fakeOutputDirectory.isValid()) + throw "could not create temporary directory"; + process = new Process(); + if (this.commandEnvironmentFunction) { + var env = this.commandEnvironmentFunction(fakeOutputDirectory.path()); + for (var key in env) + process.setEnv(key, env[key]); + } + process.exec(this.command, this.commandArgsFunction(fakeOutputDirectory.path()), true); + var artifacts = []; + if (this.fileTaggers) { + var files = this.findFiles(fakeOutputDirectory.path()); + for (var i = 0; i < files.length; ++i) + artifacts.push(this.createArtifact(fakeOutputDirectory.path(), files[i])); + } + if (this.processStdOutFunction) + artifacts = artifacts.concat(this.processStdOutFunction(process.readStdOut())); + artifacts = this.fixArtifactPaths(artifacts, outputDirectory, fakeOutputDirectory.path()); + return artifacts; + } + finally { + if (process) + process.close(); + if (fakeOutputDirectory) + fakeOutputDirectory.remove(); + } + }; + BlackboxOutputArtifactTracker.prototype.createArtifact = function (root, filePath) { + for (var ext in this.fileTaggers) { + if (filePath.endsWith(ext)) { + return { + filePath: filePath, + fileTags: this.fileTaggers[ext] + }; + } + } + if (!this.defaultFileTags) { + var relFilePath = (filePath.startsWith(root + '/') || filePath.startsWith(root + '\\')) + ? filePath.substring(root.length + 1) + : filePath; + throw "BlackboxOutputArtifactTracker: no matching file taggers for path '" + + relFilePath + "'. Set defaultFileTags to an array of file tags to " + + "apply to files not tagged by the fileTaggers map, which was:\n" + + JSON.stringify(this.fileTaggers, undefined, 4); + } + return { + filePath: filePath, + fileTags: this.defaultFileTags + }; + }; + BlackboxOutputArtifactTracker.prototype.findFiles = function (dir) { + var fileList = File.directoryEntries(dir, File.Files).map(function (p) { + return FileInfo.joinPaths(dir, p); }); + var dirList = File.directoryEntries(dir, File.Dirs | File.NoDotAndDotDot).map(function (p) { + return FileInfo.joinPaths(dir, p); }); + for (var i = 0; i < dirList.length; ++i) + fileList = fileList.concat(this.findFiles(dirList[i])); + return fileList; + }; + BlackboxOutputArtifactTracker.prototype.fixArtifactPaths = function (artifacts, realBasePath, fakeBasePath) { + for (var i = 0; i < artifacts.length; ++i) + artifacts[i].filePath = realBasePath + + artifacts[i].filePath.substr(fakeBasePath.length); + return artifacts; + }; + return BlackboxOutputArtifactTracker; +})(); + +function hasAnyOf(m, tokens) { + for (var i = 0; i < tokens.length; ++i) { + if (m[tokens[i]] !== undefined) + return true; + } +} + +function guessArchitecture(m) { + var architecture; + if (m) { + // based on the search algorithm from qprocessordetection.h in qtbase + var arm64Defs = ["_M_ARM64", "__aarch64__", "__ARM64__"]; + if (hasAnyOf(m, ["__arm__", "__TARGET_ARCH_ARM", "_M_ARM"].concat(arm64Defs))) { + if (hasAnyOf(m, arm64Defs)) { + architecture = "arm64"; + } else { + architecture = "arm"; + + var foundSubarch = false; + for (var i = 8; i >= 4; --i) { + var codes = ["zk", "tej", "te", "t2"].concat([].concat.apply([], + new Array(26)).map(function(_, i) { return String.fromCharCode(122 - i); })); + for (var j = 0; j < codes.length; ++j) { + if (m["__ARM_ARCH_" + i + codes[j].toUpperCase() + "__"] !== undefined) { + architecture += "v" + i + codes[j].toLowerCase(); + foundSubarch = true; + break; + } + } + + if (i === 7 && m["_ARM_ARCH_7"] !== undefined) { + architecture += "v7"; + foundSubarch = true; + } + + if (foundSubarch) + break; + } + } + } else if (hasAnyOf(m, ["__i386", "__i386__", "__386__"])) { + architecture = "x86"; + } else if (hasAnyOf(m, ["_M_IX86"])) { + var code = parseInt(m["_M_IX86"]); + architecture = (code < 300) ? "x86_16" : "x86"; + } else if (hasAnyOf(m, ["_M_I86"])) { + architecture = "x86_16"; + } else if (hasAnyOf(m, ["__x86_64", "__x86_64__", "__amd64", "_M_X64", "_M_AMD64"])) { + architecture = "x86_64"; + if (hasAnyOf(m, ["__x86_64h", "__x86_64h__"])) + architecture = "x86_64h"; + } else if (hasAnyOf(m, ["__ia64", "__ia64__", "_M_IA64"])) { + architecture = "ia64"; + } else if (hasAnyOf(m, ["__mips", "__mips__", "_M_MRX000"])) { + architecture = "mips"; + if (hasAnyOf(m, ["_MIPS_ARCH_MIPS64", "__mips64"])) + architecture += "64"; + } else if (hasAnyOf(m, ["__ppc__", "__ppc", "__powerpc__", + "_ARCH_COM", "_ARCH_PWR", "_ARCH_PPC", "_M_MPPC", "_M_PPC"])) { + architecture = "ppc"; + if (hasAnyOf(m, ["__ppc64__", "__powerpc64__", "__64BIT__"])) + architecture += "64"; + } else if (hasAnyOf(m, ["__s390__"])) { + if (hasAnyOf(m, ["__s390x__"])) + architecture = "s390x"; + } else if (hasAnyOf(m, ["__sparc__"])) { + architecture = "sparc"; + if (hasAnyOf(m, ["__sparc64__"])) + architecture += "64"; + } else if (hasAnyOf(m, ["__AVR__"])) { + architecture = "avr"; + } else if (hasAnyOf(m, ["__AVR32__"])) { + architecture = "avr32"; + } else if (hasAnyOf(m, ["__MSP430__"])) { + architecture = "msp430"; + } else if (hasAnyOf(m, ["__RL78__"])) { + architecture = "rl78"; + } else if (hasAnyOf(m, ["__RX__"])) { + architecture = "rx"; + } else if (hasAnyOf(m, ["__v850__"])) { + architecture = "v850"; + } else if (hasAnyOf(m, ["__riscv"])) { + architecture = "riscv"; + } else if (hasAnyOf(m, ["__xtensa__", "__XTENSA__"])) { + architecture = "xtensa"; + } else if (hasAnyOf(m, ["__m68k__"])) { + architecture = "m68k"; + } else if (hasAnyOf(m, ["__m32c__"])) { + architecture = "m32c"; + } else if (hasAnyOf(m, ["__m32r__", "__M32R__"])) { + architecture = "m32r"; + } else if (hasAnyOf(m, ["__sh__", "__SH__"])) { + architecture = "sh"; + } else if (hasAnyOf(m, ["__CR16__"])) { + architecture = "cr16"; + } else if (hasAnyOf(m, ["__mc68hc1x__", "__mc68hc1x"])) { + architecture = "hcs12"; + } else if (hasAnyOf(m, ["__e2k__"])) { + architecture = "e2k"; + } + } + + return Utilities.canonicalArchitecture(architecture); +} + +function guessTargetPlatform(m) { + if (m) { + if (hasAnyOf(m, ["__ANDROID__", "ANDROID"])) + return "android"; + if (hasAnyOf(m, ["__QNXNTO__"])) + return "qnx"; + if (hasAnyOf(m, ["__INTEGRITY"])) + return "integrity"; + if (hasAnyOf(m, ["__vxworks"])) + return "vxworks"; + if (hasAnyOf(m, ["__APPLE__"])) + return "darwin"; + if (hasAnyOf(m, ["WIN32", "_WIN32", "__WIN32__", "__NT__", "__WINDOWS__", "_WINDOWS"])) + return "windows"; + if (hasAnyOf(m, ["MSDOS", "__DOS__", "DOS386"])) + return "dos"; + if (hasAnyOf(m, ["__OS2__"])) + return "os2"; + if (hasAnyOf(m, ["_AIX"])) + return "aix"; + if (hasAnyOf(m, ["hpux", "__hpux"])) + return "hpux"; + if (hasAnyOf(m, ["__sun", "sun"])) + return "solaris"; + if (hasAnyOf(m, ["__linux__", "__linux", "__LINUX__"])) + return "linux"; + if (hasAnyOf(m, ["__FreeBSD__", "__DragonFly__", "__FreeBSD_kernel__"])) + return "freebsd"; + if (hasAnyOf(m, ["__NetBSD__"])) + return "netbsd"; + if (hasAnyOf(m, ["__OpenBSD__"])) + return "openbsd"; + if (hasAnyOf(m, ["__GNU__"])) + return "hurd"; + if (hasAnyOf(m, ["__HAIKU__"])) + return "haiku"; + } +} + +function toJSLiteral(v) { + if (v === undefined) + return "undefined"; + return JSON.stringify(v); +} diff --git a/share/qbs/imports/qbs/PathTools/path-tools.js b/share/qbs/imports/qbs/PathTools/path-tools.js new file mode 100644 index 00000000..a857a713 --- /dev/null +++ b/share/qbs/imports/qbs/PathTools/path-tools.js @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); + +function _bundleExecutableTemporaryFilePath(product, variantSuffix) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + return ".tmp/" + FileInfo.fileName(bundleExecutableFilePath(product, variantSuffix)); +} + +function bundleExecutableFilePath(product, variantSuffix) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + return product.moduleProperty("bundle", "executablePath") + (variantSuffix || ""); +} + +function applicationFilePath(product, variantSuffix) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + if (product.moduleProperty("bundle", "isBundle")) + return _bundleExecutableTemporaryFilePath(product, variantSuffix); + + return product.moduleProperty("cpp", "executablePrefix") + + product.targetName + (variantSuffix || "") + + product.moduleProperty("cpp", "executableSuffix"); +} + +function loadableModuleFilePath(product, variantSuffix) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + if (product.moduleProperty("bundle", "isBundle")) + return _bundleExecutableTemporaryFilePath(product, variantSuffix); + + return product.moduleProperty("cpp", "loadableModulePrefix") + + product.targetName + (variantSuffix || "") + + product.moduleProperty("cpp", "loadableModuleSuffix"); +} + +function staticLibraryFilePath(product, variantSuffix) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + if (product.moduleProperty("bundle", "isBundle")) + return _bundleExecutableTemporaryFilePath(product, variantSuffix); + + return product.moduleProperty("cpp", "staticLibraryPrefix") + + product.targetName + (variantSuffix || "") + + product.moduleProperty("cpp", "staticLibrarySuffix"); +} + +function dynamicLibraryFilePath(product, variantSuffix, version, maxParts) { + if (variantSuffix === undefined) + variantSuffix = product.cpp.variantSuffix; + if (product.moduleProperty("bundle", "isBundle")) + return _bundleExecutableTemporaryFilePath(product, variantSuffix); + + // If no override version was given, use the product's version + // We specifically want to differentiate between undefined and i.e. + // empty string as empty string should be taken to mean "no version" + // and undefined should be taken to mean "use the product's version" + // (which could still end up being "no version") + if (version === undefined) + version = product.moduleProperty("cpp", "internalVersion"); + + // If we have a version number, potentially strip off some components + if (maxParts === 0) + version = undefined; + else if (maxParts && version) + version = version.split('.').slice(0, maxParts).join('.'); + + // Start with prefix + name (i.e. libqbs, qbs) + var fileName = product.moduleProperty("cpp", "dynamicLibraryPrefix") + + product.targetName + + (variantSuffix || ""); + + // For Mach-O images, append the version number if there is one (i.e. libqbs.1.0.0) + var imageFormat = product.moduleProperty("cpp", "imageFormat"); + if (version && imageFormat === "macho") { + fileName += "." + version; + version = undefined; + } + + fileName += product.moduleProperty("cpp", "archSuffix"); + + // Append the suffix (i.e. libqbs.1.0.0.dylib, libqbs.so, qbs.dll) + fileName += product.moduleProperty("cpp", "dynamicLibrarySuffix"); + + // For ELF images, append the version number if there is one (i.e. libqbs.so.1.0.0) + if (version && imageFormat === "elf") + fileName += "." + version; + + return fileName; +} + +function linkerOutputFilePath(fileTag, product, variantSuffix, version, maxParts) { + switch (fileTag) { + case "application": + return applicationFilePath(product, variantSuffix); + case "loadablemodule": + return loadableModuleFilePath(product, variantSuffix); + case "staticlibrary": + return staticLibraryFilePath(product, variantSuffix); + case "dynamiclibrary": + return dynamicLibraryFilePath(product, variantSuffix, version, maxParts); + default: + throw new Error("Unknown linker output file tag: " + fileTag); + } +} + +function importLibraryFilePath(product) { + return product.moduleProperty("cpp", "dynamicLibraryPrefix") + + product.targetName + + (product.cpp.variantSuffix || "") + + product.moduleProperty("cpp", "dynamicLibraryImportSuffix"); +} + +function debugInfoIsBundle(product) { + if (!product.moduleProperty("qbs", "targetOS").contains("darwin")) + return false; + var flags = product.moduleProperty("cpp", "dsymutilFlags") || []; + return !flags.contains("-f") && !flags.contains("--flat"); +} + +function debugInfoFileName(product, variantSuffix, fileTag) { + var suffix = ""; + + // For dSYM bundles, the DWARF debug info file has no suffix + if (!product.moduleProperty("qbs", "targetOS").contains("darwin") + || !debugInfoIsBundle(product)) + suffix = product.moduleProperty("cpp", "debugInfoSuffix"); + + if (product.moduleProperty("bundle", "isBundle")) { + return FileInfo.fileName(bundleExecutableFilePath(product, variantSuffix)) + suffix; + } else { + switch (fileTag) { + case "application": + return applicationFilePath(product, variantSuffix) + suffix; + case "dynamiclibrary": + return dynamicLibraryFilePath(product, variantSuffix) + suffix; + case "loadablemodule": + return loadableModuleFilePath(product, variantSuffix) + suffix; + case "staticlibrary": + return staticLibraryFilePath(product, variantSuffix) + suffix; + default: + return product.targetName + (variantSuffix || "") + suffix; + } + } +} + +function debugInfoBundlePath(product, fileTag) { + if (!debugInfoIsBundle(product)) + return undefined; + var suffix = product.moduleProperty("cpp", "debugInfoBundleSuffix"); + if (product.moduleProperty("qbs", "targetOS").contains("darwin") + && product.moduleProperty("bundle", "isBundle")) + return product.moduleProperty("bundle", "bundleName") + suffix; + return debugInfoFileName(product, undefined, fileTag) + suffix; +} + +function debugInfoFilePath(product, variantSuffix, fileTag) { + var name = debugInfoFileName(product, variantSuffix, fileTag); + if (product.moduleProperty("qbs", "targetOS").contains("darwin") && debugInfoIsBundle(product)) { + return FileInfo.joinPaths(debugInfoBundlePath(product, fileTag), + "Contents", "Resources", "DWARF", name); + } else if (product.moduleProperty("bundle", "isBundle")) { + return FileInfo.joinPaths(product.moduleProperty("bundle", "executableFolderPath"), name); + } + + return name; +} + +function debugInfoPlistFilePath(product, fileTag) { + if (!debugInfoIsBundle(product)) + return undefined; + return FileInfo.joinPaths(debugInfoBundlePath(product, fileTag), "Contents", "Info.plist"); +} + +// Returns whether the string looks like a library filename +function isLibraryFileName(product, fileName, prefix, suffixes, isShared) { + var suffix, i; + var os = product.moduleProperty("qbs", "targetOS"); + for (i = 0; i < suffixes.length; ++i) { + suffix = suffixes[i]; + if (isShared && os.contains("unix") && !os.contains("darwin")) + suffix += "(\\.[0-9]+){0,3}"; + if (fileName.match("^" + prefix + ".+?\\" + suffix + "$")) + return true; + } + return false; +} + +function frameworkExecutablePath(frameworkPath) { + var suffix = ".framework"; + var isAbsoluteFrameworkPath = frameworkPath.slice(-suffix.length) === suffix; + if (isAbsoluteFrameworkPath) { + var frameworkName = FileInfo.fileName(frameworkPath).slice(0, -suffix.length); + return FileInfo.joinPaths(frameworkPath, frameworkName); + } + return undefined; +} + +// pathList is also a string, using the respective separator +function prependOrSetPath(path, pathList, separator) { + if (!pathList || pathList.length === 0) + return path; + return path + separator + pathList; +} diff --git a/share/qbs/imports/qbs/Probes/AndroidNdkProbe.qbs b/share/qbs/imports/qbs/Probes/AndroidNdkProbe.qbs new file mode 100644 index 00000000..e50d4251 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/AndroidNdkProbe.qbs @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.TextFile +import "../../../modules/Android/android-utils.js" as AndroidUtils + +PathProbe { + // Inputs + property path sdkPath + + environmentPaths: Environment.getEnv("ANDROID_NDK_ROOT") + platformSearchPaths: { + var paths = []; + if (sdkPath) + paths.push(FileInfo.joinPaths(sdkPath, "ndk-bundle")); + if (Host.os().contains("windows")) + paths.push(FileInfo.joinPaths(Environment.getEnv("LOCALAPPDATA"), + "Android", "sdk", "ndk-bundle")); + if (Host.os().contains("macos")) + paths.push(FileInfo.joinPaths(Environment.getEnv("HOME"), + "Library", "Android", "sdk", "ndk-bundle")); + if (Host.os().contains("linux")) + paths.push(FileInfo.joinPaths(Environment.getEnv("HOME"), + "Android", "Sdk", "ndk-bundle")); + return paths; + } + + // Outputs + property stringList candidatePaths + property string samplesDir + property var hostArch + property stringList toolchains: [] + property string ndkVersion + + configure: { + function readFileContent(filePath) { + var result = null; + if (!File.exists(filePath)) + return result; + try { + var tf = new TextFile(filePath, TextFile.ReadOnly); + result = tf.readAll(); + } finally { + if (tf) + tf.close(); + } + return result; + } + + var i, j, allPaths = (environmentPaths || []).concat(platformSearchPaths || []); + candidatePaths = allPaths; + for (i in allPaths) { + var platforms = []; + if (Host.os().contains("windows")) + platforms.push("windows-x86_64", "windows"); + if (Host.os().contains("darwin")) + platforms.push("darwin-x86_64", "darwin-x86"); + if (Host.os().contains("linux")) + platforms.push("linux-x86_64", "linux-x86"); + for (j in platforms) { + if (File.exists(FileInfo.joinPaths(allPaths[i], "prebuilt", platforms[j]))) { + path = allPaths[i]; + if (File.exists(FileInfo.joinPaths(path, "samples"))) + samplesDir = FileInfo.joinPaths(path, "samples"); // removed in r11 + hostArch = platforms[j]; + toolchains = File.directoryEntries(FileInfo.joinPaths(path, "toolchains"), + File.Dirs | File.NoDotAndDotDot); + + // NDK r11 and above + var content = readFileContent(path + "/source.properties"); + if (content) { + var lines = content.trim().split(/\r?\n/g).filter(function (line) { + return line.length > 0; + }); + for (var l = 0; l < lines.length; ++l) { + var m = lines[l].match(/^Pkg\.Revision\s*=\s*([0-9\.]+)$/); + if (m) { + ndkVersion = m[1]; + found = true; + return; + } + } + } + + // NDK r10 and below + var releaseTextFileCandidates = ["RELEASE.txt", "RELEASE.TXT"] + .map(function(v) { return FileInfo.joinPaths(path, v); }) + .filter(File.exists); + content = releaseTextFileCandidates.length + ? readFileContent(releaseTextFileCandidates[0]) : null; + if (content) { + var m = content.trim().match(/^r([0-9]+[a-z]?).*/); + if (m) { + ndkVersion = m[1]; + found = true; + return; + } + } + } + } + } + } +} diff --git a/share/qbs/imports/qbs/Probes/AndroidSdkProbe.qbs b/share/qbs/imports/qbs/Probes/AndroidSdkProbe.qbs new file mode 100644 index 00000000..5b777d3e --- /dev/null +++ b/share/qbs/imports/qbs/Probes/AndroidSdkProbe.qbs @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import "../../../modules/Android/sdk/utils.js" as SdkUtils +import "../../../modules/Android/android-utils.js" as AndroidUtils + +PathProbe { + environmentPaths: Environment.getEnv("ANDROID_HOME") + platformSearchPaths: { + if (Host.os().contains("windows")) + return [FileInfo.joinPaths(Environment.getEnv("LOCALAPPDATA"), "Android", "sdk")]; + if (Host.os().contains("macos")) + return [FileInfo.joinPaths(Environment.getEnv("HOME"), "Library", "Android", "sdk")]; + if (Host.os().contains("linux")) + return [FileInfo.joinPaths(Environment.getEnv("HOME"), "Android", "Sdk")]; + } + + // Outputs + property stringList candidatePaths + property var buildToolsVersions + property string buildToolsVersion + property var platforms + property string platform + + configure: { + var i, allPaths = (environmentPaths || []).concat(platformSearchPaths || []); + candidatePaths = allPaths; + for (i in allPaths) { + if (File.exists(FileInfo.joinPaths(allPaths[i], "build-tools"))) { + path = allPaths[i]; + buildToolsVersions = SdkUtils.availableBuildToolsVersions(path) + buildToolsVersion = buildToolsVersions[buildToolsVersions.length - 1]; + platforms = AndroidUtils.availablePlatforms(path) + platform = platforms[platforms.length - 1]; + found = true; + return; + } + } + } +} diff --git a/share/qbs/imports/qbs/Probes/BinaryProbe.qbs b/share/qbs/imports/qbs/Probes/BinaryProbe.qbs new file mode 100644 index 00000000..52b78df0 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/BinaryProbe.qbs @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Host + +PathProbe { + nameSuffixes: Host.os().contains("windows") ? [".com", ".exe", ".bat", ".cmd"] : undefined + platformSearchPaths: Host.os().contains("unix") ? ["/usr/bin", "/usr/local/bin"] : [] + platformEnvironmentPaths: [ "PATH" ] +} diff --git a/share/qbs/imports/qbs/Probes/ClBinaryProbe.qbs b/share/qbs/imports/qbs/Probes/ClBinaryProbe.qbs new file mode 100644 index 00000000..3b395901 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/ClBinaryProbe.qbs @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.ModUtils +import qbs.Utilities +import "path-probe.js" as PathProbeConfigure + +BinaryProbe { + // input + property string preferredArchitecture + + configure: { + var _selectors; + var results = PathProbeConfigure.configure(_selectors, names, nameSuffixes, nameFilter, + candidateFilter, searchPaths, pathSuffixes, + platformSearchPaths, environmentPaths, + platformEnvironmentPaths); + if (!results.found) { + var msvcs = Utilities.installedMSVCs(preferredArchitecture); + if (msvcs.length >= 1) { + var result = {}; + result.fileName = "cl.exe"; + result.path = msvcs[0].binPath; + result.filePath = FileInfo.joinPaths(path, fileName); + result.candidatePaths = result.filePath; + results.found = true; + results.files = [result]; + } + } + + found = results.found; + allResults = results.files; + + if (allResults.length === 1) { + var result = allResults[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + } + + } +} diff --git a/share/qbs/imports/qbs/Probes/ClangClBinaryProbe.qbs b/share/qbs/imports/qbs/Probes/ClangClBinaryProbe.qbs new file mode 100644 index 00000000..8dc01d37 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/ClangClBinaryProbe.qbs @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.ModUtils +import qbs.Utilities +import "path-probe.js" as PathProbeConfigure + +BinaryProbe { + // output + property string vcvarsallPath + + configure: { + var _selectors; + var results = PathProbeConfigure.configure(_selectors, names, nameSuffixes, nameFilter, + candidateFilter, searchPaths, pathSuffixes, + platformSearchPaths, environmentPaths, + platformEnvironmentPaths); + var compilerPath; + if (results.found) + compilerPath = results.files[0].filePath; + var compilers = Utilities.installedClangCls(compilerPath); + if (compilers.length >= 1) { + var result = {}; + result.fileName = "clang-cl.exe"; + result.path = compilers[0].toolchainInstallPath; + result.filePath = FileInfo.joinPaths(result.path, result.fileName); + result.candidatePaths = result.filePath; + result.vcvarsallPath = compilers[0].vcvarsallPath; + results.found = true; + results.files = [result]; + } + + found = results.found; + allResults = results.files; + + if (allResults.length === 1) { + var result = allResults[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + vcvarsallPath = result.vcvarsallPath; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/ClangClProbe.qbs b/share/qbs/imports/qbs/Probes/ClangClProbe.qbs new file mode 100644 index 00000000..f0d930be --- /dev/null +++ b/share/qbs/imports/qbs/Probes/ClangClProbe.qbs @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Utilities +import "../../../modules/cpp/gcc.js" as Gcc + +PathProbe { + // Inputs + property string compilerFilePath + property string vcvarsallFilePath + property stringList enableDefinesByLanguage + property string preferredArchitecture + property string winSdkVersion + + // Outputs + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property string architecture + property var buildEnv + property var compilerDefinesByLanguage + + configure: { + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + var info = languages.contains("c") + ? Utilities.clangClCompilerInfo( + compilerFilePath, + preferredArchitecture, + vcvarsallFilePath, + "c", + winSdkVersion) + : {}; + var infoCpp = languages.contains("cpp") + ? Utilities.clangClCompilerInfo( + compilerFilePath, + preferredArchitecture, + vcvarsallFilePath, + "cpp", + winSdkVersion) + : {}; + found = (!languages.contains("c") || + (!!info && !!info.macros && !!info.buildEnvironment)) + && (!languages.contains("cpp") || + (!!infoCpp && !!infoCpp.macros && !!infoCpp.buildEnvironment)); + + compilerDefinesByLanguage = { + "c": info.macros, + "cpp": infoCpp.macros, + }; + + var macros = info.macros || infoCpp.macros; + + versionMajor = parseInt(macros["__clang_major__"], 10); + versionMinor = parseInt(macros["__clang_minor__"], 10); + versionPatch = parseInt(macros["__clang_patchlevel__"], 10); + + buildEnv = info.buildEnvironment || infoCpp.buildEnvironment; + // clang-cl is just a wrapper around clang.exe, so the includes *should be* the same + var clangPath = FileInfo.joinPaths(FileInfo.path(compilerFilePath), "clang.exe"); + + var defaultPaths = Gcc.dumpDefaultPaths(buildEnv, clangPath, + [], Host.nullDevice(), + FileInfo.pathListSeparator(), "", ""); + includePaths = defaultPaths.includePaths; + architecture = ModUtils.guessArchitecture(macros); + } +} diff --git a/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs b/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs new file mode 100644 index 00000000..32fbcace --- /dev/null +++ b/share/qbs/imports/qbs/Probes/ConanfileProbe.qbs @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Richard Weickelt +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Process +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.TextFile +import qbs.Utilities + +Probe { + // Inputs + property stringList additionalArguments: [] + property path conanfilePath + property path packageReference + property path executable: "conan" + (Host.os().contains("windows") ? ".exe": "") + property stringList generators: ["json"] + property var options + property var settings + property bool verbose: false + + // Output + property var dependencies + property path generatedFilesPath + property var json + + // Internal + // Ensure that the probe is re-run automatically whenever conanfile changes + // by making a file system property part of the probe's signature. + property int _conanfileLastModified: conanfilePath ? File.lastModified(conanfilePath) : 0 + property path _projectBuildDirectory: project.buildDirectory + + configure: { + if (conanfilePath && packageReference) + throw("conanfilePath and packageReference must not be defined at the same time."); + + if (!conanfilePath && !packageReference) + throw("Either conanfilePath or packageReference must be defined."); + + var reference = packageReference || FileInfo.cleanPath(conanfilePath); + console.info("Probing '" + reference + "'. This might take a while..."); + if (conanfilePath && !File.exists(reference)) + throw("The conanfile '" + reference + "' does not exist."); + + var args = [ + "install", reference, + ]; + + if (options) { + if (typeof options !== "object") + throw("The property 'options' must be an object."); + Object.keys(options).forEach(function(key,index) { + args.push("-o"); + args.push(key + "=" + options[key]); + }); + } + + if (settings) { + if (typeof settings !== "object") + throw("The property 'settings' must be an object."); + Object.keys(settings).forEach(function(key,index) { + args.push("-s"); + args.push(key + "=" + settings[key]); + }); + } + + if (!generators.contains("json")) + generators.push("json"); + + for (var i = 0; i < generators.length; i++) + args = args.concat(["-g", generators[i]]); + + for (var i = 0; i < additionalArguments.length; i++) + args.push(additionalArguments[i]); + + generatedFilesPath = FileInfo.cleanPath(_projectBuildDirectory + + "/genconan/" + + Utilities.getHash(args.join())); + + args = args.concat(["-if", generatedFilesPath]); + var p = new Process(); + p.start(executable, args); + while (!p.waitForFinished(500)) { + const output = p.readStdOut(); + if (verbose && output) { + console.info(output); + } + } + while (!p.atEnd()) { + const output = p.readStdOut(); + if (verbose && output) { + console.info(output); + } + } + if (p.exitCode()) { + const errorOutput = p.readStdErr(); + p.close(); + throw errorOutput; + } + p.close(); + + if (generators.contains("json")) { + if (!File.exists(generatedFilesPath + "/conanbuildinfo.json")) + throw("No conanbuildinfo.json has been generated."); + + var jsonFile = new TextFile(generatedFilesPath + "/conanbuildinfo.json", TextFile.ReadOnly); + json = JSON.parse(jsonFile.readAll()); + jsonFile.close(); + + dependencies = {}; + for (var i = 0; i < json.dependencies.length; ++i) { + var dep = json.dependencies[i]; + dependencies[dep.name] = dep; + } + } + + found = true; + } +} diff --git a/share/qbs/imports/qbs/Probes/CosmicProbe.qbs b/share/qbs/imports/qbs/Probes/CosmicProbe.qbs new file mode 100644 index 00000000..7de781e6 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/CosmicProbe.qbs @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import "../../../modules/cpp/cosmic.js" as COSMIC + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + + // Outputs + property string architecture + property string endianness + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + // COSMIC compiler support only the C-language. + if (!languages.contains("c")) { + found = false; + return; + } + + var macros = COSMIC.dumpMacros(compilerFilePath); + if (!macros) { + found = false; + return; + } + + compilerDefinesByLanguage["c"] = macros; + + architecture = COSMIC.guessArchitecture(compilerFilePath); + endianness = COSMIC.guessEndianness(architecture); + var defaultPaths = COSMIC.dumpDefaultPaths(compilerFilePath, architecture); + includePaths = defaultPaths.includePaths; + + var version = COSMIC.dumpVersion(compilerFilePath); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture && !!endianness; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/DmcProbe.qbs b/share/qbs/imports/qbs/Probes/DmcProbe.qbs new file mode 100644 index 00000000..6a8723a3 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/DmcProbe.qbs @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.ModUtils +import "../../../modules/cpp/dmc.js" as DMC + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + + property string _targetPlatform + property string _targetArchitecture + property string _targetExtender // Only for DOS 16/32 bit. + + // Outputs + property string architecture + property string targetPlatform + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + var defaultPathsByLanguage = {}; + for (var i = 0; i < languages.length; ++i) { + var tag = languages[i]; + compilerDefinesByLanguage[tag] = DMC.dumpMacros( + compilerFilePath, + _targetPlatform, + _targetArchitecture, + _targetExtender, + tag); + var paths = DMC.dumpDefaultPaths(compilerFilePath, tag); + defaultPathsByLanguage[tag] = paths; + } + + var macros = compilerDefinesByLanguage["c"] + || compilerDefinesByLanguage["cpp"]; + + architecture = ModUtils.guessArchitecture(macros); + targetPlatform = ModUtils.guessTargetPlatform(macros); + + var defaultPaths = defaultPathsByLanguage["cpp"] + || defaultPathsByLanguage["c"]; + + includePaths = defaultPaths.includePaths; + + var version = DMC.guessVersion(macros); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/FrameworkProbe.qbs b/share/qbs/imports/qbs/Probes/FrameworkProbe.qbs new file mode 100644 index 00000000..c3d98a49 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/FrameworkProbe.qbs @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +PathProbe { + platformSearchPaths: (qbs.sysroot ? [qbs.sysroot + "/System/Library/Frameworks"] : []).concat([ + "~/Library/Frameworks", + "/usr/local/lib", + "/Library/Frameworks", + "/System/Library/Frameworks" + ]) + nameSuffixes: ".framework" +} diff --git a/share/qbs/imports/qbs/Probes/GccBinaryProbe.qbs b/share/qbs/imports/qbs/Probes/GccBinaryProbe.qbs new file mode 100644 index 00000000..0872e6cc --- /dev/null +++ b/share/qbs/imports/qbs/Probes/GccBinaryProbe.qbs @@ -0,0 +1,78 @@ +import qbs.Environment +import qbs.FileInfo +import qbs.Host +import "path-probe.js" as PathProbeConfigure + +BinaryProbe { + nameSuffixes: undefined // _compilerName already contains ".exe" suffix on Windows + // Inputs + property string _compilerName + property string _toolchainPrefix + + // Outputs + property string tcPrefix + + platformSearchPaths: { + var paths = base; + if (qbs.targetOS.contains("windows") && Host.os().contains("windows")) + paths.push(FileInfo.joinPaths( + Environment.getEnv("SystemDrive"), "MinGW", "bin")); + return paths; + } + + names: { + var prefixes = []; + if (_toolchainPrefix) { + prefixes.push(_toolchainPrefix); + } else { + var arch = qbs.architecture; + if (qbs.targetOS.contains("windows")) { + if (!arch || arch === "x86") { + prefixes.push("mingw32-", + "i686-w64-mingw32-", + "i686-w64-mingw32.shared-", + "i686-w64-mingw32.static-", + "i686-mingw32-", + "i586-mingw32msvc-"); + } + if (!arch || arch === "x86_64") { + prefixes.push("x86_64-w64-mingw32-", + "x86_64-w64-mingw32.shared-", + "x86_64-w64-mingw32.static-", + "amd64-mingw32msvc-"); + } + } + } + return prefixes.map(function(prefix) { + return prefix + _compilerName; + }).concat([_compilerName]); + } + + configure: { + var selectors; + var results = PathProbeConfigure.configure( + selectors, names, nameSuffixes, nameFilter, candidateFilter, searchPaths, + pathSuffixes, platformSearchPaths, environmentPaths, platformEnvironmentPaths); + + found = results.found; + if (!found) + return; + + var resultsMapper = function(result) { + (nameSuffixes || [""]).forEach(function(suffix) { + var end = _compilerName + suffix; + if (result.fileName.endsWith(end)) + result.tcPrefix = result.fileName.slice(0, -end.length); + }); + return result; + }; + results.files = results.files.map(resultsMapper); + allResults = results.files; + var result = results.files[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + tcPrefix = result.tcPrefix; + } +} diff --git a/share/qbs/imports/qbs/Probes/GccProbe.qbs b/share/qbs/imports/qbs/Probes/GccProbe.qbs new file mode 100644 index 00000000..5c6dc193 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/GccProbe.qbs @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import "../../../modules/cpp/gcc.js" as Gcc + +PathProbe { + // Inputs + property var compilerFilePathByLanguage + property stringList enableDefinesByLanguage + property stringList flags: [] + property var environment + + property string _sysroot: qbs.sysroot + property stringList _targetOS: qbs.targetOS + + // Outputs + property string architecture + property string endianness + property string targetPlatform + property stringList includePaths + property stringList libraryPaths + property stringList frameworkPaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + for (var i = 0; i < languages.length; ++i) { + var fp = compilerFilePathByLanguage[languages[i]]; + if (fp && File.exists(fp)) { + try { + compilerDefinesByLanguage[languages[i]] = Gcc.dumpMacros(environment, fp, + flags, + Host.nullDevice(), + languages[i]); + } catch (e) { + // Only throw errors when determining the compiler defines for the C language; + // for other languages we presume it is an indication that the language is not + // installed (as is typically the case for Objective-C/C++ on non-Apple systems) + if (languages[i] === "c") + throw e; + } + } else if (languages[i] === "c") { + found = false; + return; + } + } + + var macros = compilerDefinesByLanguage["c"] + || compilerDefinesByLanguage["cpp"] + || compilerDefinesByLanguage["objc"] + || compilerDefinesByLanguage["objcpp"]; + var defaultPaths = Gcc.dumpDefaultPaths(environment, compilerFilePathByLanguage["cpp"] || + compilerFilePathByLanguage["c"], + flags, Host.nullDevice(), + FileInfo.pathListSeparator(), _sysroot, _targetOS); + found = !!macros && !!defaultPaths; + + includePaths = defaultPaths.includePaths; + libraryPaths = defaultPaths.libraryPaths; + frameworkPaths = defaultPaths.frameworkPaths; + + // We have to dump the compiler's macros; -dumpmachine is not suitable because it is not + // always complete (for example, the subarch is not included for arm architectures). + architecture = ModUtils.guessArchitecture(macros); + targetPlatform = ModUtils.guessTargetPlatform(macros); + + switch (macros["__BYTE_ORDER__"]) { + case "__ORDER_BIG_ENDIAN__": + endianness = "big"; + break; + case "__ORDER_LITTLE_ENDIAN__": + endianness = "little"; + break; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/GccVersionProbe.qbs b/share/qbs/imports/qbs/Probes/GccVersionProbe.qbs new file mode 100644 index 00000000..49783547 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/GccVersionProbe.qbs @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.Host +import "../../../modules/cpp/gcc.js" as Gcc + +PathProbe { + // Inputs + property string compilerFilePath + property var environment + + property stringList _toolchain: qbs.toolchain + + // Outputs + property int versionMajor + property int versionMinor + property int versionPatch + + configure: { + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var macros = Gcc.dumpMacros(environment, compilerFilePath, undefined, Host.nullDevice()); + + if (_toolchain.contains("clang")) { + versionMajor = parseInt(macros["__clang_major__"], 10); + versionMinor = parseInt(macros["__clang_minor__"], 10); + versionPatch = parseInt(macros["__clang_patchlevel__"], 10); + found = true; + } else { + versionMajor = parseInt(macros["__GNUC__"], 10); + versionMinor = parseInt(macros["__GNUC_MINOR__"], 10); + versionPatch = parseInt(macros["__GNUC_PATCHLEVEL__"], 10); + found = true; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/IarProbe.qbs b/share/qbs/imports/qbs/Probes/IarProbe.qbs new file mode 100644 index 00000000..a0008be4 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/IarProbe.qbs @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import "../../../modules/cpp/iar.js" as IAR + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + + // Outputs + property string architecture + property string endianness + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + var defaultPathsByLanguage = {}; + for (var i = 0; i < languages.length; ++i) { + var tag = languages[i]; + compilerDefinesByLanguage[tag] = IAR.dumpMacros( + compilerFilePath, tag); + var paths = IAR.dumpDefaultPaths(compilerFilePath, tag); + defaultPathsByLanguage[tag] = paths; + } + + var macros = compilerDefinesByLanguage["c"] + || compilerDefinesByLanguage["cpp"]; + + architecture = IAR.guessArchitecture(macros); + endianness = IAR.guessEndianness(macros); + + var defaultPaths = defaultPathsByLanguage["cpp"] + || defaultPathsByLanguage["c"]; + + includePaths = defaultPaths.includePaths; + + var version = IAR.guessVersion(macros, architecture); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture && !!endianness; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/IcoUtilsVersionProbe.qbs b/share/qbs/imports/qbs/Probes/IcoUtilsVersionProbe.qbs new file mode 100644 index 00000000..90c3a06b --- /dev/null +++ b/share/qbs/imports/qbs/Probes/IcoUtilsVersionProbe.qbs @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import "../../../modules/ico/ico.js" as IcoUtils + +Probe { + // Inputs + property string toolFilePath + + // Outputs + property var version + + configure: { + version = IcoUtils.findIcoUtilsVersion(toolFilePath); + found = !!version; + } +} diff --git a/share/qbs/imports/qbs/Probes/IncludeProbe.qbs b/share/qbs/imports/qbs/Probes/IncludeProbe.qbs new file mode 100644 index 00000000..6201cbc5 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/IncludeProbe.qbs @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +PathProbe { + platformSearchPaths: qbs.targetOS.contains("unix") ? [ + "/usr/include", + "/usr/local/include", + "/include", + "/app/include", + ] : [] + platformEnvironmentPaths: { + if (qbs.toolchain.contains('msvc')) + return [ "INCLUDE" ]; + return undefined; + } +} diff --git a/share/qbs/imports/qbs/Probes/InnoSetupProbe.qbs b/share/qbs/imports/qbs/Probes/InnoSetupProbe.qbs new file mode 100644 index 00000000..87475cb5 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/InnoSetupProbe.qbs @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Utilities + +PathProbe { + // Outputs + property var version + + configure: { + var keys = [ + "HKEY_LOCAL_MACHINE\\SOFTWARE\\", + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\" + ]; + var keySuffixes = [ + "Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 5_is1", + "Microsoft\\Windows\\CurrentVersion\\Uninstall\\Inno Setup 6_is1" + ]; + for (var i = 0; i < keys.length; ++i) { + for (var j = 0; j < keySuffixes.length; ++j) { + var key = keys[i] + keySuffixes[j]; + + var v = Utilities.getNativeSetting(key, "DisplayVersion"); + if (v) { + path = Utilities.getNativeSetting(key, "InstallLocation"); + version = v; + found = path && version; + return; + } + } + } + } +} diff --git a/share/qbs/imports/qbs/Probes/JdkProbe.qbs b/share/qbs/imports/qbs/Probes/JdkProbe.qbs new file mode 100644 index 00000000..efb5a533 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/JdkProbe.qbs @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.Host +import "../../../modules/java/utils.js" as JavaUtils + +PathProbe { + // Inputs + property string architecture: !_androidCrossCompiling ? qbs.architecture : undefined + property bool _androidCrossCompiling: qbs.targetOS.contains("android") + && !Host.os().contains("android") + + environmentPaths: Environment.getEnv("JAVA_HOME") + platformSearchPaths: [ + "/usr/lib/jvm/default-java", // Debian/Ubuntu + "/etc/alternatives/java_sdk_openjdk", // Fedora + "/usr/lib/jvm/default" // Arch + ] + + configure: { + path = JavaUtils.findJdkPath(Host.os(), architecture, environmentPaths, + platformSearchPaths); + found = !!path; + } +} diff --git a/share/qbs/imports/qbs/Probes/JdkVersionProbe.qbs b/share/qbs/imports/qbs/Probes/JdkVersionProbe.qbs new file mode 100644 index 00000000..786d62f7 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/JdkVersionProbe.qbs @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import "../../../modules/java/utils.js" as JavaUtils + +Probe { + // Inputs + property string javac + + // Outputs + property var version + + configure: { + version = JavaUtils.findJdkVersion(javac); + found = !!version; + } +} diff --git a/share/qbs/imports/qbs/Probes/KeilProbe.qbs b/share/qbs/imports/qbs/Probes/KeilProbe.qbs new file mode 100644 index 00000000..b123584a --- /dev/null +++ b/share/qbs/imports/qbs/Probes/KeilProbe.qbs @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.Host +import "../../../modules/cpp/keil.js" as KEIL + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + + // Outputs + property string architecture + property string endianness + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + for (var i = 0; i < languages.length; ++i) { + var tag = languages[i]; + compilerDefinesByLanguage[tag] = KEIL.dumpMacros( + compilerFilePath, tag, Host.nullDevice()); + } + + var macros = compilerDefinesByLanguage["c"] + || compilerDefinesByLanguage["cpp"]; + + architecture = KEIL.guessArchitecture(macros); + endianness = KEIL.guessEndianness(macros); + + var defaultPaths = KEIL.dumpDefaultPaths( + compilerFilePath, Host.nullDevice()); + + includePaths = defaultPaths.includePaths; + + var version = KEIL.guessVersion(macros); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture && !!endianness; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/LibraryProbe.qbs b/share/qbs/imports/qbs/Probes/LibraryProbe.qbs new file mode 100644 index 00000000..7631eb44 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/LibraryProbe.qbs @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +PathProbe { + property string endianness + nameSuffixes: { + if (qbs.targetOS.contains("windows")) + return [".lib"]; + if (qbs.targetOS.contains("macos")) + return [".dylib", ".a"]; + return [".so", ".a"]; + } + platformSearchPaths: { + var result = []; + if (qbs.targetOS.contains("unix")) { + if (qbs.targetOS.contains("linux") && qbs.architecture) { + if (qbs.architecture === "armv7") + result = ["/usr/lib/arm-linux-gnueabihf"] + else if (qbs.architecture === "arm64") + result = ["/usr/lib/aarch64-linux-gnu"] + else if (qbs.architecture === "mips" && endianness === "big") + result = ["/usr/lib/mips-linux-gnu"] + else if (qbs.architecture === "mips" && endianness === "little") + result = ["/usr/lib/mipsel-linux-gnu"] + else if (qbs.architecture === "mips64") + result = ["/usr/lib/mips64el-linux-gnuabi64"] + else if (qbs.architecture === "ppc") + result = ["/usr/lib/powerpc-linux-gnu"] + else if (qbs.architecture === "ppc64") + result = ["/usr/lib/powerpc64le-linux-gnu"] + else if (qbs.architecture === "x86_64") + result = ["/usr/lib64", "/usr/lib/x86_64-linux-gnu"] + else if (qbs.architecture === "x86") + result = ["/usr/lib32", "/usr/lib/i386-linux-gnu"] + } + result = result.concat(["/usr/lib", "/usr/local/lib", "/lib", "/app/lib"]); + } + + return result; + } + nameFilter: { + if (qbs.targetOS.contains("unix")) { + return function(name) { + return "lib" + name; + } + } else { + return function(name) { + return name; + } + } + } + platformEnvironmentPaths: { + if (qbs.targetOS.contains("windows")) + return [ "PATH" ]; + else + return [ "LIBRARY_PATH" ]; + } +} diff --git a/share/qbs/imports/qbs/Probes/MsvcProbe.qbs b/share/qbs/imports/qbs/Probes/MsvcProbe.qbs new file mode 100644 index 00000000..d3624e01 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/MsvcProbe.qbs @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Utilities + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + property string preferredArchitecture + property string winSdkVersion + + // Outputs + property string architecture + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var buildEnv + property var compilerDefinesByLanguage + + configure: { + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + var info = languages.contains("c") + ? Utilities.msvcCompilerInfo(compilerFilePath, "c", winSdkVersion) : {}; + var infoCpp = languages.contains("cpp") + ? Utilities.msvcCompilerInfo(compilerFilePath, "cpp", winSdkVersion) : {}; + found = (!languages.contains("c") || + (!!info && !!info.macros && !!info.buildEnvironment)) + && (!languages.contains("cpp") || + (!!infoCpp && !!infoCpp.macros && !!infoCpp.buildEnvironment)); + + compilerDefinesByLanguage = { + "c": info.macros, + "cpp": infoCpp.macros, + }; + + var macros = info.macros || infoCpp.macros; + architecture = ModUtils.guessArchitecture(macros); + + var ver = macros["_MSC_FULL_VER"]; + + versionMajor = parseInt(ver.substr(0, 2), 10); + versionMinor = parseInt(ver.substr(2, 2), 10); + versionPatch = parseInt(ver.substr(4), 10); + + buildEnv = info.buildEnvironment || infoCpp.buildEnvironment; + var clParentDir = FileInfo.joinPaths(FileInfo.path(compilerFilePath), ".."); + var inclPath = FileInfo.joinPaths(clParentDir, "INCLUDE"); + if (!File.exists(inclPath)) + inclPath = FileInfo.joinPaths(clParentDir, "..", "INCLUDE"); + if (!File.exists(inclPath)) + inclPath = FileInfo.joinPaths(clParentDir, "..", "..", "INCLUDE"); + if (File.exists(inclPath)) + includePaths = [inclPath]; + + if (preferredArchitecture && Utilities.canonicalArchitecture(preferredArchitecture) + !== Utilities.canonicalArchitecture(architecture)) { + throw "'" + preferredArchitecture + + "' differs from the architecture produced by this compiler (" + + architecture + ")"; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/NodeJsProbe.qbs b/share/qbs/imports/qbs/Probes/NodeJsProbe.qbs new file mode 100644 index 00000000..520e57f5 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/NodeJsProbe.qbs @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.FileInfo +import qbs.Host + +BinaryProbe { + names: ["node", "nodejs"] + platformSearchPaths: { + var paths = base; + if (Host.os().contains("windows")) { + var env32 = Environment.getEnv("PROGRAMFILES(X86)"); + var env64 = Environment.getEnv("PROGRAMFILES"); + if (env64 === env32 && env64.endsWith(" (x86)")) + env64 = env64.slice(0, -(" (x86)".length)); // QTBUG-3845 + paths.push(FileInfo.joinPaths(env64, "nodejs")); + paths.push(FileInfo.joinPaths(env32, "nodejs")); + } + return paths; + } +} diff --git a/share/qbs/imports/qbs/Probes/NpmProbe.qbs b/share/qbs/imports/qbs/Probes/NpmProbe.qbs new file mode 100644 index 00000000..08490065 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/NpmProbe.qbs @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import "path-probe.js" as PathProbeConfigure +import "../../../modules/nodejs/nodejs.js" as NodeJs + +NodeJsProbe { + names: ["npm"] + + // Inputs + property string interpreterPath + + // Outputs + property path npmBin + property path npmRoot + property path npmPrefix + + configure: { + if (!interpreterPath) + throw '"interpreterPath" must be specified'; + + var selectors; + var results = PathProbeConfigure.configure( + selectors, names, nameSuffixes, nameFilter, candidateFilter, searchPaths, + pathSuffixes, platformSearchPaths, environmentPaths, platformEnvironmentPaths); + + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), + Host.os().contains("windows")); + v.prepend(interpreterPath); + + var resultsMapper = function(result) { + result.npmBin = result.found + ? NodeJs.findLocation(result.filePath, "bin", v.value) + : undefined; + result.npmRoot = result.found + ? NodeJs.findLocation(result.filePath, "root", v.value) + : undefined; + result.npmPrefix = result.found + ? NodeJs.findLocation(result.filePath, "prefix", v.value) + : undefined; + return result; + }; + results.files = results.files.map(resultsMapper); + + found = results.found; + allResults = results.files; + + var result = results.files[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + npmBin = result.npmBin; + npmRoot = result.npmRoot; + npmPrefix = result.npmPrefix; + } +} diff --git a/share/qbs/imports/qbs/Probes/PathProbe.qbs b/share/qbs/imports/qbs/Probes/PathProbe.qbs new file mode 100644 index 00000000..dc3b32ab --- /dev/null +++ b/share/qbs/imports/qbs/Probes/PathProbe.qbs @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import "path-probe.js" as PathProbeConfigure +import qbs.Host +import qbs.ModUtils + +Probe { + // Inputs + property stringList names + property stringList nameSuffixes + property var nameFilter + property var candidateFilter + property varList selectors + property pathList searchPaths + property stringList pathSuffixes + property pathList platformSearchPaths: Host.os().contains("unix") ? ['/usr', '/usr/local'] : [] + property stringList environmentPaths + property stringList platformEnvironmentPaths + + // Output + property stringList candidatePaths + property string path + property string filePath + property string fileName + + property varList allResults + + configure: { + var results = PathProbeConfigure.configure(selectors, names, nameSuffixes, nameFilter, + candidateFilter, searchPaths, pathSuffixes, + platformSearchPaths, environmentPaths, + platformEnvironmentPaths); + found = results.found; + allResults = results.files; + + if (allResults.length === 1) { + var result = allResults[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs new file mode 100644 index 00000000..61a9c0b7 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/PkgConfigProbe.qbs @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Host +import qbs.Process +import qbs.FileInfo + +Probe { + // Inputs + property string sysroot: qbs.sysroot + property string executable: 'pkg-config' + property string name + property stringList packageNames: [name] + property string minVersion + property string exactVersion + property string maxVersion + property bool forStaticBuild: false + property stringList libDirs // Full, non-sysrooted paths, mirroring the environment variable + + // Output + property stringList cflags // Unmodified --cflags output + property stringList libs // Unmodified --libs output + + property stringList defines + property stringList libraries + property stringList libraryPaths + property stringList includePaths + property stringList compilerFlags + property stringList linkerFlags + property string modversion + + configure: { + if (!packageNames || packageNames.length === 0) + throw 'PkgConfigProbe.packageNames must be specified.'; + var p = new Process(); + var stdout; + try { + var libDirsToSet = libDirs; + if (sysroot) { + p.setEnv("PKG_CONFIG_SYSROOT_DIR", sysroot); + if (!libDirsToSet) { + libDirsToSet = [ + sysroot + "/usr/lib/pkgconfig", + sysroot + "/usr/share/pkgconfig" + ]; + } + } + if (libDirsToSet) + p.setEnv("PKG_CONFIG_LIBDIR", libDirsToSet.join(FileInfo.pathListSeparator())); + var versionArgs = []; + if (minVersion !== undefined) + versionArgs.push("--atleast-version=" + minVersion); + if (exactVersion !== undefined) + versionArgs.push("--exact-version=" + exactVersion); + if (maxVersion !== undefined) + versionArgs.push("--max-version=" + maxVersion); + if (versionArgs.length !== 0 + && p.exec(executable, versionArgs.concat(packageNames)) !== 0) { + return; + } + var args = packageNames; + if (p.exec(executable, args.concat([ '--cflags' ])) === 0) { + stdout = p.readStdOut().trim(); + cflags = stdout ? stdout.split(/\s/): []; + var libsArgs = args.concat("--libs"); + if (forStaticBuild) + libsArgs.push("--static"); + if (p.exec(executable, libsArgs) === 0) { + stdout = p.readStdOut().trim(); + libs = stdout ? stdout.split(/\s/): []; + if (p.exec(executable, [packageNames[0]].concat([ '--modversion' ])) === 0) { + modversion = p.readStdOut().trim(); + found = true; + includePaths = []; + defines = [] + compilerFlags = []; + for (var i = 0; i < cflags.length; ++i) { + var flag = cflags[i]; + if (flag.startsWith("-I")) + includePaths.push(flag.slice(2)); + else if (flag.startsWith("-D")) + defines.push(flag.slice(2)); + else + compilerFlags.push(flag); + } + libraries = []; + libraryPaths = []; + linkerFlags = []; + for (i = 0; i < libs.length; ++i) { + flag = libs[i]; + if (flag.startsWith("-l")) + libraries.push(flag.slice(2)); + else if (flag.startsWith("-L")) + libraryPaths.push(flag.slice(2)); + else + linkerFlags.push(flag); + } + console.debug("PkgConfigProbe: found packages " + packageNames); + return; + } + } + } + found = false; + cflags = undefined; + libs = undefined; + } finally { + p.close(); + } + } +} diff --git a/share/qbs/imports/qbs/Probes/SdccProbe.qbs b/share/qbs/imports/qbs/Probes/SdccProbe.qbs new file mode 100644 index 00000000..ae616fa2 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/SdccProbe.qbs @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import "../../../modules/cpp/sdcc.js" as SDCC + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + property string preferredArchitecture + + // Outputs + property string architecture + property string endianness + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + // SDCC compiler support only the C-language. + if (!languages.contains("c")) { + found = false; + return; + } + + var macros = SDCC.dumpMacros(compilerFilePath, preferredArchitecture); + if (!macros) { + found = false; + return; + } + + compilerDefinesByLanguage["c"] = macros; + + architecture = SDCC.guessArchitecture(macros); + endianness = SDCC.guessEndianness(macros); + + var defaultPaths = SDCC.dumpDefaultPaths(compilerFilePath, architecture); + includePaths = defaultPaths.includePaths; + + var version = SDCC.guessVersion(macros); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture && !!endianness; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs b/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs new file mode 100644 index 00000000..f494d601 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/TypeScriptProbe.qbs @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import "path-probe.js" as PathProbeConfigure +import "../../../modules/typescript/typescript.js" as TypeScript + +BinaryProbe { + id: tsc + names: ["tsc"] + searchPaths: packageManagerBinPath ? [packageManagerBinPath] : [] + + // Inputs + property path interpreterPath + property path packageManagerBinPath + property path packageManagerRootPath + + // Outputs + property var version + + configure: { + if (!condition) + return; + if (!interpreterPath) + throw '"interpreterPath" must be specified'; + if (!packageManagerBinPath) + throw '"packageManagerBinPath" must be specified'; + if (!packageManagerRootPath) + throw '"packageManagerRootPath" must be specified'; + + var selectors; + var results = PathProbeConfigure.configure( + selectors, names, nameSuffixes, nameFilter, candidateFilter, searchPaths, + pathSuffixes, platformSearchPaths, environmentPaths, platformEnvironmentPaths); + + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), + Host.os().contains("windows")); + v.prepend(interpreterPath); + + var resultsMapper = function(result) { + result.version = result.found + ? TypeScript.findTscVersion(result.filePath, v.value) + : undefined; + if (FileInfo.fromNativeSeparators(packageManagerBinPath) !== result.path || + !File.exists( + FileInfo.fromNativeSeparators(packageManagerRootPath, "typescript"))) { + result = { found: false }; + } + return result; + }; + results.files = results.files.map(resultsMapper); + + found = results.found; + allResults = results.files; + + var result = results.files[0]; + candidatePaths = result.candidatePaths; + path = result.path; + filePath = result.filePath; + fileName = result.fileName; + version = result.version; + } +} diff --git a/share/qbs/imports/qbs/Probes/WatcomProbe.qbs b/share/qbs/imports/qbs/Probes/WatcomProbe.qbs new file mode 100644 index 00000000..3ea22acb --- /dev/null +++ b/share/qbs/imports/qbs/Probes/WatcomProbe.qbs @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.Host +import qbs.ModUtils +import "../../../modules/cpp/watcom.js" as WATCOM + +PathProbe { + // Inputs + property string compilerFilePath + property stringList enableDefinesByLanguage + + property string _pathListSeparator + property string _toolchainInstallPath + property string _targetPlatform + property string _targetArchitecture + + // Outputs + property string architecture + property string endianness + property string targetPlatform + property int versionMajor + property int versionMinor + property int versionPatch + property stringList includePaths + property var compilerDefinesByLanguage + property var environment + + configure: { + compilerDefinesByLanguage = {}; + + if (!File.exists(compilerFilePath)) { + found = false; + return; + } + + var languages = enableDefinesByLanguage; + if (!languages || languages.length === 0) + languages = ["c"]; + + environment = WATCOM.guessEnvironment(Host.os(), _targetPlatform, _targetArchitecture, + _toolchainInstallPath, _pathListSeparator); + + includePaths = environment["INCLUDE"].split(_pathListSeparator).filter(function(path) { + return File.exists(path); + }); + + for (var i = 0; i < languages.length; ++i) { + var tag = languages[i]; + compilerDefinesByLanguage[tag] = WATCOM.dumpMacros( + environment, compilerFilePath, + _targetPlatform, _targetArchitecture, tag); + } + + var macros = compilerDefinesByLanguage["c"] + || compilerDefinesByLanguage["cpp"]; + + endianness = macros["__BIG_ENDIAN"] ? "big" : "little"; + architecture = ModUtils.guessArchitecture(macros); + targetPlatform = ModUtils.guessTargetPlatform(macros); + + var version = WATCOM.guessVersion(macros); + if (version) { + versionMajor = version.major; + versionMinor = version.minor; + versionPatch = version.patch; + found = !!architecture && !!targetPlatform; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/WiXProbe.qbs b/share/qbs/imports/qbs/Probes/WiXProbe.qbs new file mode 100644 index 00000000..561b275c --- /dev/null +++ b/share/qbs/imports/qbs/Probes/WiXProbe.qbs @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Utilities + +PathProbe { + // Inputs + property string registryKey: { + var keys = [ + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Installer XML", + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Installer XML" + ]; + for (var i in keys) { + var groups = Utilities.nativeSettingGroups(keys[i]).filter(function (v) { + return v.match(/^([0-9]+)\.([0-9]+)$/); + }); + + groups.sort(function (a, b) { + var re = /^([0-9]+)\.([0-9]+)$/; + a = a.match(re); + b = b.match(re); + a = {major: a[1], minor: a[2]}; + b = {major: b[1], minor: b[2]}; + if (a.major === b.major) + return b.minor - a.minor; + return b.major - a.major; + }); + + for (var j in groups) { + var fullKey = keys[i] + "\\" + groups[j]; + if (Utilities.getNativeSetting(fullKey, "ProductVersion")) + return fullKey; + } + } + } + + // Outputs + property var root + property var version + + configure: { + var key = registryKey; + path = Utilities.getNativeSetting(key, "InstallFolder"); + root = Utilities.getNativeSetting(key, "InstallRoot"); + version = Utilities.getNativeSetting(key, "ProductVersion"); + found = path && root && version; + } +} diff --git a/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs b/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs new file mode 100644 index 00000000..3401315f --- /dev/null +++ b/share/qbs/imports/qbs/Probes/XcodeLocationProbe.qbs @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Process + +Probe { + property path developerPath + configure: { + var p = new Process(); + try { + p.exec("/usr/bin/xcode-select", ["--print-path"], true); + developerPath = p.readStdOut().trim(); + } catch (e) { + developerPath = "/Applications/Xcode.app/Contents/Developer"; + } finally { + p.close(); + found = true; + } + } +} diff --git a/share/qbs/imports/qbs/Probes/XcodeProbe.qbs b/share/qbs/imports/qbs/Probes/XcodeProbe.qbs new file mode 100644 index 00000000..9a0d0107 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/XcodeProbe.qbs @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Process +import qbs.PropertyList +import "../../../modules/xcode/xcode.js" as Xcode + +Probe { + // Inputs + property string sdksPath + property string developerPath + property string xcodebuildPath + property stringList targetOS: qbs.targetOS + property string platformType + property string platformPath + property string devicePlatformPath + property string _xcodeInfoPlist: FileInfo.joinPaths(developerPath, "..", "Info.plist") + + // Outputs + property var architectureSettings + property var availableSdks + property var platformSettings + property string xcodeVersion + + configure: { + if (File.exists(_xcodeInfoPlist)) { + // Optimized case (no forking): reads CFBundleShortVersionString from + // Xcode.app/Contents/Info.plist + var propertyList = new PropertyList(); + try { + propertyList.readFromFile(_xcodeInfoPlist); + + var plist = propertyList.toObject(); + if (plist) + xcodeVersion = plist["CFBundleShortVersionString"]; + } finally { + propertyList.clear(); + } + } else { + // Fallback case: execute xcodebuild -version if Xcode.app/Contents/Info.plist is + // missing; this can happen if developerPath is /, for example + var process; + try { + process = new Process(); + process.exec(xcodebuildPath, ["-version"], true); + var lines = process.readStdOut().trim().split(/\r?\n/g).filter(function (line) { + return line.length > 0; + }); + for (var l = 0; l < lines.length; ++l) { + var m = lines[l].match(/^Xcode ([0-9\.]+)$/); + if (m) { + xcodeVersion = m[1]; + break; + } + } + } finally { + process.close(); + } + } + + architectureSettings = {}; + var archSpecsPath = Xcode.archsSpecsPath(xcodeVersion, targetOS, platformType, + platformPath, devicePlatformPath, developerPath); + var archSpecsReader = new Xcode.XcodeArchSpecsReader(archSpecsPath); + archSpecsReader.getArchitectureSettings().map(function (setting) { + var val = archSpecsReader.getArchitectureSettingValue(setting); + if (val) + architectureSettings[setting] = val; + }); + + availableSdks = Xcode.sdkInfoList(sdksPath); + var platformInfoPlist = FileInfo.joinPaths(platformPath, "Info.plist"); + platformSettings = Xcode.platformInfo(platformInfoPlist); + found = !!xcodeVersion; + } +} diff --git a/share/qbs/imports/qbs/Probes/path-probe.js b/share/qbs/imports/qbs/Probes/path-probe.js new file mode 100644 index 00000000..1858f522 --- /dev/null +++ b/share/qbs/imports/qbs/Probes/path-probe.js @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); + +function asStringList(key, value) { + if (typeof(value) === "string") + return [value]; + if (value instanceof Array) + return value; + throw key + " must be a string or a stringList"; +} + +function canonicalSelectors(selectors, nameSuffixes) { + var mapper = function(selector) { + if (typeof(selector) === "string") + return {names : [selector]}; + if (selector instanceof Array) + return {names : selector}; + // dict + if (!selector.names) + throw '"names" must be specified'; + selector.names = asStringList("names", selector.names); + if (selector.nameSuffixes) + selector.nameSuffixes = asStringList("nameSuffixes", selector.nameSuffixes); + else + selector.nameSuffixes = nameSuffixes; + return selector; + }; + return selectors.map(mapper); +} + +function pathsFromEnvs(envs, pathListSeparator) { + envs = envs || []; + var result = []; + for (var i = 0; i < envs.length; ++i) { + var value = Environment.getEnv(envs[i]) || ''; + if (value.length > 0) + result = result.concat(value.split(pathListSeparator)); + } + return result; +} + +function configure(selectors, names, nameSuffixes, nameFilter, candidateFilter, + searchPaths, pathSuffixes, platformSearchPaths, environmentPaths, + platformEnvironmentPaths) { + var result = { found: false, files: [] }; + if (!selectors && !names) + throw '"names" or "selectors" must be specified'; + + if (!selectors) { + selectors = [ + {names: names, nameSuffixes: nameSuffixes} + ]; + } else { + selectors = canonicalSelectors(selectors, nameSuffixes); + } + + if (nameFilter) { + selectors.forEach(function(selector) { + selector.names = selector.names.map(nameFilter); + }); + } + + selectors.forEach(function(selector) { + selector.names = ModUtils.concatAll.apply(undefined, selector.names.map(function(name) { + return (selector.nameSuffixes || [""]).map(function(suffix) { + return name + suffix; + }); + })); + }); + + // FIXME: Suggest how to obtain paths from system + var _paths = ModUtils.concatAll( + pathsFromEnvs(environmentPaths, FileInfo.pathListSeparator()), + searchPaths, + pathsFromEnvs(platformEnvironmentPaths, FileInfo.pathListSeparator()), + platformSearchPaths); + var _suffixes = ModUtils.concatAll('', pathSuffixes); + _paths = _paths.map(function(p) { return FileInfo.fromNativeSeparators(p); }); + _suffixes = _suffixes.map(function(p) { return FileInfo.fromNativeSeparators(p); }); + + var findFile = function(selector) { + var file = { found: false, candidatePaths: [] }; + for (var i = 0; i < selector.names.length; ++i) { + for (var j = 0; j < _paths.length; ++j) { + for (var k = 0; k < _suffixes.length; ++k) { + var _filePath = FileInfo.joinPaths(_paths[j], _suffixes[k], selector.names[i]); + file.candidatePaths.push(_filePath); + if (File.exists(_filePath) + && (!candidateFilter || candidateFilter(_filePath))) { + file.found = true; + file.filePath = _filePath; + + // Manually specify the path components that constitute _filePath rather + // than using the FileInfo.path and FileInfo.fileName functions because we + // want to break _filePath into its constituent parts based on the input + // originally given by the user. For example, the FileInfo functions would + // produce a different result if any of the items in the names property + // contained more than a single path component. + file.fileName = selector.names[i]; + file.path = FileInfo.joinPaths(_paths[j], _suffixes[k]); + return file; + } + } + } + } + + return file; + }; + + result.files = selectors.map(findFile); + result.found = result.files.reduce(function(acc, value) { return acc && value.found }, true); + + return result; +} diff --git a/share/qbs/imports/qbs/UnixUtils/unix-utils.js b/share/qbs/imports/qbs/UnixUtils/unix-utils.js new file mode 100644 index 00000000..aba27726 --- /dev/null +++ b/share/qbs/imports/qbs/UnixUtils/unix-utils.js @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); + +function soname(product, outputFileName) { + var soVersion = product.moduleProperty("cpp", "soVersion"); + if (product.moduleProperty("qbs", "targetOS").contains("darwin")) { + // If this is a bundle, ignore the parameter and use the relative path to the bundle binary + // For example: qbs.framework/Versions/1/qbs + if (product.moduleProperty("bundle", "isBundle")) + outputFileName = product.moduleProperty("bundle", "executablePath"); + } else if (soVersion) { + // For non-Darwin platforms, append the shared library major version number to the soname + // For example: libqbscore.so.1 + var version = product.moduleProperty("cpp", "internalVersion"); + if (version) { + outputFileName = outputFileName.substr(0, outputFileName.length - version.length) + + soVersion; + } else { + outputFileName += "." + soVersion; + } + } + + // Prepend the soname prefix + // For example, @rpath/libqbscore.dylib or /usr/lib/libqbscore.so.1 + var prefix = product.moduleProperty("cpp", "sonamePrefix"); + if (prefix) + outputFileName = FileInfo.joinPaths(prefix, outputFileName); + + return outputFileName; +} diff --git a/share/qbs/imports/qbs/WindowsUtils/windows-utils.js b/share/qbs/imports/qbs/WindowsUtils/windows-utils.js new file mode 100644 index 00000000..e4b8487e --- /dev/null +++ b/share/qbs/imports/qbs/WindowsUtils/windows-utils.js @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +function winapiFamilyDefine(name) { + return { + "desktop": "DESKTOP_APP", + "phone": "PHONE_APP", + "pc": "PC_APP", + "server": "SERVER", + "system": "SYSTEM" + }[name]; +} + +function winapiPartitionDefine(name) { + return { + "app": "APP", + "desktop": "DESKTOP", + "phone": "PHONE_APP", + "pc": "PC_APP", + "server": "SERVER", + "system": "SYSTEM" + }[name]; +} + +function characterSetDefines(charset) { + var defines = []; + if (charset === "unicode") + defines.push("UNICODE", "_UNICODE"); + else if (charset === "mbcs") + defines.push("_MBCS"); + return defines; +} + +function canonicalizeVersion(version) { + switch (version) { + case "7": + return "6.1"; + case "8": + return "6.2"; + case "8.1": + return "6.3"; + default: + return version; + } +} + +function knownWindowsVersions() { + // Add new Windows versions to this list when they are released + return ['10.0', '6.3', '6.2', '6.1', '6.0', '5.2', '5.1', '5.0', '4.0']; +} + +function isValidWindowsVersion(systemVersion) { + var realVersions = knownWindowsVersions(); + for (i in realVersions) + if (systemVersion === realVersions[i]) + return true; + + return false; +} + +function getWindowsVersionInFormat(systemVersion, format) { + if (!systemVersion) + return undefined; + + var major = parseInt(systemVersion.split('.')[0], 10); + var minor = parseInt(systemVersion.split('.')[1], 10); + + switch (format) { + case "hex": + // https://msdn.microsoft.com/en-us/library/6sehtctf.aspx + return "0x" + ("0000" + ((major << 8) | minor).toString(16)).slice(-4); + case "subsystem": + // https://msdn.microsoft.com/en-us/library/fcc1zstk.aspx + return major + '.' + (minor < 10 ? '0' : '') + minor; + default: + throw ("Unrecognized Windows version format " + format + ". Must be in {hex, subsystem}."); + } +} diff --git a/share/qbs/imports/qbs/base/AndroidApk.qbs b/share/qbs/imports/qbs/base/AndroidApk.qbs new file mode 100644 index 00000000..70cf6aa9 --- /dev/null +++ b/share/qbs/imports/qbs/base/AndroidApk.qbs @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo + +Product { + type: ["android.package"] + qbs.targetPlatform: "android" + Depends { name: "Android.sdk" } +} diff --git a/share/qbs/imports/qbs/base/AppleApplicationDiskImage.qbs b/share/qbs/imports/qbs/base/AppleApplicationDiskImage.qbs new file mode 100644 index 00000000..6491bf14 --- /dev/null +++ b/share/qbs/imports/qbs/base/AppleApplicationDiskImage.qbs @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils + +AppleDiskImage { + property string sourceBase: "/Applications" + readonly property string absoluteSourceBase: FileInfo.joinPaths(qbs.installRoot, sourceBase) + property stringList symlinks: ["/Applications:Applications"] + + readonly property string stageDirectory: FileInfo.joinPaths(destinationDirectory, "Volumes", dmg.volumeName) + + Rule { + multiplex: true + outputFileTags: ["dmg.input", "dmg.input.symlink"] + outputArtifacts: Array.prototype.map.call(product.symlinks, function (symlink) { + var symlinkTarget = symlink.split(':')[0]; + var symlinkName = symlink.split(':')[1] || symlinkTarget; + if (FileInfo.isAbsolutePath(symlinkName)) + throw(symlink + " is an invalid symlink; the destination must be a relative path"); + return { + filePath: FileInfo.joinPaths(product.stageDirectory, symlinkName), + fileTags: ["dmg.input", "dmg.input.symlink"], + dmg: { symlinkTarget: symlinkTarget, sourceBase: product.stageDirectory }, + }; + }) + prepare: Array.prototype.map.call(outputs["dmg.input"], function (symlink) { + var cmd = new Command("ln", ["-sfn", symlink.dmg.symlinkTarget, symlink.filePath]); + cmd.workingDirectory = product.stageDirectory; + cmd.description = "symlinking " + symlink.fileName + " to " + symlink.dmg.symlinkTarget; + return cmd; + }); + } + + Rule { + multiplex: true + inputs: ["dmg.input.symlink"] + inputsFromDependencies: ["installable"] + outputFileTags: ["dmg.input"] + outputArtifacts: { + var absSourceBase = product.absoluteSourceBase; + var symlinkPaths = (inputs["dmg.input.symlink"] || []).map(function (s) { return s.filePath; }); + return Array.prototype.map.call(inputs["installable"], function (a) { + var fp = ModUtils.artifactInstalledFilePath(a); + if (fp.startsWith(absSourceBase)) { + var outputFilePath = fp.replace(absSourceBase, product.stageDirectory); + + // Check for symlink conflicts + for (var i in symlinkPaths) { + if (outputFilePath.startsWith(symlinkPaths[i])) + throw new Error("Cannot install '" + a.filePath + + "' to '" + outputFilePath + "' because it " + + "would conflict with the symlink at '" + + symlinkPaths[i] + "'"); + } + + return { + filePath: outputFilePath, + fileTags: ["dmg.input"], + dmg: { sourceBase: product.stageDirectory } + } + } + }).filter(function (a) { return !!a; }); + } + prepare: { + var absSourceBase = product.absoluteSourceBase; + var cmds = [], dmgs = outputs["dmg.input"]; + for (var i in dmgs) { + var a = dmgs[i]; + var cmd = new JavaScriptCommand(); + cmd.src = a.filePath.replace(product.stageDirectory, absSourceBase); + cmd.dst = a.filePath; + cmd.silent = true; + cmd.sourceCode = function () { File.copy(src, dst); }; + cmds.push(cmd); + } + return cmds; + } + } +} diff --git a/share/qbs/imports/qbs/base/AppleDiskImage.qbs b/share/qbs/imports/qbs/base/AppleDiskImage.qbs new file mode 100644 index 00000000..1467d822 --- /dev/null +++ b/share/qbs/imports/qbs/base/AppleDiskImage.qbs @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "dmg" } + type: ["dmg.dmg"] +} diff --git a/share/qbs/imports/qbs/base/Application.qbs b/share/qbs/imports/qbs/base/Application.qbs new file mode 100644 index 00000000..76536c68 --- /dev/null +++ b/share/qbs/imports/qbs/base/Application.qbs @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +NativeBinary { + type: isForAndroid && !consoleApplication ? ["android.package"] : ["application"] + + property bool usesNativeCode + + Depends { + // Note: If we are multiplexing, then this dependency is technically only needed in + // the aggregate. However, the user should not have to write the respective + // condition when assigning to properties of this module, so we load it + // regardless and turn off its rules for the native part of the build. + name: "Android.sdk" + condition: isForAndroid && !consoleApplication + } + Properties { + condition: isForAndroid && !consoleApplication && !usesNativeCode + multiplexByQbsProperties: [] + aggregate: false + } + Properties { + condition: isForAndroid && !consoleApplication && usesNativeCode + && multiplexByQbsProperties && multiplexByQbsProperties.contains("architectures") + && qbs.architectures && qbs.architectures.length > 1 + aggregate: true + multiplexedType: "android.nativelibrary" + } + aggregate: base + multiplexByQbsProperties: base + multiplexedType: base + + installDir: isBundle ? "Applications" : "bin" + + Group { + condition: install && _installable + fileTagsFilter: isBundle ? "bundle.content" : "application" + qbs.install: true + qbs.installDir: installDir + qbs.installSourceBase: isBundle ? destinationDirectory : outer + } + + Group { + condition: installDebugInformation && _installable + fileTagsFilter: ["debuginfo_app"] + qbs.install: true + qbs.installDir: debugInformationInstallDir + qbs.installSourceBase: destinationDirectory + } +} diff --git a/share/qbs/imports/qbs/base/ApplicationExtension.qbs b/share/qbs/imports/qbs/base/ApplicationExtension.qbs new file mode 100644 index 00000000..eae5145c --- /dev/null +++ b/share/qbs/imports/qbs/base/ApplicationExtension.qbs @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +XPCService { + Depends { name: "xcode" } + + type: base.concat(["applicationextension"]) + + property bool _useLegacyExtensionLibraries: + qbs.targetOS.contains("macos") && parseInt(xcode.sdkVersion.split(".")[1], 10) < 11 || + qbs.targetOS.contains("ios") && parseInt(xcode.sdkVersion.split(".")[0], 10) < 9 + + cpp.entryPoint: "_NSExtensionMain" + cpp.frameworkPaths: base.concat(_useLegacyExtensionLibraries + ? qbs.sysroot + "/System/Library/PrivateFrameworks/" + : []) + cpp.frameworks: { + var frameworks = base.concat(["Foundation"]); + if (_useLegacyExtensionLibraries) + frameworks.push("PlugInKit"); + return frameworks; + } + + cpp.requireAppExtensionSafeApi: true + + xpcServiceType: undefined + property var extensionAttributes + property string extensionPointIdentifier + property string extensionPrincipalClass + + bundle.infoPlist: { + var infoPlist = base; + infoPlist["NSExtension"] = { + "NSExtensionAttributes": extensionAttributes || {}, + "NSExtensionPointIdentifier": extensionPointIdentifier, + "NSExtensionPrincipalClass": extensionPrincipalClass + }; + return infoPlist; + } +} diff --git a/share/qbs/imports/qbs/base/AutotestRunner.qbs b/share/qbs/imports/qbs/base/AutotestRunner.qbs new file mode 100644 index 00000000..30921eb3 --- /dev/null +++ b/share/qbs/imports/qbs/base/AutotestRunner.qbs @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils + +Product { + name: "autotest-runner" + type: ["autotest-result"] + builtByDefault: false + property stringList arguments: [] + property stringList environment: ModUtils.flattenDictionary(qbs.commonRunEnvironment) + property bool limitToSubProject: true + property stringList wrapper: [] + property string workingDir + property stringList auxiliaryInputs + property int timeout: -1 + + Depends { + productTypes: "autotest" + limitToSubProject: product.limitToSubProject + } + Depends { + productTypes: auxiliaryInputs + limitToSubProject: product.limitToSubProject + } + + Rule { + inputsFromDependencies: "application" + auxiliaryInputs: product.auxiliaryInputs + outputFileTags: "autotest-result" + prepare: { + // TODO: This is hacky. Possible solution: Add autotest tag to application + // in autotest module and have that as inputsFromDependencies instead of application. + if (!input.product.type.contains("autotest")) { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + return cmd; + } + var commandFilePath; + var installed = input.moduleProperty("qbs", "install"); + if (installed) + commandFilePath = ModUtils.artifactInstalledFilePath(input); + if (!commandFilePath || !File.exists(commandFilePath)) + commandFilePath = input.filePath; + var workingDir = product.workingDir ? product.workingDir + : FileInfo.path(commandFilePath); + var arguments = product.arguments; + var allowFailure = false; + var timeout = product.timeout; + if (input.autotest) { + // FIXME: We'd like to let the user override with an empty list, but + // qbscore turns undefined lists into empty ones at the moment. + if (input.autotest.arguments && input.autotest.arguments.length > 0) + arguments = input.autotest.arguments; + + if (input.autotest.workingDir) + workingDir = input.autotest.workingDir; + allowFailure = input.autotest.allowFailure; + + if (input.autotest.timeout !== undefined) + timeout = input.autotest.timeout; + } + var fullCommandLine = product.wrapper + .concat([commandFilePath]) + .concat(arguments); + var cmd = new Command(fullCommandLine[0], fullCommandLine.slice(1)); + cmd.description = "running test " + input.fileName; + cmd.environment = product.environment; + cmd.workingDirectory = workingDir; + cmd.timeout = timeout; + cmd.jobPool = "autotest-runner"; + if (allowFailure) + cmd.maxExitCode = 32767; + return cmd; + } + } +} diff --git a/share/qbs/imports/qbs/base/CppApplication.qbs b/share/qbs/imports/qbs/base/CppApplication.qbs new file mode 100644 index 00000000..86d2fc74 --- /dev/null +++ b/share/qbs/imports/qbs/base/CppApplication.qbs @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Application { + Depends { name: "cpp" } + usesNativeCode: true +} + diff --git a/share/qbs/imports/qbs/base/DynamicLibrary.qbs b/share/qbs/imports/qbs/base/DynamicLibrary.qbs new file mode 100644 index 00000000..818665e3 --- /dev/null +++ b/share/qbs/imports/qbs/base/DynamicLibrary.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Library { + type: ["dynamiclibrary"].concat(isForAndroid ? ["android.nativelibrary"] : []) +} diff --git a/share/qbs/imports/qbs/base/InnoSetup.qbs b/share/qbs/imports/qbs/base/InnoSetup.qbs new file mode 100644 index 00000000..e40a627f --- /dev/null +++ b/share/qbs/imports/qbs/base/InnoSetup.qbs @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + condition: qbs.targetOS.contains("windows") && innosetup.present + Depends { name: "innosetup"; condition: qbs.targetOS.contains("windows"); required: false } + type: ["innosetup.exe"] +} diff --git a/share/qbs/imports/qbs/base/InstallPackage.qbs b/share/qbs/imports/qbs/base/InstallPackage.qbs new file mode 100644 index 00000000..e85fe382 --- /dev/null +++ b/share/qbs/imports/qbs/base/InstallPackage.qbs @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.ModUtils +import qbs.TextFile + +Product { + type: ["archiver.archive"] + builtByDefault: false + Depends { name: "archiver" } + archiver.type: "tar" + archiver.workingDirectory: qbs.installRoot + + Rule { + multiplex: true + inputsFromDependencies: ["installable"] + Artifact { + filePath: product.name + ".tarlist" + fileTags: ["archiver.input-list"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode =function() { + var ofile = new TextFile(output.filePath, TextFile.WriteOnly); + try { + for (var i = 0; i < inputs["installable"].length; ++i) { + var inp = inputs["installable"][i]; + var installRoot = inp.moduleProperty("qbs", "installRoot"); + var installedFilePath = ModUtils.artifactInstalledFilePath(inp); + ofile.writeLine(FileInfo.relativePath(installRoot, installedFilePath)); + } + } finally { + ofile.close(); + } + }; + return [cmd]; + } + } +} diff --git a/share/qbs/imports/qbs/base/JavaClassCollection.qbs b/share/qbs/imports/qbs/base/JavaClassCollection.qbs new file mode 100644 index 00000000..23b975a0 --- /dev/null +++ b/share/qbs/imports/qbs/base/JavaClassCollection.qbs @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "java" } + type: ["java.class"] +} diff --git a/share/qbs/imports/qbs/base/JavaJarFile.qbs b/share/qbs/imports/qbs/base/JavaJarFile.qbs new file mode 100644 index 00000000..39ab9ec4 --- /dev/null +++ b/share/qbs/imports/qbs/base/JavaJarFile.qbs @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "java" } + type: ["java.jar"] + property string entryPoint +} diff --git a/share/qbs/imports/qbs/base/Library.qbs b/share/qbs/imports/qbs/base/Library.qbs new file mode 100644 index 00000000..914d79bc --- /dev/null +++ b/share/qbs/imports/qbs/base/Library.qbs @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +NativeBinary { + type: { + if (qbs.targetOS.contains("ios") && parseInt(cpp.minimumIosVersion, 10) < 8) + return ["staticlibrary"]; + return ["dynamiclibrary"].concat(isForAndroid ? ["android.nativelibrary"] : []); + } + + readonly property bool isDynamicLibrary: type.contains("dynamiclibrary") + readonly property bool isStaticLibrary: type.contains("staticlibrary") + readonly property bool isLoadableModule: type.contains("loadablemodule") + + installDir: { + if (isBundle) + return "Library/Frameworks"; + if (isDynamicLibrary) + return qbs.targetOS.contains("windows") ? "bin" : "lib"; + if (isStaticLibrary) + return "lib"; + } + + property bool installImportLib: false + property string importLibInstallDir: "lib" + + Group { + condition: install && _installable + fileTagsFilter: { + if (isBundle) + return ["bundle.content"]; + if (isDynamicLibrary) + return ["dynamiclibrary", "dynamiclibrary_symlink"]; + if (isStaticLibrary) + return ["staticlibrary"]; + if (isLoadableModule) + return ["loadablemodule"]; + return []; + } + qbs.install: true + qbs.installDir: installDir + qbs.installSourceBase: isBundle ? destinationDirectory : outer + } + + Group { + condition: installImportLib + && type.contains("dynamiclibrary") + && _installable + fileTagsFilter: "dynamiclibrary_import" + qbs.install: true + qbs.installDir: importLibInstallDir + } + + Group { + condition: installDebugInformation && _installable + fileTagsFilter: { + if (isDynamicLibrary) + return ["debuginfo_dll"]; + else if (isLoadableModule) + return ["debuginfo_loadablemodule"]; + return []; + } + qbs.install: true + qbs.installDir: debugInformationInstallDir + qbs.installSourceBase: destinationDirectory + } +} diff --git a/share/qbs/imports/qbs/base/LoadableModule.qbs b/share/qbs/imports/qbs/base/LoadableModule.qbs new file mode 100644 index 00000000..34579e4d --- /dev/null +++ b/share/qbs/imports/qbs/base/LoadableModule.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +DynamicLibrary { + type: isForDarwin ? ["loadablemodule"] : base +} diff --git a/share/qbs/imports/qbs/base/NSISSetup.qbs b/share/qbs/imports/qbs/base/NSISSetup.qbs new file mode 100644 index 00000000..1362f271 --- /dev/null +++ b/share/qbs/imports/qbs/base/NSISSetup.qbs @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "nsis"; condition: qbs.targetOS.contains("windows") } + type: ["nsissetup"] +} diff --git a/share/qbs/imports/qbs/base/NativeBinary.qbs b/share/qbs/imports/qbs/base/NativeBinary.qbs new file mode 100644 index 00000000..900ed9fa --- /dev/null +++ b/share/qbs/imports/qbs/base/NativeBinary.qbs @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + property bool isForAndroid: qbs.targetOS.contains("android") + property bool isForDarwin: qbs.targetOS.contains("darwin") + property bool isBundle: isForDarwin && bundle.isBundle + + property bool install: false + property string installDir + // Product artifacts should be installed if it's not multiplexed or aggregated, + // or if it is multiplexed and it's the aggregate product + readonly property bool _installable: !multiplexed || !aggregate || !multiplexConfigurationId + + property bool installDebugInformation: install + property string debugInformationInstallDir: installDir + + Depends { name: "bundle"; condition: isForDarwin } + + aggregate: { + if (!isForDarwin) + return false; + var multiplexProps = multiplexByQbsProperties; + if (!multiplexProps) + return false; + if (multiplexProps.contains("architectures")) { + var archs = qbs.architectures; + if (archs && archs.length > 1) + return true; + } + if (multiplexProps.contains("buildVariants")) { + var variants = qbs.buildVariants; + return variants && variants.length > 1; + } + return false; + } + + multiplexByQbsProperties: { + if (isForDarwin) + return ["profiles", "architectures", "buildVariants"]; + if (isForAndroid) + return ["architectures"] + return ["profiles"]; + } +} diff --git a/share/qbs/imports/qbs/base/NetModule.qbs b/share/qbs/imports/qbs/base/NetModule.qbs new file mode 100644 index 00000000..0f52ffe4 --- /dev/null +++ b/share/qbs/imports/qbs/base/NetModule.qbs @@ -0,0 +1,4 @@ +Product { + Depends { name: "cli" } + type: ["cli.netmodule"] +} diff --git a/share/qbs/imports/qbs/base/NodeJSApplication.qbs b/share/qbs/imports/qbs/base/NodeJSApplication.qbs new file mode 100644 index 00000000..1908310e --- /dev/null +++ b/share/qbs/imports/qbs/base/NodeJSApplication.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "nodejs" } +} diff --git a/share/qbs/imports/qbs/base/QtApplication.qbs b/share/qbs/imports/qbs/base/QtApplication.qbs new file mode 100644 index 00000000..32800d29 --- /dev/null +++ b/share/qbs/imports/qbs/base/QtApplication.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +CppApplication { + Depends { name: "Qt.core" } +} diff --git a/share/qbs/imports/qbs/base/QtGuiApplication.qbs b/share/qbs/imports/qbs/base/QtGuiApplication.qbs new file mode 100644 index 00000000..7b2abf01 --- /dev/null +++ b/share/qbs/imports/qbs/base/QtGuiApplication.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +QtApplication { + Depends { name: "Qt.gui" } +} diff --git a/share/qbs/imports/qbs/base/StaticLibrary.qbs b/share/qbs/imports/qbs/base/StaticLibrary.qbs new file mode 100644 index 00000000..5a78a83b --- /dev/null +++ b/share/qbs/imports/qbs/base/StaticLibrary.qbs @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Library { + type: ["staticlibrary"] +} diff --git a/share/qbs/imports/qbs/base/WindowsInstallerPackage.qbs b/share/qbs/imports/qbs/base/WindowsInstallerPackage.qbs new file mode 100644 index 00000000..791fc947 --- /dev/null +++ b/share/qbs/imports/qbs/base/WindowsInstallerPackage.qbs @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "wix"; condition: qbs.targetOS.contains("windows") } + type: ["msi"] +} diff --git a/share/qbs/imports/qbs/base/WindowsSetupPackage.qbs b/share/qbs/imports/qbs/base/WindowsSetupPackage.qbs new file mode 100644 index 00000000..5175e9d8 --- /dev/null +++ b/share/qbs/imports/qbs/base/WindowsSetupPackage.qbs @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Product { + Depends { name: "wix"; condition: qbs.targetOS.contains("windows") } + type: ["wixsetup"] +} diff --git a/share/qbs/imports/qbs/base/XPCService.qbs b/share/qbs/imports/qbs/base/XPCService.qbs new file mode 100644 index 00000000..16c25900 --- /dev/null +++ b/share/qbs/imports/qbs/base/XPCService.qbs @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +Application { + type: base.concat(["xpcservice"]) + + condition: qbs.targetOS.contains("darwin") + + property string xpcServiceType: "Application" + + bundle.infoPlist: { + var infoPlist = base; + if (xpcServiceType) { + infoPlist["XPCService"] = { + "ServiceType": xpcServiceType + }; + } + return infoPlist; + } +} diff --git a/share/qbs/module-providers/Qt/provider.qbs b/share/qbs/module-providers/Qt/provider.qbs new file mode 100644 index 00000000..33083c51 --- /dev/null +++ b/share/qbs/module-providers/Qt/provider.qbs @@ -0,0 +1,6 @@ +import "setup-qt.js" as SetupQt + +ModuleProvider { + property stringList qmakeFilePaths + relativeSearchPaths: SetupQt.doSetup(qmakeFilePaths, outputBaseDir, path, qbs) +} diff --git a/share/qbs/module-providers/Qt/setup-qt.js b/share/qbs/module-providers/Qt/setup-qt.js new file mode 100644 index 00000000..a8fbf9da --- /dev/null +++ b/share/qbs/module-providers/Qt/setup-qt.js @@ -0,0 +1,1707 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Host = require("qbs.Host"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function splitNonEmpty(s, c) { return s.split(c).filter(function(e) { return e; }); } +function toNative(p) { return FileInfo.toNativeSeparators(p); } +function exeSuffix(qbs) { return Host.os().contains("windows") ? ".exe" : ""; } + +function getQmakeFilePaths(qmakeFilePaths, qbs) { + if (qmakeFilePaths && qmakeFilePaths.length > 0) + return qmakeFilePaths; + console.info("Detecting Qt installations..."); + var filePaths = []; + var pathValue = Environment.getEnv("PATH"); + if (pathValue) { + var dirs = splitNonEmpty(pathValue, FileInfo.pathListSeparator()); + var suffix = exeSuffix(qbs); + for (var i = 0; i < dirs.length; ++i) { + var candidate = FileInfo.joinPaths(dirs[i], "qmake" + suffix); + var canonicalCandidate = FileInfo.canonicalPath(candidate); + if (!canonicalCandidate || !File.exists(canonicalCandidate)) + continue; + if (FileInfo.completeBaseName(canonicalCandidate) !== "qtchooser") + candidate = canonicalCandidate; + if (!filePaths.contains(candidate)) { + console.info("Found Qt at '" + toNative(candidate) + "'."); + filePaths.push(candidate); + } + } + } + if (filePaths.length === 0) { + console.warn("Could not find any qmake executables in PATH. Either make sure a qmake " + + "executable is present in PATH or set the moduleProviders.Qt.qmakeFilePaths property " + + "to point a qmake executable."); + } + return filePaths; +} + +function queryQmake(qmakeFilePath) { + var qmakeProcess = new Process; + qmakeProcess.exec(qmakeFilePath, ["-query"]); + if (qmakeProcess.exitCode() !== 0) { + throw "The qmake executable '" + toNative(qmakeFilePath) + "' failed with exit code " + + qmakeProcess.exitCode() + "."; + } + var queryResult = {}; + while (!qmakeProcess.atEnd()) { + var line = qmakeProcess.readLine(); + var index = (line || "").indexOf(":"); + if (index !== -1) + queryResult[line.slice(0, index)] = line.slice(index + 1).trim(); + } + return queryResult; +} + +function pathQueryValue(queryResult, key) { + var p = queryResult[key]; + if (p) + return FileInfo.fromNativeSeparators(p); +} + +function readFileContent(filePath) { + var f = new TextFile(filePath, TextFile.ReadOnly); + var content = f.readAll(); + f.close(); + return content; +} + +// TODO: Don't do the split every time... +function configVariable(configContent, key) { + var configContentLines = configContent.split('\n'); + var regexp = new RegExp("^\\s*" + key + "\\s*\\+{0,1}=(.*)"); + for (var i = 0; i < configContentLines.length; ++i) { + var line = configContentLines[i]; + var match = regexp.exec(line); + if (match) + return match[1].trim(); + } +} + +function configVariableItems(configContent, key) { + return splitNonEmpty(configVariable(configContent, key), ' '); +} + +function msvcPrefix() { return "win32-msvc"; } + +function isMsvcQt(qtProps) { return qtProps.mkspecName.startsWith(msvcPrefix()); } + +function msvcCompilerVersionForYear(year) { + var mapping = { + "2005": "14", "2008": "15", "2010": "16", "2012": "17", "2013": "18", "2015": "19", + "2017": "19.1", "2019": "19.2" + }; + return mapping[year]; +} + +function msvcCompilerVersionFromMkspecName(mkspecName) { + return msvcCompilerVersionForYear(mkspecName.slice(msvcPrefix().length)); +} + +function addQtBuildVariant(qtProps, buildVariantName) { + if (qtProps.qtConfigItems.contains(buildVariantName)) + qtProps.buildVariant.push(buildVariantName); +} + +function checkForStaticBuild(qtProps) { + if (qtProps.qtMajorVersion >= 5) + return qtProps.qtConfigItems.contains("static"); + if (qtProps.frameworkBuild) + return false; // there are no Qt4 static frameworks + var isWin = qtProps.mkspecName.startsWith("win"); + var libDir = isWin ? qtProps.binaryPath : qtProps.libraryPath; + var coreLibFiles = File.directoryEntries(libDir, File.Files) + .filter(function(fp) { return fp.contains("Core"); }); + if (coreLibFiles.length === 0) + throw "Could not determine whether Qt is a static build."; + for (var i = 0; i < coreLibFiles.length; ++i) { + if (Utilities.isSharedLibrary(coreLibFiles[i])) + return false; + } + return true; +} + +function isForMinGw(qtProps) { + return qtProps.mkspecName.startsWith("win32-g++") || qtProps.mkspecName.startsWith("mingw"); +} + +function targetsDesktopWindows(qtProps) { + return qtProps.mkspecName.startsWith("win32-") || isForMinGw(qtProps); +} + +function guessMinimumWindowsVersion(qtProps) { + if (qtProps.mkspecName.startsWith("winrt-")) + return "10.0"; + if (!targetsDesktopWindows(qtProps)) + return ""; + if (qtProps.architecture === "x86_64" || qtProps.architecture === "ia64") + return "5.2" + var match = qtProps.mkspecName.match(/^win32-msvc(\d+)$/); + if (match) { + var msvcVersion = match[1]; + if (msvcVersion < 2012) + return "5.0"; + return "5.1"; + } + return qtProps.qtMajorVersion < 5 ? "5.0" : "5.1"; +} + +function needsDSuffix(qtProps) { + return !isForMinGw(qtProps) || Utilities.versionCompare(qtProps.qtVersion, "5.14.0") < 0 + || qtProps.configItems.contains("debug_and_release"); +} + +function fillEntryPointLibs(qtProps, debug) { + result = []; + var isMinGW = isForMinGw(qtProps); + + // Some Linux distributions rename the qtmain library. + var qtMainCandidates = ["qtmain"]; + if (isMinGW && qtProps.qtMajorVersion === 5) + qtMainCandidates.push("qt5main"); + if (qtProps.qtMajorVersion === 6) + qtMainCandidates.push("Qt6EntryPoint"); + + for (var i = 0; i < qtMainCandidates.length; ++i) { + var baseNameCandidate = qtMainCandidates[i]; + var qtmain = qtProps.libraryPath + '/'; + if (isMinGW) + qtmain += "lib"; + qtmain += baseNameCandidate + qtProps.qtLibInfix; + if (debug && needsDSuffix(qtProps)) + qtmain += 'd'; + if (isMinGW) { + qtmain += ".a"; + } else { + qtmain += ".lib"; + if (Utilities.versionCompare(qtProps.qtVersion, "5.4.0") >= 0) + result.push("Shell32.lib"); + } + if (File.exists(qtmain)) { + result.push(qtmain); + break; + } + } + if (result.length === 0) { + console.warn("Could not find the qtmain library at '" + toNative(qtProps.libraryPath) + + "'. You will not be able to link Qt applications."); + } + return result; +} + +function abiToArchitecture(abi) { + switch (abi) { + case "armeabi-v7a": + return "armv7a"; + case "arm64-v8a": + return "arm64"; + case "x86": + case "x86_64": + default: + return abi; + } +} + +function getQtProperties(qmakeFilePath, qbs) { + var queryResult = queryQmake(qmakeFilePath); + var qtProps = {}; + qtProps.installPrefixPath = pathQueryValue(queryResult, "QT_INSTALL_PREFIX"); + qtProps.documentationPath = pathQueryValue(queryResult, "QT_INSTALL_DOCS"); + qtProps.includePath = pathQueryValue(queryResult, "QT_INSTALL_HEADERS"); + qtProps.libraryPath = pathQueryValue(queryResult, "QT_INSTALL_LIBS"); + qtProps.hostLibraryPath = pathQueryValue(queryResult, "QT_HOST_LIBS"); + qtProps.binaryPath = pathQueryValue(queryResult, "QT_HOST_BINS") + || pathQueryValue(queryResult, "QT_INSTALL_BINS"); + qtProps.installPath = pathQueryValue(queryResult, "QT_INSTALL_BINS"); + qtProps.documentationPath = pathQueryValue(queryResult, "QT_INSTALL_DOCS"); + qtProps.pluginPath = pathQueryValue(queryResult, "QT_INSTALL_PLUGINS"); + qtProps.qmlPath = pathQueryValue(queryResult, "QT_INSTALL_QML"); + qtProps.qmlImportPath = pathQueryValue(queryResult, "QT_INSTALL_IMPORTS"); + qtProps.qtVersion = queryResult.QT_VERSION; + + var mkspecsBaseSrcPath; + if (Utilities.versionCompare(qtProps.qtVersion, "5") >= 0) { + qtProps.mkspecBasePath = FileInfo.joinPaths(pathQueryValue(queryResult, "QT_HOST_DATA"), + "mkspecs"); + mkspecsBaseSrcPath = FileInfo.joinPaths(pathQueryValue(queryResult, "QT_HOST_DATA/src"), + "mkspecs"); + } else { + qtProps.mkspecBasePath = FileInfo.joinPaths + (pathQueryValue(queryResult, "QT_INSTALL_DATA"), "mkspecs"); + } + + if (Utilities.versionCompare(qtProps.qtVersion, "6") >= 0) { + qtProps.libExecPath = pathQueryValue(queryResult, "QT_HOST_LIBEXECS") + || pathQueryValue(queryResult, "QT_INSTALL_LIBEXECS"); + } + + // QML tools were only moved in Qt 6.2. + qtProps.qmlLibExecPath = Utilities.versionCompare(qtProps.qtVersion, "6.2") >= 0 + ? qtProps.libExecPath : qtProps.binaryPath; + + // qhelpgenerator was only moved in Qt 6.3. + qtProps.helpGeneratorLibExecPath = Utilities.versionCompare(qtProps.qtVersion, "6.3") >= 0 + ? qtProps.libExecPath : qtProps.binaryPath; + + if (!File.exists(qtProps.mkspecBasePath)) + throw "Cannot extract the mkspecs directory."; + + var qconfigContent = readFileContent(FileInfo.joinPaths(qtProps.mkspecBasePath, + "qconfig.pri")); + qtProps.qtMajorVersion = parseInt(configVariable(qconfigContent, "QT_MAJOR_VERSION")); + qtProps.qtMinorVersion = parseInt(configVariable(qconfigContent, "QT_MINOR_VERSION")); + qtProps.qtPatchVersion = parseInt(configVariable(qconfigContent, "QT_PATCH_VERSION")); + qtProps.qtNameSpace = configVariable(qconfigContent, "QT_NAMESPACE"); + qtProps.qtLibInfix = configVariable(qconfigContent, "QT_LIBINFIX") || ""; + qtProps.architecture = configVariable(qconfigContent, "QT_TARGET_ARCH") + || configVariable(qconfigContent, "QT_ARCH") || "x86"; + qtProps.configItems = configVariableItems(qconfigContent, "CONFIG"); + qtProps.qtConfigItems = configVariableItems(qconfigContent, "QT_CONFIG"); + + // retrieve the mkspec + if (qtProps.qtMajorVersion >= 5) { + qtProps.mkspecName = queryResult.QMAKE_XSPEC; + qtProps.mkspecPath = FileInfo.joinPaths(qtProps.mkspecBasePath, qtProps.mkspecName); + if (mkspecsBaseSrcPath && !File.exists(qtProps.mkspecPath)) + qtProps.mkspecPath = FileInfo.joinPaths(mkspecsBaseSrcPath, qtProps.mkspecName); + } else { + if (Host.os().contains("windows")) { + var baseDirPath = FileInfo.joinPaths(qtProps.mkspecBasePath, "default"); + var fileContent = readFileContent(FileInfo.joinPaths(baseDirPath, "qmake.conf")); + qtProps.mkspecPath = configVariable(fileContent, "QMAKESPEC_ORIGINAL"); + if (!File.exists(qtProps.mkspecPath)) { + // Work around QTBUG-28792. + // The value of QMAKESPEC_ORIGINAL is wrong for MinGW packages. Y u h8 me? + var match = fileContent.exec(/\binclude\(([^)]+)\/qmake\.conf\)/m); + if (match) { + qtProps.mkspecPath = FileInfo.cleanPath(FileInfo.joinPaths( + baseDirPath, match[1])); + } + } + } else { + qtProps.mkspecPath = FileInfo.canonicalPath( + FileInfo.joinPaths(qtProps.mkspecBasePath, "default")); + } + + // E.g. in qmake.conf for Qt 4.8/mingw we find this gem: + // QMAKESPEC_ORIGINAL=C:\\Qt\\Qt\\4.8\\mingw482\\mkspecs\\win32-g++ + qtProps.mkspecPath = FileInfo.cleanPath(qtProps.mkspecPath); + + qtProps.mkspecName = qtProps.mkspecPath; + var idx = qtProps.mkspecName.lastIndexOf('/'); + if (idx !== -1) + qtProps.mkspecName = qtProps.mkspecName.slice(idx + 1); + } + if (!File.exists(qtProps.mkspecPath)) + throw "mkspec '" + toNative(qtProps.mkspecPath) + "' does not exist"; + + // Starting with qt 5.14, android sdk provides multi-abi + if (Utilities.versionCompare(qtProps.qtVersion, "5.14.0") >= 0 + && qtProps.mkspecPath.contains("android")) { + var qdeviceContent = readFileContent(FileInfo.joinPaths(qtProps.mkspecBasePath, + "qdevice.pri")); + qtProps.androidAbis = configVariable(qdeviceContent, "DEFAULT_ANDROID_ABIS").split(' '); + } + + // determine MSVC version + if (isMsvcQt(qtProps)) { + var msvcMajor = configVariable(qconfigContent, "QT_MSVC_MAJOR_VERSION"); + var msvcMinor = configVariable(qconfigContent, "QT_MSVC_MINOR_VERSION"); + var msvcPatch = configVariable(qconfigContent, "QT_MSVC_PATCH_VERSION"); + if (msvcMajor && msvcMinor && msvcPatch) + qtProps.msvcVersion = msvcMajor + "." + msvcMinor + "." + msvcPatch; + else + qtProps.msvcVersion = msvcCompilerVersionFromMkspecName(qtProps.mkspecName); + } + + // determine whether we have a framework build + qtProps.frameworkBuild = qtProps.mkspecPath.contains("macx") + && qtProps.configItems.contains("qt_framework"); + + // determine whether Qt is built with debug, release or both + qtProps.buildVariant = []; + addQtBuildVariant(qtProps, "debug"); + addQtBuildVariant(qtProps, "release"); + + qtProps.staticBuild = checkForStaticBuild(qtProps); + + // determine whether user apps require C++11 + if (qtProps.qtConfigItems.contains("c++11") && qtProps.staticBuild) + qtProps.configItems.push("c++11"); + + // Set the minimum operating system versions appropriate for this Qt version + qtProps.windowsVersion = guessMinimumWindowsVersion(qtProps); + if (qtProps.windowsVersion) { // Is target OS Windows? + if (qtProps.buildVariant.contains("debug")) + qtProps.entryPointLibsDebug = fillEntryPointLibs(qtProps, true); + if (qtProps.buildVariant.contains("release")) + qtProps.entryPointLibsRelease = fillEntryPointLibs(qtProps, false); + } else if (qtProps.mkspecPath.contains("macx")) { + if (qtProps.qtMajorVersion >= 5) { + var lines = getFileContentsRecursively(FileInfo.joinPaths(qtProps.mkspecPath, + "qmake.conf")); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i].trim(); + match = line.match + (/^QMAKE_(MACOSX|IOS|TVOS|WATCHOS)_DEPLOYMENT_TARGET\s*=\s*(.*)\s*$/); + if (match) { + var platform = match[1]; + var version = match[2]; + if (platform === "MACOSX") + qtProps.macosVersion = version; + else if (platform === "IOS") + qtProps.iosVersion = version; + else if (platform === "TVOS") + qtProps.tvosVersion = version; + else if (platform === "WATCHOS") + qtProps.watchosVersion = version; + } + } + var isMac = qtProps.mkspecName !== "macx-ios-clang" + && qtProps.mkspecName !== "macx-tvos-clang" + && qtProps.mkspecName !== "macx-watchos-clang"; + if (isMac) { + // Qt 5.0.x placed the minimum version in a different file + if (!qtProps.macosVersion) + qtProps.macosVersion = "10.6"; + + // If we're using C++11 with libc++, make sure the deployment target is >= 10.7 + if (Utilities.versionCompare(qtProps.macosVersion, "10, 7") < 0 + && qtProps.qtConfigItems.contains("c++11")) { + qtProps.macosVersion = "10.7"; + } + } + } else if (qtProps.qtMajorVersion === 4 && qtProps.qtMinorVersion >= 6) { + var qconfigDir = qtProps.frameworkBuild + ? FileInfo.joinPaths(qtProps.libraryPath, "QtCore.framework", "Headers") + : FileInfo.joinPaths(qtProps.includePath, "Qt"); + try { + var qconfig = new TextFile(FileInfo.joinPaths(qconfigDir, "qconfig.h"), + TextFile.ReadOnly); + var qtCocoaBuild = false; + var ok = true; + do { + line = qconfig.readLine(); + if (line.match(/\s*#define\s+QT_MAC_USE_COCOA\s+1\s*/)) { + qtCocoaBuild = true; + break; + } + } while (!qconfig.atEof()); + qtProps.macosVersion = qtCocoaBuild ? "10.5" : "10.4"; + } + catch (e) {} + finally { + if (qconfig) + qconfig.close(); + } + if (!qtProps.macosVersion) { + throw "Could not determine whether Qt is using Cocoa or Carbon from '" + + toNative(qconfig.filePath()) + "'."; + } + } + } else if (qtProps.mkspecPath.contains("android")) { + if (qtProps.qtMajorVersion >= 5) + qtProps.androidVersion = "2.3"; + else if (qtProps.qtMajorVersion === 4 && qtProps.qtMinorVersion >= 8) + qtProps.androidVersion = "1.6"; // Necessitas + } + return qtProps; +} + +function makePluginData() { + var pluginData = {}; + pluginData.type = undefined; + pluginData.className = undefined; + pluginData.autoLoad = true; + pluginData["extends"] = []; + return pluginData; +} + +function makeQtModuleInfo(name, qbsName, deps) { + var moduleInfo = {}; + moduleInfo.name = name; // As in the path to the headers and ".name" in the pri files. + if (moduleInfo.name === undefined) + moduleInfo.name = ""; + moduleInfo.qbsName = qbsName; // Lower-case version without "qt" prefix. + moduleInfo.dependencies = deps || []; // qbs names. + if (moduleInfo.qbsName && moduleInfo.qbsName !== "core" + && !moduleInfo.dependencies.contains("core")) { + moduleInfo.dependencies.unshift("core"); + } + moduleInfo.isPrivate = qbsName && qbsName.endsWith("-private"); + moduleInfo.hasLibrary = !moduleInfo.isPrivate; + moduleInfo.isStaticLibrary = false; + moduleInfo.isPlugin = false; + moduleInfo.mustExist = true; + moduleInfo.modulePrefix = ""; // empty value means "Qt". + moduleInfo.version = undefined; + moduleInfo.includePaths = []; + moduleInfo.compilerDefines = []; + moduleInfo.staticLibrariesDebug = []; + moduleInfo.staticLibrariesRelease = []; + moduleInfo.dynamicLibrariesDebug = []; + moduleInfo.dynamicLibrariesRelease = []; + moduleInfo.linkerFlagsDebug = []; + moduleInfo.linkerFlagsRelease = []; + moduleInfo.libFilePathDebug = undefined; + moduleInfo.libFilePathRelease = undefined; + moduleInfo.frameworksDebug = []; + moduleInfo.frameworksRelease = []; + moduleInfo.frameworkPathsDebug = []; + moduleInfo.frameworkPathsRelease = []; + moduleInfo.libraryPaths = []; + moduleInfo.libDir = ""; + moduleInfo.config = []; + moduleInfo.supportedPluginTypes = []; + moduleInfo.pluginData = makePluginData(); + return moduleInfo; +} + +function frameworkHeadersPath(qtModuleInfo, qtProps) { + return FileInfo.joinPaths(qtProps.libraryPath, qtModuleInfo.name + ".framework", "Headers"); +} + +function qt4ModuleIncludePaths(qtModuleInfo, qtProps) { + var paths = []; + if (isFramework(qtModuleInfo, qtProps)) + paths.push(frameworkHeadersPath(qtModuleInfo, qtProps)); + else + paths.push(qtProps.includePath, FileInfo.joinPaths(qtProps.includePath, qtModuleInfo.name)); + return paths; +} + +// We erroneously called the "testlib" module "test" for quite a while. Let's not punish users +// for that. +function addTestModule(modules) { + var testModule = makeQtModuleInfo("QtTest", "test", ["testlib"]); + testModule.hasLibrary = false; + modules.push(testModule); +} + +// See above. +function addDesignerComponentsModule(modules) { + var module = makeQtModuleInfo("QtDesignerComponents", "designercomponents", + ["designercomponents-private"]); + module.hasLibrary = false; + modules.push(module); +} + +function isFramework(modInfo, qtProps) { + if (!qtProps.frameworkBuild || modInfo.isStaticLibrary) + return false; + var modulesNeverBuiltAsFrameworks = [ + "bootstrap", "openglextensions", "platformsupport", "qmldevtools", "harfbuzzng" + ]; + + if (qtProps.qtMajorVersion <= 5) { + modulesNeverBuiltAsFrameworks.push("uitools"); // is framework since qt6 + } + + return !modulesNeverBuiltAsFrameworks.contains(modInfo.qbsName); +} + +function libBaseName(modInfo, libName, debugBuild, qtProps) { + var name = libName; + if (qtProps.mkspecName.startsWith("win")) { + if (debugBuild && needsDSuffix(qtProps)) + name += 'd'; + if (!modInfo.isStaticLibrary && qtProps.qtMajorVersion < 5) + name += qtProps.qtMajorVersion; + } + if (qtProps.mkspecName.contains("macx") + || qtProps.mkspecName.contains("ios") + || qtProps.mkspecName.contains("darwin")) { + if (!isFramework(modInfo, qtProps) + && qtProps.buildVariant.contains("debug") + && (!qtProps.buildVariant.contains("release") || debugBuild)) { + name += "_debug"; + } + } + return name; +} + +function moduleNameWithoutPrefix(modInfo) { + if (modInfo.name === "Phonon") + return "phonon"; + if (!modInfo.modulePrefix && modInfo.name.startsWith("Qt")) + return modInfo.name.slice(2); // Strip off "Qt". + if (modInfo.name.startsWith(modInfo.modulePrefix)) + return modInfo.name.slice(modInfo.modulePrefix.length); + return modInfo.name; +} + +function libraryBaseName(modInfo, qtProps, debugBuild) { + if (modInfo.isPlugin) + return libBaseName(modInfo, modInfo.name, debugBuild, qtProps); + + // Some modules use a different naming scheme, so it doesn't get boring. + var libNameBroken = modInfo.name === "Enginio" + || modInfo.name === "DataVisualization" + || modInfo.name === "Phonon"; + + var libName = ""; + if (!modInfo.isExternal) { + libName += !modInfo.modulePrefix && !libNameBroken ? "Qt" : modInfo.modulePrefix; + if (qtProps.qtMajorVersion >= 5 && !isFramework(modInfo, qtProps) && !libNameBroken) + libName += qtProps.qtMajorVersion; + } + libName += moduleNameWithoutPrefix(modInfo); + if (!modInfo.isExternal) + libName += qtProps.qtLibInfix; + return libBaseName(modInfo, libName, debugBuild, qtProps); +} + +function libNameForLinker(modInfo, qtProps, debugBuild) { + if (!modInfo.hasLibrary) + return undefined; + var libName = libraryBaseName(modInfo, qtProps, debugBuild); + if (qtProps.mkspecName.contains("msvc")) + libName += ".lib"; + return libName; +} + +function guessLibraryFilePath(prlFilePath, libDir, qtProps) { + var baseName = FileInfo.baseName(prlFilePath); + var prefixCandidates = ["", "lib"]; + var suffixCandidates = ["so." + qtProps.qtVersion, "so", "a", "lib", "dll.a"]; + for (var i = 0; i < prefixCandidates.length; ++i) { + var prefix = prefixCandidates[i]; + for (var j = 0; j < suffixCandidates.length; ++j) { + var suffix = suffixCandidates[j]; + var candidate = FileInfo.joinPaths(libDir, prefix + baseName + '.' + suffix); + if (File.exists(candidate)) + return candidate; + } + } +} + +function doReplaceQtLibNamesWithFilePath(namePathMap, libList) { + for (var i = 0; i < libList.length; ++i) { + var lib = libList[i]; + var path = namePathMap[lib]; + if (path) + libList[i] = path; + } +} + +function replaceQtLibNamesWithFilePath(modules, qtProps) { + // We don't want to add the libraries for Qt modules via "-l", because of the + // danger that a wrong one will be picked up, e.g. from /usr/lib. Instead, + // we pull them in using the full file path. + var linkerNamesToFilePathsDebug = {}; + var linkerNamesToFilePathsRelease = {}; + for (var i = 0; i < modules.length; ++i) { + var m = modules[i]; + linkerNamesToFilePathsDebug[libNameForLinker(m, qtProps, true)] = m.libFilePathDebug; + linkerNamesToFilePathsRelease[libNameForLinker(m, qtProps, false)] = m.libFilePathRelease; + } + for (i = 0; i < modules.length; ++i) { + var module = modules[i]; + doReplaceQtLibNamesWithFilePath(linkerNamesToFilePathsDebug, module.dynamicLibrariesDebug); + doReplaceQtLibNamesWithFilePath(linkerNamesToFilePathsDebug, module.staticLibrariesDebug); + doReplaceQtLibNamesWithFilePath(linkerNamesToFilePathsRelease, + module.dynamicLibrariesRelease); + doReplaceQtLibNamesWithFilePath(linkerNamesToFilePathsRelease, + module.staticLibrariesRelease); + } +} + +function doSetupLibraries(modInfo, qtProps, debugBuild, nonExistingPrlFiles, androidAbi) { + if (!modInfo.hasLibrary) + return; // Can happen for Qt4 convenience modules, like "widgets". + + if (debugBuild) { + if (!qtProps.buildVariant.contains("debug")) + return; + var modulesNeverBuiltAsDebug = ["bootstrap", "qmldevtools"]; + for (var i = 0; i < modulesNeverBuiltAsDebug.length; ++i) { + var m = modulesNeverBuiltAsDebug[i]; + if (modInfo.qbsName === m || modInfo.qbsName === m + "-private") + return; + } + } else if (!qtProps.buildVariant.contains("release")) { + return; + } + + var libs = modInfo.isStaticLibrary + ? (debugBuild ? modInfo.staticLibrariesDebug : modInfo.staticLibrariesRelease) + : (debugBuild ? modInfo.dynamicLibrariesDebug : modInfo.dynamicLibrariesRelease); + var frameworks = debugBuild ? modInfo.frameworksDebug : modInfo.frameworksRelease; + var frameworkPaths = debugBuild ? modInfo.frameworkPathsDebug : modInfo.frameworkPathsRelease; + var flags = debugBuild ? modInfo.linkerFlagsDebug : modInfo.linkerFlagsRelease; + var libFilePath; + + if (qtProps.mkspecName.contains("ios") && modInfo.isStaticLibrary) { + libs.push("z", "m"); + if (qtProps.qtMajorVersion === 5 && qtProps.qtMinorVersion < 8) { + var platformSupportModule = makeQtModuleInfo("QtPlatformSupport", "platformsupport"); + libs.push(libNameForLinker(platformSupportModule, qtProps, debugBuild)); + } + if (modInfo.name === "qios") { + flags.push("-force_load", FileInfo.joinPaths( + qtProps.pluginPath, "platforms", + libBaseName(modInfo, "libqios", debugBuild, qtProps) + ".a")); + } + } + var prlFilePath = modInfo.isPlugin + ? FileInfo.joinPaths(qtProps.pluginPath, modInfo.pluginData.type) + : (modInfo.libDir ? modInfo.libDir : qtProps.libraryPath); + var libDir = prlFilePath; + if (isFramework(modInfo, qtProps)) { + prlFilePath = FileInfo.joinPaths(prlFilePath, + libraryBaseName(modInfo, qtProps, false) + ".framework"); + libDir = prlFilePath; + if (Utilities.versionCompare(qtProps.qtVersion, "5.14") >= 0) + prlFilePath = FileInfo.joinPaths(prlFilePath, "Resources"); + } + var baseName = libraryBaseName(modInfo, qtProps, debugBuild); + if (!qtProps.mkspecName.startsWith("win") && !isFramework(modInfo, qtProps)) + baseName = "lib" + baseName; + prlFilePath = FileInfo.joinPaths(prlFilePath, baseName); + var isNonStaticQt4OnWindows = qtProps.mkspecName.startsWith("win") + && !modInfo.isStaticLibrary && qtProps.qtMajorVersion < 5; + if (isNonStaticQt4OnWindows) + prlFilePath = prlFilePath.slice(0, prlFilePath.length - 1); // The prl file base name does *not* contain the version number... + // qt for android versions 6.0 and 6.1 don't have the architecture suffix in the prl file + if (androidAbi.length > 0 + && modInfo.name !== "QtBootstrap" + && (modInfo.name !== "QtQmlDevTools" || modInfo.name === "QtQmlDevTools" + && Utilities.versionCompare(qtProps.qtVersion, "6.2") >= 0) + && (Utilities.versionCompare(qtProps.qtVersion, "6.0") < 0 + || Utilities.versionCompare(qtProps.qtVersion, "6.2") >= 0)) { + prlFilePath += "_"; + prlFilePath += androidAbi; + } + + prlFilePath += ".prl"; + + try { + var prlFile = new TextFile(prlFilePath, TextFile.ReadOnly); + while (!prlFile.atEof()) { + var line = prlFile.readLine().trim(); + var equalsOffset = line.indexOf('='); + if (equalsOffset === -1) + continue; + if (line.startsWith("QMAKE_PRL_TARGET")) { + var isMingw = qtProps.mkspecName.startsWith("win") + && qtProps.mkspecName.contains("g++"); + var isQtVersionBefore56 = qtProps.qtMajorVersion < 5 + || (qtProps.qtMajorVersion === 5 && qtProps.qtMinorVersion < 6); + + // QMAKE_PRL_TARGET has a "lib" prefix, except for mingw. + // Of course, the exception has an exception too: For static libs, mingw *does* + // have the "lib" prefix. + var libFileName = ""; + if (isQtVersionBefore56 && qtProps.qtMajorVersion === 5 && isMingw + && !modInfo.isStaticLibrary) { + libFileName += "lib"; + } + + libFileName += line.slice(equalsOffset + 1).trim(); + if (isNonStaticQt4OnWindows) + libFileName += 4; // This is *not* part of QMAKE_PRL_TARGET... + if (isQtVersionBefore56) { + if (qtProps.mkspecName.contains("msvc")) { + libFileName += ".lib"; + } else if (isMingw) { + libFileName += ".a"; + if (!File.exists(FileInfo.joinPaths(libDir, libFileName))) + libFileName = libFileName.slice(0, -2) + ".dll"; + } + } + libFilePath = FileInfo.joinPaths(libDir, libFileName); + continue; + } + if (line.startsWith("QMAKE_PRL_CONFIG")) { + modInfo.config = splitNonEmpty(line.slice(equalsOffset + 1).trim(), ' '); + continue; + } + if (!line.startsWith("QMAKE_PRL_LIBS =")) + continue; + + var parts = extractPaths(line.slice(equalsOffset + 1).trim(), prlFilePath); + for (i = 0; i < parts.length; ++i) { + var part = parts[i]; + part = part.replace("$$[QT_INSTALL_LIBS]", qtProps.libraryPath); + part = part.replace("$$[QT_INSTALL_PLUGINS]", qtProps.pluginPath); + part = part.replace("$$[QT_INSTALL_PREFIX]", qtProps.installPrefixPath); + if (part.startsWith("-l")) { + libs.push(part.slice(2)); + } else if (part.startsWith("-L")) { + modInfo.libraryPaths.push(part.slice(2)); + } else if (part.startsWith("-F")) { + frameworkPaths.push(part.slice(2)); + } else if (part === "-framework") { + if (++i < parts.length) + frameworks.push(parts[i]); + } else if (part === "-pthread") { + // prl files for android have QMAKE_PRL_LIBS = -llog -pthread but the pthread + // functionality is included in libc. + if (androidAbi.length === 0) + libs.push("pthread"); + } else if (part.startsWith('-')) { // Some other option + console.debug("QMAKE_PRL_LIBS contains non-library option '" + part + + "' in file '" + prlFilePath + "'"); + flags.push(part); + } else if (part.startsWith("/LIBPATH:")) { + libraryPaths.push(part.slice(9).replace(/\\/g, '/')); + } else { // Assume it's a file path/name. + libs.push(part.replace(/\\/g, '/')); + } + } + } + } catch (e) { + // qt_ext_lib_extX.pri (usually) don't have a corresponding prl file. + // So the pri file variable QMAKE_LIBS_LIBX points to the library + if (modInfo.isExternal) { + libFilePath = debugBuild ? modInfo.staticLibrariesDebug[0] : + modInfo.staticLibrariesRelease[0]; + } + if (!libFilePath || !File.exists(libFilePath)) + libFilePath = guessLibraryFilePath(prlFilePath, libDir, qtProps); + if (nonExistingPrlFiles.contains(prlFilePath)) + return; + nonExistingPrlFiles.push(prlFilePath); + if (modInfo.mustExist) { + console.warn("Could not open prl file '" + toNative(prlFilePath) + "' for module '" + + modInfo.name + + "' (" + e + "), and failed to deduce the library file path. " + + " This module will likely not be usable by qbs."); + } + } + finally { + if (prlFile) + prlFile.close(); + } + + if (debugBuild) + modInfo.libFilePathDebug = libFilePath; + else + modInfo.libFilePathRelease = libFilePath; +} + +function setupLibraries(qtModuleInfo, qtProps, nonExistingPrlFiles, androidAbi) { + doSetupLibraries(qtModuleInfo, qtProps, true, nonExistingPrlFiles, androidAbi); + doSetupLibraries(qtModuleInfo, qtProps, false, nonExistingPrlFiles, androidAbi); +} + +function allQt4Modules(qtProps) { + // as per http://doc.qt.io/qt-4.8/modules.html + private stuff. + var modules = []; + + var core = makeQtModuleInfo("QtCore", "core"); + core.compilerDefines.push("QT_CORE_LIB"); + if (qtProps.qtNameSpace) + core.compilerDefines.push("QT_NAMESPACE=" + qtProps.qtNameSpace); + modules.push(core, + makeQtModuleInfo("QtCore", "core-private", ["core"]), + makeQtModuleInfo("QtGui", "gui"), + makeQtModuleInfo("QtGui", "gui-private", ["gui"]), + makeQtModuleInfo("QtMultimedia", "multimedia", ["gui", "network"]), + makeQtModuleInfo("QtMultimedia", "multimedia-private", ["multimedia"]), + makeQtModuleInfo("QtNetwork", "network"), + makeQtModuleInfo("QtNetwork", "network-private", ["network"]), + makeQtModuleInfo("QtOpenGL", "opengl", ["gui"]), + makeQtModuleInfo("QtOpenGL", "opengl-private", ["opengl"]), + makeQtModuleInfo("QtOpenVG", "openvg", ["gui"]), + makeQtModuleInfo("QtScript", "script"), + makeQtModuleInfo("QtScript", "script-private", ["script"]), + makeQtModuleInfo("QtScriptTools", "scripttools", ["script", "gui"]), + makeQtModuleInfo("QtScriptTools", "scripttools-private", ["scripttools"]), + makeQtModuleInfo("QtSql", "sql"), + makeQtModuleInfo("QtSql", "sql-private", ["sql"]), + makeQtModuleInfo("QtSvg", "svg", ["gui"]), + makeQtModuleInfo("QtSvg", "svg-private", ["svg"]), + makeQtModuleInfo("QtWebKit", "webkit", ["gui", "network"]), + makeQtModuleInfo("QtWebKit", "webkit-private", ["webkit"]), + makeQtModuleInfo("QtXml", "xml"), + makeQtModuleInfo("QtXml", "xml-private", ["xml"]), + makeQtModuleInfo("QtXmlPatterns", "xmlpatterns", ["network"]), + makeQtModuleInfo("QtXmlPatterns", "xmlpatterns-private", ["xmlpatterns"]), + makeQtModuleInfo("QtDeclarative", "declarative", ["gui", "script"]), + makeQtModuleInfo("QtDeclarative", "declarative-private", ["declarative"]), + makeQtModuleInfo("QtDesigner", "designer", ["gui", "xml"]), + makeQtModuleInfo("QtDesigner", "designer-private", ["designer"]), + makeQtModuleInfo("QtUiTools", "uitools"), + makeQtModuleInfo("QtUiTools", "uitools-private", ["uitools"]), + makeQtModuleInfo("QtHelp", "help", ["network", "sql"]), + makeQtModuleInfo("QtHelp", "help-private", ["help"]), + makeQtModuleInfo("QtTest", "testlib"), + makeQtModuleInfo("QtTest", "testlib-private", ["testlib"])); + if (qtProps.mkspecName.startsWith("win")) { + var axcontainer = makeQtModuleInfo("QAxContainer", "axcontainer"); + axcontainer.modulePrefix = "Q"; + axcontainer.isStaticLibrary = true; + axcontainer.includePaths.push(FileInfo.joinPaths(qtProps.includePath, "ActiveQt")); + modules.push(axcontainer); + + var axserver = makeQtModuleInfo("QAxServer", "axserver"); + axserver.modulePrefix = "Q"; + axserver.isStaticLibrary = true; + axserver.compilerDefines.push("QAXSERVER"); + axserver.includePaths.push(FileInfo.joinPaths(qtProps.includePath, "ActiveQt")); + modules.push(axserver); + } else { + modules.push(makeQtModuleInfo("QtDBus", "dbus")); + modules.push(makeQtModuleInfo("QtDBus", "dbus-private", ["dbus"])); + } + + var designerComponentsPrivate = makeQtModuleInfo( + "QtDesignerComponents", "designercomponents-private", + ["gui-private", "designer-private"]); + designerComponentsPrivate.hasLibrary = true; + modules.push(designerComponentsPrivate); + + var phonon = makeQtModuleInfo("Phonon", "phonon"); + phonon.includePaths = qt4ModuleIncludePaths(phonon, qtProps); + modules.push(phonon); + + // Set up include paths that haven't been set up before this point. + for (i = 0; i < modules.length; ++i) { + var module = modules[i]; + if (module.includePaths.length > 0) + continue; + module.includePaths = qt4ModuleIncludePaths(module, qtProps); + } + + // Set up compiler defines haven't been set up before this point. + for (i = 0; i < modules.length; ++i) { + module = modules[i]; + if (module.compilerDefines.length > 0) + continue; + module.compilerDefines.push("QT_" + module.qbsName.toUpperCase() + "_LIB"); + } + + // These are for the convenience of project file authors. It allows them + // to add a dependency to e.g. "Qt.widgets" without a version check. + var virtualModule = makeQtModuleInfo(undefined, "widgets", ["core", "gui"]); + virtualModule.hasLibrary = false; + modules.push(virtualModule); + virtualModule = makeQtModuleInfo(undefined, "quick", ["declarative"]); + virtualModule.hasLibrary = false; + modules.push(virtualModule); + virtualModule = makeQtModuleInfo(undefined, "concurrent"); + virtualModule.hasLibrary = false; + modules.push(virtualModule); + virtualModule = makeQtModuleInfo(undefined, "printsupport", ["core", "gui"]); + virtualModule.hasLibrary = false; + modules.push(virtualModule); + + addTestModule(modules); + addDesignerComponentsModule(modules); + + var modulesThatCanBeDisabled = [ + "xmlpatterns", "multimedia", "phonon", "svg", "webkit", "script", "scripttools", + "declarative", "gui", "dbus", "opengl", "openvg"]; + var nonExistingPrlFiles = []; + for (i = 0; i < modules.length; ++i) { + module = modules[i]; + var name = module.qbsName; + var privateIndex = name.indexOf("-private"); + if (privateIndex !== -1) + name = name.slice(0, privateIndex); + if (modulesThatCanBeDisabled.contains(name)) + module.mustExist = false; + if (qtProps.staticBuild) + module.isStaticLibrary = true; + setupLibraries(module, qtProps, nonExistingPrlFiles, ""); + } + replaceQtLibNamesWithFilePath(modules, qtProps); + + return modules; +} + +function getFileContentsRecursively(filePath) { + var file = new TextFile(filePath, TextFile.ReadOnly); + var lines = splitNonEmpty(file.readAll(), '\n'); + for (var i = 0; i < lines.length; ++i) { + var includeString = "include("; + var line = lines[i].trim(); + if (!line.startsWith(includeString)) + continue; + var offset = includeString.length; + var closingParenPos = line.indexOf(')', offset); + if (closingParenPos === -1) { + console.warn("Invalid include statement in '" + toNative(filePath) + "'"); + continue; + } + var includedFilePath = line.slice(offset, closingParenPos); + if (!FileInfo.isAbsolutePath(includedFilePath)) + includedFilePath = FileInfo.joinPaths(FileInfo.path(filePath), includedFilePath); + var includedContents = getFileContentsRecursively(includedFilePath); + var j = i; + for (var k = 0; k < includedContents.length; ++k) + lines.splice(++j, 0, includedContents[k]); + lines.splice(i--, 1); + } + file.close(); + return lines; +} + +function extractPaths(rhs, filePath) { + var paths = []; + var startIndex = 0; + for (;;) { + while (startIndex < rhs.length && rhs.charAt(startIndex) === ' ') + ++startIndex; + if (startIndex >= rhs.length) + break; + var endIndex; + if (rhs.charAt(startIndex) === '"') { + ++startIndex; + endIndex = rhs.indexOf('"', startIndex); + if (endIndex === -1) { + console.warn("Unmatched quote in file '" + toNative(filePath) + "'"); + break; + } + } else { + endIndex = rhs.indexOf(' ', startIndex + 1); + if (endIndex === -1) + endIndex = rhs.length; + } + paths.push(FileInfo.cleanPath(rhs.slice(startIndex, endIndex) + .replace("$$PWD", FileInfo.path(filePath)))); + startIndex = endIndex + 1; + } + return paths; +} + +function removeDuplicatedDependencyLibs(modules) { + var revDeps = {}; + var currentPath = []; + var getLibraries; + var getLibFilePath; + + function setupReverseDependencies(modules) { + var moduleByName = {}; + for (var i = 0; i < modules.length; ++i) + moduleByName[modules[i].qbsName] = modules[i]; + for (i = 0; i < modules.length; ++i) { + var module = modules[i]; + for (var j = 0; j < module.dependencies.length; ++j) { + var depmod = moduleByName[module.dependencies[j]]; + if (!depmod) + continue; + if (!revDeps[depmod.qbsName]) + revDeps[depmod.qbsName] = []; + revDeps[depmod.qbsName].push(module); + } + } + } + + function roots(modules) { + var result = []; + for (i = 0; i < modules.length; ++i) { + var module = modules[i] + if (module.dependencies.length === 0) + result.push(module); + } + return result; + } + + function traverse(module, libs) { + if (currentPath.contains(module)) + return; + currentPath.push(module); + var moduleLibraryLists = getLibraries(module); + for (var i = 0; i < moduleLibraryLists.length; ++i) { + var modLibList = moduleLibraryLists[i]; + for (j = modLibList.length - 1; j >= 0; --j) { + if (libs.contains(modLibList[j])) + modLibList.splice(j, 1); + } + } + + var libFilePath = getLibFilePath(module); + if (libFilePath) + libs.push(libFilePath); + for (i = 0; i < moduleLibraryLists.length; ++i) + libs = libs.concat(moduleLibraryLists[i]); + libs.sort(); + + var deps = revDeps[module.qbsName]; + for (i = 0; i < (deps || []).length; ++i) + traverse(deps[i], libs); + + currentPath.pop(); + } + + setupReverseDependencies(modules); + + // Traverse the debug variants of modules. + getLibraries = function(module) { + return [module.dynamicLibrariesDebug, module.staticLibrariesDebug]; + }; + getLibFilePath = function(module) { return module.libFilePathDebug; }; + var rootModules = roots(modules); + for (var i = 0; i < rootModules.length; ++i) + traverse(rootModules[i], []); + + // Traverse the release variants of modules. + getLibraries = function(module) { + return [module.dynamicLibrariesRelease, module.staticLibrariesRelease]; + }; + getLibFilePath = function(module) { return module.libFilePathRelease; }; + for (i = 0; i < rootModules.length; ++i) + traverse(rootModules[i], []); +} + +function allQt5Modules(qtProps, androidAbi) { + var nonExistingPrlFiles = []; + var modules = []; + var modulesDir = FileInfo.joinPaths(qtProps.mkspecBasePath, "modules"); + var modulePriFiles = File.directoryEntries(modulesDir, File.Files); + for (var i = 0; i < modulePriFiles.length; ++i) { + var priFileName = modulePriFiles[i]; + var priFilePath = FileInfo.joinPaths(modulesDir, priFileName); + var externalFileNamePrefix = "qt_ext_"; + var moduleFileNamePrefix = "qt_lib_"; + var pluginFileNamePrefix = "qt_plugin_"; + var moduleFileNameSuffix = ".pri"; + var fileHasExternalPrefix = priFileName.startsWith(externalFileNamePrefix); + var fileHasModulePrefix = priFileName.startsWith(moduleFileNamePrefix); + var fileHasPluginPrefix = priFileName.startsWith(pluginFileNamePrefix); + if (!fileHasPluginPrefix && !fileHasModulePrefix && !fileHasExternalPrefix + || !priFileName.endsWith(moduleFileNameSuffix)) { + continue; + } + var moduleInfo = makeQtModuleInfo(); + moduleInfo.isPlugin = fileHasPluginPrefix; + moduleInfo.isExternal = !moduleInfo.isPlugin && !fileHasModulePrefix; + var fileNamePrefix = moduleInfo.isPlugin ? pluginFileNamePrefix : moduleInfo.isExternal + ? externalFileNamePrefix : moduleFileNamePrefix; + moduleInfo.qbsName = priFileName.slice(fileNamePrefix.length, -moduleFileNameSuffix.length); + if (moduleInfo.isPlugin) { + moduleInfo.name = moduleInfo.qbsName; + moduleInfo.isStaticLibrary = true; + } + var moduleKeyPrefix = (moduleInfo.isPlugin ? "QT_PLUGIN" : "QT") + + '.' + moduleInfo.qbsName + '.'; + moduleInfo.qbsName = moduleInfo.qbsName.replace("_private", "-private"); + var hasV2 = false; + var hasModuleEntry = false; + var lines = getFileContentsRecursively(priFilePath); + if (moduleInfo.isExternal) { + moduleInfo.name = "qt" + moduleInfo.qbsName; + moduleInfo.isStaticLibrary = true; + for (var k = 0; k < lines.length; ++k) { + var extLine = lines[k].trim(); + var extFirstEqualsOffset = extLine.indexOf('='); + if (extFirstEqualsOffset === -1) + continue; + var extKey = extLine.slice(0, extFirstEqualsOffset).trim(); + var extValue = extLine.slice(extFirstEqualsOffset + 1).trim(); + if (!extKey.startsWith("QMAKE_") || !extValue) + continue; + + var elements = extKey.split('_'); + if (elements.length >= 3) { + if (elements[1] === "LIBS") { + extValue = extValue.replace("/home/qt/work/qt/qtbase/lib", + qtProps.libraryPath); + extValue = extValue.replace("$$[QT_INSTALL_LIBS]", qtProps.libraryPath); + extValue = extValue.replace("$$[QT_INSTALL_LIBS/get]", qtProps.libraryPath); + if (elements.length === 4 ) { + if (elements[3] === androidAbi) { + moduleInfo.staticLibrariesRelease.push(extValue); + moduleInfo.staticLibrariesDebug.push(extValue); + } + } else if (elements.length === 5 ) { + // That's for "x86_64" + var abi = elements[3] + '_' + elements[4]; + if (abi === androidAbi) { + moduleInfo.staticLibrariesRelease.push(extValue); + moduleInfo.staticLibrariesDebug.push(extValue); + } + } else { + moduleInfo.staticLibrariesRelease.push(extValue); + moduleInfo.staticLibrariesDebug.push(extValue); + } + } else if (elements[1] === "INCDIR") { + moduleInfo.includePaths.push(extValue.replace("$$[QT_INSTALL_HEADERS]", + qtProps.includePath)); + } + } + } + moduleInfo.compilerDefines.push("QT_" + moduleInfo.qbsName.toUpperCase() + "_LIB"); + moduleInfo.mustExist = false; + } else { + for (var j = 0; j < lines.length; ++j) { + var line = lines[j].trim(); + var firstEqualsOffset = line.indexOf('='); + if (firstEqualsOffset === -1) + continue; + var key = line.slice(0, firstEqualsOffset).trim(); + var value = line.slice(firstEqualsOffset + 1).trim(); + if (!key.startsWith(moduleKeyPrefix) || !value) + continue; + if (key.endsWith(".name")) { + moduleInfo.name = value; + } else if (key.endsWith(".module")) { + hasModuleEntry = true; + } else if (key.endsWith(".depends")) { + moduleInfo.dependencies = splitNonEmpty(value, ' '); + for (var k = 0; k < moduleInfo.dependencies.length; ++k) { + moduleInfo.dependencies[k] + = moduleInfo.dependencies[k].replace("_private", "-private"); + } + } else if (key.endsWith(".module_config")) { + var elems = splitNonEmpty(value, ' '); + for (k = 0; k < elems.length; ++k) { + var elem = elems[k]; + if (elem === "no_link") + moduleInfo.hasLibrary = false; + else if (elem === "staticlib") + moduleInfo.isStaticLibrary = true; + else if (elem === "internal_module") + moduleInfo.isPrivate = true; + else if (elem === "v2") + hasV2 = true; + } + } else if (key.endsWith(".includes")) { + moduleInfo.includePaths = extractPaths(value, priFilePath); + for (k = 0; k < moduleInfo.includePaths.length; ++k) { + moduleInfo.includePaths[k] = moduleInfo.includePaths[k] + .replace("$$QT_MODULE_INCLUDE_BASE", qtProps.includePath) + .replace("$$QT_MODULE_HOST_LIB_BASE", qtProps.hostLibraryPath) + .replace("$$QT_MODULE_LIB_BASE", qtProps.libraryPath); + } + } else if (key.endsWith(".libs")) { + var libDirs = extractPaths(value, priFilePath); + if (libDirs.length === 1) { + moduleInfo.libDir = libDirs[0] + .replace("$$QT_MODULE_HOST_LIB_BASE", qtProps.hostLibraryPath) + .replace("$$QT_MODULE_LIB_BASE", qtProps.libraryPath); + } else { + moduleInfo.libDir = qtProps.libraryPath; + } + } else if (key.endsWith(".DEFINES")) { + moduleInfo.compilerDefines = splitNonEmpty(value, ' '); + } else if (key.endsWith(".VERSION")) { + moduleInfo.version = value; + } else if (key.endsWith(".plugin_types")) { + moduleInfo.supportedPluginTypes = splitNonEmpty(value, ' '); + } else if (key.endsWith(".TYPE")) { + moduleInfo.pluginData.type = value; + } else if (key.endsWith(".EXTENDS")) { + moduleInfo.pluginData["extends"] = splitNonEmpty(value, ' '); + for (k = 0; k < moduleInfo.pluginData["extends"].length; ++k) { + if (moduleInfo.pluginData["extends"][k] === "-") { + moduleInfo.pluginData["extends"].splice(k, 1); + moduleInfo.pluginData.autoLoad = false; + break; + } + } + } else if (key.endsWith(".CLASS_NAME")) { + moduleInfo.pluginData.className = value; + } + } + } + if (hasV2 && !hasModuleEntry) + moduleInfo.hasLibrary = false; + + // Fix include paths for Apple frameworks. + // The qt_lib_XXX.pri files contain wrong values for versions < 5.6. + if (!hasV2 && isFramework(moduleInfo, qtProps)) { + moduleInfo.includePaths = []; + var baseIncDir = frameworkHeadersPath(moduleInfo, qtProps); + if (moduleInfo.isPrivate) { + baseIncDir = FileInfo.joinPaths(baseIncDir, moduleInfo.version); + moduleInfo.includePaths.push(baseIncDir, + FileInfo.joinPaths(baseIncDir, moduleInfo.name)); + } else { + moduleInfo.includePaths.push(baseIncDir); + } + } + + setupLibraries(moduleInfo, qtProps, nonExistingPrlFiles, androidAbi); + + modules.push(moduleInfo); + if (moduleInfo.qbsName === "testlib") + addTestModule(modules); + if (moduleInfo.qbsName === "designercomponents-private") + addDesignerComponentsModule(modules); + } + + replaceQtLibNamesWithFilePath(modules, qtProps); + removeDuplicatedDependencyLibs(modules); + return modules; +} + +function extractQbsArchs(module, qtProps) { + if (qtProps.mkspecName.startsWith("macx-")) { + var archs = []; + if (module.libFilePathRelease) + archs = Utilities.getArchitecturesFromBinary(module.libFilePathRelease); + return archs; + } + var qbsArch = Utilities.canonicalArchitecture(qtProps.architecture); + if (qbsArch === "arm" && qtProps.mkspecPath.contains("android")) + qbsArch = "armv7a"; + // Qt4 has "QT_ARCH = windows" in qconfig.pri for both MSVC and mingw. + if (qbsArch === "windows") + return [] + + return [qbsArch]; +} + +function qbsTargetPlatformFromQtMkspec(qtProps) { + var mkspec = qtProps.mkspecName; + var idx = mkspec.lastIndexOf('/'); + if (idx !== -1) + mkspec = mkspec.slice(idx + 1); + if (mkspec.startsWith("aix-")) + return "aix"; + if (mkspec.startsWith("android-")) + return "android"; + if (mkspec.startsWith("cygwin-")) + return "windows"; + if (mkspec.startsWith("darwin-")) + return "macos"; + if (mkspec.startsWith("freebsd-")) + return "freebsd"; + if (mkspec.startsWith("haiku-")) + return "haiku"; + if (mkspec.startsWith(("hpux-")) || mkspec.startsWith(("hpuxi-"))) + return "hpux"; + if (mkspec.startsWith("hurd-")) + return "hurd"; + if (mkspec.startsWith("integrity-")) + return "integrity"; + if (mkspec.startsWith("linux-")) + return "linux"; + if (mkspec.startsWith("macx-")) { + if (mkspec.startsWith("macx-ios-")) + return "ios"; + if (mkspec.startsWith("macx-tvos-")) + return "tvos"; + if (mkspec.startsWith("macx-watchos-")) + return "watchos"; + return "macos"; + } + if (mkspec.startsWith("netbsd-")) + return "netbsd"; + if (mkspec.startsWith("openbsd-")) + return "openbsd"; + if (mkspec.startsWith("qnx-")) + return "qnx"; + if (mkspec.startsWith("solaris-")) + return "solaris"; + if (mkspec.startsWith("vxworks-")) + return "vxworks"; + if (targetsDesktopWindows(qtProps) || mkspec.startsWith("winrt-")) + return "windows"; +} + +function pathToJSLiteral(path) { return JSON.stringify(FileInfo.fromNativeSeparators(path)); } + +function defaultQpaPlugin(module, qtProps) { + if (qtProps.qtMajorVersion < 5) + return undefined; + if (qtProps.qtMajorVersion === 5 && qtProps.qtMinorVersion < 8) { + var qConfigPri = new TextFile(FileInfo.joinPaths(qtProps.mkspecBasePath, "qconfig.pri")); + var magicString = "QT_DEFAULT_QPA_PLUGIN ="; + while (!qConfigPri.atEof()) { + var line = qConfigPri.readLine().trim(); + if (line.startsWith(magicString)) + return line.slice(magicString.length).trim(); + } + qConfigPri.close(); + } else { + var gtGuiHeadersPath = qtProps.frameworkBuild + ? FileInfo.joinPaths(qtProps.libraryPath, "QtGui.framework", "Headers") + : FileInfo.joinPaths(qtProps.includePath, "QtGui"); + var qtGuiConfigHeader = FileInfo.joinPaths(gtGuiHeadersPath, "qtgui-config.h"); + var headerFiles = []; + headerFiles.push(qtGuiConfigHeader); + while (headerFiles.length > 0) { + var filePath = headerFiles.shift(); + var headerFile = new TextFile(filePath, TextFile.ReadOnly); + var regexp = /^#define QT_QPA_DEFAULT_PLATFORM_NAME "(.+)".*$/; + var includeRegexp = /^#include "(.+)".*$/; + while (!headerFile.atEof()) { + line = headerFile.readLine().trim(); + var match = line.match(regexp); + if (match) + return 'q' + match[1]; + match = line.match(includeRegexp); + if (match) { + var includedFile = match[1]; + if (!FileInfo.isAbsolutePath(includedFile)) { + includedFile = FileInfo.cleanPath( + FileInfo.joinPaths(FileInfo.path(filePath), includedFile)); + } + headerFiles.push(includedFile); + } + } + headerFile.close(); + } + } + + if (module.isStaticLibrary) + console.warn("Could not determine default QPA plugin for static Qt."); +} + +function libraryFileTag(module, qtProps) { + if (module.isStaticLibrary) + return "staticlibrary"; + return isMsvcQt(qtProps) || qtProps.mkspecName.startsWith("win32-g++") + ? "dynamiclibrary_import" : "dynamiclibrary"; +} + +function findVariable(content, start) { + var result = [-1, -1]; + result[0] = content.indexOf('@', start); + if (result[0] === -1) + return result; + result[1] = content.indexOf('@', result[0] + 1); + if (result[1] === -1) { + result[0] = -1; + return result; + } + var forbiddenChars = [' ', '\n']; + for (var i = 0; i < forbiddenChars.length; ++i) { + var forbidden = forbiddenChars[i]; + var k = content.indexOf(forbidden, result[0] + 1); + if (k !== -1 && k < result[1]) + return findVariable(content, result[0] + 1); + } + return result; +} + +function minVersionJsString(minVersion) { + return !minVersion ? "original" : ModUtils.toJSLiteral(minVersion); +} + +function replaceSpecialValues(content, module, qtProps, abi) { + var architectures = []; + if (abi.length > 0) + architectures.push(abiToArchitecture(abi)); + else + architectures = extractQbsArchs(module, qtProps); + var dict = { + archs: ModUtils.toJSLiteral(architectures), + targetPlatform: ModUtils.toJSLiteral(qbsTargetPlatformFromQtMkspec(qtProps)), + config: ModUtils.toJSLiteral(qtProps.configItems), + qtConfig: ModUtils.toJSLiteral(qtProps.qtConfigItems), + binPath: ModUtils.toJSLiteral(qtProps.binaryPath), + installPath: ModUtils.toJSLiteral(qtProps.installPath), + installPrefixPath: ModUtils.toJSLiteral(qtProps.installPrefixPath), + libPath: ModUtils.toJSLiteral(qtProps.libraryPath), + libExecPath: ModUtils.toJSLiteral(qtProps.libExecPath), + qmlLibExecPath: ModUtils.toJSLiteral(qtProps.qmlLibExecPath), + pluginPath: ModUtils.toJSLiteral(qtProps.pluginPath), + incPath: ModUtils.toJSLiteral(qtProps.includePath), + docPath: ModUtils.toJSLiteral(qtProps.documentationPath), + helpGeneratorLibExecPath: ModUtils.toJSLiteral(qtProps.helpGeneratorLibExecPath), + mkspecName: ModUtils.toJSLiteral(qtProps.mkspecName), + mkspecPath: ModUtils.toJSLiteral(qtProps.mkspecPath), + version: ModUtils.toJSLiteral(qtProps.qtVersion), + libInfix: ModUtils.toJSLiteral(qtProps.qtLibInfix), + availableBuildVariants: ModUtils.toJSLiteral(qtProps.buildVariant), + staticBuild: ModUtils.toJSLiteral(qtProps.staticBuild), + frameworkBuild: ModUtils.toJSLiteral(qtProps.frameworkBuild), + name: ModUtils.toJSLiteral(moduleNameWithoutPrefix(module)), + has_library: ModUtils.toJSLiteral(module.hasLibrary), + dependencies: ModUtils.toJSLiteral(module.dependencies), + includes: ModUtils.toJSLiteral(module.includePaths), + staticLibsDebug: ModUtils.toJSLiteral(module.staticLibrariesDebug), + staticLibsRelease: ModUtils.toJSLiteral(module.staticLibrariesRelease), + dynamicLibsDebug: ModUtils.toJSLiteral(module.dynamicLibrariesDebug), + dynamicLibsRelease: ModUtils.toJSLiteral(module.dynamicLibrariesRelease), + linkerFlagsDebug: ModUtils.toJSLiteral(module.linkerFlagsDebug), + linkerFlagsRelease: ModUtils.toJSLiteral(module.linkerFlagsRelease), + libraryPaths: ModUtils.toJSLiteral(module.libraryPaths), + frameworkPathsDebug: ModUtils.toJSLiteral(module.frameworkPathsDebug), + frameworkPathsRelease: ModUtils.toJSLiteral(module.frameworkPathsRelease), + frameworksDebug: ModUtils.toJSLiteral(module.frameworksDebug), + frameworksRelease: ModUtils.toJSLiteral(module.frameworksRelease), + libFilePathDebug: ModUtils.toJSLiteral(module.libFilePathDebug), + libFilePathRelease: ModUtils.toJSLiteral(module.libFilePathRelease), + libNameForLinkerDebug: ModUtils.toJSLiteral(libNameForLinker(module, qtProps, true)), + pluginTypes: ModUtils.toJSLiteral(module.supportedPluginTypes), + moduleConfig: ModUtils.toJSLiteral(module.config), + libNameForLinkerRelease: ModUtils.toJSLiteral(libNameForLinker(module, qtProps, false)), + entryPointLibsDebug: ModUtils.toJSLiteral(qtProps.entryPointLibsDebug), + entryPointLibsRelease: ModUtils.toJSLiteral(qtProps.entryPointLibsRelease), + minWinVersion: minVersionJsString(qtProps.windowsVersion), + minMacVersion: minVersionJsString(qtProps.macosVersion), + minIosVersion: minVersionJsString(qtProps.iosVersion), + minTvosVersion: minVersionJsString(qtProps.tvosVersion), + minWatchosVersion: minVersionJsString(qtProps.watchosVersion), + minAndroidVersion: minVersionJsString(qtProps.androidVersion), + }; + + var additionalContent = ""; + var compilerDefines = ModUtils.toJSLiteral(module.compilerDefines); + if (module.qbsName === "declarative" || module.qbsName === "quick") { + var debugMacro = module.qbsName === "declarative" || qtProps.qtMajorVersion < 5 + ? "QT_DECLARATIVE_DEBUG" : "QT_QML_DEBUG"; + var indent = " "; + additionalContent = "property bool qmlDebugging: false\n" + + indent + "property string qmlPath"; + if (qtProps.qmlPath) + additionalContent += ": " + pathToJSLiteral(qtProps.qmlPath) + '\n'; + else + additionalContent += '\n'; + + additionalContent += indent + "property string qmlImportsPath: " + + pathToJSLiteral(qtProps.qmlImportPath); + + compilerDefines = "{\n" + + indent + indent + "var result = " + compilerDefines + ";\n" + + indent + indent + "if (qmlDebugging)\n" + + indent + indent + indent + "result.push(\"" + debugMacro + "\");\n" + + indent + indent + "return result;\n" + + indent + "}"; + } + dict.defines = compilerDefines; + if (module.qbsName === "gui") + dict.defaultQpaPlugin = ModUtils.toJSLiteral(defaultQpaPlugin(module, qtProps)); + if (module.qbsName === "qml") + dict.qmlPath = pathToJSLiteral(qtProps.qmlPath); + if (module.isStaticLibrary && module.qbsName !== "core") { + if (additionalContent) + additionalContent += "\n "; + additionalContent += "isStaticLibrary: true"; + } + if (module.isPlugin) { + dict.className = ModUtils.toJSLiteral(module.pluginData.className); + dict["extends"] = ModUtils.toJSLiteral(module.pluginData["extends"]); + } + indent = " "; + var metaTypesFile = qtProps.libraryPath + "/metatypes/qt" + + qtProps.qtMajorVersion + module.qbsName + "_metatypes.json"; + if (File.exists(metaTypesFile)) { + if (additionalContent) + additionalContent += "\n" + indent; + additionalContent += "Group {\n"; + additionalContent += indent + indent + "files: " + JSON.stringify(metaTypesFile) + "\n" + + indent + indent + "filesAreTargets: true\n" + + indent + indent + "fileTags: [\"qt.core.metatypes\"]\n" + + indent + "}"; + } + if (module.hasLibrary && !isFramework(module, qtProps)) { + if (additionalContent) + additionalContent += "\n" + indent; + additionalContent += "Group {\n"; + if (module.isPlugin) { + additionalContent += indent + indent + + "condition: Qt[\"" + module.qbsName + "\"].enableLinking\n"; + } + additionalContent += indent + indent + "files: [Qt[\"" + module.qbsName + "\"]" + + ".libFilePath]\n" + + indent + indent + "filesAreTargets: true\n" + + indent + indent + "fileTags: [\"" + libraryFileTag(module, qtProps) + + "\"]\n" + + indent + "}"; + } + dict.additionalContent = additionalContent; + + for (var pos = findVariable(content, 0); pos[0] !== -1; + pos = findVariable(content, pos[0])) { + var replacement = dict[content.slice(pos[0] + 1, pos[1])] || ""; + content = content.slice(0, pos[0]) + replacement + content.slice(pos[1] + 1); + pos[0] += replacement.length; + } + return content; +} + +function copyTemplateFile(fileName, targetDirectory, qtProps, abi, location, allFiles, module, + pluginMap, nonEssentialPlugins) +{ + if (!File.makePath(targetDirectory)) { + throw "Cannot create directory '" + toNative(targetDirectory) + "'."; + } + var sourceFile = new TextFile(FileInfo.joinPaths(location, "templates", fileName), + TextFile.ReadOnly); + var newContent = sourceFile.readAll(); + if (module) { + newContent = replaceSpecialValues(newContent, module, qtProps, abi); + } else { + newContent = newContent.replace("@allPluginsByType@", + '(' + ModUtils.toJSLiteral(pluginMap) + ')'); + newContent = newContent.replace("@nonEssentialPlugins@", + ModUtils.toJSLiteral(nonEssentialPlugins)); + newContent = newContent.replace("@version@", ModUtils.toJSLiteral(qtProps.qtVersion)); + } + sourceFile.close(); + var targetPath = FileInfo.joinPaths(targetDirectory, fileName); + allFiles.push(targetPath); + var targetFile = new TextFile(targetPath, TextFile.WriteOnly); + targetFile.write(newContent); + targetFile.close(); +} + +function setupOneQt(qmakeFilePath, outputBaseDir, uniquify, location, qbs) { + if (!File.exists(qmakeFilePath)) + throw "The specified qmake file path '" + toNative(qmakeFilePath) + "' does not exist."; + var qtProps = getQtProperties(qmakeFilePath, qbs); + var androidAbis = []; + if (qtProps.androidAbis !== undefined) + // Multiple androidAbis detected: Qt >= 5.14 + androidAbis = qtProps.androidAbis; + else + // Single abi detected: Qt < 5.14 + androidAbis.push(''); + if (androidAbis.length > 1) + console.info("Qt with multiple abi detected: '" + androidAbis + "'"); + + var relativeSearchPaths = []; + for (a = 0; a < androidAbis.length; ++a) { + if (androidAbis.length > 1) + console.info("Configuring abi '" + androidAbis[a] + "'..."); + var modules = qtProps.qtMajorVersion < 5 ? allQt4Modules(qtProps) : + allQt5Modules(qtProps,androidAbis[a]); + var pluginsByType = {}; + var nonEssentialPlugins = []; + for (var i = 0; i < modules.length; ++i) { + var m = modules[i]; + if (m.isPlugin) { + if (!pluginsByType[m.pluginData.type]) + pluginsByType[m.pluginData.type] = []; + pluginsByType[m.pluginData.type].push(m.name); + if (!m.pluginData.autoLoad) + nonEssentialPlugins.push(m.name); + } + } + + var relativeSearchPath = uniquify ? Utilities.getHash(qmakeFilePath) : ""; + relativeSearchPath = FileInfo.joinPaths(relativeSearchPath, androidAbis[a]); + var qbsQtModuleBaseDir = FileInfo.joinPaths(outputBaseDir, relativeSearchPath, + "modules", "Qt"); + if (File.exists(qbsQtModuleBaseDir)) + File.remove(qbsQtModuleBaseDir); + + var allFiles = []; + copyTemplateFile("QtModule.qbs", qbsQtModuleBaseDir, qtProps, androidAbis[a], location, + allFiles); + copyTemplateFile("QtPlugin.qbs", qbsQtModuleBaseDir, qtProps, androidAbis[a], location, + allFiles); + copyTemplateFile("plugin_support.qbs", + FileInfo.joinPaths(qbsQtModuleBaseDir, "plugin_support"), qtProps, + androidAbis[a], location, allFiles, undefined, pluginsByType, + nonEssentialPlugins); + + for (i = 0; i < modules.length; ++i) { + var module = modules[i]; + var qbsQtModuleDir = FileInfo.joinPaths(qbsQtModuleBaseDir, module.qbsName); + var moduleTemplateFileName; + if (module.qbsName === "core") { + moduleTemplateFileName = "core.qbs"; + copyTemplateFile("moc.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + copyTemplateFile("qdoc.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + copyTemplateFile("rcc.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + } else if (module.qbsName === "gui") { + moduleTemplateFileName = "gui.qbs"; + } else if (module.qbsName === "scxml") { + moduleTemplateFileName = "scxml.qbs"; + } else if (module.qbsName === "dbus") { + moduleTemplateFileName = "dbus.qbs"; + copyTemplateFile("dbus.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + } else if (module.qbsName === "qml") { + moduleTemplateFileName = "qml.qbs"; + copyTemplateFile("qml.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + var qmlcacheStr = "qmlcache"; + if (File.exists(FileInfo.joinPaths(qtProps.qmlLibExecPath, + "qmlcachegen" + exeSuffix(qbs)))) { + copyTemplateFile(qmlcacheStr + ".qbs", + FileInfo.joinPaths(qbsQtModuleBaseDir, qmlcacheStr), qtProps, + androidAbis[a], location, allFiles); + } + } else if (module.qbsName === "quick") { + moduleTemplateFileName = "quick.qbs"; + copyTemplateFile("quick.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + copyTemplateFile("rcc.js", qbsQtModuleDir, qtProps, androidAbis[a], location, + allFiles); + } else if (module.isPlugin) { + moduleTemplateFileName = "plugin.qbs"; + } else { + moduleTemplateFileName = "module.qbs"; + } + copyTemplateFile(moduleTemplateFileName, qbsQtModuleDir, qtProps, androidAbis[a], + location, allFiles, module); + } + + // Note that it's not strictly necessary to copy this one, as it has no variable content. + // But we do it anyway for consistency. + copyTemplateFile("android_support.qbs", + FileInfo.joinPaths(qbsQtModuleBaseDir, "android_support"), + qtProps, androidAbis[a], location, allFiles); + relativeSearchPaths.push(relativeSearchPath) + } + return relativeSearchPaths; +} + +function doSetup(qmakeFilePaths, outputBaseDir, location, qbs) { + qmakeFilePaths = getQmakeFilePaths(qmakeFilePaths, qbs); + if (!qmakeFilePaths || qmakeFilePaths.length === 0) + return []; + var uniquifySearchPath = qmakeFilePaths.length > 1; + var allSearchPaths = []; + for (var i = 0; i < qmakeFilePaths.length; ++i) { + try { + console.info("Setting up Qt at '" + toNative(qmakeFilePaths[i]) + "'..."); + var searchPaths = setupOneQt(qmakeFilePaths[i], outputBaseDir, uniquifySearchPath, + location, qbs); + if (searchPaths.length > 0) { + for (var j = 0; j < searchPaths.length; ++j ) + allSearchPaths.push(searchPaths[j]); + console.info("Qt was set up successfully."); + } + } catch (e) { + console.warn("Error setting up Qt for '" + toNative(qmakeFilePaths[i]) + "': " + e); + } + } + return allSearchPaths; +} diff --git a/share/qbs/module-providers/Qt/templates/QtModule.qbs b/share/qbs/module-providers/Qt/templates/QtModule.qbs new file mode 100644 index 00000000..62e05327 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/QtModule.qbs @@ -0,0 +1,86 @@ +import qbs.FileInfo + +Module { + condition: (qbs.targetPlatform === targetPlatform || isCombinedUIKitBuild) + && (!qbs.architecture + || architectures.length === 0 + || architectures.contains(qbs.architecture)) + + readonly property bool isCombinedUIKitBuild: ["ios", "tvos", "watchos"].contains(targetPlatform) + && ["x86", "x86_64"].contains(qbs.architecture) + && qbs.targetPlatform === targetPlatform + "-simulator" + + Depends { name: "cpp" } + Depends { name: "Qt.core" } + + Depends { name: "Qt.plugin_support" } + property stringList pluginTypes + Qt.plugin_support.pluginTypes: pluginTypes + Depends { + condition: Qt.core.staticBuild && !isPlugin + name: "Qt"; + submodules: { + // We have to pull in all plugins here, because dependency resolving happens + // before module merging, and we don't know yet if someone set + // Qt.pluginSupport.pluginsByType in the product. + // The real filtering is done later by the plugin module files themselves. + var list = []; + var allPlugins = Qt.plugin_support.allPluginsByType; + for (var i = 0; i < (pluginTypes || []).length; ++i) + Array.prototype.push.apply(list, allPlugins[pluginTypes[i]]) + return list; + } + } + + property string qtModuleName + property path binPath: Qt.core.binPath + property path incPath: Qt.core.incPath + property path libPath: Qt.core.libPath + property string qtLibInfix: Qt.core.libInfix + property string libNameForLinkerDebug + property string libNameForLinkerRelease + property string libNameForLinker: Qt.core.qtBuildVariant === "debug" + ? libNameForLinkerDebug : libNameForLinkerRelease + property string libFilePathDebug + property string libFilePathRelease + property string libFilePath: Qt.core.qtBuildVariant === "debug" + ? libFilePathDebug : libFilePathRelease + version: Qt.core.version + property bool hasLibrary: true + property bool isStaticLibrary: false + property bool isPlugin: false + + property stringList architectures + property string targetPlatform + property stringList staticLibsDebug + property stringList staticLibsRelease + property stringList dynamicLibsDebug + property stringList dynamicLibsRelease + property stringList linkerFlagsDebug + property stringList linkerFlagsRelease + property stringList staticLibs: Qt.core.qtBuildVariant === "debug" + ? staticLibsDebug : staticLibsRelease + property stringList dynamicLibs: Qt.core.qtBuildVariant === "debug" + ? dynamicLibsDebug : dynamicLibsRelease + property stringList frameworksDebug + property stringList frameworksRelease + property stringList frameworkPathsDebug + property stringList frameworkPathsRelease + property stringList mFrameworks: Qt.core.qtBuildVariant === "debug" + ? frameworksDebug : frameworksRelease + property stringList mFrameworkPaths: Qt.core.qtBuildVariant === "debug" + ? frameworkPathsDebug: frameworkPathsRelease + cpp.linkerFlags: Qt.core.qtBuildVariant === "debug" + ? linkerFlagsDebug : linkerFlagsRelease + property bool enableLinking: qtModuleName != undefined && hasLibrary + property stringList moduleConfig + + Properties { + condition: enableLinking + cpp.staticLibraries: staticLibs + cpp.dynamicLibraries: dynamicLibs + cpp.frameworks: mFrameworks.concat(!isStaticLibrary && Qt.core.frameworkBuild + ? [libNameForLinker] : []) + cpp.systemFrameworkPaths: mFrameworkPaths + } +} diff --git a/share/qbs/module-providers/Qt/templates/QtPlugin.qbs b/share/qbs/module-providers/Qt/templates/QtPlugin.qbs new file mode 100644 index 00000000..883e3446 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/QtPlugin.qbs @@ -0,0 +1,51 @@ +import qbs.FileInfo +import qbs.TextFile + +QtModule { + isPlugin: true + + property string className + property stringList extendsModules + + enableLinking: { + if (!base) + return false; + if (!isStaticLibrary) + return false; + if (!Qt.plugin_support.linkPlugins) + return false; + if (!(Qt.plugin_support.enabledPlugins || []).contains(qtModuleName)) + return false; + if (!extendsModules || extendsModules.length === 0) + return true; + for (var i = 0; i < extendsModules.length; ++i) { + var moduleName = extendsModules[i]; + if (product.Qt[moduleName] && product.Qt[moduleName].present) + return true; + } + return false; + } + + Rule { + condition: enableLinking + multiplex: true + Artifact { + filePath: product.targetName + "_qt_plugin_import_" + + product.moduleProperty(product.moduleName, "qtModuleName") + ".cpp" + fileTags: "cpp" + } + + prepare: { + var cmd = new JavaScriptCommand(); + var pluginName = product.moduleProperty(product.moduleName, "qtModuleName"); + cmd.description = "creating static import for plugin '" + pluginName + "'"; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + var className = product.moduleProperty(product.moduleName, "className"); + f.writeLine("#include \n\nQ_IMPORT_PLUGIN(" + className + ")"); + f.close(); + }; + return cmd; + } + } +} diff --git a/share/qbs/module-providers/Qt/templates/android_support.qbs b/share/qbs/module-providers/Qt/templates/android_support.qbs new file mode 100644 index 00000000..68276070 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/android_support.qbs @@ -0,0 +1,542 @@ +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.TextFile +import qbs.Utilities +import qbs.Process +import qbs.Xml + +Module { + version: @version@ + property string qmlRootDir: product.sourceDirectory + property stringList extraPrefixDirs + property stringList qmlImportPaths + property stringList deploymentDependencies // qmake: ANDROID_DEPLOYMENT_DEPENDENCIES + property stringList extraPlugins // qmake: ANDROID_EXTRA_PLUGINS + property stringList extraLibs // qmake: ANDROID_EXTRA_LIBS + property bool verboseAndroidDeployQt: false + property string _androidDeployQtFilePath: FileInfo.joinPaths(_qtBinaryDir, "bin", + "androiddeployqt") + property string rccFilePath + property string _qtBinaryDir + property string _qtInstallDir + property bool _enableSdkSupport: product.type && product.type.contains("android.package") + && !consoleApplication + property bool _enableNdkSupport: !product.aggregate || product.multiplexConfigurationId + property string _templatesBaseDir: FileInfo.joinPaths(_qtInstallDir, "src", "android") + property string _deployQtOutDir: FileInfo.joinPaths(product.buildDirectory, "deployqt_out") + + property bool _multiAbi: Utilities.versionCompare(version, "5.14") >= 0 + + // QTBUG-87288: correct QtNetwork jar dependencies for 5.15.0 < Qt < 5.15.3 + property bool _correctQtNetworkDependencies: Utilities.versionCompare(version, "5.15.0") > 0 && + Utilities.versionCompare(version, "5.15.3") < 0 + + Depends { name: "Android.sdk"; condition: _enableSdkSupport } + Depends { name: "Android.ndk"; condition: _enableNdkSupport } + Depends { name: "java"; condition: _enableSdkSupport } + Depends { name: "cpp"; condition: _enableNdkSupport } + + Properties { + condition: _enableNdkSupport && qbs.toolchain.contains("clang") + Android.ndk.appStl: "c++_shared" + } + Properties { + condition: _enableNdkSupport && !qbs.toolchain.contains("clang") + Android.ndk.appStl: "gnustl_shared" + } + Properties { + condition: _enableSdkSupport + Android.sdk.customManifestProcessing: true + java._tagJniHeaders: false // prevent rule cycle + } + readonly property string _qtAndroidJarFileName: Utilities.versionCompare(version, "6.0") >= 0 ? + "Qt6Android.jar" : "QtAndroid.jar" + Properties { + condition: _enableSdkSupport && Utilities.versionCompare(version, "5.15") >= 0 + && Utilities.versionCompare(version, "6.0") < 0 + java.additionalClassPaths: [FileInfo.joinPaths(_qtInstallDir, "jar", "QtAndroid.jar")] + } + Properties { + condition: _enableSdkSupport && Utilities.versionCompare(version, "6.0") >= 0 + java.additionalClassPaths: [FileInfo.joinPaths(_qtInstallDir, "jar", "Qt6Android.jar")] + } + // "ANDROID_HAS_WSTRING" was removed from qtcore qstring.h in Qt 5.14.0 + Properties { + condition: _enableNdkSupport && Utilities.versionCompare(version, "5.14.0") < 0 && + (Android.ndk.abi === "armeabi-v7a" || Android.ndk.abi === "x86") + cpp.defines: "ANDROID_HAS_WSTRING" + } + Properties { + condition: _enableSdkSupport + Android.sdk._bundledInAssets: _multiAbi + } + Properties { + condition: _enableSdkSupport && Utilities.versionCompare(version, "6.0") < 0 + Android.sdk.minimumVersion: "21" + } + Properties { + condition: _enableSdkSupport && Utilities.versionCompare(version, "6.0") >= 0 + Android.sdk.minimumVersion: "23" + } + + Properties { + condition: _enableNdkSupport + cpp.archSuffix: _multiAbi ? "_" + Android.ndk.abi : "" + } + + Rule { + condition: _enableSdkSupport + multiplex: true + property stringList inputTags: ["android.nativelibrary", "qrc"] + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + Artifact { + filePath: "androiddeployqt.json" + fileTags: "qt_androiddeployqt_input" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.sourceCode = function() { + var theBinary; + var nativeLibs = inputs["android.nativelibrary"]; + var architectures = []; + var triples = []; + var qtInstallDirectories = []; + var hostArch; + var targetArchitecture; + if (nativeLibs.length === 1) { + theBinary = nativeLibs[0]; + hostArch = theBinary.Android.ndk.hostArch; + targetArchitecture = theBinary.Android.ndk.abi; + if (product.Qt.android_support._multiAbi) { + architectures.push(theBinary.Android.ndk.abi); + triples.push(theBinary.cpp.toolchainTriple); + qtInstallDirectories.push(theBinary.Qt.android_support._qtInstallDir); + } + } else { + for (i = 0; i < nativeLibs.length; ++i) { + var candidate = nativeLibs[i]; + if (product.Qt.android_support._multiAbi) { + if (candidate.product.name === product.name) { + architectures.push(candidate.Android.ndk.abi); + triples.push(candidate.cpp.toolchainTriple); + qtInstallDirectories.push( + candidate.Qt.android_support._qtInstallDir); + hostArch = candidate.Android.ndk.hostArch; + targetArchitecture = candidate.Android.ndk.abi; + theBinary = candidate; + } + } else { + if (!candidate.fileName.contains(candidate.product.targetName)) + continue; + if (!theBinary) { + theBinary = candidate; + hostArch = theBinary.Android.ndk.hostArch; + targetArchitecture = theBinary.Android.ndk.abi; + continue; + } + if (candidate.product.name !== product.name) { + continue; // This is not going to be a match + } + if (candidate.product.name === product.name + && theBinary.product.name !== product.name) { + theBinary = candidate; // The new candidate is a better match. + hostArch = theBinary.Android.ndk.hostArch; + targetArchitecture = theBinary.Android.ndk.abi; + continue; + } + + throw "Qt applications for Android support only one native binary " + + "per package.\n" + + "In particular, you cannot build a Qt app for more than " + + "one architecture at the same time."; + } + } + } + var f = new TextFile(output.filePath, TextFile.WriteOnly); + f.writeLine("{"); + f.writeLine('"description": "This file was generated by qbs to be read by ' + + 'androiddeployqt and should not be modified by hand.",'); + if (Utilities.versionCompare(product.Qt.core.version, "6.3.0") >= 0) { + var line = '"qt": {'; + for (var i = 0; i < qtInstallDirectories.length && i < architectures.length; + ++i) { + line = line + '"' + architectures[i] + '":"' + + qtInstallDirectories[i] + '"'; + if (i < qtInstallDirectories.length-1 || i < architectures.length-1) + line = line + ','; + } + line = line + "},"; + f.writeLine(line); + } else { + f.writeLine('"qt": "' + product.Qt.android_support._qtInstallDir + '",'); + } + f.writeLine('"sdk": "' + product.Android.sdk.sdkDir + '",'); + f.writeLine('"sdkBuildToolsRevision": "' + product.Android.sdk.buildToolsVersion + + '",'); + f.writeLine('"ndk": "' + product.Android.sdk.ndkDir + '",'); + f.writeLine('"toolchain-prefix": "llvm",'); + f.writeLine('"tool-prefix": "llvm",'); + f.writeLine('"useLLVM": true,'); + f.writeLine('"ndk-host": "' + hostArch + '",'); + if (!product.Qt.android_support._multiAbi) { + f.writeLine('"target-architecture": "' + targetArchitecture + '",'); + } + else { + var line = '"architectures": {'; + for (var i in architectures) { + line = line + '"' + architectures[i] + '":"' + triples[i] + '"'; + if (i < architectures.length-1) + line = line + ','; + } + line = line + "},"; + f.writeLine(line); + } + f.writeLine('"qml-root-path": "' + product.Qt.android_support.qmlRootDir + '",'); + var deploymentDeps = product.Qt.android_support.deploymentDependencies; + if (deploymentDeps && deploymentDeps.length > 0) + f.writeLine('"deployment-dependencies": "' + deploymentDeps.join() + '",'); + var extraPlugins = product.Qt.android_support.extraPlugins; + if (extraPlugins && extraPlugins.length > 0) + f.writeLine('"android-extra-plugins": "' + extraPlugins.join() + '",'); + var extraLibs = product.Qt.android_support.extraLibs; + if (extraLibs && extraLibs.length > 0) { + for (var i = 0; i < extraLibs.length; ++i) { + if (!FileInfo.isAbsolutePath(extraLibs[i])) { + extraLibs[i] = FileInfo.joinPaths(product.sourceDirectory, extraLibs[i]); + } + } + f.writeLine('"android-extra-libs": "' + extraLibs.join() + '",'); + } + var prefixDirs = product.Qt.android_support.extraPrefixDirs; + if (prefixDirs && prefixDirs.length > 0) + f.writeLine('"extraPrefixDirs": ' + JSON.stringify(prefixDirs) + ','); + var qmlImportPaths = product.Qt.android_support.qmlImportPaths; + if (qmlImportPaths && qmlImportPaths.length > 0) + f.writeLine('"qml-import-paths": "' + qmlImportPaths.join(',') + '",'); + else if ((product.qmlImportPaths instanceof Array) && product.qmlImportPaths.length > 0) + f.writeLine('"qml-import-paths": "' + product.qmlImportPaths.join(',') + '",'); + + if (Utilities.versionCompare(product.Qt.android_support.version, "6.0") >= 0) { + f.writeLine('"qml-importscanner-binary": "' + + product.Qt.core.qmlImportScannerFilePath + '",'); + f.writeLine('"rcc-binary": "' + product.Qt.android_support.rccFilePath + '",'); + + if (inputs["qrc"] && inputs["qrc"].length > 0) { + var qrcFiles = []; + var qrcInputs = inputs["qrc"]; + for (i = 0; i < qrcInputs.length; ++i) { + qrcFiles.push(qrcInputs[i].filePath); + } + f.writeLine('"qrcFiles": "' + qrcFiles.join(',') + '",'); + } + } + + // QBS-1429 + if (!product.Qt.android_support._multiAbi) { + f.writeLine('"stdcpp-path": "' + (product.cpp.sharedStlFilePath + ? product.cpp.sharedStlFilePath : product.cpp.staticStlFilePath) + + '",'); + f.writeLine('"application-binary": "' + theBinary.filePath + '"'); + } else { + f.writeLine('"stdcpp-path": "' + product.Android.sdk.ndkDir + + '/toolchains/llvm/prebuilt/' + hostArch + '/sysroot/usr/lib/",'); + f.writeLine('"application-binary": "' + theBinary.product.targetName + '"'); + } + + f.writeLine("}"); + f.close(); + }; + return cmd; + } + } + + // We use the manifest template from the Qt installation if and only if the project + // does not provide a manifest file. + Rule { + condition: _enableSdkSupport + multiplex: true + requiresInputs: false + inputs: "android.manifest" + excludedInputs: "qt.android_manifest" + outputFileTags: ["android.manifest", "qt.android_manifest"] + outputArtifacts: { + if (inputs["android.manifest"]) + return []; + return [{ + filePath: "qt_manifest/AndroidManifest.xml", + fileTags: ["android.manifest", "qt.android_manifest"] + }]; + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "copying Qt Android manifest template"; + cmd.sourceCode = function() { + File.copy(FileInfo.joinPaths(product.Qt.android_support._templatesBaseDir, + "templates", "AndroidManifest.xml"), output.filePath); + }; + return cmd; + } + } + + Rule { + condition: _enableSdkSupport + multiplex: true + property stringList defaultInputs: ["qt_androiddeployqt_input", + "android.manifest_processed"] + property stringList allInputs: ["qt_androiddeployqt_input", "android.manifest_processed", + "android.nativelibrary"] + inputsFromDependencies: "android.nativelibrary" + inputs: product.aggregate ? defaultInputs : allInputs + outputFileTags: [ + "android.manifest_final", "android.resources", "android.assets", "bundled_jar", + "android.deployqt_list", + ] + outputArtifacts: [ + { + filePath: "AndroidManifest.xml", + fileTags: "android.manifest_final" + }, + { + filePath: product.Qt.android_support._deployQtOutDir + "/res/values/libs.xml", + fileTags: "android.resources" + }, + { + filePath: product.Qt.android_support._deployQtOutDir + + "/res/values/strings.xml", + fileTags: "android.resources" + }, + { + filePath: product.Qt.android_support._deployQtOutDir + "/assets/.dummy", + fileTags: "android.assets" + }, + { + filePath: "deployqt.list", + fileTags: "android.deployqt_list" + }, + // androiddeployqt potentially copies more jar files but this one will always be there + // since it comes with Qt.core + { + filePath: FileInfo.joinPaths(product.java.classFilesDir, + product.Qt.android_support._qtAndroidJarFileName), + fileTags: "bundled_jar" + } + ] + prepare: { + var cmds = []; + var copyCmd = new JavaScriptCommand(); + copyCmd.description = "copying Qt resource templates"; + copyCmd.sourceCode = function() { + File.copy(inputs["android.manifest_processed"][0].filePath, + product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml"); + File.copy(product.Qt.android_support._templatesBaseDir + "/java/res", + product.Qt.android_support._deployQtOutDir + "/res"); + File.copy(product.Qt.android_support._templatesBaseDir + + "/templates/res/values/libs.xml", + product.Qt.android_support._deployQtOutDir + "/res/values/libs.xml"); + if (!product.Qt.android_support._multiAbi) { + try { + File.remove(FileInfo.path(outputs["android.assets"][0].filePath)); + } catch (e) { + } + } + else { + for (var i in inputs["android.nativelibrary"]) { + var input = inputs["android.nativelibrary"][i]; + File.copy(input.filePath, + FileInfo.joinPaths(product.Qt.android_support._deployQtOutDir, + "libs", input.Android.ndk.abi, + input.fileName)); + } + } + }; + cmds.push(copyCmd); + + var androidDeployQtArgs = [ + "--output", product.Qt.android_support._deployQtOutDir, + "--input", inputs["qt_androiddeployqt_input"][0].filePath, "--aux-mode", + "--deployment", "bundled", + "--android-platform", product.Android.sdk.platform, + ]; + if (product.Qt.android_support.verboseAndroidDeployQt) + androidDeployQtArgs.push("--verbose"); + var androidDeployQtCmd = new Command( + product.Qt.android_support._androidDeployQtFilePath, androidDeployQtArgs); + androidDeployQtCmd.description = "running androiddeployqt"; + cmds.push(androidDeployQtCmd); + + // We do not want androiddeployqt to write directly into our APK base dir, so + // we ran it on an isolated directory and now we move stuff over. + // We remember the files for which we do that, so if the next invocation + // of androiddeployqt creates fewer files, the other ones are removed from + // the APK base dir. + var moveCmd = new JavaScriptCommand(); + moveCmd.description = "processing androiddeployqt output"; + moveCmd.sourceCode = function() { + File.makePath(product.java.classFilesDir); + var libsDir = product.Qt.android_support._deployQtOutDir + "/libs"; + var libDir = product.Android.sdk.packageContentsDir + "/lib"; + var listFilePath = outputs["android.deployqt_list"][0].filePath; + var oldLibs = []; + try { + var listFile = new TextFile(listFilePath, TextFile.ReadOnly); + var listFileLine = listFile.readLine(); + while (listFileLine) { + oldLibs.push(listFileLine); + listFileLine = listFile.readLine(); + } + listFile.close(); + } catch (e) { + } + listFile = new TextFile(listFilePath, TextFile.WriteOnly); + var newLibs = []; + var moveLibFiles = function(prefix) { + var fullSrcPrefix = FileInfo.joinPaths(libsDir, prefix); + var files = File.directoryEntries(fullSrcPrefix, File.Files); + for (var i = 0; i < files.length; ++i) { + var file = files[i]; + var srcFilePath = FileInfo.joinPaths(fullSrcPrefix, file); + var targetFilePath; + if (file.endsWith(".jar")) + targetFilePath = FileInfo.joinPaths(product.java.classFilesDir, file); + else + targetFilePath = FileInfo.joinPaths(libDir, prefix, file); + File.move(srcFilePath, targetFilePath); + listFile.writeLine(targetFilePath); + newLibs.push(targetFilePath); + } + var dirs = File.directoryEntries(fullSrcPrefix, + File.Dirs | File.NoDotAndDotDot); + for (i = 0; i < dirs.length; ++i) + moveLibFiles(FileInfo.joinPaths(prefix, dirs[i])); + }; + moveLibFiles(""); + listFile.close(); + for (i = 0; i < oldLibs.length; ++i) { + if (!newLibs.contains(oldLibs[i])) + File.remove(oldLibs[i]); + } + }; + cmds.push(moveCmd); + + // androiddeployqt doesn't strip the deployed libraries anymore so it has to done here + // but only for release build + if (product.qbs.buildVariant == "release") { + var stripLibsCmd = new JavaScriptCommand(); + stripLibsCmd.description = "stripping unneeded symbols from deployed qt libraries"; + stripLibsCmd.sourceCode = function() { + var stripArgs = ["--strip-all"]; + var architectures = []; + for (var i in inputs["android.nativelibrary"]) + architectures.push(inputs["android.nativelibrary"][i].Android.ndk.abi); + for (var i in architectures) { + var abiDirPath = FileInfo.joinPaths(product.Android.sdk.packageContentsDir, + "lib", architectures[i]); + var files = File.directoryEntries(abiDirPath, File.Files); + for (var i = 0; i < files.length; ++i) { + var filePath = FileInfo.joinPaths(abiDirPath, files[i]); + if (FileInfo.suffix(filePath) == "so") { + stripArgs.push(filePath); + } + } + } + var process = new Process(); + process.exec(product.cpp.stripPath, stripArgs, false); + } + cmds.push(stripLibsCmd); + } + + var correctingCmd = new JavaScriptCommand(); + if (product.Qt.android_support._correctQtNetworkDependencies) { + correctingCmd.description = "correcting network jar dependency"; + correctingCmd.sourceCode = function() { + var findNetworkLib = function() { + var libsDir = product.Android.sdk.packageContentsDir + "/lib"; + var dirList = File.directoryEntries(libsDir, File.Dirs | + File.NoDotAndDotDot); + for (var i = 0; i < dirList.length; ++i) { + var archDir = FileInfo.joinPaths(libsDir, dirList[i]); + var fileList = File.directoryEntries(archDir, File.Files); + if (fileList) { + for (var j = 0; j < fileList.length; ++j) { + if (fileList[j].contains("libQt5Network")) { + return true; + } + } + } + } + return false; + } + + if (findNetworkLib()) { + var manifestData = new Xml.DomDocument(); + var manifestFilePath = product.Qt.android_support._deployQtOutDir + + "/AndroidManifest.xml" + manifestData.load(manifestFilePath); + + var rootElem = manifestData.documentElement(); + if (!rootElem || !rootElem.isElement() || rootElem.tagName() != "manifest") + throw "No manifest tag found in '" + manifestFilePath + "'."; + var appElem = rootElem.firstChild("application"); + if (!appElem || !appElem.isElement() || appElem.tagName() != "application") + throw "No application tag found in '" + manifestFilePath + "'."; + var activityElem = appElem.firstChild("activity"); + if (!activityElem || !activityElem.isElement() || + activityElem.tagName() != "activity") + throw "No activity tag found in '" + manifestFilePath + "'."; + var metaDataElem = activityElem.firstChild("meta-data"); + while (metaDataElem && metaDataElem.isElement()) { + if (metaDataElem.attribute("android:name") == + "android.app.load_local_jars" ) { + var value = metaDataElem.attribute("android:value"); + var fileName = "QtAndroidNetwork.jar"; + metaDataElem.setAttribute("android:value", value + ":jar/" + + fileName); + var jarFilePath = FileInfo.joinPaths( + product.Qt.android_support._qtInstallDir, "jar", + fileName); + var targetFilePath = FileInfo.joinPaths(product.java.classFilesDir, + fileName); + File.copy(jarFilePath, targetFilePath); + break; + } + metaDataElem = metaDataElem.nextSibling("meta-data"); + } + manifestData.save(outputs["android.manifest_final"][0].filePath, 4); + } else { + File.move(product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml", + outputs["android.manifest_final"][0].filePath); + } + }; + } else { + correctingCmd.description = "copying manifest"; + correctingCmd.sourceCode = function() { + File.move(product.Qt.android_support._deployQtOutDir + "/AndroidManifest.xml", + outputs["android.manifest_final"][0].filePath); + } + } + cmds.push(correctingCmd); + + return cmds; + } + } + + Group { + condition: Qt.android_support._enableSdkSupport + name: "helper sources from qt" + prefix: Qt.android_support._templatesBaseDir + "/java/" + Android.sdk.aidlSearchPaths: prefix + "src" + files: [ + "**/*.java", + "**/*.aidl", + ] + } + + validate: { + if (Utilities.versionCompare(version, "5.12") < 0) + throw ModUtils.ModuleError("Cannot use Qt " + version + " with Android. " + + "Version 5.12 or later is required."); + } +} diff --git a/share/qbs/module-providers/Qt/templates/core.qbs b/share/qbs/module-providers/Qt/templates/core.qbs new file mode 100644 index 00000000..f00f1621 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/core.qbs @@ -0,0 +1,561 @@ +import qbs.FileInfo +import qbs.ModUtils +import qbs.TextFile +import qbs.Utilities +import qbs.Xml +import "moc.js" as Moc +import "qdoc.js" as Qdoc +import "rcc.js" as Rcc + +Module { + condition: (qbs.targetPlatform === targetPlatform || isCombinedUIKitBuild) + && (!qbs.architecture + || architectures.length === 0 + || architectures.contains(qbs.architecture)) + + readonly property bool isCombinedUIKitBuild: ["ios", "tvos", "watchos"].contains(targetPlatform) + && (!qbs.architecture || ["x86", "x86_64"].contains(qbs.architecture)) + && qbs.targetPlatform === targetPlatform + "-simulator" + + Depends { name: "cpp" } + Depends { name: "Sanitizers.address" } + + Depends { name: "Qt.android_support"; condition: qbs.targetOS.contains("android") } + Properties { + condition: qbs.targetOS.contains("android") + Qt.android_support._qtBinaryDir: FileInfo.path(binPath) + Qt.android_support._qtInstallDir: FileInfo.path(installPath) + Qt.android_support.version: version + Qt.android_support.rccFilePath: Rcc.fullPath(product) + } + // qmlImportScanner is required by androiddeployqt even if the project doesn't + // depend on qml. That's why the scannerName must be defined here and not in the + // qml module + property string qmlImportScannerName: "qmlimportscanner" + property string qmlImportScannerFilePath: qmlLibExecPath + '/' + qmlImportScannerName + + version: @version@ + property stringList architectures: @archs@ + property string targetPlatform: @targetPlatform@ + property string libInfix: @libInfix@ + property stringList config: @config@ + property stringList qtConfig: @qtConfig@ + property path binPath: @binPath@ + property path installPath: @installPath@ + property path incPath: @incPath@ + property path libPath: @libPath@ + property path installPrefixPath: @installPrefixPath@ + property path libExecPath: @libExecPath@ + property path qmlLibExecPath: @qmlLibExecPath@ + property path pluginPath: @pluginPath@ + property string mkspecName: @mkspecName@ + property path mkspecPath: @mkspecPath@ + property string mocName: "moc" + property stringList mocFlags: [] + property string lreleaseName: "lrelease" + property string rccName: "rcc" + property string qdocName: versionMajor >= 5 ? "qdoc" : "qdoc3" + property stringList qdocEnvironment + property path docPath: @docPath@ + property string helpGeneratorLibExecPath: @helpGeneratorLibExecPath@ + property stringList helpGeneratorArgs: versionMajor >= 5 ? ["-platform", "minimal"] : [] + property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : [] + property int versionMajor: versionParts[0] + property int versionMinor: versionParts[1] + property int versionPatch: versionParts[2] + property bool frameworkBuild: @frameworkBuild@ + property bool staticBuild: @staticBuild@ + property stringList pluginMetaData: [] + property bool enableKeywords: true + property bool generateMetaTypesFile + readonly property bool _generateMetaTypesFile: generateMetaTypesFile + && Utilities.versionCompare(version, "5.15") >= 0 + property string metaTypesInstallDir + + property stringList availableBuildVariants: @availableBuildVariants@ + property string qtBuildVariant: { + if (availableBuildVariants.contains(qbs.buildVariant)) + return qbs.buildVariant; + return availableBuildVariants.length > 0 ? availableBuildVariants[0] : ""; + } + + property stringList staticLibsDebug: @staticLibsDebug@ + property stringList staticLibsRelease: @staticLibsRelease@ + property stringList dynamicLibsDebug: @dynamicLibsDebug@ + property stringList dynamicLibsRelease: @dynamicLibsRelease@ + property stringList staticLibs: qtBuildVariant === "debug" + ? staticLibsDebug : staticLibsRelease + property stringList dynamicLibs: qtBuildVariant === "debug" + ? dynamicLibsDebug : dynamicLibsRelease + property stringList linkerFlagsDebug: @linkerFlagsDebug@ + property stringList linkerFlagsRelease: @linkerFlagsRelease@ + property stringList coreLinkerFlags: qtBuildVariant === "debug" + ? linkerFlagsDebug : linkerFlagsRelease + property stringList frameworksDebug: @frameworksDebug@ + property stringList frameworksRelease: @frameworksRelease@ + property stringList coreFrameworks: qtBuildVariant === "debug" + ? frameworksDebug : frameworksRelease + property stringList frameworkPathsDebug: @frameworkPathsDebug@ + property stringList frameworkPathsRelease: @frameworkPathsRelease@ + property stringList coreFrameworkPaths: qtBuildVariant === "debug" + ? frameworkPathsDebug : frameworkPathsRelease + property string libNameForLinkerDebug: @libNameForLinkerDebug@ + property string libNameForLinkerRelease: @libNameForLinkerRelease@ + property string libNameForLinker: qtBuildVariant === "debug" + ? libNameForLinkerDebug : libNameForLinkerRelease + property string libFilePathDebug: @libFilePathDebug@ + property string libFilePathRelease: @libFilePathRelease@ + property string libFilePath: qtBuildVariant === "debug" + ? libFilePathDebug : libFilePathRelease + + property stringList coreLibPaths: @libraryPaths@ + property bool hasLibrary: true + + // These are deliberately not path types + // We don't want to resolve them against the source directory + property string generatedHeadersDir: product.buildDirectory + "/qt.headers" + property string qdocOutputDir: product.buildDirectory + "/qdoc_html" + property string qmDir: product.destinationDirectory + property string qmBaseName: product.targetName + property bool lreleaseMultiplexMode: false + + property stringList moduleConfig: @moduleConfig@ + + Sanitizers.address.enabled: config.contains("sanitize_address") + + Properties { + condition: moduleConfig.contains("use_gold_linker") + cpp.linkerVariant: "gold" + } + Properties { + condition: !moduleConfig.contains("use_gold_linker") && qbs.toolchain.contains("gcc") + cpp.linkerVariant: original + } + + cpp.cxxLanguageVersion: Utilities.versionCompare(version, "6.0.0") >= 0 + ? "c++17" + : Utilities.versionCompare(version, "5.7.0") >= 0 ? "c++11" : original + cpp.enableCompilerDefinesByLanguage: ["cpp"].concat( + qbs.targetOS.contains("darwin") ? ["objcpp"] : []) + cpp.defines: { + var defines = @defines@; + // ### QT_NO_DEBUG must be added if the current build variant is not derived + // from the build variant "debug" + if (!qbs.enableDebugCode) + defines.push("QT_NO_DEBUG"); + if (!enableKeywords) + defines.push("QT_NO_KEYWORDS"); + if (qbs.targetOS.containsAny(["ios", "tvos"])) { + defines = defines.concat(["DARWIN_NO_CARBON", "QT_NO_CORESERVICES", "QT_NO_PRINTER", + "QT_NO_PRINTDIALOG"]); + if (Utilities.versionCompare(version, "5.6.0") < 0) + defines.push("main=qtmn"); + } + return defines; + } + cpp.driverFlags: { + var flags = []; + if (qbs.toolchain.contains("gcc")) { + if (config.contains("sanitize_undefined")) + flags.push("-fsanitize=undefined"); + if (config.contains("sanitize_thread")) + flags.push("-fsanitize=thread"); + if (config.contains("sanitize_memory")) + flags.push("-fsanitize=memory"); + } + return flags; + } + cpp.includePaths: generatedHeadersDir + cpp.systemIncludePaths: @includes@.concat(mkspecPath) + cpp.libraryPaths: { + var libPaths = [libPath]; + if (staticBuild && pluginPath) + libPaths.push(pluginPath + "/platforms"); + libPaths = libPaths.concat(coreLibPaths); + return libPaths; + } + cpp.staticLibraries: { + var libs = []; + if (qbs.targetOS.contains('windows') && !product.consoleApplication) { + libs = libs.concat(qtBuildVariant === "debug" + ? @entryPointLibsDebug@ : @entryPointLibsRelease@); + } + libs = libs.concat(staticLibs); + return libs; + } + cpp.dynamicLibraries: dynamicLibs + cpp.linkerFlags: coreLinkerFlags + cpp.systemFrameworkPaths: coreFrameworkPaths.concat(frameworkBuild ? [libPath] : []) + cpp.frameworks: { + var frameworks = coreFrameworks + if (frameworkBuild) + frameworks.push(libNameForLinker); + if (qbs.targetOS.contains('ios') && staticBuild) + frameworks = frameworks.concat(["Foundation", "CoreFoundation"]); + if (frameworks.length === 0) + return undefined; + return frameworks; + } + cpp.rpaths: qbs.targetOS.contains('linux') && !qbs.targetOS.contains("android") ? [libPath] : + undefined + cpp.runtimeLibrary: qbs.toolchain.contains("msvc") + ? config.contains("static_runtime") ? "static" : "dynamic" + : original + cpp.positionIndependentCode: versionMajor >= 5 ? true : original + cpp.cxxFlags: { + var flags = []; + if (qbs.toolchain.contains('msvc')) { + if (versionMajor < 5) + flags.push('/Zc:wchar_t-'); + if (Utilities.versionCompare(version, "6.3") >= 0 + && Utilities.versionCompare(cpp.compilerVersion, "19.10") >= 0) { + flags.push("/permissive-"); + } + } + return flags; + } + cpp.cxxStandardLibrary: { + if (qbs.targetOS.contains('darwin') && qbs.toolchain.contains('clang') + && config.contains('c++11')) + return "libc++"; + return original; + } + cpp.minimumWindowsVersion: @minWinVersion@ + cpp.minimumMacosVersion: @minMacVersion@ + cpp.minimumIosVersion: @minIosVersion@ + cpp.minimumTvosVersion: @minTvosVersion@ + cpp.minimumWatchosVersion: @minWatchosVersion@ + cpp.minimumAndroidVersion: @minAndroidVersion@ + + // Universal Windows Platform support + cpp.windowsApiFamily: mkspecName.startsWith("winrt-") ? "pc" : undefined + cpp.windowsApiAdditionalPartitions: mkspecPath.startsWith("winrt-") ? ["phone"] : undefined + cpp.requireAppContainer: mkspecName.startsWith("winrt-") + + additionalProductTypes: ["qm", "qt.core.metatypes"] + + validate: { + var validator = new ModUtils.PropertyValidator("Qt.core"); + validator.setRequiredProperty("binPath", binPath); + validator.setRequiredProperty("incPath", incPath); + validator.setRequiredProperty("libPath", libPath); + validator.setRequiredProperty("mkspecPath", mkspecPath); + validator.setRequiredProperty("version", version); + validator.setRequiredProperty("config", config); + validator.setRequiredProperty("qtConfig", qtConfig); + validator.setRequiredProperty("versionMajor", versionMajor); + validator.setRequiredProperty("versionMinor", versionMinor); + validator.setRequiredProperty("versionPatch", versionPatch); + + if (!staticBuild) + validator.setRequiredProperty("pluginPath", pluginPath); + + // Allow custom version suffix since some distributions might want to do this, + // but otherwise the version must start with a valid 3-component string + validator.addVersionValidator("version", version, 3, 3, true); + validator.addRangeValidator("versionMajor", versionMajor, 1); + validator.addRangeValidator("versionMinor", versionMinor, 0); + validator.addRangeValidator("versionPatch", versionPatch, 0); + + validator.addCustomValidator("availableBuildVariants", availableBuildVariants, function (v) { + return v.length > 0; + }, "the Qt installation supports no build variants"); + + validator.addCustomValidator("qtBuildVariant", qtBuildVariant, function (variant) { + return availableBuildVariants.contains(variant); + }, "'" + qtBuildVariant + "' is not supported by this Qt installation"); + + validator.addCustomValidator("qtBuildVariant", qtBuildVariant, function (variant) { + return variant === qbs.buildVariant || !qbs.toolchain.contains("msvc"); + }, " is '" + qtBuildVariant + "', but qbs.buildVariant is '" + qbs.buildVariant + + "', which is not allowed when using MSVC"); + + validator.addFileNameValidator("resourceFileBaseName", resourceFileBaseName); + + validator.validate(); + } + + FileTagger { + patterns: ["*.qrc"] + fileTags: ["qrc"] + } + + FileTagger { + patterns: ["*.ts"] + fileTags: ["ts"] + } + + FileTagger { + patterns: ["*.qdoc", "*.qdocinc"] + fileTags: ["qdoc"] + } + + FileTagger { + patterns: ["*.qdocconf"] + fileTags: ["qdocconf"] + } + + FileTagger { + patterns: ["*.qhp"] + fileTags: ["qhp"] + } + + property bool combineMocOutput: cpp.combineCxxSources + property bool enableBigResources: false + // Product should not moc in the aggregate when multiplexing. + property bool enableMoc: !(product.multiplexed || product.aggregate) + || product.multiplexConfigurationId + + Rule { + name: "QtCoreMocRuleCpp" + condition: enableMoc + property string cppInput: cpp.combineCxxSources ? "cpp.combine" : "cpp" + property string objcppInput: cpp.combineObjcxxSources ? "objcpp.combine" : "objcpp" + inputs: [objcppInput, cppInput] + auxiliaryInputs: "qt_plugin_metadata" + excludedInputs: "unmocable" + outputFileTags: ["hpp", "unmocable", "qt.core.metatypes.in"] + outputArtifacts: Moc.outputArtifacts.apply(Moc, arguments) + prepare: Moc.commands.apply(Moc, arguments) + } + Rule { + name: "QtCoreMocRuleHpp" + condition: enableMoc + inputs: "hpp" + auxiliaryInputs: ["qt_plugin_metadata", "cpp", "objcpp"]; + excludedInputs: "unmocable" + outputFileTags: ["hpp", "cpp", "moc_cpp", "unmocable", "qt.core.metatypes.in"] + outputArtifacts: Moc.outputArtifacts.apply(Moc, arguments) + prepare: Moc.commands.apply(Moc, arguments) + } + + Rule { + multiplex: true + inputs: ["moc_cpp"] + Artifact { + filePath: "amalgamated_moc_" + product.targetName + ".cpp" + fileTags: ["cpp", "unmocable"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + ModUtils.mergeCFiles(inputs["moc_cpp"], output.filePath); + }; + return [cmd]; + } + } + + Rule { + multiplex: true + inputs: "qt.core.metatypes.in" + Artifact { + filePath: product.targetName.toLowerCase() + "_metatypes.json" + fileTags: "qt.core.metatypes" + qbs.install: product.Qt.core.metaTypesInstallDir + qbs.installDir: product.Qt.core.metaTypesInstallDir + } + prepare: { + var inputFilePaths = inputs["qt.core.metatypes.in"].map(function(a) { + return a.filePath; + }); + var cmd = new Command(Moc.fullPath(product), + ["--collect-json", "-o", output.filePath].concat(inputFilePaths)); + cmd.description = "generating " + output.fileName; + cmd.highlight = "codegen"; + return cmd; + } + } + + property path resourceSourceBase + property string resourcePrefix: "/" + property string resourceFileBaseName: product.targetName + Rule { + multiplex: true + inputs: ["qt.core.resource_data"] + Artifact { + filePath: product.Qt.core.resourceFileBaseName + ".qrc" + fileTags: ["qrc"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.sourceCode = function() { + var doc = new Xml.DomDocument("RCC"); + + var rccNode = doc.createElement("RCC"); + rccNode.setAttribute("version", "1.0"); + doc.appendChild(rccNode); + + var inputsByPrefix = {} + for (var i = 0; i < inputs["qt.core.resource_data"].length; ++i) { + var inp = inputs["qt.core.resource_data"][i]; + var prefix = inp.Qt.core.resourcePrefix; + var inputsList = inputsByPrefix[prefix] || []; + inputsList.push(inp); + inputsByPrefix[prefix] = inputsList; + } + + for (var prefix in inputsByPrefix) { + var qresourceNode = doc.createElement("qresource"); + qresourceNode.setAttribute("prefix", prefix); + rccNode.appendChild(qresourceNode); + + for (var i = 0; i < inputsByPrefix[prefix].length; ++i) { + var inp = inputsByPrefix[prefix][i]; + var fullResPath = inp.filePath; + var baseDir = inp.Qt.core.resourceSourceBase; + var resAlias = baseDir + ? FileInfo.relativePath(baseDir, fullResPath) : inp.fileName; + + var fileNode = doc.createElement("file"); + fileNode.setAttribute("alias", resAlias); + qresourceNode.appendChild(fileNode); + + var fileTextNode = doc.createTextNode(fullResPath); + fileNode.appendChild(fileTextNode); + } + } + + doc.save(output.filePath, 4); + }; + return [cmd]; + } + } + + Rule { + inputs: ["qrc"] + outputFileTags: ["cpp", "cpp_intermediate_object"] + outputArtifacts: { + var artifact = { + filePath: "qrc_" + input.completeBaseName + ".cpp", + fileTags: ["cpp"] + }; + if (input.Qt.core.enableBigResources) + artifact.fileTags.push("cpp_intermediate_object"); + return [artifact]; + } + prepare: { + var args = [input.filePath, + "-name", FileInfo.completeBaseName(input.filePath), + "-o", output.filePath]; + if (input.Qt.core.enableBigResources) + args.push("-pass", "1"); + var cmd = new Command(Rcc.fullPath(product), args); + cmd.description = "rcc " + + (input.Qt.core.enableBigResources ? "(pass 1) " : "") + + input.fileName; + cmd.highlight = 'codegen'; + return cmd; + } + } + + Rule { + inputs: ["intermediate_obj"] + Artifact { + filePath: input.completeBaseName + ".2" + input.cpp.objectSuffix + fileTags: ["obj"] + } + prepare: { + function findChild(artifact, predicate) { + var children = artifact.children; + var len = children.length; + for (var i = 0; i < len; ++i) { + var child = children[i]; + if (predicate(child)) + return child; + child = findChild(child, predicate); + if (child) + return child; + } + return undefined; + } + var qrcArtifact = findChild(input, function(c) { return c.fileTags.contains("qrc"); }); + var cppArtifact = findChild(input, function(c) { return c.fileTags.contains("cpp"); }); + var cmd = new Command(Rcc.fullPath(product), + [qrcArtifact.filePath, + "-temp", input.filePath, + "-name", FileInfo.completeBaseName(input.filePath), + "-o", output.filePath, + "-pass", "2"]); + cmd.description = "rcc (pass 2) " + qrcArtifact.fileName; + cmd.highlight = 'codegen'; + return cmd; + } + } + + Rule { + inputs: ["ts"] + multiplex: lreleaseMultiplexMode + + Artifact { + filePath: FileInfo.joinPaths(product.Qt.core.qmDir, + (product.Qt.core.lreleaseMultiplexMode + ? product.Qt.core.qmBaseName + : input.baseName) + ".qm") + fileTags: ["qm"] + } + + prepare: { + var inputFilePaths; + if (product.Qt.core.lreleaseMultiplexMode) + inputFilePaths = inputs["ts"].map(function(artifact) { return artifact.filePath; }); + else + inputFilePaths = [input.filePath]; + var args = ['-silent', '-qm', output.filePath].concat(inputFilePaths); + var cmd = new Command(product.Qt.core.binPath + '/' + + product.Qt.core.lreleaseName, args); + cmd.description = 'creating ' + output.fileName; + cmd.highlight = 'filegen'; + return cmd; + } + } + + Rule { + inputs: "qdocconf-main" + explicitlyDependsOn: ["qdoc", "qdocconf"] + + outputFileTags: ModUtils.allFileTags(Qdoc.qdocFileTaggers()) + outputArtifacts: Qdoc.outputArtifacts(product, input) + + prepare: { + var outputDir = product.Qt.core.qdocOutputDir; + var args = Qdoc.qdocArgs(product, input, outputDir); + var cmd = new Command(product.Qt.core.binPath + '/' + product.Qt.core.qdocName, args); + cmd.description = 'qdoc ' + input.fileName; + cmd.highlight = 'filegen'; + cmd.environment = product.Qt.core.qdocEnvironment; + cmd.environment.push("OUTDIR=" + outputDir); // Qt 4 replacement for -outputdir + return cmd; + } + } + + Rule { + inputs: "qhp" + auxiliaryInputs: ModUtils.allFileTags(Qdoc.qdocFileTaggers()) + .filter(function(tag) { return tag !== "qhp"; }) + + Artifact { + filePath: input.completeBaseName + ".qch" + fileTags: ["qch"] + } + + prepare: { + var args = [input.filePath]; + args = args.concat(product.Qt.core.helpGeneratorArgs); + args.push("-o"); + args.push(output.filePath); + var cmd = new Command( + product.Qt.core.helpGeneratorLibExecPath + "/qhelpgenerator", args); + cmd.description = 'qhelpgenerator ' + input.fileName; + cmd.highlight = 'filegen'; + cmd.stdoutFilterFunction = function(output) { + return ""; + }; + return cmd; + } + } + + @additionalContent@ +} diff --git a/share/qbs/module-providers/Qt/templates/dbus.js b/share/qbs/module-providers/Qt/templates/dbus.js new file mode 100644 index 00000000..3cdd6fb9 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/dbus.js @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); + +function outputFileName(input, suffix) +{ + var parts = input.fileName.split('.').filter(function(s) { return s.length > 0; }); + if (parts.length === 0) + throw "Cannot run qdbusxml2cpp on '" + input.filePath + "': Unsuitable file name."; + var outputBaseName = parts.length === 1 ? parts[0] : parts[parts.length - 2]; + return outputBaseName.toLowerCase() + suffix; +} + +function createCommands(product, input, outputs, option) +{ + var exe = ModUtils.moduleProperty(product, "binPath") + '/' + + ModUtils.moduleProperty(product, "xml2cppName"); + var hppOutput = outputs["hpp"][0]; + var hppArgs = ModUtils.moduleProperty(product, "xml2CppHeaderFlags"); + hppArgs.push(option, hppOutput.fileName + ':', input.filePath); // Can't use filePath on Windows + var hppCmd = new Command(exe, hppArgs) + hppCmd.description = "qdbusxml2cpp " + input.fileName + " -> " + hppOutput.fileName; + hppCmd.highlight = "codegen"; + hppCmd.workingDirectory = FileInfo.path(hppOutput.filePath); + var cppOutput = outputs["cpp"][0]; + var cppArgs = ModUtils.moduleProperty(product, "xml2CppSourceFlags"); + cppArgs.push("-i", hppOutput.filePath, option, ':' + cppOutput.fileName, input.filePath); + var cppCmd = new Command(exe, cppArgs) + cppCmd.description = "qdbusxml2cpp " + input.fileName + " -> " + cppOutput.fileName; + cppCmd.highlight = "codegen"; + cppCmd.workingDirectory = FileInfo.path(cppOutput.filePath); + return [hppCmd, cppCmd]; +} diff --git a/share/qbs/module-providers/Qt/templates/dbus.qbs b/share/qbs/module-providers/Qt/templates/dbus.qbs new file mode 100644 index 00000000..08e1e49e --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/dbus.qbs @@ -0,0 +1,70 @@ +import qbs.FileInfo +import qbs.ModUtils +import "../QtModule.qbs" as QtModule +import "dbus.js" as DBus + +QtModule { + qtModuleName: "DBus" + + property string xml2cppName: "qdbusxml2cpp" + property stringList xml2CppHeaderFlags: [] + property stringList xml2CppSourceFlags: [] + + Rule { + inputs: ["qt.dbus.adaptor"] + + Artifact { + filePath: FileInfo.joinPaths(input.moduleProperty("Qt.core", "generatedHeadersDir"), + DBus.outputFileName(input, "_adaptor.h")) + fileTags: ["hpp"] + } + Artifact { + filePath: DBus.outputFileName(input, "_adaptor.cpp") + fileTags: ["cpp"] + } + + prepare: DBus.createCommands(product, input, outputs, "-a") + } + + Rule { + inputs: ["qt.dbus.interface"] + + Artifact { + filePath: FileInfo.joinPaths(input.moduleProperty("Qt.core", "generatedHeadersDir"), + DBus.outputFileName(input, "_interface.h")) + fileTags: ["hpp"] + } + Artifact { + filePath: DBus.outputFileName(input, "_interface.cpp") + fileTags: ["cpp"] + } + + prepare: DBus.createCommands(product, input, outputs, "-p") + } + + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + moduleConfig: @moduleConfig@ + + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + + @additionalContent@ +} + diff --git a/share/qbs/module-providers/Qt/templates/gui.qbs b/share/qbs/module-providers/Qt/templates/gui.qbs new file mode 100644 index 00000000..6ba5e48c --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/gui.qbs @@ -0,0 +1,73 @@ +import qbs.FileInfo +import qbs.ModUtils +import qbs.Utilities +import '../QtModule.qbs' as QtModule + +QtModule { + qtModuleName: "Gui" + + property string uicName: "uic" + + FileTagger { + patterns: ["*.ui"] + fileTags: ["ui"] + } + + Rule { + inputs: ["ui"] + + Artifact { + filePath: FileInfo.joinPaths(input.moduleProperty("Qt.core", "generatedHeadersDir"), + 'ui_' + input.completeBaseName + '.h') + fileTags: ["hpp"] + } + + prepare: { + var uicPath = Utilities.versionCompare(product.Qt.gui.version, "6.1") < 0 + ? product.Qt.core.binPath + '/' + product.Qt.gui.uicName + : product.Qt.core.libExecPath + '/' + product.Qt.gui.uicName; + + var cmd = new Command(uicPath, [input.filePath, '-o', output.filePath]); + cmd.description = 'generating ' + output.fileName; + cmd.highlight = 'codegen'; + return cmd; + } + } + + property string defaultQpaPlugin: @defaultQpaPlugin@ + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + + cpp.entryPoint: qbs.targetOS.containsAny(["ios", "tvos"]) + && Utilities.versionCompare(version, "5.6.0") >= 0 + ? "_qt_main_wrapper" + : undefined + + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + + Properties { + condition: Qt.core.staticBuild && qbs.targetOS.contains("ios") + cpp.frameworks: base.concat(["UIKit", "QuartzCore", "CoreText", "CoreGraphics", + "Foundation", "CoreFoundation", "AudioToolbox"]) + } + cpp.frameworks: base + @additionalContent@ +} + diff --git a/share/qbs/module-providers/Qt/templates/moc.js b/share/qbs/module-providers/Qt/templates/moc.js new file mode 100644 index 00000000..7d230267 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/moc.js @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var ModUtils = require("qbs.ModUtils"); +var Utilities = require("qbs.Utilities"); + +function args(product, input, outputs) +{ + var defines = product.cpp.compilerDefinesByLanguage; + if (input.fileTags.contains("objcpp")) + defines = ModUtils.flattenDictionary(defines["objcpp"]) || []; + else if (input.fileTags.contains("cpp") || input.fileTags.contains("hpp")) + defines = ModUtils.flattenDictionary(defines["cpp"]) || []; + else + defines = []; + defines = defines.uniqueConcat(product.cpp.platformDefines); + defines = defines.uniqueConcat(input.cpp.defines); + var includePaths = input.cpp.includePaths; + includePaths = includePaths.uniqueConcat(input.cpp.systemIncludePaths); + var useCompilerPaths = product.Qt.core.versionMajor >= 5; + if (useCompilerPaths) { + includePaths = includePaths.uniqueConcat(input.cpp.compilerIncludePaths); + } + var frameworkPaths = product.cpp.frameworkPaths; + frameworkPaths = frameworkPaths.uniqueConcat( + product.cpp.systemFrameworkPaths); + if (useCompilerPaths) { + frameworkPaths = frameworkPaths.uniqueConcat( + product.cpp.compilerFrameworkPaths); + } + var pluginMetaData = product.Qt.core.pluginMetaData; + var args = []; + if (product.Qt.core._generateMetaTypesFile) + args.push("--output-json"); + var outputFileName; + for (tag in outputs) { + if (tag !== "qt.core.metatypes.in") { + outputFileName = outputs[tag][0].filePath; + break; + } + } + args = args.concat( + defines.map(function(item) { return '-D' + item; }), + includePaths.map(function(item) { return '-I' + item; }), + frameworkPaths.map(function(item) { return '-F' + item; }), + pluginMetaData.map(function(item) { return '-M' + item; }), + product.Qt.core.mocFlags, + '-o', outputFileName, + input.filePath); + return args; +} + +function fullPath(product) +{ + if (Utilities.versionCompare(product.Qt.core.version, "6.1") < 0) + return product.Qt.core.binPath + '/' + product.Qt.core.mocName; + return product.Qt.core.libExecPath + '/' + product.Qt.core.mocName; +} + +function outputArtifacts(project, product, inputs, input) +{ + var mocInfo = QtMocScanner.apply(input); + if (!mocInfo.hasQObjectMacro) + return []; + var artifact = { fileTags: ["unmocable"] }; + if (mocInfo.hasPluginMetaDataMacro) + artifact.explicitlyDependsOn = ["qt_plugin_metadata"]; + if (input.fileTags.contains("hpp")) { + artifact.filePath = input.Qt.core.generatedHeadersDir + + "/moc_" + input.completeBaseName + ".cpp"; + var amalgamate = input.Qt.core.combineMocOutput; + artifact.fileTags.push(mocInfo.mustCompile ? (amalgamate ? "moc_cpp" : "cpp") : "hpp"); + } else { + artifact.filePath = input.Qt.core.generatedHeadersDir + '/' + + input.completeBaseName + ".moc"; + artifact.fileTags.push("hpp"); + } + var artifacts = [artifact]; + if (product.Qt.core._generateMetaTypesFile) + artifacts.push({filePath: artifact.filePath + ".json", fileTags: "qt.core.metatypes.in"}); + return artifacts; +} + +function commands(project, product, inputs, outputs, input, output) +{ + var cmd = new Command(fullPath(product), args(product, input, outputs)); + cmd.description = 'moc ' + input.fileName; + cmd.highlight = 'codegen'; + return cmd; +} diff --git a/share/qbs/module-providers/Qt/templates/module.qbs b/share/qbs/module-providers/Qt/templates/module.qbs new file mode 100644 index 00000000..ccafe412 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/module.qbs @@ -0,0 +1,30 @@ +import '../QtModule.qbs' as QtModule + +QtModule { + qtModuleName: @name@ + Depends { name: "Qt"; submodules: @dependencies@} + + architectures: @archs@ + targetPlatform: @targetPlatform@ + hasLibrary: @has_library@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + moduleConfig: @moduleConfig@ + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + @additionalContent@ +} diff --git a/share/qbs/module-providers/Qt/templates/plugin.qbs b/share/qbs/module-providers/Qt/templates/plugin.qbs new file mode 100644 index 00000000..e73e2a4d --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/plugin.qbs @@ -0,0 +1,27 @@ +import '../QtPlugin.qbs' as QtPlugin + +QtPlugin { + qtModuleName: @name@ + Depends { name: "Qt"; submodules: @dependencies@} + + className: @className@ + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + cpp.libraryPaths: @libraryPaths@ + extendsModules: @extends@ + @additionalContent@ +} diff --git a/share/qbs/module-providers/Qt/templates/plugin_support.qbs b/share/qbs/module-providers/Qt/templates/plugin_support.qbs new file mode 100644 index 00000000..19a73958 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/plugin_support.qbs @@ -0,0 +1,77 @@ +Module { + // Set by user. + property varList pluginsByType + property bool linkPlugins: product.type + && (product.type.contains("application") || product.type.contains("sharedlibrary")) + + // Set by Qt modules. + property stringList pluginTypes + + // Set by setup-qt. + readonly property var allPluginsByType: @allPluginsByType@ + readonly property stringList nonEssentialPlugins: @nonEssentialPlugins@ + + // Derived. + readonly property var defaultPluginsByType: { + var map = {}; + for (var i = 0; i < (pluginTypes || []).length; ++i) { + var pType = pluginTypes[i]; + map[pType] = (allPluginsByType[pType] || []).filter(function(p) { + return !nonEssentialPlugins.contains(p); }); + } + return map; + } + readonly property var effectivePluginsByType: { + var ppt = pluginsByType || []; + var eppt = {}; + for (var i = 0; i < ppt.length; ++i) { + var listEntry = ppt[i]; + for (var pluginType in listEntry) { + var newValue = listEntry[pluginType]; + if (!newValue) + newValue = []; + else if (typeof newValue == "string") + newValue = [newValue]; + if (!newValue instanceof Array) + throw "Invalid value '" + newValue + "' in Qt.plugin_support.pluginsByType"; + eppt[pluginType] = (eppt[pluginType] || []).uniqueConcat(newValue); + } + } + var dppt = defaultPluginsByType; + for (var pluginType in dppt) { + if (!eppt[pluginType]) + eppt[pluginType] = dppt[pluginType]; + } + return eppt; + } + readonly property stringList enabledPlugins: { + var list = []; + var eppt = effectivePluginsByType; + for (var t in eppt) + Array.prototype.push.apply(list, eppt[t]); + return list; + } + + validate: { + var ppt = pluginsByType; + if (!ppt) + return; + var appt = allPluginsByType; + for (var i = 0; i < ppt.length; ++i) { + for (var pluginType in ppt[i]) { + var requestedPlugins = ppt[i][pluginType]; + if (!requestedPlugins) + continue; + var availablePlugins = appt[pluginType] || []; + if (typeof requestedPlugins === "string") + requestedPlugins = [requestedPlugins]; + for (var j = 0; j < requestedPlugins.length; ++j) { + if (!availablePlugins.contains(requestedPlugins[j])) { + throw "Plugin '" + requestedPlugins[j] + "' of type '" + pluginType + + "' was requested, but is not available."; + } + } + } + } + } +} diff --git a/share/qbs/module-providers/Qt/templates/qdoc.js b/share/qbs/module-providers/Qt/templates/qdoc.js new file mode 100644 index 00000000..72c161c5 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/qdoc.js @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); + +function qdocArgs(product, input, outputDir) { + var args = [input.filePath]; + var qtVersion = ModUtils.moduleProperty(product, "versionMajor"); + if (qtVersion >= 5) { + args.push("-outputdir"); + args.push(outputDir); + } + + return args; +} + +var _qdocDefaultFileTag = "qdoc-output"; +function qdocFileTaggers() { + var t = _qdocDefaultFileTag; + return { + ".qhp": [t, "qhp"], + ".qhp.sha1": [t, "qhp-sha1"], + ".css": [t, "qdoc-css"], + ".html": [t, "qdoc-html"], + ".index": [t, "qdoc-index"], + ".png": [t, "qdoc-png"] + }; +} + +function outputArtifacts(product, input) { + var tracker = new ModUtils.BlackboxOutputArtifactTracker(); + tracker.hostOS = product.moduleProperty("qbs", "hostOS"); + tracker.shellPath = product.moduleProperty("qbs", "shellPath"); + tracker.defaultFileTags = [_qdocDefaultFileTag]; + tracker.fileTaggers = qdocFileTaggers(); + tracker.command = FileInfo.joinPaths(ModUtils.moduleProperty(product, "binPath"), + ModUtils.moduleProperty(product, "qdocName")); + tracker.commandArgsFunction = function (outputDirectory) { + return qdocArgs(product, input, outputDirectory); + }; + tracker.commandEnvironmentFunction = function (outputDirectory) { + var env = {}; + var qdocEnv = ModUtils.moduleProperty(product, "qdocEnvironment"); + for (var j = 0; j < qdocEnv.length; ++j) { + var e = qdocEnv[j]; + var idx = e.indexOf("="); + var name = e.slice(0, idx); + var value = e.slice(idx + 1, e.length); + env[name] = value; + } + env["OUTDIR"] = outputDirectory; // Qt 4 replacement for -outputdir + return env; + }; + return tracker.artifacts(ModUtils.moduleProperty(product, "qdocOutputDir")); +} diff --git a/share/qbs/module-providers/Qt/templates/qml.js b/share/qbs/module-providers/Qt/templates/qml.js new file mode 100644 index 00000000..2a2ff85a --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/qml.js @@ -0,0 +1,89 @@ +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Process = require("qbs.Process"); +var TextFile = require("qbs.TextFile"); + +function scannerData(scannerFilePath, qmlFiles, qmlPath, hostOS) +{ + var p; + try { + p = new Process(); + if (!hostOS.contains("windows")) { + p.exec(scannerFilePath, ["-qmlFiles"].concat(qmlFiles).concat(["-importPath", qmlPath]), + true); + return JSON.parse(p.readStdOut()); + } + var data = []; + var nextFileIndex = 0; + while (nextFileIndex < qmlFiles.length) { + var currentFileList = []; + var currentFileListStringLength = 0; + while (nextFileIndex < qmlFiles.length && currentFileListStringLength < 30000) { + var currentFile = qmlFiles[nextFileIndex++]; + currentFileList.push(currentFile); + currentFileListStringLength += currentFile.length; + } + p.exec(scannerFilePath, ["-qmlFiles"].concat(currentFileList) + .concat(["-importPath", qmlPath]), true); + data = data.concat(JSON.parse(p.readStdOut())); + } + return data; + } finally { + if (p) + p.close(); + } +} + +function getPrlRhs(line) +{ + return line.split('=')[1].trim(); +} + +function getLibsForPlugin(pluginData, buildVariant, targetOS, toolchain, qtLibDir, qtPluginDir, + qtDir) +{ + if (!pluginData.path) + return ""; + var prlFileName = ""; + if (!targetOS.contains("windows")) + prlFileName += "lib"; + prlFileName += pluginData.plugin; + if (buildVariant === "debug" && targetOS.contains("windows")) + prlFileName += "d"; + prlFileName += ".prl"; + var prlFilePath = FileInfo.joinPaths(pluginData.path, prlFileName); + if (!File.exists(prlFilePath)) { + console.warn("prl file for QML plugin '" + pluginData.plugin + "' not present at '" + + prlFilePath + "'. Linking may fail."); + return ""; + } + var prlFile = new TextFile(prlFilePath, TextFile.ReadOnly); + try { + var pluginLib; + var otherLibs = []; + var line; + while (!prlFile.atEof()) { + line = prlFile.readLine().trim(); + if (!line) + continue; + if (line.startsWith("QMAKE_PRL_TARGET")) + pluginLib = FileInfo.joinPaths(pluginData.path, getPrlRhs(line)); + if (line.startsWith("QMAKE_PRL_LIBS = ")) { + var otherLibsLine = ' ' + getPrlRhs(line); + if (toolchain.contains("msvc")) { + otherLibsLine = otherLibsLine.replace(/ -L/g, " /LIBPATH:"); + otherLibsLine = otherLibsLine.replace(/-l([^ ]+)/g, "$1" + ".lib"); + } + otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_LIBS\]/g, qtLibDir); + otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_PLUGINS\]/g, qtPluginDir); + otherLibsLine = otherLibsLine.replace(/\$\$\[QT_INSTALL_PREFIX\]/g, qtDir); + otherLibs = otherLibs.concat(otherLibsLine.split(' ')); + } + } + if (!pluginLib) + throw "Malformed prl file '" + prlFilePath + "'."; + return [pluginLib].concat(otherLibs); + } finally { + prlFile.close(); + } +} diff --git a/share/qbs/module-providers/Qt/templates/qml.qbs b/share/qbs/module-providers/Qt/templates/qml.qbs new file mode 100644 index 00000000..f15705cc --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/qml.qbs @@ -0,0 +1,216 @@ +import qbs.FileInfo +import qbs.Host +import qbs.TextFile +import '../QtModule.qbs' as QtModule +import "qml.js" as Qml + +QtModule { + qtModuleName: "Qml" + Depends { name: "Qt"; submodules: @dependencies@} + + property string qmlImportScannerName: Qt.core.qmlImportScannerName + property string qmlImportScannerFilePath: Qt.core.qmlImportScannerFilePath + property string qmlPath: @qmlPath@ + + property bool generateCacheFiles: false + Depends { name: "Qt.qmlcache"; condition: generateCacheFiles; required: false } + readonly property bool cachingEnabled: generateCacheFiles && Qt.qmlcache.present + property string qmlCacheGenPath + Properties { + condition: cachingEnabled + Qt.qmlcache.qmlCacheGenPath: qmlCacheGenPath || original + Qt.qmlcache.installDir: cacheFilesInstallDir || original + } + + property string cacheFilesInstallDir + + readonly property string pluginListFilePathDebug: product.buildDirectory + "/plugins.list.d" + readonly property string pluginListFilePathRelease: product.buildDirectory + "/plugins.list" + property bool linkPlugins: isStaticLibrary && Qt.plugin_support.linkPlugins + + hasLibrary: @has_library@ + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: (linkPlugins ? ['@' + pluginListFilePathDebug] : []).concat(@staticLibsDebug@) + staticLibsRelease: (linkPlugins ? ['@' + pluginListFilePathRelease] : []).concat(@staticLibsRelease@) + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + moduleConfig: @moduleConfig@ + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + @additionalContent@ + + FileTagger { + patterns: ["*.qml"] + fileTags: ["qt.qml.qml"] + } + + FileTagger { + patterns: ["*.js"] + fileTags: ["qt.qml.js"] + } + + // Type registration + property string importName + property string importVersion: product.version + readonly property stringList _importVersionParts: (importVersion || "").split(".") + property string typesFileName: { + if (product.type && product.type.contains("application")) + return product.targetName + ".qmltypes"; + return "plugins.qmltypes"; + } + property string typesInstallDir + property stringList extraMetaTypesFiles + Properties { + condition: importName + Qt.core.generateMetaTypesFile: true + } + Qt.core.generateMetaTypesFile: original + Rule { + condition: importName + inputs: "qt.core.metatypes" + multiplex: true + explicitlyDependsOnFromDependencies: "qt.core.metatypes" + Artifact { + filePath: product.targetName.toLowerCase() + "_qmltyperegistrations.cpp" + fileTags: ["cpp", "unmocable"] + } + Artifact { + filePath: product.Qt.qml.typesFileName + fileTags: "qt.qml.types" + qbs.install: product.Qt.qml.typesInstallDir + qbs.installDir: product.Qt.qml.typesInstallDir + } + prepare: { + var versionParts = product.Qt.qml._importVersionParts; + var args = [ + "--generate-qmltypes=" + outputs["qt.qml.types"][0].filePath, + "--import-name=" + product.Qt.qml.importName, + "--major-version=" + versionParts[0], + "--minor-version=" + (versionParts.length > 1 ? versionParts[1] : "0") + ]; + var foreignTypes = product.Qt.qml.extraMetaTypesFiles || []; + var metaTypeArtifactsFromDeps = explicitlyDependsOn["qt.core.metatypes"] || []; + var filePathFromArtifact = function(a) { return a.filePath; }; + foreignTypes = foreignTypes.concat(metaTypeArtifactsFromDeps.map(filePathFromArtifact)); + if (foreignTypes.length > 0) + args.push("--foreign-types=" + foreignTypes.join(",")); + args.push("-o", outputs.cpp[0].filePath); + args = args.concat(inputs["qt.core.metatypes"].map(filePathFromArtifact)); + var cmd = new Command(product.Qt.core.qmlLibExecPath + "/qmltyperegistrar", args); + cmd.description = "running qmltyperegistrar"; + cmd.highlight = "codegen"; + return cmd; + } + } + + Rule { + condition: linkPlugins + multiplex: true + requiresInputs: false + inputs: ["qt.qml.qml"] + outputFileTags: ["cpp", "qt.qml.pluginlist"] + outputArtifacts: { + var list = []; + if (inputs["qt.qml.qml"]) + list.push({ filePath: "qml_plugin_import.cpp", fileTags: ["cpp"] }); + list.push({ + filePath: product.Qt.core.qtBuildVariant === "debug" + ? product.Qt.qml.pluginListFilePathDebug + : product.Qt.qml.pluginListFilePathRelease, + fileTags: ["qt.qml.pluginlist"] + }); + return list; + } + prepare: { + var cmd = new JavaScriptCommand(); + if (inputs["qt.qml.qml"]) + cmd.description = "creating " + outputs["cpp"][0].fileName; + else + cmd.silent = true; + cmd.sourceCode = function() { + var qmlInputs = inputs["qt.qml.qml"]; + if (!qmlInputs) + qmlInputs = []; + var scannerData = Qml.scannerData(product.Qt.qml.qmlImportScannerFilePath, + qmlInputs.map(function(inp) { return inp.filePath; }), + product.Qt.qml.qmlPath, Host.os()); + var cppFile; + var listFile; + try { + if (qmlInputs.length > 0) + cppFile = new TextFile(outputs["cpp"][0].filePath, TextFile.WriteOnly); + listFile = new TextFile(outputs["qt.qml.pluginlist"][0].filePath, + TextFile.WriteOnly); + if (cppFile) + cppFile.writeLine("#include "); + var plugins = { }; + var libsWithUniqueObjects = []; + for (var p in scannerData) { + var plugin = scannerData[p].plugin; + if (!plugin || plugins[plugin]) + continue; + plugins[plugin] = true; + var className = scannerData[p].classname; + if (!className) { + throw "QML plugin '" + plugin + "' is missing a classname entry. " + + "Please add one to the qmldir file."; + } + if (cppFile) + cppFile.writeLine("Q_IMPORT_PLUGIN(" + className + ")"); + var libs = Qml.getLibsForPlugin(scannerData[p], + product.Qt.core.qtBuildVariant, + product.qbs.targetOS, + product.qbs.toolchain, + product.Qt.core.libPath, + product.Qt.core.pluginPath, + product.Qt.core.installPrefixPath); + for (var i = 0; i < libs.length; ++i) { + var lib = libs[i]; + if (!lib.endsWith(product.cpp.objectSuffix) + || (!libsWithUniqueObjects.contains(lib) + && !product.cpp.staticLibraries.contains(FileInfo.cleanPath(lib)))) { + libsWithUniqueObjects.push(lib); + } + } + } + listFile.write(libsWithUniqueObjects.join("\n")); + } finally { + if (cppFile) + cppFile.close(); + if (listFile) + listFile.close(); + }; + }; + return [cmd]; + } + } + + validate: { + if (importName) { + if (!importVersion) + throw "Qt.qml.importVersion must be set if Qt.qml.importName is set."; + var isInt = function(value) { + return !isNaN(value) && parseInt(Number(value)) == value + && !isNaN(parseInt(value, 10)); + } + if (!isInt(_importVersionParts[0]) + || (_importVersionParts.length > 1 && !isInt(_importVersionParts[1]))) { + throw "Qt.qml.importVersion must be of the form x.y, where x and y are integers."; + } + + } + } +} diff --git a/share/qbs/module-providers/Qt/templates/qmlcache.qbs b/share/qbs/module-providers/Qt/templates/qmlcache.qbs new file mode 100644 index 00000000..9a595688 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/qmlcache.qbs @@ -0,0 +1,86 @@ +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.Process +import qbs.Utilities + +Module { + additionalProductTypes: ["qt.qml.qmlc", "qt.qml.jsc"] + validate: { + if (!qmlcachegenProbe.found) + throw "qmlcachegen unsupported for this target"; + } + property string qmlCacheGenPath: FileInfo.joinPaths(Qt.core.qmlLibExecPath, "qmlcachegen") + + (Host.os().contains("windows") ? ".exe" : "") + property bool supportsAllArchitectures: Utilities.versionCompare(Qt.core.version, "5.11") >= 0 + property string installDir + + readonly property stringList _targetArgs: { + if (supportsAllArchitectures) + return []; + function translateArch(arch) { + if (arch === "x86") + return "i386"; + if (arch.startsWith("armv")) + return "arm"; + return arch; + } + + var args = ["--target-architecture", translateArch(qbs.architecture)]; + return args; + } + + Depends { name: "Qt.core" } + Probe { + id: qmlcachegenProbe + + property string arch: qbs.architecture + property string _qmlCacheGenPath: qmlCacheGenPath + property stringList targetArgs: _targetArgs + property bool _supportsAllArchitectures: supportsAllArchitectures + + configure: { + if (_supportsAllArchitectures) { + found = File.exists(_qmlCacheGenPath); + return; + } + var process = new Process(); + found = false; + try { + found = process.exec(_qmlCacheGenPath, + targetArgs.concat("--check-if-supported")) == 0; + if (!found) { + var msg = "QML cache generation was requested but is unsupported on " + + "architecture '" + arch + "'."; + console.warn(msg); + } + } finally { + process.close(); + } + } + } + Rule { + condition: qmlcachegenProbe.found + inputs: ["qt.qml.qml", "qt.qml.js"] + outputArtifacts: [{ + filePath: input.fileName + 'c', + fileTags: input.fileTags.filter(function(tag) { + return tag === "qt.qml.qml" || tag === "qt.qml.js"; + })[0] + 'c' + }] + outputFileTags: ["qt.qml.qmlc", "qt.qml.jsc"] + prepare: { + var args = input.Qt.qmlcache._targetArgs.concat(input.filePath, "-o", output.filePath); + var cmd = new Command(input.Qt.qmlcache.qmlCacheGenPath, args); + cmd.description = "precompiling " + input.fileName; + cmd.highlight = "compiler"; + return cmd; + } + } + Group { + condition: product.Qt.qmlcache.installDir !== undefined + fileTagsFilter: product.Qt.qmlcache.additionalProductTypes + qbs.install: true + qbs.installDir: product.Qt.qmlcache.installDir + } +} diff --git a/share/qbs/module-providers/Qt/templates/quick.js b/share/qbs/module-providers/Qt/templates/quick.js new file mode 100644 index 00000000..e677143e --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/quick.js @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var Process = require("qbs.Process"); +var Rcc = require("rcc.js"); + +function scanQrc(product, qrcFilePath) { + var absInputDir = FileInfo.path(qrcFilePath); + var result = []; + var process = new Process(); + try { + var rcc = FileInfo.joinPaths(Rcc.fullPath(product) + product.cpp.executableSuffix); + var exitCode = process.exec(rcc, ["--list", qrcFilePath], true); + for (;;) { + var line = process.readLine(); + if (!line) + break; + line = line.trim(); + line = FileInfo.relativePath(absInputDir, line); + result.push(line); + } + } finally { + process.close(); + } + return result; +} + +function qtQuickCompilerOutputName(filePath) { + var str = filePath.replace(/\//g, '_'); + var i = str.lastIndexOf('.'); + if (i != -1) + str = str.substr(0, i) + '_' + str.substr(i + 1); + str += ".cpp"; + return str; +} + +function qtQuickResourceFileOutputName(fileName) { + return fileName.replace(/\.qrc$/, "_qtquickcompiler.qrc"); +} + +function contentFromQrc(product, qrcFilePath) { + var supportsFiltering = product.Qt.quick._supportsQmlJsFiltering; + var filesInQrc = scanQrc(product, qrcFilePath); + var qmlJsFiles = filesInQrc.filter(function (filePath) { + return (/\.(mjs|js|qml)$/).test(filePath); + } ); + var content = {}; + if (!supportsFiltering || filesInQrc.length - qmlJsFiles.length > 0) { + content.newQrcFileName = qtQuickResourceFileOutputName(input.fileName); + } + content.qmlJsFiles = qmlJsFiles.map(function (filePath) { + return { + input: filePath, + output: qtQuickCompilerOutputName(filePath) + }; + }); + return content; +} diff --git a/share/qbs/module-providers/Qt/templates/quick.qbs b/share/qbs/module-providers/Qt/templates/quick.qbs new file mode 100644 index 00000000..276246d6 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/quick.qbs @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Process +import qbs.TextFile +import qbs.Utilities +import '../QtModule.qbs' as QtModule +import 'quick.js' as QC + +QtModule { + qtModuleName: @name@ + Depends { name: "Qt"; submodules: @dependencies@ } + + hasLibrary: @has_library@ + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + moduleConfig: @moduleConfig@ + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + @additionalContent@ + + readonly property bool _compilerIsQmlCacheGen: Utilities.versionCompare(Qt.core.version, + "5.11") >= 0 + readonly property bool _supportsQmlJsFiltering: Utilities.versionCompare(Qt.core.version, + "5.15") < 0 + readonly property string _generatedLoaderFileName: _compilerIsQmlCacheGen + ? "qmlcache_loader.cpp" + : "qtquickcompiler_loader.cpp" + property string _compilerBaseDir: _compilerIsQmlCacheGen ? Qt.core.qmlLibExecPath + : Qt.core.binPath + property string compilerBaseName: (_compilerIsQmlCacheGen ? "qmlcachegen" : "qtquickcompiler") + property string compilerFilePath: FileInfo.joinPaths(_compilerBaseDir, + compilerBaseName + product.cpp.executableSuffix) + + property bool compilerAvailable: File.exists(compilerFilePath); + property bool useCompiler: compilerAvailable && !_compilerIsQmlCacheGen + + Scanner { + condition: useCompiler + inputs: 'qt.quick.qrc' + searchPaths: [FileInfo.path(input.filePath)] + scan: QC.scanQrc(product, input.filePath) + } + + FileTagger { + condition: useCompiler + patterns: "*.qrc" + fileTags: ["qt.quick.qrc"] + priority: 100 + } + + Rule { + condition: useCompiler + inputs: ["qt.quick.qrc"] + Artifact { + filePath: input.fileName + ".json" + fileTags: ["qt.quick.qrcinfo"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function() { + var content = QC.contentFromQrc(product, input.filePath); + content.qrcFilePath = input.filePath; + + var tf = new TextFile(output.filePath, TextFile.WriteOnly); + tf.write(JSON.stringify(content)); + tf.close(); + } + return cmd; + } + } + + Rule { + condition: useCompiler + inputs: ["qt.quick.qrcinfo"] + outputFileTags: ["cpp", "qrc"] + multiplex: true + outputArtifacts: { + var infos = []; + inputs["qt.quick.qrcinfo"].forEach(function (input) { + var tf = new TextFile(input.filePath, TextFile.ReadOnly); + infos.push(JSON.parse(tf.readAll())); + tf.close(); + }); + + var result = []; + infos.forEach(function (info) { + if (info.newQrcFileName) { + result.push({ + filePath: info.newQrcFileName, + fileTags: ["qrc"] + }); + } + info.qmlJsFiles.forEach(function (qmlJsFile) { + result.push({ + filePath: qmlJsFile.output, + fileTags: ["cpp"] + }); + }); + }); + result.push({ + filePath: product.Qt.quick._generatedLoaderFileName, + fileTags: ["cpp"] + }); + return result; + } + prepare: { + var infos = []; + inputs["qt.quick.qrcinfo"].forEach(function (input) { + var tf = new TextFile(input.filePath, TextFile.ReadOnly); + infos.push(JSON.parse(tf.readAll())); + tf.close(); + }); + + var cmds = []; + var qmlCompiler = product.Qt.quick.compilerFilePath; + var useCacheGen = product.Qt.quick._compilerIsQmlCacheGen; + var cmd; + var loaderFlags = []; + + function findOutput(fileName) { + for (var k in outputs) { + for (var i in outputs[k]) { + if (outputs[k][i].fileName === fileName) + return outputs[k][i]; + } + } + throw new Error("Qt Quick compiler rule: Cannot find output artifact " + + fileName + "."); + } + + infos.forEach(function (info) { + if (info.newQrcFileName) { + loaderFlags.push("--resource-file-mapping=" + + FileInfo.fileName(info.qrcFilePath) + + '=' + info.newQrcFileName); + // Qt 5.15 doesn't really filter anyting but merely copies the qrc + // content to the new location + var args = ["--filter-resource-file", + info.qrcFilePath]; + if (useCacheGen) + args.push("-o"); + args.push(findOutput(info.newQrcFileName).filePath); + cmd = new Command(qmlCompiler, args); + cmd.description = "generating " + info.newQrcFileName; + cmds.push(cmd); + } else { + loaderFlags.push("--resource-file-mapping=" + info.qrcFilePath); + } + info.qmlJsFiles.forEach(function (qmlJsFile) { + var args = ["--resource=" + info.qrcFilePath, qmlJsFile.input]; + if (useCacheGen) + args.push("-o"); + args.push(findOutput(qmlJsFile.output).filePath); + cmd = new Command(qmlCompiler, args); + cmd.description = "generating " + qmlJsFile.output; + cmd.workingDirectory = FileInfo.path(info.qrcFilePath); + cmds.push(cmd); + }); + }); + + var args = loaderFlags.concat(infos.map(function (info) { return info.qrcFilePath; })); + if (useCacheGen) + args.push("-o"); + args.push(findOutput(product.Qt.quick._generatedLoaderFileName).filePath); + cmd = new Command(qmlCompiler, args); + cmd.description = "generating loader source"; + cmds.push(cmd); + return cmds; + } + } +} diff --git a/share/qbs/module-providers/Qt/templates/rcc.js b/share/qbs/module-providers/Qt/templates/rcc.js new file mode 100644 index 00000000..89c57d99 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/rcc.js @@ -0,0 +1,8 @@ +var Utilities = require("qbs.Utilities"); + +function fullPath(product) +{ + if (Utilities.versionCompare(product.Qt.core.version, "6.1") < 0) + return product.Qt.core.binPath + '/' + product.Qt.core.rccName; + return product.Qt.core.libExecPath + '/' + product.Qt.core.rccName; +} diff --git a/share/qbs/module-providers/Qt/templates/scxml.qbs b/share/qbs/module-providers/Qt/templates/scxml.qbs new file mode 100644 index 00000000..b800dfe7 --- /dev/null +++ b/share/qbs/module-providers/Qt/templates/scxml.qbs @@ -0,0 +1,81 @@ +import qbs.FileInfo +import qbs.Utilities +import "../QtModule.qbs" as QtModule + +QtModule { + qtModuleName: "Scxml" + + property string _qscxmlcDir: Utilities.versionCompare(Qt.core.version, "6.3") >= 0 + ? Qt.core.libExecPath : Qt.core.binPath + property string qscxmlcName: "qscxmlc" + property string className + property string namespace + property bool generateStateMethods + property stringList additionalCompilerFlags + + Rule { + inputs: ["qt.scxml.compilable"] + + Artifact { + filePath: FileInfo.joinPaths(input.moduleProperty("Qt.core", "generatedHeadersDir"), + input.baseName + ".h") + fileTags: ["hpp", "unmocable"] + } + Artifact { + filePath: input.baseName + ".cpp" + fileTags: ["cpp", "unmocable"] + } + + prepare: { + var compilerName = product.moduleProperty("Qt.scxml", "qscxmlcName"); + var compilerPath = FileInfo.joinPaths(input.Qt.scxml._qscxmlcDir, compilerName); + var args = ["--header", outputs["hpp"][0].filePath, + "--impl", outputs["cpp"][0].filePath]; + var cxx98 = input.moduleProperty("cpp", "cxxLanguageVersion") === "c++98"; + if (cxx98) + args.push("-no-c++11"); + var className = input.moduleProperty("Qt.scxml", "className"); + if (className) + args.push("--classname", className); + var namespace = input.moduleProperty("Qt.scxml", "namespace"); + if (namespace) + args.push("--namespace", namespace); + if (input.Qt.scxml.generateStateMethods + && Utilities.versionCompare(product.Qt.scxml.version, "5.9") >= 0) { + args.push("--statemethods"); + } + if (input.Qt.scxml.additionalCompilerFlags) + args = args.concat(input.Qt.scxml.additionalCompilerFlags); + args.push(input.filePath); + var cmd = new Command(compilerPath, args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "codegen"; + return [cmd]; + } + } + + architectures: @archs@ + targetPlatform: @targetPlatform@ + staticLibsDebug: @staticLibsDebug@ + staticLibsRelease: @staticLibsRelease@ + dynamicLibsDebug: @dynamicLibsDebug@ + dynamicLibsRelease: @dynamicLibsRelease@ + linkerFlagsDebug: @linkerFlagsDebug@ + linkerFlagsRelease: @linkerFlagsRelease@ + frameworksDebug: @frameworksDebug@ + frameworksRelease: @frameworksRelease@ + frameworkPathsDebug: @frameworkPathsDebug@ + frameworkPathsRelease: @frameworkPathsRelease@ + libNameForLinkerDebug: @libNameForLinkerDebug@ + libNameForLinkerRelease: @libNameForLinkerRelease@ + libFilePathDebug: @libFilePathDebug@ + libFilePathRelease: @libFilePathRelease@ + pluginTypes: @pluginTypes@ + moduleConfig: @moduleConfig@ + + cpp.defines: @defines@ + cpp.systemIncludePaths: @includes@ + cpp.libraryPaths: @libraryPaths@ + + @additionalContent@ +} diff --git a/share/qbs/module-providers/__fallback/fallback.qbs b/share/qbs/module-providers/__fallback/fallback.qbs new file mode 100644 index 00000000..52a3f080 --- /dev/null +++ b/share/qbs/module-providers/__fallback/fallback.qbs @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.Probes + +Module { + Depends { name: "cpp" } + Depends { name: "pkgconfig"; required: false } + + property string theName: FileInfo.completeBaseName(filePath) + + Probes.PkgConfigProbe { + id: pkgConfigProbe + condition: pkgconfig.present + sysroot: pkgconfig.sysroot + name: theName + executable: pkgconfig.executableFilePath + libDirs: pkgconfig.libDirs + forStaticBuild: pkgconfig.staticMode + } + + Properties { + condition: pkgConfigProbe.found + version: pkgConfigProbe.modversion + cpp.dynamicLibraries: pkgConfigProbe.libraries + cpp.libraryPaths: pkgConfigProbe.libraryPaths + cpp.includePaths: pkgConfigProbe.includePaths + cpp.defines: pkgConfigProbe.defines + cpp.driverLinkerFlags: pkgConfigProbe.linkerFlags + cpp.commonCompilerFlags: pkgConfigProbe.compilerFlags + } + + validate: { + if (!pkgConfigProbe.found) { + throw "Dependency '" + theName + "' not found for product '" + product.name + "'. " + + "Locating a package of this name via pkg-config also failed."; + } + } +} diff --git a/share/qbs/module-providers/__fallback/provider.qbs b/share/qbs/module-providers/__fallback/provider.qbs new file mode 100644 index 00000000..72740f3c --- /dev/null +++ b/share/qbs/module-providers/__fallback/provider.qbs @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo + +ModuleProvider { + relativeSearchPaths: { + console.debug("Running fallback provider for module '" + name + "'."); + var inputFilePath = FileInfo.joinPaths(path, "fallback.qbs"); + var outputDir = FileInfo.joinPaths(outputBaseDir, "modules", name.replace(".", "/")); + File.makePath(outputDir); + var outputFilePath = FileInfo.joinPaths(outputDir, name + ".qbs"); + File.copy(inputFilePath, outputFilePath); + return ""; + } +} diff --git a/share/qbs/module-providers/qbspkgconfig.qbs b/share/qbs/module-providers/qbspkgconfig.qbs new file mode 100644 index 00000000..fc162320 --- /dev/null +++ b/share/qbs/module-providers/qbspkgconfig.qbs @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.PkgConfig +import qbs.Process +import qbs.TextFile + +import "Qt/setup-qt.js" as SetupQt + +ModuleProvider { + property string executableFilePath + property stringList extraPaths + property stringList libDirs + property bool staticMode: false + property path sysroot: { + if (qbs.targetOS.contains("macos")) + return ""; + return qbs.sysroot; + } + property bool mergeDependencies: true + + relativeSearchPaths: { + + function exeSuffix(qbs) { return Host.os().contains("windows") ? ".exe" : ""; } + + // we need Probes in Providers... + function getPkgConfigExecutable(qbs) { + function splitNonEmpty(s, c) { return s.split(c).filter(function(e) { return e; }) } + + var pathValue = Environment.getEnv("PATH"); + if (!pathValue) + return undefined; + var dirs = splitNonEmpty(pathValue, FileInfo.pathListSeparator()); + var suffix = exeSuffix(qbs); + var filePaths = []; + for (var i = 0; i < dirs.length; ++i) { + var candidate = FileInfo.joinPaths(dirs[i], "pkg-config" + suffix); + var canonicalCandidate = FileInfo.canonicalPath(candidate); + if (!canonicalCandidate || !File.exists(canonicalCandidate)) + continue; + return canonicalCandidate; + } + return undefined; + } + + function getModuleInfo(pkg, staticMode) { + var result = {}; + + var mapper = function(flag) { return flag.value; } + var typeFilter = function(type) { + return function(flag) { return flag.type === type; } + } + + function getLibsInfo(libs) { + var result = {}; + result.dynamicLibraries = libs.filter(typeFilter(PkgConfig.LibraryName)).map(mapper); + result.staticLibraries = + libs.filter(typeFilter(PkgConfig.StaticLibraryName)).map(mapper); + result.libraryPaths = libs.filter(typeFilter(PkgConfig.LibraryPath)).map(mapper); + result.frameworks = libs.filter(typeFilter(PkgConfig.Framework)).map(mapper); + result.frameworkPaths = + libs.filter(typeFilter(PkgConfig.FrameworkPath)).map(mapper); + result.driverLinkerFlags = + libs.filter(typeFilter(PkgConfig.LinkerFlag)).map(mapper); + return result; + } + + result.version = pkg.version; + result.includePaths = pkg.cflags.filter(typeFilter(PkgConfig.IncludePath)).map(mapper); + result.systemIncludePaths = + pkg.cflags.filter(typeFilter(PkgConfig.SystemIncludePath)).map(mapper); + result.defines = pkg.cflags.filter(typeFilter(PkgConfig.Define)).map(mapper); + result.commonCompilerFlags = + pkg.cflags.filter(typeFilter(PkgConfig.CompilerFlag)).map(mapper); + + var allLibs = pkg.libs; + if (staticMode) + allLibs = allLibs.concat(pkg.libsPrivate); + var libsInfo = getLibsInfo(allLibs); + for (var key in libsInfo) { + result[key] = libsInfo[key]; + } + + return result; + } + + function getModuleName(packageName) { return packageName.replace('.', '-'); } + + function getModuleDependencies(pkg, staticMode) { + var mapper = function(p) { + var result = {}; + for (var key in p) + result[key] = p[key]; + result.name = getModuleName(result.name); + return result; + } + var result = pkg.requires.map(mapper); + if (staticMode) + result = result.concat(pkg.requiresPrivate.map(mapper)); + return result; + } + + console.debug("Running pkgconfig provider.") + + var outputDir = FileInfo.joinPaths(outputBaseDir, "modules"); + File.makePath(outputDir); + + var options = {}; + options.libDirs = libDirs; + options.sysroot = sysroot; + options.staticMode = staticMode; + options.mergeDependencies = mergeDependencies; + options.extraPaths = extraPaths; + if (options.sysroot && !options.libDirs) { + options.libDirs = [ + sysroot + "/usr/lib/pkgconfig", + sysroot + "/usr/share/pkgconfig" + ]; + } + if (!options.libDirs) { + // if we have pkg-config installed, let's ask it for its search paths (since + // built-in search paths can differ between platforms) + var executable = executableFilePath ? executableFilePath : getPkgConfigExecutable(qbs); + if (executable) { + var p = new Process() + if (p.exec(executable, ['pkg-config', '--variable=pc_path']) === 0) { + var stdout = p.readStdOut().trim(); + // TODO: pathListSeparator? depends on what pkg-config prints on Windows + options.libDirs = stdout ? stdout.split(':'): []; + } + } + } + + function setupQt(pkg) { + var packageName = pkg.baseFileName; + if (packageName === "QtCore" + || packageName === "Qt5Core" + || packageName === "Qt6Core") { + var binDir = pkg.variables["bindir"] || pkg.variables["host_bins"]; + if (!binDir) { + if (packageName === "QtCore") { // Qt4 does not have host_bins + var mocLocation = pkg.variables["moc_location"]; + if (!mocLocation) { + console.warn("No moc_location variable in " + packageName); + return; + } + binDir = FileInfo.path(mocLocation); + } else { + console.warn("No 'bindir' or 'host_bins' variable in " + packageName); + return; + } + } + var suffix = exeSuffix(qbs); + var qmakePaths = [FileInfo.joinPaths(binDir, "qmake" + suffix)]; + var qtProviderDir = FileInfo.joinPaths(path, "Qt"); + SetupQt.doSetup(qmakePaths, outputBaseDir, qtProviderDir, qbs); + } + } + + var moduleMapping = { + "protobuf": "protobuflib", + "grpc++": "grpcpp" + } + + var pkgConfig = new PkgConfig(options); + + var brokenPackages = []; + var packages = pkgConfig.packages(); + for (var packageName in packages) { + var pkg = packages[packageName]; + if (pkg.isBroken) { + brokenPackages.push(pkg); + continue; + } + if (packageName.startsWith("Qt")) { + setupQt(pkg); + continue; + } + var moduleName = moduleMapping[packageName] + ? moduleMapping[packageName] + : getModuleName(packageName); + var moduleInfo = getModuleInfo(pkg, staticMode); + var deps = getModuleDependencies(pkg, staticMode); + + var moduleDir = FileInfo.joinPaths(outputDir, moduleName); + File.makePath(moduleDir); + var module = + new TextFile(FileInfo.joinPaths(moduleDir, "module.qbs"), TextFile.WriteOnly); + module.writeLine("Module {"); + module.writeLine(" version: " + ModUtils.toJSLiteral(moduleInfo.version)); + module.writeLine(" Depends { name: 'cpp' }"); + deps.forEach(function(dep) { + module.write(" Depends { name: '" + dep.name + "'"); + for (var k in dep) { + if (k === "name") + continue; + module.write("; " + k + ": " + ModUtils.toJSLiteral(dep[k])); + } + module.writeLine(" }"); + }) + function writeProperty(propertyName) { + var value = moduleInfo[propertyName]; + if (value.length !== 0) { // skip empty props for simplicity of the module file + module.writeLine( + " cpp." + propertyName + ":" + ModUtils.toJSLiteral(value)); + } + } + writeProperty("includePaths"); + writeProperty("systemIncludePaths"); + writeProperty("defines"); + writeProperty("commonCompilerFlags"); + writeProperty("dynamicLibraries"); + writeProperty("staticLibraries"); + writeProperty("libraryPaths"); + writeProperty("frameworks"); + writeProperty("frameworkPaths"); + writeProperty("driverLinkerFlags"); + module.writeLine("}"); + module.close(); + } + + if (brokenPackages.length !== 0) { + console.warn("Failed to load some pkg-config packages:"); + for (var i = 0; i < brokenPackages.length; ++i) { + console.warn(" " + brokenPackages[i].filePath + + ": " + brokenPackages[i].errorText); + } + } + + return ""; + } +} diff --git a/share/qbs/modules/Android/android-utils.js b/share/qbs/modules/Android/android-utils.js new file mode 100644 index 00000000..f5684d00 --- /dev/null +++ b/share/qbs/modules/Android/android-utils.js @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); + +function availablePlatforms(baseDir) { + var re = /^android-([0-9]+)$/; + var platforms = File.directoryEntries(FileInfo.joinPaths(baseDir, "platforms"), + File.Dirs | File.NoDotAndDotDot); + var versions = []; + for (var i = 0; i < platforms.length; ++i) { + var match = platforms[i].match(re); + if (match !== null) { + versions.push(platforms[i]); + } + } + + versions.sort(function (a, b) { + return parseInt(a.match(re)[1], 10) - parseInt(b.match(re)[1], 10); + }); + return versions; +} diff --git a/share/qbs/modules/Android/ndk/ndk.qbs b/share/qbs/modules/Android/ndk/ndk.qbs new file mode 100644 index 00000000..3b223e4f --- /dev/null +++ b/share/qbs/modules/Android/ndk/ndk.qbs @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes +import qbs.Utilities + +import "utils.js" as NdkUtils + +Module { + Probes.AndroidNdkProbe { + id: ndkProbe + environmentPaths: (ndkDir ? [ndkDir] : []).concat(base) + } + + version: ndkProbe.ndkVersion + + readonly property string abi: NdkUtils.androidAbi(qbs.architecture) + PropertyOptions { + name: "abi" + description: "Supported Android ABIs" + allowedValues: ["arm64-v8a", "armeabi-v7a", "x86", "x86_64"] + } + // From https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/docs/BuildSystemMaintainers.md + // Android Studio‘s LLDB debugger uses a binary’s build ID to locate debug information. To + // ensure that LLDB works with a binary, pass an option like -Wl,--build-id=sha1 to Clang when + // linking. Other --build-id= modes are OK, but avoid a plain --build-id argument when using + // LLD, because Android Studio‘s version of LLDB doesn’t recognize LLD's default 8-byte build + // ID. See Issue 885. + + // Plain --build-id option is nevertheless implemented when buildId property is empty. + + // Possible values (from man page of ld.lld — ELF linker from the LLVM project): + // one of fast, md5, sha1, tree, uuid, 0xhex-string, and none. tree is an alias for sha1. + // Build-IDs of type fast, md5, sha1, and tree are calculated from the object contents. fast is + // not intended to be cryptographically secure. + property string buildId: "sha1" + + // See https://developer.android.com/ndk/guides/cpp-support.html + property string appStl: "c++_shared" + + PropertyOptions { + name: "appStl" + description: "C++ Runtime Libraries." + allowedValues: ["c++_static", "c++_shared"] + } + + property string hostArch: ndkProbe.hostArch + property string ndkDir: ndkProbe.path + property string ndkSamplesDir: ndkProbe.samplesDir + property string platform: { + switch (abi) { + case "armeabi-v7a": + // case "x86": // x86 has broken wstring support + return "android-19"; + default: + return "android-21"; + } + } + + property int platformVersion: { + if (platform) { + var match = platform.match(/^android-([0-9]+)$/); + if (match !== null) { + return parseInt(match[1], 10); + } + } + } + + property stringList abis: { + var list = ["armeabi-v7a"]; + if (platformVersion >= 16) + list.push("x86"); + if (platformVersion >= 21) + list.push("arm64-v8a", "x86_64"); + return list; + } + + property string armMode: abi && abi.startsWith("armeabi") + ? (qbs.buildVariant === "debug" ? "arm" : "thumb") + : undefined; + PropertyOptions { + name: "armMode" + description: "Determines the instruction set for armeabi configurations." + allowedValues: ["arm", "thumb"] + } + + validate: { + if (!ndkDir) { + throw ModUtils.ModuleError("Could not find an Android NDK at any of the following " + + "locations:\n\t" + ndkProbe.candidatePaths.join("\n\t") + + "\nInstall the Android NDK to one of the above locations, " + + "or set the Android.ndk.ndkDir property or " + + "ANDROID_NDK_ROOT environment variable to a valid " + + "Android NDK location."); + } + + if (Utilities.versionCompare(version, "19") < 0) + throw ModUtils.ModuleError("Unsupported NDK version " + + Android.ndk.version + + ", please upgrade your NDK to r19+"); + + if (product.aggregate && !product.multiplexConfigurationId) + return; + var validator = new ModUtils.PropertyValidator("Android.ndk"); + validator.setRequiredProperty("abi", abi); + validator.setRequiredProperty("appStl", appStl); + validator.setRequiredProperty("hostArch", hostArch); + validator.setRequiredProperty("platform", platform); + return validator.validate(); + } +} diff --git a/share/qbs/modules/Android/ndk/utils.js b/share/qbs/modules/Android/ndk/utils.js new file mode 100644 index 00000000..ab312921 --- /dev/null +++ b/share/qbs/modules/Android/ndk/utils.js @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Utilities = require("qbs.Utilities") + +function abiNameToDirName(abiName) { + switch (abiName) { + case "armeabi": + case "armeabi-v7a": + return "arm"; + case "arm64-v8a": + return "arm64"; + default: + return abiName; + } +} + +function androidAbi(arch) { + switch (arch) { + case "arm64": + return "arm64-v8a"; + case "armv5": + case "armv5te": + return "armeabi"; + case "armv7": + case "armv7a": + return "armeabi-v7a"; + default: + return arch; + } +} + +function commonCompilerFlags(toolchain, buildVariant, ndk) { + var flags = ["-Werror=format-security"]; + + var abi = ndk.abi; + var armMode = ndk.armMode; + if (abi === "arm64-v8a") + flags.push("-fpic"); + + if (abi === "armeabi" || abi === "armeabi-v7a") { + flags.push("-fpic"); + + if (abi === "armeabi") + flags.push("-mtune=xscale", "-msoft-float"); + + if (abi === "armeabi-v7a") { + flags.push("-mfpu=vfpv3-d16"); + flags.push("-mfloat-abi=softfp"); + } + } + + if (abi === "x86" || abi === "x86_64") + flags.push("-fPIC"); + + flags.push("-fno-limit-debug-info"); + + if (armMode) + flags.push("-m" + armMode); + + // https://github.com/android-ndk/ndk/issues/884 is fixed in r21 + if (ndk.version < 21) + flags.push("-fno-addrsig"); + + // https://github.com/android/ndk/issues/635 is fixed in api 24 + if (abi === "x86" && ndk.platformVersion < 24) + flags.push("-mstackrealign"); + + return flags; +} + +function commonLinkerFlags(ndk) { + var buildId = (ndk.buildId) ? "--build-id=" + ndk.buildId : "--build-id"; + return ["-z", "noexecstack", "-z", "relro", "-z", "now", buildId, "--gc-sections"]; +} + +function stlFileName(prefix, ndk, suffix) { + return prefix + ndk.appStl.slice(0, ndk.appStl.indexOf('_')) + suffix; +} diff --git a/share/qbs/modules/Android/sdk/sdk.qbs b/share/qbs/modules/Android/sdk/sdk.qbs new file mode 100644 index 00000000..d663a01e --- /dev/null +++ b/share/qbs/modules/Android/sdk/sdk.qbs @@ -0,0 +1,548 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes +import qbs.TextFile +import qbs.Utilities +import qbs.Xml +import "utils.js" as SdkUtils + +Module { + Probes.AndroidSdkProbe { + id: sdkProbe + environmentPaths: (sdkDir ? [sdkDir] : []).concat(base) + } + + Probes.AndroidNdkProbe { + id: ndkProbe + sdkPath: sdkProbe.path + environmentPaths: (ndkDir ? [ndkDir] : []).concat(base) + } + + Probes.PathProbe { + id: bundletoolProbe + platformSearchPaths: [Android.sdk.sdkDir] + names: ["bundletool-all"] + nameSuffixes: ["-0.11.0.jar", "-0.12.0.jar", "-0.13.0.jar", "-0.13.3.jar", "-0.13.4.jar", + "-0.14.0.jar", "-0.15.0.jar", "-1.0.0.jar", "-1.1.0.jar", "-1.2.0.jar", "-1.3.0.jar", + "-1.4.0.jar", "-1.5.0.jar", "-1.6.0.jar", "-1.6.1.jar", "-1.7.0.jar", "-1.7.1.jar", + "-1.8.0.jar"] + } + + property path sdkDir: sdkProbe.path + property path ndkDir: ndkProbe.path + property path ndkSamplesDir: ndkProbe.samplesDir + property string buildToolsVersion: sdkProbe.buildToolsVersion + property var buildToolsVersionParts: buildToolsVersion ? buildToolsVersion.split('.').map(function(item) { return parseInt(item, 10); }) : [] + property int buildToolsVersionMajor: buildToolsVersionParts[0] + property int buildToolsVersionMinor: buildToolsVersionParts[1] + property int buildToolsVersionPatch: buildToolsVersionParts[2] + property string platform: sdkProbe.platform + property string minimumVersion: "21" + property string targetVersion: platformVersion.toString() + + property path bundletoolFilePath: bundletoolProbe.filePath + + // Product-specific properties and files + property string packageName: { + var idx = product.name.indexOf(".") + if (idx > 0 && idx < product.name.length) + return product.name; + return "com.example." + product.name; + } + property int versionCode + property string versionName + property string apkBaseName: packageName + property bool automaticSources: true + property bool legacyLayout: false + property path sourceSetDir: legacyLayout + ? product.sourceDirectory + : FileInfo.joinPaths(product.sourceDirectory, "src/main") + property path resourcesDir: FileInfo.joinPaths(sourceSetDir, "res") + property path assetsDir: FileInfo.joinPaths(sourceSetDir, "assets") + property path sourcesDir: FileInfo.joinPaths(sourceSetDir, legacyLayout ? "src" : "java") + property string manifestFile: defaultManifestFile + readonly property string defaultManifestFile: FileInfo.joinPaths(sourceSetDir, + "AndroidManifest.xml") + + property bool _enableRules: !product.multiplexConfigurationId && !!packageName + + property bool _bundledInAssets: true + + Group { + name: "java sources" + condition: Android.sdk.automaticSources + prefix: FileInfo.resolvePath(product.sourceDirectory, Android.sdk.sourcesDir + '/') + files: "**/*.java" + } + + Group { + name: "android resources" + condition: Android.sdk.automaticSources + fileTags: ["android.resources"] + prefix: FileInfo.resolvePath(product.sourceDirectory, Android.sdk.resourcesDir + '/') + files: "**/*" + } + + Group { + name: "android assets" + condition: Android.sdk.automaticSources + fileTags: ["android.assets"] + prefix: FileInfo.resolvePath(product.sourceDirectory, Android.sdk.assetsDir + '/') + files: "**/*" + } + + Group { + name: "manifest" + condition: Android.sdk.automaticSources + fileTags: ["android.manifest"] + files: Android.sdk.manifestFile + && Android.sdk.manifestFile !== Android.sdk.defaultManifestFile + ? [Android.sdk.manifestFile] + : (File.exists(Android.sdk.defaultManifestFile) + ? [Android.sdk.defaultManifestFile] : []) + } + + + // Internal properties. + property int platformVersion: { + if (platform) { + var match = platform.match(/^android-([0-9]+)$/); + if (match !== null) { + return parseInt(match[1], 10); + } + } + } + + property string platformJavaVersion: { + if (platformVersion >= 21) + return "1.7"; + return "1.5"; + } + + property path buildToolsDir: FileInfo.joinPaths(sdkDir, "build-tools", buildToolsVersion) + property string aaptName: "aapt2" + PropertyOptions { + name: "aaptName" + allowedValues: ["aapt", "aapt2"] + } + property path aaptFilePath: FileInfo.joinPaths(buildToolsDir, aaptName) + readonly property bool _enableAapt2: aaptName === "aapt2" + property string packageType: "apk" + PropertyOptions { + name: "packageType" + allowedValues: ["apk", "aab"] + } + readonly property bool _generateAab: packageType == "aab" + + property path apksignerFilePath: FileInfo.joinPaths(buildToolsDir, "apksigner") + property path aidlFilePath: FileInfo.joinPaths(buildToolsDir, "aidl") + property path dxFilePath: FileInfo.joinPaths(buildToolsDir, "dx") + property path d8FilePath: FileInfo.joinPaths(buildToolsDir, "d8") + property string dexCompilerName: "d8" + PropertyOptions { + name: "dexCompilerName" + allowedValues: ["dx", "d8"] + } + readonly property bool _useD8: dexCompilerName === "d8" + property path zipalignFilePath: FileInfo.joinPaths(buildToolsDir, "zipalign") + property path androidJarFilePath: FileInfo.joinPaths(sdkDir, "platforms", platform, + "android.jar") + property path frameworkAidlFilePath: FileInfo.joinPaths(sdkDir, "platforms", platform, + "framework.aidl") + property path generatedJavaFilesBaseDir: FileInfo.joinPaths(product.buildDirectory, "gen") + property path generatedJavaFilesDir: FileInfo.joinPaths(generatedJavaFilesBaseDir, + (packageName || "").split('.').join('/')) + property path compiledResourcesDir: FileInfo.joinPaths(product.buildDirectory, + "compiled_resources") + property string packageContentsDir: FileInfo.joinPaths(product.buildDirectory, packageType) + property stringList aidlSearchPaths + + Depends { name: "java"; condition: _enableRules } + Depends { name: "codesign"; condition: _enableRules } + Properties { + condition: _enableRules + java.languageVersion: platformJavaVersion + java.runtimeVersion: platformJavaVersion + java.bootClassPaths: androidJarFilePath + codesign.apksignerFilePath: Android.sdk.apksignerFilePath + codesign._packageName: Android.sdk.apkBaseName + (_generateAab ? ".aab" : ".apk") + codesign.useApksigner: !_generateAab + } + + validate: { + if (!sdkDir) { + throw ModUtils.ModuleError("Could not find an Android SDK at any of the following " + + "locations:\n\t" + sdkProbe.candidatePaths.join("\n\t") + + "\nInstall the Android SDK to one of the above locations, " + + "or set the Android.sdk.sdkDir property or " + + "ANDROID_HOME environment variable to a valid " + + "Android SDK location."); + } + if (!bundletoolFilePath && _generateAab) { + throw ModUtils.ModuleError("Could not find Android bundletool at the following " + + "location:\n\t" + Android.sdk.sdkDir + + "\nInstall the Android bundletool to the above location, " + + "or set the Android.sdk.bundletoolFilePath property.\n" + + "Android bundletool can be downloaded from " + + "https://github.com/google/bundletool"); + } + if (Utilities.versionCompare(buildToolsVersion, "24.0.3") < 0) { + throw ModUtils.ModuleError("Version of Android SDK build tools too old. This version " + + "is " + buildToolsVersion + " and minimum version is " + + "24.0.3. Please update the Android SDK.") + } + } + + FileTagger { + patterns: ["AndroidManifest.xml"] + fileTags: ["android.manifest"] + } + + FileTagger { + patterns: ["*.aidl"] + fileTags: ["android.aidl"] + } + + Parameter { + property bool embedJar: true + } + + Rule { + condition: _enableRules + inputs: ["android.aidl"] + Artifact { + filePath: FileInfo.joinPaths(Utilities.getHash(input.filePath), + input.completeBaseName + ".java") + fileTags: ["java.java"] + } + + prepare: { + var aidl = product.Android.sdk.aidlFilePath; + var args = ["-p" + product.Android.sdk.frameworkAidlFilePath]; + var aidlSearchPaths = input.Android.sdk.aidlSearchPaths; + for (var i = 0; i < (aidlSearchPaths ? aidlSearchPaths.length : 0); ++i) + args.push("-I" + aidlSearchPaths[i]); + args.push(input.filePath, output.filePath); + var cmd = new Command(aidl, args); + cmd.description = "processing " + input.fileName; + return [cmd]; + } + } + + property bool customManifestProcessing: false + Group { + condition: !Android.sdk.customManifestProcessing + fileTagsFilter: "android.manifest_processed" + fileTags: "android.manifest_final" + } + Rule { + condition: _enableRules + inputs: "android.manifest" + Artifact { + filePath: FileInfo.joinPaths("processed_manifest", input.fileName) + fileTags: "android.manifest_processed" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "ensuring correct package name in Android manifest file"; + cmd.sourceCode = function() { + var manifestData = new Xml.DomDocument(); + manifestData.load(input.filePath); + var rootElem = manifestData.documentElement(); + if (!rootElem || !rootElem.isElement() || rootElem.tagName() != "manifest") + throw "No manifest tag found in '" + input.filePath + "'."; + + // Quick sanity check. Don't try to be fancy; let's not risk rejecting valid names. + var packageName = product.Android.sdk.packageName; + if (!packageName.match(/^[^.]+(?:\.[^.]+)+$/)) { + throw "Package name '" + packageName + "' is not valid. Please set " + + "Android.sdk.packageName to a name following the " + + "'com.mycompany.myproduct' pattern." + } + rootElem.setAttribute("package", packageName); + if (product.Android.sdk.versionCode !== undefined) + rootElem.setAttribute("android:versionCode", product.Android.sdk.versionCode); + if (product.Android.sdk.versionName !== undefined) + rootElem.setAttribute("android:versionName", product.Android.sdk.versionName); + + if (product.Android.sdk._bundledInAssets) { + // Remove + // custom AndroidManifest.xml because assets are in rcc files for qt >= 5.14 + var appElem = rootElem.firstChild("application"); + if (!appElem || !appElem.isElement() || appElem.tagName() != "application") + throw "No application tag found in '" + input.filePath + "'."; + var activityElem = appElem.firstChild("activity"); + if (!activityElem || !activityElem.isElement() || + activityElem.tagName() != "activity") + throw "No activity tag found in '" + input.filePath + "'."; + var metaDataElem = activityElem.firstChild("meta-data"); + while (metaDataElem && metaDataElem.isElement()) { + if (SdkUtils.elementHasBundledAttributes(metaDataElem)) { + var elemToRemove = metaDataElem; + metaDataElem = metaDataElem.nextSibling("meta-data"); + activityElem.removeChild(elemToRemove); + } else { + metaDataElem = metaDataElem.nextSibling("meta-data"); + } + } + } + + var usedSdkElem = rootElem.firstChild("uses-sdk"); + if (!usedSdkElem || !usedSdkElem.isElement()) { + usedSdkElem = manifestData.createElement("uses-sdk"); + rootElem.appendChild(usedSdkElem); + } else { + if (!usedSdkElem.isElement()) + throw "Tag uses-sdk is not an element in '" + input.filePath + "'."; + } + usedSdkElem.setAttribute("android:minSdkVersion", + product.Android.sdk.minimumVersion); + usedSdkElem.setAttribute("android:targetSdkVersion", + product.Android.sdk.targetVersion); + + rootElem.appendChild(usedSdkElem); + manifestData.save(output.filePath, 4); + } + return cmd; + } + } + + Rule { + condition: _enableRules && !_enableAapt2 + multiplex: true + inputs: ["android.resources", "android.assets", "android.manifest_final"] + + outputFileTags: ["java.java"] + outputArtifacts: { + var artifacts = []; + var resources = inputs["android.resources"]; + if (resources && resources.length) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.Android.sdk.generatedJavaFilesDir, + "R.java"), + fileTags: ["java.java"] + }); + } + + return artifacts; + } + + prepare: SdkUtils.prepareAaptGenerate.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules && _enableAapt2 + inputs: ["android.resources"] + outputArtifacts: { + var outputs = []; + var resources = inputs["android.resources"]; + for (var i = 0; i < resources.length; ++i) { + var filePath = resources[i].filePath; + var resourceFileName = SdkUtils.generateAapt2ResourceFileName(filePath); + var compiledName = FileInfo.joinPaths(product.Android.sdk.compiledResourcesDir, + resourceFileName); + outputs.push({filePath: compiledName, fileTags: "android.resources_compiled"}); + } + return outputs; + } + outputFileTags: ["android.resources_compiled"] + + prepare: SdkUtils.prepareAapt2CompileResource.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules && _enableAapt2 + multiplex: true + inputs: ["android.resources_compiled", "android.assets", "android.manifest_final"] + outputFileTags: ["java.java", "android.apk_resources"] + outputArtifacts: { + var artifacts = []; + artifacts.push({ + filePath: product.Android.sdk.apkBaseName + (product.Android.sdk._generateAab ? + ".apk_aab" : ".apk_apk"), + fileTags: ["android.apk_resources"] + }); + var resources = inputs["android.resources_compiled"]; + if (resources && resources.length) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.Android.sdk.generatedJavaFilesDir, + "R.java"), + fileTags: ["java.java"] + }); + } + + return artifacts; + } + prepare: SdkUtils.prepareAapt2Link.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules + multiplex: true + + Artifact { + filePath: FileInfo.joinPaths(product.Android.sdk.generatedJavaFilesDir, + "BuildConfig.java") + fileTags: ["java.java"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating BuildConfig.java"; + cmd.sourceCode = function() { + var debugValue = product.qbs.buildVariant === "debug" ? "true" : "false"; + var ofile = new TextFile(output.filePath, TextFile.WriteOnly); + ofile.writeLine("package " + product.Android.sdk.packageName + ";") + ofile.writeLine("public final class BuildConfig {"); + ofile.writeLine(" public final static boolean DEBUG = " + debugValue + ";"); + ofile.writeLine("}"); + ofile.close(); + }; + return [cmd]; + } + } + + Rule { + condition: _enableRules + multiplex: true + inputs: ["java.class"] + inputsFromDependencies: ["java.jar", "bundled_jar"] + Artifact { + filePath: product.Android.sdk._generateAab ? + FileInfo.joinPaths(product.Android.sdk.packageContentsDir, "dex", + "classes.dex") : + FileInfo.joinPaths(product.Android.sdk.packageContentsDir, "classes.dex") + fileTags: ["android.dex"] + } + prepare: SdkUtils.prepareDex.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules + property stringList inputTags: "android.nativelibrary" + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + Artifact { + filePath: FileInfo.joinPaths(product.Android.sdk.packageContentsDir, "lib", + input.Android.ndk.abi, product.Android.sdk._archInName ? + input.baseName + "_" + input.Android.ndk.abi + ".so" : + input.fileName) + fileTags: "android.nativelibrary_deployed" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "copying " + input.fileName + " for packaging"; + cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); }; + return cmd; + } + } + + Rule { + condition: _enableRules + multiplex: true + property stringList inputTags: "android.stl" + inputsFromDependencies: inputTags + inputs: product.aggregate ? [] : inputTags + outputFileTags: "android.stl_deployed" + outputArtifacts: { + var deploymentData = SdkUtils.stlDeploymentData(product, inputs, "stl"); + var outputs = []; + for (var i = 0; i < deploymentData.outputFilePaths.length; ++i) { + outputs.push({filePath: deploymentData.outputFilePaths[i], + fileTags: "android.stl_deployed"}); + } + return outputs; + } + prepare: { + var cmds = []; + var deploymentData = SdkUtils.stlDeploymentData(product, inputs); + for (var i = 0; i < deploymentData.uniqueInputs.length; ++i) { + var input = deploymentData.uniqueInputs[i]; + var stripArgs = ["--strip-all", "-o", deploymentData.outputFilePaths[i], + input.filePath]; + var cmd = new Command(input.cpp.stripPath, stripArgs); + cmd.description = "deploying " + input.fileName; + cmds.push(cmd); + } + return cmds; + } + } + + Rule { + condition: _enableRules && !_enableAapt2 && !_generateAab + multiplex: true + inputs: [ + "android.resources", "android.assets", "android.manifest_final", + "android.dex", "android.stl_deployed", + "android.nativelibrary_deployed" + ] + Artifact { + filePath: product.Android.sdk.apkBaseName + ".apk_unsigned" + fileTags: "android.package_unsigned" + } + prepare: SdkUtils.prepareAaptPackage.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules && _enableAapt2 && !_generateAab + multiplex: true + inputs: [ + "android.apk_resources", "android.manifest_final", + "android.dex", "android.stl_deployed", + "android.nativelibrary_deployed" + ] + Artifact { + filePath: product.Android.sdk.apkBaseName + ".apk_unsigned" + fileTags: "android.package_unsigned" + } + prepare: SdkUtils.prepareApkPackage.apply(SdkUtils, arguments) + } + + Rule { + condition: _enableRules && _enableAapt2 && _generateAab + multiplex: true + inputs: [ + "android.apk_resources", "android.manifest_final", + "android.dex", "android.stl_deployed", + "android.nativelibrary_deployed" + ] + Artifact { + filePath: product.Android.sdk.apkBaseName + ".aab_unsigned" + fileTags: "android.package_unsigned" + } + prepare: SdkUtils.prepareBundletoolPackage.apply(SdkUtils, arguments) + } +} diff --git a/share/qbs/modules/Android/sdk/utils.js b/share/qbs/modules/Android/sdk/utils.js new file mode 100644 index 00000000..2b111522 --- /dev/null +++ b/share/qbs/modules/Android/sdk/utils.js @@ -0,0 +1,449 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); +var Xml = require("qbs.Xml"); + +function availableBuildToolsVersions(sdkDir) { + var re = /^([0-9]+)\.([0-9]+)\.([0-9]+)$/; + var buildTools = File.directoryEntries(FileInfo.joinPaths(sdkDir, "build-tools"), + File.Dirs | File.NoDotAndDotDot); + var versions = []; + for (var i = 0; i < buildTools.length; ++i) { + var match = buildTools[i].match(re); + if (match !== null) { + versions.push(buildTools[i]); + } + } + + // Sort by version number + versions.sort(function (a, b) { + return Utilities.versionCompare(a, b); + }); + + return versions; +} + +function prepareDex(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var dexCompilerFilePath = product.Android.sdk._useD8 ? product.Android.sdk.d8FilePath + : product.Android.sdk.dxFilePath; + var args = ["--output", FileInfo.path(output.filePath)]; + + if (product.Android.sdk._useD8) { + args.push("--no-desugaring", "--release"); + var classes = inputs["java.class"]; + if (classes) { + args = args.concat(classes.map(function(javaClass) { + return FileInfo.relativePath(product.java.classFilesDir, javaClass.filePath) })); + } + } else { + args.unshift("--dex"); + args.push(product.java.classFilesDir); + } + + var jarFiles = []; + function traverseJarDeps(dep) { + if (dep.parameters.Android && dep.parameters.Android.sdk + && dep.parameters.Android.sdk.embedJar === false) + return; + + var isJar = typeof dep.artifacts["java.jar"] !== "undefined"; + if (!isJar) + return; + + dep.artifacts["java.jar"].forEach(function(artifact) { + if (!jarFiles.contains(artifact.filePath)) + jarFiles.push(artifact.filePath); + }); + dep.dependencies.forEach(traverseJarDeps); + } + product.dependencies.forEach(traverseJarDeps); + + if (typeof product.artifacts["java.jar"] !== "undefined") { + product.artifacts["java.jar"].forEach(function(artifact) { + if (!jarFiles.contains(artifact.filePath)) + jarFiles.push(artifact.filePath); + }); + } + + args = args.concat(jarFiles); + + var cmd; + if (product.Android.sdk._useD8) { + cmd = new JavaScriptCommand(); + cmd.args = args; + cmd.dexCompilerFilePath = dexCompilerFilePath; + cmd.description = "creating " + output.fileName; + cmd.workingDirectory = product.java.classFilesDir; + cmd.extendedDescription = dexCompilerFilePath + " " + args.join(' '); + cmd.highlight = "compiler"; + cmd.sourceCode = function() { + // androiddeployqt copied jar files in product.java.classFilesDir + // but the rule only tags one jar file ("QtAndroid.jar"/"Qt6Android.jar") + // So to pass all files to d8, Qbs needs to read the directory + var bundledJarFilesDir = product.java.classFilesDir; + var bundledJarFiles = File.directoryEntries(bundledJarFilesDir, File.Files + | File.NoDotAndDotDot); + args = args.concat(bundledJarFiles.map(function(jarFile) { + return FileInfo.joinPaths(bundledJarFilesDir, jarFile) })); + var process = new Process(); + var exitCode; + process.setWorkingDirectory(workingDirectory); + process.exec(dexCompilerFilePath, args, true); + try { + process.exec(dexCompilerFilePath, args, true); + } catch (e) { + throw new Error("Error while running dex compiler command: '" + + Process.shellQuote(dexCompilerFilePath, args) + "': " + e.toString()); + } finally { + process.close(); + } + } + } else { + cmd = new Command(dexCompilerFilePath, args); + cmd.description = "creating " + output.fileName; + cmd.workingDirectory = product.java.classFilesDir; + } + return [cmd]; +} + +function findParentDir(filePath, parentDirName) +{ + var lastDir; + var currentDir = FileInfo.path(filePath); + while (lastDir !== currentDir) { + if (FileInfo.fileName(currentDir) === parentDirName) + return currentDir; + lastDir = currentDir; + currentDir = FileInfo.path(currentDir); + } +} + +function commonAaptPackageArgs(project, product, inputs, outputs, input, output, + explicitlyDependsOn) { + var manifestFilePath = inputs["android.manifest_final"][0].filePath; + var args = ["package", "--auto-add-overlay", "-f", + "-M", manifestFilePath, + "-I", product.Android.sdk.androidJarFilePath]; + var resources = inputs["android.resources"]; + var resourceDirs = []; + if (resources) { + for (var i = 0; i < resources.length; ++i) { + var resDir = findParentDir(resources[i].filePath, "res"); + if (!resDir) { + throw "File '" + resources[i].filePath + "' is tagged as an Android resource, " + + "but is not located under a directory called 'res'."; + } + if (!resourceDirs.contains(resDir)) + resourceDirs.push(resDir); + } + } + for (i = 0; i < resourceDirs.length; ++i) + args.push("-S", resourceDirs[i]); + var assets = inputs["android.assets"]; + var assetDirs = []; + if (assets) { + for (i = 0; i < assets.length; ++i) { + var assetDir = findParentDir(assets[i].filePath, "assets"); + if (!assetDir) { + throw "File '" + assets[i].filePath + "' is tagged as an Android asset, " + + "but is not located under a directory called 'assets'."; + } + if (!assetDirs.contains(assetDir)) + assetDirs.push(assetDir); + } + } + for (i = 0; i < assetDirs.length; ++i) + args.push("-A", assetDirs[i]); + if (product.qbs.buildVariant === "debug") + args.push("--debug-mode"); + return args; +} + +// Rules: from https://developer.android.com/studio/command-line/aapt2 +// Input Output +// XML resource files, such as Resource table with *.arsc.flat as its extension. +// String and Style, which are +// located in the res/values/ +// directory. + +// All other resource files. All files other than the files under res/values/ directory are +// converted to binary XML files with *.flat extensions. +// Additionally all PNG files are crunched by default and adopt +// *.png.flat extensions. +function generateAapt2ResourceFileName(filePath) { + var suffix = FileInfo.suffix(filePath); + if (suffix === "xml") { + var data = new Xml.DomDocument(); + data.load(filePath); + var rootElem = data.documentElement(); + if (rootElem && rootElem.isElement() && rootElem.tagName() === "resources") + // This is a valid XML resource file + suffix = "arsc"; + // If the xml file is not a "resources" one then it's treated like any other resource file. + } + var dir = FileInfo.path(filePath); + var baseName = FileInfo.completeBaseName(filePath) + return FileInfo.fileName(dir) + "_" + baseName + "." + suffix + ".flat"; +} + +function prepareAapt2CompileResource(project, product, inputs, outputs, input, output, + explicitlyDependsOn) { + var cmds = []; + var resources = inputs["android.resources"]; + var compilesResourcesDir = product.Android.sdk.compiledResourcesDir; + if (!File.makePath(compilesResourcesDir)) { + throw "Cannot create directory '" + FileInfo.toNativeSeparators(compilesResourcesDir) + + "'."; + } + var args = ["compile", FileInfo.toNativeSeparators(input.filePath), + "-o", FileInfo.toNativeSeparators(compilesResourcesDir)]; + var cmd = new Command(product.Android.sdk.aaptFilePath, args); + var outputFileName = generateAapt2ResourceFileName(input.filePath); + cmd.description = "compiling resource " + input.fileName + " into " + outputFileName; + cmds.push(cmd); + + return cmds; +} + +function prepareAapt2Link(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var baseOutputFilePath = outputs["android.apk_resources"][0].filePath; + var manifestFilePath = inputs["android.manifest_final"][0].filePath; + var compilesResourcesDir = product.Android.sdk.compiledResourcesDir; + var compiledResources = inputs["android.resources_compiled"]; + + var args = ["link", "-o", baseOutputFilePath, "-I", product.Android.sdk.androidJarFilePath]; + var i = 0; + if (compiledResources) { + for (i = 0; i < compiledResources.length; ++i) + args.push(compiledResources[i].filePath); + } + args.push("--no-auto-version"); + args.push("--auto-add-overlay"); + args.push("--manifest", manifestFilePath); + args.push("--java", product.Android.sdk.generatedJavaFilesBaseDir); + + var assets = inputs["android.assets"]; + var assetDirs = []; + if (assets) { + for (i = 0; i < assets.length; ++i) { + var assetDir = findParentDir(assets[i].filePath, "assets"); + if (!assetDir) { + throw "File '" + assets[i].filePath + "' is tagged as an Android asset, " + + "but is not located under a directory called 'assets'."; + } + if (!assetDirs.contains(assetDir)) + assetDirs.push(assetDir); + } + } + for (i = 0; i < assetDirs.length; ++i) + args.push("-A", assetDirs[i]); + if (product.qbs.buildVariant === "debug") + args.push("-v"); + if (product.Android.sdk._generateAab) + args.push("--proto-format"); + var cmd = new Command(product.Android.sdk.aaptFilePath, args); + cmd.description = "linking resources"; + cmd.workingDirectory = product.buildDirectory; + cmds.push(cmd); + + return cmds; +} + +function prepareAaptGenerate(project, product, inputs, outputs, input, output, + explicitlyDependsOn) { + var args = commonAaptPackageArgs.apply(this, arguments); + args.push("--no-crunch", "-m"); + var resources = inputs["android.resources"]; + if (resources && resources.length) + args.push("-J", ModUtils.moduleProperty(product, "generatedJavaFilesBaseDir")); + var cmd = new Command(product.Android.sdk.aaptFilePath, args); + cmd.description = "processing resources"; + return [cmd]; +} + +function prepareAaptPackage(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var apkOutput = outputs["android.package_unsigned"][0]; + var args = commonAaptPackageArgs.apply(this, arguments); + args.push("-F", apkOutput.filePath + ".unaligned"); + args.push(product.Android.sdk.packageContentsDir); + var cmd = new Command(product.Android.sdk.aaptFilePath, args); + cmd.description = "generating " + apkOutput.fileName; + cmds.push(cmd); + + cmd = new Command(product.Android.sdk.zipalignFilePath, + ["-f", "4", apkOutput.filePath + ".unaligned", apkOutput.filePath]); + cmd.silent = true; + cmds.push(cmd); + + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.unalignedApk = apkOutput.filePath + ".unaligned"; + cmd.sourceCode = function() { File.remove(unalignedApk); }; + cmds.push(cmd); + return cmds; +} + +function prepareApkPackage(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var apkInputFilePath = inputs["android.apk_resources"][0].filePath; + var apkOutput = outputs["android.package_unsigned"][0]; + var apkOutputFilePathUnaligned = apkOutput.filePath + ".unaligned"; + var dexFilePath = inputs["android.dex"][0].filePath; + + var copyCmd = new JavaScriptCommand(); + copyCmd.description = "copying apk"; + copyCmd.source = apkInputFilePath; + copyCmd.target = apkOutputFilePathUnaligned; + copyCmd.sourceCode = function() { + File.copy(source, target); + } + cmds.push(copyCmd); + + var jarArgs = ["-uvf", apkOutputFilePathUnaligned, "."]; + var libPath = FileInfo.joinPaths(product.Android.sdk.packageContentsDir); + var jarCmd = new Command(product.java.jarFilePath, jarArgs); + jarCmd.description = "packaging files"; + jarCmd.workingDirectory = libPath; + cmds.push(jarCmd); + + cmd = new Command(product.Android.sdk.zipalignFilePath, + ["-f", "4", apkOutputFilePathUnaligned, apkOutput.filePath]); + cmd.silent = true; + cmds.push(cmd); + + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.unalignedApk = apkOutputFilePathUnaligned; + cmd.sourceCode = function() { File.remove(unalignedApk); }; + cmds.push(cmd); + return cmds; +} + +function prepareBundletoolPackage(project, product, inputs, outputs, input, output, + explicitlyDependsOn) { + var cmds = []; + var baseModuleDir = product.Android.sdk.packageContentsDir; + var manifestDirName = FileInfo.joinPaths(baseModuleDir, "manifest"); + var pkgBaseFileName = inputs["android.apk_resources"][0].filePath; + + var jarResourcesArgs = ["xf", pkgBaseFileName]; + var jarResourcesCmd = new Command(product.java.jarFilePath, jarResourcesArgs); + jarResourcesCmd.description = "extracting resources apk"; + jarResourcesCmd.workingDirectory = baseModuleDir; + cmds.push(jarResourcesCmd); + + var moveManifestCmd = new JavaScriptCommand(); + moveManifestCmd.description = "moving manifest in manifest directory"; + moveManifestCmd.path = manifestDirName; + moveManifestCmd.manifestFilePath = baseModuleDir + "/AndroidManifest.xml"; + moveManifestCmd.sourceCode = function() { + if (!File.exists(path)) + File.makePath(path); + if (File.exists(manifestFilePath)) + File.move(manifestFilePath, path + "/AndroidManifest.xml"); + } + cmds.push(moveManifestCmd); + + var baseFilePath = FileInfo.joinPaths(product.buildDirectory, "base.zip"); + var jarBaseArgs = ["cfM", baseFilePath, "."]; + var jarBaseCmd = new Command(product.java.jarFilePath, jarBaseArgs); + jarBaseCmd.description = "compressing base module"; + jarBaseCmd.workingDirectory = baseModuleDir; + cmds.push(jarBaseCmd); + + var aabFilePath = outputs["android.package_unsigned"][0].filePath; + var removeCmd = new JavaScriptCommand(); + removeCmd.description = "removing previous aab"; + removeCmd.filePath = aabFilePath; + removeCmd.sourceCode = function() { + if (File.exists(filePath)) + File.remove(filePath); + } + cmds.push(removeCmd); + + var bundleConfigFilePath = FileInfo.joinPaths(product.buildDirectory, "BundleConfig.json"); + var createBundleConfigCmd = new JavaScriptCommand(); + createBundleConfigCmd.description = "create BundleConfig.json"; + createBundleConfigCmd.filePath = bundleConfigFilePath; + createBundleConfigCmd.sourceCode = function() { + var bc = new TextFile(filePath, TextFile.WriteOnly); + bc.writeLine('{"optimizations": {'); + bc.writeLine('"uncompress_native_libraries": {'); + bc.writeLine('"enabled": false'); + bc.writeLine('}}}'); + } + cmds.push(createBundleConfigCmd); + + var args = ["-jar", product.Android.sdk.bundletoolFilePath, "build-bundle"]; + args.push("--modules=" + baseFilePath); + args.push("--output=" + aabFilePath); + args.push("--config=" + bundleConfigFilePath); + var cmd = new Command(product.java.interpreterFilePath, args); + cmd.description = "generating " + aabFilePath.fileName; + cmds.push(cmd); + + return cmds; +} + +function stlDeploymentData(product, inputs, type) +{ + var data = { uniqueInputs: [], outputFilePaths: []}; + var uniqueFilePaths = []; + var theInputs = inputs["android.stl"]; + if (!theInputs) + return data; + for (var i = 0; i < theInputs.length; ++i) { + var currentInput = theInputs[i]; + if (uniqueFilePaths.contains(currentInput.filePath)) + continue; + uniqueFilePaths.push(currentInput.filePath); + data.uniqueInputs.push(currentInput); + var outputFileName = currentInput.fileName; + data.outputFilePaths.push(FileInfo.joinPaths(product.Android.sdk.packageContentsDir, "lib", + currentInput.Android.ndk.abi, + outputFileName)); + } + return data; +} + +function elementHasBundledAttributes(element) +{ + return element.hasAttribute("android:name") && + (element.attribute("android:name") === "android.app.bundled_in_assets_resource_id") || + (element.attribute("android:name") === "android.app.bundled_in_lib_resource_id"); +} diff --git a/share/qbs/modules/Exporter/pkgconfig/pkgconfig.js b/share/qbs/modules/Exporter/pkgconfig/pkgconfig.js new file mode 100644 index 00000000..52b4dffe --- /dev/null +++ b/share/qbs/modules/Exporter/pkgconfig/pkgconfig.js @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); + +function quote(value) +{ + if (value.contains(" ") || value.contains("'") || value.contains('"')) { + return '"' + value.replace(/(["'\\])/g, "\\$1") + '"'; + } + return value; +} + +function writeEntry(product, file, key, propertyName, required, additionalValues) +{ + var value = product.Exporter.pkgconfig[propertyName]; + if (additionalValues && additionalValues.length > 0) + value = (value || []).concat(additionalValues); + var valueIsNotEmpty = value && (!(value instanceof Array) || value.length > 0); + if (valueIsNotEmpty) { + if (value instanceof Array) + value = value.join(' '); + file.writeLine(key + ": " + value); + } else if (required) { + throw "Failure creating " + FileInfo.fileName(file.filePath()) + ": The entry '" + key + + "' is required, but property Exporter.pkgconfig." + + propertyName + " is not set."; + } +} + +function collectAutodetectedData(topLevelProduct) +{ + var data = { + libs: [], + cflags: [], + requires: [], + requiresPrivate: [] + }; + if (!topLevelProduct.Exporter.pkgconfig.autoDetect) + return data; + + var excludedDeps = topLevelProduct.Exporter.pkgconfig.excludedDependencies || []; + var explicitRequires = topLevelProduct.Exporter.pkgconfig.requiresEntry || []; + var explicitRequiresPrivate = topLevelProduct.Exporter.pkgconfig.requiresPrivateEntry || []; + + var transformFunc = topLevelProduct.Exporter.pkgconfig.transformFunction; + + // Make use of the "prefix" convenience variable if applicable. + function quoteAndPrefixify(value) + { + var quotedValue = quote(value); + var installPrefix = topLevelProduct.qbs.installPrefix || ""; + if (!topLevelProduct.Exporter.pkgconfig._usePrefix || typeof value !== "string" + || !value.startsWith(installPrefix) + || (value.length > installPrefix.length && value[installPrefix.length] !== '/')) { + return quotedValue; + } + return quotedValue.replace(topLevelProduct.qbs.installPrefix, "${prefix}"); + } + + function transformedValue(product, moduleName, propertyName) + { + var originalValue = product.exports[moduleName][propertyName]; + var value = transformFunc + ? eval("(" + transformFunc + ")(product, moduleName, propertyName, originalValue)") + : originalValue; + if (value instanceof Array) + value.forEach(function(v, i, a) { a[i] = quoteAndPrefixify(v); }); + else if (value) + value = quoteAndPrefixify(value); + return value; + } + + function collectLibs(productOrModule) + { + var libs = []; + var libArtifacts; + var isProduct = !productOrModule.present; + var considerDynamicLibs = !isProduct || (productOrModule.type + && productOrModule.type.contains("dynamiclibrary")); + if (considerDynamicLibs) { + libArtifacts = productOrModule.artifacts.dynamiclibrary; + } else { + var considerStaticLibs = !isProduct || (productOrModule.type + && productOrModule.type.contains("staticlibrary")); + if (considerStaticLibs) + libArtifacts = productOrModule.artifacts.staticlibrary; + } + for (var i = 0; i < (libArtifacts || []).length; ++i) { + var libArtifact = libArtifacts[i]; + if (libArtifact.qbs.install) { + var installDir = FileInfo.path(ModUtils.artifactInstalledFilePath(libArtifact)); + installDir = installDir.slice(libArtifact.qbs.installRoot.length); + libs.push("-L" + quoteAndPrefixify(FileInfo.cleanPath(installDir)), + "-l" + quote(productOrModule.targetName)); + } + } + if (!productOrModule.exports.cpp) + return libs; + var libPaths = transformedValue(productOrModule, "cpp", "libraryPaths"); + if (libPaths) + libs.push.apply(libs, libPaths.map(function(p) { return "-L" + p; })); + function libNamesToLibEntries(libNames) { + return libNames.map(function(libName) { return "-l" + libName; }); + }; + var dlls = transformedValue(productOrModule, "cpp", "dynamicLibraries"); + if (dlls) + libs.push.apply(libs, libNamesToLibEntries(dlls)); + var staticLibs = transformedValue(productOrModule, "cpp", "staticLibraries"); + if (staticLibs) + libs.push.apply(libs, libNamesToLibEntries(staticLibs)); + var lFlags = transformedValue(productOrModule, "cpp", "linkerFlags"); + if (lFlags) + libs.push.apply(libs, lFlags); + lFlags = transformedValue(productOrModule, "cpp", "driverFlags"); + if (lFlags) + libs.push.apply(libs, lFlags); + lFlags = transformedValue(productOrModule, "cpp", "driverLinkerFlags"); + if (lFlags) + libs.push.apply(libs, lFlags); + return libs; + } + + function collectCFlags(productOrModule) + { + if (!productOrModule.exports.cpp) + return []; + var flags = []; + var defs = transformedValue(productOrModule, "cpp", "defines"); + if (defs) + flags.push.apply(flags, defs.map(function(d) { return "-D" + d; })); + var incPaths = transformedValue(productOrModule, "cpp", "includePaths"); + if (incPaths) + flags.push.apply(flags, incPaths.map(function(p) { return "-I" + p; })); + var cflags = transformedValue(productOrModule, "cpp", "commonCompilerFlags"); + if (cflags) + flags.push.apply(flags, cflags); + cflags = transformedValue(productOrModule, "cpp", "driverFlags"); + if (cflags) + flags.push.apply(flags, cflags); + cflags = transformedValue(productOrModule, "cpp", "cxxFlags") + || transformedValue(productOrModule, "cpp", "cFlags"); + if (cflags) + flags.push.apply(flags, cflags); + return flags; + } + + function collectAutodetectedDataRecursive(productOrModule, privateContext) + { + if (!privateContext) { + data.libs.push.apply(data.libs, collectLibs(productOrModule)); + data.cflags.push.apply(data.cflags, collectCFlags(productOrModule)); + } + var exportedDeps = productOrModule.exports ? productOrModule.exports.dependencies : []; + var exportedDepNames = []; + var privateDeps = []; + for (var i = 0; i < exportedDeps.length; ++i) + exportedDepNames.push(exportedDeps[i].name); + for (i = 0; i < (productOrModule.dependencies || []).length; ++i) { + var dep = productOrModule.dependencies[i]; + if (exportedDepNames.contains(dep.name)) + continue; + privateDeps.push(dep); + } + + function gatherData(dep) { + if (dep.name === "Exporter.pkgconfig") + return; + var depHasPkgConfig = dep.Exporter && dep.Exporter.pkgconfig; + if (depHasPkgConfig) { + var entry = FileInfo.completeBaseName(dep.Exporter.pkgconfig.fileName); + if (excludedDeps.contains(entry)) + return; + if (isPrivateDep && !data.requiresPrivate.contains(entry) + && !explicitRequiresPrivate.contains(entry)) { + data.requiresPrivate.push(entry); + } + if (!isPrivateDep && !data.requires.contains(entry) + && !explicitRequires.contains(entry)) { + data.requires.push(entry); + } + } else { + if (excludedDeps.contains(dep.name)) + return; + if (isPrivateDep && explicitRequiresPrivate.contains(dep.name)) + return; + if (!isPrivateDep && explicitRequires.contains(dep.name)) + return; + collectAutodetectedDataRecursive(dep, isPrivateDep); + } + } + var isPrivateDep = privateContext; + exportedDeps.forEach(gatherData); + isPrivateDep = true; + privateDeps.forEach(gatherData); + } + + collectAutodetectedDataRecursive(topLevelProduct, false); + return data; +} diff --git a/share/qbs/modules/Exporter/pkgconfig/pkgconfig.qbs b/share/qbs/modules/Exporter/pkgconfig/pkgconfig.qbs new file mode 100644 index 00000000..c36afd95 --- /dev/null +++ b/share/qbs/modules/Exporter/pkgconfig/pkgconfig.qbs @@ -0,0 +1,87 @@ +import qbs.FileInfo +import qbs.TextFile + +import "pkgconfig.js" as HelperFunctions + +Module { + property string fileName: product.targetName + ".pc" + property bool autoDetect: true + property var transformFunction // function(product, moduleName, propertyName, valueElement) + property stringList excludedDependencies + + property string nameEntry: product.name + property string descriptionEntry: product.name + property string versionEntry: product.version + property string urlEntry + property stringList cflagsEntry: [] + property stringList libsEntry: [] + property stringList libsPrivateEntry: [] + property stringList requiresEntry: [] + property stringList requiresPrivateEntry: [] + property stringList conflictsEntry: [] + + property var customVariables + + property bool _usePrefix: autoDetect && qbs.installPrefix + + additionalProductTypes: ["Exporter.pkgconfig.pc"] + + Rule { + multiplex: true + requiresInputs: false + + // Make sure all relevant library artifacts have been created by the time we run. + auxiliaryInputs: { + if (!autoDetect) + return undefined; + if (product.type.contains("staticlibrary")) + return ["staticlibrary"]; + if (product.type.contains("dynamiclibrary")) + return ["dynamiclibrary"]; + } + + Artifact { + filePath: product.Exporter.pkgconfig.fileName + fileTags: ["Exporter.pkgconfig.pc"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + if (product.Exporter.pkgconfig._usePrefix) + f.writeLine("prefix=" + product.qbs.installPrefix + "\n"); + var customVariables = product.Exporter.pkgconfig.customVariables; + if (customVariables) { + for (var customVar in customVariables) + f.writeLine(customVar + "=" + customVariables[customVar]); + f.writeLine(""); + } + var autoDetectedData = HelperFunctions.collectAutodetectedData(product); + HelperFunctions.writeEntry(product, f, "Name", "nameEntry", true); + HelperFunctions.writeEntry(product, f, "Description", "descriptionEntry", true); + HelperFunctions.writeEntry(product, f, "Version", "versionEntry", true); + HelperFunctions.writeEntry(product, f, "URL", "urlEntry"); + HelperFunctions.writeEntry(product, f, "Cflags", "cflagsEntry", false, + autoDetectedData.cflags); + HelperFunctions.writeEntry(product, f, "Libs", "libsEntry", false, + autoDetectedData.libs); + HelperFunctions.writeEntry(product, f, "Libs.private", "libsPrivateEntry"); + HelperFunctions.writeEntry(product, f, "Requires", "requiresEntry", false, + autoDetectedData.requires); + HelperFunctions.writeEntry(product, f, "Requires.private", "requiresPrivateEntry", + false, autoDetectedData.requiresPrivate); + HelperFunctions.writeEntry(product, f, "Conflicts", "conflictsEntry"); + }; + return [cmd]; + } + } + + validate: { + if (requiresEntry && excludedDependencies + && requiresEntry.containsAny(excludedDependencies)) { + throw "The contents of Export.pkgconfig.requiresEntry and " + + "Export.pkgconfig.excludedDependencies must not overlap."; + } + } +} diff --git a/share/qbs/modules/Exporter/qbs/qbsexporter.js b/share/qbs/modules/Exporter/qbs/qbsexporter.js new file mode 100644 index 00000000..be46372c --- /dev/null +++ b/share/qbs/modules/Exporter/qbs/qbsexporter.js @@ -0,0 +1,272 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); + +function tagListToString(tagList) +{ + return JSON.stringify(tagList); +} + +function stringToTagList(tagListString) +{ + return JSON.parse(tagListString); +} + +function writeTargetArtifactGroup(output, tagList, artifactList, moduleInstallDir, moduleFile) +{ + // Do not add our qbs module file itself. + if (tagListToString(tagList) === tagListToString(output.fileTags)) + return; + + moduleFile.writeLine(" Group {"); + moduleFile.writeLine(" filesAreTargets: true"); + var filteredTagList = tagList.filter(function(t) { return t !== "installable"; }); + moduleFile.writeLine(" fileTags: " + JSON.stringify(filteredTagList)); + moduleFile.writeLine(" files: ["); + for (i = 0; i < artifactList.length; ++i) { + var artifact = artifactList[i]; + var installedArtifactFilePath = ModUtils.artifactInstalledFilePath(artifact); + + // Use relative file paths for relocatability. + var relativeInstalledArtifactFilePath = FileInfo.relativePath(moduleInstallDir, + installedArtifactFilePath); + moduleFile.writeLine(" " + JSON.stringify(relativeInstalledArtifactFilePath) + + ","); + } + moduleFile.writeLine(" ]"); + moduleFile.writeLine(" }"); + +} + +function writeTargetArtifactGroups(product, output, moduleFile) +{ + var relevantArtifacts = []; + for (var i = 0; i < (product.Exporter.qbs._artifactTypes || []).length; ++i) { + var tag = product.Exporter.qbs._artifactTypes[i]; + var artifactsForTag = product.artifacts[tag] || []; + for (var j = 0; j < artifactsForTag.length; ++j) { + if (!relevantArtifacts.contains(artifactsForTag[j])) + relevantArtifacts.push(artifactsForTag[j]); + } + } + var artifactsByTags = {}; + var artifactCount = relevantArtifacts ? relevantArtifacts.length : 0; + for (i = 0; i < artifactCount; ++i) { + var artifact = relevantArtifacts[i]; + if (!artifact.fileTags.contains("installable")) + continue; + + // Put all artifacts with the same set of file tags into the same group, so we don't + // create more groups than necessary. + var key = tagListToString(artifact.fileTags); + var currentList = artifactsByTags[key]; + if (currentList) + currentList.push(artifact); + else + currentList = [artifact]; + artifactsByTags[key] = currentList; + } + var moduleInstallDir = FileInfo.path(ModUtils.artifactInstalledFilePath(output)); + for (var tagListKey in artifactsByTags) { + writeTargetArtifactGroup(output, stringToTagList(tagListKey), artifactsByTags[tagListKey], + moduleInstallDir, moduleFile); + } +} + +function checkValuePrefix(name, value, forbiddenPrefix, prefixDescription) +{ + if (value.startsWith(forbiddenPrefix)) { + throw "Value '" + value + "' for exported property '" + name + "' in product '" + + product.name + "' points into " + prefixDescription + ".\n" + + "Did you forget to set the prefixMapping property in an Export item?"; + } +} + +function stringifyValue(project, product, moduleInstallDir, prop, value) +{ + if (value instanceof Array) { + var repr = "["; + for (var i = 0; i < value.length; ++i) { + repr += stringifyValue(project, product, moduleInstallDir, prop, value[i]) + ", "; + } + repr += "]"; + return repr; + } + if (typeof(value) !== "string") { + var value = JSON.stringify(value); + if (prop.type === "variant") + value = '(' + value + ')'; + return value; + } + + // Catch user oversights: Paths that point into the project source or build directories + // make no sense in the module. + if (!value.startsWith(product.qbs.installRoot)) { + checkValuePrefix(prop.name, value, project.buildDirectory, "project build directory"); + checkValuePrefix(prop.name, value, project.sourceDirectory, "project source directory"); + } + + // Adapt file paths pointing into the install dir, that is, make them relative to the + // module file for relocatability. We accept them with or without the install root. + // The latter form will typically be a result of applying the prefixMapping property, + // while the first one could be an untransformed path, for instance if the project + // file is written in such a way that include paths are picked up from the installed + // location rather than the source directory. + var valuePrefixToStrip; + var fullInstallPrefix = FileInfo.joinPaths(product.qbs.installRoot, product.qbs.installPrefix); + if (fullInstallPrefix.length > 1 && value.startsWith(fullInstallPrefix)) { + valuePrefixToStrip = fullInstallPrefix; + } else { + var installPrefix = FileInfo.joinPaths("/", product.qbs.installPrefix); + if (installPrefix.length > 1 && value.startsWith(installPrefix)) + valuePrefixToStrip = installPrefix; + } + if (valuePrefixToStrip) { + var deployedModuleInstallDir = moduleInstallDir.slice(fullInstallPrefix.length); + return "FileInfo.cleanPath(FileInfo.joinPaths(path, FileInfo.relativePath(" + + JSON.stringify(deployedModuleInstallDir) + ", " + + JSON.stringify(value.slice(valuePrefixToStrip.length) || "/") + ")))"; + } + + return JSON.stringify(value); +} + +function writeProperty(project, product, moduleInstallDir, prop, indentation, considerValue, + moduleFile) +{ + var line = indentation; + var separatorIndex = prop.name.lastIndexOf("."); + var isModuleProperty = separatorIndex !== -1; + var needsDeclaration = !prop.isBuiltin && !isModuleProperty; + if (needsDeclaration) + line += "property " + prop.type + " "; + var moduleName; + if (isModuleProperty) { + moduleName = prop.name.slice(0, separatorIndex); + if ((product.Exporter.qbs.excludedDependencies || []).contains(moduleName)) + return; + } + line += prop.name + ": "; + + // We emit the literal value, unless the source code clearly refers to values from inside the + // original project, in which case the evaluated value is used. + if (considerValue && /(project|product|exportingProduct)\./.test(prop.sourceCode)) { + var value; + if (isModuleProperty) { + var propertyName = prop.name.slice(separatorIndex + 1); + value = product.exports[moduleName][propertyName]; + } else { + value = product.exports[prop.name]; + } + line += stringifyValue(project, product, moduleInstallDir, prop, value); + } else { + line += prop.sourceCode.replace(/importingProduct\./g, "product."); + } + moduleFile.writeLine(line); +} + +function writeProperties(project, product, moduleInstallDir, list, indentation, considerValue, + moduleFile) +{ + for (var i = 0; i < list.length; ++i) { + writeProperty(project, product, moduleInstallDir, list[i], indentation, considerValue, + moduleFile); + } +} + +// This writes properties set on other modules in the Export item, i.e. property assignments +// like "cpp.includePaths: '...'". +function writeModuleProperties(project, product, output, moduleFile) +{ + var moduleInstallDir = FileInfo.path(ModUtils.artifactInstalledFilePath(output)); + var filteredProps = product.exports.properties.filter(function(p) { + return p.name !== "name"; + }); + + // The right-hand side can refer to values from the exporting product, in which case + // the evaluated value, rather than the source code, needs to go into the module file. + var considerValues = true; + writeProperties(project, product, moduleInstallDir, filteredProps, " ", considerValues, + moduleFile); +} + +function writeItem(product, item, indentation, moduleFile) +{ + moduleFile.writeLine(indentation + item.name + " {"); + var newIndentation = indentation + " "; + + // These are sub-items of the Export item, whose properties entirely live in the context + // of the importing product. Therefore, they must never use pre-evaluated values. + var considerValues = false; + writeProperties(undefined, product, undefined, item.properties, newIndentation, considerValues, + moduleFile) + + for (var i = 0; i < item.childItems.length; ++i) + writeItem(product, item.childItems[i], newIndentation, moduleFile); + moduleFile.writeLine(indentation + "}"); +} + +function isExcludedDependency(product, childItem) +{ + if ((product.Exporter.qbs.excludedDependencies || []).length === 0) + return false; + if (childItem.name !== "Depends") + return false; + for (var i = 0; i < childItem.properties.length; ++i) { + var prop = childItem.properties[i]; + var unquotedRhs = prop.sourceCode.slice(1, -1); + if (prop.name === "name" && product.Exporter.qbs.excludedDependencies.contains(unquotedRhs)) + return true; + } + return false; +} + +function writeChildItems(product, moduleFile) +{ + for (var i = 0; i < product.exports.childItems.length; ++i) { + var item = product.exports.childItems[i]; + if (!isExcludedDependency(product, item)) + writeItem(product, item, " ", moduleFile); + } +} + +function writeImportStatements(product, moduleFile) +{ + var imports = product.exports.imports; + + // We potentially use FileInfo ourselves when transforming paths in stringifyValue(). + if (!imports.contains("import qbs.FileInfo")) + imports.push("import qbs.FileInfo"); + + for (var i = 0; i < imports.length; ++i) + moduleFile.writeLine(imports[i]); +} diff --git a/share/qbs/modules/Exporter/qbs/qbsexporter.qbs b/share/qbs/modules/Exporter/qbs/qbsexporter.qbs new file mode 100644 index 00000000..1e7cb02d --- /dev/null +++ b/share/qbs/modules/Exporter/qbs/qbsexporter.qbs @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.TextFile + +import "qbsexporter.js" as HelperFunctions + +Module { + property stringList artifactTypes + property string fileName: product.targetName + ".qbs" + property stringList excludedDependencies + property string additionalContent + + property stringList _artifactTypes: artifactTypes ? artifactTypes : ["installable"] + + additionalProductTypes: ["Exporter.qbs.module"] + + Rule { + multiplex: true + requiresInputs: false + + // Make sure we only run when all other artifacts are already present. + // TODO: This also matches target artifacts in dependencies. Should not hurt, + // but might be a hint that we should have auxiliaryInputsFromDependencies. + auxiliaryInputs: product.type.filter(function(t) { return t !== "Exporter.qbs.module"; }) + + Artifact { + filePath: product.Exporter.qbs.fileName + fileTags: ["Exporter.qbs.module"] + qbs.install: true + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + HelperFunctions.writeImportStatements(product, f); + f.writeLine("\nModule {"); + HelperFunctions.writeModuleProperties(project, product, output, f); + HelperFunctions.writeTargetArtifactGroups(product, output, f); + HelperFunctions.writeChildItems(product, f); + if (product.Exporter.qbs.additionalContent) + f.writeLine(product.Exporter.qbs.additionalContent); + f.writeLine("}"); + f.close(); + }; + return [cmd]; + } + } +} diff --git a/share/qbs/modules/Sanitizers/address/asan.qbs b/share/qbs/modules/Sanitizers/address/asan.qbs new file mode 100644 index 00000000..39605ef4 --- /dev/null +++ b/share/qbs/modules/Sanitizers/address/asan.qbs @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Utilities + +Module { + Depends { name: "cpp" } + + property bool enabled: true + readonly property bool _supported: qbs.toolchain.contains("gcc") + || qbs.toolchain.contains("clang-cl") + || (qbs.toolchain.contains("msvc") + && Utilities.versionCompare(cpp.compilerVersion, "19.28.29500.0") >= 0) + readonly property bool _enabled: enabled && _supported + + property string detectUseAfterReturn: "always" + PropertyOptions { + name: "detectUseAfterReturn" + description: "Whether to detect problems with stack use after return from a function" + allowedValues: ["never", "runtime", "always"] + } + + property bool detectUseAfterScope: true + + cpp.driverFlags: { + var flags = []; + if (!_enabled) + return flags; + if (qbs.toolchain.contains("msvc") && !qbs.toolchain.contains("clang-cl")) { + flags.push("/fsanitize=address"); + if (detectUseAfterReturn !== "never") + flags.push("/fsanitize-address-use-after-return"); + return flags; + } + flags.push("-fsanitize=address", "-fno-omit-frame-pointer"); + if (detectUseAfterScope) + flags.push("-fsanitize-address-use-after-scope"); + if (detectUseAfterReturn) { + if (qbs.toolchain.contains("llvm")) { + if (Utilities.versionCompare(cpp.compilerVersion, "13") >= 0) + flags.push("-fsanitize-address-use-after-return=" + detectUseAfterReturn); + } else if (detectUseAfterReturn === "never") { + flags.push("--param", "asan-use-after-return=0"); + } + } + return flags; + } +} diff --git a/share/qbs/modules/archiver/archiver.qbs b/share/qbs/modules/archiver/archiver.qbs new file mode 100644 index 00000000..6da3f43f --- /dev/null +++ b/share/qbs/modules/archiver/archiver.qbs @@ -0,0 +1,241 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.Host +import qbs.FileInfo +import qbs.Probes + +Module { + // jar is a suitable fallback for creating zip files as they are the same format + // This will most likely end up being used on Windows + Depends { name: "java"; required: false } + + Probes.BinaryProbe { + id: tarProbe + names: ["tar"] + } + + Probes.BinaryProbe { + id: zipProbe + names: ["zip"] + } + + Probes.BinaryProbe { + id: sevenZipProbe + names: ["7z"] + platformSearchPaths: { + var paths = base; + if (Host.os().contains("windows")) { + var env32 = Environment.getEnv("PROGRAMFILES(X86)"); + var env64 = Environment.getEnv("PROGRAMFILES"); + if (env64 === env32 && env64.endsWith(" (x86)")) + env64 = env64.slice(0, -(" (x86)".length)); // QTBUG-3845 + paths.push(FileInfo.joinPaths(env64, "7-Zip")); + paths.push(FileInfo.joinPaths(env32, "7-Zip")); + } + return paths; + } + } + + property string type + property string archiveBaseName: product.targetName + property string workingDirectory + property stringList flags: [] + property path outputDirectory: product.destinationDirectory + property string archiveExtension: { + if (type === "7zip") + return "7z"; + if (type == "tar") { + var extension = "tar"; + if (compressionType !== "none") + extension += "." + compressionType; + return extension; + } + if (type === "zip") + return "zip"; + return undefined; + } + property string command: { + if (type === "7zip") + return sevenZipProbe.filePath; + if (type === "tar") { + if (tarProbe.found) + return tarProbe.filePath; + if (sevenZipProbe.found) + return sevenZipProbe.filePath; + } + if (type === "zip") { + // Prefer zip (probably Info-Zip) and fall back to 7z or jar when it's not available + // (as is the likely case on Windows) + if (zipProbe.found) + return zipProbe.filePath; + if (sevenZipProbe.found) + return sevenZipProbe.filePath; + if (java.present) + return java.jarFilePath; + } + return undefined; + } + + property string compressionLevel + property string compressionType: { + if (type === "tar") + return "gz"; + return undefined; + } + + PropertyOptions { + name: "type" + description: "The type of archive to create." + allowedValues: ["7zip", "tar", "zip"] + } + + PropertyOptions { + name: "compressionLevel" + description: "How much effort to put into compression.\n" + + "Higher numbers mean smaller archive files at the cost of taking more time.\n" + + "This property is only used for the '7zip' and 'zip' types.\n" + + "'7zip' only supports 0 and odd numbers." + allowedValues: [undefined, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] + } + + PropertyOptions { + name: "compressionType" + description: "The compression format to use.\n" + + "For tar archives, the respective tool needs to be present.\n" + + "This property is only used for the 'tar' and 'zip' types." + allowedValues: ["none", "gz", "bz2", "Z", "xz", "deflate", "store"] + } + + Rule { + inputs: ["archiver.input-list"] + + Artifact { + filePath: FileInfo.joinPaths(product.moduleProperty("archiver", "outputDirectory"), + product.moduleProperty("archiver", "archiveBaseName") + '.' + + product.moduleProperty("archiver", "archiveExtension")); + fileTags: ["archiver.archive"] + } + + prepare: { + var binary = product.moduleProperty("archiver", "command"); + var binaryName = FileInfo.baseName(binary); + var args = []; + var commands = []; + var type = product.moduleProperty("archiver", "type"); + var compression = product.moduleProperty("archiver", "compressionType"); + var compressionLevel = product.moduleProperty("archiver", "compressionLevel"); + if (binaryName === "7z") { + var rmCommand = new JavaScriptCommand(); + rmCommand.silent = true; + rmCommand.sourceCode = function() { + if (File.exists(output.filePath)) + File.remove(output.filePath); + }; + commands.push(rmCommand); + args.push("a", "-y", "-mmt=on"); + switch (type) { + case "7zip": + args.push("-t7z"); + break; + case "zip": + args.push("-tzip"); + break; + case "tar": + if (compression === "gz") + args.push("-tgzip"); + else if (compression === "bz2") + args.push("-tbzip2"); + else + args.push("-ttar"); + break; + default: + throw "7zip: unrecognized archive type: '" + type + "'"; + } + + if (compressionLevel) + args.push("-mx" + compressionLevel); + args = args.concat(product.moduleProperty("archiver", "flags")); + args.push(output.filePath); + args.push("@" + input.filePath); + } else if (binaryName === "tar" && type === "tar") { + args.push("-c"); + if (compression === "gz") + args.push("-z"); + else if (compression === "bz2") + args.push("-j"); + else if (compression === "Z") + args.push("-Z"); + else if (compression === "xz") + args.push("-J"); + args.push("-f", output.filePath, "-T", input.filePath); + args = args.concat(product.moduleProperty("archiver", "flags")); + } else if (binaryName === "jar" && type === "zip") { + if (compression === "none" || compressionLevel === "0") + args.push("-0"); + + args.push("-cfM", output.filePath, "@" + input.filePath); + args = args.concat(product.moduleProperty("archiver", "flags")); + } else if (binaryName === "zip" && type === "zip") { + // The "zip" program included with most Linux and Unix distributions + // (including macOS) is Info-ZIP's Zip, so this should be fairly portable. + if (compression === "none") { + args.push("-0"); + } else { + compression = compression === "bz2" ? "bzip2" : compression; + if (["store", "deflate", "bzip2"].contains(compression)) + args.push("-Z", compression); + + if (compressionLevel) + args.push("-" + compressionLevel); + } + + args.push("-r", output.filePath, ".", "-i@" + input.filePath); + args = args.concat(product.moduleProperty("archiver", "flags")); + } else if (["tar", "zip", "jar"].contains(binaryName)) { + throw binaryName + ": unrecognized archive type: '" + type + "'"; + } else if (binaryName) { + throw "unrecognized archive tool: '" + binaryName + "'"; + } else { + throw "no archive tool available to produce archive type: '" + type + "'"; + } + + var archiverCommand = new Command(binary, args); + archiverCommand.description = "creating archive file " + output.fileName; + archiverCommand.highlight = "linker"; + archiverCommand.workingDirectory + = product.moduleProperty("archiver", "workingDirectory"); + commands.push(archiverCommand); + return commands; + } + } +} diff --git a/share/qbs/modules/autotest/autotest.qbs b/share/qbs/modules/autotest/autotest.qbs new file mode 100644 index 00000000..c8a1c518 --- /dev/null +++ b/share/qbs/modules/autotest/autotest.qbs @@ -0,0 +1,6 @@ +Module { + property stringList arguments + property bool allowFailure: false + property string workingDir + property int timeout +} diff --git a/share/qbs/modules/bundle/BundleModule.qbs b/share/qbs/modules/bundle/BundleModule.qbs new file mode 100644 index 00000000..6526fa31 --- /dev/null +++ b/share/qbs/modules/bundle/BundleModule.qbs @@ -0,0 +1,789 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.BundleTools +import qbs.DarwinTools +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.PropertyList +import qbs.TextFile +import qbs.Utilities +import "bundle.js" as Bundle +import "../codesign/codesign.js" as Codesign + +Module { + Depends { name: "xcode"; required: false; } + Depends { name: "codesign"; required: false; } + + Probe { + id: bundleSettingsProbe + condition: qbs.targetOS.contains("darwin") + + property string xcodeDeveloperPath: xcode.developerPath + property var xcodeArchSettings: xcode._architectureSettings + property string productTypeIdentifier: _productTypeIdentifier + property bool useXcodeBuildSpecs: _useXcodeBuildSpecs + property bool isMacOs: qbs.targetOS.contains("macos") + property bool xcodePresent: xcode.present + property string xcodeVersion: xcode.version + + // Note that we include several settings pointing to properties which reference the output + // of this probe (WRAPPER_NAME, WRAPPER_EXTENSION, etc.). This is to ensure that derived + // properties take into account the value of these settings if the user customized them. + property var additionalSettings: ({ + "DEVELOPMENT_LANGUAGE": "English", + "EXECUTABLE_VARIANT_SUFFIX": "", // e.g. _debug, _profile + "FRAMEWORK_VERSION": frameworkVersion, + "GENERATE_PKGINFO_FILE": generatePackageInfo !== undefined + ? (generatePackageInfo ? "YES" : "NO") + : undefined, + "IS_MACCATALYST": "NO", + "LD_RUNPATH_SEARCH_PATHS_NO": [], + "PRODUCT_NAME": product.targetName, + "LOCAL_APPS_DIR": Environment.getEnv("HOME") + "/Applications", + "LOCAL_LIBRARY_DIR": Environment.getEnv("HOME") + "/Library", + // actually, this is cpp.targetAbi, but XCode does not set it for non-simulator builds + // while Qbs set it to "macho". + "LLVM_TARGET_TRIPLE_SUFFIX": qbs.targetOS.contains("simulator") ? "-simulator" : "", + "SWIFT_PLATFORM_TARGET_PREFIX": isMacOs ? "macos" + : qbs.targetOS.contains("ios") ? "ios" : "", + "TARGET_BUILD_DIR": product.buildDirectory, + "WRAPPER_NAME": bundleName, + "WRAPPER_EXTENSION": extension + }) + + // Outputs + property var xcodeSettings: ({}) + property var productTypeIdentifierChain: [] + + configure: { + var specsPaths = [path]; + var specsSeparator = "-"; + if (xcodeDeveloperPath && useXcodeBuildSpecs) { + specsPaths = Bundle.macOSSpecsPaths(xcodeVersion, xcodeDeveloperPath); + specsSeparator = " "; + } + + var reader = new Bundle.XcodeBuildSpecsReader(specsPaths, + specsSeparator, + additionalSettings, + !isMacOs); + var settings = reader.expandedSettings(productTypeIdentifier, + xcodePresent + ? xcodeArchSettings + : {}); + var chain = reader.productTypeIdentifierChain(productTypeIdentifier); + if (settings && chain) { + xcodeSettings = settings; + productTypeIdentifierChain = chain; + found = true; + } else { + xcodeSettings = {}; + productTypeIdentifierChain = []; + found = false; + } + } + } + + additionalProductTypes: !(product.multiplexed || product.aggregate) + || !product.multiplexConfigurationId ? ["bundle.content"] : [] + + property bool isBundle: !product.consoleApplication && qbs.targetOS.contains("darwin") + + readonly property bool isShallow: bundleSettingsProbe.xcodeSettings["SHALLOW_BUNDLE"] === "YES" + + property string identifierPrefix: "org.example" + property string identifier: [identifierPrefix, Utilities.rfc1034Identifier(product.targetName)].join(".") + + property string extension: bundleSettingsProbe.xcodeSettings["WRAPPER_EXTENSION"] + + property string packageType: Bundle.packageType(_productTypeIdentifier) + + property string signature: "????" // legacy creator code in Mac OS Classic (CFBundleSignature), can be ignored + + property string bundleName: bundleSettingsProbe.xcodeSettings["WRAPPER_NAME"] + + property string frameworkVersion: { + var n = parseInt(product.version, 10); + return isNaN(n) ? bundleSettingsProbe.xcodeSettings["FRAMEWORK_VERSION"] : String(n); + } + + property bool generatePackageInfo: { + // Make sure to return undefined as default to indicate "not set" + var genPkgInfo = bundleSettingsProbe.xcodeSettings["GENERATE_PKGINFO_FILE"]; + if (genPkgInfo) + return genPkgInfo === "YES"; + } + + property pathList publicHeaders + property pathList privateHeaders + property pathList resources + + property var infoPlist + property bool processInfoPlist: true + property bool embedInfoPlist: product.consoleApplication && !isBundle + property string infoPlistFormat: qbs.targetOS.contains("macos") ? "same-as-input" : "binary1" + + property string localizedResourcesFolderSuffix: ".lproj" + + property string lsregisterName: "lsregister" + property string lsregisterPath: FileInfo.joinPaths( + "/System/Library/Frameworks/CoreServices.framework" + + "/Versions/A/Frameworks/LaunchServices.framework" + + "/Versions/A/Support", lsregisterName); + + // all paths are relative to the directory containing the bundle + readonly property string infoPlistPath: bundleSettingsProbe.xcodeSettings["INFOPLIST_PATH"] + readonly property string infoStringsPath: bundleSettingsProbe.xcodeSettings["INFOSTRINGS_PATH"] + readonly property string pbdevelopmentPlistPath: bundleSettingsProbe.xcodeSettings["PBDEVELOPMENTPLIST_PATH"] + readonly property string pkgInfoPath: bundleSettingsProbe.xcodeSettings["PKGINFO_PATH"] + readonly property string versionPlistPath: bundleSettingsProbe.xcodeSettings["VERSIONPLIST_PATH"] + + readonly property string executablePath: bundleSettingsProbe.xcodeSettings["EXECUTABLE_PATH"] + + readonly property string contentsFolderPath: bundleSettingsProbe.xcodeSettings["CONTENTS_FOLDER_PATH"] + readonly property string documentationFolderPath: bundleSettingsProbe.xcodeSettings["DOCUMENTATION_FOLDER_PATH"] + readonly property string executableFolderPath: bundleSettingsProbe.xcodeSettings["EXECUTABLE_FOLDER_PATH"] + readonly property string executablesFolderPath: bundleSettingsProbe.xcodeSettings["EXECUTABLES_FOLDER_PATH"] + readonly property string frameworksFolderPath: bundleSettingsProbe.xcodeSettings["FRAMEWORKS_FOLDER_PATH"] + readonly property string javaFolderPath: bundleSettingsProbe.xcodeSettings["JAVA_FOLDER_PATH"] + readonly property string localizedResourcesFolderPath: bundleSettingsProbe.xcodeSettings["LOCALIZED_RESOURCES_FOLDER_PATH"] + readonly property string pluginsFolderPath: bundleSettingsProbe.xcodeSettings["PLUGINS_FOLDER_PATH"] + readonly property string privateHeadersFolderPath: bundleSettingsProbe.xcodeSettings["PRIVATE_HEADERS_FOLDER_PATH"] + readonly property string publicHeadersFolderPath: bundleSettingsProbe.xcodeSettings["PUBLIC_HEADERS_FOLDER_PATH"] + readonly property string scriptsFolderPath: bundleSettingsProbe.xcodeSettings["SCRIPTS_FOLDER_PATH"] + readonly property string sharedFrameworksFolderPath: bundleSettingsProbe.xcodeSettings["SHARED_FRAMEWORKS_FOLDER_PATH"] + readonly property string sharedSupportFolderPath: bundleSettingsProbe.xcodeSettings["SHARED_SUPPORT_FOLDER_PATH"] + readonly property string unlocalizedResourcesFolderPath: bundleSettingsProbe.xcodeSettings["UNLOCALIZED_RESOURCES_FOLDER_PATH"] + readonly property string versionsFolderPath: bundleSettingsProbe.xcodeSettings["VERSIONS_FOLDER_PATH"] + + // private properties + property string _productTypeIdentifier: Bundle.productTypeIdentifier(product.type) + property stringList _productTypeIdentifierChain: bundleSettingsProbe.productTypeIdentifierChain + + property bool _useXcodeBuildSpecs: true // false to use ONLY the qbs build specs + + property var extraEnv: ({ + "PRODUCT_BUNDLE_IDENTIFIER": identifier + }) + + readonly property var qmakeEnv: { + return { + "BUNDLEIDENTIFIER": identifier, + "EXECUTABLE": product.targetName, + "FULL_VERSION": product.version || "1.0", // CFBundleVersion + "ICON": product.targetName, // ### QBS-73 + "LIBRARY": product.targetName, + "SHORT_VERSION": product.version || "1.0", // CFBundleShortVersionString + "TYPEINFO": signature // CFBundleSignature + }; + } + + readonly property var defaultInfoPlist: { + return { + CFBundleDevelopmentRegion: "en", // default localization + CFBundleDisplayName: product.targetName, // localizable + CFBundleExecutable: product.targetName, + CFBundleIdentifier: identifier, + CFBundleInfoDictionaryVersion: "6.0", + CFBundleName: product.targetName, // short display name of the bundle, localizable + CFBundlePackageType: packageType, + CFBundleShortVersionString: product.version || "1.0", // "release" version number, localizable + CFBundleSignature: signature, // legacy creator code in Mac OS Classic, can be ignored + CFBundleVersion: product.version || "1.0.0" // build version number, must be 3 octets + }; + } + + validate: { + if (!qbs.targetOS.contains("darwin")) + return; + if (!bundleSettingsProbe.found) { + var error = "Bundle product type " + _productTypeIdentifier + " is not supported."; + if ((_productTypeIdentifier || "").startsWith("com.apple.product-type.")) + error += " You may need to upgrade Xcode."; + throw error; + } + + var validator = new ModUtils.PropertyValidator("bundle"); + validator.setRequiredProperty("bundleName", bundleName); + validator.setRequiredProperty("infoPlistPath", infoPlistPath); + validator.setRequiredProperty("pbdevelopmentPlistPath", pbdevelopmentPlistPath); + validator.setRequiredProperty("pkgInfoPath", pkgInfoPath); + validator.setRequiredProperty("versionPlistPath", versionPlistPath); + validator.setRequiredProperty("executablePath", executablePath); + validator.setRequiredProperty("contentsFolderPath", contentsFolderPath); + validator.setRequiredProperty("documentationFolderPath", documentationFolderPath); + validator.setRequiredProperty("executableFolderPath", executableFolderPath); + validator.setRequiredProperty("executablesFolderPath", executablesFolderPath); + validator.setRequiredProperty("frameworksFolderPath", frameworksFolderPath); + validator.setRequiredProperty("javaFolderPath", javaFolderPath); + validator.setRequiredProperty("localizedResourcesFolderPath", localizedResourcesFolderPath); + validator.setRequiredProperty("pluginsFolderPath", pluginsFolderPath); + validator.setRequiredProperty("privateHeadersFolderPath", privateHeadersFolderPath); + validator.setRequiredProperty("publicHeadersFolderPath", publicHeadersFolderPath); + validator.setRequiredProperty("scriptsFolderPath", scriptsFolderPath); + validator.setRequiredProperty("sharedFrameworksFolderPath", sharedFrameworksFolderPath); + validator.setRequiredProperty("sharedSupportFolderPath", sharedSupportFolderPath); + validator.setRequiredProperty("unlocalizedResourcesFolderPath", unlocalizedResourcesFolderPath); + + if (packageType === "FMWK") { + validator.setRequiredProperty("frameworkVersion", frameworkVersion); + validator.setRequiredProperty("versionsFolderPath", versionsFolderPath); + } + + // extension and infoStringsPath might not be set + return validator.validate(); + } + + FileTagger { + fileTags: ["infoplist"] + patterns: ["Info.plist", "*-Info.plist"] + } + + Rule { + condition: qbs.targetOS.contains("darwin") + multiplex: true + requiresInputs: false // TODO: The resources property should probably be a tag instead. + inputs: ["infoplist", "partial_infoplist"] + + outputFileTags: ["bundle.input", "aggregate_infoplist"] + outputArtifacts: { + var artifacts = []; + var embed = ModUtils.moduleProperty(product, "embedInfoPlist"); + if (ModUtils.moduleProperty(product, "isBundle") || embed) { + artifacts.push({ + filePath: FileInfo.joinPaths( + product.destinationDirectory, product.name + "-Info.plist"), + fileTags: ["aggregate_infoplist"].concat(!embed ? ["bundle.input"] : []), + bundle: { + _bundleFilePath: FileInfo.joinPaths( + product.destinationDirectory, + ModUtils.moduleProperty(product, "infoPlistPath")), + } + }); + } + return artifacts; + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating Info.plist for " + product.name; + cmd.highlight = "codegen"; + cmd.infoPlist = ModUtils.moduleProperty(product, "infoPlist") || {}; + cmd.processInfoPlist = ModUtils.moduleProperty(product, "processInfoPlist"); + cmd.infoPlistFormat = ModUtils.moduleProperty(product, "infoPlistFormat"); + cmd.extraEnv = ModUtils.moduleProperty(product, "extraEnv"); + cmd.qmakeEnv = ModUtils.moduleProperty(product, "qmakeEnv"); + + cmd.buildEnv = product.moduleProperty("cpp", "buildEnv"); + + cmd.developerPath = product.moduleProperty("xcode", "developerPath"); + cmd.platformInfoPlist = product.moduleProperty("xcode", "platformInfoPlist"); + cmd.sdkSettingsPlist = product.moduleProperty("xcode", "sdkSettingsPlist"); + cmd.toolchainInfoPlist = product.moduleProperty("xcode", "toolchainInfoPlist"); + + cmd.osBuildVersion = product.moduleProperty("qbs", "hostOSBuildVersion"); + + cmd.sourceCode = function() { + var plist, process, key, i; + + // Contains the combination of default, file, and in-source keys and values + // Start out with the contents of this file as the "base", if given + var aggregatePlist = {}; + + for (i = 0; i < (inputs.infoplist || []).length; ++i) { + aggregatePlist = + BundleTools.infoPlistContents(inputs.infoplist[i].filePath); + infoPlistFormat = (infoPlistFormat === "same-as-input") + ? BundleTools.infoPlistFormat(inputs.infoplist[i].filePath) + : "xml1"; + break; + } + + // Add local key-value pairs (overrides equivalent keys specified in the file if + // one was given) + for (key in infoPlist) { + if (infoPlist.hasOwnProperty(key)) + aggregatePlist[key] = infoPlist[key]; + } + + // Do some postprocessing if desired + if (processInfoPlist) { + // Add default values to the aggregate plist if the corresponding keys + // for those values are not already present + var defaultValues = ModUtils.moduleProperty(product, "defaultInfoPlist"); + for (key in defaultValues) { + if (defaultValues.hasOwnProperty(key) && !(key in aggregatePlist)) + aggregatePlist[key] = defaultValues[key]; + } + + // Add keys from platform's Info.plist if not already present + var platformInfo = {}; + var sdkSettings = {}; + var toolchainInfo = {}; + if (developerPath) { + plist = new PropertyList(); + try { + plist.readFromFile(platformInfoPlist); + platformInfo = plist.toObject(); + } finally { + plist.clear(); + } + + var additionalProps = platformInfo["AdditionalInfo"]; + for (key in additionalProps) { + // override infoPlist? + if (additionalProps.hasOwnProperty(key) && !(key in aggregatePlist)) + aggregatePlist[key] = defaultValues[key]; + } + props = platformInfo['OverrideProperties']; + for (key in props) { + aggregatePlist[key] = props[key]; + } + + plist = new PropertyList(); + try { + plist.readFromFile(sdkSettingsPlist); + sdkSettings = plist.toObject(); + } finally { + plist.clear(); + } + + plist = new PropertyList(); + try { + plist.readFromFile(toolchainInfoPlist); + toolchainInfo = plist.toObject(); + } finally { + plist.clear(); + } + } + + aggregatePlist["BuildMachineOSBuild"] = osBuildVersion; + + // setup env + env = { + "SDK_NAME": sdkSettings["CanonicalName"], + "XCODE_VERSION_ACTUAL": toolchainInfo["DTXcode"], + "SDK_PRODUCT_BUILD_VERSION": toolchainInfo["DTPlatformBuild"], + "GCC_VERSION": platformInfo["DTCompiler"], + "XCODE_PRODUCT_BUILD_VERSION": platformInfo["DTPlatformBuild"], + "PLATFORM_PRODUCT_BUILD_VERSION": platformInfo["ProductBuildVersion"], + } + env["MAC_OS_X_PRODUCT_BUILD_VERSION"] = osBuildVersion; + + for (key in extraEnv) + env[key] = extraEnv[key]; + + for (key in buildEnv) + env[key] = buildEnv[key]; + + for (key in qmakeEnv) + env[key] = qmakeEnv[key]; + + var expander = new DarwinTools.PropertyListVariableExpander(); + expander.undefinedVariableFunction = function (key, varName) { + var msg = "Info.plist variable expansion encountered undefined variable '" + + varName + "' when expanding value for key '" + key + + "', defined in one of the following files:\n\t"; + var allFilePaths = []; + + for (i = 0; i < (inputs.infoplist || []).length; ++i) + allFilePaths.push(inputs.infoplist[i].filePath); + + if (platformInfoPlist) + allFilePaths.push(platformInfoPlist); + msg += allFilePaths.join("\n\t") + "\n"; + msg += "or in the bundle.infoPlist property of product '" + + product.name + "'"; + console.warn(msg); + }; + aggregatePlist = expander.expand(aggregatePlist, env); + + // Add keys from partial Info.plists from asset catalogs, XIBs, and storyboards. + for (var j = 0; j < (inputs.partial_infoplist || []).length; ++j) { + var partialInfoPlist = + BundleTools.infoPlistContents( + inputs.partial_infoplist[j].filePath) + || {}; + for (key in partialInfoPlist) { + if (partialInfoPlist.hasOwnProperty(key) + && aggregatePlist[key] === undefined) + aggregatePlist[key] = partialInfoPlist[key]; + } + } + + } + + // Anything with an undefined or otherwise empty value should be removed + // Only JSON-formatted plists can have null values, other formats error out + // This also follows Xcode behavior + DarwinTools.cleanPropertyList(aggregatePlist); + + if (infoPlistFormat === "same-as-input") + infoPlistFormat = "xml1"; + + var validFormats = [ "xml1", "binary1", "json" ]; + if (!validFormats.contains(infoPlistFormat)) + throw("Invalid Info.plist format " + infoPlistFormat + ". " + + "Must be in [xml1, binary1, json]."); + + // Write the plist contents in the format appropriate for the current platform + plist = new PropertyList(); + try { + plist.readFromObject(aggregatePlist); + plist.writeToFile(outputs.aggregate_infoplist[0].filePath, infoPlistFormat); + } finally { + plist.clear(); + } + } + return cmd; + } + } + + Rule { + condition: qbs.targetOS.contains("darwin") + multiplex: true + inputs: ["aggregate_infoplist"] + + outputFileTags: ["bundle.input", "pkginfo"] + outputArtifacts: { + var artifacts = []; + if (ModUtils.moduleProperty(product, "isBundle") && ModUtils.moduleProperty(product, "generatePackageInfo")) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, "PkgInfo"), + fileTags: ["bundle.input", "pkginfo"], + bundle: { _bundleFilePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "pkgInfoPath")) } + }); + } + return artifacts; + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating PkgInfo for " + product.name; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var infoPlist = BundleTools.infoPlistContents(inputs.aggregate_infoplist[0].filePath); + + var pkgType = infoPlist['CFBundlePackageType']; + if (!pkgType) + throw("CFBundlePackageType not found in Info.plist; this should not happen"); + + var pkgSign = infoPlist['CFBundleSignature']; + if (!pkgSign) + throw("CFBundleSignature not found in Info.plist; this should not happen"); + + var pkginfo = new TextFile(outputs.pkginfo[0].filePath, TextFile.WriteOnly); + pkginfo.write(pkgType + pkgSign); + pkginfo.close(); + } + return cmd; + } + } + + Rule { + condition: qbs.targetOS.contains("darwin") + multiplex: true + inputs: ["bundle.input", + "aggregate_infoplist", "pkginfo", "hpp", + "icns", "codesign.xcent", + "compiled_ibdoc", "compiled_assetcatalog", + "codesign.embedded_provisioningprofile"] + + // Make sure the inputs of this rule are only those rules which produce outputs compatible + // with the type of the bundle being produced. + excludedInputs: Bundle.excludedAuxiliaryInputs(project, product) + + outputFileTags: [ + "bundle.content", + "bundle.symlink.headers", "bundle.symlink.private-headers", + "bundle.symlink.resources", "bundle.symlink.executable", + "bundle.symlink.version", "bundle.hpp", "bundle.resource", + "bundle.provisioningprofile", "bundle.content.copied", "bundle.application-executable", + "bundle.code-signature"] + outputArtifacts: { + var i, artifacts = []; + if (ModUtils.moduleProperty(product, "isBundle")) { + for (i in inputs["bundle.input"]) { + var fp = inputs["bundle.input"][i].moduleProperty("bundle", "_bundleFilePath"); + if (!fp) + throw("Artifact " + inputs["bundle.input"][i].filePath + " has no associated bundle file path"); + var extraTags = inputs["bundle.input"][i].fileTags.contains("application") + ? ["bundle.application-executable"] : []; + artifacts.push({ + filePath: fp, + fileTags: ["bundle.content", "bundle.content.copied"].concat(extraTags) + }); + } + + var provprofiles = inputs["codesign.embedded_provisioningprofile"]; + for (i in provprofiles) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + ModUtils.moduleProperty(product, + "contentsFolderPath"), + provprofiles[i].fileName), + fileTags: ["bundle.provisioningprofile", "bundle.content"] + }); + } + + var packageType = ModUtils.moduleProperty(product, "packageType"); + var isShallow = ModUtils.moduleProperty(product, "isShallow"); + if (packageType === "FMWK" && !isShallow) { + var publicHeaders = ModUtils.moduleProperty(product, "publicHeaders"); + if (publicHeaders && publicHeaders.length) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "bundleName"), "Headers"), + fileTags: ["bundle.symlink.headers", "bundle.content"] + }); + } + + var privateHeaders = ModUtils.moduleProperty(product, "privateHeaders"); + if (privateHeaders && privateHeaders.length) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "bundleName"), "PrivateHeaders"), + fileTags: ["bundle.symlink.private-headers", "bundle.content"] + }); + } + + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "bundleName"), "Resources"), + fileTags: ["bundle.symlink.resources", "bundle.content"] + }); + + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "bundleName"), product.targetName), + fileTags: ["bundle.symlink.executable", "bundle.content"] + }); + + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "versionsFolderPath"), "Current"), + fileTags: ["bundle.symlink.version", "bundle.content"] + }); + } + + var headerTypes = ["public", "private"]; + for (var h in headerTypes) { + var sources = ModUtils.moduleProperty(product, headerTypes[h] + "Headers"); + var destination = FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, headerTypes[h] + "HeadersFolderPath")); + for (i in sources) { + artifacts.push({ + filePath: FileInfo.joinPaths(destination, FileInfo.fileName(sources[i])), + fileTags: ["bundle.hpp", "bundle.content"] + }); + } + } + + sources = ModUtils.moduleProperty(product, "resources"); + for (i in sources) { + destination = BundleTools.destinationDirectoryForResource(product, {baseDir: FileInfo.path(sources[i]), fileName: FileInfo.fileName(sources[i])}); + artifacts.push({ + filePath: FileInfo.joinPaths(destination, FileInfo.fileName(sources[i])), + fileTags: ["bundle.resource", "bundle.content"] + }); + } + + var wrapperPath = FileInfo.joinPaths( + product.destinationDirectory, + ModUtils.moduleProperty(product, "bundleName")); + for (var i = 0; i < artifacts.length; ++i) + artifacts[i].bundle = { wrapperPath: wrapperPath }; + + if (Host.os().contains("darwin") && product.codesign + && product.codesign.enableCodeSigning) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.bundle.contentsFolderPath, "_CodeSignature/CodeResources"), + fileTags: ["bundle.code-signature", "bundle.content"] + }); + } + } + return artifacts; + } + + prepare: { + var i, cmd, commands = []; + var packageType = ModUtils.moduleProperty(product, "packageType"); + + var bundleType = "bundle"; + if (packageType === "APPL") + bundleType = "application"; + if (packageType === "FMWK") + bundleType = "framework"; + + // Product is unbundled + if (!product.bundle.isBundle) { + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function () { }; + commands.push(cmd); + } + + var symlinks = outputs["bundle.symlink.version"]; + for (i in symlinks) { + cmd = new Command("ln", ["-sfn", ModUtils.moduleProperty(product, "frameworkVersion"), + symlinks[i].filePath]); + cmd.silent = true; + commands.push(cmd); + } + + var publicHeaders = outputs["bundle.symlink.headers"]; + for (i in publicHeaders) { + cmd = new Command("ln", ["-sfn", "Versions/Current/Headers", + publicHeaders[i].filePath]); + cmd.silent = true; + commands.push(cmd); + } + + var privateHeaders = outputs["bundle.symlink.private-headers"]; + for (i in privateHeaders) { + cmd = new Command("ln", ["-sfn", "Versions/Current/PrivateHeaders", + privateHeaders[i].filePath]); + cmd.silent = true; + commands.push(cmd); + } + + var resources = outputs["bundle.symlink.resources"]; + for (i in resources) { + cmd = new Command("ln", ["-sfn", "Versions/Current/Resources", + resources[i].filePath]); + cmd.silent = true; + commands.push(cmd); + } + + var executables = outputs["bundle.symlink.executable"]; + for (i in executables) { + cmd = new Command("ln", ["-sfn", FileInfo.joinPaths("Versions", "Current", product.targetName), + executables[i].filePath]); + cmd.silent = true; + commands.push(cmd); + } + + function sortedArtifactList(list, func) { + if (list) { + return list.sort(func || (function (a, b) { + return a.filePath.localeCompare(b.filePath); + })); + } + } + + var bundleInputs = sortedArtifactList(inputs["bundle.input"], function (a, b) { + return a.moduleProperty("bundle", "_bundleFilePath").localeCompare( + b.moduleProperty("bundle", "_bundleFilePath")); + }); + var bundleContents = sortedArtifactList(outputs["bundle.content.copied"]); + for (i in bundleContents) { + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.source = bundleInputs[i].filePath; + cmd.destination = bundleContents[i].filePath; + cmd.sourceCode = function() { + File.copy(source, destination); + }; + commands.push(cmd); + } + + cmd = new JavaScriptCommand(); + cmd.description = "copying provisioning profile"; + cmd.highlight = "filegen"; + cmd.sources = (inputs["codesign.embedded_provisioningprofile"] || []) + .map(function(artifact) { return artifact.filePath; }); + cmd.destination = (outputs["bundle.provisioningprofile"] || []) + .map(function(artifact) { return artifact.filePath; }); + cmd.sourceCode = function() { + var i; + for (var i in sources) { + File.copy(sources[i], destination[i]); + } + }; + if (cmd.sources && cmd.sources.length) + commands.push(cmd); + + cmd = new JavaScriptCommand(); + cmd.description = "copying public headers"; + cmd.highlight = "filegen"; + cmd.sources = ModUtils.moduleProperty(product, "publicHeaders"); + cmd.destination = FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "publicHeadersFolderPath")); + cmd.sourceCode = function() { + var i; + for (var i in sources) { + File.copy(sources[i], FileInfo.joinPaths(destination, FileInfo.fileName(sources[i]))); + } + }; + if (cmd.sources && cmd.sources.length) + commands.push(cmd); + + cmd = new JavaScriptCommand(); + cmd.description = "copying private headers"; + cmd.highlight = "filegen"; + cmd.sources = ModUtils.moduleProperty(product, "privateHeaders"); + cmd.destination = FileInfo.joinPaths(product.destinationDirectory, ModUtils.moduleProperty(product, "privateHeadersFolderPath")); + cmd.sourceCode = function() { + var i; + for (var i in sources) { + File.copy(sources[i], FileInfo.joinPaths(destination, FileInfo.fileName(sources[i]))); + } + }; + if (cmd.sources && cmd.sources.length) + commands.push(cmd); + + cmd = new JavaScriptCommand(); + cmd.description = "copying resources"; + cmd.highlight = "filegen"; + cmd.sources = ModUtils.moduleProperty(product, "resources"); + cmd.sourceCode = function() { + var i; + for (var i in sources) { + var destination = BundleTools.destinationDirectoryForResource(product, {baseDir: FileInfo.path(sources[i]), fileName: FileInfo.fileName(sources[i])}); + File.copy(sources[i], FileInfo.joinPaths(destination, FileInfo.fileName(sources[i]))); + } + }; + if (cmd.sources && cmd.sources.length) + commands.push(cmd); + + if (product.moduleProperty("qbs", "hostOS").contains("darwin")) { + Array.prototype.push.apply(commands, Codesign.prepareSign( + project, product, inputs, outputs, input, output)); + + if (bundleType === "application" + && product.moduleProperty("qbs", "targetOS").contains("macos")) { + cmd = new Command(ModUtils.moduleProperty(product, "lsregisterPath"), + ["-f", product.bundle.bundleName]); + cmd.description = "registering " + ModUtils.moduleProperty(product, "bundleName"); + commands.push(cmd); + } + } + + return commands; + } + } +} diff --git a/share/qbs/modules/bundle/MacOSX-Package-Types.xcspec b/share/qbs/modules/bundle/MacOSX-Package-Types.xcspec new file mode 100644 index 00000000..23f09464 --- /dev/null +++ b/share/qbs/modules/bundle/MacOSX-Package-Types.xcspec @@ -0,0 +1,533 @@ +/** + MacOSX Package Types.xcspec + + Copyright (c) 1999-2015 Apple Inc. All rights reserved. + + Package type specifications in the Mac OS X platform. +*/ +( + // Mach-O executable + { Type = PackageType; + Identifier = com.apple.package-type.mach-o-executable; + Name = "Mach-O Executable"; + Description = "Mach-O executable"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + }; + ProductReference = { + FileType = compiled.mach-o.executable; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = YES; + }; + }, + + // Mach-O object file + { Type = PackageType; + Identifier = com.apple.package-type.mach-o-objfile; + Name = "Mach-O Object File"; + Description = "Mach-O Object File"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + }; + ProductReference = { + FileType = compiled.mach-o.objfile; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // Mach-O dynamic library + { Type = PackageType; + Identifier = com.apple.package-type.mach-o-dylib; + Name = "Mach-O Dynamic Library"; + Description = "Mach-O dynamic library"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + }; + ProductReference = { + FileType = compiled.mach-o.dylib; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // Static library ('ar' archive containing .o files) + { Type = PackageType; + Identifier = com.apple.package-type.static-library; + Name = "Mach-O Static Library"; + Description = "Mach-O static library"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = "lib"; + EXECUTABLE_SUFFIX = ".a"; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + }; + ProductReference = { + FileType = archive.ar; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // Mach-O bundle (not related to a CFBundle) + { Type = PackageType; + Identifier = com.apple.package-type.mach-o-bundle; + Name = "Mach-O Loadable"; + Description = "Mach-O loadable"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ".dylib"; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + }; + ProductReference = { + FileType = compiled.mach-o.bundle; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // CFBundle wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper; + Name = "Wrapper"; + Description = "Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "BNDL"; + WRAPPER_PREFIX = ""; + WRAPPER_SUFFIX = ".bundle"; + WRAPPER_NAME = "$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)"; + CONTENTS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))"; + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_FOLDER_PATH = "$(EXECUTABLE_FOLDER_PATH_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))"; + EXECUTABLE_PATH = "$(EXECUTABLE_FOLDER_PATH)/$(EXECUTABLE_NAME)"; + INFOPLIST_PATH = "$(CONTENTS_FOLDER_PATH)/Info.plist"; + INFOSTRINGS_PATH = "$(LOCALIZED_RESOURCES_FOLDER_PATH)/InfoPlist.strings"; + PKGINFO_PATH = "$(CONTENTS_FOLDER_PATH)/PkgInfo"; + PBDEVELOPMENTPLIST_PATH = "$(CONTENTS_FOLDER_PATH)/pbdevelopment.plist"; + VERSIONPLIST_PATH = "$(CONTENTS_FOLDER_PATH)/version.plist"; + PUBLIC_HEADERS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Headers"; + PRIVATE_HEADERS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/PrivateHeaders"; + EXECUTABLES_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Executables"; // Not the same as EXECUTABLE_FOLDER_PATH + FRAMEWORKS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Frameworks"; + SHARED_FRAMEWORKS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/SharedFrameworks"; + SHARED_SUPPORT_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/SharedSupport"; + UNLOCALIZED_RESOURCES_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))"; + LOCALIZED_RESOURCES_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj"; + DOCUMENTATION_FOLDER_PATH = "$(LOCALIZED_RESOURCES_FOLDER_PATH)/Documentation"; + MODULES_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Modules"; + PLUGINS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/PlugIns"; + SCRIPTS_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Scripts"; + JAVA_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Java"; + SYSTEM_EXTENSIONS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)/Library/SystemExtensions"; + + // Settings specific to deep bundles (macOS) + CONTENTS_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(WRAPPER_NAME)/Contents"; + EXECUTABLE_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(CONTENTS_FOLDER_PATH)/MacOS"; + UNLOCALIZED_RESOURCES_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(CONTENTS_FOLDER_PATH)/Resources"; + + // Settings specific to shallow bundles (iOS, DriverKit on any OS) + CONTENTS_FOLDER_PATH_SHALLOW_BUNDLE_YES = "$(WRAPPER_NAME)"; + EXECUTABLE_FOLDER_PATH_SHALLOW_BUNDLE_YES = "$(CONTENTS_FOLDER_PATH)"; + UNLOCALIZED_RESOURCES_FOLDER_PATH_SHALLOW_BUNDLE_YES = "$(CONTENTS_FOLDER_PATH)"; + + // DriverKit should always use shallow bundles + SHALLOW_BUNDLE = "$(SHALLOW_BUNDLE_$(SWIFT_PLATFORM_TARGET_PREFIX))"; + SHALLOW_BUNDLE_ = YES; + SHALLOW_BUNDLE_macos = NO; + SHALLOW_BUNDLE_ios = NO; // for macCatalyst + SHALLOW_BUNDLE_driverkit = YES; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Shallow CFBundle wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.shallow; + BasedOn = com.apple.package-type.wrapper; + Name = "Wrapper (Shallow)"; + Description = "Shallow Wrapper"; + DefaultBuildSettings = { + SHALLOW_BUNDLE = YES; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Application wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.application; + BasedOn = com.apple.package-type.wrapper; + Name = "Application Wrapper"; + Description = "Application Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "APPL"; + GENERATE_PKGINFO_FILE = YES; + }; + ProductReference = { + FileType = wrapper.application; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = YES; + }; + }, + + // Shallow Application wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.application.shallow; + BasedOn = com.apple.package-type.wrapper.shallow; + Name = "Application Wrapper (Shallow)"; + Description = "Shallow Application Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "APPL"; + GENERATE_PKGINFO_FILE = YES; + SHALLOW_BUNDLE = YES; + }; + ProductReference = { + FileType = wrapper.application; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = YES; + }; + }, + + // System extension wrapper + { + Type = PackageType; + Identifier = com.apple.package-type.wrapper.system-extension; + BasedOn = com.apple.package-type.wrapper; + Name = "System Extension Wrapper"; + Description = "System Extension Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "SYSX"; + }; + ProductReference = { + FileType = wrapper.system-extension; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Driver extension wrapper + { + Type = PackageType; + Identifier = com.apple.package-type.wrapper.driver-extension; + BasedOn = com.apple.package-type.wrapper.system-extension; + Name = "Driver Extension Wrapper"; + Description = "Driver Extension Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "DEXT"; + }; + ProductReference = { + FileType = wrapper.driver-extension; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Kernel extension wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.kernel-extension; + BasedOn = com.apple.package-type.wrapper; + Name = "Kernel Extension Wrapper"; + Description = "Kernel Extension Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "KEXT"; + PUBLIC_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/Headers/$(KEXT_FAMILY_NAME)"; + PRIVATE_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/PrivateHeaders/$(KEXT_FAMILY_NAME)"; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Shallow Kernel extension wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.kernel-extension.shallow; + BasedOn = com.apple.package-type.wrapper.shallow; + Name = "Kernel Extension Wrapper (Shallow)"; + Description = "Shallow Kernel Extension Wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "KEXT"; + PUBLIC_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/Headers/$(KEXT_FAMILY_NAME)"; + PRIVATE_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/PrivateHeaders/$(KEXT_FAMILY_NAME)"; + SHALLOW_BUNDLE = YES; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Framework wrapper + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.framework; + BasedOn = com.apple.package-type.wrapper; + Name = "Framework Wrapper"; + Description = "Framework wrapper"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "FMWK"; + WRAPPER_SUFFIX = ".framework"; + VERSIONS_FOLDER_PATH = "$(VERSIONS_FOLDER_PATH_SHALLOW_BUNDLE_$(SHALLOW_BUNDLE))"; + CURRENT_VERSION = "Current"; + INFOPLIST_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Info.plist"; + PKGINFO_PATH = "$(WRAPPER_NAME)/PkgInfo"; + VERSIONPLIST_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/version.plist"; + EXECUTABLES_FOLDER_PATH = "$(LOCALIZED_RESOURCES_FOLDER_PATH)"; // Not the same as EXECUTABLE_FOLDER_PATH + SHARED_SUPPORT_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)"; + CODESIGNING_FOLDER_PATH = "$(TARGET_BUILD_DIR)/$(CONTENTS_FOLDER_PATH)"; + + // Settings specific to deep bundles (macOS) + VERSIONS_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(WRAPPER_NAME)/Versions"; + CONTENTS_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(VERSIONS_FOLDER_PATH)/$(FRAMEWORK_VERSION)"; + EXECUTABLE_FOLDER_PATH_SHALLOW_BUNDLE_NO = "$(CONTENTS_FOLDER_PATH)"; + + // Settings specific to shallow bundles (iOS, DriverKit on any OS) + VERSIONS_FOLDER_PATH_SHALLOW_BUNDLE_YES = "$(WRAPPER_NAME)"; + }; + ProductReference = { + FileType = wrapper.framework; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Static framework wrapper (like a framework, except that it contains a libX.a instead of a dylib) + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.framework.static; + Name = "Mach-O Static Framework"; + Description = "Mach-O static framework"; + BasedOn = com.apple.package-type.wrapper.framework; + DefaultBuildSettings = { + }; + ProductReference = { + FileType = wrapper.framework.static; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Shallow Framework Package + { Type = PackageType; + Identifier = com.apple.package-type.wrapper.framework.shallow; + Name = "Shallow Framework Wrapper"; + Description = "Shallow framework wrapper"; + BasedOn = com.apple.package-type.wrapper.framework; + DefaultBuildSettings = { + SHALLOW_BUNDLE = YES; + }; + ProductReference = { + FileType = wrapper.framework; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Unit Test Bundle wrapper + { Type = PackageType; + Identifier = com.apple.package-type.bundle.unit-test; + BasedOn = com.apple.package-type.wrapper; + Name = "Unit Test Bundle"; + Description = "Unit Test Bundle"; + DefaultBuildSettings = { + WRAPPER_SUFFIX = "xctest"; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Legacy OCUnit Test Bundle wrapper + { Type = PackageType; + Identifier = com.apple.package-type.bundle.ocunit-test; + BasedOn = com.apple.package-type.wrapper; + Name = "OCUnit Test Bundle"; + Description = "OCUnit Test Bundle"; + DefaultBuildSettings = { + WRAPPER_SUFFIX = "octest"; + }; + ProductReference = { + FileType = wrapper.cfbundle; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // In-app Purchase Content wrapper + { Type = PackageType; + Identifier = com.apple.package-type.in-app-purchase-content; + BasedOn = com.apple.package-type.wrapper; + Name = "In-App Purchase Content"; + Description = "In-App Purchase Content"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = ""; + WRAPPER_SUFFIX = ""; + EXECUTABLE_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + INFOPLIST_PATH = "$(WRAPPER_NAME)/ContentInfo.plist"; + INFOSTRINGS_PATH = "$(LOCALIZED_RESOURCES_FOLDER_PATH)/ContentInfo.strings"; + PUBLIC_HEADERS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + PRIVATE_HEADERS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + EXECUTABLES_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + FRAMEWORKS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + SHARED_FRAMEWORKS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + SHARED_SUPPORT_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + UNLOCALIZED_RESOURCES_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + LOCALIZED_RESOURCES_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj"; + DOCUMENTATION_FOLDER_PATH = "$(LOCALIZED_RESOURCES_FOLDER_PATH)"; + MODULES_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + PLUGINS_FOLDER_PATH = "$(CONTENTS_FOLDER_PATH)"; + SCRIPTS_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)"; + JAVA_FOLDER_PATH = "$(UNLOCALIZED_RESOURCES_FOLDER_PATH)"; + }; + ProductReference = { + FileType = folder; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // XPC Service wrapper + { Type = PackageType; + Identifier = com.apple.package-type.xpc-service; + BasedOn = com.apple.package-type.wrapper; + Name = "XPC Service"; + Description = "XPC Service"; + DefaultBuildSettings = { + PRODUCT_BUNDLE_PACKAGE_TYPE = "XPC!"; + WRAPPER_SUFFIX = ".xpc"; + }; + ProductReference = { + FileType = wrapper.xpc-service; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // PlugInKit PlugIn wrapper + { Type = PackageType; + Identifier = com.apple.package-type.pluginkit-plugin; + BasedOn = com.apple.package-type.xpc-service; + Name = "PlugInKit PlugIn"; + Description = "PlugInKit PlugIn"; + DefaultBuildSettings = { + WRAPPER_SUFFIX = ".pluginkit"; + }; + ProductReference = { + FileType = wrapper.app-extension; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // App Extension wrapper + { Type = PackageType; + Identifier = com.apple.package-type.app-extension; + BasedOn = com.apple.package-type.pluginkit-plugin; + Name = "App Extension"; + Description = "App Extension"; + DefaultBuildSettings = { + WRAPPER_SUFFIX = ".appex"; + }; + ProductReference = { + FileType = wrapper.app-extension; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + + }, + + // Spotlight Importer wrapper + { Type = PackageType; + Identifier = com.apple.package-type.spotlight-importer; + BasedOn = com.apple.package-type.wrapper; + Name = "Spotlight Importer"; + Description = "Spotlight Importer"; + DefaultBuildSettings = { + }; + ProductReference = { + FileType = wrapper.spotlight-importer; + Name = "$(WRAPPER_NAME)"; + IsLaunchable = NO; + }; + }, + + // Jar file + { Type = PackageType; + Identifier = com.apple.package-type.jarfile; + Name = "Jar File"; + Description = "Jar file"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ".jar"; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + JAVA_ARCHIVE_CLASSES = YES; + JAVA_MAKE_ZIPFILE = NO; + }; + ProductReference = { + FileType = archive.jar; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // Zip file + { Type = PackageType; + Identifier = com.apple.package-type.zipfile; + Name = "Zip File"; + Description = "Zip file"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ".zip"; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + JAVA_ARCHIVE_CLASSES = YES; + JAVA_MAKE_ZIPFILE = YES; + }; + ProductReference = { + FileType = archive.zip; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, + + // Java class folder + { Type = PackageType; + Identifier = com.apple.package-type.javaclassfolder; + Name = "Class Folder"; + Description = "Class folder"; + DefaultBuildSettings = { + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + EXECUTABLE_NAME = "$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX)"; + EXECUTABLE_PATH = "$(EXECUTABLE_NAME)"; + JAVA_ARCHIVE_CLASSES = NO; + }; + ProductReference = { + FileType = wrapper.java-classfolder; + Name = "$(EXECUTABLE_NAME)"; + IsLaunchable = NO; + }; + }, +) diff --git a/share/qbs/modules/bundle/MacOSX-Product-Types.xcspec b/share/qbs/modules/bundle/MacOSX-Product-Types.xcspec new file mode 100644 index 00000000..bc1d087d --- /dev/null +++ b/share/qbs/modules/bundle/MacOSX-Product-Types.xcspec @@ -0,0 +1,803 @@ +// +// MacOSX Product Types.xcspec +// +// Copyright © 1999-2020 Apple Inc. All rights reserved. +// +// Product type specifications in the macOS platform. +// +( + // + // Single-file product types + // + + // Tool (normal Unix command-line executable) + { Type = ProductType; + Identifier = com.apple.product-type.tool; + Class = PBXToolProductType; + Name = "Command-line Tool"; + Description = "Standalone command-line tool"; + IconNamePrefix = "TargetExecutable"; + DefaultTargetName = "Command-line Tool"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; + MACH_O_TYPE = "mh_execute"; + EXECUTABLE_PREFIX = ""; + EXECUTABLE_SUFFIX = ""; + REZ_EXECUTABLE = YES; + INSTALL_PATH = "/usr/local/bin"; + FRAMEWORK_FLAG_PREFIX = "-framework"; + LIBRARY_FLAG_PREFIX = "-l"; + LIBRARY_FLAG_NOSPACE = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + STRIP_STYLE = "all"; + CODE_SIGNING_ALLOWED = YES; + }; + PackageTypes = ( + com.apple.package-type.mach-o-executable // default + ); + WantsSigningEditing = YES; + WantsBundleIdentifierEditing = YES; + }, + + // Java tool + { Type = ProductType; + Identifier = com.apple.product-type.tool.java; + Name = "Java Command-line Tool"; + Description = "Java Command-line tool"; + IconNamePrefix = "TargetExecutable"; + DefaultTargetName = "Java Command-line Tool"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; + REZ_EXECUTABLE = YES; + INSTALL_PATH = "/usr/local/bin"; + }; + IsJava = YES; + PackageTypes = ( + com.apple.package-type.jarfile, // default + com.apple.package-type.zipfile, + com.apple.package-type.javaclassfolder + ); + }, + + // Object file + { Type = ProductType; + Identifier = com.apple.product-type.objfile; + Class = XCStandaloneExecutableProductType; + Name = "Object File"; + Description = "Object File"; + IconNamePrefix = "TargetPlugin"; + DefaultTargetName = "Object File"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; + MACH_O_TYPE = "mh_object"; + LINK_WITH_STANDARD_LIBRARIES = NO; + REZ_EXECUTABLE = YES; + EXECUTABLE_SUFFIX = ".$(EXECUTABLE_EXTENSION)"; + EXECUTABLE_EXTENSION = "o"; + PUBLIC_HEADERS_FOLDER_PATH = "/usr/local/include"; + PRIVATE_HEADERS_FOLDER_PATH = "/usr/local/include"; + INSTALL_PATH = "$(HOME)/Objects"; + FRAMEWORK_FLAG_PREFIX = "-framework"; + LIBRARY_FLAG_PREFIX = "-l"; + LIBRARY_FLAG_NOSPACE = YES; + SKIP_INSTALL = YES; + STRIP_STYLE = "debugging"; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + KEEP_PRIVATE_EXTERNS = YES; + DEAD_CODE_STRIPPING = NO; + }; + PackageTypes = ( + com.apple.package-type.mach-o-objfile // default + ); + }, + + // Dynamic library + { Type = ProductType; + Identifier = com.apple.product-type.library.dynamic; + Class = PBXDynamicLibraryProductType; + Name = "Dynamic Library"; + Description = "Dynamic library"; + IconNamePrefix = "TargetLibrary"; + DefaultTargetName = "Dynamic Library"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; + MACH_O_TYPE = "mh_dylib"; + REZ_EXECUTABLE = YES; + EXECUTABLE_SUFFIX = ".$(EXECUTABLE_EXTENSION)"; + EXECUTABLE_EXTENSION = "dylib"; + PUBLIC_HEADERS_FOLDER_PATH = "/usr/local/include"; + PRIVATE_HEADERS_FOLDER_PATH = "/usr/local/include"; + INSTALL_PATH = "/usr/local/lib"; + DYLIB_INSTALL_NAME_BASE = "$(INSTALL_PATH)"; + LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)"; + DYLIB_COMPATIBILITY_VERSION = "1"; + DYLIB_CURRENT_VERSION = "1"; + FRAMEWORK_FLAG_PREFIX = "-framework"; + LIBRARY_FLAG_PREFIX = "-l"; + LIBRARY_FLAG_NOSPACE = YES; + STRIP_STYLE = "debugging"; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + CODE_SIGNING_ALLOWED = YES; + CODE_SIGNING_REQUIRED = NO; + }; + PackageTypes = ( + com.apple.package-type.mach-o-dylib // default + ); + }, + + // Static library + { Type = ProductType; + Identifier = com.apple.product-type.library.static; + Class = PBXStaticLibraryProductType; + Name = "Static Library"; + Description = "Static library"; + IconNamePrefix = "TargetLibrary"; + DefaultTargetName = "Static Library"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(EXECUTABLE_NAME)"; + MACH_O_TYPE = "staticlib"; + REZ_EXECUTABLE = YES; + EXECUTABLE_PREFIX = "lib"; + EXECUTABLE_SUFFIX = ".$(EXECUTABLE_EXTENSION)"; + EXECUTABLE_EXTENSION = "a"; + PUBLIC_HEADERS_FOLDER_PATH = "/usr/local/include"; + PRIVATE_HEADERS_FOLDER_PATH = "/usr/local/include"; + INSTALL_PATH = "/usr/local/lib"; + FRAMEWORK_FLAG_PREFIX = "-framework"; + LIBRARY_FLAG_PREFIX = "-l"; + LIBRARY_FLAG_NOSPACE = YES; + STRIP_STYLE = "debugging"; + CLANG_ENABLE_MODULE_DEBUGGING = NO; + CODE_SIGNING_ALLOWED = NO; + }; + AlwaysPerformSeparateStrip = YES; + PackageTypes = ( + com.apple.package-type.static-library // default + ); + }, + + // Java library (jar or zip file) + { Type = ProductType; + Identifier = com.apple.product-type.library.java.archive; + Name = "Java Library"; + Description = "Java library packaged as a Jar file, Zip file, or class folder"; + IconNamePrefix = "TargetPlugin"; + DefaultTargetName = "Java Library"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(PRODUCT_NAME)"; + INSTALL_PATH = "/usr/local/lib"; + }; + IsJava = YES; + PackageTypes = ( + com.apple.package-type.jarfile, // default + com.apple.package-type.zipfile, + com.apple.package-type.javaclassfolder + ); + }, + + + // + // Wrapper product types + // + + // Bundle + { Type = ProductType; + Identifier = com.apple.product-type.bundle; + Class = PBXBundleProductType; + Name = "Bundle"; + Description = "Generic bundle"; + IconNamePrefix = "TargetPlugin"; + DefaultTargetName = "Bundle"; + DefaultBuildProperties = { + FULL_PRODUCT_NAME = "$(WRAPPER_NAME)"; + MACH_O_TYPE = "mh_bundle"; + WRAPPER_PREFIX = ""; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "bundle"; + WRAPPER_NAME = "$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)"; + FRAMEWORK_FLAG_PREFIX = "-framework"; + LIBRARY_FLAG_PREFIX = "-l"; + LIBRARY_FLAG_NOSPACE = YES; + STRIP_STYLE = "non-global"; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + CODE_SIGNING_ALLOWED = YES; + }; + PackageTypes = ( + com.apple.package-type.wrapper, // default + com.apple.package-type.wrapper.shallow // Not clear if this is needed in the presence of the Shallow Bundle product type below. + ); + IsWrapper = YES; + HasInfoPlist = YES; + HasInfoPlistStrings = YES; + WantsBundleIdentifierEditing = YES; + WantsSigningEditing = YES; + }, + + // Shallow Bundle Product + { Type = ProductType; + Identifier = com.apple.product-type.bundle.shallow; + BasedOn = com.apple.product-type.bundle; + Class = PBXBundleProductType; + Name = "Bundle (Shallow)"; + Description = "Bundle (Shallow)"; + PackageTypes = ( + com.apple.package-type.wrapper.shallow + ); + }, + + // Application + { Type = ProductType; + Identifier = com.apple.product-type.application; + BasedOn = com.apple.product-type.bundle; + Class = PBXApplicationProductType; + Name = "Application"; + Description = "Application"; + IconNamePrefix = "TargetApp"; + DefaultTargetName = "Application"; + DefaultBuildProperties = { + MACH_O_TYPE = "mh_execute"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_SYMBOLS_PRIVATE_EXTERN = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = YES; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "app"; + INSTALL_PATH = "$(LOCAL_APPS_DIR)"; + STRIP_STYLE = "all"; + CODE_SIGNING_ALLOWED = YES; + LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST))"; + LD_RUNPATH_SEARCH_PATHS_YES = ( "@loader_path/../Frameworks", ); + }; + PackageTypes = ( + com.apple.package-type.wrapper.application // default + ); + + /** Product type validation hooks */ + Validation = { + + // Checks - a dictionary of checks that are perform just prior to building the product + // Each dictionary key is the "XCPropertyMacroExpression" to evaluate + // The dictionary value contains the error message to display if the condition evaluates to false. + Checks = { + // This is intentially empty as currently all of the checks are done in-code for this particular application type. However, we enable the plubmbing for the validation tool spec infrastructure to be called to avoid any further hacks in pbxbuild or xcbuild. This is to enable rdar://problem/45590882. + }; + + // Determines if the legacy build system has support for this validation hook. This is a workaround for enabling additional validation in xcbuild (specifically for rdar://problem/45590882), which does not have the same plugin restriction that is imposed on pbxbuild's implementation of the validation hooks. + EnabledForLegacyBuildSystem = NO; + + // ValidationToolSpec - the identifier of the tool (script) to run after a target is constructed. + ValidationToolSpec = "com.apple.build-tools.platform.validate"; + }; + CanEmbedCompilerSanitizerLibraries = YES; + RunpathSearchPathForEmbeddedFrameworks = "@executable_path/../Frameworks"; + ValidateEmbeddedBinaries = YES; + ProvisioningProfileSupported = YES; + ProvisioningProfileRequired = NO; + WantsBundleIdentifierEditing = YES; + WantsSigningEditing = YES; + }, + + // Shallow Application Product + { Type = ProductType; + Identifier = com.apple.product-type.application.shallow; + BasedOn = com.apple.product-type.application; + Class = PBXApplicationProductType; // see radar 5604879, this shouldn't be necesary + Name = "Application (Shallow Bundle)"; + Description = "Application (Shallow Bundle)"; + PackageTypes = ( + com.apple.package-type.wrapper.application.shallow + ); + }, + + // Java Application + { Type = ProductType; + Identifier = com.apple.product-type.application.java; + BasedOn = com.apple.product-type.application; + Name = "Java Application"; + Description = "Java Application"; + DefaultTargetName = "Java Application"; + DefaultBuildProperties = { + INFOPLIST_PATH = ""; + PKGINFO_PATH = ""; + }; + IsJava = YES; + }, + + // Framework + { Type = ProductType; + Identifier = com.apple.product-type.framework; + BasedOn = com.apple.product-type.bundle; + Class = PBXFrameworkProductType; + Name = "Framework"; + Description = "Framework"; + IconNamePrefix = "TargetFramework"; + DefaultTargetName = "Framework"; + DefaultBuildProperties = { + MACH_O_TYPE = "mh_dylib"; + FRAMEWORK_VERSION = "A"; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "framework"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + DYLIB_INSTALL_NAME_BASE = "$(INSTALL_PATH)"; + LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)"; + STRIP_STYLE = "debugging"; + CODE_SIGNING_ALLOWED = YES; + CODE_SIGNING_REQUIRED = NO; + ENTITLEMENTS_REQUIRED = NO; + CODE_SIGNING_REQUIRES_TEAM = YES; + }; + PackageTypes = ( + com.apple.package-type.wrapper.framework // default + ); + }, + + // Shallow Framework Product + { Type = ProductType; + Identifier = com.apple.product-type.framework.shallow; + BasedOn = com.apple.product-type.framework; + Class = PBXFrameworkProductType; + Name = "Framework (Shallow Bundle)"; + Description = "Framework (Shallow Bundle)"; + PackageTypes = ( + com.apple.package-type.wrapper.framework.shallow + ); + }, + + // Static framework + { Type = ProductType; + Identifier = com.apple.product-type.framework.static; + BasedOn = com.apple.product-type.framework; + Class = XCStaticFrameworkProductType; + Name = "Static Framework"; + Description = "Static Framework"; + IconNamePrefix = "TargetFramework"; + DefaultTargetName = "Static Framework"; + DefaultBuildProperties = { + MACH_O_TYPE = "staticlib"; + FRAMEWORK_VERSION = "A"; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "framework"; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + DYLIB_INSTALL_NAME_BASE = ""; + LD_DYLIB_INSTALL_NAME = ""; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + CODE_SIGNING_ALLOWED = NO; + }; + AlwaysPerformSeparateStrip = YES; + PackageTypes = ( + com.apple.package-type.wrapper.framework.static // default + ); + }, + + // System extension + { Type = ProductType; + Identifier = com.apple.product-type.system-extension; + BasedOn = com.apple.product-type.bundle; + Name = "DriverKit Driver"; + Description = "DriverKit driver"; + DefaultTargetName = "DriverKit Driver"; + DefaultBuildProperties = { + MACH_O_TYPE = "mh_execute"; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "systemextension"; + + PRODUCT_NAME = "$(PRODUCT_BUNDLE_IDENTIFIER)"; + }; + PackageTypes = ( + com.apple.package-type.wrapper.system-extension, + ); + ProvisioningProfileSupported = YES; + ProvisioningProfileRequired = NO; + }, + + // DriverKit driver + { Type = ProductType; + Identifier = com.apple.product-type.driver-extension; + BasedOn = com.apple.product-type.system-extension; + Name = "DriverKit Driver"; + Description = "DriverKit driver"; + DefaultTargetName = "DriverKit Driver"; + DefaultBuildProperties = { + SDKROOT = "driverkit"; + MACH_O_TYPE = "mh_execute"; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "dext"; + INSTALL_PATH = "$(DEFAULT_DEXT_INSTALL_PATH)"; + STRIP_STYLE = "debugging"; + + DEXT_FRAMEWORK_NAME = "DriverKit"; + DEXT_FRAMEWORK = "$(SYSTEM_LIBRARY_DIR)/Frameworks/$(DEXT_FRAMEWORK_NAME).framework"; + + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + + PRODUCT_NAME = "$(PRODUCT_BUNDLE_IDENTIFIER)"; + PRODUCT_TYPE_HEADER_SEARCH_PATHS = "$(inherited) $(IIG_HEADERS_DIR)"; + }; + DefaultEntitlements = { + "com.apple.developer.driverkit" = YES; + }; + PackageTypes = ( + com.apple.package-type.wrapper.driver-extension, + ); + }, + + // Kernel Extension + { Type = ProductType; + Identifier = com.apple.product-type.kernel-extension; + BasedOn = com.apple.product-type.bundle; + Class = XCKernelExtensionProductType; + Name = "Kernel Extension"; + Description = "Kernel extension"; + DefaultTargetName = "Kernel Extension"; + DefaultBuildProperties = { + MACH_O_TYPE = "mh_execute"; + WRAPPER_SUFFIX = ".$(WRAPPER_EXTENSION)"; + WRAPPER_EXTENSION = "kext"; + INSTALL_PATH = "$(DEFAULT_KEXT_INSTALL_PATH)"; + STRIP_STYLE = "debugging"; + + KEXT_FRAMEWORK_NAME = "Kernel"; + KEXT_FRAMEWORK = "$(SYSTEM_LIBRARY_DIR)/Frameworks/$(KEXT_FRAMEWORK_NAME).framework"; + KEXT_FAMILY_NAME = "family"; + PUBLIC_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/Headers/$(KEXT_FAMILY_NAME)"; + PRIVATE_HEADERS_FOLDER_PATH = "$(KEXT_FRAMEWORK)/Contents/PrivateHeaders/$(KEXT_FAMILY_NAME)"; + MODULE_NAME = "com.company.driver.modulename"; + MODULE_VERSION = "1.0"; + MODULE_START = "0"; + MODULE_STOP = "0"; + + ENABLE_APPLE_KEXT_CODE_GENERATION = YES; // -fapple-kext + GCC_ENABLE_KERNEL_DEVELOPMENT = YES; // -mkernel + + GCC_USE_STANDARD_INCLUDE_SEARCHING = NO; // -nostdinc + GCC_ENABLE_PASCAL_STRINGS = NO; // Disables -fpascal-strings + GCC_FORCE_CPU_SUBTYPE_ALL = YES; // -force_cpusubtype_ALL + GCC_CHECK_RETURN_VALUE_OF_OPERATOR_NEW = YES; // -fcheck-new + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; // -fvisibility-inlines-hidden + GCC_ENABLE_BUILTIN_FUNCTIONS = NO; // -fno-builtin + GCC_NO_COMMON_BLOCKS = YES; // -fno-common + GCC_ENABLE_CPP_EXCEPTIONS = NO; // -fno-exceptions + GCC_ENABLE_CPP_RTTI = NO; // -fno-rtti + + // Supposedly these two flags are the default in GCC, but they're provided here for compatibility with older Xcode versions. + GCC_ENABLE_FUNCTION_INLINING = YES; // -finline + GCC_DISABLE_STATIC_FUNCTION_INLINING = YES; // -fno-keep-inline-functions + + // Per-product-type settings. + // The KERNEL_*** settings are defined differently for some SDKs, so we continue to use them for compatibility reasons. + KERNEL_FRAMEWORK = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/Kernel.framework"; + KERNEL_FRAMEWORK_HEADERS = "$(KERNEL_FRAMEWORK)/Headers"; + KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(KERNEL_FRAMEWORK)/PrivateHeaders $(KERNEL_FRAMEWORK_HEADERS)"; + // These settings are reserved for use by product types. + GCC_PRODUCT_TYPE_PREPROCESSOR_DEFINITIONS = "$(inherited) KERNEL KERNEL_PRIVATE DRIVER_PRIVATE APPLE NeXT"; + PRODUCT_TYPE_CFLAGS = "$(inherited) $(KEXT_CFLAGS)"; + PRODUCT_TYPE_CPLUSPLUSFLAGS = "$(inherited) $(KEXT_CPLUSPLUSFLAGS)"; + PRODUCT_SPECIFIC_LDFLAGS = "$(inherited) $(KEXT_LDFLAGS)"; + PRODUCT_TYPE_HEADER_SEARCH_PATHS = "$(inherited) $(KERNEL_EXTENSION_HEADER_SEARCH_PATHS)"; + + CODE_SIGNING_ALLOWED = YES; + + ARCHS_STANDARD = "arm64e x86_64"; + ARCHS_STANDARD_64_BIT = "$(ARCHS_STANDARD)"; + ARCHS_STANDARD_INCLUDING_64_BIT = "$(ARCHS_STANDARD)"; + }; + PackageTypes = ( + com.apple.package-type.wrapper.kernel-extension, // Default + com.apple.package-type.wrapper.kernel-extension.shallow, + ); + }, + + // Shallow Kernel Extension + { + Type = ProductType; + Identifier = com.apple.product-type.kernel-extension.shallow; + BasedOn = com.apple.product-type.kernel-extension; + Class = XCKernelExtensionProductType; + Name = "Kernel Extension (Shallow)"; + Description = "Kernel extension (shallow)"; + DefaultBuildProperties = { + // None yet + }; + PackageTypes = ( + com.apple.package-type.wrapper.kernel-extension.shallow, + ); + }, + + // IOKit Kernel Extension + { Type = ProductType; + Identifier = com.apple.product-type.kernel-extension.iokit; + BasedOn = com.apple.product-type.kernel-extension; + Class = XCKernelExtensionProductType; + Name = "IOKit Kernel Extension"; + Description = "IOKit Kernel extension"; + DefaultTargetName = "IOKit Kernel Extension"; + DefaultBuildProperties = { + CODE_SIGNING_ALLOWED = YES; + }; + PackageTypes = ( + com.apple.package-type.wrapper.kernel-extension, // Default + com.apple.package-type.wrapper.kernel-extension.shallow, + ); + }, + + // Shallow IOKit Kernel Extension + { Type = ProductType; + Identifier = com.apple.product-type.kernel-extension.iokit.shallow; + BasedOn = com.apple.product-type.kernel-extension; + Class = XCKernelExtensionProductType; + Name = "IOKit Kernel Extension (Shallow)"; + Description = "IOKit Kernel extension (Shallow)"; + DefaultTargetName = "IOKit Kernel Extension (Shallow)"; + DefaultBuildProperties = { + // None yet + }; + PackageTypes = ( + com.apple.package-type.wrapper.kernel-extension.shallow, + ); + }, + + // Unit Test Bundle + { Type = ProductType; + Identifier = com.apple.product-type.bundle.unit-test; + BasedOn = com.apple.product-type.bundle; + Class = PBXXCTestBundleProductType; + Name = "Unit Test Bundle"; + Description = "Unit Test Bundle"; + DefaultBuildProperties = { + WRAPPER_EXTENSION = "xctest"; + ENABLE_TESTING_SEARCH_PATHS = YES; + PRODUCT_SPECIFIC_LDFLAGS = "-framework XCTest"; + XCTRUNNER_PATH = "$(XCTRUNNER_PATH$(TEST_BUILD_STYLE))"; + LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST))"; + LD_RUNPATH_SEARCH_PATHS_YES = ( + "@loader_path/../Frameworks", + "@executable_path/../Frameworks", + ); + }; + PackageTypes = ( + com.apple.package-type.bundle.unit-test + ); + CanEmbedCompilerSanitizerLibraries = YES; + IsUnitTest = YES; + WantsBundleIdentifierEditing = NO; + }, + + // UI Testing Bundle + { Type = ProductType; + Identifier = com.apple.product-type.bundle.ui-testing; + BasedOn = com.apple.product-type.bundle.unit-test; + Class = PBXXCTestBundleProductType; + Name = "UI Testing Bundle"; + Description = "UI Testing Bundle"; + DefaultBuildProperties = { + USES_XCTRUNNER = "YES"; + }; + PackageTypes = ( + com.apple.package-type.bundle.unit-test + ); + ProvisioningProfileSupported = YES; + IsUITest = YES; + InfoPlistAdditions = { + XCTContainsUITests = YES; + }; + WantsBundleIdentifierEditing = NO; + }, + + // Legacy OCUnit Test Bundle + { Type = ProductType; + Identifier = com.apple.product-type.bundle.ocunit-test; + BasedOn = com.apple.product-type.bundle; + Class = PBXBundleProductType; + Name = "OCUnit Test Bundle"; + Description = "OCUnit Test Bundle"; + DefaultBuildProperties = { + WRAPPER_EXTENSION = "octest"; + }; + PackageTypes = ( + com.apple.package-type.bundle.ocunit-test + ); + IsUnitTest = YES; + }, + + // In-App Purchase Content + { Type = ProductType; + Identifier = com.apple.product-type.in-app-purchase-content; + Class = PBXBundleProductType; + Name = "In-App Purchase Content"; + Description = "In-App Purchase Content"; + DefaultBuildProperties = { + CODE_SIGNING_ALLOWED = NO; + FULL_PRODUCT_NAME = "$(WRAPPER_NAME)"; + }; + PackageTypes = ( + com.apple.package-type.in-app-purchase-content, // default + ); + IsWrapper = YES; + HasInfoPlist = YES; + HasInfoPlistStrings = NO; + }, + + // XPC Service + { + Type = ProductType; + Identifier = "com.apple.product-type.xpc-service"; + BasedOn = "com.apple.product-type.bundle"; + Class = PBXBundleProductType; + Name = "XPC Service"; + Description = "XPC Service"; + IconNamePrefix = XPCService; + DefaultTargetName = "XPC Service"; + CanEmbedCompilerSanitizerLibraries = YES; + "DefaultBuildProperties" = { + "MACH_O_TYPE" = "mh_execute"; + WRAPPER_EXTENSION = "xpc"; + LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)_$(_BOOL_$(SKIP_INSTALL)))"; + LD_RUNPATH_SEARCH_PATHS_YES_YES = ( + "@loader_path/../Frameworks", + "@loader_path/../../../../Frameworks", + ); + LD_RUNPATH_SEARCH_PATHS_YES_NO = ( "@loader_path/../Frameworks", ); + }; + PackageTypes = ( + "com.apple.package-type.xpc-service", + ); + ProvisioningProfileSupported = YES; + ProvisioningProfileRequired = NO; + WantsBundleIdentifierEditing = YES; + WantsSigningEditing = YES; + }, + + // PlugIn-Kit PlugIn + { + Type = ProductType; + Identifier = "com.apple.product-type.pluginkit-plugin"; + BasedOn = "com.apple.product-type.xpc-service"; + Class = PBXBundleProductType; + Name = "PlugInKit PlugIn"; + Description = "PlugInKit PlugIn"; + IconNamePrefix = XPCService; + DefaultTargetName = "PlugInKit PlugIn"; + "DefaultBuildProperties" = { + "PRODUCT_SPECIFIC_LDFLAGS" = "$(SDKROOT)/System/Library/PrivateFrameworks/PlugInKit.framework/PlugInKit"; + WRAPPER_EXTENSION = "pluginkit"; + }; + PackageTypes = ( + "com.apple.package-type.pluginkit-plugin", + ); + }, + + // App Extension + { + Type = ProductType; + Identifier = "com.apple.product-type.app-extension"; + BasedOn = "com.apple.product-type.pluginkit-plugin"; + Class = PBXBundleProductType; + Name = "App Extension"; + Description = "App Extension"; + IconNamePrefix = AppExtension; + DefaultTargetName = "App Extension"; + "DefaultBuildProperties" = { + "CODE_SIGNING_ALLOWED" = YES; + "APPLICATION_EXTENSION_API_ONLY" = YES; + "PRODUCT_SPECIFIC_LDFLAGS" = "-e _NSExtensionMain"; + WRAPPER_EXTENSION = "appex"; + }; + PackageTypes = ( + "com.apple.package-type.app-extension", + ); + ProvisioningProfileSupported = YES; + ProvisioningProfileRequired = NO; + WantsBundleIdentifierEditing = YES; + WantsSigningEditing = YES; + }, + + // Xcode Extension + { + Type = ProductType; + Identifier = "com.apple.product-type.xcode-extension"; + BasedOn = "com.apple.product-type.app-extension"; + Name = "Xcode Extension"; + Description = "Xcode Extension"; + IconNamePrefix = XcodeExtension; + DefaultTargetName = "Xcode Extension"; + "DefaultBuildProperties" = { + "CODE_SIGNING_ALLOWED" = YES; + "APPLICATION_EXTENSION_API_ONLY" = YES; + "PRODUCT_SPECIFIC_LDFLAGS" = "-e _XCExtensionMain -lXcodeExtension"; + "PRODUCT_TYPE_FRAMEWORK_SEARCH_PATHS" = ( + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", + ); + "PRODUCT_TYPE_LIBRARY_SEARCH_PATHS" = ( + "$(inherited)", + "$(DEVELOPER_USR_DIR)/lib", + ); + LD_RUNPATH_SEARCH_PATHS = ( + "@loader_path/../Frameworks", + ); + WRAPPER_EXTENSION = "appex"; + }; + PackageTypes = ( + "com.apple.package-type.app-extension", + ); + ProvisioningProfileSupported = YES; + ProvisioningProfileRequired = NO; + WantsBundleIdentifierEditing = YES; + WantsSigningEditing = YES; + }, + + // Spotlight Importer + { + Type = ProductType; + Identifier = "com.apple.product-type.spotlight-importer"; + BasedOn = "com.apple.product-type.bundle"; + Class = PBXBundleProductType; + Name = "Spotlight Importer"; + Description = "Spotlight Importer"; + DefaultTargetName = "Spotlight"; + "DefaultBuildProperties" = { + "CODE_SIGNING_ALLOWED" = YES; + }; + PackageTypes = ( + "com.apple.package-type.spotlight-importer", + ); + }, + + // Copied from iOS specs to aid in build system diagnostic support. + // Later, we should put these in some central place. + { + Type = ProductType; + Identifier = "com.apple.product-type.app-extension.messages"; + BasedOn = "com.apple.product-type.app-extension"; + }, + + { + Type = ProductType; + Identifier = "com.apple.product-type.app-extension.messages-sticker-pack"; + BasedOn = "com.apple.product-type.app-extension"; + IsCapabilitiesUnsupported = YES; + WantsSimpleTargetEditing = YES; + DefaultBuildProperties = { + MESSAGES_APPLICATION_EXTENSION_PRODUCT_BINARY_SOURCE_PATH = "$(PLATFORM_DIR)/Library/Application Support/MessagesApplicationExtensionStub/MessagesApplicationExtensionStub"; + ASSETCATALOG_COMPILER_INCLUDE_STICKER_CONTENT = YES; + ASSETCATALOG_COMPILER_TARGET_STICKERS_ICON_ROLE = "extension"; + ASSETCATALOG_COMPILER_STICKER_PACK_IDENTIFIER_PREFIX = "$(PRODUCT_BUNDLE_IDENTIFIER).sticker-pack."; + }; + AllowedBuildPhases = ( + "com.apple.buildphase.resources", + "com.apple.buildphase.shell-script", + ); + InfoPlistAdditions = { + LSApplicationIsStickerProvider = YES; + }; + }, + + { + Type = ProductType; + Identifier = "com.apple.product-type.application.on-demand-install-capable"; + BasedOn = "com.apple.product-type.application"; + Name = "App Clip"; + Description = "App Clip"; + DefaultBuildProperties = { + ENABLE_ON_DEMAND_RESOURCES = NO; + ASSETCATALOG_COMPILER_STANDALONE_ICON_BEHAVIOR = none; // Don't include standalone icons to keep size down + PRODUCT_SPECIFIC_LDFLAGS = "$(inherited) -framework AppClip"; + SKIP_INSTALL = YES; + }; + DefaultEntitlements = { + "com.apple.developer.on-demand-install-capable" = YES; + }; + SupportsOnDemandResources = NO; + IsEmbeddable = YES; + BuildPhaseInjectionsWhenEmbedding = ( + { + BuildPhase = "CopyFiles"; + Name = "Embed App Clips"; + RunOnlyForDeploymentPostprocessing = NO; + DstSubFolderSpec = 16; + DstPath = "$(CONTENTS_FOLDER_PATH)/AppClips"; + } + ); + }, +) diff --git a/share/qbs/modules/bundle/bundle.js b/share/qbs/modules/bundle/bundle.js new file mode 100644 index 00000000..7fb89974 --- /dev/null +++ b/share/qbs/modules/bundle/bundle.js @@ -0,0 +1,332 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var DarwinTools = require("qbs.DarwinTools"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var Utilities = require("qbs.Utilities"); + +// HACK: Workaround until the PropertyList extension is supported cross-platform +var TextFile = require("qbs.TextFile"); +var PropertyList2 = (function () { + function PropertyList2() { + } + PropertyList2.prototype.readFromFile = function (filePath) { + var str; + var process = new Process(); + try { + if (process.exec("plutil", ["-convert", "json", "-o", "-", filePath], false) === 0) { + str = process.readStdOut(); + } else { + var tf = new TextFile(filePath); + try { + str = tf.readAll(); + } finally { + tf.close(); + } + } + } finally { + process.close(); + } + + if (str) + this.obj = JSON.parse(str); + }; + PropertyList2.prototype.toObject = function () { + return this.obj; + }; + PropertyList2.prototype.clear = function () { + }; + return PropertyList2; +}()); + +// Order is significant due to productTypeIdentifier() search path +var _productTypeIdentifiers = { + "inapppurchase": "com.apple.product-type.in-app-purchase-content", + "applicationextension": "com.apple.product-type.app-extension", + "xpcservice": "com.apple.product-type.xpc-service", + "application": "com.apple.product-type.application", + "dynamiclibrary": "com.apple.product-type.framework", + "loadablemodule": "com.apple.product-type.bundle", + "staticlibrary": "com.apple.product-type.framework.static", + "kernelmodule": "com.apple.product-type.kernel-extension" +}; + +function productTypeIdentifier(productType) { + for (var k in _productTypeIdentifiers) { + if (productType.contains(k)) + return _productTypeIdentifiers[k]; + } + return "com.apple.package-type.wrapper"; +} + +function excludedAuxiliaryInputs(project, product) { + var chain = product.bundle._productTypeIdentifierChain; + var bestPossibleType; + for (var i = chain.length - 1; i >= 0; --i) { + switch (chain[i]) { + case "com.apple.product-type.bundle": + bestPossibleType = "loadablemodule"; + break; + case "com.apple.product-type.framework": + bestPossibleType = "dynamiclibrary"; + break; + case "com.apple.product-type.framework.static": + bestPossibleType = "staticlibrary"; + break; + case "com.apple.product-type.application": + case "com.apple.product-type.xpc-service": + bestPossibleType = "application"; + break; + } + } + + var excluded = []; + var possibleTypes = ["application", "dynamiclibrary", "staticlibrary", "loadablemodule"]; + for (i = 0; i < possibleTypes.length; ++i) { + if (possibleTypes[i] !== bestPossibleType) + excluded.push(possibleTypes[i]); + } + + return excluded; +} + +function packageType(productTypeIdentifier) { + switch (productTypeIdentifier) { + case "com.apple.product-type.in-app-purchase-content": + return undefined; + case "com.apple.product-type.app-extension": + case "com.apple.product-type.xpc-service": + return "XPC!"; + case "com.apple.product-type.application": + return "APPL"; + case "com.apple.product-type.framework": + case "com.apple.product-type.framework.static": + return "FMWK"; + case "com.apple.product-type.kernel-extension": + case "com.apple.product-type.kernel-extension.iokit": + return "KEXT"; + default: + return "BNDL"; + } +} + +function _assign(target, source) { + if (source) { + for (var k in source) { + if (source.hasOwnProperty(k)) + target[k] = source[k]; + } + return target; + } +} + +function macOSSpecsPaths(version, developerPath) { + var result = []; + if (Utilities.versionCompare(version, "12.5") >= 0) { + result.push(FileInfo.joinPaths( + developerPath, "..", "PlugIns", "XCBSpecifications.ideplugin", + "Contents", "Resources")); + } + + if (Utilities.versionCompare(version, "12") >= 0) { + result.push(FileInfo.joinPaths( + developerPath, "Platforms", "MacOSX.platform", "Developer", "Library", "Xcode", + "PrivatePlugIns", "IDEOSXSupportCore.ideplugin", "Contents", "Resources")); + } else { + result.push(FileInfo.joinPaths( + developerPath, "Platforms", "MacOSX.platform", "Developer", "Library", "Xcode", + "Specifications")); + } + return result; +} + +var XcodeBuildSpecsReader = (function () { + function XcodeBuildSpecsReader(specsPaths, separator, additionalSettings, useShallowBundles) { + this._additionalSettings = additionalSettings; + this._useShallowBundles = useShallowBundles; + + this._packageTypes = []; + this._productTypes = []; + + var i, j; + for (i = 0; i < specsPaths.length; ++i) { + var specsPath = specsPaths[i]; + var names = ["", "Darwin", "MacOSX"]; + for (j = 0; j < names.length; ++j) { + var name = names[j]; + var plist = new PropertyList2(); + var plist2 = new PropertyList2(); + try + { + var plistName = [name, "Package", "Types.xcspec"].join(name ? separator : ""); + var plistName2 = [name, "Product", "Types.xcspec"].join(name ? separator : ""); + var plistPath = FileInfo.joinPaths(specsPath, plistName); + var plistPath2 = FileInfo.joinPaths(specsPath, plistName2); + if (File.exists(plistPath)) { + plist.readFromFile(plistPath); + this._packageTypes = this._packageTypes.concat(plist.toObject()); + } + if (File.exists(plistPath2)) { + plist2.readFromFile(plistPath2); + this._productTypes = this._productTypes.concat(plist2.toObject()); + } + } finally { + plist.clear(); + plist2.clear(); + } + } + } + + this._types = {}; + for (i = 0; i < this._packageTypes.length; ++i) + this._types[this._packageTypes[i]["Identifier"]] = this._packageTypes[i]; + for (i = 0; i < this._productTypes.length; ++i) + this._types[this._productTypes[i]["Identifier"]] = this._productTypes[i]; + + } + XcodeBuildSpecsReader.prototype.productTypeIdentifierChain = function (typeIdentifier) { + var ids = [typeIdentifier]; + var obj = this._types[typeIdentifier]; + var parentId = obj && obj["BasedOn"]; + if (parentId) + return ids.concat(this.productTypeIdentifierChain(parentId)); + return ids; + }; + XcodeBuildSpecsReader.prototype.settings = function (typeIdentifier, recursive, skipPackageTypes) { + // Silently use shallow bundles when preferred since it seems to be some sort of automatic + // shadowing mechanism. For example, this matches Xcode behavior where static frameworks + // are shallow even though no such product specification exists, and also seems to match + // other behavior i.e. where productType in pbxproj files is never explicitly shallow. + if (this._useShallowBundles && this._types[typeIdentifier + ".shallow"] && !skipPackageTypes) + typeIdentifier += ".shallow"; + + var typesObject = this._types[typeIdentifier]; + if (typesObject) { + var buildProperties = {}; + + if (recursive) { + // Get all the settings for the product's package type + if (!skipPackageTypes && typesObject["PackageTypes"]) { + for (var k = 0; k < typesObject["PackageTypes"].length; ++k) { + var props = this.settings(typesObject["PackageTypes"][k], recursive, true); + for (var y in props) { + if (props.hasOwnProperty(y)) + buildProperties[y] = props[y]; + } + break; + } + } + + // Get all the settings for the product's inherited product type + if (typesObject["BasedOn"]) { + // We'll only do the auto shallow substitution for wrapper package types... + // this ensures that in-app purchase content bundles are non-shallow on both + // macOS and iOS, for example (which matches Xcode behavior) + var isWrapper = false; + if (typesObject["ProductReference"]) { + var fileType = typesObject["ProductReference"]["FileType"]; + if (fileType) + isWrapper = fileType.startsWith("wrapper."); + } + + // Prevent recursion loop if this spec's base plus .shallow would be the same + // as the current spec's identifier + var baseIdentifier = typesObject["BasedOn"]; + if (this._useShallowBundles && isWrapper + && this._types[baseIdentifier + ".shallow"] + && typeIdentifier !== baseIdentifier + ".shallow") + baseIdentifier += ".shallow"; + + props = this.settings(baseIdentifier, recursive, true); + for (y in props) { + if (props.hasOwnProperty(y)) + buildProperties[y] = props[y]; + } + } + } + + + if (typesObject["Type"] === "PackageType") { + props = typesObject["DefaultBuildSettings"]; + for (y in props) { + if (props.hasOwnProperty(y)) + buildProperties[y] = props[y]; + } + } + + if (typesObject["Type"] === "ProductType") { + props = typesObject["DefaultBuildProperties"]; + for (y in props) { + if (props.hasOwnProperty(y)) + buildProperties[y] = props[y]; + } + } + + return buildProperties; + } + }; + XcodeBuildSpecsReader.prototype.setting = function (typeIdentifier, settingName) { + var obj = this.settings(typeIdentifier, false); + if (obj) { + return obj[settingName]; + } + }; + XcodeBuildSpecsReader.prototype.expandedSettings = function (typeIdentifier, baseSettings) { + var obj = this.settings(typeIdentifier, true); + if (obj) { + for (var k in obj) + obj[k] = this.expandedSetting(typeIdentifier, baseSettings, k); + return obj; + } + }; + XcodeBuildSpecsReader.prototype.expandedSetting = function (typeIdentifier, baseSettings, + settingName) { + var obj = baseSettings || {}; + obj = _assign(obj, this.settings(typeIdentifier, true)); + if (obj) { + for (var x in this._additionalSettings) { + var additionalSetting = this._additionalSettings[x]; + if (additionalSetting !== undefined) + obj[x] = additionalSetting; + } + var setting = obj[settingName]; + var original; + while (original !== setting) { + original = setting; + setting = DarwinTools.expandPlistEnvironmentVariables({ key: setting }, obj, false)["key"]; + } + return setting; + } + }; + return XcodeBuildSpecsReader; +}()); diff --git a/share/qbs/modules/capnproto/capnproto.js b/share/qbs/modules/capnproto/capnproto.js new file mode 100644 index 00000000..64464f42 --- /dev/null +++ b/share/qbs/modules/capnproto/capnproto.js @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Utilities = require("qbs.Utilities"); + +function validateCompiler(name, path) { + if (!File.exists(path)) + throw "Cannot find executable '" + name + "'. Please set the compilerPath " + + "property or make sure the compiler is found in PATH"; +} + +function validatePlugin(name, path) { + if (!name) + throw "pluginName is not set"; + if (!File.exists(path)) + throw "Cannot find plugin '" + name + "'. Please set the pluginPath " + + "property or make sure the plugin is found in PATH"; +} + +function getOutputDir(module, input) { + var outputDir = module.outputDir; + var importPaths = module.importPaths; + if (importPaths.length !== 0) { + var canonicalInput = File.canonicalFilePath(FileInfo.path(input.filePath)); + for (var i = 0; i < importPaths.length; ++i) { + var path = File.canonicalFilePath(importPaths[i]); + + if (canonicalInput.startsWith(path)) { + return outputDir + "/" + FileInfo.relativePath(path, canonicalInput); + } + } + } + return outputDir; +} + +function artifact(outputDir, input, tag, suffix) { + return { + fileTags: [tag], + filePath: FileInfo.joinPaths(outputDir, FileInfo.baseName(input.fileName) + suffix), + cpp: { + includePaths: [].concat(input.cpp.includePaths, outputDir), + warningLevel: "none", + } + }; +} + +function doPrepare(module, product, input, outputs, lang) +{ + var outputDir = FileInfo.path(outputs["cpp"][0].filePath); + + var args = []; + args.push("--output=" + module.pluginPath + ":" + outputDir); + args.push("--src-prefix=" + FileInfo.path(input.filePath)); + + var importPaths = module.importPaths; + importPaths.forEach(function(path) { + if (!FileInfo.isAbsolutePath(path)) + path = FileInfo.joinPaths(product.sourceDirectory, path); + args.push("--import-path", path); + }); + + args.push(input.filePath); + + var cmd = new Command(module.compilerPath, args); + cmd.highlight = "codegen"; + cmd.description = "generating " + lang + " files for " + input.fileName; + return [cmd]; +} diff --git a/share/qbs/modules/capnproto/capnprotobase.qbs b/share/qbs/modules/capnproto/capnprotobase.qbs new file mode 100644 index 00000000..e84d3943 --- /dev/null +++ b/share/qbs/modules/capnproto/capnprotobase.qbs @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Probes +import "capnproto.js" as HelperFunctions + +Module { + property string compilerName: "capnpc" + property string compilerPath: compilerProbe.filePath + + property string pluginName + property string pluginPath: pluginProbe.filePath + + property pathList importPaths: [] + + readonly property string outputDir: product.buildDirectory + "/capnp" + + Probes.BinaryProbe { + id: compilerProbe + names: compilerName ? [compilerName] : [] + } + + Probes.BinaryProbe { + id: pluginProbe + names: pluginName ? [pluginName] : [] + } + + FileTagger { + patterns: ["*.capnp"] + fileTags: ["capnproto.input"]; + } + + validate: { + HelperFunctions.validateCompiler(compilerName, compilerPath); + HelperFunctions.validatePlugin(pluginName, pluginPath); + } +} diff --git a/share/qbs/modules/capnproto/cpp/capnprotocpp.qbs b/share/qbs/modules/capnproto/cpp/capnprotocpp.qbs new file mode 100644 index 00000000..f33bc9a4 --- /dev/null +++ b/share/qbs/modules/capnproto/cpp/capnprotocpp.qbs @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import "../capnprotobase.qbs" as CapnProtoBase +import "../capnproto.js" as HelperFunctions + +CapnProtoBase { + property bool useRpc: false + + Depends { name: "cpp" } + Depends { name: "capnp" } + Depends { name: "capnp-rpc"; condition: useRpc } + + pluginName: "capnpc-c++" + + cpp.systemIncludePaths: outputDir + cpp.cxxLanguageVersion: "c++14" + + Rule { + inputs: ["capnproto.input"] + outputFileTags: ["hpp", "cpp"] + outputArtifacts: { + var outputDir = HelperFunctions.getOutputDir(input.capnproto.cpp, input); + var result = [ + HelperFunctions.artifact(outputDir, input, "hpp", ".capnp.h"), + HelperFunctions.artifact(outputDir, input, "cpp", ".capnp.c++") + ]; + return result; + } + + prepare: { + var result = HelperFunctions.doPrepare( + input.capnproto.cpp, product, input, outputs, "cpp"); + return result; + } + } +} diff --git a/share/qbs/modules/cli/CLIModule.qbs b/share/qbs/modules/cli/CLIModule.qbs new file mode 100644 index 00000000..df58942b --- /dev/null +++ b/share/qbs/modules/cli/CLIModule.qbs @@ -0,0 +1,190 @@ +// base for Common Language Infrastructure modules +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import "cli.js" as CLI + +Module { + Depends { name: "bundle"; condition: qbs.targetOS.contains("darwin") } + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } + + condition: false + + property string warningLevel: 'all' // 'none', 'all' + property bool treatWarningsAsErrors: false + property string architecture: "anycpu" // for the CLI this is a much better default than qbs.architecture + property string optimization: qbs.optimization + property bool debugInformation: qbs.debugInformation + property stringList defines + property stringList platformDefines: qbs.enableDebugCode ? [] : ["NDEBUG"] + property stringList compilerDefines + PropertyOptions { + name: "compilerDefines" + description: "preprocessor macros that are defined when using this particular compiler" + } + + property pathList libraryPaths + property string csharpCompilerName + property string csharpCompilerPath: FileInfo.joinPaths(toolchainInstallPath, csharpCompilerName) + property string vbCompilerName + property string vbCompilerPath: FileInfo.joinPaths(toolchainInstallPath, vbCompilerName) + property string fsharpCompilerName + property string fsharpCompilerPath: FileInfo.joinPaths(toolchainInstallPath, fsharpCompilerName) + property string resgenName: "resgen" + property string resgenPath: FileInfo.joinPaths(toolchainInstallPath, resgenName) + property string dynamicLibrarySuffix: ".dll" + property string executableSuffix: ".exe" + property string netmoduleSuffix: ".netmodule" + property string debugInfoSuffix + property stringList dynamicLibraries // list of names, will be linked with /reference:name + property stringList netmodules // list of netmodule files, will be linked with /addmodule:name + + property bool generateManifestFile: true + + property string toolchainInstallPath + + property stringList compilerFlags + PropertyOptions { + name: "compilerFlags" + description: "additional compiler flags" + } + + // Platform properties. Those are intended to be set by the toolchain setup + // and are prepended to the corresponding user properties. + property stringList platformCompilerFlags + + FileTagger { + patterns: ["*.cs", "*.CS"] + fileTags: ["cli.csharp"] + } + + FileTagger { + patterns: ["*.vb", "*.VB"] + fileTags: ["cli.vb"] + } + + FileTagger { + patterns: ["*.fs", "*.FS"] + fileTags: ["cli.fsharp"] + } + + FileTagger { + patterns: ["*.fsi", "*.FSI"] + fileTags: ["cli.fsharp_signature"] + } + + FileTagger { + patterns: ["*.resx", "*.RESX"] + fileTags: ["cli.resx"] + } + + validate: { + var validator = new ModUtils.PropertyValidator("cli"); + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + validator.validate(); + } + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), + Host.os().contains("windows")); + v.prepend(product.cli.toolchainInstallPath); + v.set(); + } + + Rule { + id: cliApplication + multiplex: true + inputs: ["cli.csharp", "cli.vb", "cli.fsharp"] + inputsFromDependencies: ["cli.netmodule", "dynamiclibrary", "cli.resources"] + + Artifact { + fileTags: ["application"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "executableSuffix")) + } + + Artifact { + fileTags: ["debuginfo_app"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "debugInfoSuffix")) + } + + prepare: CLI.prepareCompiler(product, inputs, outputs.application[0]) + } + + Rule { + id: cliDynamicLibrary + multiplex: true + inputs: ["cli.csharp", "cli.vb", "cli.fsharp"] + inputsFromDependencies: ["cli.netmodule", "dynamiclibrary", "cli.resources"] + + Artifact { + fileTags: ["dynamiclibrary"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "dynamicLibrarySuffix")) + } + + Artifact { + fileTags: ["debuginfo_dll"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "debugInfoSuffix")) + } + + prepare: CLI.prepareCompiler(product, inputs, outputs.dynamiclibrary[0]) + } + + Rule { + id: netmodule + multiplex: true + inputs: ["cli.csharp", "cli.vb", "cli.fsharp"] + inputsFromDependencies: ["cli.netmodule", "dynamiclibrary", "cli.resources"] + + Artifact { + fileTags: ["cli.netmodule"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "netmoduleSuffix")) + } + + Artifact { + fileTags: ["debuginfo_netmodule"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + product.moduleProperty(product.moduleName, + "debugInfoSuffix")) + } + + prepare: CLI.prepareCompiler(product, inputs, outputs["cli.netmodule"][0]) + } + + Rule { + inputs: ["cli.resx"] + + Artifact { + fileTags: ["cli.resources"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + input.completeBaseName + ".resources") + } + + prepare: { + var args = [ input.filePath, output.filePath ]; + var cmd = new Command(ModUtils.moduleProperty(product, "resgenPath"), args); + cmd.description = "building " + input.fileName; + cmd.highlight = "compiler"; + cmd.workingDirectory = FileInfo.path(output.filePath); + return cmd; + } + } +} diff --git a/share/qbs/modules/cli/cli.js b/share/qbs/modules/cli/cli.js new file mode 100644 index 00000000..38833ac5 --- /dev/null +++ b/share/qbs/modules/cli/cli.js @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); + +function prepareCompiler(product, inputs, output) { + var i; + var args = ["/nologo"]; + + var platformDefines = product.moduleProperty("cli", "platformDefines"); + var compilerDefines = product.moduleProperty("cli", "compilerDefines"); + var defines = product.moduleProperty("cli", "defines"); + var platformCompilerFlags = product.moduleProperty("cli", "platformCompilerFlags"); + var compilerFlags = product.moduleProperty("cli", "compilerFlags") + var libraryPaths = product.moduleProperty("cli", "libraryPaths"); + var dynamicLibraries = product.moduleProperty("cli", "dynamicLibraries"); + var netmodules = product.moduleProperty("cli", "netmodules"); + var warnAsError = product.moduleProperty("cli", "treatWarningsAsErrors"); + var warningLevel = product.moduleProperty("cli", "warningLevel"); + var debugInformation = product.moduleProperty("cli", "debugInformation"); + var optimization = product.moduleProperty("cli", "optimization"); + var architecture = product.moduleProperty("cli", "architecture"); + + var csharpCompilerPath = product.moduleProperty("cli", "csharpCompilerPath"); + var vbCompilerPath = product.moduleProperty("cli", "vbCompilerPath"); + var fsharpCompilerPath = product.moduleProperty("cli", "fsharpCompilerPath"); + + var compilers = { + "cli.csharp": csharpCompilerPath, + "cli.vb": vbCompilerPath, + "cli.fsharp": fsharpCompilerPath + }; + + var pathFunction = product.moduleProperty("qbs", "hostOS").contains("windows") + ? FileInfo.toWindowsSeparators + : function (path) { return path; }; + + var outputDescription = "assembly"; + if (output.fileTags.contains("application")) { + args.push("/target:" + (product.consoleApplication === false ? "winexe" : "exe")); + } else if (output.fileTags.contains("dynamiclibrary")) { + args.push("/target:library"); + } else if (output.fileTags.contains("cli.netmodule")) { + args.push("/target:module"); + outputDescription = "netmodule"; + } + + // Make sure our input files are all the same language + var keys = Object.keys(inputs); + var language; + for (i in keys) { + if (Object.keys(compilers).contains(keys[i])) { + if (language) + throw("You cannot compile source files in more than one CLI language into a single " + outputDescription + "."); + language = keys[i]; + } + } + + if (!compilers[language]) { + throw("No CLI compiler available to compile " + language + " files."); + } + + // docs state "/platform is not available in the development environment in Visual C# Express" + // does this mean from the IDE or the compiler itself shipped with Express does not support it? + if (architecture !== undefined) { + if (architecture === "x86" || + architecture === "anycpu" || + architecture === "anycpu32bitpreferred") // requires .NET 4.5 + ; + else if (architecture === "x86_64") + architecture = "x64"; + else if (architecture === "ia64") + architecture = "Itanium"; + else if (architecture === "arm") + architecture = "ARM"; + else + throw("Invalid CLI architecture: " + architecture); + + args.push("/platform:" + architecture); + } + + if (debugInformation !== undefined) + args.push("/debug" + (debugInformation ? "+" : "-")); + + if (optimization !== undefined) + args.push("/optimize" + (optimization !== "none" ? "+" : "-")); + + if (warnAsError !== undefined) + args.push("/warnaserror" + (warnAsError ? "+" : "-")); + + if (warningLevel !== undefined) { + if (language === "cli.vb") { + if (warningLevel === "none" || warningLevel === "0") + args.push("/quiet"); + } else { + if (warningLevel === "all") + warningLevel = "4"; + else if (warningLevel === "none") + warningLevel = "0"; + args.push("/warn:" + warningLevel); + } + } + + // Preprocessor defines + var allDefines = (platformDefines || []).concat(compilerDefines || []).concat(defines || []); + if (allDefines.length > 0) + args.push("/define:" + allDefines.join(";")); + + // Library search paths + for (i in libraryPaths) + args.push("/lib:" + libraryPaths.join(",")); + + // Dependent libraries + for (i in dynamicLibraries) { + args.push("/reference:" + + dynamicLibraries[i] + + product.moduleProperty("cli", "dynamicLibrarySuffix")); + } + + for (i in inputs.dynamiclibrary) + args.push("/reference:" + inputs.dynamiclibrary[i].filePath); + + // Dependent netmodules + for (i in netmodules) { + args.push("/addmodule:" + netmodules.map(function (f) { + return f + product.moduleProperty("cli", "netmoduleSuffix"); + }).join(";")); + } + + if (inputs["cli.netmodule"]) { + args.push("/addmodule:" + inputs["cli.netmodule"].map(function (f) { + return f.filePath; + }).join(";")); + } + + // Dependent resources + for (i in inputs["cli.resources"]) + args.push("/resource:" + pathFunction(inputs["cli.resources"][i].filePath)); + + // Additional compiler flags + args = args.concat((platformCompilerFlags || []).concat(compilerFlags || [])); + + args.push("/out:" + pathFunction(output.filePath)); + + for (i in inputs[keys[0]]) + args.push(pathFunction(inputs[keys[0]][i].filePath)); + + var cmd = new Command(compilers[language], args); + cmd.description = "linking " + output.fileName; + cmd.highlight = "linker"; + cmd.workingDirectory = FileInfo.path(output.filePath); + return cmd; +} diff --git a/share/qbs/modules/cli/mono.qbs b/share/qbs/modules/cli/mono.qbs new file mode 100644 index 00000000..2ed65fd6 --- /dev/null +++ b/share/qbs/modules/cli/mono.qbs @@ -0,0 +1,27 @@ +import qbs.File +import qbs.Host +import qbs.Probes + +CLIModule { + condition: qbs.toolchain && qbs.toolchain.contains("mono") + + debugInfoSuffix: ".mdb" + csharpCompilerName: "mcs" + vbCompilerName: "vbnc" + fsharpCompilerName: "fsharpc" + + Probes.PathProbe { + id: monoProbe + names: ["mono"] + platformSearchPaths: { + var paths = []; + if (Host.os().contains("macos")) + paths.push("/Library/Frameworks/Mono.framework/Commands"); + if (Host.os().contains("unix")) + paths.push("/usr/bin"); + return paths; + } + } + + toolchainInstallPath: monoProbe.path +} diff --git a/share/qbs/modules/cli/windows-dotnet.qbs b/share/qbs/modules/cli/windows-dotnet.qbs new file mode 100644 index 00000000..6fde50b8 --- /dev/null +++ b/share/qbs/modules/cli/windows-dotnet.qbs @@ -0,0 +1,35 @@ +import qbs.Utilities + +CLIModule { + condition: qbs.toolchain && qbs.toolchain.contains("dotnet") + + debugInfoSuffix: ".pdb" + csharpCompilerName: "csc" + vbCompilerName: "vbc" + fsharpCompilerName: "fsc" + + Probe { + id: dotnetProbe + + property string toolchainInstallPath // Output + + configure: { + // https://msdn.microsoft.com/en-us/library/hh925568.aspx + var keys = [ + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\NET Framework Setup\\NDP", + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\NET Framework Setup\\NDP" + ]; + for (var i in keys) { + var key = keys[i] + "\\v4\\Full"; + var value = Utilities.getNativeSetting(key, "InstallPath"); + if (value) { + toolchainInstallPath = value; + found = true; + break; + } + } + } + } + + toolchainInstallPath: dotnetProbe.toolchainInstallPath +} diff --git a/share/qbs/modules/codesign/CodeSignModule.qbs b/share/qbs/modules/codesign/CodeSignModule.qbs new file mode 100644 index 00000000..6db35c85 --- /dev/null +++ b/share/qbs/modules/codesign/CodeSignModule.qbs @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import "codesign.js" as CodeSign + +Module { + condition: false + + property bool enableCodeSigning: false + + property string codesignName + property string codesignPath: codesignName + property stringList codesignFlags + + property string signingTimestamp + PropertyOptions { + name: "signingTimestamp" + description: "URL of the RFC 3161 time stamp server." + } + + property bool _canSignArtifacts: false // whether can sign individual actifacts +} diff --git a/share/qbs/modules/codesign/android.qbs b/share/qbs/modules/codesign/android.qbs new file mode 100644 index 00000000..e149e033 --- /dev/null +++ b/share/qbs/modules/codesign/android.qbs @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Raphaël Cotty +** Contact: http://www.qt.io/licensing +** +** This file is part of the Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import "codesign.js" as CodeSign + +CodeSignModule { + condition: qbs.targetOS.contains("android") + priority: 1 + enableCodeSigning: true + + property bool useApksigner: true + property path apksignerFilePath + + Probes.JdkProbe { + id: jdk + environmentPaths: (jdkPath ? [jdkPath] : []).concat(base) + } + property string jdkPath: jdk.path + property string jarsignerFilePath: FileInfo.joinPaths(jdkPath, "bin", jarsignerName) + property string jarsignerName: "jarsigner" + property string keytoolFilePath: FileInfo.joinPaths(jdkPath, "bin", keytoolName) + property string keytoolName: "keytool" + + property string debugKeystorePath: FileInfo.joinPaths( + Environment.getEnv(Host.os().contains("windows") + ? "USERPROFILE" : "HOME"), + ".android", "debug.keystore") + readonly property string debugKeystorePassword: "android" + readonly property string debugPassword: "android" + readonly property string debugKeyAlias: "androiddebugkey" + + property string keystorePath: debugKeystorePath + property string keystorePassword: debugKeystorePassword + property string keyPassword: debugPassword + property string keyAlias: debugKeyAlias + + // Private property set by the Android.sdk module + property string _packageName + + Rule { + condition: useApksigner + inputs: ["android.package_unsigned"] + Artifact { + filePath: product.codesign._packageName + fileTags: "android.package" + } + prepare: CodeSign.signApkPackage.apply(this, arguments) + } + + Rule { + condition: !useApksigner + inputs: ["android.package_unsigned"] + Artifact { + filePath: product.codesign._packageName + fileTags: "android.package" + } + prepare: CodeSign.signAabPackage.apply(this, arguments) + } + + validate: { + // Typically there is a debug keystore in ~/.android/debug.keystore which gets created + // by the native build tools the first time a build is done. However, we don't want to + // create it ourselves, because writing to a location outside the qbs build directory is + // both polluting and has the potential for race conditions. So we'll instruct the user what + // to do. + if (keystorePath === debugKeystorePath && !File.exists(debugKeystorePath)) { + throw ModUtils.ModuleError("Could not find an Android debug keystore at " + + codesign.debugKeystorePath + ". " + + "If you are developing for Android on this machine for the first time and " + + "have never built an application using the native Gradle / Android Studio " + + "tooling, this is normal. You must create the debug keystore now using the " + + "following command, in order to continue:\n\n" + + CodeSign.createDebugKeyStoreCommandString(codesign.keytoolFilePath, + codesign.debugKeystorePath, + codesign.debugKeystorePassword, + codesign.debugPassword, + codesign.debugKeyAlias) + + "\n\n" + + "See the following URL for more information: " + + "https://developer.android.com/studio/publish/app-signing.html#debug-mode"); + } + } +} diff --git a/share/qbs/modules/codesign/apple.qbs b/share/qbs/modules/codesign/apple.qbs new file mode 100644 index 00000000..05232d7c --- /dev/null +++ b/share/qbs/modules/codesign/apple.qbs @@ -0,0 +1,387 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.BundleTools +import qbs.DarwinTools +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.PropertyList +import qbs.Probes +import qbs.Utilities +import "codesign.js" as CodeSign +import "../xcode/xcode.js" as XcodeUtils + +CodeSignModule { + Depends { name: "xcode"; required: qbs.toolchain && qbs.toolchain.contains("xcode") } + + Probes.BinaryProbe { + id: codesignProbe + names: [codesignName] + } + + condition: Host.os().contains("macos") && qbs.targetOS.contains("darwin") + priority: 0 + + enableCodeSigning: _codeSigningRequired + + codesignName: "codesign" + codesignPath: codesignProbe.filePath + + _canSignArtifacts: true + + property string signingType: { + if (_adHocCodeSigningAllowed) + return "ad-hoc"; + if (_codeSigningAllowed) + return "app-store"; + } + + PropertyOptions { + name: "signingType" + allowedValues: ["app-store", "apple-id", "ad-hoc"] + } + + property string signingIdentity: { + if (signingType === "ad-hoc") // only useful on macOS + return "-"; + + var isDebug = qbs.buildVariant !== "release"; + + if (qbs.targetOS.contains("ios") || qbs.targetOS.contains("tvos") + || qbs.targetOS.contains("watchos")) { + switch (signingType) { + case "app-store": + return isDebug ? "iPhone Developer" : "iPhone Distribution"; + } + } + + if (qbs.targetOS.contains("macos")) { + switch (signingType) { + case "app-store": + return isDebug ? "Mac Developer" : "3rd Party Mac Developer Application"; + case "apple-id": + return "Developer ID Application"; + } + } + } + + signingTimestamp: "none" + + property string provisioningProfile + PropertyOptions { + name: "provisioningProfile" + description: "Name or UUID of the provisioning profile to embed in the application; " + + "typically left blank to allow automatic provisioning" + } + + property string teamIdentifier + PropertyOptions { + name: "teamIdentifier" + description: "Name or identifier of the development team whose identities will be used; " + + "typically left blank unless signed into multiple development teams" + } + + property path provisioningProfilesPath: "~/Library/MobileDevice/Provisioning Profiles" + + readonly property var _actualSigningIdentity: { + if (signingIdentity === "-") { + return { + SHA1: signingIdentity, + subjectInfo: { CN: "ad hoc" } + } + } + + var identities = CodeSign.findSigningIdentities(signingIdentity, teamIdentifier); + if (identities && Object.keys(identities).length > 1) { + throw "Multiple codesigning identities (i.e. certificate and private key pairs) " + + "matching '" + signingIdentity + "' were found." + + CodeSign.humanReadableIdentitySummary(identities); + } + + for (var i in identities) + return identities[i]; + } + + // Allowed for macOS + readonly property bool _adHocCodeSigningAllowed: + XcodeUtils.boolFromSdkOrPlatform("AD_HOC_CODE_SIGNING_ALLOWED", + xcode._sdkProps, xcode._platformProps, true) + + // Allowed for all device platforms (not simulators) + readonly property bool _codeSigningAllowed: + XcodeUtils.boolFromSdkOrPlatform("CODE_SIGNING_ALLOWED", + xcode._sdkProps, xcode._platformProps, true) + + // Required for tvOS, iOS, and watchOS (not simulators) + property bool _codeSigningRequired: { + // allow to override value from Xcode so tests do not require signing + var envRequired = Environment.getEnv("QBS_AUTOTEST_CODE_SIGNING_REQUIRED"); + if (envRequired) + return envRequired === "1"; + return XcodeUtils.boolFromSdkOrPlatform("CODE_SIGNING_REQUIRED", + xcode._sdkProps, xcode._platformProps, false) + } + + // Required for tvOS, iOS, and watchOS (not simulators) + readonly property bool _entitlementsRequired: + XcodeUtils.boolFromSdkOrPlatform("ENTITLEMENTS_REQUIRED", + xcode._sdkProps, xcode._platformProps, false) + + readonly property bool _provisioningProfileAllowed: + product.bundle + && product.bundle.isBundle + && product.type.contains("application") + && xcode.platformType !== "simulator" + + // Required for tvOS, iOS, and watchOS (not simulators) + // PROVISIONING_PROFILE_REQUIRED is specified only in Embedded-Device.xcspec in the + // IDEiOSSupportCore IDE plugin, so we'll just write out the logic here manually + readonly property bool _provisioningProfileRequired: + _provisioningProfileAllowed && !qbs.targetOS.contains("macos") + + // Not used on simulator platforms either but provisioning profiles aren't used there anyways + readonly property string _provisioningProfilePlatform: { + if (qbs.targetOS.contains("macos")) + return "OSX"; + if (qbs.targetOS.contains("ios") || qbs.targetOS.contains("watchos")) + return "iOS"; + if (qbs.targetOS.contains("tvos")) + return "tvOS"; + } + + readonly property string _embeddedProfileName: + (xcode._platformProps || {})["EMBEDDED_PROFILE_NAME"] + + setupBuildEnvironment: { + var prefixes = product.xcode ? [ + product.xcode.platformPath + "/Developer", + product.xcode.toolchainPath, + product.xcode.developerPath + ] : []; + for (var i = 0; i < prefixes.length; ++i) { + var codesign_allocate = prefixes[i] + "/usr/bin/codesign_allocate"; + if (File.exists(codesign_allocate)) { + var v = new ModUtils.EnvironmentVariable("CODESIGN_ALLOCATE"); + v.value = codesign_allocate; + v.set(); + break; + } + } + } + + Group { + name: "Provisioning Profiles" + prefix: codesign.provisioningProfilesPath + "/" + files: ["*.mobileprovision", "*.provisionprofile"] + } + + FileTagger { + fileTags: ["codesign.entitlements"] + patterns: ["*.entitlements"] + } + + FileTagger { + fileTags: ["codesign.provisioningprofile"] + patterns: ["*.mobileprovision", "*.provisionprofile"] + } + + Rule { + multiplex: true + condition: product.codesign.enableCodeSigning && + product.codesign._provisioningProfileAllowed + inputs: ["codesign.provisioningprofile"] + + outputFileTags: ["codesign.embedded_provisioningprofile"] + outputArtifacts: { + var artifacts = []; + var provisioningProfiles = (inputs["codesign.provisioningprofile"] || []) + .map(function (a) { return a.filePath; }); + var bestProfile = CodeSign.findBestProvisioningProfile(product, provisioningProfiles); + var uuid = product.provisioningProfile; + if (bestProfile) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.codesign._embeddedProfileName), + fileTags: ["codesign.embedded_provisioningprofile"], + codesign: { + _provisioningProfileFilePath: bestProfile.filePath, + _provisioningProfileData: JSON.stringify(bestProfile.data), + } + }); + } else if (uuid) { + throw "Your build settings specify a provisioning profile with the UUID '" + + uuid + "', however, no such provisioning profile was found."; + } else if (product._provisioningProfileRequired) { + var hasProfiles = !!((inputs["codesign.provisioningprofile"] || []).length); + var teamIdentifier = product.teamIdentifier; + var codeSignIdentity = product.signingIdentity; + if (hasProfiles) { + if (codeSignIdentity) { + console.warn("No provisioning profiles matching the bundle identifier '" + + product.bundle.identifier + + "' were found."); + } else { + console.warn("No provisioning profiles matching an applicable signing " + + "identity were found."); + } + } else { + if (codeSignIdentity) { + if (teamIdentifier) { + console.warn("No provisioning profiles with a valid signing identity " + + "(i.e. certificate and private key pair) matching the " + + "team ID '" + teamIdentifier + "' were found.") + } else { + console.warn("No provisioning profiles with a valid signing identity " + + "(i.e. certificate and private key pair) were found."); + } + } else { + console.warn("No non-expired provisioning profiles were found."); + } + } + } + return artifacts; + } + + prepare: { + var cmd = new JavaScriptCommand(); + var data = JSON.parse(output.codesign._provisioningProfileData); + cmd.source = output.codesign._provisioningProfileFilePath; + cmd.destination = output.filePath; + cmd.description = "using provisioning profile " + data.Name + " (" + data.UUID + ")"; + cmd.highlight = "filegen"; + cmd.sourceCode = function() { + File.copy(source, destination); + }; + return [cmd]; + } + } + + Rule { + multiplex: true + condition: product.codesign.enableCodeSigning + inputs: ["codesign.entitlements", "codesign.embedded_provisioningprofile"] + + Artifact { + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + ".xcent") + fileTags: ["codesign.xcent"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating entitlements"; + cmd.highlight = "codegen"; + cmd.bundleIdentifier = product.bundle.identifier; + cmd.signingEntitlements = (inputs["codesign.entitlements"] || []) + .map(function (a) { return a.filePath; }); + cmd.provisioningProfiles = (inputs["codesign.embedded_provisioningprofile"] || []) + .map(function (a) { return a.filePath; }); + cmd.platformPath = product.xcode ? product.xcode.platformPath : undefined; + cmd.sdkPath = product.xcode ? product.xcode.sdkPath : undefined; + cmd.sourceCode = function() { + var i; + var provData = {}; + var provisionProfiles = inputs["codesign.embedded_provisioningprofile"]; + for (i in provisionProfiles) { + var plist = new PropertyList(); + try { + plist.readFromData(Utilities.smimeMessageContent( + provisionProfiles[i].filePath)); + provData = plist.toObject(); + } finally { + plist.clear(); + } + } + + var aggregateEntitlements = {}; + + // Start building up an aggregate entitlements plist from the files in the SDKs, + // which contain placeholders in the same manner as Info.plist + function entitlementsFileContents(path) { + return File.exists(path) ? BundleTools.infoPlistContents(path) : undefined; + } + var entitlementsSources = []; + if (platformPath) { + entitlementsSources.push( + entitlementsFileContents( + FileInfo.joinPaths(platformPath, "Entitlements.plist"))); + } + if (sdkPath) { + entitlementsSources.push( + entitlementsFileContents( + FileInfo.joinPaths(sdkPath, "Entitlements.plist"))); + } + + for (i = 0; i < signingEntitlements.length; ++i) { + entitlementsSources.push(entitlementsFileContents(signingEntitlements[i])); + } + + for (i = 0; i < entitlementsSources.length; ++i) { + var contents = entitlementsSources[i]; + for (var key in contents) { + if (contents.hasOwnProperty(key)) + aggregateEntitlements[key] = contents[key]; + } + } + + contents = provData["Entitlements"]; + for (key in contents) { + if (contents.hasOwnProperty(key) && !aggregateEntitlements.hasOwnProperty(key)) + aggregateEntitlements[key] = contents[key]; + } + + // Expand entitlements variables with data from the provisioning profile + var env = { + "AppIdentifierPrefix": (provData["ApplicationIdentifierPrefix"] || "") + ".", + "CFBundleIdentifier": bundleIdentifier + }; + DarwinTools.expandPlistEnvironmentVariables(aggregateEntitlements, env, true); + + // Anything with an undefined or otherwise empty value should be removed + // Only JSON-formatted plists can have null values, other formats error out + // This also follows Xcode behavior + DarwinTools.cleanPropertyList(aggregateEntitlements); + + var plist = new PropertyList(); + try { + plist.readFromObject(aggregateEntitlements); + plist.writeToFile(outputs["codesign.xcent"][0].filePath, "xml1"); + } finally { + plist.clear(); + } + }; + return [cmd]; + } + } +} diff --git a/share/qbs/modules/codesign/codesign.js b/share/qbs/modules/codesign/codesign.js new file mode 100644 index 00000000..463e7cbb --- /dev/null +++ b/share/qbs/modules/codesign/codesign.js @@ -0,0 +1,473 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var PathTools = require("qbs.PathTools"); +var Process = require("qbs.Process"); +var PropertyList = require("qbs.PropertyList"); +var Utilities = require("qbs.Utilities"); + +function findSigningIdentities(searchString, team) { + if (!searchString) + return {}; + var identities = Utilities.signingIdentities(); + var matchedIdentities = {}; + for (var key in identities) { + var identity = identities[key]; + if (team && ![identity.subjectInfo.O, identity.subjectInfo.OU].contains(team)) + continue; + if (searchString === key || identity.subjectInfo.CN.startsWith(searchString)) + matchedIdentities[key] = identity; + } + return matchedIdentities; +} + +function humanReadableIdentitySummary(identities) { + return "\n\t" + Object.keys(identities).map(function (key) { + return identities[key].subjectInfo.CN + + " in team " + + identities[key].subjectInfo.O + + " (" + identities[key].subjectInfo.OU + ")"; + }).join("\n\t"); +} + +/** + * Returns the best provisioning profile for code signing a binary with the given parameters. + * Ideally, this should behave identically as Xcode but the algorithm is not documented + * \l{https://developer.apple.com/library/ios/qa/qa1814/_index.html}{Automatic Provisioning} + */ +function findBestProvisioningProfile(product, files) { + var actualSigningIdentity = product.codesign._actualSigningIdentity || {}; + var teamIdentifier = product.codesign.teamIdentifier; + var bundleIdentifier = product.bundle.identifier; + var targetOS = product.qbs.targetOS; + var buildVariant = product.qbs.buildVariant; + var query = product.codesign.provisioningProfile; + var profilePlatform = product.codesign._provisioningProfilePlatform; + + // Read all provisioning profiles on disk into plist objects in memory + var profiles = files.map(function(filePath) { + var plist = new PropertyList(); + try { + plist.readFromData(Utilities.smimeMessageContent(filePath)); + return { + data: plist.toObject(), + filePath: filePath + }; + } finally { + plist.clear(); + } + }); + + // Do a simple search by matching UUID or Name + if (query) { + for (var i = 0; i < profiles.length; ++i) { + var obj = profiles[i]; + if (obj.data && (obj.data.UUID === query || obj.data.Name === query)) + return obj; + } + + // If we asked for a specific provisioning profile, don't select one automatically + return undefined; + } + + // Provisioning profiles are not normally used with ad-hoc code signing or non-apps + // We do these checks down here only for the automatic selection but not above because + // if the user explicitly selects a provisioning profile it should be used no matter what + if (actualSigningIdentity.SHA1 === "-" || !product.type.contains("application")) + return undefined; + + // Filter out any provisioning profiles we know to be unsuitable from the start + profiles = profiles.filter(function (profile) { + var data = profile.data; + + if (actualSigningIdentity.subjectInfo) { + var certCommonNames = (data["DeveloperCertificates"] || []).map(function (cert) { + return Utilities.certificateInfo(cert).subjectInfo.CN; + }); + if (!certCommonNames.contains(actualSigningIdentity.subjectInfo.CN)) { + console.log("Skipping provisioning profile with no matching certificate names for '" + + actualSigningIdentity.subjectInfo.CN + + "' (found " + certCommonNames.join(", ") + "): " + + profile.filePath); + return false; + } + } + + var platforms = data["Platform"] || []; + if (platforms.length > 0 && profilePlatform && !platforms.contains(profilePlatform)) { + console.log("Skipping provisioning profile for platform " + platforms.join(", ") + + " (current platform " + profilePlatform + ")" + + ": " + profile.filePath); + return false; + } + + if (teamIdentifier + && !data["TeamIdentifier"].contains(teamIdentifier) + && data["TeamName"] !== teamIdentifier) { + console.log("Skipping provisioning profile for team " + data["TeamIdentifier"] + + " (" + data["TeamName"] + ") (current team " + teamIdentifier + ")" + + ": " + profile.filePath); + return false; + } + + if (Date.parse(data["ExpirationDate"]) <= Date.now()) { + console.log("Skipping expired provisioning profile: " + profile.filePath); + return false; + } + + // Filter development vs distribution profiles; + // though the certificate common names check should have been sufficient + var isDebug = buildVariant === "debug"; + if (data["Entitlements"]["get-task-allow"] !== isDebug) { + console.log("Skipping provisioning profile for wrong debug mode: " + profile.filePath); + return false; + } + + var prefix = data["ApplicationIdentifierPrefix"]; + var fullAppId = data["Entitlements"]["application-identifier"]; + if ([prefix, bundleIdentifier].join(".") !== fullAppId + && [prefix, "*"].join(".") !== fullAppId) { + console.log("Skipping provisioning profile not matching full (" + + [prefix, bundleIdentifier].join(".") + ") or wildcard (" + + [prefix, "*"].join(".") + ") app ID (found " + fullAppId + "): " + + profile.filePath); + return false; + } + + return true; + }); + + // Sort by expiration date - sooner expiration dates come last + profiles.sort(function(profileA, profileB) { + var expA = Date.parse(profileA.data["ExpirationDate"]); + var expB = Date.parse(profileB.data["ExpirationDate"]); + if (expA < expB) + return -1; + if (expA > expB) + return 1; + return 0; + }); + + // Sort by application identifier - wildcard profiles come last + profiles.sort(function(profileA, profileB) { + var idA = profileA.data["Entitlements"]["application-identifier"]; + var idB = profileB.data["Entitlements"]["application-identifier"]; + if (!idA.endsWith(".*") && idB.endsWith(".*")) + return -1; + if (idA.endsWith(".*") && !idB.endsWith(".*")) + return 1; + return 0; + }); + + if (profiles.length) { + console.log("Automatic provisioning using profile " + + profiles[0].data.UUID + + " (" + + profiles[0].data.TeamName + + " - " + + profiles[0].data.Name + + ") in product " + + product.name); + return profiles[0]; + } +} + +/** + * Finds out the search paths for the `signtool.exe` utility supplied with + * the Windows SDK's. + */ +function findBestSignToolSearchPaths(arch) { + var searchPaths = []; + var keys = [ + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows", + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows" + ]; + for (var keyIndex = 0; keyIndex < keys.length; ++keyIndex) { + var re = /^v([0-9]+)\.([0-9]+)$/; + var groups = Utilities.nativeSettingGroups(keys[keyIndex]).filter(function(version) { + return version.match(re); + }); + + groups.sort(function(a, b) { + return Utilities.versionCompare(b.substring(1), a.substring(1)); + }); + + function addSearchPath(searchPath) { + if (File.exists(searchPath) && !searchPaths.contains(searchPath)) { + searchPaths.push(searchPath); + return true; + } + return false; + } + + for (var groupIndex = 0; groupIndex < groups.length; ++groupIndex) { + var fullKey = keys[keyIndex] + "\\" + groups[groupIndex]; + var fullVersion = Utilities.getNativeSetting(fullKey, "ProductVersion"); + if (fullVersion) { + var installRoot = FileInfo.cleanPath( + Utilities.getNativeSetting(fullKey, "InstallationFolder")); + if (installRoot) { + // Try to add the architecture-independent path at first. + var searchPath = FileInfo.joinPaths(installRoot, "App Certification Kit"); + if (!addSearchPath(searchPath)) { + // Try to add the architecture-dependent paths at second. + var binSearchPath = FileInfo.joinPaths(installRoot, "bin/" + fullVersion); + if (!File.exists(binSearchPath)) { + binSearchPath += ".0"; + if (!File.exists(binSearchPath)) + continue; + } + + function kitsArchitectureSubDirectory(arch) { + if (arch === "x86") + return "x86"; + else if (arch === "x86_64") + return "x64"; + else if (arch.startsWith("arm64")) + return "arm64"; + else if (arch.startsWith("arm")) + return "arm"; + } + + var archDir = kitsArchitectureSubDirectory(arch); + searchPath = FileInfo.joinPaths(binSearchPath, archDir); + addSearchPath(searchPath); + } + } + } + } + } + + return searchPaths; +} + +function prepareSign(project, product, inputs, outputs, input, output) { + var cmd, cmds = []; + + if (!product.codesign.enableCodeSigning) + return cmds; + + var isBundle = "bundle.content" in outputs; + var outputFilePath = isBundle + ? FileInfo.joinPaths(product.destinationDirectory, product.bundle.bundleName) + : outputs["codesign.signed_artifact"][0].filePath; + var outputFileName = isBundle + ? product.bundle.bundleName + : outputs["codesign.signed_artifact"][0].fileName; + var isProductBundle = product.bundle && product.bundle.isBundle; + + // If the product is a bundle, just sign the bundle + // instead of signing the bundle and executable separately + var shouldSignArtifact = !isProductBundle || isBundle; + + var enableCodeSigning = product.codesign.enableCodeSigning; + if (enableCodeSigning && shouldSignArtifact) { + var actualSigningIdentity = product.codesign._actualSigningIdentity; + if (!actualSigningIdentity) { + throw "No codesigning identities (i.e. certificate and private key pairs) matching “" + + product.codesign.signingIdentity + "” were found."; + } + + // If this is a framework, we need to sign its versioned directory + var subpath = ""; + if (isBundle) { + var isFramework = product.bundle.packageType === "FMWK"; + if (isFramework) { + subpath = product.bundle.contentsFolderPath; + subpath = subpath.substring(product.bundle.bundleName.length); + } + } + + var args = ["--force", "--sign", actualSigningIdentity.SHA1]; + + // If signingTimestamp is undefined or empty, do not specify the flag at all - + // this uses the system-specific default behavior + var signingTimestamp = product.codesign.signingTimestamp; + if (signingTimestamp) { + // If signingTimestamp is an empty string, specify the flag but do + // not specify a value - this uses a default Apple-provided server + var flag = "--timestamp"; + if (signingTimestamp) + flag += "=" + signingTimestamp; + args.push(flag); + } + + for (var j in inputs["codesign.xcent"]) { + args.push("--entitlements", inputs["codesign.xcent"][j].filePath); + break; // there should only be one + } + + args = args.concat(product.codesign.codesignFlags || []); + + args.push(outputFilePath + subpath); + cmd = new Command(product.codesign.codesignPath, args); + cmd.description = "codesign " + outputFileName + + " (" + actualSigningIdentity.subjectInfo.CN + ")"; + cmd.outputFilePath = outputFilePath; + cmd.stderrFilterFunction = function(stderr) { + return stderr.replace(outputFilePath + ": replacing existing signature\n", ""); + }; + cmds.push(cmd); + } + + if (isBundle) { + cmd = new Command("touch", ["-c", outputFilePath]); + cmd.silent = true; + cmds.push(cmd); + } + + return cmds; +} + +function signApkPackage(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var apkInput = inputs["android.package_unsigned"][0]; + var apkOutput = outputs["android.package"][0]; + var cmd; + if (product.codesign.enableCodeSigning) { + var args = ["sign", + "--ks", product.codesign.keystorePath, + "--ks-pass", "pass:" + product.codesign.keystorePassword, + "--ks-key-alias", product.codesign.keyAlias, + "--key-pass", "pass:" + product.codesign.keyPassword, + "--out", apkOutput.filePath, + apkInput.filePath]; + cmd = new Command(product.codesign.apksignerFilePath, args); + cmd.description = "signing " + apkOutput.fileName; + } else { + cmd = new JavaScriptCommand(); + cmd.description = "copying without signing " + apkOutput.fileName; + cmd.source = apkInput.filePath; + cmd.target = apkOutput.filePath; + cmd.silent = true; + cmd.sourceCode = function() { + // If enableCodeSigning is changed to false without any change to unsigned package then + // the copy won't happen because of timestamps. So the target file needs file needs to + // be removed to avoid it. + File.remove(target); + File.copy(source, target); + } + } + return cmd; +} + +function signAabPackage(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var aabInput = inputs["android.package_unsigned"][0]; + var aabOutput = outputs["android.package"][0]; + var cmd; + if (product.codesign.enableCodeSigning) { + args = ["-sigalg", "SHA1withRSA", "-digestalg", "SHA1", + "-keystore", product.codesign.keystorePath, + "-storepass", product.codesign.keystorePassword, + "-keypass", product.codesign.keyPassword, + "-signedjar", aabOutput.filePath, + aabInput.filePath, + product.codesign.keyAlias]; + cmd = new Command(product.codesign.jarsignerFilePath, args); + cmd.description = "signing " + aabOutput.fileName; + } else { + cmd = new JavaScriptCommand(); + cmd.description = "copying without signing " + aabOutput.fileName; + cmd.source = aabInput.filePath; + cmd.target = aabOutput.filePath; + cmd.silent = true; + cmd.sourceCode = function() { + // If enableCodeSigning is changed to false without any change to unsigned package then + // the copy won't happen because of timestamps. So the target file needs file needs to + // be removed to avoid it. + File.remove(target); + File.copy(source, target); + } + } + return cmd; +} + +function createDebugKeyStoreCommandString(keytoolFilePath, keystoreFilePath, keystorePassword, + keyPassword, keyAlias) { + var args = ["-genkey", "-keystore", keystoreFilePath, "-alias", keyAlias, + "-storepass", keystorePassword, "-keypass", keyPassword, "-keyalg", "RSA", + "-keysize", "2048", "-validity", "10000", "-dname", + "CN=Android Debug,O=Android,C=US"]; + return Process.shellQuote(keytoolFilePath, args); +} + +function prepareSigntool(project, product, inputs, outputs, input, output) { + var cmd, cmds = []; + + if (!product.codesign.enableCodeSigning) + return cmds; + + var args = ["sign"]; + + var subjectName = product.codesign.subjectName; + if (subjectName) + args.push("/n", subjectName); + + var rootSubjectName = product.codesign.rootSubjectName; + if (rootSubjectName) + args.push("/r", rootSubjectName); + + var hashAlgorithm = product.codesign.hashAlgorithm; + if (hashAlgorithm) + args.push("/fd", hashAlgorithm); + + var signingTimestamp = product.codesign.signingTimestamp; + if (signingTimestamp) + args.push("/tr", signingTimestamp); + + var timestampAlgorithm = product.codesign.timestampAlgorithm; + if (timestampAlgorithm) + args.push("/td", timestampAlgorithm); + + var certificatePath = product.codesign.certificatePath; + if (certificatePath) + args.push("/f", certificatePath); + + var certificatePassword = product.codesign.certificatePassword; + if (certificatePassword) + args.push("/p", certificatePassword); + + var crossCertificatePath = product.codesign.crossCertificatePath; + if (crossCertificatePath) + args.push("/ac", crossCertificatePath); + + args = args.concat(product.codesign.codesignFlags || []); + + var outputArtifact = outputs["codesign.signed_artifact"][0]; + args.push(outputArtifact.filePath); + + cmd = new Command(product.codesign.codesignPath, args); + cmd.description = "signing " + outputArtifact.fileName; + cmd.highlight = "linker"; + cmds.push(cmd); + return cmds; +} diff --git a/share/qbs/modules/codesign/noop.qbs b/share/qbs/modules/codesign/noop.qbs new file mode 100644 index 00000000..d8c75eab --- /dev/null +++ b/share/qbs/modules/codesign/noop.qbs @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +CodeSignModule { + condition: true + priority: -100 +} diff --git a/share/qbs/modules/codesign/signtool.qbs b/share/qbs/modules/codesign/signtool.qbs new file mode 100644 index 00000000..0fc50f1b --- /dev/null +++ b/share/qbs/modules/codesign/signtool.qbs @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import "codesign.js" as CODESIGN + +CodeSignModule { + condition: qbs.targetOS.contains("windows") + && Host.os().contains("windows") + && qbs.toolchain.contains("msvc") + + _canSignArtifacts: true + + Probes.BinaryProbe { + id: signtoolProbe + names: [codesignName] + searchPaths: CODESIGN.findBestSignToolSearchPaths(Host.architecture()) + } + + codesignName: "signtool" + codesignPath: signtoolProbe.filePath + + property string subjectName + PropertyOptions { + name: "subjectName" + description: "Name of the subject of the signing certificate." + } + + property string rootSubjectName + PropertyOptions { + name: "rootSubjectName" + description: "Name of the subject of the root certificate that the signing " + + "certificate must chain to." + } + + property string hashAlgorithm + PropertyOptions { + name: "hashAlgorithm" + description: "Name of the hash algorithm used on the signing certificate." + allowedValues: ["sha1", "sha256", "sha384", "sha512"] + } + + property string timestampAlgorithm + PropertyOptions { + name: "timestampAlgorithm" + description: "Name of the timestamp algorithm." + allowedValues: ["sha1", "sha256"] + } + + property path certificatePath + PropertyOptions { + name: "certificatePath" + description: "Path to the signing certificate PFX file." + } + + property string certificatePassword + PropertyOptions { + name: "certificatePassword" + description: "Password to use when opening a certificate PFX file." + } + + property path crossCertificatePath + PropertyOptions { + name: "crossCertificatePath" + description: "Path to the additional certificate CER file." + } + + validate: { + if (enableCodeSigning && !File.exists(codesignPath)) { + throw ModUtils.ModuleError("Could not find 'signtool' utility"); + } + } +} diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs new file mode 100644 index 00000000..038de861 --- /dev/null +++ b/share/qbs/modules/cpp/CppModule.qbs @@ -0,0 +1,578 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +// base for Cpp modules +import qbs.Host +import qbs.ModUtils +import qbs.Utilities +import qbs.WindowsUtils +import "cpp.js" as Cpp +import "setuprunenv.js" as SetupRunEnv + +Module { + condition: false + + Depends { name: "cpufeatures" } + + version: compilerVersion + property string compilerVersion: + [compilerVersionMajor, compilerVersionMinor, compilerVersionPatch].join(".") + property int compilerVersionMajor + property int compilerVersionMinor + property int compilerVersionPatch + property string warningLevel : 'all' // 'none', 'all' + property bool treatWarningsAsErrors : false + property bool enableSuspiciousLinkerFlagWarnings: true + property string architecture: qbs.architecture + property string endianness + property string machineType // undocumented + property string imageFormat // undocumented + property string optimization: qbs.optimization + property bool debugInformation: qbs.debugInformation + property bool enableReproducibleBuilds: false + property bool separateDebugInformation: false + property pathList prefixHeaders + property bool useCPrecompiledHeader: true + property bool useCxxPrecompiledHeader: true + property bool useObjcPrecompiledHeader: true + property bool useObjcxxPrecompiledHeader: true + + property bool treatSystemHeadersAsDependencies: false + + property stringList defines + property stringList platformDefines: qbs.enableDebugCode ? [] : ["NDEBUG"] + property stringList compilerDefines: compilerDefinesByLanguage + ? ModUtils.flattenDictionary(compilerDefinesByLanguage["c"]) + : [] + property var compilerDefinesByLanguage: undefined + PropertyOptions { + name: "compilerDefinesByLanguage" + description: "preprocessor macros that are defined when using this particular compiler" + } + property stringList enableCompilerDefinesByLanguage: [] + + property string windowsApiCharacterSet + property string windowsApiFamily + property stringList windowsApiAdditionalPartitions + property bool requireAppContainer + + property string minimumWindowsVersion + PropertyOptions { + name: "minimumWindowsVersion" + description: "A version number in the format [major].[minor] indicating the earliest \ + version of Windows that the product should run on. Defines WINVER, \ + _WIN32_WINNT, and _WIN32_WINDOWS, and applies a version number to the \ + linker flags /SUBSYSTEM and /OSVERSION for MSVC or \ + --major-subsystem-version, --minor-subsystem-version, \ + --major-os-version and --minor-os-version for MinGW. \ + If undefined, compiler defaults will be used." + } + + property string minimumOsxVersion + + property string minimumMacosVersion: minimumOsxVersion + PropertyOptions { + name: "minimumMacosVersion" + description: "a version number in the format [major].[minor] indicating the earliest \ + version of macOS that the product should run on. passes -mmacosx-version-min= \ + to the compiler. if undefined, compiler defaults will be used." + } + + property string minimumIosVersion: qbs.architecture == "armv7a" ? "6.0" : undefined + PropertyOptions { + name: "minimumIosVersion" + description: "a version number in the format [major].[minor] indicating the earliest \ + version of iOS that the product should run on. passes -miphoneos-version-min= \ + to the compiler. if undefined, compiler defaults will be used." + } + + property string minimumWatchosVersion + PropertyOptions { + name: "minimumWatchosVersion" + description: "a version number in the format [major].[minor] indicating the earliest \ + version of watchOS that the product should run on. if undefined, compiler \ + defaults will be used." + } + + property string minimumTvosVersion: "6.0" + PropertyOptions { + name: "minimumTvosVersion" + description: "a version number in the format [major].[minor] indicating the earliest \ + version of tvOS that the product should run on. if undefined, compiler \ + defaults will be used." + } + + property string minimumAndroidVersion // not used, undocumented + PropertyOptions { + name: "minimumAndroidVersion" + description: "a version number in the format [major].[minor] indicating the earliest \ + version of Android that the product should run on. this value is converted into an SDK \ + version which is then written to AndroidManifest.xml." + } + + property string maximumAndroidVersion // not used, undocumented + PropertyOptions { + name: "maximumAndroidVersion" + description: "a version number in the format [major].[minor] indicating the latest \ + version of Android that the product should run on. this value is converted into an SDK \ + version which is then written to AndroidManifest.xml. if undefined, no upper limit will \ + be set." + } + + property string toolchainInstallPath + PropertyOptions { + name: "toolchainInstallPath" + description: "a path to the directory where the toolchain executable files are located." + } + + property pathList includePaths + property pathList systemIncludePaths + property pathList distributionIncludePaths + property pathList compilerIncludePaths + property pathList libraryPaths + property pathList distributionLibraryPaths + property pathList compilerLibraryPaths + property pathList frameworkPaths + property pathList systemFrameworkPaths + property pathList distributionFrameworkPaths + property pathList compilerFrameworkPaths + property stringList systemRunPaths: [] + + property string assemblerName + property string assemblerPath: assemblerName + property string compilerName + property string compilerPath: compilerName + property var compilerPathByLanguage + property stringList compilerWrapper + property string linkerName + property string linkerPath: linkerName + property stringList linkerWrapper + property string staticLibraryPrefix: "" + property string dynamicLibraryPrefix: "" + property string loadableModulePrefix: "" + property string executablePrefix: "" + property string staticLibrarySuffix: "" + property string dynamicLibrarySuffix: "" + property string archSuffix: "" + property string loadableModuleSuffix: "" + property string executableSuffix: "" + property string debugInfoSuffix: "" + property string debugInfoBundleSuffix: "" + property string variantSuffix: "" + property string dynamicLibraryImportSuffix: ".lib" + property string objectSuffix: ".o" + property string linkerMapSuffix: ".map" + property string compilerListingSuffix: ".lst" + property string assemblerListingSuffix: ".lst" + property string resourceSuffix: ".res" + property string precompiledHeaderSuffix + property bool createSymlinks: true + property stringList dynamicLibraries // list of names, will be linked with -lname + property stringList staticLibraries // list of static library files + property stringList frameworks // list of frameworks, will be linked with '-framework ' + property stringList weakFrameworks // list of weakly-linked frameworks, will be linked with '-weak_framework ' + property string rpathOrigin + property stringList rpaths + property string sonamePrefix: "" + property bool useRPaths: true + property bool useRPathLink + property string rpathLinkFlag + property bool discardUnusedData + property bool removeDuplicateLibraries: true + + property string defineFlag + property string includeFlag + property string systemIncludeFlag + property string preincludeFlag + property string libraryDependencyFlag + property string libraryPathFlag + property string linkerScriptFlag + + property stringList knownArchitectures: [] + property var toolchainDetails + property string compilerExtension: Host.os().contains("windows") ? ".exe" : "" + + property string linkerMode: "automatic" + PropertyOptions { + name: "linkerMode" + allowedValues: ["automatic", "manual"] + description: "Controls whether to automatically use an appropriate compiler frontend " + + "in place of the system linker when linking binaries. The default is \"automatic\", " + + "which chooses either the C++ compiler, C compiler, or system linker specified by " + + "the linkerName/linkerPath properties, depending on the type of object files " + + "present on the linker command line. \"manual\" allows you to explicitly specify " + + "the linker using the linkerName/linkerPath properties, and allows linker flags " + + "passed to the linkerFlags and platformLinkerFlags properties to be escaped " + + "manually (using -Wl or -Xlinker) instead of automatically based on the selected " + + "linker." + } + + property stringList assemblerFlags + PropertyOptions { + name: "assemblerFlags" + description: "additional flags for the assembler" + } + + property stringList cppFlags + PropertyOptions { + name: "cppFlags" + description: "additional flags for the C preprocessor" + } + + property stringList cFlags + PropertyOptions { + name: "cFlags" + description: "additional flags for the C compiler" + } + + property stringList cxxFlags + PropertyOptions { + name: "cxxFlags" + description: "additional flags for the C++ compiler" + } + + property stringList objcFlags + PropertyOptions { + name: "objcFlags" + description: "additional flags for the Objective-C compiler" + } + + property stringList objcxxFlags + PropertyOptions { + name: "objcxxFlags" + description: "additional flags for the Objective-C++ compiler" + } + property stringList commonCompilerFlags + PropertyOptions { + name: "commonCompilerFlags" + description: "flags added to all compilation independently of the language" + } + + property stringList linkerFlags + PropertyOptions { + name: "linkerFlags" + description: "additional linker flags" + } + + property stringList driverFlags + PropertyOptions { + name: "driverFlags" + description: "additional compiler driver flags" + } + + property stringList driverLinkerFlags + PropertyOptions { + name: "driverLinkerFlags" + description: "additional compiler driver flags used for linking only" + } + + property bool generateLinkerMapFile: false + PropertyOptions { + name: "generateLinkerMapFile" + description: "generate linker map file" + } + + property bool generateCompilerListingFiles: false + PropertyOptions { + name: "generateCompilerListingFiles" + description: "generate compiler listing files" + } + + property bool generateAssemblerListingFiles: false + PropertyOptions { + name: "generateAssemblerListingFiles" + description: "generate assembler listing files" + } + + property bool positionIndependentCode: true + PropertyOptions { + name: "positionIndependentCode" + description: "generate position independent code" + } + + property string entryPoint + PropertyOptions { + name: "entryPoint" + description: "entry point symbol for an executable or dynamic library" + } + + property string runtimeLibrary + PropertyOptions { + name: "runtimeLibrary" + description: "determine which runtime library to use" + allowedValues: ['static', 'dynamic'] + } + + property string visibility: 'default' + PropertyOptions { + name: "visibility" + description: "export symbols visibility level" + allowedValues: ['default', 'hidden', 'hiddenInlines', 'minimal'] + } + + property stringList cLanguageVersion + PropertyOptions { + name: "cLanguageVersion" + description: "The version of the C standard with which the code must comply." + } + + property stringList cxxLanguageVersion + PropertyOptions { + name: "cxxLanguageVersion" + description: "The version of the C++ standard with which the code must comply." + } + + property bool useLanguageVersionFallback + PropertyOptions { + name: "useLanguageVersionFallback" + description: "whether to explicitly use the language standard version fallback values in " + + "compiler command line invocations" + } + + property string cxxStandardLibrary + PropertyOptions { + name: "cxxStandardLibrary" + allowedValues: ["libstdc++", "libc++"] + description: "version of the C++ standard library to use" + } + + property bool enableExceptions: true + PropertyOptions { + name: "enableExceptions" + description: "enable/disable exception handling (enabled by default)" + } + + property string exceptionHandlingModel: "default" + PropertyOptions { + name: "exceptionHandlingModel" + description: "the kind of exception handling to be used by the compiler" + } + + property bool enableRtti + + // Platform properties. Those are intended to be set by the toolchain setup + // and are prepended to the corresponding user properties. + property stringList platformAssemblerFlags + property stringList platformCommonCompilerFlags + property stringList platformCFlags + property stringList platformCxxFlags + property stringList platformObjcFlags + property stringList platformObjcxxFlags + property stringList platformLinkerFlags + property stringList platformDriverFlags + + // Apple platforms properties + property bool automaticReferenceCounting + PropertyOptions { + name: "automaticReferenceCounting" + description: "whether to enable Automatic Reference Counting (ARC) for Objective-C" + } + + property bool requireAppExtensionSafeApi + PropertyOptions { + name: "requireAppExtensionSafeApi" + description: "whether to require app-extension-safe APIs only" + } + + property bool allowUnresolvedSymbols + + property bool combineCSources: false + property bool combineCxxSources: false + property bool combineObjcSources: false + property bool combineObjcxxSources: false + + // Those are set internally by different cpp module implementations + property stringList targetAssemblerFlags + property stringList targetDriverFlags + property stringList targetLinkerFlags + + property bool _skipAllChecks: false // Internal + + property bool validateTargetTriple: true // undocumented + + // TODO: The following four rules could use a convenience base item if rule properties + // were available in Artifact items and prepare scripts. + Rule { + multiplex: true + inputs: ["c.combine"] + Artifact { + filePath: "amalgamated_" + product.targetName + ".c" + fileTags: ["c"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + ModUtils.mergeCFiles(inputs["c.combine"], output.filePath); + }; + return [cmd]; + } + } + Rule { + multiplex: true + inputs: ["cpp.combine"] + Artifact { + filePath: "amalgamated_" + product.targetName + ".cpp" + fileTags: ["cpp"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + ModUtils.mergeCFiles(inputs["cpp.combine"], output.filePath); + }; + return [cmd]; + } + } + Rule { + multiplex: true + inputs: ["objc.combine"] + Artifact { + filePath: "amalgamated_" + product.targetName + ".m" + fileTags: ["objc"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + ModUtils.mergeCFiles(inputs["objc.combine"], output.filePath); + }; + return [cmd]; + } + } + Rule { + multiplex: true + inputs: ["objcpp.combine"] + Artifact { + filePath: "amalgamated_" + product.targetName + ".mm" + fileTags: ["objccpp"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + ModUtils.mergeCFiles(inputs["objcpp.combine"], output.filePath); + }; + return [cmd]; + } + } + + FileTagger { + patterns: ["*.c"] + fileTags: combineCSources ? ["c.combine"] : ["c"] + } + + FileTagger { + patterns: ["*.C", "*.cpp", "*.cxx", "*.c++", "*.cc"] + fileTags: combineCxxSources ? ["cpp.combine"] : ["cpp"] + } + + FileTagger { + patterns: ["*.m"] + fileTags: combineObjcSources ? ["objc.combine"] : ["objc"] + } + + FileTagger { + patterns: ["*.mm"] + fileTags: combineObjcxxSources ? ["objcpp.combine"] : ["objcpp"] + } + + FileTagger { + patterns: ["*.h", "*.H", "*.hpp", "*.hxx", "*.h++"] + fileTags: ["hpp"] + } + + property var validateFunc: { + return function() { + var validator = new ModUtils.PropertyValidator("cpp"); + validator.setRequiredProperty("architecture", architecture, + "you might want to re-run 'qbs-setup-toolchains'"); + validator.addCustomValidator("architecture", architecture, function (value) { + return !architecture || architecture === Utilities.canonicalArchitecture(architecture); + }, "'" + architecture + "' is invalid. You must use the canonical name '" + + Utilities.canonicalArchitecture(architecture) + "'"); + validator.setRequiredProperty("endianness", endianness); + validator.setRequiredProperty("compilerDefinesByLanguage", compilerDefinesByLanguage); + validator.setRequiredProperty("compilerVersion", compilerVersion); + validator.setRequiredProperty("compilerVersionMajor", compilerVersionMajor); + validator.setRequiredProperty("compilerVersionMinor", compilerVersionMinor); + validator.setRequiredProperty("compilerVersionPatch", compilerVersionPatch); + validator.addVersionValidator("compilerVersion", compilerVersion, 3, 3); + validator.addRangeValidator("compilerVersionMajor", compilerVersionMajor, 1); + validator.addRangeValidator("compilerVersionMinor", compilerVersionMinor, 0); + validator.addRangeValidator("compilerVersionPatch", compilerVersionPatch, 0); + if (minimumWindowsVersion) { + validator.addVersionValidator("minimumWindowsVersion", minimumWindowsVersion, 2, 2); + validator.addCustomValidator("minimumWindowsVersion", minimumWindowsVersion, function (v) { + return !v || v === WindowsUtils.canonicalizeVersion(v); + }, "'" + minimumWindowsVersion + "' is invalid. Did you mean '" + + WindowsUtils.canonicalizeVersion(minimumWindowsVersion) + "'?"); + } + validator.validate(); + + if (minimumWindowsVersion && !WindowsUtils.isValidWindowsVersion(minimumWindowsVersion)) { + console.warn("Unknown Windows version '" + minimumWindowsVersion + + "'; expected one of: " + + WindowsUtils.knownWindowsVersions().map(function (a) { + return '"' + a + '"'; }).join(", ") + + ". See https://docs.microsoft.com/en-us/windows/desktop/SysInfo/operating-system-version"); + } + + if (knownArchitectures && knownArchitectures.length > 0) { + var isSupported = Cpp.supportsArchitecture(qbs.architecture, knownArchitectures); + if (!isSupported) { + throw ModUtils.ModuleError("Unsupported architecture: '" + qbs.architecture + "'"); + } + } + } + } + + validate: { + return validateFunc(); + } + + setupRunEnvironment: { + SetupRunEnv.setupRunEnvironment(product, config); + } + + Parameter { + property bool link + } + Parameter { + property bool linkWholeArchive + } + Parameter { + property string symbolLinkMode + } +} diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs new file mode 100644 index 00000000..81d8bded --- /dev/null +++ b/share/qbs/modules/cpp/DarwinGCC.qbs @@ -0,0 +1,296 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.DarwinTools +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.PathTools +import qbs.Probes +import qbs.PropertyList +import qbs.TextFile +import qbs.Utilities +import "darwin.js" as Darwin +import "gcc.js" as Gcc + +UnixGCC { + condition: false + + Depends { name: "xcode"; required: qbs.toolchain && qbs.toolchain.contains("xcode") } + + Probes.BinaryProbe { + id: lipoProbe + condition: !_skipAllChecks + names: [lipoName] + platformSearchPaths: { + var paths = (xcode.present && xcode.devicePlatformPath) + ? [xcode.devicePlatformPath + "/Developer/usr/bin"] + : []; + return paths.concat([toolchainInstallPath, "/usr/bin"]); + } + } + + property string lipoPathPrefix: Gcc.pathPrefix(lipoProbe.found + ? lipoProbe.path + : toolchainInstallPath, toolchainPrefix) + + lipoName: "lipo" + lipoPath: lipoPathPrefix + lipoName + property bool enableAggregationRules: product.aggregate && !product.multiplexConfigurationId + + targetVendor: "apple" + targetSystem: "darwin" + targetAbi: "macho" + imageFormat: "macho" + + cxxStandardLibrary: libcxxAvailable ? "libc++" : base + loadableModulePrefix: "" + loadableModuleSuffix: ".bundle" + dynamicLibrarySuffix: ".dylib" + + Properties { + condition: product.multiplexByQbsProperties.contains("buildVariants") + && qbs.buildVariants && qbs.buildVariants.length > 1 + && (!product.aggregate || !!product.multiplexConfigurationId) + && qbs.buildVariant !== "release" + variantSuffix: "_" + qbs.buildVariant + } + + separateDebugInformation: true + debugInfoBundleSuffix: ".dSYM" + debugInfoSuffix: ".dwarf" + rpathOrigin: "@loader_path" + useRPathLink: !minimumDarwinVersion + || Utilities.versionCompare(minimumDarwinVersion, "10.5") < 0 + rpathLinkFlag: "-L" + + toolchainInstallPath: xcode.present + ? FileInfo.joinPaths(xcode.toolchainPath, "usr", "bin") : base + sysroot: xcode.present ? xcode.sdkPath : base + sysrootFlags: sysroot ? ["-isysroot", sysroot] : [] + + setupBuildEnvironment: { + for (var key in product.cpp.buildEnv) { + var v = new ModUtils.EnvironmentVariable(key); + v.value = product.cpp.buildEnv[key]; + v.set(); + } + } + + property var defaultInfoPlist: { + var dict = {}; + + if (qbs.targetOS.contains("macos")) { + dict["NSPrincipalClass"] = "NSApplication"; // needed for Retina display support + + if (minimumMacosVersion) + dict["LSMinimumSystemVersion"] = minimumMacosVersion; + } + + if (qbs.targetOS.contains("ios") && minimumIosVersion) + dict["MinimumOSVersion"] = minimumIosVersion; + else if (qbs.targetOS.contains("tvos") && minimumTvosVersion) + dict["MinimumOSVersion"] = minimumTvosVersion; + else if (qbs.targetOS.contains("watchos") && minimumWatchosVersion) + dict["MinimumOSVersion"] = minimumWatchosVersion; + + if (qbs.targetOS.containsAny(["ios", "tvos"])) { + dict["LSRequiresIPhoneOS"] = true; + + if (xcode.platformType === "device") { + if (qbs.targetOS.contains("ios")) { + if (qbs.architecture === "arm64") + dict["UIRequiredDeviceCapabilities"] = ["arm64"]; + else + dict["UIRequiredDeviceCapabilities"] = ["armv7"]; + } + + if (qbs.targetOS.contains("tvos")) + dict["UIRequiredDeviceCapabilities"] = ["arm64"]; + } + } + + if (xcode.present) { + var targetDevices = DarwinTools.targetedDeviceFamily(xcode.targetDevices); + if (qbs.targetOS.contains("ios")) + dict["UIDeviceFamily"] = targetDevices; + + if (qbs.targetOS.containsAny(["ios", "watchos"])) { + var orientations = [ + "UIInterfaceOrientationPortrait", + "UIInterfaceOrientationPortraitUpsideDown", + "UIInterfaceOrientationLandscapeLeft", + "UIInterfaceOrientationLandscapeRight" + ]; + + if (targetDevices.contains("ipad")) + dict["UISupportedInterfaceOrientations~ipad"] = orientations; + + if (targetDevices.contains("watch")) + dict["UISupportedInterfaceOrientations"] = orientations.slice(0, 2); + + if (targetDevices.contains("iphone")) { + orientations.splice(1, 1); + dict["UISupportedInterfaceOrientations"] = orientations; + } + } + } + + return dict; + } + + targetLinkerFlags: darwinArchFlags.concat(minimumDarwinVersionLinkerFlags) + + targetAssemblerFlags: !assemblerHasTargetOption ? darwinArchFlags : base; + + targetDriverFlags: !compilerHasTargetOption ? legacyTargetDriverFlags : base + + property stringList legacyTargetDriverFlags: + base.concat(darwinArchFlags).concat(minimumDarwinVersionCompilerFlags) + + // private properties + readonly property stringList darwinArchFlags: targetArch ? ["-arch", targetArch] : [] + + readonly property stringList minimumDarwinVersionCompilerFlags: + (minimumDarwinVersionCompilerFlag && minimumDarwinVersion) + ? [minimumDarwinVersionCompilerFlag + "=" + minimumDarwinVersion] : [] + + readonly property stringList minimumDarwinVersionLinkerFlags: + (minimumDarwinVersionLinkerFlag && minimumDarwinVersion && compilerVersionMajor < 11) + ? [minimumDarwinVersionLinkerFlag, minimumDarwinVersion] : [] + + readonly property var buildEnv: { + var env = { + "ARCHS_STANDARD": xcode.standardArchitectures, + "EXECUTABLE_NAME": product.targetName, + "LANG": "en_US.US-ASCII", + "PRODUCT_NAME": product.name + } + + // Set the corresponding environment variable even if the minimum OS version is undefined, + // because this indicates the default deployment target for that OS + if (qbs.targetOS.contains("ios") && minimumIosVersion) + env["IPHONEOS_DEPLOYMENT_TARGET"] = minimumIosVersion; + if (qbs.targetOS.contains("macos") && minimumMacosVersion) + env["MACOSX_DEPLOYMENT_TARGET"] = minimumMacosVersion; + if (qbs.targetOS.contains("watchos") && minimumWatchosVersion) + env["WATCHOS_DEPLOYMENT_TARGET"] = minimumWatchosVersion; + if (qbs.targetOS.contains("tvos") && minimumTvosVersion) + env["TVOS_DEPLOYMENT_TARGET"] = minimumTvosVersion; + + if (xcode.present) + env["TARGETED_DEVICE_FAMILY"] = + DarwinTools.targetedDeviceFamily(xcode.targetDevices).join(","); + return env; + } + + property string minimumDarwinVersion + property string minimumDarwinVersionCompilerFlag + property string minimumDarwinVersionLinkerFlag + + property bool libcxxAvailable: qbs.toolchain.contains("clang") && cxxLanguageVersion !== "c++98" + + Rule { + condition: enableAggregationRules + inputsFromDependencies: ["application"] + multiplex: true + + outputFileTags: ["bundle.input", "application", "primary", "debuginfo_app", + "debuginfo_bundle", "bundle.variant_symlink", "debuginfo_plist", + "codesign.signed_artifact"] + outputArtifacts: Darwin.lipoOutputArtifacts(product, inputs, "application", "app") + + prepare: Darwin.prepareLipo.apply(Darwin, arguments) + } + + Rule { + condition: enableAggregationRules + inputsFromDependencies: ["loadablemodule"] + multiplex: true + + outputFileTags: ["bundle.input", "loadablemodule", "primary", "debuginfo_loadablemodule", + "debuginfo_bundle", "debuginfo_plist", "codesign.signed_artifact"] + outputArtifacts: Darwin.lipoOutputArtifacts(product, inputs, "loadablemodule", + "loadablemodule") + + prepare: Darwin.prepareLipo.apply(Darwin, arguments) + } + + Rule { + condition: enableAggregationRules + inputsFromDependencies: ["dynamiclibrary"] + multiplex: true + + outputFileTags: ["bundle.input", "dynamiclibrary", "dynamiclibrary_symbols", "primary", + "debuginfo_dll","debuginfo_bundle","bundle.variant_symlink", + "debuginfo_plist", "codesign.signed_artifact"] + outputArtifacts: Darwin.lipoOutputArtifacts(product, inputs, "dynamiclibrary", "dll") + + prepare: Darwin.prepareLipo.apply(Darwin, arguments) + } + + Rule { + condition: enableAggregationRules + inputsFromDependencies: ["staticlibrary"] + multiplex: true + + outputFileTags: ["bundle.input", "staticlibrary", "primary", "codesign.signed_artifact"] + outputArtifacts: Darwin.lipoOutputArtifacts(product, inputs, "staticlibrary") + + prepare: Darwin.prepareLipo.apply(Darwin, arguments) + } + + Rule { + condition: qbs.targetOS.contains("darwin") + multiplex: true + + Artifact { + filePath: product.name + "-cpp-Info.plist" + fileTags: ["partial_infoplist"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.inputData = product.cpp.defaultInfoPlist; + cmd.outputFilePath = output.filePath; + cmd.sourceCode = function() { + var plist = new PropertyList(); + try { + plist.readFromObject(inputData); + plist.writeToFile(outputFilePath, "xml1"); + } finally { + plist.clear(); + } + }; + return [cmd]; + } + } +} diff --git a/share/qbs/modules/cpp/GenericGCC.qbs b/share/qbs/modules/cpp/GenericGCC.qbs new file mode 100644 index 00000000..025aad49 --- /dev/null +++ b/share/qbs/modules/cpp/GenericGCC.qbs @@ -0,0 +1,720 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.PathTools +import qbs.Probes +import qbs.Process +import qbs.TextFile +import qbs.Utilities +import qbs.UnixUtils +import qbs.WindowsUtils +import 'cpp.js' as Cpp +import 'gcc.js' as Gcc + +CppModule { + condition: qbs.toolchain && qbs.toolchain.contains("gcc") + priority: -100 + + Depends { name: "codesign" } + + Probes.GccBinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + _compilerName: compilerName + _toolchainPrefix: toolchainPrefix + } + + // Find the version as early as possible in case other things depend on it, + // for example the question of whether certain flags are supported and which need to be used + // in the GccProbe itself. + Probes.GccVersionProbe { + id: gccVersionProbe + compilerFilePath: compilerPath + environment: probeEnv + } + + Probes.GccProbe { + id: gccProbe + condition: !_skipAllChecks + compilerFilePathByLanguage: compilerPathByLanguage + enableDefinesByLanguage: enableCompilerDefinesByLanguage + environment: probeEnv + flags: targetDriverFlags.concat(sysrootFlags) + _sysroot: sysroot + } + property var probeEnv + + Probes.BinaryProbe { + id: binutilsProbe + condition: !File.exists(archiverPath) && !_skipAllChecks + names: Gcc.toolNames([archiverName, assemblerName, linkerName, nmName, + objcopyName, stripName], toolchainPrefix) + } + + targetLinkerFlags: Gcc.targetFlags("linker", false, + target, targetArch, machineType, qbs.targetOS) + targetAssemblerFlags: Gcc.targetFlags("assembler", assemblerHasTargetOption, + target, targetArch, machineType, qbs.targetOS) + targetDriverFlags: Gcc.targetFlags("compiler", compilerHasTargetOption, + target, targetArch, machineType, qbs.targetOS) + + Probe { + id: nmProbe + condition: !_skipAllChecks + property string theNmPath: nmPath + property bool hasDynamicOption + configure: { + var proc = new Process(); + try { + hasDynamicOption = proc.exec(theNmPath, ["-D", theNmPath], false) == 0; + console.debug("nm has -D: " + hasDynamicOption); + } finally { + proc.close(); + } + } + } + + qbs.architecture: gccProbe.found ? gccProbe.architecture : original + endianness: gccProbe.endianness + + compilerDefinesByLanguage: gccProbe.compilerDefinesByLanguage + + compilerVersionMajor: gccVersionProbe.versionMajor + compilerVersionMinor: gccVersionProbe.versionMinor + compilerVersionPatch: gccVersionProbe.versionPatch + + compilerIncludePaths: gccProbe.includePaths + compilerFrameworkPaths: gccProbe.frameworkPaths + compilerLibraryPaths: gccProbe.libraryPaths + + staticLibraryPrefix: "lib" + staticLibrarySuffix: ".a" + + precompiledHeaderSuffix: ".gch" + + property bool compilerHasTargetOption: qbs.toolchain.contains("clang") + && Utilities.versionCompare(compilerVersion, "3.1") >= 0 + property bool assemblerHasTargetOption: qbs.toolchain.contains("xcode") + && Utilities.versionCompare(compilerVersion, "7") >= 0 + property string target: targetArch + ? [targetArch, targetVendor, targetSystem, targetAbi].join("-") + : undefined + property string targetArch: Utilities.canonicalTargetArchitecture( + qbs.architecture, endianness, + targetVendor, targetSystem, targetAbi) + property string targetVendor: "unknown" + property string targetSystem: "unknown" + property string targetAbi: "unknown" + + property string toolchainPrefix: compilerPathProbe.found + ? compilerPathProbe.tcPrefix + : undefined + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + property string binutilsPath: binutilsProbe.found ? binutilsProbe.path : toolchainInstallPath + + assemblerName: 'as' + compilerExtension + compilerName: cxxCompilerName + linkerName: 'ld' + compilerExtension + property string archiverName: 'ar' + compilerExtension + property string nmName: 'nm' + compilerExtension + property string objcopyName: "objcopy" + compilerExtension + property string stripName: "strip" + compilerExtension + property string dsymutilName: "dsymutil" + compilerExtension + property string lipoName + property string sysroot: qbs.sysroot + property string syslibroot: sysroot + property stringList sysrootFlags: sysroot ? ["--sysroot=" + sysroot] : [] + + property string exportedSymbolsCheckMode: "ignore-undefined" + PropertyOptions { + name: "exportedSymbolsCheckMode" + allowedValues: ["strict", "ignore-undefined"] + description: "Controls when we consider an updated dynamic library as changed with " + + "regards to other binaries depending on it. The default is \"ignore-undefined\", " + + "which means we do not care about undefined symbols being added or removed. " + + "If you do care about that, e.g. because you link dependent products with an option " + + "such as \"--no-undefined\", then you should set this property to \"strict\"." + } + + property string linkerVariant + PropertyOptions { + name: "linkerVariant" + allowedValues: ["bfd", "gold", "lld"] + description: "Allows to specify the linker variant. Maps to gcc's and clang's -fuse-ld " + + "option." + } + Properties { + condition: linkerVariant + driverLinkerFlags: "-fuse-ld=" + linkerVariant + } + + property string toolchainPathPrefix: Gcc.pathPrefix(toolchainInstallPath, toolchainPrefix) + property string binutilsPathPrefix: Gcc.pathPrefix(binutilsPath, toolchainPrefix) + + property string cCompilerName: (qbs.toolchain.contains("clang") ? "clang" : "gcc") + + compilerExtension + property string cxxCompilerName: (qbs.toolchain.contains("clang") ? "clang++" : "g++") + + compilerExtension + + compilerPathByLanguage: ({ + "c": toolchainPathPrefix + cCompilerName, + "cpp": toolchainPathPrefix + cxxCompilerName, + "objc": toolchainPathPrefix + cCompilerName, + "objcpp": toolchainPathPrefix + cxxCompilerName, + "asm_cpp": toolchainPathPrefix + cCompilerName + }) + + assemblerPath: binutilsPathPrefix + assemblerName + compilerPath: toolchainPathPrefix + compilerName + linkerPath: binutilsPathPrefix + linkerName + property string archiverPath: binutilsPathPrefix + archiverName + property string nmPath: binutilsPathPrefix + nmName + property bool _nmHasDynamicOption: nmProbe.hasDynamicOption + property string objcopyPath: binutilsPathPrefix + objcopyName + property string stripPath: binutilsPathPrefix + stripName + property string dsymutilPath: toolchainPathPrefix + dsymutilName + property string lipoPath + property stringList dsymutilFlags + + property bool alwaysUseLipo: false + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-isystem" + preincludeFlag: "-include" + libraryPathFlag: "-L" + linkerScriptFlag: "-T" + + readonly property bool shouldCreateSymlinks: { + return createSymlinks && internalVersion && ["macho", "elf"].contains(cpp.imageFormat); + } + + readonly property bool shouldSignArtifacts: codesign._canSignArtifacts + && codesign.enableCodeSigning + // codesigning is done during the lipo step + && !product.multiplexed + + property string internalVersion: { + if (product.version === undefined) + return undefined; + + var coreVersion = product.version.match("^([0-9]+\.){0,3}[0-9]+"); + if (!coreVersion) + return undefined; + + var maxVersionParts = 3; + var versionParts = coreVersion[0].split('.').slice(0, maxVersionParts); + + // pad if necessary + for (var i = versionParts.length; i < maxVersionParts; ++i) + versionParts.push("0"); + + return versionParts.join('.'); + } + + property string soVersion: { + if (!internalVersion) + return ""; + + return internalVersion.split('.')[0]; + } + + property var buildEnv: { + var env = {}; + if (qbs.toolchain.contains("mingw")) + env.PATH = [toolchainInstallPath]; // For libwinpthread etc + return env; + } + + exceptionHandlingModel: { + if (qbs.toolchain.contains("mingw")) { + // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html claims + // __USING_SJLJ_EXCEPTIONS__ is defined as 1 when using SJLJ exceptions, but there don't + // seem to be defines for the other models, so use the presence of the DLLs for now. + var prefix = toolchainInstallPath; + if (!Host.os().contains("windows")) + prefix = FileInfo.joinPaths(toolchainInstallPath, "..", "lib", "gcc", + toolchainPrefix, + [compilerVersionMajor, compilerVersionMinor].join(".")); + var models = ["seh", "sjlj", "dw2"]; + for (var i = 0; i < models.length; ++i) { + if (File.exists(FileInfo.joinPaths(prefix, "libgcc_s_" + models[i] + "-1.dll"))) { + return models[i]; + } + } + } + return base; + } + + validate: { + if (_skipAllChecks) + return; + if (!File.exists(compilerPath)) { + var pathMessage = FileInfo.isAbsolutePath(compilerPath) + ? "at '" + compilerPath + "'" + : "'" + compilerPath + "' in PATH"; + throw ModUtils.ModuleError("Could not find selected C++ compiler " + pathMessage + ". " + + "Ensure that the compiler is properly " + + "installed, or set cpp.toolchainInstallPath to a valid " + + "toolchain path, or consider whether you meant to set " + + "cpp.compilerName instead."); + } + + var isWrongTriple = false; + + if (gccProbe.architecture) { + if (Utilities.canonicalArchitecture(architecture) + !== Utilities.canonicalArchitecture(gccProbe.architecture)) + isWrongTriple = true; + } else if (architecture) { + // This is a warning and not an error on the rare chance some new architecture comes + // about which qbs does not know about the macros of. But it *might* still work. + console.warn("Unknown architecture '" + architecture + "' " + + "may not be supported by this compiler."); + } + + if (gccProbe.endianness) { + if (endianness !== gccProbe.endianness) + isWrongTriple = true; + } else if (endianness) { + console.warn("Could not detect endianness ('" + + endianness + "' given)"); + } + + if (gccProbe.targetPlatform) { + // Can't differentiate Darwin OSes at the compiler level alone + if (gccProbe.targetPlatform === "darwin" + ? !qbs.targetOS.contains("darwin") + : qbs.targetPlatform !== gccProbe.targetPlatform) + isWrongTriple = true; + } else if (qbs.targetPlatform) { + console.warn("Could not detect target platform ('" + + qbs.targetPlatform + "' given)"); + } + + if (isWrongTriple) { + var realTriple = [ + Utilities.canonicalArchitecture(gccProbe.architecture), + gccProbe.targetPlatform, + gccProbe.endianness ? gccProbe.endianness + "-endian" : undefined + ].join("-"); + var givenTriple = [ + Utilities.canonicalArchitecture(architecture), + qbs.targetPlatform, + endianness ? endianness + "-endian" : undefined + ].join("-"); + var msg = "The selected compiler '" + compilerPath + "' produces code for '" + + realTriple + "', but '" + givenTriple + "' was given, which is incompatible."; + if (validateTargetTriple) { + msg += " If you are absolutely certain that your configuration is correct " + + "(check the values of the qbs.architecture, qbs.targetPlatform, " + + "and qbs.endianness properties) and that this message has been " + + "emitted in error, set the cpp.validateTargetTriple property to " + + "false. However, you should consider submitting a bug report in any " + + "case."; + throw ModUtils.ModuleError(msg); + } else { + console.warn(msg); + } + } + + var validateFlagsFunction = function (value) { + if (value) { + for (var i = 0; i < value.length; ++i) { + if (["-target", "-triple", "-arch"].contains(value[i])) + return false; + } + } + return true; + } + + var validator = new ModUtils.PropertyValidator("cpp"); + var msg = "'-target', '-triple' and '-arch' cannot appear in flags; set qbs.architecture instead"; + validator.addCustomValidator("assemblerFlags", assemblerFlags, validateFlagsFunction, msg); + validator.addCustomValidator("cppFlags", cppFlags, validateFlagsFunction, msg); + validator.addCustomValidator("cFlags", cFlags, validateFlagsFunction, msg); + validator.addCustomValidator("cxxFlags", cxxFlags, validateFlagsFunction, msg); + validator.addCustomValidator("objcFlags", objcFlags, validateFlagsFunction, msg); + validator.addCustomValidator("objcxxFlags", objcxxFlags, validateFlagsFunction, msg); + validator.addCustomValidator("commonCompilerFlags", commonCompilerFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformAssemblerFlags", platformAssemblerFlags, validateFlagsFunction, msg); + //validator.addCustomValidator("platformCppFlags", platformCppFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformCFlags", platformCFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformCxxFlags", platformCxxFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformObjcFlags", platformObjcFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformObjcxxFlags", platformObjcxxFlags, validateFlagsFunction, msg); + validator.addCustomValidator("platformCommonCompilerFlags", platformCommonCompilerFlags, validateFlagsFunction, msg); + + validator.setRequiredProperty("compilerVersion", compilerVersion); + validator.setRequiredProperty("compilerVersionMajor", compilerVersionMajor); + validator.setRequiredProperty("compilerVersionMinor", compilerVersionMinor); + validator.setRequiredProperty("compilerVersionPatch", compilerVersionPatch); + validator.addVersionValidator("compilerVersion", compilerVersion, 3, 3); + validator.addRangeValidator("compilerVersionMajor", compilerVersionMajor, 1); + validator.addRangeValidator("compilerVersionMinor", compilerVersionMinor, 0); + validator.addRangeValidator("compilerVersionPatch", compilerVersionPatch, 0); + + validator.setRequiredProperty("compilerIncludePaths", compilerIncludePaths); + validator.setRequiredProperty("compilerFrameworkPaths", compilerFrameworkPaths); + validator.setRequiredProperty("compilerLibraryPaths", compilerLibraryPaths); + + validator.validate(); + } + + // Product should be linked if it's not multiplexed or aggregated at all, + // or if it is multiplexed, if it's not the aggregate product + readonly property bool shouldLink: !(product.multiplexed || product.aggregate) + || product.multiplexConfigurationId + + Rule { + name: "dynamicLibraryLinker" + condition: product.cpp.shouldLink + multiplex: true + inputs: { + var tags = ["obj", "res", "linkerscript", "versionscript"]; + if (product.bundle && product.bundle.embedInfoPlist + && product.qbs.targetOS.contains("darwin")) { + tags.push("aggregate_infoplist"); + } + return tags; + } + inputsFromDependencies: ["dynamiclibrary_symbols", "staticlibrary", "dynamiclibrary_import"] + + outputFileTags: { + var tags = ["bundle.input", "dynamiclibrary", "dynamiclibrary_symlink", + "dynamiclibrary_symbols", "debuginfo_dll", "debuginfo_bundle", + "dynamiclibrary_import", "debuginfo_plist"]; + if (shouldSignArtifacts) + tags.push("codesign.signed_artifact"); + return tags; + } + outputArtifacts: { + var artifacts = [{ + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.dynamicLibraryFilePath(product)), + fileTags: ["bundle.input", "dynamiclibrary"] + .concat(product.cpp.shouldSignArtifacts + ? ["codesign.signed_artifact"] : []), + bundle: { + _bundleFilePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.bundleExecutableFilePath(product)) + } + }]; + if (product.cpp.imageFormat === "pe") { + artifacts.push({ + fileTags: ["dynamiclibrary_import"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.importLibraryFilePath(product)), + alwaysUpdated: false + }); + } else { + // List of libfoo's public symbols for smart re-linking. + artifacts.push({ + filePath: product.destinationDirectory + "/.sosymbols/" + + PathTools.dynamicLibraryFilePath(product), + fileTags: ["dynamiclibrary_symbols"], + alwaysUpdated: false, + }); + } + + if (product.cpp.shouldCreateSymlinks && (!product.bundle || !product.bundle.isBundle)) { + var maxVersionParts = product.cpp.internalVersion ? 3 : 1; + for (var i = 0; i < maxVersionParts; ++i) { + var symlink = { + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.dynamicLibraryFilePath( + product, undefined, undefined, i)), + fileTags: ["dynamiclibrary_symlink"] + }; + if (i > 0 && artifacts[i-1].filePath == symlink.filePath) + break; // Version number has less than three components. + artifacts.push(symlink); + } + } + if (!product.aggregate) + artifacts = artifacts.concat(Gcc.debugInfoArtifacts(product, undefined, "dll")); + return artifacts; + } + + prepare: Gcc.prepareLinker.apply(Gcc, arguments) + } + + Rule { + name: "staticLibraryLinker" + condition: product.cpp.shouldLink + multiplex: true + inputs: ["obj", "res", "linkerscript"] + inputsFromDependencies: ["dynamiclibrary_symbols", "dynamiclibrary_import", "staticlibrary"] + + outputFileTags: ["bundle.input", "staticlibrary", "c_staticlibrary", "cpp_staticlibrary"] + outputArtifacts: { + var tags = ["bundle.input", "staticlibrary"]; + var objs = inputs["obj"]; + var objCount = objs ? objs.length : 0; + for (var i = 0; i < objCount; ++i) { + var ft = objs[i].fileTags; + if (ft.contains("c_obj")) + tags.push("c_staticlibrary"); + if (ft.contains("cpp_obj")) + tags.push("cpp_staticlibrary"); + } + return [{ + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.staticLibraryFilePath(product)), + fileTags: tags, + bundle: { + _bundleFilePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.bundleExecutableFilePath(product)) + } + }]; + } + + prepare: { + var args = ['rcs', output.filePath]; + for (var i in inputs.obj) + args.push(inputs.obj[i].filePath); + for (var i in inputs.res) + args.push(inputs.res[i].filePath); + var cmd = new Command(product.cpp.archiverPath, args); + cmd.description = 'creating ' + output.fileName; + cmd.highlight = 'linker' + cmd.jobPool = "linker"; + cmd.responseFileUsagePrefix = '@'; + return cmd; + } + } + + Rule { + name: "loadableModuleLinker" + condition: product.cpp.shouldLink + multiplex: true + inputs: { + var tags = ["obj", "res", "linkerscript"]; + if (product.bundle && product.bundle.embedInfoPlist + && product.qbs.targetOS.contains("darwin")) { + tags.push("aggregate_infoplist"); + } + return tags; + } + inputsFromDependencies: ["dynamiclibrary_symbols", "dynamiclibrary_import", "staticlibrary"] + + outputFileTags: { + var tags = ["bundle.input", "loadablemodule", "debuginfo_loadablemodule", + "debuginfo_bundle", "debuginfo_plist"]; + if (shouldSignArtifacts) + tags.push("codesign.signed_artifact"); + return tags; + } + outputArtifacts: { + var app = { + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.loadableModuleFilePath(product)), + fileTags: ["bundle.input", "loadablemodule"] + .concat(product.cpp.shouldSignArtifacts + ? ["codesign.signed_artifact"] : []), + bundle: { + _bundleFilePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.bundleExecutableFilePath(product)) + } + } + var artifacts = [app]; + if (!product.aggregate) + artifacts = artifacts.concat(Gcc.debugInfoArtifacts(product, undefined, + "loadablemodule")); + return artifacts; + } + + prepare: Gcc.prepareLinker.apply(Gcc, arguments) + } + + Rule { + name: "applicationLinker" + condition: product.cpp.shouldLink + multiplex: true + inputs: { + var tags = ["obj", "res", "linkerscript"]; + if (product.bundle && product.bundle.embedInfoPlist + && product.qbs.targetOS.contains("darwin")) { + tags.push("aggregate_infoplist"); + } + return tags; + } + inputsFromDependencies: ["dynamiclibrary_symbols", "dynamiclibrary_import", "staticlibrary"] + + outputFileTags: { + var tags = ["bundle.input", "application", "debuginfo_app", "debuginfo_bundle", + "debuginfo_plist"]; + if (shouldSignArtifacts) + tags.push("codesign.signed_artifact"); + if (generateLinkerMapFile) + tags.push("mem_map"); + return tags; + } + outputArtifacts: { + var app = { + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.applicationFilePath(product)), + fileTags: ["bundle.input", "application"].concat( + product.cpp.shouldSignArtifacts ? ["codesign.signed_artifact"] : []), + bundle: { + _bundleFilePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.bundleExecutableFilePath(product)) + } + } + var artifacts = [app]; + if (!product.aggregate) + artifacts = artifacts.concat(Gcc.debugInfoArtifacts(product, undefined, "app")); + if (product.cpp.generateLinkerMapFile) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + product.cpp.linkerMapSuffix), + fileTags: ["mem_map"] + }); + } + return artifacts; + } + + prepare: Gcc.prepareLinker.apply(Gcc, arguments) + } + + Rule { + name: "compiler" + inputs: ["cpp", "c", "objcpp", "objc", "asm_cpp"] + auxiliaryInputs: ["hpp"] + explicitlyDependsOn: ["c_pch", "cpp_pch", "objc_pch", "objcpp_pch"] + outputFileTags: Cpp.compilerOutputTags(false).concat(["c_obj", "cpp_obj"]) + outputArtifacts: Cpp.compilerOutputArtifacts(input, inputs) + prepare: Gcc.prepareCompiler.apply(Gcc, arguments) + } + + Rule { + name: "assembler" + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(false) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: Gcc.prepareAssembler.apply(Gcc, arguments) + } + + Rule { + condition: useCPrecompiledHeader + inputs: ["c_pch_src"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("c", false) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "c", false) + prepare: Gcc.prepareCompiler.apply(Gcc, arguments) + } + + Rule { + condition: useCxxPrecompiledHeader + inputs: ["cpp_pch_src"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("cpp", false) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "cpp", false) + prepare: Gcc.prepareCompiler.apply(Gcc, arguments) + } + + Rule { + condition: useObjcPrecompiledHeader + inputs: ["objc_pch_src"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("objc", false) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "objc", false) + prepare: Gcc.prepareCompiler.apply(Gcc, arguments) + } + + Rule { + condition: useObjcxxPrecompiledHeader + inputs: ["objcpp_pch_src"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("objcpp", false) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "objcpp", false) + prepare: Gcc.prepareCompiler.apply(Gcc, arguments) + } + + FileTagger { + patterns: "*.s" + fileTags: ["asm"] + } + + FileTagger { + patterns: "*.S" + fileTags: ["asm_cpp"] + } + + FileTagger { + patterns: "*.sx" + fileTags: ["asm_cpp"] + } + + Scanner { + inputs: ["linkerscript"] + recursive: true + scan: { + console.debug("scanning linkerscript " + filePath + " for dependencies"); + var retval = []; + var linkerScript = new TextFile(filePath, TextFile.ReadOnly); + var regexp = /[\s]*INCLUDE[\s]+(\S+).*/ // "INCLUDE filename" + var match; + while (!linkerScript.atEof()) { + match = regexp.exec(linkerScript.readLine()); + if (match) { + var dependencyFileName = match[1]; + retval.push(dependencyFileName); + console.debug("linkerscript " + filePath + " depends on " + dependencyFileName); + } + } + linkerScript.close(); + return retval; + } + searchPaths: { + var retval = []; + for (var i = 0; i < (product.cpp.libraryPaths || []).length; i++) + retval.push(product.cpp.libraryPaths[i]); + var regexp = /[\s]*SEARCH_DIR\((\S+)\).*/ // "SEARCH_DIR(path)" + var match; + var linkerScript = new TextFile(input.filePath, TextFile.ReadOnly); + while (!linkerScript.atEof()) { + match = regexp.exec(linkerScript.readLine()); + if(match) { + var additionalPath = match[1]; + // path can be quoted to use non-latin letters, remove quotes if present + if (additionalPath.startsWith("\"") && additionalPath.endsWith("\"")) + additionalPath = additionalPath.slice(1, additionalPath.length - 1); + retval.push(additionalPath); + } + } + linkerScript.close(); + return retval; + } + } +} diff --git a/share/qbs/modules/cpp/LinuxGCC.qbs b/share/qbs/modules/cpp/LinuxGCC.qbs new file mode 100644 index 00000000..17346d04 --- /dev/null +++ b/share/qbs/modules/cpp/LinuxGCC.qbs @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Host +import qbs.Process + +UnixGCC { + condition: qbs.targetOS.contains('linux') && + qbs.toolchain && qbs.toolchain.contains('gcc') + priority: 1 + + targetVendor: "pc" + targetSystem: "linux" + targetAbi: "gnu" + + Probe { + id: runPathsProbe + condition: !_skipAllChecks && qbs.targetPlatform === Host.platform() + property stringList systemRunPaths: [] + configure: { + var paths = []; + var ldconfig = new Process(); + try { + var success = ldconfig.exec("ldconfig", ["-vNX"]); + if (success === -1) + return; + var line; + do { + line = ldconfig.readLine(); + if (line.charAt(0) === '/') { + var colonIndex = line.indexOf(':'); + if (colonIndex == -1) + continue; + paths.push(line.slice(0, colonIndex)); + } + } while (line && line.length > 0) + found = true; + systemRunPaths = paths; + } finally { + ldconfig.close(); + } + } + } + + systemRunPaths: runPathsProbe.found ? runPathsProbe.systemRunPaths : base +} diff --git a/share/qbs/modules/cpp/MingwBaseModule.qbs b/share/qbs/modules/cpp/MingwBaseModule.qbs new file mode 100644 index 00000000..e96f8ba4 --- /dev/null +++ b/share/qbs/modules/cpp/MingwBaseModule.qbs @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.TextFile +import qbs.Utilities +import qbs.WindowsUtils + +import "setuprunenv.js" as SetupRunEnv + +GenericGCC { + condition: false + + dynamicLibrarySuffix: ".dll" + executableSuffix: ".exe" + debugInfoSuffix: ".debug" + imageFormat: "pe" + windowsApiCharacterSet: "unicode" + platformDefines: base.concat(WindowsUtils.characterSetDefines(windowsApiCharacterSet)) + .concat("WIN32") + runtimeLibrary: "dynamic" + + Properties { + condition: product.multiplexByQbsProperties.contains("buildVariants") + && qbs.buildVariants && qbs.buildVariants.length > 1 + && qbs.buildVariant !== "release" + && product.type.containsAny(["staticlibrary", "dynamiclibrary"]) + variantSuffix: "d" + } + + FileTagger { + patterns: ["*.manifest"] + fileTags: ["native.pe.manifest"] + } + + FileTagger { + patterns: ["*.rc"] + fileTags: ["rc"] + } + + Rule { + inputs: ["native.pe.manifest"] + multiplex: true + + outputFileTags: ["rc"] + outputArtifacts: { + if (product.type.containsAny(["application", "dynamiclibrary"])) { + return [{ + filePath: input.completeBaseName + ".rc", + fileTags: ["rc"] + }]; + } + return []; + } + + prepare: { + var inputList = inputs["native.pe.manifest"]; + // TODO: Emulate manifest merging like Microsoft's mt.exe tool does + if (inputList.length !== 1) { + throw("The MinGW toolchain does not support manifest merging; " + + "you may only specify a single manifest file to embed into your assembly."); + } + + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.productType = product.type; + cmd.inputFilePath = inputList[0].filePath; + cmd.outputFilePath = output.filePath; + cmd.sourceCode = function() { + var tf; + try { + tf = new TextFile(outputFilePath, TextFile.WriteOnly); + if (productType.contains("application")) + tf.write("1 "); // CREATEPROCESS_MANIFEST_RESOURCE_ID + else if (productType.contains("dynamiclibrary")) + tf.write("2 "); // ISOLATIONAWARE_MANIFEST_RESOURCE_ID + tf.write("24 "); // RT_MANIFEST + tf.writeLine(Utilities.cStringQuote(inputFilePath)); + } finally { + if (tf) + tf.close(); + } + }; + return [cmd]; + } + } +} + diff --git a/share/qbs/modules/cpp/UnixGCC.qbs b/share/qbs/modules/cpp/UnixGCC.qbs new file mode 100644 index 00000000..94dfb190 --- /dev/null +++ b/share/qbs/modules/cpp/UnixGCC.qbs @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File + +GenericGCC { + condition: qbs.toolchain && qbs.toolchain.contains("gcc") + && qbs.targetOS.contains("unix") + priority: -50 + + dynamicLibraryPrefix: "lib" + loadableModulePrefix: "lib" + dynamicLibrarySuffix: ".so" + debugInfoSuffix: ".debug" + imageFormat: "elf" + systemRunPaths: ["/lib", "/usr/lib"].filter(function(p) { return File.exists(p); }) + rpathOrigin: "$ORIGIN" + useRPathLink: true + rpathLinkFlag: "-rpath-link=" +} + diff --git a/share/qbs/modules/cpp/android-gcc.qbs b/share/qbs/modules/cpp/android-gcc.qbs new file mode 100644 index 00000000..aded485c --- /dev/null +++ b/share/qbs/modules/cpp/android-gcc.qbs @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.TextFile +import qbs.Utilities +import "../../modules/Android/ndk/utils.js" as NdkUtils +import 'gcc.js' as Gcc + +LinuxGCC { + Depends { name: "Android.ndk" } + + condition: qbs.targetOS.contains("android") && qbs.toolchain && qbs.toolchain.contains("llvm") + priority: 2 + rpaths: [] + + // toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android + cxxLanguageVersion: "c++14" + + property string archLibsDir: { + switch (qbs.architecture) { + case "arm64": + return "aarch64"; + case "armv7a": + return "arm"; + case "x86_64": + return qbs.architecture; + case "x86": + return "i686"; + } + } + property string targetDir: "android" + (["armeabi", "armeabi-v7a"].contains(Android.ndk.abi) ? "eabi" : "") + property string triple: [archLibsDir, targetSystem, targetDir].join("-") + property string libsDir: FileInfo.joinPaths(sysroot, "usr", "lib", triple); + + property string sharedStlFilePath: (libsDir && Android.ndk.appStl.endsWith("_shared")) + ? FileInfo.joinPaths(libsDir, dynamicLibraryPrefix + Android.ndk.appStl + dynamicLibrarySuffix) + : undefined + property string staticStlFilePath: (libsDir && Android.ndk.appStl.endsWith("_static")) + ? FileInfo.joinPaths(libsDir, Android.ndk.platformVersion, + NdkUtils.stlFileName(staticLibraryPrefix, Android.ndk, + staticLibrarySuffix)) + : undefined + + Group { + name: "Android STL" + condition: product.cpp.sharedStlFilePath && product.cpp.shouldLink + files: product.cpp.sharedStlFilePath ? [product.cpp.sharedStlFilePath] : [] + fileTags: "android.stl" + } + + toolchainInstallPath: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", + "llvm", "prebuilt", + Android.ndk.hostArch, "bin") + + property string toolchainTriple: [targetAbi === "androideabi" ? "arm" : targetArch, + targetSystem, targetAbi].join("-") + + internalVersion: undefined + toolchainPrefix: undefined + + machineType: { + if (Android.ndk.abi === "armeabi-v7a") + return "armv7-a"; + } + + qbs.optimization: targetAbi === "androideabi" ? "small" : base + + enableExceptions: Android.ndk.appStl !== "system" + enableRtti: Android.ndk.appStl !== "system" + + commonCompilerFlags: NdkUtils.commonCompilerFlags(qbs.toolchain, qbs.buildVariant, Android.ndk) + + linkerFlags: NdkUtils.commonLinkerFlags(Android.ndk); + driverLinkerFlags: { + var flags = ["-fuse-ld=lld", "-Wl,--exclude-libs,libgcc.a", "-nostdlib++"]; + // See https://android.googlesource.com/platform/ndk/+/ndk-release-r21/docs/BuildSystemMaintainers.md#Unwinding + if (Android.ndk.abi === "armeabi-v7a") { + flags = flags.concat(["-Wl,--exclude-libs,libgcc_real.a"]); + if (Android.ndk.appStl.startsWith("c++")) + flags = flags.concat(["-Wl,--exclude-libs,libunwind.a"]); + } + return flags; + } + + platformDriverFlags: ["-fdata-sections", "-ffunction-sections", "-funwind-tables", + "-fstack-protector-strong", "-no-canonical-prefixes"] + + dynamicLibraries: { + var libs = ["c", "m"]; + if (sharedStlFilePath) + libs.push(FileInfo.joinPaths(libsDir, Android.ndk.platformVersion, + NdkUtils.stlFileName(dynamicLibraryPrefix, Android.ndk, + dynamicLibrarySuffix))); + return libs; + } + staticLibraries: staticStlFilePath + + // When using ndk r19c, llvm doesn't add sysroot/usr/include/c++/v1 to the path + // But it works starting with ndk r20b + systemIncludePaths: (Utilities.versionCompare(Android.ndk.version, "20") < 0) ? + FileInfo.joinPaths(sysroot, "usr", "include", "c++", "v1") : [] + + defines: ["ANDROID", "__ANDROID__"] + + binutilsPath: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", "llvm", "prebuilt", + Android.ndk.hostArch, "bin"); + binutilsPathPrefix: FileInfo.joinPaths(binutilsPath, "llvm-") + sysroot: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", "llvm", "prebuilt", + Android.ndk.hostArch, "sysroot") + + targetArch: { + switch (qbs.architecture) { + case "arm64": + return "aarch64"; + case "armv5": + case "armv5te": + return "armv5te"; + case "armv7a": + case "x86_64": + return qbs.architecture; + case "x86": + return "i686"; + } + } + + target: [targetArch, targetSystem, targetAbi].join("-") + targetSystem: "linux" + targetAbi: "android" + (["armeabi", "armeabi-v7a"].contains(Android.ndk.abi) ? "eabi" : "") + + Android.ndk.platformVersion + + endianness: "little" + + Rule { + condition: shouldLink + inputs: "dynamiclibrary" + Artifact { + filePath: FileInfo.joinPaths("stripped-libs", input.fileName) + fileTags: "android.nativelibrary" + } + prepare: { + var stripArgs = ["--strip-all", "-o", output.filePath, input.filePath]; + var stripCmd = new Command(product.cpp.stripPath, stripArgs); + stripCmd.description = "stripping unneeded symbols from " + input.fileName; + return stripCmd; + } + } + + _skipAllChecks: !shouldLink + + validate: { + if (_skipAllChecks) + return; + var baseValidator = new ModUtils.PropertyValidator("qbs"); + baseValidator.addCustomValidator("architecture", targetArch, function (value) { + return value !== undefined; + }, "unknown Android architecture '" + qbs.architecture + "'."); + + var validator = new ModUtils.PropertyValidator("cpp"); + validator.setRequiredProperty("targetArch", targetArch); + + return baseValidator.validate() && validator.validate(); + } +} diff --git a/share/qbs/modules/cpp/cosmic.js b/share/qbs/modules/cpp/cosmic.js new file mode 100644 index 00000000..4979f33f --- /dev/null +++ b/share/qbs/modules/cpp/cosmic.js @@ -0,0 +1,443 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); + +function toolchainDetails(qbs) { + var architecture = qbs.architecture; + if (architecture.startsWith("arm")) { + return { + "executableSuffix": ".cxm", + "staticLibrarySuffix": ".cxm", + "assemblerName": "cacorm", + "compilerName": "cxcorm" + }; + } else if (architecture === "stm8") { + return { + "executableSuffix": ".sm8", + "staticLibrarySuffix": ".sm8", + "assemblerName": "castm8", + "compilerName": "cxstm8" + }; + } else if (architecture === "hcs8") { + return { + "executableSuffix": ".h08", + "staticLibrarySuffix": ".h08", + "assemblerName": "ca6808", + "compilerName": "cx6808" + }; + } else if (architecture === "hcs12") { + return { + "executableSuffix": ".h12", + "staticLibrarySuffix": ".h12", + "assemblerName": "ca6812", + "compilerName": "cx6812" + }; + } else if (architecture === "m68k") { + return { + "executableSuffix": ".332", + "staticLibrarySuffix": ".332", + "assemblerName": "ca332", + "compilerName": "cx332" + }; + } +} + +function guessArchitecture(compilerFilePath) { + var baseName = FileInfo.baseName(compilerFilePath); + if (baseName === "cxcorm") + return "arm"; + else if (baseName === "cxstm8") + return "stm8"; + else if (baseName === "cx6808") + return "hcs8"; + else if (baseName === "cx6812") + return "hcs12"; + else if (baseName === "cx332") + return "m68k"; +} + +function dumpMacros(compilerFilePath) { + // Note: The COSMIC compiler does not support the predefined + // macros dumping. So, we do it with the following trick, where we try + // to create and compile a special temporary file and to parse the console + // output with the own magic pattern: (""|"key"|"value"|""). + + var outputDirectory = new TemporaryDir(); + var outputFilePath = FileInfo.fromNativeSeparators(FileInfo.joinPaths(outputDirectory.path(), + "dump-macros.c")); + var outputFile = new TextFile(outputFilePath, TextFile.WriteOnly); + outputFile.writeLine("#define VALUE_TO_STRING(x) #x"); + outputFile.writeLine("#define VALUE(x) VALUE_TO_STRING(x)"); + outputFile.writeLine("#define VAR_NAME_VALUE(var) #var VALUE(var)"); + // The COSMIC compiler defines only one pre-defined macro + // (at least nothing is said about other macros in the documentation). + var keys = ["__CSMC__"]; + for (var i in keys) { + var key = keys[i]; + outputFile.writeLine("#if defined (" + key + ")"); + outputFile.writeLine("#pragma message (VAR_NAME_VALUE(" + key + "))"); + outputFile.writeLine("#endif"); + } + outputFile.close(); + + var process = new Process(); + process.exec(compilerFilePath, [outputFilePath], false); + File.remove(outputFilePath); + + var map = {}; + // COSMIC compiler use the errors output! + process.readStdErr().trim().split(/\r?\n/g).map(function(line) { + var match = line.match(/^#message \("(.+)" "(.+)"\)$/); + if (match) + map[match[1]] = match[2]; + }); + return map; +} + +function dumpVersion(compilerFilePath) { + var p = new Process(); + p.exec(compilerFilePath, ["-vers"]); + // COSMIC compiler use the errors output! + var output = p.readStdErr(); + var match = output.match(/^COSMIC.+V(\d+)\.?(\d+)\.?(\*|\d+)?/); + if (match) { + var major = match[1] ? parseInt(match[1], 10) : 0; + var minor = match[2] ? parseInt(match[2], 10) : 0; + var patch = match[3] ? parseInt(match[3], 10) : 0; + return { major: major, minor: minor, patch: patch }; + } +} + +function guessEndianness(architecture) { + // There is no mention of supported endianness in the cosmic compiler. + return "big"; +} + +function dumpDefaultPaths(compilerFilePath, architecture) { + var rootPath = FileInfo.path(compilerFilePath); + var includePath; + var includePaths = []; + if (architecture.startsWith("arm")) { + includePath = FileInfo.joinPaths(rootPath, "hcorm"); + if (File.exists(includePath)) + includePaths.push(includePath); + } else if (architecture === "stm8") { + includePath = FileInfo.joinPaths(rootPath, "hstm8"); + if (File.exists(includePath)) + includePaths.push(includePath); + } else if (architecture === "hcs8") { + includePath = FileInfo.joinPaths(rootPath, "h6808"); + if (File.exists(includePath)) + includePaths.push(includePath); + } else if (architecture === "hcs12") { + includePath = FileInfo.joinPaths(rootPath, "h6812"); + if (File.exists(includePath)) + includePaths.push(includePath); + } else if (architecture === "m68k") { + includePath = FileInfo.joinPaths(rootPath, "h332"); + if (File.exists(includePath)) + includePaths.push(includePath); + } + + var libraryPaths = []; + var libraryPath = FileInfo.joinPaths(rootPath, "lib"); + if (File.exists(libraryPath)) + libraryPaths.push(libraryPath); + + return { + "includePaths": includePaths, + "libraryPaths": libraryPaths, + } +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + + // Up to 128 include files. + args = args.concat(Cpp.collectPreincludePathsArguments(input)); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Up to 128 include paths. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("+debug"); + + var architecture = input.qbs.architecture; + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "none": + // Disabled by default. + break; + case "all": + // Highest warning level. + args.push("-pw7"); + break; + } + + // C language version flags. + if (tag === "c") { + var knownValues = ["c99"]; + var cLanguageVersion = Cpp.languageVersion( + input.cpp.cLanguageVersion, knownValues, "C"); + switch (cLanguageVersion) { + case "c99": + args.push("-p", "c99"); + break; + default: + break; + } + } + + // Objects output directory. + args.push("-co", FileInfo.path(outputs.obj[0].filePath)); + + // Listing files generation flag. + if (input.cpp.generateCompilerListingFiles) { + // Enable listings. + args.push("-l"); + // Listings output directory. + args.push("-cl", FileInfo.path(outputs.lst[0].filePath)); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(product)); + + // Input. + args.push(input.filePath); + return args; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + + // Up to 128 include paths. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("-xx"); + + // Misc flags. + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + + // Listing files generation flag. + if (input.cpp.generateAssemblerListingFiles) { + args.push("-l"); + args.push("+l", outputs.lst[0].filePath); + } + + // Objects output file path. + args.push("-o", outputs.obj[0].filePath); + + // Input. + args.push(input.filePath); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + + // Library paths. + args = args.concat(Cpp.collectLibraryPaths(product).map(function(path) { + // It is workaround to use the relative paths avoids a strange linking + // errors. Maybe it is related to the limitations on the length of the + // command arguments, or on the length of the paths. + return product.cpp.libraryPathFlag + Cpp.relativePath(product.buildDirectory, path); + })); + + // Output. + args.push("-o", outputs.application[0].filePath); + + // Map file generation flag. + if (product.cpp.generateLinkerMapFile) + args.push("-m", outputs.mem_map[0].filePath); + + // Misc flags. + args = args.concat(Cpp.collectMiscEscapableLinkerArguments(product), + Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + + // Linker scripts. + args = args.concat(Cpp.collectLinkerScriptPathsArguments(product, inputs)); + + // Input objects. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + + // Library dependencies (order has matters). + args = args.concat(Cpp.collectLibraryDependencies(product).map(function(dep) { + // It is workaround to use the relative paths avoids a strange linking + // errors. Maybe it is related to the limitations on the length of the + // command arguments, or on the length of the paths. + return Cpp.relativePath(product.buildDirectory, dep.filePath); + })); + + return args; +} + +function archiverFlags(project, product, inputs, outputs) { + var args = ["-cl"]; + + // Output. + args.push(outputs.staticlibrary[0].filePath); + + // Input objects. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + return args; +} + +function createPath(fullPath) { + var cmd = new JavaScriptCommand(); + cmd.fullPath = fullPath; + cmd.silent = true; + cmd.sourceCode = function() { + File.makePath(fullPath); + }; + return cmd; +} + +// It is a workaround to rename the generated object file to the desired name. +// Reason is that the Cosmic compiler always generates the object files in the +// format of 'module.o', but we expect it in flexible format, e.g. 'module.c.obj' +// or 'module.c.o' depending on the cpp.objectSuffix property. +function renameObjectFile(project, product, inputs, outputs, input, output) { + var object = outputs.obj[0]; + var cmd = new JavaScriptCommand(); + cmd.newObject = object.filePath; + cmd.oldObject = FileInfo.joinPaths(FileInfo.path(object.filePath), + object.baseName + ".o"); + cmd.silent = true; + cmd.sourceCode = function() { File.move(oldObject, newObject); }; + return cmd; +} + +// It is a workaround to rename the generated listing file to the desired name. +// Reason is that the Cosmic compiler always generates the listing files in the +// format of 'module.ls', but we expect it in flexible format, e.g. 'module.c.lst' +// or 'module.c.ls' depending on the cpp.compilerListingSuffix property. +function renameListingFile(project, product, inputs, outputs, input, output) { + var listing = outputs.lst[0]; + var cmd = new JavaScriptCommand(); + cmd.newListing = listing.filePath; + cmd.oldListing = FileInfo.joinPaths(FileInfo.path(listing.filePath), + listing.baseName + ".ls"); + cmd.silent = true; + cmd.sourceCode = function() { File.move(oldListing, newListing); }; + return cmd; +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + + // Create output objects path, because the Cosmic doesn't do it. + var cmd = createPath(FileInfo.path(outputs.obj[0].filePath)); + cmds.push(cmd); + + // Create output listing path, because the Cosmic doesn't do it. + if (input.cpp.generateCompilerListingFiles) { + cmd = createPath(FileInfo.path(outputs.lst[0].filePath)); + cmds.push(cmd); + } + + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + cmd = new Command(input.cpp.compilerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + cmds.push(cmd); + + cmds.push(renameObjectFile(project, product, inputs, outputs, input, output)); + + if (input.cpp.generateCompilerListingFiles) + cmds.push(renameListingFile(project, product, inputs, outputs, input, output)); + + return cmds; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + + // Create output objects path, because the Cosmic doesn't do it. + var cmd = createPath(FileInfo.path(outputs.obj[0].filePath)); + cmds.push(cmd); + + // Create output listing path, because the Cosmic doesn't do it. + if (input.cpp.generateCompilerListingFiles) { + cmd = createPath(FileInfo.path(outputs.lst[0].filePath)); + cmds.push(cmd); + } + + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); + cmd = new Command(input.cpp.assemblerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + cmds.push(cmd); + return cmds; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var primaryOutput = outputs.application[0]; + var args = linkerFlags(project, product, inputs, outputs); + var cmd = new Command(product.cpp.linkerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + return [cmd]; +} + +function prepareArchiver(project, product, inputs, outputs, input, output) { + var args = archiverFlags(project, product, inputs, outputs); + var cmd = new Command(product.cpp.archiverPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "creating " + output.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + return [cmd]; +} diff --git a/share/qbs/modules/cpp/cosmic.qbs b/share/qbs/modules/cpp/cosmic.qbs new file mode 100644 index 00000000..46c904ac --- /dev/null +++ b/share/qbs/modules/cpp/cosmic.qbs @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.PathTools +import qbs.Probes +import qbs.Utilities +import "cosmic.js" as COSMIC +import "cpp.js" as Cpp + +CppModule { + condition: qbs.toolchain && qbs.toolchain.contains("cosmic") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["cxcorm"] + } + + Probes.CosmicProbe { + id: cosmicProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + } + + qbs.architecture: cosmicProbe.found ? cosmicProbe.architecture : original + qbs.targetPlatform: "none" + + compilerVersionMajor: cosmicProbe.versionMajor + compilerVersionMinor: cosmicProbe.versionMinor + compilerVersionPatch: cosmicProbe.versionPatch + endianness: cosmicProbe.endianness + + compilerDefinesByLanguage: cosmicProbe.compilerDefinesByLanguage + compilerIncludePaths: cosmicProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + compilerName: toolchainDetails.compilerName + compilerExtension + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: toolchainDetails.assemblerName + compilerExtension + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: "clnk" + compilerExtension + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string archiverName: "clib" + compilerExtension + property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + + runtimeLibrary: "static" + + staticLibrarySuffix: toolchainDetails.staticLibrarySuffix + executableSuffix: toolchainDetails.executableSuffix + + imageFormat: "cosmic" + + enableExceptions: false + enableRtti: false + + defineFlag: "-d" + includeFlag: "-i" + systemIncludeFlag: "-i" + preincludeFlag: "-ph" + libraryDependencyFlag: "" + libraryPathFlag: "-l" + linkerScriptFlag: "" + + toolchainDetails: COSMIC.toolchainDetails(qbs) + + knownArchitectures: ["arm", "hcs12", "hcs8", "m68k", "stm8"] + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(generateAssemblerListingFiles) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: COSMIC.prepareAssembler.apply(COSMIC, arguments) + } + + FileTagger { + patterns: ["*.s"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) + outputArtifacts: Cpp.compilerOutputArtifacts(input) + prepare: COSMIC.prepareCompiler.apply(COSMIC, arguments) + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) + outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) + prepare: COSMIC.prepareLinker.apply(COSMIC, arguments) + } + + Rule { + id: staticLibraryLinker + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: COSMIC.prepareArchiver.apply(COSMIC, arguments) + } +} diff --git a/share/qbs/modules/cpp/cpp.js b/share/qbs/modules/cpp/cpp.js new file mode 100644 index 00000000..b93d42f2 --- /dev/null +++ b/share/qbs/modules/cpp/cpp.js @@ -0,0 +1,469 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); +var Utilities = require("qbs.Utilities"); + +function languageVersion(versionArray, knownValues, lang) { + if (!versionArray) + return undefined; + var versions = [].uniqueConcat(versionArray); + if (versions.length === 1) + return versions[0]; + for (var i = 0; i < knownValues.length; ++i) { + var candidate = knownValues[i]; + if (versions.contains(candidate)) + return candidate; + } + var version = versions[0]; + console.debug("Randomly choosing '" + version + + "' from list of unknown " + lang + " version strings (" + versions + ")"); + return version; +} + +function extractMacros(output, regexp) { + var m = {}; + output.trim().split(/\r?\n/g).map(function(line) { + if (regexp) { + var match = regexp.exec(line); + if (!match) + return; + line = match[1]; + } + var prefix = "#define "; + if (!line.startsWith(prefix)) + return; + var index = line.indexOf(" ", prefix.length); + if (index !== -1) + m[line.substr(prefix.length, index - prefix.length)] = line.substr(index + 1); + }); + return m; +} + +function relativePath(baseDirectory, filePath) { + if (FileInfo.isAbsolutePath(filePath)) + return FileInfo.relativePath(baseDirectory, filePath); + return filePath; +} + +function assemblerOutputTags(needsListingFiles) { + var tags = ["obj"]; + if (needsListingFiles) + tags.push("lst"); + return tags; +} + +function compilerOutputTags(needsListingFiles) { + var tags = ["obj", "intermediate_obj"]; + if (needsListingFiles) + tags.push("lst"); + return tags; +} + +function applicationLinkerOutputTags(needsLinkerMapFile) { + var tags = ["application"]; + if (needsLinkerMapFile) + tags.push("mem_map"); + return tags; +} + +function dynamicLibraryLinkerOutputTags() { + return ["dynamiclibrary", "dynamiclibrary_import"]; +} + +function staticLibraryLinkerOutputTags() { + return ["staticlibrary"]; +} + +function resourceCompilerOutputTags() { + return ["res"]; +} + +function precompiledHeaderOutputTags(lang, generateObjects) { + var tags = [lang + "_pch"]; + if (generateObjects) + tags.push("obj"); + return tags; +}; + +function assemblerOutputArtifacts(input) { + var artifacts = []; + artifacts.push({ + fileTags: ["obj"], + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.fileName + input.cpp.objectSuffix) + }); + if (input.cpp.generateAssemblerListingFiles) { + artifacts.push({ + fileTags: ["lst"], + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.fileName + input.cpp.assemblerListingSuffix) + }); + } + return artifacts; +} + +function compilerOutputArtifacts(input, inputs) { + var objTags = input.fileTags.contains("cpp_intermediate_object") + ? ["intermediate_obj"] + : ["obj"]; + if (inputs) { + if (inputs.c || inputs.objc) + objTags.push("c_obj"); + if (inputs.cpp || inputs.objcpp) + objTags.push("cpp_obj"); + } + var artifacts = [{ + fileTags: objTags, + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.fileName + input.cpp.objectSuffix) + }]; + if (input.cpp.generateCompilerListingFiles) { + artifacts.push({ + fileTags: ["lst"], + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.fileName + input.cpp.compilerListingSuffix) + }); + } + return artifacts; +} + +function applicationLinkerOutputArtifacts(product) { + var artifacts = [{ + fileTags: ["application"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.applicationFilePath(product)) + }]; + if (product.cpp.generateLinkerMapFile) { + artifacts.push({ + fileTags: ["mem_map"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + product.cpp.linkerMapSuffix) + }); + } + return artifacts; +} + +function dynamicLibraryLinkerOutputArtifacts(product) { + return [{ + fileTags: ["dynamiclibrary"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.dynamicLibraryFilePath(product)) + }, { + fileTags: ["dynamiclibrary_import"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.importLibraryFilePath(product)), + alwaysUpdated: false + }]; +} + +function staticLibraryLinkerOutputArtifacts(product) { + return [{ + fileTags: ["staticlibrary"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.staticLibraryFilePath(product)) + }]; +} + +function resourceCompilerOutputArtifacts(input) { + return [{ + fileTags: ["res"], + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.completeBaseName + input.cpp.resourceSuffix) + }]; +} + +function precompiledHeaderOutputArtifacts(input, product, lang, generateObjects) { + var artifacts = [{ + fileTags: [lang + "_pch"], + filePath: product.name + "_" + lang + product.cpp.precompiledHeaderSuffix + }]; + if (generateObjects) { + artifacts.push({ + fileTags: ["obj"], + filePath: Utilities.getHash(input.completeBaseName) + + "_" + lang + input.cpp.objectSuffix + }); + } + return artifacts; +} + +function collectLibraryDependencies(product) { + var seen = {}; + var seenObjectFiles = []; + var result = []; + + function addFilePath(filePath, wholeArchive, productName) { + result.push({ filePath: filePath, wholeArchive: wholeArchive, productName: productName }); + } + + function addArtifactFilePaths(dep, artifacts) { + if (!artifacts) + return; + var artifactFilePaths = artifacts.map(function(a) { return a.filePath; }); + var wholeArchive = dep.parameters.cpp && dep.parameters.cpp.linkWholeArchive; + var artifactsAreImportLibs = artifacts.length > 0 + && artifacts[0].fileTags.contains("dynamiclibrary_import"); + for (var i = 0; i < artifactFilePaths.length; ++i) { + addFilePath(artifactFilePaths[i], wholeArchive, + artifactsAreImportLibs ? dep.name : undefined); + } + } + + function addExternalLibs(obj) { + if (!obj.cpp) + return; + function ensureArray(a) { + return (a instanceof Array) ? a : []; + } + function sanitizedModuleListProperty(obj, moduleName, propertyName) { + return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName)); + } + function handleExternalLibraries(tag, libSuffix, objSuffix) { + var externalLibs = sanitizedModuleListProperty(obj, "cpp", tag) || []; + externalLibs.forEach(function(libName) { + var isObjectFile = objSuffix && libName.endsWith(objSuffix); + if (isObjectFile) { + if (seenObjectFiles.contains(libName)) + return; + seenObjectFiles.push(libName); + } + if (!libName.endsWith(libSuffix) && !isObjectFile && !libName.startsWith('@')) + libName += libSuffix; + addFilePath(libName, false); + }); + } + handleExternalLibraries("staticLibraries", + obj.moduleProperty("cpp", "staticLibrarySuffix"), + obj.moduleProperty("cpp", "objectSuffix")); + handleExternalLibraries("dynamicLibraries", + obj.moduleProperty("cpp", "dynamicLibraryImportSuffix")); + } + + function traverse(dep) { + if (seen.hasOwnProperty(dep.name)) + return; + if (dep.parameters.cpp && dep.parameters.cpp.link === false) + return; + + var staticLibraryArtifacts = dep.artifacts["staticlibrary"]; + var dynamicLibraryArtifacts = staticLibraryArtifacts + ? null : dep.artifacts["dynamiclibrary_import"]; + if (staticLibraryArtifacts) { + seen[dep.name] = true; + dep.dependencies.forEach(traverse); + addArtifactFilePaths(dep, staticLibraryArtifacts); + addExternalLibs(dep); + } else if (dynamicLibraryArtifacts) { + seen[dep.name] = true; + addArtifactFilePaths(dep, dynamicLibraryArtifacts); + } + } + + product.dependencies.forEach(traverse); + addExternalLibs(product); + return result; +} + +function collectAbsoluteLibraryDependencyPaths(product) { + var paths = collectLibraryPaths(product); + var deps = collectLibraryDependencies(product); + return deps.map(function(dep) { + var filePath = dep.filePath; + if (FileInfo.isAbsolutePath(filePath)) + return filePath; + for (var i = 0; i < paths.length; ++i) { + var fullPath = FileInfo.joinPaths(paths[i], filePath); + if (File.exists(fullPath)) + return fullPath; + } + return filePath; + }); +} + +function collectDefines(input) { + var allDefines = []; + var platformDefines = input.cpp.platformDefines; + if (platformDefines) + allDefines = allDefines.uniqueConcat(platformDefines); + var defines = input.cpp.defines; + if (defines) + allDefines = allDefines.uniqueConcat(defines); + return allDefines; +} + +function collectIncludePaths(input) { + var allIncludePaths = []; + var includePaths = input.cpp.includePaths; + if (includePaths) + allIncludePaths = allIncludePaths.uniqueConcat(includePaths); + return allIncludePaths; +} + +function collectSystemIncludePaths(input) { + var allIncludePaths = []; + var systemIncludePaths = input.cpp.systemIncludePaths; + if (systemIncludePaths) + allIncludePaths = allIncludePaths.uniqueConcat(systemIncludePaths); + var distributionIncludePaths = input.cpp.distributionIncludePaths; + if (distributionIncludePaths) + allIncludePaths = allIncludePaths.uniqueConcat(distributionIncludePaths); + return allIncludePaths; +} + +function collectPreincludePaths(input) { + return input.cpp.prefixHeaders; +} + +function collectLibraryPaths(product) { + var allLibraryPaths = []; + var libraryPaths = product.cpp.libraryPaths; + if (libraryPaths) + allLibraryPaths = allLibraryPaths.uniqueConcat(libraryPaths); + var distributionLibraryPaths = product.cpp.distributionLibraryPaths; + if (distributionLibraryPaths) + allLibraryPaths = allLibraryPaths.uniqueConcat(distributionLibraryPaths); + return allLibraryPaths; +} + +function collectLinkerScriptPaths(inputs) { + return inputs.linkerscript + ? inputs.linkerscript.map(function(script) { return script.filePath; }) + : []; +} + +function collectLinkerObjectPaths(inputs) { + return inputs.obj ? inputs.obj.map(function(obj) { return obj.filePath; }) : []; +} + +function collectResourceObjectPaths(inputs) { + return inputs.res ? inputs.res.map(function(res) { return res.filePath; }) : []; +} + +function collectLibraryDependenciesArguments(product) { + var deps = collectLibraryDependencies(product); + return deps.map(function(dep) { return product.cpp.libraryDependencyFlag + dep.filePath }) +} + +function collectDefinesArguments(input) { + var defines = collectDefines(input); + return defines.map(function(define) { return input.cpp.defineFlag + define }); +} + +function collectIncludePathsArguments(input) { + var paths = collectIncludePaths(input); + return paths.map(function(path) { return input.cpp.includeFlag + path }); +} + +function collectSystemIncludePathsArguments(input, flag) { + flag = (flag === undefined) ? input.cpp.systemIncludeFlag : flag; + var paths = collectSystemIncludePaths(input); + return paths.map(function(path) { return flag + path }); +} + +function collectPreincludePathsArguments(input, split) { + var paths = collectPreincludePaths(input); + if (split) { + var args = []; + for (var i = 0; i < paths.length; ++i) + args.push(input.cpp.preincludeFlag, paths[i]); + return args; + } else { + return paths.map(function(path) { return input.cpp.preincludeFlag + path }); + } +} + +function collectLibraryPathsArguments(product, flag) { + flag = (flag === undefined) ? product.cpp.libraryPathFlag : flag; + var paths = collectLibraryPaths(product); + return paths.map(function(path) { return flag + path }); +} + +function collectLinkerScriptPathsArguments(product, inputs, split, flag) { + flag = (flag === undefined) ? product.cpp.linkerScriptFlag : flag; + var paths = collectLinkerScriptPaths(inputs); + if (split) { + var args = []; + for (var i = 0; i < paths.length; ++i) + args.push(flag, paths[i]); + return args; + } else { + return paths.map(function(path) { return flag + path }); + } +} + +function collectLinkerObjectPathsArguments(product, inputs, flag) { + flag = (flag === undefined) ? "" : flag; + var paths = collectLinkerObjectPaths(product); + return paths.map(function(path) { return flag + path }); +} + +function collectMiscCompilerArguments(input, tag) { + return [].concat(ModUtils.moduleProperty(input, "platformFlags"), + ModUtils.moduleProperty(input, "flags"), + ModUtils.moduleProperty(input, "platformFlags", tag), + ModUtils.moduleProperty(input, "flags", tag)); +} + +function collectMiscAssemblerArguments(input, tag) { + return [].concat(ModUtils.moduleProperty(input, "platformFlags", tag), + ModUtils.moduleProperty(input, "flags", tag)); +} + +function collectMiscDriverArguments(config) { + return [].concat(ModUtils.moduleProperty(config, "platformDriverFlags"), + ModUtils.moduleProperty(config, "driverFlags"), + ModUtils.moduleProperty(config, "targetDriverFlags")); +} + +function collectMiscLinkerArguments(product) { + return [].concat(ModUtils.moduleProperty(product, "driverLinkerFlags")); +} + +function collectMiscEscapableLinkerArguments(product) { + return [].concat(ModUtils.moduleProperty(product, "platformLinkerFlags"), + ModUtils.moduleProperty(product, "linkerFlags")); +} + +function supportsArchitecture(architecture, knownArchitectures) { + for (var i = 0; i < knownArchitectures.length; ++i) { + if (architecture.startsWith("arm")) { + if (architecture.startsWith(knownArchitectures[i])) + return true; + } else { + if (architecture === knownArchitectures[i]) + return true; + } + } + return false; +} diff --git a/share/qbs/modules/cpp/darwin.js b/share/qbs/modules/cpp/darwin.js new file mode 100644 index 00000000..e4f740db --- /dev/null +++ b/share/qbs/modules/cpp/darwin.js @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Codesign = require("../codesign/codesign.js"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Gcc = require("./gcc.js"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); + +function lipoOutputArtifacts(product, inputs, fileTag, debugSuffix) { + var buildVariants = []; + for (var i = 0; i < inputs[fileTag].length; ++i) { + var variant = inputs[fileTag][i].qbs.buildVariant; + var suffix = inputs[fileTag][i].cpp.variantSuffix; + if (!buildVariants.some(function (x) { return x.name === variant; })) + buildVariants.push({ name: variant, suffix: suffix }); + } + + var list = []; + + if (fileTag === "dynamiclibrary") { + Array.prototype.push.apply(list, buildVariants.map(function (variant) { + return { + filePath: product.destinationDirectory + "/.sosymbols/" + + PathTools.dynamicLibraryFilePath(product, variant.suffix), + fileTags: ["dynamiclibrary_symbols"], + qbs: { buildVariant: variant.name }, + cpp: { variantSuffix: variant.suffix }, + alwaysUpdated: false + }; + })); + } + + // Bundles should have a "normal" variant. In the case of frameworks, they cannot normally be + // linked to without a default variant unless a variant is specifically chosen at link time + // by passing the full path to the shared library executable instead of the -framework switch. + // Technically this doesn't affect qbs since qbs always uses full paths for internal + // dependencies but the "normal" variant is always the one that is linked to, since the + // alternative variants should only be chosen at runtime using the DYLD_IMAGE_SUFFIX variable. + // So for frameworks we'll create a symlink to the "default" variant as chosen by the user + // (we cannot do this automatically since the user must tell us which variant should be + // preferred, if there are multiple alternative variants). Applications are fine without a + // symlink but still need an explicitly chosen variant to set as the CFBundleExecutable so that + // Finder/LaunchServices can launch it normally but for simplicity we'll just use the symlink + // approach for all bundle types. + var defaultVariant; + if (!buildVariants.some(function (x) { return x.name === "release"; }) + && product.multiplexByQbsProperties.contains("buildVariants") + && product.qbs.buildVariants && product.qbs.buildVariants.length > 1) { + var defaultBuildVariant = product.qbs.defaultBuildVariant; + buildVariants.map(function (variant) { + if (variant.name === defaultBuildVariant) + defaultVariant = variant; + }); + if (!defaultVariant) { + throw new Error("qbs.defaultBuildVariant is '" + defaultBuildVariant + "', but this " + + "variant is not in the qbs.buildVariants list (" + + product.qbs.buildVariants.join(", ") + ")"); + } + + buildVariants.push({ + name: "release", + suffix: "", + isSymLink: true + }); + } + + Array.prototype.push.apply(list, buildVariants.map(function (variant) { + var tags = ["bundle.input"]; + if (variant.isSymLink) + tags.push("bundle.variant_symlink"); + else + tags.push(fileTag, "primary"); + + if (product.codesign.enableCodeSigning) + tags.push("codesign.signed_artifact"); + + return { + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.linkerOutputFilePath(fileTag, product, + variant.suffix)), + fileTags: tags, + qbs: { + buildVariant: variant.name, + _buildVariantFileName: variant.isSymLink && defaultVariant + ? FileInfo.fileName(PathTools.linkerOutputFilePath( + fileTag, product, + defaultVariant.suffix)) + : undefined + }, + bundle: { + _bundleFilePath: product.destinationDirectory + "/" + + PathTools.bundleExecutableFilePath(product, variant.suffix) + }, + cpp: { + variantSuffix: variant.suffix + } + }; + })); + if (debugSuffix) + Array.prototype.push.apply(list, Gcc.debugInfoArtifacts(product, buildVariants, + debugSuffix)); + return list; +} + +function prepareLipo(project, product, inputs, outputs, input, output) { + var cmd; + var commands = []; + for (var p in inputs) + inputs[p] = inputs[p].filter(function(inp) { return inp.product.name === product.name; }); + var allInputs = [].concat.apply([], Object.keys(inputs).map(function (tag) { + return ["application", "dynamiclibrary", "staticlibrary", "loadablemodule"].contains(tag) + ? inputs[tag] : []; + })); + + (outputs["bundle.variant_symlink"] || []).map(function (symlink) { + cmd = new Command("ln", ["-sfn", symlink.qbs._buildVariantFileName, symlink.filePath]); + cmd.silent = true; + commands.push(cmd); + }); + + for (var i = 0; i < outputs.primary.length; ++i) { + var vInputs = allInputs.filter(function (f) { + return f.qbs.buildVariant === outputs.primary[i].qbs.buildVariant + }).map(function (f) { + return f.filePath + }); + + if (vInputs.length > 1 || product.cpp.alwaysUseLipo) { + cmd = new Command(ModUtils.moduleProperty(product, "lipoPath"), + ["-create", "-output", outputs.primary[i].filePath].concat(vInputs)); + cmd.description = "lipo " + outputs.primary[i].fileName; + cmd.highlight = "linker"; + } else { + cmd = new JavaScriptCommand(); + cmd.src = vInputs[0]; + cmd.dst = outputs.primary[i].filePath; + cmd.sourceCode = function () { + File.copy(src, dst); + }; + cmd.silent = true; + } + + commands.push(cmd); + } + + commands = commands.concat( + Gcc.separateDebugInfoCommandsDarwin(product, outputs, outputs.primary)); + + if (outputs.dynamiclibrary_symbols) + Array.prototype.push.apply(commands, Gcc.createSymbolCheckingCommands(product, outputs)); + + if (product.codesign.enableCodeSigning) { + Array.prototype.push.apply( + commands, Codesign.prepareSign(project, product, inputs, outputs, input, output)); + } + + return commands; +} + diff --git a/share/qbs/modules/cpp/dmc.js b/share/qbs/modules/cpp/dmc.js new file mode 100644 index 00000000..a398d658 --- /dev/null +++ b/share/qbs/modules/cpp/dmc.js @@ -0,0 +1,506 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function targetFlags(platform, architecture, extender, consoleApp, type) { + if (platform === "dos") { + if (architecture === "x86_16") { + if (extender === "dosz") + return ["-mz"]; + else if (extender === "dosr") + return ["-mr"]; + return ["-mc"]; + } else if (architecture === "x86") { + if (extender === "dosx") + return ["-mx"]; + else if (extender === "dosp") + return ["-mp"]; + } + } else if (platform === "windows") { + var flags = []; + if (architecture === "x86_16") { + flags.push("-ml"); + if (type.contains("application") && !consoleApp) + flags.push("-WA"); + else if (type.contains("dynamiclibrary")) + flags.push("-WD"); + } else if (architecture === "x86") { + flags.push("-mn"); + if (type.contains("application")) + flags.push("-WA"); + else if (type.contains("dynamiclibrary")) + flags.push("-WD"); + } + return flags; + } + return []; +} + +function languageFlags(tag) { + if (tag === "cpp") + return ["-cpp"]; + return []; +} + +function dumpMacros(compilerPath, platform, architecture, extender, tag) { + // Note: The DMC compiler does not support the predefined/ macros dumping. So, we do it + // with the following trick, where we try to create and compile a special temporary file + // and to parse the console output with the own magic pattern: #define . + + var outputDirectory = new TemporaryDir(); + var outputFilePath = FileInfo.joinPaths(outputDirectory.path(), "dump-macros.c"); + var outputFile = new TextFile(outputFilePath, TextFile.WriteOnly); + outputFile.writeLine("#define VALUE_TO_STRING(x) #x"); + outputFile.writeLine("#define VALUE(x) VALUE_TO_STRING(x)"); + outputFile.writeLine("#define VAR_NAME_VALUE(var) \"#define \" #var\" \"VALUE(var)"); + // Declare all available pre-defined macros of DMC compiler. + var keys = [ + // Prepare the DOS target macros. + "_MSDOS", "MSDOS", + // Prepare the OS/2 target macros. + "__OS2__", + // Prepare the Windows target macros. + "WIN32", "_WIN32", "__NT__", + // Prepare extended the 32 and 16 bit DOS target macros. + "DOS386", "DOS16RM", + // Prepare the memory model macros. + "M_I86", "_M_I86", + "_M_I86TM", "M_I86TM", + "_M_I86SM", "M_I86SM", + "_M_I86MM", "M_I86MM", + "_M_I86CM", "M_I86CM", + "_M_I86LM", "M_I86LM", + "_M_I86VM", "M_I86VM", + // Prepare 8086 macros. + "_M_I8086", "M_I8086", + // Prepare 286 macros. + "_M_I286", "M_I286", + // Prepare 32 bit macros. + "_M_IX86", + // Prepare compiler identification macros. + "__DMC__", "__DMC_VERSION_STRING__", + // Prepare common compiler macros. + "_CHAR_UNSIGNED", "_CHAR_EQ_UCHAR", "_DEBUG_TRACE", "_DLL", + "_ENABLE_ARRAYNEW", "_BOOL_DEFINED", "_WCHAR_T_DEFINED", + "_CPPRTTI", "_CPPUNWIND", "_MD", "_PUSHPOP_SUPPORTED", + "_STDCALL_SUPPORTED", "__INTSIZE", "__DEFALIGN", "_INTEGRAL_MAX_BITS", + "_WINDOWS", "_WINDLL", "__INLINE_8087", "__I86__", "__SMALL__", + "__MEDIUM__", "__COMPACT__", "__LARGE__", "__VCM__", "__FPCE__", + "__FPCE__IEEE__", "DEBUG", + // Prepare C99 and C++98 macros. + "__STDC__", "__STDC_HOSTED__", "__STDC_VERSION__", "__STDC_IEC_559__", + "__STDC_IEC_559_COMPLEX__", "__STDC_ISO_10646__", "__cplusplus" + ]; + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + outputFile.writeLine("#if defined (" + key + ")"); + outputFile.writeLine("#pragma message (VAR_NAME_VALUE(" + key + "))"); + outputFile.writeLine("#endif"); + } + outputFile.close(); + + var process = new Process(); + process.setWorkingDirectory(outputDirectory.path()); + var lang = languageFlags(tag); + var target = targetFlags(platform, architecture, extender, false, ["application"]); + var args = ["-c"].concat(lang, target, FileInfo.toWindowsSeparators(outputFilePath)); + process.exec(compilerPath, args, false); + File.remove(outputFilePath); + var out = process.readStdOut(); + return Cpp.extractMacros(out); +} + +function dumpDefaultPaths(compilerFilePath, tag) { + var binPath = FileInfo.path(compilerFilePath); + var rootPath = FileInfo.path(binPath); + var includePaths = []; + var cppIncludePath = FileInfo.joinPaths(rootPath, "stlport/stlport"); + if (File.exists(cppIncludePath)) + includePaths.push(cppIncludePath); + var cIncludePath = FileInfo.joinPaths(rootPath, "include"); + if (File.exists(cIncludePath)) + includePaths.push(cIncludePath); + + var libraryPaths = []; + var libraryPath = FileInfo.joinPaths(rootPath, "lib"); + if (File.exists(libraryPath)) + libraryPaths.push(libraryPath); + + return { + "includePaths": includePaths, + "libraryPaths": libraryPaths, + } +} + +function guessVersion(macros) { + var version = macros["__DMC__"]; + return { major: parseInt(version / 100), + minor: parseInt(version % 100), + patch: 0 }; +} + +function effectiveLinkerPath(product) { + if (product.cpp.linkerMode === "automatic") { + var compilerPath = product.cpp.compilerPath; + if (compilerPath) + return compilerPath; + console.log("Found no C-language objects, choosing system linker for " + product.name); + } + return product.cpp.linkerPath; +} + +function useCompilerDriverLinker(product) { + var linker = effectiveLinkerPath(product); + var compilers = product.cpp.compilerPathByLanguage; + if (compilers) + return linker === compilers["cpp"] || linker === compilers["c"]; + return linker === product.cpp.compilerPath; +} + +function depsOutputTags() { + return ["dep"]; +} + +function depsOutputArtifacts(input, product) { + return [{ + fileTags: depsOutputTags(), + filePath: FileInfo.joinPaths(product.destinationDirectory, + input.baseName + ".dep") + }]; +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = ["-c"]; + + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + args = args.concat(languageFlags(tag)); + args = args.concat(targetFlags(product.qbs.targetPlatform, product.qbs.architecture, + product.cpp.extenderName, product.consoleApplication, + product.type)); + + // Input. + args.push(FileInfo.toWindowsSeparators(input.filePath)); + // Output. + args.push("-o" + FileInfo.toWindowsSeparators(outputs.obj[0].filePath)); + // Preinclude headers. + args = args.concat(Cpp.collectPreincludePaths(input).map(function(path) { + return input.cpp.preincludeFlag + FileInfo.toWindowsSeparators(path); + })); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + if (tag === "cpp") { + // We need to add the paths to the STL includes, because the DMC compiler does + // not handle it by default (because the STL libraries is a separate port). + var compilerIncludePaths = input.cpp.compilerIncludePaths || []; + args = args.concat(compilerIncludePaths.map(function(path) { + return input.cpp.includeFlag + FileInfo.toWindowsSeparators(path); + })); + } + + // Other includes. + args = args.concat(Cpp.collectIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toWindowsSeparators(path); + })); + args = args.concat(Cpp.collectSystemIncludePaths(input).map(function(path) { + return input.cpp.systemIncludeFlag + FileInfo.toWindowsSeparators(path); + })); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("-d"); + + // Optimization flags. + switch (input.cpp.optimization) { + case "small": + args.push("-o+space"); + break; + case "fast": + args.push("-o+speed"); + break; + case "none": + args.push("-o+none"); + break; + } + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "none": + args.push("-w"); + break; + case "all": + args.push("-w-"); + break; + } + if (input.cpp.treatWarningsAsErrors) + args.push("-wx"); + + if (tag === "cpp") { + // Exceptions flag. + if (input.cpp.enableExceptions) + args.push("-Ae"); + + // RTTI flag. + var enableRtti = input.cpp.enableRtti; + if (input.cpp.enableRtti) + args.push("-Ar"); + } + + // Listing files generation flag. + if (input.cpp.generateCompilerListingFiles) { + // We need to use the relative path here, because the DMC compiler does not handle + // a long file path for this option. + var listingPath = Cpp.relativePath(product.buildDirectory, outputs.lst[0].filePath); + args.push("-l" + FileInfo.toWindowsSeparators(listingPath)); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = ["-c"]; + + // Input. + args.push(FileInfo.toWindowsSeparators(input.filePath)); + // Output. + args.push("-o" + FileInfo.toWindowsSeparators(outputs.obj[0].filePath)); + // Preinclude headers. + args = args.concat(Cpp.collectPreincludePaths(input).map(function(path) { + return input.cpp.preincludeFlag + FileInfo.toWindowsSeparators(path); + })); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Other includes. + args = args.concat(Cpp.collectIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toWindowsSeparators(path); + })); + args = args.concat(Cpp.collectSystemIncludePaths(input).map(function(path) { + return input.cpp.systemIncludeFlag + FileInfo.toWindowsSeparators(path); + })); + + // Misc flags. + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + + var useCompilerDriver = useCompilerDriverLinker(product); + if (useCompilerDriver) { + args = args.concat(targetFlags(product.qbs.targetPlatform, product.qbs.architecture, + product.cpp.extenderName, product.consoleApplication, + product.type)); + + // Input objects. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs).map(function(path) { + return FileInfo.toWindowsSeparators(path); + })); + + // Input resources. + args = args.concat(Cpp.collectResourceObjectPaths(inputs).map(function(path) { + return FileInfo.toWindowsSeparators(path); + })); + + // Input libraries. + args = args.concat(Cpp.collectAbsoluteLibraryDependencyPaths(product).map(function(path) { + return FileInfo.toWindowsSeparators(path); + })); + + // Output. + if (product.type.contains("application")) { + args.push("-o" + FileInfo.toWindowsSeparators(outputs.application[0].filePath)); + args.push("-L/" + (product.cpp.generateLinkerMapFile ? "MAP" : "NOMAP")); + if (product.qbs.targetPlatform === "windows" && product.qbs.architecture === "x86") + args.push("-L/SUBSYSTEM:" + (product.consoleApplication ? "CONSOLE" : "WINDOWS")); + } else if (product.type.contains("dynamiclibrary")) { + args.push("-o" + FileInfo.toWindowsSeparators(outputs.dynamiclibrary[0].filePath)); + if (product.qbs.targetPlatform === "windows" && product.qbs.architecture === "x86") { + args.push("kernel32.lib"); + args.push("-L/IMPLIB:" + FileInfo.toWindowsSeparators( + outputs.dynamiclibrary_import[0].filePath)); + } + } + + if (product.cpp.debugInformation) + args.push("-L/DEBUG"); + + args.push("-L/NOLOGO", "-L/SILENT"); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscEscapableLinkerArguments(product), + Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function archiverFlags(project, product, inputs, outputs) { + var args = ["-c"]; + // Output. + args.push(FileInfo.toWindowsSeparators(outputs.staticlibrary[0].filePath)); + // Input objects. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs).map(function(path) { + return FileInfo.toWindowsSeparators(path); + })); + return args; +} + +function rccCompilerFlags(project, product, input, outputs) { + // Input. + var args = [FileInfo.toWindowsSeparators(input.filePath)]; + // Output. + args.push("-o" + FileInfo.toWindowsSeparators(outputs.res[0].filePath)); + // Bitness. + args.push("-32"); + + // Defines + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Other includes. + args = args.concat(Cpp.collectIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toWindowsSeparators(path); + })); + args = args.concat(Cpp.collectSystemIncludePaths(input).map(function(path) { + return input.cpp.systemIncludeFlag + FileInfo.toWindowsSeparators(path); + })); + return args; +} + +function buildLinkerMapFilePath(target, suffix) { + return FileInfo.joinPaths(FileInfo.path(target.filePath), + FileInfo.completeBaseName(target.fileName) + suffix); +} + +// It is a workaround which removes the generated linker map file if it is disabled +// by cpp.generateLinkerMapFile property. Reason is that the DMC compiler always +// generates this file, and does not have an option to disable generation for a linker +// map file. So, we can to remove a listing files only after the linking completes. +function removeLinkerMapFile(project, product, inputs, outputs, input, output) { + var target = outputs.dynamiclibrary ? outputs.dynamiclibrary[0] + : outputs.application[0]; + var cmd = new JavaScriptCommand(); + cmd.mapFilePath = buildLinkerMapFilePath(target, ".map") + cmd.silent = true; + cmd.sourceCode = function() { File.remove(mapFilePath); }; + return cmd; +} + +// It is a workaround to rename the extension of the output linker map file to the +// specified one, since the linker generates only files with the '.map' extension. +function renameLinkerMapFile(project, product, inputs, outputs, input, output) { + var target = outputs.dynamiclibrary ? outputs.dynamiclibrary[0] + : outputs.application[0]; + var cmd = new JavaScriptCommand(); + cmd.newMapFilePath = buildLinkerMapFilePath(target, product.cpp.linkerMapSuffix); + cmd.oldMapFilePath = buildLinkerMapFilePath(target, ".map"); + cmd.silent = true; + cmd.sourceCode = function() { + if (oldMapFilePath !== newMapFilePath) + File.move(oldMapFilePath, newMapFilePath); + }; + return cmd; +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + var cmd = new Command(input.cpp.compilerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + return [cmd]; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); + var cmd = new Command(input.cpp.assemblerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + return [cmd]; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var cmds = []; + var primaryOutput = outputs.dynamiclibrary ? outputs.dynamiclibrary[0] + : outputs.application[0]; + var args = linkerFlags(project, product, inputs, outputs); + var linkerPath = effectiveLinkerPath(product); + var cmd = new Command(linkerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + cmds.push(cmd); + + if (product.cpp.generateLinkerMapFile) + cmds.push(renameLinkerMapFile(project, product, inputs, outputs, input, output)); + else + cmds.push(removeLinkerMapFile(project, product, inputs, outputs, input, output)); + + return cmds; +} + +function prepareArchiver(project, product, inputs, outputs, input, output) { + var args = archiverFlags(project, product, inputs, outputs); + var cmd = new Command(product.cpp.archiverPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "creating " + output.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + return [cmd]; +} + +function prepareRccCompiler(project, product, inputs, outputs, input, output) { + var args = rccCompilerFlags(project, product, input, outputs); + var cmd = new Command(input.cpp.rccCompilerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + return [cmd]; +} diff --git a/share/qbs/modules/cpp/dmc.qbs b/share/qbs/modules/cpp/dmc.qbs new file mode 100644 index 00000000..db9e6b2f --- /dev/null +++ b/share/qbs/modules/cpp/dmc.qbs @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.PathTools +import qbs.Probes +import qbs.Utilities +import "dmc.js" as DMC +import "cpp.js" as Cpp + +CppModule { + condition: Host.os().contains("windows") && qbs.toolchain && qbs.toolchain.contains("dmc") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["dmc"] + } + + Probes.DmcProbe { + id: dmcProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + _targetPlatform: qbs.targetPlatform + _targetArchitecture: qbs.architecture + _targetExtender: extenderName + } + + qbs.architecture: dmcProbe.found ? dmcProbe.architecture : original + qbs.targetPlatform: dmcProbe.found ? dmcProbe.targetPlatform : original + + compilerVersionMajor: dmcProbe.versionMajor + compilerVersionMinor: dmcProbe.versionMinor + compilerVersionPatch: dmcProbe.versionPatch + endianness: "little" + + compilerDefinesByLanguage: dmcProbe.compilerDefinesByLanguage + compilerIncludePaths: dmcProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + compilerName: "dmc.exe" + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: "dmc.exe" + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: "link.exe" + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string archiverName: "lib.exe" + property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + property string rccCompilerName: "rcc.exe" + property string rccCompilerPath: FileInfo.joinPaths(toolchainInstallPath, rccCompilerName) + + property string extenderName + PropertyOptions { + name: "extenderName" + allowedValues: [undefined, "dosz", "dosr", "dosx", "dosp"] + description: "Specifies the DOS memory extender to compile with:\n" + + " - \"dosz\" is the ZPM 16 bit DOS Extender\n" + + " - \"dosr\" is the Rational 16 bit DOS Extender\n" + + " - \"dosx\" is the DOSX 32 bit DOS Extender\n" + + " - \"dosp\" is the Pharlap 32 bit DOS Extender\n" + ; + } + + runtimeLibrary: "dynamic" + + staticLibrarySuffix: ".lib" + dynamicLibrarySuffix: ".dll" + executableSuffix: ".exe" + objectSuffix: ".obj" + + imageFormat: { + if (qbs.targetPlatform === "dos") + return "mz"; + else if (qbs.targetPlatform === "windows") + return "pe"; + } + + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-I" + preincludeFlag: "-HI" + libraryPathFlag: "-L/packcode" + + knownArchitectures: ["x86", "x86_16"] + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: DMC.depsOutputTags().concat( + Cpp.assemblerOutputTags(generateAssemblerListingFiles)) + outputArtifacts: DMC.depsOutputArtifacts(input, product).concat( + Cpp.assemblerOutputArtifacts(input)) + prepare: DMC.prepareAssembler.apply(DMC, arguments) + } + + FileTagger { + patterns: ["*.s", "*.asm"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: DMC.depsOutputTags().concat( + Cpp.compilerOutputTags(generateCompilerListingFiles)) + outputArtifacts: DMC.depsOutputArtifacts(input, product).concat( + Cpp.compilerOutputArtifacts(input)) + prepare: DMC.prepareCompiler.apply(DMC, arguments) + } + + + Rule { + id: rccCompiler + inputs: ["rc"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) + prepare: DMC.prepareRccCompiler.apply(DMC, arguments) + } + + FileTagger { + patterns: ["*.rc"] + fileTags: ["rc"] + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "res", "linkerscript"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) + outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) + prepare: DMC.prepareLinker.apply(DMC, arguments) + } + + Rule { + id: dynamicLibraryLinker + multiplex: true + inputs: ["obj", "res"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.dynamicLibraryLinkerOutputTags() + outputArtifacts: Cpp.dynamicLibraryLinkerOutputArtifacts(product) + prepare: DMC.prepareLinker.apply(DMC, arguments) + } + + Rule { + id: staticLibraryLinker + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: DMC.prepareArchiver.apply(DMC, arguments) + } +} diff --git a/share/qbs/modules/cpp/freebsd-gcc.qbs b/share/qbs/modules/cpp/freebsd-gcc.qbs new file mode 100644 index 00000000..fb6d45b3 --- /dev/null +++ b/share/qbs/modules/cpp/freebsd-gcc.qbs @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import "freebsd.js" as FreeBSD +import qbs.Host + +UnixGCC { + condition: qbs.targetOS.contains("freebsd") && + qbs.toolchain && qbs.toolchain.contains("gcc") + priority: 1 + + targetSystem: "freebsd" + (Host.os().contains("freebsd") ? FreeBSD.hostKernelRelease() : "") + + distributionIncludePaths: ["/usr/local/include"] + distributionLibraryPaths: ["/usr/local/lib"] +} diff --git a/share/qbs/modules/cpp/freebsd.js b/share/qbs/modules/cpp/freebsd.js new file mode 100644 index 00000000..37dc432a --- /dev/null +++ b/share/qbs/modules/cpp/freebsd.js @@ -0,0 +1,10 @@ +var Utilities = require("qbs.Utilities"); + +function stripKernelReleaseSuffix(r) { + var idx = r.indexOf("-RELEASE"); + return idx >= 0 ? r.substr(0, idx) : r; +} + +function hostKernelRelease() { + return stripKernelReleaseSuffix(Utilities.kernelVersion()); +} diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js new file mode 100644 index 00000000..25fe0686 --- /dev/null +++ b/share/qbs/modules/cpp/gcc.js @@ -0,0 +1,1579 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Codesign = require("../codesign/codesign.js"); +var Cpp = require("cpp.js"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Host = require("qbs.Host"); +var DarwinTools = require("qbs.DarwinTools"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); +var Process = require("qbs.Process"); +var TextFile = require("qbs.TextFile"); +var UnixUtils = require("qbs.UnixUtils"); +var Utilities = require("qbs.Utilities"); +var WindowsUtils = require("qbs.WindowsUtils"); + +function effectiveLinkerPath(product, inputs) { + if (product.cpp.linkerMode === "automatic") { + var compilers = product.cpp.compilerPathByLanguage; + if (compilers) { + if (inputs.cpp_obj || inputs.cpp_staticlibrary) { + console.log("Found C++ or Objective-C++ objects, choosing C++ linker for " + + product.name); + return compilers["cpp"]; + } + + if (inputs.c_obj || inputs.c_staticlibrary) { + console.log("Found C or Objective-C objects, choosing C linker for " + + product.name); + return compilers["c"]; + } + } + + console.log("Found no C-language objects, choosing system linker for " + + product.name); + } + + return product.cpp.linkerPath; +} + +function useCompilerDriverLinker(product, inputs) { + var linker = effectiveLinkerPath(product, inputs); + var compilers = product.cpp.compilerPathByLanguage; + if (compilers) { + return linker === compilers["cpp"] + || linker === compilers["c"]; + } + return linker === product.cpp.compilerPath; +} + +function collectLibraryDependencies(product, isDarwin) { + var publicDeps = {}; + var objects = []; + var objectByFilePath = {}; + var tagForLinkingAgainstSharedLib = product.cpp.imageFormat === "pe" + ? "dynamiclibrary_import" : "dynamiclibrary"; + var removeDuplicateLibraries = product.cpp.removeDuplicateLibraries + + function addObject(obj, addFunc) { + /* If the object is already known, remove its previous usage and insert + * it again in the new desired position. This preserves the order of + * the other objects, and is analogous to what qmake does (see the + * mergeLflags parameter in UnixMakefileGenerator::findLibraries()). + */ + if (removeDuplicateLibraries && (obj.filePath in objectByFilePath)) { + var oldObj = objectByFilePath[obj.filePath]; + var i = objects.indexOf(oldObj); + if (i >= 0) + objects.splice(i, 1); + } + addFunc.call(objects, obj); + objectByFilePath[obj.filePath] = obj; + } + + function addPublicFilePath(filePath, dep) { + var existing = objectByFilePath[filePath]; + var wholeArchive = dep.parameters.cpp && dep.parameters.cpp.linkWholeArchive; + var symbolLinkMode = dep.parameters.cpp && dep.parameters.cpp.symbolLinkMode; + if (existing) { + existing.direct = true; + existing.wholeArchive = wholeArchive; + existing.symbolLinkMode = symbolLinkMode; + } else { + addObject({ direct: true, filePath: filePath, + wholeArchive: wholeArchive, symbolLinkMode: symbolLinkMode }, + Array.prototype.unshift); + } + } + + function addPrivateFilePath(filePath) { + var existing = objectByFilePath[filePath]; + if (!existing) + addObject({ direct: false, filePath: filePath }, Array.prototype.unshift); + } + + function addArtifactFilePaths(dep, tag, addFunction) { + var artifacts = dep.artifacts[tag]; + if (!artifacts) + return; + var artifactFilePaths = artifacts.map(function(a) { return a.filePath; }); + for (var i = 0; i < artifactFilePaths.length; ++i) + addFunction(artifactFilePaths[i], dep); + } + + function addExternalLibs(obj) { + if (!obj.cpp) + return; + function ensureArray(a) { + return (a instanceof Array) ? a : []; + } + function sanitizedModuleListProperty(obj, moduleName, propertyName) { + return ensureArray(ModUtils.sanitizedModuleProperty(obj, moduleName, propertyName)); + } + var externalLibs = [].concat( + ensureArray(sanitizedModuleListProperty(obj, "cpp", "staticLibraries")), + ensureArray(sanitizedModuleListProperty(obj, "cpp", "dynamicLibraries"))); + for (var i = 0, len = externalLibs.length; i < len; ++i) + addObject({ direct: true, filePath: externalLibs[i] }, Array.prototype.push); + if (isDarwin) { + externalLibs = [].concat( + ensureArray(sanitizedModuleListProperty(obj, "cpp", "frameworks"))); + for (var i = 0, len = externalLibs.length; i < len; ++i) + addObject({ direct: true, filePath: externalLibs[i], framework: true }, + Array.prototype.push); + externalLibs = [].concat( + ensureArray(sanitizedModuleListProperty(obj, "cpp", "weakFrameworks"))); + for (var i = 0, len = externalLibs.length; i < len; ++i) + addObject({ direct: true, filePath: externalLibs[i], framework: true, + symbolLinkMode: "weak" }, Array.prototype.push); + } + } + + function traverse(dep, isBelowIndirectDynamicLib) { + if (publicDeps[dep.name]) + return; + + if (dep.parameters.cpp && dep.parameters.cpp.link === false) + return; + + var isStaticLibrary = typeof dep.artifacts["staticlibrary"] !== "undefined"; + var isDynamicLibrary = !isStaticLibrary + && typeof dep.artifacts[tagForLinkingAgainstSharedLib] !== "undefined"; + if (!isStaticLibrary && !isDynamicLibrary) + return; + + var nextIsBelowIndirectDynamicLib = isBelowIndirectDynamicLib || isDynamicLibrary; + dep.dependencies.forEach(function(depdep) { + // If "dep" is an aggregate product, and "depdep" is one of the multiplexed variants + // of the same product, we don't want to depend on the multiplexed variants, because + // that could mean linking more than one time against the same library. Instead skip + // the multiplexed dependency, and depend only on the aggregate one. + if (depdep.name === dep.name) + return; + traverse(depdep, nextIsBelowIndirectDynamicLib); + }); + if (isStaticLibrary) { + if (!isBelowIndirectDynamicLib) { + addArtifactFilePaths(dep, "staticlibrary", addPublicFilePath); + addExternalLibs(dep); + publicDeps[dep.name] = true; + } + } else if (isDynamicLibrary) { + if (!isBelowIndirectDynamicLib) { + addArtifactFilePaths(dep, tagForLinkingAgainstSharedLib, addPublicFilePath); + publicDeps[dep.name] = true; + } else { + addArtifactFilePaths(dep, tagForLinkingAgainstSharedLib, addPrivateFilePath); + } + } + } + + function traverseDirectDependency(dep) { + traverse(dep, false); + } + + product.dependencies.forEach(traverseDirectDependency); + addExternalLibs(product); + + var seenRPathLinkDirs = {}; + var result = { libraries: [], rpath_link: [] }; + objects.forEach( + function (obj) { + if (obj.direct) { + result.libraries.push({ filePath: obj.filePath, + wholeArchive: obj.wholeArchive, + symbolLinkMode: obj.symbolLinkMode, + framework: obj.framework }); + } else { + var dirPath = FileInfo.path(obj.filePath); + if (!seenRPathLinkDirs.hasOwnProperty(dirPath)) { + seenRPathLinkDirs[dirPath] = true; + result.rpath_link.push(dirPath); + } + } + }); + return result; +} + +function escapeLinkerFlags(product, inputs, linkerFlags) { + if (!linkerFlags || linkerFlags.length === 0) + return []; + + if (useCompilerDriverLinker(product, inputs)) { + var sep = ","; + var useXlinker = linkerFlags.some(function (f) { return f.contains(sep); }); + if (useXlinker) { + // One or more linker arguments contain the separator character itself + // Use -Xlinker to handle these + var xlinkerFlags = []; + linkerFlags.map(function (linkerFlag) { + if (product.cpp.enableSuspiciousLinkerFlagWarnings + && linkerFlag.startsWith("-Wl,")) { + console.warn("Encountered escaped linker flag '" + linkerFlag + "'. This may " + + "cause the target to fail to link. Please do not escape these " + + "flags manually; qbs does that for you."); + } + xlinkerFlags.push("-Xlinker", linkerFlag); + }); + return xlinkerFlags; + } + + if (product.cpp.enableSuspiciousLinkerFlagWarnings && linkerFlags.contains("-Xlinker")) { + console.warn("Encountered -Xlinker linker flag escape sequence. This may cause the " + + "target to fail to link. Please do not escape these flags manually; " + + "qbs does that for you."); + } + + // If no linker arguments contain the separator character we can just use -Wl, + // which is more compact and easier to read in logs + return [["-Wl"].concat(linkerFlags).join(sep)]; + } + + return linkerFlags; +} + +function linkerFlags(project, product, inputs, outputs, primaryOutput, linkerPath) { + var isDarwin = product.qbs.targetOS.contains("darwin"); + var libraryDependencies = collectLibraryDependencies(product, isDarwin); + var frameworks = product.cpp.frameworks; + var weakFrameworks = product.cpp.weakFrameworks; + var rpaths = (product.cpp.useRPaths !== false) ? product.cpp.rpaths : undefined; + var systemRunPaths = product.cpp.systemRunPaths || []; + var canonicalSystemRunPaths = systemRunPaths.map(function(p) { + return File.canonicalFilePath(p); + }); + var i, args = additionalCompilerAndLinkerFlags(product); + + var escapableLinkerFlags = []; + + if (primaryOutput.fileTags.contains("dynamiclibrary")) { + if (isDarwin) { + args.push((function () { + var tags = ["c", "cpp", "objc", "objcpp", "asm_cpp"]; + for (var i = 0; i < tags.length; ++i) { + if (linkerPath === product.cpp.compilerPathByLanguage[tags[i]]) + return "-dynamiclib"; + } + return "-dylib"; // for ld64 + })()); + } else { + args.push("-shared"); + } + + if (isDarwin) { + if (product.cpp.internalVersion) + args.push("-current_version", product.cpp.internalVersion); + escapableLinkerFlags.push("-install_name", UnixUtils.soname(product, + primaryOutput.fileName)); + } else if (product.cpp.imageFormat === "elf") { + escapableLinkerFlags.push("-soname=" + UnixUtils.soname(product, + primaryOutput.fileName)); + } + } + + if (primaryOutput.fileTags.contains("loadablemodule")) + args.push(isDarwin ? "-bundle" : "-shared"); + + if (primaryOutput.fileTags.containsAny(["dynamiclibrary", "loadablemodule"])) { + if (isDarwin) + escapableLinkerFlags.push("-headerpad_max_install_names"); + else if (product.cpp.imageFormat === "elf") + escapableLinkerFlags.push("--as-needed"); + } + + if (isLegacyQnxSdk(product)) { + ["c", "cpp"].map(function (tag) { + if (linkerPath === product.cpp.compilerPathByLanguage[tag]) + args = args.concat(qnxLangArgs(product, tag)); + }); + } + + var targetLinkerFlags = product.cpp.targetLinkerFlags; + if (targetLinkerFlags) + Array.prototype.push.apply(escapableLinkerFlags, targetLinkerFlags); + + var sysroot = product.cpp.syslibroot; + if (sysroot) { + if (product.qbs.toolchain.contains("qcc")) + escapableLinkerFlags.push("--sysroot=" + sysroot); + else if (isDarwin) + escapableLinkerFlags.push("-syslibroot", sysroot); + else + args.push("--sysroot=" + sysroot); // do not escape, compiler-as-linker also needs it + } + + if (product.cpp.allowUnresolvedSymbols) { + if (isDarwin) + escapableLinkerFlags.push("-undefined", "suppress"); + else + escapableLinkerFlags.push("--unresolved-symbols=ignore-all"); + } + + function fixupRPath(rpath) { + // iOS, tvOS, watchOS, and others, are fine + if (!product.qbs.targetOS.contains("macos")) + return rpath; + + // ...as are newer versions of macOS + var min = product.cpp.minimumMacosVersion; + if (min && Utilities.versionCompare(min, "10.10") >= 0) + return rpath; + + // In older versions of dyld, a trailing slash is required + if (!rpath.endsWith("/")) + return rpath + "/"; + + return rpath; + } + + function isNotSystemRunPath(p) { + return !FileInfo.isAbsolutePath(p) || (!systemRunPaths.contains(p) + && !canonicalSystemRunPaths.contains(File.canonicalFilePath(p))); + }; + + if (!product.qbs.targetOS.contains("windows")) { + for (i in rpaths) { + if (isNotSystemRunPath(rpaths[i])) + escapableLinkerFlags.push("-rpath", fixupRPath(rpaths[i])); + } + } + + if (product.cpp.entryPoint) + escapableLinkerFlags.push("-e", product.cpp.entryPoint); + + if (product.qbs.toolchain.contains("mingw")) { + if (product.consoleApplication !== undefined) + escapableLinkerFlags.push("-subsystem", + product.consoleApplication ? "console" : "windows"); + + var minimumWindowsVersion = product.cpp.minimumWindowsVersion; + if (minimumWindowsVersion) { + var subsystemVersion = WindowsUtils.getWindowsVersionInFormat(minimumWindowsVersion, 'subsystem'); + if (subsystemVersion) { + var major = subsystemVersion.split('.')[0]; + var minor = subsystemVersion.split('.')[1]; + + // http://sourceware.org/binutils/docs/ld/Options.html + escapableLinkerFlags.push("--major-subsystem-version", major, + "--minor-subsystem-version", minor, + "--major-os-version", major, + "--minor-os-version", minor); + } + } + } + + if (inputs.aggregate_infoplist) + args.push("-sectcreate", "__TEXT", "__info_plist", inputs.aggregate_infoplist[0].filePath); + + var isLinkingCppObjects = !!(inputs.cpp_obj || inputs.cpp_staticlibrary); + var stdlib = isLinkingCppObjects + ? product.cpp.cxxStandardLibrary + : undefined; + if (stdlib && product.qbs.toolchain.contains("clang")) + args.push("-stdlib=" + stdlib); + + // Flags for library search paths + var allLibraryPaths = Cpp.collectLibraryPaths(product); + if (systemRunPaths.length > 0) + allLibraryPaths = allLibraryPaths.filter(isNotSystemRunPath); + args = args.concat(allLibraryPaths.map(function(path) { return product.cpp.libraryPathFlag + path })); + + escapableLinkerFlags = escapableLinkerFlags.concat(Cpp.collectLinkerScriptPathsArguments(product, inputs)); + + var versionScripts = inputs.versionscript + ? inputs.versionscript.map(function(a) { return a.filePath; }) : []; + Array.prototype.push.apply(escapableLinkerFlags, [].uniqueConcat(versionScripts) + .map(function(path) { return '--version-script=' + path })); + + if (isDarwin && product.cpp.warningLevel === "none") + args.push('-w'); + + var useCompilerDriver = useCompilerDriverLinker(product, inputs); + args = args.concat(configFlags(product, useCompilerDriver)); + escapableLinkerFlags = escapableLinkerFlags.concat(Cpp.collectMiscEscapableLinkerArguments(product)); + + // Note: due to the QCC response files hack in prepareLinker(), at least one object file or + // library file must follow the output file path so that QCC has something to process before + // sending the rest of the arguments through the response file. + args.push("-o", primaryOutput.filePath); + + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + args = args.concat(Cpp.collectResourceObjectPaths(inputs)); + + for (i in frameworks) { + frameworkExecutablePath = PathTools.frameworkExecutablePath(frameworks[i]); + if (FileInfo.isAbsolutePath(frameworkExecutablePath)) + args.push(frameworkExecutablePath); + else + args = args.concat(['-framework', frameworks[i]]); + } + + for (i in weakFrameworks) { + frameworkExecutablePath = PathTools.frameworkExecutablePath(weakFrameworks[i]); + if (FileInfo.isAbsolutePath(frameworkExecutablePath)) + args = args.concat(['-weak_library', frameworkExecutablePath]); + else + args = args.concat(['-weak_framework', weakFrameworks[i]]); + } + + var wholeArchiveActive = false; + var prevLib; + for (i = 0; i < libraryDependencies.libraries.length; ++i) { + var dep = libraryDependencies.libraries[i]; + var lib = dep.filePath; + if (lib === prevLib) + continue; + prevLib = lib; + if (dep.wholeArchive && !wholeArchiveActive) { + var wholeArchiveFlag; + if (isDarwin) { + wholeArchiveFlag = "-force_load"; + } else { + wholeArchiveFlag = "--whole-archive"; + wholeArchiveActive = true; + } + Array.prototype.push.apply(args, + escapeLinkerFlags(product, inputs, [wholeArchiveFlag])); + } + if (!dep.wholeArchive && wholeArchiveActive) { + Array.prototype.push.apply(args, + escapeLinkerFlags(product, inputs, ["--no-whole-archive"])); + wholeArchiveActive = false; + } + + var symbolLinkMode = dep.symbolLinkMode; + if (isDarwin && symbolLinkMode) { + if (!["lazy", "reexport", "upward", "weak"].contains(symbolLinkMode)) + throw new Error("unknown value '" + symbolLinkMode + "' for cpp.symbolLinkMode"); + + if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@')) + escapableLinkerFlags.push("-" + symbolLinkMode + "_library", lib); + else if (dep.framework) + escapableLinkerFlags.push("-" + symbolLinkMode + "_framework", lib); + else + escapableLinkerFlags.push("-" + symbolLinkMode + "-l" + lib); + } else if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@')) { + args.push(dep.framework ? PathTools.frameworkExecutablePath(lib) : lib); + } else if (dep.framework) { + args.push("-framework", lib); + } else { + args.push('-l' + lib); + } + } + if (wholeArchiveActive) { + Array.prototype.push.apply(args, + escapeLinkerFlags(product, inputs, ["--no-whole-archive"])); + } + var discardUnusedData = product.cpp.discardUnusedData; + if (discardUnusedData !== undefined) { + var flags = []; + if (discardUnusedData === true) { + if (isDarwin) + escapableLinkerFlags.push("-dead_strip"); + else + escapableLinkerFlags.push("--gc-sections"); + } else if (!isDarwin) { + escapableLinkerFlags.push("--no-gc-sections"); + } + } + + if (product.cpp.useRPathLink) { + if (!product.cpp.rpathLinkFlag) + throw new Error("Using rpath-link but cpp.rpathLinkFlag is not defined"); + Array.prototype.push.apply(escapableLinkerFlags, libraryDependencies.rpath_link.map( + function(dir) { + return product.cpp.rpathLinkFlag + dir; + })); + } + + var importLibs = outputs.dynamiclibrary_import; + if (importLibs) + escapableLinkerFlags.push("--out-implib", importLibs[0].filePath); + + if (outputs.application && product.cpp.generateLinkerMapFile) { + if (isDarwin) + escapableLinkerFlags.push("-map", outputs.mem_map[0].filePath); + else + escapableLinkerFlags.push("-Map=" + outputs.mem_map[0].filePath); + } + + var escapedLinkerFlags = escapeLinkerFlags(product, inputs, escapableLinkerFlags); + Array.prototype.push.apply(escapedLinkerFlags, args); + if (useCompilerDriver) + escapedLinkerFlags = escapedLinkerFlags.concat(Cpp.collectMiscLinkerArguments(product)); + if (product.qbs.toolchain.contains("mingw") && product.cpp.runtimeLibrary === "static") + escapedLinkerFlags = ['-static-libgcc', '-static-libstdc++'].concat(escapedLinkerFlags); + return escapedLinkerFlags; +} + +// for compiler AND linker +function configFlags(config, isDriver) { + var args = []; + + if (isDriver !== false) + args = args.concat(Cpp.collectMiscDriverArguments(config)); + + var frameworkPaths = config.cpp.frameworkPaths; + if (frameworkPaths) + args = args.uniqueConcat(frameworkPaths.map(function(path) { return '-F' + path })); + + var allSystemFrameworkPaths = []; + + var systemFrameworkPaths = config.cpp.systemFrameworkPaths; + if (systemFrameworkPaths) + allSystemFrameworkPaths = allSystemFrameworkPaths.uniqueConcat(systemFrameworkPaths); + + var distributionFrameworkPaths = config.cpp.distributionFrameworkPaths; + if (distributionFrameworkPaths) + allSystemFrameworkPaths = allSystemFrameworkPaths.uniqueConcat(distributionFrameworkPaths); + + args = args.concat(allSystemFrameworkPaths.map(function(path) { return '-iframework' + path })); + + return args; +} + +function languageTagFromFileExtension(toolchain, fileName) { + var i = fileName.lastIndexOf('.'); + if (i === -1) + return; + var m = { + "c" : "c", + "C" : "cpp", + "cpp" : "cpp", + "cxx" : "cpp", + "c++" : "cpp", + "cc" : "cpp", + "m" : "objc", + "mm" : "objcpp", + "s" : "asm", + "S" : "asm_cpp" + }; + if (!toolchain.contains("clang")) + m["sx"] = "asm_cpp"; // clang does NOT recognize .sx + return m[fileName.substring(i + 1)]; +} + +// Older versions of the QNX SDK have C and C++ compilers whose filenames differ only by case, +// which won't work in case insensitive environments like Win32+NTFS, HFS+ and APFS +function isLegacyQnxSdk(config) { + return config.qbs.toolchain.contains("qcc") && config.qnx && !config.qnx.qnx7; +} + +function effectiveCompilerInfo(toolchain, input, output) { + var compilerPath, language; + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); + + // Whether we're compiling a precompiled header or normal source file + var pchOutput = output.fileTags.contains(tag + "_pch"); + + var compilerPathByLanguage = input.cpp.compilerPathByLanguage; + if (compilerPathByLanguage) + compilerPath = compilerPathByLanguage[tag]; + if (!compilerPath + || tag !== languageTagFromFileExtension(toolchain, input.fileName) + || isLegacyQnxSdk(input)) { + if (input.qbs.toolchain.contains("qcc")) + language = qnxLangArgs(input, tag); + else + language = ["-x", languageName(tag) + (pchOutput ? '-header' : '')]; + } + if (!compilerPath) + // fall back to main compiler + compilerPath = input.cpp.compilerPath; + return { + path: compilerPath, + language: language, + tag: tag + }; +} + + +function qnxLangArgs(config, tag) { + switch (tag) { + case "c": + return ["-lang-c"]; + case "cpp": + return ["-lang-c++"]; + default: + return []; + } +} + +function handleCpuFeatures(input, flags) { + function potentiallyAddFlagForFeature(propName, flagName) { + var propValue = input.cpufeatures[propName]; + if (propValue === true) + flags.push("-m" + flagName); + else if (propValue === false) + flags.push("-mno-" + flagName); + } + + if (!input.qbs.architecture) + return; + if (input.qbs.architecture.startsWith("x86")) { + potentiallyAddFlagForFeature("x86_avx", "avx"); + potentiallyAddFlagForFeature("x86_avx2", "avx2"); + potentiallyAddFlagForFeature("x86_avx512bw", "avx512bw"); + potentiallyAddFlagForFeature("x86_avx512cd", "avx512cd"); + potentiallyAddFlagForFeature("x86_avx512dq", "avx512dq"); + potentiallyAddFlagForFeature("x86_avx512er", "avx512er"); + potentiallyAddFlagForFeature("x86_avx512f", "avx512f"); + potentiallyAddFlagForFeature("x86_avx512ifma", "avx512ifma"); + potentiallyAddFlagForFeature("x86_avx512pf", "avx512pf"); + potentiallyAddFlagForFeature("x86_avx512vbmi", "avx512vbmi"); + potentiallyAddFlagForFeature("x86_avx512vl", "avx512vl"); + potentiallyAddFlagForFeature("x86_f16c", "f16c"); + potentiallyAddFlagForFeature("x86_sse2", "sse2"); + potentiallyAddFlagForFeature("x86_sse3", "sse3"); + potentiallyAddFlagForFeature("x86_sse4_1", "sse4.1"); + potentiallyAddFlagForFeature("x86_sse4_2", "sse4.2"); + potentiallyAddFlagForFeature("x86_ssse3", "ssse3"); + } else if (input.qbs.architecture.startsWith("arm")) { + if (input.cpufeatures.arm_neon === true) + flags.push("-mfpu=neon"); + if (input.cpufeatures.arm_vfpv4 === true) + flags.push("-mfpu=vfpv4"); + } else if (input.qbs.architecture.startsWith("mips")) { + potentiallyAddFlagForFeature("mips_dsp", "dsp"); + potentiallyAddFlagForFeature("mips_dspr2", "dspr2"); + } +} + +function standardFallbackValueOrDefault(toolchain, compilerVersion, languageVersion, + useLanguageVersionFallback) { + // NEVER use the fallback values (safety brake for users in case our version map is ever wrong) + if (useLanguageVersionFallback === false) + return languageVersion; + + // Deprecated, but compatible with older compiler versions. + // Note that these versions are the first to support the *value* to the -std= command line + // option, not necessarily the first versions where support for that language standard was + // considered fully implemented. Tested manually. + var languageVersionsMap = { + "c++11": { + "fallback": "c++0x", + "toolchains": [ + {"name": "xcode", "version": "4.3"}, + {"name": "clang", "version": "3.0"}, + {"name": "gcc", "version": "4.7"} + ] + }, + "c11": { + "fallback": "c1x", + "toolchains": [ + {"name": "xcode", "version": "5.0"}, + {"name": "clang", "version": "3.1"}, + {"name": "gcc", "version": "4.7"} + ] + }, + "c17": { + "fallback": "c11", + "toolchains": [ + {"name": "xcode", "version": "10.2"}, + {"name": "clang", "version": "7.0"}, + {"name": "gcc", "version": "8.1"} + ] + }, + "c2x": { + "fallback": "c17", + "toolchains": [ + {"name": "xcode", "version": "11.4"}, + {"name": "clang", "version": "9.0"}, + {"name": "gcc", "version": "9.0"} + ] + }, + "c++14": { + "fallback": "c++1y", + "toolchains": [ + {"name": "xcode", "version": "6.3"}, + {"name": "clang", "version": "3.5"}, + {"name": "gcc", "version": "4.9"} + ] + }, + "c++17": { + "fallback": "c++1z", + "toolchains": [ + {"name": "xcode", "version": "9.3"}, + {"name": "clang", "version": "5.0"}, + {"name": "gcc", "version": "5.1"} + ] + }, + "c++20": { + "fallback": "c++2a", + "toolchains": [ + {"name": "xcode", "version": "12.5"}, + {"name": "clang", "version": "11.0"}, + {"name": "gcc", "version": "10.1"} + ] + }, + "c++23": { + "fallback": "c++2b", + "toolchains": [ + {"name": "xcode"}, + {"name": "clang"}, + {"name": "gcc"} + ] + } + }; + + var m = languageVersionsMap[languageVersion]; + if (m) { + for (var idx = 0; idx < m.toolchains.length; ++idx) { + var tc = m.toolchains[idx]; + if (toolchain.contains(tc.name)) { + // If we found our toolchain and it doesn't yet support the language standard + // we're requesting, or we're using an older version that only supports the + // preliminary flag, use that. + if (useLanguageVersionFallback + || !tc.version + || Utilities.versionCompare(compilerVersion, tc.version) < 0) + return m.fallback; + break; + } + } + } + + // If we didn't find our toolchain at all, simply use the standard value. + return languageVersion; +} + +function compilerFlags(project, product, input, output, explicitlyDependsOn) { + var i; + + // Determine which C-language we're compiling + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(output.fileTags)); + if (!["c", "cpp", "objc", "objcpp", "asm_cpp"].contains(tag)) + throw ("unsupported source language: " + tag); + + var compilerInfo = effectiveCompilerInfo(product.qbs.toolchain, + input, output); + + var args = additionalCompilerAndLinkerFlags(product); + + Array.prototype.push.apply(args, product.cpp.sysrootFlags); + handleCpuFeatures(input, args); + + if (input.cpp.debugInformation) + args.push('-g'); + var opt = input.cpp.optimization + if (opt === 'fast') + args.push('-O2'); + if (opt === 'small') + args.push('-Os'); + if (opt === 'none') + args.push('-O0'); + + var warnings = input.cpp.warningLevel + if (warnings === 'none') + args.push('-w'); + if (warnings === 'all') { + args.push('-Wall'); + args.push('-Wextra'); + } + if (input.cpp.treatWarningsAsErrors) + args.push('-Werror'); + + args = args.concat(configFlags(input)); + + if (!input.qbs.toolchain.contains("qcc")) + args.push('-pipe'); + + if (input.cpp.enableReproducibleBuilds) { + var toolchain = product.qbs.toolchain; + if (!toolchain.contains("clang")) { + var hashString = FileInfo.relativePath(project.sourceDirectory, input.filePath); + var hash = Utilities.getHash(hashString); + args.push("-frandom-seed=0x" + hash.substring(0, 8)); + } + + var major = product.cpp.compilerVersionMajor; + var minor = product.cpp.compilerVersionMinor; + if ((toolchain.contains("clang") && (major > 3 || (major === 3 && minor >= 5))) || + (toolchain.contains("gcc") && (major > 4 || (major === 4 && minor >= 9)))) { + args.push("-Wdate-time"); + } + } + + var useArc = input.cpp.automaticReferenceCounting; + if (useArc !== undefined && (tag === "objc" || tag === "objcpp")) { + args.push(useArc ? "-fobjc-arc" : "-fno-objc-arc"); + } + + var enableExceptions = input.cpp.enableExceptions; + if (enableExceptions !== undefined) { + if (tag === "cpp" || tag === "objcpp") + args.push(enableExceptions ? "-fexceptions" : "-fno-exceptions"); + + if (tag === "objc" || tag === "objcpp") { + args.push(enableExceptions ? "-fobjc-exceptions" : "-fno-objc-exceptions"); + if (useArc !== undefined) + args.push(useArc ? "-fobjc-arc-exceptions" : "-fno-objc-arc-exceptions"); + } + } + + var enableRtti = input.cpp.enableRtti; + if (enableRtti !== undefined && (tag === "cpp" || tag === "objcpp")) { + args.push(enableRtti ? "-frtti" : "-fno-rtti"); + } + + var visibility = input.cpp.visibility; + if (!product.qbs.toolchain.contains("mingw")) { + if (visibility === 'hidden' || visibility === 'minimal') + args.push('-fvisibility=hidden'); + if ((visibility === 'hiddenInlines' || visibility === 'minimal') && tag === 'cpp') + args.push('-fvisibility-inlines-hidden'); + if (visibility === 'default') + args.push('-fvisibility=default') + } + + if (compilerInfo.language) + // Only push language arguments if we have to. + Array.prototype.push.apply(args, compilerInfo.language); + + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag)); + + var pchTag = compilerInfo.tag + "_pch"; + var pchOutput = output.fileTags.contains(pchTag); + var pchInputs = explicitlyDependsOn[pchTag]; + if (!pchOutput && pchInputs && pchInputs.length === 1 + && ModUtils.moduleProperty(input, 'usePrecompiledHeader', tag)) { + var pchInput = pchInputs[0]; + var pchFilePath = FileInfo.joinPaths(FileInfo.path(pchInput.filePath), + pchInput.completeBaseName); + args.push(input.cpp.preincludeFlag, pchFilePath); + } + + args = args.concat(Cpp.collectPreincludePathsArguments(input)); + + var positionIndependentCode = input.cpp.positionIndependentCode; + if (positionIndependentCode && !product.qbs.targetOS.contains("windows")) + args.push('-fPIC'); + + var cppFlags = input.cpp.cppFlags; + for (i in cppFlags) + args.push('-Wp,' + cppFlags[i]) + + args = args.concat(Cpp.collectDefinesArguments(input)); + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + var minimumWindowsVersion = input.cpp.minimumWindowsVersion; + if (minimumWindowsVersion && product.qbs.targetOS.contains("windows")) { + var hexVersion = WindowsUtils.getWindowsVersionInFormat(minimumWindowsVersion, 'hex'); + if (hexVersion) { + var versionDefs = [ 'WINVER', '_WIN32_WINNT', '_WIN32_WINDOWS' ]; + for (i in versionDefs) + args.push(input.cpp.defineFlag + versionDefs[i] + '=' + hexVersion); + } + } + + function currentLanguageVersion(tag) { + switch (tag) { + case "c": + case "objc": + var knownValues = ["c2x", "c17", "c11", "c99", "c90", "c89"]; + return Cpp.languageVersion(input.cpp.cLanguageVersion, knownValues, "C"); + case "cpp": + case "objcpp": + knownValues = ["c++23", "c++2b", "c++20", "c++2a", "c++17", "c++1z", + "c++14", "c++1y", "c++11", "c++0x", + "c++03", "c++98"]; + return Cpp.languageVersion(input.cpp.cxxLanguageVersion, knownValues, "C++"); + } + } + + var langVersion = currentLanguageVersion(tag); + if (langVersion) { + args.push("-std=" + standardFallbackValueOrDefault(product.qbs.toolchain, + product.cpp.compilerVersion, + langVersion, + product.cpp.useLanguageVersionFallback)); + } + + if (tag === "cpp" || tag === "objcpp") { + var cxxStandardLibrary = product.cpp.cxxStandardLibrary; + if (cxxStandardLibrary && product.qbs.toolchain.contains("clang")) { + args.push("-stdlib=" + cxxStandardLibrary); + } + } + + args.push("-o", output.filePath); + args.push("-c", input.filePath); + + return args; +} + +function additionalCompilerAndLinkerFlags(product) { + var args = [] + + var requireAppExtensionSafeApi = product.cpp.requireAppExtensionSafeApi; + if (requireAppExtensionSafeApi !== undefined && product.qbs.targetOS.contains("darwin")) { + args.push(requireAppExtensionSafeApi ? "-fapplication-extension" : "-fno-application-extension"); + } + + return args +} + +// Returns the GCC language name equivalent to fileTag, accepted by the -x argument +function languageName(fileTag) { + if (fileTag === 'c') + return 'c'; + else if (fileTag === 'cpp') + return 'c++'; + else if (fileTag === 'objc') + return 'objective-c'; + else if (fileTag === 'objcpp') + return 'objective-c++'; + else if (fileTag === 'asm') + return 'assembler'; + else if (fileTag === 'asm_cpp') + return 'assembler-with-cpp'; +} + +function prepareAssembler(project, product, inputs, outputs, input, output) { + var assemblerPath = product.cpp.assemblerPath; + + var args = product.cpp.targetAssemblerFlags; + + if (input.cpp.debugInformation) + args.push('-g'); + + var warnings = input.cpp.warningLevel + if (warnings === 'none') + args.push('-W'); + + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input, input.cpp.includeFlag)); + + args.push("-o", output.filePath); + args.push(input.filePath); + + var cmd = new Command(assemblerPath, args); + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + return cmd; +} + +function compilerEnvVars(config, compilerInfo) +{ + if (config.qbs.toolchain.contains("qcc")) + return ["QCC_CONF_PATH"]; + + var list = ["CPATH", "TMPDIR"]; + if (compilerInfo.tag === "c") + list.push("C_INCLUDE_PATH"); + else if (compilerInfo.tag === "cpp") + list.push("CPLUS_INCLUDE_PATH"); + else if (compilerInfo.tag === "objc") + list.push("OBJC_INCLUDE_PATH"); + else if (compilerInfo.tag === "objccpp") + list.push("OBJCPLUS_INCLUDE_PATH"); + if (config.qbs.targetOS.contains("macos")) + list.push("MACOSX_DEPLOYMENT_TARGET"); + else if (config.qbs.targetOS.contains("ios")) + list.push("IPHONEOS_DEPLOYMENT_TARGET"); + else if (config.qbs.targetOS.contains("tvos")) + list.push("TVOS_DEPLOYMENT_TARGET"); + else if (config.qbs.targetOS.contains("watchos")) + list.push("WATCHOS_DEPLOYMENT_TARGET"); + if (config.qbs.toolchain.contains("clang")) { + list.push("TEMP", "TMP"); + } else { + list.push("LANG", "LC_CTYPE", "LC_MESSAGES", "LC_ALL", "GCC_COMPARE_DEBUG", + "GCC_EXEC_PREFIX", "COMPILER_PATH", "SOURCE_DATE_EPOCH"); + } + return list; +} + +function linkerEnvVars(config, inputs) +{ + if (config.qbs.toolchain.contains("clang") || config.qbs.toolchain.contains("qcc")) + return []; + var list = ["GNUTARGET", "LDEMULATION", "COLLECT_NO_DEMANGLE"]; + if (useCompilerDriverLinker(config, inputs)) + list.push("LIBRARY_PATH"); + return list; +} + +function setResponseFileThreshold(command, product) +{ + if (product.qbs.targetOS.contains("windows") && Host.os().contains("windows")) + command.responseFileThreshold = 10000; +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var compilerInfo = effectiveCompilerInfo(product.qbs.toolchain, + input, output); + var compilerPath = compilerInfo.path; + var pchOutput = output.fileTags.contains(compilerInfo.tag + "_pch"); + + var args = compilerFlags(project, product, input, output, explicitlyDependsOn); + var wrapperArgsLength = 0; + var wrapperArgs = product.cpp.compilerWrapper; + var extraEnv; + if (wrapperArgs && wrapperArgs.length > 0) { + + // distcc cannot deal with absolute compiler paths (QBS-1336). + for (var i = 0; i < wrapperArgs.length; ++i) { + if (FileInfo.baseName(wrapperArgs[i]) !== "distcc") + continue; + if (i === wrapperArgs.length - 1) { + if (FileInfo.isAbsolutePath(compilerPath)) { + extraEnv = ["PATH=" + FileInfo.path(compilerPath)]; + compilerPath = FileInfo.fileName(compilerPath); + } + } else if (FileInfo.isAbsolutePath(wrapperArgs[i + 1])) { + extraEnv = ["PATH=" + FileInfo.path(FileInfo.path(wrapperArgs[i + 1]))]; + wrapperArgs[i + 1] = FileInfo.fileName(wrapperArgs[i + 1]); + } + break; + } + + wrapperArgsLength = wrapperArgs.length; + args.unshift(compilerPath); + compilerPath = wrapperArgs.shift(); + args = wrapperArgs.concat(args); + } + + var cmd = new Command(compilerPath, args); + cmd.description = (pchOutput ? 'pre' : '') + 'compiling ' + input.fileName; + if (pchOutput) + cmd.description += ' (' + compilerInfo.tag + ')'; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + cmd.relevantEnvironmentVariables = compilerEnvVars(input, compilerInfo); + if (extraEnv) + cmd.environment = extraEnv; + cmd.responseFileArgumentIndex = wrapperArgsLength; + cmd.responseFileUsagePrefix = '@'; + setResponseFileThreshold(cmd, product); + return cmd; +} + +// Concatenates two arrays of library names and preserves the dependency order that ld needs. +function concatLibs(libs, deplibs) { + var r = []; + var s = {}; + + function addLibs(lst) { + for (var i = lst.length; --i >= 0;) { + var lib = lst[i]; + if (!s[lib]) { + s[lib] = true; + r.unshift(lib); + } + } + } + + addLibs(deplibs); + addLibs(libs); + return r; +} + +function collectStdoutLines(command, args) +{ + var p = new Process(); + try { + p.exec(command, args); + return p.readStdOut().split(/\r?\n/g).filter(function (e) { return e; }); + } finally { + p.close(); + } +} + +function getSymbolInfo(product, inputFile) +{ + var result = { }; + var command = product.cpp.nmPath; + var args = ["-g", "-P"]; + if (product.cpp._nmHasDynamicOption) + args.push("-D"); + try { + result.allGlobalSymbols = collectStdoutLines(command, args.concat(inputFile)); + + // GNU nm has the "--defined" option but POSIX nm does not, so we have to manually + // construct the list of defined symbols by subtracting. + var undefinedGlobalSymbols = collectStdoutLines(command, args.concat(["-u", inputFile])); + result.definedGlobalSymbols = result.allGlobalSymbols.filter(function(line) { + return !undefinedGlobalSymbols.contains(line); }); + result.success = true; + } catch (e) { + console.debug("Failed to collect symbols for shared library: nm command '" + + command + "' failed (" + e.toString() + ")"); + result.success = false; + } + return result; +} + +function createSymbolFile(filePath, allSymbols, definedSymbols) +{ + var file; + try { + file = new TextFile(filePath, TextFile.WriteOnly); + for (var lineNr in allSymbols) + file.writeLine(allSymbols[lineNr]); + file.writeLine("==="); + for (lineNr in definedSymbols) + file.writeLine(definedSymbols[lineNr]); + } finally { + if (file) + file.close(); + } +} + +function readSymbolFile(filePath) +{ + var result = { success: true, allGlobalSymbols: [], definedGlobalSymbols: [] }; + var file; + try { + file = new TextFile(filePath, TextFile.ReadOnly); + var prop = "allGlobalSymbols"; + while (true) { + var line = file.readLine(); + if (!line) + break; + if (line === "===") { + prop = "definedGlobalSymbols"; + continue; + } + result[prop].push(line); + } + } catch (e) { + console.debug("Failed to read symbols from '" + filePath + "'"); + result.success = false; + } finally { + if (file) + file.close(); + } + return result; +} + +function createSymbolCheckingCommands(product, outputs) { + var commands = []; + if (!outputs.dynamiclibrary || !outputs.dynamiclibrary_symbols) + return commands; + + if (outputs.dynamiclibrary.length !== outputs.dynamiclibrary_symbols.length) + throw new Error("The number of outputs tagged dynamiclibrary (" + + outputs.dynamiclibrary.length + ") must be equal to the number of " + + "outputs tagged dynamiclibrary_symbols (" + + outputs.dynamiclibrary_symbols.length + ")"); + + for (var d = 0; d < outputs.dynamiclibrary_symbols.length; ++d) { + // Update the symbols file if the list of relevant symbols has changed. + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.d = d; + cmd.sourceCode = function() { + if (outputs.dynamiclibrary[d].qbs.buildVariant + !== outputs.dynamiclibrary_symbols[d].qbs.buildVariant) + throw new Error("Build variant of output tagged dynamiclibrary (" + + outputs.dynamiclibrary[d].qbs.buildVariant + ") is not equal to " + + "build variant of output tagged dynamiclibrary_symbols (" + + outputs.dynamiclibrary_symbols[d].qbs.buildVariant + ") at index " + + d); + + var libFilePath = outputs.dynamiclibrary[d].filePath; + var symbolFilePath = outputs.dynamiclibrary_symbols[d].filePath; + + var newNmResult = getSymbolInfo(product, libFilePath); + if (!newNmResult.success) + return; + + if (!File.exists(symbolFilePath)) { + console.debug("Symbol file '" + symbolFilePath + "' does not yet exist."); + createSymbolFile(symbolFilePath, newNmResult.allGlobalSymbols, + newNmResult.definedGlobalSymbols); + return; + } + + var oldNmResult = readSymbolFile(symbolFilePath); + var checkMode = product.cpp.exportedSymbolsCheckMode; + var oldSymbols; + var newSymbols; + if (checkMode === "strict") { + oldSymbols = oldNmResult.allGlobalSymbols; + newSymbols = newNmResult.allGlobalSymbols; + } else { + var weakFilter = function(line) { + var symbolType = line.split(/\s+/)[1]; + return symbolType != "v" && symbolType != "V" + && symbolType != "w" && symbolType != "W"; + }; + oldSymbols = oldNmResult.definedGlobalSymbols.filter(weakFilter); + newSymbols = newNmResult.definedGlobalSymbols.filter(weakFilter); + } + if (oldSymbols.length !== newSymbols.length) { + console.debug("List of relevant symbols differs for '" + libFilePath + "'."); + createSymbolFile(symbolFilePath, newNmResult.allGlobalSymbols, + newNmResult.definedGlobalSymbols); + return; + } + for (var i = 0; i < oldSymbols.length; ++i) { + var oldLine = oldSymbols[i]; + var newLine = newSymbols[i]; + var oldLineElems = oldLine.split(/\s+/); + var newLineElems = newLine.split(/\s+/); + if (oldLineElems[0] !== newLineElems[0] // Object name. + || oldLineElems[1] !== newLineElems[1]) { // Object type + console.debug("List of relevant symbols differs for '" + libFilePath + "'."); + createSymbolFile(symbolFilePath, newNmResult.allGlobalSymbols, + newNmResult.definedGlobalSymbols); + return; + } + } + } + commands.push(cmd); + } + return commands; +} + +function separateDebugInfoCommands(product, outputs, primaryOutput) { + var commands = []; + + var debugInfo = outputs.debuginfo_app || outputs.debuginfo_dll + || outputs.debuginfo_loadablemodule; + + if (debugInfo) { + var objcopy = product.cpp.objcopyPath; + + var cmd = new Command(objcopy, ["--only-keep-debug", primaryOutput.filePath, + debugInfo[0].filePath]); + cmd.silent = true; + commands.push(cmd); + + cmd = new Command(objcopy, ["--strip-debug", primaryOutput.filePath]); + cmd.silent = true; + commands.push(cmd); + + cmd = new Command(objcopy, ["--add-gnu-debuglink=" + debugInfo[0].filePath, + primaryOutput.filePath]); + cmd.silent = true; + commands.push(cmd); + } + + return commands; +} + +function separateDebugInfoCommandsDarwin(product, outputs, primaryOutputs) { + var commands = []; + + var debugInfo = outputs.debuginfo_app || outputs.debuginfo_dll + || outputs.debuginfo_loadablemodule; + if (debugInfo) { + var dsymPath = debugInfo[0].filePath; + if (outputs.debuginfo_bundle && outputs.debuginfo_bundle[0]) + dsymPath = outputs.debuginfo_bundle[0].filePath; + + var flags = product.cpp.dsymutilFlags || []; + var files = primaryOutputs.map(function (f) { return f.filePath; }); + var cmd = new Command(product.cpp.dsymutilPath, + flags.concat(["-o", dsymPath].concat(files))); + cmd.description = "generating dSYM for " + product.name; + commands.push(cmd); + + // strip debug info + cmd = new Command(product.cpp.stripPath, ["-S"].concat(files)); + cmd.silent = true; + commands.push(cmd); + } + + return commands; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var i, primaryOutput, cmd, commands = []; + + if (outputs.application) { + primaryOutput = outputs.application[0]; + } else if (outputs.dynamiclibrary) { + primaryOutput = outputs.dynamiclibrary[0]; + } else if (outputs.loadablemodule) { + primaryOutput = outputs.loadablemodule[0]; + } + + var linkerPath = effectiveLinkerPath(product, inputs) + + var args = linkerFlags(project, product, inputs, outputs, primaryOutput, linkerPath); + var wrapperArgsLength = 0; + var wrapperArgs = product.cpp.linkerWrapper; + if (wrapperArgs && wrapperArgs.length > 0) { + wrapperArgsLength = wrapperArgs.length; + args.unshift(linkerPath); + linkerPath = wrapperArgs.shift(); + args = wrapperArgs.concat(args); + } + + var responseFileArgumentIndex = wrapperArgsLength; + + // qcc doesn't properly handle response files, so we have to do it manually + var useQnxResponseFileHack = product.qbs.toolchain.contains("qcc") + && useCompilerDriverLinker(product, inputs); + if (useQnxResponseFileHack) { + // qcc needs to see at least one object/library file to think it has something to do, + // so start the response file at the second object file (so, 3 after the last -o option) + var idx = args.lastIndexOf("-o"); + if (idx !== -1 && idx + 3 < args.length) + responseFileArgumentIndex += idx + 3; + } + + cmd = new Command(linkerPath, args); + cmd.description = 'linking ' + primaryOutput.fileName; + cmd.highlight = 'linker'; + cmd.jobPool = "linker"; + cmd.relevantEnvironmentVariables = linkerEnvVars(product, inputs); + cmd.responseFileArgumentIndex = responseFileArgumentIndex; + cmd.responseFileUsagePrefix = useQnxResponseFileHack ? "-Wl,@" : "@"; + setResponseFileThreshold(cmd, product); + commands.push(cmd); + + if (product.qbs.targetOS.contains("darwin")) { + if (!product.aggregate) { + commands = commands.concat(separateDebugInfoCommandsDarwin( + product, outputs, [primaryOutput])); + } + } else { + commands = commands.concat(separateDebugInfoCommands(product, outputs, primaryOutput)); + } + + if (outputs.dynamiclibrary) { + Array.prototype.push.apply(commands, createSymbolCheckingCommands(product, outputs)); + + // Create symlinks from {libfoo, libfoo.1, libfoo.1.0} to libfoo.1.0.0 + var links = outputs["dynamiclibrary_symlink"]; + var symlinkCount = links ? links.length : 0; + for (i = 0; i < symlinkCount; ++i) { + cmd = new Command("ln", ["-sf", primaryOutput.fileName, + links[i].filePath]); + cmd.highlight = "filegen"; + cmd.description = "creating symbolic link '" + + links[i].fileName + "'"; + cmd.workingDirectory = FileInfo.path(primaryOutput.filePath); + commands.push(cmd); + } + } + + if (product.cpp.shouldSignArtifacts) { + Array.prototype.push.apply( + commands, Codesign.prepareSign(project, product, inputs, outputs, input, output)); + } + + return commands; +} + +function debugInfoArtifacts(product, variants, debugInfoTagSuffix) { + var fileTag; + switch (debugInfoTagSuffix) { + case "app": + fileTag = "application"; + break; + case "dll": + fileTag = "dynamiclibrary"; + break; + default: + fileTag = debugInfoTagSuffix; + break; + } + + variants = variants || [{}]; + + var artifacts = []; + if (product.cpp.separateDebugInformation) { + variants.map(function (variant) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.debugInfoFilePath(product, + variant.suffix, + fileTag)), + fileTags: ["debuginfo_" + debugInfoTagSuffix] + }); + }); + if (PathTools.debugInfoIsBundle(product)) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.debugInfoBundlePath(product, fileTag)), + fileTags: ["debuginfo_bundle"] + }); + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.debugInfoPlistFilePath(product, fileTag)), + fileTags: ["debuginfo_plist"] + }); + } + } + return artifacts; +} + +function dumpMacros(env, compilerFilePath, args, nullDevice, tag) { + var p = new Process(); + try { + p.setEnv("LC_ALL", "C"); + for (var key in env) + p.setEnv(key, env[key]); + // qcc NEEDS the explicit -Wp, prefix to -dM; clang and gcc do not but all three accept it + p.exec(compilerFilePath, + (args || []).concat(["-Wp,-dM", "-E", "-x", languageName(tag || "c") , nullDevice]), + true); + return Cpp.extractMacros(p.readStdOut()); + } finally { + p.close(); + } +} + +function dumpDefaultPaths(env, compilerFilePath, args, nullDevice, pathListSeparator, sysroot, + targetOS) { + var p = new Process(); + try { + p.setEnv("LC_ALL", "C"); + for (var key in env) + p.setEnv(key, env[key]); + args = args || []; + p.exec(compilerFilePath, args.concat(["-v", "-E", "-x", "c++", nullDevice]), true); + var suffix = " (framework directory)"; + var includePaths = []; + var libraryPaths = []; + var frameworkPaths = []; + var addIncludes = false; + var lines = p.readStdErr().trim().split(/\r?\n/g).map(function (line) { return line.trim(); }); + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + var prefix = "LIBRARY_PATH="; + if (line.startsWith(prefix)) { + libraryPaths = libraryPaths.concat(line.substr(prefix.length) + .split(pathListSeparator)); + } else if (line === "#include <...> search starts here:") { + addIncludes = true; + } else if (line === "End of search list.") { + addIncludes = false; + } else if (addIncludes) { + if (line.endsWith(suffix)) + frameworkPaths.push(line.substr(0, line.length - suffix.length)); + else + includePaths.push(line); + } + } + + sysroot = sysroot || ""; + + if (includePaths.length === 0) + includePaths.push(sysroot + "/usr/include", sysroot + "/usr/local/include"); + + if (libraryPaths.length === 0) + libraryPaths.push(sysroot + "/lib", sysroot + "/usr/lib"); + + if (frameworkPaths.length === 0 && targetOS.contains("darwin")) + frameworkPaths.push(sysroot + "/System/Library/Frameworks"); + + return { + "includePaths": includePaths, + "libraryPaths": libraryPaths, + "frameworkPaths": frameworkPaths + }; + } finally { + p.close(); + } +} + +function targetLinkerFlags(targetArch, targetOS) { + var linkerFlags = { + "windows": { + "i386": "i386pe", + "x86_64": "i386pep", + }, + "freebsd": { + "i386": "elf_i386_fbsd", + "x86_64": "elf_x86_64_fbsd", + }, + "other": { + "i386": "elf_i386", + "x86_64": "elf_x86_64", + } + }; + if (targetOS.contains("windows")) + return linkerFlags["windows"][targetArch]; + else if (targetOS.contains("freebsd")) + return linkerFlags["freebsd"][targetArch]; + return linkerFlags["other"][targetArch]; +} + +function targetFlags(tool, hasTargetOption, target, targetArch, machineType, targetOS) { + var args = []; + if (hasTargetOption) { + if (target) + args.push("-target", target); + } else { + var archArgs = { + "compiler": { + "i386": ["-m32"], + "x86_64": ["-m64"], + }, + "linker": { + "i386": ["-m", targetLinkerFlags("i386", targetOS)], + "x86_64": ["-m", targetLinkerFlags("x86_64", targetOS)], + }, + "assembler": { + "i386": ["--32"], + "x86_64": ["--64"], + }, + }; + + var flags = archArgs[tool] ? archArgs[tool][targetArch] : undefined; + if (flags) + args = args.concat(flags); + + if (machineType && tool !== "linker") + args.push("-march=" + machineType); + } + return args; +} + +function toolNames(rawToolNames, toolchainPrefix) +{ + return toolchainPrefix + ? rawToolNames.map(function(rawName) { return toolchainPrefix + rawName; }) + : rawToolNames; +} + +function pathPrefix(baseDir, prefix) +{ + var path = ''; + if (baseDir) { + path += baseDir; + if (path.substr(-1) !== '/') + path += '/'; + } + if (prefix) + path += prefix; + return path; +} diff --git a/share/qbs/modules/cpp/iar.js b/share/qbs/modules/cpp/iar.js new file mode 100644 index 00000000..d5f019cb --- /dev/null +++ b/share/qbs/modules/cpp/iar.js @@ -0,0 +1,768 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); + +function supportXLinker(architecture) { + return architecture === "78k" + || architecture === "avr" + || architecture === "avr32" + || architecture === "cr16" + || architecture === "hcs12" + || architecture === "hcs8" + || architecture === "m16c" + || architecture === "m32c" + || architecture === "m68k" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "r32c" + || architecture === "v850"; +} + +function supportILinker(architecture) { + return architecture.startsWith("arm") + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx" + || architecture === "sh" + || architecture === "stm8"; +} + +function supportXArchiver(architecture) { + return architecture === "78k" + || architecture === "avr" + || architecture === "avr32" + || architecture === "cr16" + || architecture === "hcs12" + || architecture === "hcs8" + || architecture === "m16c" + || architecture === "m32c" + || architecture === "m68k" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "r32c" + || architecture === "v850"; +} + +function supportIArchiver(architecture) { + return architecture.startsWith("arm") + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx" + || architecture === "sh" + || architecture === "stm8"; +} + +function supportXAssembler(architecture) { + return architecture.startsWith("arm") + || architecture === "78k" + || architecture === "avr" + || architecture === "hcs12" + || architecture === "m16c" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "m32c" + || architecture === "v850"; +} + +function supportIAssembler(architecture) { + return architecture === "avr32" + || architecture === "cr16" + || architecture === "hcs8" + || architecture === "r32c" + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx" + || architecture === "sh" + || architecture === "stm8" + || architecture === "m68k"; +} + +function supportEndianness(architecture) { + return architecture.startsWith("arm") + || architecture === "rx"; +} + +function supportCppExceptions(architecture) { + return architecture.startsWith("arm") + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx"; +} + +function supportCppRtti(architecture) { + return architecture.startsWith("arm") + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx"; +} + +function supportCppWarningAboutCStyleCast(architecture) { + return architecture.startsWith("arm") + || architecture === "avr" + || architecture === "avr32" + || architecture === "cr16" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "rh850" + || architecture === "rl78" + || architecture === "rx" + || architecture === "stm8" + || architecture === "v850"; +} + +function supportDeprecatedFeatureWarnings(architecture) { + return architecture.startsWith("arm") + || architecture === "avr" + || architecture === "cr16" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "rh850" + || architecture === "rl78" + || architecture === "rx" + || architecture === "stm8" + || architecture === "v850"; +} + +function supportCLanguageVersion(architecture) { + return architecture !== "78k"; +} + +function supportCppLanguage(compilerFilePath) { + var baseName = FileInfo.baseName(compilerFilePath); + return baseName !== "iccs08"; +} + +// It is a 'magic' IAR-specific target architecture code. +function architectureCode(architecture) { + switch (architecture) { + case "78k": + return "26"; + case "avr": + return "90"; + case "avr32": + return "82"; + case "mcs51": + return "51"; + case "msp430": + return "43"; + case "v850": + return "85"; + case "m68k": + return "68"; + case "m32c": + return "48"; + case "r32c": + return "53"; + case "m16c": + return "34"; + case "cr16": + return "45"; + case "hcs12": + return "12"; + case "hcs8": + return "78"; + case "rh850": case "riscv": case "rl78": case "rx": case "sh": case "stm8": + return ""; + default: + if (architecture.startsWith("arm")) + return ""; + break; + } +} + +function toolchainDetails(qbs) { + var architecture = qbs.architecture; + var code = architectureCode(architecture); + var details = {}; + + if (supportXLinker(architecture)) { + details.libraryPathFlag = "-I"; + details.linkerScriptFlag = "-f"; + details.linkerName = "xlink"; + details.linkerSilentFlag = "-S"; + details.linkerMapFileFlag = "-l"; + details.linkerEntryPointFlag = "-s"; + } else if (supportILinker(architecture)) { + details.libraryPathFlag = "-L"; + details.linkerScriptFlag = "--config"; + details.linkerSilentFlag = "--silent"; + details.linkerMapFileFlag = "--map"; + details.linkerEntryPointFlag = "--entry"; + details.linkerName = architecture.startsWith("arm") + ? "ilinkarm" : ("ilink" + architecture); + } + + if (supportXArchiver(architecture)) + details.archiverName = "xar"; + else if (supportIArchiver(architecture)) + details.archiverName = "iarchive"; + + var hasCode = (code !== ""); + details.staticLibrarySuffix = hasCode ? (".r" + code) : ".a"; + details.executableSuffix = hasCode + ? ((qbs.debugInformation) ? (".d" + code) : (".a" + code)) : ".out"; + details.objectSuffix = hasCode ? (".r" + code) : ".o"; + details.imageFormat = hasCode ? "ubrof" : "elf"; + + if (architecture.startsWith("arm")) { + details.compilerName = "iccarm"; + details.assemblerName = "iasmarm"; + } else if (architecture === "78k") { + details.compilerName = "icc78k"; + details.assemblerName = "a78k"; + } else if (architecture === "avr") { + details.compilerName = "iccavr"; + details.assemblerName = "aavr"; + } else if (architecture === "avr32") { + details.compilerName = "iccavr32"; + details.assemblerName = "aavr32"; + } else if (architecture === "cr16") { + details.compilerName = "icccr16c"; + details.assemblerName = "acr16c"; + } else if (architecture === "hcs12") { + details.compilerName = "icchcs12"; + details.assemblerName = "ahcs12"; + } else if (architecture === "hcs8") { + details.compilerName = "iccs08"; + details.assemblerName = "as08"; + } else if (architecture === "m16c") { + details.compilerName = "iccm16c"; + details.assemblerName = "am16c"; + } else if (architecture === "m32c") { + details.compilerName = "iccm32c"; + details.assemblerName = "am32c"; + } else if (architecture === "m68k") { + details.compilerName = "icccf"; + details.assemblerName = "acf"; + } else if (architecture === "mcs51") { + details.compilerName = "icc8051"; + details.assemblerName = "a8051"; + } else if (architecture === "msp430") { + details.compilerName = "icc430"; + details.assemblerName = "a430"; + } else if (architecture === "r32c") { + details.compilerName = "iccr32c"; + details.assemblerName = "ar32c"; + } else if (architecture === "rh850") { + details.compilerName = "iccrh850"; + details.assemblerName = "iasmrh850"; + } else if (architecture === "riscv") { + details.compilerName = "iccriscv"; + details.assemblerName = "iasmriscv"; + } else if (architecture === "rl78") { + details.compilerName = "iccrl78"; + details.assemblerName = "iasmrl78"; + } else if (architecture === "rx") { + details.compilerName = "iccrx"; + details.assemblerName = "iasmrx"; + } else if (architecture === "sh") { + details.compilerName = "iccsh"; + details.assemblerName = "iasmsh"; + } else if (architecture === "stm8") { + details.compilerName = "iccstm8"; + details.assemblerName = "iasmstm8"; + } else if (architecture === "v850") { + details.compilerName = "iccv850"; + details.assemblerName = "av850"; + } + + return details; +} + +function guessArmArchitecture(core) { + var arch = "arm"; + if (core === "__ARM4M__") + arch += "v4m"; + else if (core === "__ARM4TM__") + arch += "v4tm"; + else if (core === "__ARM5E__") + arch += "v5e"; + else if (core === "__ARM5__") + arch += "v5"; + else if (core === "__ARM6M__") + arch += "v6m"; + else if (core === "__ARM6SM__") + arch += "v6sm"; + else if (core === "__ARM6__") + arch += "v6"; + else if (core === "__ARM7M__") + arch += "v7m"; + else if (core === "__ARM7R__") + arch += "v7r"; + return arch; +} + +function guessArchitecture(macros) { + if (macros["__ICC430__"] === "1") + return "msp430"; + else if (macros["__ICC78K__"] === "1") + return "78k"; + else if (macros["__ICC8051__"] === "1") + return "mcs51"; + else if (macros["__ICCARM__"] === "1") + return guessArmArchitecture(macros["__CORE__"]); + else if (macros["__ICCAVR32__"] === "1") + return "avr32"; + else if (macros["__ICCAVR__"] === "1") + return "avr"; + else if (macros["__ICCCF__"] === "1") + return "m68k"; + else if (macros["__ICCCR16C__"] === "1") + return "cr16"; + else if (macros["__ICCHCS12__"] === "1") + return "hcs12"; + else if (macros["__ICCM16C__"] === "1") + return "m16c"; + else if (macros["__ICCM32C__"] === "1") + return "m32c"; + else if (macros["__ICCR32C__"] === "1") + return "r32c"; + else if (macros["__ICCRH850__"] === "1") + return "rh850"; + else if (macros["__ICCRISCV__"] === "1") + return "riscv"; + else if (macros["__ICCRL78__"] === "1") + return "rl78"; + else if (macros["__ICCRX__"] === "1") + return "rx"; + else if (macros["__ICCS08__"] === "1") + return "hcs8"; + else if (macros["__ICCSH__"] === "1") + return "sh"; + else if (macros["__ICCSTM8__"] === "1") + return "stm8"; + else if (macros["__ICCV850__"] === "1") + return "v850"; +} + +function guessEndianness(macros) { + if (macros["__LITTLE_ENDIAN__"] === "1") + return "little"; + return "big" +} + +function guessVersion(macros, architecture) { + var version = parseInt(macros["__VER__"], 10); + if (architecture.startsWith("arm")) { + return { major: parseInt(version / 1000000), + minor: parseInt(version / 1000) % 1000, + patch: parseInt(version) % 1000 } + } else if (architecture === "78k" + || architecture === "avr" + || architecture === "avr32" + || architecture === "cr16" + || architecture === "hcs12" + || architecture === "hcs8" + || architecture === "m16c" + || architecture === "m32c" + || architecture === "m68k" + || architecture === "mcs51" + || architecture === "msp430" + || architecture === "r32c" + || architecture === "rh850" + || architecture === "riscv" + || architecture === "rl78" + || architecture === "rx" + || architecture === "sh" + || architecture === "stm8" + || architecture === "v850") { + return { major: parseInt(version / 100), + minor: parseInt(version % 100), + patch: 0 } + } +} + +function cppLanguageOption(compilerFilePath) { + var baseName = FileInfo.baseName(compilerFilePath); + switch (baseName) { + case "iccarm": + case "iccrh850": + case "iccriscv": + case "iccrl78": + case "iccrx": + return "--c++"; + case "icc430": + case "icc78k": + case "icc8051": + case "iccavr": + case "iccavr32": + case "icccf": + case "icccr16c": + case "icchcs12": + case "iccm16c": + case "iccm32c": + case "iccr32c": + case "iccsh": + case "iccstm8": + case "iccv850": + return "--ec++"; + } +} + +function dumpMacros(compilerFilePath, tag) { + var tempDir = new TemporaryDir(); + var inFilePath = FileInfo.fromNativeSeparators(tempDir.path() + "/empty-source.c"); + var inFile = new TextFile(inFilePath, TextFile.WriteOnly); + var outFilePath = FileInfo.fromNativeSeparators(tempDir.path() + "/iar-macros.predef"); + + var args = [ inFilePath, "--predef_macros", outFilePath ]; + if (tag === "cpp" && supportCppLanguage(compilerFilePath)) + args.push(cppLanguageOption(compilerFilePath)); + + var p = new Process(); + p.exec(compilerFilePath, args, true); + var outFile = new TextFile(outFilePath, TextFile.ReadOnly); + return Cpp.extractMacros(outFile.readAll()); +} + +function dumpCompilerIncludePaths(compilerFilePath, tag) { + // We can dump the compiler include paths using the undocumented `--IDE3` flag, + // e.g. which also is used in the IAR extension for the VSCode. In this case the + // compiler procuces the console output in the following format: + // `$$TOOL_BEGIN $$VERSION "3" $$INC_BEGIN $$FILEPATH "" $$TOOL_END` + + var tempDir = new TemporaryDir(); + var inFilePath = FileInfo.fromNativeSeparators(tempDir.path() + "/empty-source.c"); + var inFile = new TextFile(inFilePath, TextFile.WriteOnly); + + var args = ["--IDE3", inFilePath]; + if (tag === "cpp" && supportCppLanguage(compilerFilePath)) + args.push(cppLanguageOption(compilerFilePath)); + + var includePaths = []; + var p = new Process(); + // It is possible that the process can return an error code in case the + // compiler does not support the `--IDE3` flag. So, don't throw an error in this case. + p.exec(compilerFilePath, args, false); + p.readStdOut().trim().split(/\r?\n/g).map(function(line) { + var m = line.match(/\$\$INC_BEGIN\s\$\$FILEPATH\s\"([^"]*)/); + if (m) { + var includePath = m[1].replace(/\\\\/g, '/'); + if (includePath && File.exists(includePath)) + includePaths.push(includePath); + } + }); + + if (includePaths.length === 0) { + // This can happen if the compiler does not support the `--IDE3` flag, + // e.g. IAR for S08 architecture. In this case we use fallback to the + // detection of the `inc` directory. + var includePath = FileInfo.joinPaths(FileInfo.path(compilerFilePath), "../inc/"); + if (File.exists(includePath)) + includePaths.push(includePath); + } + + return includePaths; +} + +function dumpDefaultPaths(compilerFilePath, tag) { + var includePaths = dumpCompilerIncludePaths(compilerFilePath, tag); + return { + "includePaths": includePaths + }; +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + + // Input. + args.push(input.filePath); + + // Output. + args.push("-o", outputs.obj[0].filePath); + + // Preinclude headers. + args = args.concat(Cpp.collectPreincludePathsArguments(input, true)); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + // Silent output generation flag. + args.push("--silent"); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("--debug"); + + // Optimization flags. + switch (input.cpp.optimization) { + case "small": + args.push("-Ohz"); + break; + case "fast": + args.push("-Ohs"); + break; + case "none": + args.push("-On"); + break; + } + + var architecture = input.qbs.architecture; + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "none": + args.push("--no_warnings"); + break; + case "all": + if (supportDeprecatedFeatureWarnings(architecture)) { + args.push("--deprecated_feature_warnings=" + +"+attribute_syntax," + +"+preprocessor_extensions," + +"+segment_pragmas"); + } + if (tag === "cpp" && supportCppWarningAboutCStyleCast(architecture)) + args.push("--warn_about_c_style_casts"); + break; + } + if (input.cpp.treatWarningsAsErrors) + args.push("--warnings_are_errors"); + + // C language version flags. + if (tag === "c" && supportCLanguageVersion(architecture)) { + var knownValues = ["c89"]; + var cLanguageVersion = Cpp.languageVersion( + input.cpp.cLanguageVersion, knownValues, "C"); + switch (cLanguageVersion) { + case "c89": + args.push("--c89"); + break; + default: + // Default C language version is C18/C11/C99 that + // depends on the IAR version. + break; + } + } + + // C++ language version flags. + var compilerFilePath = input.cpp.compilerPath; + if (tag === "cpp" && supportCppLanguage(compilerFilePath)) { + // C++ language flag. + var cppOption = cppLanguageOption(compilerFilePath); + args.push(cppOption); + + // Exceptions flag. + var enableExceptions = input.cpp.enableExceptions; + if (!enableExceptions && supportCppExceptions(architecture)) + args.push("--no_exceptions"); + + // RTTI flag. + var enableRtti = input.cpp.enableRtti; + if (!enableRtti && supportCppRtti(architecture)) + args.push("--no_rtti"); + } + + // Byte order flags. + var endianness = input.cpp.endianness; + if (endianness && supportEndianness(architecture)) + args.push("--endian=" + endianness); + + // Listing files generation flag. + if (input.cpp.generateCompilerListingFiles) + args.push("-l", outputs.lst[0].filePath); + + // Misc flags. + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + + // Input. + args.push(input.filePath); + + // Output. + args.push("-o", outputs.obj[0].filePath); + + var architecture = input.qbs.architecture; + + // The `--preinclude` flag is only supported for a certain + // set of assemblers, not for all. + if (supportIAssembler(architecture)) + args = args.concat(Cpp.collectPreincludePathsArguments(input)); + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("-r"); + + // Architecture specific flags. + if (supportIAssembler(architecture)) { + // Silent output generation flag. + args.push("--silent"); + // Warning level flags. + if (input.cpp.warningLevel === "none") + args.push("--no_warnings"); + if (input.cpp.treatWarningsAsErrors) + args.push("--warnings_are_errors"); + } else if (supportXAssembler(architecture)){ + // Silent output generation flag. + args.push("-S"); + // Warning level flags. + args.push("-w" + (input.cpp.warningLevel === "none" ? "-" : "+")); + } + + // Byte order flags. + var endianness = input.cpp.endianness; + if (endianness && supportEndianness(architecture)) + args.push("--endian", endianness); + + // Listing files generation flag. + if (input.cpp.generateAssemblerListingFiles) + args.push("-l", outputs.lst[0].filePath); + + // Misc flags. + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + + // Inputs. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + + // Output. + args.push("-o", outputs.application[0].filePath); + + // Library paths. + args = args.concat(Cpp.collectLibraryPathsArguments(product)); + + // Library dependencies. + args = args.concat(Cpp.collectLibraryDependenciesArguments(product)); + + // Linker scripts. + args = args.concat(Cpp.collectLinkerScriptPathsArguments(product, inputs, true)); + + // Silent output generation flag. + args.push(product.cpp.linkerSilentFlag); + + // Map file generation flag. + if (product.cpp.generateLinkerMapFile) + args.push(product.cpp.linkerMapFileFlag, outputs.mem_map[0].filePath); + + // Entry point flag. + if (product.cpp.entryPoint) + args.push(product.cpp.linkerEntryPointFlag, product.cpp.entryPoint); + + // Debug information flag. + if (supportXLinker(product.qbs.architecture)) { + if (product.cpp.debugInformation) + args.push("-rt"); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscEscapableLinkerArguments(product), + Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function archiverFlags(project, product, inputs, outputs) { + var args = []; + + // Inputs. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + + // Output. + var architecture = product.qbs.architecture; + if (supportIArchiver(architecture)) + args.push("--create"); + args.push("-o", outputs.staticlibrary[0].filePath); + + return args; +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + var compilerPath = input.cpp.compilerPath; + var cmd = new Command(compilerPath, args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + return [cmd]; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); + var assemblerPath = input.cpp.assemblerPath; + var cmd = new Command(assemblerPath, args); + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + return [cmd]; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var primaryOutput = outputs.application[0]; + var args = linkerFlags(project, product, inputs, outputs); + var linkerPath = product.cpp.linkerPath; + var cmd = new Command(linkerPath, args); + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + return [cmd]; +} + +function prepareArchiver(project, product, inputs, outputs, input, output) { + var args = archiverFlags(project, product, inputs, outputs); + var archiverPath = product.cpp.archiverPath; + var cmd = new Command(archiverPath, args); + cmd.description = "creating " + output.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + cmd.stdoutFilterFunction = function(output) { + return ""; + }; + return [cmd]; +} diff --git a/share/qbs/modules/cpp/iar.qbs b/share/qbs/modules/cpp/iar.qbs new file mode 100644 index 00000000..f02c033c --- /dev/null +++ b/share/qbs/modules/cpp/iar.qbs @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.PathTools +import qbs.Probes +import qbs.Utilities +import "cpp.js" as Cpp +import "iar.js" as IAR + +CppModule { + condition: qbs.toolchain && qbs.toolchain.contains("iar") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["iccarm"] + } + + Probes.IarProbe { + id: iarProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + } + + qbs.architecture: iarProbe.found ? iarProbe.architecture : original + qbs.targetPlatform: "none" + + compilerVersionMajor: iarProbe.versionMajor + compilerVersionMinor: iarProbe.versionMinor + compilerVersionPatch: iarProbe.versionPatch + endianness: iarProbe.endianness + + compilerDefinesByLanguage: iarProbe.compilerDefinesByLanguage + compilerIncludePaths: iarProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + compilerName: toolchainDetails.compilerName + compilerExtension + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: toolchainDetails.assemblerName + compilerExtension + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: toolchainDetails.linkerName + compilerExtension + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string archiverName: toolchainDetails.archiverName + compilerExtension + property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + + runtimeLibrary: "static" + + staticLibrarySuffix: toolchainDetails.staticLibrarySuffix + executableSuffix: toolchainDetails.executableSuffix + objectSuffix: toolchainDetails.objectSuffix + + imageFormat: toolchainDetails.imageFormat + + enableExceptions: false + enableRtti: false + + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-I" + preincludeFlag: "--preinclude" + libraryDependencyFlag: "" + libraryPathFlag: toolchainDetails.libraryPathFlag + linkerScriptFlag: toolchainDetails.linkerScriptFlag + + property string linkerSilentFlag: toolchainDetails.linkerSilentFlag + property string linkerMapFileFlag: toolchainDetails.linkerMapFileFlag + property string linkerEntryPointFlag: toolchainDetails.linkerEntryPointFlag + + toolchainDetails: IAR.toolchainDetails(qbs) + + knownArchitectures: ["78k", "arm", "avr", "avr32", "cr16", + "hcs12", "hcs8", "m16c", "m32c", "m68k", "mcs51", "msp430", + "r32c", "rh850", "riscv", "rl78", "rx", "sh", "stm8", "v850"] + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(generateAssemblerListingFiles) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: IAR.prepareAssembler.apply(IAR, arguments) + } + + FileTagger { + patterns: ["*.s", "*.s43", "*.s51", "*.s90", "*.msa", "*.asm"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) + outputArtifacts: Cpp.compilerOutputArtifacts(input) + prepare: IAR.prepareCompiler.apply(IAR, arguments) + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) + outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) + prepare: IAR.prepareLinker.apply(IAR, arguments) + } + + Rule { + id: staticLibraryLinker + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: IAR.prepareArchiver.apply(IAR, arguments) + } +} diff --git a/share/qbs/modules/cpp/ios-gcc.qbs b/share/qbs/modules/cpp/ios-gcc.qbs new file mode 100644 index 00000000..92e072a0 --- /dev/null +++ b/share/qbs/modules/cpp/ios-gcc.qbs @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.DarwinTools +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Utilities + +DarwinGCC { + priority: 1 + condition: qbs.targetOS.contains('ios') && + qbs.toolchain && qbs.toolchain.contains('gcc') + + minimumIosVersion: { + if (Host.architecture() == "armv7a") + return "6.0"; + // XCode 12 requres version (at least 8.0) to be present in the -target triplet + // when compiling for ios-simulator + if (xcode.present && Utilities.versionCompare(xcode.version, "12.0") >= 0) + return "8.0"; + } + targetSystem: "ios" + (minimumIosVersion || "") + + minimumDarwinVersion: minimumIosVersion + minimumDarwinVersionCompilerFlag: qbs.targetOS.contains("ios-simulator") + ? "-mios-simulator-version-min" + : "-miphoneos-version-min" + minimumDarwinVersionLinkerFlag: qbs.targetOS.contains("ios-simulator") + ? "-ios_simulator_version_min" + : "-iphoneos_version_min" + + libcxxAvailable: base + && (!minimumDarwinVersion + || Utilities.versionCompare(minimumDarwinVersion, "5") >= 0) + + platformObjcFlags: base.concat(simulatorObjcFlags) + platformObjcxxFlags: base.concat(simulatorObjcFlags) + + // Private properties + readonly property stringList simulatorObjcFlags: { + // default in Xcode and also required for building 32-bit Simulator binaries with ARC + // since the default ABI version is 0 for 32-bit targets + return qbs.targetOS.contains("ios-simulator") + ? ["-fobjc-abi-version=2", "-fobjc-legacy-dispatch"] + : []; + } + + Rule { + condition: !product.qbs.targetOS.contains("ios-simulator") + inputsFromDependencies: ["bundle.content"] + + Artifact { + filePath: FileInfo.joinPaths(product.destinationDirectory, product.targetName + ".ipa") + fileTags: ["ipa"] + } + + prepare: { + var cmd = new Command("PackageApplication", [input.filePath, "-o", output.filePath]); + cmd.description = "creating ipa"; + cmd.highlight = "codegen"; + return cmd; + } + } +} diff --git a/share/qbs/modules/cpp/keil.js b/share/qbs/modules/cpp/keil.js new file mode 100644 index 00000000..8f3297aa --- /dev/null +++ b/share/qbs/modules/cpp/keil.js @@ -0,0 +1,992 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function isMcs51Architecture(architecture) { + return architecture === "mcs51"; +} + +function isMcs251Architecture(architecture) { + return architecture === "mcs251"; +} + +function isMcsArchitecture(architecture) { + return isMcs51Architecture(architecture) + || isMcs251Architecture(architecture); +} + +function isC166Architecture(architecture) { + return architecture === "c166"; +} + +function isArmArchitecture(architecture) { + return architecture.startsWith("arm"); +} + +function isMcsCompiler(compilerPath) { + var base = FileInfo.baseName(compilerPath).toLowerCase(); + return base === "c51" || base === "cx51" || base === "c251"; +} + +function isC166Compiler(compilerPath) { + return FileInfo.baseName(compilerPath).toLowerCase() === "c166"; +} + +function isArmCCCompiler(compilerPath) { + return FileInfo.baseName(compilerPath).toLowerCase() === "armcc"; +} + +function isArmClangCompiler(compilerPath) { + return FileInfo.baseName(compilerPath).toLowerCase() === "armclang"; +} + +function preincludeFlag(compilerPath) { + if (isArmCCCompiler(compilerPath)) + return "--preinclude"; + else if (isArmClangCompiler(compilerPath)) + return "-include"; +} + +function toolchainDetails(qbs) { + var architecture = qbs.architecture; + if (isMcs51Architecture(architecture)) { + return { + "imageFormat": "omf", + "linkerMapSuffix":".m51", + "objectSuffix": ".obj", + "executableSuffix": ".abs", + "compilerName": "c51", + "assemblerName": "a51", + "linkerName": "bl51", + "archiverName": "lib51" + }; + } else if (isMcs251Architecture(architecture)) { + return { + "imageFormat": "omf", + "linkerMapSuffix":".m51", + "objectSuffix": ".obj", + "executableSuffix": ".abs", + "compilerName": "c251", + "assemblerName": "a251", + "linkerName": "l251", + "archiverName": "lib251" + }; + } else if (isC166Architecture(architecture)) { + return { + "imageFormat": "omf", + "linkerMapSuffix":".m66", + "objectSuffix": ".obj", + "executableSuffix": ".abs", + "compilerName": "c166", + "assemblerName": "a166", + "linkerName": "l166", + "archiverName": "lib166" + }; + } else if (isArmArchitecture(architecture)) { + return { + "imageFormat": "elf", + "linkerMapSuffix":".map", + "objectSuffix": ".o", + "executableSuffix": ".axf", + "disassemblerName": "fromelf", + "compilerName": "armcc", + "assemblerName": "armasm", + "linkerName": "armlink", + "archiverName": "armar" + }; + } +} + +function guessArmCCArchitecture(targetArchArm, targetArchThumb) { + var arch = "arm"; + if (targetArchArm === "4" && targetArchThumb === "0") + arch += "v4"; + else if (targetArchArm === "4" && targetArchThumb === "1") + arch += "v4t"; + else if (targetArchArm === "5" && targetArchThumb === "2") + arch += "v5t"; + else if (targetArchArm === "6" && targetArchThumb === "3") + arch += "v6"; + else if (targetArchArm === "6" && targetArchThumb === "4") + arch += "v6t2"; + else if (targetArchArm === "0" && targetArchThumb === "3") + arch += "v6m"; + else if (targetArchArm === "7" && targetArchThumb === "4") + arch += "v7r"; + else if (targetArchArm === "0" && targetArchThumb === "4") + arch += "v7m"; + return arch; +} + +function guessArmClangArchitecture(targetArchArm, targetArchProfile) { + targetArchProfile = targetArchProfile.replace(/'/g, ""); + var arch = "arm"; + if (targetArchArm !== "" && targetArchProfile !== "") + arch += "v" + targetArchArm + targetArchProfile.toLowerCase(); + return arch; +} + +function guessArchitecture(macros) { + if (macros["__C51__"]) + return "mcs51"; + else if (macros["__C251__"]) + return "mcs251"; + else if (macros["__C166__"]) + return "c166"; + else if (macros["__CC_ARM"] === "1") + return guessArmCCArchitecture(macros["__TARGET_ARCH_ARM"], macros["__TARGET_ARCH_THUMB"]); + else if (macros["__clang__"] === "1" && macros["__arm__"] === "1") + return guessArmClangArchitecture(macros["__ARM_ARCH"], macros["__ARM_ARCH_PROFILE"]); +} + +function guessEndianness(macros) { + if (macros["__C51__"] || macros["__C251__"]) { + // The 8051 processors are 8-bit. So, the data with an integer type + // represented by more than one byte is stored as big endian in the + // Keil toolchain. See for more info: + // * http://www.keil.com/support/man/docs/c51/c51_ap_2bytescalar.htm + // * http://www.keil.com/support/man/docs/c51/c51_ap_4bytescalar.htm + // * http://www.keil.com/support/man/docs/c251/c251_ap_2bytescalar.htm + // * http://www.keil.com/support/man/docs/c251/c251_ap_4bytescalar.htm + return "big"; + } else if (macros["__C166__"]) { + // The C166 processors are 16-bit. So, the data with an integer type + // represented by more than one byte is stored as little endian in the + // Keil toolchain. See for more info: + // * http://www.keil.com/support/man/docs/c166/c166_ap_ints.htm + // * http://www.keil.com/support/man/docs/c166/c166_ap_longs.htm + return "little"; + } else if (macros["__CC_ARM"]) { + return macros["__BIG_ENDIAN"] ? "big" : "little"; + } else if (macros["__clang__"] && macros["__arm__"]) { + switch (macros["__BYTE_ORDER__"]) { + case "__ORDER_BIG_ENDIAN__": + return "big"; + case "__ORDER_LITTLE_ENDIAN__": + return "little"; + } + } +} + +function guessVersion(macros) { + if (macros["__C51__"] || macros["__C251__"]) { + var mcsVersion = macros["__C51__"] || macros["__C251__"]; + return { major: parseInt(mcsVersion / 100), + minor: parseInt(mcsVersion % 100), + patch: 0 } + } else if (macros["__C166__"]) { + var xcVersion = macros["__C166__"]; + return { major: parseInt(xcVersion / 100), + minor: parseInt(xcVersion % 100), + patch: 0 } + } else if (macros["__CC_ARM"] || macros["__clang__"]) { + var armVersion = macros["__ARMCC_VERSION"]; + return { major: parseInt(armVersion / 1000000), + minor: parseInt(armVersion / 10000) % 100, + patch: parseInt(armVersion) % 10000 } + } +} + +function dumpMcsCompilerMacros(compilerFilePath, tag) { + // C51 or C251 compiler support only C language. + if (tag === "cpp") + return {}; + + // Note: The C51 or C251 compiler does not support the predefined + // macros dumping. So, we do it with the following trick, where we try + // to create and compile a special temporary file and to parse the console + // output with the own magic pattern: (""|"key"|"value"|""). + + var outputDirectory = new TemporaryDir(); + var outputFilePath = FileInfo.fromNativeSeparators(FileInfo.joinPaths(outputDirectory.path(), + "dump-macros.c")); + var outputFile = new TextFile(outputFilePath, TextFile.WriteOnly); + + outputFile.writeLine("#define VALUE_TO_STRING(x) #x"); + outputFile.writeLine("#define VALUE(x) VALUE_TO_STRING(x)"); + + // Predefined keys for C51 and C251 compilers, see details: + // * https://www.keil.com/support/man/docs/c51/c51_pp_predefmacroconst.htm + // * https://www.keil.com/support/man/docs/c251/c251_pp_predefmacroconst.htm + var keys = ["__C51__", "__CX51__", "__C251__", "__MODEL__", + "__STDC__", "__FLOAT64__", "__MODSRC__"]; + + // For C51 compiler. + outputFile.writeLine("#if defined(__C51__) || defined(__CX51__)"); + outputFile.writeLine("# define VAR_NAME_VALUE(var) \"(\"\"\"\"|\"#var\"|\"VALUE(var)\"|\"\"\"\")\""); + for (var i in keys) { + var key = keys[i]; + outputFile.writeLine("# if defined (" + key + ")"); + outputFile.writeLine("# pragma message (VAR_NAME_VALUE(" + key + "))"); + outputFile.writeLine("# endif"); + } + outputFile.writeLine("#endif"); + + // For C251 compiler. + outputFile.writeLine("#if defined(__C251__)"); + outputFile.writeLine("# define VAR_NAME_VALUE(var) \"\"|#var|VALUE(var)|\"\""); + for (var i in keys) { + var key = keys[i]; + outputFile.writeLine("# if defined (" + key + ")"); + outputFile.writeLine("# warning (VAR_NAME_VALUE(" + key + "))"); + outputFile.writeLine("# endif"); + } + outputFile.writeLine("#endif"); + + outputFile.close(); + + var process = new Process(); + process.exec(compilerFilePath, [outputFilePath], false); + File.remove(outputFilePath); + var map = {}; + process.readStdOut().trim().split(/\r?\n/g).map(function(line) { + var parts = line.split("\"|\"", 4); + if (parts.length === 4) + map[parts[1]] = parts[2]; + }); + return map; +} + +function dumpC166CompilerMacros(compilerFilePath, tag) { + // C166 compiler support only C language. + if (tag === "cpp") + return {}; + + // Note: The C166 compiler does not support the predefined + // macros dumping. Also, it does not support the '#pragma' and + // '#message|warning|error' directives properly (it is impossible + // to print to console the value of macro). + // So, we do it with the following trick, where we try + // to create and compile a special temporary file and to parse the console + // output with the own magic pattern, e.g: + // + // *** WARNING C320 IN LINE 41 OF c51.c: __C166__ + // *** WARNING C2 IN LINE 42 OF c51.c: '757': unknown #pragma/control, line ignored + // + // where the '__C166__' is a key, and the '757' is a value. + + var outputDirectory = new TemporaryDir(); + var outputFilePath = FileInfo.fromNativeSeparators(outputDirectory.path() + "/dump-macros.c"); + var outputFile = new TextFile(outputFilePath, TextFile.WriteOnly); + + // Predefined keys for C166 compiler, see details: + // * https://www.keil.com/support/man/docs/c166/c166_pp_predefmacroconst.htm + var keys = ["__C166__", "__DUS__", "__MAC__", "__MOD167__", + "__MODEL__", "__MODV2__", "__SAVEMAC__", "__STDC__"]; + + // For C166 compiler. + outputFile.writeLine("#if defined(__C166__)"); + for (var i in keys) { + var key = keys[i]; + outputFile.writeLine("# if defined (" + key + ")"); + outputFile.writeLine("# warning " + key); + outputFile.writeLine("# pragma " + key); + outputFile.writeLine("# endif"); + } + outputFile.writeLine("#endif"); + + outputFile.close(); + + function extractKey(line, knownKeys) { + for (var i in keys) { + var key = knownKeys[i]; + var regexp = new RegExp("^\\*\\*\\* WARNING C320 IN LINE .+: (" + key + ")$"); + var match = regexp.exec(line); + if (match) + return key; + } + }; + + function extractValue(line) { + var regexp = new RegExp("^\\*\\*\\* WARNING C2 IN LINE .+'(.+)':.+$"); + var match = regexp.exec(line); + if (match) + return match[1]; + }; + + var process = new Process(); + process.exec(compilerFilePath, [outputFilePath], false); + File.remove(outputFilePath); + var lines = process.readStdOut().trim().split(/\r?\n/g); + var map = {}; + for (var i = 0; i < lines.length; ++i) { + // First line should contains the macro key. + var keyLine = lines[i]; + var key = extractKey(keyLine, keys); + if (!key) + continue; + + i += 1; + if (i >= lines.length) + break; + + // Second line should contains the macro value. + var valueLine = lines[i]; + var value = extractValue(valueLine); + if (!value) + continue; + map[key] = value; + } + return map; +} + +function dumpArmCCCompilerMacros(compilerFilePath, tag, nullDevice) { + var args = [ "-E", "--list-macros", "--cpu=cortex-m0", nullDevice ]; + if (tag === "cpp") + args.push("--cpp"); + + var p = new Process(); + p.exec(compilerFilePath, args, false); + return Cpp.extractMacros(p.readStdOut()); +} + +function dumpArmClangCompilerMacros(compilerFilePath, tag, nullDevice) { + var args = [ "--target=arm-arm-none-eabi", "-mcpu=cortex-m0", "-dM", "-E", + "-x", ((tag === "cpp") ? "c++" : "c"), nullDevice ]; + var p = new Process(); + p.exec(compilerFilePath, args, false); + return Cpp.extractMacros(p.readStdOut()); +} + +function dumpMacros(compilerFilePath, tag, nullDevice) { + if (isMcsCompiler(compilerFilePath)) + return dumpMcsCompilerMacros(compilerFilePath, tag, nullDevice); + else if (isC166Compiler(compilerFilePath)) + return dumpC166CompilerMacros(compilerFilePath, tag, nullDevice); + else if (isArmCCCompiler(compilerFilePath)) + return dumpArmCCCompilerMacros(compilerFilePath, tag, nullDevice); + else if (isArmClangCompiler(compilerFilePath)) + return dumpArmClangCompilerMacros(compilerFilePath, tag, nullDevice); + return {}; +} + +function dumpMcsCompilerIncludePaths(compilerFilePath) { + var includePath = compilerFilePath.replace(/bin[\\\/](.*)$/i, "inc"); + return [includePath]; +} + +function dumpC166CompilerIncludePaths(compilerFilePath) { + // Same as for MCS compiler. + return dumpMcsCompilerIncludePaths(compilerFilePath); +} + +function dumpArmCCCompilerIncludePaths(compilerFilePath) { + var includePath = compilerFilePath.replace(/bin[\\\/](.*)$/i, "include"); + return [includePath]; +} + +function dumpArmClangCompilerIncludePaths(compilerFilePath, nullDevice) { + var args = [ "--target=arm-arm-none-eabi", "-mcpu=cortex-m0", "-v", "-E", + "-x", "c++", nullDevice ]; + var p = new Process(); + p.exec(compilerFilePath, args, false); + var lines = p.readStdErr().trim().split(/\r?\n/g).map(function (line) { return line.trim(); }); + var addIncludes = false; + var includePaths = []; + for (var i = 0; i < lines.length; ++i) { + var line = lines[i]; + if (line === "#include <...> search starts here:") + addIncludes = true; + else if (line === "End of search list.") + addIncludes = false; + else if (addIncludes) + includePaths.push(line); + } + return includePaths; +} + +function dumpDefaultPaths(compilerFilePath, nullDevice) { + var includePaths = []; + if (isMcsCompiler(compilerFilePath)) + includePaths = dumpMcsCompilerIncludePaths(compilerFilePath); + else if (isC166Compiler(compilerFilePath)) + includePaths = dumpC166CompilerIncludePaths(compilerFilePath); + else if (isArmCCCompiler(compilerFilePath)) + includePaths = dumpArmCCCompilerIncludePaths(compilerFilePath); + else if (isArmClangCompiler(compilerFilePath)) + includePaths = dumpArmClangCompilerIncludePaths(compilerFilePath, nullDevice); + return { "includePaths": includePaths }; +} + +function filterMcsOutput(output) { + var filteredLines = []; + output.split(/\r\n|\r|\n/).forEach(function(line) { + var regexp = /^\s*\*{3}\s|^\s{29}|^\s{4}\S|^\s{2}[0-9A-F]{4}|^\s{21,25}\d+|^[0-9A-F]{4}\s\d+/; + if (regexp.exec(line)) + filteredLines.push(line); + }); + return filteredLines.join('\n'); +}; + +function filterC166Output(output) { + var filteredLines = []; + output.split(/\r\n|\r|\n/).forEach(function(line) { + var regexp = /^\s*\*{3}\s|^\s{29}|^\s{27,28}\d+|^\s{21}\d+|^\s{4}\S|^\s{2}[0-9A-F]{4}|^[0-9A-F]{4}\s\d+/; + if (regexp.exec(line)) + filteredLines.push(line); + }); + return filteredLines.join('\n'); +}; + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + // Determine which C-language we're compiling. + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + var args = []; + + var architecture = input.qbs.architecture; + if (isMcsArchitecture(architecture) || isC166Architecture(architecture)) { + // Input. + args.push(input.filePath); + + // Output. + args.push("OBJECT(" + FileInfo.toWindowsSeparators(outputs.obj[0].filePath) + ")"); + + // Defines. + var defines = Cpp.collectDefines(input); + if (defines.length > 0) + args = args.concat("DEFINE (" + defines.join(",") + ")"); + + // Includes. + var allIncludePaths = [].concat(Cpp.collectIncludePaths(input), + Cpp.collectSystemIncludePaths(input)); + if (allIncludePaths.length > 0) + args = args.concat("INCDIR(" + allIncludePaths.map(function(path) { + return FileInfo.toWindowsSeparators(path); }).join(";") + ")"); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("DEBUG"); + + // Optimization level flags. + switch (input.cpp.optimization) { + case "small": + args.push("OPTIMIZE (SIZE)"); + break; + case "fast": + args.push("OPTIMIZE (SPEED)"); + break; + case "none": + args.push("OPTIMIZE (0)"); + break; + } + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "none": + args.push("WARNINGLEVEL (0)"); + break; + case "all": + args.push("WARNINGLEVEL (2)"); + if (isMcs51Architecture(architecture)) + args.push("FARWARNING"); + break; + } + + // Listing files generation flag. + if (!input.cpp.generateCompilerListingFiles) + args.push("NOPRINT"); + else + args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath) + ")"); + } else if (isArmArchitecture(architecture)) { + // Input. + args.push("-c", input.filePath); + + // Output. + args.push("-o", outputs.obj[0].filePath); + + // Preinclude headers. + args = args.concat(Cpp.collectPreincludePathsArguments(input, true)); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + var compilerPath = input.cpp.compilerPath; + if (isArmCCCompiler(compilerPath)) { + // Debug information flags. + if (input.cpp.debugInformation) { + args.push("--debug"); + args.push("-g"); + } + + // Optimization level flags. + switch (input.cpp.optimization) { + case "small": + args.push("-Ospace") + break; + case "fast": + args.push("-Otime") + break; + case "none": + args.push("-O0") + break; + } + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "none": + args.push("-W"); + break; + default: + // By default all warnings are enabled. + break; + } + + if (tag === "c") { + // C language version flags. + var knownCLanguageValues = ["c99", "c90"]; + var cLanguageVersion = Cpp.languageVersion( + input.cpp.cLanguageVersion, knownCLanguageValues, "C"); + switch (cLanguageVersion) { + case "c99": + args.push("--c99"); + break; + case "c90": + args.push("--c90"); + break; + } + } else if (tag === "cpp") { + // C++ language version flags. + var knownCppLanguageValues = ["c++11", "c++03"]; + var cppLanguageVersion = Cpp.languageVersion( + input.cpp.cxxLanguageVersion, knownCppLanguageValues, "C++"); + switch (cppLanguageVersion) { + case "c++11": + args.push("--cpp11"); + break; + default: + // Default C++ language is C++03. + args.push("--cpp"); + break; + } + + // Exceptions flags. + var enableExceptions = input.cpp.enableExceptions; + if (enableExceptions !== undefined) + args.push(enableExceptions ? "--exceptions" : "--no_exceptions"); + + // RTTI flags. + var enableRtti = input.cpp.enableRtti; + if (enableRtti !== undefined) + args.push(enableRtti ? "--rtti" : "--no_rtti"); + } + + // Listing files generation flag. + if (input.cpp.generateCompilerListingFiles) { + args.push("--list"); + args.push("--list_dir", FileInfo.path(outputs.lst[0].filePath)); + } + } else if (isArmClangCompiler(compilerPath)) { + // Debug information flags. + if (input.cpp.debugInformation) + args.push("-g"); + + // Optimization level flags. + switch (input.cpp.optimization) { + case "small": + args.push("-Oz") + break; + case "fast": + args.push("-Ofast") + break; + case "none": + args.push("-O0") + break; + } + + // Warning level flags. + switch (input.cpp.warningLevel) { + case "all": + args.push("-Wall"); + break; + default: + break; + } + + if (input.cpp.treatWarningsAsErrors) + args.push("-Werror"); + + if (tag === "c") { + // C language version flags. + var knownCLanguageValues = ["c11", "c99", "c90", "c89"]; + var cLanguageVersion = Cpp.languageVersion( + input.cpp.cLanguageVersion, knownCLanguageValues, "C"); + if (cLanguageVersion) + args.push("-std=" + cLanguageVersion); + } else if (tag === "cpp") { + // C++ language version flags. + var knownCppLanguageValues = ["c++17", "c++14", "c++11", "c++03", "c++98"]; + var cppLanguageVersion = Cpp.languageVersion( + input.cpp.cxxLanguageVersion, knownCppLanguageValues, "C++"); + if (cppLanguageVersion) + args.push("-std=" + cppLanguageVersion); + + // Exceptions flags. + var enableExceptions = input.cpp.enableExceptions; + if (enableExceptions !== undefined) + args.push(enableExceptions ? "-fexceptions" : "-fno-exceptions"); + + // RTTI flags. + var enableRtti = input.cpp.enableRtti; + if (enableRtti !== undefined) + args.push(enableRtti ? "-frtti" : "-fno-rtti"); + } + + // Listing files generation does not supported! + // There are only a workaround: http://www.keil.com/support/docs/4152.htm + } + } + + // Misc flags. + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(input)); + return args; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + var architecture = input.qbs.architecture; + if (isMcsArchitecture(architecture) || isC166Architecture(architecture)) { + // Input. + args.push(input.filePath); + + // Output. + args.push("OBJECT(" + FileInfo.toWindowsSeparators(outputs.obj[0].filePath) + ")"); + + // Includes. + var allIncludePaths = [].concat(Cpp.collectIncludePaths(input), + Cpp.collectSystemIncludePaths(input)); + if (allIncludePaths.length > 0) + args = args.concat("INCDIR(" + allIncludePaths.map(function(path) { + return FileInfo.toWindowsSeparators(path); }).join(";") + ")"); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("DEBUG"); + + // Enable errors printing. + args.push("EP"); + + // Listing files generation flag. + if (!input.cpp.generateAssemblerListingFiles) + args.push("NOPRINT"); + else + args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath) + ")"); + } else if (isArmArchitecture(architecture)) { + // Input. + args.push(input.filePath); + + // Output. + args.push("-o", outputs.obj[0].filePath); + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input)); + + // Debug information flags. + if (input.cpp.debugInformation) { + args.push("--debug"); + args.push("-g"); + } + + // Warning level flags. + if (input.cpp.warningLevel === "none") + args.push("--no_warn"); + + // Byte order flags. + var endianness = input.cpp.endianness; + if (endianness) + args.push((endianness === "little") ? "--littleend" : "--bigend"); + + // Listing files generation flag. + if (input.cpp.generateAssemblerListingFiles) + args.push("--list", outputs.lst[0].filePath); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + return args; +} + +function disassemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = ["--disassemble", "--interleave=source"]; + args.push(outputs.obj[0].filePath); + args.push("--output=" + outputs.lst[0].filePath); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + + var libraryPaths = Cpp.collectLibraryPaths(product); + + var architecture = product.qbs.architecture; + if (isMcsArchitecture(architecture) || isC166Architecture(architecture)) { + // Semi-intelligent handling the library paths. + // We need to add the full path prefix to the library file if this + // file is not absolute or not relative. Reason is that the C51, C251, + // and C166 linkers does not support the library paths. + function collectLibraryObjectPaths(product) { + var libraryObjects = Cpp.collectLibraryDependencies(product); + return libraryObjects.map(function(dep) { + var filePath = dep.filePath; + if (FileInfo.isAbsolutePath(filePath)) + return filePath; + for (var i = 0; i < libraryPaths.length; ++i) { + var fullPath = FileInfo.joinPaths(libraryPaths[i], filePath); + if (File.exists(fullPath)) + return fullPath; + } + return filePath; + }); + } + + // Note: The C51, C251, or C166 linker does not distinguish an object files and + // a libraries, it interpret all this stuff as an input objects, + // so, we need to pass it together in one string. + function collectAllObjectPathsArguments(product, inputs) { + return [].concat(Cpp.collectLinkerObjectPaths(inputs), + collectLibraryObjectPaths(product)); + } + + // Add all input objects as arguments (application and library object files). + var allObjectPaths = collectAllObjectPathsArguments(product, inputs); + if (allObjectPaths.length > 0) + args = args.concat(allObjectPaths.map(function(path) { + return FileInfo.toWindowsSeparators(path); }).join(",")); + + // Output. + args.push("TO", FileInfo.toWindowsSeparators(outputs.application[0].filePath)); + + // Map file generation flag. + if (!product.cpp.generateLinkerMapFile) + args.push("NOPRINT"); + else + args.push("PRINT(" + FileInfo.toWindowsSeparators(outputs.mem_map[0].filePath) + ")"); + } else if (isArmArchitecture(architecture)) { + // Inputs. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + + // Output. + args.push("--output", outputs.application[0].filePath); + + // Library paths. + if (libraryPaths.length > 0) + args.push(product.cpp.libraryPathFlag + libraryPaths.join(",")); + + // Library dependencies. + args = args.concat(Cpp.collectLibraryDependenciesArguments(product)); + + // Linker scripts. + args = args.concat(Cpp.collectLinkerScriptPathsArguments(product, inputs, true)); + + // Map file generation flag. + if (product.cpp.generateLinkerMapFile) + args.push("--list", outputs.mem_map[0].filePath); + + // Entry point flag. + if (product.cpp.entryPoint) + args.push("--entry", product.cpp.entryPoint); + + // Debug information flag. + var debugInformation = product.cpp.debugInformation; + if (debugInformation !== undefined) + args.push(debugInformation ? "--debug" : "--no_debug"); + } + + // Misc flags. + args = args.concat(Cpp.collectMiscEscapableLinkerArguments(product), + Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function archiverFlags(project, product, inputs, outputs) { + var args = []; + + // Inputs. + var objectPaths = Cpp.collectLinkerObjectPaths(inputs); + + var architecture = product.qbs.architecture; + if (isMcsArchitecture(architecture) || isC166Architecture(architecture)) { + // Library creation command. + args.push("TRANSFER"); + + // Inputs. + if (objectPaths.length > 0) + args = args.concat(objectPaths.map(function(path) { + return FileInfo.toWindowsSeparators(path); }).join(",")); + + // Output. + args.push("TO", FileInfo.toWindowsSeparators(outputs.staticlibrary[0].filePath)); + } else if (isArmArchitecture(architecture)) { + // Note: The ARM archiver command line expect the output file + // first, and then a set of input objects. + + // Output. + args.push("--create", outputs.staticlibrary[0].filePath); + + // Inputs. + args = args.concat(objectPaths); + + // Debug information flag. + if (product.cpp.debugInformation) + args.push("--debug_symbols"); + } + + return args; +} + +// The ARMCLANG compiler does not support generation +// for the listing files: +// * https://www.keil.com/support/docs/4152.htm +// So, we generate the listing files from the object files +// using the disassembler. +function generateClangCompilerListing(project, product, inputs, outputs, input, output) { + if (isArmClangCompiler(input.cpp.compilerPath) && input.cpp.generateCompilerListingFiles) { + var args = disassemblerFlags(project, product, input, outputs, explicitlyDependsOn); + var disassemblerPath = input.cpp.disassemblerPath; + var cmd = new Command(disassemblerPath, args); + cmd.silent = true; + return cmd; + } +} + +// The ARMCC compiler generates the listing files only in a short form, +// e.g. to 'module.lst' instead of 'module.{c|cpp}.lst', that complicates +// the auto-tests. Therefore we need to rename generated listing files +// with correct unified names. +function generateArmccCompilerListing(project, product, inputs, outputs, input, output) { + if (isArmCCCompiler(input.cpp.compilerPath) && input.cpp.generateCompilerListingFiles) { + var listingPath = FileInfo.path(outputs.lst[0].filePath); + var cmd = new JavaScriptCommand(); + cmd.oldListing = FileInfo.joinPaths(listingPath, input.baseName + ".lst"); + cmd.newListing = FileInfo.joinPaths( + listingPath, input.fileName + input.cpp.compilerListingSuffix); + cmd.silent = true; + cmd.sourceCode = function() { File.move(oldListing, newListing); }; + return cmd; + } +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + var compilerPath = input.cpp.compilerPath; + var architecture = input.cpp.architecture; + var cmd = new Command(compilerPath, args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + if (isMcsArchitecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterMcsOutput; + } else if (isC166Architecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterC166Output; + } + cmds.push(cmd); + + cmd = generateClangCompilerListing(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + cmd = generateArmccCompilerListing(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + return cmds; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); + var assemblerPath = input.cpp.assemblerPath; + var architecture = input.cpp.architecture; + var cmd = new Command(assemblerPath, args); + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + if (isMcsArchitecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterMcsOutput; + } else if (isC166Architecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterC166Output; + } + return [cmd]; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var primaryOutput = outputs.application[0]; + var args = linkerFlags(project, product, inputs, outputs); + var linkerPath = product.cpp.linkerPath; + var architecture = product.cpp.architecture; + var cmd = new Command(linkerPath, args); + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + if (isMcsArchitecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterMcsOutput; + } else if (isC166Architecture(architecture)) { + cmd.maxExitCode = 1; + cmd.stdoutFilterFunction = filterC166Output; + } + return [cmd]; +} + +function prepareArchiver(project, product, inputs, outputs, input, output) { + var args = archiverFlags(project, product, inputs, outputs); + var archiverPath = product.cpp.archiverPath; + var architecture = product.cpp.architecture; + var cmd = new Command(archiverPath, args); + cmd.description = "creating " + output.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + if (isMcsArchitecture(architecture)) { + cmd.stdoutFilterFunction = filterMcsOutput; + } else if (isC166Architecture(architecture)) { + cmd.stdoutFilterFunction = filterC166Output; + } + return [cmd]; +} diff --git a/share/qbs/modules/cpp/keil.qbs b/share/qbs/modules/cpp/keil.qbs new file mode 100644 index 00000000..edee1697 --- /dev/null +++ b/share/qbs/modules/cpp/keil.qbs @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.Probes +import "cpp.js" as Cpp +import "keil.js" as KEIL + +CppModule { + condition: Host.os().contains("windows") && qbs.toolchain && qbs.toolchain.contains("keil") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["c51"] + } + + Probes.KeilProbe { + id: keilProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + } + + qbs.architecture: keilProbe.found ? keilProbe.architecture : original + qbs.targetPlatform: "none" + + compilerVersionMajor: keilProbe.versionMajor + compilerVersionMinor: keilProbe.versionMinor + compilerVersionPatch: keilProbe.versionPatch + endianness: keilProbe.endianness + + compilerDefinesByLanguage: keilProbe.compilerDefinesByLanguage + compilerIncludePaths: keilProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + compilerName: toolchainDetails.compilerName + compilerExtension + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: toolchainDetails.assemblerName + compilerExtension + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: toolchainDetails.linkerName + compilerExtension + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string archiverName: toolchainDetails.archiverName + compilerExtension + property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + + property string disassemblerName: toolchainDetails.disassemblerName + compilerExtension + property string disassemblerPath: FileInfo.joinPaths(toolchainInstallPath, disassemblerName) + + runtimeLibrary: "static" + + staticLibrarySuffix: ".lib" + executableSuffix: toolchainDetails.executableSuffix + objectSuffix: toolchainDetails.objectSuffix + linkerMapSuffix: toolchainDetails.linkerMapSuffix + + imageFormat: toolchainDetails.imageFormat + + enableExceptions: false + enableRtti: false + + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-I" + preincludeFlag: KEIL.preincludeFlag(compilerPath) + libraryDependencyFlag: "" + libraryPathFlag: "--userlibpath=" + linkerScriptFlag: "--scatter" + + toolchainDetails: KEIL.toolchainDetails(qbs) + + knownArchitectures: ["arm", "c166", "mcs251", "mcs51"] + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(generateAssemblerListingFiles) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: KEIL.prepareAssembler.apply(KEIL, arguments) + } + + FileTagger { + patterns: ["*.s", "*.a51", ".asm"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) + outputArtifacts: Cpp.compilerOutputArtifacts(input) + prepare: KEIL.prepareCompiler.apply(KEIL, arguments) + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) + outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) + prepare: KEIL.prepareLinker.apply(KEIL, arguments) + } + + Rule { + id: staticLibraryLinker + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: KEIL.prepareArchiver.apply(KEIL, arguments) + } +} diff --git a/share/qbs/modules/cpp/macos-gcc.qbs b/share/qbs/modules/cpp/macos-gcc.qbs new file mode 100644 index 00000000..612b46ae --- /dev/null +++ b/share/qbs/modules/cpp/macos-gcc.qbs @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.ModUtils +import qbs.Utilities + +DarwinGCC { + priority: 1 + condition: qbs.targetOS.contains('macos') && + qbs.toolchain && qbs.toolchain.contains('gcc') + + targetSystem: "macosx" + (minimumMacosVersion || "") + + minimumDarwinVersion: minimumMacosVersion + minimumDarwinVersionCompilerFlag: "-mmacosx-version-min" + minimumDarwinVersionLinkerFlag: "-macosx_version_min" + + libcxxAvailable: base + && minimumDarwinVersion + && Utilities.versionCompare(minimumDarwinVersion, "10.7") >= 0 +} diff --git a/share/qbs/modules/cpp/msvc.js b/share/qbs/modules/cpp/msvc.js new file mode 100644 index 00000000..1b70904c --- /dev/null +++ b/share/qbs/modules/cpp/msvc.js @@ -0,0 +1,679 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Codesign = require("../codesign/codesign.js"); +var Cpp = require("cpp.js"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Utilities = require("qbs.Utilities"); +var WindowsUtils = require("qbs.WindowsUtils"); + +function effectiveLinkerPath(product, inputs) { + if (product.cpp.linkerMode === "automatic") { + var compiler = product.cpp.compilerPath; + if (compiler) { + if (inputs.obj || inputs.staticlibrary) { + console.log("Found C/C++ objects, using compiler as a linker for " + product.name); + return compiler; + } + } + + console.log("Found no C-language objects, choosing system linker for " + product.name); + } + + return product.cpp.linkerPath; +} + +function handleCpuFeatures(input, flags) { + if (!input.qbs.architecture) + return; + if (input.qbs.architecture.startsWith("x86")) { + if (input.qbs.architecture === "x86") { + var sse2 = input.cpufeatures.x86_sse2; + if (sse2 === true) + flags.push("/arch:SSE2"); + if (sse2 === false) + flags.push("/arch:IA32"); + } + if (input.cpufeatures.x86_avx === true) + flags.push("/arch:AVX"); + if (input.cpufeatures.x86_avx2 === true) + flags.push("/arch:AVX2"); + } else if (input.qbs.architecture.startsWith("arm")) { + if (input.cpufeatures.arm_vfpv4 === true) + flags.push("/arch:VFPv4"); + if (input.cpp.machineType === "armv7ve") + flags.push("/arch:ARMv7VE"); + } +} + +function hasCxx17Option(input) +{ + // Probably this is not the earliest version to support the flag, but we have tested this one + // and it's a pain to find out the exact minimum. + return Utilities.versionCompare(input.cpp.compilerVersion, "19.12.25831") >= 0 + || (input.qbs.toolchain.contains("clang-cl") && input.cpp.compilerVersionMajor >= 7); +} + +function hasZCplusPlusOption(input) +{ + // /Zc:__cplusplus is supported starting from Visual Studio 15.7 + // Looks like closest MSVC version is 14.14.26428 (cl ver 19.14.26433) + // At least, this version is tested + // https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus + // clang-cl supports this option starting around-ish versions 8/9, but it + // ignores this option, so this doesn't really matter + // https://reviews.llvm.org/D45877 + return Utilities.versionCompare(input.cpp.compilerVersion, "19.14.26433") >= 0 + || (input.qbs.toolchain.contains("clang-cl") && input.cpp.compilerVersionMajor >= 9); +} + +function hasCxx20Option(input) +{ + return Utilities.versionCompare(input.cpp.compilerVersion, "19.29.30133.0") >= 0 + || (input.qbs.toolchain.contains("clang-cl") && input.cpp.compilerVersionMajor >= 13); +} + +function hasCVerOption(input) +{ + return Utilities.versionCompare(input.cpp.compilerVersion, "19.29.30138.0") >= 0 + || (input.qbs.toolchain.contains("clang-cl") && input.cpp.compilerVersionMajor >= 13); +} + +function supportsExternalIncludesOption(input) { + if (input.qbs.toolchain.contains("clang-cl")) + return false; // Exclude clang-cl. + // This option was introcuded since MSVC 2017 v15.6 (aka _MSC_VER 19.13). + // But due to some MSVC bugs: + // * https://developercommunity.visualstudio.com/content/problem/181006/externali-include-paths-not-working.html + // this option has been fixed since MSVC 2017 update 9, v15.9 (aka _MSC_VER 19.16). + return Utilities.versionCompare(input.cpp.compilerVersion, "19.16") >= 0; +} + +function addCxxLanguageVersionFlag(input, args) { + var cxxVersion = Cpp.languageVersion(input.cpp.cxxLanguageVersion, + ["c++23", "c++20", "c++17", "c++14", "c++11", "c++98"], "C++"); + if (!cxxVersion) + return; + + // Visual C++ 2013, Update 3 + var hasStdOption = Utilities.versionCompare(input.cpp.compilerVersion, "18.00.30723") >= 0 + // or clang-cl + || input.qbs.toolchain.contains("clang-cl"); + if (!hasStdOption) + return; + + var flag; + if (cxxVersion === "c++14") + flag = "/std:c++14"; + else if (cxxVersion === "c++17" && hasCxx17Option(input)) + flag = "/std:c++17"; + else if (cxxVersion === "c++20" && hasCxx20Option(input)) + flag = "/std:c++20"; + else if (cxxVersion !== "c++11" && cxxVersion !== "c++98") + flag = "/std:c++latest"; + if (flag) + args.push(flag); +} + +function addCLanguageVersionFlag(input, args) { + var cVersion = Cpp.languageVersion(input.cpp.cLanguageVersion, + ["c17", "c11"], "C"); + if (!cVersion) + return; + + var hasStdOption = hasCVerOption(input); + if (!hasStdOption) + return; + + var flag; + if (cVersion === "c17") + flag = "/std:c17"; + else if (cVersion === "c11") + flag = "/std:c11"; + if (flag) + args.push(flag); +} + +function handleClangClArchitectureFlags(product, architecture, flags) { + if (product.qbs.toolchain.contains("clang-cl")) { + if (architecture === "x86") + flags.push("-m32"); + else if (architecture === "x86_64") + flags.push("-m64"); + } +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var i; + var debugInformation = input.cpp.debugInformation; + var args = ['/nologo', '/c'] + + handleCpuFeatures(input, args); + + // Determine which C-language we're compiling + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(Object.keys(outputs))); + if (!["c", "cpp"].contains(tag)) + throw ("unsupported source language"); + + var enableExceptions = input.cpp.enableExceptions; + if (enableExceptions) { + var ehModel = input.cpp.exceptionHandlingModel; + switch (ehModel) { + case "default": + args.push("/EHsc"); // "Yes" in VS + break; + case "seh": + args.push("/EHa"); // "Yes with SEH exceptions" in VS + break; + case "externc": + args.push("/EHs"); // "Yes with Extern C functions" in VS + break; + } + } + + var enableRtti = input.cpp.enableRtti; + if (enableRtti !== undefined) { + args.push(enableRtti ? "/GR" : "/GR-"); + } + + switch (input.cpp.optimization) { + case "small": + args.push('/Os') + break; + case "fast": + args.push('/O2') + break; + case "none": + args.push("/Od"); + break; + } + + handleClangClArchitectureFlags(product, input.cpp.architecture, args); + + if (debugInformation) { + if (product.cpp.separateDebugInformation) + args.push('/Zi'); + else + args.push('/Z7'); + } + + var rtl = product.cpp.runtimeLibrary; + if (rtl) { + rtl = (rtl === "static" ? "/MT" : "/MD"); + if (product.qbs.enableDebugCode) + rtl += "d"; + args.push(rtl); + } + + args = args.concat(Cpp.collectMiscDriverArguments(product)); + + // warnings: + var warningLevel = input.cpp.warningLevel; + if (warningLevel === 'none') + args.push('/w') + if (warningLevel === 'all') + args.push('/Wall') + if (input.cpp.treatWarningsAsErrors) + args.push('/WX') + + var includePaths = Cpp.collectIncludePaths(input); + args = args.concat([].uniqueConcat(includePaths).map(function(path) { + return input.cpp.includeFlag + FileInfo.toWindowsSeparators(path); + })); + + var includeFlag = input.cpp.includeFlag; + if (supportsExternalIncludesOption(input)) { + args.push("/experimental:external"); + var enforcesSlashW = + Utilities.versionCompare(input.cpp.compilerVersion, "19.29.30037") >= 0 + if (enforcesSlashW) + args.push("/external:W0") + includeFlag = input.cpp.systemIncludeFlag; + } + var systemIncludePaths = Cpp.collectSystemIncludePaths(input); + args = args.concat([].uniqueConcat(systemIncludePaths).map(function(path) { + return includeFlag + FileInfo.toWindowsSeparators(path); + })); + + var defines = Cpp.collectDefines(input); + args = args.concat([].uniqueConcat(defines).map(function(define) { + return input.cpp.defineFlag + define.replace(/%/g, "%%"); + })); + + var minimumWindowsVersion = product.cpp.minimumWindowsVersion; + if (minimumWindowsVersion) { + var hexVersion = WindowsUtils.getWindowsVersionInFormat(minimumWindowsVersion, 'hex'); + if (hexVersion) { + var versionDefs = [ 'WINVER', '_WIN32_WINNT', '_WIN32_WINDOWS' ]; + for (i in versionDefs) { + args.push(input.cpp.defineFlag + versionDefs[i] + '=' + hexVersion); + } + } + } + + if (product.cpp.debugInformation && product.cpp.separateDebugInformation) + args.push("/Fd" + product.targetName + ".cl" + product.cpp.debugInfoSuffix); + + if (input.cpp.generateCompilerListingFiles) + args.push("/Fa" + FileInfo.toWindowsSeparators(outputs.lst[0].filePath)); + + if (input.cpp.enableCxxLanguageMacro && hasZCplusPlusOption(input)) + args.push("/Zc:__cplusplus"); + + var objectMap = outputs.obj || outputs.intermediate_obj + var objOutput = objectMap ? objectMap[0] : undefined + args.push('/Fo' + FileInfo.toWindowsSeparators(objOutput.filePath)) + args.push(FileInfo.toWindowsSeparators(input.filePath)) + + var preincludePaths = Cpp.collectPreincludePaths(input); + args = args.concat([].uniqueConcat(preincludePaths).map(function(path) { + return input.cpp.preincludeFlag + FileInfo.toWindowsSeparators(path); + })); + + // Language + if (tag === "cpp") { + args.push("/TP"); + addCxxLanguageVersionFlag(input, args); + } else if (tag === "c") { + args.push("/TC"); + addCLanguageVersionFlag(input, args); + } + + // Whether we're compiling a precompiled header or normal source file + var pchOutput = outputs[tag + "_pch"] ? outputs[tag + "_pch"][0] : undefined; + var pchInputs = explicitlyDependsOn[tag + "_pch"]; + if (pchOutput) { + // create PCH + if (input.qbs.toolchain.contains("clang-cl")) { + // clang-cl does not support /Yc flag without filename + args.push("/Yc" + FileInfo.toWindowsSeparators(input.filePath)); + // clang-cl complains when pch file is not included + args.push("/FI" + FileInfo.toWindowsSeparators(input.filePath)); + args.push("/Fp" + FileInfo.toWindowsSeparators(pchOutput.filePath)); + args.push("/Fo" + FileInfo.toWindowsSeparators(objOutput.filePath)); + } else { // real msvc + args.push("/Yc"); + args.push("/Fp" + FileInfo.toWindowsSeparators(pchOutput.filePath)); + args.push("/Fo" + FileInfo.toWindowsSeparators(objOutput.filePath)); + args.push(FileInfo.toWindowsSeparators(input.filePath)); + } + + } else if (pchInputs && pchInputs.length === 1 + && ModUtils.moduleProperty(input, "usePrecompiledHeader", tag)) { + // use PCH + var pchSourceArtifacts = product.artifacts[tag + "_pch_src"]; + if (pchSourceArtifacts && pchSourceArtifacts.length > 0) { + var pchSourceFilePath = pchSourceArtifacts[0].filePath; + var pchFilePath = FileInfo.toWindowsSeparators(pchInputs[0].filePath); + args.push("/FI" + pchSourceFilePath); + args.push("/Yu" + pchSourceFilePath); + args.push("/Fp" + pchFilePath); + } else { + console.warning("products." + product.name + ".usePrecompiledHeader is true, " + + "but there is no " + tag + "_pch_src artifact."); + } + } + + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag)); + + var compilerPath = product.cpp.compilerPath; + var wrapperArgs = product.cpp.compilerWrapper; + if (wrapperArgs && wrapperArgs.length > 0) { + args.unshift(compilerPath); + compilerPath = wrapperArgs.shift(); + args = wrapperArgs.concat(args); + } + var cmd = new Command(compilerPath, args) + cmd.description = (pchOutput ? 'pre' : '') + 'compiling ' + input.fileName; + if (pchOutput) + cmd.description += ' (' + tag + ')'; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + cmd.workingDirectory = product.buildDirectory; + cmd.responseFileUsagePrefix = '@'; + // cl.exe outputs the cpp file name. We filter that out. + cmd.inputFileName = input.fileName; + cmd.relevantEnvironmentVariables = ["CL", "_CL_", "INCLUDE"]; + cmd.stdoutFilterFunction = function(output) { + return output.split(inputFileName + "\r\n").join(""); + }; + return [cmd]; +} + +function linkerSupportsWholeArchive(product) +{ + return Utilities.versionCompare(product.cpp.compilerVersion, "19.0.24215.1") >= 0 +} + +function handleDiscardProperty(product, flags) { + var discardUnusedData = product.cpp.discardUnusedData; + if (discardUnusedData === true) + flags.push("/OPT:REF"); + else if (discardUnusedData === false) + flags.push("/OPT:NOREF"); +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var i; + var linkDLL = (outputs.dynamiclibrary ? true : false) + var primaryOutput = (linkDLL ? outputs.dynamiclibrary[0] : outputs.application[0]) + var debugInformation = product.cpp.debugInformation; + var additionalManifestInputs = Array.prototype.map.call(inputs["native.pe.manifest"], + function (a) { + return a.filePath; + }); + var moduleDefinitionInputs = Array.prototype.map.call(inputs["def"], + function (a) { + return a.filePath; + }); + var generateManifestFiles = !linkDLL && product.cpp.generateManifestFile; + var useClangCl = product.qbs.toolchain.contains("clang-cl"); + var canEmbedManifest = useClangCl || product.cpp.compilerVersionMajor >= 17 // VS 2012 + + var linkerPath = effectiveLinkerPath(product, inputs); + var useCompilerDriver = linkerPath === product.cpp.compilerPath; + // args variable is built as follows: + // [linkerWrapper] linkerPath /nologo [driverFlags driverLinkerFlags] + // allInputs libDeps [/link] linkerArgs + var args = [] + + if (useCompilerDriver) { + args.push('/nologo'); + args = args.concat(Cpp.collectMiscDriverArguments(product), + Cpp.collectMiscLinkerArguments(product)); + } + + var allInputs = [].concat(Cpp.collectLinkerObjectPaths(inputs), + Cpp.collectResourceObjectPaths(inputs)); + args = args.concat([].uniqueConcat(allInputs).map(function(path) { + return FileInfo.toWindowsSeparators(path); + })); + + var linkerArgs = ['/nologo'] + if (linkDLL) { + linkerArgs.push('/DLL'); + linkerArgs.push('/IMPLIB:' + FileInfo.toWindowsSeparators(outputs.dynamiclibrary_import[0].filePath)); + } + + if (debugInformation) { + linkerArgs.push("/DEBUG"); + var debugInfo = outputs.debuginfo_app || outputs.debuginfo_dll; + if (debugInfo) + linkerArgs.push("/PDB:" + debugInfo[0].fileName); + } else { + linkerArgs.push('/INCREMENTAL:NO') + } + + switch (product.qbs.architecture) { + case "x86": + linkerArgs.push("/MACHINE:X86"); + break; + case "x86_64": + linkerArgs.push("/MACHINE:X64"); + break; + case "ia64": + linkerArgs.push("/MACHINE:IA64"); + break; + case "armv7": + linkerArgs.push("/MACHINE:ARM"); + break; + case "arm64": + linkerArgs.push("/MACHINE:ARM64"); + break; + } + + if (useCompilerDriver) + handleClangClArchitectureFlags(product, product.qbs.architecture, args); + + var requireAppContainer = product.cpp.requireAppContainer; + if (requireAppContainer !== undefined) + linkerArgs.push("/APPCONTAINER" + (requireAppContainer ? "" : ":NO")); + + var minimumWindowsVersion = product.cpp.minimumWindowsVersion; + var subsystemSwitch = undefined; + if (minimumWindowsVersion || product.consoleApplication !== undefined) { + // Ensure that we default to console if product.consoleApplication is undefined + // since that could still be the case if only minimumWindowsVersion had been defined + subsystemSwitch = product.consoleApplication === false ? '/SUBSYSTEM:WINDOWS' : '/SUBSYSTEM:CONSOLE'; + } + + var useLldLink = useCompilerDriver && product.cpp.linkerVariant === "lld" + || !useCompilerDriver && product.cpp.linkerName === "lld-link.exe"; + if (minimumWindowsVersion) { + var subsystemVersion = WindowsUtils.getWindowsVersionInFormat(minimumWindowsVersion, + 'subsystem'); + if (subsystemVersion) { + subsystemSwitch += ',' + subsystemVersion; + // llvm linker does not support /OSVERSION + if (!useLldLink) + linkerArgs.push('/OSVERSION:' + subsystemVersion); + } + } + + if (subsystemSwitch) + linkerArgs.push(subsystemSwitch); + + var linkerOutputNativeFilePath = FileInfo.toWindowsSeparators(primaryOutput.filePath); + var manifestFileNames = []; + if (generateManifestFiles) { + if (canEmbedManifest) { + linkerArgs.push("/MANIFEST:embed"); + additionalManifestInputs.forEach(function (manifestFileName) { + linkerArgs.push("/MANIFESTINPUT:" + manifestFileName); + }); + } else { + linkerOutputNativeFilePath + = FileInfo.toWindowsSeparators( + FileInfo.path(primaryOutput.filePath) + "/intermediate." + + primaryOutput.fileName); + + var manifestFileName = linkerOutputNativeFilePath + ".manifest"; + linkerArgs.push('/MANIFEST', '/MANIFESTFILE:' + manifestFileName); + manifestFileNames = [manifestFileName].concat(additionalManifestInputs); + } + } + + if (moduleDefinitionInputs.length === 1) + linkerArgs.push("/DEF:" + moduleDefinitionInputs[0]); + else if (moduleDefinitionInputs.length > 1) + throw new Error("Only one '.def' file can be specified for linking"); + + var wholeArchiveSupported = linkerSupportsWholeArchive(product); + var wholeArchiveRequested = false; + var libDeps = Cpp.collectLibraryDependencies(product); + var prevLib; + for (i = 0; i < libDeps.length; ++i) { + var dep = libDeps[i]; + var lib = dep.filePath; + if (lib === prevLib) + continue; + prevLib = lib; + + if (wholeArchiveSupported && dep.wholeArchive) { + // need to pass libraries to the driver to avoid "no input files" error if no object + // files are specified; thus libraries are duplicated when using "WHOLEARCHIVE" + if (useCompilerDriver && allInputs.length === 0) + args.push(FileInfo.toWindowsSeparators(lib)); + linkerArgs.push("/WHOLEARCHIVE:" + FileInfo.toWindowsSeparators(lib)); + } else { + args.push(FileInfo.toWindowsSeparators(lib)); + } + if (dep.wholeArchive) + wholeArchiveRequested = true; + } + if (wholeArchiveRequested && !wholeArchiveSupported) { + console.warn("Product '" + product.name + "' sets cpp.linkWholeArchive on a dependency, " + + "but your linker does not support the /WHOLEARCHIVE option. " + + "Please upgrade to Visual Studio 2015 Update 2 or higher."); + } + + if (product.cpp.entryPoint) + linkerArgs.push("/ENTRY:" + product.cpp.entryPoint); + + if (outputs.application && product.cpp.generateLinkerMapFile) { + if (useLldLink) + linkerArgs.push("/lldmap:" + outputs.mem_map[0].filePath); + else + linkerArgs.push("/MAP:" + outputs.mem_map[0].filePath); + } + + if (useCompilerDriver) + args.push('/Fe' + linkerOutputNativeFilePath); + else + linkerArgs.push('/OUT:' + linkerOutputNativeFilePath); + + var libraryPaths = Cpp.collectLibraryPaths(product); + linkerArgs = linkerArgs.concat([].uniqueConcat(libraryPaths).map(function(path) { + return product.cpp.libraryPathFlag + FileInfo.toWindowsSeparators(path); + })); + + handleDiscardProperty(product, linkerArgs); + var linkerFlags = product.cpp.platformLinkerFlags.concat(product.cpp.linkerFlags); + linkerArgs = linkerArgs.concat(linkerFlags); + if (product.cpp.allowUnresolvedSymbols) + linkerArgs.push("/FORCE:UNRESOLVED"); + + var wrapperArgs = product.cpp.linkerWrapper; + if (wrapperArgs && wrapperArgs.length > 0) { + args.unshift(linkerPath); + linkerPath = wrapperArgs.shift(); + args = wrapperArgs.concat(args); + } + var commands = []; + var warningCmd = new JavaScriptCommand(); + warningCmd.silent = true; + warningCmd.libDeps = libDeps; + warningCmd.sourceCode = function() { + for (var i = 0; i < libDeps.length; ++i) { + if (!libDeps[i].productName || File.exists(libDeps[i].filePath)) + continue; + console.warn("Import library '" + FileInfo.toNativeSeparators(libDeps[i].filePath) + + "' does not exist. This typically happens when a DLL does not " + + "export any symbols. Please make sure the '" + libDeps[i].productName + + "' library exports symbols, or, if you do not intend to actually " + + "link against it, specify \"cpp.link: false\" in the Depends item."); + } + }; + commands.push(warningCmd); + + if (linkerArgs.length !== 0) + args = args.concat(useCompilerDriver ? ['/link'] : []).concat(linkerArgs); + + var cmd = new Command(linkerPath, args) + cmd.description = 'linking ' + primaryOutput.fileName; + cmd.highlight = 'linker'; + cmd.jobPool = "linker"; + cmd.relevantEnvironmentVariables = ["LINK", "_LINK_", "LIB", "TMP"]; + cmd.workingDirectory = FileInfo.path(primaryOutput.filePath) + cmd.responseFileUsagePrefix = '@'; + cmd.responseFileSeparator = useCompilerDriver ? ' ' : '\n'; + cmd.stdoutFilterFunction = function(output) { + res = output.replace(/^.*performing full link.*\s*/, ""); + res = res.replace(/^ *Creating library.*\s*/, ""); + res = res.replace(/^\s*Generating code\s*/, ""); + res = res.replace(/^\s*Finished generating code\s*/, ""); + return res; + }; + commands.push(cmd); + + if (generateManifestFiles && !canEmbedManifest) { + var outputNativeFilePath = FileInfo.toWindowsSeparators(primaryOutput.filePath); + cmd = new JavaScriptCommand(); + cmd.src = linkerOutputNativeFilePath; + cmd.dst = outputNativeFilePath; + cmd.sourceCode = function() { + File.copy(src, dst); + } + cmd.silent = true + commands.push(cmd); + + args = ['/nologo', '/manifest'].concat(manifestFileNames); + args.push("/outputresource:" + outputNativeFilePath + ";#" + (linkDLL ? "2" : "1")); + cmd = new Command("mt.exe", args) + cmd.description = 'embedding manifest into ' + primaryOutput.fileName; + cmd.highlight = 'linker'; + cmd.workingDirectory = FileInfo.path(primaryOutput.filePath) + commands.push(cmd); + } + + if (product.cpp.shouldSignArtifacts) { + Array.prototype.push.apply( + commands, Codesign.prepareSigntool( + project, product, inputs, outputs, input, output)); + } + + return commands; +} + +function createRcCommand(binary, input, output, logo) { + var platformDefines = input.cpp.platformDefines; + var defines = input.cpp.defines; + var includePaths = input.cpp.includePaths; + var systemIncludePaths = input.cpp.systemIncludePaths; + + var args = []; + if (logo === "can-suppress-logo") + args.push("/nologo"); + for (i in platformDefines) { + args.push("/d"); + args.push(platformDefines[i]); + } + for (i in defines) { + args.push("/d"); + args.push(defines[i]); + } + for (i in includePaths) { + args.push("/I"); + args.push(includePaths[i]); + } + for (i in systemIncludePaths) { + args.push("/I"); + args.push(systemIncludePaths[i]); + } + args = args.concat(["/FO", output.filePath, input.filePath]); + var cmd = new Command(binary, args); + cmd.description = 'compiling ' + input.fileName; + cmd.highlight = 'compiler'; + cmd.jobPool = "compiler"; + + if (logo === "always-shows-logo") { + // Remove the first two lines of stdout. That's the logo. + cmd.stdoutFilterFunction = function(output) { + var idx = 0; + for (var i = 0; i < 3; ++i) + idx = output.indexOf('\n', idx + 1); + return output.substr(idx + 1); + } + } + + return cmd; +} diff --git a/share/qbs/modules/cpp/qnx-qcc.qbs b/share/qbs/modules/cpp/qnx-qcc.qbs new file mode 100644 index 00000000..a39a6a99 --- /dev/null +++ b/share/qbs/modules/cpp/qnx-qcc.qbs @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo + +UnixGCC { + Depends { name: "qnx" } + + condition: qbs.targetOS.contains("qnx") && + qbs.toolchain && qbs.toolchain.contains("qcc") + priority: 1 + + distributionIncludePaths: FileInfo.joinPaths(qnx.targetDir, "usr", "include") + + toolchainInstallPath: FileInfo.joinPaths(qnx.hostDir, "usr", "bin") + + sysroot: qnx.targetDir + sysrootFlags: sysroot ? [systemIncludeFlag + FileInfo.joinPaths(sysroot, "usr", "include")] : [] + + cCompilerName: "qcc" + compilerExtension + cxxCompilerName: (qnx.qnx7 ? "q++" : "QCC") + compilerExtension + + targetDriverFlags: qnxTarget ? ["-V" + qnxTarget] : [] + + systemIncludeFlag: !qnx.qnx7 ? includeFlag : base + + property string qnxTarget: qbs.architecture + ? qnx.compilerName + "_" + targetSystem + qnxTargetArchName + : undefined + + property string qnxTargetArchName: { + switch (qbs.architecture) { + case "arm64": + return "aarch64le"; + case "armv7a": + return "armv7le"; + case "x86": + case "x86_64": + return qbs.architecture; + } + } + + // QNX doesn't support Objective-C or Objective-C++ and qcc/q++ don't use toolchainPrefix + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + compilerPathByLanguage: ({ + "c": FileInfo.joinPaths(toolchainInstallPath, cCompilerName), + "cpp": FileInfo.joinPaths(toolchainInstallPath, cxxCompilerName), + "objc": undefined, + "objcpp": undefined, + "asm_cpp": FileInfo.joinPaths(toolchainInstallPath, cCompilerName) + }) + + toolchainPrefix: target + "-" + + targetVendor: ["x86", "x86_64"].contains(qbs.architecture) ? "pc" : base + targetSystem: "nto" + targetAbi: "qnx" + qnx.version + (qnxTargetArchName === "armv7le" ? "eabi" : "") + + buildEnv: qnx.buildEnv + probeEnv: buildEnv + + setupBuildEnvironment: { + for (var key in product.cpp.buildEnv) { + v = new ModUtils.EnvironmentVariable(key); + v.value = product.cpp.buildEnv[key]; + v.set(); + } + } +} diff --git a/share/qbs/modules/cpp/sdcc.js b/share/qbs/modules/cpp/sdcc.js new file mode 100644 index 00000000..928ded5c --- /dev/null +++ b/share/qbs/modules/cpp/sdcc.js @@ -0,0 +1,573 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var BinaryFile = require("qbs.BinaryFile"); +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Host = require("qbs.Host"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); +var WindowsUtils = require("qbs.WindowsUtils"); + +function toolchainDetails(qbs) { + var architecture = qbs.architecture; + if (architecture === "mcs51") { + return { + "assemblerName": "sdas8051", + "linkerName": "sdld" + } + } else if (architecture === "stm8") { + return { + "assemblerName": "sdasstm8", + "linkerName": "sdldstm8" + } + } else if (architecture === "hcs8") { + return { + "assemblerName": "sdas6808", + "linkerName": "sdld6808" + } + } +} + +function targetArchitectureFlag(architecture) { + if (architecture === "mcs51") + return "-mmcs51"; + if (architecture === "stm8") + return "-mstm8"; + if (architecture === "hcs8") + return "-mhc08"; +} + +function guessArchitecture(macros) { + if (macros["__SDCC_mcs51"] === "1") + return "mcs51"; + if (macros["__SDCC_stm8"] === "1") + return "stm8"; + if (macros["__SDCC_hc08"] === "1") + return "hcs8"; +} + +function guessEndianness(macros) { + // SDCC stores numbers in little-endian format. + return "little"; +} + +function guessVersion(macros) { + if ("__SDCC_VERSION_MAJOR" in macros + && "__SDCC_VERSION_MINOR" in macros + && "__SDCC_VERSION_PATCH" in macros) { + return { major: parseInt(macros["__SDCC_VERSION_MAJOR"], 10), + minor: parseInt(macros["__SDCC_VERSION_MINOR"], 10), + patch: parseInt(macros["__SDCC_VERSION_PATCH"], 10) } + } else if ("__SDCC" in macros) { + var versions = macros["__SDCC"].split("_"); + if (versions.length === 3) { + return { major: parseInt(versions[0], 10), + minor: parseInt(versions[1], 10), + patch: parseInt(versions[2], 10) }; + } + } +} + +function dumpMacros(compilerFilePath, architecture) { + var tempDir = new TemporaryDir(); + var fakeIn = new TextFile(tempDir.path() + "/empty-source.c", TextFile.WriteOnly); + var args = [ fakeIn.filePath(), "-dM", "-E" ]; + + var targetFlag = targetArchitectureFlag(architecture); + if (targetFlag) + args.push(targetFlag); + + var p = new Process(); + p.exec(compilerFilePath, args, true); + return Cpp.extractMacros(p.readStdOut()); +} + +function dumpDefaultPaths(compilerFilePath, architecture) { + var args = [ "--print-search-dirs" ]; + + var targetFlag = targetArchitectureFlag(architecture); + if (targetFlag) + args.push(targetFlag); + + var p = new Process(); + p.exec(compilerFilePath, args, true); + var includePaths = []; + var addIncludePaths = false; + var lines = p.readStdOut().trim().split(/\r?\n/g); + for (var i in lines) { + var line = lines[i]; + if (line.startsWith("includedir:")) { + addIncludePaths = true; + } else if (line.startsWith("programs:") + || line.startsWith("datadir:") + || line.startsWith("libdir:") + || line.startsWith("libpath:")) { + addIncludePaths = false; + } else if (addIncludePaths) { + if (File.exists(line)) + includePaths.push(line); + } + } + + return { + "includePaths": includePaths + } +} + +function effectiveLinkerPath(product) { + if (product.cpp.linkerMode === "automatic") + return product.cpp.compilerPath; + return product.cpp.linkerPath; +} + +function useCompilerDriverLinker(product) { + var linker = effectiveLinkerPath(product); + return linker === product.cpp.compilerPath; +} + +function escapeLinkerFlags(product, linkerFlags) { + if (!linkerFlags || linkerFlags.length === 0 || !useCompilerDriverLinker(product)) + return linkerFlags; + return ["-Wl " + linkerFlags.join(",")]; +} + +function escapePreprocessorFlags(preprocessorFlags) { + if (!preprocessorFlags || preprocessorFlags.length === 0) + return preprocessorFlags; + return ["-Wp " + preprocessorFlags.join(",")]; +} + +// We need to use the asm_adb, asm_src, asm_sym and rst_data +// artifacts without of any conditions. Because SDCC always generates +// it (and seems, this behavior can not be disabled for SDCC). +function extraCompilerOutputTags() { + return ["asm_adb", "asm_src", "asm_sym", "rst_data"]; +} + +// We need to use the lk_cmd, and mem_summary artifacts without +// of any conditions. Because SDCC always generates +// it (and seems, this behavior can not be disabled for SDCC). +function extraApplicationLinkerOutputTags() { + return ["lk_cmd", "mem_summary"]; +} + +// We need to use the asm_adb, asm_src, asm_sym and rst_data +// artifacts without of any conditions. Because SDCC always generates +// it (and seems, this behavior can not be disabled for SDCC). +function extraCompilerOutputArtifacts(input) { + return [{ + fileTags: ["asm_adb"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".adb" + }, { + fileTags: ["asm_src"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".asm" + }, { + fileTags: ["asm_sym"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".sym" + }, { + fileTags: ["rst_data"], + filePath: Utilities.getHash(input.baseDir) + "/" + + input.fileName + ".rst" + }]; +} + +// We need to use the lk_cmd, and mem_summary artifacts without +// of any conditions. Because SDCC always generates +// it (and seems, this behavior can not be disabled for SDCC). +function extraApplicationLinkerOutputArtifacts(product) { + return [{ + fileTags: ["lk_cmd"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + ".lk") + }, { + fileTags: ["mem_summary"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + ".mem") + }]; +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + var escapablePreprocessorFlags = []; + + // Input. + args.push(input.filePath); + + // Output. + args.push("-c"); + args.push("-o", outputs.obj[0].filePath); + + // Prefix headers. + escapablePreprocessorFlags = escapablePreprocessorFlags.concat( + Cpp.collectPreincludePathsArguments(input)); + + // Defines. + args = args.concat(Cpp.collectDefinesArguments(input)); + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + escapablePreprocessorFlags = escapablePreprocessorFlags.concat( + Cpp.collectSystemIncludePathsArguments(input)); + + // Target MCU flag. + var targetFlag = targetArchitectureFlag(input.cpp.architecture); + if (targetFlag) + args.push(targetFlag); + + // Debug information flags. + if (input.cpp.debugInformation) + args.push("--debug"); + + // Optimization level flags. + switch (input.cpp.optimization) { + case "small": + args.push("--opt-code-size"); + break; + case "fast": + args.push("--opt-code-speed"); + break; + case "none": + // SDCC has not option to disable the optimization. + break; + } + + // Warning level flags. + var warnings = input.cpp.warningLevel + if (warnings === "none") { + args.push("--less-pedantic"); + escapablePreprocessorFlags.push("-w"); + } else if (warnings === "all") { + escapablePreprocessorFlags.push("-Wall"); + } + if (input.cpp.treatWarningsAsErrors) + args.push("--Werror"); + + // Determine which C-language we"re compiling. + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + + // C language version flags. + if (tag === "c") { + var knownValues = ["c2x", "c17", "c11", "c99", "c89"]; + var cLanguageVersion = Cpp.languageVersion( + input.cpp.cLanguageVersion, knownValues, "C"); + switch (cLanguageVersion) { + case "c17": + cLanguageVersion = "c11"; + // fall through + case "c89": + case "c99": + case "c11": + case "c2x": + args.push("--std-" + cLanguageVersion); + break; + } + } + + var escapedPreprocessorFlags = escapePreprocessorFlags(escapablePreprocessorFlags); + if (escapedPreprocessorFlags) + Array.prototype.push.apply(args, escapedPreprocessorFlags); + + // Misc flags. + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(input)); + return args; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = []; + + // Includes. + args = args.concat(Cpp.collectIncludePathsArguments(input)); + args = args.concat(Cpp.collectSystemIncludePathsArguments(input, input.cpp.includeFlag)); + + // Misc flags. + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + + args.push("-ol"); + args.push(outputs.obj[0].filePath); + args.push(input.filePath); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + + // Target MCU flag. + var targetFlag = targetArchitectureFlag(product.cpp.architecture); + if (targetFlag) + args.push(targetFlag); + + var escapableLinkerFlags = []; + + // Map file generation flag. + if (product.cpp.generateLinkerMapFile) + escapableLinkerFlags.push("-m"); + + escapableLinkerFlags = escapableLinkerFlags.concat(Cpp.collectMiscEscapableLinkerArguments(product)); + + var useCompilerDriver = useCompilerDriverLinker(product); + + // Output. + if (useCompilerDriver) + args.push("-o"); + args.push(outputs.application[0].filePath); + + // Inputs. + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + + // Library paths. + var libraryPathFlag = useCompilerDriver ? "-L" : "-k"; + args = args.concat(Cpp.collectLibraryPathsArguments(product, libraryPathFlag)); + + // Linker scripts. + // Note: We need to split the '-f' flag and the file path to separate + // lines when we don't use the compiler driver mode. + escapableLinkerFlags = escapableLinkerFlags.concat( + Cpp.collectLinkerScriptPathsArguments(product, inputs, !useCompilerDriver)); + + // Library dependencies. + args = args.concat(Cpp.collectLibraryDependenciesArguments(product)); + + var escapedLinkerFlags = escapeLinkerFlags(product, escapableLinkerFlags); + if (escapedLinkerFlags) + Array.prototype.push.apply(args, escapedLinkerFlags); + + // Misc flags. + if (useCompilerDriver) { + args = args.concat(Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + } + return args; +} + +function archiverFlags(project, product, inputs, outputs) { + var args = ["-rc"]; + args.push(outputs.staticlibrary[0].filePath); + args = args.concat(Cpp.collectLinkerObjectPaths(inputs)); + return args; +} + +function buildLinkerMapFilePath(target, suffix) { + return FileInfo.joinPaths(FileInfo.path(target.filePath), + FileInfo.completeBaseName(target.fileName) + suffix); +} + +// This is the workaround for the SDCC bug on a Windows host: +// * https://sourceforge.net/p/sdcc/bugs/2970/ +// We need to replace the '\r\n\' line endings with the'\n' line +// endings for each generated object file. +function patchObjectFile(project, product, inputs, outputs, input, output) { + var isWindows = Host.os().contains("windows"); + if (isWindows && input.cpp.debugInformation) { + var cmd = new JavaScriptCommand(); + cmd.objectPath = outputs.obj[0].filePath; + cmd.silent = true; + cmd.sourceCode = function() { + var file = new BinaryFile(objectPath, BinaryFile.ReadWrite); + var data = file.read(file.size()); + file.resize(0); + for (var pos = 0; pos < data.length; ++pos) { + // Find the next index of CR (\r) symbol. + var index = data.indexOf(0x0d, pos); + if (index < 0) + index = data.length; + // Write next data chunk between the previous position and the CR + // symbol, exclude the CR symbol. + file.write(data.slice(pos, index)); + pos = index; + } + }; + return cmd; + } +} + +// It is a workaround which removes the generated linker map file +// if it is disabled by cpp.generateLinkerMapFile property. +// Reason is that the SDCC compiler always generates this file, +// and does not have an option to disable generation for a linker +// map file. So, we can to remove a listing files only after the +// linking completes. +function removeLinkerMapFile(project, product, inputs, outputs, input, output) { + if (!product.cpp.generateLinkerMapFile) { + var target = outputs.application[0]; + var cmd = new JavaScriptCommand(); + cmd.mapFilePath = buildLinkerMapFilePath(target, product.cpp.linkerMapSuffix) + cmd.silent = true; + cmd.sourceCode = function() { File.remove(mapFilePath); }; + return cmd; + } +} + +// It is a workaround to rename the extension of the output linker +// map file to the specified one, since the linker generates only +// files with the '.map' extension. +function renameLinkerMapFile(project, product, inputs, outputs, input, output) { + if (product.cpp.generateLinkerMapFile && (product.cpp.linkerMapSuffix !== ".map")) { + var target = outputs.application[0]; + var cmd = new JavaScriptCommand(); + cmd.newMapFilePath = buildLinkerMapFilePath(target, product.cpp.linkerMapSuffix); + cmd.oldMapFilePath = buildLinkerMapFilePath(target, ".map"); + cmd.silent = true; + cmd.sourceCode = function() { File.move(oldMapFilePath, newMapFilePath); }; + return cmd; + } +} + +// It is a workaround which removes the generated listing files +// if it is disabled by cpp.generateCompilerListingFiles property +// or when the cpp.compilerListingSuffix differs with '.lst'. +// Reason is that the SDCC compiler does not have an option to +// disable generation for a listing files. Besides, the SDCC +// compiler use this files and for the linking. So, we can to +// remove a listing files only after the linking completes. +function removeCompilerListingFiles(project, product, inputs, outputs, input, output) { + var cmd = new JavaScriptCommand(); + cmd.objects = inputs.obj.map(function(a) { return a; }); + cmd.silent = true; + cmd.sourceCode = function() { + objects.forEach(function(object) { + if (!object.filePath.endsWith(".c" + object.cpp.objectSuffix)) + return; // Skip the assembler generated objects. + if (!object.cpp.generateCompilerListingFiles + || (object.cpp.compilerListingSuffix !== ".lst")) { + var listingPath = FileInfo.joinPaths(FileInfo.path(object.filePath), + object.completeBaseName + ".lst"); + File.remove(listingPath); + } + }) + }; + return cmd; +} + +// It is a workaround that duplicates the generated listing files +// but with desired names. The problem is that the SDCC compiler does +// not support an options to specify names for the generated listing +// files. At the same time, the compiler always generates the listing +// files in the form of 'module.c.lst', which makes it impossible to +// change the file suffix to a user-specified one. In addition, these +// files are also somehow used for linking. Thus, we can not rename them +// on the compiling stage. +function duplicateCompilerListingFile(project, product, inputs, outputs, input, output) { + if (input.cpp.generateCompilerListingFiles + && (input.cpp.compilerListingSuffix !== ".lst")) { + var cmd = new JavaScriptCommand(); + cmd.newListing = outputs.lst[0].filePath; + cmd.oldListing = FileInfo.joinPaths(FileInfo.path(outputs.lst[0].filePath), + outputs.lst[0].completeBaseName + ".lst"); + cmd.silent = true; + cmd.sourceCode = function() { File.copy(oldListing, newListing); }; + return cmd; + } +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + var compilerPath = input.cpp.compilerPath; + var cmd = new Command(compilerPath, args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "compiler"; + cmds.push(cmd); + + cmd = patchObjectFile(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + cmd = duplicateCompilerListingFile(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + return cmds; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var args = assemblerFlags(project, product, input, outputs, explicitlyDependsOn); + var assemblerPath = input.cpp.assemblerPath; + var cmd = new Command(assemblerPath, args); + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "assembler"; + cmds.push(cmd); + + cmd = patchObjectFile(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + return cmds; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var cmds = []; + var args = linkerFlags(project, product, inputs, outputs); + var linkerPath = effectiveLinkerPath(product); + var cmd = new Command(linkerPath, args); + cmd.description = "linking " + outputs.application[0].fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + cmds.push(cmd); + + cmd = removeCompilerListingFiles(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + cmd = renameLinkerMapFile(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + cmd = removeLinkerMapFile(project, product, inputs, outputs, input, output); + if (cmd) + cmds.push(cmd); + + return cmds; +} + +function prepareArchiver(project, product, inputs, outputs, input, output) { + var args = archiverFlags(project, product, inputs, outputs); + var archiverPath = product.cpp.archiverPath; + var cmd = new Command(archiverPath, args); + cmd.description = "creating " + output.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "linker"; + return [cmd]; +} diff --git a/share/qbs/modules/cpp/sdcc.qbs b/share/qbs/modules/cpp/sdcc.qbs new file mode 100644 index 00000000..4e6f05bc --- /dev/null +++ b/share/qbs/modules/cpp/sdcc.qbs @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Probes +import "cpp.js" as Cpp +import "sdcc.js" as SDCC + +CppModule { + condition: qbs.toolchain && qbs.toolchain.contains("sdcc") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["sdcc"] + } + + Probes.SdccProbe { + id: sdccProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + preferredArchitecture: qbs.architecture + } + + qbs.architecture: sdccProbe.found ? sdccProbe.architecture : original + qbs.targetPlatform: "none" + + compilerVersionMajor: sdccProbe.versionMajor + compilerVersionMinor: sdccProbe.versionMinor + compilerVersionPatch: sdccProbe.versionPatch + endianness: sdccProbe.endianness + + compilerDefinesByLanguage: sdccProbe.compilerDefinesByLanguage + compilerIncludePaths: sdccProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + property string linkerMode: "automatic" + + compilerName: "sdcc" + compilerExtension + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: toolchainDetails.assemblerName + compilerExtension + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: toolchainDetails.linkerName + compilerExtension + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string archiverName: "sdar" + compilerExtension + property string archiverPath: FileInfo.joinPaths(toolchainInstallPath, archiverName) + + runtimeLibrary: "static" + + staticLibrarySuffix: ".lib" + executableSuffix: ".ihx" + objectSuffix: ".rel" + + imageFormat: "ihx" + + enableExceptions: false + enableRtti: false + + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-isystem" + preincludeFlag: "-include" + libraryDependencyFlag: "-l" + libraryPathFlag: "-L" + linkerScriptFlag: "-f" + + toolchainDetails: SDCC.toolchainDetails(qbs) + + knownArchitectures: ["hcs8", "mcs51", "stm8"] + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: SDCC.extraCompilerOutputTags().concat( + Cpp.assemblerOutputTags(generateAssemblerListingFiles)) + outputArtifacts: SDCC.extraCompilerOutputArtifacts(input).concat( + Cpp.assemblerOutputArtifacts(input)) + prepare: SDCC.prepareAssembler.apply(SDCC, arguments) + } + + FileTagger { + patterns: ["*.s", "*.a51", "*.asm"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: SDCC.extraCompilerOutputTags().concat( + Cpp.compilerOutputTags(generateCompilerListingFiles)) + outputArtifacts: SDCC.extraCompilerOutputArtifacts(input).concat( + Cpp.compilerOutputArtifacts(input)) + prepare: SDCC.prepareCompiler.apply(SDCC, arguments) + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "linkerscript"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: SDCC.extraApplicationLinkerOutputTags().concat( + Cpp.applicationLinkerOutputTags(generateLinkerMapFile)) + outputArtifacts: SDCC.extraApplicationLinkerOutputArtifacts(product).concat( + Cpp.applicationLinkerOutputArtifacts(product)) + prepare: SDCC.prepareLinker.apply(SDCC, arguments) + } + + Rule { + id: staticLibraryLinker + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: SDCC.prepareArchiver.apply(SDCC, arguments) + } +} diff --git a/share/qbs/modules/cpp/setuprunenv.js b/share/qbs/modules/cpp/setuprunenv.js new file mode 100644 index 00000000..df034e72 --- /dev/null +++ b/share/qbs/modules/cpp/setuprunenv.js @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var File = require("qbs.File"); +var Host = require("qbs.Host"); +var ModUtils = require("qbs.ModUtils"); // TODO: append/prepend functionality should go to qbs.Environment + +function addNewElement(list, elem) +{ + if (!list.contains(elem)) + list.push(elem); +} + +function artifactDir(artifact) +{ + if (!artifact.qbs.install) + return FileInfo.path(artifact.filePath); + return FileInfo.path(ModUtils.artifactInstalledFilePath(artifact)); +} + +function addExternalLibPath(product, list, path) +{ + addNewElement(list, path); + if (Host.os().contains("windows") && FileInfo.fileName(path) === "lib") { + var binPath = FileInfo.joinPaths(FileInfo.path(path), "bin"); + if (File.exists(binPath)) + addNewElement(list, binPath); + } +} + +function gatherPaths(product, libPaths, frameworkPaths, seenProducts) +{ + if (seenProducts.contains(product.name)) + return; + seenProducts.push(product.name); + + // Gather explicitly given library paths. + if (product.cpp && product.cpp.libraryPaths) + product.cpp.libraryPaths.forEach(function(p) { addExternalLibPath(product, libPaths, p); }); + if (product.cpp && product.cpp.frameworkPaths) + product.cpp.frameworkPaths.forEach(function(p) { addNewElement(frameworkPaths, p); }); + if (product.cpp && product.cpp.systemFrameworkPaths) + product.cpp.systemFrameworkPaths.forEach(function(p) { addNewElement(frameworkPaths, p); }); + + // Extract paths from dynamic libraries, if they are given as file paths. + if (product.cpp && product.cpp.dynamicLibraries) { + product.cpp.dynamicLibraries.forEach(function(dll) { + if (FileInfo.isAbsolutePath(dll)) + addExternalLibPath(product, libPaths, FileInfo.path(dll)); + }); + } + + // Traverse library dependencies. + for (var i = 0; i < product.dependencies.length; ++i) { + var dep = product.dependencies[i]; + var dllSymlinkArtifacts = dep.artifacts["bundle.symlink.executable"]; + if (dllSymlinkArtifacts) { + var addArtifact = function(artifact) { + addNewElement(frameworkPaths, FileInfo.path(artifactDir(artifact))); + }; + dllSymlinkArtifacts.forEach(addArtifact); // TODO: Will also catch applications. Can we prevent that? + } else { + addArtifact = function(artifact) { + addNewElement(libPaths, artifactDir(artifact)); + }; + var dllArtifacts = dep.artifacts["dynamiclibrary"]; + if (dllArtifacts) + dllArtifacts.forEach(addArtifact); + var loadableModuleArtifacts = dep.artifacts["loadablemodule"]; + if (loadableModuleArtifacts) + loadableModuleArtifacts.forEach(addArtifact); + } + if (!dep.hasOwnProperty("present")) // Recurse if the dependency is a product. TODO: Provide non-heuristic way to decide whether dependency is a product. + gatherPaths(dep, libPaths, frameworkPaths, seenProducts); + } +} + + +function setupRunEnvironment(product, config) +{ + if (config.contains("ignore-lib-dependencies")) + return; + + if (Host.platform() !== product.qbs.targetPlatform) + return; + + var libPaths = []; + var frameworkPaths = []; + gatherPaths(product, libPaths, frameworkPaths, []); + + var runPaths = product.cpp ? product.cpp.systemRunPaths : undefined; + if (runPaths && runPaths.length > 0) { + var canonicalRunPaths = runPaths.map(function(p) { return File.canonicalFilePath(p); }); + var filterFunc = function(libPath) { + return !runPaths.contains(libPath) + && !canonicalRunPaths.contains(File.canonicalFilePath(libPath)); + }; + libPaths = libPaths.filter(filterFunc); + frameworkPaths = frameworkPaths.filter(filterFunc); + } + + if (libPaths.length > 0) { + var envVarName; + if (product.qbs.targetOS.contains("windows")) + envVarName = "PATH"; + else if (product.qbs.targetOS.contains("macos")) + envVarName = "DYLD_LIBRARY_PATH"; + else + envVarName = "LD_LIBRARY_PATH"; + var envVar = new ModUtils.EnvironmentVariable(envVarName, FileInfo.pathListSeparator(), + Host.os().contains("windows")); + libPaths.forEach(function(p) { envVar.prepend(p); }); + envVar.set(); + } + + if (product.qbs.targetOS.contains("macos") && frameworkPaths.length > 0) { + envVar = new ModUtils.EnvironmentVariable("DYLD_FRAMEWORK_PATH", ':', false); + frameworkPaths.forEach(function(p) { envVar.prepend(p); }); + envVar.set(); + } +} diff --git a/share/qbs/modules/cpp/tvos-gcc.qbs b/share/qbs/modules/cpp/tvos-gcc.qbs new file mode 100644 index 00000000..19bc9b78 --- /dev/null +++ b/share/qbs/modules/cpp/tvos-gcc.qbs @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +DarwinGCC { + priority: 1 + condition: qbs.targetOS.contains('tvos') && + qbs.toolchain && qbs.toolchain.contains('gcc') + + targetSystem: "tvos" + (minimumTvosVersion || "") + + minimumDarwinVersion: minimumTvosVersion + minimumDarwinVersionCompilerFlag: qbs.targetOS.contains("tvos-simulator") + ? "-mtvos-simulator-version-min" + : "-mtvos-version-min" + minimumDarwinVersionLinkerFlag: qbs.targetOS.contains("tvos-simulator") + ? "-tvos_simulator_version_min" + : "-tvos_version_min" +} diff --git a/share/qbs/modules/cpp/watchos-gcc.qbs b/share/qbs/modules/cpp/watchos-gcc.qbs new file mode 100644 index 00000000..46e4bf87 --- /dev/null +++ b/share/qbs/modules/cpp/watchos-gcc.qbs @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +DarwinGCC { + priority: 1 + condition: qbs.targetOS.contains('watchos') && + qbs.toolchain && qbs.toolchain.contains('gcc') + + targetSystem: "watchos" + (minimumWatchosVersion || "") + + minimumDarwinVersion: minimumWatchosVersion + minimumDarwinVersionCompilerFlag: qbs.targetOS.contains("watchos-simulator") + ? "-mwatchos-simulator-version-min" + : "-mwatchos-version-min" + minimumDarwinVersionLinkerFlag: qbs.targetOS.contains("watchos-simulator") + ? "-watchos_simulator_version_min" + : "-watchos_version_min" +} diff --git a/share/qbs/modules/cpp/watcom.js b/share/qbs/modules/cpp/watcom.js new file mode 100644 index 00000000..005780c7 --- /dev/null +++ b/share/qbs/modules/cpp/watcom.js @@ -0,0 +1,568 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Cpp = require("cpp.js"); +var Environment = require("qbs.Environment"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var PathTools = require("qbs.PathTools"); +var Process = require("qbs.Process"); +var TemporaryDir = require("qbs.TemporaryDir"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function toolchainDetails(qbs) { + var platform = qbs.targetPlatform; + var details = {}; + if (platform === "dos") { + details.imageFormat = "mz"; + details.executableSuffix = ".exe"; + } else if (platform === "os2") { + details.imageFormat = "pe"; + details.executableSuffix = ".exe"; + details.dynamicLibrarySuffix = ".dll"; + } else if (platform === "windows") { + details.imageFormat = "pe"; + details.executableSuffix = ".exe"; + details.dynamicLibrarySuffix = ".dll"; + } else if (platform === "linux") { + details.imageFormat = "elf"; + details.executableSuffix = ""; + details.dynamicLibrarySuffix = ".so"; + } + return details; +} + +function languageFlag(tag) { + if (tag === "c") + return "-xc"; + else if (tag === "cpp") + return "-xc++"; +} + +function targetFlag(platform, architecture, type) { + if (platform === "dos") { + if (architecture === "x86_16") + return "-bdos"; + else if (architecture === "x86") + return "-bdos4g"; + } else if (platform === "os2") { + if (architecture === "x86_16") + return "-bos2"; + else if (architecture === "x86") + return "-bos2v2"; + } else if (platform === "windows") { + if (architecture === "x86_16") { + if (type.contains("dynamiclibrary")) + return "-bwindows_dll"; + return "-bwindows"; + } else if (architecture === "x86") { + if (type.contains("dynamiclibrary")) + return "-bnt_dll"; + return "-bnt"; + } + } else if (platform === "linux") { + return "-blinux"; + } +} + +function guessVersion(macros) { + var version = parseInt(macros["__WATCOMC__"], 10) + || parseInt(macros["__WATCOM_CPLUSPLUS__"], 10); + if (version) { + return { major: parseInt((version - 1100) / 100), + minor: parseInt(version / 10) % 10, + patch: ((version % 10) > 0) ? parseInt(version % 10) : 0 } + } +} + +function guessEnvironment(hostOs, platform, architecture, + toolchainInstallPath, pathListSeparator) { + var toolchainRootPath = FileInfo.path(toolchainInstallPath); + if (!File.exists(toolchainRootPath)) { + throw "Unable to deduce environment due to compiler root directory: '" + + toolchainRootPath + "' does not exist"; + } + + var env = {}; + + function setVariable(key, properties, path, separator) { + var values = []; + for (var i = 0; i < properties.length; ++i) { + if (path) { + var fullpath = FileInfo.joinPaths(path, properties[i]); + values.push(FileInfo.toNativeSeparators(fullpath)); + } else { + values.push(properties[i]); + } + } + env[key] = values.join(separator); + } + + setVariable("WATCOM", [toolchainRootPath], undefined, pathListSeparator); + setVariable("EDPATH", ["eddat"], toolchainRootPath, pathListSeparator); + + if (hostOs.contains("linux")) + setVariable("PATH", ["binl64", "binl"], toolchainRootPath, pathListSeparator); + else if (hostOs.contains("windows")) + setVariable("PATH", ["binnt64", "binnt"], toolchainRootPath, pathListSeparator); + + if (platform === "linux") { + setVariable("INCLUDE", ["lh"], toolchainRootPath, pathListSeparator); + } else { + // Common for DOS, Windows, OS/2. + setVariable("WIPFC", ["wipfc"], toolchainRootPath, pathListSeparator); + setVariable("WHTMLHELP", ["binnt/help"], toolchainRootPath, pathListSeparator); + + var includes = ["h"]; + if (platform === "dos") { + // Same includes as before. + } else if (platform === "os2") { + if (architecture === "x86") + includes = includes.concat(["h/os2"]); + else if (architecture === "x86_16") + includes = includes.concat(["h/os21x"]); + } else if (platform === "windows") { + if (architecture === "x86") + includes = includes.concat(["h/nt", "h/nt/directx", "h/nt/ddk"]); + else if (architecture === "x86_16") + includes = includes.concat(["h/win"]); + } else { + throw "Unable to deduce environment for unsupported target platform: '" + + platform + "'"; + } + + setVariable("INCLUDE", includes, toolchainRootPath, pathListSeparator); + } + + return env; +} + +function dumpMacros(environment, compilerPath, platform, architecture, tag) { + // Note: The Open Watcom compiler does not support the predefined + // macros dumping. So, we do it with the following trick, where we try + // to create and compile a special temporary file and to parse the console + // output with the own magic pattern: #define . + + var outputDirectory = new TemporaryDir(); + var outputFilePath = FileInfo.joinPaths(outputDirectory.path(), "dump-macros.c"); + var outputFile = new TextFile(outputFilePath, TextFile.WriteOnly); + outputFile.writeLine("#define VALUE_TO_STRING(x) #x"); + outputFile.writeLine("#define VALUE(x) VALUE_TO_STRING(x)"); + outputFile.writeLine("#define VAR_NAME_VALUE(var) \"#define \"#var\" \"VALUE(var)"); + // Declare all available pre-defined macros of Watcon compiler. + var keys = [ + // Prepare the DOS target macros. + "__DOS__", "_DOS", "MSDOS", + // Prepare the OS/2 target macros. + "__OS2__", + // Prepare the QNX target macros. + "__QNX__", + // Prepare the Netware target macros. + "__NETWARE__", "__NETWARE_386__", + // Prepare the Windows target macros. + "__NT__", "__WINDOWS__", "_WINDOWS", "__WINDOWS_386__", + // Prepare the Linux and Unix target macros. + "__LINUX__", "__UNIX__", + // Prepare the 16-bit target specific macros. + "__I86__", "M_I86", "_M_I86", "_M_IX86", + // Prepare the 32-bit target specific macros. + "__386__", "M_I386", "_M_I386", "_M_IX86", + // Prepare the indicated options macros. + "_MT", "_DLL", "__FPI__", "__CHAR_SIGNED__", "__INLINE_FUNCTIONS__", + "_CPPRTTI", "_CPPUNWIND", "NO_EXT_KEYS", + // Prepare the common memory model macros. + "__FLAT__", "__SMALL__", "__MEDIUM__", + "__COMPACT__", "__LARGE__", "__HUGE__", + // Prepare the 16-bit memory model macros. + "M_I86SM", "_M_I86SM", "M_I86MM", "_M_I86MM", "M_I86CM", + "_M_I86CM", "M_I86LM", "_M_I86LM", "M_I86HM", "_M_I86HM", + // Prepare the 32-bit memory model macros. + "M_386FM", "_M_386FM", "M_386SM", "M_386MM", "_M_386MM", + "M_386CM", "_M_386CM", "M_386LM", "_M_386LM", + // Prepare the compiler macros. + "__X86__", "__cplusplus", "__WATCOMC__", "__WATCOM_CPLUSPLUS__", + "_INTEGRAL_MAX_BITS", "_PUSHPOP_SUPPORTED", "_STDCALL_SUPPORTED", + // Prepare the other macros. + "__3R__", "_based", "_cdecl", "cdecl", "_export", "_far16", "_far", "far", + "_fastcall", "_fortran", "fortran", "_huge", "huge", "_inline", "_interrupt", + "interrupt", "_loadds", "_near", "near", "_pascal", "pascal", "_saveregs", + "_segment", "_segname", "_self", "SOMDLINK", "_STDCALL_SUPPORTED", "__SW_0", + "__SW_3R", "__SW_5", "__SW_FP287", "__SW_FP2", "__SW_FP387", "__SW_FP3", + "__SW_FPI", "__SW_MF", "__SW_MS", "__SW_ZDP", "__SW_ZFP", "__SW_ZGF", + "__SW_ZGP", "_stdcall", "_syscall", "__BIG_ENDIAN" + ]; + for (var i = 0; i < keys.length; ++i) { + var key = keys[i]; + outputFile.writeLine("#if defined(" + key + ")"); + outputFile.writeLine("#pragma message (VAR_NAME_VALUE(" + key + "))"); + outputFile.writeLine("#endif"); + } + outputFile.close(); + + var process = new Process(); + process.setWorkingDirectory(outputDirectory.path()); + for (var envkey in environment) + process.setEnv(envkey, environment[envkey]); + + var target = targetFlag(platform, architecture, ["application"]); + var lang = languageFlag(tag); + var args = [ target, lang, outputFilePath ]; + + process.exec(compilerPath, args, false); + var m = Cpp.extractMacros(process.readStdOut(), /"?(#define(\s\w+){1,2})"?$/); + if (tag === "cpp" && m["__cplusplus"] === "1") + return m; + else if (tag === "c") + return m; +} + +function effectiveLinkerPath(product) { + if (product.cpp.linkerMode === "automatic") { + var compilerPath = product.cpp.compilerPath; + if (compilerPath) + return compilerPath; + console.log("Found no C-language objects, choosing system linker for " + product.name); + } + return product.cpp.linkerPath; +} + +function useCompilerDriverLinker(product) { + var linker = effectiveLinkerPath(product); + var compiler = product.cpp.compilerPath; + return linker === compiler; +} + +function escapeLinkerFlags(useCompilerDriver, linkerFlags) { + if (!linkerFlags || linkerFlags.length === 0) + return []; + + if (useCompilerDriver) { + var sep = ","; + return [["-Wl"].concat(linkerFlags).join(sep)]; + } + return linkerFlags; +} + +function assemblerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = [FileInfo.toNativeSeparators(input.filePath)]; + args.push("-fo=" + FileInfo.toNativeSeparators(outputs.obj[0].filePath)); + + args = args.concat(Cpp.collectPreincludePaths(input).map(function(path) { + return "-fi" + FileInfo.toNativeSeparators(path); + })); + + args = args.concat(Cpp.collectDefinesArguments(input, "-d")); + + var includePaths = [].concat(Cpp.collectIncludePaths(input)).concat( + Cpp.collectSystemIncludePaths(input)); + args = args.concat(includePaths.map(function(path) { + return "-i" + FileInfo.toNativeSeparators(path); + })); + + if (input.cpp.debugInformation) + args.push("-d1"); + + var warnings = input.cpp.warningLevel + if (warnings === "none") + args.push("-w0"); + else if (warnings === "all") + args.push("-wx"); + if (input.cpp.treatWarningsAsErrors) + args.push("-we"); + + args.push("-zq"); // Silent. + args = args.concat(Cpp.collectMiscAssemblerArguments(input)); + return args; +} + +function compilerFlags(project, product, input, outputs, explicitlyDependsOn) { + var args = ["-g" + (input.cpp.debugInformation ? "3" : "0")]; + + var target = targetFlag(product.qbs.targetPlatform, product.qbs.architecture, + product.type); + args.push(target); + + if (product.type.contains("application")) { + if (product.qbs.targetPlatform === "windows") { + var consoleApplication = product.consoleApplication; + args.push(consoleApplication ? "-mconsole" : "-mwindows"); + } + } else if (product.type.contains("dynamiclibrary")) { + args.push("-shared"); + } + + var optimization = input.cpp.optimization + if (optimization === "fast") + args.push("-Ot"); + else if (optimization === "small") + args.push("-Os"); + else if (optimization === "none") + args.push("-O0"); + + var warnings = input.cpp.warningLevel + if (warnings === "none") { + args.push("-w"); + } else if (warnings === "all") { + args.push("-Wall"); + args.push("-Wextra"); + } + if (input.cpp.treatWarningsAsErrors) + args.push("-Werror"); + + var tag = ModUtils.fileTagForTargetLanguage(input.fileTags.concat(outputs.obj[0].fileTags)); + + var langFlag = languageFlag(tag); + if (langFlag) + args.push(langFlag); + + if (tag === "cpp") { + var enableExceptions = input.cpp.enableExceptions; + if (enableExceptions) { + var ehModel = input.cpp.exceptionHandlingModel; + switch (ehModel) { + case "direct": + args.push("-feh-direct"); + break; + case "table": + args.push("-feh-table"); + break; + default: + args.push("-feh"); + break; + } + } else { + args.push("-fno-eh"); + } + + var enableRtti = input.cpp.enableRtti; + args.push(enableRtti ? "-frtti" : "-fno-rtti"); + } else if (tag === "c") { + var knownValues = ["c99", "c89"]; + var cLanguageVersion = Cpp.languageVersion(input.cpp.cLanguageVersion, knownValues, "C"); + switch (cLanguageVersion) { + case "c89": + args.push("-std=c89"); + break; + case "c99": + args.push("-std=c99"); + break; + } + } + + var preincludePaths = Cpp.collectPreincludePaths(input); + for (var i = 0; i < preincludePaths.length; ++i) + args.push(input.cpp.preincludeFlag, preincludePaths[i]); + + args = args.concat(Cpp.collectDefinesArguments(input)); + + args = args.concat(Cpp.collectIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toNativeSeparators(path); + })); + args = args.concat(Cpp.collectSystemIncludePaths(input).map(function(path) { + return input.cpp.systemIncludeFlag + FileInfo.toNativeSeparators(path); + })); + + args = args.concat(Cpp.collectMiscCompilerArguments(input, tag), + Cpp.collectMiscDriverArguments(input)); + + args.push("-o", FileInfo.toNativeSeparators(outputs.obj[0].filePath)); + args.push("-c", FileInfo.toNativeSeparators(input.filePath)); + + return args; +} + +function resourceCompilerFlags(project, product, input, outputs) { + var args = [input.filePath]; + args.push("-fo=" + FileInfo.toNativeSeparators(outputs.res[0].filePath)); + args = args.concat(Cpp.collectDefinesArguments(input, "-d")); + + args = args.concat(Cpp.collectIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toNativeSeparators(path); + })); + args = args.concat(Cpp.collectSystemIncludePaths(input).map(function(path) { + return input.cpp.includeFlag + FileInfo.toNativeSeparators(path); + })); + args.push("-q", "-ad", "-r"); + return args; +} + +function linkerFlags(project, product, inputs, outputs) { + var args = []; + var useCompilerDriver = useCompilerDriverLinker(product); + if (useCompilerDriver) { + var target = targetFlag(product.qbs.targetPlatform, product.qbs.architecture, + product.type); + args.push(target); + + if (product.type.contains("application")) { + args.push("-o", FileInfo.toNativeSeparators(outputs.application[0].filePath)); + if (product.cpp.generateLinkerMapFile) + args.push("-fm=" + FileInfo.toNativeSeparators(outputs.mem_map[0].filePath)); + } else if (product.type.contains("dynamiclibrary")) { + if (product.qbs.targetPlatform === "windows") { + args.push("-Wl, option implib=" + FileInfo.toNativeSeparators( + outputs.dynamiclibrary_import[0].filePath)); + } + args.push("-o", FileInfo.toNativeSeparators(outputs.dynamiclibrary[0].filePath)) + } + + var escapableLinkerFlags = []; + var targetLinkerFlags = product.cpp.targetLinkerFlags; + if (targetLinkerFlags) + escapableLinkerFlags = escapableLinkerFlags.concat(targetLinkerFlags); + + escapableLinkerFlags = escapableLinkerFlags.concat( + Cpp.collectMiscEscapableLinkerArguments(product)); + + var escapedLinkerFlags = escapeLinkerFlags(useCompilerDriver, escapableLinkerFlags); + if (escapedLinkerFlags) + args = args.concat(escapedLinkerFlags); + + args = args.concat(Cpp.collectLibraryPaths(product).map(function(path) { + return product.cpp.libraryPathFlag + FileInfo.toNativeSeparators(path); + })); + args = args.concat(Cpp.collectLinkerObjectPaths(inputs).map(function(path) { + return FileInfo.toNativeSeparators(path); + })); + + var libraryDependencies = Cpp.collectLibraryDependencies(product); + for (var i = 0; i < libraryDependencies.length; ++i) { + var lib = libraryDependencies[i].filePath; + if (FileInfo.isAbsolutePath(lib) || lib.startsWith('@')) + args.push(FileInfo.toNativeSeparators(lib)); + else + args.push("-Wl, libfile " + lib); + } + + var resourcePaths = Cpp.collectResourceObjectPaths(inputs).map(function(path) { + return FileInfo.toNativeSeparators(path); + }); + if (resourcePaths.length > 0) + args = args.concat("-Wl, resource " + resourcePaths.join(",")); + } + + args = args.concat(Cpp.collectMiscLinkerArguments(product), + Cpp.collectMiscDriverArguments(product)); + return args; +} + +function libraryManagerFlags(project, product, inputs, outputs) { + var args = ["-b", "-n", "-q"]; + args = args.concat(Cpp.collectLinkerObjectPaths(inputs).map(function(path) { + return "+" + FileInfo.toNativeSeparators(path); + })); + args.push("-o", FileInfo.toNativeSeparators(outputs.staticlibrary[0].filePath)); + return args; +} + +function disassemblerFlags(project, product, inputs, outputs) { + var objectPath = Cpp.relativePath(product.buildDirectory, outputs.obj[0].filePath); + var listingPath = Cpp.relativePath(product.buildDirectory, outputs.lst[0].filePath); + var args = []; + args.push(FileInfo.toNativeSeparators(objectPath)); + args.push("-l=" + FileInfo.toNativeSeparators(listingPath)); + args.push("-s", "-a"); + return args; +} + +function generateCompilerListing(project, product, inputs, outputs, input, output) { + var args = disassemblerFlags(project, product, input, outputs); + var cmd = new Command(input.cpp.disassemblerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.silent = true; + cmd.jobPool = "watcom_job_pool"; + return cmd; +} + +function prepareAssembler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var args = assemblerFlags(project, product, input, outputs); + var cmd = new Command(input.cpp.assemblerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "assembling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "watcom_job_pool"; + cmds.push(cmd); + if (input.cpp.generateAssemblerListingFiles) + cmds.push(generateCompilerListing(project, product, inputs, outputs, input, output)); + return cmds; +} + +function prepareCompiler(project, product, inputs, outputs, input, output, explicitlyDependsOn) { + var cmds = []; + var args = compilerFlags(project, product, input, outputs, explicitlyDependsOn); + var cmd = new Command(input.cpp.compilerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "watcom_job_pool"; + cmds.push(cmd); + if (input.cpp.generateCompilerListingFiles) + cmds.push(generateCompilerListing(project, product, inputs, outputs, input, output)); + return cmds; +} + +function prepareResourceCompiler(project, product, inputs, outputs, input, output, + explicitlyDependsOn) { + var args = resourceCompilerFlags(project, product, input, outputs); + var cmd = new Command(input.cpp.resourceCompilerPath, args); + // Set working directory to source directory as a workaround + // to make the resources compilable by resource compiler (it is magic). + cmd.workingDirectory = product.sourceDirectory; + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.jobPool = "watcom_job_pool"; + return [cmd]; +} + +function prepareLinker(project, product, inputs, outputs, input, output) { + var primaryOutput = outputs.dynamiclibrary ? outputs.dynamiclibrary[0] + : outputs.application[0]; + var args = linkerFlags(project, product, inputs, outputs); + var linkerPath = effectiveLinkerPath(product); + var cmd = new Command(linkerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.jobPool = "watcom_job_pool"; + return [cmd]; +} + +function prepareLibraryManager(project, product, inputs, outputs, input, output) { + var args = libraryManagerFlags(project, product, inputs, outputs); + var cmd = new Command(product.cpp.libraryManagerPath, args); + cmd.workingDirectory = product.buildDirectory; + cmd.description = "linking " + outputs.staticlibrary[0].fileName; + cmd.highlight = "linker"; + cmd.jobPool = "watcom_job_pool"; + return [cmd]; +} diff --git a/share/qbs/modules/cpp/watcom.qbs b/share/qbs/modules/cpp/watcom.qbs new file mode 100644 index 00000000..eed63692 --- /dev/null +++ b/share/qbs/modules/cpp/watcom.qbs @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs 1.0 +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes +import "cpp.js" as Cpp +import "watcom.js" as WATCOM + +CppModule { + condition: qbs.toolchain && qbs.toolchain.contains("watcom") + + Probes.BinaryProbe { + id: compilerPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["owcc"] + } + + Probes.WatcomProbe { + id: watcomProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + _pathListSeparator: qbs.pathListSeparator + _toolchainInstallPath: toolchainInstallPath + _targetPlatform: qbs.targetPlatform + _targetArchitecture: qbs.architecture + } + + qbs.architecture: watcomProbe.found ? watcomProbe.architecture : original + qbs.targetPlatform: watcomProbe.found ? watcomProbe.targetPlatform : original + + compilerVersionMajor: watcomProbe.versionMajor + compilerVersionMinor: watcomProbe.versionMinor + compilerVersionPatch: watcomProbe.versionPatch + endianness: watcomProbe.endianness + + compilerDefinesByLanguage: watcomProbe.compilerDefinesByLanguage + compilerIncludePaths: watcomProbe.includePaths + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path : undefined + + /* Work-around for QtCreator which expects these properties to exist. */ + property string cCompilerName: compilerName + property string cxxCompilerName: compilerName + + compilerName: "owcc" + compilerExtension + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + assemblerName: "wasm" + compilerExtension + assemblerPath: FileInfo.joinPaths(toolchainInstallPath, assemblerName) + + linkerName: "wlink" + compilerExtension + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + property string disassemblerName: "wdis" + compilerExtension + property string disassemblerPath: FileInfo.joinPaths(toolchainInstallPath, + disassemblerName) + property string resourceCompilerName: "wrc" + compilerExtension + property string resourceCompilerPath: FileInfo.joinPaths(toolchainInstallPath, + resourceCompilerName) + property string libraryManagerName: "wlib" + compilerExtension + property string libraryManagerPath: FileInfo.joinPaths(toolchainInstallPath, + libraryManagerName) + + runtimeLibrary: "dynamic" + + staticLibrarySuffix: ".lib" + dynamicLibrarySuffix: toolchainDetails.dynamicLibrarySuffix + executableSuffix: toolchainDetails.executableSuffix + objectSuffix: ".obj" + + imageFormat: toolchainDetails.imageFormat + + defineFlag: "-D" + includeFlag: "-I" + systemIncludeFlag: "-I" + preincludeFlag: "-include" + libraryDependencyFlag: "-l" + libraryPathFlag: "-L" + linkerScriptFlag: "" + + toolchainDetails: WATCOM.toolchainDetails(qbs) + + knownArchitectures: ["x86", "x86_16"] + + property var buildEnv: watcomProbe.environment + setupBuildEnvironment: { + for (var key in product.cpp.buildEnv) { + var v = new ModUtils.EnvironmentVariable(key, product.qbs.pathListSeparator); + v.prepend(product.cpp.buildEnv[key]); + v.set(); + } + } + + Rule { + id: assembler + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(generateAssemblerListingFiles) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: WATCOM.prepareAssembler.apply(WATCOM, arguments) + } + + FileTagger { + patterns: ["*.asm"] + fileTags: ["asm"] + } + + Rule { + id: compiler + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) + outputArtifacts: Cpp.compilerOutputArtifacts(input) + prepare: WATCOM.prepareCompiler.apply(WATCOM, arguments) + } + + Rule { + id: rccCompiler + inputs: ["rc"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) + prepare: WATCOM.prepareResourceCompiler.apply(WATCOM, arguments) + } + + FileTagger { + patterns: ["*.rc"] + fileTags: ["rc"] + } + + Rule { + id: applicationLinker + multiplex: true + inputs: ["obj", "res", "linkerscript"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.applicationLinkerOutputTags(generateLinkerMapFile) + outputArtifacts: Cpp.applicationLinkerOutputArtifacts(product) + prepare: WATCOM.prepareLinker.apply(WATCOM, arguments) + } + + Rule { + id: dynamicLibraryLinker + condition: qbs.targetOS.contains("windows") + multiplex: true + inputs: ["obj", "res"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.dynamicLibraryLinkerOutputTags(); + outputArtifacts: Cpp.dynamicLibraryLinkerOutputArtifacts(product) + prepare: WATCOM.prepareLinker.apply(WATCOM, arguments) + } + + Rule { + id: libraryManager + multiplex: true + inputs: ["obj"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: Cpp.staticLibraryLinkerOutputTags() + outputArtifacts: Cpp.staticLibraryLinkerOutputArtifacts(product) + prepare: WATCOM.prepareLibraryManager.apply(WATCOM, arguments) + } + + JobLimit { + jobPool: "watcom_job_pool" + jobCount: 1 + } +} diff --git a/share/qbs/modules/cpp/windows-clang-cl.qbs b/share/qbs/modules/cpp/windows-clang-cl.qbs new file mode 100644 index 00000000..cc58097f --- /dev/null +++ b/share/qbs/modules/cpp/windows-clang-cl.qbs @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import qbs.FileInfo +import 'windows-msvc-base.qbs' as MsvcBaseModule + +MsvcBaseModule { + condition: Host.os().contains('windows') && + qbs.targetOS.contains('windows') && + qbs.toolchain && qbs.toolchain.contains('clang-cl') + priority: 100 + + Probes.ClangClBinaryProbe { + id: clangPathProbe + condition: !toolchainInstallPath && !_skipAllChecks + names: ["clang-cl"] + } + + Probes.ClangClProbe { + id: clangClProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + vcvarsallFilePath: vcvarsallPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + preferredArchitecture: qbs.architecture + winSdkVersion: windowsSdkVersion + } + + qbs.architecture: clangClProbe.found ? clangClProbe.architecture : original + + compilerVersionMajor: clangClProbe.versionMajor + compilerVersionMinor: clangClProbe.versionMinor + compilerVersionPatch: clangClProbe.versionPatch + compilerIncludePaths: clangClProbe.includePaths + compilerDefinesByLanguage: clangClProbe.compilerDefinesByLanguage + + toolchainInstallPath: clangPathProbe.found ? clangPathProbe.path + : undefined + buildEnv: clangClProbe.buildEnv + + property string linkerVariant + PropertyOptions { + name: "linkerVariant" + allowedValues: ["lld", "link"] + description: "Allows to specify the linker variant. Maps to clang-cl's -fuse-ld option." + } + Properties { + condition: linkerVariant + driverLinkerFlags: "-fuse-ld=" + linkerVariant + } + + property string vcvarsallPath : clangPathProbe.found ? clangPathProbe.vcvarsallPath : undefined + + compilerName: "clang-cl.exe" + linkerName: "lld-link.exe" + linkerPath: FileInfo.joinPaths(toolchainInstallPath, linkerName) + + validateFunc: { + return function() { + if (_skipAllChecks) + return; + var validator = new ModUtils.PropertyValidator("cpp"); + validator.setRequiredProperty("vcvarsallPath", vcvarsallPath); + validator.validate(); + base(); + } + } +} diff --git a/share/qbs/modules/cpp/windows-clang-mingw.qbs b/share/qbs/modules/cpp/windows-clang-mingw.qbs new file mode 100644 index 00000000..b5bac057 --- /dev/null +++ b/share/qbs/modules/cpp/windows-clang-mingw.qbs @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Utilities +import "msvc.js" as MSVC + +import "setuprunenv.js" as SetupRunEnv + +MingwBaseModule { + condition: qbs.targetOS.contains("windows") && + qbs.toolchain && qbs.toolchain.contains("clang") + priority: 0 + + // llvm-as and llvm-objopy are not shipped with the official binaries on Windows at the + // moment (8.0). We fall back to using the mingw versions in that case. + assemblerName: "llvm-as" + compilerExtension + assemblerPath: { + if (File.exists(base)) + return base; + if (qbs.sysroot) + return FileInfo.joinPaths(qbs.sysroot, "bin", "as" + compilerExtension); + } + objcopyName: "llvm-objcopy" + compilerExtension + objcopyPath: { + if (File.exists(base)) + return base; + if (qbs.sysroot) + return FileInfo.joinPaths(qbs.sysroot, "bin", "objcopy" + compilerExtension); + } + + archiverName: "llvm-ar" + compilerExtension + + linkerVariant: "lld" + targetVendor: "pc" + targetSystem: "windows" + targetAbi: "gnu" + property string rcFilePath: FileInfo.joinPaths(toolchainInstallPath, + "llvm-rc" + compilerExtension) + + setupBuildEnvironment: { + if (Host.os().contains("windows") && product.qbs.sysroot) { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), true); + v.prepend(FileInfo.joinPaths(product.qbs.sysroot, "bin")); + v.set(); + } + } + + setupRunEnvironment: { + if (Host.os().contains("windows") && product.qbs.sysroot) { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), true); + v.prepend(FileInfo.joinPaths(product.qbs.sysroot, "bin")); + v.set(); + SetupRunEnv.setupRunEnvironment(product, config); + } + } + + Rule { + inputs: ["rc"] + auxiliaryInputs: ["hpp"] + + Artifact { + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + input.completeBaseName + ".res") + fileTags: ["obj"] + } + + prepare: MSVC.createRcCommand(product.cpp.rcFilePath, input, output) + } +} diff --git a/share/qbs/modules/cpp/windows-mingw.qbs b/share/qbs/modules/cpp/windows-mingw.qbs new file mode 100644 index 00000000..4c20eda5 --- /dev/null +++ b/share/qbs/modules/cpp/windows-mingw.qbs @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Utilities + +import 'cpp.js' as Cpp +import "setuprunenv.js" as SetupRunEnv + +MingwBaseModule { + condition: qbs.targetOS.contains("windows") && + qbs.toolchain && qbs.toolchain.contains("mingw") + priority: 0 + + probeEnv: buildEnv + + property string windresName: "windres" + compilerExtension + property path windresPath: { + var filePath = toolchainPathPrefix + windresName; + if (!File.exists(filePath)) + filePath = FileInfo.joinPaths(toolchainInstallPath, windresName); + return filePath; + } + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), true); + v.prepend(product.cpp.toolchainInstallPath); + v.set(); + } + + setupRunEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), true); + v.prepend(product.cpp.toolchainInstallPath); + v.set(); + SetupRunEnv.setupRunEnvironment(product, config); + } + + Rule { + inputs: ["rc"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) + prepare: { + var platformDefines = input.cpp.platformDefines; + var defines = input.cpp.defines; + var includePaths = input.cpp.includePaths; + var systemIncludePaths = input.cpp.systemIncludePaths; + var args = []; + var i; + for (i in platformDefines) { + args.push('-D'); + args.push(platformDefines[i]); + } + for (i in defines) { + args.push('-D'); + args.push(defines[i]); + } + for (i in includePaths) { + args.push('-I'); + args.push(includePaths[i]); + } + for (i in systemIncludePaths) { + args.push('-I'); + args.push(systemIncludePaths[i]); + } + + args.push("-O", "coff"); // Set COFF format explicitly. + args = args.concat(['-i', input.filePath, '-o', output.filePath]); + var cmd = new Command(product.cpp.windresPath, args); + cmd.description = 'compiling ' + input.fileName; + cmd.highlight = 'compiler'; + return cmd; + } + } +} + diff --git a/share/qbs/modules/cpp/windows-msvc-base.qbs b/share/qbs/modules/cpp/windows-msvc-base.qbs new file mode 100644 index 00000000..d188d53f --- /dev/null +++ b/share/qbs/modules/cpp/windows-msvc-base.qbs @@ -0,0 +1,341 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.PathTools +import qbs.Probes +import qbs.Utilities +import qbs.WindowsUtils +import 'cpp.js' as Cpp +import 'msvc.js' as MSVC + +CppModule { + condition: false + + Depends { name: "codesign" } + + windowsApiCharacterSet: "unicode" + platformDefines: { + var defines = base.concat(WindowsUtils.characterSetDefines(windowsApiCharacterSet)) + .concat("WIN32"); + var def = WindowsUtils.winapiFamilyDefine(windowsApiFamily); + if (def) + defines.push("WINAPI_FAMILY=WINAPI_FAMILY_" + def); + (windowsApiAdditionalPartitions || []).map(function (name) { + defines.push("WINAPI_PARTITION_" + WindowsUtils.winapiPartitionDefine(name) + "=1"); + }); + return defines; + } + platformCommonCompilerFlags: { + var flags = base; + if (compilerVersionMajor >= 18) // 2013 + flags.push("/FS"); + return flags; + } + warningLevel: "default" + compilerName: "cl.exe" + compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + assemblerName: { + switch (qbs.architecture) { + case "armv7": + return "armasm.exe"; + case "arm64": + return "armasm64.exe"; + case "ia64": + return "ias.exe"; + case "x86": + return "ml.exe"; + case "x86_64": + return "ml64.exe"; + } + } + + linkerName: "link.exe" + runtimeLibrary: "dynamic" + separateDebugInformation: true + + property bool generateManifestFile: true + + architecture: qbs.architecture + endianness: "little" + staticLibrarySuffix: ".lib" + dynamicLibrarySuffix: ".dll" + executableSuffix: ".exe" + debugInfoSuffix: ".pdb" + objectSuffix: ".obj" + precompiledHeaderSuffix: ".pch" + imageFormat: "pe" + Properties { + condition: product.multiplexByQbsProperties.contains("buildVariants") + && qbs.buildVariants && qbs.buildVariants.length > 1 + && qbs.buildVariant !== "release" + && product.type.containsAny(["staticlibrary", "dynamiclibrary"]) + variantSuffix: "d" + } + + property var buildEnv + + readonly property bool shouldSignArtifacts: codesign.enableCodeSigning + property bool enableCxxLanguageMacro: false + + setupBuildEnvironment: { + for (var key in product.cpp.buildEnv) { + var v = new ModUtils.EnvironmentVariable(key, ';'); + v.prepend(product.cpp.buildEnv[key]); + v.set(); + } + } + + property string windowsSdkVersion + + defineFlag: "/D" + includeFlag: "/I" + systemIncludeFlag: "/external:I" + preincludeFlag: "/FI" + libraryPathFlag: "/LIBPATH:" + + Rule { + condition: useCPrecompiledHeader + inputs: ["c_pch_src"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("c", true) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "c", true) + prepare: MSVC.prepareCompiler.apply(MSVC, arguments) + } + + Rule { + condition: useCxxPrecompiledHeader + inputs: ["cpp_pch_src"] + explicitlyDependsOn: ["c_pch"] // to prevent vc--0.pdb conflict + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.precompiledHeaderOutputTags("cpp", true) + outputArtifacts: Cpp.precompiledHeaderOutputArtifacts(input, product, "cpp", true) + prepare: MSVC.prepareCompiler.apply(MSVC, arguments) + } + + Rule { + name: "compiler" + inputs: ["cpp", "c"] + auxiliaryInputs: ["hpp"] + explicitlyDependsOn: ["c_pch", "cpp_pch"] + outputFileTags: Cpp.compilerOutputTags(generateCompilerListingFiles) + outputArtifacts: Cpp.compilerOutputArtifacts(input) + prepare: MSVC.prepareCompiler.apply(MSVC, arguments) + } + + FileTagger { + patterns: ["*.manifest"] + fileTags: ["native.pe.manifest"] + } + + FileTagger { + patterns: ["*.def"] + fileTags: ["def"] + } + + Rule { + name: "applicationLinker" + multiplex: true + inputs: ['obj', 'res', 'native.pe.manifest', 'def'] + inputsFromDependencies: ['staticlibrary', 'dynamiclibrary_import', "debuginfo_app"] + + outputFileTags: { + var tags = ["application", "debuginfo_app"]; + if (generateLinkerMapFile) + tags.push("mem_map"); + if (shouldSignArtifacts) + tags.push("codesign.signed_artifact"); + return tags; + } + outputArtifacts: { + var app = { + fileTags: ["application"].concat( + product.cpp.shouldSignArtifacts ? ["codesign.signed_artifact"] : []), + filePath: FileInfo.joinPaths( + product.destinationDirectory, + PathTools.applicationFilePath(product)) + }; + var artifacts = [app]; + if (product.cpp.debugInformation && product.cpp.separateDebugInformation) { + artifacts.push({ + fileTags: ["debuginfo_app"], + filePath: app.filePath.substr(0, app.filePath.length - 4) + + product.cpp.debugInfoSuffix + }); + } + if (product.cpp.generateLinkerMapFile) { + artifacts.push({ + fileTags: ["mem_map"], + filePath: FileInfo.joinPaths( + product.destinationDirectory, + product.targetName + product.cpp.linkerMapSuffix) + }); + } + return artifacts; + } + + prepare: MSVC.prepareLinker.apply(MSVC, arguments) + } + + Rule { + name: "dynamicLibraryLinker" + multiplex: true + inputs: ['obj', 'res', 'native.pe.manifest', 'def'] + inputsFromDependencies: ['staticlibrary', 'dynamiclibrary_import', "debuginfo_dll"] + + outputFileTags: { + var tags = ["dynamiclibrary", "dynamiclibrary_import", "debuginfo_dll"]; + if (shouldSignArtifacts) + tags.push("codesign.signed_artifact"); + return tags; + } + outputArtifacts: { + var artifacts = [ + { + fileTags: ["dynamiclibrary"].concat( + product.cpp.shouldSignArtifacts ? ["codesign.signed_artifact"] : []), + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.dynamicLibraryFilePath(product)) + }, + { + fileTags: ["dynamiclibrary_import"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.importLibraryFilePath(product)), + alwaysUpdated: false + } + ]; + if (product.cpp.debugInformation && product.cpp.separateDebugInformation) { + var lib = artifacts[0]; + artifacts.push({ + fileTags: ["debuginfo_dll"], + filePath: lib.filePath.substr(0, lib.filePath.length - 4) + + product.cpp.debugInfoSuffix + }); + } + return artifacts; + } + + prepare: MSVC.prepareLinker.apply(MSVC, arguments) + } + + Rule { + name: "libtool" + multiplex: true + inputs: ["obj", "res"] + inputsFromDependencies: ["staticlibrary", "dynamiclibrary_import"] + outputFileTags: ["staticlibrary", "debuginfo_cl"] + outputArtifacts: { + var artifacts = [ + { + fileTags: ["staticlibrary"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + PathTools.staticLibraryFilePath(product)) + } + ]; + if (product.cpp.debugInformation && product.cpp.separateDebugInformation) { + artifacts.push({ + fileTags: ["debuginfo_cl"], + filePath: product.targetName + ".cl" + product.cpp.debugInfoSuffix + }); + } + return artifacts; + } + prepare: { + var args = ['/nologo'] + var lib = outputs["staticlibrary"][0]; + var nativeOutputFileName = FileInfo.toWindowsSeparators(lib.filePath) + args.push('/OUT:' + nativeOutputFileName) + for (var i in inputs.obj) { + var fileName = FileInfo.toWindowsSeparators(inputs.obj[i].filePath) + args.push(fileName) + } + for (var i in inputs.res) { + var fileName = FileInfo.toWindowsSeparators(inputs.res[i].filePath) + args.push(fileName) + } + var cmd = new Command("lib.exe", args); + cmd.description = 'creating ' + lib.fileName; + cmd.highlight = 'linker'; + cmd.jobPool = "linker"; + cmd.workingDirectory = FileInfo.path(lib.filePath) + cmd.responseFileUsagePrefix = '@'; + return cmd; + } + } + + FileTagger { + patterns: ["*.rc"] + fileTags: ["rc"] + } + + Rule { + inputs: ["rc"] + auxiliaryInputs: ["hpp"] + outputFileTags: Cpp.resourceCompilerOutputTags() + outputArtifacts: Cpp.resourceCompilerOutputArtifacts(input) + prepare: { + // From MSVC 2010 on, the logo can be suppressed. + var logo = product.cpp.compilerVersionMajor >= 16 + ? "can-suppress-logo" : "always-shows-logo"; + return MSVC.createRcCommand("rc", input, output, logo); + } + } + + FileTagger { + patterns: "*.asm" + fileTags: ["asm"] + } + + Rule { + inputs: ["asm"] + outputFileTags: Cpp.assemblerOutputTags(false) + outputArtifacts: Cpp.assemblerOutputArtifacts(input) + prepare: { + var args = ["/nologo", "/c", + "/Fo" + FileInfo.toWindowsSeparators(output.filePath), + FileInfo.toWindowsSeparators(input.filePath)]; + if (product.cpp.debugInformation) + args.push("/Zi"); + args = args.concat(Cpp.collectMiscAssemblerArguments(input, "asm")); + var cmd = new Command(product.cpp.assemblerPath, args); + cmd.description = "assembling " + input.fileName; + cmd.jobPool = "assembler"; + cmd.inputFileName = input.fileName; + cmd.stdoutFilterFunction = function(output) { + var lines = output.split("\r\n").filter(function (s) { + return !s.endsWith(inputFileName); }); + return lines.join("\r\n"); + }; + return cmd; + } + } +} diff --git a/share/qbs/modules/cpp/windows-msvc.qbs b/share/qbs/modules/cpp/windows-msvc.qbs new file mode 100644 index 00000000..a57c4cc5 --- /dev/null +++ b/share/qbs/modules/cpp/windows-msvc.qbs @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Host +import qbs.Probes +import "windows-msvc-base.qbs" as MsvcBaseModule + +MsvcBaseModule { + condition: Host.os().contains('windows') && + qbs.targetOS.contains('windows') && + qbs.toolchain && qbs.toolchain.contains('msvc') + priority: 50 + + Probes.ClBinaryProbe { + id: compilerPathProbe + preferredArchitecture: qbs.architecture + condition: !toolchainInstallPath && !_skipAllChecks + names: ["cl"] + } + + Probes.MsvcProbe { + id: msvcProbe + condition: !_skipAllChecks + compilerFilePath: compilerPath + enableDefinesByLanguage: enableCompilerDefinesByLanguage + preferredArchitecture: qbs.architecture + winSdkVersion: windowsSdkVersion + } + + qbs.architecture: msvcProbe.found ? msvcProbe.architecture : original + + compilerVersionMajor: msvcProbe.versionMajor + compilerVersionMinor: msvcProbe.versionMinor + compilerVersionPatch: msvcProbe.versionPatch + compilerIncludePaths: msvcProbe.includePaths + compilerDefinesByLanguage: msvcProbe.compilerDefinesByLanguage + + toolchainInstallPath: compilerPathProbe.found ? compilerPathProbe.path + : undefined + buildEnv: msvcProbe.buildEnv + + enableCxxLanguageMacro: true +} diff --git a/share/qbs/modules/cpufeatures/cpufeatures.qbs b/share/qbs/modules/cpufeatures/cpufeatures.qbs new file mode 100644 index 00000000..17e6b851 --- /dev/null +++ b/share/qbs/modules/cpufeatures/cpufeatures.qbs @@ -0,0 +1,23 @@ +Module { + property bool arm_neon + property bool arm_vfpv4 + property bool mips_dsp + property bool mips_dspr2 + property bool x86_avx + property bool x86_avx2 + property bool x86_avx512bw + property bool x86_avx512cd + property bool x86_avx512dq + property bool x86_avx512er + property bool x86_avx512f + property bool x86_avx512ifma + property bool x86_avx512pf + property bool x86_avx512vbmi + property bool x86_avx512vl + property bool x86_f16c + property bool x86_sse2 + property bool x86_sse3 + property bool x86_sse4_1 + property bool x86_sse4_2 + property bool x86_ssse3 +} diff --git a/share/qbs/modules/dmg/DMGModule.qbs b/share/qbs/modules/dmg/DMGModule.qbs new file mode 100644 index 00000000..f069cb5d --- /dev/null +++ b/share/qbs/modules/dmg/DMGModule.qbs @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.DarwinTools +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Process +import qbs.TextFile +import "dmg.js" as Dmg + +Module { + Depends { name: "xcode"; required: false } + + condition: Host.os().contains("darwin") && qbs.targetOS.contains("darwin") + + property string volumeName: product.targetName + PropertyOptions { + name: "volumeName" + description: "the name of the disk image (displayed in Finder when mounted)" + } + + property bool badgeVolumeIcon: false + PropertyOptions { + name: "badgeVolumeIcon" + description: "whether to render the user-supplied icon on top of the " + + "default volume icon instead of using it directly" + } + + property string format: "UDBZ" + PropertyOptions { + name: "format" + description: "the format to create the disk image in" + } + + property int compressionLevel: qbs.buildVariant === "release" ? 9 : undefined + PropertyOptions { + name: "compressionLevel" + description: "sets the zlib or bzip2 compression level for UDZO and UDBZ disk images" + } + + property string textutilPath: "/usr/bin/textutil" + property string hdiutilPath: "/usr/bin/hdiutil" + property string dmgSuffix: ".dmg" + + property string sourceBase + + readonly property string pythonPath: File.canonicalFilePath(FileInfo.joinPaths(path, + "..", "..", + "python")) + + property string backgroundColor + property int iconSize: 128 + property int windowX: 100 + property int windowY: 100 + property int windowWidth: 640 + property int windowHeight: 480 + property var iconPositions + + property int iconX: windowWidth / 2 + property int iconY: windowHeight / 2 + + property string defaultLicenseLocale + property string licenseLocale + property string licenseLanguageName + property string licenseAgreeButtonText + property string licenseDisagreeButtonText + property string licensePrintButtonText + property string licenseSaveButtonText + property string licenseInstructionText + + FileTagger { + patterns: [ + "*.txt", "*.rtf", "*.html", "*.doc", "*.docx", "*.odt", "*.xml", "*.webarchive", + "LICENSE" + ] + fileTags: ["dmg.license.input"] + } + + FileTagger { + patterns: ["*.icns"] + fileTags: ["icns"] + } + + FileTagger { + patterns: ["*.tif", "*.tiff"] + fileTags: ["tiff"] + } + + Rule { + inputs: ["dmg.license.input"] + + outputFileTags: ["dmg.license"] + outputArtifacts: ([{ + filePath: FileInfo.joinPaths(product.destinationDirectory, "licenses", + FileInfo.relativePath(product.sourceDirectory, + input.filePath) + ".rtf"), + fileTags: ["dmg.license"], + dmg: { + licenseLocale: input.dmg.licenseLocale, + licenseLanguageName: input.dmg.licenseLanguageName, + licenseAgreeButtonText: input.dmg.licenseAgreeButtonText, + licenseDisagreeButtonText: input.dmg.licenseDisagreeButtonText, + licensePrintButtonText: input.dmg.licensePrintButtonText, + licenseSaveButtonText: input.dmg.licenseSaveButtonText, + licenseInstructionText: input.dmg.licenseInstructionText + } + }]) + + prepare: Dmg.prepareLicense.apply(Dmg, arguments) + } + + Rule { + multiplex: true + inputs: ["dmg.input", "dmg.license", "icns", "tiff"] + + Artifact { + fileTags: ["dmg.dmg"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + product.dmg.dmgSuffix) + } + + prepare: Dmg.prepareDmg.apply(Dmg, arguments) + } +} diff --git a/share/qbs/modules/dmg/dmg.js b/share/qbs/modules/dmg/dmg.js new file mode 100644 index 00000000..4d972db9 --- /dev/null +++ b/share/qbs/modules/dmg/dmg.js @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var DarwinTools = require("qbs.DarwinTools"); +var FileInfo = require("qbs.FileInfo"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); + +function localizationFromArtifact(input) { + var locale = input.dmg.licenseLocale || DarwinTools.localizationKey(input.filePath); + if (!locale) + throw("Could not determine localization for license file: " + input.filePath); + return locale; +} + +function dmgbuildSettings(product, inputs) { + var backgroundImages = inputs["tiff"]; + var backgroundImage; + if (backgroundImages) { + if (backgroundImages.length > 1) + throw new Error("only one background image may be specified"); + backgroundImage = backgroundImages[0].filePath; + } + + var volumeIcons = inputs["icns"]; + var volumeIcon; + if (volumeIcons) { + if (volumeIcons.length > 1) + throw new Error("only one volume icon may be specified"); + volumeIcon = volumeIcons[0].filePath; + } + + var licenseFileObjects = Array.prototype.map.call(inputs["dmg.license"], function (a) { + return { + "dmg": { + "licenseLocale": localizationFromArtifact(a), + "licenseLanguageName": a.dmg.licenseLanguageName, + "licenseAgreeButtonText": a.dmg.licenseAgreeButtonText, + "licenseDisagreeButtonText": a.dmg.licenseDisagreeButtonText, + "licensePrintButtonText": a.dmg.licensePrintButtonText, + "licenseSaveButtonText": a.dmg.licenseSaveButtonText, + "licenseInstructionText": a.dmg.licenseInstructionText, + }, + "filePath": a.filePath + }; + }); + + function reduceLicensesForKey(licenseFileObjects, key) { + return licenseFileObjects.reduce(function (accumulator, currentValue) { + var locale = currentValue.dmg.licenseLocale; + if (accumulator[locale]) + throw new Error("Multiple license files for localization '" + locale + "'"); + switch (key) { + case "licenses": + accumulator[locale] = currentValue.filePath; + break; + case "buttons": + var texts = [ + currentValue.dmg.licenseLanguageName, + currentValue.dmg.licenseAgreeButtonText, + currentValue.dmg.licenseDisagreeButtonText, + currentValue.dmg.licensePrintButtonText, + currentValue.dmg.licenseSaveButtonText, + currentValue.dmg.licenseInstructionText + ]; + accumulator[locale] = texts.every(function (a) { return !!a; }) ? texts : undefined; + break; + } + return accumulator; + }, {}); + } + + var contentsArray = Array.prototype.map.call(inputs["dmg.input"], function (a) { + if (a.dmg.sourceBase && !a.filePath.startsWith(a.dmg.sourceBase)) { + throw new Error("Cannot install '" + a.filePath + "', " + + "because it doesn't start with the value of " + + "dmg.sourceBase '" + a.dmg.sourceBase + "'."); + } + + var isSymlink = a.fileTags.contains("dmg.input.symlink"); + return { + "x": a.dmg.iconX, + "y": a.dmg.iconY, + "type": isSymlink ? "link" : "file", + "path": isSymlink ? a.dmg.symlinkTarget : a.filePath, + "name": FileInfo.relativePath(a.dmg.sourceBase || FileInfo.path(a.filePath), a.filePath) + }; + }); + + Array.prototype.forEach.call(product.dmg.iconPositions, function (obj) { + var existingIndex = -1; + Array.prototype.forEach.call(contentsArray, function (contentsItem, i) { + if (contentsItem["name"] === obj["path"]) + existingIndex = i; + }); + + if (existingIndex >= 0) { + contentsArray[existingIndex]["x"] = obj["x"]; + contentsArray[existingIndex]["y"] = obj["y"]; + } else { + contentsArray.push({ + "type": "position", + "name": obj["path"], // name => path is not a typo + "path": obj["path"], + "x": obj["x"], + "y": obj["y"] + }); + } + }); + + return { + "title": product.dmg.volumeName, + "icon": !product.dmg.badgeVolumeIcon ? volumeIcon : undefined, + "badge-icon": product.dmg.badgeVolumeIcon ? volumeIcon : undefined, + "background": backgroundImage, + "background-color": product.dmg.backgroundColor, + "icon-size": product.dmg.iconSize, + "window": { + "position": { + "x": product.dmg.windowX, + "y": product.dmg.windowY + }, + "size": { + "width": product.dmg.windowWidth, + "height": product.dmg.windowHeight + } + }, + "format": product.dmg.format, + "compression-level": product.dmg.compressionLevel, + "license": { + "default-language": product.dmg.defaultLicenseLocale, + "licenses": reduceLicensesForKey(licenseFileObjects, "licenses"), + "buttons": reduceLicensesForKey(licenseFileObjects, "buttons") + }, + "contents": contentsArray + }; +} + +function prepareLicense(project, product, inputs, outputs, input, output) { + var cmd = new Command(product.dmg.textutilPath, [ + "-convert", "rtf", + "-strip", + "-font", "Arial", + "-output", output.filePath, + "--", input.filePath + ]); + cmd.description = "converting " + input.fileName; + return [cmd]; +} + +function prepareDmg(project, product, inputs, outputs, input, output) { + var i; + var cmd; + var cmds = []; + + var settingsJsonFilePath = FileInfo.joinPaths(product.destinationDirectory, + "settings.json"); + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.settingsJSON = dmgbuildSettings(product, inputs); + cmd.settingsJsonFilePath = settingsJsonFilePath; + cmd.sourceCode = function () { + var tf; + try { + tf = new TextFile(settingsJsonFilePath, TextFile.WriteOnly); + tf.writeLine(JSON.stringify(settingsJSON, undefined, 4)); + } finally { + if (tf) + tf.close(); + } + } + cmds.push(cmd); + + // Create the actual DMG via dmgbuild + cmd = new Command(FileInfo.joinPaths(product.qbs.libexecPath, "dmgbuild"), + [product.dmg.volumeName, + output.filePath, + "--no-hidpi", // qbs handles this by itself + "--settings", settingsJsonFilePath]); + cmd.environment = ["PYTHONPATH=" + product.dmg.pythonPath]; + cmd.description = "creating " + output.fileName; + cmds.push(cmd); + + return cmds; +} diff --git a/share/qbs/modules/freedesktop/FreeDesktop.qbs b/share/qbs/modules/freedesktop/FreeDesktop.qbs new file mode 100644 index 00000000..c892a261 --- /dev/null +++ b/share/qbs/modules/freedesktop/FreeDesktop.qbs @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Alberto Mardegan +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.ModUtils +import qbs.TextFile +import "freedesktop.js" as Fdo + +Module { + id: fdoModule + + property string name: product.name + + property var desktopKeys + + readonly property var defaultDesktopKeys: { + return { + 'Type': 'Application', + 'Name': product.freedesktop.name, + 'Exec': product.targetName, + 'Terminal': 'false', + 'Version': '1.1', + } + } + property bool _fdoSupported: qbs.targetOS.contains("unix") && !qbs.targetOS.contains("darwin") + + additionalProductTypes: "freedesktop.desktopfile" + + FileTagger { + patterns: [ "*.desktop" ] + fileTags: [ "freedesktop.desktopfile_source" ] + } + + Rule { + condition: _fdoSupported + + inputs: [ "freedesktop.desktopfile_source" ] + outputFileTags: [ "freedesktop.desktopfile" ] + + Artifact { + fileTags: [ "freedesktop.desktopfile" ] + filePath: input.fileName + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName + " from " + input.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var aggregateDesktopKeys = Fdo.parseDesktopFile(input.filePath); + var desktopKeys = ModUtils.moduleProperty(product, "desktopKeys") || {} + var mainSection = aggregateDesktopKeys['Desktop Entry']; + for (key in desktopKeys) { + if (desktopKeys.hasOwnProperty(key)) { + mainSection[key] = desktopKeys[key]; + } + } + + var defaultValues = product.freedesktop.defaultDesktopKeys + for (key in defaultValues) { + if (!(key in mainSection)) { + mainSection[key] = defaultValues[key]; + } + } + + Fdo.dumpDesktopFile(output.filePath, aggregateDesktopKeys); + } + return [cmd]; + } + } + + Group { + condition: fdoModule._fdoSupported + fileTagsFilter: [ "freedesktop.desktopfile" ] + qbs.install: true + qbs.installDir: "share/applications" + } + + Group { + condition: fdoModule._fdoSupported + fileTagsFilter: [ "freedesktop.appIcon" ] + qbs.install: true + qbs.installDir: "share/icons/hicolor/scalable/apps" + } + + FileTagger { + patterns: [ "*.metainfo.xml", "*.appdata.xml" ] + fileTags: [ "freedesktop.appstream" ] + } + + Group { + condition: fdoModule._fdoSupported + fileTagsFilter: [ "freedesktop.appstream" ] + qbs.install: true + qbs.installDir: "share/metainfo" + } +} diff --git a/share/qbs/modules/freedesktop/freedesktop.js b/share/qbs/modules/freedesktop/freedesktop.js new file mode 100644 index 00000000..d3c60b19 --- /dev/null +++ b/share/qbs/modules/freedesktop/freedesktop.js @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Alberto Mardegan +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var TextFile = require("qbs.TextFile"); + +function parseDesktopFile(filePath) { + var file = new TextFile(filePath); + var fileValues = {}; + var currentSection = {}; + var sectionRex = /\[(.+)\]/g; + while (!file.atEof()) { + var line = file.readLine().trim(); + if (line.length == 0) continue; + if (line[0] == '#') continue; + var match = sectionRex.exec(line); + if (match) { + var currentSectionName = match[1]; + fileValues[currentSectionName] = {}; + currentSection = fileValues[currentSectionName]; + continue; + } + var parts = line.split('=', 2); + currentSection[parts[0]] = parts[1] + } + file.close(); + return fileValues +} + +function dumpDesktopFile(filePath, keys) { + var file = new TextFile(filePath, TextFile.WriteOnly); + for (var sectionName in keys) { + file.writeLine('[' + sectionName + ']'); + var section = keys[sectionName]; + for (var key in section) { + var line = key + '=' + section[key]; + file.writeLine(line); + } + // Write an empty line between sections (and before EOF) + file.writeLine(''); + } + file.close(); +} diff --git a/share/qbs/modules/ib/IBModule.qbs b/share/qbs/modules/ib/IBModule.qbs new file mode 100644 index 00000000..4ff8abea --- /dev/null +++ b/share/qbs/modules/ib/IBModule.qbs @@ -0,0 +1,239 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.BundleTools +import qbs.DarwinTools +import qbs.File +import qbs.Host +import qbs.FileInfo +import qbs.ModUtils +import qbs.Process +import 'ib.js' as Ib + +Module { + Depends { name: "xcode"; required: false } + + Probe { + id: ibProbe + property string toolPath: ibtoolPath // input + property string toolVersion // output + configure: { + toolVersion = Ib.ibtoolVersion(toolPath); + found = true; + } + } + + condition: Host.os().contains("darwin") && qbs.targetOS.contains("darwin") + + property bool warnings: true + property bool errors: true + property bool notices: true + + property stringList flags + + // tiffutil specific + property string tiffutilName: "tiffutil" + property string tiffutilPath: FileInfo.joinPaths("/usr/bin", tiffutilName) + property bool combineHidpiImages: true + + // iconutil specific + property string iconutilName: "iconutil" + property string iconutilPath: FileInfo.joinPaths("/usr/bin", iconutilName) + + // XIB/NIB specific + property string ibtoolName: "ibtool" + property string ibtoolPath: FileInfo.joinPaths(xcode.developerPath, "/usr/bin", ibtoolName) + property bool flatten: true + property string module + property bool autoActivateCustomFonts: true + + // Asset catalog specific + property string actoolName: xcode.present ? "actool" : "ictool" + property string actoolPath: FileInfo.joinPaths(xcode.developerPath, "/usr/bin", actoolName) + property string appIconName + property string launchImageName + property bool compressPngs: true + + // private properties + property string outputFormat: "human-readable-text" + property string tiffSuffix: ".tiff" + property string appleIconSuffix: ".icns" + property string compiledAssetCatalogSuffix: ".car" + property string compiledNibSuffix: ".nib" + property string compiledStoryboardSuffix: ".storyboardc" + + version: ibtoolVersion + property string ibtoolVersion: ibProbe.toolVersion + property var ibtoolVersionParts: ibtoolVersion ? ibtoolVersion.split('.').map(function(item) { return parseInt(item, 10); }) : [] + property int ibtoolVersionMajor: ibtoolVersionParts[0] + property int ibtoolVersionMinor: ibtoolVersionParts[1] + property int ibtoolVersionPatch: ibtoolVersionParts[2] + + property stringList targetDevices: xcode.present + ? xcode.targetDevices + : DarwinTools.targetDevices(qbs.targetOS) + + validate: { + var validator = new ModUtils.PropertyValidator("ib"); + validator.setRequiredProperty("ibtoolVersion", ibtoolVersion); + validator.setRequiredProperty("ibtoolVersionMajor", ibtoolVersionMajor); + validator.setRequiredProperty("ibtoolVersionMinor", ibtoolVersionMinor); + validator.addVersionValidator("ibtoolVersion", ibtoolVersion, 2, 3); + validator.addRangeValidator("ibtoolVersionMajor", ibtoolVersionMajor, 1); + validator.addRangeValidator("ibtoolVersionMinor", ibtoolVersionMinor, 0); + if (ibtoolVersionPatch !== undefined) + validator.addRangeValidator("ibtoolVersionPatch", ibtoolVersionPatch, 0); + validator.validate(); + } + + FileTagger { + patterns: ["*.png"] + fileTags: ["png"] + } + + FileTagger { + patterns: ["*.iconset"] // bundle + fileTags: ["iconset"] + } + + FileTagger { + patterns: ["*.nib", "*.xib"] + fileTags: ["nib"] + } + + FileTagger { + patterns: ["*.storyboard"] + fileTags: ["storyboard"] + } + + FileTagger { + patterns: ["*.xcassets"] // bundle + fileTags: ["assetcatalog"] + } + + Rule { + multiplex: true + inputs: ["png"] + + outputFileTags: ["tiff"] + outputArtifacts: Ib.tiffutilArtifacts(product, inputs) + + prepare: Ib.prepareTiffutil.apply(Ib, arguments) + } + + Rule { + inputs: ["iconset"] + + outputFileTags: ["icns", "bundle.input"] + outputArtifacts: ([{ + filePath: FileInfo.joinPaths(product.destinationDirectory, input.completeBaseName + + ModUtils.moduleProperty(product, "appleIconSuffix")), + fileTags: ["icns", "bundle.input"], + bundle: { + _bundleFilePath: FileInfo.joinPaths(BundleTools.destinationDirectoryForResource(product, input), + input.completeBaseName + + ModUtils.moduleProperty(product, "appleIconSuffix")) + } + }]) + + prepare: { + var args = ["--convert", "icns", "--output", output.filePath, input.filePath]; + var cmd = new Command(ModUtils.moduleProperty(product, "iconutilPath"), args); + cmd.description = "compiling " + input.fileName; + return cmd; + } + } + + Rule { + inputs: ["nib", "storyboard"] + + outputFileTags: { + var tags = ["partial_infoplist"]; + for (var i = 0; i < inputs.length; ++i) + tags = tags.uniqueConcat(ModUtils.allFileTags(Ib.ibtoolFileTaggers(inputs[i]))); + return tags; + } + + outputArtifacts: Ib.ibtoolOutputArtifacts(product, inputs, input) + + prepare: { + var cmd = new Command(ModUtils.moduleProperty(product, "ibtoolPath"), + Ib.ibtooldArguments(product, inputs, input, outputs)); + cmd.description = "compiling " + input.fileName; + + // Also display the language name of the nib/storyboard being compiled if it has one + var localizationKey = DarwinTools.localizationKey(input.filePath); + if (localizationKey) + cmd.description += ' (' + localizationKey + ')'; + + cmd.highlight = 'compiler'; + + // May not be strictly needed, but is set by some versions of Xcode + if (input.fileTags.contains("storyboard")) + cmd.environment.push("IBSC_MINIMUM_COMPATIBILITY_VERSION=" + + (product.moduleProperty("cpp", "minimumDarwinVersion") || "")); + + cmd.stdoutFilterFunction = function(output) { + return ""; + }; + + return cmd; + } + } + + Rule { + inputs: ["assetcatalog"] + multiplex: true + + outputArtifacts: Ib.actoolOutputArtifacts(product, inputs) + outputFileTags: ["bundle.input", "compiled_assetcatalog", "partial_infoplist"] + + prepare: { + var mkdir = new JavaScriptCommand(); + mkdir.silent = true; + mkdir.sourceCode = function () { + File.makePath(FileInfo.joinPaths(product.buildDirectory, "actool.dir")); + }; + + var cmd = new Command(ModUtils.moduleProperty(product, "actoolPath"), + Ib.ibtooldArguments(product, inputs, input, outputs)); + cmd.description = inputs["assetcatalog"].map(function (input) { + return "compiling " + input.fileName; + }).join('\n'); + cmd.highlight = "compiler"; + + cmd.stdoutFilterFunction = function(output) { + return ""; + }; + + return [mkdir, cmd]; + } + } +} diff --git a/share/qbs/modules/ib/ib.js b/share/qbs/modules/ib/ib.js new file mode 100644 index 00000000..ebb615e8 --- /dev/null +++ b/share/qbs/modules/ib/ib.js @@ -0,0 +1,367 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var BundleTools = require("qbs.BundleTools"); +var DarwinTools = require("qbs.DarwinTools"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var PropertyList = require("qbs.PropertyList"); + +function artifactsFromInputs(inputs) { + var artifacts = []; + for (var tag in inputs) { + artifacts = artifacts.concat(inputs[tag]); + } + return artifacts; +} + +function tiffutilScalesMap(inputs) { + return artifactsFromInputs(inputs).map(function (a) { + var m = a.filePath.match(/^(.+?)(@(\d+)x)?(\..+?)$/); + var basePath = m[1]; + var scale = m[2] || ""; + var nscale = m[3]; + var extension = m[4]; + if (scale && scale < 1) + throw new Error("Invalid scale '" + nscale + "' for image '" + a.filePath + "'"); + return { + basePath: basePath, + extension: extension, + scale: scale + }; + }).reduce(function (previous, current) { + previous[current["basePath"]] = (previous[current["basePath"]] || []).concat([{ + extension: current["extension"], + scale: current["scale"] + }]); + return previous; + }, {}); +} + +function tiffutilOutputFilePath(product, basePath) { + return FileInfo.joinPaths(product.destinationDirectory, + "hidpi-images", + FileInfo.relativePath(product.sourceDirectory, basePath) + + product.ib.tiffSuffix); +} + +function tiffutilArtifacts(product, inputs) { + var artifacts = []; + var map = tiffutilScalesMap(inputs); + for (var key in map) { + artifacts.push({ + filePath: tiffutilOutputFilePath(product, key), + fileTags: ["tiff"] + }); + } + return artifacts; +} + +function prepareTiffutil(project, product, inputs, outputs, input, output) { + var cmds = []; + var map = tiffutilScalesMap(inputs); + for (var key in map) { + var args = ["-cat" + (product.ib.combineHidpiImages ? "hidpicheck" : "")]; + var count = 0; + map[key].forEach(function (obj) { + args.push(key + obj["scale"] + obj["extension"]); + ++count; + }); + args.push("-out", tiffutilOutputFilePath(product, key)); + var cmd = new Command(product.ib.tiffutilPath, args); + cmd.description = "creating " + output.fileName; + cmd.count = count; + cmd.outputFilePath = output.filePath; + cmd.stderrFilterFunction = function (output) { + return output.replace(count + " images written to " + outputFilePath + ".", ""); + }; + cmds.push(cmd); + } + return cmds; +} + +function ibtooldArguments(product, inputs, input, outputs, overrideOutput) { + var i; + var args = []; + var allInputs = artifactsFromInputs(inputs); + + var outputFormat = ModUtils.moduleProperty(product, "outputFormat"); + if (outputFormat) { + if (!["binary1", "xml1", "human-readable-text"].contains(outputFormat)) + throw("Invalid ibtoold output format: " + outputFormat + ". " + + "Must be in [binary1, xml1, human-readable-text]."); + + args.push("--output-format", outputFormat); + } + + var debugFlags = ["warnings", "errors", "notices"]; + for (var j in debugFlags) { + var flag = debugFlags[j]; + if (ModUtils.modulePropertyFromArtifacts(product, allInputs, product.moduleName, flag)) { + args.push("--" + flag); + } + } + + if (inputs.assetcatalog) { + args.push("--platform", DarwinTools.applePlatformName( + product.moduleProperty("qbs", "targetOS"), + product.moduleProperty("xcode", "platformType"))); + + var appIconName = ModUtils.modulePropertyFromArtifacts(product, inputs.assetcatalog, product.moduleName, "appIconName"); + if (appIconName) + args.push("--app-icon", appIconName); + + var launchImageName = ModUtils.modulePropertyFromArtifacts(product, inputs.assetcatalog, product.moduleName, "launchImageName"); + if (launchImageName) + args.push("--launch-image", launchImageName); + + // Undocumented but used by Xcode (only for iOS?), probably runs pngcrush or equivalent + if (ModUtils.modulePropertyFromArtifacts(product, inputs.assetcatalog, product.moduleName, "compressPngs")) + args.push("--compress-pngs"); + } else { + var sysroot = product.moduleProperty("qbs", "sysroot"); + if (sysroot) + args.push("--sdk", sysroot); + + args.push("--flatten", ModUtils.modulePropertyFromArtifacts(product, allInputs, product.moduleName, "flatten") ? 'YES' : 'NO'); + + // --module and --auto-activate-custom-fonts were introduced in Xcode 6.0 + if (ModUtils.moduleProperty(product, "ibtoolVersionMajor") >= 6) { + var module = ModUtils.moduleProperty(product, "module"); + if (module) + args.push("--module", module); + + if (ModUtils.modulePropertyFromArtifacts(product, allInputs, product.moduleName, "autoActivateCustomFonts")) + args.push("--auto-activate-custom-fonts"); + } + } + + // --minimum-deployment-target was introduced in Xcode 5.0 + var minimumDarwinVersion = product.moduleProperty("cpp", "minimumDarwinVersion"); + if (minimumDarwinVersion && ModUtils.moduleProperty(product, "ibtoolVersionMajor") >= 5) + args.push("--minimum-deployment-target", minimumDarwinVersion); + + // --target-device and -output-partial-info-plist were introduced in Xcode 6.0 for ibtool + if (ModUtils.moduleProperty(product, "ibtoolVersionMajor") >= 6 || inputs.assetcatalog) { + args.push("--output-partial-info-plist", (outputs && outputs.partial_infoplist) + ? outputs.partial_infoplist[outputs.partial_infoplist.length - 1].filePath + : "/dev/null"); + + // For iOS, we'd normally only output the devices specified in TARGETED_DEVICE_FAMILY + // We can't get this info from Info.plist keys due to dependency order, so use the qbs prop + var targetDevices = ModUtils.moduleProperty(product, "targetDevices"); + for (i in targetDevices) { + args.push("--target-device", targetDevices[i]); + } + } + + args = args.concat(ModUtils.modulePropertiesFromArtifacts(product, allInputs, + product.moduleName, "flags")); + + if (overrideOutput) { + args.push("--compile", overrideOutput); + } else { + if (outputs.compiled_assetcatalog) + args.push("--compile", product.buildDirectory + "/actool.dir"); + else // compiled_ibdoc + args.push("--compile", product.buildDirectory + "/ibtool.dir/" + + ibtoolCompiledDirSuffix(product, input)); + } + + for (i in allInputs) + args.push(allInputs[i].filePath); + + return args; +} + +function ibtoolFileTaggers(fileTags) { + var ext; + if (fileTags.contains("nib") && !fileTags.contains("storyboard")) + ext = "nib"; + if (fileTags.contains("storyboard") && !fileTags.contains("nib")) + ext = "storyboard"; + + if (!ext) + throw "unknown ibtool input file tags: " + fileTags; + + var t = ["bundle.input", "compiled_ibdoc"]; + return { + ".nib": t.concat(["compiled_" + ext + (ext !== "nib" ? "_nib" : "")]), + ".plist": t.concat(["compiled_" + ext + "_infoplist"]), + ".storyboard": t.concat(["compiled_" + ext]) + }; +} + +function ibtoolCompiledDirSuffix(product, input) { + var suffix = input.completeBaseName; + if (input.fileTags.contains("nib")) + suffix += ModUtils.moduleProperty(product, "compiledNibSuffix"); + else if (input.fileTags.contains("storyboard")) + suffix += ModUtils.moduleProperty(product, "compiledStoryboardSuffix"); + return suffix; +} + +function ibtoolOutputArtifacts(product, inputs, input) { + var suffix = ibtoolCompiledDirSuffix(product, input); + var tracker = new ModUtils.BlackboxOutputArtifactTracker(); + tracker.hostOS = product.moduleProperty("qbs", "hostOS"); + tracker.shellPath = product.moduleProperty("qbs", "shellPath"); + tracker.fileTaggers = ibtoolFileTaggers(input.fileTags); + tracker.command = ModUtils.moduleProperty(product, "ibtoolPath"); + tracker.commandArgsFunction = function (outputDirectory) { + // Last --output-format argument overrides any previous ones + // Append the name of the base output since it can be either a file or a directory + // in the case of XIB compilations + return ibtooldArguments(product, inputs, input, + undefined, FileInfo.joinPaths(outputDirectory, suffix)) + .concat(["--output-format", "xml1"]); + }; + + var ibtoolBuildDirectory = product.buildDirectory + "/ibtool.dir"; + var main = BundleTools.destinationDirectoryForResource(product, input); + + var artifacts = tracker.artifacts(ibtoolBuildDirectory); + + if (product.moduleProperty("ib", "ibtoolVersionMajor") >= 6) { + var prefix = input.fileTags.contains("storyboard") ? "SB" : ""; + var path = FileInfo.joinPaths(product.destinationDirectory, input.completeBaseName + + "-" + prefix + "PartialInfo.plist"); + artifacts.push({ filePath: path, fileTags: ["partial_infoplist"] }); + } + + // Let the output artifacts known the "main" output + // This can be either a file or directory so the artifact might already exist in the output list + for (var i = 0; i < artifacts.length; ++i) { + if (artifacts[i].fileTags.contains("compiled_ibdoc")) + artifacts[i].bundle = { + _bundleFilePath: artifacts[i].filePath.replace(ibtoolBuildDirectory, main) + }; + } + + return artifacts; +} + +function actoolOutputArtifacts(product, inputs) { + // actool has no --dry-run option (rdar://21786925), + // so compile to a fake temporary directory in order to extract the list of output files + var tracker = new ModUtils.BlackboxOutputArtifactTracker(); + tracker.hostOS = product.moduleProperty("qbs", "hostOS"); + tracker.shellPath = product.moduleProperty("qbs", "shellPath"); + tracker.command = ModUtils.moduleProperty(product, "actoolPath"); + tracker.commandArgsFunction = function (outputDirectory) { + // Last --output-format argument overrides any previous ones + return ibtooldArguments(product, inputs, undefined, + undefined, outputDirectory).concat(["--output-format", "xml1"]); + }; + tracker.processStdOutFunction = parseActoolOutput; + var artifacts = tracker.artifacts(product.buildDirectory + "/actool.dir"); + + // Newer versions of actool don't generate *anything* if there's no input; + // in that case a partial Info.plist would not have been generated either + if (artifacts && artifacts.length > 0) { + artifacts.push({ + filePath: FileInfo.joinPaths(product.destinationDirectory, + "assetcatalog_generated_info.plist"), + fileTags: ["partial_infoplist"] + }); + } + + for (var i = 0; i < artifacts.length; ++i) { + if (artifacts[i].fileTags.contains("compiled_assetcatalog")) { + artifacts[i].bundle = { + _bundleFilePath: artifacts[i].filePath.replace( + product.buildDirectory + "/actool.dir", + BundleTools.destinationDirectoryForResource(product, inputs.assetcatalog[0])) + }; + } + } + + return artifacts; +} + +function parseActoolOutput(output) { + var propertyList = new PropertyList(); + try { + propertyList.readFromString(output); + + var plist = propertyList.toObject(); + if (plist) + plist = plist["com.apple.actool.compilation-results"]; + if (plist) { + var artifacts = []; + files = plist["output-files"]; + for (var i in files) { + if (files[i] === "/dev/null") + continue; + var tags = files[i].endsWith(".plist") + ? ["partial_infoplist"] + : ["bundle.input", "compiled_assetcatalog"]; + artifacts.push({ + // Even though we pass in a canonical base dir, the paths in the XML File + // are non-canonical. See QBS-1417. + filePath: FileInfo.canonicalPath(files[i]), + fileTags: tags + }); + } + + return artifacts; + } + } finally { + propertyList.clear(); + } +} + +function ibtoolVersion(ibtool) { + var process; + var version; + try { + process = new Process(); + if (process.exec(ibtool, ["--version", "--output-format", "xml1"], true) !== 0) + console.error(process.readStdErr()); + + var propertyList = new PropertyList(); + try { + propertyList.readFromString(process.readStdOut()); + + var plist = propertyList.toObject(); + if (plist) + plist = plist["com.apple.ibtool.version"]; + if (plist) + version = plist["short-bundle-version"]; + } finally { + propertyList.clear(); + } + } finally { + process.close(); + } + return version; +} diff --git a/share/qbs/modules/ico/IcoModule.qbs b/share/qbs/modules/ico/IcoModule.qbs new file mode 100644 index 00000000..7157aab0 --- /dev/null +++ b/share/qbs/modules/ico/IcoModule.qbs @@ -0,0 +1,101 @@ +import qbs.File +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes +import qbs.Process +import qbs.Utilities +import "ico.js" as IcoUtils + +Module { + Probes.BinaryProbe { + id: icotoolProbe + names: ["icotool"] + } + + Probes.IcoUtilsVersionProbe { + id: icotoolVersionProbe + toolFilePath: icotoolFilePath + } + + version: icotoolVersionProbe.version + + property int alphaThreshold + property int cursorHotspotX + property int cursorHotspotY + property bool raw + + // private properties + property string icotoolFilePath: icotoolProbe.filePath + readonly property bool hasCursorHotspotBug: Utilities.versionCompare(version, "0.32") < 0 + + FileTagger { + patterns: ["*.png"] + fileTags: ["png"] + } + + FileTagger { + patterns: ["*.iconset"] // bundle + fileTags: ["iconset"] + } + + Rule { + inputs: ["iconset"] + + Artifact { + filePath: input.baseName + ".ico" + fileTags: ["ico"] + } + + prepare: IcoUtils.prepareIconset.apply(IcoUtils, arguments) + } + + Rule { + multiplex: true + inputs: ["png"] + + Artifact { + filePath: product.targetName + ".ico" + fileTags: ["ico"] + } + + prepare: IcoUtils.prepare.apply(IcoUtils, arguments) + } + + Rule { + inputs: ["iconset"] + + Artifact { + filePath: input.baseName + ".cur" + fileTags: ["cur"] + } + + prepare: IcoUtils.prepareIconset.apply(IcoUtils, arguments) + } + + Rule { + multiplex: true + inputs: ["png"] + + Artifact { + filePath: product.targetName + ".cur" + fileTags: ["cur"] + } + + prepare: IcoUtils.prepare.apply(IcoUtils, arguments) + } + + validate: { + if (!icotoolFilePath) + throw ModUtils.ModuleError("Could not find icotool in any of the following " + + "locations:\n\t" + icotoolProbe.candidatePaths.join("\n\t") + + "\nInstall the icoutils package on your platform."); + + if (!version) + throw ModUtils.ModuleError("Could not determine icoutils package version."); + + var validator = new ModUtils.PropertyValidator("ico"); + validator.setRequiredProperty("version", version); + validator.addVersionValidator("version", version, 2, 3); + return validator.validate() + } +} diff --git a/share/qbs/modules/ico/ico.js b/share/qbs/modules/ico/ico.js new file mode 100644 index 00000000..a61d585a --- /dev/null +++ b/share/qbs/modules/ico/ico.js @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Process = require("qbs.Process"); + +function prepareIconset(project, product, inputs, outputs, input, output) { + inputs = File.directoryEntries(input.filePath, File.Files).map(function (p) { + return { + filePath: FileInfo.joinPaths(input.filePath, p), + fileTags: p.endsWith(".png") ? ["png"] : [], + ico: {} + }; + }); + inputs = {"png": inputs.filter(function (a) { return a.fileTags.contains("png"); })}; + input = undefined; + return prepare(project, product, inputs, outputs, input, output); +} + +function prepare(project, product, inputs, outputs, input, output) { + var args = ["--create", "--output=" + output.filePath]; + if (output.fileTags.contains("ico")) { + args.push("--icon"); + if (product.ico.alphaThreshold !== undefined) + args.push("--alpha-threshold=" + product.ico.alphaThreshold); + } + + var isCursor = output.fileTags.contains("cur"); + if (isCursor) + args.push("--cursor"); + + var hasMultipleImages = inputs["png"].length > 1; + inputs["png"].map(function(inp) { + if (isCursor) { + var hasX = inp.ico.cursorHotspotX !== undefined; + var hasY = inp.ico.cursorHotspotY !== undefined; + if (hasX || hasY) { + if (hasMultipleImages && product.ico.hasCursorHotspotBug) { + console.warn("icotool " + product.ico.version + " does not support setting " + + "the hotspot for cursor files with multiple images. Install " + + "icoutils 0.32.0 or newer to use this feature."); + } else { + if (hasX) + args.push("--hotspot-x=" + inp.ico.cursorHotspotX); + if (hasY) + args.push("--hotspot-y=" + inp.ico.cursorHotspotY); + } + } + } + if (inp.ico.raw) + args.push("-r"); + args.push(inp.filePath); + }); + + var cmd = new Command(product.ico.icotoolFilePath, args); + cmd.description = "creating " + output.fileName; + return [cmd]; +} + +function findIcoUtilsVersion(toolFilePath) { + var p = new Process(); + try { + p.exec(toolFilePath, ["--version"]); + var re = /^[a-z]+ \(icoutils\) ([0-9]+(?:\.[0-9]+){1,2})$/m; + var match = p.readStdOut().trim().match(re); + if (match !== null) + return match[1]; + } finally { + p.close(); + } +} diff --git a/share/qbs/modules/innosetup/InnoSetupModule.qbs b/share/qbs/modules/innosetup/InnoSetupModule.qbs new file mode 100644 index 00000000..930d85a9 --- /dev/null +++ b/share/qbs/modules/innosetup/InnoSetupModule.qbs @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.ModUtils +import qbs.Probes + +Module { + condition: qbs.targetOS.contains("windows") + + Probes.InnoSetupProbe { + id: innoSetupProbe + } + + property path toolchainInstallPath: innoSetupProbe.path + version: innoSetupProbe.version + property var versionParts: version ? version.split('.').map(function (item) { return parseInt(item, 10); }) : [] + property int versionMajor: versionParts[0] + property int versionMinor: versionParts[1] + property int versionPatch: versionParts[2] + + property string compilerName: "ISCC.exe" + property string compilerPath: FileInfo.joinPaths(toolchainInstallPath, compilerName) + + property bool verboseOutput: false + PropertyOptions { + name: "verboseOutput" + description: "display verbose output from the Inno Setup compiler" + } + + property pathList includePaths + PropertyOptions { + name: "includePaths" + description: "directories to add to the include search path" + } + + property stringList defines + PropertyOptions { + name: "defines" + description: "variables that are defined when using the Inno Setup compiler" + } + + property stringList compilerFlags + PropertyOptions { + name: "compilerFlags" + description: "additional flags for the Inno Setup compiler" + } + + readonly property string executableSuffix: ".exe" + + validate: { + if (!innoSetupProbe.found) { + throw ModUtils.ModuleError("Could not find InnoSetup in Windows registry. Make " + + "sure InnoSetup is installed correctly."); + } + var validator = new ModUtils.PropertyValidator("innosetup"); + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + validator.setRequiredProperty("version", version); + validator.setRequiredProperty("versionMajor", versionMajor); + validator.setRequiredProperty("versionMinor", versionMinor); + validator.setRequiredProperty("versionPatch", versionPatch); + validator.addVersionValidator("version", version, 3, 3); + validator.addRangeValidator("versionMajor", versionMajor, 1); + validator.addRangeValidator("versionMinor", versionMinor, 0); + validator.addRangeValidator("versionPatch", versionPatch, 0); + validator.validate(); + } + + // Inno Setup Script + FileTagger { + patterns: ["*.iss"] + fileTags: ["innosetup.iss"] + } + + Rule { + id: innoSetupCompiler + inputs: ["innosetup.iss"] + auxiliaryInputs: ["installable"] + + Artifact { + fileTags: ["innosetup.exe", "application"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + ModUtils.moduleProperty(product, "executableSuffix")) + } + + prepare: { + var i; + var args = [ + "/O" + FileInfo.toNativeSeparators(FileInfo.path(output.filePath)), + "/F" + FileInfo.toNativeSeparators(FileInfo.completeBaseName(output.fileName)) + ]; + + if (!ModUtils.moduleProperty(product, "verboseOutput")) + args.push("/Q"); + + var includePaths = ModUtils.moduleProperty(product, "includePaths"); + for (i in includePaths) + args.push("/I" + FileInfo.toNativeSeparators(includePaths[i])); + + // User-supplied defines + var defines = ModUtils.moduleProperty(product, "defines"); + for (i in defines) + args.push("/D" + defines[i]); + + // User-supplied flags + var flags = ModUtils.moduleProperty(product, "compilerFlags"); + for (i in flags) + args.push(flags[i]); + + args.push(FileInfo.toNativeSeparators(input.filePath)); + var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.workingDirectory = FileInfo.path(input.filePath); + return cmd; + } + } +} diff --git a/share/qbs/modules/java/JavaModule.qbs b/share/qbs/modules/java/JavaModule.qbs new file mode 100644 index 00000000..d4d7c449 --- /dev/null +++ b/share/qbs/modules/java/JavaModule.qbs @@ -0,0 +1,361 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import qbs.Process +import qbs.TextFile +import qbs.Utilities + +import "utils.js" as JavaUtils + +Module { + Probes.JdkProbe { + id: jdk + environmentPaths: (jdkPath ? [jdkPath] : []).concat(base) + } + + Probes.JdkVersionProbe { + id: jdkVersionProbe + javac: compilerFilePath + } + + property stringList additionalClassPaths + property stringList additionalCompilerFlags + property stringList additionalJarFlags + property stringList bootClassPaths + property string compilerFilePath: FileInfo.joinPaths(jdkPath, "bin", compilerName) + property string compilerName: "javac" + property bool enableWarnings: true + property string interpreterFilePath : FileInfo.joinPaths(jdkPath, "bin", interpreterName) + property string interpreterName: "java" + property string jarFilePath: FileInfo.joinPaths(jdkPath, "bin", jarName) + property string jarName: "jar" + property string jarsignerFilePath: FileInfo.joinPaths(jdkPath, "bin", jarsignerName) + property string jarsignerName: "jarsigner" + property string keytoolFilePath: FileInfo.joinPaths(jdkPath, "bin", keytoolName) + property string keytoolName: "keytool" + + property bool _tagJniHeaders: true + + property string jdkPath: jdk.path + + version: [compilerVersionMajor, compilerVersionMinor, compilerVersionPatch].join(".") + property string compilerVersion: jdkVersionProbe.version + ? jdkVersionProbe.version[1] : undefined + property var compilerVersionParts: JavaUtils.splitVersionString(compilerVersion) + property int compilerVersionMajor: compilerVersionParts[0] + property int compilerVersionMinor: compilerVersionParts[1] + property int compilerVersionPatch: compilerVersionParts[2] + property int compilerVersionUpdate: compilerVersionParts[3] + + property string languageVersion + PropertyOptions { + name: "languageVersion" + description: "Java language version to interpret source code as" + } + + property string runtimeVersion + PropertyOptions { + name: "runtimeVersion" + description: "version of the Java runtime to generate compatible bytecode for" + } + + property var manifest: { + return { + "Manifest-Version": "1.0", + "Class-Path": manifestClassPath ? manifestClassPath.join(" ") : undefined + }; + } + + PropertyOptions { + name: "manifest" + description: "properties to add to the manifest file when building a JAR" + } + + PropertyOptions { + name: "manifestFile" + description: "Use files tagged \"java.manifest\" instead." + removalVersion: "1.9" + } + property stringList manifestClassPath + PropertyOptions { + name: "manifestClassPath" + description: "entries to add to the manifest's Class-Path when building a JAR" + } + + property bool warningsAsErrors: false + + property pathList jdkIncludePaths: { + var paths = []; + if (isAppleJava) { + paths.push(FileInfo.joinPaths(qbs.sysroot, + "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers")); + } else { + paths.push(FileInfo.joinPaths(jdkPath, "include")); + + var hostOS = Host.os().contains("windows") ? Host.os().concat(["win32"]) : Host.os(); + var platforms = ["win32", "darwin", "linux", "bsd", "solaris"]; + for (var i = 0; i < platforms.length; ++i) { + if (hostOS.contains(platforms[i])) { + // Corresponds to JDK_INCLUDE_SUBDIR in the JDK Makefiles + paths.push(FileInfo.joinPaths(jdkPath, "include", platforms[i])); + break; + } + } + } + + return paths; + } + + // Internal properties + property path classFilesDir: FileInfo.joinPaths(product.buildDirectory, "classes") + property path internalClassFilesDir: FileInfo.joinPaths(product.buildDirectory, ".classes") + + property bool isAppleJava: Host.os().contains("darwin") + && (compilerVersionMajor < 1 + || (compilerVersionMajor === 1 && compilerVersionMinor < 7)) + + // https://developer.apple.com/library/content/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html + // tools.jar does not exist. Classes usually located here are instead included in classes.jar. + // The same is true for rt.jar, although not mentioned in the documentation + property path classesJarPath: { + if (isAppleJava) + return FileInfo.joinPaths(jdkPath, "bundle", "Classes", "classes.jar"); + } + + property path runtimeJarPath: { + if (compilerVersionMajor >= 9) + return undefined; + if (classesJarPath) + return classesJarPath; + return FileInfo.joinPaths(jdkPath, "jre", "lib", "rt.jar"); + } + + property path toolsJarPath: { + if (compilerVersionMajor >= 9) + return undefined; + if (classesJarPath) + return classesJarPath; + return FileInfo.joinPaths(jdkPath, "lib", "tools.jar"); + } + + validate: { + var validator = new ModUtils.PropertyValidator("java"); + validator.setRequiredProperty("jdkPath", jdkPath); + validator.setRequiredProperty("compilerVersion", compilerVersion); + validator.setRequiredProperty("compilerVersionParts", compilerVersionParts); + validator.setRequiredProperty("compilerVersionMajor", compilerVersionMajor); + validator.setRequiredProperty("compilerVersionMinor", compilerVersionMinor); + if (Utilities.versionCompare(version, "9") < 0) + validator.setRequiredProperty("compilerVersionUpdate", compilerVersionUpdate); + validator.addVersionValidator("compilerVersion", compilerVersion + ? compilerVersion.replace("_", ".") : undefined, 1, 4); + validator.addRangeValidator("compilerVersionMajor", compilerVersionMajor, 1); + validator.addRangeValidator("compilerVersionMinor", compilerVersionMinor, 0); + validator.addRangeValidator("compilerVersionPatch", compilerVersionPatch, 0); + if (Utilities.versionCompare(version, "9") < 0) + validator.addRangeValidator("compilerVersionUpdate", compilerVersionUpdate, 0); + validator.validate(); + } + + FileTagger { + patterns: "*.java" + fileTags: ["java.java"] + } + + FileTagger { + patterns: ["*.mf"] + fileTags: ["java.manifest"] + } + + Group { + name: "io.qt.qbs.internal.java-helper" + files: { + return JavaUtils.helperFullyQualifiedNames("java").map(function(name) { + return FileInfo.joinPaths(path, name + ".java"); + }); + } + + fileTags: ["java.java-internal"] + } + + Rule { + multiplex: true + inputs: ["java.java-internal"] + + outputFileTags: ["java.class-internal"] + outputArtifacts: { + return JavaUtils.helperOutputArtifacts(product); + } + + prepare: { + var cmd = new Command(ModUtils.moduleProperty(product, "compilerFilePath"), + JavaUtils.javacArguments(product, inputs, + JavaUtils.helperOverrideArgs(product, + "javac"))); + cmd.ignoreDryRun = true; + cmd.silent = true; + return [cmd]; + } + } + + Rule { + multiplex: true + inputs: ["java.java"] + inputsFromDependencies: ["java.jar"] + explicitlyDependsOn: ["java.class-internal"] + + outputFileTags: ["java.class"].concat(_tagJniHeaders ? ["hpp"] : ["java.jni-hpp"]) // Annotations can produce additional java source files. Ignored for now. + outputArtifacts: { + var artifacts = JavaUtils.outputArtifacts(product, inputs); + if (!product.java._tagJniHeaders) { + for (var i = 0; i < artifacts.length; ++i) { + var a = artifacts[i]; + if (a.fileTags instanceof Array) + a.fileTags = a.fileTags.map(function(tag) { + if (tag === "hpp") + return "java.jni-hpp"; + return tag; + }); + } + } + return artifacts; + } + prepare: { + var cmd = new Command(ModUtils.moduleProperty(product, "compilerFilePath"), + JavaUtils.javacArguments(product, inputs)); + cmd.description = "compiling Java sources"; + cmd.highlight = "compiler"; + return [cmd]; + } + } + + Rule { + inputs: ["java.class", "java.manifest"] + multiplex: true + + Artifact { + fileTags: ["java.jar"] + filePath: FileInfo.joinPaths(product.destinationDirectory, product.targetName + ".jar") + } + + prepare: { + var i, key; + var flags = "cf"; + var args = [output.filePath]; + + var aggregateManifest = {}; + var manifestFiles = (inputs["java.manifest"] || []).map(function (a) { return a.filePath; }); + manifestFiles.forEach(function (manifestFile) { + var mf = JavaUtils.manifestContents(manifestFile); + for (key in mf) { + if (mf.hasOwnProperty(key)) { + var oldValue = aggregateManifest[key]; + var newValue = mf[key]; + if (oldValue !== undefined && oldValue !== newValue) { + throw new Error("Conflicting values '" + + oldValue + "' and '" + + newValue + "' for manifest file key '" + key + "'"); + } + + aggregateManifest[key] = newValue; + } + } + }); + + // Add local key-value pairs (overrides equivalent keys specified in the file if + // one was given) + var manifest = product.java.manifest; + for (key in manifest) { + if (manifest.hasOwnProperty(key)) + aggregateManifest[key] = manifest[key]; + } + + for (key in aggregateManifest) { + if (aggregateManifest.hasOwnProperty(key) && aggregateManifest[key] === undefined) + delete aggregateManifest[key]; + } + + // Use default manifest unless we actually have properties to set + var needsManifestFile = manifestFiles.length > 0 + || aggregateManifest !== {"Manifest-Version": "1.0"}; + + var manifestFile = FileInfo.joinPaths(product.buildDirectory, "manifest.mf"); + + var mf; + try { + mf = new TextFile(manifestFile, TextFile.WriteOnly); + + // Ensure that manifest version comes first + mf.write("Manifest-Version: " + (aggregateManifest["Manifest-Version"] || "1.0") + "\n"); + delete aggregateManifest["Manifest-Version"]; + + for (key in aggregateManifest) + mf.write(key + ": " + aggregateManifest[key] + "\n"); + + mf.write("\n"); + } finally { + if (mf) { + mf.close(); + } + } + + if (needsManifestFile) { + flags += "m"; + args.push(manifestFile); + } + + var entryPoint = ModUtils.moduleProperty(product, "entryPoint"); + var entryPoint = product.entryPoint; + if (entryPoint) { + flags += "e"; + args.push(entryPoint); + } + + args.unshift(flags); + + var otherFlags = ModUtils.moduleProperty(product, "additionalJarFlags"); + if (otherFlags) + args = args.concat(otherFlags); + + for (i in inputs["java.class"]) + args.push(FileInfo.relativePath(ModUtils.moduleProperty(product, "classFilesDir"), + inputs["java.class"][i].filePath)); + var cmd = new Command(ModUtils.moduleProperty(product, "jarFilePath"), args); + cmd.workingDirectory = ModUtils.moduleProperty(product, "classFilesDir"); + cmd.description = "building " + FileInfo.fileName(output.fileName); + cmd.highlight = "linker"; + return cmd; + } + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/Artifact.java b/share/qbs/modules/java/io/qt/qbs/Artifact.java new file mode 100644 index 00000000..cc06d397 --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/Artifact.java @@ -0,0 +1,76 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Artifact { + private String filePath; + private List fileTags; + + public Artifact(String filePath) { + if (filePath == null) + throw new IllegalArgumentException("filePath"); + + this.filePath = filePath; + this.fileTags = new ArrayList(); + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public List getFileTags() { + return Collections.unmodifiableList(fileTags); + } + + public void setFileTags(List fileTags) { + this.fileTags = new ArrayList(fileTags); + } + + public void addFileTag(String fileTag) { + this.fileTags.add(fileTag); + } + + public void removeFileTag(String fileTag) { + this.fileTags.remove(fileTag); + } + + public void clearFileTags() { + this.fileTags.clear(); + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/ArtifactListJsonWriter.java b/share/qbs/modules/java/io/qt/qbs/ArtifactListJsonWriter.java new file mode 100644 index 00000000..d7f60ddc --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/ArtifactListJsonWriter.java @@ -0,0 +1,153 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.List; + +/** + * This uses a custom JSON implementation because the Java Standard Library does + * not yet have native support for JSON, and only minimal support is required + * here. + */ +public class ArtifactListJsonWriter implements ArtifactListWriter { + private static final int TAB_WIDTH = 4; + + // based on escapeString from qtbase/qjsonwriter.cpp + private static String escapeString(String s) { + String out = ""; + for (int i = 0; i < s.length();) { + int u = s.codePointAt(i); + + // unpaired surrogate + if (u >= Character.MIN_SURROGATE && u <= Character.MAX_SURROGATE) { + out += "\ufffd"; + i += Character.charCount(u); + continue; + } + + if (u < 0x80) { + if (u < 0x20 || u == 0x22 || u == 0x5c) { + out += "\\"; + switch (u) { + case 0x22: + out += "\""; + break; + case 0x5c: + out += "\\"; + break; + case 0x8: + out += "b"; + break; + case 0xc: + out += "f"; + break; + case 0xa: + out += "n"; + break; + case 0xd: + out += "r"; + break; + case 0x9: + out += "t"; + break; + default: + out += "u"; + out += "0"; + out += "0"; + String hex = Integer.toHexString(u); + if (hex.length() == 1) + out += "0"; + out += hex; + break; + } + } else { + out += s.substring(i, i + Character.charCount(u)); + } + } else { + out += s.substring(i, i + Character.charCount(u)); + } + + i += Character.charCount(u); + } + + return out; + } + + private static void writeString(PrintStream printWriter, String s) { + printWriter.print("\""); + printWriter.print(escapeString(s)); + printWriter.print("\""); + } + + private static void writeIndent(PrintStream printWriter, int level) { + for (int i = 0; i < level * TAB_WIDTH; ++i) { + printWriter.print(" "); + } + } + + private static void writeArtifact(Artifact artifact, + PrintStream printWriter, int indentLevel, Boolean comma) { + writeIndent(printWriter, indentLevel++); + printWriter.print("{\n"); + writeIndent(printWriter, indentLevel); + writeString(printWriter, "filePath"); + printWriter.print(": "); + writeString(printWriter, artifact.getFilePath()); + printWriter.println(","); + writeIndent(printWriter, indentLevel); + writeString(printWriter, "fileTags"); + printWriter.print(": ["); + for (int i = 0; i < artifact.getFileTags().size(); ++i) { + writeString(printWriter, artifact.getFileTags().get(i)); + if (i != artifact.getFileTags().size() - 1) + printWriter.print(", "); + } + printWriter.println("]"); + writeIndent(printWriter, --indentLevel); + printWriter.println("}" + (comma ? "," : "")); + } + + @Override + public void write(List artifacts, OutputStream outputStream) + throws IOException { + PrintStream printWriter = new PrintStream(outputStream); + printWriter.print("[\n"); + for (int i = 0; i < artifacts.size(); ++i) { + writeArtifact(artifacts.get(i), printWriter, 1, + i != artifacts.size() - 1); + } + + printWriter.println("]"); + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/ArtifactListWriter.java b/share/qbs/modules/java/io/qt/qbs/ArtifactListWriter.java new file mode 100644 index 00000000..a213207b --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/ArtifactListWriter.java @@ -0,0 +1,39 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; + +public interface ArtifactListWriter { + void write(List artifacts, OutputStream outputStream) throws IOException; +} diff --git a/share/qbs/modules/java/io/qt/qbs/tools/JavaCompilerScannerTool.java b/share/qbs/modules/java/io/qt/qbs/tools/JavaCompilerScannerTool.java new file mode 100644 index 00000000..10df621e --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/tools/JavaCompilerScannerTool.java @@ -0,0 +1,51 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs.tools; + +import io.qt.qbs.tools.utils.JavaCompilerScanner; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; + +public class JavaCompilerScannerTool { + public static void main(String[] args) { + try { + JavaCompilerScanner scanner = new JavaCompilerScanner(); + int result = scanner.run(new ArrayList(Arrays.asList(args))); + scanner.write(System.out); + System.exit(result); + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerOptions.java b/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerOptions.java new file mode 100644 index 00000000..7bb5b41b --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerOptions.java @@ -0,0 +1,102 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs.tools.utils; + +import javax.lang.model.SourceVersion; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileManager; +import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class JavaCompilerOptions { + private final List recognizedOptions; + private final List classNames; + private final List files; + + private JavaCompilerOptions(List recognizedOptions, List classNames, List files) { + this.recognizedOptions = recognizedOptions; + this.classNames = classNames; + this.files = files; + } + + public static JavaCompilerOptions parse(JavaCompiler compiler, + JavaFileManager fileManager, String... arguments) { + List recognizedOptions = new ArrayList(); + List classNames = new ArrayList(); + List files = new ArrayList(); + + for (int i = 0; i < arguments.length; ++i) { + int argumentCount = compiler.isSupportedOption(arguments[i]); + if (argumentCount < 0) + argumentCount = fileManager.isSupportedOption(arguments[i]); + + if (argumentCount >= 0) { + + // isSupportedOption() returns 1 for -Xlint* in Java 9. Bug? + if (arguments[i].startsWith("-Xlint")) + argumentCount = 0; + + for (int j = 0; j < argumentCount + 1; ++j) { + if (i + j >= arguments.length) { + throw new IllegalArgumentException(arguments[i]); + } + recognizedOptions.add(arguments[i + j]); + } + + i += argumentCount; + } else { + File file = new File(arguments[i]); + if (file.exists()) + files.add(file); + else if (SourceVersion.isName(arguments[i])) + classNames.add(arguments[i]); + else + throw new IllegalArgumentException(arguments[i]); + } + } + + return new JavaCompilerOptions(recognizedOptions, classNames, files); + } + + public List getRecognizedOptions() { + return Collections.unmodifiableList(recognizedOptions); + } + + public List getFiles() { + return Collections.unmodifiableList(files); + } + + public List getClassNames() { + return Collections.unmodifiableList(classNames); + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerScanner.java b/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerScanner.java new file mode 100644 index 00000000..ef655500 --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerScanner.java @@ -0,0 +1,107 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs.tools.utils; + +import io.qt.qbs.*; + +import javax.tools.*; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.*; + +public class JavaCompilerScanner { + private List artifacts = new ArrayList(); + private ArtifactListWriter writer = new ArtifactListJsonWriter(); + + public List getArtifacts() { + return this.artifacts; + } + + public int run(List compilerArguments) { + artifacts.clear(); + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager standardFileManager = compiler + .getStandardFileManager(null, null, null); + final JavaFileManager fileManager = new ForwardingJavaFileManager( + standardFileManager) { + @Override + public JavaFileObject getJavaFileForOutput( + JavaFileManager.Location location, String className, + JavaFileObject.Kind kind, FileObject sibling) + throws IOException { + JavaFileObject o = super.getJavaFileForOutput(location, + className, kind, sibling); + Artifact artifact = new Artifact(new File(o.toUri() + .getSchemeSpecificPart()).toString()); + if (kind.equals(JavaFileObject.Kind.CLASS)) { + artifact.addFileTag("java.class"); + } else if (kind.equals(JavaFileObject.Kind.SOURCE)) { + artifact.addFileTag("java.java"); + } + artifacts.add(artifact); + return new NullFileObject(o); + } + + @Override + public FileObject getFileForOutput( + JavaFileManager.Location location, String packageName, + String relativeName, FileObject sibling) throws IOException { + FileObject o = super.getFileForOutput(location, packageName, + relativeName, sibling); + Artifact artifact = new Artifact(new File(o.toUri() + .getSchemeSpecificPart()).toString()); + if (o.getName().endsWith(".h")) { + artifact.addFileTag("hpp"); + } + artifacts.add(artifact); + return new NullFileObject(o); + } + }; + + final JavaCompilerOptions options = JavaCompilerOptions + .parse(compiler, standardFileManager, compilerArguments + .toArray(new String[compilerArguments.size()])); + + return compiler.getTask( + null, + fileManager, + null, + options.getRecognizedOptions(), + options.getClassNames(), + standardFileManager.getJavaFileObjectsFromFiles(options + .getFiles())).call() ? 0 : 1; + } + + public void write(OutputStream outputStream) throws IOException { + writer.write(getArtifacts(), outputStream); + } +} diff --git a/share/qbs/modules/java/io/qt/qbs/tools/utils/NullFileObject.java b/share/qbs/modules/java/io/qt/qbs/tools/utils/NullFileObject.java new file mode 100644 index 00000000..d74a69fb --- /dev/null +++ b/share/qbs/modules/java/io/qt/qbs/tools/utils/NullFileObject.java @@ -0,0 +1,147 @@ +/**************************************************************************** + ** + ** Copyright (C) 2015 Jake Petroules. + ** Contact: http://www.qt.io/licensing + ** + ** This file is part of Qbs. + ** + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and The Qt Company. For licensing terms and + ** conditions see http://www.qt.io/terms-conditions. For further information + ** use the contact form at http://www.qt.io/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 or version 3 as published by the Free + ** Software Foundation and appearing in the file LICENSE.LGPLv21 and + ** LICENSE.LGPLv3 included in the packaging of this file. Please review the + ** following information to ensure the GNU Lesser General Public License + ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and + ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, The Qt Company gives you certain additional + ** rights. These rights are described in The Qt Company LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ****************************************************************************/ + +package io.qt.qbs.tools.utils; + +import javax.lang.model.element.Modifier; +import javax.lang.model.element.NestingKind; +import javax.tools.FileObject; +import javax.tools.JavaFileObject; +import java.io.*; +import java.net.URI; + +/** + * Represents a FileObject that discards its output when written. + */ +public class NullFileObject implements FileObject, JavaFileObject { + FileObject obj; + + public NullFileObject(FileObject obj) { + this.obj = obj; + } + + @Override + public URI toUri() { + return obj.toUri(); + } + + @Override + public String getName() { + return obj.getName(); + } + + @Override + public InputStream openInputStream() throws IOException { + return obj.openInputStream(); + } + + @Override + public OutputStream openOutputStream() throws IOException { + return new OutputStream() { + @Override + public void write(int b) throws IOException { + } + }; + } + + @Override + public Reader openReader(boolean ignoreEncodingErrors) throws IOException { + return obj.openReader(ignoreEncodingErrors); + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) + throws IOException { + return obj.getCharContent(ignoreEncodingErrors); + } + + @Override + public Writer openWriter() throws IOException { + return new Writer() { + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + } + + @Override + public void flush() throws IOException { + } + + @Override + public void close() throws IOException { + } + }; + } + + @Override + public long getLastModified() { + return obj.getLastModified(); + } + + @Override + public boolean delete() { + return true; + } + + @Override + public Kind getKind() { + if (obj instanceof JavaFileObject) { + return ((JavaFileObject) obj).getKind(); + } + + throw new UnsupportedOperationException(); + } + + @Override + public boolean isNameCompatible(String simpleName, Kind kind) { + if (obj instanceof JavaFileObject) { + return ((JavaFileObject) obj).isNameCompatible(simpleName, kind); + } + + throw new UnsupportedOperationException(); + } + + @Override + public NestingKind getNestingKind() { + if (obj instanceof JavaFileObject) { + return ((JavaFileObject) obj).getNestingKind(); + } + + throw new UnsupportedOperationException(); + } + + @Override + public Modifier getAccessLevel() { + if (obj instanceof JavaFileObject) { + return ((JavaFileObject) obj).getAccessLevel(); + } + + throw new UnsupportedOperationException(); + } +} diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js new file mode 100644 index 00000000..8fb9661f --- /dev/null +++ b/share/qbs/modules/java/utils.js @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); +var TextFile = require("qbs.TextFile"); +var Utilities = require("qbs.Utilities"); +var WindowsUtils = require("qbs.WindowsUtils"); + +function is64bitProcess() { + var y = jdkRootRegistryKey(true); + var n = jdkRootRegistryKey(false); + y = Utilities.getNativeSetting(y + "\\" + Utilities.getNativeSetting(y, "CurrentVersion"), "JavaHome"); + n = Utilities.getNativeSetting(n + "\\" + Utilities.getNativeSetting(n, "CurrentVersion"), "JavaHome"); + return y !== n; +} + +function useWow64Key(arch) { + var wow64 = false; + switch (arch) { + case "x86_64": + case "ia64": + // QTBUG-3845 + if (!is64bitProcess()) + return undefined; + break; + case "x86": + case "armv7": + wow64 = is64bitProcess(); + break; + } + return wow64; +} + +function jdkRootRegistryKey(wow64) { + // If an architecture is specified, search the appropriate key for that architecture, + // on this version of Windows (i.e. WOW64 or not) if compatible, + // otherwise get both keys since any JDK will be usable + if (wow64 === undefined) + return undefined; + return FileInfo.toWindowsSeparators(FileInfo.joinPaths("HKEY_LOCAL_MACHINE", "SOFTWARE", + (wow64 ? "Wow6432Node" : undefined), + "JavaSoft", "Java Development Kit")); +} + +function findJdkPath(hostOS, arch, environmentPaths, searchPaths) { + var i; + for (i = 0; i < environmentPaths.length; ++i) { + if (environmentPaths[i]) + return environmentPaths[i]; + } + + if (hostOS.contains("windows")) { + var rootKey = jdkRootRegistryKey(useWow64Key(arch)); + if (rootKey) { + var current = Utilities.getNativeSetting(rootKey, "CurrentVersion"); // 1.8 etc. + if (current) { + var home = Utilities.getNativeSetting([rootKey, current].join("\\"), "JavaHome"); + if (home) { + return home; + } + } + } + + return undefined; + } + + if (hostOS.contains("macos")) { + var p = new Process(); + try { + // We filter by architecture here so that we'll get a compatible JVM for JNI use. + var args = []; + if (arch) { + // Hardcoding apple/macosx/macho here is fine because we know we're on macOS + args.push("--arch", + Utilities.canonicalTargetArchitecture(arch, undefined, + "apple", "macosx", "macho")); + } + + // --failfast doesn't print the default JVM if nothing matches the filter(s). + var status = p.exec("/usr/libexec/java_home", args.concat(["--failfast"])); + return status === 0 ? p.readStdOut().trim() : undefined; + } finally { + p.close(); + } + } + + if (hostOS.contains("unix")) { + var requiredTools = ["javac", "java", "jar"]; + for (i = 0; i < searchPaths.length; ++i) { + function fullToolPath(tool) { + return FileInfo.joinPaths(searchPaths[i], "bin", tool); + } + + if (requiredTools.map(function(p) { return fullToolPath(p); }) + .every(function(p) { return File.exists(p); })) { + return searchPaths[i]; + } + } + + return undefined; + } +} + +function findJdkVersion(compilerFilePath) { + var p = new Process(); + try { + p.exec(compilerFilePath, ["-version"]); + var re = /^javac (([0-9]+(?:\.[0-9]+){0,2})(_([0-9]+))?)(.*)?$/m; + var match = p.readStdErr().trim().match(re); + if (!match) + match = p.readStdOut().trim().match(re); + if (match !== null) + return match; + } finally { + p.close(); + } +} + +function splitVersionString(compilerVersion) { + if (!compilerVersion) + return []; + + var result = compilerVersion.split(/[\._]/).map(function(item) { + return parseInt(item, 10); + }); + // special case, if javac -version returned "12" instead of "12.0.0" + if (result.length === 1) + result.push(0, 0); + return result; +} + +function supportsGeneratedNativeHeaderFiles(product) { + var compilerVersionMajor = ModUtils.moduleProperty(product, "compilerVersionMajor"); + if (compilerVersionMajor === 1) { + if (ModUtils.moduleProperty(product, "compilerVersionMinor") >= 8) { + return true; + } + } + + return compilerVersionMajor > 1; +} + +function javacArguments(product, inputs, overrides) { + function getModuleProperty(product, propertyName, overrides) { + if (overrides && overrides[propertyName]) + return overrides[propertyName]; + return ModUtils.moduleProperty(product, propertyName); + } + + function getModuleProperties(product, propertyName, overrides) { + if (overrides && overrides[propertyName]) + return overrides[propertyName]; + return ModUtils.moduleProperty(product, propertyName); + } + + var i; + var outputDir = getModuleProperty(product, "classFilesDir", overrides); + var classPaths = [outputDir]; + var additionalClassPaths = getModuleProperties(product, "additionalClassPaths", overrides); + if (additionalClassPaths) + classPaths = classPaths.concat(additionalClassPaths); + for (i in inputs["java.jar"]) + classPaths.push(inputs["java.jar"][i].filePath); + var debugArg = product.moduleProperty("qbs", "buildVariant") === "debug" + ? "-g" : "-g:none"; + var pathListSeparator = FileInfo.pathListSeparator(); + var args = [ + "-classpath", classPaths.join(pathListSeparator), + "-s", product.buildDirectory, + debugArg, "-d", outputDir + ]; + if (supportsGeneratedNativeHeaderFiles(product)) + args.push("-h", product.buildDirectory); + var runtimeVersion = getModuleProperty(product, "runtimeVersion", overrides); + if (runtimeVersion) + args.push("-target", runtimeVersion); + var languageVersion = getModuleProperty(product, "languageVersion", overrides); + if (languageVersion) + args.push("-source", languageVersion); + var bootClassPaths = getModuleProperties(product, "bootClassPaths", overrides); + if (bootClassPaths && bootClassPaths.length > 0 + && (!runtimeVersion || Utilities.versionCompare(runtimeVersion, "9") < 0)) { + args.push("-bootclasspath", bootClassPaths.join(pathListSeparator)); + } + if (!getModuleProperty(product, "enableWarnings", overrides)) + args.push("-nowarn"); + if (getModuleProperty(product, "warningsAsErrors", overrides)) + args.push("-Werror"); + var otherFlags = getModuleProperties(product, "additionalCompilerFlags", overrides); + if (otherFlags) + args = args.concat(otherFlags); + for (i in inputs["java.java"]) + args.push(inputs["java.java"][i].filePath); + for (i in inputs["java.java-internal"]) + args.push(inputs["java.java-internal"][i].filePath); + return args; +} + +/** + * Returns a list of fully qualified Java class names for the compiler helper tool. + * + * @param type @c java to return names of sources, @c to return names of compiled classes + */ +function helperFullyQualifiedNames(type) { + var names = [ + "io/qt/qbs/Artifact", + "io/qt/qbs/ArtifactListJsonWriter", + "io/qt/qbs/ArtifactListWriter", + "io/qt/qbs/tools/JavaCompilerScannerTool", + "io/qt/qbs/tools/utils/JavaCompilerOptions", + "io/qt/qbs/tools/utils/JavaCompilerScanner", + "io/qt/qbs/tools/utils/JavaCompilerScanner$1", + "io/qt/qbs/tools/utils/NullFileObject", + "io/qt/qbs/tools/utils/NullFileObject$1", + "io/qt/qbs/tools/utils/NullFileObject$2", + ]; + if (type === "java") { + return names.filter(function (name) { + return !name.contains("$"); + }); + } else if (type === "class") { + return names; + } +} + +function helperOutputArtifacts(product) { + File.makePath(ModUtils.moduleProperty(product, "internalClassFilesDir")); + return helperFullyQualifiedNames("class").map(function (name) { + return { + filePath: FileInfo.joinPaths(ModUtils.moduleProperty(product, "internalClassFilesDir"), + name + ".class"), + fileTags: ["java.class-internal"] + }; + }); +} + +function helperOverrideArgs(product, tool) { + var overrides = {}; + if (tool === "javac") { + // Build the helper tool with the same source and target version as the JDK it's being + // compiled with. Both are irrelevant here since the resulting tool will only be run + // with the same JDK as it was built with, and we know in advance the source is + // compatible with all Java language versions from 1.6 and above. + var jdkVersionArray = [product.java.compilerVersionMajor]; + if (product.java.compilerVersionMajor < 9) + jdkVersionArray.push(product.java.compilerVersionMinor); + var jdkVersion = jdkVersionArray.join("."); + overrides["languageVersion"] = jdkVersion; + overrides["runtimeVersion"] = jdkVersion; + + // Build the helper tool's class files separately from the actual product's class files + overrides["classFilesDir"] = ModUtils.moduleProperty(product, "internalClassFilesDir"); + + // Add tools.jar to the classpath as required for the tree scanner API + var toolsJarPath = ModUtils.moduleProperty(product, "toolsJarPath"); + if (toolsJarPath) + overrides["additionalClassPaths"] = [toolsJarPath].concat( + ModUtils.moduleProperty(product, "additionalClassPaths")); + } + + // Inject the current JDK's runtime classes into the boot class path when building/running the + // dependency scanner. This is normally not necessary but is important for Android platforms + // where android.jar is the only JAR on the boot classpath and JSR 199 is unavailable. + var rtJarPath = product.java.runtimeJarPath; + overrides["bootClassPaths"] = (rtJarPath ? [rtJarPath] : []).concat( + ModUtils.moduleProperty(product, "bootClassPaths")); + return overrides; +} + +function outputArtifacts(product, inputs) { + // Handle the case where a product depends on Java but has no Java sources + if (!inputs["java.java"] || inputs["java.java"].length === 0) + return []; + + // We need to ensure that the output directory is created first, because the Java compiler + // internally checks that it is present before performing any actions + File.makePath(ModUtils.moduleProperty(product, "classFilesDir")); + + var process; + try { + process = new Process(); + process.setWorkingDirectory( + FileInfo.joinPaths(ModUtils.moduleProperty(product, "internalClassFilesDir"))); + + var sep = FileInfo.pathListSeparator(); + var toolsJarPath = ModUtils.moduleProperty(product, "toolsJarPath"); + var javaArgs = [ + "-classpath", process.workingDirectory() + (toolsJarPath ? (sep + toolsJarPath) : ""), + "io/qt/qbs/tools/JavaCompilerScannerTool", + ]; + process.exec(ModUtils.moduleProperty(product, "interpreterFilePath"), javaArgs + .concat(javacArguments(product, inputs, helperOverrideArgs(product))), true); + var out = JSON.parse(process.readStdOut()); + console.error(process.readStdErr()); + return out; + } finally { + if (process) + process.close(); + } +} + +function manifestContents(filePath) { + if (filePath === undefined) + return undefined; + + var contents, file; + try { + file = new TextFile(filePath); + contents = file.readAll(); + } finally { + if (file) { + file.close(); + } + } + + if (contents) { + var dict = {}; + var lines = contents.split(/\r?\n/g).filter(function (line) { return line.length > 0; }); + for (var i = 0; i < lines.length; ++i) { + var kv = lines[i].split(":"); + if (kv.length !== 2) + throw new Error("Syntax error in manifest file '" + + filePath + "'; found \"" + lines[i] + "\" on line " + + parseInt(i, 10) + "; expected format \"Key: Value\""); + dict[kv[0].trim()] = kv[1].trim(); + } + + return dict; + } +} diff --git a/share/qbs/modules/lex_yacc/lexyacc.js b/share/qbs/modules/lex_yacc/lexyacc.js new file mode 100644 index 00000000..31474d32 --- /dev/null +++ b/share/qbs/modules/lex_yacc/lexyacc.js @@ -0,0 +1,84 @@ +var FileInfo = require("qbs.FileInfo"); +var TextFile = require("qbs.TextFile"); + +function unquote(s) +{ + return s.startsWith('"') && s.endsWith('"') ? s.substr(1, s.length - 2) : s; +} + +function readLexOptions(filePath) { + var result = {}; + var f = new TextFile(filePath, TextFile.ReadOnly); + var regex = /^%option\s+([^ \t=]+)(?:\s*=\s*(\S+))?/; + while (!f.atEof()) { + var line = f.readLine(); + var m = regex.exec(line); + if (!m) { + if (line === "%%") + break; + continue; + } + result[m[1]] = m[2] || true; + } + f.close(); + return result; +} + +function lexOutputFilePath(input, posixFileName, options) +{ + var outDir = input.lex_yacc.outputDir; + var fileName; + if (options.outfile) { + fileName = unquote(options.outfile); + } else if (options.prefix) { + fileName = FileInfo.baseName(posixFileName) + '.' + + unquote(options.prefix) + '.' + + FileInfo.suffix(posixFileName); + } else if (input.lex_yacc.uniqueSymbolPrefix) { + fileName = input.baseName; + fileName += posixFileName; + } else { + fileName = posixFileName; + } + return FileInfo.joinPaths(outDir, fileName); +} + +function readYaccOptions(filePath) { + var result = {}; + var f = new TextFile(filePath, TextFile.ReadOnly); + var regex = /^%output\s+(.+)/; + while (!f.atEof()) { + var line = f.readLine(); + var m = regex.exec(line); + if (!m) { + if (line === "%%") + break; + continue; + } + result.output = m[1]; + break; + } + f.close(); + return result; +} + +function yaccOutputFilePath(input, posixFileName, options) +{ + var outDir = input.lex_yacc.outputDir; + var fileName; + if (options.output) { + var outputFileName = unquote(options.output); + var suffix = FileInfo.suffix(posixFileName); + if (suffix === "c") { + fileName = outputFileName; + } else { + fileName = FileInfo.completeBaseName(outputFileName) + + '.' + suffix + FileInfo.suffix(outputFileName).slice(1); + } + } else if (input.lex_yacc.uniqueSymbolPrefix) { + fileName = input.baseName + posixFileName.slice(1); + } else { + fileName = posixFileName; + } + return FileInfo.joinPaths(outDir, fileName); +} diff --git a/share/qbs/modules/lex_yacc/lexyacc.qbs b/share/qbs/modules/lex_yacc/lexyacc.qbs new file mode 100644 index 00000000..48af1d79 --- /dev/null +++ b/share/qbs/modules/lex_yacc/lexyacc.qbs @@ -0,0 +1,102 @@ +import "lexyacc.js" as HelperFunctions + +Module { + Depends { name: "cpp" } + + property bool enableCompilerWarnings: false + property string lexBinary: "lex" + property string yaccBinary: "yacc" + property string outputTag: "c" + property bool uniqueSymbolPrefix: false + property string lexOutputFilePath + property string yaccOutputFilePath + property stringList lexFlags: [] + property stringList yaccFlags: [] + + readonly property string outputDir: product.buildDirectory + "/lexyacc" + + Rule { + inputs: ["lex.input"] + outputFileTags: [product.lex_yacc.outputTag] + outputArtifacts: { + var output = { + fileTags: [product.lex_yacc.outputTag], + lex_yacc: {}, + }; + var options = HelperFunctions.readLexOptions(input.filePath); + if (!options.outfile && input.lex_yacc.lexOutputFilePath) { + options.outfile = input.lex_yacc.lexOutputFilePath; + output.lex_yacc.useOutfileFromModule = true; + } + output.filePath = HelperFunctions.lexOutputFilePath(input, "lex.yy.c", options); + output.cpp = { + includePaths: [].concat(input.cpp.includePaths, input.lex_yacc.outputDir), + warningLevel: input.lex_yacc.enableCompilerWarnings ? "all" : "none", + }; + return [output]; + } + prepare: { + var args = input.lex_yacc.lexFlags; + if (output.lex_yacc.useOutfileFromModule) + args.push("-o" + input.lex_yacc.lexOutputFilePath); + else if (input.lex_yacc.uniqueSymbolPrefix) + args.push("-P" + input.baseName, "-o" + output.filePath); + args.push(input.filePath); + var cmd = new Command(input.lex_yacc.lexBinary, args); + cmd.workingDirectory = input.lex_yacc.outputDir; + cmd.description = "generating " + output.fileName; + return [cmd]; + } + } + + Rule { + inputs: ["yacc.input"] + outputFileTags: [product.lex_yacc.outputTag, "hpp"] + outputArtifacts: { + var src = { + fileTags: [product.lex_yacc.outputTag], + lex_yacc: {}, + }; + var options = HelperFunctions.readYaccOptions(input.filePath); + if (!options.output && input.lex_yacc.yaccOutputFilePath) { + options.output = input.lex_yacc.yaccOutputFilePath; + src.lex_yacc.useOutputFromModule = true; + } + var hdr = { + filePath: HelperFunctions.yaccOutputFilePath(input, "y.tab.h", options), + fileTags: ["hpp"], + }; + src.filePath = HelperFunctions.yaccOutputFilePath(input, "y.tab.c", options); + src.cpp = { + includePaths: [].concat(input.cpp.includePaths, input.lex_yacc.outputDir), + warningLevel: input.lex_yacc.enableCompilerWarnings ? "all" : "none", + }; + return [hdr, src]; + } + prepare: { + var args = input.lex_yacc.yaccFlags; + args.push("-d"); + var impl = outputs[input.lex_yacc.outputTag][0]; + if (impl.lex_yacc.useOutputFromModule) + args.push("-o" + input.lex_yacc.yaccOutputFilePath); + else if (input.lex_yacc.uniqueSymbolPrefix) + args.push("-b", input.baseName, "-p", input.baseName); + args.push(input.filePath); + var cmd = new Command(input.lex_yacc.yaccBinary, args); + cmd.workingDirectory = input.lex_yacc.outputDir; + cmd.description = "generating " + + impl.fileName + + " and " + outputs["hpp"][0].fileName; + return [cmd]; + } + } + + FileTagger { + patterns: ["*.l"] + fileTags: ["lex.input"]; + } + FileTagger { + patterns: ["*.y"] + fileTags: ["yacc.input"]; + } +} diff --git a/share/qbs/modules/nodejs/NodeJS.qbs b/share/qbs/modules/nodejs/NodeJS.qbs new file mode 100644 index 00000000..db10fb36 --- /dev/null +++ b/share/qbs/modules/nodejs/NodeJS.qbs @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes + +Module { + // JavaScript files which have been "processed" - currently this simply means "copied to output + // directory" but might later include minification and obfuscation processing + additionalProductTypes: ["nodejs_processed_js"].concat(applicationFile ? ["application"] : []) + + Probes.NodeJsProbe { + id: nodejs + searchPaths: toolchainInstallPath ? [toolchainInstallPath] : [] + } + + Probes.NpmProbe { + id: npm + searchPaths: toolchainInstallPath ? [toolchainInstallPath] : [] + interpreterPath: FileInfo.path(nodejs.filePath) + } + + property path applicationFile + PropertyOptions { + name: "applicationFile" + description: "file whose corresponding output will be executed when running the Node.js app" + } + + Group { + name: "Application file"; + prefix: product.sourceDirectory + '/' + files: nodejs.applicationFile ? [nodejs.applicationFile] : [] + } + + property path toolchainInstallPath: { + if (nodejs.path && npm.path && nodejs.path !== npm.path) + throw("node and npm binaries do not belong to the same installation (" + + nodejs.path + " vs " + npm.path + ")"); + return nodejs.path || npm.path; + } + + property path interpreterFileName: nodejs.fileName + property path interpreterFilePath: nodejs.filePath + + property path packageManagerFileName: npm.fileName + property path packageManagerFilePath: npm.filePath + + property path packageManagerBinPath: npm.npmBin + property path packageManagerRootPath: npm.npmRoot + property path packageManagerPrefixPath: npm.npmPrefix + + // private properties + readonly property path compiledIntermediateDir: FileInfo.joinPaths(product.buildDirectory, + "tmp", "nodejs.intermediate") + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), Host.os().contains("windows")); + v.prepend(product.nodejs.toolchainInstallPath); + v.set(); + } + + setupRunEnvironment: { + var v = new ModUtils.EnvironmentVariable("NODE_PATH", FileInfo.pathListSeparator(), Host.os().contains("windows")); + v.prepend(FileInfo.path(Environment.getEnv("QBS_RUN_FILE_PATH"))); + v.set(); + } + + FileTagger { + patterns: ["*.js"] + fileTags: ["js"] + } + + validate: { + var validator = new ModUtils.PropertyValidator("nodejs"); + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + validator.setRequiredProperty("interpreterFileName", interpreterFileName); + validator.setRequiredProperty("interpreterFilePath", interpreterFilePath); + validator.setRequiredProperty("packageManagerFileName", packageManagerFileName); + validator.setRequiredProperty("packageManagerFilePath", packageManagerFilePath); + validator.setRequiredProperty("packageManagerBinPath", packageManagerBinPath); + validator.setRequiredProperty("packageManagerRootPath", packageManagerRootPath); + validator.setRequiredProperty("packageManagerPrefixPath", packageManagerPrefixPath); + validator.validate(); + } + + Rule { + inputs: ["js"] + + outputArtifacts: { + var tags = ["nodejs_processed_js"]; + if (input.fileTags.contains("application_js") || + product.moduleProperty("nodejs", "applicationFile") === input.filePath) + tags.push("application"); + + // Preserve directory structure of input files + var intermediatePath = product.sourceDirectory; + + // Handle nodejs.compiledIntermediateDir (QBS-5 workaround) + var compiled = product.moduleProperty("nodejs", "compiledIntermediateDir"); + if (input.filePath.startsWith(compiled)) { + intermediatePath = compiled; + } + + intermediatePath = FileInfo.path(FileInfo.relativePath(intermediatePath, + input.filePath)); + + return [{ + filePath: FileInfo.joinPaths(product.destinationDirectory, intermediatePath, + input.fileName), + fileTags: tags + }]; + } + + outputFileTags: ["nodejs_processed_js", "application"] + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "copying " + input.fileName; + cmd.sourceCode = function() { + File.copy(input.filePath, output.filePath); + }; + return cmd; + } + } +} diff --git a/share/qbs/modules/nodejs/nodejs.js b/share/qbs/modules/nodejs/nodejs.js new file mode 100644 index 00000000..c329b7fc --- /dev/null +++ b/share/qbs/modules/nodejs/nodejs.js @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var Process = require("qbs.Process"); + +function findLocation(packageManagerFilePath, location, nodejsPath) { + var p = new Process(); + try { + if (nodejsPath) + p.setEnv("PATH", nodejsPath); + if (p.exec(packageManagerFilePath, [location, "-g"]) !== 0) + console.error(p.readStdErr().trim()); + return p.readStdOut().trim(); + } finally { + p.close(); + } +} diff --git a/share/qbs/modules/nsis/NSISModule.qbs b/share/qbs/modules/nsis/NSISModule.qbs new file mode 100644 index 00000000..cf862694 --- /dev/null +++ b/share/qbs/modules/nsis/NSISModule.qbs @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Utilities + +Module { + condition: qbs.targetOS.contains("windows") + + property path toolchainInstallPath: Utilities.getNativeSetting(registryKey) + + version: (versionMajor !== undefined && versionMinor !== undefined) ? (versionMajor + "." + versionMinor) : undefined + property var versionParts: [ versionMajor, versionMinor, versionPatch, versionBuild ] + property int versionMajor: Utilities.getNativeSetting(registryKey, "VersionMajor") + property int versionMinor: Utilities.getNativeSetting(registryKey, "VersionMinor") + property int versionPatch: Utilities.getNativeSetting(registryKey, "VersionBuild") + property int versionBuild: Utilities.getNativeSetting(registryKey, "VersionRevision") + + property string compilerName: "makensis" + property string compilerPath: compilerName + + property string warningLevel: "normal" + PropertyOptions { + name: "warningLevel" + allowedValues: ["none", "normal", "errors", "warnings", "info", "all"] + } + + property bool disableConfig: false + PropertyOptions { + name: "disableConfig" + description: "disable inclusion of nsisconf.nsh" + } + + property bool enableQbsDefines: true + PropertyOptions { + name: "enableQbsDefines" + description: "built-in variables that are defined when using the NSIS compiler" + } + + property stringList defines + PropertyOptions { + name: "defines" + description: "variables that are defined when using the NSIS compiler" + } + + property stringList compilerFlags + PropertyOptions { + name: "compilerFlags" + description: "additional flags for the NSIS compiler" + } + + property string compressor: "default" + PropertyOptions { + name: "compressor" + description: "the compression algorithm used to compress files/data in the installer" + allowedValues: ["default", "zlib", "zlib-solid", "bzip2", "bzip2-solid", "lzma", "lzma-solid"] + } + + property string executableSuffix: ".exe" + + // Private properties + property string registryKey: { + if (!Host.os().contains("windows")) + return undefined; + + var keys = [ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS" ]; + for (var i in keys) { + if (Utilities.getNativeSetting(keys[i])) + return keys[i]; + } + } + + validate: { + var validator = new ModUtils.PropertyValidator("nsis"); + + // Only *require* the toolchain install path on Windows + // On other (Unix-like) operating systems it'll probably be in the PATH + if (qbs.targetOS.contains("windows")) + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + + validator.setRequiredProperty("versionMajor", versionMajor); + validator.setRequiredProperty("versionMinor", versionMinor); + validator.setRequiredProperty("versionPatch", versionPatch); + validator.setRequiredProperty("versionBuild", versionBuild); + validator.addVersionValidator("version", version, 2, 4); + validator.addRangeValidator("versionMajor", versionMajor, 1); + validator.addRangeValidator("versionMinor", versionMinor, 0); + validator.addRangeValidator("versionPatch", versionPatch, 0); + validator.addRangeValidator("versionBuild", versionBuild, 0); + validator.validate(); + } + + setupBuildEnvironment: { + if (product.nsis.toolchainInstallPath) { + var v = new ModUtils.EnvironmentVariable("PATH", ";", true); + v.prepend(product.nsis.toolchainInstallPath); + v.prepend(FileInfo.joinPaths(product.nsis.toolchainInstallPath, "bin")); + v.set(); + } + } + + // NSIS Script File + FileTagger { + patterns: ["*.nsi"] + fileTags: ["nsi"] + } + + // NSIS Header File + FileTagger { + patterns: ["*.nsh"] + fileTags: ["nsh"] + } + + Rule { + id: nsisCompiler + multiplex: true + inputs: ["nsi"] + auxiliaryInputs: ["installable"] + + Artifact { + fileTags: ["nsissetup", "application"] + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + ModUtils.moduleProperty( + product, "executableSuffix")) + } + + prepare: { + var i; + var args = []; + + // Prefix character for makensis options + var opt = product.moduleProperty("qbs", "hostOS").contains("windows") ? "/" : "-"; + + if (ModUtils.moduleProperty(product, "disableConfig")) { + args.push(opt + "NOCONFIG"); + } + + var warningLevel = ModUtils.moduleProperty(product, "warningLevel"); + var warningLevels = ["none", "errors", "warnings", "info", "all"]; + if (warningLevel !== "normal") { + var level = warningLevels.indexOf(warningLevel); + if (level < 0) { + throw("Unexpected warning level '" + warningLevel + "'."); + } else { + args.push(opt + "V" + level); + } + } + + var enableQbsDefines = ModUtils.moduleProperty(product, "enableQbsDefines") + if (enableQbsDefines) { + var map = { + "project.": project, + "product.": product + }; + + for (var prefix in map) { + var obj = map[prefix]; + for (var prop in obj) { + var val = obj[prop]; + if (typeof val !== 'function' && typeof val !== 'object' && !prop.startsWith("_")) { + args.push(opt + "D" + prefix + prop + "=" + val); + } + } + } + + // Users are likely to need this + var arch = product.moduleProperty("qbs", "architecture"); + args.push(opt + "Dqbs.architecture=" + arch); + + // Helper define for alternating between 32-bit and 64-bit logic + if (arch === "x86_64" || arch === "ia64") { + args.push(opt + "DWin64"); + } + } + + // User-supplied defines + var defines = ModUtils.moduleProperty(product, "defines"); + for (i in defines) { + args.push(opt + "D" + defines[i]); + } + + // User-supplied flags + var flags = ModUtils.moduleProperty(product, "compilerFlags"); + for (i in flags) { + args.push(flags[i]); + } + + // Override the compression algorithm if needed + var compressor = ModUtils.moduleProperty(product, "compressor"); + if (compressor !== "default") { + var compressorFlag = opt + "XSetCompressor /FINAL "; + if (compressor.endsWith("-solid")) { + compressorFlag += "/SOLID "; + } + args.push(compressorFlag + compressor.split('-')[0]); + } + + var inputFileNames = []; + for (i in inputs.nsi) { + inputFileNames.push(inputs.nsi[i].fileName); + args.push(FileInfo.toNativeSeparators(inputs.nsi[i].filePath, + product.moduleProperty("qbs", "hostOS"))); + } + + // Output file name - this goes last to override any OutFile command in the script + args.push(opt + "XOutFile " + output.filePath); + + var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), args); + cmd.description = "compiling " + inputFileNames.join(", "); + cmd.highlight = "compiler"; + cmd.workingDirectory = FileInfo.path(output.filePath); + return cmd; + } + } +} diff --git a/share/qbs/modules/pkgconfig/pkgconfig.qbs b/share/qbs/modules/pkgconfig/pkgconfig.qbs new file mode 100644 index 00000000..b436263e --- /dev/null +++ b/share/qbs/modules/pkgconfig/pkgconfig.qbs @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import qbs.File +import qbs.Probes + +Module { + Probes.BinaryProbe { + id: pkgconfigProbe + names: "pkg-config" + } + + property path sysroot: { + if (qbs.targetOS.contains("macos")) + return ""; + return qbs.sysroot; + } + property string executableFilePath: pkgconfigProbe.filePath + property stringList libDirs + property bool staticMode: false + + validate: { + if (!executableFilePath) { + throw "No pkg-config executable found. " + + "Please set modules.pkgconfig.executableFilePath."; + } + if (!File.exists(executableFilePath)) + throw "The pkg-config executable '" + executableFilePath + "' does not exist."; + } +} diff --git a/share/qbs/modules/protobuf/cpp/protobufcpp.qbs b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs new file mode 100644 index 00000000..f377c63c --- /dev/null +++ b/share/qbs/modules/protobuf/cpp/protobufcpp.qbs @@ -0,0 +1,172 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes +import qbs.ModUtils +import "../protobufbase.qbs" as ProtobufBase +import "../protobuf.js" as HelperFunctions + +ProtobufBase { + property string includePath: includeProbe.found ? includeProbe.path : undefined + property string libraryPath: libraryProbe.found ? libraryProbe.path : undefined + + property bool useGrpc: false + + property bool _linkLibraries: true + readonly property bool _hasModules: protobuflib.present && (!useGrpc || grpcpp.present) + + property string grpcIncludePath: grpcIncludeProbe.found ? grpcIncludeProbe.path : undefined + property string grpcLibraryPath: grpcLibraryProbe.found ? grpcLibraryProbe.path : undefined + + readonly property string _libraryName: { + var libraryName; + if (libraryProbe.found) { + libraryName = FileInfo.baseName(libraryProbe.fileName); + if (libraryName.startsWith("lib")) + libraryName = libraryName.substring(3); + } + return libraryName; + } + + Depends { name: "cpp" } + Depends { + name: "protobuflib"; + condition: _linkLibraries; + required: false; + enableFallback: false + } + Depends { + name: "grpcpp"; + condition: _linkLibraries && useGrpc; + required: false; + enableFallback: false + } + + property path grpcPluginPath: grpcPluginProbe.filePath + + Probes.BinaryProbe { + condition: useGrpc + id: grpcPluginProbe + names: "grpc_cpp_plugin" + } + + cpp.libraryPaths: { + if (!_linkLibraries || _hasModules) + return []; + + var result = []; + if (libraryProbe.found) + result.push(libraryProbe.path); + if (useGrpc && grpcLibraryProbe.found) + result.push(grpcLibraryPath); + return result; + } + cpp.dynamicLibraries: { + if (!_linkLibraries || _hasModules) + return []; + + var result = []; + if (_libraryName) + result.push(_libraryName) + if (qbs.targetOS.contains("unix")) + result.push("pthread"); + if (useGrpc) + result.push("grpc++"); + return result; + } + cpp.includePaths: { + if (!_linkLibraries || _hasModules) + return [outputDir]; + + var result = [outputDir]; + if (includeProbe.found) + result.push(includePath); + if (useGrpc && grpcIncludeProbe.found) + result.push(grpcIncludePath); + return result; + } + + Rule { + inputs: ["protobuf.input", "protobuf.grpc"] + outputFileTags: ["hpp", "protobuf.hpp", "cpp"] + outputArtifacts: { + var outputDir = HelperFunctions.getOutputDir(input.protobuf.cpp, input); + var result = [ + HelperFunctions.cppArtifact(outputDir, input, ["hpp", "protobuf.hpp"], + ".pb.h"), + HelperFunctions.cppArtifact(outputDir, input, "cpp", ".pb.cc") + ]; + if (input.fileTags.contains("protobuf.grpc")) { + result.push( + HelperFunctions.cppArtifact(outputDir, input, ["hpp", "protobuf.hpp"], + ".grpc.pb.h"), + HelperFunctions.cppArtifact(outputDir, input, ["cpp"], ".grpc.pb.cc")); + } + + return result; + } + + prepare: { + var result = HelperFunctions.doPrepare( + input.protobuf.cpp, product, input, outputs, "cpp"); + if (input.fileTags.contains("protobuf.grpc")) { + result = ModUtils.concatAll(result, HelperFunctions.doPrepare( + input.protobuf.cpp, product, input, outputs, "grpc", + "protoc-gen-grpc=" + input.protobuf.cpp.grpcPluginPath)); + } + return result; + } + } + + Probes.IncludeProbe { + id: includeProbe + names: "google/protobuf/message.h" + platformSearchPaths: includePath ? [] : base + searchPaths: includePath ? [includePath] : [] + } + + Probes.LibraryProbe { + id: libraryProbe + names: [ + "protobuf", + "protobufd", + ] + platformSearchPaths: libraryPath ? [] : base + searchPaths: libraryPath ? [libraryPath] : [] + } + + Probes.IncludeProbe { + id: grpcIncludeProbe + pathSuffixes: "grpc++" + names: "grpc++.h" + platformSearchPaths: grpcIncludePath ? [] : base + searchPaths: grpcIncludePath ? [grpcIncludePath] : [] + } + + Probes.LibraryProbe { + id: grpcLibraryProbe + names: "grpc++" + platformSearchPaths: grpcLibraryPath ? [] : base + searchPaths: grpcLibraryPath ? [grpcLibraryPath] : [] + } + + validate: { + HelperFunctions.validateCompiler(compilerName, compilerPath); + + if (_hasModules) + return; + + if (_linkLibraries && !includeProbe.found) + throw "Can't find cpp protobuf include files. Please set the includePath property."; + if (_linkLibraries && !libraryProbe.found) + throw "Can't find cpp protobuf library. Please set the libraryPath property."; + + if (useGrpc) { + if (!File.exists(grpcPluginPath)) + throw "Can't find grpc_cpp_plugin plugin. Please set the grpcPluginPath property."; + if (_linkLibraries && !grpcIncludeProbe.found) + throw "Can't find grpc++ include files. Please set the grpcIncludePath property."; + if (_linkLibraries && !grpcLibraryProbe.found) + throw "Can't find grpc++ library. Please set the grpcLibraryPath property."; + } + } +} diff --git a/share/qbs/modules/protobuf/nanopb/nanopb.qbs b/share/qbs/modules/protobuf/nanopb/nanopb.qbs new file mode 100644 index 00000000..898e230b --- /dev/null +++ b/share/qbs/modules/protobuf/nanopb/nanopb.qbs @@ -0,0 +1,103 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes +import qbs.ModUtils +import "../protobufbase.qbs" as ProtobufBase +import "../protobuf.js" as HelperFunctions + +ProtobufBase { + property string includePath: includeProbe.found ? includeProbe.path : undefined + property string libraryPath: libraryProbe.found ? libraryProbe.path : undefined + property string pluginPath: pluginProbe.filePath + property string pluginName: "protoc-gen-nanopb" + readonly property string _plugin: "protoc-gen-nanopb=" + pluginPath + readonly property string _libraryName: { + var libraryName; + if (libraryProbe.found) { + libraryName = FileInfo.baseName(libraryProbe.fileName); + if (libraryName.startsWith("lib")) + libraryName = libraryName.substring(3); + } + return libraryName; + } + + Depends { name: "cpp" } + + cpp.libraryPaths: { + var result = []; + if (libraryProbe.found) + result.push(libraryProbe.path); + return result; + } + cpp.dynamicLibraries: { + var result = []; + if (_libraryName) + result.push(_libraryName); + return result; + } + cpp.includePaths: { + var result = [outputDir]; + if (includeProbe.found) + result.push(includePath); + return result; + } + + Rule { + inputs: ["protobuf.input"] + outputFileTags: ["hpp", "protobuf.hpp", "cpp"] + outputArtifacts: { + var outputDir = HelperFunctions.getOutputDir(input.protobuf.nanopb, input); + var result = [ + HelperFunctions.cppArtifact(outputDir, input, ["hpp", "protobuf.hpp"], + ".pb.h"), + HelperFunctions.cppArtifact(outputDir, input, ["cpp"], ".pb.c") + ]; + + return result; + } + + prepare: { + var options = input.protobuf.nanopb.importPaths.map(function (path) { + return "-I" + path; + }) + + var result = HelperFunctions.doPrepare( + input.protobuf.nanopb, product, input, outputs, "nanopb", + input.protobuf.nanopb._plugin, options); + return result; + } + } + + Probes.IncludeProbe { + id: includeProbe + names: ["pb.h", "pb_encode.h", "pb_decode.h", "pb_common.h"] + platformSearchPaths: includePath ? [] : base + searchPaths: includePath ? [includePath] : [] + } + + Probes.LibraryProbe { + id: libraryProbe + names: [ + "protobuf-nanopb", + "protobuf-nanopbd", + ] + platformSearchPaths: libraryPath ? [] : base + searchPaths: libraryPath ? [libraryPath] : [] + } + + Probes.BinaryProbe { + id: pluginProbe + names: pluginName + } + + validate: { + HelperFunctions.validateCompiler(compilerName, compilerPath); + + if (!includeProbe.found) + throw "Can't find nanopb protobuf include files. Please set the includePath property."; + if (!libraryProbe.found) + throw "Can't find nanopb protobuf library. Please set the libraryPath property."; + if (!HelperFunctions.checkPath(pluginPath)) + throw "Can't find nanopb protobuf plugin. Please set the pluginPath property."; + } +} diff --git a/share/qbs/modules/protobuf/objc/protobufobjc.qbs b/share/qbs/modules/protobuf/objc/protobufobjc.qbs new file mode 100644 index 00000000..a3e70889 --- /dev/null +++ b/share/qbs/modules/protobuf/objc/protobufobjc.qbs @@ -0,0 +1,64 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes +import "../protobufbase.qbs" as ProtobufBase +import "../protobuf.js" as HelperFunctions + +ProtobufBase { + property string includePath: includeProbe.path + property string libraryPath: libraryProbe.path + property string frameworkPath: frameworkProbe.path + + Depends { name: "cpp" } + + cpp.includePaths: [outputDir].concat(!frameworkPath && includePath ? [includePath] : []) + cpp.libraryPaths: !frameworkPath && libraryPath ? [libraryPath] : [] + cpp.dynamicLibraries: !frameworkPath && libraryPath ? ["ProtocolBuffers"] : [] + cpp.frameworkPaths: frameworkPath ? [frameworkPath] : [] + cpp.frameworks: ["Foundation"].concat(frameworkPath ? ["Protobuf"] : []) + cpp.defines: frameworkPath ? ["GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS"] : [] + + Rule { + inputs: ["protobuf.input"] + outputFileTags: ["hpp", "protobuf.hpp", "objc"] + outputArtifacts: { + var outputDir = HelperFunctions.getOutputDir(input.protobuf.objc, input); + return [ + HelperFunctions.objcArtifact(outputDir, input, ["hpp", "protobuf.hpp"], + ".pbobjc.h"), + HelperFunctions.objcArtifact(outputDir, input, ["objc"], ".pbobjc.m") + ]; + } + + prepare: HelperFunctions.doPrepare(input.protobuf.objc, product, input, outputs, "objc") + } + + Probes.IncludeProbe { + id: includeProbe + names: "GPBMessage.h" + } + + Probes.LibraryProbe { + id: libraryProbe + names: "ProtocolBuffers" + } + + Probes.FrameworkProbe { + id: frameworkProbe + names: ["Protobuf"] + } + + validate: { + HelperFunctions.validateCompiler(compilerName, compilerPath); + if (!HelperFunctions.checkPath(frameworkPath)) { + if (!HelperFunctions.checkPath(includePath)) { + throw "Can't find objective-c protobuf include files. Please set the includePath " + + "or frameworkPath property."; + } + if (!HelperFunctions.checkPath(libraryPath)) { + throw "Can't find objective-c protobuf library. Please set the libraryPath or " + + "frameworkPath property."; + } + } + } +} diff --git a/share/qbs/modules/protobuf/protobuf.js b/share/qbs/modules/protobuf/protobuf.js new file mode 100644 index 00000000..60d6f48e --- /dev/null +++ b/share/qbs/modules/protobuf/protobuf.js @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); + +function validateCompiler(compilerName, compilerPath) { + if (!File.exists(compilerPath)) { + throw "Can't find '" + compilerName + "' binary. Please set the compilerPath property or " + + "make sure the compiler is found in PATH"; + } +} + +function checkPath(path) { + return path && File.exists(path); +}; + +function toCamelCase(str){ + return str.split('_').map(function(word, index) { + // If it is the first word make sure to lowercase all the chars. + if (index === 0) { + return word.toLowerCase(); + } + // If it is not the first word only upper case the first char and lowercase the rest. + return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); + }).join(''); +} + +function getOutputDir(module, input) { + var outputDir = module.outputDir; + var importPaths = module.importPaths; + if (importPaths.length !== 0) { + var canonicalInput = File.canonicalFilePath(FileInfo.path(input.filePath)); + for (var i = 0; i < importPaths.length; ++i) { + var path = File.canonicalFilePath(importPaths[i]); + + if (canonicalInput.startsWith(path)) { + return outputDir + "/" + FileInfo.relativePath(path, canonicalInput); + } + } + } + return outputDir; +} + +function cppArtifact(outputDir, input, tags, suffix) { + return { + fileTags: tags, + filePath: FileInfo.joinPaths(outputDir, FileInfo.baseName(input.fileName) + suffix), + cpp: { + includePaths: [].concat(input.cpp.includePaths, outputDir), + defines: ["NDEBUG"], + warningLevel: "none", + } + }; +} + +function objcArtifact(outputDir, input, tags, suffix) { + return { + fileTags: tags, + filePath: FileInfo.joinPaths( + outputDir, toCamelCase(FileInfo.baseName(input.fileName)) + suffix), + cpp: { + automaticReferenceCounting: false, + includePaths: [].concat(input.cpp.includePaths, outputDir), + warningLevel: "none", + } + } +} + +function doPrepare(module, product, input, outputs, generator, plugin, generatorOptions) +{ + var outputDir = module.outputDir; + var args = []; + + if (!!plugin) + args.push("--plugin=" + plugin) + + args.push("--" + generator + "_out", outputDir); + if (!!generatorOptions) { + for (var i = 0; i < generatorOptions.length; ++i) + args.push("--" + generator + "_opt=" + generatorOptions[i]) + } + + var importPaths = module.importPaths; + if (importPaths.length === 0) + importPaths = [FileInfo.path(input.filePath)]; + importPaths.forEach(function(path) { + if (!FileInfo.isAbsolutePath(path)) + path = FileInfo.joinPaths(product.sourceDirectory, path); + args.push("--proto_path", path); + }); + + args.push(input.filePath); + + var cmd = new Command(module.compilerPath, args); + cmd.highlight = "codegen"; + cmd.description = "generating " + generator + " files for " + input.fileName; + return [cmd]; +} diff --git a/share/qbs/modules/protobuf/protobufbase.qbs b/share/qbs/modules/protobuf/protobufbase.qbs new file mode 100644 index 00000000..e302d375 --- /dev/null +++ b/share/qbs/modules/protobuf/protobufbase.qbs @@ -0,0 +1,23 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes +import "protobuf.js" as HelperFunctions + +Module { + property string compilerName: "protoc" + property string compilerPath: compilerProbe.filePath + + property pathList importPaths: [] + + readonly property string outputDir: product.buildDirectory + "/protobuf" + + FileTagger { + patterns: ["*.proto"] + fileTags: ["protobuf.input"] + } + + Probes.BinaryProbe { + id: compilerProbe + names: [compilerName] + } +} diff --git a/share/qbs/modules/qbs/common.qbs b/share/qbs/modules/qbs/common.qbs new file mode 100644 index 00000000..8ddfc582 --- /dev/null +++ b/share/qbs/modules/qbs/common.qbs @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.FileInfo +import qbs.ModUtils +import qbs.PathTools +import qbs.Utilities + +Module { + readonly property string configurationName: "default" + property string defaultBuildVariant: { + switch (configurationName.toLowerCase()) { + case "release": + return "release"; + default: + return "debug"; + } + } + + property string buildVariant: defaultBuildVariant + + property bool enableDebugCode: buildVariant == "debug" + property bool debugInformation: (buildVariant !== "release") + property string optimization: (buildVariant === "debug" ? "none" : "fast") + readonly property string hostPlatform: undefined // set internally + readonly property stringList hostOS: Utilities.canonicalPlatform(hostPlatform) + property string hostOSVersion: { + if (hostOS && hostOS.contains("macos")) { + return Utilities.getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductVersion") || + Utilities.getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductVersion"); + } else if (hostOS && hostOS.contains("windows")) { + var version = Utilities.getNativeSetting(windowsRegistryKey, "CurrentVersion"); + return version + "." + hostOSBuildVersion; + } + } + readonly property string hostArchitecture: undefined // set internally + + property string hostOSBuildVersion: { + if (hostOS.contains("macos")) { + return Utilities.getNativeSetting("/System/Library/CoreServices/ServerVersion.plist", "ProductBuildVersion") || + Utilities.getNativeSetting("/System/Library/CoreServices/SystemVersion.plist", "ProductBuildVersion"); + } else if (hostOS.contains("windows")) { + return Utilities.getNativeSetting(windowsRegistryKey, "CurrentBuildNumber"); + } + } + + readonly property var hostOSVersionParts: hostOSVersion ? hostOSVersion.split('.').map(function(item) { return parseInt(item, 10); }) : [] + readonly property int hostOSVersionMajor: hostOSVersionParts[0] || 0 + readonly property int hostOSVersionMinor: hostOSVersionParts[1] || 0 + readonly property int hostOSVersionPatch: hostOSVersionParts[2] || 0 + + property string targetPlatform: hostPlatform + readonly property stringList targetOS: Utilities.canonicalPlatform(targetPlatform) + property string pathListSeparator: hostOS.contains("windows") ? ";" : ":" + property string pathSeparator: hostOS.contains("windows") ? "\\" : "/" + property string nullDevice: hostOS.contains("windows") ? "NUL" : "/dev/null" + property path shellPath: hostOS.contains("windows") ? windowsShellPath : "/bin/sh" + property string profile: project.profile + property string toolchainType: { + if (targetOS.contains("windows")) + return hostOS.contains("windows") ? "msvc" : "mingw"; + if (targetOS.contains("darwin")) + return hostOS.contains("macos") ? "xcode" : "clang"; + if (targetOS.contains("freebsd")) + return "clang"; + if (targetOS.contains("qnx")) + return "qcc"; + if (targetOS.containsAny(["haiku", "vxworks", "unix"])) + return "gcc"; + } + readonly property stringList toolchain: Utilities.canonicalToolchain(toolchainType) + property string architecture + property bool install: false + property path installSourceBase + property string installRoot: project.buildDirectory + "/install-root" + property string installDir + property string installPrefix: qbs.targetOS.contains("unix") ? "/usr/local" : "" + property path sysroot + + PropertyOptions { + name: "buildVariant" + allowedValues: ['debug', 'release', 'profiling'] + description: "name of the build variant" + } + + PropertyOptions { + name: "optimization" + allowedValues: ['none', 'fast', 'small'] + description: "optimization level" + } + + validate: { + var validator = new ModUtils.PropertyValidator("qbs"); + validator.setRequiredProperty("hostOS", hostOS); + validator.setRequiredProperty("targetOS", targetOS); + validator.addCustomValidator("targetOS", targetOS, function (value) { + if (!value || (value.contains("osx") && !value.contains("macos"))) + return false; + return true; + }, "the value 'osx' has been replaced by 'macos'; use that instead and update " + + "hostOS and targetOS condition checks in your project accordingly"); + if (hostOS && (hostOS.contains("windows") || hostOS.contains("macos"))) { + validator.setRequiredProperty("hostOSVersion", hostOSVersion, + "could not detect host operating system version; " + + "verify that system files and registry keys have not " + + "been modified."); + if (hostOSVersion) + validator.addVersionValidator("hostOSVersion", hostOSVersion, 2, 4); + + validator.setRequiredProperty("hostOSBuildVersion", hostOSBuildVersion, + "could not detect host operating system build version; " + + "verify that system files or registry have not been " + + "tampered with."); + } + + validator.addCustomValidator("architecture", architecture, function (value) { + return !architecture || architecture === Utilities.canonicalArchitecture(architecture); + }, "'" + architecture + "' is invalid. You must use the canonical name '" + + Utilities.canonicalArchitecture(architecture) + "'"); + + validator.addCustomValidator("toolchain", toolchain, function (value) { + if (toolchain === undefined) + return false; // cannot have null toolchain, empty is valid... for now + var canonical = Utilities.canonicalToolchain.apply(Utilities, toolchain); + for (var i = 0; i < Math.max(canonical.length, toolchain.length); ++i) { + if (canonical[i] !== toolchain[i]) + return false; + } + return true; + }, "'" + toolchain + "' is invalid. You must use the canonical list '" + + Utilities.canonicalToolchain.apply(Utilities, toolchain) + "'"); + + validator.addCustomValidator("toolchain", toolchain, function (value) { + // None of the pairs listed here may appear in the same toolchain list. + // Note that this check is applied AFTER canonicalization, so for example + // {"clang", "msvc"} need not be checked, since a toolchain containing clang is + // guaranteed to also contain gcc. + var pairs = [ + ["gcc", "msvc"], + ["llvm", "mingw"] + ]; + var canonical = Utilities.canonicalToolchain.apply(Utilities, value); + for (var i = 0; i < pairs.length; ++i) { + if (canonical.contains(pairs[i][0]) && canonical.contains(pairs[i][1])) + return false; + } + return true; + }, "'" + toolchain + "' contains one or more mutually exclusive toolchain types."); + + validator.validate(); + } + + // private properties + property string windowsRegistryKey: "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion" + property path windowsSystemRoot: FileInfo.fromWindowsSeparators(Utilities.getNativeSetting(windowsRegistryKey, "SystemRoot")) + property path windowsShellPath: FileInfo.fromWindowsSeparators(Environment.getEnv("COMSPEC")) || FileInfo.joinPaths(windowsSystemRoot, "System32", "cmd.exe") + property string windowsPathVariable: hostOS.contains("windows") ? "PATH" : "WINEPATH" + + property var commonRunEnvironment: ({}) + setupRunEnvironment: { + var env = product.qbs.commonRunEnvironment; + for (var i in env) { + var v = new ModUtils.EnvironmentVariable(i, product.qbs.pathListSeparator, + product.qbs.hostOS.contains("windows")); + v.value = env[i]; + v.set(); + } + } + + // Properties that can be set for multiplexing products. + property stringList profiles: [] + property stringList architectures: [] + property stringList buildVariants: [] + + // internal properties + readonly property string version: [versionMajor, versionMinor, versionPatch].join(".") + readonly property int versionMajor: undefined // set internally + readonly property int versionMinor: undefined // set internally + readonly property int versionPatch: undefined // set internally + readonly property var multiplexMap: ({ + profiles: "profile", + architectures: "architecture", + buildVariants: "buildVariant" + }) +} diff --git a/share/qbs/modules/qnx/qnx.qbs b/share/qbs/modules/qnx/qnx.qbs new file mode 100644 index 00000000..f329db18 --- /dev/null +++ b/share/qbs/modules/qnx/qnx.qbs @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import qbs.Utilities + +Module { + Probes.PathProbe { + id: qnxSdkProbe + names: ["qnx700", "qnx660", "qnx650"] + searchPaths: Host.os().contains("windows") + ? [Environment.getEnv("USERPROFILE"), Environment.getEnv("SystemDrive")] + : [Environment.getEnv("HOME"), "/opt"] + } + + Probe { + id: qnxTargetOsProbe + property string qnxSdkDir: sdkDir + property stringList targets: [] + configure: { + if (qnxSdkDir) { + var validEntries = []; + var entries = File.directoryEntries( + FileInfo.joinPaths(qnxSdkDir, "target"), + File.Dirs | File.NoDotAndDotDot); + for (var i = 0; i < entries.length; ++i) { + if (/^qnx[0-9]$/.test(entries[i])) + validEntries.push(entries[i]); + } + validEntries.sort(); + validEntries.reverse(); + targets = validEntries; + found = targets.length > 0; + } else { + found = false; + } + } + } + + version: qnxSdkProbe.found ? qnxSdkProbe.fileName.substr(3, 3).split("").join(".") : undefined + + readonly property bool qnx7: version ? Utilities.versionCompare(version, "7") >= 0 : false + + property string sdkDir: qnxSdkProbe.filePath + + property string hostArch: qnx7 ? "x86_64" : "x86" + + property string hostOs: { + if (Host.os().contains("linux")) + return "linux"; + if (Host.os().contains("macos")) + return "darwin"; + if (Host.os().contains("windows")) + return qnx7 ? "win64" : "win32"; + } + + property string targetOs: qnxTargetOsProbe.targets[0] + + property string compilerName: "gcc" + + property string configurationDir: FileInfo.joinPaths(Environment.getEnv("HOME"), ".qnx") + property string hostDir: FileInfo.joinPaths(sdkDir, "host", hostOs, hostArch) + property string targetDir: FileInfo.joinPaths(sdkDir, "target", targetOs) + + property var buildEnv: ({ + "QNX_HOST": hostDir, + "QNX_TARGET": targetDir, + "QNX_CONFIGURATION": configurationDir + }) + + qbs.sysroot: targetDir + + validate: { + if (!sdkDir) { + throw ModUtils.ModuleError("Could not find a QNX SDK in any of the following " + + "locations:\n\t" + qnxSdkProbe.candidatePaths.join("\n\t") + + "\nInstall the QNX SDK to one of the above locations, " + + "or set the qnx.sdkDir property to a valid QNX SDK " + + "location."); + } + + if (!hostOs) { + throw ModUtils.ModuleError("Host operating system '" + Host.os() + + "' is not supported by the QNX SDK."); + } else if (!File.exists(hostDir)) { + throw ModUtils.ModuleError("Detected host tools operating system '" + hostOs + + "' and architecture '" + hostArch + "' directory is not " + + "present in the QNX SDK installed at '" + sdkDir + + "' in the expected location '" + hostDir + + "'; did you forget to install it?"); + } + + if (!targetOs) + throw ModUtils.ModuleError("Could not find any QNX targets in '" + targetDir + "'"); + } +} diff --git a/share/qbs/modules/texttemplate/texttemplate.qbs b/share/qbs/modules/texttemplate/texttemplate.qbs new file mode 100644 index 00000000..c7292966 --- /dev/null +++ b/share/qbs/modules/texttemplate/texttemplate.qbs @@ -0,0 +1,64 @@ +import qbs.TextFile + +Module { + property var dict: ({}) + property string outputTag: "text" + property string outputFileName + FileTagger { + patterns: ["*.in"] + fileTags: ["texttemplate.input"] + } + Rule { + inputs: ["texttemplate.input"] + outputFileTags: [product.texttemplate.outputTag] + outputArtifacts: [ + { + fileTags: [product.texttemplate.outputTag], + filePath: input.texttemplate.outputFileName || input.completeBaseName + } + ] + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.sourceCode = function() { + try { + var src = new TextFile(input.filePath, TextFile.ReadOnly); + var dst = new TextFile(output.filePath, TextFile.WriteOnly); + var rex = /\${(\$|\w+)}/g; + var match; + while (!src.atEof()) { + rex.lastIndex = 0; + var line = src.readLine(); + var matches = []; + while (match = rex.exec(line)) + matches.push(match); + for (var i = matches.length; --i >= 0;) { + match = matches[i]; + var replacement; + if (match[1] === "$") { + replacement = "$"; + } else { + replacement = input.texttemplate.dict[match[1]]; + if (typeof replacement === "undefined") { + throw new Error("Placeholder '" + match[1] + + "' is not defined in textemplate.dict for '" + + input.fileName + "'."); + } + } + line = line.substr(0, match.index) + + replacement + + line.substr(match.index + match[0].length); + } + dst.writeLine(line); + } + } finally { + if (src) + src.close(); + if (dst) + dst.close(); + } + }; + return [cmd]; + } + } +} diff --git a/share/qbs/modules/typescript/TypeScriptModule.qbs b/share/qbs/modules/typescript/TypeScriptModule.qbs new file mode 100644 index 00000000..c8ca270e --- /dev/null +++ b/share/qbs/modules/typescript/TypeScriptModule.qbs @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import qbs.Process +import "typescript.js" as TypeScript + +Module { + // Qbs does NOT support standalone TypeScript installations + // (for example, %PROGRAMFILES%\Microsoft SDKs\TypeScript and some Debian and RPM packages), + // because they do not include typescript.d.ts, which is necessary for building internal tools. + // Only npm-based installations of TypeScript are supported (this is also the most common). + Depends { name: "nodejs" } + + additionalProductTypes: ["compiled_typescript"] + + Probes.TypeScriptProbe { + id: tsc + interpreterPath: FileInfo.path(nodejs.interpreterFilePath) + packageManagerBinPath: nodejs.packageManagerBinPath + packageManagerRootPath: nodejs.packageManagerRootPath + } + + property path toolchainInstallPath: tsc.path + + property path toolchainLibDirName: (versionMajor > 1 || (versionMajor === 1 && versionMinor >= 6)) ? "lib" : "bin" + property path toolchainLibInstallPath: FileInfo.joinPaths(nodejs.packageManagerRootPath, "typescript", toolchainLibDirName) + + version: tsc.version ? tsc.version[2] : undefined + property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : [] + property int versionMajor: versionParts[0] + property int versionMinor: versionParts[1] + property int versionPatch: versionParts[2] + property int versionBuild: versionParts[3] + property string versionSuffix: tsc.version ? tsc.version[3] : undefined + + property string compilerName: tsc.fileName + property string compilerPath: tsc.filePath + + property string warningLevel: "normal" + PropertyOptions { + name: "warningLevel" + description: "pedantic to warn on expressions and declarations with an implied 'any' type" + allowedValues: ["normal", "pedantic"] + } + + property string targetVersion + PropertyOptions { + name: "targetVersion" + description: "ECMAScript target version" + allowedValues: ["ES3", "ES5", "ES2015"] + } + + property string moduleLoader + PropertyOptions { + name: "moduleLoader" + allowedValues: ["commonjs", "amd"] + } + + property bool stripComments: !qbs.debugInformation + PropertyOptions { + name: "stripComments" + description: "whether to remove comments from the generated output" + } + + property bool generateDeclarations: false + PropertyOptions { + name: "generateDeclarations" + description: "whether to generate corresponding .d.ts files during compilation" + } + + // In release mode, nodejs can/should default-enable minification and obfuscation, + // making the source maps useless, so these default settings work out fine + property bool generateSourceMaps: qbs.debugInformation + PropertyOptions { + name: "generateSourceMaps" + description: "whether to generate corresponding .map files during compilation" + } + + property stringList compilerFlags + PropertyOptions { + name: "compilerFlags" + description: "additional flags for the TypeScript compiler" + } + + property bool singleFile: false + PropertyOptions { + name: "singleFile" + description: "whether to compile all source files to a single output file" + } + + validate: { + var interpreterMessage = "TypeScript requires the Node.js interpreter to be called 'node'."; + if (File.exists("/etc/debian_version")) { + interpreterMessage += " Did you forget to install the nodejs-legacy package? " + + "See https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html " + + "for more information."; + } + + var preValidator = new ModUtils.PropertyValidator("nodejs"); + preValidator.addCustomValidator("interpreterFileName", nodejs.interpreterFileName, function (value) { + return value === "node" + (Host.os().contains("windows") ? ".exe" : ""); + }, interpreterMessage); + preValidator.addCustomValidator("interpreterFilePath", nodejs.interpreterFilePath, function (value) { + return value.endsWith(nodejs.interpreterFileName); + }, interpreterMessage); + preValidator.validate(); + + var validator = new ModUtils.PropertyValidator("typescript"); + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + validator.setRequiredProperty("compilerName", compilerName); + validator.setRequiredProperty("compilerPath", compilerPath); + validator.setRequiredProperty("version", version); + validator.setRequiredProperty("versionParts", versionParts); + validator.setRequiredProperty("versionMajor", versionMajor); + validator.setRequiredProperty("versionMinor", versionMinor); + validator.setRequiredProperty("versionPatch", versionPatch); + validator.addVersionValidator("version", version, 3, 4); + validator.addRangeValidator("versionMajor", versionMajor, 1); + validator.addRangeValidator("versionMinor", versionMinor, 0); + validator.addRangeValidator("versionPatch", versionPatch, 0); + + if (versionParts && versionParts.length >= 4) { + validator.setRequiredProperty("versionBuild", versionBuild); + validator.addRangeValidator("versionBuild", versionBuild, 0); + } + + validator.validate(); + } + + // TypeScript declaration files + FileTagger { + patterns: ["*.d.ts"] + fileTags: ["typescript_declaration"] + } + + // TypeScript source files + FileTagger { + patterns: ["*.ts"] + fileTags: ["typescript"] + } + + Group { + name: "io.qt.qbs.internal.typescript-helper" + files: [ + FileInfo.joinPaths(path, "qbs-tsc-scan", "qbs-tsc-scan.ts"), + FileInfo.joinPaths(typescript.toolchainLibInstallPath, "typescript.d.ts"), + FileInfo.joinPaths(typescript.toolchainLibInstallPath, "..", "package.json") + ] + fileTags: ["typescript.typescript-internal"] + } + + Rule { + multiplex: true + inputs: ["typescript.typescript-internal"] + + outputFileTags: ["typescript.compiled_typescript-internal"] + outputArtifacts: { + if (!TypeScript.supportsModernFeatures(product)) + return []; + return [{ + filePath: FileInfo.joinPaths(product.buildDirectory, + ".io.qt.qbs.internal.typescript", "qbs-tsc-scan.ts"), + fileTags: ["typescript.typescript-internal.copy"] + }, + { + filePath: FileInfo.joinPaths(product.buildDirectory, + ".io.qt.qbs.internal.typescript", + "node_modules", "typescript", "lib", "typescript.d.ts"), + fileTags: ["typescript.typescript-internal.copy"] + }, + { + filePath: FileInfo.joinPaths(product.buildDirectory, + ".io.qt.qbs.internal.typescript", + "node_modules", "typescript", "package.json"), + fileTags: ["typescript.typescript-internal.copy"] + }, + { + filePath: FileInfo.joinPaths(product.buildDirectory, + ".io.qt.qbs.internal.typescript", "qbs-tsc-scan.js"), + fileTags: ["typescript.compiled_typescript-internal"] + }]; + } + + prepare: { + var inputPaths = inputs["typescript.typescript-internal"].map(function (input) { + return input.filePath; + }); + + var outputPaths = outputs["typescript.typescript-internal.copy"].map(function (output) { + return output.filePath; + }); + + var sortFunc = function (a, b) { + return FileInfo.fileName(a).localeCompare(FileInfo.fileName(b)); + }; + + var jcmd = new JavaScriptCommand(); + jcmd.ignoreDryRun = true; + jcmd.silent = true; + jcmd.inputPaths = inputPaths.sort(sortFunc); + jcmd.outputPaths = outputPaths.sort(sortFunc); + jcmd.sourceCode = function() { + for (var i = 0; i < inputPaths.length; ++i) + File.copy(inputPaths[i], outputPaths[i]); + }; + + var outDir = FileInfo.path( + outputs["typescript.compiled_typescript-internal"][0].filePath); + var args = ["--module", "commonjs", + "--outDir", outDir].concat(outputPaths.filter(function (f) { return !f.endsWith(".json"); })); + var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), args); + cmd.ignoreDryRun = true; + cmd.silent = true; + return [jcmd, cmd]; + } + } + + Rule { + id: typescriptCompiler + multiplex: true + inputs: ["typescript"] + inputsFromDependencies: ["typescript_declaration"] + explicitlyDependsOn: ["typescript.compiled_typescript-internal"] + + outputArtifacts: TypeScript.outputArtifacts(product, inputs) + + outputFileTags: ["application_js", "compiled_typescript", "js", "source_map", "typescript_declaration"] + + prepare: { + var cmd, cmds = []; + + cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), + TypeScript.tscArguments(product, inputs)); + cmd.description = "compiling " + (ModUtils.moduleProperty(product, "singleFile") + ? outputs.compiled_typescript[0].fileName + : inputs.typescript.map(function(obj) { + return obj.fileName; }).join(", ")); + cmd.highlight = "compiler"; + cmds.push(cmd); + + // QBS-5 + // Move the compiled JavaScript files compiled by TypeScript to an intermediate + // directory so that the nodejs module can perform any necessary postprocessing + // on the result. The nodejs module will move the files back to their original + // locations after postprocessing. + cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.outDir = product.buildDirectory; + cmd.sourceCode = function() { + for (var i = 0; i < outputs.compiled_typescript.length; ++i) { + var output = outputs.compiled_typescript[i]; + var intermediatePath = FileInfo.path(FileInfo.relativePath(product.moduleProperty("nodejs", "compiledIntermediateDir"), output.filePath)); + var originalFilePath = FileInfo.joinPaths(outDir, intermediatePath, output.fileName); + File.copy(originalFilePath, output.filePath); + File.remove(originalFilePath); + } + }; + cmds.push(cmd); + + return cmds; + } + } +} diff --git a/share/qbs/modules/typescript/qbs-tsc-scan/.gitignore b/share/qbs/modules/typescript/qbs-tsc-scan/.gitignore new file mode 100644 index 00000000..2ac7185a --- /dev/null +++ b/share/qbs/modules/typescript/qbs-tsc-scan/.gitignore @@ -0,0 +1,5 @@ +# Visual Studio Code IDE +tsconfig.json +qbs-tsc-scan.js +typings/node/node.d.ts +typings/typescript/typescript.d.ts diff --git a/share/qbs/modules/typescript/qbs-tsc-scan/qbs-tsc-scan.ts b/share/qbs/modules/typescript/qbs-tsc-scan/qbs-tsc-scan.ts new file mode 100644 index 00000000..ca5eb420 --- /dev/null +++ b/share/qbs/modules/typescript/qbs-tsc-scan/qbs-tsc-scan.ts @@ -0,0 +1,68 @@ +import ts = require("typescript"); + +declare var process: any; + +export namespace io.qt.qbs { + export class Artifact { + filePath: string; + fileTags: string[]; + } + + export namespace tools { + export namespace utils { + function stringEndsWith(s: string, e: string) { + return s.slice(-e.length) === e; + } + + export function artifactFromFilePath(filePath: string): Artifact { + var fileTags: string[] = []; + if (stringEndsWith(filePath, ".js.map")) { + fileTags.push("source_map"); + } else if (stringEndsWith(filePath, ".js")) { + fileTags.push("js", "compiled_typescript"); + } else if (stringEndsWith(filePath, ".d.ts")) { + fileTags.push("typescript_declaration"); + } + + return { filePath: filePath, fileTags: fileTags }; + } + } + + function compileInternal(fileNames: string[], options: ts.CompilerOptions): qbs.Artifact[] { + var outputArtifacts: qbs.Artifact[] = []; + var program = ts.createProgram(fileNames, options); + var emitResult = program.emit(undefined, filePath => { + outputArtifacts.push(utils.artifactFromFilePath(filePath)); + }); + + var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + allDiagnostics.forEach(diagnostic => { + var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + if (diagnostic.file) { + var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + console.error(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); + } else { + console.error(message); + } + }); + + return emitResult.emitSkipped ? undefined : outputArtifacts; + } + + export function compile(commandLineArguments: string[]): qbs.Artifact[] { + var parsedCommandLine = ts.parseCommandLine(commandLineArguments); + return compileInternal(parsedCommandLine.fileNames, parsedCommandLine.options); + } + + export function TypeScriptCompilerScannerToolMain(): void { + var outputArtifacts = compile(process.argv.slice(2)); + if (outputArtifacts !== undefined) { + console.log(JSON.stringify(outputArtifacts)); + } else { + process.exit(1); + } + } + } +} + +io.qt.qbs.tools.TypeScriptCompilerScannerToolMain(); diff --git a/share/qbs/modules/typescript/typescript.js b/share/qbs/modules/typescript/typescript.js new file mode 100644 index 00000000..7b2cf98d --- /dev/null +++ b/share/qbs/modules/typescript/typescript.js @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var FileInfo = require("qbs.FileInfo"); +var ModUtils = require("qbs.ModUtils"); +var Process = require("qbs.Process"); + +function findTscVersion(compilerFilePath, nodejsPath) { + var p = new Process(); + try { + if (nodejsPath) + p.setEnv("PATH", nodejsPath); + p.exec(compilerFilePath, ["--version"]); + var re = /^(?:message TS6029: )?Version (([0-9]+(?:\.[0-9]+){1,3})(?:-(.+?))?)$/m; + var match = p.readStdOut().trim().match(re); + if (match !== null) + return match; + } finally { + p.close(); + } +} + +function tscArguments(product, inputs) { + var i; + var args = []; + + if (ModUtils.moduleProperty(product, "warningLevel") === "pedantic") { + args.push("--noImplicitAny"); + } + + var targetVersion = ModUtils.moduleProperty(product, "targetVersion"); + if (targetVersion) { + args.push("--target"); + args.push(targetVersion); + } + + var moduleLoader = ModUtils.moduleProperty(product, "moduleLoader"); + if (moduleLoader) { + args.push("--module"); + args.push(moduleLoader); + } + + if (ModUtils.moduleProperty(product, "stripComments")) { + args.push("--removeComments"); + } + + if (ModUtils.moduleProperty(product, "generateDeclarations")) { + args.push("--declaration"); + } + + if (ModUtils.moduleProperty(product, "generateSourceMaps")) { + args.push("--sourcemap"); + } + + // User-supplied flags + var flags = ModUtils.moduleProperty(product, "compilerFlags"); + for (i in flags) { + args.push(flags[i]); + } + + if (supportsModernFeatures(product)) { + args.push("--rootDir", product.sourceDirectory); + } + + args.push("--outDir", product.buildDirectory); + + if (ModUtils.moduleProperty(product, "singleFile")) { + args.push(outOption(product), + FileInfo.joinPaths(product.destinationDirectory, product.targetName) + ".js"); + } + + if (inputs.typescript_declaration) { + for (i = 0; i < inputs.typescript_declaration.length; ++i) { + args.push(inputs.typescript_declaration[i].filePath); + } + } + + if (inputs.typescript) { + for (i = 0; i < inputs.typescript.length; ++i) { + args.push(inputs.typescript[i].filePath); + } + } + + if (inputs["typescript.typescript-internal"]) { + for (i = 0; i < inputs["typescript.typescript-internal"].length; ++i) { + args.push(inputs["typescript.typescript-internal"][i].filePath); + } + } + + return args; +} + +function outputArtifacts(product, inputs) { + if (!supportsModernFeatures(product)) { + console.warn("Qbs does not properly support TypeScript versions prior to 1.5 due to " + + "severe limitations in dependency tracking. This is TypeScript version " + + ModUtils.moduleProperty(product, "version") + ". It is strongly recommended " + + "that you upgrade TypeScript, or continue at your own risk."); + return legacyOutputArtifacts(product, inputs); + } + + var process; + try { + process = new Process(); + process.setEnv("NODE_PATH", [ + ModUtils.moduleProperty(product, "toolchainInstallPath"), + product.moduleProperty("nodejs", "packageManagerRootPath") + ].join(FileInfo.pathListSeparator())); + process.exec(product.moduleProperty("nodejs", "interpreterFilePath"), + [FileInfo.joinPaths(product.buildDirectory, + ".io.qt.qbs.internal.typescript", + "qbs-tsc-scan.js")] + .concat(tscArguments(product, inputs)), true); + var artifacts = JSON.parse(process.readStdOut()); + + // Find and tag the "main" output file + var applicationFile = product.moduleProperty("nodejs", "applicationFile"); + if (applicationFile) { + var i, appIndex = -1; + if (product.moduleProperty("typescript", "singleFile")) { + for (i = 0; i < artifacts.length; ++i) { + if (artifacts[i].fileTags.contains("compiled_typescript")) { + appIndex = i; + break; + } + } + } else { + var expected = FileInfo.relativePath(product.sourceDirectory, applicationFile); + if (!expected.endsWith(".ts")) + // tsc doesn't allow this anyways, so it's a perfectly reasonable restriction + throw "TypeScript source file name '" + applicationFile + + "' does not end with .ts"; + + expected = expected.slice(0, -2) + "js"; + + for (i = 0; i < artifacts.length; ++i) { + if (expected === FileInfo.relativePath(product.buildDirectory, + artifacts[i].filePath)) { + appIndex = i; + break; + } + } + } + + if (appIndex === -1 || !artifacts[appIndex].fileTags.contains("compiled_typescript")) + throw "nodejs.applicationFile was set, but Qbs couldn't find the compiled " + + "JavaScript file corresponding to '" + applicationFile + "'"; + + artifacts[appIndex].fileTags = artifacts[appIndex].fileTags.concat(["application_js"]); + } + + return artifacts; + } finally { + if (process) + process.close(); + } +} + +function legacyOutputArtifacts(product, inputs) { + var artifacts = []; + + if (!inputs.typescript) { + return artifacts; + } + + var jsTags = ["js", "compiled_typescript"]; + var filePath = FileInfo.joinPaths(product.destinationDirectory, product.targetName); + if (product.moduleProperty("typescript", "singleFile")) { + // We could check + // if (product.moduleProperty("nodejs", "applicationFile") === inputs.typescript[i].filePath) + // but since we're compiling to a single file there's no need to state it explicitly + jsTags.push("application_js"); + + artifacts.push({fileTags: jsTags, + filePath: FileInfo.joinPaths( + product.moduleProperty("nodejs", + "compiledIntermediateDir"), + product.targetName + ".js")}); + + if (product.moduleProperty("typescript", "generateDeclarations")) { + artifacts.push({fileTags: ["typescript_declaration"], + filePath: filePath + ".d.ts"}); + } + + if (product.moduleProperty("typescript", "generateSourceMaps")) { + artifacts.push({fileTags: ["source_map"], + filePath: filePath + ".js.map"}); + } + } else { + for (var i = 0; i < inputs.typescript.length; ++i) { + jsTags = ["js", "compiled_typescript"]; + if (product.moduleProperty("nodejs", "applicationFile") === inputs.typescript[i].filePath) + jsTags.push("application_js"); + + var intermediatePath = FileInfo.path(FileInfo.relativePath( + product.sourceDirectory, + inputs.typescript[i].filePath)); + + var baseName = FileInfo.baseName(inputs.typescript[i].fileName); + filePath = FileInfo.joinPaths(product.destinationDirectory, + intermediatePath, + baseName); + + artifacts.push({fileTags: jsTags, + filePath: FileInfo.joinPaths( + product.moduleProperty("nodejs", + "compiledIntermediateDir"), + intermediatePath, + baseName + ".js")}); + + if (product.moduleProperty("typescript", "generateDeclarations")) { + artifacts.push({fileTags: ["typescript_declaration"], + filePath: filePath + ".d.ts"}); + } + + if (product.moduleProperty("typescript", "generateSourceMaps")) { + artifacts.push({fileTags: ["source_map"], + filePath: filePath + ".js.map"}); + } + } + } + + return artifacts; +} + +function outOption(product) { + var compilerVersionMajor = ModUtils.moduleProperty(product, "versionMajor"); + if (compilerVersionMajor === 1) { + if (ModUtils.moduleProperty(product, "versionMinor") < 6) { + return "--out"; + } + } + + return "--outFile"; +} + +function supportsModernFeatures(product) { + var compilerVersionMajor = ModUtils.moduleProperty(product, "versionMajor"); + if (compilerVersionMajor === 1) { + if (ModUtils.moduleProperty(product, "versionMinor") >= 5) { + return true; + } + } + + return compilerVersionMajor > 1; +} diff --git a/share/qbs/modules/vcs/vcs-module.qbs b/share/qbs/modules/vcs/vcs-module.qbs new file mode 100644 index 00000000..f3a47d2a --- /dev/null +++ b/share/qbs/modules/vcs/vcs-module.qbs @@ -0,0 +1,154 @@ +import qbs.File +import qbs.FileInfo +import qbs.Process +import qbs.TextFile +import qbs.Utilities + +Module { + property string type: typeProbe.type + property string repoDir: project.sourceDirectory + property string toolFilePath: { + if (type === "git") + return "git"; + if (type === "svn") + return "svn"; + } + + property string headerFileName: "vcs-repo-state.h" + readonly property string repoState: gitProbe.repoState || subversionProbe.repoState + + // Internal + readonly property string includeDir: FileInfo.joinPaths(product.buildDirectory, "vcs-include") + readonly property string metaDataBaseDir: typeProbe.metaDataBaseDir + + PropertyOptions { + name: "type" + allowedValues: ["git", "svn"] + description: "the version control system your project is using" + } + + Depends { name: "cpp"; condition: headerFileName } + Properties { + condition: headerFileName + cpp.includePaths: [includeDir] + } + + Probe { + id: typeProbe + + property string tool: toolFilePath + property string theRepoDir: repoDir + + property string type + property string metaDataBaseDir + + configure: { + var detector = new Process(); + try { + detector.setWorkingDirectory(theRepoDir); + if (detector.exec(tool || "git", ["rev-parse", "--git-dir"]) === 0) { + found = true; + type = "git"; + metaDataBaseDir = detector.readStdOut().trim(); + if (!FileInfo.isAbsolutePath(metaDataBaseDir)) + metaDataBaseDir = FileInfo.joinPaths(theRepoDir, metaDataBaseDir); + return; + } + if (detector.exec(tool || "svn", + ["info", "--show-item", "wc-root", "--no-newline"]) === 0) { + found = true + type = "svn"; + metaDataBaseDir = FileInfo.joinPaths(detector.readStdOut(), ".svn"); + return; + } else if (detector.exec(tool || "svn", ["info"]) === 0) { + if (detector.exec(tool || "svn", ["--version", "--quiet"]) === 0 + && Utilities.versionCompare(detector.readStdOut().trim(), "1.9") < 0) { + throw "svn too old, version >= 1.9 required"; + } + } + } finally { + detector.close(); + } + } + } + + Probe { + id: gitProbe + condition: type === "git" + + property string tool: toolFilePath + property string theRepoDir: repoDir + property string filePath: FileInfo.joinPaths(metaDataBaseDir, "logs/HEAD") + property var timestamp: File.lastModified(filePath) + + property string repoState + + configure: { + if (!File.exists(filePath)) + return; // No commits yet. + var proc = new Process(); + try { + proc.setWorkingDirectory(theRepoDir); + proc.exec(tool, ["describe", "--always", "HEAD"], true); + repoState = proc.readStdOut().trim(); + if (repoState) + found = true; + } finally { + proc.close(); + } + } + } + + Probe { + id: subversionProbe + condition: type === "svn" + + property string tool: toolFilePath + property string theRepoDir: repoDir + property string filePath: FileInfo.joinPaths(metaDataBaseDir, "wc.db") + property var timestamp: File.lastModified(filePath) + + property string repoState + + configure: { + var proc = new Process(); + try { + proc.setWorkingDirectory(theRepoDir); + proc.exec(tool, ["info", "-r", "HEAD", "--show-item", "revision", "--no-newline"], + true); + repoState = proc.readStdOut().trim(); + if (repoState) + found = true; + } finally { + proc.close(); + } + } + } + + Rule { + condition: headerFileName + multiplex: true + Artifact { + filePath: FileInfo.joinPaths(product.vcs.includeDir, product.vcs.headerFileName) + fileTags: ["hpp"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.highlight = "codegen"; + cmd.repoState = product.vcs.repoState; + cmd.sourceCode = function() { + var f = new TextFile(output.filePath, TextFile.WriteOnly); + try { + f.writeLine("#ifndef VCS_REPO_STATE_H"); + f.writeLine("#define VCS_REPO_STATE_H"); + f.writeLine('#define VCS_REPO_STATE "' + (repoState ? repoState : "none") + '"') + f.writeLine("#endif"); + } finally { + f.close(); + } + }; + return [cmd]; + } + } +} diff --git a/share/qbs/modules/wix/WiXModule.qbs b/share/qbs/modules/wix/WiXModule.qbs new file mode 100644 index 00000000..31bdac51 --- /dev/null +++ b/share/qbs/modules/wix/WiXModule.qbs @@ -0,0 +1,453 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import qbs.File +import qbs.FileInfo +import qbs.Host +import qbs.ModUtils +import qbs.Probes +import qbs.Utilities + +Module { + condition: qbs.targetOS.contains("windows") + + Probes.WiXProbe { + id: wixProbe + } + + property path toolchainInstallPath: wixProbe.path + property path toolchainInstallRoot: wixProbe.root + version: wixProbe.version + property var versionParts: version ? version.split('.').map(function(item) { return parseInt(item, 10); }) : [] + property int versionMajor: versionParts[0] + property int versionMinor: versionParts[1] + property int versionPatch: versionParts[2] + property int versionBuild: versionParts[3] + + property string compilerName: "candle.exe" + property string compilerPath: FileInfo.joinPaths(toolchainInstallRoot, compilerName) + property string linkerName: "light.exe" + property string linkerPath: FileInfo.joinPaths(toolchainInstallRoot, linkerName) + + property string warningLevel: "normal" + PropertyOptions { + name: "warningLevel" + allowedValues: ["none", "normal", "pedantic"] + } + + property bool debugInformation: qbs.debugInformation + property bool treatWarningsAsErrors: false + property bool verboseOutput: false + PropertyOptions { + name: "verboseOutput" + description: "display verbose output from the compiler and linker" + } + + property bool visualStudioCompatibility: true + PropertyOptions { + name: "visualStudioCompatibility" + description: "whether to define most of the same variables as " + + "Visual Studio when using the Candle compiler" + } + + property bool enableQbsDefines: true + PropertyOptions { + name: "enableQbsDefines" + description: "built-in variables that are defined when using the Candle compiler" + } + + property pathList includePaths + PropertyOptions { + name: "includePaths" + description: "directories to add to the include search path" + } + + property stringList defines + PropertyOptions { + name: "defines" + description: "variables that are defined when using the Candle compiler" + } + + property stringList compilerFlags + PropertyOptions { + name: "compilerFlags" + description: "additional flags for the Candle compiler" + } + + property stringList linkerFlags + PropertyOptions { + name: "linkerFlags" + description: "additional flags for the Light linker" + } + + property stringList cultures + PropertyOptions { + name: "cultures" + description: "the list of localizations to build the MSI for; leave undefined to build all localizations" + } + + property stringList extensions: product.type.contains("wixsetup") ? ["WixBalExtension"] : [] // default to WiX Standard Bootstrapper extension + + // private properties + property string targetSuffix: { + if (product.type.contains("msi")) { + return windowsInstallerSuffix; + } else if (product.type.contains("wixsetup")) { + return executableSuffix; + } + } + + // MSI/MSM package validation only works natively on Windows + property bool enablePackageValidation: Host.os().contains("windows") + + property string executableSuffix: ".exe" + property string windowsInstallerSuffix: ".msi" + + validate: { + var validator = new ModUtils.PropertyValidator("wix"); + validator.setRequiredProperty("toolchainInstallPath", toolchainInstallPath); + validator.setRequiredProperty("toolchainInstallRoot", toolchainInstallRoot); + validator.setRequiredProperty("version", version); + validator.setRequiredProperty("versionMajor", versionMajor); + validator.setRequiredProperty("versionMinor", versionMinor); + validator.setRequiredProperty("versionPatch", versionPatch); + validator.addVersionValidator("version", version, 3, 4); + validator.addRangeValidator("versionMajor", versionMajor, 1); + validator.addRangeValidator("versionMinor", versionMinor, 0); + validator.addRangeValidator("versionPatch", versionPatch, 0); + + if (versionParts && versionParts.length >= 4) { + validator.setRequiredProperty("versionBuild", versionBuild); + validator.addRangeValidator("versionBuild", versionBuild, 0); + } + + validator.validate(); + } + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), true); + v.prepend(product.wix.toolchainInstallPath); + v.prepend(product.wix.toolchainInstallRoot); + v.set(); + } + + // WiX Include Files + FileTagger { + patterns: ["*.wxi"] + fileTags: ["wxi"] + } + + // WiX Localization Files + FileTagger { + patterns: ["*.wxl"] + fileTags: ["wxl"] + } + + // WiX Source Files + FileTagger { + patterns: ["*.wxs"] + fileTags: ["wxs"] + } + + Rule { + id: candleCompiler + inputs: ["wxs"] + auxiliaryInputs: ["wxi", "installable"] + + Artifact { + fileTags: ["wixobj"] + filePath: FileInfo.joinPaths(Utilities.getHash(input.baseDir), + FileInfo.baseName(input.fileName) + ".wixobj") + } + + prepare: { + var i; + var args = ["-nologo"]; + + if (ModUtils.moduleProperty(input, "warningLevel") === "none") { + args.push("-sw"); + } else { + if (ModUtils.moduleProperty(input, "warningLevel") === "pedantic") { + args.push("-pedantic"); + } + + if (ModUtils.moduleProperty(input, "treatWarningsAsErrors")) { + args.push("-wx"); + } + } + + if (ModUtils.moduleProperty(input, "verboseOutput")) { + args.push("-v"); + } + + var arch = product.moduleProperty("qbs", "architecture"); + + // http://wixtoolset.org/documentation/manual/v3/xsd/wix/package.html + switch (arch) { + case "x86_64": + arch = "x64"; + break; + case "armv7": + case "armv7a": + arch = "arm"; + break; + } + + // Visual Studio defines these variables along with various solution and project names and paths; + // we'll pass most of them to ease compatibility between QBS and WiX projects originally created + // using Visual Studio. The only definitions we don't pass are the ones which make no sense at all + // in QBS, like the solution and project directories since they do not exist. + if (ModUtils.moduleProperty(input, "visualStudioCompatibility")) { + var toolchain = product.moduleProperty("qbs", "toolchain"); + var toolchainInstallPath = product.moduleProperty("cpp", "toolchainInstallPath"); + if (toolchain && toolchain.contains("msvc") && toolchainInstallPath) { + var vcDir = toolchainInstallPath.replace(/[\\/]bin$/i, ""); + var vcRootDir = vcDir.replace(/[\\/]VC$/i, ""); + args.push("-dDevEnvDir=" + FileInfo.toWindowsSeparators(FileInfo.joinPaths(vcRootDir, 'Common7', 'IDE'))); + } + + var buildVariant = product.moduleProperty("qbs", "buildVariant"); + if (buildVariant === "debug") { + args.push("-dDebug"); + args.push("-dConfiguration=Debug"); + } else if (buildVariant === "release") { + // VS doesn't define "Release" + args.push("-dConfiguration=Release"); + } + + var productTargetExt = ModUtils.moduleProperty(input, "targetSuffix"); + if (!productTargetExt) { + throw("WiX: Unsupported product type '" + product.type + "'"); + } + + var builtBinaryFilePath = FileInfo.joinPaths(product.destinationDirectory, product.targetName + productTargetExt); + args.push("-dOutDir=" + FileInfo.toWindowsSeparators(FileInfo.path(builtBinaryFilePath))); // in VS, relative to the project file by default + + args.push("-dPlatform=" + (arch || "x86")); + + args.push("-dProjectName=" + project.name); + + args.push("-dTargetDir=" + FileInfo.toWindowsSeparators(FileInfo.path(builtBinaryFilePath))); // in VS, an absolute path + args.push("-dTargetExt=" + productTargetExt); + args.push("-dTargetFileName=" + product.targetName + productTargetExt); + args.push("-dTargetName=" + product.targetName); + args.push("-dTargetPath=" + FileInfo.toWindowsSeparators(builtBinaryFilePath)); + } + + var includePaths = ModUtils.moduleProperty(input, "includePaths"); + for (i in includePaths) { + args.push("-I" + includePaths[i]); + } + + var enableQbsDefines = ModUtils.moduleProperty(input, "enableQbsDefines") + if (enableQbsDefines) { + var map = { + "project.": project, + "product.": product + }; + + for (var prefix in map) { + var obj = map[prefix]; + for (var prop in obj) { + var val = obj[prop]; + if (typeof val !== 'function' && typeof val !== 'object' && !prop.startsWith("_")) { + args.push("-d" + prefix + prop + "=" + val); + } + } + } + + // Helper define for alternating between 32-bit and 64-bit logic + if (arch === "x64" || arch === "ia64") { + args.push("-dWin64"); + } + } + + // User-supplied defines + var defines = ModUtils.moduleProperty(input, "defines"); + for (i in defines) { + args.push("-d" + defines[i]); + } + + // User-supplied flags + var flags = ModUtils.moduleProperty(input, "compilerFlags"); + for (i in flags) { + args.push(flags[i]); + } + + args.push("-out"); + args.push(FileInfo.toWindowsSeparators(output.filePath)); + + if (arch) { + args.push("-arch"); + args.push(arch); + } + + var extensions = ModUtils.moduleProperty(input, "extensions"); + for (i in extensions) { + args.push("-ext"); + args.push(extensions[i]); + } + + args.push(FileInfo.toWindowsSeparators(input.filePath)); + + var cmd = new Command(ModUtils.moduleProperty(product, "compilerPath"), args); + cmd.description = "compiling " + input.fileName; + cmd.highlight = "compiler"; + cmd.workingDirectory = FileInfo.path(output.filePath); + // candle.exe outputs the file name. We filter that out. + cmd.inputFileName = input.fileName; + cmd.stdoutFilterFunction = function(output) { + return output.split(inputFileName + "\r\n").join(""); + }; + return cmd; + } + } + + Rule { + id: lightLinker + multiplex: true + inputs: ["wixobj", "wxl"] + auxiliaryInputs: ["installable"] + inputsFromDependencies: product.type.contains("wixsetup") ? ["msi"] : [] + + outputArtifacts: { + var artifacts = []; + + if (product.type.contains("wixsetup")) { + artifacts.push({ + fileTags: ["wixsetup", "application"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + ModUtils.moduleProperty(product, + "executableSuffix")) + }); + } + + if (product.type.contains("msi")) { + artifacts.push({ + fileTags: ["msi"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + + ModUtils.moduleProperty(product, + "windowsInstallerSuffix")) + }); + } + + if (ModUtils.moduleProperty(product, "debugInformation")) { + artifacts.push({ + fileTags: ["wixpdb"], + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + ".wixpdb") + }); + } + + return artifacts; + } + + outputFileTags: ["application", "msi", "wixpdb", "wixsetup"] + + prepare: { + var i; + var primaryOutput; + if (product.type.contains("wixsetup")) { + primaryOutput = outputs.wixsetup[0]; + } else if (product.type.contains("msi")) { + primaryOutput = outputs.msi[0]; + } else { + throw("WiX: Unsupported product type '" + product.type + "'"); + } + + var args = ["-nologo"]; + + if (!ModUtils.moduleProperty(product, "enablePackageValidation")) { + args.push("-sval"); + } + + if (ModUtils.moduleProperty(product, "warningLevel") === "none") { + args.push("-sw"); + } else { + if (ModUtils.moduleProperty(product, "warningLevel") === "pedantic") { + args.push("-pedantic"); + } + + if (ModUtils.moduleProperty(product, "treatWarningsAsErrors")) { + args.push("-wx"); + } + } + + if (ModUtils.moduleProperty(product, "verboseOutput")) { + args.push("-v"); + } + + args.push("-out"); + args.push(FileInfo.toWindowsSeparators(primaryOutput.filePath)); + + if (ModUtils.moduleProperty(product, "debugInformation")) { + args.push("-pdbout"); + args.push(FileInfo.toWindowsSeparators(outputs.wixpdb[0].filePath)); + } else { + args.push("-spdb"); + } + + var extensions = ModUtils.moduleProperty(product, "extensions"); + for (i in extensions) { + args.push("-ext"); + args.push(extensions[i]); + } + + for (i in inputs.wxl) { + args.push("-loc"); + args.push(FileInfo.toWindowsSeparators(inputs.wxl[i].filePath)); + } + + if (product.type.contains("msi")) { + var cultures = ModUtils.moduleProperty(product, "cultures"); + args.push("-cultures:" + + (cultures && cultures.length > 0 ? cultures.join(";") : "null")); + } + + // User-supplied flags + var flags = ModUtils.moduleProperty(product, "linkerFlags"); + for (i in flags) { + args.push(flags[i]); + } + + for (i in inputs.wixobj) { + args.push(FileInfo.toWindowsSeparators(inputs.wixobj[i].filePath)); + } + + var cmd = new Command(ModUtils.moduleProperty(product, "linkerPath"), args); + cmd.description = "linking " + primaryOutput.fileName; + cmd.highlight = "linker"; + cmd.workingDirectory = FileInfo.path(primaryOutput.filePath); + return cmd; + } + } +} diff --git a/share/qbs/modules/xcode/xcode.js b/share/qbs/modules/xcode/xcode.js new file mode 100644 index 00000000..c6c77ca7 --- /dev/null +++ b/share/qbs/modules/xcode/xcode.js @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +var DarwinTools = require("qbs.DarwinTools"); +var File = require("qbs.File"); +var FileInfo = require("qbs.FileInfo"); +var Process = require("qbs.Process"); +var PropertyList = require("qbs.PropertyList"); +var Utilities = require("qbs.Utilities"); + +var XcodeArchSpecsReader = (function () { + function XcodeArchSpecsReader(specsPath) { + var plist = new PropertyList(); + try { + plist.readFromFile(specsPath); + this.specsObject = plist.toObject(); + } finally { + plist.clear(); + } + } + XcodeArchSpecsReader.prototype.getArchitectureSettings = function () { + if (this.specsObject) { + var names = []; + for (var i = 0; i < this.specsObject.length; ++i) { + var dict = this.specsObject[i]; + var name = dict["ArchitectureSetting"]; + if (name) + names.push(name); + } + return names; + } + }; + XcodeArchSpecsReader.prototype.getArchitectureSettingValue = function (settingName) { + // settingName can be: ARCHS_STANDARD, ARCHS_STANDARD_32_BIT, ARCHS_STANDARD_64_BIT, + // ARCHS_STANDARD_32_64_BIT, ARCHS_STANDARD_INCLUDING_64_BIT, or ARCHS_UNIVERSAL_IPHONE_OS. + // NATIVE_ARCH_ACTUAL doesn't have a RealArchitectures property since it's determined by + // Xcode programmatically. + if (this.specsObject) { + for (var i = 0; i < this.specsObject.length; ++i) { + var dict = this.specsObject[i]; + if (dict["ArchitectureSetting"] === settingName) { + var realArchs = dict["RealArchitectures"]; + if (realArchs) { + var effectiveRealArchs = []; + for (var j = 0; j < realArchs.length; ++j) { + var re = /^\$\(([A-Za-z0-9_]+)\)$/; + var match = realArchs[j].match(re); + if (match) { + var val = this.getArchitectureSettingValue(match[1]); + // Don't silently omit values if missing. For example, if + // ARCHS_FOO=[x86_64, $(ARCHS_BAR)], return 'undefined' instead of + // simply [x86_64]. Not known to have any real world occurrences. + if (!val) + return undefined; + Array.prototype.push.apply(effectiveRealArchs, val); + } else { + effectiveRealArchs.push(realArchs[j]); + } + } + return effectiveRealArchs; + } + } + } + } + }; + return XcodeArchSpecsReader; +}()); + +function platformInfo(platformInfoPlist) { + var propertyList = new PropertyList(); + try { + propertyList.readFromFile(platformInfoPlist); + return propertyList.toObject(); + } finally { + propertyList.clear(); + } +} + +function sdkInfoList(sdksPath) { + var sdkInfo = []; + var sdks = File.directoryEntries(sdksPath, File.Dirs | File.NoDotAndDotDot); + for (var i in sdks) { + // SDK directory name must contain a version number; + // we don't want the versionless iPhoneOS.sdk directory for example + if (!sdks[i].match(/[0-9]+/)) + continue; + + if (sdks[i].startsWith("DriverKit")) + continue; + + var settingsPlist = FileInfo.joinPaths(sdksPath, sdks[i], "SDKSettings.plist"); + var propertyList = new PropertyList(); + try { + propertyList.readFromFile(settingsPlist); + + function checkPlist(plist) { + if (!plist || !plist["CanonicalName"] || !plist["Version"]) + return false; + + var re = /^[0-9]+\.[0-9]+(\.[0-9]+)?$/; + return plist["Version"].match(re); + } + + var plist = propertyList.toObject(); + if (!checkPlist(plist)) { + console.warn("Skipping corrupted SDK installation: " + + FileInfo.joinPaths(sdksPath, sdks[i])); + continue; + } + + sdkInfo.push(plist); + } finally { + propertyList.clear(); + } + } + + // Sort by SDK version number + sdkInfo.sort(function (a, b) { return Utilities.versionCompare(a["Version"], b["Version"]); }); + + return sdkInfo; +} + +function findSigningIdentities(security, searchString) { + var process; + var identities; + if (searchString) { + try { + process = new Process(); + if (process.exec(security, ["find-identity", "-p", "codesigning", "-v"], true) !== 0) + console.error(process.readStdErr()); + + var lines = process.readStdOut().split("\n"); + for (var i in lines) { + // e.g. 1) AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA "Mac Developer: John Doe (XXXXXXXXXX) john.doe@example.org" + var match = lines[i].match(/^\s*[0-9]+\)\s+([A-Fa-f0-9]{40})\s+"([^"]+)"$/); + if (match !== null) { + var hexId = match[1]; + var displayName = match[2]; + if (hexId === searchString || displayName.startsWith(searchString)) { + if (!identities) + identities = []; + identities.push([hexId, displayName]); + break; + } + } + } + } finally { + process.close(); + } + } + return identities; +} + +function provisioningProfilePlistContents(filePath) { + if (filePath === undefined || !File.exists(filePath)) + return undefined; + + var plist = new PropertyList(); + try { + plist.readFromFile(filePath); + return plist.toObject(); + } finally { + plist.clear(); + } +} + +function boolFromSdkOrPlatform(varName, sdkProps, platformProps, defaultValue) { + var values = [(sdkProps || {})[varName], (platformProps || {})[varName]]; + for (var i = 0; i < values.length; ++i) { + if (values[i] === "YES") + return true; + if (values[i] === "NO") + return false; + } + return defaultValue; +} + +function archsSpecsPath(version, targetOS, platformType, platformPath, devicePlatformPath, + developerPath) { + if (Utilities.versionCompare(version, "13.3") >= 0) { + var baseDir = FileInfo.joinPaths(developerPath, "..", + "PlugIns/XCBSpecifications.ideplugin/Contents/Resources"); + var baseName = targetOS.contains("macos") ? "MacOSX Architectures" + : targetOS.contains("ios-simulator") ? "iOS Simulator" + : targetOS.contains("ios") ? "iOS Device" + : targetOS.contains("tvos-simulator") ? "tvOS Simulator" + : targetOS.contains("tvos") ? "tvOS Device" + : targetOS.contains("watchos-simulator") ? "watchOS Simulator" : "watchOS Device"; + return FileInfo.joinPaths(baseDir, baseName + ".xcspec"); + } + var _specsPluginBaseName; + if (Utilities.versionCompare(version, "12") >= 0) { + if (targetOS.contains("macos")) + _specsPluginBaseName = "OSX"; + } + if (Utilities.versionCompare(version, "7") >= 0) { + if (targetOS.contains("ios")) + _specsPluginBaseName = "iOSPlatform"; + if (targetOS.contains("tvos")) + _specsPluginBaseName = "AppleTV"; + if (targetOS.contains("watchos")) + _specsPluginBaseName = "Watch"; + } + + var _archSpecsDir = _specsPluginBaseName + ? FileInfo.joinPaths(devicePlatformPath, "Developer", "Library", "Xcode", + "PrivatePlugIns", + "IDE" + _specsPluginBaseName + "SupportCore.ideplugin", "Contents", + "Resources") + : FileInfo.joinPaths(platformPath, "Developer", "Library", "Xcode", "Specifications"); + + var _archSpecsFileBaseName = targetOS.contains("ios") + ? (targetOS.contains("ios-simulator") ? "iPhone Simulator " : "iPhoneOS") + : DarwinTools.applePlatformDirectoryName(targetOS, platformType) + " "; + + if (_specsPluginBaseName) { + switch (platformType) { + case "device": + return FileInfo.joinPaths(_archSpecsDir, "Device.xcspec"); + case "simulator": + return FileInfo.joinPaths(_archSpecsDir, "Simulator.xcspec"); + } + } + + return FileInfo.joinPaths(_archSpecsDir, _archSpecsFileBaseName + "Architectures.xcspec"); +} diff --git a/share/qbs/modules/xcode/xcode.qbs b/share/qbs/modules/xcode/xcode.qbs new file mode 100644 index 00000000..1975f04b --- /dev/null +++ b/share/qbs/modules/xcode/xcode.qbs @@ -0,0 +1,207 @@ +import qbs.BundleTools +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.DarwinTools +import qbs.ModUtils +import qbs.Probes +import qbs.PropertyList +import qbs.Utilities + +Module { + id: xcodeModule + + Probes.XcodeLocationProbe { + id: xcodeLocationProbe + condition: !xcodeModule.developerPath + } + + Probes.XcodeProbe { + id: xcodeProbe + developerPath: xcodeModule.developerPath + platformType: xcodeModule.platformType + platformPath: xcodeModule.platformPath + devicePlatformPath: xcodeModule.devicePlatformPath + xcodebuildPath: xcodeModule.xcodebuildPath + sdksPath: xcodeModule.sdksPath + } + + condition: qbs.targetOS.contains("darwin") && + qbs.toolchain && qbs.toolchain.contains("xcode") + + version: xcodeProbe.xcodeVersion + + property path developerPath: xcodeLocationProbe.found + ? xcodeLocationProbe.developerPath + : undefined + property string sdk: DarwinTools.applePlatformName(qbs.targetOS, platformType) + property stringList targetDevices: DarwinTools.targetDevices(qbs.targetOS) + + property string platformType: { + if (qbs.targetOS.containsAny(["ios-simulator", "tvos-simulator", "watchos-simulator"])) + return "simulator"; + if (qbs.targetOS.containsAny(["ios", "tvos", "watchos"])) + return "device"; + } + + readonly property string sdkName: { + if (_sdkSettings) { + return _sdkSettings["CanonicalName"]; + } + } + + readonly property string sdkVersion: { + if (_sdkSettings) { + return _sdkSettings["Version"]; + } + } + readonly property string shortSdkVersion: { + var v = sdkVersion; + if (v && v.split('.').length > 2) + v = v.slice(0, v.lastIndexOf('.')); + return v; + } + + readonly property string latestSdkName: { + if (_latestSdk) { + return _latestSdk["CanonicalName"]; + } + } + + readonly property string latestSdkVersion: { + if (_latestSdk) { + return _latestSdk["Version"]; + } + } + + readonly property stringList availableSdkNames: { + if (_availableSdks) { + return _availableSdks.map(function (obj) { return obj["CanonicalName"]; }); + } + } + + readonly property stringList availableSdkVersions: { + if (_availableSdks) { + return _availableSdks.map(function (obj) { return obj["Version"]; }); + } + } + + readonly property path toolchainPath: FileInfo.joinPaths(toolchainsPath, + "XcodeDefault" + ".xctoolchain") + readonly property path platformPath: FileInfo.joinPaths(platformsPath, + DarwinTools.applePlatformDirectoryName( + qbs.targetOS, platformType) + + ".platform") + readonly property path devicePlatformPath: FileInfo.joinPaths( + platformsPath, + DarwinTools.applePlatformDirectoryName( + qbs.targetOS, "device") + + ".platform") + readonly property path simulatorPlatformPath: FileInfo.joinPaths( + platformsPath, + DarwinTools.applePlatformDirectoryName( + qbs.targetOS, "simulator") + + ".platform") + readonly property path sdkPath: FileInfo.joinPaths(sdksPath, + DarwinTools.applePlatformDirectoryName( + qbs.targetOS, platformType, + shortSdkVersion) + ".sdk") + + // private properties + readonly property path toolchainsPath: FileInfo.joinPaths(developerPath, "Toolchains") + readonly property path platformsPath: FileInfo.joinPaths(developerPath, "Platforms") + readonly property path sdksPath: FileInfo.joinPaths(platformPath, "Developer", "SDKs") + + readonly property path platformInfoPlist: FileInfo.joinPaths(platformPath, "Info.plist") + readonly property path sdkSettingsPlist: FileInfo.joinPaths(sdkPath, "SDKSettings.plist") + readonly property path toolchainInfoPlist: FileInfo.joinPaths(toolchainPath, + "ToolchainInfo.plist") + + readonly property var _platformSettings: xcodeProbe.platformSettings + + readonly property var _platformProps: { + if (_platformSettings) + return _platformSettings["DefaultProperties"]; + } + + readonly property stringList standardArchitectures: _architectureSettings["ARCHS_STANDARD"] + + readonly property var _architectureSettings: xcodeProbe.architectureSettings + + readonly property var _availableSdks: xcodeProbe.availableSdks + + readonly property var _latestSdk: _availableSdks[_availableSdks.length - 1] + + readonly property var _sdkSettings: { + if (_availableSdks) { + for (var i in _availableSdks) { + if (_availableSdks[i]["Version"] === sdk) + return _availableSdks[i]; + if (_availableSdks[i]["CanonicalName"] === sdk) + return _availableSdks[i]; + } + + // Latest SDK available for the platform + if (DarwinTools.applePlatformName(qbs.targetOS, platformType) === sdk) + return _latestSdk; + } + } + + readonly property var _sdkProps: { + if (_sdkSettings) { + return _sdkSettings["DefaultProperties"]; + } + } + + qbs.sysroot: sdkPath + + validate: { + if (!_availableSdks) { + throw "There are no SDKs available for this platform in the Xcode installation."; + } + + if (!_sdkSettings) { + throw "There is no matching SDK available for " + sdk + "."; + } + + var validator = new ModUtils.PropertyValidator("xcode"); + validator.setRequiredProperty("developerPath", developerPath); + validator.setRequiredProperty("sdk", sdk); + validator.setRequiredProperty("sdkName", sdkName); + validator.setRequiredProperty("sdkVersion", sdkVersion); + validator.setRequiredProperty("toolchainsPath", toolchainsPath); + validator.setRequiredProperty("toolchainPath", toolchainPath); + validator.setRequiredProperty("platformsPath", platformsPath); + validator.setRequiredProperty("platformPath", platformPath); + validator.setRequiredProperty("sdksPath", sdkPath); + validator.setRequiredProperty("sdkPath", sdkPath); + validator.addVersionValidator("sdkVersion", sdkVersion, 2, 3); + validator.addCustomValidator("sdkName", sdkName, function (value) { + return value === DarwinTools.applePlatformDirectoryName( + qbs.targetOS, platformType, shortSdkVersion, false).toLowerCase(); + }, "is '" + sdkName + "', but target OS is [" + qbs.targetOS.join(",") + + "] and Xcode SDK version is '" + sdkVersion + "'"); + validator.addCustomValidator("sdk", sdk, function (value) { + return value === sdkName || (value + shortSdkVersion) === sdkName; + }, "is '" + sdk + "', but canonical SDK name is '" + sdkName + "'"); + validator.validate(); + } + + property var buildEnv: ({ + "DEVELOPER_DIR": developerPath, + "SDKROOT": sdkPath + }) + + setupBuildEnvironment: { + var v = new ModUtils.EnvironmentVariable("PATH", FileInfo.pathListSeparator(), false); + v.prepend(product.xcode.platformPath + "/Developer/usr/bin"); + v.prepend(product.xcode.developerPath + "/usr/bin"); + v.set(); + + for (var key in product.xcode.buildEnv) { + v = new ModUtils.EnvironmentVariable(key); + v.value = product.xcode.buildEnv[key]; + v.set(); + } + } +} diff --git a/share/share.qbs b/share/share.qbs new file mode 100644 index 00000000..97af3039 --- /dev/null +++ b/share/share.qbs @@ -0,0 +1,145 @@ +import qbs.File +import qbs.FileInfo +import qbs.TextFile +import qbs.Utilities + +Product { + name: "qbs resources" + type: ["qbs qml type descriptions", "qbs qml type bundle"] + Depends { name: "qbsbuildconfig" } + + Group { + name: "Incredibuild" + prefix: "../bin/" + files: ["ibmsvc.xml", "ibqbs.bat"] + fileTags: [] + qbs.install: qbs.targetOS.contains("windows") + qbs.installDir: qbsbuildconfig.appInstallDir + } + + Group { + name: "Python executables" + files: ["../src/3rdparty/python/bin/dmgbuild"] + fileTags: ["qbs resources"] + qbs.install: true + qbs.installDir: qbsbuildconfig.libexecInstallDir + qbs.installSourceBase: "../src/3rdparty/python/bin" + } + + Group { + name: "Python packages" + prefix: "../src/3rdparty/python/**/" + files: ["*.py"] + fileTags: ["qbs resources"] + qbs.install: true + qbs.installDir: qbsbuildconfig.resourcesInstallDir + "/share/qbs/python" + qbs.installSourceBase: "../src/3rdparty/python/lib/python2.7/site-packages" + } + + Group { + name: "Imports" + files: ["qbs/imports/qbs/**/*"] + fileTags: ["qbs resources"] + qbs.install: true + qbs.installDir: qbsbuildconfig.resourcesInstallDir + "/share" + qbs.installSourceBase: "." + } + + Group { + name: "Modules" + files: ["qbs/modules/**/*"] + fileTags: ["qbs resources"] + qbs.install: true + qbs.installDir: qbsbuildconfig.resourcesInstallDir + "/share" + qbs.installSourceBase: "." + } + + Group { + name: "Module providers" + files: ["qbs/module-providers/*", "qbs/module-providers/**/*"] + fileTags: ["qbs resources"] + qbs.install: true + qbs.installDir: qbsbuildconfig.resourcesInstallDir + "/share" + qbs.installSourceBase: "." + } + + Group { + name: "Examples as resources" + files: ["../examples/**/*"] + fileTags: [] + qbs.install: true + qbs.installDir: qbsbuildconfig.resourcesInstallDir + "/share/qbs" + qbs.installSourceBase: ".." + } + + Rule { + condition: Utilities.versionCompare(product.qbs.version, "1.9.1") >= 0 + multiplex: true + Artifact { + filePath: "qbs.qmltypes" + fileTags: ["qbs qml type descriptions"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var tf; + try { + tf = new TextFile(output.filePath, TextFile.WriteOnly); + tf.writeLine(Utilities.qmlTypeInfo()); + } finally { + if (tf) + tf.close(); + } + }; + return cmd; + } + } + + Rule { + condition: Utilities.versionCompare(product.qbs.version, "1.9.1") >= 0 + multiplex: true + Artifact { + filePath: "qbs-bundle.json" + fileTags: ["qbs qml type bundle"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "generating " + output.fileName; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var tf; + try { + var imports = File.directoryEntries(FileInfo.joinPaths(product.sourceDirectory, + "qbs", "imports", "qbs"), + File.Dirs | File.NoDotAndDotDot).filter( + function(i) { return i !== "base"; }).concat( + Utilities.builtinExtensionNames()).map( + function(i) { return "qbs." + i; }); + imports.sort(); + var obj = { + "name": "qbs", + "searchPaths": ["$(QBS_IMPORT_PATH)"], + "installPaths": ["$(QBS_IMPORT_PATH)"], + "implicitImports": ["__javascriptQt5__"], + "supportedImports": ["qbs"].concat(imports) + }; + tf = new TextFile(output.filePath, TextFile.WriteOnly); + tf.writeLine(JSON.stringify(obj, undefined, 4)); + } finally { + if (tf) + tf.close(); + } + }; + return cmd; + } + } + + Group { + name: "QML Type Info" + fileTagsFilter: ["qbs qml type descriptions", "qbs qml type bundle"] + qbs.install: true + qbs.installDir: qbsbuildconfig.qmlTypeDescriptionsInstallDir + } +} diff --git a/src/3rdparty/python/.gitignore b/src/3rdparty/python/.gitignore new file mode 100644 index 00000000..3a4de078 --- /dev/null +++ b/src/3rdparty/python/.gitignore @@ -0,0 +1,3 @@ +*.pyc +*.dist-info +*.egg-info diff --git a/src/3rdparty/python/bin/dmgbuild b/src/3rdparty/python/bin/dmgbuild new file mode 100755 index 00000000..74fc367c --- /dev/null +++ b/src/3rdparty/python/bin/dmgbuild @@ -0,0 +1,36 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +from __future__ import print_function + +import dmgbuild +import sys +import argparse + +parser = argparse.ArgumentParser(description='Construct a disk image file.') +parser.add_argument('volume_name', metavar='volume-name', + help='The name to give to the volume (this will appear in the title bar when the user mounts the disk image).') +parser.add_argument('filename', metavar='output.dmg', + help='The filename of the disk image to create.') +parser.add_argument('-s', '--settings', + help='The path of the settings file.') +parser.add_argument('-D', dest='defines', action='append', default=[], + help='Define a value for the settings file (e.g. -Dfoo=bar).') +parser.add_argument('--no-hidpi', dest='lookForHiDPI', action='store_false', default=True, + help='Do not search for HiDPI versions of the background image (if specified)') + + +args = parser.parse_args() + +defines = {} +for d in args.defines: + k,v = d.split('=', 1) + k = k.strip() + v = v.strip() + if (v.startswith("'") and v.endswith("'")) \ + or (v.startswith('"') and v.endswith('"')): + v = v[1:-1] + defines[k] = v + +dmgbuild.build_dmg(args.filename, args.volume_name, args.settings, defines=defines, lookForHiDPI=args.lookForHiDPI) diff --git a/src/3rdparty/python/lib/python2.7/site-packages/biplist/LICENSE b/src/3rdparty/python/lib/python2.7/site-packages/biplist/LICENSE new file mode 100644 index 00000000..1c7ba6cc --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/biplist/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2010, Andrew Wooster +All rights reserved. + +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 biplist 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 HOLDER 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. diff --git a/src/3rdparty/python/lib/python2.7/site-packages/biplist/__init__.py b/src/3rdparty/python/lib/python2.7/site-packages/biplist/__init__.py new file mode 100644 index 00000000..f9d5836d --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/biplist/__init__.py @@ -0,0 +1,977 @@ +"""biplist -- a library for reading and writing binary property list files. + +Binary Property List (plist) files provide a faster and smaller serialization +format for property lists on OS X. This is a library for generating binary +plists which can be read by OS X, iOS, or other clients. + +The API models the plistlib API, and will call through to plistlib when +XML serialization or deserialization is required. + +To generate plists with UID values, wrap the values with the Uid object. The +value must be an int. + +To generate plists with NSData/CFData values, wrap the values with the +Data object. The value must be a string. + +Date values can only be datetime.datetime objects. + +The exceptions InvalidPlistException and NotBinaryPlistException may be +thrown to indicate that the data cannot be serialized or deserialized as +a binary plist. + +Plist generation example: + + from biplist import * + from datetime import datetime + plist = {'aKey':'aValue', + '0':1.322, + 'now':datetime.now(), + 'list':[1,2,3], + 'tuple':('a','b','c') + } + try: + writePlist(plist, "example.plist") + except (InvalidPlistException, NotBinaryPlistException), e: + print "Something bad happened:", e + +Plist parsing example: + + from biplist import * + try: + plist = readPlist("example.plist") + print plist + except (InvalidPlistException, NotBinaryPlistException), e: + print "Not a plist:", e +""" + +from collections import namedtuple +import datetime +import io +import math +import plistlib +from struct import pack, unpack, unpack_from +from struct import error as struct_error +import sys +import time + +try: + unicode + unicodeEmpty = r'' +except NameError: + unicode = str + unicodeEmpty = '' +try: + long +except NameError: + long = int +try: + {}.iteritems + iteritems = lambda x: x.iteritems() +except AttributeError: + iteritems = lambda x: x.items() + +__all__ = [ + 'Uid', 'Data', 'readPlist', 'writePlist', 'readPlistFromString', + 'writePlistToString', 'InvalidPlistException', 'NotBinaryPlistException' +] + +# Apple uses Jan 1, 2001 as a base for all plist date/times. +apple_reference_date = datetime.datetime.utcfromtimestamp(978307200) + +class Uid(object): + """Wrapper around integers for representing UID values. This + is used in keyed archiving.""" + integer = 0 + def __init__(self, integer): + self.integer = integer + + def __repr__(self): + return "Uid(%d)" % self.integer + + def __eq__(self, other): + if isinstance(self, Uid) and isinstance(other, Uid): + return self.integer == other.integer + return False + + def __cmp__(self, other): + return self.integer - other.integer + + def __lt__(self, other): + return self.integer < other.integer + + def __hash__(self): + return self.integer + + def __int__(self): + return int(self.integer) + +class Data(bytes): + """Wrapper around bytes to distinguish Data values.""" + +class InvalidPlistException(Exception): + """Raised when the plist is incorrectly formatted.""" + +class NotBinaryPlistException(Exception): + """Raised when a binary plist was expected but not encountered.""" + +def readPlist(pathOrFile): + """Raises NotBinaryPlistException, InvalidPlistException""" + didOpen = False + result = None + if isinstance(pathOrFile, (bytes, unicode)): + pathOrFile = open(pathOrFile, 'rb') + didOpen = True + try: + reader = PlistReader(pathOrFile) + result = reader.parse() + except NotBinaryPlistException as e: + try: + pathOrFile.seek(0) + result = None + if hasattr(plistlib, 'loads'): + contents = None + if isinstance(pathOrFile, (bytes, unicode)): + with open(pathOrFile, 'rb') as f: + contents = f.read() + else: + contents = pathOrFile.read() + result = plistlib.loads(contents) + else: + result = plistlib.readPlist(pathOrFile) + result = wrapDataObject(result, for_binary=True) + except Exception as e: + raise InvalidPlistException(e) + finally: + if didOpen: + pathOrFile.close() + return result + +def wrapDataObject(o, for_binary=False): + if isinstance(o, Data) and not for_binary: + v = sys.version_info + if not (v[0] >= 3 and v[1] >= 4): + o = plistlib.Data(o) + elif isinstance(o, (bytes, plistlib.Data)) and for_binary: + if hasattr(o, 'data'): + o = Data(o.data) + elif isinstance(o, tuple): + o = wrapDataObject(list(o), for_binary) + o = tuple(o) + elif isinstance(o, list): + for i in range(len(o)): + o[i] = wrapDataObject(o[i], for_binary) + elif isinstance(o, dict): + for k in o: + o[k] = wrapDataObject(o[k], for_binary) + return o + +def writePlist(rootObject, pathOrFile, binary=True): + if not binary: + rootObject = wrapDataObject(rootObject, binary) + if hasattr(plistlib, "dump"): + if isinstance(pathOrFile, (bytes, unicode)): + with open(pathOrFile, 'wb') as f: + return plistlib.dump(rootObject, f) + else: + return plistlib.dump(rootObject, pathOrFile) + else: + return plistlib.writePlist(rootObject, pathOrFile) + else: + didOpen = False + if isinstance(pathOrFile, (bytes, unicode)): + pathOrFile = open(pathOrFile, 'wb') + didOpen = True + writer = PlistWriter(pathOrFile) + result = writer.writeRoot(rootObject) + if didOpen: + pathOrFile.close() + return result + +def readPlistFromString(data): + return readPlist(io.BytesIO(data)) + +def writePlistToString(rootObject, binary=True): + if not binary: + rootObject = wrapDataObject(rootObject, binary) + if hasattr(plistlib, "dumps"): + return plistlib.dumps(rootObject) + elif hasattr(plistlib, "writePlistToBytes"): + return plistlib.writePlistToBytes(rootObject) + else: + return plistlib.writePlistToString(rootObject) + else: + ioObject = io.BytesIO() + writer = PlistWriter(ioObject) + writer.writeRoot(rootObject) + return ioObject.getvalue() + +def is_stream_binary_plist(stream): + stream.seek(0) + header = stream.read(7) + if header == b'bplist0': + return True + else: + return False + +PlistTrailer = namedtuple('PlistTrailer', 'offsetSize, objectRefSize, offsetCount, topLevelObjectNumber, offsetTableOffset') +PlistByteCounts = namedtuple('PlistByteCounts', 'nullBytes, boolBytes, intBytes, realBytes, dateBytes, dataBytes, stringBytes, uidBytes, arrayBytes, setBytes, dictBytes') + +class PlistReader(object): + file = None + contents = '' + offsets = None + trailer = None + currentOffset = 0 + # Used to detect recursive object references. + offsetsStack = [] + + def __init__(self, fileOrStream): + """Raises NotBinaryPlistException.""" + self.reset() + self.file = fileOrStream + + def parse(self): + return self.readRoot() + + def reset(self): + self.trailer = None + self.contents = '' + self.offsets = [] + self.currentOffset = 0 + self.offsetsStack = [] + + def readRoot(self): + result = None + self.reset() + # Get the header, make sure it's a valid file. + if not is_stream_binary_plist(self.file): + raise NotBinaryPlistException() + self.file.seek(0) + self.contents = self.file.read() + if len(self.contents) < 32: + raise InvalidPlistException("File is too short.") + trailerContents = self.contents[-32:] + try: + self.trailer = PlistTrailer._make(unpack("!xxxxxxBBQQQ", trailerContents)) + + if pow(2, self.trailer.offsetSize*8) < self.trailer.offsetTableOffset: + raise InvalidPlistException("Offset size insufficient to reference all objects.") + + if pow(2, self.trailer.objectRefSize*8) < self.trailer.offsetCount: + raise InvalidPlistException("Too many offsets to represent in size of object reference representation.") + + offset_size = self.trailer.offsetSize * self.trailer.offsetCount + offset = self.trailer.offsetTableOffset + + if offset + offset_size > pow(2, 64): + raise InvalidPlistException("Offset table is excessively long.") + + if self.trailer.offsetSize > 16: + raise InvalidPlistException("Offset size is greater than maximum integer size.") + + if self.trailer.objectRefSize == 0: + raise InvalidPlistException("Object reference size is zero.") + + if offset >= len(self.contents) - 32: + raise InvalidPlistException("Offset table offset is too large.") + + if offset < len("bplist00x"): + raise InvalidPlistException("Offset table offset is too small.") + + if self.trailer.topLevelObjectNumber >= self.trailer.offsetCount: + raise InvalidPlistException("Top level object number is larger than the number of objects.") + + offset_contents = self.contents[offset:offset+offset_size] + offset_i = 0 + offset_table_length = len(offset_contents) + + while offset_i < self.trailer.offsetCount: + begin = self.trailer.offsetSize*offset_i + end = begin+self.trailer.offsetSize + if end > offset_table_length: + raise InvalidPlistException("End of object is at invalid offset %d in offset table of length %d" % (end, offset_table_length)) + tmp_contents = offset_contents[begin:end] + tmp_sized = self.getSizedInteger(tmp_contents, self.trailer.offsetSize) + self.offsets.append(tmp_sized) + offset_i += 1 + self.setCurrentOffsetToObjectNumber(self.trailer.topLevelObjectNumber) + result = self.readObject() + except TypeError as e: + raise InvalidPlistException(e) + return result + + def setCurrentOffsetToObjectNumber(self, objectNumber): + if objectNumber > len(self.offsets) - 1: + raise InvalidPlistException("Invalid offset number: %d" % objectNumber) + self.currentOffset = self.offsets[objectNumber] + if self.currentOffset in self.offsetsStack: + raise InvalidPlistException("Recursive data structure detected in object: %d" % objectNumber) + + def beginOffsetProtection(self): + self.offsetsStack.append(self.currentOffset) + return self.currentOffset + + def endOffsetProtection(self, offset): + try: + index = self.offsetsStack.index(offset) + self.offsetsStack = self.offsetsStack[:index] + except ValueError as e: + pass + + def readObject(self): + protection = self.beginOffsetProtection() + result = None + tmp_byte = self.contents[self.currentOffset:self.currentOffset+1] + if len(tmp_byte) != 1: + raise InvalidPlistException("No object found at offset: %d" % self.currentOffset) + marker_byte = unpack("!B", tmp_byte)[0] + format = (marker_byte >> 4) & 0x0f + extra = marker_byte & 0x0f + self.currentOffset += 1 + + def proc_extra(extra): + if extra == 0b1111: + extra = self.readObject() + return extra + + # bool, null, or fill byte + if format == 0b0000: + if extra == 0b0000: + result = None + elif extra == 0b1000: + result = False + elif extra == 0b1001: + result = True + elif extra == 0b1111: + pass # fill byte + else: + raise InvalidPlistException("Invalid object found at offset: %d" % (self.currentOffset - 1)) + # int + elif format == 0b0001: + result = self.readInteger(pow(2, extra)) + # real + elif format == 0b0010: + result = self.readReal(extra) + # date + elif format == 0b0011 and extra == 0b0011: + result = self.readDate() + # data + elif format == 0b0100: + extra = proc_extra(extra) + result = self.readData(extra) + # ascii string + elif format == 0b0101: + extra = proc_extra(extra) + result = self.readAsciiString(extra) + # Unicode string + elif format == 0b0110: + extra = proc_extra(extra) + result = self.readUnicode(extra) + # uid + elif format == 0b1000: + result = self.readUid(extra) + # array + elif format == 0b1010: + extra = proc_extra(extra) + result = self.readArray(extra) + # set + elif format == 0b1100: + extra = proc_extra(extra) + result = set(self.readArray(extra)) + # dict + elif format == 0b1101: + extra = proc_extra(extra) + result = self.readDict(extra) + else: + raise InvalidPlistException("Invalid object found: {format: %s, extra: %s}" % (bin(format), bin(extra))) + self.endOffsetProtection(protection) + return result + + def readContents(self, length, description="Object contents"): + end = self.currentOffset + length + if end >= len(self.contents) - 32: + raise InvalidPlistException("%s extends into trailer" % description) + elif length < 0: + raise InvalidPlistException("%s length is less than zero" % length) + data = self.contents[self.currentOffset:end] + return data + + def readInteger(self, byteSize): + data = self.readContents(byteSize, "Integer") + self.currentOffset = self.currentOffset + byteSize + return self.getSizedInteger(data, byteSize, as_number=True) + + def readReal(self, length): + to_read = pow(2, length) + data = self.readContents(to_read, "Real") + if length == 2: # 4 bytes + result = unpack('>f', data)[0] + elif length == 3: # 8 bytes + result = unpack('>d', data)[0] + else: + raise InvalidPlistException("Unknown Real of length %d bytes" % to_read) + return result + + def readRefs(self, count): + refs = [] + i = 0 + while i < count: + fragment = self.readContents(self.trailer.objectRefSize, "Object reference") + ref = self.getSizedInteger(fragment, len(fragment)) + refs.append(ref) + self.currentOffset += self.trailer.objectRefSize + i += 1 + return refs + + def readArray(self, count): + if not isinstance(count, (int, long)): + raise InvalidPlistException("Count of entries in dict isn't of integer type.") + result = [] + values = self.readRefs(count) + i = 0 + while i < len(values): + self.setCurrentOffsetToObjectNumber(values[i]) + value = self.readObject() + result.append(value) + i += 1 + return result + + def readDict(self, count): + if not isinstance(count, (int, long)): + raise InvalidPlistException("Count of keys/values in dict isn't of integer type.") + result = {} + keys = self.readRefs(count) + values = self.readRefs(count) + i = 0 + while i < len(keys): + self.setCurrentOffsetToObjectNumber(keys[i]) + key = self.readObject() + self.setCurrentOffsetToObjectNumber(values[i]) + value = self.readObject() + result[key] = value + i += 1 + return result + + def readAsciiString(self, length): + if not isinstance(length, (int, long)): + raise InvalidPlistException("Length of ASCII string isn't of integer type.") + data = self.readContents(length, "ASCII string") + result = unpack("!%ds" % length, data)[0] + self.currentOffset += length + return str(result.decode('ascii')) + + def readUnicode(self, length): + if not isinstance(length, (int, long)): + raise InvalidPlistException("Length of Unicode string isn't of integer type.") + actual_length = length*2 + data = self.readContents(actual_length, "Unicode string") + self.currentOffset += actual_length + return data.decode('utf_16_be') + + def readDate(self): + data = self.readContents(8, "Date") + x = unpack(">d", data)[0] + if math.isnan(x): + raise InvalidPlistException("Date is NaN") + # Use timedelta to workaround time_t size limitation on 32-bit python. + try: + result = datetime.timedelta(seconds=x) + apple_reference_date + except OverflowError: + if x > 0: + result = datetime.datetime.max + else: + result = datetime.datetime.min + self.currentOffset += 8 + return result + + def readData(self, length): + if not isinstance(length, (int, long)): + raise InvalidPlistException("Length of data isn't of integer type.") + result = self.readContents(length, "Data") + self.currentOffset += length + return Data(result) + + def readUid(self, length): + if not isinstance(length, (int, long)): + raise InvalidPlistException("Uid length isn't of integer type.") + return Uid(self.readInteger(length+1)) + + def getSizedInteger(self, data, byteSize, as_number=False): + """Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise.""" + result = 0 + if byteSize == 0: + raise InvalidPlistException("Encountered integer with byte size of 0.") + # 1, 2, and 4 byte integers are unsigned + elif byteSize == 1: + result = unpack('>B', data)[0] + elif byteSize == 2: + result = unpack('>H', data)[0] + elif byteSize == 4: + result = unpack('>L', data)[0] + elif byteSize == 8: + if as_number: + result = unpack('>q', data)[0] + else: + result = unpack('>Q', data)[0] + elif byteSize <= 16: + # Handle odd-sized or integers larger than 8 bytes + # Don't naively go over 16 bytes, in order to prevent infinite loops. + result = 0 + if hasattr(int, 'from_bytes'): + result = int.from_bytes(data, 'big') + else: + for byte in data: + if not isinstance(byte, int): # Python3.0-3.1.x return ints, 2.x return str + byte = unpack_from('>B', byte)[0] + result = (result << 8) | byte + else: + raise InvalidPlistException("Encountered integer longer than 16 bytes.") + return result + +class HashableWrapper(object): + def __init__(self, value): + self.value = value + def __repr__(self): + return "" % [self.value] + +class BoolWrapper(object): + def __init__(self, value): + self.value = value + def __repr__(self): + return "" % self.value + +class FloatWrapper(object): + _instances = {} + def __new__(klass, value): + # Ensure FloatWrapper(x) for a given float x is always the same object + wrapper = klass._instances.get(value) + if wrapper is None: + wrapper = object.__new__(klass) + wrapper.value = value + klass._instances[value] = wrapper + return wrapper + def __repr__(self): + return "" % self.value + +class StringWrapper(object): + __instances = {} + + encodedValue = None + encoding = None + + def __new__(cls, value): + '''Ensure we only have a only one instance for any string, + and that we encode ascii as 1-byte-per character when possible''' + + encodedValue = None + + for encoding in ('ascii', 'utf_16_be'): + try: + encodedValue = value.encode(encoding) + except: pass + if encodedValue is not None: + if encodedValue not in cls.__instances: + cls.__instances[encodedValue] = super(StringWrapper, cls).__new__(cls) + cls.__instances[encodedValue].encodedValue = encodedValue + cls.__instances[encodedValue].encoding = encoding + return cls.__instances[encodedValue] + + raise ValueError('Unable to get ascii or utf_16_be encoding for %s' % repr(value)) + + def __len__(self): + '''Return roughly the number of characters in this string (half the byte length)''' + if self.encoding == 'ascii': + return len(self.encodedValue) + else: + return len(self.encodedValue)//2 + + def __lt__(self, other): + return self.encodedValue < other.encodedValue + + @property + def encodingMarker(self): + if self.encoding == 'ascii': + return 0b0101 + else: + return 0b0110 + + def __repr__(self): + return '' % (self.encoding, self.encodedValue) + +class PlistWriter(object): + header = b'bplist00bybiplist1.0' + file = None + byteCounts = None + trailer = None + computedUniques = None + writtenReferences = None + referencePositions = None + wrappedTrue = None + wrappedFalse = None + # Used to detect recursive object references. + objectsStack = [] + + def __init__(self, file): + self.reset() + self.file = file + self.wrappedTrue = BoolWrapper(True) + self.wrappedFalse = BoolWrapper(False) + + def reset(self): + self.byteCounts = PlistByteCounts(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + self.trailer = PlistTrailer(0, 0, 0, 0, 0) + + # A set of all the uniques which have been computed. + self.computedUniques = set() + # A list of all the uniques which have been written. + self.writtenReferences = {} + # A dict of the positions of the written uniques. + self.referencePositions = {} + + self.objectsStack = [] + + def positionOfObjectReference(self, obj): + """If the given object has been written already, return its + position in the offset table. Otherwise, return None.""" + return self.writtenReferences.get(obj) + + def writeRoot(self, root): + """ + Strategy is: + - write header + - wrap root object so everything is hashable + - compute size of objects which will be written + - need to do this in order to know how large the object refs + will be in the list/dict/set reference lists + - write objects + - keep objects in writtenReferences + - keep positions of object references in referencePositions + - write object references with the length computed previously + - computer object reference length + - write object reference positions + - write trailer + """ + output = self.header + wrapped_root = self.wrapRoot(root) + self.computeOffsets(wrapped_root, asReference=True, isRoot=True) + self.trailer = self.trailer._replace(**{'objectRefSize':self.intSize(len(self.computedUniques))}) + self.writeObjectReference(wrapped_root, output) + output = self.writeObject(wrapped_root, output, setReferencePosition=True) + + # output size at this point is an upper bound on how big the + # object reference offsets need to be. + self.trailer = self.trailer._replace(**{ + 'offsetSize':self.intSize(len(output)), + 'offsetCount':len(self.computedUniques), + 'offsetTableOffset':len(output), + 'topLevelObjectNumber':0 + }) + + output = self.writeOffsetTable(output) + output += pack('!xxxxxxBBQQQ', *self.trailer) + self.file.write(output) + + def beginRecursionProtection(self, obj): + if not isinstance(obj, (set, dict, list, tuple)): + return + if id(obj) in self.objectsStack: + raise InvalidPlistException("Recursive containers are not allowed in plists.") + self.objectsStack.append(id(obj)) + + def endRecursionProtection(self, obj): + if not isinstance(obj, (set, dict, list, tuple)): + return + try: + index = self.objectsStack.index(id(obj)) + self.objectsStack = self.objectsStack[:index] + except ValueError as e: + pass + + def wrapRoot(self, root): + result = None + self.beginRecursionProtection(root) + + if isinstance(root, bool): + if root is True: + result = self.wrappedTrue + else: + result = self.wrappedFalse + elif isinstance(root, float): + result = FloatWrapper(root) + elif isinstance(root, set): + n = set() + for value in root: + n.add(self.wrapRoot(value)) + result = HashableWrapper(n) + elif isinstance(root, dict): + n = {} + for key, value in iteritems(root): + n[self.wrapRoot(key)] = self.wrapRoot(value) + result = HashableWrapper(n) + elif isinstance(root, list): + n = [] + for value in root: + n.append(self.wrapRoot(value)) + result = HashableWrapper(n) + elif isinstance(root, tuple): + n = tuple([self.wrapRoot(value) for value in root]) + result = HashableWrapper(n) + elif isinstance(root, (str, unicode)) and not isinstance(root, Data): + result = StringWrapper(root) + elif isinstance(root, bytes): + result = Data(root) + else: + result = root + + self.endRecursionProtection(root) + return result + + def incrementByteCount(self, field, incr=1): + self.byteCounts = self.byteCounts._replace(**{field:self.byteCounts.__getattribute__(field) + incr}) + + def computeOffsets(self, obj, asReference=False, isRoot=False): + def check_key(key): + if key is None: + raise InvalidPlistException('Dictionary keys cannot be null in plists.') + elif isinstance(key, Data): + raise InvalidPlistException('Data cannot be dictionary keys in plists.') + elif not isinstance(key, StringWrapper): + raise InvalidPlistException('Keys must be strings.') + + def proc_size(size): + if size > 0b1110: + size += self.intSize(size) + return size + # If this should be a reference, then we keep a record of it in the + # uniques table. + if asReference: + if obj in self.computedUniques: + return + else: + self.computedUniques.add(obj) + + if obj is None: + self.incrementByteCount('nullBytes') + elif isinstance(obj, BoolWrapper): + self.incrementByteCount('boolBytes') + elif isinstance(obj, Uid): + size = self.intSize(obj.integer) + self.incrementByteCount('uidBytes', incr=1+size) + elif isinstance(obj, (int, long)): + size = self.intSize(obj) + self.incrementByteCount('intBytes', incr=1+size) + elif isinstance(obj, FloatWrapper): + size = self.realSize(obj) + self.incrementByteCount('realBytes', incr=1+size) + elif isinstance(obj, datetime.datetime): + self.incrementByteCount('dateBytes', incr=2) + elif isinstance(obj, Data): + size = proc_size(len(obj)) + self.incrementByteCount('dataBytes', incr=1+size) + elif isinstance(obj, StringWrapper): + size = proc_size(len(obj)) + self.incrementByteCount('stringBytes', incr=1+size) + elif isinstance(obj, HashableWrapper): + obj = obj.value + if isinstance(obj, set): + size = proc_size(len(obj)) + self.incrementByteCount('setBytes', incr=1+size) + for value in obj: + self.computeOffsets(value, asReference=True) + elif isinstance(obj, (list, tuple)): + size = proc_size(len(obj)) + self.incrementByteCount('arrayBytes', incr=1+size) + for value in obj: + asRef = True + self.computeOffsets(value, asReference=True) + elif isinstance(obj, dict): + size = proc_size(len(obj)) + self.incrementByteCount('dictBytes', incr=1+size) + for key, value in iteritems(obj): + check_key(key) + self.computeOffsets(key, asReference=True) + self.computeOffsets(value, asReference=True) + else: + raise InvalidPlistException("Unknown object type: %s (%s)" % (type(obj).__name__, repr(obj))) + + def writeObjectReference(self, obj, output): + """Tries to write an object reference, adding it to the references + table. Does not write the actual object bytes or set the reference + position. Returns a tuple of whether the object was a new reference + (True if it was, False if it already was in the reference table) + and the new output. + """ + position = self.positionOfObjectReference(obj) + if position is None: + self.writtenReferences[obj] = len(self.writtenReferences) + output += self.binaryInt(len(self.writtenReferences) - 1, byteSize=self.trailer.objectRefSize) + return (True, output) + else: + output += self.binaryInt(position, byteSize=self.trailer.objectRefSize) + return (False, output) + + def writeObject(self, obj, output, setReferencePosition=False): + """Serializes the given object to the output. Returns output. + If setReferencePosition is True, will set the position the + object was written. + """ + def proc_variable_length(format, length): + result = b'' + if length > 0b1110: + result += pack('!B', (format << 4) | 0b1111) + result = self.writeObject(length, result) + else: + result += pack('!B', (format << 4) | length) + return result + + def timedelta_total_seconds(td): + # Shim for Python 2.6 compatibility, which doesn't have total_seconds. + # Make one argument a float to ensure the right calculation. + return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10.0**6) / 10.0**6 + + if setReferencePosition: + self.referencePositions[obj] = len(output) + + if obj is None: + output += pack('!B', 0b00000000) + elif isinstance(obj, BoolWrapper): + if obj.value is False: + output += pack('!B', 0b00001000) + else: + output += pack('!B', 0b00001001) + elif isinstance(obj, Uid): + size = self.intSize(obj.integer) + output += pack('!B', (0b1000 << 4) | size - 1) + output += self.binaryInt(obj.integer) + elif isinstance(obj, (int, long)): + byteSize = self.intSize(obj) + root = math.log(byteSize, 2) + output += pack('!B', (0b0001 << 4) | int(root)) + output += self.binaryInt(obj, as_number=True) + elif isinstance(obj, FloatWrapper): + # just use doubles + output += pack('!B', (0b0010 << 4) | 3) + output += self.binaryReal(obj) + elif isinstance(obj, datetime.datetime): + try: + timestamp = (obj - apple_reference_date).total_seconds() + except AttributeError: + timestamp = timedelta_total_seconds(obj - apple_reference_date) + output += pack('!B', 0b00110011) + output += pack('!d', float(timestamp)) + elif isinstance(obj, Data): + output += proc_variable_length(0b0100, len(obj)) + output += obj + elif isinstance(obj, StringWrapper): + output += proc_variable_length(obj.encodingMarker, len(obj)) + output += obj.encodedValue + elif isinstance(obj, bytes): + output += proc_variable_length(0b0101, len(obj)) + output += obj + elif isinstance(obj, HashableWrapper): + obj = obj.value + if isinstance(obj, (set, list, tuple)): + if isinstance(obj, set): + output += proc_variable_length(0b1100, len(obj)) + else: + output += proc_variable_length(0b1010, len(obj)) + + objectsToWrite = [] + for objRef in sorted(obj) if isinstance(obj, set) else obj: + (isNew, output) = self.writeObjectReference(objRef, output) + if isNew: + objectsToWrite.append(objRef) + for objRef in objectsToWrite: + output = self.writeObject(objRef, output, setReferencePosition=True) + elif isinstance(obj, dict): + output += proc_variable_length(0b1101, len(obj)) + keys = [] + values = [] + objectsToWrite = [] + for key, value in sorted(iteritems(obj)): + keys.append(key) + values.append(value) + for key in keys: + (isNew, output) = self.writeObjectReference(key, output) + if isNew: + objectsToWrite.append(key) + for value in values: + (isNew, output) = self.writeObjectReference(value, output) + if isNew: + objectsToWrite.append(value) + for objRef in objectsToWrite: + output = self.writeObject(objRef, output, setReferencePosition=True) + return output + + def writeOffsetTable(self, output): + """Writes all of the object reference offsets.""" + all_positions = [] + writtenReferences = list(self.writtenReferences.items()) + writtenReferences.sort(key=lambda x: x[1]) + for obj,order in writtenReferences: + # Porting note: Elsewhere we deliberately replace empty unicdoe strings + # with empty binary strings, but the empty unicode string + # goes into writtenReferences. This isn't an issue in Py2 + # because u'' and b'' have the same hash; but it is in + # Py3, where they don't. + if bytes != str and obj == unicodeEmpty: + obj = b'' + position = self.referencePositions.get(obj) + if position is None: + raise InvalidPlistException("Error while writing offsets table. Object not found. %s" % obj) + output += self.binaryInt(position, self.trailer.offsetSize) + all_positions.append(position) + return output + + def binaryReal(self, obj): + # just use doubles + result = pack('>d', obj.value) + return result + + def binaryInt(self, obj, byteSize=None, as_number=False): + result = b'' + if byteSize is None: + byteSize = self.intSize(obj) + if byteSize == 1: + result += pack('>B', obj) + elif byteSize == 2: + result += pack('>H', obj) + elif byteSize == 4: + result += pack('>L', obj) + elif byteSize == 8: + if as_number: + result += pack('>q', obj) + else: + result += pack('>Q', obj) + elif byteSize <= 16: + try: + result = pack('>Q', 0) + pack('>Q', obj) + except struct_error as e: + raise InvalidPlistException("Unable to pack integer %d: %s" % (obj, e)) + else: + raise InvalidPlistException("Core Foundation can't handle integers with size greater than 16 bytes.") + return result + + def intSize(self, obj): + """Returns the number of bytes necessary to store the given integer.""" + # SIGNED + if obj < 0: # Signed integer, always 8 bytes + return 8 + # UNSIGNED + elif obj <= 0xFF: # 1 byte + return 1 + elif obj <= 0xFFFF: # 2 bytes + return 2 + elif obj <= 0xFFFFFFFF: # 4 bytes + return 4 + # SIGNED + # 0x7FFFFFFFFFFFFFFF is the max. + elif obj <= 0x7FFFFFFFFFFFFFFF: # 8 bytes signed + return 8 + elif obj <= 0xffffffffffffffff: # 8 bytes unsigned + return 16 + else: + raise InvalidPlistException("Core Foundation can't handle integers with size greater than 8 bytes.") + + def realSize(self, obj): + return 8 diff --git a/src/3rdparty/python/lib/python2.7/site-packages/biplist/qt_attribution.json b/src/3rdparty/python/lib/python2.7/site-packages/biplist/qt_attribution.json new file mode 100644 index 00000000..266e9dd8 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/biplist/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "biplist", + "Name": "biplist", + "QDocModule": "qbs", + "QtUsage": "Used in the qbs dmg module for building Apple disk images.", + "Description": "biplist is a library for reading/writing binary plists.", + "Homepage": "https://bitbucket.org/wooster/biplist", + "Version": "1.0.2", + "License": "BSD 3-clause \"New\" or \"Revised\" License", + "LicenseId": "BSD-3-Clause", + "LicenseFile": "LICENSE", + "Copyright": "Copyright (c) 2010, Andrew Wooster" +} diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/LICENSE b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/LICENSE new file mode 100644 index 00000000..e91f4eb3 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/__init__.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/__init__.py new file mode 100644 index 00000000..e7f985c3 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/__init__.py @@ -0,0 +1,3 @@ +from .core import build_dmg + +__all__ = ['dmgbuild'] diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/badge.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/badge.py new file mode 100644 index 00000000..159a5370 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/badge.py @@ -0,0 +1,143 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from Quartz import * +import math + +_REMOVABLE_DISK_PATH = '/System/Library/Extensions/IOStorageFamily.kext/Contents/Resources/Removable.icns' + +def badge_disk_icon(badge_file, output_file): + # Load the Removable disk icon + url = CFURLCreateWithFileSystemPath(None, _REMOVABLE_DISK_PATH, + kCFURLPOSIXPathStyle, False) + backdrop = CGImageSourceCreateWithURL(url, None) + backdropCount = CGImageSourceGetCount(backdrop) + + # Load the badge + url = CFURLCreateWithFileSystemPath(None, badge_file, + kCFURLPOSIXPathStyle, False) + badge = CGImageSourceCreateWithURL(url, None) + assert badge is not None, 'Unable to process image file: %s' % badge_file + badgeCount = CGImageSourceGetCount(badge) + + # Set up a destination for our target + url = CFURLCreateWithFileSystemPath(None, output_file, + kCFURLPOSIXPathStyle, False) + target = CGImageDestinationCreateWithURL(url, 'com.apple.icns', + backdropCount, None) + + # Get the RGB colorspace + rgbColorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) + + # Scale + scale = 1.0 + + # Perspective transform + corners = ((0.2, 0.95), (0.8, 0.95), (0.85, 0.35), (0.15, 0.35)) + + # Translation + position = (0.5, 0.5) + + for n in range(backdropCount): + props = CGImageSourceCopyPropertiesAtIndex(backdrop, n, None) + width = props['PixelWidth'] + height = props['PixelHeight'] + dpi = props['DPIWidth'] + depth = props['Depth'] + + # Choose the best sized badge image + bestWidth = None + bestHeight = None + bestBadge = None + bestDepth = None + bestDPI = None + for m in range(badgeCount): + badgeProps = CGImageSourceCopyPropertiesAtIndex(badge, m, None) + badgeWidth = badgeProps['PixelWidth'] + badgeHeight = badgeProps['PixelHeight'] + badgeDPI = badgeProps['DPIWidth'] + badgeDepth = badgeProps['Depth'] + + if bestBadge is None or (badgeWidth <= width + and (bestWidth > width + or badgeWidth > bestWidth + or (badgeWidth == bestWidth + and badgeDPI == dpi + and badgeDepth <= depth + and (bestDepth is None + or badgeDepth > bestDepth)))): + bestBadge = m + bestWidth = badgeWidth + bestHeight = badgeHeight + bestDPI = badgeDPI + bestDepth = badgeDepth + + badgeImage = CGImageSourceCreateImageAtIndex(badge, bestBadge, None) + badgeCI = CIImage.imageWithCGImage_(badgeImage) + + backgroundImage = CGImageSourceCreateImageAtIndex(backdrop, n, None) + backgroundCI = CIImage.imageWithCGImage_(backgroundImage) + + compositor = CIFilter.filterWithName_('CISourceOverCompositing') + lanczos = CIFilter.filterWithName_('CILanczosScaleTransform') + perspective = CIFilter.filterWithName_('CIPerspectiveTransform') + transform = CIFilter.filterWithName_('CIAffineTransform') + + lanczos.setValue_forKey_(badgeCI, kCIInputImageKey) + lanczos.setValue_forKey_(scale * float(width)/bestWidth, kCIInputScaleKey) + lanczos.setValue_forKey_(1.0, kCIInputAspectRatioKey) + + topLeft = (width * scale * corners[0][0], + width * scale * corners[0][1]) + topRight = (width * scale * corners[1][0], + width * scale * corners[1][1]) + bottomRight = (width * scale * corners[2][0], + width * scale * corners[2][1]) + bottomLeft = (width * scale * corners[3][0], + width * scale * corners[3][1]) + + out = lanczos.valueForKey_(kCIOutputImageKey) + if width >= 16: + perspective.setValue_forKey_(out, kCIInputImageKey) + perspective.setValue_forKey_(CIVector.vectorWithX_Y_(*topLeft), + 'inputTopLeft') + perspective.setValue_forKey_(CIVector.vectorWithX_Y_(*topRight), + 'inputTopRight') + perspective.setValue_forKey_(CIVector.vectorWithX_Y_(*bottomRight), + 'inputBottomRight') + perspective.setValue_forKey_(CIVector.vectorWithX_Y_(*bottomLeft), + 'inputBottomLeft') + out = perspective.valueForKey_(kCIOutputImageKey) + + tfm = NSAffineTransform.transform() + tfm.translateXBy_yBy_(math.floor((position[0] - 0.5 * scale) * width), + math.floor((position[1] - 0.5 * scale) * height)) + + transform.setValue_forKey_(out, kCIInputImageKey) + transform.setValue_forKey_(tfm, 'inputTransform') + out = transform.valueForKey_(kCIOutputImageKey) + + compositor.setValue_forKey_(out, kCIInputImageKey) + compositor.setValue_forKey_(backgroundCI, kCIInputBackgroundImageKey) + + result = compositor.valueForKey_(kCIOutputImageKey) + + cgContext = CGBitmapContextCreate(None, + width, + height, + 8, + 0, + rgbColorSpace, + kCGImageAlphaPremultipliedLast) + context = CIContext.contextWithCGContext_options_(cgContext, None) + + context.drawImage_inRect_fromRect_(result, + ((0, 0), (width, height)), + ((0, 0), (width, height))) + + image = CGBitmapContextCreateImage(cgContext) + + CGImageDestinationAddImage(target, image, props) + + CGImageDestinationFinalize(target) + diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/colors.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/colors.py new file mode 100644 index 00000000..891e5d53 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/colors.py @@ -0,0 +1,498 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import re +import math + +class Color (object): + def to_rgb(self): + raise Exception('Must implement to_rgb() in subclasses') + +class RGB (Color): + def __init__(self, r, g, b): + self.r = r + self.g = g + self.b = b + + def to_rgb(self): + return self + +class HSL (Color): + def __init__(self, h, s, l): + self.h = h + self.s = s + self.l = l + + @staticmethod + def _hue_to_rgb(t1, t2, hue): + if hue < 0: + hue += 6 + elif hue >= 6: + hue -= 6 + + if hue < 1: + return (t2 - t1) * hue + t1 + elif hue < 3: + return t2 + elif hue < 4: + return (t2 - t1) * (4 - hue) + t1 + else: + return t1 + + def to_rgb(self): + hue = self.h / 60.0 + if self.l <= 0.5: + t2 = self.l * (self.s + 1) + else: + t2 = self.l + self.s - (self.l * self.s) + t1 = self.l * 2 - t2 + r = self._hue_to_rgb(t1, t2, hue + 2) + g = self._hue_to_rgb(t1, t2, hue) + b = self._hue_to_rgb(t1, t2, hue - 2) + return RGB(r, g, b) + +class HWB (Color): + def __init__(self, h, w, b): + self.h = h + self.w = w + self.b = b + + @staticmethod + def _hue_to_rgb(hue): + if hue < 0: + hue += 6 + elif hue >= 6: + hue -= 6 + + if hue < 1: + return hue + elif hue < 3: + return 1 + elif hue < 4: + return (4 - hue) + else: + return 0 + + def to_rgb(self): + hue = self.h / 60.0 + t1 = 1 - self.w - self.b + r = self._hue_to_rgb(hue + 2) * t1 + self.w + g = self._hue_to_rgb(hue) * t1 + self.w + b = self._hue_to_rgb(hue - 2) * t1 + self.w + return RGB(r, g, b) + +class CMYK (Color): + def __init__(self, c, m, y, k): + self.c = c + self.m = m + self.y = y + self.k = k + + def to_rgb(self): + r = 1.0 - min(1.0, self.c + self.k) + g = 1.0 - min(1.0, self.m + self.k) + b = 1.0 - min(1.0, self.y + self.k) + return RGB(r, g, b) + +class Gray (Color): + def __init__(self, g): + self.g = g + + def to_rgb(self): + return RGB(g, g, g) + +_x11_colors = { + 'aliceblue': (240, 248, 255), + 'antiquewhite': (250, 235, 215), + 'aqua': ( 0, 255, 255), + 'aquamarine': (127, 255, 212), + 'azure': (240, 255, 255), + 'beige': (245, 245, 220), + 'bisque': (255, 228, 196), + 'black': ( 0, 0, 0), + 'blanchedalmond': (255, 235, 205), + 'blue': ( 0, 0, 255), + 'blueviolet': (138, 43, 226), + 'brown': (165, 42, 42), + 'burlywood': (222, 184, 135), + 'cadetblue': ( 95, 158, 160), + 'chartreuse': (127, 255, 0), + 'chocolate': (210, 105, 30), + 'coral': (255, 127, 80), + 'cornflowerblue': (100, 149, 237), + 'cornsilk': (255, 248, 220), + 'crimson': (220, 20, 60), + 'cyan': ( 0, 255, 255), + 'darkblue': ( 0, 0, 139), + 'darkcyan': ( 0, 139, 139), + 'darkgoldenrod': (184, 134, 11), + 'darkgray': (169, 169, 169), + 'darkgreen': ( 0, 100, 0), + 'darkgrey': (169, 169, 169), + 'darkkhaki': (189, 183, 107), + 'darkmagenta': (139, 0, 139), + 'darkolivegreen': ( 85, 107, 47), + 'darkorange': (255, 140, 0), + 'darkorchid': (153, 50, 204), + 'darkred': (139, 0, 0), + 'darksalmon': (233, 150, 122), + 'darkseagreen': (143, 188, 143), + 'darkslateblue': ( 72, 61, 139), + 'darkslategray': ( 47, 79, 79), + 'darkslategrey': ( 47, 79, 79), + 'darkturquoise': ( 0, 206, 209), + 'darkviolet': (148, 0, 211), + 'deeppink': (255, 20, 147), + 'deepskyblue': ( 0, 191, 255), + 'dimgray': (105, 105, 105), + 'dimgrey': (105, 105, 105), + 'dodgerblue': ( 30, 144, 255), + 'firebrick': (178, 34, 34), + 'floralwhite': (255, 250, 240), + 'forestgreen': ( 34, 139, 34), + 'fuchsia': (255, 0, 255), + 'gainsboro': (220, 220, 220), + 'ghostwhite': (248, 248, 255), + 'gold': (255, 215, 0), + 'goldenrod': (218, 165, 32), + 'gray': (128, 128, 128), + 'grey': (128, 128, 128), + 'green': ( 0, 128, 0), + 'greenyellow': (173, 255, 47), + 'honeydew': (240, 255, 240), + 'hotpink': (255, 105, 180), + 'indianred': (205, 92, 92), + 'indigo': ( 75, 0, 130), + 'ivory': (255, 255, 240), + 'khaki': (240, 230, 140), + 'lavender': (230, 230, 250), + 'lavenderblush': (255, 240, 245), + 'lawngreen': (124, 252, 0), + 'lemonchiffon': (255, 250, 205), + 'lightblue': (173, 216, 230), + 'lightcoral': (240, 128, 128), + 'lightcyan': (224, 255, 255), + 'lightgoldenrodyellow': (250, 250, 210), + 'lightgray': (211, 211, 211), + 'lightgreen': (144, 238, 144), + 'lightgrey': (211, 211, 211), + 'lightpink': (255, 182, 193), + 'lightsalmon': (255, 160, 122), + 'lightseagreen': ( 32, 178, 170), + 'lightskyblue': (135, 206, 250), + 'lightslategray': (119, 136, 153), + 'lightslategrey': (119, 136, 153), + 'lightsteelblue': (176, 196, 222), + 'lightyellow': (255, 255, 224), + 'lime': ( 0, 255, 0), + 'limegreen': ( 50, 205, 50), + 'linen': (250, 240, 230), + 'magenta': (255, 0, 255), + 'maroon': (128, 0, 0), + 'mediumaquamarine': (102, 205, 170), + 'mediumblue': ( 0, 0, 205), + 'mediumorchid': (186, 85, 211), + 'mediumpurple': (147, 112, 219), + 'mediumseagreen': ( 60, 179, 113), + 'mediumslateblue': (123, 104, 238), + 'mediumspringgreen': ( 0, 250, 154), + 'mediumturquoise': ( 72, 209, 204), + 'mediumvioletred': (199, 21, 133), + 'midnightblue': ( 25, 25, 112), + 'mintcream': (245, 255, 250), + 'mistyrose': (255, 228, 225), + 'moccasin': (255, 228, 181), + 'navajowhite': (255, 222, 173), + 'navy': ( 0, 0, 128), + 'oldlace': (253, 245, 230), + 'olive': (128, 128, 0), + 'olivedrab': (107, 142, 35), + 'orange': (255, 165, 0), + 'orangered': (255, 69, 0), + 'orchid': (218, 112, 214), + 'palegoldenrod': (238, 232, 170), + 'palegreen': (152, 251, 152), + 'paleturquoise': (175, 238, 238), + 'palevioletred': (219, 112, 147), + 'papayawhip': (255, 239, 213), + 'peachpuff': (255, 218, 185), + 'peru': (205, 133, 63), + 'pink': (255, 192, 203), + 'plum': (221, 160, 221), + 'powderblue': (176, 224, 230), + 'purple': (128, 0, 128), + 'red': (255, 0, 0), + 'rosybrown': (188, 143, 143), + 'royalblue': ( 65, 105, 225), + 'saddlebrown': (139, 69, 19), + 'salmon': (250, 128, 114), + 'sandybrown': (244, 164, 96), + 'seagreen': ( 46, 139, 87), + 'seashell': (255, 245, 238), + 'sienna': (160, 82, 45), + 'silver': (192, 192, 192), + 'skyblue': (135, 206, 235), + 'slateblue': (106, 90, 205), + 'slategray': (112, 128, 144), + 'slategrey': (112, 128, 144), + 'snow': (255, 250, 250), + 'springgreen': ( 0, 255, 127), + 'steelblue': ( 70, 130, 180), + 'tan': (210, 180, 140), + 'teal': ( 0, 128, 128), + 'thistle': (216, 191, 216), + 'tomato': (255, 99, 71), + 'turquoise': ( 64, 224, 208), + 'violet': (238, 130, 238), + 'wheat': (245, 222, 179), + 'white': (255, 255, 255), + 'whitesmoke': (245, 245, 245), + 'yellow': (255, 255, 0), + 'yellowgreen': (154, 205, 50) + } + +_ws_re = re.compile(r'\s+') +_token_re = re.compile(r'[A-Za-z_][A-Za-z0-9_]*') +_hex_re = re.compile(r'#([0-9a-f]{3}(?:[0-9a-f]{3})?)$') +_number_re = re.compile(r'[0-9]*(\.[0-9]*)') + + +class ColorParser (object): + def __init__(self, s): + self._string = s + self._pos = 0 + + def skipws(self): + m = _ws_re.match(self._string, self._pos) + if m: + self._pos = m.end(0) + + def expect(self, s, context=''): + if len(self._string) - self._pos < len(s) \ + or self._string[self._pos:self._pos + len(s)] != s: + raise ValueError('bad color "%s" - expected "%s"%s' + % (self._string, s, context)) + self._pos += len(s) + + def expectEnd(self): + if self._pos != len(self._string): + raise ValueError('junk at end of color "%s"' % self._string) + + def getToken(self): + m = _token_re.match(self._string, self._pos) + if m: + token = m.group(0) + + self._pos = m.end(0) + return token + return None + + def parseNumber(self, context=''): + m = _number_re.match(self._string, self._pos) + if m: + self._pos = m.end(0) + return float(m.group(0)) + raise ValueError('bad color "%s" - expected a number%s' + % (self._string, context)) + + def parseColor(self): + self.skipws() + + token = self.getToken() + if token: + if token == 'rgb': + return self.parseRGB() + elif token == 'hsl': + return self.parseHSL() + elif token == 'hwb': + return self.parseHWB() + elif token == 'cmyk': + return self.parseCMYK() + elif token == 'gray' or token == 'grey': + return self.parseGray() + + try: + r, g, b = _x11_colors[token] + except KeyError: + raise ValueError('unknown color name "%s"' % token) + + self.expectEnd() + + return RGB(r / 255.0, g / 255.0, b / 255.0) + + m = _hex_re.match(self._string, self._pos) + if m: + hrgb = m.group(1) + + if len(hrgb) == 3: + r = int('0x' + 2 * hrgb[0], 16) + g = int('0x' + 2 * hrgb[1], 16) + b = int('0x' + 2 * hrgb[2], 16) + else: + r = int('0x' + hrgb[0:2], 16) + g = int('0x' + hrgb[2:4], 16) + b = int('0x' + hrgb[4:6], 16) + + self._pos = m.end(0) + self.skipws() + + self.expectEnd() + + return RGB(r / 255.0, g / 255.0, b / 255.0) + + raise ValueError('bad color syntax "%s"' % self._string) + + def parseRGB(self): + self.expect('(', 'after "rgb"') + self.skipws() + + r = self.parseValue() + + self.skipws() + self.expect(',', 'in "rgb"') + self.skipws() + + g = self.parseValue() + + self.skipws() + self.expect(',', 'in "rgb"') + self.skipws() + + b = self.parseValue() + + self.skipws() + self.expect(')', 'at end of "rgb"') + + self.skipws() + self.expectEnd() + + return RGB(r, g, b) + + def parseHSL(self): + self.expect('(', 'after "hsl"') + self.skipws() + + h = self.parseAngle() + + self.skipws() + self.expect(',', 'in "hsl"') + self.skipws() + + s = self.parseValue() + + self.skipws() + self.expect(',', 'in "hsl"') + self.skipws() + + l = self.parseValue() + + self.skipws() + self.expect(')', 'at end of "hsl"') + + self.skipws() + self.expectEnd() + + return HSL(h, s, l) + + def parseHWB(self): + self.expect('(', 'after "hwb"') + self.skipws() + + h = self.parseAngle() + + self.skipws() + self.expect(',', 'in "hwb"') + self.skipws() + + w = self.parseValue() + + self.skipws() + self.expect(',', 'in "hwb"') + self.skipws() + + b = self.parseValue() + + self.skipws() + self.expect(')', 'at end of "hwb"') + + self.skipws() + self.expectEnd() + + return HWB(h, w, b) + + def parseCMYK(self): + self.expect('(', 'after "cmyk"') + self.skipws() + + c = self.parseValue() + + self.skipws() + self.expect(',', 'in "cmyk"') + self.skipws() + + m = self.parseValue() + + self.skipws() + self.expect(',', 'in "cmyk"') + self.skipws() + + y = self.parseValue() + + self.skipws() + self.expect(',', 'in "cmyk"') + self.skipws() + + k = self.parseValue() + + self.skipws() + self.expect(')', 'at end of "cmyk"') + + self.skipws() + self.expectEnd() + + return CMYK(c, m, y, k) + + def parseGray(self): + self.expect('(', 'after "gray"') + self.skipws() + + g = self.parseValue() + + self.skipws() + self.expect(')', 'at end of "gray') + + self.skipws() + self.expectEnd() + + return Gray(g) + + def parseValue(self): + n = self.parseNumber() + self.skipws() + if self._string[self._pos] == '%': + n = n / 100.0 + self.pos += 1 + return n + + def parseAngle(self): + n = self.parseNumber() + self.skipws() + tok = self.getToken() + if tok == 'rad': + n = n * 180.0 / math.pi + elif tok == 'grad' or tok == 'gon': + n = n * 0.9 + elif tok != 'deg': + raise ValueError('bad angle unit "%s"' % tok) + return n + +_color_re = re.compile(r'\s*(#|rgb|hsl|hwb|cmyk|gray|grey|%s)' + % '|'.join(_x11_colors.keys())) + + +def isAColor(s): + return _color_re.match(s) + + +def parseColor(s): + return ColorParser(s).parseColor() diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/core.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/core.py new file mode 100644 index 00000000..d94a06c1 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/core.py @@ -0,0 +1,655 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import os +import pkg_resources +import platform +import re +import shutil +import stat +import subprocess +import sys +import tempfile +import tokenize +import json +import time + +try: + {}.iteritems + iteritems = lambda x: x.iteritems() + iterkeys = lambda x: x.iterkeys() +except AttributeError: + iteritems = lambda x: x.items() + iterkeys = lambda x: x.keys() +try: + unicode +except NameError: + unicode = str + +if sys.version_info < (3, 4): + import biplist + def plist_from_bytes(data): + return biplist.readPlistFromString(data) + def plist_bytes(data): + return biplist.Data(data) +else: + import plistlib + def plist_from_bytes(data): + return plistlib.loads(data) + def plist_bytes(data): + return data + +from mac_alias import * +from ds_store import * + +from . import colors +from . import licensing + +try: + from . import badge +except ImportError: + badge = None + +_hexcolor_re = re.compile(r'#[0-9a-f]{3}(?:[0-9a-f]{3})?') + +# The first element in the platform.mac_ver() tuple is a string containing the +# macOS version (e.g., '10.15.6'). Parse into an integer tuple. +MACOS_VERSION = tuple(int(v) for v in platform.mac_ver()[0].split('.')) + +class DMGError(Exception): + pass + +def hdiutil(cmd, *args, **kwargs): + plist = kwargs.get('plist', True) + all_args = ['/usr/bin/hdiutil', cmd] + all_args.extend(args) + if plist: + all_args.append('-plist') + p = subprocess.Popen(all_args, stdout=subprocess.PIPE, close_fds=True) + output, errors = p.communicate() + if plist: + results = plist_from_bytes(output) + else: + results = output + retcode = p.wait() + return retcode, results + +# On Python 2 we can just execfile() it, but Python 3 deprecated that +def load_settings(filename, settings): + if sys.version_info[0] == 2: + execfile(filename, settings, settings) + else: + encoding = 'utf-8' + with open(filename, 'rb') as fp: + try: + encoding = tokenize.detect_encoding(fp.readline)[0] + except SyntaxError: + pass + + with open(filename, 'r', encoding=encoding) as fp: + exec(compile(fp.read(), filename, 'exec'), settings, settings) + +def load_json(filename, settings): + """Read an appdmg .json spec. Uses the defaults for appdmg, rather than + the usual defaults for dmgbuild. """ + + with open(filename, 'r') as fp: + json_data = json.load(fp) + + if 'title' not in json_data: + raise ValueError('missing \'title\' in JSON settings file') + if 'contents' not in json_data: + raise ValueError('missing \'contents\' in JSON settings file') + + settings['volume_name'] = json_data['title'] + settings['icon'] = json_data.get('icon', None) + settings['badge_icon'] = json_data.get('badge-icon', None) + bk = json_data.get('background', None) + if bk is None: + bk = json_data.get('background-color', None) + if bk is not None: + settings['background'] = bk + settings['icon_size'] = json_data.get('icon-size', 80) + wnd = json_data.get('window', { 'position': (100, 100), + 'size': (640, 480) }) + pos = wnd.get('position', { 'x': 100, 'y': 100 }) + siz = wnd.get('size', { 'width': 640, 'height': 480 }) + settings['window_rect'] = ((pos.get('x', 100), pos.get('y', 100)), + (siz.get('width', 640), siz.get('height', 480))) + settings['format'] = json_data.get('format', 'UDZO') + settings['compression_level'] = json_data.get('compression-level', None) + settings['license'] = json_data.get('license', None) + files = [] + hide = [] + hide_extensions = [] + symlinks = {} + icon_locations = {} + for fileinfo in json_data.get('contents', []): + if 'path' not in fileinfo: + raise ValueError('missing \'path\' in contents in JSON settings file') + if 'x' not in fileinfo: + raise ValueError('missing \'x\' in contents in JSON settings file') + if 'y' not in fileinfo: + raise ValueError('missing \'y\' in contents in JSON settings file') + + kind = fileinfo.get('type', 'file') + path = fileinfo['path'] + name = fileinfo.get('name', os.path.basename(path.rstrip('/'))) + if kind == 'file': + files.append((path, name)) + elif kind == 'link': + symlinks[name] = path + elif kind == 'position': + pass + icon_locations[name] = (fileinfo['x'], fileinfo['y']) + hide_ext = fileinfo.get('hide_extension', False) + if hide_ext: + hide_extensions.append(name) + hidden = fileinfo.get('hidden', False) + if hidden: + hide.append(name) + + settings['files'] = files + settings['hide_extensions'] = hide_extensions + settings['hide'] = hide + settings['symlinks'] = symlinks + settings['icon_locations'] = icon_locations + +def build_dmg(filename, volume_name, settings_file=None, settings={}, + defines={}, lookForHiDPI=True, detach_retries=5): + options = { + # Default settings + 'filename': filename, + 'volume_name': volume_name, + 'format': 'UDBZ', + 'compression_level': None, + 'size': None, + 'files': [], + 'symlinks': {}, + 'hide': [], + 'hide_extensions': [], + 'icon': None, + 'badge_icon': None, + 'background': None, + 'show_status_bar': False, + 'show_tab_view': False, + 'show_toolbar': False, + 'show_pathbar': False, + 'show_sidebar': False, + 'sidebar_width': 180, + 'arrange_by': None, + 'grid_offset': (0, 0), + 'grid_spacing': 100.0, + 'scroll_position': (0.0, 0.0), + 'show_icon_preview': False, + 'show_item_info': False, + 'label_pos': 'bottom', + 'text_size': 16.0, + 'icon_size': 128.0, + 'include_icon_view_settings': 'auto', + 'include_list_view_settings': 'auto', + 'list_icon_size': 16.0, + 'list_text_size': 12.0, + 'list_scroll_position': (0, 0), + 'list_sort_by': 'name', + 'list_use_relative_dates': True, + 'list_calculate_all_sizes': False, + 'list_columns': ('name', 'date-modified', 'size', 'kind', 'date-added'), + 'list_column_widths': { + 'name': 300, + 'date-modified': 181, + 'date-created': 181, + 'date-added': 181, + 'date-last-opened': 181, + 'size': 97, + 'kind': 115, + 'label': 100, + 'version': 75, + 'comments': 300, + }, + 'list_column_sort_directions': { + 'name': 'ascending', + 'date-modified': 'descending', + 'date-created': 'descending', + 'date-added': 'descending', + 'date-last-opened': 'descending', + 'size': 'descending', + 'kind': 'ascending', + 'label': 'ascending', + 'version': 'ascending', + 'comments': 'ascending', + }, + 'window_rect': ((100, 100), (640, 280)), + 'default_view': 'icon-view', + 'icon_locations': {}, + 'license': None, + 'defines': defines + } + + # Execute the settings file + if settings_file: + # We now support JSON settings files using appdmg's format + if settings_file.endswith('.json'): + load_json(settings_file, options) + else: + load_settings(settings_file, options) + + # Add any overrides + options.update(settings) + + # Set up the finder data + bounds = options['window_rect'] + + bounds_string = '{{%s, %s}, {%s, %s}}' % (bounds[0][0], + bounds[0][1], + bounds[1][0], + bounds[1][1]) + bwsp = { + 'ShowStatusBar': options['show_status_bar'], + 'WindowBounds': bounds_string, + 'ContainerShowSidebar': False, + 'PreviewPaneVisibility': False, + 'SidebarWidth': options['sidebar_width'], + 'ShowTabView': options['show_tab_view'], + 'ShowToolbar': options['show_toolbar'], + 'ShowPathbar': options['show_pathbar'], + 'ShowSidebar': options['show_sidebar'] + } + + arrange_options = { + 'name': 'name', + 'date-modified': 'dateModified', + 'date-created': 'dateCreated', + 'date-added': 'dateAdded', + 'date-last-opened': 'dateLastOpened', + 'size': 'size', + 'kind': 'kind', + 'label': 'label', + } + + icvp = { + 'viewOptionsVersion': 1, + 'backgroundType': 0, + 'backgroundColorRed': 1.0, + 'backgroundColorGreen': 1.0, + 'backgroundColorBlue': 1.0, + 'gridOffsetX': float(options['grid_offset'][0]), + 'gridOffsetY': float(options['grid_offset'][1]), + 'gridSpacing': float(options['grid_spacing']), + 'arrangeBy': str(arrange_options.get(options['arrange_by'], 'none')), + 'showIconPreview': options['show_icon_preview'] == True, + 'showItemInfo': options['show_item_info'] == True, + 'labelOnBottom': options['label_pos'] == 'bottom', + 'textSize': float(options['text_size']), + 'iconSize': float(options['icon_size']), + 'scrollPositionX': float(options['scroll_position'][0]), + 'scrollPositionY': float(options['scroll_position'][1]) + } + + background = options['background'] + + columns = { + 'name': 'name', + 'date-modified': 'dateModified', + 'date-created': 'dateCreated', + 'date-added': 'dateAdded', + 'date-last-opened': 'dateLastOpened', + 'size': 'size', + 'kind': 'kind', + 'label': 'label', + 'version': 'version', + 'comments': 'comments' + } + + default_widths = { + 'name': 300, + 'date-modified': 181, + 'date-created': 181, + 'date-added': 181, + 'date-last-opened': 181, + 'size': 97, + 'kind': 115, + 'label': 100, + 'version': 75, + 'comments': 300, + } + + default_sort_directions = { + 'name': 'ascending', + 'date-modified': 'descending', + 'date-created': 'descending', + 'date-added': 'descending', + 'date-last-opened': 'descending', + 'size': 'descending', + 'kind': 'ascending', + 'label': 'ascending', + 'version': 'ascending', + 'comments': 'ascending', + } + + lsvp = { + 'viewOptionsVersion': 1, + 'sortColumn': columns.get(options['list_sort_by'], 'name'), + 'textSize': float(options['list_text_size']), + 'iconSize': float(options['list_icon_size']), + 'showIconPreview': options['show_icon_preview'], + 'scrollPositionX': options['list_scroll_position'][0], + 'scrollPositionY': options['list_scroll_position'][1], + 'useRelativeDates': options['list_use_relative_dates'], + 'calculateAllSizes': options['list_calculate_all_sizes'], + } + + lsvp['columns'] = {} + cndx = {} + + for n, column in enumerate(options['list_columns']): + cndx[column] = n + width = options['list_column_widths'].get(column, + default_widths[column]) + asc = 'ascending' == options['list_column_sort_directions'].get(column, + default_sort_directions[column]) + + lsvp['columns'][columns[column]] = { + 'index': n, + 'width': width, + 'identifier': columns[column], + 'visible': True, + 'ascending': asc + } + + n = len(options['list_columns']) + for k in iterkeys(columns): + if cndx.get(k, None) is None: + cndx[k] = n + width = default_widths[k] + asc = 'ascending' == default_sort_directions[k] + + lsvp['columns'][columns[column]] = { + 'index': n, + 'width': width, + 'identifier': columns[column], + 'visible': False, + 'ascending': asc + } + + n += 1 + + default_view = options['default_view'] + views = { + 'icon-view': b'icnv', + 'column-view': b'clmv', + 'list-view': b'Nlsv', + 'coverflow': b'Flwv' + } + + icvl = (b'type', views.get(default_view, 'icnv')) + + include_icon_view_settings = default_view == 'icon-view' \ + or options['include_icon_view_settings'] not in \ + ('auto', 'no', 0, False, None) + include_list_view_settings = default_view in ('list-view', 'coverflow') \ + or options['include_list_view_settings'] not in \ + ('auto', 'no', 0, False, None) + + filename = options['filename'] + volume_name = options['volume_name'] + + # Construct a writeable image to start with + dirname, basename = os.path.split(os.path.realpath(filename)) + if not basename.endswith('.dmg'): + basename += '.dmg' + writableFile = tempfile.NamedTemporaryFile(dir=dirname, prefix='.temp', + suffix=basename) + + total_size = options['size'] + if total_size == None: + # Start with a size of 128MB - this way we don't need to calculate the + # size of the background image, volume icon, and .DS_Store file (and + # 128 MB should be well sufficient for even the most outlandish image + # sizes, like an uncompressed 5K multi-resolution TIFF) + total_size = 128 * 1024 * 1024 + + def roundup(x, n): + return x if x % n == 0 else x + n - x % n + + for path in options['files']: + if isinstance(path, tuple): + path = path[0] + + if not os.path.islink(path) and os.path.isdir(path): + for dirpath, dirnames, filenames in os.walk(path): + for f in filenames: + fp = os.path.join(dirpath, f) + total_size += roundup(os.lstat(fp).st_size, 4096) + else: + total_size += roundup(os.lstat(path).st_size, 4096) + + for name,target in iteritems(options['symlinks']): + total_size += 4096 + + total_size = str(max(total_size / 1000, 1024)) + 'K' + + ret, output = hdiutil('create', + '-ov', + '-volname', volume_name, + '-fs', 'HFS+', + '-fsargs', '-c c=64,a=16,e=16', + '-size', total_size, + writableFile.name) + + if ret: + raise DMGError('Unable to create disk image') + + # IDME was deprecated in macOS 10.15/Catalina; as a result, use of -noidme + # started raising a warning. + if MACOS_VERSION >= (10, 15): + ret, output = hdiutil('attach', + '-nobrowse', + '-owners', 'off', + writableFile.name) + else: + ret, output = hdiutil('attach', + '-nobrowse', + '-owners', 'off', + '-noidme', + writableFile.name) + + if ret: + raise DMGError('Unable to attach disk image') + + try: + for info in output['system-entities']: + if info.get('mount-point', None): + device = info['dev-entry'] + mount_point = info['mount-point'] + + icon = options['icon'] + if badge: + badge_icon = options['badge_icon'] + else: + badge_icon = None + icon_target_path = os.path.join(mount_point, '.VolumeIcon.icns') + if icon: + shutil.copyfile(icon, icon_target_path) + elif badge_icon: + badge.badge_disk_icon(badge_icon, icon_target_path) + + if icon or badge_icon: + subprocess.call(['/usr/bin/SetFile', '-a', 'C', mount_point]) + + background_bmk = None + + if not isinstance(background, (str, unicode)): + pass + elif colors.isAColor(background): + c = colors.parseColor(background).to_rgb() + + icvp['backgroundType'] = 1 + icvp['backgroundColorRed'] = float(c.r) + icvp['backgroundColorGreen'] = float(c.g) + icvp['backgroundColorBlue'] = float(c.b) + else: + if os.path.isfile(background): + # look to see if there are HiDPI resources available + + if lookForHiDPI is True: + name, extension = os.path.splitext(os.path.basename(background)) + orderedImages = [background] + imageDirectory = os.path.dirname(background) + if imageDirectory == '': + imageDirectory = '.' + for candidateName in os.listdir(imageDirectory): + hasScale = re.match( + r'^(?P.+)@(?P\d+)x(?P\.\w+)$', + candidateName) + if hasScale and name == hasScale.group('name') and \ + extension == hasScale.group('extension'): + scale = int(hasScale.group('scale')) + if len(orderedImages) < scale: + orderedImages += [None] * (scale - len(orderedImages)) + orderedImages[scale - 1] = os.path.join(imageDirectory, candidateName) + + if len(orderedImages) > 1: + # compile the grouped tiff + backgroundFile = tempfile.NamedTemporaryFile(suffix='.tiff') + background = backgroundFile.name + output = tempfile.TemporaryFile(mode='w+') + try: + subprocess.check_call( + ['/usr/bin/tiffutil', '-cathidpicheck'] + + list(filter(None, orderedImages)) + + ['-out', background], stdout=output, stderr=output) + except Exception as e: + output.seek(0) + raise ValueError( + 'unable to compile combined HiDPI file "%s" got error: %s\noutput: %s' + % (background, str(e), output.read())) + + _, kind = os.path.splitext(background) + path_in_image = os.path.join(mount_point, '.background' + kind) + shutil.copyfile(background, path_in_image) + elif pkg_resources.resource_exists('dmgbuild', 'resources/' + background + '.tiff'): + tiffdata = pkg_resources.resource_string( + 'dmgbuild', + 'resources/' + background + '.tiff') + path_in_image = os.path.join(mount_point, '.background.tiff') + + with open(path_in_image, 'wb') as f: + f.write(tiffdata) + else: + raise ValueError('background file "%s" not found' % background) + + alias = Alias.for_file(path_in_image) + background_bmk = Bookmark.for_file(path_in_image) + + icvp['backgroundType'] = 2 + icvp['backgroundImageAlias'] = plist_bytes(alias.to_bytes()) + + for f in options['files']: + if isinstance(f, tuple): + f_in_image = os.path.join(mount_point, f[1]) + f = f[0] + else: + basename = os.path.basename(f.rstrip('/')) + f_in_image = os.path.join(mount_point, basename) + + # use system ditto command to preserve code signing, etc. + subprocess.call(['/usr/bin/ditto', f, f_in_image]) + + for name,target in iteritems(options['symlinks']): + name_in_image = os.path.join(mount_point, name) + os.symlink(target, name_in_image) + + to_hide = [] + for name in options['hide_extensions']: + name_in_image = os.path.join(mount_point, name) + to_hide.append(name_in_image) + + if to_hide: + subprocess.call(['/usr/bin/SetFile', '-a', 'E'] + to_hide) + + to_hide = [] + for name in options['hide']: + name_in_image = os.path.join(mount_point, name) + to_hide.append(name_in_image) + + if to_hide: + subprocess.call(['/usr/bin/SetFile', '-a', 'V'] + to_hide) + + userfn = options.get('create_hook', None) + if callable(userfn): + userfn(mount_point, options) + + image_dsstore = os.path.join(mount_point, '.DS_Store') + + with DSStore.open(image_dsstore, 'w+') as d: + d['.']['vSrn'] = ('long', 1) + d['.']['bwsp'] = bwsp + if include_icon_view_settings: + d['.']['icvp'] = icvp + if background_bmk: + d['.']['pBBk'] = background_bmk + if include_list_view_settings: + d['.']['lsvp'] = lsvp + d['.']['icvl'] = icvl + + for k,v in iteritems(options['icon_locations']): + d[k]['Iloc'] = v + + # Delete .Trashes, if it gets created + shutil.rmtree(os.path.join(mount_point, '.Trashes'), True) + except: + # Always try to detach + hdiutil('detach', '-force', device, plist=False) + raise + + for tries in range(detach_retries): + ret, output = hdiutil('detach', device, plist=False) + if not ret: + break + time.sleep(1) + + if ret: + hdiutil('detach', '-force', device, plist=False) + raise DMGError('Unable to detach device cleanly') + + # Shrink the output to the minimum possible size + ret, output = hdiutil('resize', + '-quiet', + '-sectors', 'min', + writableFile.name, + plist=False) + + if ret: + raise DMGError('Unable to shrink') + + key_prefix = {'UDZO': 'zlib', 'UDBZ': 'bzip2', 'ULFO': 'lzfse'} + compression_level = options['compression_level'] + if options['format'] in key_prefix and compression_level: + compression_args = [ + '-imagekey', + key_prefix[options['format']] + '-level=' + str(compression_level) + ] + else: + compression_args = [] + + ret, output = hdiutil('convert', writableFile.name, + '-format', options['format'], + '-ov', + '-o', filename, *compression_args) + + if ret: + raise DMGError('Unable to convert') + + if options['license']: + ret, output = hdiutil('unflatten', '-quiet', filename, plist=False) + + if ret: + raise DMGError('Unable to unflatten to add license') + + licensing.add_license(filename, options['license']) + + ret, output = hdiutil('flatten', '-quiet', filename, plist=False) + + if ret: + raise DMGError('Unable to flatten after adding license') diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/licensing.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/licensing.py new file mode 100644 index 00000000..87110404 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/licensing.py @@ -0,0 +1,461 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import os +import struct + +from .resources import * + +# ISO language and country codes to Macintosh Region codes (from Script.h) +# == CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(NULL, +# kTextLanguageDontCare, +# ) +region_codes = { + "en_US": 0, + "fr_FR": 1, + "en_GB": 2, + "de_DE": 3, + "it_IT": 4, + "nl_NL": 5, + "nl_BE": 6, + "sv_SE": 7, + "es_ES": 8, + "da_DK": 9, + "pt_PT": 10, + "fr_CA": 11, + "nb_NO": 12, + "he_IL": 13, + "ja_JP": 14, + "en_AU": 15, + "ar": 16, + "fi_FI": 17, + "fr_CH": 18, + "de_CH": 19, + "el_GR": 20, + "is_IS": 21, + "mt_MT": 22, + "el_CY": 23, + "tr_TR": 24, + "hi_IN": 33, + "ur_PK": 34, + "it_CH": 36, + "ro_RO": 39, + "grc": 40, + "lt_LT": 41, + "pl_PL": 42, + "hu_HU": 43, + "et_EE": 44, + "lv_LV": 45, + "se": 46, + "fo_FO": 47, + "fa_IR": 48, + "ru_RU": 49, + "ga_IE": 50, + "ko_KR": 51, + "zh_CN": 52, + "zh_TW": 53, + "th_TH": 54, + "cs_CZ": 56, + "sk_SK": 57, + "bn": 60, + "be_BY": 61, + "uk_UA": 62, + "sr_RS": 65, + "sl_SI": 66, + "mk_MK": 67, + "hr_HR": 68, + "pt_BR": 71, + "bg_BG": 72, + "ca_ES": 73, + "gd": 75, + "gv": 76, + "br": 77, + "iu_CA": 78, + "cy": 79, + "ga-Latg_IE": 81, + "en_CA": 82, + "dz_BT": 83, + "hy_AM": 84, + "ka_GE": 85, + "es_419": 86, + "to_TO": 88, + "fr_001": 91, + "de_AT": 92, + "gu_IN": 94, + "pa": 95, + "ur_IN": 96, + "vi_VN": 97, + "fr_BE": 98, + "uz_UZ": 99, + "en_SG": 100, + "nn_NO": 101, + "af_ZA": 102, + "eo": 103, + "mr_IN": 104, + "bo": 105, + "ne_NP": 106, + "kl": 107, + "en_IE": 108 +} + +# Map of region constants to script constants (from Script.h) +# TextEncoding textEncoding; +# GetTextEncodingFromScriptInfo(kTextScriptDontCare, kTextLanguageDontCare, , &textEncoding); +# == GetTextEncodingBase(textEncoding); +script_codes = { + 0: 0, + 1: 0, + 2: 0, + 3: 0, + 4: 0, + 5: 0, + 6: 0, + 7: 0, + 8: 0, + 9: 0, + 10: 0, + 11: 0, + 12: 0, + 13: 5, + 14: 1, + 15: 0, + 16: 4, + 17: 0, + 18: 0, + 19: 0, + 20: 6, + 21: 37, + 22: 0, + 23: 6, + 24: 35, + 25: 36, + 26: 0, + 27: 0, + 30: 0, + 31: 0, + 32: 0, + 33: 9, + 34: 4, + 35: 35, + 36: 0, + 37: 0, + 39: 38, + 40: 6, + 41: 29, + 42: 29, + 43: 29, + 44: 29, + 45: 29, + 46: 0, + 47: 37, + 48: 140, + 49: 7, + 50: 39, + 51: 3, + 52: 25, + 53: 2, + 54: 21, + 56: 29, + 57: 29, + 59: 29, + 60: 13, + 61: 7, + 62: 7, + 64: 6, + 65: 7, + 66: 36, + 67: 7, + 68: 36, + 70: 0, + 71: 0, + 72: 7, + 73: 0, + 75: 39, + 76: 39, + 77: 39, + 78: 236, + 79: 39, + 81: 40, + 82: 0, + 83: 26, + 84: 24, + 85: 23, + 86: 0, + 88: 0, + 91: 0, + 92: 0, + 94: 11, + 95: 10, + 96: 4, + 97: 30, + 98: 0, + 99: 7, + 100: 0, + 101: 0, + 102: 0, + 103: 0, + 104: 9, + 105: 26, + 106: 9, + 107: 0, + 108: 0 +} + +# Map of TextEncodingBase constants to Python encoder names (from TextCommon.h) +encodings_map = { + 0: 'mac_roman', # kTextEncodingMacRoman + 1: 'shift_jis', # kTextEncodingMacJapanese + 2: 'big5', # kTextEncodingMacChineseTrad + 3: 'euc_kr', # kTextEncodingMacKorean + 4: 'mac_arabic', # kTextEncodingMacArabic + 6: 'mac_greek', # kTextEncodingMacGreek + 7: 'mac_cyrillic', # kTextEncodingMacCyrillic + 21: 'iso8859_11', # kTextEncodingMacThai + 25: 'euc-cn', # kTextEncodingMacChineseSimp + 29: 'mac_centeuro', # kTextEncodingMacCentralEurRoman + 35: 'mac_turkish', # kTextEncodingMacTurkish + 36: 'mac_croatian', # kTextEncodingMacCroatian + 37: 'mac_iceland', # kTextEncodingMacIcelandic + 38: 'mac_romanian', # kTextEncodingMacRomanian + 140: 'mac_farsi' # kTextEncodingMacFarsi +} + +# Standard fonts +fonts = { + 'New York': 2, + 'Geneva': 3, + 'Monaco': 4, + 'Venice': 5, + 'London': 6, + 'Athens': 7, + 'San Francisco': 8, + 'Toronto': 9, + 'Cairo': 11, + 'Los Angeles': 12, + 'Times': 20, + 'Helvetica': 21, + 'Courier': 22, + 'Symbol': 23, + 'Mobile': 24 +} + +# Buttons (these come from the SLAResources file which you can find in the SLA +# SDK on developer.apple.com) +default_buttons = { + 0: ( + b'English', + b'Agree', + b'Disagree', + b'Print', + b'Save', + b'If you agree with the terms of this license, press "Agree" to ' + b'install the software. If you do not agree, press "Disagree".' + ), + + 3: ( + b'Deutsch', + b'Akzeptieren', + b'Ablehnen', + b'Drucken', + b'Sichern...', + b'Klicken Sie in \xd2Akzeptieren\xd3, wenn Sie mit den Bestimmungen des Software-Lizenzvertrags einverstanden sind. Falls nicht, bitte \xd2Ablehnen\xd3 anklicken. Sie k\x9annen die Software nur installieren, wenn Sie \xd2Akzeptieren\xd3 angeklickt haben.' + ), + + 8: ( + b'Espa\x96ol', + b'Aceptar', + b'No aceptar', + b'Imprimir', + b'Guardar...', + b'Si est\x87 de acuerdo con los t\x8erminos de esta licencia, pulse "Aceptar" para instalar el software. En el supuesto de que no est\x8e de acuerdo con los t\x8erminos de esta licencia, pulse "No aceptar."' + ), + + 1: ( + b'Fran\x8dais', + b'Accepter', + b'Refuser', + b'Imprimer', + b'Enregistrer...', + b'Si vous acceptez les termes de la pr\x8esente licence, cliquez sur "Accepter" afin d\'installer le logiciel. Si vous n\'\x90tes pas d\'accord avec les termes de la licence, cliquez sur "Refuser".' + ), + + 4: ( + b'Italiano', + b'Accetto', + b'Rifiuto', + b'Stampa', + b'Registra...', + b'Se accetti le condizioni di questa licenza, fai clic su "Accetto" per installare il software. Altrimenti fai clic su "Rifiuto".' + ), + + 14: ( + b'Japanese', + b'\x93\xaf\x88\xd3\x82\xb5\x82\xdc\x82\xb7', + b'\x93\xaf\x88\xd3\x82\xb5\x82\xdc\x82\xb9\x82\xf1', + b'\x88\xf3\x8d\xfc\x82\xb7\x82\xe9', + b'\x95\xdb\x91\xb6...', + b'\x96{\x83\\\x83t\x83g\x83E\x83G\x83A\x8eg\x97p\x8b\x96\x91\xf8\x8c_\x96\xf1\x82\xcc\x8f\xf0\x8c\x8f\x82\xc9\x93\xaf\x88\xd3\x82\xb3\x82\xea\x82\xe9\x8f\xea\x8d\x87\x82\xc9\x82\xcd\x81A\x83\\\x83t\x83g\x83E\x83G\x83A\x82\xf0\x83C\x83\x93\x83X\x83g\x81[\x83\x8b\x82\xb7\x82\xe9\x82\xbd\x82\xdf\x82\xc9\x81u\x93\xaf\x88\xd3\x82\xb5\x82\xdc\x82\xb7\x81v\x82\xf0\x89\x9f\x82\xb5\x82\xc4\x82\xad\x82\xbe\x82\xb3\x82\xa2\x81B\x81@\x93\xaf\x88\xd3\x82\xb3\x82\xea\x82\xc8\x82\xa2\x8f\xea\x8d\x87\x82\xc9\x82\xcd\x81A\x81u\x93\xaf\x88\xd3\x82\xb5\x82\xdc\x82\xb9\x82\xf1\x81v\x82\xf0\x89\x9f\x82\xb5\x82\xc4\x82\xad\x82\xbe\x82\xb3\x82\xa2\x81B' + ), + + 5: ( + b'Nederlands', + b'Ja', + b'Nee', + b'Print', + b'Bewaar...', + b'Indien u akkoord gaat met de voorwaarden van deze licentie, kunt u op \'Ja\' klikken om de programmatuur te installeren. Indien u niet akkoord gaat, klikt u op \'Nee\'.' + ), + + 7: ( + b'Svensk', + b'Godk\x8anns', + b'Avb\x9ajs', + b'Skriv ut', + b'Spara...', + b'Om Du godk\x8anner licensvillkoren klicka p\x8c "Godk\x8anns" f\x9ar att installera programprodukten. Om Du inte godk\x8anner licensvillkoren, klicka p\x8c "Avb\x9ajs".' + ), + + 71: ( + b'Portugu\x90s', + b'Concordar', + b'Discordar', + b'Imprimir', + b'Salvar...', + b'Se est\x87 de acordo com os termos desta licen\x8da, pressione "Concordar" para instalar o software. Se n\x8bo est\x87 de acordo, pressione "Discordar".' + ), + + 52: ( + b'Simplified Chinese', + b'\xcd\xac\xd2\xe2', + b'\xb2\xbb\xcd\xac\xd2\xe2', + b'\xb4\xf2\xd3\xa1', + b'\xb4\xe6\xb4\xa2\xa1\xad', + b'\xc8\xe7\xb9\xfb\xc4\xfa\xcd\xac\xd2\xe2\xb1\xbe\xd0\xed\xbf\xc9\xd0\xad\xd2\xe9\xb5\xc4\xcc\xf5\xbf\xee\xa3\xac\xc7\xeb\xb0\xb4\xa1\xb0\xcd\xac\xd2\xe2\xa1\xb1\xc0\xb4\xb0\xb2\xd7\xb0\xb4\xcb\xc8\xed\xbc\xfe\xa1\xa3\xc8\xe7\xb9\xfb\xc4\xfa\xb2\xbb\xcd\xac\xd2\xe2\xa3\xac\xc7\xeb\xb0\xb4\xa1\xb0\xb2\xbb\xcd\xac\xd2\xe2\xa1\xb1\xa1\xa3' + ), + + 53: ( + b'Traditional Chinese', + b'\xa6P\xb7N', + b'\xa4\xa3\xa6P\xb7N', + b'\xa6C\xa6L', + b'\xc0x\xa6s\xa1K', + b'\xa6p\xaaG\xb1z\xa6P\xb7N\xa5\xbb\xb3\\\xa5i\xc3\xd2\xb8\xcc\xaa\xba\xb1\xf8\xb4\xda\xa1A\xbd\xd0\xab\xf6\xa1\xa7\xa6P\xb7N\xa1\xa8\xa5H\xa6w\xb8\xcb\xb3n\xc5\xe9\xa1C\xa6p\xaaG\xa4\xa3\xa6P\xb7N\xa1A\xbd\xd0\xab\xf6\xa1\xa7\xa4\xa3\xa6P\xb7N\xa1\xa8\xa1C' + ), + + 9: ( + b'Dansk', + b'Enig', + b'Uenig', + b'Udskriv', + b'Arkiver...', + b'Hvis du accepterer betingelserne i licensaftalen, skal du klikke p\x8c \xd2Enig\xd3 for at installere softwaren. Klik p\x8c \xd2Uenig\xd3 for at annullere installeringen.' + ), + + 17: ( + b'Suomi', + b'Hyv\x8aksyn', + b'En hyv\x8aksy', + b'Tulosta', + b'Tallenna\xc9', + b'Hyv\x8aksy lisenssisopimuksen ehdot osoittamalla \xd5Hyv\x8aksy\xd5. Jos et hyv\x8aksy sopimuksen ehtoja, osoita \xd5En hyv\x8aksy\xd5.' + ), + + 51: ( + b'Korean', + b'\xb5\xbf\xc0\xc7', + b'\xb5\xbf\xc0\xc7 \xbe\xc8\xc7\xd4', + b'\xc7\xc1\xb8\xb0\xc6\xae', + b'\xc0\xfa\xc0\xe5...', + b'\xbb\xe7\xbf\xeb \xb0\xe8\xbe\xe0\xbc\xad\xc0\xc7 \xb3\xbb\xbf\xeb\xbf\xa1 \xb5\xbf\xc0\xc7\xc7\xcf\xb8\xe9, "\xb5\xbf\xc0\xc7" \xb4\xdc\xc3\xdf\xb8\xa6 \xb4\xad\xb7\xaf \xbc\xd2\xc7\xc1\xc6\xae\xbf\xfe\xbe\xee\xb8\xa6 \xbc\xb3\xc4\xa1\xc7\xcf\xbd\xca\xbd\xc3\xbf\xc0. \xb5\xbf\xc0\xc7\xc7\xcf\xc1\xf6 \xbe\xca\xb4\xc2\xb4\xd9\xb8\xe9, "\xb5\xbf\xc0\xc7 \xbe\xc8\xc7\xd4" \xb4\xdc\xc3\xdf\xb8\xa6 \xb4\xa9\xb8\xa3\xbd\xca\xbd\xc3\xbf\xc0.' + ), + + 12: ( + b'Norsk', + b'Enig', + b'Ikke enig', + b'Skriv ut', + b'Arkiver...', + b'Hvis De er enig i bestemmelsene i denne lisensavtalen, klikker De p\x8c "Enig"-knappen for \x8c installere programvaren. Hvis De ikke er enig, klikker De p\x8c "Ikke enig".' + ), +} + +class LPicResource (Resource): + def __init__(self, res_id, res_name, default_lang, lpic, res_attrs=0): + data = [] + data.append(struct.pack(b'>HH', default_lang, len(lpic))) + for lang,rid,two_byte in lpic: + data.append(struct.pack(b'>HHH', lang, rid, int(two_byte))) + super(LPicResource, self).__init__(b'LPic', res_id, res_name, + b''.join(data), res_attrs) + +def get_encoder_name(locale): + if locale not in region_codes: + raise Exception("Cannot determine region code for locale '%s'" % locale) + region_code = region_codes[locale] + + if region_code not in script_codes: + raise Exception("Cannot determine script code for locale '%s'" % locale) + script_code = script_codes[region_code] + + if script_code not in encodings_map: + raise Exception("Cannot determine Python encoder name for locale '%s' - " + "encode the string data manually as a byte array instead" % locale) + return encodings_map[script_code] + +def maybe_encode(s, encoding): + if isinstance(s, bytes): + return s + return s.encode(encoding) + +def add_license(filename, license_info): + """Add a license agreement to the specified disk image file, which should + have been unflattened first.""" + + fork = ResourceFork.from_file(filename) + + default_lang = license_info.get('default-language', 'en_US') + default_lang_id = region_codes.get(default_lang, 0) + + lpic = [] + ndx = 1 + for language,license_data in license_info['licenses'].items(): + if language not in region_codes: + raise Exception("Unknown language '" + language + "'. Valid languages are: " + + ", ".join(sorted(region_codes.keys()))) + encoding_name = get_encoder_name(language) + lang_id = region_codes[language] + + is_two_byte = lang_id in (14, 51, 52, 53) # Japanese, Korean, SimpChinese, TradChinese + + if os.path.isfile(license_data): + mode = 'rb' if license_data.endswith('.rtf') else 'r' + with open(license_data, mode=mode) as f: + license_data = f.read() + + if type(license_data) == bytes and license_data.startswith(b'{\\rtf1'): + fork.add(Resource(b'RTF ', 5000 + ndx, (language + ' SLA').encode(), + license_data)) + else: + fork.add(TextResource(5000 + ndx, (language + ' SLA').encode(), + maybe_encode(license_data, encoding_name))) + fork.add(StyleResource(5000 + ndx, (language + ' SLA').encode(), + [Style(0, 12, 9, Style.Helvetica, + 0, 0, (0, 0, 0))])) + + buttons = license_info.get('buttons', {}).get(language, None) + if buttons is None: + buttons = default_buttons.get(lang_id, None) + if buttons is None: + buttons = default_buttons[0] + + buttons = [maybe_encode(b, encoding_name) for b in buttons] + + fork.add(StringListResource(5000 + ndx, (language + ' Buttons').encode(), buttons)) + + lpic.append((lang_id, ndx, is_two_byte)) + + ndx += 1 + + fork.add(LPicResource(5000, None, default_lang_id, lpic)) + + fork.write_to_file(filename) diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/qt_attribution.json b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/qt_attribution.json new file mode 100644 index 00000000..d9f97ae2 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "dmgbuild", + "Name": "dmgbuild", + "QDocModule": "qbs", + "QtUsage": "Used in the qbs dmg module for building Apple disk images.", + "Description": "macOS command line utility to build disk images", + "Homepage": "https://github.com/al45tair/dmgbuild", + "Version": "1.3.1", + "License": "MIT License", + "LicenseId": "MIT", + "LicenseFile": "LICENSE", + "Copyright": "Copyright (c) 2014 Alastair Houghton" +} diff --git a/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/resources.py b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/resources.py new file mode 100644 index 00000000..03e2a43f --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/dmgbuild/resources.py @@ -0,0 +1,359 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +import struct + +class Resource (object): + def __init__(self, res_type, res_id, res_name, data=None, res_attrs=0): + self.res_type = res_type + self.res_id = res_id + self.res_name = res_name + self.res_attrs = res_attrs + if data is None: + self.data = None + self.data = data + + self.data_offset = None + self.name_offset = None + + def __repr__(self): + return 'Resource(%r, %r, %r, data=%r, res_attrs=%r)' % (self.res_type, + self.res_id, + self.res_name, + self.data, + self.res_attrs) + +class TMPLResource (Resource): + def __init__(self, res_id, res_name, tmpl, res_attrs=0): + data = [] + for name,typecode in tmpl: + data.append(struct.pack(b'B', len(name))) + data.append(name) + data.append(typecode) + super(TMPLResource, self).__init__(b'TMPL', res_id, res_name, + b''.join(data), res_attrs) + +class StringListResource (Resource): + def __init__(self, res_id, res_name, strings, res_attrs=0): + data = [] + data.append(struct.pack(b'>H', len(strings))) + for s in strings: + data.append(struct.pack(b'B', len(s))) + data.append(s) + + super(StringListResource, self).__init__(b'STR#', res_id, res_name, + b''.join(data), res_attrs) + +class TextResource (Resource): + def __init__(self, res_id, res_name, string, res_attrs=0): + super(TextResource, self).__init__(b'TEXT', res_id, res_name, + string, res_attrs) + +class Style (object): + # Fonts + NewYork = 2 + Geneva = 3 + Monaco = 4 + Venice = 5 + London = 6 + Athens = 7 + SanFrancisco = 8 + Toronto = 9 + Cairo = 11 + LosAngeles = 12 + Times = 20 + Helvetica = 21 + Courier = 22 + Symbol = 23 + Mobile = 24 + + # Styles + Bold = 0x0100 + Italic = 0x0200 + Underline = 0x0400 + Outline = 0x0800 + Shadow = 0x1000 + Condense = 0x2000 + Expand = 0x4000 + + def __init__(self, start_character, height, ascent, font_id, face, + size, color): + self.start_character = start_character + self.height = height + self.ascent = ascent + self.font_id = font_id + self.face = face + self.size = size + self.color = color + + def __repr__(self): + styles = [] + if self.face & Style.Bold: + styles.append('Style.Bold') + if self.face & Style.Italic: + styles.append('Style.Italic') + if self.face & Style.Underline: + styles.append('Style.Underline') + if self.face & Style.Outline: + styles.append('Style.Outline') + if self.face & Style.Shadow: + styles.append('Style.Shadow') + if self.face & Style.Condense: + styles.append('Style.Condense') + if self.face & Style.Expand: + styles.append('Style.Expand') + if self.face & ~0x4f00: + styles.append('%#06x' % (self.face & ~0x4f00)) + if styles: + styles = '|'.join(styles) + else: + styles = '0' + + font_revmap = { + 2: 'Style.NewYork', + 3: 'Style.Geneva', + 4: 'Style.Monaco', + 5: 'Style.Venice', + 6: 'Style.London', + 7: 'Style.Athens', + 8: 'Style.SanFrancisco', + 9: 'Style.Toronto', + 11: 'Style.Cairo', + 12: 'Style.LosAngeles', + 20: 'Style.Times', + 21: 'Style.Helvetica', + 22: 'Style.Courier', + 23: 'Style.Symbol', + 24: 'Style.Mobile' + } + + font = font_revmap.get(self.font_id, '%s' % self.font_id) + + return 'Style(%r, %r, %r, %s, %s, %r, %r)' % ( + self.start_character, + self.height, + self.ascent, + font, + styles, + self.size, + self.color) + +class StyleResource (Resource): + def __init__(self, res_id, res_name, styles, res_attrs=0): + data = [] + data.append(struct.pack(b'>H', len(styles))) + for style in styles: + data.append(struct.pack(b'>LHHHHHHHH', + style.start_character, + style.height, + style.ascent, + style.font_id, + style.face, + style.size, + style.color[0], + style.color[1], + style.color[2])) + super(StyleResource, self).__init__(b'styl', res_id, res_name, + b''.join(data), res_attrs) + +class ResourceFork (object): + def __init__(self, resources=None): + self.types = {} + self.attrs = 0 + if resources is not None: + for res in resources: + self.add(res) + + @classmethod + def from_data(clss, data): + if len(data) < 16: + raise ValueError('Bad resource data - data too short') + + # Read the header + data_start, map_start, data_len, map_len = struct.unpack(b'>LLLL', + data[0:16]) + + if data_start + data_len > len(data): + raise ValueError('Bad resource data - data out of range') + if map_start + map_len > len(data): + raise ValueError('Bad resource data - map out of range') + if map_len < 30: + raise ValueError('Bad resource data - map too short') + + # Read the map header + fork_attrs, type_offset, name_offset, max_type_ndx \ + = struct.unpack(b'>HHHH', data[map_start + 22:map_start + 30]) + num_types = max_type_ndx + 1 + + if type_offset + 8 * num_types > map_len: + raise ValueError('Bad resource data - type data outside map') + + if name_offset > map_len: + raise ValueError('Bad resource data - names outside map') + + type_offset += map_start + name_offset += map_start + + result = ResourceFork() + + # Now read the type list + for ntype in range(0, num_types): + type_pos = 2 + type_offset + 8 * ntype + res_type, max_item_ndx, ref_offset \ + = struct.unpack(b'>4sHH', data[type_pos:type_pos+8]) + num_items = max_item_ndx + 1 + + result.types[res_type] = [] + + ref_list_offset = type_offset + ref_offset + if ref_list_offset + 12 * num_items > map_start + map_len: + raise ValueError('Bad resource data - ref list outside map') + + for nitem in range(0, num_items): + ref_elt = ref_list_offset + 12 * nitem + res_id, res_name_offset, data_offset \ + = struct.unpack(b'>hHL', data[ref_elt:ref_elt+8]) + + res_attrs = data_offset >> 24 + data_offset &= 0xffffff + + if data_offset >= data_len: + raise ValueError('Bad resource data - item data out of range') + + data_offset += data_start + res_len = struct.unpack(b'>L', data[data_offset:data_offset+4])[0] + if data_offset + res_len >= data_start + data_len: + raise ValueError('Bad resource data - item data too large') + + res_data = data[data_offset + 4:data_offset + res_len + 4] + + if res_name_offset == 0xffff: + res_name = None + else: + res_name_offset += name_offset + if res_name_offset >= map_start + map_len: + raise ValueError('Bad resource data - name out of range') + try: + # python2 + res_name_len = struct.unpack(b'B', data[res_name_offset])[0] + except: + # python3 + res_name_len = data[res_name_offset] + + res_name = data[res_name_offset + 1:res_name_offset + res_name_len + 1] + + result.types[res_type].append(Resource(res_type, res_id, + res_name, + res_data, res_attrs)) + + return result + + @classmethod + def from_file(clss, filename): + with open(filename + '/..namedfork/rsrc', 'rb') as f: + data = f.read() + return clss.from_data(data) + + def to_data(self): + data = [] + data_len = 0 + names = [] + names_len = 0 + types_len = len(self.types) * 8 + types_data = [] + reflist_data = [] + reflist_len = 0 + + for res_type, items in self.types.items(): + types_data.append(struct.pack(b'>4sHH', + res_type, + len(items) - 1, + 2 + types_len + reflist_len)) + for item in items: + data_offset = data_len + + if item.res_name is None: + name_offset = 65535 + else: + name_offset = names_len + n = item.res_name + names.append(struct.pack(b'B', len(n)) + n) + names_len += 1 + len(n) + + if item.data is None: + data_len += 4 + else: + data_len += 4 + (len(item.data) + 3) & ~3 + + reflist_len += 12 + reflist_data.append(struct.pack(b'>hHLL', + item.res_id, + name_offset, + (item.res_attrs << 24) \ + | data_offset, + 0)) + + # Header + data.append(struct.pack(b'>LLLL240s', 256, 256 + data_len, data_len, + 30 + types_len + reflist_len + names_len, + b'')) + + # Resource data + for res_type, items in self.types.items(): + for item in items: + if item.data is None: + dlen = 0 + else: + dlen = len(item.data) + plen = (dlen + 3) & ~3 + data.append(struct.pack(b'>L', dlen)) + if item.data is not None: + data.append(item.data) + if plen != dlen: + data.append(b'\0' * (plen - dlen)) + + # Resource map header + data.append(struct.pack(b'>16sLHHHHH', + b'', 0, 0, + self.attrs, 28, 30 + types_len + reflist_len, + len(self.types) - 1)) + + # Type list + data.append(b''.join(types_data)) + + # Reference lists + data.append(b''.join(reflist_data)) + + # Name list + data.append(b''.join(names)) + + return b''.join(data) + + def write_to_file(self, filename): + with open(filename + '/..namedfork/rsrc', 'wb') as f: + f.write(self.to_data()) + + def __len__(self): + return len(self.types) + + def __getitem__(self, key): + return self.types[key] + + def __iter__(self): + for res_type, items in self.types.items(): + for item in items: + yield item + + def __repr__(self): + output = [] + for item in self: + output.append(repr(item)) + return 'ResourceFork([%s])' % ', '.join(output) + + def add(self, res): + if res.res_type in self.types: + self.types[res.res_type].append(res) + else: + self.types[res.res_type] = [res] + + def remove(self, res): + self.types[res.res_type].remove(res) diff --git a/src/3rdparty/python/lib/python2.7/site-packages/ds_store/LICENSE b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/LICENSE new file mode 100644 index 00000000..e91f4eb3 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/3rdparty/python/lib/python2.7/site-packages/ds_store/__init__.py b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/__init__.py new file mode 100644 index 00000000..a6b81210 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/__init__.py @@ -0,0 +1,3 @@ +from .store import DSStore, DSStoreEntry + +__all__ = ['DSStore', 'DSStoreEntry'] diff --git a/src/3rdparty/python/lib/python2.7/site-packages/ds_store/buddy.py b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/buddy.py new file mode 100644 index 00000000..320768cd --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/buddy.py @@ -0,0 +1,478 @@ +# -*- coding: utf-8 -*- +import os +import bisect +import struct +import binascii + +try: + {}.iterkeys + iterkeys = lambda x: x.iterkeys() +except AttributeError: + iterkeys = lambda x: x.keys() +try: + unicode +except NameError: + unicode = str + +class BuddyError(Exception): + pass + +class Block(object): + def __init__(self, allocator, offset, size): + self._allocator = allocator + self._offset = offset + self._size = size + self._value = bytearray(allocator.read(offset, size)) + self._pos = 0 + self._dirty = False + + def __len__(self): + return self._size + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._dirty: + self.flush() + + def flush(self): + if self._dirty: + self._dirty = False + self._allocator.write(self._offset, self._value) + + def invalidate(self): + self._dirty = False + + def zero_fill(self): + len = self._size - self._pos + zeroes = b'\0' * len + self._value[self._pos:self._size] = zeroes + self._dirty = True + + def tell(self): + return self._pos + + def seek(self, pos, whence=os.SEEK_SET): + if whence == os.SEEK_CUR: + pos += self._pos + elif whence == os.SEEK_END: + pos = self._size - pos + + if pos < 0 or pos > self._size: + raise ValueError('Seek out of range in Block instance') + + self._pos = pos + + def read(self, size_or_format): + if isinstance(size_or_format, (str, unicode, bytes)): + size = struct.calcsize(size_or_format) + fmt = size_or_format + else: + size = size_or_format + fmt = None + + if self._size - self._pos < size: + raise BuddyError('Unable to read %lu bytes in block' % size) + + data = self._value[self._pos:self._pos + size] + self._pos += size + + if fmt is not None: + if isinstance(data, bytearray): + return struct.unpack_from(fmt, bytes(data)) + else: + return struct.unpack(fmt, data) + else: + return data + + def write(self, data_or_format, *args): + if len(args): + data = struct.pack(data_or_format, *args) + else: + data = data_or_format + + if self._pos + len(data) > self._size: + raise ValueError('Attempt to write past end of Block') + + self._value[self._pos:self._pos + len(data)] = data + self._pos += len(data) + + self._dirty = True + + def insert(self, data_or_format, *args): + if len(args): + data = struct.pack(data_or_format, *args) + else: + data = data_or_format + + del self._value[-len(data):] + self._value[self._pos:self._pos] = data + self._pos += len(data) + + self._dirty = True + + def delete(self, size): + if self._pos + size > self._size: + raise ValueError('Attempt to delete past end of Block') + del self._value[self._pos:self._pos + size] + self._value += b'\0' * size + self._dirty = True + + def __str__(self): + return binascii.b2a_hex(self._value) + +class Allocator(object): + def __init__(self, the_file): + self._file = the_file + self._dirty = False + + self._file.seek(0) + + # Read the header + magic1, magic2, offset, size, offset2, self._unknown1 \ + = self.read(-4, '>I4sIII16s') + + if magic2 != b'Bud1' or magic1 != 1: + raise BuddyError('Not a buddy file') + + if offset != offset2: + raise BuddyError('Root addresses differ') + + self._root = Block(self, offset, size) + + # Read the block offsets + count, self._unknown2 = self._root.read('>II') + self._offsets = [] + c = (count + 255) & ~255 + while c: + self._offsets += self._root.read('>256I') + c -= 256 + self._offsets = self._offsets[:count] + + # Read the TOC + self._toc = {} + count = self._root.read('>I')[0] + for n in range(count): + nlen = self._root.read('B')[0] + name = bytes(self._root.read(nlen)) + value = self._root.read('>I')[0] + self._toc[name] = value + + # Read the free lists + self._free = [] + for n in range(32): + count = self._root.read('>I') + self._free.append(list(self._root.read('>%uI' % count))) + + @classmethod + def open(cls, file_or_name, mode='r+'): + if isinstance(file_or_name, (str, unicode)): + if not 'b' in mode: + mode = mode[:1] + 'b' + mode[1:] + f = open(file_or_name, mode) + else: + f = file_or_name + + if 'w' in mode: + # Create an empty file in this case + f.truncate() + + # An empty root block needs 1264 bytes: + # + # 0 4 offset count + # 4 4 unknown + # 8 4 root block offset (2048) + # 12 255 * 4 padding (offsets are in multiples of 256) + # 1032 4 toc count (0) + # 1036 228 free list + # total 1264 + + # The free list will contain the following: + # + # 0 5 * 4 no blocks of width less than 5 + # 20 6 * 8 1 block each of widths 5 to 10 + # 68 4 no blocks of width 11 (allocated for the root) + # 72 19 * 8 1 block each of widths 12 to 30 + # 224 4 no blocks of width 31 + # total 228 + # + # (The reason for this layout is that we allocate 2**5 bytes for + # the header, which splits the initial 2GB region into every size + # below 2**31, including *two* blocks of size 2**5, one of which + # we take. The root block itself then needs a block of size + # 2**11. Conveniently, each of these initial blocks will be + # located at offset 2**n where n is its width.) + + # Write the header + header = struct.pack(b'>I4sIII16s', + 1, b'Bud1', + 2048, 1264, 2048, + b'\x00\x00\x10\x0c' + b'\x00\x00\x00\x87' + b'\x00\x00\x20\x0b' + b'\x00\x00\x00\x00') + f.write(header) + f.write(b'\0' * 2016) + + # Write the root block + free_list = [struct.pack(b'>5I', 0, 0, 0, 0, 0)] + for n in range(5, 11): + free_list.append(struct.pack(b'>II', 1, 2**n)) + free_list.append(struct.pack(b'>I', 0)) + for n in range(12, 31): + free_list.append(struct.pack(b'>II', 1, 2**n)) + free_list.append(struct.pack(b'>I', 0)) + + root = b''.join([struct.pack(b'>III', 1, 0, 2048 | 5), + struct.pack(b'>I', 0) * 255, + struct.pack(b'>I', 0)] + free_list) + f.write(root) + + return Allocator(f) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + self.flush() + self._file.close() + + def flush(self): + if self._dirty: + size = self._root_block_size() + self.allocate(size, 0) + with self.get_block(0) as rblk: + self._write_root_block_into(rblk) + + addr = self._offsets[0] + offset = addr & ~0x1f + size = 1 << (addr & 0x1f) + + self._file.seek(0, os.SEEK_SET) + self._file.write(struct.pack(b'>I4sIII16s', + 1, b'Bud1', + offset, size, offset, + self._unknown1)) + + self._dirty = False + + self._file.flush() + + def read(self, offset, size_or_format): + """Read data at `offset', or raise an exception. `size_or_format' + may either be a byte count, in which case we return raw data, + or a format string for `struct.unpack', in which case we + work out the size and unpack the data before returning it.""" + # N.B. There is a fixed offset of four bytes(!) + self._file.seek(offset + 4, os.SEEK_SET) + + if isinstance(size_or_format, (str, unicode)): + size = struct.calcsize(size_or_format) + fmt = size_or_format + else: + size = size_or_format + fmt = None + + ret = self._file.read(size) + if len(ret) < size: + ret += b'\0' * (size - len(ret)) + + if fmt is not None: + if isinstance(ret, bytearray): + ret = struct.unpack_from(fmt, bytes(ret)) + else: + ret = struct.unpack(fmt, ret) + + return ret + + def write(self, offset, data_or_format, *args): + """Write data at `offset', or raise an exception. `data_or_format' + may either be the data to write, or a format string for `struct.pack', + in which case we pack the additional arguments and write the + resulting data.""" + # N.B. There is a fixed offset of four bytes(!) + self._file.seek(offset + 4, os.SEEK_SET) + + if len(args): + data = struct.pack(data_or_format, *args) + else: + data = data_or_format + + self._file.write(data) + + def get_block(self, block): + try: + addr = self._offsets[block] + except IndexError: + return None + + offset = addr & ~0x1f + size = 1 << (addr & 0x1f) + + return Block(self, offset, size) + + def _root_block_size(self): + """Return the number of bytes required by the root block.""" + # Offsets + size = 8 + size += 4 * ((len(self._offsets) + 255) & ~255) + + # TOC + size += 4 + size += sum([5 + len(s) for s in self._toc]) + + # Free list + size += sum([4 + 4 * len(fl) for fl in self._free]) + + return size + + def _write_root_block_into(self, block): + # Offsets + block.write('>II', len(self._offsets), self._unknown2) + block.write('>%uI' % len(self._offsets), *self._offsets) + extra = len(self._offsets) & 255 + if extra: + block.write(b'\0\0\0\0' * (256 - extra)) + + # TOC + keys = list(self._toc.keys()) + keys.sort() + + block.write('>I', len(keys)) + for k in keys: + block.write('B', len(k)) + block.write(k) + block.write('>I', self._toc[k]) + + # Free list + for w, f in enumerate(self._free): + block.write('>I', len(f)) + if len(f): + block.write('>%uI' % len(f), *f) + + def _buddy(self, offset, width): + f = self._free[width] + b = offset ^ (1 << width) + + try: + ndx = f.index(b) + except ValueError: + ndx = None + + return (f, b, ndx) + + def _release(self, offset, width): + # Coalesce + while True: + f,b,ndx = self._buddy(offset, width) + + if ndx is None: + break + + offset &= b + width += 1 + del f[ndx] + + # Add to the list + bisect.insort(f, offset) + + # Mark as dirty + self._dirty = True + + def _alloc(self, width): + w = width + while not self._free[w]: + w += 1 + while w > width: + offset = self._free[w].pop(0) + w -= 1 + self._free[w] = [offset, offset ^ (1 << w)] + self._dirty = True + return self._free[width].pop(0) + + def allocate(self, bytes, block=None): + """Allocate or reallocate a block such that it has space for at least + `bytes' bytes.""" + if block is None: + # Find the first unused block + try: + block = self._offsets.index(0) + except ValueError: + block = len(self._offsets) + self._offsets.append(0) + + # Compute block width + width = max(bytes.bit_length(), 5) + + addr = self._offsets[block] + offset = addr & ~0x1f + + if addr: + blkwidth = addr & 0x1f + if blkwidth == width: + return block + self._release(offset, width) + self._offsets[block] = 0 + + offset = self._alloc(width) + self._offsets[block] = offset | width + return block + + def release(self, block): + addr = self._offsets[block] + + if addr: + width = addr & 0x1f + offset = addr & ~0x1f + self._release(offset, width) + + if block == len(self._offsets): + del self._offsets[block] + else: + self._offsets[block] = 0 + + def __len__(self): + return len(self._toc) + + def __getitem__(self, key): + if not isinstance(key, (str, unicode)): + raise TypeError('Keys must be of string type') + if not isinstance(key, bytes): + key = key.encode('latin_1') + return self._toc[key] + + def __setitem__(self, key, value): + if not isinstance(key, (str, unicode)): + raise TypeError('Keys must be of string type') + if not isinstance(key, bytes): + key = key.encode('latin_1') + self._toc[key] = value + self._dirty = True + + def __delitem__(self, key): + if not isinstance(key, (str, unicode)): + raise TypeError('Keys must be of string type') + if not isinstance(key, bytes): + key = key.encode('latin_1') + del self._toc[key] + self._dirty = True + + def iterkeys(self): + return iterkeys(self._toc) + + def keys(self): + return iterkeys(self._toc) + + def __iter__(self): + return iterkeys(self._toc) + + def __contains__(self, key): + return key in self._toc + diff --git a/src/3rdparty/python/lib/python2.7/site-packages/ds_store/qt_attribution.json b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/qt_attribution.json new file mode 100644 index 00000000..a4854d1e --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "ds_store", + "Name": "ds_store", + "QDocModule": "qbs", + "QtUsage": "Used in the qbs dmg module for building Apple disk images.", + "Description": "Manipulate Finder .DS_Store files from Python", + "Homepage": "https://github.com/al45tair/ds_store", + "Version": "1.1.2", + "License": "MIT License", + "LicenseId": "MIT", + "LicenseFile": "LICENSE", + "Copyright": "Copyright (c) 2014 Alastair Houghton" +} diff --git a/src/3rdparty/python/lib/python2.7/site-packages/ds_store/store.py b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/store.py new file mode 100644 index 00000000..b6f805b2 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/ds_store/store.py @@ -0,0 +1,1251 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +from __future__ import print_function +from __future__ import division + +import binascii +import struct +import biplist +import mac_alias + +try: + next +except NameError: + next = lambda x: x.next() +try: + unicode +except NameError: + unicode = str + +from . import buddy + +class ILocCodec(object): + @staticmethod + def encode(point): + return struct.pack(b'>IIII', point[0], point[1], + 0xffffffff, 0xffff0000) + + @staticmethod + def decode(bytesData): + if isinstance(bytesData, bytearray): + x, y = struct.unpack_from(b'>II', bytes(bytesData[:8])) + else: + x, y = struct.unpack(b'>II', bytesData[:8]) + return (x, y) + +class PlistCodec(object): + @staticmethod + def encode(plist): + return biplist.writePlistToString(plist) + + @staticmethod + def decode(bytes): + return biplist.readPlistFromString(bytes) + +class BookmarkCodec(object): + @staticmethod + def encode(bmk): + return bmk.to_bytes() + + @staticmethod + def decode(bytes): + return mac_alias.Bookmark.from_bytes(bytes) + +# This list tells the code how to decode particular kinds of entry in the +# .DS_Store file. This is really a convenience, and we currently only +# support a tiny subset of the possible entry types. +codecs = { + b'Iloc': ILocCodec, + b'bwsp': PlistCodec, + b'lsvp': PlistCodec, + b'lsvP': PlistCodec, + b'icvp': PlistCodec, + b'pBBk': BookmarkCodec + } + +class DSStoreEntry(object): + """Holds the data from an entry in a ``.DS_Store`` file. Note that this is + not meant to represent the entry itself---i.e. if you change the type + or value, your changes will *not* be reflected in the underlying file. + + If you want to make a change, you should either use the :class:`DSStore` + object's :meth:`DSStore.insert` method (which will replace a key if it + already exists), or the mapping access mode for :class:`DSStore` (often + simpler anyway). + """ + def __init__(self, filename, code, typecode, value=None): + if str != bytes and type(filename) == bytes: + filename = filename.decode('utf-8') + + if not isinstance(code, bytes): + code = code.encode('latin_1') + + self.filename = filename + self.code = code + self.type = typecode + self.value = value + + @classmethod + def read(cls, block): + """Read a ``.DS_Store`` entry from the containing Block""" + # First read the filename + nlen = block.read(b'>I')[0] + filename = block.read(2 * nlen).decode('utf-16be') + + # Next, read the code and type + code, typecode = block.read(b'>4s4s') + + # Finally, read the data + if typecode == b'bool': + value = block.read(b'>?')[0] + elif typecode == b'long' or typecode == b'shor': + value = block.read(b'>I')[0] + elif typecode == b'blob': + vlen = block.read(b'>I')[0] + value = block.read(vlen) + + codec = codecs.get(code, None) + if codec: + value = codec.decode(value) + typecode = codec + elif typecode == b'ustr': + vlen = block.read(b'>I')[0] + value = block.read(2 * vlen).decode('utf-16be') + elif typecode == b'type': + value = block.read(b'>4s')[0] + elif typecode == b'comp' or typecode == b'dutc': + value = block.read(b'>Q')[0] + else: + raise ValueError('Unknown type code "%s"' % typecode) + + return DSStoreEntry(filename, code, typecode, value) + + def __lt__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + return (sfl < ofl + or (self.filename == other.filename + and self.code < other.code)) + + def __le__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + return (sfl < ofl + or (sfl == ofl + and self.code <= other.code)) + + def __eq__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + return (sfl == ofl + and self.code == other.code) + + def __ne__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + return (sfl != ofl + or self.code != other.code) + + def __gt__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + + selfCode = self.code + if str != bytes and type(selfCode) is bytes: + selfCode = selfCode.decode('utf-8') + otherCode = other.code + if str != bytes and type(otherCode) is bytes: + otherCode = otherCode.decode('utf-8') + + return (sfl > ofl or (sfl == ofl and selfCode > otherCode)) + + def __ge__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + sfl = self.filename.lower() + ofl = other.filename.lower() + return (sfl > ofl + or (sfl == ofl + and self.code >= other.code)) + + def __cmp__(self, other): + if not isinstance(other, DSStoreEntry): + raise TypeError('Can only compare against other DSStoreEntry objects') + r = cmp(self.filename.lower(), other.filename.lower()) + if r: + return r + return cmp(self.code, other.code) + + def byte_length(self): + """Compute the length of this entry, in bytes""" + utf16 = self.filename.encode('utf-16be') + l = 4 + len(utf16) + 8 + + if isinstance(self.type, unicode): + entry_type = self.type.encode('latin_1') + value = self.value + elif isinstance(self.type, (bytes, str)): + entry_type = self.type + value = self.value + else: + entry_type = b'blob' + value = self.type.encode(self.value) + + if entry_type == b'bool': + l += 1 + elif entry_type == b'long' or entry_type == b'shor': + l += 4 + elif entry_type == b'blob': + l += 4 + len(value) + elif entry_type == b'ustr': + utf16 = value.encode('utf-16be') + l += 4 + len(utf16) + elif entry_type == b'type': + l += 4 + elif entry_type == b'comp' or entry_type == b'dutc': + l += 8 + else: + raise ValueError('Unknown type code "%s"' % entry_type) + + return l + + def write(self, block, insert=False): + """Write this entry to the specified Block""" + if insert: + w = block.insert + else: + w = block.write + + if isinstance(self.type, unicode): + entry_type = self.type.encode('latin_1') + value = self.value + elif isinstance(self.type, (bytes, str)): + entry_type = self.type + value = self.value + else: + entry_type = b'blob' + value = self.type.encode(self.value) + + utf16 = self.filename.encode('utf-16be') + w(b'>I', len(utf16) // 2) + w(utf16) + w(b'>4s4s', self.code, entry_type) + + if entry_type == b'bool': + w(b'>?', value) + elif entry_type == b'long' or entry_type == b'shor': + w(b'>I', value) + elif entry_type == b'blob': + w(b'>I', len(value)) + w(value) + elif entry_type == b'ustr': + utf16 = value.encode('utf-16be') + w(b'>I', len(utf16) // 2) + w(utf16) + elif entry_type == b'type': + if isinstance(value, unicode): + value = value.encode('latin_1') + w(b'>4s', value) + elif entry_type == b'comp' or entry_type == b'dutc': + w(b'>Q', value) + else: + raise ValueError('Unknown type code "%s"' % entry_type) + + def __repr__(self): + return '<%s %s>' % (self.filename, self.code) + +class DSStore(object): + """Python interface to a ``.DS_Store`` file. Works by manipulating the file + on the disk---so this code will work with ``.DS_Store`` files for *very* + large directories. + + A :class:`DSStore` object can be used as if it was a mapping, e.g.:: + + d['foobar.dat']['Iloc'] + + will fetch the "Iloc" record for "foobar.dat", or raise :class:`KeyError` if + there is no such record. If used in this manner, the :class:`DSStore` object + will return (type, value) tuples, unless the type is "blob" and the module + knows how to decode it. + + Currently, we know how to decode "Iloc", "bwsp", "lsvp", "lsvP" and "icvp" + blobs. "Iloc" decodes to an (x, y) tuple, while the others are all decoded + using ``biplist``. + + Assignment also works, e.g.:: + + d['foobar.dat']['note'] = ('ustr', u'Hello World!') + + as does deletion with ``del``:: + + del d['foobar.dat']['note'] + + This is usually going to be the most convenient interface, though + occasionally (for instance when creating a new ``.DS_Store`` file) you + may wish to drop down to using :class:`DSStoreEntry` objects directly.""" + def __init__(self, store): + self._store = store + self._superblk = self._store['DSDB'] + with self._get_block(self._superblk) as s: + self._rootnode, self._levels, self._records, \ + self._nodes, self._page_size = s.read(b'>IIIII') + self._min_usage = 2 * self._page_size // 3 + self._dirty = False + + @classmethod + def open(cls, file_or_name, mode='r+', initial_entries=None): + """Open a ``.DS_Store`` file; pass either a Python file object, or a + filename in the ``file_or_name`` argument and a file access mode in + the ``mode`` argument. If you are creating a new file using the "w" + or "w+" modes, you may also specify a list of entries with which + to initialise the file.""" + store = buddy.Allocator.open(file_or_name, mode) + + if mode == 'w' or mode == 'w+': + superblk = store.allocate(20) + store['DSDB'] = superblk + page_size = 4096 + + if not initial_entries: + root = store.allocate(page_size) + + with store.get_block(root) as rootblk: + rootblk.zero_fill() + + with store.get_block(superblk) as s: + s.write(b'>IIIII', root, 0, 0, 1, page_size) + else: + # Make sure they're in sorted order + initial_entries = list(initial_entries) + initial_entries.sort() + + # Construct the tree + current_level = initial_entries + next_level = [] + levels = [] + ptr_size = 0 + node_count = 0 + while True: + total = 8 + nodes = [] + node = [] + for e in current_level: + new_total = total + ptr_size + e.byte_length() + if new_total > page_size: + nodes.append(node) + next_level.append(e) + total = 8 + node = [] + else: + total = new_total + node.append(e) + if node: + nodes.append(node) + + node_count += len(nodes) + levels.append(nodes) + + if len(nodes) == 1: + break + + current_level = next_level + next_level = [] + ptr_size = 4 + + # Allocate nodes + ptrs = [store.allocate(page_size) for n in range(node_count)] + + # Generate nodes + pointers = [] + prev_pointers = None + for level in levels: + ppndx = 0 + lptrs = ptrs[-len(level):] + del ptrs[-len(level):] + for node in level: + ndx = lptrs.pop(0) + if prev_pointers is None: + with store.get_block(ndx) as block: + block.write(b'>II', 0, len(node)) + for e in node: + e.write(block) + else: + next_node = prev_pointers[ppndx + len(node)] + node_ptrs = prev_pointers[ppndx:ppndx+len(node)] + + with store.get_block(ndx) as block: + block.write(b'>II', next_node, len(node)) + for ptr, e in zip(node_ptrs, node): + block.write(b'>I', ptr) + e.write(block) + + pointers.append(ndx) + prev_pointers = pointers + pointers = [] + + root = prev_pointers[0] + + with store.get_block(superblk) as s: + s.write(b'>IIIII', root, len(levels), len(initial_entries), + node_count, page_size) + + return DSStore(store) + + def _get_block(self, number): + return self._store.get_block(number) + + def flush(self): + """Flush any dirty data back to the file.""" + if self._dirty: + self._dirty = False + + with self._get_block(self._superblk) as s: + s.write(b'>IIIII', self._rootnode, self._levels, self._records, + self._nodes, self._page_size) + self._store.flush() + + def close(self): + """Flush dirty data and close the underlying file.""" + self.flush() + self._store.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + # Internal B-Tree nodes look like this: + # + # [ next | count | (ptr0 | rec0) | (ptr1 | rec1) ... (ptrN | recN) ] + + # Leaf nodes look like this: + # + # [ 0 | count | rec0 | rec1 ... recN ] + + # Iterate over the tree, starting at `node' + def _traverse(self, node): + if node is None: + node = self._rootnode + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + if next_node: + for n in range(count): + ptr = block.read(b'>I')[0] + for e in self._traverse(ptr): + yield e + e = DSStoreEntry.read(block) + yield e + for e in self._traverse(next_node): + yield e + else: + for n in range(count): + e = DSStoreEntry.read(block) + yield e + + # Display the data in `node' + def _dump_node(self, node): + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + print('next: %u\ncount: %u\n' % (next_node, count)) + for n in range(count): + if next_node: + ptr = block.read(b'>I')[0] + print('%8u ' % ptr, end=' ') + else: + print(' ', end=' ') + e = DSStoreEntry.read(block) + print(e, ' (%u)' % e.byte_length()) + print('used: %u' % block.tell()) + + # Display the data in the super block + def _dump_super(self): + print('root: %u\nlevels: %u\nrecords: %u\nnodes: %u\npage-size: %u' \ + % (self._rootnode, self._levels, self._records, + self._nodes, self._page_size)) + + # Splits entries across two blocks, returning one pivot + # + # Tries to balance the block usage across the two as best it can + def _split2(self, blocks, entries, pointers, before, internal): + left_block = blocks[0] + right_block = blocks[1] + + count = len(entries) + + # Find the feasible splits + best_split = None + best_diff = None + total = before[count] + + if 8 + total <= self._page_size: + # We can use a *single* node for this + best_split = count + else: + # Split into two nodes + for n in range(1, count - 1): + left_size = 8 + before[n] + right_size = 8 + total - before[n + 1] + + if left_size > self._page_size: + break + if right_size > self._page_size: + continue + + diff = abs(left_size - right_size) + + if best_split is None or diff < best_diff: + best_split = n + best_diff = diff + + if best_split is None: + return None + + # Write the nodes + left_block.seek(0) + if internal: + next_node = pointers[best_split] + else: + next_node = 0 + left_block.write(b'>II', next_node, best_split) + + for n in range(best_split): + if internal: + left_block.write(b'>I', pointers[n]) + entries[n].write(left_block) + + left_block.zero_fill() + + if best_split == count: + return [] + + right_block.seek(0) + if internal: + next_node = pointers[count] + else: + next_node = 0 + right_block.write(b'>II', next_node, count - best_split - 1) + + for n in range(best_split + 1, count): + if internal: + right_block.write(b'>I', pointers[n]) + entries[n].write(right_block) + + right_block.zero_fill() + + pivot = entries[best_split] + + return [pivot] + + def _split(self, node, entry, right_ptr=0): + self._nodes += 1 + self._dirty = True + new_right = self._store.allocate(self._page_size) + with self._get_block(node) as block, \ + self._get_block(new_right) as right_block: + + # First, measure and extract all the elements + entry_size = entry.byte_length() + entry_pos = None + next_node, count = block.read(b'>II') + if next_node: + entry_size += 4 + pointers = [] + entries = [] + before = [] + total = 0 + for n in range(count): + pos = block.tell() + if next_node: + ptr = block.read(b'>I')[0] + pointers.append(ptr) + e = DSStoreEntry.read(block) + if e > entry: + entry_pos = n + entries.append(entry) + pointers.append(right_ptr) + before.append(total) + total += entry_size + entries.append(e) + before.append(total) + total += block.tell() - pos + before.append(total) + if next_node: + pointers.append(next_node) + + pivot = self._split2([block, right_block], + entries, pointers, before, + bool(next_node))[0] + + self._records += 1 + self._nodes += 1 + self._dirty = True + + return (pivot, new_right) + + # Allocate a new root node containing the element `pivot' and the pointers + # `left' and `right' + def _new_root(self, left, pivot, right): + new_root = self._store.allocate(self._page_size) + with self._get_block(new_root) as block: + block.write(b'>III', right, 1, left) + pivot.write(block) + self._rootnode = new_root + self._levels += 1 + self._nodes += 1 + self._dirty = True + + # Insert an entry into an inner node; `path' is the path from the root + # to `node', not including `node' itself. `right_ptr' is the new node + # pointer (inserted to the RIGHT of `entry') + def _insert_inner(self, path, node, entry, right_ptr): + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + insert_pos = None + insert_ndx = None + n = 0 + while n < count: + pos = block.tell() + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + if e == entry: + if n == count - 1: + right_ptr = next_node + next_node = ptr + block_seek(pos) + else: + right_ptr = block.read(b'>I')[0] + block.seek(pos + 4) + insert_pos = pos + insert_ndx = n + block.delete(e.byte_length() + 4) + count -= 1 + self._records += 1 + self._dirty = True + continue + elif insert_pos is None and e > entry: + insert_pos = pos + insert_ndx = n + n += 1 + if insert_pos is None: + insert_pos = block.tell() + insert_ndx = count + remaining = self._page_size - block.tell() + + if remaining < entry.byte_length() + 4: + pivot, new_right = self._split(node, entry, right_ptr) + if path: + self._insert_inner(path[:-1], path[-1], pivot, new_right) + else: + self._new_root(node, pivot, new_right) + else: + if insert_ndx == count: + block.seek(insert_pos) + block.write(b'>I', next_node) + entry.write(block) + next_node = right_ptr + else: + block.seek(insert_pos + 4) + entry.write(block, True) + block.insert('>I', right_ptr) + block.seek(0) + count += 1 + block.write(b'>II', next_node, count) + self._records += 1 + self._dirty = True + + # Insert `entry' into the leaf node `node' + def _insert_leaf(self, path, node, entry): + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + insert_pos = None + insert_ndx = None + n = 0 + while n < count: + pos = block.tell() + e = DSStoreEntry.read(block) + if e == entry: + insert_pos = pos + insert_ndx = n + block.seek(pos) + block.delete(e.byte_length()) + count -= 1 + self._records += 1 + self._dirty = True + continue + elif insert_pos is None and e > entry: + insert_pos = pos + insert_ndx = n + n += 1 + if insert_pos is None: + insert_pos = block.tell() + insert_ndx = count + remaining = self._page_size - block.tell() + + if remaining < entry.byte_length(): + pivot, new_right = self._split(node, entry) + if path: + self._insert_inner(path[:-1], path[-1], pivot, new_right) + else: + self._new_root(node, pivot, new_right) + else: + block.seek(insert_pos) + entry.write(block, True) + block.seek(0) + count += 1 + block.write(b'>II', next_node, count) + self._records += 1 + self._dirty = True + + def insert(self, entry): + """Insert ``entry`` (which should be a :class:`DSStoreEntry`) + into the B-Tree.""" + path = [] + node = self._rootnode + while True: + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + if next_node: + for n in range(count): + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + if entry < e: + next_node = ptr + break + elif entry == e: + # If we find an existing entry the same, replace it + self._insert_inner(path, node, entry, None) + return + path.append(node) + node = next_node + else: + self._insert_leaf(path, node, entry) + return + + # Return usage information for the specified `node' + def _block_usage(self, node): + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + + for n in range(count): + if next_node: + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + + used = block.tell() + + return (count, used) + + # Splits entries across three blocks, returning two pivots + def _split3(self, blocks, entries, pointers, before, internal): + count = len(entries) + + # Find the feasible splits + best_split = None + best_diff = None + total = before[count] + for n in range(1, count - 3): + left_size = 8 + before[n] + remaining = 16 + total - before[n + 1] + + if left_size > self._page_size: + break + if remaining > 2 * self._page_size: + continue + + for m in range(n + 2, count - 1): + mid_size = 8 + before[m] - before[n + 1] + right_size = 8 + total - before[m + 1] + + if mid_size > self._page_size: + break + if right_size > self._page_size: + continue + + diff = abs(left_size - mid_size) * abs(right_size - mid_size) + + if best_split is None or diff < best_diff: + best_split = (n, m, count) + best_diff = diff + + if best_split is None: + return None + + # Write the nodes + prev_split = -1 + for block, split in zip(blocks, best_split): + block.seek(0) + if internal: + next_node = pointers[split] + else: + next_node = 0 + block.write(b'>II', next_node, split) + + for n in range(prev_split + 1, split): + if internal: + block.write(b'>I', pointers[n]) + entries[n].write(block) + + block.zero_fill() + + prev_split = split + + return (entries[best_split[0]], entries[best_split[1]]) + + # Extract all of the entries from the specified list of `blocks', + # separating them by the specified `pivots'. Also computes the + # amount of space used before each entry. + def _extract(self, blocks, pivots): + pointers = [] + entries = [] + before = [] + total = 0 + ppivots = pivots + [None] + for b,p in zip(blocks, ppivots): + b.seek(0) + next_node, count = b.read(b'>II') + for n in range(count): + pos = b.tell() + if next_node: + ptr = b.read(b'>I')[0] + pointers.append(ptr) + e = DSStoreEntry.read(b) + entries.append(e) + before.append(total) + total += b.tell() - pos + if next_node: + pointers.append(next_node) + if p: + entries.append(p) + before.append(total) + total += p.byte_length() + if next_node: + total += 4 + before.append(total) + + return (entries, pointers, before) + + # Rebalance the specified `node', whose path from the root is `path'. + def _rebalance(self, path, node): + # Can't rebalance the root + if not path: + return + + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + + with self._get_block(path[-1]) as parent: + # Find the left and right siblings and respective pivots + parent_next, parent_count = parent.read(b'>II') + left_pos = None + left_node = None + left_pivot = None + node_pos = None + right_pos = None + right_node = None + right_pivot = None + prev_e = prev_ptr = prev_pos = None + for n in range(parent_count): + pos = parent.tell() + ptr = parent.read(b'>I')[0] + e = DSStoreEntry.read(parent) + + if ptr == node: + node_pos = pos + right_pivot = e + left_pos = prev_pos + left_pivot = prev_e + left_node = prev_ptr + elif prev_ptr == node: + right_node = ptr + right_pos = pos + break + + prev_e = e + prev_ptr = ptr + prev_pos = pos + + if parent_next == node: + node_pos = parent.tell() + left_pos = prev_pos + left_pivot = prev_e + left_node = prev_ptr + elif right_node is None: + right_node = parent_next + right_pos = parent.tell() + + parent_used = parent.tell() + + if left_node and right_node: + with self._get_block(left_node) as left, \ + self._get_block(right_node) as right: + blocks = [left, block, right] + pivots = [left_pivot, right_pivot] + + entries, pointers, before = self._extract(blocks, pivots) + + # If there's a chance that we could use two pages instead + # of three, go for it + pivots = self._split2(blocks, entries, pointers, + before, bool(next_node)) + if pivots is None: + ptrs = [left_node, node, right_node] + pivots = self._split3(blocks, entries, pointers, + before, bool(next_node)) + else: + if pivots: + ptrs = [left_node, node] + else: + ptrs = [left_node] + self._store.release(node) + self._nodes -= 1 + node = left_node + self._store.release(right_node) + self._nodes -= 1 + self._dirty = True + + # Remove the pivots from the parent + with self._get_block(path[-1]) as parent: + if right_node == parent_next: + parent.seek(left_pos) + parent.delete(right_pos - left_pos) + parent_next = left_node + else: + parent.seek(left_pos + 4) + parent.delete(right_pos - left_pos) + parent.seek(0) + parent_count -= 2 + parent.write(b'>II', parent_next, parent_count) + self._records -= 2 + + # Replace with those in pivots + for e,rp in zip(pivots, ptrs[1:]): + self._insert_inner(path[:-1], path[-1], e, rp) + elif left_node: + with self._get_block(left_node) as left: + blocks = [left, block] + pivots = [left_pivot] + + entries, pointers, before = self._extract(blocks, pivots) + + pivots = self._split2(blocks, entries, pointers, + before, bool(next_node)) + + # Remove the pivot from the parent + with self._get_block(path[-1]) as parent: + if node == parent_next: + parent.seek(left_pos) + parent.delete(node_pos - left_pos) + parent_next = left_node + else: + parent.seek(left_pos + 4) + parent.delete(node_pos - left_pos) + parent.seek(0) + parent_count -= 1 + parent.write(b'>II', parent_next, parent_count) + self._records -= 1 + + # Replace the pivot + if pivots: + self._insert_inner(path[:-1], path[-1], pivots[0], node) + elif right_node: + with self._get_block(right_node) as right: + blocks = [block, right] + pivots = [right_pivot] + + entries, pointers, before = self._extract(blocks, pivots) + + pivots = self._split2(blocks, entries, pointers, + before, bool(next_node)) + + # Remove the pivot from the parent + with self._get_block(path[-1]) as parent: + if right_node == parent_next: + parent.seek(pos) + parent.delete(right_pos - node_pos) + parent_next = node + else: + parent.seek(pos + 4) + parent.delete(right_pos - node_pos) + parent.seek(0) + parent_count -= 1 + parent.write(b'>II', parent_next, parent_count) + self._records -= 1 + + # Replace the pivot + if pivots: + self._insert_inner(path[:-1], path[-1], pivots[0], + right_node) + + if not path and not parent_count: + self._store.release(path[-1]) + self._nodes -= 1 + self._dirty = True + self._rootnode = node + else: + count, used = self._block_usage(path[-1]) + + if used < self._page_size // 2: + self._rebalance(path[:-1], path[-1]) + + # Delete from the leaf node `node'. `filename_lc' has already been + # lower-cased. + def _delete_leaf(self, node, filename_lc, code): + found = False + + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + + for n in range(count): + pos = block.tell() + e = DSStoreEntry.read(block) + if e.filename.lower() == filename_lc \ + and (code is None or e.code == code): + block.seek(pos) + block.delete(e.byte_length()) + found = True + + # This does not affect the loop; THIS IS NOT A BUG + count -= 1 + + self._records -= 1 + self._dirty = True + + if found: + used = block.tell() + + block.seek(0) + block.write(b'>II', next_node, count) + + return used < self._page_size // 2 + else: + return False + + # Remove the largest entry from the subtree starting at `node' (with + # path from root `path'). Returns a tuple (rebalance, entry) where + # rebalance is either None if no rebalancing is required, or a + # (path, node) tuple giving the details of the node to rebalance. + def _take_largest(self, path, node): + path = list(path) + rebalance = None + while True: + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + + if next_node: + path.append(node) + node = next_node + continue + + for n in range(count): + pos = block.tell() + e = DSStoreEntry.read(block) + + count -= 1 + block.seek(0) + block.write(b'>II', next_node, count) + + if pos < self._page_size // 2: + rebalance = (path, node) + break + + return rebalance, e + + # Delete an entry from an inner node, `node' + def _delete_inner(self, path, node, filename_lc, code): + rebalance = False + + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + + for n in range(count): + pos = block.tell() + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + if e.filename.lower() == filename_lc \ + and (code is None or e.code == code): + # Take the largest from the left subtree + rebalance, largest = self._take_largest(path, ptr) + + # Delete this entry + if n == count - 1: + right_ptr = next_node + next_node = ptr + block.seek(pos) + else: + right_ptr = block.read(b'>I')[0] + block.seek(pos + 4) + + block.delete(e.byte_length() + 4) + + count -= 1 + block.seek(0) + block.write(b'>II', next_node, count) + + self._records -= 1 + self._dirty = True + + break + + # Replace the pivot value + self._insert_inner(path, node, largest, right_ptr) + + # Rebalance from the node we stole from + if rebalance: + self._rebalance(rebalance[0], rebalance[1]) + return True + return False + + def delete(self, filename, code): + """Delete an item, identified by ``filename`` and ``code`` + from the B-Tree.""" + if isinstance(filename, DSStoreEntry): + code = filename.code + filename = filename.filename + + # If we're deleting *every* node for "filename", we must recurse + if code is None: + ###TODO: Fix this so we can do bulk deletes + raise ValueError('You must delete items individually. Sorry') + + # Otherwise, we're deleting *one* specific node + filename_lc = filename.lower() + path = [] + node = self._rootnode + while True: + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + if next_node: + for n in range(count): + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + e_lc = e.filename.lower() + if filename_lc < e_lc \ + or (filename_lc == e_lc and code < e.code): + next_node = ptr + break + elif filename_lc == e_lc and code == e.code: + self._delete_inner(path, node, filename_lc, code) + return + path.append(node) + node = next_node + else: + if self._delete_leaf(node, filename_lc, code): + self._rebalance(path, node) + return + + # Find implementation + def _find(self, node, filename_lc, code=None): + if not isinstance(code, bytes): + code = code.encode('latin_1') + with self._get_block(node) as block: + next_node, count = block.read(b'>II') + if next_node: + for n in range(count): + ptr = block.read(b'>I')[0] + e = DSStoreEntry.read(block) + if filename_lc < e.filename.lower(): + for e in self._find(ptr, filename_lc, code): + yield e + return + elif filename_lc == e.filename.lower(): + if code is None or (code and code < e.code): + for e in self._find(ptr, filename_lc, code): + yield e + if code is None or code == e.code: + yield e + elif code < e.code: + return + for e in self._find(next_node, filename_lc, code): + yield e + else: + for n in range(count): + e = DSStoreEntry.read(block) + if filename_lc == e.filename.lower(): + if code is None or code == e.code: + yield e + elif code < e.code: + return + + def find(self, filename, code=None): + """Returns a generator that will iterate over matching entries in + the B-Tree.""" + if isinstance(filename, DSStoreEntry): + code = filename.code + filename = filename.filename + + filename_lc = filename.lower() + + return self._find(self._rootnode, filename_lc, code) + + def __len__(self): + return self._records + + def __iter__(self): + return self._traverse(self._rootnode) + + class Partial(object): + """This is used to implement indexing.""" + def __init__(self, store, filename): + self._store = store + self._filename = filename + + def __getitem__(self, code): + if code is None: + raise KeyError('no such key - [%s][None]' % self._filename) + + if not isinstance(code, bytes): + code = code.encode('latin_1') + + try: + item = next(self._store.find(self._filename, code)) + except StopIteration: + raise KeyError('no such key - [%s][%s]' % (self._filename, + code)) + + if not isinstance(item.type, (bytes, str, unicode)): + return item.value + + return (item.type, item.value) + + def __setitem__(self, code, value): + if code is None: + raise KeyError('bad key - [%s][None]' % self._filename) + + if not isinstance(code, bytes): + code = code.encode('latin_1') + + codec = codecs.get(code, None) + if codec: + entry_type = codec + entry_value = value + else: + entry_type = value[0] + entry_value = value[1] + + self._store.insert(DSStoreEntry(self._filename, code, + entry_type, entry_value)) + + def __delitem__(self, code): + if code is None: + raise KeyError('no such key - [%s][None]' % self._filename) + + self._store.delete(self._filename, code) + + def __iter__(self): + for item in self._store.find(self._filename): + yield item + + def __getitem__(self, filename): + return self.Partial(self, filename) + diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/LICENSE b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/LICENSE new file mode 100644 index 00000000..e91f4eb3 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/__init__.py b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/__init__.py new file mode 100644 index 00000000..7eb31410 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/__init__.py @@ -0,0 +1,27 @@ +from .alias import * +from .bookmark import * + +__all__ = [ 'ALIAS_KIND_FILE', 'ALIAS_KIND_FOLDER', + 'ALIAS_HFS_VOLUME_SIGNATURE', + 'ALIAS_FIXED_DISK', 'ALIAS_NETWORK_DISK', 'ALIAS_400KB_FLOPPY_DISK', + 'ALIAS_800KB_FLOPPY_DISK', 'ALIAS_1_44MB_FLOPPY_DISK', + 'ALIAS_EJECTABLE_DISK', + 'ALIAS_NO_CNID', + 'kBookmarkPath', 'kBookmarkCNIDPath', 'kBookmarkFileProperties', + 'kBookmarkFileName', 'kBookmarkFileID', 'kBookmarkFileCreationDate', + 'kBookmarkTOCPath', 'kBookmarkVolumePath', + 'kBookmarkVolumeURL', 'kBookmarkVolumeName', 'kBookmarkVolumeUUID', + 'kBookmarkVolumeSize', 'kBookmarkVolumeCreationDate', + 'kBookmarkVolumeProperties', 'kBookmarkContainingFolder', + 'kBookmarkUserName', 'kBookmarkUID', 'kBookmarkWasFileReference', + 'kBookmarkCreationOptions', 'kBookmarkURLLengths', + 'kBookmarkSecurityExtension', + 'AppleShareInfo', + 'VolumeInfo', + 'TargetInfo', + 'Alias', + 'Bookmark', + 'Data', + 'URL' ] + + diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/alias.py b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/alias.py new file mode 100644 index 00000000..f74b949e --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/alias.py @@ -0,0 +1,607 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +from __future__ import division + +import struct +import datetime +import io +import re +import os +import os.path +import stat +import sys + +if sys.platform == 'darwin': + from . import osx + +try: + long +except NameError: + long = int + +from .utils import * + +ALIAS_KIND_FILE = 0 +ALIAS_KIND_FOLDER = 1 + +ALIAS_HFS_VOLUME_SIGNATURE = b'H+' + +ALIAS_FIXED_DISK = 0 +ALIAS_NETWORK_DISK = 1 +ALIAS_400KB_FLOPPY_DISK = 2 +ALIAS_800KB_FLOPPY_DISK = 3 +ALIAS_1_44MB_FLOPPY_DISK = 4 +ALIAS_EJECTABLE_DISK = 5 + +ALIAS_NO_CNID = 0xffffffff + +def encode_utf8(s): + if isinstance(s, bytes): + return s + return s.encode('utf-8') + +def decode_utf8(s): + if isinstance(s, bytes): + return s.decode('utf-8') + return s + +class AppleShareInfo (object): + def __init__(self, zone=None, server=None, user=None): + #: The AppleShare zone + self.zone = zone + #: The AFP server + self.server = server + #: The username + self.user = user + + def __repr__(self): + return 'AppleShareInfo(%r,%r,%r)' % (self.zone, self.server, self.user) + +class VolumeInfo (object): + def __init__(self, name, creation_date, fs_type, disk_type, + attribute_flags, fs_id, appleshare_info=None, + driver_name=None, posix_path=None, disk_image_alias=None, + dialup_info=None, network_mount_info=None): + #: The name of the volume on which the target resides + self.name = name + + #: The creation date of the target's volume + self.creation_date = creation_date + + #: The filesystem type (a two character code, e.g. ``b'H+'`` for HFS+) + self.fs_type = fs_type + + #: The type of disk; should be one of + #: + #: * ALIAS_FIXED_DISK + #: * ALIAS_NETWORK_DISK + #: * ALIAS_400KB_FLOPPY_DISK + #: * ALIAS_800KB_FLOPPY_DISK + #: * ALIAS_1_44MB_FLOPPY_DISK + #: * ALIAS_EJECTABLE_DISK + self.disk_type = disk_type + + #: Filesystem attribute flags (from HFS volume header) + self.attribute_flags = attribute_flags + + #: Filesystem identifier + self.fs_id = fs_id + + #: AppleShare information (for automatic remounting of network shares) + #: *(optional)* + self.appleshare_info = appleshare_info + + #: Driver name (*probably* contains a disk driver name on older Macs) + #: *(optional)* + self.driver_name = driver_name + + #: POSIX path of the mount point of the target's volume + #: *(optional)* + self.posix_path = posix_path + + #: :class:`Alias` object pointing at the disk image on which the + #: target's volume resides *(optional)* + self.disk_image_alias = disk_image_alias + + #: Dialup information (for automatic establishment of dialup connections) + self.dialup_info = dialup_info + + #: Network mount information (for automatic remounting) + self.network_mount_info = network_mount_info + + def __repr__(self): + args = ['name', 'creation_date', 'fs_type', 'disk_type', + 'attribute_flags', 'fs_id'] + values = [] + for a in args: + v = getattr(self, a) + values.append(repr(v)) + + kwargs = ['appleshare_info', 'driver_name', 'posix_path', + 'disk_image_alias', 'dialup_info', 'network_mount_info'] + for a in kwargs: + v = getattr(self, a) + if v is not None: + values.append('%s=%r' % (a, v)) + return 'VolumeInfo(%s)' % ','.join(values) + +class TargetInfo (object): + def __init__(self, kind, filename, folder_cnid, cnid, creation_date, + creator_code, type_code, levels_from=-1, levels_to=-1, + folder_name=None, cnid_path=None, carbon_path=None, + posix_path=None, user_home_prefix_len=None): + #: Either ALIAS_KIND_FILE or ALIAS_KIND_FOLDER + self.kind = kind + + #: The filename of the target + self.filename = filename + + #: The CNID (Catalog Node ID) of the target's containing folder; + #: CNIDs are similar to but different than traditional UNIX inode + #: numbers + self.folder_cnid = folder_cnid + + #: The CNID (Catalog Node ID) of the target + self.cnid = cnid + + #: The target's *creation* date. + self.creation_date = creation_date + + #: The target's Mac creator code (a four-character binary string) + self.creator_code = creator_code + + #: The target's Mac type code (a four-character binary string) + self.type_code = type_code + + #: The depth of the alias? Always seems to be -1 on OS X. + self.levels_from = levels_from + + #: The depth of the target? Always seems to be -1 on OS X. + self.levels_to = levels_to + + #: The (POSIX) name of the target's containing folder. *(optional)* + self.folder_name = folder_name + + #: The path from the volume root as a sequence of CNIDs. *(optional)* + self.cnid_path = cnid_path + + #: The Carbon path of the target *(optional)* + self.carbon_path = carbon_path + + #: The POSIX path of the target relative to the volume root. Note + #: that this may or may not have a leading '/' character, but it is + #: always relative to the containing volume. *(optional)* + self.posix_path = posix_path + + #: If the path points into a user's home folder, the number of folders + #: deep that we go before we get to that home folder. *(optional)* + self.user_home_prefix_len = user_home_prefix_len + + def __repr__(self): + args = ['kind', 'filename', 'folder_cnid', 'cnid', 'creation_date', + 'creator_code', 'type_code'] + values = [] + for a in args: + v = getattr(self, a) + values.append(repr(v)) + + if self.levels_from != -1: + values.append('levels_from=%r' % self.levels_from) + if self.levels_to != -1: + values.append('levels_to=%r' % self.levels_to) + + kwargs = ['folder_name', 'cnid_path', 'carbon_path', + 'posix_path', 'user_home_prefix_len'] + for a in kwargs: + v = getattr(self, a) + values.append('%s=%r' % (a, v)) + + return 'TargetInfo(%s)' % ','.join(values) + +TAG_CARBON_FOLDER_NAME = 0 +TAG_CNID_PATH = 1 +TAG_CARBON_PATH = 2 +TAG_APPLESHARE_ZONE = 3 +TAG_APPLESHARE_SERVER_NAME = 4 +TAG_APPLESHARE_USERNAME = 5 +TAG_DRIVER_NAME = 6 +TAG_NETWORK_MOUNT_INFO = 9 +TAG_DIALUP_INFO = 10 +TAG_UNICODE_FILENAME = 14 +TAG_UNICODE_VOLUME_NAME = 15 +TAG_HIGH_RES_VOLUME_CREATION_DATE = 16 +TAG_HIGH_RES_CREATION_DATE = 17 +TAG_POSIX_PATH = 18 +TAG_POSIX_PATH_TO_MOUNTPOINT = 19 +TAG_RECURSIVE_ALIAS_OF_DISK_IMAGE = 20 +TAG_USER_HOME_LENGTH_PREFIX = 21 + +class Alias (object): + def __init__(self, appinfo=b'\0\0\0\0', version=2, volume=None, + target=None, extra=[]): + """Construct a new :class:`Alias` object with the specified + contents.""" + + #: Application specific information (four byte byte-string) + self.appinfo = appinfo + + #: Version (we support only version 2) + self.version = version + + #: A :class:`VolumeInfo` object describing the target's volume + self.volume = volume + + #: A :class:`TargetInfo` object describing the target + self.target = target + + #: A list of extra `(tag, value)` pairs + self.extra = list(extra) + + @classmethod + def _from_fd(cls, b): + appinfo, recsize, version = struct.unpack(b'>4shh', b.read(8)) + + if recsize < 150: + raise ValueError('Incorrect alias length') + + if version != 2: + raise ValueError('Unsupported alias version %u' % version) + + kind, volname, voldate, fstype, disktype, \ + folder_cnid, filename, cnid, crdate, creator_code, type_code, \ + levels_from, levels_to, volattrs, volfsid, reserved = \ + struct.unpack(b'>h28pI2shI64pII4s4shhI2s10s', b.read(142)) + + voldate = mac_epoch + datetime.timedelta(seconds=voldate) + crdate = mac_epoch + datetime.timedelta(seconds=crdate) + + alias = Alias() + alias.appinfo = appinfo + + alias.volume = VolumeInfo (volname.decode().replace('/',':'), + voldate, fstype, disktype, + volattrs, volfsid) + alias.target = TargetInfo (kind, filename.decode().replace('/',':'), + folder_cnid, cnid, + crdate, creator_code, type_code) + alias.target.levels_from = levels_from + alias.target.levels_to = levels_to + + tag = struct.unpack(b'>h', b.read(2))[0] + + while tag != -1: + length = struct.unpack(b'>h', b.read(2))[0] + value = b.read(length) + if length & 1: + b.read(1) + + if tag == TAG_CARBON_FOLDER_NAME: + alias.target.folder_name = value.decode().replace('/',':') + elif tag == TAG_CNID_PATH: + alias.target.cnid_path = struct.unpack('>%uI' % (length // 4), + value) + elif tag == TAG_CARBON_PATH: + alias.target.carbon_path = value + elif tag == TAG_APPLESHARE_ZONE: + if alias.volume.appleshare_info is None: + alias.volume.appleshare_info = AppleShareInfo() + alias.volume.appleshare_info.zone = value + elif tag == TAG_APPLESHARE_SERVER_NAME: + if alias.volume.appleshare_info is None: + alias.volume.appleshare_info = AppleShareInfo() + alias.volume.appleshare_info.server = value + elif tag == TAG_APPLESHARE_USERNAME: + if alias.volume.appleshare_info is None: + alias.volume.appleshare_info = AppleShareInfo() + alias.volume.appleshare_info.user = value + elif tag == TAG_DRIVER_NAME: + alias.volume.driver_name = value + elif tag == TAG_NETWORK_MOUNT_INFO: + alias.volume.network_mount_info = value + elif tag == TAG_DIALUP_INFO: + alias.volume.dialup_info = value + elif tag == TAG_UNICODE_FILENAME: + alias.target.filename = value[2:].decode('utf-16be') + elif tag == TAG_UNICODE_VOLUME_NAME: + alias.volume.name = value[2:].decode('utf-16be') + elif tag == TAG_HIGH_RES_VOLUME_CREATION_DATE: + seconds = struct.unpack(b'>Q', value)[0] / 65536.0 + alias.volume.creation_date \ + = mac_epoch + datetime.timedelta(seconds=seconds) + elif tag == TAG_HIGH_RES_CREATION_DATE: + seconds = struct.unpack(b'>Q', value)[0] / 65536.0 + alias.target.creation_date \ + = mac_epoch + datetime.timedelta(seconds=seconds) + elif tag == TAG_POSIX_PATH: + alias.target.posix_path = value.decode() + elif tag == TAG_POSIX_PATH_TO_MOUNTPOINT: + alias.volume.posix_path = value.decode() + elif tag == TAG_RECURSIVE_ALIAS_OF_DISK_IMAGE: + alias.volume.disk_image_alias = Alias.from_bytes(value) + elif tag == TAG_USER_HOME_LENGTH_PREFIX: + alias.target.user_home_prefix_len = struct.unpack(b'>h', value)[0] + else: + alias.extra.append((tag, value)) + + tag = struct.unpack(b'>h', b.read(2))[0] + + return alias + + @classmethod + def from_bytes(cls, bytes): + """Construct an :class:`Alias` object given binary Alias data.""" + with io.BytesIO(bytes) as b: + return cls._from_fd(b) + + @classmethod + def for_file(cls, path): + """Create an :class:`Alias` that points at the specified file.""" + if sys.platform != 'darwin': + raise Exception('Not implemented (requires special support)') + + path = encode_utf8(path) + + a = Alias() + + # Find the filesystem + st = osx.statfs(path) + vol_path = st.f_mntonname + + # Grab its attributes + attrs = [osx.ATTR_CMN_CRTIME, + osx.ATTR_VOL_NAME, + 0, 0, 0] + volinfo = osx.getattrlist(vol_path, attrs, 0) + + vol_crtime = volinfo[0] + vol_name = encode_utf8(volinfo[1]) + + # Also grab various attributes of the file + attrs = [(osx.ATTR_CMN_OBJTYPE + | osx.ATTR_CMN_CRTIME + | osx.ATTR_CMN_FNDRINFO + | osx.ATTR_CMN_FILEID + | osx.ATTR_CMN_PARENTID), 0, 0, 0, 0] + info = osx.getattrlist(path, attrs, osx.FSOPT_NOFOLLOW) + + if info[0] == osx.VDIR: + kind = ALIAS_KIND_FOLDER + else: + kind = ALIAS_KIND_FILE + + cnid = info[3] + folder_cnid = info[4] + + dirname, filename = os.path.split(path) + + if dirname == b'' or dirname == b'.': + dirname = os.getcwd() + + foldername = os.path.basename(dirname) + + creation_date = info[1] + + if kind == ALIAS_KIND_FILE: + creator_code = struct.pack(b'I', info[2].fileInfo.fileCreator) + type_code = struct.pack(b'I', info[2].fileInfo.fileType) + else: + creator_code = b'\0\0\0\0' + type_code = b'\0\0\0\0' + + a.target = TargetInfo(kind, filename, folder_cnid, cnid, creation_date, + creator_code, type_code) + a.volume = VolumeInfo(vol_name, vol_crtime, b'H+', + ALIAS_FIXED_DISK, 0, b'\0\0') + + a.target.folder_name = foldername + a.volume.posix_path = vol_path + + rel_path = os.path.relpath(path, vol_path) + + # Leave off the initial '/' if vol_path is '/' (no idea why) + if vol_path == b'/': + a.target.posix_path = rel_path + else: + a.target.posix_path = b'/' + rel_path + + # Construct the Carbon and CNID paths + carbon_path = [] + cnid_path = [] + head, tail = os.path.split(rel_path) + if not tail: + head, tail = os.path.split(head) + while head or tail: + if head: + attrs = [osx.ATTR_CMN_FILEID, 0, 0, 0, 0] + info = osx.getattrlist(os.path.join(vol_path, head), attrs, 0) + cnid_path.append(info[0]) + carbon_tail = tail.replace(b':',b'/') + carbon_path.insert(0, carbon_tail) + head, tail = os.path.split(head) + + carbon_path = vol_name + b':' + b':\0'.join(carbon_path) + + a.target.carbon_path = carbon_path + a.target.cnid_path = cnid_path + + return a + + def _to_fd(self, b): + # We'll come back and fix the length when we're done + pos = b.tell() + b.write(struct.pack(b'>4shh', self.appinfo, 0, self.version)) + + carbon_volname = encode_utf8(self.volume.name).replace(b':',b'/') + carbon_filename = encode_utf8(self.target.filename).replace(b':',b'/') + voldate = (self.volume.creation_date - mac_epoch).total_seconds() + crdate = (self.target.creation_date - mac_epoch).total_seconds() + + # NOTE: crdate should be in local time, but that's system dependent + # (so doing so is ridiculous, and nothing could rely on it). + b.write(struct.pack(b'>h28pI2shI64pII4s4shhI2s10s', + self.target.kind, + carbon_volname, int(voldate), + self.volume.fs_type, + self.volume.disk_type, + self.target.folder_cnid, + carbon_filename, + self.target.cnid, + int(crdate), + self.target.creator_code, + self.target.type_code, + self.target.levels_from, + self.target.levels_to, + self.volume.attribute_flags, + self.volume.fs_id, + b'\0'*10)) + + # Excuse the odd order; we're copying Finder + if self.target.folder_name: + carbon_foldername = encode_utf8(self.target.folder_name)\ + .replace(b':',b'/') + b.write(struct.pack(b'>hh', TAG_CARBON_FOLDER_NAME, + len(carbon_foldername))) + b.write(carbon_foldername) + if len(carbon_foldername) & 1: + b.write(b'\0') + + b.write(struct.pack(b'>hhQhhQ', + TAG_HIGH_RES_VOLUME_CREATION_DATE, + 8, int(voldate * 65536), + TAG_HIGH_RES_CREATION_DATE, + 8, int(crdate * 65536))) + + if self.target.cnid_path: + cnid_path = struct.pack('>%uI' % len(self.target.cnid_path), + *self.target.cnid_path) + b.write(struct.pack(b'>hh', TAG_CNID_PATH, + len(cnid_path))) + b.write(cnid_path) + + if self.target.carbon_path: + carbon_path=encode_utf8(self.target.carbon_path) + b.write(struct.pack(b'>hh', TAG_CARBON_PATH, + len(carbon_path))) + b.write(carbon_path) + if len(carbon_path) & 1: + b.write(b'\0') + + if self.volume.appleshare_info: + ai = self.volume.appleshare_info + if ai.zone: + b.write(struct.pack(b'>hh', TAG_APPLESHARE_ZONE, + len(ai.zone))) + b.write(ai.zone) + if len(ai.zone) & 1: + b.write(b'\0') + if ai.server: + b.write(struct.pack(b'>hh', TAG_APPLESHARE_SERVER_NAME, + len(ai.server))) + b.write(ai.server) + if len(ai.server) & 1: + b.write(b'\0') + if ai.username: + b.write(struct.pack(b'>hh', TAG_APPLESHARE_USERNAME, + len(ai.username))) + b.write(ai.username) + if len(ai.username) & 1: + b.write(b'\0') + + if self.volume.driver_name: + driver_name = encode_utf8(self.volume.driver_name) + b.write(struct.pack(b'>hh', TAG_DRIVER_NAME, + len(driver_name))) + b.write(driver_name) + if len(driver_name) & 1: + b.write(b'\0') + + if self.volume.network_mount_info: + b.write(struct.pack(b'>hh', TAG_NETWORK_MOUNT_INFO, + len(self.volume.network_mount_info))) + b.write(self.volume.network_mount_info) + if len(self.volume.network_mount_info) & 1: + b.write(b'\0') + + if self.volume.dialup_info: + b.write(struct.pack(b'>hh', TAG_DIALUP_INFO, + len(self.volume.network_mount_info))) + b.write(self.volume.network_mount_info) + if len(self.volume.network_mount_info) & 1: + b.write(b'\0') + + utf16 = decode_utf8(self.target.filename)\ + .replace(':','/').encode('utf-16-be') + b.write(struct.pack(b'>hhh', TAG_UNICODE_FILENAME, + len(utf16) + 2, + len(utf16) // 2)) + b.write(utf16) + + utf16 = decode_utf8(self.volume.name)\ + .replace(':','/').encode('utf-16-be') + b.write(struct.pack(b'>hhh', TAG_UNICODE_VOLUME_NAME, + len(utf16) + 2, + len(utf16) // 2)) + b.write(utf16) + + if self.target.posix_path: + posix_path = encode_utf8(self.target.posix_path) + b.write(struct.pack(b'>hh', TAG_POSIX_PATH, + len(posix_path))) + b.write(posix_path) + if len(posix_path) & 1: + b.write(b'\0') + + if self.volume.posix_path: + posix_path = encode_utf8(self.volume.posix_path) + b.write(struct.pack(b'>hh', TAG_POSIX_PATH_TO_MOUNTPOINT, + len(posix_path))) + b.write(posix_path) + if len(posix_path) & 1: + b.write(b'\0') + + if self.volume.disk_image_alias: + d = self.volume.disk_image_alias.to_bytes() + b.write(struct.pack(b'>hh', TAG_RECURSIVE_ALIAS_OF_DISK_IMAGE, + len(d))) + b.write(d) + if len(d) & 1: + b.write(b'\0') + + if self.target.user_home_prefix_len is not None: + b.write(struct.pack(b'>hhh', TAG_USER_HOME_LENGTH_PREFIX, + 2, self.target.user_home_prefix_len)) + + for t,v in self.extra: + b.write(struct.pack(b'>hh', t, len(v))) + b.write(v) + if len(v) & 1: + b.write(b'\0') + + b.write(struct.pack(b'>hh', -1, 0)) + + blen = b.tell() - pos + b.seek(pos + 4, os.SEEK_SET) + b.write(struct.pack(b'>h', blen)) + + def to_bytes(self): + """Returns the binary representation for this :class:`Alias`.""" + with io.BytesIO() as b: + self._to_fd(b) + return b.getvalue() + + def __str__(self): + return '' % self.target.filename + + def __repr__(self): + values = [] + if self.appinfo != b'\0\0\0\0': + values.append('appinfo=%r' % self.appinfo) + if self.version != 2: + values.append('version=%r' % self.version) + if self.volume is not None: + values.append('volume=%r' % self.volume) + if self.target is not None: + values.append('target=%r' % self.target) + if self.extra: + values.append('extra=%r' % self.extra) + return 'Alias(%s)' % ','.join(values) diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/bookmark.py b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/bookmark.py new file mode 100644 index 00000000..0de6b940 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/bookmark.py @@ -0,0 +1,665 @@ +# -*- coding: utf-8 -*- +# +# This file implements the Apple "bookmark" format, which is the replacement +# for the old-fashioned alias format. The details of this format were +# reverse engineered; some things are still not entirely clear. +# +from __future__ import unicode_literals, print_function + +import struct +import uuid +import datetime +import os +import sys +import pprint + +try: + from urlparse import urljoin +except ImportError: + from urllib.parse import urljoin + +if sys.platform == 'darwin': + from . import osx + +def iteritems(x): + return x.iteritems() + +try: + unicode +except NameError: + unicode = str + long = int + xrange = range + def iteritems(x): + return x.items() + +from .utils import * + +BMK_DATA_TYPE_MASK = 0xffffff00 +BMK_DATA_SUBTYPE_MASK = 0x000000ff + +BMK_STRING = 0x0100 +BMK_DATA = 0x0200 +BMK_NUMBER = 0x0300 +BMK_DATE = 0x0400 +BMK_BOOLEAN = 0x0500 +BMK_ARRAY = 0x0600 +BMK_DICT = 0x0700 +BMK_UUID = 0x0800 +BMK_URL = 0x0900 +BMK_NULL = 0x0a00 + +BMK_ST_ZERO = 0x0000 +BMK_ST_ONE = 0x0001 + +BMK_BOOLEAN_ST_FALSE = 0x0000 +BMK_BOOLEAN_ST_TRUE = 0x0001 + +# Subtypes for BMK_NUMBER are really CFNumberType values +kCFNumberSInt8Type = 1 +kCFNumberSInt16Type = 2 +kCFNumberSInt32Type = 3 +kCFNumberSInt64Type = 4 +kCFNumberFloat32Type = 5 +kCFNumberFloat64Type = 6 +kCFNumberCharType = 7 +kCFNumberShortType = 8 +kCFNumberIntType = 9 +kCFNumberLongType = 10 +kCFNumberLongLongType = 11 +kCFNumberFloatType = 12 +kCFNumberDoubleType = 13 +kCFNumberCFIndexType = 14 +kCFNumberNSIntegerType = 15 +kCFNumberCGFloatType = 16 + +# Resource property flags (from CFURLPriv.h) +kCFURLResourceIsRegularFile = 0x00000001 +kCFURLResourceIsDirectory = 0x00000002 +kCFURLResourceIsSymbolicLink = 0x00000004 +kCFURLResourceIsVolume = 0x00000008 +kCFURLResourceIsPackage = 0x00000010 +kCFURLResourceIsSystemImmutable = 0x00000020 +kCFURLResourceIsUserImmutable = 0x00000040 +kCFURLResourceIsHidden = 0x00000080 +kCFURLResourceHasHiddenExtension = 0x00000100 +kCFURLResourceIsApplication = 0x00000200 +kCFURLResourceIsCompressed = 0x00000400 +kCFURLResourceIsSystemCompressed = 0x00000400 +kCFURLCanSetHiddenExtension = 0x00000800 +kCFURLResourceIsReadable = 0x00001000 +kCFURLResourceIsWriteable = 0x00002000 +kCFURLResourceIsExecutable = 0x00004000 +kCFURLIsAliasFile = 0x00008000 +kCFURLIsMountTrigger = 0x00010000 + +# Volume property flags (from CFURLPriv.h) +kCFURLVolumeIsLocal = 0x1 # +kCFURLVolumeIsAutomount = 0x2 # +kCFURLVolumeDontBrowse = 0x4 # +kCFURLVolumeIsReadOnly = 0x8 # +kCFURLVolumeIsQuarantined = 0x10 +kCFURLVolumeIsEjectable = 0x20 # +kCFURLVolumeIsRemovable = 0x40 # +kCFURLVolumeIsInternal = 0x80 # +kCFURLVolumeIsExternal = 0x100 # +kCFURLVolumeIsDiskImage = 0x200 # +kCFURLVolumeIsFileVault = 0x400 +kCFURLVolumeIsLocaliDiskMirror = 0x800 +kCFURLVolumeIsiPod = 0x1000 # +kCFURLVolumeIsiDisk = 0x2000 +kCFURLVolumeIsCD = 0x4000 +kCFURLVolumeIsDVD = 0x8000 +kCFURLVolumeIsDeviceFileSystem = 0x10000 +kCFURLVolumeSupportsPersistentIDs = 0x100000000 +kCFURLVolumeSupportsSearchFS = 0x200000000 +kCFURLVolumeSupportsExchange = 0x400000000 +# reserved 0x800000000 +kCFURLVolumeSupportsSymbolicLinks = 0x1000000000 +kCFURLVolumeSupportsDenyModes = 0x2000000000 +kCFURLVolumeSupportsCopyFile = 0x4000000000 +kCFURLVolumeSupportsReadDirAttr = 0x8000000000 +kCFURLVolumeSupportsJournaling = 0x10000000000 +kCFURLVolumeSupportsRename = 0x20000000000 +kCFURLVolumeSupportsFastStatFS = 0x40000000000 +kCFURLVolumeSupportsCaseSensitiveNames = 0x80000000000 +kCFURLVolumeSupportsCasePreservedNames = 0x100000000000 +kCFURLVolumeSupportsFLock = 0x200000000000 +kCFURLVolumeHasNoRootDirectoryTimes = 0x400000000000 +kCFURLVolumeSupportsExtendedSecurity = 0x800000000000 +kCFURLVolumeSupports2TBFileSize = 0x1000000000000 +kCFURLVolumeSupportsHardLinks = 0x2000000000000 +kCFURLVolumeSupportsMandatoryByteRangeLocks = 0x4000000000000 +kCFURLVolumeSupportsPathFromID = 0x8000000000000 +# reserved 0x10000000000000 +kCFURLVolumeIsJournaling = 0x20000000000000 +kCFURLVolumeSupportsSparseFiles = 0x40000000000000 +kCFURLVolumeSupportsZeroRuns = 0x80000000000000 +kCFURLVolumeSupportsVolumeSizes = 0x100000000000000 +kCFURLVolumeSupportsRemoteEvents = 0x200000000000000 +kCFURLVolumeSupportsHiddenFiles = 0x400000000000000 +kCFURLVolumeSupportsDecmpFSCompression = 0x800000000000000 +kCFURLVolumeHas64BitObjectIDs = 0x1000000000000000 +kCFURLVolumePropertyFlagsAll = 0xffffffffffffffff + +BMK_URL_ST_ABSOLUTE = 0x0001 +BMK_URL_ST_RELATIVE = 0x0002 + +# Bookmark keys +# = 0x1003 +kBookmarkPath = 0x1004 # Array of path components +kBookmarkCNIDPath = 0x1005 # Array of CNIDs +kBookmarkFileProperties = 0x1010 # (CFURL rp flags, + # CFURL rp flags asked for, + # 8 bytes NULL) +kBookmarkFileName = 0x1020 +kBookmarkFileID = 0x1030 +kBookmarkFileCreationDate = 0x1040 +# = 0x1054 # ? +# = 0x1055 # ? +# = 0x1056 # ? +# = 0x1101 # ? +# = 0x1102 # ? +kBookmarkTOCPath = 0x2000 # A list of (TOC id, ?) pairs +kBookmarkVolumePath = 0x2002 +kBookmarkVolumeURL = 0x2005 +kBookmarkVolumeName = 0x2010 +kBookmarkVolumeUUID = 0x2011 # Stored (perversely) as a string +kBookmarkVolumeSize = 0x2012 +kBookmarkVolumeCreationDate = 0x2013 +kBookmarkVolumeProperties = 0x2020 # (CFURL vp flags, + # CFURL vp flags asked for, + # 8 bytes NULL) +kBookmarkVolumeIsRoot = 0x2030 # True if volume is FS root +kBookmarkVolumeBookmark = 0x2040 # Embedded bookmark for disk image (TOC id) +kBookmarkVolumeMountPoint = 0x2050 # A URL +# = 0x2070 +kBookmarkContainingFolder = 0xc001 # Index of containing folder in path +kBookmarkUserName = 0xc011 # User that created bookmark +kBookmarkUID = 0xc012 # UID that created bookmark +kBookmarkWasFileReference = 0xd001 # True if the URL was a file reference +kBookmarkCreationOptions = 0xd010 +kBookmarkURLLengths = 0xe003 # See below +# = 0xf017 # Localized name? +# = 0xf022 +kBookmarkSecurityExtension = 0xf080 +# = 0xf081 + +# kBookmarkURLLengths is an array that is set if the URL encoded by the +# bookmark had a base URL; in that case, each entry is the length of the +# base URL in question. Thus a URL +# +# file:///foo/bar/baz blam/blat.html +# +# will result in [3, 2], while the URL +# +# file:///foo bar/baz blam blat.html +# +# would result in [1, 2, 1, 1] + + +class Data (object): + def __init__(self, bytedata=None): + #: The bytes, stored as a byte string + self.bytes = bytes(bytedata) + + def __repr__(self): + return 'Data(%r)' % self.bytes + +class URL (object): + def __init__(self, base, rel=None): + if rel is not None: + #: The base URL, if any (a :class:`URL`) + self.base = base + #: The rest of the URL (a string) + self.relative = rel + else: + self.base = None + self.relative = base + + @property + def absolute(self): + """Return an absolute URL.""" + if self.base is None: + return self.relative + else: + base_abs = self.base.absolute + return urljoin(self.base.absolute, self.relative) + + def __repr__(self): + return 'URL(%r)' % self.absolute + +class Bookmark (object): + def __init__(self, tocs=None): + if tocs is None: + #: The TOCs for this Bookmark + self.tocs = [] + else: + self.tocs = tocs + + @classmethod + def _get_item(cls, data, hdrsize, offset): + offset += hdrsize + if offset > len(data) - 8: + raise ValueError('Offset out of range') + + length,typecode = struct.unpack(b'd', databytes)[0]) + return osx_epoch + secs + elif dtype == BMK_BOOLEAN: + if dsubtype == BMK_BOOLEAN_ST_TRUE: + return True + elif dsubtype == BMK_BOOLEAN_ST_FALSE: + return False + elif dtype == BMK_UUID: + return uuid.UUID(bytes=databytes) + elif dtype == BMK_URL: + if dsubtype == BMK_URL_ST_ABSOLUTE: + return URL(databytes.decode('utf-8')) + elif dsubtype == BMK_URL_ST_RELATIVE: + baseoff,reloff = struct.unpack(b' size: + raise ValueError('Not a bookmark file (header size too large)') + + if size != len(data): + raise ValueError('Not a bookmark file (truncated)') + + tocoffset, = struct.unpack(b' size - hdrsize \ + or size - tocbase < 20: + raise ValueError('TOC offset out of range') + + tocsize,tocmagic,tocid,nexttoc,toccount \ + = struct.unpack(b' -0x80000000 and item < 0x7fffffff: + result = struct.pack(b'd', float(secs.total_seconds())) + elif isinstance(item, uuid.UUID): + result = struct.pack(b' -1: + sz = sz[:nul] + return sz.decode('utf-8') + +def _decode_attrlist_result(buf, attrs, options): + result = [] + + assert len(buf) >= 4 + total_size = uint32_t.from_buffer(buf, 0).value + assert total_size <= len(buf) + + offset = 4 + + # Common attributes + if attrs[0] & ATTR_CMN_RETURNED_ATTRS: + a = attribute_set_t.from_buffer(buf, offset) + result.append(a) + offset += sizeof (attribute_set_t) + if not (options & FSOPT_PACK_INVAL_ATTRS): + attrs = [a.commonattr, a.volattr, a.dirattr, a.fileattr, a.forkattr] + if attrs[0] & ATTR_CMN_NAME: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + name = _decode_utf8_nul(buf[ofs:ofs+a.attr_length]) + offset += sizeof (attrreference_t) + result.append(name) + if attrs[0] & ATTR_CMN_DEVID: + a = dev_t.from_buffer(buf, offset) + offset += sizeof(dev_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_FSID: + a = fsid_t.from_buffer(buf, offset) + offset += sizeof(fsid_t) + result.append(a) + if attrs[0] & ATTR_CMN_OBJTYPE: + a = fsobj_type_t.from_buffer(buf, offset) + offset += sizeof(fsobj_type_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_OBJTAG: + a = fsobj_tag_t.from_buffer(buf, offset) + offset += sizeof(fsobj_tag_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_OBJID: + a = fsobj_id_t.from_buffer(buf, offset) + offset += sizeof(fsobj_id_t) + result.append(a) + if attrs[0] & ATTR_CMN_OBJPERMANENTID: + a = fsobj_id_t.from_buffer(buf, offset) + offset += sizeof(fsobj_id_t) + result.append(a) + if attrs[0] & ATTR_CMN_PAROBJID: + a = fsobj_id_t.from_buffer(buf, offset) + offset += sizeof(fsobj_id_t) + result.append(a) + if attrs[0] & ATTR_CMN_SCRIPT: + a = text_encoding_t.from_buffer(buf, offset) + offset += sizeof(text_encoding_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_CRTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + if attrs[0] & ATTR_CMN_MODTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + if attrs[0] & ATTR_CMN_CHGTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + if attrs[0] & ATTR_CMN_ACCTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + if attrs[0] & ATTR_CMN_BKUPTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + if attrs[0] & ATTR_CMN_FNDRINFO: + a = FinderInfo.from_buffer(buf, offset) + offset += sizeof(FinderInfo) + result.append(a) + if attrs[0] & ATTR_CMN_OWNERID: + a = uid_t.from_buffer(buf, offset) + offset += sizeof(uid_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_GRPID: + a = gid_t.from_buffer(buf, offset) + offset += sizeof(gid_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_ACCESSMASK: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_FLAGS: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_USERACCESS: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_EXTENDED_SECURITY: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + offset += sizeof(attrreference_t) + ec = uint32_t.from_buffer(buf, ofs + 36).value + class kauth_acl(Structure): + _fields_ = [('acl_entrycount', c_uint), + ('acl_flags', c_uint), + ('acl_ace', kauth_ace * ec)] + class kauth_filesec(Structure): + _fields_ = [('fsec_magic', c_uint), + ('fsec_owner', guid_t), + ('fsec_group', guid_t), + ('fsec_acl', kauth_acl)] + a = kauth_filesec.from_buffer(buf, ofs) + result.append(a) + if attrs[0] & ATTR_CMN_UUID: + result.append(uuid.UUID(bytes=buf[offset:offset+16])) + offset += sizeof(guid_t) + if attrs[0] & ATTR_CMN_GRPUUID: + result.append(uuid.UUID(bytes=buf[offset:offset+16])) + offset += sizeof(guid_t) + if attrs[0] & ATTR_CMN_FILEID: + a = uint64_t.from_buffer(buf, offset) + offset += sizeof(uint64_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_PARENTID: + a = uint64_t.from_buffer(buf, offset) + offset += sizeof(uint64_t) + result.append(a.value) + if attrs[0] & ATTR_CMN_FULLPATH: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + path = _decode_utf8_nul(buf[ofs:ofs+a.attr_length]) + offset += sizeof (attrreference_t) + result.append(path) + if attrs[0] & ATTR_CMN_ADDEDTIME: + a = timespec.from_buffer(buf, offset) + offset += sizeof(timespec) + result.append(_datetime_from_timespec(a)) + + # Volume attributes + if attrs[1] & ATTR_VOL_FSTYPE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_SIGNATURE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_SIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_SPACEFREE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_SPACEAVAIL: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_MINALLOCATION: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_ALLOCATIONCLUMP: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_IOBLOCKSIZE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_OBJCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_FILECOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_DIRCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_MAXOBJCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_MOUNTPOINT: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + path = _decode_utf8_nul(buf[ofs:ofs+a.attr_length]) + offset += sizeof (attrreference_t) + result.append(path) + if attrs[1] & ATTR_VOL_NAME: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + name = _decode_utf8_nul(buf[ofs:ofs+a.attr_length]) + offset += sizeof (attrreference_t) + result.append(name) + if attrs[1] & ATTR_VOL_MOUNTFLAGS: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[1] & ATTR_VOL_MOUNTEDDEVICE: + a = attrreference_t.from_buffer(buf, offset) + ofs = offset + a.attr_dataoffset + path = _decode_utf8_nul(buf[ofs:ofs+a.attr_length]) + offset += sizeof (attrreference_t) + result.append(path) + if attrs[1] & ATTR_VOL_ENCODINGSUSED: + a = c_ulonglong.from_buffer(buf, offset) + offset += sizeof(c_ulonglong) + result.append(a.value) + if attrs[1] & ATTR_VOL_CAPABILITIES: + a = vol_capabilities_attr_t.from_buffer(buf, offset) + offset += sizeof(vol_capabilities_attr_t) + result.append(a) + if attrs[1] & ATTR_VOL_UUID: + result.append(uuid.UUID(bytes=buf[offset:offset+16])) + offset += sizeof(uuid_t) + if attrs[1] & ATTR_VOL_ATTRIBUTES: + a = vol_attributes_attr_t.from_buffer(buf, offset) + offset += sizeof(vol_attributes_attr_t) + result.append(a) + + # Directory attributes + if attrs[2] & ATTR_DIR_LINKCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[2] & ATTR_DIR_ENTRYCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[2] & ATTR_DIR_MOUNTSTATUS: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + + # File attributes + if attrs[3] & ATTR_FILE_LINKCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_TOTALSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_ALLOCSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_IOBLOCKSIZE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_CLUMPSIZE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_DEVTYPE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_FILETYPE: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_FORKCOUNT: + a = uint32_t.from_buffer(buf, offset) + offset += sizeof(uint32_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_DATALENGTH: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_DATAALLOCSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_DATAEXTENTS: + a = extentrecord.from_buffer(buf, offset) + offset += sizeof(extentrecord) + result.append(a.value) + if attrs[3] & ATTR_FILE_RSRCLENGTH: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_RSRCALLOCSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[3] & ATTR_FILE_RSRCEXTENTS: + a = extentrecord.from_buffer(buf, offset) + offset += sizeof(extentrecord) + result.append(a.value) + + # Fork attributes + if attrs[4] & ATTR_FORK_TOTALSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + if attrs[4] & ATTR_FORK_ALLOCSIZE: + a = off_t.from_buffer(buf, offset) + offset += sizeof(off_t) + result.append(a.value) + + return result + +# Sadly, ctypes.get_errno() seems not to work +__error = libc.__error +__error.restype = POINTER(c_int) + +def _get_errno(): + return __error().contents.value + +def getattrlist(path, attrs, options): + if not isinstance(path, bytes): + path = path.encode('utf-8') + attrs = list(attrs) + if attrs[1]: + attrs[1] |= ATTR_VOL_INFO + alist = attrlist(bitmapcount=5, + commonattr=attrs[0], + volattr=attrs[1], + dirattr=attrs[2], + fileattr=attrs[3], + forkattr=attrs[4]) + + bufsize = _attrbuf_size(attrs) + buf = create_string_buffer(bufsize) + + ret = _getattrlist(path, byref(alist), buf, bufsize, + options | FSOPT_REPORT_FULLSIZE) + + if ret < 0: + err = _get_errno() + raise OSError(err, os.strerror(err), path) + + return _decode_attrlist_result(buf, attrs, options) + +def fgetattrlist(fd, attrs, options): + if hasattr(fd, 'fileno'): + fd = fd.fileno() + attrs = list(attrs) + if attrs[1]: + attrs[1] |= ATTR_VOL_INFO + alist = attrlist(bitmapcount=5, + commonattr=attrs[0], + volattr=attrs[1], + dirattr=attrs[2], + fileattr=attrs[3], + forkattr=attrs[4]) + + bufsize = _attrbuf_size(attrs) + buf = create_string_buffer(bufsize) + + ret = _fgetattrlist(fd, byref(alist), buf, bufsize, + options | FSOPT_REPORT_FULLSIZE) + + if ret < 0: + err = _get_errno() + raise OSError(err, os.strerror(err)) + + return _decode_attrlist_result(buf, attrs, options) + +def statfs(path): + if not isinstance(path, bytes): + path = path.encode('utf-8') + result = struct_statfs() + ret = _statfs(path, byref(result)) + if ret < 0: + err = _get_errno() + raise OSError(err, os.strerror(err), path) + return result + +def fstatfs(fd): + if hasattr(fd, 'fileno'): + fd = fd.fileno() + result = struct_statfs() + ret = _fstatfs(fd, byref(result)) + if ret < 0: + err = _get_errno() + raise OSError(err, os.strerror(err)) + return result diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/qt_attribution.json b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/qt_attribution.json new file mode 100644 index 00000000..968b6318 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/qt_attribution.json @@ -0,0 +1,13 @@ +{ + "Id": "mac_alias", + "Name": "mac_alias", + "QDocModule": "qbs", + "QtUsage": "Used in the qbs dmg module for building Apple disk images.", + "Description": "Generate/parse Mac OS Alias records from Python", + "Homepage": "https://github.com/al45tair/mac_alias", + "Version": "2.0.6", + "License": "MIT License", + "LicenseId": "MIT", + "LicenseFile": "LICENSE", + "Copyright": "Copyright (c) 2014 Alastair Houghton" +} diff --git a/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/utils.py b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/utils.py new file mode 100644 index 00000000..6a7d0a12 --- /dev/null +++ b/src/3rdparty/python/lib/python2.7/site-packages/mac_alias/utils.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import datetime + +ZERO = datetime.timedelta(0) +class UTC (datetime.tzinfo): + def utcoffset(self, dt): + return ZERO + def dst(self, dt): + return ZERO + def tzname(self, dt): + return 'UTC' + +utc = UTC() +mac_epoch = datetime.datetime(1904,1,1,0,0,0,0,utc) +unix_epoch = datetime.datetime(1970,1,1,0,0,0,0,utc) +osx_epoch = datetime.datetime(2001,1,1,0,0,0,0,utc) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..278b86ad --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(app) +add_subdirectory(lib) +add_subdirectory(libexec) +add_subdirectory(plugins) +add_subdirectory(shared) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt new file mode 100644 index 00000000..3a4ab38e --- /dev/null +++ b/src/app/CMakeLists.txt @@ -0,0 +1,8 @@ +add_subdirectory(config) +add_subdirectory(config-ui) +add_subdirectory(qbs) +add_subdirectory(qbs-create-project) +add_subdirectory(qbs-setup-android) +add_subdirectory(qbs-setup-qt) +add_subdirectory(qbs-setup-toolchains) +add_subdirectory(shared) diff --git a/src/app/app.pri b/src/app/app.pri new file mode 100644 index 00000000..5cd9cb4a --- /dev/null +++ b/src/app/app.pri @@ -0,0 +1,23 @@ +include(../install_prefix.pri) + +QT = core +TEMPLATE = app +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_PROCESS_COMBINED_ARGUMENT_START +!isEmpty(QBS_APPS_DESTDIR):DESTDIR = $${QBS_APPS_DESTDIR} +else:DESTDIR = ../../../bin + +!isEmpty(QBS_APPS_RPATH_DIR) { + linux-*:QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${QBS_APPS_RPATH_DIR}\' + macx:QMAKE_LFLAGS += -Wl,-rpath,$${QBS_APPS_RPATH_DIR} +} + +CONFIG += console +CONFIG -= app_bundle +CONFIG += c++17 + +include($${PWD}/../lib/corelib/use_corelib.pri) +include($${PWD}/shared/logging/logging.pri) + +!isEmpty(QBS_APPS_INSTALL_DIR):target.path = $${QBS_APPS_INSTALL_DIR} +else:target.path = $${QBS_INSTALL_PREFIX}/bin +INSTALLS += target diff --git a/src/app/app.pro b/src/app/app.pro new file mode 100644 index 00000000..935ce177 --- /dev/null +++ b/src/app/app.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS =\ + qbs\ + qbs-create-project \ + qbs-setup-android \ + qbs-setup-toolchains \ + qbs-setup-qt \ + config + +!isEmpty(QT.widgets.name):SUBDIRS += config-ui diff --git a/src/app/apps.qbs b/src/app/apps.qbs new file mode 100644 index 00000000..4ea0a2c8 --- /dev/null +++ b/src/app/apps.qbs @@ -0,0 +1,12 @@ +Project { + references: [ + "config/config.qbs", + "config-ui/config-ui.qbs", + "qbs/qbs.qbs", + "qbs-create-project/qbs-create-project.qbs", + "qbs-setup-android/qbs-setup-android.qbs", + "qbs-setup-qt/qbs-setup-qt.qbs", + "qbs-setup-toolchains/qbs-setup-toolchains.qbs", + "shared/shared.qbs", + ] +} diff --git a/src/app/config-ui/CMakeLists.txt b/src/app/config-ui/CMakeLists.txt new file mode 100644 index 00000000..f3375d5e --- /dev/null +++ b/src/app/config-ui/CMakeLists.txt @@ -0,0 +1,19 @@ +set(SOURCES + commandlineparser.cpp + commandlineparser.h + main.cpp + mainwindow.cpp + mainwindow.h + mainwindow.ui + ) + +# TODO: support Info.plist +if(APPLE) + set(MACOS_SOURCES fgapp.mm) + set(MACOS_FRAMEWORKS "-framework ApplicationServices" "-framework Cocoa") +endif() + +add_qbs_app(qbs-config-ui + DEPENDS qbscore qbsconsolelogger Qt${QT_VERSION_MAJOR}::Widgets ${MACOS_FRAMEWORKS} + SOURCES ${SOURCES} ${MACOS_SOURCES} + ) diff --git a/src/app/config-ui/Info.plist b/src/app/config-ui/Info.plist new file mode 100644 index 00000000..6b74be4a --- /dev/null +++ b/src/app/config-ui/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleIdentifier + org.qt-project.qbs-config-ui + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Qbs Settings + LSUIElement + 1 + + diff --git a/src/app/config-ui/commandlineparser.cpp b/src/app/config-ui/commandlineparser.cpp new file mode 100644 index 00000000..5f726504 --- /dev/null +++ b/src/app/config-ui/commandlineparser.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineparser.h" + +#include +#include + +#include + +using qbs::Internal::Tr; + +static QString helpOptionShort() { return QStringLiteral("-h"); } +static QString helpOptionLong() { return QStringLiteral("--help"); } +static QString settingsDirOption() { return QStringLiteral("--settings-dir"); } +static QString systemOption() { return QStringLiteral("--system"); } + +void CommandLineParser::parse(const QStringList &commandLine) +{ + m_commandLine = commandLine; + Q_ASSERT(!m_commandLine.empty()); + m_command = QFileInfo(m_commandLine.takeFirst()).fileName(); + m_helpRequested = false; + m_settingsDir.clear(); + + if (m_commandLine.empty()) + return; + const QString &arg = m_commandLine.front(); + if (arg == helpOptionShort() || arg == helpOptionLong()) { + m_commandLine.removeFirst(); + m_helpRequested = true; + } else if (arg == systemOption()) { + m_commandLine.removeFirst(); + m_settingsScope = qbs::Settings::SystemScope; + } else if (arg == settingsDirOption()) { + m_commandLine.removeFirst(); + assignOptionArgument(settingsDirOption(), m_settingsDir); + } + + if (!m_commandLine.empty()) + complainAboutExtraArguments(); +} + +void CommandLineParser::throwError(const QString &message) +{ + qbs::ErrorInfo error(Tr::tr("Syntax error: %1").arg(message)); + error.append(usageString()); + throw error; +} + +QString CommandLineParser::usageString() const +{ + QString s = Tr::tr("This tool displays qbs settings in a GUI.\n" + "If you have more than a few settings, this might be preferable to " + "plain \"qbs config\", as it presents a hierarchical view.\n"); + s += Tr::tr("Usage:\n"); + s += Tr::tr(" %1 [%2 ] [%5] [%3|%4]\n") + .arg(m_command, settingsDirOption(), helpOptionShort(), helpOptionLong(), + systemOption()); + return s; +} + +void CommandLineParser::assignOptionArgument(const QString &option, QString &argument) +{ + if (m_commandLine.empty()) + throwError(Tr::tr("Option '%1' needs an argument.").arg(option)); + argument = m_commandLine.takeFirst(); + if (argument.isEmpty()) + throwError(Tr::tr("Argument for option '%1' must not be empty.").arg(option)); +} + +void CommandLineParser::complainAboutExtraArguments() +{ + throwError(Tr::tr("Extraneous command-line arguments '%1'.") + .arg(m_commandLine.join(QLatin1Char(' ')))); +} diff --git a/src/app/config-ui/commandlineparser.h b/src/app/config-ui/commandlineparser.h new file mode 100644 index 00000000..b8ab1a9f --- /dev/null +++ b/src/app/config-ui/commandlineparser.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_CONFIGUI_COMMANDLINEPARSER_H +#define QBS_CONFIGUI_COMMANDLINEPARSER_H + +#include + +#include + +class CommandLineParser +{ +public: + void parse(const QStringList &commandLine); + + bool helpRequested() const { return m_helpRequested; } + QString settingsDir() const { return m_settingsDir; } + qbs::Settings::Scope settingsScope() const { return m_settingsScope; } + + QString usageString() const; + +private: + [[noreturn]] void throwError(const QString &message); + void assignOptionArgument(const QString &option, QString &argument); + [[noreturn]] void complainAboutExtraArguments(); + + bool m_helpRequested = false; + qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope; + QString m_settingsDir; + QStringList m_commandLine; + QString m_command; +}; + +#endif // Include guard diff --git a/src/app/config-ui/config-ui.pro b/src/app/config-ui/config-ui.pro new file mode 100644 index 00000000..84d3b3e4 --- /dev/null +++ b/src/app/config-ui/config-ui.pro @@ -0,0 +1,26 @@ +include(../app.pri) + +CONFIG -= console +QT += gui widgets + +TARGET = qbs-config-ui + +HEADERS += \ + commandlineparser.h \ + mainwindow.h + +SOURCES += \ + commandlineparser.cpp \ + main.cpp \ + mainwindow.cpp + +OTHER_FILES += \ + Info.plist + +osx { + QMAKE_LFLAGS += -sectcreate __TEXT __info_plist $$shell_quote($$PWD/Info.plist) + OBJECTIVE_SOURCES += fgapp.mm + LIBS += -framework ApplicationServices -framework Cocoa +} + +FORMS += mainwindow.ui diff --git a/src/app/config-ui/config-ui.qbs b/src/app/config-ui/config-ui.qbs new file mode 100644 index 00000000..544542ca --- /dev/null +++ b/src/app/config-ui/config-ui.qbs @@ -0,0 +1,32 @@ +QbsApp { + Depends { name: "Qt.widgets" } + name: "qbs-config-ui" + consoleApplication: false + files: [ + "commandlineparser.cpp", + "commandlineparser.h", + "main.cpp", + "mainwindow.cpp", + "mainwindow.h", + "mainwindow.ui", + ] + + Group { + condition: qbs.targetOS.contains("macos") + files: [ + "fgapp.mm", + "Info.plist" + ] + } + + Properties { + condition: qbs.targetOS.contains("macos") + cpp.frameworks: ["ApplicationServices", "Cocoa"] + bundle.isBundle: false + } + + Properties { + condition: qbs.targetOS.contains("darwin") + bundle.isBundle: false + } +} diff --git a/src/app/config-ui/fgapp.mm b/src/app/config-ui/fgapp.mm new file mode 100644 index 00000000..5ddd1e8a --- /dev/null +++ b/src/app/config-ui/fgapp.mm @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#import +#include + +extern "C" void qt_macos_forceTransformProcessToForegroundApplicationAndActivate() +{ + [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular]; + [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; +} diff --git a/src/app/config-ui/main.cpp b/src/app/config-ui/main.cpp new file mode 100644 index 00000000..dcf53898 --- /dev/null +++ b/src/app/config-ui/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "mainwindow.h" + +#include "commandlineparser.h" + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + CommandLineParser clParser; + try { + clParser.parse(app.arguments()); + if (clParser.helpRequested()) { + std::cout << qPrintable(clParser.usageString()); + return EXIT_SUCCESS; + } + } catch (const qbs::ErrorInfo &error) { + std::cerr << qPrintable(error.toString()); + return EXIT_FAILURE; + } + + MainWindow mw(clParser.settingsDir(), clParser.settingsScope()); + mw.show(); + return app.exec(); +} diff --git a/src/app/config-ui/mainwindow.cpp b/src/app/config-ui/mainwindow.cpp new file mode 100644 index 00000000..31239dc4 --- /dev/null +++ b/src/app/config-ui/mainwindow.cpp @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include + +#include +#include +#include + +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#else +#include +#endif + +#include +#include +#include +#include +#include + +namespace { + +class TrimValidator : public QValidator +{ +public: + explicit TrimValidator(QObject *parent = nullptr) : QValidator(parent) {} + + // QValidator interface + State validate(QString &input, int &pos) const override + { + Q_UNUSED(pos); + if (input.startsWith(QLatin1Char(' ')) || input.endsWith(QLatin1Char(' '))) + return State::Intermediate; + return State::Acceptable; + } + + void fixup(QString &input) const override + { + input = input.trimmed(); + } +}; + +class SettingsItemDelegate: public QStyledItemDelegate +{ +public: + explicit SettingsItemDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {} + + QWidget *createEditor(QWidget *parent, + const QStyleOptionViewItem &option, + const QModelIndex &index) const override + { + const auto editor = QStyledItemDelegate::createEditor(parent, option, index); + const auto lineEdit = qobject_cast(editor); + if (lineEdit) + lineEdit->setValidator(new TrimValidator(lineEdit)); + return editor; + } +}; + +} // namespace + +MainWindow::MainWindow(const QString &settingsDir, qbs::Settings::Scope scope, QWidget *parent) + : QMainWindow(parent), ui(new Ui::MainWindow) +{ + ui->setupUi(this); + m_model = new qbs::SettingsModel(settingsDir, scope, this); + ui->treeView->setModel(m_model); + ui->treeView->setItemDelegate(new SettingsItemDelegate(ui->treeView)); + ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->treeView, &QTreeView::expanded, this, &MainWindow::adjustColumns); + connect(ui->treeView, &QWidget::customContextMenuRequested, + this, &MainWindow::provideContextMenu); + adjustColumns(); + + QMenu * const fileMenu = menuBar()->addMenu(tr("&File")); + QMenu * const viewMenu = menuBar()->addMenu(tr("&View")); + + const auto reloadAction = new QAction(tr("&Reload"), this); + reloadAction->setShortcut(QKeySequence::Refresh); + connect(reloadAction, &QAction::triggered, this, &MainWindow::reloadSettings); + const auto saveAction = new QAction(tr("&Save"), this); + saveAction->setShortcut(QKeySequence::Save); + connect(saveAction, &QAction::triggered, this, &MainWindow::saveSettings); + const auto expandAllAction = new QAction(tr("&Expand All"), this); + expandAllAction->setShortcut(int(Qt::CTRL) | int(Qt::Key_E)); + connect(expandAllAction, &QAction::triggered, this, &MainWindow::expandAll); + const auto collapseAllAction = new QAction(tr("C&ollapse All"), this); + collapseAllAction->setShortcut(int(Qt::CTRL) | int(Qt::Key_O)); + connect(collapseAllAction, &QAction::triggered, this, &MainWindow::collapseAll); + const auto exitAction = new QAction(tr("E&xit"), this); + exitAction->setShortcut(QKeySequence::Quit); + exitAction->setMenuRole(QAction::QuitRole); + connect(exitAction, &QAction::triggered, this, &MainWindow::exit); + + fileMenu->addAction(reloadAction); + fileMenu->addAction(saveAction); + fileMenu->addSeparator(); + fileMenu->addAction(exitAction); + + viewMenu->addAction(expandAllAction); + viewMenu->addAction(collapseAllAction); + + ui->treeView->installEventFilter(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::adjustColumns() +{ + for (int column = 0; column < m_model->columnCount(); ++column) + ui->treeView->resizeColumnToContents(column); +} + +void MainWindow::expandAll() +{ + ui->treeView->expandAll(); + adjustColumns(); +} + +void MainWindow::collapseAll() +{ + ui->treeView->collapseAll(); + adjustColumns(); +} + +void MainWindow::reloadSettings() +{ + if (m_model->hasUnsavedChanges()) { + const QMessageBox::StandardButton answer = QMessageBox::question(this, + tr("Unsaved Changes"), + tr("You have unsaved changes. Do you want to discard them?")); + if (answer != QMessageBox::Yes) + return; + } + m_model->reload(); +} + +void MainWindow::saveSettings() +{ + m_model->save(); +} + +void MainWindow::exit() +{ + if (m_model->hasUnsavedChanges()) { + const QMessageBox::StandardButton answer = QMessageBox::question(this, + tr("Unsaved Changes"), + tr("You have unsaved changes. Do you want to save them now?")); + if (answer == QMessageBox::Yes) + m_model->save(); + } + qApp->quit(); +} + +void MainWindow::provideContextMenu(const QPoint &pos) +{ + const QModelIndex index = ui->treeView->indexAt(pos); + if (index.isValid() && index.column() != m_model->keyColumn()) + return; + const QString settingsKey = m_model->data(index).toString(); + + QMenu contextMenu; + QAction addKeyAction(this); + QAction removeKeyAction(this); + if (index.isValid()) { + addKeyAction.setText(tr("Add new key below '%1'").arg(settingsKey)); + removeKeyAction.setText(tr("Remove key '%1' and all its sub-keys").arg(settingsKey)); + contextMenu.addAction(&addKeyAction); + contextMenu.addAction(&removeKeyAction); + } else { + addKeyAction.setText(tr("Add new top-level key")); + contextMenu.addAction(&addKeyAction); + } + + const QAction *action = contextMenu.exec(ui->treeView->mapToGlobal(pos)); + if (action == &addKeyAction) + m_model->addNewKey(index); + else if (action == &removeKeyAction) + m_model->removeKey(index); +} + +extern "C" void qt_macos_forceTransformProcessToForegroundApplicationAndActivate(); + +bool MainWindow::eventFilter(QObject *watched, QEvent *event) +{ + if (ui->treeView->hasFocus() && event->type() == QEvent::KeyPress) { + const auto keyEvent = static_cast(event); + if (keyEvent->matches(QKeySequence::Delete)) { + const QModelIndexList indexes = ui->treeView->selectionModel()->selectedRows(); + if (indexes.size() == 1) { + const QModelIndex index = indexes.front(); + if (index.isValid()) { + m_model->removeKey(index); + return true; + } + } + } + } + + if (event->type() == QEvent::WindowActivate) { + // Effectively delay the foreground process transformation from QApplication construction to + // when the UI is shown - this prevents the application icon from popping up in the Dock + // when running `qbs help`, and QCoreApplication::arguments() requires the application + // object to be constructed, so it is not easily worked around + #if defined(Q_OS_MACOS) || defined(Q_OS_OSX) + qt_macos_forceTransformProcessToForegroundApplicationAndActivate(); + #endif + } + + + return QMainWindow::eventFilter(watched, event); +} diff --git a/src/app/config-ui/mainwindow.h b/src/app/config-ui/mainwindow.h new file mode 100644 index 00000000..b8a12d61 --- /dev/null +++ b/src/app/config-ui/mainwindow.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +#include + +namespace qbs { class SettingsModel; } + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +class QPoint; +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(const QString &settingsDir, qbs::Settings::Scope scope, + QWidget *parent = nullptr); + ~MainWindow() override; + + bool eventFilter(QObject *watched, QEvent *event) override; + +private: + void adjustColumns(); + void expandAll(); + void collapseAll(); + void reloadSettings(); + void saveSettings(); + void exit(); + void provideContextMenu(const QPoint &pos); + + Ui::MainWindow *ui; + qbs::SettingsModel *m_model; +}; + +#endif // MAINWINDOW_H diff --git a/src/app/config-ui/mainwindow.ui b/src/app/config-ui/mainwindow.ui new file mode 100644 index 00000000..7a3416ce --- /dev/null +++ b/src/app/config-ui/mainwindow.ui @@ -0,0 +1,37 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + Qbs Settings + + + + + + + + + + + + 0 + 0 + 800 + 27 + + + + + + + + diff --git a/src/app/config/CMakeLists.txt b/src/app/config/CMakeLists.txt new file mode 100644 index 00000000..064d8fb2 --- /dev/null +++ b/src/app/config/CMakeLists.txt @@ -0,0 +1,13 @@ +set(SOURCES + configcommand.h + configcommandexecutor.cpp + configcommandexecutor.h + configcommandlineparser.cpp + configcommandlineparser.h + configmain.cpp + ) + +add_qbs_app(qbs-config + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} + ) diff --git a/src/app/config/config.pro b/src/app/config/config.pro new file mode 100644 index 00000000..278c481d --- /dev/null +++ b/src/app/config/config.pro @@ -0,0 +1,13 @@ +include(../app.pri) + +TARGET = qbs-config + +SOURCES += \ + configcommandexecutor.cpp \ + configcommandlineparser.cpp \ + configmain.cpp + +HEADERS += \ + configcommand.h \ + configcommandexecutor.h \ + configcommandlineparser.h diff --git a/src/app/config/config.qbs b/src/app/config/config.qbs new file mode 100644 index 00000000..2744b93f --- /dev/null +++ b/src/app/config/config.qbs @@ -0,0 +1,12 @@ +QbsApp { + name: "qbs-config" + files: [ + "configcommand.h", + "configcommandexecutor.cpp", + "configcommandexecutor.h", + "configcommandlineparser.cpp", + "configcommandlineparser.h", + "configmain.cpp" + ] +} + diff --git a/src/app/config/configcommand.h b/src/app/config/configcommand.h new file mode 100644 index 00000000..f8e2a8ae --- /dev/null +++ b/src/app/config/configcommand.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONFIGCOMMAND_H +#define CONFIGCOMMAND_H + +#include + +#include +#include + +class ConfigCommand +{ +public: + enum Command { CfgSet, CfgUnset, CfgList, CfgExport, CfgImport, CfgAddProfile, CfgNone }; + + ConfigCommand() : command(CfgNone) {} + + Command command; + QStringList varNames; + QString varValue; + QString fileName; +}; + +#endif // CONFIGCOMMAND_H diff --git a/src/app/config/configcommandexecutor.cpp b/src/app/config/configcommandexecutor.cpp new file mode 100644 index 00000000..02351498 --- /dev/null +++ b/src/app/config/configcommandexecutor.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "configcommandexecutor.h" + +#include "configcommand.h" +#include "../shared/logging/consolelogger.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace qbs; + +ConfigCommandExecutor::ConfigCommandExecutor(Settings *settings, Settings::Scopes scope) + : m_settings(settings), m_scope(scope) +{ + if (m_scope == qbs::Settings::SystemScope) + m_settings->setScopeForWriting(qbs::Settings::SystemScope); +} + +void ConfigCommandExecutor::execute(const ConfigCommand &command) +{ + switch (command.command) { + case ConfigCommand::CfgList: + printSettings(command); + break; + case ConfigCommand::CfgSet: + setValue(command.varNames.front(), command.varValue); + break; + case ConfigCommand::CfgUnset: + for (const QString &varName : command.varNames) + m_settings->remove(varName); + break; + case ConfigCommand::CfgAddProfile: { + Profile profile(command.varValue, m_settings); + profile.removeProfile(); + Q_ASSERT(command.varNames.size() % 2 == 0); + for (int i = 0; i < command.varNames.size(); i += 2) { + const QString &key = command.varNames.at(i); + const QString &rawValue = command.varNames.at(i + 1); + profile.setValue(key, representationToSettingsValue(rawValue)); + } + break; + } + case ConfigCommand::CfgExport: + exportSettings(command.fileName); + break; + case ConfigCommand::CfgImport: + // Display old and new settings, in case import fails or user accidentally nukes everything + std::printf("old "); // Will end up as "old settings:" + printSettings(command); + importSettings(command.fileName); + std::printf("\nnew "); + printSettings(command); + break; + case ConfigCommand::CfgNone: + qFatal("%s: Impossible command value.", Q_FUNC_INFO); + break; + } +} + +void ConfigCommandExecutor::setValue(const QString &key, const QString &rawInput) +{ + m_settings->setValue(key, representationToSettingsValue(rawInput)); +} + +void ConfigCommandExecutor::printSettings(const ConfigCommand &command) +{ + if (command.varNames.empty()) { + const auto keys = m_settings->allKeys(m_scope); + for (const QString &key : keys) + printOneSetting(key); + } else { + for (const QString &parentKey : command.varNames) { + if (m_settings->value(parentKey, m_scope).isValid()) { // Key is a leaf. + printOneSetting(parentKey); + } else { // Key is a node. + const auto keys = m_settings->allKeysWithPrefix(parentKey, m_scope); + for (const QString &key : keys) + printOneSetting(parentKey + QLatin1Char('.') + key); + } + } + } +} + +void ConfigCommandExecutor::printOneSetting(const QString &key) +{ + std::printf("%s: %s\n", qPrintable(key), + qPrintable(qbs::settingsValueToRepresentation(m_settings->value(key, m_scope)))); + } + +void ConfigCommandExecutor::exportSettings(const QString &filename) +{ + QFile file(filename); + if (!file.open(QFile::Truncate | QFile::WriteOnly | QFile::Text)) { + throw ErrorInfo(tr("Could not open file '%1' for writing: %2") + .arg(QDir::toNativeSeparators(filename), file.errorString())); + } + QTextStream stream(&file); + setupDefaultCodec(stream); + const auto keys = m_settings->allKeys(m_scope); + for (const QString &key : keys) + stream << key << ": " << qbs::settingsValueToRepresentation(m_settings->value(key, m_scope)) + << Qt::endl; +} + +void ConfigCommandExecutor::importSettings(const QString &filename) +{ + QFile file(filename); + if (!file.open(QFile::ReadOnly | QFile::Text)) { + throw ErrorInfo(tr("Could not open file '%1' for reading: %2") + .arg(QDir::toNativeSeparators(filename), file.errorString())); + } + // Remove all current settings + const auto keys = m_settings->allKeys(m_scope); + for (const QString &key : keys) + m_settings->remove(key); + + QTextStream stream(&file); + setupDefaultCodec(stream); + while (!stream.atEnd()) { + QString line = stream.readLine(); + int colon = line.indexOf(QLatin1Char(':')); + if (colon >= 0 && !line.startsWith(QLatin1Char('#'))) { + const QString key = line.left(colon).trimmed(); + const QString value = line.mid(colon + 1).trimmed(); + m_settings->setValue(key, representationToSettingsValue(value)); + } + } +} diff --git a/src/app/config/configcommandexecutor.h b/src/app/config/configcommandexecutor.h new file mode 100644 index 00000000..463818a7 --- /dev/null +++ b/src/app/config/configcommandexecutor.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONFIGCOMMANDEXECUTOR_H +#define CONFIGCOMMANDEXECUTOR_H + +#include + +#include + +class ConfigCommand; + +class ConfigCommandExecutor +{ + Q_DECLARE_TR_FUNCTIONS(ConfigCommandExecutor) +public: + ConfigCommandExecutor(qbs::Settings *settings, qbs::Settings::Scopes scope); + + void execute(const ConfigCommand &command); + +private: + void setValue(const QString &key, const QString &rawInput); + void printSettings(const ConfigCommand &command); + void printOneSetting(const QString &key); + void exportSettings(const QString &filename); + void importSettings(const QString &filename); + + qbs::Settings *m_settings; + const qbs::Settings::Scopes m_scope; +}; + +#endif // CONFIGCOMMANDEXECUTOR_H diff --git a/src/app/config/configcommandlineparser.cpp b/src/app/config/configcommandlineparser.cpp new file mode 100644 index 00000000..f4d0a142 --- /dev/null +++ b/src/app/config/configcommandlineparser.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "configcommandlineparser.h" + +#include +#include + +#include + +using namespace qbs; +using namespace Internal; + +void ConfigCommandLineParser::parse(const QStringList &commandLine) +{ + m_command = ConfigCommand(); + m_helpRequested = false; + m_settingsDir.clear(); + + m_commandLine = commandLine; + if (m_commandLine.empty()) + throw Error(Tr::tr("No parameters supplied.")); + if (m_commandLine.size() == 1 && (m_commandLine.front() == QLatin1String("--help") + || m_commandLine.front() == QLatin1String("-h"))) { + m_helpRequested = true; + return; + } + + while (!m_commandLine.empty() && m_commandLine.front().startsWith(QLatin1String("--"))) { + const QString arg = m_commandLine.takeFirst().mid(2); + if (arg == QLatin1String("list")) + setCommand(ConfigCommand::CfgList); + else if (arg == QLatin1String("unset")) + setCommand(ConfigCommand::CfgUnset); + else if (arg == QLatin1String("export")) + setCommand(ConfigCommand::CfgExport); + else if (arg == QLatin1String("import")) + setCommand(ConfigCommand::CfgImport); + else if (arg == QLatin1String("add-profile")) + setCommand(ConfigCommand::CfgAddProfile); + else if (arg == QLatin1String("settings-dir")) + assignOptionArgument(arg, m_settingsDir); + else if (arg == QLatin1String("user")) + setScope(qbs::Settings::UserScope); + else if (arg == QLatin1String("system")) + setScope(qbs::Settings::SystemScope); + else + throw Error(Tr::tr("Unknown option for config command.")); + } + + switch (command().command) { + case ConfigCommand::CfgNone: + if (m_commandLine.empty()) + throw Error(Tr::tr("No parameters supplied.")); + if (m_commandLine.size() > 2) + throw Error(Tr::tr("Too many arguments.")); + m_command.varNames << m_commandLine.front(); + if (m_commandLine.size() == 1) { + setCommand(ConfigCommand::CfgList); + } else { + m_command.varValue = m_commandLine.at(1); + setCommand(ConfigCommand::CfgSet); + } + break; + case ConfigCommand::CfgUnset: + if (m_commandLine.empty()) + throw Error(Tr::tr("Need name of variable to unset.")); + m_command.varNames = m_commandLine; + break; + case ConfigCommand::CfgExport: + if (m_commandLine.size() != 1) + throw Error(Tr::tr("Need name of file to which to export.")); + m_command.fileName = m_commandLine.front(); + break; + case ConfigCommand::CfgImport: + if (m_commandLine.size() != 1) + throw Error(Tr::tr("Need name of file from which to import.")); + m_command.fileName = m_commandLine.front(); + break; + case ConfigCommand::CfgList: + m_command.varNames = m_commandLine; + break; + case ConfigCommand::CfgAddProfile: + if (m_commandLine.empty()) + throw Error(Tr::tr("Profile name missing.")); + m_command.varValue = m_commandLine.takeFirst(); + if (m_command.varValue.isEmpty()) + throw Error(Tr::tr("Profile name must not be empty.")); + m_command.varNames = m_commandLine; + if (m_command.varNames.isEmpty()) + throw Error(Tr::tr("Profile properties must be provided.")); + if (m_command.varNames.size() % 2 != 0) + throw Error(Tr::tr("Profile properties must be key/value pairs.")); + for (int i = 0; i < m_command.varNames.size(); ++i) { + if (m_command.varNames.at(i).isEmpty()) + throw Error(Tr::tr("Property names must not be empty.")); + } + break; + default: + break; + } +} + +void ConfigCommandLineParser::setCommand(ConfigCommand::Command command) +{ + if (m_command.command != ConfigCommand::CfgNone) + throw Error(Tr::tr("You cannot specify more than one command.")); + m_command.command = command; +} + +void ConfigCommandLineParser::setScope(Settings::Scope scope) +{ + if (m_scope != qbs::Settings::allScopes()) + throw Error(Tr::tr("The --user and --system options can only appear once.")); + m_scope = scope; +} + +void ConfigCommandLineParser::printUsage() const +{ + std::puts("Usage:\n" + " qbs config [--settings-dir \n" + " qbs config [--settings-dir \n" + " qbs config [--settings-dir " + "\n" + "Options:\n" + " --list [ ...] list keys under key or all keys\n" + " --user consider only user-level settings\n" + " --system consider only system-level settings\n" + " --unset remove key with given name\n" + " --add-profile ... add profile with the given name and properties\n" + " --import import settings from given file\n" + " --export export settings to given file\n"); +} + +void ConfigCommandLineParser::assignOptionArgument(const QString &option, QString &argument) +{ + if (m_commandLine.empty()) + throw Error(Tr::tr("Option '%1' needs an argument.").arg(option)); + argument = m_commandLine.takeFirst(); + if (argument.isEmpty()) + throw Error(Tr::tr("Argument for option '%1' must not be empty.").arg(option)); +} diff --git a/src/app/config/configcommandlineparser.h b/src/app/config/configcommandlineparser.h new file mode 100644 index 00000000..f1f02667 --- /dev/null +++ b/src/app/config/configcommandlineparser.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef COMMANDLINEPARSER_H +#define COMMANDLINEPARSER_H + +#include "configcommand.h" + +#include + +#include + +class ConfigCommandLineParser +{ +public: + void parse(const QStringList &commandLine); + + ConfigCommand command() const { return m_command; } + + qbs::Settings::Scopes scope() const { return m_scope; } + QString settingsDir() const { return m_settingsDir; } + bool helpRequested() const { return m_helpRequested; } + void printUsage() const; + + class Error + { + public: + Error(QString message) : m_message(std::move(message)) { } + QString message() const { return m_message; } + private: + QString m_message; + }; + +private: + void assignOptionArgument(const QString &option, QString &argument); + void setCommand(ConfigCommand::Command command); + void setScope(qbs::Settings::Scope scope); + + ConfigCommand m_command; + qbs::Settings::Scopes m_scope = qbs::Settings::allScopes(); + bool m_helpRequested = false; + QString m_settingsDir; + QStringList m_commandLine; +}; + +#endif // COMMANDLINEPARSER_H diff --git a/src/app/config/configmain.cpp b/src/app/config/configmain.cpp new file mode 100644 index 00000000..29cfaf9c --- /dev/null +++ b/src/app/config/configmain.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "configcommandlineparser.h" +#include "configcommandexecutor.h" + +#include +#include +#include + +#include + +#include +#include + +using qbs::Internal::Tr; +using qbs::Settings; + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + ConfigCommandLineParser parser; + try { + parser.parse(app.arguments().mid(1)); + if (parser.helpRequested()) { + std::cout << qPrintable(Tr::tr("This tool manages qbs settings.")) << std::endl; + parser.printUsage(); + return EXIT_SUCCESS; + } + Settings settings(parser.settingsDir()); + ConfigCommandExecutor(&settings, parser.scope()).execute(parser.command()); + } catch (const ConfigCommandLineParser::Error &e) { + std::cerr << qPrintable(e.message()) << std::endl; + parser.printUsage(); + return EXIT_FAILURE; + } catch (const qbs::ErrorInfo &e) { + std::cerr << qPrintable(e.toString()) << std::endl; + return EXIT_FAILURE; + } +} diff --git a/src/app/qbs-create-project/CMakeLists.txt b/src/app/qbs-create-project/CMakeLists.txt new file mode 100644 index 00000000..a627d11f --- /dev/null +++ b/src/app/qbs-create-project/CMakeLists.txt @@ -0,0 +1,10 @@ +set(SOURCES + createproject.cpp + createproject.h + create-project-main.cpp + ) + +add_qbs_app(qbs-create-project + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} + ) diff --git a/src/app/qbs-create-project/create-project-main.cpp b/src/app/qbs-create-project/create-project-main.cpp new file mode 100644 index 00000000..bb5d1a6b --- /dev/null +++ b/src/app/qbs-create-project/create-project-main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "createproject.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +int main(int argc, char *argv[]) +{ + using qbs::ErrorInfo; + using qbs::Internal::Tr; + + QCoreApplication app(argc, argv); + const QCommandLineOption flatOpt(QStringLiteral("flat"), + Tr::tr("Do not create nested project files, even if there are subdirectories and " + "the top-level directory does not contain any files.")); + const QCommandLineOption whiteListOpt(QStringLiteral("whitelist"), + Tr::tr("Only consider files whose names match these patterns. The list entries " + "can contain wildcards and are separated by commas. By default, all files " + "are considered."), QStringLiteral("whitelist")); + const QCommandLineOption blackListOpt(QStringLiteral("blacklist"), + Tr::tr("Ignore files whose names match these patterns. The list entries " + "can contain wildcards and are separated by commas. By default, no files " + "are ignored."), QStringLiteral("blacklist")); + QCommandLineParser parser; + parser.setApplicationDescription(Tr::tr("This tool creates a qbs project from an existing " + "source tree.\nNote: The resulting project file(s) " + "will likely require manual editing.")); + parser.addOption(flatOpt); + parser.addOption(whiteListOpt); + parser.addOption(blackListOpt); + parser.addHelpOption(); + parser.process(app); + const ProjectStructure projectStructure = parser.isSet(flatOpt) + ? ProjectStructure::Flat : ProjectStructure::Composite; + const QStringList whiteList = parser.value(whiteListOpt).split(QLatin1Char(','), + QBS_SKIP_EMPTY_PARTS); + const QStringList blackList = parser.value(blackListOpt).split(QLatin1Char(','), + QBS_SKIP_EMPTY_PARTS); + try { + ProjectCreator().run(QDir::currentPath(), projectStructure, whiteList, blackList); + } catch (const ErrorInfo &e) { + std::cerr << qPrintable(Tr::tr("Error creating project: %1").arg(e.toString())) + << std::endl; + return 1; + } +} diff --git a/src/app/qbs-create-project/createproject.cpp b/src/app/qbs-create-project/createproject.cpp new file mode 100644 index 00000000..4167a396 --- /dev/null +++ b/src/app/qbs-create-project/createproject.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "createproject.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +using qbs::ErrorInfo; +using qbs::Internal::Tr; + +static const char *indent = " "; + +void ProjectCreator::run(const QString &topLevelDir, ProjectStructure projectStructure, + const QStringList &whiteList, const QStringList &blackList) +{ + m_projectStructure = projectStructure; + qbs::Internal::transform(whiteList, m_whiteList, [](const QString &s) { + return QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)); }); + qbs::Internal::transform(blackList, m_blackList, [](const QString &s) { + return QRegularExpression(QRegularExpression::wildcardToRegularExpression(s)); }); + m_topLevelProject.dirPath = topLevelDir; + setupProject(&m_topLevelProject); + serializeProject(m_topLevelProject); +} + +void ProjectCreator::setupProject(Project *project) +{ + QDirIterator dit(project->dirPath, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + while (dit.hasNext()) { + dit.next(); + if (dit.fileInfo().isFile()) { + if (dit.fileName().endsWith(QLatin1String(".qbs"))) + throw ErrorInfo(Tr::tr("Project already contains qbs files, aborting.")); + if (isSourceFile(dit.fileName())) + project->fileNames << dit.fileName(); + } else if (dit.fileInfo().isDir()) { + ProjectPtr subProject(new Project); + subProject->dirName = dit.fileName(); + subProject->dirPath = dit.filePath(); + setupProject(subProject.get()); + if (!subProject->fileNames.empty() || !subProject->subProjects.empty()) + project->subProjects.push_back(std::move(subProject)); + } + } + project->fileNames.sort(); + std::sort(project->subProjects.begin(), project->subProjects.end(), + [](const ProjectPtr &p1, const ProjectPtr &p2) { return p1->dirName < p2->dirName; }); +} + +void ProjectCreator::serializeProject(const ProjectCreator::Project &project) +{ + const QString fileName = QFileInfo(project.dirPath).baseName() + QLatin1String(".qbs"); + QFile projectFile(project.dirPath + QLatin1Char('/') + fileName); + if (!projectFile.open(QIODevice::WriteOnly)) { + throw ErrorInfo(Tr::tr("Failed to open '%1' for writing: %2") + .arg(projectFile.fileName(), projectFile.errorString())); + } + QTextStream fileContents(&projectFile); + qbs::setupDefaultCodec(fileContents); + if (!project.fileNames.empty() || m_projectStructure == ProjectStructure::Flat) { + fileContents << "Product {\n"; + const ProductFlags productFlags = getFlags(project); + if (productFlags.testFlag(IsApp)) { + fileContents << indent << "type: [\"application\"]\n"; + } else { + fileContents << indent << "type: [\"unknown\"] // E.g. \"application\", " + "\"dynamiclibrary\", \"staticlibrary\"\n"; + } + if (productFlags.testFlag(NeedsQt)) { + fileContents << indent << "Depends {\n"; + fileContents << indent << indent << "name: \"Qt\"\n"; + fileContents << indent << indent << "submodules: [\"core\"] " + "// Add more here if needed\n"; + fileContents << indent << "}\n"; + } else if (productFlags.testFlag(NeedsCpp)) { + fileContents << indent << "Depends { name: \"cpp\" }\n"; + } + fileContents << indent << "files: [\n"; + for (const QString &fileName : qAsConst(project.fileNames)) + fileContents << indent << indent << qbs::toJSLiteral(fileName) << ",\n"; + fileContents << indent << "]\n"; + for (const ProjectPtr &p : project.subProjects) + addGroups(fileContents, QDir(project.dirPath), *p); + } else { + fileContents << "Project {\n"; + fileContents << indent << "references: [\n"; + for (const ProjectPtr &p : project.subProjects) { + serializeProject(*p); + fileContents << indent << indent + << qbs::toJSLiteral(QFileInfo(p->dirPath).fileName()) << ",\n"; + } + fileContents << indent << "]\n"; + } + fileContents << "}\n"; +} + +void ProjectCreator::addGroups(QTextStream &stream, const QDir &baseDir, + const ProjectCreator::Project &subProject) +{ + stream << indent << "Group {\n"; + stream << indent << indent << "name: " + << qbs::toJSLiteral(QFileInfo(subProject.dirPath).fileName()) << "\n"; + stream << indent << indent << "prefix: " + << qbs::toJSLiteral(baseDir.relativeFilePath(subProject.dirPath) + QLatin1Char('/')) + << '\n'; + stream << indent << indent << "files: [\n"; + for (const QString &fileName : qAsConst(subProject.fileNames)) + stream << indent << indent << indent << qbs::toJSLiteral(fileName) << ",\n"; + stream << indent << indent << "]\n"; + stream << indent << "}\n"; + for (const ProjectPtr &p : subProject.subProjects) + addGroups(stream, baseDir, *p); +} + +bool ProjectCreator::isSourceFile(const QString &fileName) +{ + const auto isMatch = [fileName](const QRegularExpression &rex) { + return rex.match(fileName).hasMatch(); + }; + return !qbs::Internal::any_of(m_blackList, isMatch) + && (m_whiteList.empty() || qbs::Internal::any_of(m_whiteList, isMatch)); +} + +ProjectCreator::ProductFlags ProjectCreator::getFlags(const ProjectCreator::Project &project) +{ + ProductFlags flags; + getFlagsFromFileNames(project, flags); + if (flags.testFlag(IsApp) && flags.testFlag(NeedsQt)) + return flags; + if (!flags.testFlag(NeedsCpp)) + return flags; + getFlagsFromFileContents(project, flags); + return flags; +} + +void ProjectCreator::getFlagsFromFileNames(const ProjectCreator::Project &project, + ProductFlags &flags) +{ + for (const QString &fileName : qAsConst(project.fileNames)) { + if (flags.testFlag(IsApp) && flags.testFlag(NeedsQt)) + return; + const QFileInfo fi(project.dirPath + QLatin1Char('/') + fileName); + const QString &suffix = fi.suffix(); + if (suffix == QLatin1String("qrc")) { + flags |= NeedsQt; + continue; + } + if (suffix == QLatin1String("cpp") || suffix == QLatin1String("c") + || suffix == QLatin1String("m") || suffix == QLatin1String("mm")) { + flags |= NeedsCpp; + } + if (flags.testFlag(NeedsCpp) && fi.completeBaseName() == QLatin1String("main")) + flags |= IsApp; + } + for (const ProjectPtr &p : project.subProjects) { + getFlagsFromFileNames(*p, flags); + if (flags.testFlag(IsApp) && flags.testFlag(NeedsQt)) + return; + } +} + +void ProjectCreator::getFlagsFromFileContents(const ProjectCreator::Project &project, + ProductFlags &flags) +{ + for (const QString &fileName : qAsConst(project.fileNames)) { + QFile f (project.dirPath + QLatin1Char('/') + fileName); + if (!f.open(QIODevice::ReadOnly)) { + qDebug() << "Ignoring failure to read" << f.fileName(); + continue; + } + while (!f.atEnd()) { + const QByteArray &line = f.readLine(); + if (line.contains("#include +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QDir; +class QTextStream; +QT_END_NAMESPACE + +enum class ProjectStructure { Flat, Composite }; + +class ProjectCreator +{ +public: + void run(const QString &topLevelDir, ProjectStructure projectStructure, + const QStringList &whiteList, const QStringList &blacklist); + +private: + enum ProductFlag { IsApp = 1, NeedsCpp = 2, NeedsQt = 4 }; + Q_DECLARE_FLAGS(ProductFlags, ProductFlag) + + struct Project; + void setupProject(Project *project); + void serializeProject(const Project &project); + void addGroups(QTextStream &stream, const QDir &baseDir, const Project &subProject); + bool isSourceFile(const QString &fileName); + ProductFlags getFlags(const Project &project); + void getFlagsFromFileNames(const Project &project, ProductFlags &flags); + void getFlagsFromFileContents(const Project &project, ProductFlags &flags); + + using ProjectPtr = std::unique_ptr; + struct Project { + QString dirPath; + QString dirName; + QStringList fileNames; + std::vector subProjects; + }; + Project m_topLevelProject; + ProjectStructure m_projectStructure = ProjectStructure::Flat; + QList m_whiteList; + QList m_blackList; +}; + +#endif // QBS_CREATEPROJECT_H diff --git a/src/app/qbs-create-project/qbs-create-project.pro b/src/app/qbs-create-project/qbs-create-project.pro new file mode 100644 index 00000000..1edb8521 --- /dev/null +++ b/src/app/qbs-create-project/qbs-create-project.pro @@ -0,0 +1,9 @@ +include(../app.pri) + +TARGET = qbs-create-project + +HEADERS += \ + createproject.h +SOURCES += \ + createproject.cpp \ + create-project-main.cpp diff --git a/src/app/qbs-create-project/qbs-create-project.qbs b/src/app/qbs-create-project/qbs-create-project.qbs new file mode 100644 index 00000000..ae79001e --- /dev/null +++ b/src/app/qbs-create-project/qbs-create-project.qbs @@ -0,0 +1,8 @@ +QbsApp { + name: "qbs-create-project" + files: [ + "createproject.cpp", + "createproject.h", + "create-project-main.cpp", + ] +} diff --git a/src/app/qbs-setup-android/CMakeLists.txt b/src/app/qbs-setup-android/CMakeLists.txt new file mode 100644 index 00000000..46930318 --- /dev/null +++ b/src/app/qbs-setup-android/CMakeLists.txt @@ -0,0 +1,12 @@ +set(SOURCES + android-setup.cpp + android-setup.h + commandlineparser.cpp + commandlineparser.h + main.cpp + ) + +add_qbs_app(qbs-setup-android + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} + ) diff --git a/src/app/qbs-setup-android/android-setup.cpp b/src/app/qbs-setup-android/android-setup.cpp new file mode 100644 index 00000000..329bd005 --- /dev/null +++ b/src/app/qbs-setup-android/android-setup.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "android-setup.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace qbs; +using qbs::Internal::Tr; + +static QString qls(const char *s) { return QLatin1String(s); } + +static QStringList expectedArchs() +{ + return {QStringLiteral("arm64"), QStringLiteral("armv7a"), + QStringLiteral("x86"), QStringLiteral("x86_64")}; +} + +void setupSdk(qbs::Settings *settings, const QString &profileName, const QString &sdkDirPath) +{ + if (!QDir(sdkDirPath).exists()) { + throw ErrorInfo(Tr::tr("SDK directory '%1' does not exist.") + .arg(QDir::toNativeSeparators(sdkDirPath))); + } + + Profile profile(profileName, settings); + profile.removeProfile(); + if (!sdkDirPath.isEmpty()) + profile.setValue(qls("Android.sdk.sdkDir"), QDir::cleanPath(sdkDirPath)); + profile.setValue(qls("qbs.targetPlatform"), qls("android")); +} + +static QString mapArch(const QString &androidName) +{ + if (androidName == qls("arm64-v8a")) + return qls("arm64"); + if (androidName == qls("armeabi")) + return qls("armv5te"); + if (androidName == qls("armeabi-v7a")) + return qls("armv7a"); + return androidName; +} + +struct QtAndroidInfo { + bool isValid() const { return !archs.isEmpty(); } + + QString qmakePath; + QStringList archs; + QString platform; +}; + +static QtAndroidInfo getInfoForQtDir(const QString &qtDir) +{ + QtAndroidInfo info; + info.qmakePath = qbs::Internal::HostOsInfo::appendExecutableSuffix(qtDir + qls("/bin/qmake")); + if (!QFile::exists(info.qmakePath)) + return info; + QFile qdevicepri(qtDir + qls("/mkspecs/qdevice.pri")); + if (!qdevicepri.open(QIODevice::ReadOnly)) + return info; + while (!qdevicepri.atEnd()) { + // For Qt < 5.14 use DEFAULT_ANDROID_TARGET_ARCH (which is the abi) to compute + // the architecture + // DEFAULT_ANDROID_ABIS doesn't exit + // For Qt >= 5.14: + // DEFAULT_ANDROID_TARGET_ARCH doesn't exist, use DEFAULT_ANDROID_ABIS to compute + // the architectures + const QByteArray line = qdevicepri.readLine().simplified(); + const bool isArchLine = line.startsWith("DEFAULT_ANDROID_TARGET_ARCH"); + const bool isAbisLine = line.startsWith("DEFAULT_ANDROID_ABIS"); + const bool isPlatformLine = line.startsWith("DEFAULT_ANDROID_PLATFORM"); + if (!isArchLine && !isPlatformLine && !isAbisLine) + continue; + const QList elems = line.split('='); + if (elems.size() != 2) + continue; + const QString rhs = QString::fromLatin1(elems.at(1).trimmed()); + if (isArchLine) { + info.archs << mapArch(rhs); + } else if (isAbisLine) { + const auto abis = rhs.split(QLatin1Char(' ')); + for (const QString &abi: abis) + info.archs << mapArch(abi); + } else { + info.platform = rhs; + } + } + return info; +} + +using QtInfoPerArch = QHash; +static QtInfoPerArch getQtAndroidInfo(const QString &qtSdkDir) +{ + QtInfoPerArch archs; + if (qtSdkDir.isEmpty()) + return archs; + + QStringList qtDirs(qtSdkDir); + const QStringList nameFilters{QStringLiteral("android_*"), QStringLiteral("android")}; + QDirIterator dit(qtSdkDir, nameFilters, QDir::Dirs); + while (dit.hasNext()) + qtDirs << dit.next(); + for (const auto &qtDir : qAsConst(qtDirs)) { + const QtAndroidInfo info = getInfoForQtDir(qtDir); + if (info.isValid()) { + for (const QString &arch: info.archs) + archs.insert(arch, info); + } + } + return archs; +} + +static QString maximumPlatform(const QString &platform1, const QString &platform2) +{ + if (platform1.isEmpty()) + return platform2; + if (platform2.isEmpty()) + return platform1; + static const QString prefix = qls("android-"); + const QString numberString1 = platform1.mid(prefix.size()); + const QString numberString2 = platform2.mid(prefix.size()); + bool ok; + const int value1 = numberString1.toInt(&ok); + if (!ok) { + qWarning("Ignoring malformed Android platform string '%s'.", qPrintable(platform1)); + return platform2; + } + const int value2 = numberString2.toInt(&ok); + if (!ok) { + qWarning("Ignoring malformed Android platform string '%s'.", qPrintable(platform2)); + return platform1; + } + return prefix + QString::number(std::max(value1, value2)); +} + +static QString getToolchainType(const QString &ndkDirPath) +{ + QFile sourceProperties(ndkDirPath + qls("/source.properties")); + if (!sourceProperties.open(QIODevice::ReadOnly)) + return QStringLiteral("gcc"); // <= r10 + while (!sourceProperties.atEnd()) { + const QByteArray curLine = sourceProperties.readLine().simplified(); + static const QByteArray prefix = "Pkg.Revision = "; + if (!curLine.startsWith(prefix)) + continue; + qbs::Version ndkVersion = qbs::Version::fromString( + QString::fromLatin1(curLine.mid(prefix.size()))); + if (!ndkVersion.isValid()) { + qWarning("Unexpected format of NDK revision string in '%s'", + qPrintable(sourceProperties.fileName())); + return QStringLiteral("clang"); + } + return qls(ndkVersion.majorVersion() >= 18 ? "clang" : "gcc"); + } + qWarning("No revision entry found in '%s'", qPrintable(sourceProperties.fileName())); + return QStringLiteral("clang"); +} + +static void setupNdk(qbs::Settings *settings, const QString &profileName, const QString &ndkDirPath, + const QString &qtSdkDirPath) +{ + if (!QDir(ndkDirPath).exists()) { + throw ErrorInfo(Tr::tr("NDK directory '%1' does not exist.") + .arg(QDir::toNativeSeparators(ndkDirPath))); + } + + Profile mainProfile(profileName, settings); + if (!ndkDirPath.isEmpty()) { + mainProfile.setValue(qls("Android.ndk.ndkDir"), QDir::cleanPath(ndkDirPath)); + mainProfile.setValue(qls("Android.sdk.ndkDir"), QDir::cleanPath(ndkDirPath)); + } + mainProfile.setValue(qls("qbs.toolchainType"), getToolchainType(ndkDirPath)); + const QStringList archs = expectedArchs(); + const QtInfoPerArch infoPerArch = getQtAndroidInfo(qtSdkDirPath); + const QStringList archsForProfile = infoPerArch.empty() + ? archs : QStringList(infoPerArch.keys()); + if (archsForProfile.size() == 1) + mainProfile.setValue(qls("qbs.architecture"), archsForProfile.front()); + else + mainProfile.setValue(qls("qbs.architectures"), archsForProfile); + QStringList qmakeFilePaths; + QString platform; + for (const QString &arch : archs) { + const QtAndroidInfo qtAndroidInfo = infoPerArch.value(arch); + if (!qtAndroidInfo.isValid()) + continue; + qmakeFilePaths << qtAndroidInfo.qmakePath; + platform = maximumPlatform(platform, qtAndroidInfo.platform); + } + if (!qmakeFilePaths.empty()) { + qmakeFilePaths.removeDuplicates(); + mainProfile.setValue(qls("moduleProviders.Qt.qmakeFilePaths"), qmakeFilePaths); + } + if (!platform.isEmpty()) + mainProfile.setValue(qls("Android.ndk.platform"), platform); +} + +void setupAndroid(Settings *settings, const QString &profileName, const QString &sdkDirPath, + const QString &ndkDirPath, const QString &qtSdkDirPath) +{ + setupSdk(settings, profileName, sdkDirPath); + setupNdk(settings, profileName, ndkDirPath, qtSdkDirPath); +} diff --git a/src/app/qbs-setup-android/android-setup.h b/src/app/qbs-setup-android/android-setup.h new file mode 100644 index 00000000..55aeedb2 --- /dev/null +++ b/src/app/qbs-setup-android/android-setup.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUP_ANDROID_SDKSETUP_H +#define QBS_SETUP_ANDROID_SDKSETUP_H + +#include + +namespace qbs { class Settings; } + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +void setupAndroid(qbs::Settings *settings, const QString &profileName, const QString &sdkDirPath, + const QString &ndkDirPath, const QString &qtSdkDirPath); + +#endif // Include guard. + diff --git a/src/app/qbs-setup-android/commandlineparser.cpp b/src/app/qbs-setup-android/commandlineparser.cpp new file mode 100644 index 00000000..c4ff0994 --- /dev/null +++ b/src/app/qbs-setup-android/commandlineparser.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineparser.h" + +#include +#include + +#include + +CommandLineParser::CommandLineParser() = default; + +using qbs::Internal::Tr; + +static QString helpOptionShort() { return QStringLiteral("-h"); } +static QString helpOptionLong() { return QStringLiteral("--help"); } +static QString settingsDirOption() { return QStringLiteral("--settings-dir"); } +static QString sdkDirOption() { return QStringLiteral("--sdk-dir"); } +static QString ndkDirOption() { return QStringLiteral("--ndk-dir"); } +static QString qtSdkDirOption() { return QStringLiteral("--qt-dir"); } +static QString systemOption() { return QStringLiteral("--system"); } + +void CommandLineParser::parse(const QStringList &commandLine) +{ + m_commandLine = commandLine; + Q_ASSERT(!m_commandLine.empty()); + m_command = QFileInfo(m_commandLine.takeFirst()).fileName(); + m_helpRequested = false; + m_sdkDir.clear(); + m_ndkDir.clear(); + m_profileName.clear(); + m_settingsDir.clear(); + + if (m_commandLine.empty()) + throwError(Tr::tr("No command-line arguments provided.")); + + while (!m_commandLine.empty()) { + const QString arg = m_commandLine.front(); + if (!arg.startsWith(QLatin1Char('-'))) + break; + m_commandLine.removeFirst(); + if (arg == helpOptionShort() || arg == helpOptionLong()) + m_helpRequested = true; + else if (arg == settingsDirOption()) + assignOptionArgument(settingsDirOption(), m_settingsDir); + else if (arg == systemOption()) + m_settingsScope = qbs::Settings::SystemScope; + else if (arg == sdkDirOption()) + assignOptionArgument(sdkDirOption(), m_sdkDir); + else if (arg == ndkDirOption()) + assignOptionArgument(ndkDirOption(), m_ndkDir); + else if (arg == qtSdkDirOption()) + assignOptionArgument(arg, m_qtSdkDir); + else + throwError(Tr::tr("Unknown option '%1'.").arg(arg)); + } + + if (m_helpRequested) { + if (!m_commandLine.empty()) + complainAboutExtraArguments(); + return; + } + + switch (m_commandLine.size()) { + case 0: + throwError(Tr::tr("No profile name supplied.")); + case 1: + m_profileName = m_commandLine.takeFirst(); + m_profileName.replace(QLatin1Char('.'), QLatin1Char('-')); + break; + default: + complainAboutExtraArguments(); + } +} + +void CommandLineParser::throwError(const QString &message) +{ + qbs::ErrorInfo error(Tr::tr("Syntax error: %1").arg(message)); + error.append(usageString()); + throw error; +} + +QString CommandLineParser::usageString() const +{ + QString s = Tr::tr("This tool creates qbs profiles from Android SDK and NDK installations.\n"); + s += Tr::tr("Usage:\n"); + s += Tr::tr(" %1 [%2 ] [%6] [%3 ] [%4 ] [%5 ] " + "\n") + .arg(m_command, settingsDirOption(), ndkDirOption(), sdkDirOption(), qtSdkDirOption(), systemOption()); + s += Tr::tr(" %1 %2|%3\n").arg(m_command, helpOptionShort(), helpOptionLong()); + s += Tr::tr("If an NDK path is given, the profile will be suitable for use with Android " + "projects that contain native C/C++ code.\n"); + s += Tr::tr("If a Qt path is also given, the profile will be suitable for developing " + "Qt applications for Android.\n"); + return s; +} + +void CommandLineParser::assignOptionArgument(const QString &option, QString &argument) +{ + if (m_commandLine.empty()) + throwError(Tr::tr("Option '%1' needs an argument.").arg(option)); + argument = m_commandLine.takeFirst(); + if (argument.isEmpty()) + throwError(Tr::tr("Argument for option '%1' must not be empty.").arg(option)); +} + +void CommandLineParser::complainAboutExtraArguments() +{ + throwError(Tr::tr("Extraneous command-line arguments '%1'.") + .arg(m_commandLine.join(QLatin1Char(' ')))); +} + diff --git a/src/app/qbs-setup-android/commandlineparser.h b/src/app/qbs-setup-android/commandlineparser.h new file mode 100644 index 00000000..47f42463 --- /dev/null +++ b/src/app/qbs-setup-android/commandlineparser.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_SETUP_ANDROID_COMMANDLINEPARSER_H +#define QBS_SETUP_ANDROID_COMMANDLINEPARSER_H + +#include + +#include + +class CommandLineParser +{ +public: + CommandLineParser(); + + void parse(const QStringList &commandLine); + + bool helpRequested() const { return m_helpRequested; } + + QString sdkDir() const { return m_sdkDir; } + QString ndkDir() const { return m_ndkDir; } + QString qtSdkDir() const { return m_qtSdkDir; } + QString profileName() const { return m_profileName; } + QString settingsDir() const { return m_settingsDir; } + qbs::Settings::Scope settingsScope() const { return m_settingsScope; } + + QString usageString() const; + +private: + [[noreturn]] void throwError(const QString &message); + void assignOptionArgument(const QString &option, QString &argument); + [[noreturn]] void complainAboutExtraArguments(); + + bool m_helpRequested = false; + qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope; + QString m_sdkDir; + QString m_ndkDir; + QString m_qtSdkDir; + QString m_profileName; + QString m_settingsDir; + QStringList m_commandLine; + QString m_command; +}; + +#endif // Include guard. diff --git a/src/app/qbs-setup-android/main.cpp b/src/app/qbs-setup-android/main.cpp new file mode 100644 index 00000000..18e5dbe4 --- /dev/null +++ b/src/app/qbs-setup-android/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "commandlineparser.h" +#include "android-setup.h" + +#include +#include +#include + +#include + +#include +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + CommandLineParser clParser; + try { + clParser.parse(app.arguments()); + if (clParser.helpRequested()) { + std::cout << qPrintable(clParser.usageString()) << std::endl; + return EXIT_SUCCESS; + } + qbs::Settings settings(clParser.settingsDir()); + settings.setScopeForWriting(clParser.settingsScope()); + setupAndroid(&settings, clParser.profileName(), clParser.sdkDir(), clParser.ndkDir(), + clParser.qtSdkDir()); + } catch (const qbs::ErrorInfo &e) { + std::cerr << qPrintable(qbs::Internal::Tr::tr("Error: %1").arg(e.toString())) << std::endl; + return EXIT_FAILURE; + } +} diff --git a/src/app/qbs-setup-android/qbs-setup-android.exe.manifest b/src/app/qbs-setup-android/qbs-setup-android.exe.manifest new file mode 100644 index 00000000..6b425b15 --- /dev/null +++ b/src/app/qbs-setup-android/qbs-setup-android.exe.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/app/qbs-setup-android/qbs-setup-android.pro b/src/app/qbs-setup-android/qbs-setup-android.pro new file mode 100644 index 00000000..b5e57761 --- /dev/null +++ b/src/app/qbs-setup-android/qbs-setup-android.pro @@ -0,0 +1,12 @@ +include(../app.pri) + +TARGET = qbs-setup-android + +SOURCES += \ + android-setup.cpp \ + commandlineparser.cpp \ + main.cpp + +HEADERS += \ + android-setup.h \ + commandlineparser.h diff --git a/src/app/qbs-setup-android/qbs-setup-android.qbs b/src/app/qbs-setup-android/qbs-setup-android.qbs new file mode 100644 index 00000000..b18e152b --- /dev/null +++ b/src/app/qbs-setup-android/qbs-setup-android.qbs @@ -0,0 +1,20 @@ +QbsApp { + name: "qbs-setup-android" + files: [ + "android-setup.cpp", + "android-setup.h", + "commandlineparser.cpp", + "commandlineparser.h", + "main.cpp", + ] + Group { + name: "MinGW specific files" + condition: qbs.toolchain.contains("mingw") + files: "qbs-setup-android.rc" + Group { + name: "qbs-setup-android manifest" + files: "qbs-setup-android.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } + } +} diff --git a/src/app/qbs-setup-android/qbs-setup-android.rc b/src/app/qbs-setup-android/qbs-setup-android.rc new file mode 100644 index 00000000..20cd1ab1 --- /dev/null +++ b/src/app/qbs-setup-android/qbs-setup-android.rc @@ -0,0 +1,4 @@ +#define RT_MANIFEST 24 +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "qbs-setup-android.exe.manifest" diff --git a/src/app/qbs-setup-qt/CMakeLists.txt b/src/app/qbs-setup-qt/CMakeLists.txt new file mode 100644 index 00000000..a91ab1b2 --- /dev/null +++ b/src/app/qbs-setup-qt/CMakeLists.txt @@ -0,0 +1,12 @@ +set(SOURCES + commandlineparser.cpp + commandlineparser.h + main.cpp + setupqt.cpp + setupqt.h + ) + +add_qbs_app(qbs-setup-qt + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} + ) diff --git a/src/app/qbs-setup-qt/commandlineparser.cpp b/src/app/qbs-setup-qt/commandlineparser.cpp new file mode 100644 index 00000000..3bfe9bb6 --- /dev/null +++ b/src/app/qbs-setup-qt/commandlineparser.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineparser.h" + +#include +#include + +#include + +using qbs::Internal::Tr; + +static QString helpOptionShort() { return QStringLiteral("-h"); } +static QString helpOptionLong() { return QStringLiteral("--help"); } +static QString detectOption() { return QStringLiteral("--detect"); } +static QString settingsDirOption() { return QStringLiteral("--settings-dir"); } +static QString systemOption() { return QStringLiteral("--system"); } + +void CommandLineParser::parse(const QStringList &commandLine) +{ + m_commandLine = commandLine; + Q_ASSERT(!m_commandLine.empty()); + m_command = QFileInfo(m_commandLine.takeFirst()).fileName(); + m_helpRequested = false; + m_autoDetectionMode = false; + m_qmakePath.clear(); + m_profileName.clear(); + m_settingsDir.clear(); + + if (m_commandLine.empty()) + throwError(Tr::tr("No command-line arguments provided.")); + + while (!m_commandLine.empty()) { + const QString arg = m_commandLine.front(); + if (!arg.startsWith(QLatin1Char('-'))) + break; + m_commandLine.removeFirst(); + if (arg == helpOptionShort() || arg == helpOptionLong()) + m_helpRequested = true; + else if (arg == detectOption()) + m_autoDetectionMode = true; + else if (arg == systemOption()) + m_settingsScope = qbs::Settings::SystemScope; + else if (arg == settingsDirOption()) + assignOptionArgument(settingsDirOption(), m_settingsDir); + } + + if (m_helpRequested || m_autoDetectionMode) { + if (!m_commandLine.empty()) + complainAboutExtraArguments(); + return; + } + + switch (m_commandLine.size()) { + case 0: + case 1: + throwError(Tr::tr("Not enough command-line arguments provided.")); + case 2: + m_qmakePath = m_commandLine.at(0); + m_profileName = m_commandLine.at(1); + break; + default: + complainAboutExtraArguments(); + } +} + +void CommandLineParser::throwError(const QString &message) +{ + qbs::ErrorInfo error(Tr::tr("Syntax error: %1").arg(message)); + error.append(usageString()); + throw error; +} + +QString CommandLineParser::usageString() const +{ + QString s = Tr::tr("This tool creates qbs profiles from Qt versions.\n"); + s += Tr::tr("Usage:\n"); + s += Tr::tr(" %1 [%2 ] [%4] %3\n") + .arg(m_command, settingsDirOption(), detectOption(), systemOption()); + s += Tr::tr(" %1 [%2 ] [%4] \n") + .arg(m_command, settingsDirOption(), systemOption()); + s += Tr::tr(" %1 %2|%3\n").arg(m_command, helpOptionShort(), helpOptionLong()); + s += Tr::tr("The first form tries to auto-detect all known Qt versions, looking them up " + "via the PATH environment variable.\n"); + s += Tr::tr("The second form creates one profile for one Qt version."); + return s; +} + +void CommandLineParser::assignOptionArgument(const QString &option, QString &argument) +{ + if (m_commandLine.empty()) + throwError(Tr::tr("Option '%1' needs an argument.").arg(option)); + argument = m_commandLine.takeFirst(); + if (argument.isEmpty()) + throwError(Tr::tr("Argument for option '%1' must not be empty.").arg(option)); +} + +void CommandLineParser::complainAboutExtraArguments() +{ + throwError(Tr::tr("Extraneous command-line arguments '%1'.") + .arg(m_commandLine.join(QLatin1Char(' ')))); +} diff --git a/src/app/qbs-setup-qt/commandlineparser.h b/src/app/qbs-setup-qt/commandlineparser.h new file mode 100644 index 00000000..c766a9df --- /dev/null +++ b/src/app/qbs-setup-qt/commandlineparser.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H +#define QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H + +#include + +#include + +class CommandLineParser +{ +public: + void parse(const QStringList &commandLine); + + bool helpRequested() const { return m_helpRequested; } + bool autoDetectionMode() const { return m_autoDetectionMode; } + + QString qmakePath() const { return m_qmakePath; } + QString profileName() const { return m_profileName; } + QString settingsDir() const { return m_settingsDir; } + qbs::Settings::Scope settingsScope() const { return m_settingsScope; } + + QString usageString() const; + +private: + [[noreturn]] void throwError(const QString &message); + void assignOptionArgument(const QString &option, QString &argument); + [[noreturn]] void complainAboutExtraArguments(); + + bool m_helpRequested = false; + bool m_autoDetectionMode = false; + qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope; + QString m_qmakePath; + QString m_profileName; + QString m_settingsDir; + QStringList m_commandLine; + QString m_command; +}; + +#endif // Include guard diff --git a/src/app/qbs-setup-qt/main.cpp b/src/app/qbs-setup-qt/main.cpp new file mode 100644 index 00000000..bef95eee --- /dev/null +++ b/src/app/qbs-setup-qt/main.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "setupqt.h" + +#include "commandlineparser.h" + +#include +#include +#include + +#include +#include +#include + +#include +#include + +using namespace qbs; +using Internal::Tr; + +int main(int argc, char *argv[]) +{ + QCoreApplication application(argc, argv); + + try { + CommandLineParser clParser; + clParser.parse(application.arguments()); + + if (clParser.helpRequested()) { + std::cout << qPrintable(clParser.usageString()) << std::endl; + return EXIT_SUCCESS; + } + + Settings settings(clParser.settingsDir()); + settings.setScopeForWriting(clParser.settingsScope()); + + if (clParser.autoDetectionMode()) { + // search all Qt's in path and dump their settings + const std::vector qtEnvironments = SetupQt::fetchEnvironments(); + if (qtEnvironments.empty()) { + std::cout << qPrintable(Tr::tr("No Qt installations detected. " + "No profiles created.")) + << std::endl; + } + for (const QtEnvironment &qtEnvironment : qtEnvironments) { + QString profileName = QLatin1String("qt-") + qtEnvironment.qtVersion.toString(); + if (SetupQt::checkIfMoreThanOneQtWithTheSameVersion(qtEnvironment.qtVersion, qtEnvironments)) { + QStringList prefixPathParts = QFileInfo(qtEnvironment.qmakeFilePath).path() + .split(QLatin1Char('/'), QBS_SKIP_EMPTY_PARTS); + if (!prefixPathParts.empty()) + profileName += QLatin1String("-") + prefixPathParts.last(); + } + SetupQt::saveToQbsSettings(profileName, qtEnvironment, &settings); + } + return EXIT_SUCCESS; + } + + if (!SetupQt::isQMakePathValid(clParser.qmakePath())) { + std::cerr << qPrintable(Tr::tr("'%1' does not seem to be a qmake executable.") + .arg(clParser.qmakePath())) << std::endl; + return EXIT_FAILURE; + } + + const QtEnvironment qtEnvironment = SetupQt::fetchEnvironment(clParser.qmakePath()); + QString profileName = clParser.profileName(); + profileName.replace(QLatin1Char('.'), QLatin1Char('-')); + SetupQt::saveToQbsSettings(profileName, qtEnvironment, &settings); + return EXIT_SUCCESS; + } catch (const ErrorInfo &e) { + std::cerr << qPrintable(e.toString()) << std::endl; + return EXIT_FAILURE; + } +} diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.exe.manifest b/src/app/qbs-setup-qt/qbs-setup-qt.exe.manifest new file mode 100644 index 00000000..a0b8dbac --- /dev/null +++ b/src/app/qbs-setup-qt/qbs-setup-qt.exe.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.pro b/src/app/qbs-setup-qt/qbs-setup-qt.pro new file mode 100644 index 00000000..a5694d6b --- /dev/null +++ b/src/app/qbs-setup-qt/qbs-setup-qt.pro @@ -0,0 +1,16 @@ +include(../app.pri) + +TARGET = qbs-setup-qt + +SOURCES += \ + commandlineparser.cpp \ + main.cpp \ + setupqt.cpp + +HEADERS += \ + commandlineparser.h \ + setupqt.h + +mingw { + RC_FILE = qbs-setup-qt.rc +} diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.qbs b/src/app/qbs-setup-qt/qbs-setup-qt.qbs new file mode 100644 index 00000000..3be09015 --- /dev/null +++ b/src/app/qbs-setup-qt/qbs-setup-qt.qbs @@ -0,0 +1,21 @@ +QbsApp { + name: "qbs-setup-qt" + files: [ + "commandlineparser.cpp", + "commandlineparser.h", + "main.cpp", + "setupqt.cpp", + "setupqt.h" + ] + Group { + name: "MinGW specific files" + condition: qbs.toolchain.contains("mingw") + files: "qbs-setup-qt.rc" + Group { + name: "qbs-setup-qt manifest" + files: "qbs-setup-qt.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } + } +} + diff --git a/src/app/qbs-setup-qt/qbs-setup-qt.rc b/src/app/qbs-setup-qt/qbs-setup-qt.rc new file mode 100644 index 00000000..ad2507e4 --- /dev/null +++ b/src/app/qbs-setup-qt/qbs-setup-qt.rc @@ -0,0 +1,4 @@ +#define RT_MANIFEST 24 +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "qbs-setup-qt.exe.manifest" diff --git a/src/app/qbs-setup-qt/setupqt.cpp b/src/app/qbs-setup-qt/setupqt.cpp new file mode 100644 index 00000000..08caec65 --- /dev/null +++ b/src/app/qbs-setup-qt/setupqt.cpp @@ -0,0 +1,389 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "setupqt.h" + +#include "../shared/logging/consolelogger.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +using Internal::none_of; +using Internal::contains; +using Internal::HostOsInfo; +using Internal::Tr; +using Internal::rangeTo; + +static QStringList qmakeExecutableNames() +{ + const QString baseName = HostOsInfo::appendExecutableSuffix(QStringLiteral("qmake")); + QStringList lst(baseName); + if (HostOsInfo::isLinuxHost()) { + // Some distributions ship binaries called qmake-qt5 or qmake-qt4. + lst << baseName + QLatin1String("-qt5") << baseName + QLatin1String("-qt4"); + } + return lst; +} + +static QStringList collectQmakePaths() +{ + const QStringList qmakeExeNames = qmakeExecutableNames(); + QStringList qmakePaths; + QByteArray environmentPath = qgetenv("PATH"); + const QList environmentPaths + = environmentPath.split(HostOsInfo::pathListSeparator().toLatin1()); + for (const QByteArray &path : environmentPaths) { + for (const QString &qmakeExecutableName : qmakeExeNames) { + QFileInfo pathFileInfo(QDir(QLatin1String(path)), qmakeExecutableName); + if (pathFileInfo.exists()) { + QString qmakePath = pathFileInfo.absoluteFilePath(); + if (!qmakePaths.contains(qmakePath)) + qmakePaths.push_back(qmakePath); + } + } + } + + return qmakePaths; +} + +bool SetupQt::isQMakePathValid(const QString &qmakePath) +{ + QFileInfo qmakeFileInfo(qmakePath); + return qmakeFileInfo.exists() && qmakeFileInfo.isFile() && qmakeFileInfo.isExecutable(); +} + +std::vector SetupQt::fetchEnvironments() +{ + std::vector qtEnvironments; + const auto qmakePaths = collectQmakePaths(); + for (const QString &qmakePath : qmakePaths) { + const QtEnvironment env = fetchEnvironment(qmakePath); + if (none_of(qtEnvironments, [&env](const QtEnvironment &otherEnv) { + return env.qmakeFilePath == otherEnv.qmakeFilePath; + })) { + qtEnvironments.push_back(env); + } + } + return qtEnvironments; +} + +// These functions work only for Qt from installer. +static QStringList qbsToolchainFromDirName(const QString &dir) +{ + if (dir.startsWith(QLatin1String("msvc"))) + return {QStringLiteral("msvc")}; + if (dir.startsWith(QLatin1String("mingw"))) + return {QStringLiteral("mingw"), QStringLiteral("gcc")}; + if (dir.startsWith(QLatin1String("clang"))) + return {QStringLiteral("clang"), QStringLiteral("llvm"), QStringLiteral("gcc")}; + if (dir.startsWith(QLatin1String("gcc"))) + return {QStringLiteral("gcc")}; + return {}; +} + +static Version msvcVersionFromDirName(const QString &dir) +{ + static const std::regex regexp("^msvc(\\d\\d\\d\\d).*$"); + std::smatch match; + const std::string dirString = dir.toStdString(); + if (!std::regex_match(dirString, match, regexp)) + return Version{}; + QMap mapping{ + std::make_pair("2005", "14"), std::make_pair("2008", "15"), std::make_pair("2010", "16"), + std::make_pair("2012", "17"), std::make_pair("2013", "18"), std::make_pair("2015", "19"), + std::make_pair("2017", "19.1"), std::make_pair("2019", "19.2") + }; + return Version::fromString(QString::fromStdString(mapping.value(match[1].str()))); +} + +static QString archFromDirName(const QString &dir) +{ + static const std::regex regexp("^[^_]+_(.*).*$"); + std::smatch match; + const std::string dirString = dir.toStdString(); + if (!std::regex_match(dirString, match, regexp)) + return {}; + const QString arch = QString::fromStdString(match[1]); + if (arch == QLatin1String("32")) + return QStringLiteral("x86"); + if (arch == QLatin1String("64")) + return QStringLiteral("x86_64"); + if (arch.contains(QLatin1String("arm64"))) + return QStringLiteral("arm64"); + return arch; +} + +static QString platformFromDirName(const QString &dir) +{ + if (dir.startsWith(QLatin1String("android"))) + return QStringLiteral("android"); + if (dir == QLatin1String("Boot2Qt")) + return QStringLiteral("linux"); + return HostOsInfo::hostOSIdentifier(); +} + +QtEnvironment SetupQt::fetchEnvironment(const QString &qmakePath) +{ + QtEnvironment env; + env.qmakeFilePath = qmakePath; + QDir qtDir = QFileInfo(qmakePath).dir(); + if (qtDir.dirName() == QLatin1String("bin")) { + qtDir.cdUp(); + env.qbsToolchain = qbsToolchainFromDirName(qtDir.dirName()); + env.msvcVersion = msvcVersionFromDirName(qtDir.dirName()); + env.architecture = archFromDirName(qtDir.dirName()); + if (env.msvcVersion.isValid() && env.architecture.isEmpty()) + env.architecture = QStringLiteral("x86"); + env.targetPlatform = platformFromDirName(qtDir.dirName()); + qtDir.cdUp(); + env.qtVersion = Version::fromString(qtDir.dirName()); + } + return env; +} + +static bool isToolchainProfile(const Profile &profile) +{ + const auto actual = rangeTo>( + profile.allKeys(Profile::KeySelectionRecursive)); + Internal::Set expected{ QStringLiteral("qbs.toolchainType") }; + if (HostOsInfo::isMacosHost()) + expected.insert(QStringLiteral("qbs.targetPlatform")); // match only Xcode profiles + return Internal::Set(actual).unite(expected) == actual; +} + +static bool isQtProfile(const Profile &profile) +{ + if (!profile.value(QStringLiteral("moduleProviders.Qt.qmakeFilePaths")).toStringList() + .empty()) { + return true; + } + + // For Profiles created with setup-qt < 5.13. + const QStringList searchPaths + = profile.value(QStringLiteral("preferences.qbsSearchPaths")).toStringList(); + return Internal::any_of(searchPaths, [] (const QString &path) { + return QFileInfo(path + QStringLiteral("/modules/Qt")).isDir(); + }); +} + +template bool areProfilePropertiesIncompatible(const T &set1, const T &set2) +{ + // Two objects are only considered incompatible if they are both non empty and compare inequal + // This logic is used for comparing target OS, toolchain lists, and architectures + return set1.size() > 0 && set2.size() > 0 && set1 != set2; +} + +enum Match { MatchFull, MatchPartial, MatchNone }; + +static Match compatibility(const QtEnvironment &env, const Profile &toolchainProfile) +{ + Match match = MatchFull; + + const auto toolchainType = + toolchainProfile.value(QStringLiteral("qbs.toolchainType")).toString(); + const auto toolchain = !toolchainType.isEmpty() + ? canonicalToolchain(toolchainType) + : toolchainProfile.value(QStringLiteral("qbs.toolchain")).toStringList(); + + const auto toolchainNames = rangeTo>(toolchain); + const auto qtToolchainNames = rangeTo>(env.qbsToolchain); + if (areProfilePropertiesIncompatible(toolchainNames, qtToolchainNames)) { + auto intersection = toolchainNames; + intersection.intersect(qtToolchainNames); + if (!intersection.empty()) + match = MatchPartial; + else + return MatchNone; + } + + const auto targetPlatform = toolchainProfile.value( + QStringLiteral("qbs.targetPlatform")).toString(); + if (!targetPlatform.isEmpty() && targetPlatform != env.targetPlatform) + return MatchNone; + + const QString toolchainArchitecture = toolchainProfile.value(QStringLiteral("qbs.architecture")) + .toString(); + if (areProfilePropertiesIncompatible(canonicalArchitecture(env.architecture), + canonicalArchitecture(toolchainArchitecture))) + return MatchNone; + + if (env.msvcVersion.isValid()) { + // We want to know for sure that MSVC compiler versions match, + // because it's especially important for this toolchain + const Version compilerVersion = Version::fromString( + toolchainProfile.value(QStringLiteral("cpp.compilerVersion")).toString()); + + static const Version vs2017Version{19, 1}; + if (env.msvcVersion >= vs2017Version) { + if (env.msvcVersion.majorVersion() != compilerVersion.majorVersion() + || compilerVersion < vs2017Version) { + return MatchNone; + } + } else if (env.msvcVersion.majorVersion() != compilerVersion.majorVersion() + || env.msvcVersion.minorVersion() != compilerVersion.minorVersion()) { + return MatchNone; + } + } + + return match; +} + +QString profileNameWithoutHostArch(const QString &profileName) +{ + QString result; + int i = profileName.indexOf(QLatin1Char('-')); + if (i == -1) + return result; + ++i; + int j = profileName.indexOf(QLatin1Char('_'), i); + if (j == -1) + return result; + result = profileName.mid(0, i) + profileName.mid(j + 1); + return result; +} + +// "Compressing" MSVC profiles means that if MSVC2017-x64 and MSVC2017-x86_x64 fully match, +// then we drop the crosscompiling toolchain MSVC2017-x86_x64. +static void compressMsvcProfiles(QStringList &profiles) +{ + Internal::removeIf(profiles, [&profiles] (const QString &profileName) { + int idx = profileName.indexOf(QLatin1Char('_')); + if (idx == -1) + return false; + return contains(profiles, profileNameWithoutHostArch(profileName)); + }); +} + +void SetupQt::saveToQbsSettings(const QString &qtVersionName, + const QtEnvironment &qtEnvironment, + Settings *settings) +{ + const QString cleanQtVersionName = Profile::cleanName(qtVersionName); + QString msg = QCoreApplication::translate("SetupQt", "Creating profile '%1'.") + .arg(cleanQtVersionName); + std::printf("%s\n", qPrintable(msg)); + + Profile profile(cleanQtVersionName, settings); + profile.removeProfile(); + profile.setValue(QStringLiteral("moduleProviders.Qt.qmakeFilePaths"), + QStringList(qtEnvironment.qmakeFilePath)); + if (!profile.baseProfile().isEmpty()) + return; + if (isToolchainProfile(profile)) + return; + + QStringList fullMatches; + QStringList partialMatches; + const auto profileNames = settings->profiles(); + for (const QString &profileName : profileNames) { + const Profile otherProfile(profileName, settings); + if (profileName == profile.name() + || !isToolchainProfile(otherProfile) + || isQtProfile(otherProfile)) + continue; + + switch (compatibility(qtEnvironment, otherProfile)) { + case MatchFull: + fullMatches << profileName; + break; + case MatchPartial: + partialMatches << profileName; + break; + default: + break; + } + } + + if (fullMatches.size() > 1) + compressMsvcProfiles(fullMatches); + + QString bestMatch; + if (fullMatches.size() == 1) + bestMatch = fullMatches.front(); + else if (fullMatches.empty() && partialMatches.size() == 1) + bestMatch = partialMatches.front(); + if (bestMatch.isEmpty()) { + QString message = Tr::tr("You may want to set up toolchain information " + "for the generated Qt profile. "); + if (!fullMatches.empty() || !partialMatches.empty()) { + message += Tr::tr("Consider setting one of these profiles as this profile's base " + "profile: %1.").arg((fullMatches + partialMatches) + .join(QLatin1String(", "))); + } + qbsInfo() << message; + } else { + profile.setBaseProfile(bestMatch); + qbsInfo() << Tr::tr("Setting profile '%1' as the base profile for this profile.") + .arg(bestMatch); + } +} + +bool SetupQt::checkIfMoreThanOneQtWithTheSameVersion(const Version &qtVersion, + const std::vector &qtEnvironments) +{ + bool foundOneVersion = false; + for (const QtEnvironment &qtEnvironment : qtEnvironments) { + if (qtEnvironment.qtVersion == qtVersion) { + if (foundOneVersion) + return true; + foundOneVersion = true; + } + } + + return false; +} + +} // namespace qbs diff --git a/src/app/qbs-setup-qt/setupqt.h b/src/app/qbs-setup-qt/setupqt.h new file mode 100644 index 00000000..c10ae637 --- /dev/null +++ b/src/app/qbs-setup-qt/setupqt.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPQT_H +#define QBS_SETUPQT_H + +#include +#include + +#include +#include + +#include + +namespace qbs { + +class Settings; + +class QtEnvironment +{ +public: + QString qmakeFilePath; + QStringList qbsToolchain; + QString architecture; + QString targetPlatform; + Version qtVersion; + Version msvcVersion; +}; + +class SetupQt +{ + Q_DECLARE_TR_FUNCTIONS(SetupQt) +public: + static bool isQMakePathValid(const QString &qmakePath); + static std::vector fetchEnvironments(); + static QtEnvironment fetchEnvironment(const QString &qmakePath); + static bool checkIfMoreThanOneQtWithTheSameVersion(const Version &qtVersion, + const std::vector &qtEnvironments); + static void saveToQbsSettings(const QString &qtVersionName, const QtEnvironment &qtEnvironment, + Settings *settings); +}; + +} // namespace qbs + +#endif // QBS_SETUPQT_H diff --git a/src/app/qbs-setup-toolchains/CMakeLists.txt b/src/app/qbs-setup-toolchains/CMakeLists.txt new file mode 100644 index 00000000..64347cd6 --- /dev/null +++ b/src/app/qbs-setup-toolchains/CMakeLists.txt @@ -0,0 +1,32 @@ +set(SOURCES + clangclprobe.cpp + clangclprobe.h + commandlineparser.cpp + commandlineparser.h + cosmicprobe.cpp + cosmicprobe.h + dmcprobe.cpp + dmcprobe.h + gccprobe.cpp + gccprobe.h + iarewprobe.cpp + iarewprobe.h + keilprobe.cpp + keilprobe.h + main.cpp + msvcprobe.cpp + msvcprobe.h + probe.cpp + probe.h + sdccprobe.cpp + sdccprobe.h + watcomprobe.cpp + watcomprobe.h + xcodeprobe.cpp + xcodeprobe.h + ) + +add_qbs_app(qbs-setup-toolchains + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} + ) diff --git a/src/app/qbs-setup-toolchains/clangclprobe.cpp b/src/app/qbs-setup-toolchains/clangclprobe.cpp new file mode 100644 index 00000000..c9c5a428 --- /dev/null +++ b/src/app/qbs-setup-toolchains/clangclprobe.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "clangclprobe.h" +#include "msvcprobe.h" +#include "probe.h" + +#include "../shared/logging/consolelogger.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using qbs::Settings; +using qbs::Profile; +using qbs::Internal::ClangClInfo; +using qbs::Internal::HostOsInfo; + +using qbs::Internal::Tr; + +namespace { + +Profile createProfileHelper( + Settings *settings, + const QString &profileName, + const QString &toolchainInstallPath, + const QString &vcvarsallPath, + const QString &architecture) +{ + Profile profile(profileName, settings); + profile.removeProfile(); + profile.setValue(QStringLiteral("qbs.architecture"), architecture); + profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("clang-cl")); + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), toolchainInstallPath); + profile.setValue(QStringLiteral("cpp.vcvarsallPath"), vcvarsallPath); + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.") + .arg(profile.name(), QDir::toNativeSeparators(toolchainInstallPath)); + return profile; +} + +QString findClangCl() +{ + const auto compilerName = HostOsInfo::appendExecutableSuffix(QStringLiteral("clang-cl")); + const auto compilerFromPath = findExecutable(compilerName); + if (!compilerFromPath.isEmpty()) + return compilerFromPath; + + return {}; +} + +} // namespace + +void createClangClProfile(const QFileInfo &compiler, Settings *settings, + const QString &profileName) +{ + const auto clangCl = ClangClInfo::fromCompilerFilePath( + compiler.filePath(), ConsoleLogger::instance()); + if (clangCl.isEmpty()) + return; + const auto hostArch = HostOsInfo::hostOSArchitecture(); + createProfileHelper( + settings, profileName, clangCl.toolchainInstallPath, clangCl.vcvarsallPath, hostArch); +} + +/*! + \brief Creates a clang-cl profile based on auto-detected vsversion. + \internal +*/ +void clangClProbe(Settings *settings, std::vector &profiles) +{ + const auto compilerName = QStringLiteral("clang-cl"); + qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName); + const auto clangCls = ClangClInfo::installedCompilers( + {findClangCl()}, ConsoleLogger::instance()); + if (clangCls.empty()) { + qbsInfo() << Tr::tr("%1 was not found.").arg(compilerName); + return; + } + + const auto clangCl = clangCls.front(); + const QString architectures[] = { + QStringLiteral("x86_64"), + QStringLiteral("x86") + }; + qbs::Internal::transform(architectures, profiles, [settings, clangCl](const auto &arch) { + const auto profileName = QStringLiteral("clang-cl-%1").arg(arch); + return createProfileHelper(settings, profileName, clangCl.toolchainInstallPath, + clangCl.vcvarsallPath, arch); }); +} diff --git a/src/app/qbs-setup-toolchains/clangclprobe.h b/src/app/qbs-setup-toolchains/clangclprobe.h new file mode 100644 index 00000000..2de1c0a6 --- /dev/null +++ b/src/app/qbs-setup-toolchains/clangclprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_CLANGCLPROBE_H +#define QBS_SETUPTOOLCHAINS_CLANGCLPROBE_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +void createClangClProfile(const QFileInfo &compiler, qbs::Settings *settings, + const QString &profileName); + +void clangClProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/commandlineparser.cpp b/src/app/qbs-setup-toolchains/commandlineparser.cpp new file mode 100644 index 00000000..bf3937a2 --- /dev/null +++ b/src/app/qbs-setup-toolchains/commandlineparser.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineparser.h" + +#include +#include + +#include + +using qbs::Internal::Tr; + +static QString helpOptionShort() { return QStringLiteral("-h"); } +static QString helpOptionLong() { return QStringLiteral("--help"); } +static QString detectOption() { return QStringLiteral("--detect"); } +static QString typeOption() { return QStringLiteral("--type"); } +static QString settingsDirOption() { return QStringLiteral("--settings-dir"); } +static QString systemOption() { return QStringLiteral("--system"); } + +void CommandLineParser::parse(const QStringList &commandLine) +{ + m_commandLine = commandLine; + Q_ASSERT(!m_commandLine.empty()); + m_command = QFileInfo(m_commandLine.takeFirst()).fileName(); + m_helpRequested = false; + m_autoDetectionMode = false; + m_compilerPath.clear(); + m_toolchainType.clear(); + m_profileName.clear(); + m_settingsDir.clear(); + + if (m_commandLine.empty()) + throwError(Tr::tr("No command-line arguments provided.")); + + while (!m_commandLine.empty()) { + const QString arg = m_commandLine.front(); + if (!arg.startsWith(QLatin1Char('-'))) + break; + m_commandLine.removeFirst(); + if (arg == helpOptionShort() || arg == helpOptionLong()) + m_helpRequested = true; + else if (arg == detectOption()) + m_autoDetectionMode = true; + else if (arg == systemOption()) + m_settingsScope = qbs::Settings::SystemScope; + else if (arg == typeOption()) + assignOptionArgument(typeOption(), m_toolchainType); + else if (arg == settingsDirOption()) + assignOptionArgument(settingsDirOption(), m_settingsDir); + } + + if (m_helpRequested || m_autoDetectionMode) { + if (!m_commandLine.empty()) + complainAboutExtraArguments(); + return; + } + + switch (m_commandLine.size()) { + case 0: + case 1: + throwError(Tr::tr("Not enough command-line arguments provided.")); + case 2: + m_compilerPath = m_commandLine.at(0); + m_profileName = m_commandLine.at(1); + m_profileName.replace(QLatin1Char('.'), QLatin1Char('-')); + break; + default: + complainAboutExtraArguments(); + } +} + +void CommandLineParser::throwError(const QString &message) +{ + qbs::ErrorInfo error(Tr::tr("Syntax error: %1").arg(message)); + error.append(usageString()); + throw error; +} + +QString CommandLineParser::usageString() const +{ + QString s = Tr::tr("This tool creates qbs profiles from toolchains.\n"); + s += Tr::tr("Usage:\n"); + s += Tr::tr(" %1 [%2 ] [%4] %3\n") + .arg(m_command, settingsDirOption(), detectOption(), systemOption()); + s += Tr::tr(" %1 [%3 ] [%4] [%2 ] " + " \n") + .arg(m_command, typeOption(), settingsDirOption(), systemOption()); + s += Tr::tr(" %1 %2|%3\n").arg(m_command, helpOptionShort(), helpOptionLong()); + s += Tr::tr("The first form tries to auto-detect all known toolchains, looking them up " + "via the PATH environment variable.\n"); + s += Tr::tr("The second form creates one profile for one toolchain. It will attempt " + "to find out the toolchain type automatically.\nIn case the compiler has " + "an unusual file name, you may need to provide the '--type' option."); + return s; +} + +void CommandLineParser::assignOptionArgument(const QString &option, QString &argument) +{ + if (m_commandLine.empty()) + throwError(Tr::tr("Option '%1' needs an argument.").arg(option)); + argument = m_commandLine.takeFirst(); + if (argument.isEmpty()) + throwError(Tr::tr("Argument for option '%1' must not be empty.").arg(option)); +} + +void CommandLineParser::complainAboutExtraArguments() +{ + throwError(Tr::tr("Extraneous command-line arguments '%1'.") + .arg(m_commandLine.join(QLatin1Char(' ')))); +} diff --git a/src/app/qbs-setup-toolchains/commandlineparser.h b/src/app/qbs-setup-toolchains/commandlineparser.h new file mode 100644 index 00000000..0616f068 --- /dev/null +++ b/src/app/qbs-setup-toolchains/commandlineparser.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H +#define QBS_SETUPTOOLCHAINS_COMMANDLINEPARSER_H + +#include + +#include + +class CommandLineParser +{ +public: + void parse(const QStringList &commandLine); + + bool helpRequested() const { return m_helpRequested; } + bool autoDetectionMode() const { return m_autoDetectionMode; } + + QString compilerPath() const { return m_compilerPath; } + QString toolchainType() const { return m_toolchainType; } + QString profileName() const { return m_profileName; } + QString settingsDir() const { return m_settingsDir; } + qbs::Settings::Scope settingsScope() const { return m_settingsScope; } + + QString usageString() const; + +private: + [[noreturn]] void throwError(const QString &message); + void assignOptionArgument(const QString &option, QString &argument); + [[noreturn]] void complainAboutExtraArguments(); + + bool m_helpRequested = false; + bool m_autoDetectionMode = false; + qbs::Settings::Scope m_settingsScope = qbs::Settings::UserScope; + QString m_compilerPath; + QString m_toolchainType; + QString m_profileName; + QString m_settingsDir; + QStringList m_commandLine; + QString m_command; +}; + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/cosmicprobe.cpp b/src/app/qbs-setup-toolchains/cosmicprobe.cpp new file mode 100644 index 00000000..82b7193b --- /dev/null +++ b/src/app/qbs-setup-toolchains/cosmicprobe.cpp @@ -0,0 +1,179 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "cosmicprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include +#include + +using namespace qbs; +using Internal::Tr; +using Internal::HostOsInfo; + +static QStringList knownCosmicCompilerNames() +{ + return {QStringLiteral("cxcorm"), QStringLiteral("cxstm8"), + QStringLiteral("cx6808"), QStringLiteral("cx6812"), + QStringLiteral("cx332")}; +} + +static QString guessCosmicArchitecture(const QFileInfo &compiler) +{ + const auto baseName = compiler.baseName(); + if (baseName == QLatin1String("cxcorm")) + return QStringLiteral("arm"); + if (baseName == QLatin1String("cxstm8")) + return QStringLiteral("stm8"); + if (baseName == QLatin1String("cx6808")) + return QStringLiteral("hcs8"); + if (baseName == QLatin1String("cx6812")) + return QStringLiteral("hcs12"); + if (baseName == QLatin1String("cx332")) + return QStringLiteral("m68k"); + return {}; +} + +static Profile createCosmicProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + QString profileName = QString()) +{ + const QFileInfo compiler = info.compilerPath; + const QString architecture = guessCosmicArchitecture(compiler); + + // In case the profile is auto-detected. + if (profileName.isEmpty()) { + if (!info.compilerVersion.isValid()) { + profileName = QStringLiteral("cosmic-unknown-%1").arg(architecture); + } else { + const QString version = info.compilerVersion.toString(QLatin1Char('_'), + QLatin1Char('_')); + profileName = QStringLiteral("cosmic-%1-%2").arg( + version, architecture); + } + } + + Profile profile(profileName, settings); + profile.setValue(QLatin1String("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QLatin1String("qbs.toolchainType"), QLatin1String("cosmic")); + if (!architecture.isEmpty()) + profile.setValue(QLatin1String("qbs.architecture"), architecture); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg( + profile.name(), compiler.absoluteFilePath()); + return profile; +} + +static Version dumpCosmicCompilerVersion(const QFileInfo &compiler) +{ + QProcess p; + QStringList args; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + const auto es = p.exitStatus(); + if (es != QProcess::NormalExit) { + const QByteArray out = p.readAll(); + qbsWarning() << Tr::tr("Compiler dumping failed:\n%1") + .arg(QString::fromUtf8(out)); + return Version{}; + } + + const QByteArray output = p.readAllStandardError(); + const QRegularExpression re(QLatin1String("^COSMIC.+V(\\d+)\\.?(\\d+)\\.?(\\*|\\d+)?")); + const QRegularExpressionMatch match = re.match(QString::fromLatin1(output)); + if (!match.hasMatch()) + return Version{}; + + const auto major = match.captured(1).toInt(); + const auto minor = match.captured(2).toInt(); + const auto patch = match.captured(3).toInt(); + return Version{major, minor, patch}; +} + +static std::vector installedCosmicsFromPath() +{ + std::vector infos; + const auto compilerNames = knownCosmicCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo cosmicPath( + findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!cosmicPath.exists()) + continue; + const Version version = dumpCosmicCompilerVersion(cosmicPath); + infos.push_back({cosmicPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isCosmicCompiler(const QString &compilerName) +{ + return Internal::any_of(knownCosmicCompilerNames(), [compilerName](const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createCosmicProfile(const QFileInfo &compiler, Settings *settings, + QString profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createCosmicProfileHelper(info, settings, std::move(profileName)); +} + +void cosmicProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect COSMIC toolchains..."); + + const std::vector allInfos = installedCosmicsFromPath(); + qbs::Internal::transform(allInfos, profiles, [settings](const auto &info) { + return createCosmicProfileHelper(info, settings); }); + + if (allInfos.empty()) + qbsInfo() << Tr::tr("No COSMIC toolchains found."); +} diff --git a/src/app/qbs-setup-toolchains/cosmicprobe.h b/src/app/qbs-setup-toolchains/cosmicprobe.h new file mode 100644 index 00000000..9b7b4bb1 --- /dev/null +++ b/src/app/qbs-setup-toolchains/cosmicprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_COSMICPROBE_H +#define QBS_SETUPTOOLCHAINS_COSMICPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +bool isCosmicCompiler(const QString &compilerName); + +void createCosmicProfile(const QFileInfo &compiler, qbs::Settings *settings, + QString profileName); + +void cosmicProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/dmcprobe.cpp b/src/app/qbs-setup-toolchains/dmcprobe.cpp new file mode 100644 index 00000000..cbe113df --- /dev/null +++ b/src/app/qbs-setup-toolchains/dmcprobe.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "dmcprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +using namespace qbs; +using Internal::Tr; +using Internal::HostOsInfo; + +namespace { +struct Target { + QString platform; + QString architecture; + QString extender; +}; +} + +static QStringList knownDmcCompilerNames() +{ + return {QStringLiteral("dmc")}; +} + +static QStringList dumpOutput(const QFileInfo &compiler, const QStringList &flags, + const QStringList &keys) +{ + const QString filePath = QDir(QDir::tempPath()).absoluteFilePath( + QLatin1String("dmc-dump.c")); + QFile fakeIn(filePath); + if (!fakeIn.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { + qbsWarning() << Tr::tr("Unable to open temporary file %1 for output: %2") + .arg(fakeIn.fileName(), fakeIn.errorString()); + return {}; + } + fakeIn.write("#define VALUE_TO_STRING(x) #x\n"); + fakeIn.write("#define VALUE(x) VALUE_TO_STRING(x)\n"); + fakeIn.write("#define VAR_NAME_VALUE(var) \"#define \" #var\" \"VALUE(var)\n"); + for (const auto &key : keys) { + const auto content = key.toLatin1(); + fakeIn.write("#if defined(" + content + ")\n"); + fakeIn.write("#pragma message (VAR_NAME_VALUE(" + content + "))\n"); + fakeIn.write("#endif\n"); + } + fakeIn.close(); + + QStringList args = {QStringLiteral("-e")}; + args.reserve(args.size() + int(flags.size())); + std::copy(flags.cbegin(), flags.cend(), std::back_inserter(args)); + args.push_back(QDir::toNativeSeparators(filePath)); + + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + fakeIn.remove(); + static QRegularExpression re(QLatin1String("\\r?\\n")); + const QStringList lines = QString::fromUtf8(p.readAllStandardOutput()).split(re); + return lines; +} + +static std::optional dumpDmcTarget(const QFileInfo &compiler, const QStringList &flags) +{ + const QStringList keys = { + QStringLiteral("DOS16RM"), + QStringLiteral("DOS386"), + QStringLiteral("MSDOS"), + QStringLiteral("__NT__"), + QStringLiteral("_WINDOWS"), + }; + const auto macros = dumpMacros([&compiler, &flags, &keys]() { + return dumpOutput(compiler, flags, keys); }); + + if (macros.contains(QLatin1String("__NT__"))) { + return Target{QLatin1String("windows"), QLatin1String("x86"), QLatin1String("")}; + } else if (macros.contains(QLatin1String("_WINDOWS"))) { + return Target{QLatin1String("windows"), QLatin1String("x86_16"), QLatin1String("")}; + } else if (macros.contains(QLatin1String("DOS386"))) { + if (flags.contains(QLatin1String("-mx"))) + return Target{QLatin1String("dos"), QLatin1String("x86"), QLatin1String("dosx")}; + else if (flags.contains(QLatin1String("-mp"))) + return Target{QLatin1String("dos"), QLatin1String("x86"), QLatin1String("dosp")}; + } else if (macros.contains(QLatin1String("DOS16RM"))) { + if (flags.contains(QLatin1String("-mz"))) + return Target{QLatin1String("dos"), QLatin1String("x86_16"), QLatin1String("dosz")}; + else if (flags.contains(QLatin1String("-mr"))) + return Target{QLatin1String("dos"), QLatin1String("x86_16"), QLatin1String("dosr")}; + } else if (macros.contains(QLatin1String("MSDOS"))) { + return Target{QLatin1String("dos"), QLatin1String("x86_16"), QLatin1String("")}; + } + + return {}; +} + +static std::vector createDmcProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + QStringView profileName = {}) +{ + const QFileInfo compiler = info.compilerPath; + std::vector profiles; + + const QVector probes = { + { QStringLiteral("-mn"), QStringLiteral("-WA") }, // Windows NT 32 bit. + { QStringLiteral("-ml"), QStringLiteral("-WA") }, // Windows 3.x 16 bit. + { QStringLiteral("-mx") }, // DOS with DOSX extender 32 bit. + { QStringLiteral("-mp") }, // DOS with Phar Lap extender 32 bit. + { QStringLiteral("-mr") }, // DOS with Rational DOS Extender 16 bit. + { QStringLiteral("-mz") }, // DOS with ZPM DOS Extender 16 bit. + { QStringLiteral("-mc") }, // DOS 16 bit. + }; + + for (const auto &flags : probes) { + const auto target = dumpDmcTarget(compiler, flags); + if (!target) + continue; + + QString fullProfilename; + QString platform = target->extender.isEmpty() ? target->platform : target->extender; + if (profileName.isEmpty()) { + // Create a full profile name in case we is in auto-detecting mode. + if (!info.compilerVersion.isValid()) { + fullProfilename = QStringLiteral("dmc-unknown-%1-%2") + .arg(platform, target->architecture); + } else { + const QString version = info.compilerVersion.toString(QLatin1Char('_'), + QLatin1Char('_')); + fullProfilename = QStringLiteral("dmc-%1-%2-%3") + .arg(version, platform, target->architecture); + } + } else { + // Append the detected actual architecture name to the proposed profile name. + fullProfilename = QStringLiteral("%1-%2-%3") + .arg(profileName, platform, target->architecture); + } + + Profile profile(fullProfilename, settings); + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("dmc")); + profile.setValue(QStringLiteral("qbs.architecture"), target->architecture); + profile.setValue(QStringLiteral("qbs.targetPlatform"), target->platform); + if (!target->extender.isEmpty()) + profile.setValue(QStringLiteral("cpp.extenderName"), target->extender); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.") + .arg(profile.name(), compiler.absoluteFilePath()); + + profiles.push_back(std::move(profile)); + } + + return profiles; +} + +static Version dumpDmcVersion(const QFileInfo &compiler) +{ + const QStringList keys = {QStringLiteral("__DMC__")}; + const auto macros = dumpMacros([&compiler, keys]() { + return dumpOutput(compiler, {}, keys); }); + for (const auto ¯o : macros) { + if (!macro.startsWith(QLatin1String("0x"))) + continue; + const int verCode = macro.mid(2).toInt(); + return Version{(verCode / 100), (verCode % 100), 0}; + } + qbsWarning() << Tr::tr("No __DMC__ token was found in the compiler dump"); + return Version{}; +} + +static std::vector installedDmcsFromPath() +{ + std::vector infos; + const auto compilerNames = knownDmcCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo dmcPath( + findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!dmcPath.exists()) + continue; + const Version version = dumpDmcVersion(dmcPath); + infos.push_back({dmcPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isDmcCompiler(const QString &compilerName) +{ + return Internal::any_of(knownDmcCompilerNames(), + [compilerName](const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createDmcProfile(const QFileInfo &compiler, Settings *settings, + QStringView profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createDmcProfileHelper(info, settings, profileName); +} + +void dmcProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect DMC toolchains..."); + + const std::vector allInfos = installedDmcsFromPath(); + if (allInfos.empty()) { + qbsInfo() << Tr::tr("No DMC toolchains found."); + return; + } + + for (const ToolchainInstallInfo &info : allInfos) { + const auto newProfiles = createDmcProfileHelper(info, settings); + profiles.reserve(profiles.size() + int(newProfiles.size())); + std::copy(newProfiles.cbegin(), newProfiles.cend(), std::back_inserter(profiles)); + } +} diff --git a/src/app/qbs-setup-toolchains/dmcprobe.h b/src/app/qbs-setup-toolchains/dmcprobe.h new file mode 100644 index 00000000..3159c2df --- /dev/null +++ b/src/app/qbs-setup-toolchains/dmcprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_DMCPROBE_H +#define QBS_SETUPTOOLCHAINS_DMCPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +bool isDmcCompiler(const QString &compilerName); + +void createDmcProfile(const QFileInfo &compiler, qbs::Settings *settings, + QStringView profileName); + +void dmcProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/gccprobe.cpp b/src/app/qbs-setup-toolchains/gccprobe.cpp new file mode 100644 index 00000000..dda8f227 --- /dev/null +++ b/src/app/qbs-setup-toolchains/gccprobe.cpp @@ -0,0 +1,589 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "gccprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +using namespace qbs; +using Internal::HostOsInfo; +using Internal::Tr; + +constexpr char kUninstallRegistryKey[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\" \ + "Windows\\CurrentVersion\\Uninstall\\"; + +static QString qsystem(const QString &exe, const QStringList &args = QStringList()) +{ + QProcess p; + p.setProcessChannelMode(QProcess::MergedChannels); + p.start(exe, args); + if (!p.waitForStarted()) { + throw qbs::ErrorInfo(Tr::tr("Failed to start compiler '%1': %2") + .arg(exe, p.errorString())); + } + if (!p.waitForFinished(-1) || p.exitCode() != 0) + throw qbs::ErrorInfo(Tr::tr("Failed to run compiler '%1': %2") + .arg(exe, p.errorString())); + return QString::fromLocal8Bit(p.readAll()); +} + +static QStringList validMinGWMachines() +{ + // List of MinGW machine names (gcc -dumpmachine) recognized by Qbs + return {QStringLiteral("mingw32"), + QStringLiteral("mingw64"), + QStringLiteral("i686-w64-mingw32"), + QStringLiteral("x86_64-w64-mingw32"), + QStringLiteral("i686-w64-mingw32.shared"), + QStringLiteral("x86_64-w64-mingw32.shared"), + QStringLiteral("i686-w64-mingw32.static"), + QStringLiteral("x86_64-w64-mingw32.static"), + QStringLiteral("i586-mingw32msvc"), + QStringLiteral("amd64-mingw32msvc")}; +} + +static QString gccMachineName(const QFileInfo &compiler) +{ + return qsystem(compiler.absoluteFilePath(), {QStringLiteral("-dumpmachine")}) + .trimmed(); +} + +static QStringList standardCompilerFileNames() +{ + return {HostOsInfo::appendExecutableSuffix(QStringLiteral("gcc")), + HostOsInfo::appendExecutableSuffix(QStringLiteral("g++")), + HostOsInfo::appendExecutableSuffix(QStringLiteral("clang")), + HostOsInfo::appendExecutableSuffix(QStringLiteral("clang++"))}; +} + +class ToolchainDetails +{ +public: + explicit ToolchainDetails(const QFileInfo &compiler) + { + auto baseName = HostOsInfo::stripExecutableSuffix(compiler.fileName()); + // Extract the version sub-string if it exists. We assume that a version + // sub-string located after the compiler prefix && suffix. E.g. this code + // parses a version from the compiler names, like this: + // - avr-gcc-4.9.2.exe + // - arm-none-eabi-gcc-8.2.1 + // - rl78-elf-gcc-4.9.2.201902-GNURL78 + const QRegularExpression re(QLatin1String("-(\\d+|\\d+\\.\\d+|" \ + "\\d+\\.\\d+\\.\\d+|" \ + "\\d+\\.\\d+\\.\\d+\\.\\d+)" \ + "[-[0-9a-zA-Z]*]?$")); + const QRegularExpressionMatch match = re.match(baseName); + if (match.hasMatch()) { + version = match.captured(1); + baseName = baseName.left(match.capturedStart()); + } + const auto dashIndex = baseName.lastIndexOf(QLatin1Char('-')); + suffix = baseName.mid(dashIndex + 1); + prefix = baseName.left(dashIndex + 1); + } + + QString prefix; + QString suffix; + QString version; +}; + +static void setCommonProperties(Profile &profile, const QFileInfo &compiler, + const QString &toolchainType, const ToolchainDetails &details) +{ + if (toolchainType == QStringLiteral("mingw")) + profile.setValue(QStringLiteral("qbs.targetPlatform"), + QStringLiteral("windows")); + + if (!details.prefix.isEmpty()) + profile.setValue(QStringLiteral("cpp.toolchainPrefix"), details.prefix); + + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), + compiler.absolutePath()); + profile.setValue(QStringLiteral("qbs.toolchainType"), toolchainType); + + if (!standardCompilerFileNames().contains( + HostOsInfo::appendExecutableSuffix(details.suffix))) { + qWarning("%s", qPrintable( + QStringLiteral("'%1' is not a standard compiler file name; " + "you must set the cpp.cCompilerName and " + "cpp.cxxCompilerName properties of this profile " + "manually").arg(compiler.fileName()))); + } +} + +class ToolPathSetup +{ +public: + explicit ToolPathSetup(Profile *profile, QString path, ToolchainDetails details) + : m_profile(profile), + m_compilerDirPath(std::move(path)), + m_details(std::move(details)) + { + } + + void apply(const QString &toolName, const QString &propertyName) const + { + // Check for full tool name at first (includes suffix and version). + QString filePath = toolFilePath(toolName, UseFullToolName); + if (filePath.isEmpty()) { + // Check for base tool name at second (without of suffix and version). + filePath = toolFilePath(toolName, UseBaseToolName); + if (filePath.isEmpty()) { + // Check for short tool name at third (only a tool name). + filePath = toolFilePath(toolName, UseOnlyShortToolName); + } + } + + if (filePath.isEmpty()) { + qWarning("%s", qPrintable( + QStringLiteral("'%1' not found in '%2'. " + "Qbs will try to find it in PATH at build time.") + .arg(toolName, m_compilerDirPath))); + } else { + m_profile->setValue(propertyName, filePath); + } + } + +private: + enum ToolNameParts : quint8 { + UseOnlyShortToolName = 0x0, + UseToolPrefix = 0x01, + UseToolSuffix = 0x02, + UseToolVersion = 0x04, + UseFullToolName = UseToolPrefix | UseToolSuffix | UseToolVersion, + UseBaseToolName = UseToolPrefix, + }; + + QString toolFilePath(const QString &toolName, int parts) const + { + QString fileName; + if ((parts & UseToolPrefix) && !m_details.prefix.isEmpty()) + fileName += m_details.prefix; + if ((parts & UseToolSuffix) && !m_details.suffix.isEmpty()) + fileName += m_details.suffix + QLatin1Char('-'); + fileName += toolName; + if ((parts & UseToolVersion) && !m_details.version.isEmpty()) + fileName += QLatin1Char('-') + m_details.version; + + fileName = HostOsInfo::appendExecutableSuffix(fileName); + QString filePath = QDir(m_compilerDirPath).absoluteFilePath(fileName); + if (QFile::exists(filePath)) + return filePath; + return {}; + } + + Profile * const m_profile; + QString m_compilerDirPath; + ToolchainDetails m_details; +}; + +static bool doesProfileTargetOS(const Profile &profile, const QString &os) +{ + const auto target = profile.value(QStringLiteral("qbs.targetPlatform")); + if (target.isValid()) + return Internal::contains(HostOsInfo::canonicalOSIdentifiers(target.toString()), os); + return Internal::contains(HostOsInfo::hostOSIdentifiers(), os); +} + +static QString buildProfileName(const QFileInfo &cfi) +{ + // We need to replace a dot-separated compiler version string + // with a underscore-separated string, because the profile + // name does not allow a dots. + auto result = cfi.completeBaseName(); + result.replace(QLatin1Char('.'), QLatin1Char('_')); + return result; +} + +static QStringList buildCompilerNameFilters(const QString &compilerName) +{ + QStringList filters = { + // "clang", "gcc" + compilerName, + // "clang-8", "gcc-5" + compilerName + QLatin1String("-[1-9]*"), + // "avr-gcc" + QLatin1String("*-") + compilerName, + // "avr-gcc-5.4.0" + QLatin1String("*-") + compilerName + QLatin1String("-[1-9]*"), + // "arm-none-eabi-gcc" + QLatin1String("*-*-*-") + compilerName, + // "arm-none-eabi-gcc-9.1.0" + QLatin1String("*-*-*-") + compilerName + QLatin1String("-[1-9]*"), + // "x86_64-pc-linux-gnu-gcc" + QLatin1String("*-*-*-*-") + compilerName, + // "x86_64-pc-linux-gnu-gcc-7.4.1" + QLatin1String("*-*-*-*-") + compilerName + QLatin1String("-[1-9]*") + }; + + Internal::transform(filters, [](const auto &filter) { + return HostOsInfo::appendExecutableSuffix(filter); }); + return filters; +} + +static QStringList gnuRegistrySearchPaths() +{ + if (!HostOsInfo::isWindowsHost()) + return {}; + +#ifdef Q_OS_WIN64 + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\ARM"; +#else + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\ARM"; +#endif + + QStringList searchPaths; + QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat); + const auto groupKeys = registry.childGroups(); + for (const QString &groupKey : groupKeys) { + registry.beginGroup(groupKey); + const QString rootPath = registry.value(QStringLiteral("InstallFolder")).toString(); + if (!rootPath.isEmpty()) { + const QFileInfo toolchainPath(rootPath + QLatin1String("/bin")); + if (toolchainPath.exists()) { + const auto filePath = toolchainPath.absoluteFilePath(); + if (!searchPaths.contains(filePath)) + searchPaths.push_back(filePath); + } + } + registry.endGroup(); + } + return searchPaths; +} + +static QStringList atmelRegistrySearchPaths() +{ + if (!HostOsInfo::isWindowsHost()) + return {}; + + // Registry token for the "Atmel" toolchains, e.g. provided by installed + // "Atmel Studio" IDE. + static const char kRegistryToken[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Atmel\\"; + + QStringList searchPaths; + QSettings registry(QLatin1String(kRegistryToken), QSettings::NativeFormat); + + // This code enumerate the installed toolchains provided + // by the Atmel Studio v6.x. + const auto toolchainGroups = registry.childGroups(); + for (const QString &toolchainKey : toolchainGroups) { + if (!toolchainKey.endsWith(QLatin1String("GCC"))) + continue; + registry.beginGroup(toolchainKey); + const auto entries = registry.childGroups(); + for (const auto &entryKey : entries) { + registry.beginGroup(entryKey); + const QString installDir = registry.value( + QStringLiteral("Native/InstallDir")).toString(); + const QString version = registry.value( + QStringLiteral("Native/Version")).toString(); + registry.endGroup(); + + QString toolchainPath = installDir + + QLatin1String("/Atmel Toolchain/") + + toolchainKey + QLatin1String("/Native/") + + version; + if (toolchainKey.startsWith(QLatin1String("ARM"))) + toolchainPath += QLatin1String("/arm-gnu-toolchain"); + else if (toolchainKey.startsWith(QLatin1String("AVR32"))) + toolchainPath += QLatin1String("/avr32-gnu-toolchain"); + else if (toolchainKey.startsWith(QLatin1String("AVR8)"))) + toolchainPath += QLatin1String("/avr8-gnu-toolchain"); + else + break; + + toolchainPath += QLatin1String("/bin"); + + if (QFileInfo::exists(toolchainPath)) { + searchPaths.push_back(toolchainPath); + break; + } + } + registry.endGroup(); + } + + // This code enumerate the installed toolchains provided + // by the Atmel Studio v7. + registry.beginGroup(QStringLiteral("AtmelStudio")); + const auto productVersions = registry.childGroups(); + for (const auto &productVersionKey : productVersions) { + registry.beginGroup(productVersionKey); + const QString installDir = registry.value( + QStringLiteral("InstallDir")).toString(); + registry.endGroup(); + + const QStringList knownToolchainSubdirs = { + QStringLiteral("/toolchain/arm/arm-gnu-toolchain/bin/"), + QStringLiteral("/toolchain/avr8/avr8-gnu-toolchain/bin/"), + QStringLiteral("/toolchain/avr32/avr32-gnu-toolchain/bin/"), + }; + + for (const auto &subdir : knownToolchainSubdirs) { + const QString toolchainPath = installDir + subdir; + if (!QFileInfo::exists(toolchainPath)) + continue; + searchPaths.push_back(toolchainPath); + } + } + registry.endGroup(); + + return searchPaths; +} + +static QStringList renesasRl78RegistrySearchPaths() +{ + if (!HostOsInfo::isWindowsHost()) + return {}; + + QStringList searchPaths; + + QSettings registry(QLatin1String(kUninstallRegistryKey), QSettings::NativeFormat); + const auto productGroups = registry.childGroups(); + for (const QString &productKey : productGroups) { + // Registry token for the "Renesas RL78" toolchain. + if (!productKey.startsWith( + QLatin1String("GCC for Renesas RL78"))) { + continue; + } + registry.beginGroup(productKey); + const QString installLocation = registry.value( + QLatin1String("InstallLocation")).toString(); + registry.endGroup(); + if (installLocation.isEmpty()) + continue; + + const QFileInfo toolchainPath(QDir(installLocation).absolutePath() + + QLatin1String("/rl78-elf/rl78-elf/bin")); + if (!toolchainPath.exists()) + continue; + searchPaths.push_back(toolchainPath.absoluteFilePath()); + } + + return searchPaths; +} + +static QStringList mplabX32RegistrySearchPaths() +{ + if (!HostOsInfo::isWindowsHost()) + return {}; + + QStringList searchPaths; + + QSettings registry(QLatin1String(kUninstallRegistryKey), QSettings::NativeFormat); + const auto productGroups = registry.childGroups(); + for (const QString &productKey : productGroups) { + // Registry token for the "MPLAB X32" toolchain. + if (!productKey.startsWith( + QLatin1String("MPLAB XC32 Compiler"))) { + continue; + } + registry.beginGroup(productKey); + const QString installLocation = registry.value( + QLatin1String("InstallLocation")).toString(); + registry.endGroup(); + if (installLocation.isEmpty()) + continue; + + const QFileInfo toolchainPath(QDir(installLocation).absolutePath() + + QLatin1String("/bin")); + if (!toolchainPath.exists()) + continue; + searchPaths.push_back(toolchainPath.absoluteFilePath()); + } + + return searchPaths; +} + +Profile createGccProfile(const QFileInfo &compiler, Settings *settings, + const QString &toolchainType, + const QString &profileName) +{ + const QString machineName = gccMachineName(compiler); + + if (toolchainType == QLatin1String("mingw")) { + if (!validMinGWMachines().contains(machineName)) { + throw ErrorInfo(Tr::tr("Detected gcc platform '%1' is not supported.") + .arg(machineName)); + } + } + + Profile profile(!profileName.isEmpty() ? profileName : machineName, settings); + profile.removeProfile(); + + const ToolchainDetails details(compiler); + + setCommonProperties(profile, compiler, toolchainType, details); + + if (HostOsInfo::isWindowsHost() && toolchainType == QLatin1String("clang")) { + const QStringList profileNames = settings->profiles(); + bool foundMingw = false; + for (const QString &profileName : profileNames) { + const Profile otherProfile(profileName, settings); + if (otherProfile.value(QLatin1String("qbs.toolchainType")).toString() + == QLatin1String("mingw") + || otherProfile.value(QLatin1String("qbs.toolchain")) + .toStringList().contains(QLatin1String("mingw"))) { + const QFileInfo tcDir(otherProfile.value(QLatin1String("cpp.toolchainInstallPath")) + .toString()); + if (!tcDir.fileName().isEmpty() && tcDir.exists()) { + profile.setValue(QLatin1String("qbs.sysroot"), tcDir.path()); + foundMingw = true; + break; + } + } + } + if (!foundMingw) { + qbsWarning() << Tr::tr("Using clang on Windows requires a mingw installation. " + "Please set qbs.sysroot accordingly for profile '%1'.") + .arg(profile.name()); + } + } + + if (toolchainType != QLatin1String("clang")) { + // Check whether auxiliary tools reside within the toolchain's install path. + // This might not be the case when using icecc or another compiler wrapper. + const QString compilerDirPath = compiler.absolutePath(); + const ToolPathSetup toolPathSetup(&profile, compilerDirPath, details); + toolPathSetup.apply(QStringLiteral("ar"), QStringLiteral("cpp.archiverPath")); + toolPathSetup.apply(QStringLiteral("as"), QStringLiteral("cpp.assemblerPath")); + toolPathSetup.apply(QStringLiteral("nm"), QStringLiteral("cpp.nmPath")); + if (doesProfileTargetOS(profile, QStringLiteral("darwin"))) + toolPathSetup.apply(QStringLiteral("dsymutil"), + QStringLiteral("cpp.dsymutilPath")); + else + toolPathSetup.apply(QStringLiteral("objcopy"), + QStringLiteral("cpp.objcopyPath")); + toolPathSetup.apply(QStringLiteral("strip"), + QStringLiteral("cpp.stripPath")); + } + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.") + .arg(profile.name(), compiler.absoluteFilePath()); + return profile; +} + +void gccProbe(Settings *settings, std::vector &profiles, const QString &compilerName) +{ + qbsInfo() << Tr::tr("Trying to detect %1...").arg(compilerName); + + QStringList searchPaths; + searchPaths << systemSearchPaths() + << gnuRegistrySearchPaths() + << atmelRegistrySearchPaths() + << renesasRl78RegistrySearchPaths() + << mplabX32RegistrySearchPaths(); + + std::vector candidates; + const auto filters = buildCompilerNameFilters(compilerName); + for (const auto &searchPath : qAsConst(searchPaths)) { + const QDir dir(searchPath); + const QStringList fileNames = dir.entryList( + filters, QDir::Files | QDir::Executable); + for (const QString &fileName : fileNames) { + // Ignore unexpected compiler names. + if (fileName.startsWith(QLatin1String("c89-gcc")) + || fileName.startsWith(QLatin1String("c99-gcc"))) { + continue; + } + const QFileInfo candidate(dir.filePath(fileName)); + // Filter duplicates. + const auto existingEnd = candidates.end(); + const auto existingIt = std::find_if( + candidates.begin(), existingEnd, + [candidate](const QFileInfo &existing) { + return isSameExecutable(candidate.absoluteFilePath(), + existing.absoluteFilePath()); + }); + if (existingIt == existingEnd) { + // No duplicates are found, just add a new candidate. + candidates.push_back(candidate); + } else { + // Replace the existing entry if a candidate name more than + // an existing name. + const auto candidateName = candidate.completeBaseName(); + const auto existingName = existingIt->completeBaseName(); + if (candidateName > existingName) + *existingIt = candidate; + } + } + } + + if (candidates.empty()) { + qbsInfo() << Tr::tr("No %1 toolchains found.").arg(compilerName); + return; + } + + // Sort candidates so that mingw comes first. Information from mingw profiles is potentially + // used for setting up clang profiles. + if (HostOsInfo::isWindowsHost()) { + std::sort(candidates.begin(), candidates.end(), + [](const QFileInfo &fi1, const QFileInfo &fi2) { + return fi1.absoluteFilePath().contains(QLatin1String("mingw")) + && !fi2.absoluteFilePath().contains(QLatin1String("mingw")); + }); + } + + for (const auto &candidate : qAsConst(candidates)) { + const QString toolchainType = toolchainTypeFromCompilerName( + candidate.baseName()); + const QString profileName = buildProfileName(candidate); + try { + auto profile = createGccProfile(candidate, settings, + toolchainType, profileName); + profiles.push_back(std::move(profile)); + } catch (const qbs::ErrorInfo &info) { + qbsWarning() << Tr::tr("Skipping %1: %2").arg(profileName, info.toString()); + } + } +} diff --git a/src/app/qbs-setup-toolchains/gccprobe.h b/src/app/qbs-setup-toolchains/gccprobe.h new file mode 100644 index 00000000..98e7eaa1 --- /dev/null +++ b/src/app/qbs-setup-toolchains/gccprobe.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_GCCPROBE_H +#define QBS_SETUPTOOLCHAINS_GCCPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +qbs::Profile createGccProfile(const QFileInfo &compiler, + qbs::Settings *settings, + const QString &toolchainType, + const QString &profileName = QString()); + +void gccProbe(qbs::Settings *settings, std::vector &profiles, + const QString &compilerName); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/iarewprobe.cpp b/src/app/qbs-setup-toolchains/iarewprobe.cpp new file mode 100644 index 00000000..adf5febb --- /dev/null +++ b/src/app/qbs-setup-toolchains/iarewprobe.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "iarewprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include + +using namespace qbs; +using Internal::Tr; +using Internal::HostOsInfo; + +static QStringList knownIarCompilerNames() +{ + return {QStringLiteral("icc8051"), QStringLiteral("iccarm"), + QStringLiteral("iccavr"), QStringLiteral("iccstm8"), + QStringLiteral("icc430"), QStringLiteral("iccrl78"), + QStringLiteral("iccrx"), QStringLiteral("iccrh850"), + QStringLiteral("iccv850"), QStringLiteral("icc78k"), + QStringLiteral("iccavr32"), QStringLiteral("iccsh"), + QStringLiteral("iccriscv"), QStringLiteral("icccf"), + QStringLiteral("iccm32c"), QStringLiteral("iccr32c"), + QStringLiteral("iccm16c"), QStringLiteral("icccr16c"), + QStringLiteral("icchcs12"), QStringLiteral("iccs08")}; +} + +static QString guessIarArchitecture(const QFileInfo &compiler) +{ + const auto baseName = compiler.baseName(); + if (baseName == QLatin1String("icc8051")) + return QStringLiteral("mcs51"); + if (baseName == QLatin1String("iccarm")) + return QStringLiteral("arm"); + if (baseName == QLatin1String("iccavr")) + return QStringLiteral("avr"); + if (baseName == QLatin1String("iccstm8")) + return QStringLiteral("stm8"); + if (baseName == QLatin1String("icc430")) + return QStringLiteral("msp430"); + if (baseName == QLatin1String("iccrl78")) + return QStringLiteral("rl78"); + if (baseName == QLatin1String("iccrx")) + return QStringLiteral("rx"); + if (baseName == QLatin1String("iccrh850")) + return QStringLiteral("rh850"); + if (baseName == QLatin1String("iccv850")) + return QStringLiteral("v850"); + if (baseName == QLatin1String("icc78k")) + return QStringLiteral("78k"); + if (baseName == QLatin1String("iccavr32")) + return QStringLiteral("avr32"); + if (baseName == QLatin1String("iccsh")) + return QStringLiteral("sh"); + if (baseName == QLatin1String("iccriscv")) + return QStringLiteral("riscv"); + if (baseName == QLatin1String("icccf")) + return QStringLiteral("m68k"); + if (baseName == QLatin1String("iccm32c")) + return QStringLiteral("m32c"); + if (baseName == QLatin1String("iccr32c")) + return QStringLiteral("r32c"); + if (baseName == QLatin1String("iccm16c")) + return QStringLiteral("m16c"); + if (baseName == QLatin1String("icccr16c")) + return QStringLiteral("cr16"); + if (baseName == QLatin1String("icchcs12")) + return QStringLiteral("hcs12"); + if (baseName == QLatin1String("iccs08")) + return QStringLiteral("hcs8"); + return {}; +} + +static Profile createIarProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + QString profileName = QString()) +{ + const QFileInfo compiler = info.compilerPath; + const QString architecture = guessIarArchitecture(compiler); + + // In case the profile is auto-detected. + if (profileName.isEmpty()) { + if (!info.compilerVersion.isValid()) { + profileName = QStringLiteral("iar-unknown-%1").arg(architecture); + } else { + const QString version = info.compilerVersion.toString(QLatin1Char('_'), + QLatin1Char('_')); + profileName = QStringLiteral("iar-%1-%2").arg( + version, architecture); + } + } + + Profile profile(profileName, settings); + profile.setValue(QLatin1String("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QLatin1String("qbs.toolchainType"), QLatin1String("iar")); + if (!architecture.isEmpty()) + profile.setValue(QLatin1String("qbs.architecture"), architecture); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg( + profile.name(), compiler.absoluteFilePath()); + return profile; +} + +static Version dumpIarCompilerVersion(const QFileInfo &compiler) +{ + const QString outFilePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + + QLatin1String("/macros.dump"); + const QStringList args = {QStringLiteral("."), + QStringLiteral("--predef_macros"), + outFilePath}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + const auto es = p.exitStatus(); + if (es != QProcess::NormalExit) { + const QByteArray out = p.readAll(); + qbsWarning() << Tr::tr("Compiler dumping failed:\n%1") + .arg(QString::fromUtf8(out)); + return Version{}; + } + + QByteArray dump; + QFile out(outFilePath); + if (out.open(QIODevice::ReadOnly)) + dump = out.readAll(); + out.remove(); + + const int verCode = extractVersion(dump, "__VER__ "); + if (verCode < 0) { + qbsWarning() << Tr::tr("No '__VER__' token was found in a compiler dump:\n%1") + .arg(QString::fromUtf8(dump)); + return Version{}; + } + + const QString arch = guessIarArchitecture(compiler); + if (arch == QLatin1String("arm")) + return Version{verCode / 1000000, (verCode / 1000) % 1000, verCode % 1000}; + if (arch == QLatin1String("avr") + || arch == QLatin1String("mcs51") + || arch == QLatin1String("stm8") + || arch == QLatin1String("msp430") + || arch == QLatin1String("rl78") + || arch == QLatin1String("rx") + || arch == QLatin1String("rh850") + || arch == QLatin1String("v850") + || arch == QLatin1String("78k") + || arch == QLatin1String("avr32") + || arch == QLatin1String("sh") + || arch == QLatin1String("riscv") + || arch == QLatin1String("m68k") + || arch == QLatin1String("m32c") + || arch == QLatin1String("r32c") + || arch == QLatin1String("m16c") + || arch == QLatin1String("rc16") + || arch == QLatin1String("hcs12") + || arch == QLatin1String("hcs8")) { + return Version{verCode / 100, verCode % 100}; + } + + return Version{}; +} + +static std::vector installedIarsFromPath() +{ + std::vector infos; + const auto compilerNames = knownIarCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo iarPath( + findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!iarPath.exists()) + continue; + const Version version = dumpIarCompilerVersion(iarPath); + infos.push_back({iarPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +static std::vector installedIarsFromRegistry() +{ + std::vector infos; + + if (HostOsInfo::isWindowsHost()) { + +#ifdef Q_OS_WIN64 + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\IAR Systems\\Embedded Workbench"; +#else + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\IAR Systems\\Embedded Workbench"; +#endif + + // Dictionary for know toolchains. + static const struct Entry { + QString registryKey; + QString subExePath; + } knowToolchains[] = { + {QStringLiteral("EWARM"), QStringLiteral("/arm/bin/iccarm.exe")}, + {QStringLiteral("EWAVR"), QStringLiteral("/avr/bin/iccavr.exe")}, + {QStringLiteral("EW8051"), QStringLiteral("/8051/bin/icc8051.exe")}, + {QStringLiteral("EWSTM8"), QStringLiteral("/stm8/bin/iccstm8.exe")}, + {QStringLiteral("EW430"), QStringLiteral("/430/bin/icc430.exe")}, + {QStringLiteral("EWRL78"), QStringLiteral("/rl78/bin/iccrl78.exe")}, + {QStringLiteral("EWRX"), QStringLiteral("/rx/bin/iccrx.exe")}, + {QStringLiteral("EWRH850"), QStringLiteral("/rh850/bin/iccrh850.exe")}, + {QStringLiteral("EWV850"), QStringLiteral("/v850/bin/iccv850.exe")}, + {QStringLiteral("EW78K"), QStringLiteral("/78k/bin/icc78k.exe")}, + {QStringLiteral("EWAVR32"), QStringLiteral("/avr32/bin/iccavr32.exe")}, + {QStringLiteral("EWSH"), QStringLiteral("/sh/bin/iccsh.exe")}, + {QStringLiteral("EWRISCV"), QStringLiteral("/riscv/bin/iccriscv.exe")}, + {QStringLiteral("EWCF"), QStringLiteral("/cf/bin/icccf.exe")}, + {QStringLiteral("EWM32C"), QStringLiteral("/m32c/bin/iccm32c.exe")}, + {QStringLiteral("EWR32C"), QStringLiteral("/r32c/bin/iccr32c.exe")}, + {QStringLiteral("EWM16C"), QStringLiteral("/m16c/bin/iccm16c.exe")}, + {QStringLiteral("EWCR16C"), QStringLiteral("/cr16c/bin/icccr16c.exe")}, + {QStringLiteral("EWHCS12"), QStringLiteral("/hcs12/bin/icchcs12.exe")}, + {QStringLiteral("EWS08"), QStringLiteral("/s08/bin/iccs08.exe")}, + }; + + QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat); + const auto oneLevelGroups = registry.childGroups(); + for (const QString &oneLevelKey : oneLevelGroups) { + registry.beginGroup(oneLevelKey); + const auto twoLevelGroups = registry.childGroups(); + for (const Entry &entry : knowToolchains) { + if (twoLevelGroups.contains(entry.registryKey)) { + registry.beginGroup(entry.registryKey); + const auto threeLevelGroups = registry.childGroups(); + for (const QString &threeLevelKey : threeLevelGroups) { + registry.beginGroup(threeLevelKey); + const QString rootPath = registry.value( + QStringLiteral("InstallPath")).toString(); + if (!rootPath.isEmpty()) { + // Build full compiler path. + const QFileInfo iarPath(rootPath + entry.subExePath); + if (iarPath.exists()) { + // Note: threeLevelKey is a guessed toolchain version. + infos.push_back({iarPath, Version::fromString(threeLevelKey, true)}); + } + } + registry.endGroup(); + } + registry.endGroup(); + } + } + registry.endGroup(); + } + + } + + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isIarCompiler(const QString &compilerName) +{ + return Internal::any_of(knownIarCompilerNames(), [compilerName]( + const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createIarProfile(const QFileInfo &compiler, Settings *settings, + QString profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createIarProfileHelper(info, settings, std::move(profileName)); +} + +void iarProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect IAR toolchains..."); + + // Make sure that a returned infos are sorted before using the std::set_union! + const std::vector regInfos = installedIarsFromRegistry(); + const std::vector pathInfos = installedIarsFromPath(); + std::vector allInfos; + allInfos.reserve(regInfos.size() + pathInfos.size()); + std::set_union(regInfos.cbegin(), regInfos.cend(), + pathInfos.cbegin(), pathInfos.cend(), + std::back_inserter(allInfos)); + + qbs::Internal::transform(allInfos, profiles, [settings](const auto &info) { + return createIarProfileHelper(info, settings); }); + + if (allInfos.empty()) + qbsInfo() << Tr::tr("No IAR toolchains found."); +} diff --git a/src/app/qbs-setup-toolchains/iarewprobe.h b/src/app/qbs-setup-toolchains/iarewprobe.h new file mode 100644 index 00000000..a1a51daa --- /dev/null +++ b/src/app/qbs-setup-toolchains/iarewprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_IAREWPROBE_H +#define QBS_SETUPTOOLCHAINS_IAREWPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +bool isIarCompiler(const QString &compilerName); + +void createIarProfile(const QFileInfo &compiler, qbs::Settings *settings, + QString profileName); + +void iarProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/keilprobe.cpp b/src/app/qbs-setup-toolchains/keilprobe.cpp new file mode 100644 index 00000000..4bab54c9 --- /dev/null +++ b/src/app/qbs-setup-toolchains/keilprobe.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "keilprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include +#include + +using namespace qbs; +using Internal::Tr; +using Internal::HostOsInfo; + +static QStringList knownKeilCompilerNames() +{ + return {QStringLiteral("c51"), QStringLiteral("c251"), + QStringLiteral("c166"), QStringLiteral("armcc"), + QStringLiteral("armclang")}; +} + +static QString guessKeilArchitecture(const QFileInfo &compiler) +{ + const auto baseName = compiler.baseName(); + if (baseName == QLatin1String("c51")) + return QStringLiteral("mcs51"); + if (baseName == QLatin1String("c251")) + return QStringLiteral("mcs251"); + if (baseName == QLatin1String("c166")) + return QStringLiteral("c166"); + if (baseName == QLatin1String("armcc")) + return QStringLiteral("arm"); + if (baseName == QLatin1String("armclang")) + return QStringLiteral("arm"); + return {}; +} + +static bool isArmClangCompiler(const QFileInfo &compiler) +{ + return compiler.baseName() == QLatin1String("armclang"); +} + +static Profile createKeilProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + QString profileName = QString()) +{ + const QFileInfo compiler = info.compilerPath; + const QString architecture = guessKeilArchitecture(compiler); + + // In case the profile is auto-detected. + if (profileName.isEmpty()) { + if (!info.compilerVersion.isValid()) { + profileName = QStringLiteral("keil-unknown-%1").arg(architecture); + } else { + const QString version = info.compilerVersion.toString(QLatin1Char('_'), + QLatin1Char('_')); + if (architecture == QLatin1String("arm") && isArmClangCompiler(compiler)) { + profileName = QStringLiteral("keil-llvm-%1-%2").arg( + version, architecture); + } else { + profileName = QStringLiteral("keil-%1-%2").arg( + version, architecture); + } + } + } + + Profile profile(profileName, settings); + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QStringLiteral("cpp.compilerName"), compiler.fileName()); + profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("keil")); + if (!architecture.isEmpty()) + profile.setValue(QStringLiteral("qbs.architecture"), architecture); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg( + profile.name(), compiler.absoluteFilePath()); + return profile; +} + +static Version dumpMcsCompilerVersion(const QFileInfo &compiler) +{ + QTemporaryFile fakeIn; + if (!fakeIn.open()) { + qbsWarning() << Tr::tr("Unable to open temporary file %1 for output: %2") + .arg(fakeIn.fileName(), fakeIn.errorString()); + return Version{}; + } + + fakeIn.write("#define VALUE_TO_STRING(x) #x\n"); + fakeIn.write("#define VALUE(x) VALUE_TO_STRING(x)\n"); + + // Prepare for C51 compiler. + fakeIn.write("#if defined(__C51__) || defined(__CX51__)\n"); + fakeIn.write("# define VAR_NAME_VALUE(var) \"(\"\"\"\"|\"#var\"|\"VALUE(var)\"|\"\"\"\")\"\n"); + fakeIn.write("# if defined (__C51__)\n"); + fakeIn.write("# pragma message (VAR_NAME_VALUE(__C51__))\n"); + fakeIn.write("# endif\n"); + fakeIn.write("# if defined(__CX51__)\n"); + fakeIn.write("# pragma message (VAR_NAME_VALUE(__CX51__))\n"); + fakeIn.write("# endif\n"); + fakeIn.write("#endif\n"); + + // Prepare for C251 compiler. + fakeIn.write("#if defined(__C251__)\n"); + fakeIn.write("# define VAR_NAME_VALUE(var) \"\"|#var|VALUE(var)|\"\"\n"); + fakeIn.write("# if defined(__C251__)\n"); + fakeIn.write("# warning (VAR_NAME_VALUE(__C251__))\n"); + fakeIn.write("# endif\n"); + fakeIn.write("#endif\n"); + + fakeIn.close(); + + const QStringList args = {fakeIn.fileName()}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + + const QStringList knownKeys = {QStringLiteral("__C51__"), + QStringLiteral("__CX51__"), + QStringLiteral("__C251__")}; + + auto extractVersion = [&knownKeys](const QByteArray &output) { + QTextStream stream(output); + QString line; + while (stream.readLineInto(&line)) { + if (!line.startsWith(QLatin1String("***"))) + continue; + enum { KEY_INDEX = 1, VALUE_INDEX = 2, ALL_PARTS = 4 }; + const QStringList parts = line.split(QLatin1String("\"|\"")); + if (parts.count() != ALL_PARTS) + continue; + if (!knownKeys.contains(parts.at(KEY_INDEX))) + continue; + return parts.at(VALUE_INDEX).toInt(); + } + return -1; + }; + + const QByteArray dump = p.readAllStandardOutput(); + const int verCode = extractVersion(dump); + if (verCode < 0) { + qbsWarning() << Tr::tr("No %1 tokens was found" + " in the compiler dump:\n%2") + .arg(knownKeys.join(QLatin1Char(',')), QString::fromUtf8(dump)); + return Version{}; + } + return Version{verCode / 100, verCode % 100}; +} + +static Version dumpC166CompilerVersion(const QFileInfo &compiler) +{ + QTemporaryFile fakeIn; + if (!fakeIn.open()) { + qbsWarning() << Tr::tr("Unable to open temporary file %1 for output: %2") + .arg(fakeIn.fileName(), fakeIn.errorString()); + return Version{}; + } + + fakeIn.write("#if defined(__C166__)\n"); + fakeIn.write("# warning __C166__\n"); + fakeIn.write("# pragma __C166__\n"); + fakeIn.write("#endif\n"); + + fakeIn.close(); + + const QStringList args = {fakeIn.fileName()}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + + // Extract the compiler version pattern in the form, like: + // + // *** WARNING C320 IN LINE 41 OF c51.c: __C166__ + // *** WARNING C2 IN LINE 42 OF c51.c: '757': unknown #pragma/control, line ignored + // + // where the '__C166__' is a key, and the '757' is a value (aka version). + auto extractVersion = [](const QString &output) { + const QStringList lines = output.split(QStringLiteral("\r\n")); + for (auto it = lines.cbegin(); it != lines.cend();) { + if (it->startsWith(QLatin1String("***")) && it->endsWith(QLatin1String("__C166__"))) { + ++it; + if (it == lines.cend() || !it->startsWith(QLatin1String("***"))) + break; + const int startIndex = it->indexOf(QLatin1Char('\'')); + if (startIndex == -1) + break; + const int stopIndex = it->indexOf(QLatin1Char('\''), startIndex + 1); + if (stopIndex == -1) + break; + const QString v = it->mid(startIndex + 1, stopIndex - startIndex - 1); + return v.toInt(); + } + ++it; + } + return -1; + }; + + const QByteArray dump = p.readAllStandardOutput(); + const int verCode = extractVersion(QString::fromUtf8(dump)); + if (verCode < 0) { + qbsWarning() << Tr::tr("No __C166__ token was found" + " in the compiler dump:\n%1") + .arg(QString::fromUtf8(dump)); + return Version{}; + } + return Version{verCode / 100, verCode % 100}; +} + +static Version dumpArmCCCompilerVersion(const QFileInfo &compiler) +{ + const QStringList args = {QStringLiteral("-E"), + QStringLiteral("--list-macros"), + QStringLiteral("nul")}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + const auto es = p.exitStatus(); + if (es != QProcess::NormalExit) { + const QByteArray out = p.readAll(); + qbsWarning() << Tr::tr("Compiler dumping failed:\n%1") + .arg(QString::fromUtf8(out)); + return Version{}; + } + + const QByteArray dump = p.readAll(); + const int verCode = extractVersion(dump, "__ARMCC_VERSION "); + if (verCode < 0) { + qbsWarning() << Tr::tr("No '__ARMCC_VERSION' token was found " + "in the compiler dump:\n%1") + .arg(QString::fromUtf8(dump)); + return Version{}; + } + return Version{verCode / 1000000, (verCode / 10000) % 100, verCode % 10000}; +} + +static Version dumpArmClangCompilerVersion(const QFileInfo &compiler) +{ + const QStringList args = {QStringLiteral("-dM"), QStringLiteral("-E"), + QStringLiteral("-xc"), + QStringLiteral("--target=arm-arm-none-eabi"), + QStringLiteral("-mcpu=cortex-m0"), + QStringLiteral("nul")}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + const auto es = p.exitStatus(); + if (es != QProcess::NormalExit) { + const QByteArray out = p.readAll(); + qbsWarning() << Tr::tr("Compiler dumping failed:\n%1") + .arg(QString::fromUtf8(out)); + return Version{}; + } + const QByteArray dump = p.readAll(); + const int verCode = extractVersion(dump, "__ARMCC_VERSION "); + if (verCode < 0) { + qbsWarning() << Tr::tr("No '__ARMCC_VERSION' token was found " + "in the compiler dump:\n%1") + .arg(QString::fromUtf8(dump)); + return Version{}; + } + return Version{verCode / 1000000, (verCode / 10000) % 100, verCode % 10000}; +} + +static Version dumpKeilCompilerVersion(const QFileInfo &compiler) +{ + const QString arch = guessKeilArchitecture(compiler); + if (arch == QLatin1String("mcs51") || arch == QLatin1String("mcs251")) + return dumpMcsCompilerVersion(compiler); + if (arch == QLatin1String("c166")) + return dumpC166CompilerVersion(compiler); + if (arch == QLatin1String("arm")) { + if (isArmClangCompiler(compiler)) + return dumpArmClangCompilerVersion(compiler); + return dumpArmCCCompilerVersion(compiler); + } + return Version{}; +} + +static std::vector installedKeilsFromPath() +{ + std::vector infos; + const auto compilerNames = knownKeilCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo keilPath( + findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!keilPath.exists()) + continue; + const Version version = dumpKeilCompilerVersion(keilPath); + infos.push_back({keilPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +static std::vector installedKeilsFromRegistry() +{ + std::vector infos; + + if (HostOsInfo::isWindowsHost()) { + +#ifdef Q_OS_WIN64 + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Keil\\Products"; +#else + static const char kRegistryNode[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Keil\\Products"; +#endif + + QSettings registry(QLatin1String(kRegistryNode), QSettings::NativeFormat); + const auto productGroups = registry.childGroups(); + for (const QString &productKey : productGroups) { + registry.beginGroup(productKey); + const QString productPath = registry.value(QStringLiteral("Path")) + .toString(); + QString productVersion = registry.value(QStringLiteral("Version")) + .toString(); + if (productVersion.startsWith(QLatin1Char('V'))) + productVersion.remove(0, 1); + + if (productKey == QLatin1String("MDK")) { + const QFileInfo ccPath(productPath + QStringLiteral("/ARMCC/bin/armcc.exe")); + if (ccPath.exists()) + infos.push_back({ccPath, Version::fromString(productVersion)}); + const QFileInfo clangPath(productPath + QStringLiteral("/ARMCLANG/bin/armclang.exe")); + if (clangPath.exists()) + infos.push_back({clangPath, Version::fromString(productVersion)}); + } if (productKey == QLatin1String("C51")) { + const QFileInfo cPath(productPath + QStringLiteral("/BIN/c51.exe")); + if (cPath.exists()) + infos.push_back({cPath, Version::fromString(productVersion)}); + } if (productKey == QLatin1String("C251")) { + const QFileInfo cPath(productPath + QStringLiteral("/BIN/c251.exe")); + if (cPath.exists()) + infos.push_back({cPath, Version::fromString(productVersion)}); + } if (productKey == QLatin1String("C166")) { + const QFileInfo cPath(productPath + QStringLiteral("/BIN/c166.exe")); + if (cPath.exists()) + infos.push_back({cPath, Version::fromString(productVersion)}); + } + + registry.endGroup(); + } + } + + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isKeilCompiler(const QString &compilerName) +{ + return Internal::any_of(knownKeilCompilerNames(), [compilerName]( + const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createKeilProfile(const QFileInfo &compiler, Settings *settings, + QString profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createKeilProfileHelper(info, settings, std::move(profileName)); +} + +void keilProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect KEIL toolchains..."); + + // Make sure that a returned infos are sorted before using the std::set_union! + const std::vector regInfos = installedKeilsFromRegistry(); + const std::vector pathInfos = installedKeilsFromPath(); + std::vector allInfos; + allInfos.reserve(regInfos.size() + pathInfos.size()); + std::set_union(regInfos.cbegin(), regInfos.cend(), + pathInfos.cbegin(), pathInfos.cend(), + std::back_inserter(allInfos)); + + qbs::Internal::transform(allInfos, profiles, [settings](const auto &info) { + return createKeilProfileHelper(info, settings); }); + + if (allInfos.empty()) + qbsInfo() << Tr::tr("No KEIL toolchains found."); +} diff --git a/src/app/qbs-setup-toolchains/keilprobe.h b/src/app/qbs-setup-toolchains/keilprobe.h new file mode 100644 index 00000000..fec650ab --- /dev/null +++ b/src/app/qbs-setup-toolchains/keilprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_KEILPROBE_H +#define QBS_SETUPTOOLCHAINS_KEILPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +bool isKeilCompiler(const QString &compilerName); + +void createKeilProfile(const QFileInfo &compiler, qbs::Settings *settings, + QString profileName); + +void keilProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/main.cpp b/src/app/qbs-setup-toolchains/main.cpp new file mode 100644 index 00000000..475bcf07 --- /dev/null +++ b/src/app/qbs-setup-toolchains/main.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "commandlineparser.h" +#include "probe.h" + +#include +#include +#include + +#include + +#include +#include + +using qbs::Settings; + +static void printUsage(const QString &usageString) +{ + std::cout << qPrintable(usageString) << std::endl; +} + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + CommandLineParser clParser; + try { + clParser.parse(app.arguments()); + if (clParser.helpRequested()) { + printUsage(clParser.usageString()); + return EXIT_SUCCESS; + } + Settings settings(clParser.settingsDir()); + settings.setScopeForWriting(clParser.settingsScope()); + if (clParser.autoDetectionMode()) { + probe(&settings); + return EXIT_SUCCESS; + } + createProfile(clParser.profileName(), clParser.toolchainType(), clParser.compilerPath(), + &settings); + } catch (const qbs::ErrorInfo &e) { + std::cerr << qPrintable(e.toString()) << std::endl; + return EXIT_FAILURE; + } +} diff --git a/src/app/qbs-setup-toolchains/msvcprobe.cpp b/src/app/qbs-setup-toolchains/msvcprobe.cpp new file mode 100644 index 00000000..a0fa7cee --- /dev/null +++ b/src/app/qbs-setup-toolchains/msvcprobe.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "msvcprobe.h" + +#include "probe.h" +#include "../shared/logging/consolelogger.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +using namespace qbs; +using namespace qbs::Internal; +using Internal::Tr; + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(WinSDK, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(MSVC, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +// Not necessary but helps setup-qt automatically associate base profiles +static void setQtHelperProperties(Profile &p, const MSVC *msvc) +{ + QString targetArch = msvc->architecture.split(QLatin1Char('_')).last(); + if (targetArch.isEmpty()) + targetArch = QStringLiteral("x86"); + if (targetArch == QStringLiteral("arm")) + targetArch = QStringLiteral("armv7"); + + p.setValue(QStringLiteral("qbs.architecture"), canonicalArchitecture(targetArch)); + p.setValue(QStringLiteral("cpp.compilerVersion"), msvc->compilerVersion.toString()); +} + +static void addMSVCPlatform(Settings *settings, std::vector &profiles, QString name, MSVC *msvc) +{ + qbsInfo() << Tr::tr("Setting up profile '%1'.").arg(name); + Profile p(std::move(name), settings); + p.removeProfile(); + p.setValue(QStringLiteral("qbs.targetPlatform"), QStringLiteral("windows")); + p.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("msvc")); + p.setValue(QStringLiteral("cpp.toolchainInstallPath"), msvc->binPath); + setQtHelperProperties(p, msvc); + profiles.push_back(p); +} + +static QString wow6432Key() +{ +#ifdef Q_OS_WIN64 + return QStringLiteral("\\Wow6432Node"); +#else + return {}; +#endif +} + +void msvcProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Detecting MSVC toolchains..."); + + // 1) Installed SDKs preferred over standalone Visual studio + std::vector winSDKs; + WinSDK defaultWinSDK; + + const QSettings sdkRegistry(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key() + + QLatin1String("\\Microsoft\\Microsoft SDKs\\Windows"), + QSettings::NativeFormat); + const QString defaultSdkPath = sdkRegistry.value(QStringLiteral("CurrentInstallFolder")).toString(); + if (!defaultSdkPath.isEmpty()) { + const auto sdkKeys = sdkRegistry.childGroups(); + for (const QString &sdkKey : sdkKeys) { + WinSDK sdk; + sdk.version = sdkKey; + sdk.vcInstallPath = sdkRegistry.value(sdkKey + QLatin1String("/InstallationFolder")).toString(); + sdk.isDefault = (sdk.vcInstallPath == defaultSdkPath); + if (sdk.vcInstallPath.isEmpty()) + continue; + if (sdk.vcInstallPath.endsWith(QLatin1Char('\\'))) + sdk.vcInstallPath.chop(1); + if (sdk.isDefault) + defaultWinSDK = sdk; + const auto ais = MSVC::findSupportedArchitectures(sdk); + + qbs::Internal::transform(ais, winSDKs, [&sdk](const auto &ai) { + WinSDK specificSDK = sdk; + specificSDK.architecture = ai.arch; + specificSDK.binPath = ai.binPath; + return specificSDK; + }); + } + } + + for (const WinSDK &sdk : qAsConst(winSDKs)) { + qbsInfo() << Tr::tr(" Windows SDK %1 detected:\n" + " installed in %2").arg(sdk.version, sdk.vcInstallPath); + if (sdk.isDefault) + qbsInfo() << Tr::tr(" This is the default SDK on this machine."); + } + + // 2) Installed MSVCs + std::vector msvcs = MSVC::installedCompilers(ConsoleLogger::instance()); + + for (const MSVC &msvc : qAsConst(msvcs)) { + qbsInfo() << Tr::tr(" MSVC %1 (%2) detected in\n" + " %3").arg(msvc.version, msvc.architecture, + QDir::toNativeSeparators(msvc.binPath)); + } + + if (winSDKs.empty() && msvcs.empty()) { + qbsInfo() << Tr::tr("Could not detect an installation of " + "the Windows SDK or Visual Studio."); + return; + } + + qbsInfo() << Tr::tr("Detecting build environment..."); + std::vector msvcPtrs; + msvcPtrs.resize(winSDKs.size() + msvcs.size()); + std::transform(winSDKs.begin(), winSDKs.end(), msvcPtrs.begin(), + [] (WinSDK &sdk) -> MSVC * { return &sdk; }); + std::transform(msvcs.begin(), msvcs.end(), msvcPtrs.begin() + winSDKs.size(), + [] (MSVC &msvc) -> MSVC * { return &msvc; }); + + VsEnvironmentDetector envDetector; + envDetector.start(msvcPtrs); + + for (WinSDK &sdk : winSDKs) { + const QString name = QLatin1String("WinSDK") + sdk.version + QLatin1Char('-') + + sdk.architecture; + try { + sdk.init(); + addMSVCPlatform(settings, profiles, name, &sdk); + } catch (const ErrorInfo &error) { + qbsWarning() << Tr::tr("Failed to set up %1: %2").arg(name, error.toString()); + } + } + + // we want the same MSVC version share the same suffix in profiles, thus use + // a set to know the number of versions processed so far + std::map> msvcCounters; + for (MSVC &msvc : msvcs) { + // each VS needs its own counter + auto &msvcVersions = msvcCounters[msvc.version]; + // vcInstallPath is "Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.16.27023/bin" + // Since msvcs are sorted by version, when the new vcInstallPath is inserted, we start + // a new group of compilers of the same version incrementing the set size + msvcVersions.insert(msvc.vcInstallPath); + // index is the number of specific vcInstallPaths (e.g. compiler versions) seen so far + const qsizetype index = msvcVersions.size() - 1; + const QString suffix = index == 0 ? QString() : QStringLiteral("-%1").arg(index); + const QString name = QLatin1String("MSVC") + msvc.version + suffix + QLatin1Char('-') + + msvc.architecture; + try { + msvc.init(); + addMSVCPlatform(settings, profiles, name, &msvc); + } catch (const ErrorInfo &error) { + qbsWarning() << Tr::tr("Failed to set up %1: %2").arg(name, error.toString()); + } + } +} + +void createMsvcProfile(const QFileInfo &compiler, Settings *settings, + const QString &profileName) +{ + const auto compilerFilePath = compiler.absoluteFilePath(); + MSVC msvc(compilerFilePath, MSVC::architectureFromClPath(compilerFilePath)); + msvc.init(); + std::vector dummy; + addMSVCPlatform(settings, dummy, profileName, &msvc); + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.") + .arg(profileName, QDir::toNativeSeparators(compilerFilePath)); +} diff --git a/src/app/qbs-setup-toolchains/msvcprobe.h b/src/app/qbs-setup-toolchains/msvcprobe.h new file mode 100644 index 00000000..981bbc56 --- /dev/null +++ b/src/app/qbs-setup-toolchains/msvcprobe.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_MSVCPROBE_H +#define QBS_SETUPTOOLCHAINS_MSVCPROBE_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +void createMsvcProfile(const QFileInfo &compiler, qbs::Settings *settings, + const QString &profileName); + +void msvcProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/probe.cpp b/src/app/qbs-setup-toolchains/probe.cpp new file mode 100644 index 00000000..ceb95948 --- /dev/null +++ b/src/app/qbs-setup-toolchains/probe.cpp @@ -0,0 +1,339 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "probe.h" + +#include "clangclprobe.h" +#include "cosmicprobe.h" +#include "dmcprobe.h" +#include "gccprobe.h" +#include "iarewprobe.h" +#include "keilprobe.h" +#include "msvcprobe.h" +#include "sdccprobe.h" +#include "watcomprobe.h" +#include "xcodeprobe.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#ifdef Q_OS_WIN +// We need defines for Windows 8. +#undef _WIN32_WINNT +#define _WIN32_WINNT _WIN32_WINNT_WIN8 + +#include +#include +#else +#include +#endif // Q_OS_WIN + +using namespace qbs; +using Internal::HostOsInfo; +using Internal::Tr; + +static QTextStream qStdout(stdout); +static QTextStream qStderr(stderr); + +QStringList systemSearchPaths() +{ + return QString::fromLocal8Bit(qgetenv("PATH")).split(HostOsInfo::pathListSeparator()); +} + +QString findExecutable(const QString &fileName) +{ + QString fullFileName = fileName; + if (HostOsInfo::isWindowsHost() + && !fileName.endsWith(QLatin1String(".exe"), Qt::CaseInsensitive)) { + fullFileName += QLatin1String(".exe"); + } + const auto ppaths = systemSearchPaths(); + for (const QString &ppath : ppaths) { + const QString fullPath = ppath + QLatin1Char('/') + fullFileName; + if (QFileInfo::exists(fullPath)) + return QDir::cleanPath(fullPath); + } + return {}; +} + +QString toolchainTypeFromCompilerName(const QString &compilerName) +{ + if (compilerName == QLatin1String("cl.exe")) + return QStringLiteral("msvc"); + if (compilerName == QLatin1String("clang-cl.exe")) + return QStringLiteral("clang-cl"); + const auto types = { QStringLiteral("clang"), QStringLiteral("llvm"), + QStringLiteral("mingw"), QStringLiteral("gcc") }; + for (const auto &type : types) { + if (compilerName.contains(type)) + return type; + } + if (compilerName == QLatin1String("g++")) + return QStringLiteral("gcc"); + if (isIarCompiler(compilerName)) + return QStringLiteral("iar"); + if (isKeilCompiler(compilerName)) + return QStringLiteral("keil"); + if (isSdccCompiler(compilerName)) + return QStringLiteral("sdcc"); + if (isCosmicCompiler(compilerName)) + return QStringLiteral("cosmic"); + if (isDmcCompiler(compilerName)) + return QStringLiteral("dmc"); + if (isWatcomCompiler(compilerName)) + return QStringLiteral("watcom"); + return {}; +} + +void probe(Settings *settings) +{ + std::vector profiles; + if (HostOsInfo::isWindowsHost()) { + msvcProbe(settings, profiles); + clangClProbe(settings, profiles); + } else if (HostOsInfo::isMacosHost()) { + xcodeProbe(settings, profiles); + } + + gccProbe(settings, profiles, QStringLiteral("gcc")); + gccProbe(settings, profiles, QStringLiteral("clang")); + + iarProbe(settings, profiles); + keilProbe(settings, profiles); + sdccProbe(settings, profiles); + cosmicProbe(settings, profiles); + dmcProbe(settings, profiles); + watcomProbe(settings, profiles); + + if (profiles.empty()) { + qStderr << Tr::tr("Could not detect any toolchains. No profile created.") << Qt::endl; + } else if (profiles.size() == 1 && settings->defaultProfile().isEmpty()) { + const QString profileName = profiles.front().name(); + qStdout << Tr::tr("Making profile '%1' the default.").arg(profileName) << Qt::endl; + settings->setValue(QStringLiteral("defaultProfile"), profileName); + } +} + +void createProfile(const QString &profileName, const QString &toolchainType, + const QString &compilerFilePath, Settings *settings) +{ + QFileInfo compiler(compilerFilePath); + if (compilerFilePath == compiler.fileName() && !compiler.exists()) + compiler = QFileInfo(findExecutable(compilerFilePath)); + + if (!compiler.exists()) { + throw qbs::ErrorInfo(Tr::tr("Compiler '%1' not found") + .arg(compilerFilePath)); + } + + const QString realToolchainType = !toolchainType.isEmpty() + ? toolchainType + : toolchainTypeFromCompilerName(compiler.fileName()); + const QStringList toolchain = canonicalToolchain(realToolchainType); + + if (toolchain.contains(QLatin1String("clang-cl"))) + createClangClProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("msvc"))) + createMsvcProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("gcc"))) + createGccProfile(compiler, settings, realToolchainType, profileName); + else if (toolchain.contains(QLatin1String("iar"))) + createIarProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("keil"))) + createKeilProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("sdcc"))) + createSdccProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("cosmic"))) + createCosmicProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("dmc"))) + createDmcProfile(compiler, settings, profileName); + else if (toolchain.contains(QLatin1String("watcom"))) + createWatcomProfile(compiler, settings, profileName); + else + throw qbs::ErrorInfo(Tr::tr("Cannot create profile: Unknown toolchain type.")); +} + +int extractVersion(const QByteArray ¯oDump, const QByteArray &keyToken) +{ + const int startIndex = macroDump.indexOf(keyToken); + if (startIndex == -1) + return -1; + const int endIndex = macroDump.indexOf('\n', startIndex); + if (endIndex == -1) + return -1; + const auto keyLength = keyToken.length(); + const int version = macroDump.mid(startIndex + keyLength, + endIndex - startIndex - keyLength) + .toInt(); + return version; +} + +static QString resolveSymlinks(const QString &filePath) +{ + QFileInfo fi(filePath); + int links = 16; + while (links-- && fi.isSymLink()) + fi.setFile(fi.dir(), fi.symLinkTarget()); + if (links <= 0) + return {}; + return fi.filePath(); +} + +// Copied from qfilesystemengine_win.cpp. +#ifdef Q_OS_WIN + +// File ID for Windows up to version 7. +static inline QByteArray fileIdWin7(HANDLE handle) +{ + BY_HANDLE_FILE_INFORMATION info; + if (GetFileInformationByHandle(handle, &info)) { + char buffer[sizeof "01234567:0123456701234567\0"]; + qsnprintf(buffer, sizeof(buffer), "%lx:%08lx%08lx", + info.dwVolumeSerialNumber, + info.nFileIndexHigh, + info.nFileIndexLow); + return QByteArray(buffer); + } + return {}; +} + +// File ID for Windows starting from version 8. +static QByteArray fileIdWin8(HANDLE handle) +{ + QByteArray result; + FILE_ID_INFO infoEx = {}; + if (::GetFileInformationByHandleEx( + handle, + static_cast(18), // FileIdInfo in Windows 8 + &infoEx, sizeof(FILE_ID_INFO))) { + result = QByteArray::number(infoEx.VolumeSerialNumber, 16); + result += ':'; + // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one. + result += QByteArray(reinterpret_cast(&infoEx.FileId), + int(sizeof(infoEx.FileId))).toHex(); + } + return result; +} + +static QByteArray fileIdWin(HANDLE fHandle) +{ + return QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8 + ? fileIdWin8(HANDLE(fHandle)) + : fileIdWin7(HANDLE(fHandle)); +} + +static QByteArray fileId(const QString &filePath) +{ + QByteArray result; + const HANDLE handle = ::CreateFile( + reinterpret_cast(filePath.utf16()), 0, + FILE_SHARE_READ, nullptr, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, nullptr); + if (handle != INVALID_HANDLE_VALUE) { + result = fileIdWin(handle); + ::CloseHandle(handle); + } + return result; +} + +static qint64 fileSize(const QString &filePath) +{ + return QFileInfo(filePath).size(); +} + +#else + +static QByteArray fileId(const QString &filePath) +{ + QByteArray result; + if (Q_UNLIKELY(filePath.isEmpty())) + return {}; + QT_STATBUF statResult = {}; + if (QT_STAT(filePath.toLocal8Bit().constData(), &statResult)) + return {}; + result = QByteArray::number(quint64(statResult.st_dev), 16); + result += ':'; + result += QByteArray::number(quint64(statResult.st_ino)); + return result; +} + +#endif // Q_OS_WIN + +bool isSameExecutable(const QString &filePath1, const QString &filePath2) +{ + if (filePath1 == filePath2) + return true; + if (resolveSymlinks(filePath1) == resolveSymlinks(filePath2)) + return true; + if (fileId(filePath1) == fileId(filePath2)) + return true; + +#ifdef Q_OS_WIN + if (fileSize(filePath1) == fileSize(filePath2)) + return true; +#endif + + return false; +} + +MacrosMap dumpMacros(const std::function &func) +{ + MacrosMap macros; + const QStringList lines = func(); + for (const QString &line : lines) { + const QString prefix = QLatin1String("#define "); + if (!line.startsWith(prefix)) + return macros; + const auto index = line.indexOf(QLatin1String(" "), prefix.length()); + if (index != -1) { + const auto key = line.mid(prefix.length(), index - prefix.length()); + const auto value = line.mid(index + 1); + macros.insert(key, value); + } + } + return macros; +} diff --git a/src/app/qbs-setup-toolchains/probe.h b/src/app/qbs-setup-toolchains/probe.h new file mode 100644 index 00000000..827171fb --- /dev/null +++ b/src/app/qbs-setup-toolchains/probe.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_PROBE_H +#define QBS_SETUPTOOLCHAINS_PROBE_H + +#include + +#include +#include +#include + +#include // for std::function +#include // for std::tie + +namespace qbs { class Settings; } + +QStringList systemSearchPaths(); + +QString findExecutable(const QString &fileName); + +QString toolchainTypeFromCompilerName(const QString &compilerName); + +void createProfile(const QString &profileName, const QString &toolchainType, + const QString &compilerFilePath, qbs::Settings *settings); + +void probe(qbs::Settings *settings); + +struct ToolchainInstallInfo +{ + QFileInfo compilerPath; + qbs::Version compilerVersion; +}; + +inline bool operator<(const ToolchainInstallInfo &lhs, const ToolchainInstallInfo &rhs) +{ + const auto lp = lhs.compilerPath.absoluteFilePath(); + const auto rp = rhs.compilerPath.absoluteFilePath(); + return std::tie(lp, lhs.compilerVersion) < std::tie(rp, rhs.compilerVersion); +} + +int extractVersion(const QByteArray ¯oDump, const QByteArray &keyToken); + +bool isSameExecutable(const QString &exe1, const QString &exe2); + +using MacrosMap = QMap; +MacrosMap dumpMacros(const std::function &func); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.exe.manifest b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.exe.manifest new file mode 100644 index 00000000..c2114cc8 --- /dev/null +++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.exe.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro new file mode 100644 index 00000000..69d6552e --- /dev/null +++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.pro @@ -0,0 +1,36 @@ +include(../app.pri) + +TARGET = qbs-setup-toolchains + +HEADERS += \ + clangclprobe.h \ + commandlineparser.h \ + cosmicprobe.h \ + dmcprobe.h \ + gccprobe.h \ + iarewprobe.h \ + keilprobe.h \ + msvcprobe.h \ + probe.h \ + sdccprobe.h \ + watcomprobe.h \ + xcodeprobe.h \ + +SOURCES += \ + clangclprobe.cpp \ + commandlineparser.cpp \ + cosmicprobe.cpp \ + dmcprobe.cpp \ + gccprobe.cpp \ + iarewprobe.cpp \ + keilprobe.cpp \ + main.cpp \ + msvcprobe.cpp \ + probe.cpp \ + sdccprobe.cpp \ + watcomprobe.cpp \ + xcodeprobe.cpp \ + +mingw { + RC_FILE = qbs-setup-toolchains.rc +} diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs new file mode 100644 index 00000000..6987f371 --- /dev/null +++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.qbs @@ -0,0 +1,41 @@ +QbsApp { + name: "qbs-setup-toolchains" + cpp.dynamicLibraries: qbs.targetOS.contains("windows") ? base.concat("shell32") : base + files: [ + "clangclprobe.cpp", + "clangclprobe.h", + "commandlineparser.cpp", + "commandlineparser.h", + "cosmicprobe.cpp", + "cosmicprobe.h", + "dmcprobe.cpp", + "dmcprobe.h", + "gccprobe.cpp", + "gccprobe.h", + "iarewprobe.cpp", + "iarewprobe.h", + "keilprobe.cpp", + "keilprobe.h", + "main.cpp", + "msvcprobe.cpp", + "msvcprobe.h", + "probe.cpp", + "probe.h", + "sdccprobe.cpp", + "sdccprobe.h", + "watcomprobe.cpp", + "watcomprobe.h", + "xcodeprobe.cpp", + "xcodeprobe.h", + ] + Group { + name: "MinGW specific files" + condition: qbs.toolchain.contains("mingw") + files: "qbs-setup-toolchains.rc" + Group { + name: "qbs-setup-toolchains manifest" + files: "qbs-setup-toolchains.exe.manifest" + fileTags: [] // the manifest is referenced by the rc file + } + } +} diff --git a/src/app/qbs-setup-toolchains/qbs-setup-toolchains.rc b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.rc new file mode 100644 index 00000000..0f53403f --- /dev/null +++ b/src/app/qbs-setup-toolchains/qbs-setup-toolchains.rc @@ -0,0 +1,4 @@ +#define RT_MANIFEST 24 +#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 + +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "qbs-setup-toolchains.exe.manifest" diff --git a/src/app/qbs-setup-toolchains/sdccprobe.cpp b/src/app/qbs-setup-toolchains/sdccprobe.cpp new file mode 100644 index 00000000..b5361521 --- /dev/null +++ b/src/app/qbs-setup-toolchains/sdccprobe.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "sdccprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include +#include + +using namespace qbs; +using Internal::Tr; +using Internal::HostOsInfo; + +static QStringList knownSdccCompilerNames() +{ + return {QStringLiteral("sdcc")}; +} + +static QStringList dumpOutput(const QFileInfo &compiler, const QString &targetFlag = QString()) +{ + QTemporaryFile fakeIn(QStringLiteral("XXXXXX.c")); + if (!fakeIn.open()) { + qbsWarning() << Tr::tr("Unable to open temporary file %1 for output: %2") + .arg(fakeIn.fileName(), fakeIn.errorString()); + return {}; + } + fakeIn.close(); + + const QStringList args = {QStringLiteral("-dM"), QStringLiteral("-E"), + targetFlag, fakeIn.fileName()}; + QProcess p; + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + const auto es = p.exitStatus(); + if (es != QProcess::NormalExit) { + const QByteArray out = p.readAll(); + qbsWarning() << Tr::tr("Compiler dumping failed:\n%1").arg(QString::fromUtf8(out)); + return {}; + } + + static QRegularExpression re(QStringLiteral("\\r?\\n")); + const QStringList lines = QString::fromUtf8(p.readAllStandardOutput()).split(re); + return lines; +} + +static bool supportsSdccArchitecture(const QFileInfo &compiler, QStringView flag) +{ + const auto target = QStringLiteral("-m%1").arg(flag); + const auto macros = dumpMacros([&compiler, &target]() { + return dumpOutput(compiler, target); }); + const auto token = QStringLiteral("__SDCC_%1").arg(flag); + return macros.contains(token); +} + +static std::vector createSdccProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + const QString &profileName = QString()) +{ + const QFileInfo compiler = info.compilerPath; + std::vector profiles; + + static constexpr struct KnownArch { + QStringView architecture; + QStringView flag; + } knownArchs[] = {{u"mcs51", u"mcs51"}, {u"stm8", u"stm8"}, {u"hcs8", u"hc08"}}; + + for (const auto &knownArch : knownArchs) { + // Don't create a profile in case the compiler does + // not support the proposed architecture. + if (!supportsSdccArchitecture(compiler, knownArch.flag)) + continue; + + QString fullProfileName; + if (profileName.isEmpty()) { + // Create a full profile name in case we is + // in auto-detecting mode. + if (!info.compilerVersion.isValid()) { + fullProfileName = QStringLiteral("sdcc-unknown-%1").arg(knownArch.architecture); + } else { + const QString version = info.compilerVersion.toString( + QLatin1Char('_'), QLatin1Char('_')); + fullProfileName = QStringLiteral("sdcc-%1-%2").arg( + version, knownArch.architecture); + } + } else { + // Append the detected actual architecture name + // to the proposed profile name. + fullProfileName = QStringLiteral("%1-%2").arg(profileName, knownArch.architecture); + } + + Profile profile(fullProfileName, settings); + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("sdcc")); + profile.setValue(QStringLiteral("qbs.architecture"), knownArch.architecture.toString()); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg( + profile.name(), compiler.absoluteFilePath()); + + profiles.push_back(std::move(profile)); + } + + return profiles; +} + +static Version dumpSdccVersion(const QFileInfo &compiler) +{ + const auto macros = dumpMacros([&compiler]() { return dumpOutput(compiler); }); + if (!macros.contains(QLatin1String("__SDCC"))) { + qbsWarning() << Tr::tr("No __SDCC token was found in the compiler dump"); + return Version{}; + } + + auto value = macros.value(QLatin1String("__SDCC")); + value.replace(QLatin1Char('_'), QLatin1Char('.')); + return Version::fromString(value); +} + +static std::vector installedSdccsFromPath() +{ + std::vector infos; + const auto compilerNames = knownSdccCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo sdccPath( + findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!sdccPath.exists()) + continue; + const Version version = dumpSdccVersion(sdccPath); + infos.push_back({sdccPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +static std::vector installedSdccsFromRegistry() +{ + std::vector infos; + + if (HostOsInfo::isWindowsHost()) { + // Tries to detect the candidate from the 32-bit + // or 64-bit system registry format. + auto probeSdccToolchainInfo = [](QSettings::Format format) { + SdccInstallInfo info; + QSettings registry(QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\SDCC"), + format); + const QString rootPath = registry.value(QStringLiteral("Default")) + .toString(); + if (rootPath.isEmpty()) + return info; + // Build full compiler path. + const QFileInfo sdccPath(rootPath + QLatin1String("\\bin\\sdcc.exe")); + if (!sdccPath.exists()) + return info; + info.compilerPath = sdccPath.filePath(); + // Build compiler version. + const QString version = QStringLiteral("%1.%2.%3").arg( + registry.value(QStringLiteral("VersionMajor")).toString(), + registry.value(QStringLiteral("VersionMinor")).toString(), + registry.value(QStringLiteral("VersionRevision")).toString()); + info.version = version; + return info; + }; + + static constexpr QSettings::Format allowedFormats[] = { + QSettings::NativeFormat, +#ifdef Q_OS_WIN + QSettings::Registry32Format, + QSettings::Registry64Format, +#endif + }; + + for (const QSettings::Format format : allowedFormats) { + const SdccInstallInfo candidate = probeSdccToolchainInfo(format); + if (candidate.compilerPath.isEmpty()) + continue; + const auto infosEnd = infos.cend(); + const auto infosIt = std::find_if(infos.cbegin(), infosEnd, + [candidate](const ToolchainInstallInfo &info) { + return candidate == SdccInstallInfo{ + info.compilerPath.filePath(), info.compilerVersion.toString()}; + }); + if (infosIt == infosEnd) { + infos.push_back({QFileInfo(candidate.compilerPath), + Version::fromString(candidate.version)}); + } + } + } + + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isSdccCompiler(const QString &compilerName) +{ + return Internal::any_of(knownSdccCompilerNames(), [compilerName]( + const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createSdccProfile(const QFileInfo &compiler, Settings *settings, + const QString &profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createSdccProfileHelper(info, settings, profileName); +} + +void sdccProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect SDCC toolchains..."); + + // Make sure that a returned infos are sorted before using the std::set_union! + const std::vector regInfos = installedSdccsFromRegistry(); + const std::vector pathInfos = installedSdccsFromPath(); + std::vector allInfos; + allInfos.reserve(regInfos.size() + pathInfos.size()); + std::set_union(regInfos.cbegin(), regInfos.cend(), + pathInfos.cbegin(), pathInfos.cend(), + std::back_inserter(allInfos)); + + if (allInfos.empty()) + qbsInfo() << Tr::tr("No SDCC toolchains found."); + + for (const ToolchainInstallInfo &info : allInfos) { + const auto newProfiles = createSdccProfileHelper(info, settings); + profiles.reserve(profiles.size() + int(newProfiles.size())); + std::copy(newProfiles.cbegin(), newProfiles.cend(), + std::back_inserter(profiles)); + } +} diff --git a/src/app/qbs-setup-toolchains/sdccprobe.h b/src/app/qbs-setup-toolchains/sdccprobe.h new file mode 100644 index 00000000..4c913dde --- /dev/null +++ b/src/app/qbs-setup-toolchains/sdccprobe.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_SDCCPROBE_H +#define QBS_SETUPTOOLCHAINS_SDCCPROBE_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} + +struct SdccInstallInfo +{ + QString compilerPath; + QString version; +}; + +inline bool operator==(const SdccInstallInfo &lhs, const SdccInstallInfo &rhs) +{ + return std::tie(lhs.compilerPath, lhs.version) + == std::tie(rhs.compilerPath, rhs.version); +} + +bool isSdccCompiler(const QString &compilerName); + +void createSdccProfile(const QFileInfo &compiler, qbs::Settings *settings, + const QString &profileName); + +void sdccProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/watcomprobe.cpp b/src/app/qbs-setup-toolchains/watcomprobe.cpp new file mode 100644 index 00000000..13cb8d50 --- /dev/null +++ b/src/app/qbs-setup-toolchains/watcomprobe.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "watcomprobe.h" +#include "probe.h" + +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace qbs; +using Internal::HostOsInfo; +using Internal::Tr; + +namespace { + +struct Details { + QStringView architecture; + QStringView platform; +}; + +constexpr struct Platform { + QStringView flag; + Details keys; + Details target; +} knownPlatforms[] = { + // DOS 16/32 bit. + {u"-bdos", {u"__I86__", u"__DOS__"}, {u"x86_16", u"dos"}}, + {u"-bdos4g", {u"__386__", u"__DOS__"}, {u"x86", u"dos"}}, + // Windows 16/32 bit. + {u"-bwindows", {u"__I86__", u"__WINDOWS__"}, {u"x86_16", u"windows"}}, + {u"-bnt", {u"__386__", u"__NT__"}, {u"x86", u"windows"}}, + // OS/2 16/32 bit. + {u"-bos2", {u"__I86__", u"__OS2__"}, {u"x86_16", u"os2"}}, + {u"-bos2v2", {u"__386__", u"__OS2__"}, {u"x86", u"os2"}}, + // Linux 32 bit. + {u"-blinux", {u"__386__", u"__LINUX__"}, {u"x86", u"linux"}}, +}; + +} // namespace + +static QStringList knownWatcomCompilerNames() +{ + return {QStringLiteral("owcc")}; +} + +static QStringList dumpOutput(const QFileInfo &compiler, QStringView flag, + const QList &keys) +{ + const QString filePath = QDir(QDir::tempPath()).absoluteFilePath( + QLatin1String("watcom-dump.c")); + QFile fakeIn(filePath); + if (!fakeIn.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) { + qbsWarning() << Tr::tr("Unable to open temporary file %1 for output: %2") + .arg(fakeIn.fileName(), fakeIn.errorString()); + return {}; + } + fakeIn.write("#define VALUE_TO_STRING(x) #x\n"); + fakeIn.write("#define VALUE(x) VALUE_TO_STRING(x)\n"); + fakeIn.write("#define VAR_NAME_VALUE(var) \"#define \" #var\" \"VALUE(var)\n"); + for (const auto &key : keys) { + fakeIn.write("#if defined(" + key.toLatin1() + ")\n"); + fakeIn.write("#pragma message (VAR_NAME_VALUE(" + key.toLatin1() + "))\n"); + fakeIn.write("#endif\n"); + } + fakeIn.close(); + QProcess p; + QStringList args; + if (!flag.isEmpty()) + args.push_back(flag.toString()); + args.push_back(QDir::toNativeSeparators(filePath)); + p.start(compiler.absoluteFilePath(), args); + p.waitForFinished(3000); + fakeIn.remove(); + const QStringList lines = QString::fromUtf8(p.readAllStandardOutput()) + .split(QRegularExpression(QLatin1String("\\r?\\n"))); + return lines; +} + +static bool supportsWatcomPlatform(const QFileInfo &compiler, const Platform &platform) +{ + const auto macros = dumpMacros([&compiler, &platform]() { + const QList keys = {platform.keys.architecture, platform.keys.platform}; + return dumpOutput(compiler, platform.flag, keys); }); + + auto matches = [¯os](QStringView key) { + const auto k = key.toString(); + if (!macros.contains(k)) + return false; + return macros.value(k) == QLatin1String("1"); + }; + + return matches(platform.keys.architecture) && matches(platform.keys.platform); +} + +static std::vector createWatcomProfileHelper(const ToolchainInstallInfo &info, + Settings *settings, + QStringView profileName = {}) +{ + const QFileInfo compiler = info.compilerPath; + std::vector profiles; + + for (const auto &knownPlatform : knownPlatforms) { + // Don't create a profile in case the compiler does + // not support the proposed architecture. + if (!supportsWatcomPlatform(compiler, knownPlatform)) + continue; + + QString fullProfilename; + if (profileName.isEmpty()) { + // Create a full profile name in case we is in auto-detecting mode. + if (!info.compilerVersion.isValid()) { + fullProfilename = QStringLiteral("watcom-unknown-%1-%2") + .arg(knownPlatform.target.platform) + .arg(knownPlatform.target.architecture); + } else { + const QString version= info.compilerVersion.toString(QLatin1Char('_'), + QLatin1Char('_')); + fullProfilename = QStringLiteral("watcom-%1-%2-%3") + .arg(version) + .arg(knownPlatform.target.platform) + .arg(knownPlatform.target.architecture); + } + } else { + // Append the detected actual architecture name to the proposed profile name. + fullProfilename = QStringLiteral("%1-%2-%3") + .arg(profileName) + .arg(knownPlatform.target.platform) + .arg(knownPlatform.target.architecture); + } + + Profile profile(fullProfilename, settings); + profile.setValue(QStringLiteral("cpp.toolchainInstallPath"), compiler.absolutePath()); + profile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("watcom")); + profile.setValue(QStringLiteral("qbs.architecture"), + knownPlatform.target.architecture.toString()); + profile.setValue(QStringLiteral("qbs.targetPlatform"), + knownPlatform.target.platform.toString()); + + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.") + .arg(profile.name(), compiler.absoluteFilePath()); + + profiles.push_back(std::move(profile)); + } + + return profiles; +} + +static Version dumpWatcomVersion(const QFileInfo &compiler) +{ + const QList keys = {u"__WATCOMC__", u"__WATCOM_CPLUSPLUS__"}; + const auto macros = dumpMacros([&compiler, &keys]() { + return dumpOutput(compiler, u"", keys); }); + for (const auto ¯o : macros) { + const int verCode = macro.toInt(); + return Version{(verCode - 1100) / 100, + (verCode / 10) % 10, + ((verCode % 10) > 0) ? (verCode % 10) : 0}; + } + qbsWarning() << Tr::tr("No __WATCOMC__ or __WATCOM_CPLUSPLUS__ tokens was found" + " in the compiler dump"); + return Version{}; +} + +static std::vector installedWatcomsFromPath() +{ + std::vector infos; + const auto compilerNames = knownWatcomCompilerNames(); + for (const QString &compilerName : compilerNames) { + const QFileInfo watcomPath(findExecutable( + HostOsInfo::appendExecutableSuffix(compilerName))); + if (!watcomPath.exists()) + continue; + const Version version = dumpWatcomVersion(watcomPath); + infos.push_back({watcomPath, version}); + } + std::sort(infos.begin(), infos.end()); + return infos; +} + +bool isWatcomCompiler(const QString &compilerName) +{ + return Internal::any_of(knownWatcomCompilerNames(), [compilerName](const QString &knownName) { + return compilerName.contains(knownName); + }); +} + +void createWatcomProfile(const QFileInfo &compiler, Settings *settings, QStringView profileName) +{ + const ToolchainInstallInfo info = {compiler, Version{}}; + createWatcomProfileHelper(info, settings, profileName); +} + +void watcomProbe(Settings *settings, std::vector &profiles) +{ + qbsInfo() << Tr::tr("Trying to detect WATCOM toolchains..."); + + const std::vector allInfos = installedWatcomsFromPath(); + if (allInfos.empty()) { + qbsInfo() << Tr::tr("No WATCOM toolchains found."); + return; + } + + for (const ToolchainInstallInfo &info : allInfos) { + const auto newProfiles = createWatcomProfileHelper(info, settings); + profiles.reserve(profiles.size() + int(newProfiles.size())); + std::copy(newProfiles.cbegin(), newProfiles.cend(), std::back_inserter(profiles)); + } +} diff --git a/src/app/qbs-setup-toolchains/watcomprobe.h b/src/app/qbs-setup-toolchains/watcomprobe.h new file mode 100644 index 00000000..ea010461 --- /dev/null +++ b/src/app/qbs-setup-toolchains/watcomprobe.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_WATCOMPROBE_H +#define QBS_SETUPTOOLCHAINS_WATCOMPROBE_H + +#include + +QT_BEGIN_NAMESPACE +class QFileInfo; +QT_END_NAMESPACE + +namespace qbs { +class Profile; +class Settings; +} // namespace qbs + +bool isWatcomCompiler(const QString &compilerName); +void createWatcomProfile( + const QFileInfo &compiler, qbs::Settings *settings, QStringView profileName); +void watcomProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs-setup-toolchains/xcodeprobe.cpp b/src/app/qbs-setup-toolchains/xcodeprobe.cpp new file mode 100644 index 00000000..bb246742 --- /dev/null +++ b/src/app/qbs-setup-toolchains/xcodeprobe.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probe.h" +#include "xcodeprobe.h" + +#include "../shared/logging/consolelogger.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +using namespace qbs; +using Internal::Tr; + +static const QString defaultDeveloperPath = + QStringLiteral("/Applications/Xcode.app/Contents/Developer"); +static const std::regex defaultDeveloperPathRegex( + "^/Applications/Xcode([a-zA-Z0-9 ._-]+)\\.app/Contents/Developer$"); + +static QString targetOS(const QString &applePlatformName) +{ + if (applePlatformName == QStringLiteral("macosx")) + return QStringLiteral("macos"); + if (applePlatformName == QStringLiteral("iphoneos")) + return QStringLiteral("ios"); + if (applePlatformName == QStringLiteral("iphonesimulator")) + return QStringLiteral("ios-simulator"); + if (applePlatformName == QStringLiteral("appletvos")) + return QStringLiteral("tvos"); + if (applePlatformName == QStringLiteral("appletvsimulator")) + return QStringLiteral("tvos-simulator"); + if (applePlatformName == QStringLiteral("watchos")) + return QStringLiteral("watchos"); + if (applePlatformName == QStringLiteral("watchsimulator")) + return QStringLiteral("watchos-simulator"); + return {}; +} + +static QStringList archList(const QString &applePlatformName) +{ + QStringList archs; + if (applePlatformName == QStringLiteral("macosx") + || applePlatformName == QStringLiteral("iphonesimulator") + || applePlatformName == QStringLiteral("appletvsimulator") + || applePlatformName == QStringLiteral("watchsimulator")) { + if (applePlatformName != QStringLiteral("appletvsimulator")) + archs << QStringLiteral("x86"); + if (applePlatformName != QStringLiteral("watchsimulator")) + archs << QStringLiteral("x86_64"); + if (applePlatformName == QStringLiteral("macosx")) + archs << QStringLiteral("arm64"); + } else if (applePlatformName == QStringLiteral("iphoneos") + || applePlatformName == QStringLiteral("appletvos")) { + if (applePlatformName != QStringLiteral("appletvos")) + archs << QStringLiteral("armv7a"); + archs << QStringLiteral("arm64"); + } else if (applePlatformName == QStringLiteral("watchos")) { + archs << QStringLiteral("armv7k"); + } + + return archs; +} + +namespace { +class XcodeProbe +{ +public: + XcodeProbe(qbs::Settings *settings, std::vector &profiles) + : settings(settings), profiles(profiles) + { } + + bool addDeveloperPath(const QString &path); + void detectDeveloperPaths(); + void setupDefaultToolchains(const QString &devPath, const QString &xCodeName); + void detectAll(); +private: + qbs::Settings *settings; + std::vector &profiles; + QStringList developerPaths; +}; + +bool XcodeProbe::addDeveloperPath(const QString &path) +{ + if (path.isEmpty()) + return false; + QFileInfo pInfo(path); + if (!pInfo.exists() || !pInfo.isDir()) + return false; + if (developerPaths.contains(path)) + return false; + developerPaths.push_back(path); + qbsInfo() << Tr::tr("Added developer path %1").arg(path); + return true; +} + +void XcodeProbe::detectDeveloperPaths() +{ + QProcess selectedXcode; + QString program = QStringLiteral("/usr/bin/xcode-select"); + QStringList arguments(QStringLiteral("--print-path")); + selectedXcode.start(program, arguments, QProcess::ReadOnly); + if (!selectedXcode.waitForFinished(-1) || selectedXcode.exitCode()) { + qbsInfo() << Tr::tr("Could not detect selected Xcode with /usr/bin/xcode-select"); + } else { + QString path = QString::fromLocal8Bit(selectedXcode.readAllStandardOutput()); + addDeveloperPath(path); + } + addDeveloperPath(defaultDeveloperPath); + + QProcess launchServices; + program = QStringLiteral("/usr/bin/mdfind"); + arguments = QStringList(QStringLiteral("kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'")); + launchServices.start(program, arguments, QProcess::ReadOnly); + if (!launchServices.waitForFinished(-1) || launchServices.exitCode()) { + qbsInfo() << Tr::tr("Could not detect additional Xcode installations with /usr/bin/mdfind"); + } else { + const auto paths = QString::fromLocal8Bit(launchServices.readAllStandardOutput()) + .split(QLatin1Char('\n'), QBS_SKIP_EMPTY_PARTS); + for (const QString &path : paths) + addDeveloperPath(path + QStringLiteral("/Contents/Developer")); + } +} + +void XcodeProbe::setupDefaultToolchains(const QString &devPath, const QString &xcodeName) +{ + qbsInfo() << Tr::tr("Profile '%1' created for '%2'.").arg(xcodeName, devPath); + + Profile installationProfile(xcodeName, settings); + installationProfile.removeProfile(); + installationProfile.setValue(QStringLiteral("qbs.toolchainType"), QStringLiteral("xcode")); + if (devPath != defaultDeveloperPath) + installationProfile.setValue(QStringLiteral("xcode.developerPath"), devPath); + profiles.push_back(installationProfile); + + QStringList platforms; + platforms << QStringLiteral("macosx") + << QStringLiteral("iphoneos") + << QStringLiteral("iphonesimulator") + << QStringLiteral("appletvos") + << QStringLiteral("appletvsimulator") + << QStringLiteral("watchos") + << QStringLiteral("watchsimulator"); + for (const QString &platform : qAsConst(platforms)) { + Profile platformProfile(xcodeName + QLatin1Char('-') + platform, settings); + platformProfile.removeProfile(); + platformProfile.setBaseProfile(installationProfile.name()); + platformProfile.setValue(QStringLiteral("qbs.targetPlatform"), targetOS(platform)); + profiles.push_back(platformProfile); + + const auto architectures = archList(platform); + for (const QString &arch : architectures) { + Profile archProfile(xcodeName + QLatin1Char('-') + platform + QLatin1Char('-') + arch, + settings); + archProfile.removeProfile(); + archProfile.setBaseProfile(platformProfile.name()); + archProfile.setValue(QStringLiteral("qbs.architecture"), + qbs::canonicalArchitecture(arch)); + profiles.push_back(archProfile); + } + } +} + +void XcodeProbe::detectAll() +{ + int i = 1; + detectDeveloperPaths(); + for (const QString &developerPath : qAsConst(developerPaths)) { + QString profileName = QStringLiteral("xcode"); + if (developerPath != defaultDeveloperPath) { + const auto devPath = developerPath.toStdString(); + std::smatch match; + if (std::regex_match(devPath, match, defaultDeveloperPathRegex)) + profileName += QString::fromStdString(match[1]).toLower(). + replace(QLatin1Char(' '), QLatin1Char('-')). + replace(QLatin1Char('.'), QLatin1Char('_')); + else + profileName += QString::number(i++); + } + setupDefaultToolchains(developerPath, profileName); + } +} +} // end anonymous namespace + +void xcodeProbe(qbs::Settings *settings, std::vector &profiles) +{ + XcodeProbe probe(settings, profiles); + probe.detectAll(); +} diff --git a/src/app/qbs-setup-toolchains/xcodeprobe.h b/src/app/qbs-setup-toolchains/xcodeprobe.h new file mode 100644 index 00000000..fc15d177 --- /dev/null +++ b/src/app/qbs-setup-toolchains/xcodeprobe.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETUPTOOLCHAINS_XCODEPROBE_H +#define QBS_SETUPTOOLCHAINS_XCODEPROBE_H + +#include + +namespace qbs { +class Profile; +class Settings; +} + +void xcodeProbe(qbs::Settings *settings, std::vector &profiles); + +#endif // Header guard diff --git a/src/app/qbs/CMakeLists.txt b/src/app/qbs/CMakeLists.txt new file mode 100644 index 00000000..c190efcc --- /dev/null +++ b/src/app/qbs/CMakeLists.txt @@ -0,0 +1,50 @@ +set(SOURCES + application.cpp + application.h + commandlinefrontend.cpp + commandlinefrontend.h + consoleprogressobserver.cpp + consoleprogressobserver.h + ctrlchandler.cpp + ctrlchandler.h + main.cpp + qbstool.cpp + qbstool.h + session.cpp + session.h + sessionpacket.cpp + sessionpacket.h + sessionpacketreader.cpp + sessionpacketreader.h + status.cpp + status.h + stdinreader.cpp + stdinreader.h + ) + +set(PARSER_SOURCES + commandlineoption.cpp + commandlineoption.h + commandlineoptionpool.cpp + commandlineoptionpool.h + commandlineparser.cpp + commandlineparser.h + commandpool.cpp + commandpool.h + commandtype.h + parsercommand.cpp + parsercommand.h + ) +list_transform_prepend(PARSER_SOURCES parser/) + +add_qbs_app(qbs + DEFINES + "QBS_VERSION=\"${QBS_VERSION}\"" + "QBS_RELATIVE_LIBEXEC_PATH=\"${QBS_RELATIVE_LIBEXEC_PATH}\"" + "QBS_RELATIVE_SEARCH_PATH=\"${QBS_RELATIVE_SEARCH_PATH}\"" + "QBS_RELATIVE_PLUGINS_PATH=\"${QBS_RELATIVE_PLUGINS_PATH}\"" + DEPENDS qbscore qbsconsolelogger + SOURCES ${SOURCES} ${PARSER_SOURCES} + ) + +add_dependencies(qbs qbs_cpp_scanner qbs_qt_scanner) diff --git a/src/app/qbs/application.cpp b/src/app/qbs/application.cpp new file mode 100644 index 00000000..2e654324 --- /dev/null +++ b/src/app/qbs/application.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "application.h" + +#include "commandlinefrontend.h" +#include "ctrlchandler.h" + +namespace qbs { + +Application::Application(int &argc, char **argv) + : QCoreApplication(argc, argv), m_clFrontend(nullptr), m_canceled(false) +{ + setApplicationName(QStringLiteral("qbs")); + setOrganizationName(QStringLiteral("QtProject")); + setOrganizationDomain(QStringLiteral("qt-project.org")); +} + +Application *Application::instance() +{ + return qobject_cast(QCoreApplication::instance()); +} + +void Application::setCommandLineFrontend(CommandLineFrontend *clFrontend) +{ + installCtrlCHandler(); + m_clFrontend = clFrontend; +} + +/** + * Interrupt the application. This is directly called from a signal handler. + */ +void Application::userInterrupt() +{ + if (m_canceled) + return; + Q_ASSERT(m_clFrontend); + m_canceled = true; + m_clFrontend->cancel(); +} + +} // namespace qbs diff --git a/src/app/qbs/application.h b/src/app/qbs/application.h new file mode 100644 index 00000000..747c2f7e --- /dev/null +++ b/src/app/qbs/application.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef APPLICATION_H +#define APPLICATION_H + +#include + +namespace qbs { +class CommandLineFrontend; + +class Application : public QCoreApplication +{ + Q_OBJECT +public: + Application(int &argc, char **argv); + + static Application *instance(); + + void setCommandLineFrontend(CommandLineFrontend *clFrontend); + void userInterrupt(); + +private: + CommandLineFrontend *m_clFrontend; + bool m_canceled; +}; + +} // namespace qbs + +#endif // APPLICATION_H diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp new file mode 100644 index 00000000..489be4ed --- /dev/null +++ b/src/app/qbs/commandlinefrontend.cpp @@ -0,0 +1,704 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlinefrontend.h" + +#include "application.h" +#include "consoleprogressobserver.h" +#include "session.h" +#include "status.h" +#include "parser/commandlineoption.h" +#include "../shared/logging/consolelogger.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace qbs { +using namespace Internal; + +CommandLineFrontend::CommandLineFrontend(const CommandLineParser &parser, Settings *settings, + QObject *parent) + : QObject(parent) + , m_parser(parser) + , m_settings(settings) + , m_observer(nullptr) + , m_cancelStatus(CancelStatusNone) + , m_cancelTimer(new QTimer(this)) +{ +} + +CommandLineFrontend::~CommandLineFrontend() +{ + m_cancelTimer->stop(); + delete m_observer; +} + +// Called from interrupt handler. Don't do anything non-trivial here. +void CommandLineFrontend::cancel() +{ + m_cancelStatus = CancelStatusRequested; +} + +void CommandLineFrontend::checkCancelStatus() +{ + switch (m_cancelStatus) { + case CancelStatusNone: + break; + case CancelStatusRequested: + m_cancelStatus = CancelStatusCanceling; + m_cancelTimer->stop(); + if (m_resolveJobs.empty() && m_buildJobs.empty()) + std::exit(EXIT_FAILURE); + for (AbstractJob * const job : qAsConst(m_resolveJobs)) + job->cancel(); + for (AbstractJob * const job : qAsConst(m_buildJobs)) + job->cancel(); + break; + case CancelStatusCanceling: + QBS_ASSERT(false, return); + break; + } +} + +void CommandLineFrontend::start() +{ + try { + switch (m_parser.command()) { + case RunCommandType: + case ShellCommandType: + if (m_parser.products().size() > 1) { + throw ErrorInfo(Tr::tr("Invalid use of command '%1': Cannot use more than one " + "product.\nUsage: %2") + .arg(m_parser.commandName(), m_parser.commandDescription())); + } + Q_FALLTHROUGH(); + case StatusCommandType: + case InstallCommandType: + case DumpNodesTreeCommandType: + case ListProductsCommandType: + if (m_parser.buildConfigurations().size() > 1) { + QString error = Tr::tr("Invalid use of command '%1': There can be only one " + "build configuration.\n").arg(m_parser.commandName()); + error += Tr::tr("Usage: %1").arg(m_parser.commandDescription()); + throw ErrorInfo(error); + } + break; + case SessionCommandType: { + startSession(); + return; + } + default: + break; + } + + if (m_parser.showVersion()) { + std::puts(QBS_VERSION); + qApp->exit(EXIT_SUCCESS); + return; + } + if (m_parser.showProgress()) + m_observer = new ConsoleProgressObserver; + SetupProjectParameters params; + params.setEnvironment(QProcessEnvironment::systemEnvironment()); + params.setProjectFilePath(m_parser.projectFilePath()); + params.setDryRun(m_parser.dryRun()); + params.setForceProbeExecution(m_parser.forceProbesExecution()); + params.setWaitLockBuildGraph(m_parser.waitLockBuildGraph()); + params.setFallbackProviderEnabled(!m_parser.disableFallbackProvider()); + params.setLogElapsedTime(m_parser.logTime()); + params.setSettingsDirectory(m_settings->baseDirectory()); + params.setOverrideBuildGraphData(m_parser.command() == ResolveCommandType); + params.setPropertyCheckingMode(ErrorHandlingMode::Strict); + if (!m_parser.buildBeforeInstalling() || !m_parser.commandCanResolve()) + params.setRestoreBehavior(SetupProjectParameters::RestoreOnly); + const auto buildConfigs = m_parser.buildConfigurations(); + for (const QVariantMap &buildConfig : buildConfigs) { + QVariantMap userConfig = buildConfig; + const QString configurationKey = QStringLiteral("qbs.configurationName"); + const QString profileKey = QStringLiteral("qbs.profile"); + const QString installRootKey = QStringLiteral("qbs.installRoot"); + QString installRoot = userConfig.value(installRootKey).toString(); + if (!installRoot.isEmpty() && QFileInfo(installRoot).isRelative()) { + installRoot.prepend(QLatin1Char('/')).prepend(QDir::currentPath()); + userConfig.insert(installRootKey, installRoot); + } + const QString configurationName = userConfig.take(configurationKey).toString(); + const QString profileName = userConfig.take(profileKey).toString(); + const Preferences prefs(m_settings); + params.setSearchPaths(prefs.searchPaths(QDir::cleanPath(QCoreApplication::applicationDirPath() + + QLatin1String("/" QBS_RELATIVE_SEARCH_PATH)))); + params.setPluginPaths(prefs.pluginPaths(QDir::cleanPath(QCoreApplication::applicationDirPath() + + QLatin1String("/" QBS_RELATIVE_PLUGINS_PATH)))); + params.setLibexecPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + + QLatin1String("/" QBS_RELATIVE_LIBEXEC_PATH))); + params.setTopLevelProfile(profileName); + params.setConfigurationName(configurationName); + params.setBuildRoot(buildDirectory(profileName)); + params.setOverriddenValues(userConfig); + SetupProjectJob * const job = Project().setupProject(params, + ConsoleLogger::instance().logSink(), this); + connectJob(job); + m_resolveJobs.push_back(job); + } + + /* + * Progress reporting on the terminal gets a bit tricky when resolving several projects + * concurrently, since we cannot show multiple progress bars at the same time. Instead, + * we just set the total effort to the number of projects and increase the progress + * every time one of them finishes, ignoring the progress reports from the jobs themselves. + * (Yes, that does mean it will take disproportionately long for the first progress + * notification to arrive.) + */ + if (m_parser.showProgress() && resolvingMultipleProjects()) + m_observer->initialize(tr("Setting up projects"), m_resolveJobs.size()); + + // Check every two seconds whether we received a cancel request. This value has been + // experimentally found to be acceptable. + // Note that this polling approach is not problematic here, since we are doing work anyway, + // so there's no danger of waking up the processor for no reason. + connect(m_cancelTimer, &QTimer::timeout, this, &CommandLineFrontend::checkCancelStatus); + m_cancelTimer->start(2000); + } catch (const ErrorInfo &error) { + qbsError() << error.toString(); + if (m_buildJobs.empty() && m_resolveJobs.empty()) { + qApp->exit(EXIT_FAILURE); + } else { + cancel(); + checkCancelStatus(); + } + } +} + +void CommandLineFrontend::handleCommandDescriptionReport(const QString &highlight, + const QString &message) +{ + qbsInfo() << MessageTag(highlight) << message; +} + +void CommandLineFrontend::handleJobFinished(bool success, AbstractJob *job) +{ + try { + job->deleteLater(); + if (!success) { + qbsError() << job->error().toString(); + m_resolveJobs.removeOne(job); + m_buildJobs.removeOne(job); + if (m_resolveJobs.empty() && m_buildJobs.empty()) { + qApp->exit(EXIT_FAILURE); + return; + } + cancel(); + } else if (const auto setupJob = qobject_cast(job)) { + m_resolveJobs.removeOne(job); + m_projects.push_back(setupJob->project()); + if (m_observer && resolvingMultipleProjects()) + m_observer->incrementProgressValue(); + if (m_resolveJobs.empty()) + handleProjectsResolved(); + } else if (qobject_cast(job)) { + if (m_parser.command() == RunCommandType) + qApp->exit(runTarget()); + else + qApp->quit(); + } else { // Build or clean. + m_buildJobs.removeOne(job); + if (m_buildJobs.empty()) { + switch (m_parser.command()) { + case RunCommandType: + case InstallCommandType: + install(); + break; + case GenerateCommandType: + generate(); + // fall through + case BuildCommandType: + case CleanCommandType: + qApp->exit(m_cancelStatus == CancelStatusNone ? EXIT_SUCCESS : EXIT_FAILURE); + break; + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Missing case in switch statement"); + } + } + } + } catch (const ErrorInfo &error) { + qbsError() << error.toString(); + qApp->exit(EXIT_FAILURE); + } +} + +void CommandLineFrontend::handleNewTaskStarted(const QString &description, int totalEffort) +{ + // If the user does not want a progress bar, we just print the current activity. + if (!m_parser.showProgress()) { + if (!m_parser.logTime()) + qbsInfo() << description; + return; + } + if (isBuilding()) { + m_totalBuildEffort += totalEffort; + if (++m_buildEffortsRetrieved == m_buildEffortsNeeded) { + m_observer->initialize(tr("Building"), m_totalBuildEffort); + if (m_currentBuildEffort > 0) + m_observer->setProgressValue(m_currentBuildEffort); + } + } else if (!resolvingMultipleProjects()) { + m_observer->initialize(description, totalEffort); + } +} + +void CommandLineFrontend::handleTotalEffortChanged(int totalEffort) +{ + // Can only happen when resolving. + if (m_parser.showProgress() && !isBuilding() && !resolvingMultipleProjects()) + m_observer->setMaximum(totalEffort); +} + +void CommandLineFrontend::handleTaskProgress(int value, AbstractJob *job) +{ + if (isBuilding()) { + int ¤tJobEffort = m_buildEfforts[job]; + m_currentBuildEffort += value - currentJobEffort; + currentJobEffort = value; + if (m_buildEffortsRetrieved == m_buildEffortsNeeded) + m_observer->setProgressValue(m_currentBuildEffort); + } else if (!resolvingMultipleProjects()) { + m_observer->setProgressValue(value); + } +} + +void CommandLineFrontend::handleProcessResultReport(const qbs::ProcessResult &result) +{ + bool hasOutput = !result.stdOut().empty() || !result.stdErr().empty(); + if (!hasOutput && result.success()) + return; + + LogWriter w = result.success() ? qbsInfo() : qbsError(); + w << shellQuote(QDir::toNativeSeparators(result.executableFilePath()), result.arguments()) + << (hasOutput ? QStringLiteral("\n") : QString()) + << (result.stdOut().empty() ? QString() : result.stdOut().join(QLatin1Char('\n'))); + if (!result.stdErr().empty()) + w << result.stdErr().join(QLatin1Char('\n')) << MessageTag(QStringLiteral("stdErr")); +} + +bool CommandLineFrontend::resolvingMultipleProjects() const +{ + return isResolving() && m_resolveJobs.size() + m_projects.size() > 1; +} + +bool CommandLineFrontend::isResolving() const +{ + return !m_resolveJobs.empty(); +} + +bool CommandLineFrontend::isBuilding() const +{ + return !m_buildJobs.empty(); +} + +CommandLineFrontend::ProductMap CommandLineFrontend::productsToUse() const +{ + ProductMap products; + QStringList productNames; + const bool useAll = m_parser.products().empty(); + for (const Project &project : qAsConst(m_projects)) { + QList &productList = products[project]; + const ProjectData projectData = project.projectData(); + for (const ProductData &product : projectData.allProducts()) { + productNames << product.name(); + if (useAll || m_parser.products().contains(product.name())) { + productList.push_back(product); + } + } + } + + const auto parsedProductNames = m_parser.products(); + for (const QString &productName : parsedProductNames) { + if (!productNames.contains(productName)) { + QString msg; + if (productNames.size() <= 10) { + productNames.sort(); + const QString available = productNames.join(QLatin1String("', '")); + msg = Tr::tr("No such product '%1'. " + "Available products: '%2'").arg(productName, available); + } else { + msg = Tr::tr("No such product '%1'. Use 'list-products' to see " + "all available products.").arg(productName); + } + throw ErrorInfo(msg); + } + } + + return products; +} + +void CommandLineFrontend::handleProjectsResolved() +{ + if (m_cancelStatus != CancelStatusNone) + throw ErrorInfo(Tr::tr("Execution canceled.")); + switch (m_parser.command()) { + case ResolveCommandType: + qApp->quit(); + break; + case CleanCommandType: + makeClean(); + break; + case ShellCommandType: + qApp->exit(runShell()); + break; + case StatusCommandType: + qApp->exit(printStatus(m_projects.front().projectData())); + break; + case GenerateCommandType: + checkGeneratorName(); + Q_FALLTHROUGH(); + case BuildCommandType: + build(); + break; + case InstallCommandType: + case RunCommandType: + if (m_parser.buildBeforeInstalling()) + build(); + else + install(); + break; + case UpdateTimestampsCommandType: + updateTimestamps(); + qApp->quit(); + break; + case DumpNodesTreeCommandType: + dumpNodesTree(); + qApp->quit(); + break; + case ListProductsCommandType: + listProducts(); + qApp->quit(); + break; + case HelpCommandType: + case VersionCommandType: + case SessionCommandType: + Q_ASSERT_X(false, Q_FUNC_INFO, "Impossible."); + } +} + +void CommandLineFrontend::makeClean() +{ + if (m_parser.products().empty()) { + for (const Project &project : qAsConst(m_projects)) { + m_buildJobs << project.cleanAllProducts(m_parser.cleanOptions(project.profile()), this); + } + } else { + const ProductMap &products = productsToUse(); + for (ProductMap::ConstIterator it = products.begin(); it != products.end(); ++it) { + m_buildJobs.push_back(it.key().cleanSomeProducts( + it.value(), + m_parser.cleanOptions(it.key().profile()), + this)); + } + } + connectBuildJobs(); +} + +int CommandLineFrontend::runShell() +{ + ProductData productToRun; + switch (m_parser.products().size()) { + case 0: // No specific product, use project-global environment. + break; + case 1: + productToRun = productsToUse().values().front().front(); + break; + default: + throw ErrorInfo(Tr::tr("The command '%1' cannot take more than one product.")); + } + RunEnvironment runEnvironment = m_projects.front().getRunEnvironment(productToRun, + m_parser.installOptions(m_projects.front().profile()), + QProcessEnvironment::systemEnvironment(), QStringList(), m_settings); + return runEnvironment.doRunShell(); +} + +BuildOptions CommandLineFrontend::buildOptions(const Project &project) const +{ + BuildOptions options = m_parser.buildOptions(m_projects.front().profile()); + if (options.maxJobCount() <= 0) { + const QString profileName = project.profile(); + QBS_CHECK(!profileName.isEmpty()); + options.setMaxJobCount(Preferences(m_settings, profileName).jobs()); + } + return options; +} + +QString CommandLineFrontend::buildDirectory(const QString &profileName) const +{ + QString buildDir = m_parser.projectBuildDirectory(); + if (buildDir.isEmpty()) { + buildDir = Preferences(m_settings, profileName).defaultBuildDirectory(); + if (buildDir.isEmpty()) { + qbsDebug() << "No project build directory given; using current directory."; + buildDir = QDir::currentPath(); + } else { + qbsDebug() << "No project build directory given; using directory from preferences."; + } + } + + QString projectName(QFileInfo(m_parser.projectFilePath()).baseName()); + buildDir.replace(BuildDirectoryOption::magicProjectString(), projectName); + QString projectDir(QFileInfo(m_parser.projectFilePath()).path()); + buildDir.replace(BuildDirectoryOption::magicProjectDirString(), projectDir); + if (!QFileInfo(buildDir).isAbsolute()) + buildDir = QDir::currentPath() + QLatin1Char('/') + buildDir; + buildDir = QDir::cleanPath(buildDir); + return buildDir; +} + +void CommandLineFrontend::build() +{ + if (m_parser.products().empty()) { + const Project::ProductSelection productSelection = m_parser.withNonDefaultProducts() + ? Project::ProductSelectionWithNonDefault : Project::ProductSelectionDefaultOnly; + for (const Project &project : qAsConst(m_projects)) + m_buildJobs << project.buildAllProducts(buildOptions(project), productSelection, this); + } else { + const ProductMap &products = productsToUse(); + for (ProductMap::ConstIterator it = products.begin(); it != products.end(); ++it) + m_buildJobs.push_back(it.key().buildSomeProducts(it.value(), + buildOptions(it.key()), this)); + } + connectBuildJobs(); + + /* + * Progress reporting for the build jobs works as follows: We know that for every job, + * the newTaskStarted() signal is emitted exactly once (unless there's an error). So we add up + * the respective total efforts as they come in. Once all jobs have reported their total + * efforts, we can start the overall progress report. + */ + m_buildEffortsNeeded = m_buildJobs.size(); + m_buildEffortsRetrieved = 0; + m_totalBuildEffort = 0; + m_currentBuildEffort = 0; +} + +void CommandLineFrontend::checkGeneratorName() +{ + const QString generatorName = m_parser.generateOptions().generatorName(); + m_generator = ProjectGeneratorManager::findGenerator(generatorName); + if (m_generator) + return; + const auto generatorNames = ProjectGeneratorManager::loadedGeneratorNames(); + if (!generatorNames.empty()) { + const QString generatorNamesString = generatorNames.join(QLatin1String("\n\t")); + if (!generatorName.isEmpty()) { + throw ErrorInfo(Tr::tr("No generator named '%1'. Available generators:\n\t%2") + .arg(generatorName, generatorNamesString)); + } + + throw ErrorInfo(Tr::tr("No generator specified. Available generators:\n\t%1") + .arg(generatorNamesString)); + } + + throw ErrorInfo(Tr::tr("No generator specified or no generators are available.")); +} + +void CommandLineFrontend::generate() +{ + QBS_CHECK(!!m_generator); + const ErrorInfo error = m_generator->generate(m_projects, + m_parser.buildConfigurations(), + m_parser.installOptions(QString()), + m_parser.settingsDir(), + ConsoleLogger::instance(m_settings)); + if (error.hasError()) + throw error; +} + +int CommandLineFrontend::runTarget() +{ + const ProductData productToRun = getTheOneRunnableProduct(); + const QString executableFilePath = productToRun.targetExecutable(); + if (executableFilePath.isEmpty()) { + throw ErrorInfo(Tr::tr("Cannot run: Product '%1' is not an application.") + .arg(productToRun.name())); + } + RunEnvironment runEnvironment = m_projects.front().getRunEnvironment(productToRun, + m_parser.installOptions(m_projects.front().profile()), + QProcessEnvironment::systemEnvironment(), m_parser.runEnvConfig(), m_settings); + return runEnvironment.doRunTarget(executableFilePath, m_parser.runArgs(), m_parser.dryRun()); +} + +void CommandLineFrontend::updateTimestamps() +{ + const ProductMap &products = productsToUse(); + for (ProductMap::ConstIterator it = products.constBegin(); it != products.constEnd(); ++it) { + Project p = it.key(); + p.updateTimestamps(it.value()); + } +} + +void CommandLineFrontend::dumpNodesTree() +{ + QFile stdOut; + stdOut.open(stdout, QIODevice::WriteOnly); + const ErrorInfo error = m_projects.front().dumpNodesTree(stdOut, productsToUse() + .value(m_projects.front())); + if (error.hasError()) + throw error; +} + +void CommandLineFrontend::listProducts() +{ + const QList products = productsToUse().constBegin().value(); + QStringList output; + for (const ProductData &p : products) { + QString productInfo = p.fullDisplayName(); + if (!p.isEnabled()) + productInfo.append(QLatin1Char(' ')).append(Tr::tr("[disabled]")); + else if (!p.properties().value(QStringLiteral("builtByDefault")).toBool()) + productInfo.append(QLatin1Char(' ')).append(Tr::tr("[not built by default]")); + output += productInfo; + } + output.sort(); + qbsInfo() << output.join(QLatin1Char('\n')); +} + +void CommandLineFrontend::connectBuildJobs() +{ + for (AbstractJob * const job : qAsConst(m_buildJobs)) + connectBuildJob(job); +} + +void CommandLineFrontend::connectBuildJob(AbstractJob *job) +{ + connectJob(job); + + const auto bjob = qobject_cast(job); + if (!bjob) + return; + + connect(bjob, &BuildJob::reportCommandDescription, + this, &CommandLineFrontend::handleCommandDescriptionReport); + connect(bjob, &BuildJob::reportProcessResult, + this, &CommandLineFrontend::handleProcessResultReport); +} + +void CommandLineFrontend::connectJob(AbstractJob *job) +{ + connect(job, &AbstractJob::finished, + this, &CommandLineFrontend::handleJobFinished); + connect(job, &AbstractJob::taskStarted, + this, &CommandLineFrontend::handleNewTaskStarted); + connect(job, &AbstractJob::totalEffortChanged, + this, &CommandLineFrontend::handleTotalEffortChanged); + if (m_parser.showProgress()) { + connect(job, &AbstractJob::taskProgress, + this, &CommandLineFrontend::handleTaskProgress); + } +} + +ProductData CommandLineFrontend::getTheOneRunnableProduct() +{ + QBS_CHECK(m_projects.size() == 1); // Has been checked earlier. + + if (m_parser.products().size() == 1) { + for (const ProductData &p : m_projects.front().projectData().allProducts()) { + if (p.name() == m_parser.products().constFirst()) + return p; + } + QBS_CHECK(false); + } + QBS_CHECK(m_parser.products().isEmpty()); + + QList runnableProducts; + for (const ProductData &p : m_projects.front().projectData().allProducts()) { + if (p.isRunnable()) + runnableProducts.push_back(p); + } + + if (runnableProducts.size() == 1) + return runnableProducts.front(); + + if (runnableProducts.empty()) { + throw ErrorInfo(Tr::tr("Cannot execute command '%1': Project has no runnable product.") + .arg(m_parser.commandName())); + } + + ErrorInfo error(Tr::tr("Ambiguous use of command '%1': No product given, but project " + "has more than one runnable product.").arg(m_parser.commandName())); + error.append(Tr::tr("Use the '--products' option with one of the following products:")); + for (const ProductData &p : qAsConst(runnableProducts)) { + QString productRepr = QLatin1String("\t") + p.name(); + if (p.profile() != m_projects.front().profile()) { + productRepr.append(QLatin1String(" [")).append(p.profile()) + .append(QLatin1Char(']')); + } + error.append(productRepr); + } + throw error; +} + +void CommandLineFrontend::install() +{ + Q_ASSERT(m_projects.size() == 1); + const Project project = m_projects.front(); + InstallJob *installJob; + if (m_parser.products().empty()) { + const Project::ProductSelection productSelection = m_parser.withNonDefaultProducts() + ? Project::ProductSelectionWithNonDefault : Project::ProductSelectionDefaultOnly; + installJob = project.installAllProducts(m_parser.installOptions(project.profile()), + productSelection); + } else { + const Project project = m_projects.front(); + const ProductMap products = productsToUse(); + installJob = project.installSomeProducts(products.value(project), + m_parser.installOptions(project.profile())); + } + connectJob(installJob); +} + +} // namespace qbs diff --git a/src/app/qbs/commandlinefrontend.h b/src/app/qbs/commandlinefrontend.h new file mode 100644 index 00000000..5f598cb3 --- /dev/null +++ b/src/app/qbs/commandlinefrontend.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef COMMANDLINEFRONTEND_H +#define COMMANDLINEFRONTEND_H + +#include "parser/commandlineparser.h" +#include +#include + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE + +namespace qbs { +class AbstractJob; +class ConsoleProgressObserver; +class ErrorInfo; +class ProcessResult; +class ProjectGenerator; +class Settings; + +class CommandLineFrontend : public QObject +{ + Q_OBJECT +public: + explicit CommandLineFrontend(const CommandLineParser &parser, Settings *settings, + QObject *parent = nullptr); + ~CommandLineFrontend() override; + + void cancel(); + void start(); + +private: + void handleCommandDescriptionReport(const QString &highlight, const QString &message); + void handleJobFinished(bool success, qbs::AbstractJob *job); + void handleNewTaskStarted(const QString &description, int totalEffort); + void handleTotalEffortChanged(int totalEffort); + void handleTaskProgress(int value, qbs::AbstractJob *job); + void handleProcessResultReport(const qbs::ProcessResult &result); + void checkCancelStatus(); + + using ProductMap = QHash>; + ProductMap productsToUse() const; + + bool resolvingMultipleProjects() const; + bool isResolving() const; + bool isBuilding() const; + void handleProjectsResolved(); + void makeClean(); + int runShell(); + void build(); + void checkGeneratorName(); + void generate(); + int runTarget(); + void updateTimestamps(); + void dumpNodesTree(); + void listProducts(); + void connectBuildJobs(); + void connectBuildJob(AbstractJob *job); + void connectJob(AbstractJob *job); + ProductData getTheOneRunnableProduct(); + void install(); + BuildOptions buildOptions(const Project &project) const; + QString buildDirectory(const QString &profileName) const; + + const CommandLineParser &m_parser; + Settings * const m_settings; + QList m_resolveJobs; + QList m_buildJobs; + QList m_projects; + + ConsoleProgressObserver *m_observer = nullptr; + + enum CancelStatus { CancelStatusNone, CancelStatusRequested, CancelStatusCanceling }; + CancelStatus m_cancelStatus = CancelStatus::CancelStatusNone; + QTimer * const m_cancelTimer; + + int m_buildEffortsNeeded = 0; + int m_buildEffortsRetrieved = 0; + int m_totalBuildEffort = 0; + int m_currentBuildEffort = 0; + QHash m_buildEfforts; + std::shared_ptr m_generator; +}; + +} // namespace qbs + +#endif // COMMANDLINEFRONTEND_H diff --git a/src/app/qbs/consoleprogressobserver.cpp b/src/app/qbs/consoleprogressobserver.cpp new file mode 100644 index 00000000..e6ab9db7 --- /dev/null +++ b/src/app/qbs/consoleprogressobserver.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "consoleprogressobserver.h" + +#include +#include + +#include + +namespace qbs { + +void ConsoleProgressObserver::initialize(const QString &task, int max) +{ + m_maximum = max; + m_value = 0; + m_percentage = 0; + m_hashesPrinted = 0; + std::cout << task.toLocal8Bit().constData() << ": 0%" << std::flush; + setMaximum(max); +} + +void ConsoleProgressObserver::setMaximum(int maximum) +{ + m_maximum = maximum; + if (maximum == 0) { + m_percentage = 100; + updateProgressBarIfNecessary(); + writePercentageString(); + std::cout << std::endl; + } +} + +void ConsoleProgressObserver::setProgressValue(int value) +{ + if (value > m_maximum || value <= m_value) + return; // TODO: Should be an assertion, but the executor currently breaks it. + m_value = value; + const int newPercentage = (100 * m_value) / m_maximum; + if (newPercentage == m_percentage) + return; + eraseCurrentPercentageString(); + m_percentage = newPercentage; + updateProgressBarIfNecessary(); + writePercentageString(); + if (m_value == m_maximum) + std::cout << std::endl; + else + std::cout << std::flush; +} + +void ConsoleProgressObserver::eraseCurrentPercentageString() +{ + const int charsToErase = m_percentage == 0 ? 2 : m_percentage < 10 ? 3 : 4; + const QByteArray backspaceCommand(charsToErase, '\b'); + + // Move cursor before the old percentage string. + std::cout << backspaceCommand.constData(); + + // Erase old percentage string. + std::cout << QByteArray(charsToErase, ' ').constData(); + + // Move cursor before the erased string. + std::cout << backspaceCommand.constData(); +} + +void ConsoleProgressObserver::updateProgressBarIfNecessary() +{ + static const int TotalHashCount = 50; // Should fit on most terminals without a line break. + const int hashesNeeded = (m_percentage * TotalHashCount) / 100; + if (m_hashesPrinted < hashesNeeded) { + std::cout << QByteArray(hashesNeeded - m_hashesPrinted, '#').constData(); + m_hashesPrinted = hashesNeeded; + } +} + +void ConsoleProgressObserver::writePercentageString() +{ + std::cout << QStringLiteral(" %1%").arg(m_percentage).toLocal8Bit().constData(); +} + +} // namespace qbs diff --git a/src/app/qbs/consoleprogressobserver.h b/src/app/qbs/consoleprogressobserver.h new file mode 100644 index 00000000..f14234ef --- /dev/null +++ b/src/app/qbs/consoleprogressobserver.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONSOLEPROGRESSOBSERVER_H +#define CONSOLEPROGRESSOBSERVER_H + +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { + +class ConsoleProgressObserver +{ +public: + void initialize(const QString &task, int max); + void setMaximum(int maximum); + void setProgressValue(int value); + void incrementProgressValue() { setProgressValue(m_value + 1); } + +private: + void eraseCurrentPercentageString(); + void updateProgressBarIfNecessary(); + void writePercentageString(); + + int m_maximum; + int m_value; + int m_percentage; + int m_hashesPrinted; +}; + +} // namespace qbs + +#endif // CONSOLEPROGRESSOBSERVER_H diff --git a/src/app/qbs/ctrlchandler.cpp b/src/app/qbs/ctrlchandler.cpp new file mode 100644 index 00000000..b2e293d1 --- /dev/null +++ b/src/app/qbs/ctrlchandler.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "application.h" + +static void cancel() +{ + qbs::Application * const app = qbs::Application::instance(); + if (app) + app->userInterrupt(); +} + +#if defined(Q_OS_WIN) && defined(Q_CC_MSVC) + +#include + +static BOOL WINAPI consoleCtrlHandlerRoutine(__in DWORD dwCtrlType) +{ + Q_UNUSED(dwCtrlType); + cancel(); + return TRUE; +} + +void installCtrlCHandler() +{ + SetConsoleCtrlHandler(&consoleCtrlHandlerRoutine, TRUE); +} + +#else + +#include + +static void sigIntHandler(int sig) +{ + Q_UNUSED(sig); + cancel(); +} + +void installCtrlCHandler() +{ + signal(SIGINT, sigIntHandler); +} + +#endif diff --git a/src/app/qbs/ctrlchandler.h b/src/app/qbs/ctrlchandler.h new file mode 100644 index 00000000..463b6f45 --- /dev/null +++ b/src/app/qbs/ctrlchandler.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CTRLCHANDLER_H +#define CTRLCHANDLER_H + +void installCtrlCHandler(); + +#endif // CTRLCHANDLER_H diff --git a/src/app/qbs/main.cpp b/src/app/qbs/main.cpp new file mode 100644 index 00000000..ca7c48a8 --- /dev/null +++ b/src/app/qbs/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "application.h" +#include "commandlinefrontend.h" +#include "qbstool.h" +#include "parser/commandlineparser.h" +#include "../shared/logging/consolelogger.h" + +#include + +#include +#include + +using namespace qbs; + +static bool tryToRunTool(const QStringList &arguments, int &exitCode) +{ + if (arguments.empty()) + return false; + QStringList toolArgs = arguments; + const QString toolName = toolArgs.takeFirst(); + if (toolName.startsWith(QLatin1Char('-'))) + return false; + return QbsTool::tryToRunTool(toolName, toolArgs, &exitCode); +} + +int main(int argc, char *argv[]) +{ + ConsoleLogger::instance(); + + try { + Application app(argc, argv); + QStringList arguments = app.arguments(); + arguments.removeFirst(); + + int toolExitCode = 0; + if (tryToRunTool(arguments, toolExitCode)) + return toolExitCode; + + CommandLineParser parser; + if (!parser.parseCommandLine(arguments)) + return EXIT_FAILURE; + + if (parser.command() == HelpCommandType) { + parser.printHelp(); + return 0; + } + + Settings settings(parser.settingsDir()); + ConsoleLogger::instance().setSettings(&settings); + CommandLineFrontend clFrontend(parser, &settings); + app.setCommandLineFrontend(&clFrontend); + QTimer::singleShot(0, &clFrontend, &CommandLineFrontend::start); + return app.exec(); + } catch (const ErrorInfo &error) { + qbsError() << error.toString(); + return EXIT_FAILURE; + } +} diff --git a/src/app/qbs/parser/commandlineoption.cpp b/src/app/qbs/parser/commandlineoption.cpp new file mode 100644 index 00000000..a09f36c2 --- /dev/null +++ b/src/app/qbs/parser/commandlineoption.cpp @@ -0,0 +1,701 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineoption.h" + +#include +#include +#include +#include +#include + +namespace qbs { +using namespace Internal; + +CommandLineOption::~CommandLineOption() = default; + +void CommandLineOption::parse(CommandType command, const QString &representation, QStringList &input) +{ + m_command = command; + doParse(representation, input); +} + +CommandLineOption::CommandLineOption() + : m_command(static_cast(-1)) +{ +} + +QString CommandLineOption::getArgument(const QString &representation, QStringList &input) +{ + if (input.empty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': Missing argument.\nUsage: %2") + .arg(representation, description(command()))); + } + return input.takeFirst(); +} + +QString FileOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2 \n" + "\tUse as the project file.\n" + "\tIf is a directory and it contains a single file ending in '.qbs',\n" + "\tthat file will be used.\n" + "\tIf this option is not given at all, behavior is the same as for '-f .'.\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString FileOption::shortRepresentation() const +{ + return QStringLiteral("-f"); +} + +QString FileOption::longRepresentation() const +{ + return QStringLiteral("--file"); +} + +void FileOption::doParse(const QString &representation, QStringList &input) +{ + m_projectFilePath = getArgument(representation, input); +} + +QString BuildDirectoryOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2 \n" + "\tBuild in the given directory. The default value is the current directory\n" + "\tunless preferences.defaultBuildDirectory is set.\n" + "\tRelative paths will be interpreted relative to the current directory.\n" + "\tIf the directory does not exist, it will be created. Use the following\n" + "\tspecial values as placeholders:\n" + "\t%3: name of the project file excluding the extension\n" + "\t%4: directory containing the project file\n") + .arg(longRepresentation(), shortRepresentation(), + magicProjectString(), magicProjectDirString()); +} + +QString BuildDirectoryOption::shortRepresentation() const +{ + return QStringLiteral("-d"); +} + +QString BuildDirectoryOption::longRepresentation() const +{ + return QStringLiteral("--build-directory"); +} + +QString BuildDirectoryOption::magicProjectString() +{ + return QStringLiteral("@project"); +} + +QString BuildDirectoryOption::magicProjectDirString() +{ + return QStringLiteral("@path"); +} + +void BuildDirectoryOption::doParse(const QString &representation, QStringList &input) +{ + m_projectBuildDirectory = getArgument(representation, input); +} + +QString GeneratorOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2 \n" + "\tUse the given build system generator.\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString GeneratorOption::shortRepresentation() const +{ + return QStringLiteral("-g"); +} + +QString GeneratorOption::longRepresentation() const +{ + return QStringLiteral("--generator"); +} + +void GeneratorOption::doParse(const QString &representation, QStringList &input) +{ + m_generatorName = getArgument(representation, input); + if (m_generatorName.isEmpty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': No generator given.\nUsage: %2") + .arg(representation, description(command()))); + } +} + +static QString loglevelLongRepresentation() { return QStringLiteral("--log-level"); } + +QString VerboseOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2\n" + "\tBe more verbose. Increases the log level by one.\n" + "\tThis option can be given more than once.\n" + "\tExcessive occurrences have no effect.\n" + "\tIf option '%3' appears anywhere on the command line in addition\n" + "\tto this option, its value is taken as the base which to increase.\n") + .arg(longRepresentation(), shortRepresentation(), loglevelLongRepresentation()); +} + +QString VerboseOption::shortRepresentation() const +{ + return QStringLiteral("-v"); +} + +QString VerboseOption::longRepresentation() const +{ + return QStringLiteral("--more-verbose"); +} + +QString QuietOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2\n" + "\tBe more quiet. Decreases the log level by one.\n" + "\tThis option can be given more than once.\n" + "\tExcessive occurrences have no effect.\n" + "\tIf option '%3' appears anywhere on the command line in addition\n" + "\tto this option, its value is taken as the base which to decrease.\n") + .arg(longRepresentation(), shortRepresentation(), loglevelLongRepresentation()); +} + +QString QuietOption::shortRepresentation() const +{ + return QStringLiteral("-q"); +} + +QString QuietOption::longRepresentation() const +{ + return QStringLiteral("--less-verbose"); +} + +QString JobsOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2 \n" + "\tUse concurrent build jobs. must be an integer greater than zero.\n" + "\tThe default is the number of cores.\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString JobsOption::shortRepresentation() const +{ + return QStringLiteral("-j"); +} + +QString JobsOption::longRepresentation() const +{ + return QStringLiteral("--jobs"); +} + +void JobsOption::doParse(const QString &representation, QStringList &input) +{ + const QString jobCountString = getArgument(representation, input); + bool stringOk; + m_jobCount = jobCountString.toInt(&stringOk); + if (!stringOk || m_jobCount <= 0) + throw ErrorInfo(Tr::tr("Invalid use of option '%1': Illegal job count '%2'.\nUsage: %3") + .arg(representation, jobCountString, description(command()))); +} + +QString KeepGoingOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2\n" + "\tKeep going when errors occur (if at all possible).\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString KeepGoingOption::shortRepresentation() const +{ + return QStringLiteral("-k"); +} + +QString KeepGoingOption::longRepresentation() const +{ + return QStringLiteral("--keep-going"); +} + +QString DryRunOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2\n" + "\tDry run. No commands will be executed and no permanent changes to the\n" + "\tbuild graph will be done.\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString DryRunOption::shortRepresentation() const +{ + return QStringLiteral("-n"); +} + +QString DryRunOption::longRepresentation() const +{ + return QStringLiteral("--dry-run"); +} + +QString ForceProbesOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n" + "\tForce re-execution of all Probe items' configure scripts, rather than using the\n" + "\tcached data.\n") + .arg(longRepresentation()); +} + +QString ForceProbesOption::longRepresentation() const +{ + return QStringLiteral("--force-probe-execution"); +} + +QString NoInstallOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n" + "\tDo not install any artifacts as part of the build process.\n") + .arg(longRepresentation()); +} + +QString NoInstallOption::longRepresentation() const +{ + return QStringLiteral("--no-install"); +} + + +static QString logTimeRepresentation() +{ + return QStringLiteral("--log-time"); +} + +QString ShowProgressOption::description(CommandType command) const +{ + Q_UNUSED(command); + QString desc = Tr::tr("%1\n" + "\tShow a progress bar. Implies '%2=%3'.\n").arg(longRepresentation(), + loglevelLongRepresentation(), logLevelName(LoggerMinLevel)); + return desc += Tr::tr("\tThis option is mutually exclusive with '%1'.\n") + .arg(logTimeRepresentation()); +} + +static QString showProgressRepresentation() +{ + return QStringLiteral("--show-progress"); +} + +QString ShowProgressOption::longRepresentation() const +{ + return showProgressRepresentation(); +} + +void StringListOption::doParse(const QString &representation, QStringList &input) +{ + m_arguments = getArgument(representation, input).split(QLatin1Char(',')); + if (m_arguments.empty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': Argument list must not be empty.\n" + "Usage: %2").arg(representation, description(command()))); + } + for (const QString &element : qAsConst(m_arguments)) { + if (element.isEmpty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': Argument list must not contain " + "empty elements.\nUsage: %2") + .arg(representation, description(command()))); + } + } +} + +QString ChangedFilesOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 [,...]\n" + "\tAssume these and only these files have changed.\n").arg(longRepresentation()); +} + +QString ChangedFilesOption::longRepresentation() const +{ + return QStringLiteral("--changed-files"); +} + +QString ProductsOption::description(CommandType command) const +{ + const QString prefix = Tr::tr("%1|%2").arg(longRepresentation(), shortRepresentation()); + switch (command) { + case InstallCommandType: + case RunCommandType: + case ShellCommandType: + return Tr::tr("%1 \n\tUse the specified product.\n").arg(prefix); + default: + return Tr::tr("%1 [,...]\n" + "\tTake only the specified products into account.\n").arg(prefix); + } +} + +QString ProductsOption::shortRepresentation() const +{ + return QStringLiteral("-p"); +} + +QString ProductsOption::longRepresentation() const +{ + return QStringLiteral("--products"); +} + +static QStringList allLogLevelStrings() +{ + QStringList result; + for (int i = static_cast(LoggerMinLevel); i <= static_cast(LoggerMaxLevel); ++i) + result << logLevelName(static_cast(i)); + return result; +} + +LogLevelOption::LogLevelOption() : m_logLevel(defaultLogLevel()) +{ +} + +QString LogLevelOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 \n" + "\tUse the specified log level.\n" + "\tPossible values are '%2'.\n" + "\tThe default is '%3'.\n").arg(longRepresentation(), + allLogLevelStrings().join(QLatin1String("', '")), logLevelName(defaultLogLevel())); +} + +QString LogLevelOption::longRepresentation() const +{ + return loglevelLongRepresentation(); +} + +void LogLevelOption::doParse(const QString &representation, QStringList &input) +{ + const QString levelString = getArgument(representation, input); + const QList levels = QList() << LoggerError << LoggerWarning + << LoggerInfo << LoggerDebug << LoggerTrace; + for (const LoggerLevel &l : levels) { + if (logLevelName(l) == levelString) { + m_logLevel = l; + return; + } + } + throw ErrorInfo(Tr::tr("Invalid use of option '%1': Unknown log level '%2'.\nUsage: %3") + .arg(representation, levelString, description(command()))); +} + +QString ForceTimeStampCheckOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tForce timestamp checks.\n" + "\tInstead of using the file timestamps that are stored in the build graph,\n" + "\tretrieve the timestamps from the file system.\n").arg(longRepresentation()); +} + +QString ForceTimeStampCheckOption::longRepresentation() const +{ + return QStringLiteral("--check-timestamps"); +} + +QString ForceOutputCheckOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tForce transformer output artifact checks.\n" + "\tVerify that the output artifacts declared by rules in the\n" + "\tproject are actually created.\n").arg(longRepresentation()); +} + +QString ForceOutputCheckOption::longRepresentation() const +{ + return QStringLiteral("--check-outputs"); +} + +QString BuildNonDefaultOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tBuild all products, even if their builtByDefault property is false.\n") + .arg(longRepresentation()); +} + +QString BuildNonDefaultOption::longRepresentation() const +{ + return QStringLiteral("--all-products"); +} + + +InstallRootOption::InstallRootOption() : m_useSysroot(false) +{ +} + +static QString magicSysrootString() { return QStringLiteral("@sysroot"); } + +QString InstallRootOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 \n" + "\tInstall into the given directory.\n" + "\tThe default value is '/%2'.\n" + "\tIf the directory does not exist, it will be created. Use the special\n" + "\tvalue '%3' to install into the sysroot (i.e. the value of the\n" + "\tproperty qbs.sysroot).\n") + .arg(longRepresentation(), InstallOptions::defaultInstallRoot(), magicSysrootString()); +} + +QString InstallRootOption::longRepresentation() const +{ + return QStringLiteral("--install-root"); +} + +void InstallRootOption::doParse(const QString &representation, QStringList &input) +{ + if (input.empty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1: Argument expected.\n" + "Usage: %2").arg(representation, description(command()))); + } + const QString installRoot = input.takeFirst(); + if (installRoot == magicSysrootString()) + m_useSysroot = true; + else + m_installRoot = installRoot; +} + +QString RemoveFirstOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tRemove the installation base directory before installing.\n") + .arg(longRepresentation()); +} + +QString RemoveFirstOption::longRepresentation() const +{ + return QStringLiteral("--clean-install-root"); +} + + +QString NoBuildOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tDo not build before installing.\n") + .arg(longRepresentation()); +} + +QString NoBuildOption::longRepresentation() const +{ + return QStringLiteral("--no-build"); +} + + +QString LogTimeOption::description(CommandType command) const +{ + Q_UNUSED(command); + QString desc = Tr::tr("%1\n\tLog the time that the operations involved in this command take.\n") + .arg(longRepresentation()); + desc += Tr::tr("\tThis option is implied in log levels '%1' and higher.\n") + .arg(logLevelName(LoggerDebug)); + return desc += Tr::tr("\tThis option is mutually exclusive with '%1'.\n") + .arg(showProgressRepresentation()); +} + +QString LogTimeOption::shortRepresentation() const +{ + return QStringLiteral("-t"); +} + +QString LogTimeOption::longRepresentation() const +{ + return logTimeRepresentation(); +} + + +SettingsDirOption::SettingsDirOption() = default; + +QString SettingsDirOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 \n" + "\tRead all settings (such as profile information) from the given directory.\n" + "\tThe default value is system-specific (see the QSettings documentation).\n" + "\tIf the directory does not exist, it will be created.\n") + .arg(longRepresentation()); +} + +QString SettingsDirOption::longRepresentation() const +{ + return QStringLiteral("--settings-dir"); +} + +void SettingsDirOption::doParse(const QString &representation, QStringList &input) +{ + if (input.empty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1: Argument expected.\n" + "Usage: %2").arg(representation, description(command()))); + } + m_settingsDir = input.takeFirst(); +} + +QString JobLimitsOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 :[,:...]\n" + "\tSet pool-specific job limits.\n").arg(longRepresentation()); +} + +QString JobLimitsOption::longRepresentation() const +{ + return QStringLiteral("--job-limits"); +} + +void JobLimitsOption::doParse(const QString &representation, QStringList &input) +{ + if (input.empty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1: Argument expected.\n" + "Usage: %2").arg(representation, description(command()))); + } + const QString jobLimitsSpec = input.takeFirst(); + const QStringList jobLimitStrings = jobLimitsSpec.split(QLatin1Char(',')); + for (const QString &jobLimitString : jobLimitStrings) { + const int sepIndex = jobLimitString.indexOf(QLatin1Char(':')); + if (sepIndex <= 0 || sepIndex == jobLimitString.size() - 1) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1: " + "Invalid job limits specification '%2'.\n" + "Usage: %3").arg(representation, jobLimitsSpec, + description(command()))); + } + const QString pool = jobLimitString.left(sepIndex); + const QString limitString = jobLimitString.mid(sepIndex + 1); + bool isValidNumber; + const int limit = limitString.toInt(&isValidNumber); + if (!isValidNumber) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1: '%2' is not a number.\n" + "Usage: %3").arg(representation, limitString, + description(command()))); + } + m_jobLimits.setJobLimit(pool, limit); + } +} + +QString RespectProjectJobLimitsOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tGive maximum priority to job limits defined inside the project.\n") + .arg(longRepresentation()); +} + +QString RespectProjectJobLimitsOption::longRepresentation() const +{ + return QStringLiteral("--enforce-project-job-limits"); +} + +CommandEchoModeOption::CommandEchoModeOption() = default; + +QString CommandEchoModeOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1 \n" + "\tKind of output to show when executing commands.\n" + "\tPossible values are '%2'.\n" + "\tThe default is '%3'.\n") + .arg(longRepresentation(), allCommandEchoModeStrings().join(QLatin1String("', '")), + commandEchoModeName(defaultCommandEchoMode())); +} + +QString CommandEchoModeOption::longRepresentation() const +{ + return QStringLiteral("--command-echo-mode"); +} + +CommandEchoMode CommandEchoModeOption::commandEchoMode() const +{ + return m_echoMode; +} + +void CommandEchoModeOption::doParse(const QString &representation, QStringList &input) +{ + const QString mode = getArgument(representation, input); + if (mode.isEmpty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': No command echo mode given.\nUsage: %2") + .arg(representation, description(command()))); + } + + if (!allCommandEchoModeStrings().contains(mode)) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': " + "Invalid command echo mode '%2' given.\nUsage: %3") + .arg(representation, mode, description(command()))); + } + + m_echoMode = commandEchoModeFromName(mode); +} + +QString WaitLockOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tWait indefinitely for other processes to release the build graph lock.\n") + .arg(longRepresentation()); +} + +QString WaitLockOption::longRepresentation() const +{ + return QStringLiteral("--wait-lock"); +} + +QString DisableFallbackProviderOption::description(CommandType) const +{ + return Tr::tr("%1\n\tDo not fall back to pkg-config if a dependency is not found.\n") + .arg(longRepresentation()); +} + +QString DisableFallbackProviderOption::longRepresentation() const +{ + return QStringLiteral("--no-fallback-module-provider"); +} + +QString RunEnvConfigOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1\n\tComma-separated list of strings to pass to all modules' " + "setupRunEnvironment scripts.\n").arg(longRepresentation()); +} + +QString RunEnvConfigOption::longRepresentation() const +{ + return QStringLiteral("--setup-run-env-config"); +} + +} // namespace qbs diff --git a/src/app/qbs/parser/commandlineoption.h b/src/app/qbs/parser/commandlineoption.h new file mode 100644 index 00000000..f8ec1c73 --- /dev/null +++ b/src/app/qbs/parser/commandlineoption.h @@ -0,0 +1,428 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_COMMANDLINEOPTION_H +#define QBS_COMMANDLINEOPTION_H + +#include "commandtype.h" + +#include +#include + +#include + +namespace qbs { + +class CommandLineOption +{ +public: + enum Type { + FileOptionType, + BuildDirectoryOptionType, + LogLevelOptionType, VerboseOptionType, QuietOptionType, + JobsOptionType, + KeepGoingOptionType, + DryRunOptionType, + ForceProbesOptionType, + ShowProgressOptionType, + ChangedFilesOptionType, + ProductsOptionType, + NoInstallOptionType, + InstallRootOptionType, RemoveFirstOptionType, NoBuildOptionType, + ForceTimestampCheckOptionType, + ForceOutputCheckOptionType, + BuildNonDefaultOptionType, + LogTimeOptionType, + CommandEchoModeOptionType, + SettingsDirOptionType, + JobLimitsOptionType, + RespectProjectJobLimitsOptionType, + GeneratorOptionType, + WaitLockOptionType, + RunEnvConfigOptionType, + DisableFallbackProviderType, + }; + + virtual ~CommandLineOption(); + virtual QString description(CommandType command) const = 0; + virtual QString shortRepresentation() const = 0; + virtual QString longRepresentation() const = 0; + virtual bool canAppearMoreThanOnce() const { return false; } + + void parse(CommandType command, const QString &representation, QStringList &input); + +protected: + CommandLineOption(); + QString getArgument(const QString &representation, QStringList &input); + CommandType command() const { return m_command; } + +private: + virtual void doParse(const QString &representation, QStringList &input) = 0; + + CommandType m_command; +}; + +class FileOption : public CommandLineOption +{ +public: + QString projectFilePath() const { return m_projectFilePath; } + +private: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; + void doParse(const QString &representation, QStringList &input) override; + +private: + QString m_projectFilePath; +}; + +class BuildDirectoryOption : public CommandLineOption +{ +public: + QString projectBuildDirectory() const { return m_projectBuildDirectory; } + static QString magicProjectString(); + static QString magicProjectDirString(); + +private: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; + void doParse(const QString &representation, QStringList &input) override; + +private: + QString m_projectBuildDirectory; +}; + +class GeneratorOption : public CommandLineOption +{ +public: + QString generatorName() const { return m_generatorName; } + +private: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; + void doParse(const QString &representation, QStringList &input) override; + +private: + QString m_generatorName; +}; + +class CountingOption : public CommandLineOption +{ +public: + int count() const { return m_count; } + +protected: + CountingOption() : m_count(0) {} + +private: + bool canAppearMoreThanOnce() const override{ return true; } + void doParse(const QString &, QStringList &) override { ++m_count; } + + int m_count; +}; + +class VerboseOption : public CountingOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class QuietOption : public CountingOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class JobsOption : public CommandLineOption +{ +public: + JobsOption() : m_jobCount(0) {} + int jobCount() const { return m_jobCount; } + +private: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; + void doParse(const QString &representation, QStringList &input) override; + + int m_jobCount; +}; + +class OnOffOption : public CommandLineOption +{ +public: + bool enabled() const { return m_enabled; } + +protected: + OnOffOption() : m_enabled(false) {} + +private: + void doParse(const QString &, QStringList &) override { m_enabled = true; } + + bool m_enabled; +}; + +class KeepGoingOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class DryRunOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class ForceProbesOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class NoInstallOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class ShowProgressOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class ForceTimeStampCheckOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class ForceOutputCheckOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class BuildNonDefaultOption : public OnOffOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + + +class StringListOption : public CommandLineOption +{ +public: + QStringList arguments() const { return m_arguments; } + +private: + void doParse(const QString &representation, QStringList &input) override; + + QStringList m_arguments; +}; + +class ChangedFilesOption : public StringListOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class ProductsOption : public StringListOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class RunEnvConfigOption : public StringListOption +{ + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class LogLevelOption : public CommandLineOption +{ +public: + LogLevelOption(); + int logLevel() const { return m_logLevel; } + +private: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; + void doParse(const QString &representation, QStringList &input) override; + + int m_logLevel; +}; + +class InstallRootOption : public CommandLineOption +{ +public: + InstallRootOption(); + + QString installRoot() const { return m_installRoot; } + bool useSysroot() const { return m_useSysroot; } + + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; + +private: + void doParse(const QString &representation, QStringList &input) override; + + QString m_installRoot; + bool m_useSysroot; +}; + +class RemoveFirstOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class NoBuildOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class LogTimeOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override; + QString longRepresentation() const override; +}; + +class CommandEchoModeOption : public CommandLineOption +{ +public: + CommandEchoModeOption(); + + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; + CommandEchoMode commandEchoMode() const; + +private: + void doParse(const QString &representation, QStringList &input) override; + + CommandEchoMode m_echoMode = CommandEchoModeInvalid; +}; + +class SettingsDirOption : public CommandLineOption +{ +public: + SettingsDirOption(); + + QString settingsDir() const { return m_settingsDir; } + + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; + +private: + void doParse(const QString &representation, QStringList &input) override; + + QString m_settingsDir; +}; + +class JobLimitsOption : public CommandLineOption +{ +public: + JobLimits jobLimits() const { return m_jobLimits; } + + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; + +private: + void doParse(const QString &representation, QStringList &input) override; + + JobLimits m_jobLimits; +}; + +class RespectProjectJobLimitsOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class WaitLockOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +class DisableFallbackProviderOption : public OnOffOption +{ +public: + QString description(CommandType command) const override; + QString shortRepresentation() const override { return {}; } + QString longRepresentation() const override; +}; + +} // namespace qbs + +#endif // QBS_COMMANDLINEOPTION_H diff --git a/src/app/qbs/parser/commandlineoptionpool.cpp b/src/app/qbs/parser/commandlineoptionpool.cpp new file mode 100644 index 00000000..63711f62 --- /dev/null +++ b/src/app/qbs/parser/commandlineoptionpool.cpp @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandlineoptionpool.h" + +namespace qbs { + +CommandLineOptionPool::~CommandLineOptionPool() +{ + qDeleteAll(m_options); +} + +CommandLineOption *CommandLineOptionPool::getOption(CommandLineOption::Type type) const +{ + CommandLineOption *& option = m_options[type]; + if (!option) { + switch (type) { + case CommandLineOption::FileOptionType: + option = new FileOption; + break; + case CommandLineOption::BuildDirectoryOptionType: + option = new BuildDirectoryOption; + break; + case CommandLineOption::LogLevelOptionType: + option = new LogLevelOption; + break; + case CommandLineOption::VerboseOptionType: + option = new VerboseOption; + break; + case CommandLineOption::QuietOptionType: + option = new QuietOption; + break; + case CommandLineOption::JobsOptionType: + option = new JobsOption; + break; + case CommandLineOption::KeepGoingOptionType: + option = new KeepGoingOption; + break; + case CommandLineOption::DryRunOptionType: + option = new DryRunOption; + break; + case CommandLineOption::ForceProbesOptionType: + option = new ForceProbesOption; + break; + case CommandLineOption::ShowProgressOptionType: + option = new ShowProgressOption; + break; + case CommandLineOption::ChangedFilesOptionType: + option = new ChangedFilesOption; + break; + case CommandLineOption::ProductsOptionType: + option = new ProductsOption; + break; + case CommandLineOption::NoInstallOptionType: + option = new NoInstallOption; + break; + case CommandLineOption::InstallRootOptionType: + option = new InstallRootOption; + break; + case CommandLineOption::RemoveFirstOptionType: + option = new RemoveFirstOption; + break; + case CommandLineOption::NoBuildOptionType: + option = new NoBuildOption; + break; + case CommandLineOption::ForceTimestampCheckOptionType: + option = new ForceTimeStampCheckOption; + break; + case CommandLineOption::ForceOutputCheckOptionType: + option = new ForceOutputCheckOption; + break; + case CommandLineOption::BuildNonDefaultOptionType: + option = new BuildNonDefaultOption; + break; + case CommandLineOption::LogTimeOptionType: + option = new LogTimeOption; + break; + case CommandLineOption::CommandEchoModeOptionType: + option = new CommandEchoModeOption; + break; + case CommandLineOption::SettingsDirOptionType: + option = new SettingsDirOption; + break; + case CommandLineOption::JobLimitsOptionType: + option = new JobLimitsOption; + break; + case CommandLineOption::RespectProjectJobLimitsOptionType: + option = new RespectProjectJobLimitsOption; + break; + case CommandLineOption::GeneratorOptionType: + option = new GeneratorOption; + break; + case CommandLineOption::WaitLockOptionType: + option = new WaitLockOption; + break; + case CommandLineOption::DisableFallbackProviderType: + option = new DisableFallbackProviderOption; + break; + case CommandLineOption::RunEnvConfigOptionType: + option = new RunEnvConfigOption; + break; + default: + qFatal("Unknown option type %d", type); + } + } + return option; +} + +FileOption *CommandLineOptionPool::fileOption() const +{ + return static_cast(getOption(CommandLineOption::FileOptionType)); +} + +BuildDirectoryOption *CommandLineOptionPool::buildDirectoryOption() const +{ + return static_cast(getOption(CommandLineOption::BuildDirectoryOptionType)); +} + +LogLevelOption *CommandLineOptionPool::logLevelOption() const +{ + return static_cast(getOption(CommandLineOption::LogLevelOptionType)); +} + +VerboseOption *CommandLineOptionPool::verboseOption() const +{ + return static_cast(getOption(CommandLineOption::VerboseOptionType)); +} + +QuietOption *CommandLineOptionPool::quietOption() const +{ + return static_cast(getOption(CommandLineOption::QuietOptionType)); +} + +ShowProgressOption *CommandLineOptionPool::showProgressOption() const +{ + return static_cast(getOption(CommandLineOption::ShowProgressOptionType)); +} + +DryRunOption *CommandLineOptionPool::dryRunOption() const +{ + return static_cast(getOption(CommandLineOption::DryRunOptionType)); +} + +ForceProbesOption *CommandLineOptionPool::forceProbesOption() const +{ + return static_cast(getOption(CommandLineOption::ForceProbesOptionType)); +} + +ChangedFilesOption *CommandLineOptionPool::changedFilesOption() const +{ + return static_cast(getOption(CommandLineOption::ChangedFilesOptionType)); +} + +KeepGoingOption *CommandLineOptionPool::keepGoingOption() const +{ + return static_cast(getOption(CommandLineOption::KeepGoingOptionType)); +} + +JobsOption *CommandLineOptionPool::jobsOption() const +{ + return static_cast(getOption(CommandLineOption::JobsOptionType)); +} + +ProductsOption *CommandLineOptionPool::productsOption() const +{ + return static_cast(getOption(CommandLineOption::ProductsOptionType)); +} + +NoInstallOption *CommandLineOptionPool::noInstallOption() const +{ + return static_cast(getOption(CommandLineOption::NoInstallOptionType)); +} + +InstallRootOption *CommandLineOptionPool::installRootOption() const +{ + return static_cast(getOption(CommandLineOption::InstallRootOptionType)); +} + +RemoveFirstOption *CommandLineOptionPool::removeFirstoption() const +{ + return static_cast(getOption(CommandLineOption::RemoveFirstOptionType)); +} + +NoBuildOption *CommandLineOptionPool::noBuildOption() const +{ + return static_cast(getOption(CommandLineOption::NoBuildOptionType)); +} + +ForceTimeStampCheckOption *CommandLineOptionPool::forceTimestampCheckOption() const +{ + return static_cast( + getOption(CommandLineOption::ForceTimestampCheckOptionType)); +} + +ForceOutputCheckOption *CommandLineOptionPool::forceOutputCheckOption() const +{ + return static_cast( + getOption(CommandLineOption::ForceOutputCheckOptionType)); +} + +BuildNonDefaultOption *CommandLineOptionPool::buildNonDefaultOption() const +{ + return static_cast( + getOption(CommandLineOption::BuildNonDefaultOptionType)); +} + +LogTimeOption *CommandLineOptionPool::logTimeOption() const +{ + return static_cast(getOption(CommandLineOption::LogTimeOptionType)); +} + +CommandEchoModeOption *CommandLineOptionPool::commandEchoModeOption() const +{ + return static_cast( + getOption(CommandLineOption::CommandEchoModeOptionType)); +} + +SettingsDirOption *CommandLineOptionPool::settingsDirOption() const +{ + return static_cast(getOption(CommandLineOption::SettingsDirOptionType)); +} + +JobLimitsOption *CommandLineOptionPool::jobLimitsOption() const +{ + return static_cast(getOption(CommandLineOption::JobLimitsOptionType)); +} + +RespectProjectJobLimitsOption *CommandLineOptionPool::respectProjectJobLimitsOption() const +{ + return static_cast( + getOption(CommandLineOption::RespectProjectJobLimitsOptionType)); +} + +GeneratorOption *CommandLineOptionPool::generatorOption() const +{ + return static_cast(getOption(CommandLineOption::GeneratorOptionType)); +} + +WaitLockOption *CommandLineOptionPool::waitLockOption() const +{ + return static_cast(getOption(CommandLineOption::WaitLockOptionType)); +} + +DisableFallbackProviderOption *CommandLineOptionPool::disableFallbackProviderOption() const +{ + return static_cast( + getOption(CommandLineOption::DisableFallbackProviderType)); +} + +RunEnvConfigOption *CommandLineOptionPool::runEnvConfigOption() const +{ + return static_cast(getOption(CommandLineOption::RunEnvConfigOptionType)); +} + +} // namespace qbs diff --git a/src/app/qbs/parser/commandlineoptionpool.h b/src/app/qbs/parser/commandlineoptionpool.h new file mode 100644 index 00000000..c7ac263e --- /dev/null +++ b/src/app/qbs/parser/commandlineoptionpool.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_COMMANDLINEOPTIONPOOL_H +#define QBS_COMMANDLINEOPTIONPOOL_H + +#include "commandlineoption.h" + +#include + +namespace qbs { + +class CommandLineOptionPool +{ +public: + ~CommandLineOptionPool(); + + CommandLineOption *getOption(CommandLineOption::Type type) const; + FileOption *fileOption() const; + BuildDirectoryOption *buildDirectoryOption() const; + LogLevelOption *logLevelOption() const; + VerboseOption *verboseOption() const; + QuietOption *quietOption() const; + ShowProgressOption *showProgressOption() const; + DryRunOption *dryRunOption() const; + ForceProbesOption *forceProbesOption() const; + ChangedFilesOption *changedFilesOption() const; + KeepGoingOption *keepGoingOption() const; + JobsOption *jobsOption() const; + ProductsOption *productsOption() const; + NoInstallOption *noInstallOption() const; + InstallRootOption *installRootOption() const; + RemoveFirstOption *removeFirstoption() const; + NoBuildOption *noBuildOption() const; + ForceTimeStampCheckOption *forceTimestampCheckOption() const; + ForceOutputCheckOption *forceOutputCheckOption() const; + BuildNonDefaultOption *buildNonDefaultOption() const; + LogTimeOption *logTimeOption() const; + CommandEchoModeOption *commandEchoModeOption() const; + SettingsDirOption *settingsDirOption() const; + JobLimitsOption *jobLimitsOption() const; + RespectProjectJobLimitsOption *respectProjectJobLimitsOption() const; + GeneratorOption *generatorOption() const; + WaitLockOption *waitLockOption() const; + DisableFallbackProviderOption *disableFallbackProviderOption() const; + RunEnvConfigOption *runEnvConfigOption() const; + +private: + mutable QHash m_options; +}; + +} // namespace qbs + +#endif // QBS_COMMANDLINEOPTIONPOOL_H diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp new file mode 100644 index 00000000..0f70b3fe --- /dev/null +++ b/src/app/qbs/parser/commandlineparser.cpp @@ -0,0 +1,622 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "commandlineparser.h" + +#include "commandlineoption.h" +#include "commandlineoptionpool.h" +#include "commandpool.h" +#include "parsercommand.h" +#include "../qbstool.h" +#include "../../shared/logging/consolelogger.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#ifdef Q_OS_UNIX +#include +#endif + +namespace qbs { +using Internal::Tr; + +class CommandLineParser::CommandLineParserPrivate +{ +public: + CommandLineParserPrivate(); + + void doParse(); + Command *commandFromString(const QString &commandString) const; + QList allCommands() const; + QString generalHelp() const; + + void setupProjectFile(); + void setupBuildDirectory(); + void setupProgress(); + void setupLogLevel(); + void setupBuildOptions(); + void setupBuildConfigurations(); + bool checkForExistingBuildConfiguration(const QList &buildConfigs, + const QString &configurationName); + bool withNonDefaultProducts() const; + bool dryRun() const; + QString settingsDir() const { return optionPool.settingsDirOption()->settingsDir(); } + + CommandEchoMode echoMode() const; + + QString propertyName(const QString &aCommandLineName) const; + + QStringList commandLine; + Command *command; + QString projectFilePath; + QString projectBuildDirectory; + BuildOptions buildOptions; + QList buildConfigurations; + CommandLineOptionPool optionPool; + CommandPool commandPool; + bool showProgress; + bool logTime; +}; + +CommandLineParser::CommandLineParser() = default; + +CommandLineParser::~CommandLineParser() = default; + +void CommandLineParser::printHelp() const +{ + QTextStream stream(stdout); + + Q_ASSERT(d->command == d->commandPool.getCommand(HelpCommandType)); + const auto helpCommand = static_cast(d->command); + if (helpCommand->commandToDescribe().isEmpty()) { + stream << "Qbs " QBS_VERSION ", a cross-platform build tool.\n"; + stream << d->generalHelp(); + } else { + const Command * const commandToDescribe + = d->commandFromString(helpCommand->commandToDescribe()); + if (commandToDescribe) { + stream << commandToDescribe->longDescription(); + } else if (!QbsTool::tryToRunTool(helpCommand->commandToDescribe(), + QStringList(QStringLiteral("--help")))) { + throw ErrorInfo(Tr::tr("No such command '%1'.\n%2") + .arg(helpCommand->commandToDescribe(), d->generalHelp())); + } + } +} + +CommandType CommandLineParser::command() const +{ + return d->command->type(); +} + +QString CommandLineParser::projectFilePath() const +{ + return d->projectFilePath; +} + +QString CommandLineParser::projectBuildDirectory() const +{ + return d->projectBuildDirectory; +} + +BuildOptions CommandLineParser::buildOptions(const QString &profile) const +{ + Settings settings(settingsDir()); + Preferences preferences(&settings, profile); + + if (d->buildOptions.maxJobCount() <= 0) { + d->buildOptions.setMaxJobCount(preferences.jobs()); + } + + if (d->buildOptions.echoMode() < 0) { + d->buildOptions.setEchoMode(preferences.defaultEchoMode()); + } + + return d->buildOptions; +} + +CleanOptions CommandLineParser::cleanOptions(const QString &profile) const +{ + CleanOptions options; + options.setDryRun(buildOptions(profile).dryRun()); + options.setKeepGoing(buildOptions(profile).keepGoing()); + options.setLogElapsedTime(logTime()); + return options; +} + +GenerateOptions CommandLineParser::generateOptions() const +{ + GenerateOptions options; + options.setGeneratorName(d->optionPool.generatorOption()->generatorName()); + return options; +} + +InstallOptions CommandLineParser::installOptions(const QString &profile) const +{ + InstallOptions options; + options.setRemoveExistingInstallation(d->optionPool.removeFirstoption()->enabled()); + options.setInstallRoot(d->optionPool.installRootOption()->installRoot()); + options.setInstallIntoSysroot(d->optionPool.installRootOption()->useSysroot()); + if (!options.installRoot().isEmpty()) { + QFileInfo fi(options.installRoot()); + if (!fi.isAbsolute()) + options.setInstallRoot(fi.absoluteFilePath()); + } + options.setDryRun(buildOptions(profile).dryRun()); + options.setKeepGoing(buildOptions(profile).keepGoing()); + options.setLogElapsedTime(logTime()); + return options; +} + +bool CommandLineParser::forceTimestampCheck() const +{ + return d->optionPool.forceTimestampCheckOption()->enabled(); +} + +bool CommandLineParser::forceOutputCheck() const +{ + return d->optionPool.forceOutputCheckOption()->enabled(); +} + +bool CommandLineParser::dryRun() const +{ + return d->dryRun(); +} + +bool CommandLineParser::forceProbesExecution() const +{ + return d->optionPool.forceProbesOption()->enabled(); +} + +bool CommandLineParser::waitLockBuildGraph() const +{ + return d->optionPool.waitLockOption()->enabled(); +} + +bool CommandLineParser::disableFallbackProvider() const +{ + return d->optionPool.disableFallbackProviderOption()->enabled(); +} + +bool CommandLineParser::logTime() const +{ + return d->logTime; +} + +bool CommandLineParser::withNonDefaultProducts() const +{ + return d->withNonDefaultProducts(); +} + +bool CommandLineParser::buildBeforeInstalling() const +{ + return !d->optionPool.noBuildOption()->enabled(); +} + +QStringList CommandLineParser::runArgs() const +{ + Q_ASSERT(d->command->type() == RunCommandType); + return static_cast(d->command)->targetParameters(); +} + +QStringList CommandLineParser::products() const +{ + return d->optionPool.productsOption()->arguments(); +} + +QStringList CommandLineParser::runEnvConfig() const +{ + return d->optionPool.runEnvConfigOption()->arguments(); +} + +bool CommandLineParser::showProgress() const +{ + return d->showProgress; +} + +bool CommandLineParser::showVersion() const +{ + return d->command->type() == VersionCommandType; +} + +QString CommandLineParser::settingsDir() const +{ + return d->settingsDir(); +} + +QString CommandLineParser::commandName() const +{ + return d->command->representation(); +} + +bool CommandLineParser::commandCanResolve() const +{ + return d->command->canResolve(); +} + +QString CommandLineParser::commandDescription() const +{ + return d->command->longDescription(); +} + +static QString getBuildConfigurationName(const QVariantMap &buildConfig) +{ + return buildConfig.value(QStringLiteral("qbs.configurationName")).toString(); +} + +QList CommandLineParser::buildConfigurations() const +{ + return d->buildConfigurations; +} + +bool CommandLineParser::parseCommandLine(const QStringList &args) +{ + d = std::make_unique(); + d->commandLine = args; + try { + d->doParse(); + return true; + } catch (const ErrorInfo &error) { + qbsError() << error.toString(); + return false; + } +} + + +CommandLineParser::CommandLineParserPrivate::CommandLineParserPrivate() + : command(nullptr), commandPool(optionPool), showProgress(false), logTime(false) +{ +} + +void CommandLineParser::CommandLineParserPrivate::doParse() +{ + if (commandLine.empty()) { // No command given, use default. + command = commandPool.getCommand(BuildCommandType); + } else { + command = commandFromString(commandLine.front()); + if (command) { + commandLine.removeFirst(); + } else { // No command given. + if (commandLine.front() == QLatin1String("-h") + || commandLine.front() == QLatin1String("--help")) { + command = commandPool.getCommand(HelpCommandType); + commandLine.takeFirst(); + } else if (commandLine.front() == QLatin1String("-V") + || commandLine.front() == QLatin1String("--version")) { + command = commandPool.getCommand(VersionCommandType); + commandLine.takeFirst(); + } else { + command = commandPool.getCommand(BuildCommandType); + } + } + } + command->parse(commandLine); + + if (command->type() == HelpCommandType || command->type() == VersionCommandType) + return; + + setupBuildDirectory(); + setupBuildConfigurations(); + setupProjectFile(); + setupProgress(); + setupLogLevel(); + setupBuildOptions(); +} + +Command *CommandLineParser::CommandLineParserPrivate::commandFromString(const QString &commandString) const +{ + const auto commands = allCommands(); + for (Command * const command : commands) { + if (command->representation() == commandString) + return command; + } + return nullptr; +} + +QList CommandLineParser::CommandLineParserPrivate::allCommands() const +{ + return {commandPool.getCommand(GenerateCommandType), + commandPool.getCommand(ResolveCommandType), + commandPool.getCommand(BuildCommandType), + commandPool.getCommand(CleanCommandType), + commandPool.getCommand(RunCommandType), + commandPool.getCommand(ShellCommandType), + commandPool.getCommand(StatusCommandType), + commandPool.getCommand(UpdateTimestampsCommandType), + commandPool.getCommand(InstallCommandType), + commandPool.getCommand(DumpNodesTreeCommandType), + commandPool.getCommand(ListProductsCommandType), + commandPool.getCommand(VersionCommandType), + commandPool.getCommand(SessionCommandType), + commandPool.getCommand(HelpCommandType)}; +} + +static QString extractToolDescription(const QString &tool, const QString &output) +{ + if (tool == QLatin1String("create-project")) { + // This command uses QCommandLineParser, where the description is not in the first line. + const int eol1Pos = output.indexOf(QLatin1Char('\n')); + const int eol2Pos = output.indexOf(QLatin1Char('\n'), eol1Pos + 1); + return output.mid(eol1Pos + 1, eol2Pos - eol1Pos - 1); + } + return output.left(output.indexOf(QLatin1Char('\n'))); +} + +QString CommandLineParser::CommandLineParserPrivate::generalHelp() const +{ + QString help = Tr::tr("Usage: qbs [command] [command parameters]\n"); + help += Tr::tr("Built-in commands:\n"); + const int rhsIndentation = 30; + + // Sorting the commands by name is nicer for the user. + QMap commandMap; + const auto commands = allCommands(); + for (const Command * command : commands) + commandMap.insert(command->representation(), command); + + for (const Command * command : qAsConst(commandMap)) { + help.append(QLatin1String(" ")).append(command->representation()); + const QString whitespace + = QString(rhsIndentation - 2 - command->representation().size(), QLatin1Char(' ')); + help.append(whitespace).append(command->shortDescription()).append(QLatin1Char('\n')); + } + + QStringList toolNames = QbsTool::allToolNames(); + toolNames.sort(); + if (!toolNames.empty()) { + help.append(QLatin1Char('\n')).append(Tr::tr("Auxiliary commands:\n")); + for (const QString &toolName : qAsConst(toolNames)) { + help.append(QLatin1String(" ")).append(toolName); + const QString whitespace = QString(rhsIndentation - 2 - toolName.size(), + QLatin1Char(' ')); + QbsTool tool; + tool.runTool(toolName, QStringList(QStringLiteral("--help"))); + if (tool.exitCode() != 0) + continue; + const QString shortDescription = extractToolDescription(toolName, tool.stdOut()); + help.append(whitespace).append(shortDescription).append(QLatin1Char('\n')); + } + } + + return help; +} + +void CommandLineParser::CommandLineParserPrivate::setupProjectFile() +{ + projectFilePath = optionPool.fileOption()->projectFilePath(); +} + +void CommandLineParser::CommandLineParserPrivate::setupBuildDirectory() +{ + projectBuildDirectory = optionPool.buildDirectoryOption()->projectBuildDirectory(); +} + +void CommandLineParser::CommandLineParserPrivate::setupBuildOptions() +{ + buildOptions.setDryRun(dryRun()); + QStringList changedFiles = optionPool.changedFilesOption()->arguments(); + QDir currentDir; + for (QString &file : changedFiles) + file = QDir::fromNativeSeparators(currentDir.absoluteFilePath(file)); + buildOptions.setChangedFiles(changedFiles); + buildOptions.setKeepGoing(optionPool.keepGoingOption()->enabled()); + buildOptions.setForceTimestampCheck(optionPool.forceTimestampCheckOption()->enabled()); + buildOptions.setForceOutputCheck(optionPool.forceOutputCheckOption()->enabled()); + const JobsOption * jobsOption = optionPool.jobsOption(); + buildOptions.setMaxJobCount(jobsOption->jobCount()); + buildOptions.setLogElapsedTime(logTime); + buildOptions.setEchoMode(echoMode()); + buildOptions.setInstall(!optionPool.noInstallOption()->enabled()); + buildOptions.setRemoveExistingInstallation(optionPool.removeFirstoption()->enabled()); + buildOptions.setJobLimits(optionPool.jobLimitsOption()->jobLimits()); + buildOptions.setProjectJobLimitsTakePrecedence( + optionPool.respectProjectJobLimitsOption()->enabled()); + buildOptions.setSettingsDirectory(settingsDir()); +} + +void CommandLineParser::CommandLineParserPrivate::setupBuildConfigurations() +{ + // first: configuration name, second: properties. + // Empty configuration name used for global properties. + using PropertyListItem = std::pair; + QList propertiesPerConfiguration; + + const QString configurationNameKey = QStringLiteral("qbs.configurationName"); + QString currentConfigurationName; + QVariantMap currentProperties; + const auto args = command->additionalArguments(); + for (const QString &arg : args) { + const int sepPos = arg.indexOf(QLatin1Char(':')); + QBS_CHECK(sepPos > 0); + const QString key = arg.left(sepPos); + const QString rawValue = arg.mid(sepPos + 1); + if (key == QLatin1String("config") || key == configurationNameKey) { + propertiesPerConfiguration.push_back(std::make_pair(currentConfigurationName, + currentProperties)); + currentConfigurationName = rawValue; + currentProperties.clear(); + continue; + } + currentProperties.insert(propertyName(key), representationToSettingsValue(rawValue)); + } + propertiesPerConfiguration.push_back(std::make_pair(currentConfigurationName, + currentProperties)); + + if (propertiesPerConfiguration.size() == 1) // No configuration name specified on command line. + propertiesPerConfiguration.push_back(PropertyListItem(QStringLiteral("default"), + QVariantMap())); + + const QVariantMap globalProperties = propertiesPerConfiguration.takeFirst().second; + QList buildConfigs; + for (const PropertyListItem &item : qAsConst(propertiesPerConfiguration)) { + QVariantMap properties = item.second; + for (QVariantMap::ConstIterator globalPropIt = globalProperties.constBegin(); + globalPropIt != globalProperties.constEnd(); ++globalPropIt) { + if (!properties.contains(globalPropIt.key())) + properties.insert(globalPropIt.key(), globalPropIt.value()); + } + + const QString configurationName = item.first; + if (checkForExistingBuildConfiguration(buildConfigs, configurationName)) { + qbsWarning() << Tr::tr("Ignoring redundant request to build for configuration '%1'.") + .arg(configurationName); + continue; + } + + properties.insert(configurationNameKey, configurationName); + buildConfigs.push_back(properties); + } + + buildConfigurations = buildConfigs; +} + +void CommandLineParser::CommandLineParserPrivate::setupProgress() +{ + const ShowProgressOption * const option = optionPool.showProgressOption(); + showProgress = option->enabled(); +#ifdef Q_OS_UNIX + if (showProgress && !isatty(STDOUT_FILENO)) { + showProgress = false; + qbsWarning() << Tr::tr("Ignoring option '%1', because standard output is " + "not connected to a terminal.").arg(option->longRepresentation()); + } +#endif +} + +void CommandLineParser::CommandLineParserPrivate::setupLogLevel() +{ + const LogLevelOption * const logLevelOption = optionPool.logLevelOption(); + const VerboseOption * const verboseOption = optionPool.verboseOption(); + const QuietOption * const quietOption = optionPool.quietOption(); + int logLevel = logLevelOption->logLevel(); + logLevel += verboseOption->count(); + logLevel -= quietOption->count(); + + if (showProgress && logLevel != LoggerMinLevel) { + const bool logLevelWasSetByUser + = logLevelOption->logLevel() != defaultLogLevel() + || verboseOption->count() > 0 || quietOption->count() > 0; + if (logLevelWasSetByUser) { + qbsInfo() << Tr::tr("Setting log level to '%1', because option '%2'" + " has been given.").arg(logLevelName(LoggerMinLevel), + optionPool.showProgressOption()->longRepresentation()); + } + logLevel = LoggerMinLevel; + } + if (logLevel < LoggerMinLevel) { + qbsWarning() << Tr::tr("Cannot decrease log level as much as specified; using '%1'.") + .arg(logLevelName(LoggerMinLevel)); + logLevel = LoggerMinLevel; + } else if (logLevel > LoggerMaxLevel) { + qbsWarning() << Tr::tr("Cannot increase log level as much as specified; using '%1'.") + .arg(logLevelName(LoggerMaxLevel)); + logLevel = LoggerMaxLevel; + } + + logTime = optionPool.logTimeOption()->enabled(); + if (showProgress && logTime) { + qbsWarning() << Tr::tr("Options '%1' and '%2' are incompatible. Ignoring '%2'.") + .arg(optionPool.showProgressOption()->longRepresentation(), + optionPool.logTimeOption()->longRepresentation()); + logTime = false; + } + + ConsoleLogger::instance().logSink()->setLogLevel(static_cast(logLevel)); +} + +QString CommandLineParser::CommandLineParserPrivate::propertyName(const QString &aCommandLineName) const +{ + // Make fully-qualified, ie "platform" -> "qbs.platform" + if (aCommandLineName.contains(QLatin1Char('.'))) + return aCommandLineName; + return QLatin1String("qbs.") + aCommandLineName; +} + +bool CommandLineParser::CommandLineParserPrivate::checkForExistingBuildConfiguration( + const QList &buildConfigs, const QString &configurationName) +{ + return Internal::any_of(buildConfigs, [&configurationName](const auto &buildConfig) { + return configurationName == getBuildConfigurationName(buildConfig); + }); +} + +bool CommandLineParser::CommandLineParserPrivate::withNonDefaultProducts() const +{ + if (command->type() == GenerateCommandType) + return true; + return optionPool.buildNonDefaultOption()->enabled(); +} + +bool CommandLineParser::CommandLineParserPrivate::dryRun() const +{ + if (command->type() == GenerateCommandType || command->type() == ListProductsCommandType) + return true; + return optionPool.dryRunOption()->enabled(); +} + +CommandEchoMode CommandLineParser::CommandLineParserPrivate::echoMode() const +{ + if (command->type() == GenerateCommandType) + return CommandEchoModeSilent; + + if (optionPool.commandEchoModeOption()->commandEchoMode() < CommandEchoModeInvalid) + return optionPool.commandEchoModeOption()->commandEchoMode(); + + return defaultCommandEchoMode(); +} + +} // namespace qbs diff --git a/src/app/qbs/parser/commandlineparser.h b/src/app/qbs/parser/commandlineparser.h new file mode 100644 index 00000000..70586b2d --- /dev/null +++ b/src/app/qbs/parser/commandlineparser.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_COMMANDLINEPARSER_H +#define QBS_COMMANDLINEPARSER_H + +#include "commandtype.h" + +#include +#include + +#include + +namespace qbs { +class BuildOptions; +class CleanOptions; +class GenerateOptions; +class InstallOptions; +class Settings; + +class CommandLineParser +{ + Q_DISABLE_COPY(CommandLineParser) +public: + CommandLineParser(); + ~CommandLineParser(); + + bool parseCommandLine(const QStringList &args); + void printHelp() const; + + CommandType command() const; + QString commandName() const; + bool commandCanResolve() const; + QString commandDescription() const; + QString projectFilePath() const; + QString projectBuildDirectory() const; + BuildOptions buildOptions(const QString &profile) const; + CleanOptions cleanOptions(const QString &profile) const; + GenerateOptions generateOptions() const; + InstallOptions installOptions(const QString &profile) const; + bool forceTimestampCheck() const; + bool forceOutputCheck() const; + bool dryRun() const; + bool forceProbesExecution() const; + bool waitLockBuildGraph() const; + bool disableFallbackProvider() const; + bool logTime() const; + bool withNonDefaultProducts() const; + bool buildBeforeInstalling() const; + QStringList runArgs() const; + QStringList products() const; + QStringList runEnvConfig() const; + QList buildConfigurations() const; + bool showProgress() const; + bool showVersion() const; + QString settingsDir() const; + +private: + class CommandLineParserPrivate; + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // QBS_COMMANDLINEPARSER_H diff --git a/src/app/qbs/parser/commandpool.cpp b/src/app/qbs/parser/commandpool.cpp new file mode 100644 index 00000000..1362a563 --- /dev/null +++ b/src/app/qbs/parser/commandpool.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "commandpool.h" + +#include "parsercommand.h" + +namespace qbs { + +CommandPool::CommandPool(CommandLineOptionPool &optionPool) : m_optionPool(optionPool) +{ +} + +CommandPool::~CommandPool() +{ + qDeleteAll(m_commands); +} + +qbs::Command *CommandPool::getCommand(CommandType type) const +{ + Command *& command = m_commands[type]; + if (!command) { + switch (type) { + case ResolveCommandType: + command = new ResolveCommand(m_optionPool); + break; + case GenerateCommandType: + command = new GenerateCommand(m_optionPool); + break; + case BuildCommandType: + command = new BuildCommand(m_optionPool); + break; + case CleanCommandType: + command = new CleanCommand(m_optionPool); + break; + case RunCommandType: + command = new RunCommand(m_optionPool); + break; + case ShellCommandType: + command = new ShellCommand(m_optionPool); + break; + case StatusCommandType: + command = new StatusCommand(m_optionPool); + break; + case UpdateTimestampsCommandType: + command = new UpdateTimestampsCommand(m_optionPool); + break; + case InstallCommandType: + command = new InstallCommand(m_optionPool); + break; + case DumpNodesTreeCommandType: + command = new DumpNodesTreeCommand(m_optionPool); + break; + case ListProductsCommandType: + command = new ListProductsCommand(m_optionPool); + break; + case HelpCommandType: + command = new HelpCommand(m_optionPool); + break; + case VersionCommandType: + command = new VersionCommand(m_optionPool); + break; + case SessionCommandType: + command = new SessionCommand(m_optionPool); + break; + } + } + return command; +} + +} // namespace qbs diff --git a/src/app/qbs/parser/commandpool.h b/src/app/qbs/parser/commandpool.h new file mode 100644 index 00000000..c42017d0 --- /dev/null +++ b/src/app/qbs/parser/commandpool.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_COMMANDPOOL_H +#define QBS_COMMANDPOOL_H + +#include "commandtype.h" + +#include + +namespace qbs { +class Command; +class CommandLineOptionPool; + +class CommandPool +{ + Q_DISABLE_COPY(CommandPool) +public: + CommandPool(CommandLineOptionPool &optionPool); + ~CommandPool(); + + Command *getCommand(CommandType type) const; + +private: + CommandLineOptionPool &m_optionPool; + mutable QHash m_commands; +}; + +} // namespace qbs + +#endif // QBS_COMMANDPOOL_H diff --git a/src/app/qbs/parser/commandtype.h b/src/app/qbs/parser/commandtype.h new file mode 100644 index 00000000..7d70356e --- /dev/null +++ b/src/app/qbs/parser/commandtype.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef COMMANDTYPE_H +#define COMMANDTYPE_H + +namespace qbs { + +enum CommandType { + ResolveCommandType, BuildCommandType, CleanCommandType, RunCommandType, ShellCommandType, + StatusCommandType, UpdateTimestampsCommandType, DumpNodesTreeCommandType, + InstallCommandType, HelpCommandType, GenerateCommandType, ListProductsCommandType, + VersionCommandType, SessionCommandType, +}; + +} // namespace qbs + +#endif // COMMANDTYPE_H diff --git a/src/app/qbs/parser/parser.pri b/src/app/qbs/parser/parser.pri new file mode 100644 index 00000000..f708f113 --- /dev/null +++ b/src/app/qbs/parser/parser.pri @@ -0,0 +1,16 @@ +SOURCES += \ + $$PWD/commandlineparser.cpp \ + $$PWD/commandpool.cpp \ + $$PWD/commandlineoption.cpp \ + $$PWD/commandlineoptionpool.cpp \ + $$PWD/parsercommand.cpp + +HEADERS += \ + $$PWD/commandlineparser.h \ + $$PWD/commandpool.h \ + $$PWD/commandlineoption.h \ + $$PWD/commandlineoptionpool.h \ + $$PWD/commandtype.h \ + $$PWD/parsercommand.h + +include(../../../../qbs_version.pri) diff --git a/src/app/qbs/parser/parsercommand.cpp b/src/app/qbs/parser/parsercommand.cpp new file mode 100644 index 00000000..799bf5dc --- /dev/null +++ b/src/app/qbs/parser/parsercommand.cpp @@ -0,0 +1,617 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "parsercommand.h" + +#include "commandlineoption.h" +#include "commandlineoptionpool.h" + +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +using namespace Internal; + +Command::~Command() = default; + +void Command::parse(QStringList &input) +{ + while (!input.empty()) + parseNext(input); +} + +bool Command::canResolve() const +{ + return supportedOptions().contains(CommandLineOption::FileOptionType); +} + +void Command::parsePropertyAssignment(const QString &argument) +{ + const auto throwError = [argument](const QString &msgTemplate) { + ErrorInfo error(msgTemplate.arg(argument)); + error.append(QLatin1String("Expected an assignment of the form :, " + "profile: or config:.")); + throw error; + }; + if (argument.startsWith(QLatin1Char('-'))) + throwError(Tr::tr("Unexpected option '%1'.")); + const int sepPos = argument.indexOf(QLatin1Char(':')); + if (sepPos == -1) + throwError(Tr::tr("Unexpected command line parameter '%1'.")); + if (sepPos == 0) + throwError(Tr::tr("Empty key not allowed in assignment '%1'.")); + if (!canResolve() && argument.contains(QLatin1Char(':')) + && !argument.startsWith(QLatin1String("config:"))) { + throw ErrorInfo(Tr::tr("The '%1' command does not support property assignments.") + .arg(representation())); + } + m_additionalArguments << argument; +} + +QList Command::actualSupportedOptions() const +{ + QList options = supportedOptions(); + if (type() != HelpCommandType) + options.push_back(CommandLineOption::SettingsDirOptionType); // Valid for almost all commands. + return options; +} + +void Command::parseOption(QStringList &input) +{ + const QString optionString = input.front(); + QBS_CHECK(optionString.startsWith(QLatin1Char('-'))); + input.removeFirst(); + if (optionString.size() == 1) + throwError(Tr::tr("Empty options are not allowed.")); + + // Split up grouped short options. + if (optionString.at(1) != QLatin1Char('-') && optionString.size() > 2) { + QString parameter; + for (int i = optionString.size(); --i > 0;) { + const QChar c = optionString.at(i); + if (c.isDigit()) { + parameter.prepend(c); + } else { + if (!parameter.isEmpty()) { + input.prepend(parameter); + parameter.clear(); + } + input.prepend(QLatin1Char('-') + c); + } + } + if (!parameter.isEmpty()) + throwError(Tr::tr("Unknown numeric option '%1'.").arg(parameter)); + return; + } + + bool matchFound = false; + const auto optionTypes = actualSupportedOptions(); + for (const CommandLineOption::Type optionType : optionTypes) { + CommandLineOption * const option = optionPool().getOption(optionType); + if (option->shortRepresentation() != optionString + && option->longRepresentation() != optionString) { + continue; + } + if (contains(m_usedOptions, option) && !option->canAppearMoreThanOnce()) + throwError(Tr::tr("Option '%1' cannot appear more than once.").arg(optionString)); + option->parse(type(), optionString, input); + m_usedOptions.insert(option); + matchFound = true; + break; + } + if (!matchFound) + throwError(Tr::tr("Unknown option '%1'.").arg(optionString)); +} + +void Command::parseNext(QStringList &input) +{ + QBS_CHECK(!input.empty()); + if (input.front().startsWith(QLatin1Char('-'))) + parseOption(input); + else + parsePropertyAssignment(input.takeFirst()); +} + +QString Command::supportedOptionsDescription() const +{ + // Sorting the options by name is nicer for the user. + QMap optionMap; + const auto opTypes = actualSupportedOptions(); + for (const CommandLineOption::Type opType : opTypes) { + const CommandLineOption * const option = optionPool().getOption(opType); + optionMap.insert(option->longRepresentation(), option); + } + + QString s = Tr::tr("The possible options are:\n"); + for (const CommandLineOption *option : qAsConst(optionMap)) + s += option->description(type()); + return s; +} + +void Command::throwError(const QString &reason) +{ + ErrorInfo error(Tr::tr("Invalid use of command '%1': %2").arg(representation(), reason)); + error.append(Tr::tr("Type 'qbs help %1' to see how to use this command.") + .arg(representation())); + throw error; +} + + +QString ResolveCommand::shortDescription() const +{ + return Tr::tr("Resolve a project without building it."); +} + +QString ResolveCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [[config:] [:] ...] ...\n") + .arg(representation()); + description += Tr::tr("Resolves a project in one or more configuration(s).\n"); + return description += supportedOptionsDescription(); +} + +QString ResolveCommand::representation() const +{ + return QStringLiteral("resolve"); +} + +static QList resolveOptions() +{ + return {CommandLineOption::FileOptionType, + CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::LogLevelOptionType, + CommandLineOption::VerboseOptionType, + CommandLineOption::QuietOptionType, + CommandLineOption::ShowProgressOptionType, + CommandLineOption::DryRunOptionType, + CommandLineOption::ForceProbesOptionType, + CommandLineOption::LogTimeOptionType, + CommandLineOption::DisableFallbackProviderType}; +} + +QList ResolveCommand::supportedOptions() const +{ + return resolveOptions(); +} + +QString GenerateCommand::shortDescription() const +{ + return Tr::tr("Generate project files for another build tool."); +} + +QString GenerateCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [[config:] [:] ...] ...\n") + .arg(representation()); + description += Tr::tr("Generates files to build the project using another build tool.\n"); + return description += supportedOptionsDescription(); +} + +QString GenerateCommand::representation() const +{ + return QStringLiteral("generate"); +} + +QList GenerateCommand::supportedOptions() const +{ + return {CommandLineOption::FileOptionType, + CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::LogLevelOptionType, + CommandLineOption::VerboseOptionType, + CommandLineOption::QuietOptionType, + CommandLineOption::ShowProgressOptionType, + CommandLineOption::InstallRootOptionType, + CommandLineOption::LogTimeOptionType, + CommandLineOption::GeneratorOptionType}; +} + +QString BuildCommand::shortDescription() const +{ + return Tr::tr("Build (parts of) a project. This is the default command."); +} + +QString BuildCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [[config:] [:] ...] ...\n") + .arg(representation()); + description += Tr::tr("Builds a project in one or more configuration(s).\n"); + return description += supportedOptionsDescription(); +} + +static QString buildCommandRepresentation() { return QStringLiteral("build"); } + +QString BuildCommand::representation() const +{ + return buildCommandRepresentation(); +} + +static QList buildOptions() +{ + QList options = resolveOptions(); + return options << CommandLineOption::KeepGoingOptionType + << CommandLineOption::ProductsOptionType + << CommandLineOption::ChangedFilesOptionType + << CommandLineOption::ForceTimestampCheckOptionType + << CommandLineOption::ForceOutputCheckOptionType + << CommandLineOption::BuildNonDefaultOptionType + << CommandLineOption::JobsOptionType + << CommandLineOption::CommandEchoModeOptionType + << CommandLineOption::NoInstallOptionType + << CommandLineOption::RemoveFirstOptionType + << CommandLineOption::JobLimitsOptionType + << CommandLineOption::RespectProjectJobLimitsOptionType + << CommandLineOption::WaitLockOptionType; +} + +QList BuildCommand::supportedOptions() const +{ + return buildOptions(); +} + +QString CleanCommand::shortDescription() const +{ + return Tr::tr("Remove the files generated during a build."); +} + +QString CleanCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [config:] ...\n") + .arg(representation()); + description += Tr::tr("Removes build artifacts for the given configuration(s).\n"); + return description += supportedOptionsDescription(); +} + +QString CleanCommand::representation() const +{ + return QStringLiteral("clean"); +} + +QList CleanCommand::supportedOptions() const +{ + return {CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::DryRunOptionType, + CommandLineOption::KeepGoingOptionType, + CommandLineOption::LogTimeOptionType, + CommandLineOption::ProductsOptionType, + CommandLineOption::QuietOptionType, + CommandLineOption::SettingsDirOptionType, + CommandLineOption::ShowProgressOptionType, + CommandLineOption::VerboseOptionType}; +} + +QString InstallCommand::shortDescription() const +{ + return Tr::tr("Install (parts of) a project."); +} + +QString InstallCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [[config:] [:] ...]\n") + .arg(representation()); + description += Tr::tr("Install all files marked as installable " + "to their respective destinations.\n" + "The project is built first, if necessary, unless the '%1' option " + "is given.\n").arg(optionPool().noBuildOption()->longRepresentation()); + return description += supportedOptionsDescription(); +} + +QString InstallCommand::representation() const +{ + return QStringLiteral("install"); +} + +QList installOptions() +{ + QList options = buildOptions() + << CommandLineOption::InstallRootOptionType + << CommandLineOption::NoBuildOptionType; + options.removeOne(CommandLineOption::NoInstallOptionType); + return options; +} + +QList InstallCommand::supportedOptions() const +{ + return installOptions(); +} + +QString RunCommand::shortDescription() const +{ + return QStringLiteral("Run an executable generated by building a project."); +} + +QString RunCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [config:] [:] ... " + "[ -- ]\n").arg(representation()); + description += Tr::tr("Run the specified product's executable with the specified arguments.\n"); + description += Tr::tr("If the project has only one product, the '%1' option may be omitted.\n") + .arg(optionPool().productsOption()->longRepresentation()); + description += Tr::tr("The product will be built if it is not up to date; " + "see the '%2' command.\n").arg(buildCommandRepresentation()); + return description += supportedOptionsDescription(); +} + +QString RunCommand::representation() const +{ + return QStringLiteral("run"); +} + +QList RunCommand::supportedOptions() const +{ + return QList() << installOptions() + << CommandLineOption::RunEnvConfigOptionType; +} + +void RunCommand::parseNext(QStringList &input) +{ + QBS_CHECK(!input.empty()); + if (input.front() != QLatin1String("--")) { + Command::parseNext(input); + return; + } + input.removeFirst(); + m_targetParameters = input; + input.clear(); +} + +QString ShellCommand::shortDescription() const +{ + return Tr::tr("Open a shell with a product's environment."); +} + +QString ShellCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [config:] [:] ...\n") + .arg(representation()); + description += Tr::tr("Opens a shell in the same environment that a build with the given " + "parameters would use.\n"); + return description += supportedOptionsDescription(); +} + +QString ShellCommand::representation() const +{ + return QStringLiteral("shell"); +} + +QList ShellCommand::supportedOptions() const +{ + return {CommandLineOption::FileOptionType, + CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::ProductsOptionType}; +} + +QString StatusCommand::shortDescription() const +{ + return Tr::tr("Show the status of files in the project directory."); +} + +QString StatusCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1 [options] [config:]\n") + .arg(representation()); + description += Tr::tr("Lists all the files in the project directory and shows whether " + "they are known to qbs in the respective configuration.\n"); + return description += supportedOptionsDescription(); +} + +QString StatusCommand::representation() const +{ + return QStringLiteral("status"); +} + +QList StatusCommand::supportedOptions() const +{ + return {CommandLineOption::BuildDirectoryOptionType}; +} + +QString UpdateTimestampsCommand::shortDescription() const +{ + return Tr::tr("Mark the build as up to date."); +} + +QString UpdateTimestampsCommand::longDescription() const +{ + QString description = Tr::tr( + "qbs %1 [options] [config:] ...\n") + .arg(representation()); + description += Tr::tr("Update the timestamps of all build artifacts, causing the next " + "builds of the project to do nothing if no updates to source files happen in between.\n" + "This functionality is useful if you know that the current changes to source files " + "are irrelevant to the build.\n" + "NOTE: Doing this causes a discrepancy between the \"real world\" and the information " + "in the build graph, so use with care.\n"); + return description += supportedOptionsDescription(); +} + +QString UpdateTimestampsCommand::representation() const +{ + return QStringLiteral("update-timestamps"); +} + +QList UpdateTimestampsCommand::supportedOptions() const +{ + return {CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::LogLevelOptionType, + CommandLineOption::VerboseOptionType, + CommandLineOption::QuietOptionType, + CommandLineOption::ProductsOptionType}; +} + +QString DumpNodesTreeCommand::shortDescription() const +{ + return Tr::tr("Dumps the nodes in the build graph to stdout."); +} + +QString DumpNodesTreeCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1 [options] [config:] ...\n") + .arg(representation()); + description += Tr::tr("Internal command; for debugging purposes only.\n"); + return description += supportedOptionsDescription(); +} + +QString DumpNodesTreeCommand::representation() const +{ + return QStringLiteral("dump-nodes-tree"); +} + +QList DumpNodesTreeCommand::supportedOptions() const +{ + return {CommandLineOption::BuildDirectoryOptionType, + CommandLineOption::ProductsOptionType}; +} + +QString ListProductsCommand::shortDescription() const +{ + return Tr::tr("Lists all products in the project, including sub-projects."); +} + +QString ListProductsCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1 [options] [[config:] " + "[:] ...] ...\n").arg(representation()); + return description += supportedOptionsDescription(); +} + +QString ListProductsCommand::representation() const +{ + return QStringLiteral("list-products"); +} + +QList ListProductsCommand::supportedOptions() const +{ + return {CommandLineOption::FileOptionType, + CommandLineOption::BuildDirectoryOptionType}; +} + +QString HelpCommand::shortDescription() const +{ + return Tr::tr("Show general or command-specific help."); +} + +QString HelpCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1 []\n").arg(representation()); + return description += Tr::tr("Shows either the general help or a description of " + "the given command.\n"); +} + +QString HelpCommand::representation() const +{ + return QStringLiteral("help"); +} + +QList HelpCommand::supportedOptions() const +{ + return {}; +} + +void HelpCommand::parseNext(QStringList &input) +{ + if (input.empty()) + return; + if (input.size() > 1) + throwError(Tr::tr("Cannot describe more than one command.")); + m_command = input.takeFirst(); + QBS_CHECK(input.empty()); +} + +QString VersionCommand::shortDescription() const +{ + return Tr::tr("Print the Qbs version number to stdout."); +} + +QString VersionCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1\n").arg(representation()); + return description += Tr::tr("%1\n").arg(shortDescription()); +} + +QString VersionCommand::representation() const +{ + return QStringLiteral("show-version"); +} + +QList VersionCommand::supportedOptions() const +{ + return {}; +} + +void VersionCommand::parseNext(QStringList &input) +{ + QBS_CHECK(!input.empty()); + throwError(Tr::tr("This command takes no arguments.")); +} + +QString SessionCommand::shortDescription() const +{ + return Tr::tr("Starts a session for an IDE."); +} + +QString SessionCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1\n").arg(representation()); + return description += Tr::tr("Communicates on stdin and stdout via a JSON-based API.\n" + "Intended for use with other tools, such as IDEs.\n"); +} + +QString SessionCommand::representation() const +{ + return QLatin1String("session"); +} + +void SessionCommand::parseNext(QStringList &input) +{ + QBS_CHECK(!input.empty()); + throwError(Tr::tr("This command takes no arguments.")); +} + +} // namespace qbs diff --git a/src/app/qbs/parser/parsercommand.h b/src/app/qbs/parser/parsercommand.h new file mode 100644 index 00000000..8998d38e --- /dev/null +++ b/src/app/qbs/parser/parsercommand.h @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PARSER_COMMAND_H +#define QBS_PARSER_COMMAND_H + +#include "commandlineoption.h" +#include "commandtype.h" + +#include + +namespace qbs { +class CommandLineOptionPool; + +class Command +{ +public: + virtual ~Command(); + + virtual CommandType type() const = 0; + virtual QString shortDescription() const = 0; + virtual QString longDescription() const = 0; + virtual QString representation() const = 0; + + void parse(QStringList &input); + QStringList additionalArguments() const { return m_additionalArguments; } + bool canResolve() const; + +protected: + Command(CommandLineOptionPool &optionPool) : m_optionPool(optionPool) {} + + const CommandLineOptionPool &optionPool() const { return m_optionPool; } + QString supportedOptionsDescription() const; + [[noreturn]] void throwError(const QString &reason); + + virtual void parseNext(QStringList &input); + +private: + QList actualSupportedOptions() const; + void parseOption(QStringList &input); + void parsePropertyAssignment(const QString &argument); + + virtual QList supportedOptions() const = 0; + + QStringList m_additionalArguments; + std::set m_usedOptions; + const CommandLineOptionPool &m_optionPool; +}; + +class ResolveCommand : public Command +{ +public: + ResolveCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return ResolveCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class GenerateCommand : public Command +{ +public: + GenerateCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return GenerateCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class BuildCommand : public Command +{ +public: + BuildCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return BuildCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class CleanCommand : public Command +{ +public: + CleanCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return CleanCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class InstallCommand : public Command +{ +public: + InstallCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return InstallCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class RunCommand : public Command +{ +public: + RunCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + QStringList targetParameters() const { return m_targetParameters; } + +private: + CommandType type() const override { return RunCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; + void parseNext(QStringList &input) override; + + QStringList m_targetParameters; +}; + +class ShellCommand : public Command +{ +public: + ShellCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return ShellCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +// TODO: It seems wrong that a configuration has to be given here. Ideally, this command would just track *all* files regardless of conditions. Is that possible? +class StatusCommand : public Command +{ +public: + StatusCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return StatusCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class UpdateTimestampsCommand : public Command +{ +public: + UpdateTimestampsCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return UpdateTimestampsCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class DumpNodesTreeCommand : public Command +{ +public: + DumpNodesTreeCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override{ return DumpNodesTreeCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class ListProductsCommand : public Command +{ +public: + ListProductsCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return ListProductsCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; +}; + +class HelpCommand : public Command +{ +public: + HelpCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + QString commandToDescribe() const { return m_command; } + +private: + CommandType type() const override { return HelpCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; + void parseNext(QStringList &input) override; + + QString m_command; +}; + +class VersionCommand : public Command +{ +public: + VersionCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return VersionCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override; + void parseNext(QStringList &input) override; +}; + +class SessionCommand : public Command +{ +public: + SessionCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const override { return SessionCommandType; } + QString shortDescription() const override; + QString longDescription() const override; + QString representation() const override; + QList supportedOptions() const override { return {}; } + void parseNext(QStringList &input) override; +}; + +} // namespace qbs + +#endif // QBS_PARSER_COMMAND_H diff --git a/src/app/qbs/qbs.pro b/src/app/qbs/qbs.pro new file mode 100644 index 00000000..6ce449aa --- /dev/null +++ b/src/app/qbs/qbs.pro @@ -0,0 +1,54 @@ +include(../app.pri) +include(parser/parser.pri) + +TARGET = qbs + +SOURCES += main.cpp \ + ctrlchandler.cpp \ + application.cpp \ + session.cpp \ + sessionpacket.cpp \ + sessionpacketreader.cpp \ + stdinreader.cpp \ + status.cpp \ + consoleprogressobserver.cpp \ + commandlinefrontend.cpp \ + qbstool.cpp + +HEADERS += \ + ctrlchandler.h \ + application.h \ + session.h \ + sessionpacket.h \ + sessionpacketreader.h \ + stdinreader.h \ + status.h \ + consoleprogressobserver.h \ + commandlinefrontend.h \ + qbstool.h + +include(../../library_dirname.pri) +isEmpty(QBS_RELATIVE_LIBEXEC_PATH) { + win32:QBS_RELATIVE_LIBEXEC_PATH=. + else:QBS_RELATIVE_LIBEXEC_PATH=../libexec/qbs +} +isEmpty(QBS_RELATIVE_PLUGINS_PATH):QBS_RELATIVE_PLUGINS_PATH=../$${QBS_LIBRARY_DIRNAME} +isEmpty(QBS_RELATIVE_SEARCH_PATH):QBS_RELATIVE_SEARCH_PATH=.. +DEFINES += QBS_RELATIVE_LIBEXEC_PATH=\\\"$${QBS_RELATIVE_LIBEXEC_PATH}\\\" +DEFINES += QBS_RELATIVE_PLUGINS_PATH=\\\"$${QBS_RELATIVE_PLUGINS_PATH}\\\" +DEFINES += QBS_RELATIVE_SEARCH_PATH=\\\"$${QBS_RELATIVE_SEARCH_PATH}\\\" + +CONFIG(static, static|shared) { + include(../../plugins/qbs_plugin_common.pri) + LIBS += -L$$qbsPluginDestDir + scannerPlugins = cpp qt + for (scannerPlugin, scannerPlugins) { + include(../../plugins/scanner/$$scannerPlugin/$${scannerPlugin}.pri) \ + include(../../plugins/use_plugin.pri) + } + generatorPlugins = clangcompilationdb iarew keiluv makefilegenerator visualstudio + for (generatorPlugin, generatorPlugins) { + include(../../plugins/generator/$$generatorPlugin/$${generatorPlugin}.pri) \ + include(../../plugins/use_plugin.pri) + } +} diff --git a/src/app/qbs/qbs.qbs b/src/app/qbs/qbs.qbs new file mode 100644 index 00000000..03685dd2 --- /dev/null +++ b/src/app/qbs/qbs.qbs @@ -0,0 +1,58 @@ +import qbs.Utilities + +QbsApp { + name: "qbs_app" + Depends { name: "qbs resources" } + targetName: "qbs" + Depends { + condition: Qt.core.staticBuild || qbsbuildconfig.staticBuild + productTypes: ["qbsplugin"] + } + cpp.defines: base.concat([ + "QBS_VERSION=" + Utilities.cStringQuote(qbsversion.version), + "QBS_RELATIVE_LIBEXEC_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativeLibexecPath), + "QBS_RELATIVE_SEARCH_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativeSearchPath), + "QBS_RELATIVE_PLUGINS_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativePluginsPath), + ]) + files: [ + "application.cpp", + "application.h", + "commandlinefrontend.cpp", + "commandlinefrontend.h", + "consoleprogressobserver.cpp", + "consoleprogressobserver.h", + "ctrlchandler.cpp", + "ctrlchandler.h", + "main.cpp", + "qbstool.cpp", + "qbstool.h", + "session.cpp", + "session.h", + "sessionpacket.cpp", + "sessionpacket.h", + "sessionpacketreader.cpp", + "sessionpacketreader.h", + "status.cpp", + "status.h", + "stdinreader.cpp", + "stdinreader.h", + ] + Group { + name: "parser" + prefix: name + '/' + files: [ + "commandlineoption.cpp", + "commandlineoption.h", + "commandlineoptionpool.cpp", + "commandlineoptionpool.h", + "commandlineparser.cpp", + "commandlineparser.h", + "commandpool.cpp", + "commandpool.h", + "commandtype.h", + "parsercommand.cpp", + "parsercommand.h", + ] + } +} + diff --git a/src/app/qbs/qbstool.cpp b/src/app/qbs/qbstool.cpp new file mode 100644 index 00000000..318b7963 --- /dev/null +++ b/src/app/qbs/qbstool.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qbstool.h" + +#include + +#include +#include +#include +#include + +#include + +static QString toolPrefix() { return QStringLiteral("qbs-"); } +static QString qbsBinDir() { return QCoreApplication::applicationDirPath(); } + +static QString qbsToolFilePath(const QString &toolName) +{ + return qbsBinDir() + QLatin1Char('/') + toolPrefix() + + qbs::Internal::HostOsInfo::appendExecutableSuffix(toolName); +} + +void QbsTool::runTool(const QString &toolName, const QStringList &arguments) +{ + m_failedToStart = false; + m_exitCode = -1; + const QString filePath = qbsToolFilePath(toolName); + const QFileInfo fi(filePath); + if (!fi.exists() || !fi.isFile() || !fi.isExecutable()) { + m_failedToStart = true; + return; + } + QProcess toolProc; + toolProc.start(filePath, arguments); + if (!toolProc.waitForStarted()) + m_failedToStart = true; + toolProc.waitForFinished(-1); + m_exitCode = toolProc.exitCode(); + m_stdout = QString::fromLocal8Bit(toolProc.readAllStandardOutput()); + m_stderr = QString::fromLocal8Bit(toolProc.readAllStandardError()); +} + +bool QbsTool::tryToRunTool(const QString &toolName, const QStringList &arguments, int *exitCode) +{ + QbsTool tool; + tool.runTool(toolName, arguments); + if (exitCode) + *exitCode = tool.exitCode(); + if (tool.failedToStart()) + return false; + std::cout << qPrintable(tool.stdOut()); + std::cerr << qPrintable(tool.stdErr()); + return true; +} + +QStringList QbsTool::allToolNames() +{ + const QString suffix = QLatin1String(QBS_HOST_EXE_SUFFIX); + const QStringList toolFileNames = QDir(qbsBinDir()).entryList(QStringList(toolPrefix() + + QStringLiteral("*%1").arg(suffix)), QDir::Files, QDir::Name); + QStringList toolNames; + const int prefixLength = toolPrefix().size(); + for (const QString &toolFileName : toolFileNames) { + toolNames << toolFileName.mid(prefixLength, + toolFileName.size() - prefixLength - suffix.size()); + } + return toolNames; +} diff --git a/src/app/qbs/qbstool.h b/src/app/qbs/qbstool.h new file mode 100644 index 00000000..e6d23036 --- /dev/null +++ b/src/app/qbs/qbstool.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_QBSTOOL_H +#define QBS_QBSTOOL_H + +#include + +class QbsTool +{ +public: + void runTool(const QString &toolName, const QStringList &arguments); + + bool failedToStart() const { return m_failedToStart; } + int exitCode() const { return m_exitCode; } + QString stdOut() const { return m_stdout; } + QString stdErr() const { return m_stderr; } + + static QStringList allToolNames(); + static bool tryToRunTool(const QString &toolName, const QStringList &arguments, + int *exitCode = 0); + +private: + bool m_failedToStart = false; + int m_exitCode = 0; + QString m_stdout; + QString m_stderr; +}; + +#endif // QBS_QBSTOOL_H diff --git a/src/app/qbs/session.cpp b/src/app/qbs/session.cpp new file mode 100644 index 00000000..5a1fe145 --- /dev/null +++ b/src/app/qbs/session.cpp @@ -0,0 +1,762 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "session.h" + +#include "sessionpacket.h" +#include "sessionpacketreader.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef Q_OS_WIN32 +#include +#include +#include +#include +#include +#endif + +namespace qbs { +namespace Internal { + +class SessionLogSink : public QObject, public ILogSink +{ + Q_OBJECT +signals: + void newMessage(const QJsonObject &msg); + +private: + void doPrintMessage(LoggerLevel, const QString &message, const QString &) override + { + QJsonObject msg; + msg.insert(StringConstants::type(), QLatin1String("log-data")); + msg.insert(StringConstants::messageKey(), message); + emit newMessage(msg); + } + + void doPrintWarning(const ErrorInfo &warning) override + { + QJsonObject msg; + static const QString warningString(QLatin1String("warning")); + msg.insert(StringConstants::type(), warningString); + msg.insert(warningString, warning.toJson()); + emit newMessage(msg); + } +}; + +class Session : public QObject +{ + Q_OBJECT +public: + Session(); + +private: + enum class ProjectDataMode { Never, Always, OnlyIfChanged }; + ProjectDataMode dataModeFromRequest(const QJsonObject &request); + QStringList modulePropertiesFromRequest(const QJsonObject &request); + void insertProjectDataIfNecessary( + QJsonObject &reply, + ProjectDataMode dataMode, + const ProjectData &oldProjectData, + bool includeTopLevelData + ); + void setLogLevelFromRequest(const QJsonObject &request); + bool checkNormalRequestPrerequisites(const char *replyType); + + void sendPacket(const QJsonObject &message); + void setupProject(const QJsonObject &request); + void buildProject(const QJsonObject &request); + void cleanProject(const QJsonObject &request); + void installProject(const QJsonObject &request); + void addFiles(const QJsonObject &request); + void removeFiles(const QJsonObject &request); + void getRunEnvironment(const QJsonObject &request); + void getGeneratedFilesForSources(const QJsonObject &request); + void releaseProject(); + void cancelCurrentJob(); + void quitSession(); + + void sendErrorReply(const char *replyType, const QString &message); + void sendErrorReply(const char *replyType, const ErrorInfo &error); + void insertErrorInfoIfNecessary(QJsonObject &reply, const ErrorInfo &error); + void connectProgressSignals(AbstractJob *job); + QList getProductsByName(const QStringList &productNames) const; + ProductData getProductByName(const QString &productName) const; + + struct ProductSelection { + ProductSelection(Project::ProductSelection s) : selection(s) {} + ProductSelection(QList p) : products(std::move(p)) {} + + Project::ProductSelection selection = Project::ProductSelectionDefaultOnly; + QList products; + }; + ProductSelection getProductSelection(const QJsonObject &request); + + struct FileUpdateData { + QJsonObject createErrorReply(const char *type, const QString &mainMessage) const; + + ProductData product; + GroupData group; + QStringList filePaths; + ErrorInfo error; + }; + FileUpdateData prepareFileUpdate(const QJsonObject &request); + + SessionPacketReader m_packetReader; + Project m_project; + ProjectData m_projectData; + SessionLogSink m_logSink; + std::unique_ptr m_settings; + QJsonObject m_resolveRequest; + QStringList m_moduleProperties; + AbstractJob *m_currentJob = nullptr; +}; + +void startSession() +{ + const auto session = new Session; + QObject::connect(qApp, &QCoreApplication::aboutToQuit, session, [session] { delete session; }); +} + +Session::Session() +{ +#ifdef Q_OS_WIN32 + // Make sure the line feed character appears as itself. + if (_setmode(_fileno(stdout), _O_BINARY) == -1) { + constexpr size_t errmsglen = FILENAME_MAX; + char errmsg[errmsglen]; + strerror_s(errmsg, errmsglen, errno); + std::cerr << "Failed to set stdout to binary mode: " << errmsg << std::endl; + qApp->exit(EXIT_FAILURE); + } +#endif + sendPacket(SessionPacket::helloMessage()); + connect(&m_logSink, &SessionLogSink::newMessage, this, &Session::sendPacket); + connect(&m_packetReader, &SessionPacketReader::errorOccurred, + this, [](const QString &msg) { + std::cerr << qPrintable(tr("Error: %1").arg(msg)); + qApp->exit(EXIT_FAILURE); + }); + connect(&m_packetReader, &SessionPacketReader::packetReceived, this, [this](const QJsonObject &packet) { + // qDebug() << "got packet:" << packet; // Uncomment for debugging. + const QString type = packet.value(StringConstants::type()).toString(); + if (type == QLatin1String("resolve-project")) + setupProject(packet); + else if (type == QLatin1String("build-project")) + buildProject(packet); + else if (type == QLatin1String("clean-project")) + cleanProject(packet); + else if (type == QLatin1String("install-project")) + installProject(packet); + else if (type == QLatin1String("add-files")) + addFiles(packet); + else if (type == QLatin1String("remove-files")) + removeFiles(packet); + else if (type == QLatin1String("get-run-environment")) + getRunEnvironment(packet); + else if (type == QLatin1String("get-generated-files-for-sources")) + getGeneratedFilesForSources(packet); + else if (type == QLatin1String("release-project")) + releaseProject(); + else if (type == QLatin1String("quit")) + quitSession(); + else if (type == QLatin1String("cancel-job")) + cancelCurrentJob(); + else + sendErrorReply("protocol-error", tr("Unknown request type '%1'.").arg(type)); + }); + m_packetReader.start(); +} + +Session::ProjectDataMode Session::dataModeFromRequest(const QJsonObject &request) +{ + const QString modeString = request.value(QLatin1String("data-mode")).toString(); + if (modeString == QLatin1String("only-if-changed")) + return ProjectDataMode::OnlyIfChanged; + if (modeString == QLatin1String("always")) + return ProjectDataMode::Always; + return ProjectDataMode::Never; +} + +void Session::sendPacket(const QJsonObject &message) +{ + std::cout << SessionPacket::createPacket(message).constData() << std::flush; +} + +void Session::setupProject(const QJsonObject &request) +{ + if (m_currentJob) { + if (qobject_cast(m_currentJob) + && m_currentJob->state() == AbstractJob::StateCanceling) { + m_resolveRequest = request; + return; + } + sendErrorReply("project-resolved", + tr("Cannot start resolving while another job is still running.")); + return; + } + m_moduleProperties = modulePropertiesFromRequest(request); + auto params = SetupProjectParameters::fromJson(request); + const ProjectDataMode dataMode = dataModeFromRequest(request); + m_settings = std::make_unique(params.settingsDirectory()); + const Preferences prefs(m_settings.get()); + const QString appDir = QDir::cleanPath(QCoreApplication::applicationDirPath()); + params.setSearchPaths(prefs.searchPaths(appDir + QLatin1String( + "/" QBS_RELATIVE_SEARCH_PATH))); + params.setPluginPaths(prefs.pluginPaths(appDir + QLatin1String( + "/" QBS_RELATIVE_PLUGINS_PATH))); + params.setLibexecPath(appDir + QLatin1String("/" QBS_RELATIVE_LIBEXEC_PATH)); + params.setOverrideBuildGraphData(true); + setLogLevelFromRequest(request); + SetupProjectJob * const setupJob = m_project.setupProject(params, &m_logSink, this); + m_currentJob = setupJob; + connectProgressSignals(setupJob); + connect(setupJob, &AbstractJob::finished, this, + [this, setupJob, dataMode](bool success) { + if (!m_resolveRequest.isEmpty()) { // Canceled job was superseded. + const QJsonObject newRequest = std::move(m_resolveRequest); + m_resolveRequest = QJsonObject(); + m_currentJob->deleteLater(); + m_currentJob = nullptr; + setupProject(newRequest); + return; + } + const ProjectData oldProjectData = m_projectData; + m_project = setupJob->project(); + m_projectData = m_project.projectData(); + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("project-resolved")); + if (success) + insertProjectDataIfNecessary(reply, dataMode, oldProjectData, true); + else + insertErrorInfoIfNecessary(reply, setupJob->error()); + sendPacket(reply); + m_currentJob->deleteLater(); + m_currentJob = nullptr; + }); +} + +void Session::buildProject(const QJsonObject &request) +{ + if (!checkNormalRequestPrerequisites("project-built")) + return; + const ProductSelection productSelection = getProductSelection(request); + setLogLevelFromRequest(request); + auto options = BuildOptions::fromJson(request); + options.setSettingsDirectory(m_settings->baseDirectory()); + BuildJob * const buildJob = productSelection.products.empty() + ? m_project.buildAllProducts(options, productSelection.selection, this) + : m_project.buildSomeProducts(productSelection.products, options, this); + m_currentJob = buildJob; + m_moduleProperties = modulePropertiesFromRequest(request); + const ProjectDataMode dataMode = dataModeFromRequest(request); + connectProgressSignals(buildJob); + connect(buildJob, &BuildJob::reportCommandDescription, this, + [this](const QString &highlight, const QString &message) { + QJsonObject descData; + descData.insert(StringConstants::type(), QLatin1String("command-description")); + descData.insert(QLatin1String("highlight"), highlight); + descData.insert(StringConstants::messageKey(), message); + sendPacket(descData); + }); + connect(buildJob, &BuildJob::reportProcessResult, this, [this](const ProcessResult &result) { + if (result.success() && result.stdOut().isEmpty() && result.stdErr().isEmpty()) + return; + QJsonObject resultData = result.toJson(); + resultData.insert(StringConstants::type(), QLatin1String("process-result")); + sendPacket(resultData); + }); + connect(buildJob, &BuildJob::finished, this, + [this, dataMode](bool success) { + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("project-built")); + const ProjectData oldProjectData = m_projectData; + m_projectData = m_project.projectData(); + if (success) + insertProjectDataIfNecessary(reply, dataMode, oldProjectData, false); + else + insertErrorInfoIfNecessary(reply, m_currentJob->error()); + sendPacket(reply); + m_currentJob->deleteLater(); + m_currentJob = nullptr; + }); +} + +void Session::cleanProject(const QJsonObject &request) +{ + if (!checkNormalRequestPrerequisites("project-cleaned")) + return; + setLogLevelFromRequest(request); + const ProductSelection productSelection = getProductSelection(request); + const auto options = CleanOptions::fromJson(request); + m_currentJob = productSelection.products.empty() + ? m_project.cleanAllProducts(options, this) + : m_project.cleanSomeProducts(productSelection.products, options, this); + connectProgressSignals(m_currentJob); + connect(m_currentJob, &AbstractJob::finished, this, [this](bool success) { + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("project-cleaned")); + if (!success) + insertErrorInfoIfNecessary(reply, m_currentJob->error()); + sendPacket(reply); + m_currentJob->deleteLater(); + m_currentJob = nullptr; + }); +} + +void Session::installProject(const QJsonObject &request) +{ + if (!checkNormalRequestPrerequisites("install-done")) + return; + setLogLevelFromRequest(request); + const ProductSelection productSelection = getProductSelection(request); + const auto options = InstallOptions::fromJson(request); + m_currentJob = productSelection.products.empty() + ? m_project.installAllProducts(options, productSelection.selection, this) + : m_project.installSomeProducts(productSelection.products, options, this); + connectProgressSignals(m_currentJob); + connect(m_currentJob, &AbstractJob::finished, this, [this](bool success) { + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("install-done")); + if (!success) + insertErrorInfoIfNecessary(reply, m_currentJob->error()); + sendPacket(reply); + m_currentJob->deleteLater(); + m_currentJob = nullptr; + }); +} + +void Session::addFiles(const QJsonObject &request) +{ + const FileUpdateData data = prepareFileUpdate(request); + if (data.error.hasError()) { + sendPacket(data.createErrorReply("files-added", tr("Failed to add files to project: %1") + .arg(data.error.toString()))); + return; + } + ErrorInfo error; + QStringList failedFiles; + for (const QString &filePath : data.filePaths) { + const ErrorInfo e = m_project.addFiles(data.product, data.group, {filePath}); + if (e.hasError()) { + for (const ErrorItem &ei : e.items()) + error.append(ei); + failedFiles.push_back(filePath); + } + } + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("files-added")); + insertErrorInfoIfNecessary(reply, error); + + if (failedFiles.size() != data.filePaths.size()) { + // Note that Project::addFiles() directly changes the existing project data object, so + // there's no need to retrieve it from m_project. + insertProjectDataIfNecessary(reply, ProjectDataMode::Always, {}, false); + } + + if (!failedFiles.isEmpty()) + reply.insert(QLatin1String("failed-files"), QJsonArray::fromStringList(failedFiles)); + sendPacket(reply); +} + +void Session::removeFiles(const QJsonObject &request) +{ + const FileUpdateData data = prepareFileUpdate(request); + if (data.error.hasError()) { + sendPacket(data.createErrorReply("files-removed", + tr("Failed to remove files from project: %1") + .arg(data.error.toString()))); + return; + } + ErrorInfo error; + QStringList failedFiles; + for (const QString &filePath : data.filePaths) { + const ErrorInfo e = m_project.removeFiles(data.product, data.group, {filePath}); + if (e.hasError()) { + for (const ErrorItem &ei : e.items()) + error.append(ei); + failedFiles.push_back(filePath); + } + } + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String("files-removed")); + insertErrorInfoIfNecessary(reply, error); + if (failedFiles.size() != data.filePaths.size()) + insertProjectDataIfNecessary(reply, ProjectDataMode::Always, {}, false); + if (!failedFiles.isEmpty()) + reply.insert(QLatin1String("failed-files"), QJsonArray::fromStringList(failedFiles)); + sendPacket(reply); +} + +void Session::connectProgressSignals(AbstractJob *job) +{ + static QString maxProgressString(QLatin1String("max-progress")); + connect(job, &AbstractJob::taskStarted, this, + [this](const QString &description, int maxProgress) { + QJsonObject msg; + msg.insert(StringConstants::type(), QLatin1String("task-started")); + msg.insert(StringConstants::descriptionProperty(), description); + msg.insert(maxProgressString, maxProgress); + sendPacket(msg); + }); + connect(job, &AbstractJob::totalEffortChanged, this, [this](int maxProgress) { + QJsonObject msg; + msg.insert(StringConstants::type(), QLatin1String("new-max-progress")); + msg.insert(maxProgressString, maxProgress); + sendPacket(msg); + }); + connect(job, &AbstractJob::taskProgress, this, [this](int progress) { + QJsonObject msg; + msg.insert(StringConstants::type(), QLatin1String("task-progress")); + msg.insert(QLatin1String("progress"), progress); + sendPacket(msg); + }); +} + +static QList getProductsByNameForProject(const ProjectData &project, + QStringList &productNames) +{ + QList products; + if (productNames.empty()) + return products; + for (const ProductData &p : project.products()) { + for (auto it = productNames.begin(); it != productNames.end(); ++it) { + if (*it == p.fullDisplayName()) { + products << p; + productNames.erase(it); + if (productNames.empty()) + return products; + break; + } + } + } + for (const ProjectData &p : project.subProjects()) { + products << getProductsByNameForProject(p, productNames); + if (productNames.empty()) + break; + } + return products; +} + +QList Session::getProductsByName(const QStringList &productNames) const +{ + QStringList remainingNames = productNames; + return getProductsByNameForProject(m_projectData, remainingNames); +} + +ProductData Session::getProductByName(const QString &productName) const +{ + const QList products = getProductsByName({productName}); + return products.empty() ? ProductData() : products.first(); +} + +void Session::getRunEnvironment(const QJsonObject &request) +{ + const char * const replyType = "run-environment"; + if (!checkNormalRequestPrerequisites(replyType)) + return; + const QString productName = request.value(QLatin1String("product")).toString(); + const ProductData product = getProductByName(productName); + if (!product.isValid()) { + sendErrorReply(replyType, tr("No such product '%1'.").arg(productName)); + return; + } + const auto inEnv = fromJson( + request.value(QLatin1String("base-environment"))); + const QStringList config = fromJson(request.value(QLatin1String("config"))); + const RunEnvironment runEnv = m_project.getRunEnvironment(product, InstallOptions(), inEnv, + config, m_settings.get()); + ErrorInfo error; + const QProcessEnvironment outEnv = runEnv.runEnvironment(&error); + if (error.hasError()) { + sendErrorReply(replyType, error); + return; + } + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String(replyType)); + QJsonObject outEnvObj; + const QStringList keys = outEnv.keys(); + for (const QString &key : keys) + outEnvObj.insert(key, outEnv.value(key)); + reply.insert(QLatin1String("full-environment"), outEnvObj); + sendPacket(reply); +} + +void Session::getGeneratedFilesForSources(const QJsonObject &request) +{ + const char * const replyType = "generated-files-for-sources"; + if (!checkNormalRequestPrerequisites(replyType)) + return; + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String(replyType)); + const QJsonArray specs = request.value(StringConstants::productsKey()).toArray(); + QJsonArray resultProducts; + for (const QJsonValue &p : specs) { + const QJsonObject productObject = p.toObject(); + const ProductData product = getProductByName( + productObject.value(StringConstants::fullDisplayNameKey()).toString()); + if (!product.isValid()) + continue; + QJsonObject resultProduct; + resultProduct.insert(StringConstants::fullDisplayNameKey(), product.fullDisplayName()); + QJsonArray results; + const QJsonArray requests = productObject.value(QLatin1String("requests")).toArray(); + for (const QJsonValue &r : requests) { + const QJsonObject request = r.toObject(); + const QString filePath = request.value(QLatin1String("source-file")).toString(); + const QStringList tags = fromJson(request.value(QLatin1String("tags"))); + const bool recursive = request.value(QLatin1String("recursive")).toBool(); + const QStringList generatedFiles = m_project.generatedFiles(product, filePath, + recursive, tags); + if (!generatedFiles.isEmpty()) { + QJsonObject result; + result.insert(QLatin1String("source-file"), filePath); + result.insert(QLatin1String("generated-files"), + QJsonArray::fromStringList(generatedFiles)); + results << result; + } + } + if (!results.isEmpty()) { + resultProduct.insert(QLatin1String("results"), results); + resultProducts << resultProduct; + } + } + reply.insert(StringConstants::productsKey(), resultProducts); + sendPacket(reply); +} + +void Session::releaseProject() +{ + const char * const replyType = "project-released"; + if (!m_project.isValid()) { + sendErrorReply(replyType, tr("No open project.")); + return; + } + if (m_currentJob) { + m_currentJob->disconnect(this); + m_currentJob->cancel(); + m_currentJob = nullptr; + } + m_project = Project(); + m_projectData = ProjectData(); + m_resolveRequest = QJsonObject(); + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String(replyType)); + sendPacket(reply); +} + +void Session::cancelCurrentJob() +{ + if (m_currentJob) { + if (!m_resolveRequest.isEmpty()) + m_resolveRequest = QJsonObject(); + m_currentJob->cancel(); + } +} + +Session::ProductSelection Session::getProductSelection(const QJsonObject &request) +{ + const QJsonValue productSelection = request.value(StringConstants::productsKey()); + if (productSelection.isArray()) + return ProductSelection(getProductsByName(fromJson(productSelection))); + return ProductSelection(productSelection.toString() == QLatin1String("all") + ? Project::ProductSelectionWithNonDefault + : Project::ProductSelectionDefaultOnly); +} + +Session::FileUpdateData Session::prepareFileUpdate(const QJsonObject &request) +{ + FileUpdateData data; + const QString productName = request.value(QLatin1String("product")).toString(); + data.product = getProductByName(productName); + if (data.product.isValid()) { + const QString groupName = request.value(QLatin1String("group")).toString(); + for (const GroupData &g : data.product.groups()) { + if (g.name() == groupName) { + data.group = g; + break; + } + } + if (!data.group.isValid()) + data.error = tr("Group '%1' not found in product '%2'.").arg(groupName, productName); + } else { + data.error = tr("Product '%1' not found in project.").arg(productName); + } + const QJsonArray filesArray = request.value(QLatin1String("files")).toArray(); + for (const QJsonValue &v : filesArray) + data.filePaths << v.toString(); + if (m_currentJob) + data.error = tr("Cannot update the list of source files while a job is running."); + if (!m_project.isValid()) + data.error = tr("No valid project. You need to resolve first."); + return data; +} + +void Session::insertProjectDataIfNecessary(QJsonObject &reply, ProjectDataMode dataMode, + const ProjectData &oldProjectData, bool includeTopLevelData) +{ + const bool sendProjectData = dataMode == ProjectDataMode::Always + || (dataMode == ProjectDataMode::OnlyIfChanged && m_projectData != oldProjectData); + if (!sendProjectData) + return; + QJsonObject projectData = m_projectData.toJson(m_moduleProperties); + if (includeTopLevelData) { + QJsonArray buildSystemFiles; + for (const QString &f : m_project.buildSystemFiles()) + buildSystemFiles.push_back(f); + projectData.insert(StringConstants::buildDirectoryKey(), m_projectData.buildDirectory()); + projectData.insert(QLatin1String("build-system-files"), buildSystemFiles); + const Project::BuildGraphInfo bgInfo = m_project.getBuildGraphInfo(); + projectData.insert(QLatin1String("build-graph-file-path"), bgInfo.bgFilePath); + projectData.insert(QLatin1String("profile-data"), + QJsonObject::fromVariantMap(bgInfo.profileData)); + projectData.insert(QLatin1String("overridden-properties"), + QJsonObject::fromVariantMap(bgInfo.overriddenProperties)); + } + reply.insert(QLatin1String("project-data"), projectData); +} + +void Session::setLogLevelFromRequest(const QJsonObject &request) +{ + const QString logLevelString = request.value(QLatin1String("log-level")).toString(); + if (logLevelString.isEmpty()) + return; + for (const LoggerLevel l : {LoggerError, LoggerWarning, LoggerInfo, LoggerDebug, LoggerTrace}) { + if (logLevelString == logLevelName(l)) { + m_logSink.setLogLevel(l); + return; + } + } +} + +bool Session::checkNormalRequestPrerequisites(const char *replyType) +{ + if (m_currentJob) { + sendErrorReply(replyType, tr("Another job is still running.")); + return false; + } + if (!m_project.isValid()) { + sendErrorReply(replyType, tr("No valid project. You need to resolve first.")); + return false; + } + return true; +} + +QStringList Session::modulePropertiesFromRequest(const QJsonObject &request) +{ + return fromJson(request.value(StringConstants::modulePropertiesKey())); +} + +void Session::sendErrorReply(const char *replyType, const ErrorInfo &error) +{ + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String(replyType)); + insertErrorInfoIfNecessary(reply, error); + sendPacket(reply); +} + +void Session::sendErrorReply(const char *replyType, const QString &message) +{ + sendErrorReply(replyType, ErrorInfo(message)); +} + +void Session::insertErrorInfoIfNecessary(QJsonObject &reply, const ErrorInfo &error) +{ + if (error.hasError()) + reply.insert(QLatin1String("error"), error.toJson()); +} + +void Session::quitSession() +{ + m_logSink.disconnect(this); + m_packetReader.disconnect(this); + if (m_currentJob) { + m_currentJob->disconnect(this); + connect(m_currentJob, &AbstractJob::finished, qApp, QCoreApplication::quit); + m_currentJob->cancel(); + } else { + qApp->quit(); + } +} + +QJsonObject Session::FileUpdateData::createErrorReply(const char *type, + const QString &mainMessage) const +{ + QBS_ASSERT(error.hasError(), return QJsonObject()); + ErrorInfo error(mainMessage); + for (const ErrorItem &ei : error.items()) + error.append(ei); + QJsonObject reply; + reply.insert(StringConstants::type(), QLatin1String(type)); + reply.insert(QLatin1String("error"), error.toJson()); + reply.insert(QLatin1String("failed-files"), QJsonArray::fromStringList(filePaths)); + return reply; +} + +} // namespace Internal +} // namespace qbs + +#include diff --git a/src/app/qbs/session.h b/src/app/qbs/session.h new file mode 100644 index 00000000..ebbc93b1 --- /dev/null +++ b/src/app/qbs/session.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SESSION_H +#define QBS_SESSION_H + +namespace qbs { +namespace Internal { + +void startSession(); + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/app/qbs/sessionpacket.cpp b/src/app/qbs/sessionpacket.cpp new file mode 100644 index 00000000..dd6d1726 --- /dev/null +++ b/src/app/qbs/sessionpacket.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sessionpacket.h" + +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +const QByteArray packetStart = "qbsmsg:"; + +SessionPacket::Status SessionPacket::parseInput(QByteArray &input) +{ + //qDebug() << m_expectedPayloadLength << m_payload << input; + if (m_expectedPayloadLength == -1) { + const int packetStartOffset = input.indexOf(packetStart); + if (packetStartOffset == -1) + return Status::Incomplete; + const int numberOffset = packetStartOffset + packetStart.length(); + const int newLineOffset = input.indexOf('\n', numberOffset); + if (newLineOffset == -1) + return Status::Incomplete; + const QByteArray sizeString = input.mid(numberOffset, newLineOffset - numberOffset); + bool isNumber; + const int payloadLen = sizeString.toInt(&isNumber); + if (!isNumber || payloadLen < 0) + return Status::Invalid; + m_expectedPayloadLength = payloadLen; + input.remove(0, newLineOffset + 1); + } + const int bytesToAdd = m_expectedPayloadLength - m_payload.length(); + QBS_ASSERT(bytesToAdd >= 0, return Status::Invalid); + m_payload += input.left(bytesToAdd); + input.remove(0, bytesToAdd); + return isComplete() ? Status::Complete : Status::Incomplete; +} + +QJsonObject SessionPacket::retrievePacket() +{ + QBS_ASSERT(isComplete(), return QJsonObject()); + const auto packet = QJsonDocument::fromJson(QByteArray::fromBase64(m_payload)).object(); + m_payload.clear(); + m_expectedPayloadLength = -1; + return packet; +} + +QByteArray SessionPacket::createPacket(const QJsonObject &packet) +{ + const QByteArray jsonData = QJsonDocument(packet).toJson(QJsonDocument::Compact).toBase64(); + return QByteArray(packetStart).append(QByteArray::number(jsonData.length())).append('\n') + .append(jsonData); +} + +QJsonObject SessionPacket::helloMessage() +{ + return QJsonObject{ + {StringConstants::type(), QLatin1String("hello")}, + {QLatin1String("api-level"), 2}, + {QLatin1String("api-compat-level"), 2} + }; +} + +bool SessionPacket::isComplete() const +{ + return m_payload.length() == m_expectedPayloadLength; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/app/qbs/sessionpacket.h b/src/app/qbs/sessionpacket.h new file mode 100644 index 00000000..d919ff34 --- /dev/null +++ b/src/app/qbs/sessionpacket.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SESSIONPACKET_H +#define QBS_SESSIONPACKET_H + +#include +#include + +namespace qbs { +namespace Internal { + +class SessionPacket +{ +public: + enum class Status { Incomplete, Complete, Invalid }; + Status parseInput(QByteArray &input); + + QJsonObject retrievePacket(); + + static QByteArray createPacket(const QJsonObject &packet); + static QJsonObject helloMessage(); + +private: + bool isComplete() const; + + QByteArray m_payload; + int m_expectedPayloadLength = -1; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/app/qbs/sessionpacketreader.cpp b/src/app/qbs/sessionpacketreader.cpp new file mode 100644 index 00000000..e99ea01e --- /dev/null +++ b/src/app/qbs/sessionpacketreader.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sessionpacketreader.h" + +#include "sessionpacket.h" +#include "stdinreader.h" + +namespace qbs { +namespace Internal { + +class SessionPacketReader::Private +{ +public: + QByteArray incomingData; + SessionPacket currentPacket; +}; + +SessionPacketReader::SessionPacketReader(QObject *parent) + : QObject(parent) + , d(std::make_unique()) +{ } + +SessionPacketReader::~SessionPacketReader() = default; + +void SessionPacketReader::start() +{ + StdinReader * const stdinReader = StdinReader::create(this); + connect(stdinReader, &StdinReader::errorOccurred, this, &SessionPacketReader::errorOccurred); + connect(stdinReader, &StdinReader::dataAvailable, this, [this](const QByteArray &data) { + d->incomingData += data; + while (!d->incomingData.isEmpty()) { + switch (d->currentPacket.parseInput(d->incomingData)) { + case SessionPacket::Status::Invalid: + emit errorOccurred(tr("Received invalid input.")); + return; + case SessionPacket::Status::Complete: + emit packetReceived(d->currentPacket.retrievePacket()); + break; + case SessionPacket::Status::Incomplete: + return; + } + } + }); + stdinReader->start(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/app/qbs/sessionpacketreader.h b/src/app/qbs/sessionpacketreader.h new file mode 100644 index 00000000..f186fbc8 --- /dev/null +++ b/src/app/qbs/sessionpacketreader.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SESSIONPACKETREADER_H +#define QBS_SESSIONPACKETREADER_H + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class SessionPacketReader : public QObject +{ + Q_OBJECT +public: + explicit SessionPacketReader(QObject *parent = nullptr); + ~SessionPacketReader() override; + + void start(); + +signals: + void packetReceived(const QJsonObject &packet); + void errorOccurred(const QString &msg); + +private: + class Private; + const std::unique_ptr d; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/app/qbs/status.cpp b/src/app/qbs/status.cpp new file mode 100644 index 00000000..127d26a5 --- /dev/null +++ b/src/app/qbs/status.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "status.h" + +#include "../shared/logging/consolelogger.h" + +#include +#include + +#include +#include +#include +#include +#include + +namespace qbs { + +static QList createIgnoreList(const QString &projectRootPath) +{ + QList ignoreRegularExpressionList { + QRegularExpression(QRegularExpression::anchoredPattern(projectRootPath + QLatin1String("/build.*"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.qbs"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.pro"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*Makefile"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.so*"))), + QRegularExpression(QRegularExpression::wildcardToRegularExpression(QStringLiteral("*.o"))) + }; + QString ignoreFilePath = projectRootPath + QLatin1String("/.qbsignore"); + + QFile ignoreFile(ignoreFilePath); + + if (ignoreFile.open(QFile::ReadOnly)) { + const QList ignoreTokenList = ignoreFile.readAll().split('\n'); + for (const QByteArray &btoken : ignoreTokenList) { + const QString token = QString::fromLatin1(btoken); + if (token.startsWith(QLatin1String("/"))) + ignoreRegularExpressionList.push_back( + QRegularExpression(QRegularExpression::anchoredPattern( + projectRootPath + token + QLatin1String(".*")))); + else if (!token.isEmpty()) + ignoreRegularExpressionList.push_back( + QRegularExpression(QRegularExpression::anchoredPattern(token))); + + } + } + + return ignoreRegularExpressionList; +} + +static QStringList allFilesInDirectoryRecursive( + const QDir &rootDirecory, const QList &ignoreRegularExpressionList) +{ + QStringList fileList; + + const auto fileInfos = rootDirecory.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + for (const QFileInfo &fileInfo : fileInfos) { + QString absoluteFilePath = fileInfo.absoluteFilePath(); + bool inIgnoreList = false; + for (const QRegularExpression &ignoreRegularExpression : ignoreRegularExpressionList) { + if (ignoreRegularExpression.match(absoluteFilePath).hasMatch()) { + inIgnoreList = true; + break; + } + } + + if (!inIgnoreList) { + if (fileInfo.isFile()) + fileList.push_back(absoluteFilePath); + else if (fileInfo.isDir()) + fileList << allFilesInDirectoryRecursive(QDir(absoluteFilePath), ignoreRegularExpressionList); + + } + } + + return fileList; +} + +static QStringList allFilesInProject(const QString &projectRootPath) +{ + QList ignoreRegularExpressionList = createIgnoreList(projectRootPath); + + return allFilesInDirectoryRecursive(QDir(projectRootPath), ignoreRegularExpressionList); +} + +QStringList allFiles(const ProductData &product) +{ + QStringList files; + for (const GroupData &group : product.groups()) + files += group.allFilePaths(); + return files; +} + +int printStatus(const ProjectData &project) +{ + const QString projectFilePath = project.location().filePath(); + QString projectDirectory = QFileInfo(projectFilePath).dir().path(); + int projectDirectoryPathLength = projectDirectory.length(); + + QStringList untrackedFilesInProject = allFilesInProject(projectDirectory); + QStringList missingFiles; + for (const ProductData &product : project.allProducts()) { + qbsInfo() << "\nProduct: " << product.name() + << " (" << product.location().filePath() << ":" + << product.location().line() << ")"; + for (const GroupData &group : product.groups()) { + qbsInfo() << " Group: " << group.name() + << " (" << group.location().filePath() << ":" + << group.location().line() << ")"; + QStringList sourceFiles = group.allFilePaths(); + std::sort(sourceFiles.begin(), sourceFiles.end()); + for (const QString &sourceFile : qAsConst(sourceFiles)) { + if (!QFileInfo::exists(sourceFile)) + missingFiles.push_back(sourceFile); + qbsInfo() << " " << sourceFile.mid(projectDirectoryPathLength + 1); + untrackedFilesInProject.removeOne(sourceFile); + } + } + } + + qbsInfo() << "\nMissing files:"; + for (const QString &untrackedFile : qAsConst(missingFiles)) + qbsInfo() << " " << untrackedFile.mid(projectDirectoryPathLength + 1); + + qbsInfo() << "\nUntracked files:"; + for (const QString &missingFile : qAsConst(untrackedFilesInProject)) + qbsInfo() << " " << missingFile.mid(projectDirectoryPathLength + 1); + + return 0; +} + +} // namespace qbs diff --git a/src/app/qbs/status.h b/src/app/qbs/status.h new file mode 100644 index 00000000..301363d7 --- /dev/null +++ b/src/app/qbs/status.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef STATUS_H +#define STATUS_H + +namespace qbs { +class ProjectData; + +int printStatus(const ProjectData &project); + +} // namespace qbs + +#endif // STATUS_H diff --git a/src/app/qbs/stdinreader.cpp b/src/app/qbs/stdinreader.cpp new file mode 100644 index 00000000..5f00d7de --- /dev/null +++ b/src/app/qbs/stdinreader.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "stdinreader.h" + +#include + +#include +#include +#include + +#include +#include + +#ifdef Q_OS_WIN32 +#include +#else +#include +#endif + +namespace qbs { +namespace Internal { + +class UnixStdinReader : public StdinReader +{ +public: + UnixStdinReader(QObject *parent) : StdinReader(parent), m_notifier(0, QSocketNotifier::Read) {} + +private: + void start() override + { + if (!m_stdIn.open(stdin, QIODevice::ReadOnly)) { + emit errorOccurred(tr("Cannot read from standard input.")); + return; + } +#ifdef Q_OS_UNIX + const auto emitError = [this] { + emit errorOccurred(tr("Failed to make standard input non-blocking: %1") + .arg(QLatin1String(std::strerror(errno)))); + }; + const int flags = fcntl(0, F_GETFL, 0); + if (flags == -1) { + emitError(); + return; + } + if (fcntl(0, F_SETFL, flags | O_NONBLOCK)) { + emitError(); + return; + } +#endif + connect(&m_notifier, &QSocketNotifier::activated, this, [this] { + emit dataAvailable(m_stdIn.readAll()); + }); + + // Neither the aboutToClose() nor the readChannelFinished() signals + // are triggering, so we need a timer to check whether the controlling + // process disappeared. + const auto stdinClosedChecker = new QTimer(this); + connect(stdinClosedChecker, &QTimer::timeout, this, [this, stdinClosedChecker] { + if (m_stdIn.atEnd()) { + stdinClosedChecker->stop(); + emit errorOccurred(tr("Input channel closed unexpectedly.")); + } + }); + stdinClosedChecker->start(1000); + } + + QFile m_stdIn; + QSocketNotifier m_notifier; +}; + +class WindowsStdinReader : public StdinReader +{ +public: + WindowsStdinReader(QObject *parent) : StdinReader(parent) {} + +private: + void start() override + { +#ifdef Q_OS_WIN32 + m_stdinHandle = GetStdHandle(STD_INPUT_HANDLE); + if (!m_stdinHandle) { + emit errorOccurred(tr("Failed to create handle for standard input.")); + return; + } + + // A timer seems slightly less awful than to block in a thread + // (how would we abort that one?), but ideally we'd like + // to have a signal-based approach like in the Unix variant. + const auto timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, [this, timer] { + char buf[1024]; + DWORD bytesAvail; + if (!PeekNamedPipe(m_stdinHandle, nullptr, 0, nullptr, &bytesAvail, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } + while (bytesAvail > 0) { + DWORD bytesRead; + if (!ReadFile(m_stdinHandle, buf, std::min(bytesAvail, sizeof buf), + &bytesRead, nullptr)) { + timer->stop(); + emit errorOccurred(tr("Failed to read from input channel.")); + return; + } + emit dataAvailable(QByteArray(buf, bytesRead)); + bytesAvail -= bytesRead; + } + }); + timer->start(10); +#endif + } + +#ifdef Q_OS_WIN32 + HANDLE m_stdinHandle; +#endif +}; + +StdinReader *StdinReader::create(QObject *parent) +{ + if (HostOsInfo::isWindowsHost()) + return new WindowsStdinReader(parent); + return new UnixStdinReader(parent); +} + +StdinReader::StdinReader(QObject *parent) : QObject(parent) { } + +} // namespace Internal +} // namespace qbs diff --git a/src/app/qbs/stdinreader.h b/src/app/qbs/stdinreader.h new file mode 100644 index 00000000..b3737e5a --- /dev/null +++ b/src/app/qbs/stdinreader.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_STDINREADER_H +#define QBS_STDINREADER_H + +#include + +namespace qbs { +namespace Internal { + +class StdinReader : public QObject +{ + Q_OBJECT +public: + static StdinReader *create(QObject *parent); + virtual void start() = 0; + +signals: + void errorOccurred(const QString &error); + void dataAvailable(const QByteArray &data); + +protected: + explicit StdinReader(QObject *parent); +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/app/shared/CMakeLists.txt b/src/app/shared/CMakeLists.txt new file mode 100644 index 00000000..504db2b5 --- /dev/null +++ b/src/app/shared/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(logging) diff --git a/src/app/shared/logging/CMakeLists.txt b/src/app/shared/logging/CMakeLists.txt new file mode 100644 index 00000000..f6e4fc13 --- /dev/null +++ b/src/app/shared/logging/CMakeLists.txt @@ -0,0 +1,12 @@ +set(SOURCES + coloredoutput.cpp + coloredoutput.h + consolelogger.cpp + consolelogger.h + ) + +add_qbs_library(qbsconsolelogger + STATIC + DEPENDS qbscore + SOURCES ${SOURCES} + ) diff --git a/src/app/shared/logging/coloredoutput.cpp b/src/app/shared/logging/coloredoutput.cpp new file mode 100644 index 00000000..d5e45cad --- /dev/null +++ b/src/app/shared/logging/coloredoutput.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "coloredoutput.h" +#include +#ifdef Q_OS_WIN32 +# include +#endif + +#include + +#ifdef Q_OS_UNIX +#include +#endif + +void printfColored(TextColor color, const char *str, va_list vl) +{ + fprintfColored(color, stdout, str, vl); +} + +void printfColored(TextColor color, const char *str, ...) +{ + va_list vl; + va_start(vl, str); + printfColored(color, str, vl); + va_end(vl); +} + +void fprintfColored(TextColor color, std::FILE *file, const char *str, va_list vl) +{ +#if defined(Q_OS_UNIX) + if (color != TextColorDefault && isatty(fileno(file))) { + unsigned char bright = (color & TextColorBright) >> 3; + std::fprintf(file, "\033[%d;%dm", bright, 30 + (color & ~TextColorBright)); + std::vfprintf(file, str, vl); + std::fprintf(stdout, "\033[0m"); + std::fprintf(stderr, "\033[0m"); + } else +#elif defined(Q_OS_WIN32) + HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + if (color != TextColorDefault + && hStdout != INVALID_HANDLE_VALUE + && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) + { + WORD bgrColor = ((color & 1) << 2) | (color & 2) | ((color & 4) >> 2); // BGR instead of RGB. + if (color & TextColorBright) + bgrColor += FOREGROUND_INTENSITY; + SetConsoleTextAttribute(hStdout, (csbiInfo.wAttributes & 0xf0) | bgrColor); + std::vfprintf(file, str, vl); + SetConsoleTextAttribute(hStdout, csbiInfo.wAttributes); + } else +#endif + { + std::vfprintf(file, str, vl); + } +} + +void fprintfColored(TextColor color, std::FILE *file, const char *str, ...) +{ + va_list vl; + va_start(vl, str); + fprintfColored(color, file, str, vl); + va_end(vl); +} + +bool terminalSupportsColor() +{ +#if defined(Q_OS_UNIX) + const QByteArray &term = qgetenv("TERM"); + return !term.isEmpty() && term != "dumb"; +#else + return true; +#endif +} diff --git a/src/app/shared/logging/coloredoutput.h b/src/app/shared/logging/coloredoutput.h new file mode 100644 index 00000000..5b98a4ba --- /dev/null +++ b/src/app/shared/logging/coloredoutput.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_COLOREDOUTPUT_H +#define QBS_COLOREDOUTPUT_H + +#include +#include + +// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors +enum TextColor { + TextColorDefault = -1, + TextColorBlack = 0, + TextColorDarkRed = 1, + TextColorDarkGreen = 2, + TextColorDarkBlue = 4, + TextColorDarkCyan = TextColorDarkGreen | TextColorDarkBlue, + TextColorDarkMagenta = TextColorDarkRed | TextColorDarkBlue, + TextColorDarkYellow = TextColorDarkRed | TextColorDarkGreen, + TextColorGray = 7, + TextColorBright = 8, + TextColorRed = TextColorDarkRed | TextColorBright, + TextColorGreen = TextColorDarkGreen | TextColorBright, + TextColorBlue = TextColorDarkBlue | TextColorBright, + TextColorCyan = TextColorDarkCyan | TextColorBright, + TextColorMagenta = TextColorDarkMagenta | TextColorBright, + TextColorYellow = TextColorDarkYellow | TextColorBright, + TextColorWhite = TextColorGray | TextColorBright +}; + +void printfColored(TextColor color, const char *str, va_list vl); +void printfColored(TextColor color, const char *str, ...); +void fprintfColored(TextColor color, std::FILE *file, const char *str, va_list vl); +void fprintfColored(TextColor color, std::FILE *file, const char *str, ...); +bool terminalSupportsColor(); + +#endif // QBS_COLOREDOUTPUT_H diff --git a/src/app/shared/logging/consolelogger.cpp b/src/app/shared/logging/consolelogger.cpp new file mode 100644 index 00000000..8850ba48 --- /dev/null +++ b/src/app/shared/logging/consolelogger.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "consolelogger.h" + +#include +#include + +#include + +static QHash setupColorTable() +{ + QHash colorTable; + colorTable[QStringLiteral("compiler")] = TextColorDefault; + colorTable[QStringLiteral("linker")] = TextColorDarkGreen; + colorTable[QStringLiteral("codegen")] = TextColorDarkYellow; + colorTable[QStringLiteral("filegen")] = TextColorDarkYellow; + return colorTable; +} + +ConsoleLogSink::ConsoleLogSink() : m_coloredOutputEnabled(true), m_enabled(true) +{ +} + +void ConsoleLogSink::doPrintMessage(qbs::LoggerLevel level, const QString &message, + const QString &tag) +{ + if (!m_enabled) + return; + + std::FILE * const file = level == qbs::LoggerInfo && tag != QStringLiteral("stdErr") + ? stdout : stderr; + + const QString levelTag = logLevelTag(level); + TextColor color = TextColorDefault; + switch (level) { + case qbs::LoggerError: + color = TextColorRed; + break; + case qbs::LoggerWarning: + color = TextColorYellow; + break; + default: + break; + } + + fprintfWrapper(color, file, levelTag.toLocal8Bit().constData()); + static QHash colorTable = setupColorTable(); + fprintfWrapper(colorTable.value(tag, TextColorDefault), file, "%s\n", + message.toLocal8Bit().constData()); + std::fflush(file); +} + +void ConsoleLogSink::fprintfWrapper(TextColor color, std::FILE *file, const char *str, ...) +{ + va_list vl; + va_start(vl, str); + if (m_coloredOutputEnabled && terminalSupportsColor()) + fprintfColored(color, file, str, vl); + else + std::vfprintf(file, str, vl); + va_end(vl); +} + + +ConsoleLogger &ConsoleLogger::instance(qbs::Settings *settings) +{ + static ConsoleLogger logger(settings); + return logger; +} + +void ConsoleLogger::setSettings(qbs::Settings *settings) +{ + if (settings) + m_logSink.setColoredOutputEnabled(qbs::Preferences(settings).useColoredOutput()); +} + +ConsoleLogger::ConsoleLogger(qbs::Settings *settings) : Logger(&m_logSink) +{ + setSettings(settings); +} diff --git a/src/app/shared/logging/consolelogger.h b/src/app/shared/logging/consolelogger.h new file mode 100644 index 00000000..db7a705f --- /dev/null +++ b/src/app/shared/logging/consolelogger.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LOGSINK_H +#define QBS_LOGSINK_H + +#include "coloredoutput.h" + +#include + +namespace qbs { class Settings; } + +class ConsoleLogSink : public qbs::ILogSink +{ +public: + ConsoleLogSink(); + + void setColoredOutputEnabled(bool enabled) { m_coloredOutputEnabled = enabled; } + void setEnabled(bool enabled) { m_enabled = enabled; } + +private: + void doPrintMessage(qbs::LoggerLevel level, const QString &message, const QString &tag) override; + void fprintfWrapper(TextColor color, FILE *file, const char *str, ...); + +private: + bool m_coloredOutputEnabled; + bool m_enabled; +}; + + +class ConsoleLogger : public qbs::Internal::Logger +{ +public: + static ConsoleLogger &instance(qbs::Settings *settings = 0); + ConsoleLogSink *logSink() { return &m_logSink; } + void setSettings(qbs::Settings *settings); + +private: + ConsoleLogger(qbs::Settings *settings); + + ConsoleLogSink m_logSink; +}; + +inline qbs::Internal::LogWriter qbsError() { + return ConsoleLogger::instance().qbsLog(qbs::LoggerError); +} +inline qbs::Internal::LogWriter qbsWarning() { return ConsoleLogger::instance().qbsWarning(); } +inline qbs::Internal::LogWriter qbsInfo() { return ConsoleLogger::instance().qbsInfo(); } +inline qbs::Internal::LogWriter qbsDebug() { return ConsoleLogger::instance().qbsDebug(); } +inline qbs::Internal::LogWriter qbsTrace() { return ConsoleLogger::instance().qbsTrace(); } + +#endif // QBS_LOGSINK_H diff --git a/src/app/shared/logging/logging.pri b/src/app/shared/logging/logging.pri new file mode 100644 index 00000000..e24f33e1 --- /dev/null +++ b/src/app/shared/logging/logging.pri @@ -0,0 +1,2 @@ +HEADERS += $$PWD/consolelogger.h $$PWD/coloredoutput.h +SOURCES += $$PWD/consolelogger.cpp $$PWD/coloredoutput.cpp diff --git a/src/app/shared/logging/logging.qbs b/src/app/shared/logging/logging.qbs new file mode 100644 index 00000000..4e0738a4 --- /dev/null +++ b/src/app/shared/logging/logging.qbs @@ -0,0 +1,14 @@ +QbsStaticLibrary { + Depends { name: "qbscore" } + name: "qbsconsolelogger" + files: [ + "coloredoutput.cpp", + "coloredoutput.h", + "consolelogger.cpp", + "consolelogger.h" + ] + Export { + Depends { name: "cpp" } + cpp.includePaths: "." + } +} diff --git a/src/app/shared/shared.qbs b/src/app/shared/shared.qbs new file mode 100644 index 00000000..8f964168 --- /dev/null +++ b/src/app/shared/shared.qbs @@ -0,0 +1,5 @@ +Project { + references: [ + "logging/logging.qbs", + ] +} diff --git a/src/install_prefix.pri b/src/install_prefix.pri new file mode 100644 index 00000000..34aef1d5 --- /dev/null +++ b/src/install_prefix.pri @@ -0,0 +1 @@ +unix: isEmpty(QBS_INSTALL_PREFIX): QBS_INSTALL_PREFIX = /usr/local diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 00000000..48eee260 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,7 @@ +if (QBS_USE_BUNDLED_QT_SCRIPT OR NOT Qt5Script_FOUND) + add_subdirectory(scriptengine) +endif() + +add_subdirectory(pkgconfig) +add_subdirectory(corelib) +add_subdirectory(msbuild) diff --git a/src/lib/bundledlibs.pri b/src/lib/bundledlibs.pri new file mode 100644 index 00000000..6ffedbbd --- /dev/null +++ b/src/lib/bundledlibs.pri @@ -0,0 +1,3 @@ +!qbs_use_bundled_qtscript:!qtHaveModule(script) { + CONFIG += qbs_use_bundled_qtscript +} diff --git a/src/lib/corelib/CMakeLists.txt b/src/lib/corelib/CMakeLists.txt new file mode 100644 index 00000000..a6efd0ff --- /dev/null +++ b/src/lib/corelib/CMakeLists.txt @@ -0,0 +1,474 @@ +set(QBS_HEADERS qbs.h) + +set(FILE_UPDATE_SOURCES + changeset.cpp + changeset.h + projectfileupdater.cpp + projectfileupdater.h + qmljsrewriter.cpp + qmljsrewriter.h + ) +list_transform_prepend(FILE_UPDATE_SOURCES api/) + +set(API_SOURCES + internaljobs.cpp + internaljobs.h + jobs.cpp + languageinfo.cpp + project.cpp + project_p.h + projectdata.cpp + projectdata_p.h + propertymap_p.h + rulecommand.cpp + rulecommand_p.h + runenvironment.cpp + transformerdata.cpp + transformerdata_p.h + ) +list_transform_prepend(API_SOURCES api/) + +set(API_HEADERS + jobs.h + languageinfo.h + project.h + projectdata.h + rulecommand.h + runenvironment.h + transformerdata.h + ) +list_transform_prepend(API_HEADERS api/) + +set(BUILD_GRAPH_SOURCES + abstractcommandexecutor.cpp + abstractcommandexecutor.h + artifact.cpp + artifact.h + artifactcleaner.cpp + artifactcleaner.h + artifactsscriptvalue.cpp + artifactsscriptvalue.h + artifactvisitor.cpp + artifactvisitor.h + buildgraph.cpp + buildgraph.h + buildgraphnode.cpp + buildgraphnode.h + buildgraphloader.cpp + buildgraphloader.h + buildgraphvisitor.h + cycledetector.cpp + cycledetector.h + dependencyparametersscriptvalue.cpp + dependencyparametersscriptvalue.h + depscanner.cpp + depscanner.h + emptydirectoriesremover.cpp + emptydirectoriesremover.h + environmentscriptrunner.cpp + environmentscriptrunner.h + executor.cpp + executor.h + executorjob.cpp + executorjob.h + filedependency.cpp + filedependency.h + inputartifactscanner.cpp + inputartifactscanner.h + jscommandexecutor.cpp + jscommandexecutor.h + nodeset.cpp + nodeset.h + nodetreedumper.cpp + nodetreedumper.h + processcommandexecutor.cpp + processcommandexecutor.h + productbuilddata.cpp + productbuilddata.h + productinstaller.cpp + productinstaller.h + projectbuilddata.cpp + projectbuilddata.h + qtmocscanner.cpp + qtmocscanner.h + rawscanneddependency.cpp + rawscanneddependency.h + rawscanresults.cpp + rawscanresults.h + requestedartifacts.cpp + requestedartifacts.h + requesteddependencies.cpp + requesteddependencies.h + rescuableartifactdata.h + rulecommands.cpp + rulecommands.h + rulegraph.cpp + rulegraph.h + rulenode.cpp + rulenode.h + rulesapplicator.cpp + rulesapplicator.h + rulesevaluationcontext.cpp + rulesevaluationcontext.h + scriptclasspropertyiterator.h + timestampsupdater.cpp + timestampsupdater.h + transformer.cpp + transformer.h + transformerchangetracking.cpp + transformerchangetracking.h + ) +list_transform_prepend(BUILD_GRAPH_SOURCES buildgraph/) + +set(BUILD_GRAPH_HEADERS buildgraph/forward_decls.h) + +set(GENERATORS_SOURCES + generatableprojectiterator.cpp + generatableprojectiterator.h + generator.cpp + generatordata.cpp + generatorutils.cpp + generatorutils.h + generatorversioninfo.cpp + generatorversioninfo.h + igeneratableprojectvisitor.h + ixmlnodevisitor.h + xmlproject.cpp + xmlproject.h + xmlprojectwriter.cpp + xmlprojectwriter.h + xmlproperty.cpp + xmlproperty.h + xmlpropertygroup.cpp + xmlpropertygroup.h + xmlworkspace.cpp + xmlworkspace.h + xmlworkspacewriter.cpp + xmlworkspacewriter.h + ) +list_transform_prepend(GENERATORS_SOURCES generators/) + +set(GENERATORS_HEADERS generators/generator.h generators/generatordata.h) + +set(JS_EXTENSIONS_SOURCES + environmentextension.cpp + file.cpp + fileinfoextension.cpp + host.cpp + jsextensions.cpp + jsextensions.h + moduleproperties.cpp + moduleproperties.h + pkgconfigjs.cpp + pkgconfigjs.h + process.cpp + temporarydir.cpp + textfile.cpp + binaryfile.cpp + utilitiesextension.cpp + domxml.cpp + ) +list_transform_prepend(JS_EXTENSIONS_SOURCES jsextensions/) + +if(APPLE) + set(JS_EXTENSIONS_MACOS_SOURCES + propertylist_darwin.h + propertylist_darwin.mm + propertylistutils.h + propertylistutils.mm + ) +else() + set(JS_EXTENSIONS_MACOS_SOURCES propertylist.cpp) +endif() +list_transform_prepend(JS_EXTENSIONS_MACOS_SOURCES jsextensions/) + +set(LANGUAGE_SOURCES + artifactproperties.cpp + artifactproperties.h + astimportshandler.cpp + astimportshandler.h + astpropertiesitemhandler.cpp + astpropertiesitemhandler.h + asttools.cpp + asttools.h + builtindeclarations.cpp + builtindeclarations.h + deprecationinfo.h + evaluationdata.h + evaluator.cpp + evaluator.h + evaluatorscriptclass.cpp + evaluatorscriptclass.h + filecontext.cpp + filecontext.h + filecontextbase.cpp + filecontextbase.h + filetags.cpp + filetags.h + identifiersearch.cpp + identifiersearch.h + item.cpp + item.h + itemdeclaration.cpp + itemdeclaration.h + itemobserver.h + itempool.cpp + itempool.h + itemreader.cpp + itemreader.h + itemreaderastvisitor.cpp + itemreaderastvisitor.h + itemreadervisitorstate.cpp + itemreadervisitorstate.h + itemtype.h + jsimports.h + language.cpp + language.h + loader.cpp + loader.h + moduleloader.cpp + moduleloader.h + modulemerger.cpp + modulemerger.h + moduleproviderinfo.h + moduleproviderloader.cpp + moduleproviderloader.h + preparescriptobserver.cpp + preparescriptobserver.h + probesresolver.cpp + probesresolver.h + projectresolver.cpp + projectresolver.h + property.cpp + property.h + propertydeclaration.cpp + propertydeclaration.h + propertymapinternal.cpp + propertymapinternal.h + qualifiedid.cpp + qualifiedid.h + resolvedfilecontext.cpp + resolvedfilecontext.h + scriptengine.cpp + scriptengine.h + scriptimporter.cpp + scriptimporter.h + scriptpropertyobserver.cpp + scriptpropertyobserver.h + value.cpp + value.h + ) +list_transform_prepend(LANGUAGE_SOURCES language/) + +set(LANGUAGE_HEADERS language/forward_decls.h) + +set(LOGGING_SOURCES + categories.cpp + categories.h + ilogsink.cpp + logger.cpp + logger.h + translator.h + ) +list_transform_prepend(LOGGING_SOURCES logging/) + +set(LOGGING_HEADERS logging/ilogsink.h) + +set(PARSER_SOURCES + qmlerror.cpp + qmlerror.h + qmljsast.cpp + qmljsast_p.h + qmljsastfwd_p.h + qmljsastvisitor.cpp + qmljsastvisitor_p.h + qmljsengine_p.cpp + qmljsengine_p.h + qmljsglobal_p.h + qmljsgrammar.cpp + qmljsgrammar_p.h + qmljskeywords_p.h + qmljslexer.cpp + qmljslexer_p.h + qmljsmemorypool_p.h + qmljsparser.cpp + qmljsparser_p.h + ) +list_transform_prepend(PARSER_SOURCES parser/) + +set(TOOLS_SOURCES + architectures.cpp + buildgraphlocker.cpp + buildgraphlocker.h + buildoptions.cpp + clangclinfo.cpp + clangclinfo.h + cleanoptions.cpp + codelocation.cpp + commandechomode.cpp + dynamictypecheck.h + error.cpp + executablefinder.cpp + executablefinder.h + fileinfo.cpp + fileinfo.h + filesaver.cpp + filesaver.h + filetime.cpp + filetime.h + generateoptions.cpp + hostosinfo.h + id.cpp + id.h + iosutils.h + joblimits.cpp + jsliterals.cpp + jsliterals.h + jsonhelper.h + installoptions.cpp + launcherinterface.cpp + launcherinterface.h + launcherpackets.cpp + launcherpackets.h + launchersocket.cpp + launchersocket.h + msvcinfo.cpp + msvcinfo.h + pathutils.h + persistence.cpp + persistence.h + porting.h + preferences.cpp + processresult.cpp + processresult_p.h + processutils.cpp + processutils.h + profile.cpp + profiling.cpp + profiling.h + progressobserver.cpp + progressobserver.h + projectgeneratormanager.cpp + qbsassert.cpp + qbsassert.h + qbspluginmanager.cpp + qbspluginmanager.h + qbsprocess.cpp + qbsprocess.h + qttools.cpp + qttools.h + scannerpluginmanager.cpp + scannerpluginmanager.h + scripttools.cpp + scripttools.h + set.h + settings.cpp + settingscreator.cpp + settingscreator.h + settingsmodel.cpp + settingsrepresentation.cpp + setupprojectparameters.cpp + shellutils.cpp + shellutils.h + stlutils.h + stringconstants.h + stringutils.h + toolchains.cpp + version.cpp + visualstudioversioninfo.cpp + visualstudioversioninfo.h + vsenvironmentdetector.cpp + vsenvironmentdetector.h + weakpointer.h + ) +list_transform_prepend(TOOLS_SOURCES tools/) + +set(TOOLS_HEADERS + architectures.h + buildoptions.h + cleanoptions.h + codelocation.h + commandechomode.h + error.h + generateoptions.h + installoptions.h + joblimits.h + preferences.h + processresult.h + profile.h + projectgeneratormanager.h + qbs_export.h + settings.h + settingsmodel.h + settingsrepresentation.h + setupprojectparameters.h + toolchains.h + version.h + ) +list_transform_prepend(TOOLS_HEADERS tools/) + +set(EXTERNAL_DEPENDS "") +if(APPLE) + set(TOOLS_MACOS_SOURCES + applecodesignutils.cpp + applecodesignutils.h + ) + list_transform_prepend(TOOLS_MACOS_SOURCES tools/) + set(EXTERNAL_DEPENDS "-framework Foundation" "-framework Security") +endif() + +if(WIN32) + set(EXTERNAL_DEPENDS "psapi" "shell32") +endif() + +add_qbs_library(qbscore + DEFINES + "QBS_VERSION=\"${QBS_VERSION}\"" + "QBS_RELATIVE_LIBEXEC_PATH=\"${QBS_RELATIVE_LIBEXEC_PATH}\"" + "QBS_LIBRARY" + ${QBS_UNIT_TESTS_DEFINES} + DEPENDS + Qt${QT_VERSION_MAJOR}::CorePrivate + Qt${QT_VERSION_MAJOR}::Network + Qt${QT_VERSION_MAJOR}::Xml + Qt6Core5Compat + qbspkgconfig + qbsscriptengine + PUBLIC_DEPENDS + Qt${QT_VERSION_MAJOR}::Core + ${EXTERNAL_DEPENDS} + INCLUDES + "${CMAKE_CURRENT_SOURCE_DIR}/../.." + SOURCES + ${QBS_HEADERS} + ${FILE_UPDATE_SOURCES} + ${API_SOURCES} + ${API_HEADERS} + ${BUILD_GRAPH_SOURCES} + ${BUILD_GRAPH_HEADERS} + ${GENERATORS_SOURCES} + ${GENERATORS_HEADERS} + ${JS_EXTENSIONS_SOURCES} + ${JS_EXTENSIONS_MACOS_SOURCES} + ${LANGUAGE_SOURCES} + ${LANGUAGE_HEADERS} + ${LOGGING_SOURCES} + ${LOGGING_HEADERS} + ${PARSER_SOURCES} + ${TOOLS_SOURCES} + ${TOOLS_HEADERS} + ${TOOLS_MACOS_SOURCES} + ) + +# not sure if there's a better way to do this +if(INSTALL_PUBLIC_HEADERS) + install(FILES ${QBS_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}) + install(FILES ${API_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/api) + install(FILES ${BUILD_GRAPH_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/buildgraph) + install(FILES ${GENERATORS_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/generators) + install(FILES ${LOGGING_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/logging) + install(FILES ${LANGUAGE_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/language) + install(FILES ${TOOLS_HEADERS} DESTINATION ${QBS_HEADERS_INSTALL_DIR}/tools) + set(QMAKE_PRI_FILES use_installed_corelib.pri ../../../qbs_version.pri) + install(FILES ${QMAKE_PRI_FILES} DESTINATION ${QBS_HEADERS_INSTALL_DIR}) +endif() diff --git a/src/lib/corelib/api/api.pri b/src/lib/corelib/api/api.pri new file mode 100644 index 00000000..69443dff --- /dev/null +++ b/src/lib/corelib/api/api.pri @@ -0,0 +1,49 @@ +include(../../../install_prefix.pri) + +HEADERS += \ + $$PWD/internaljobs.h \ + $$PWD/projectdata.h \ + $$PWD/runenvironment.h \ + $$PWD/jobs.h \ + $$PWD/languageinfo.h \ + $$PWD/project.h \ + $$PWD/project_p.h \ + $$PWD/propertymap_p.h \ + $$PWD/projectdata_p.h \ + $$PWD/rulecommand.h \ + $$PWD/rulecommand_p.h \ + $$PWD/transformerdata.h \ + $$PWD/transformerdata_p.h + +SOURCES += \ + $$PWD/internaljobs.cpp \ + $$PWD/runenvironment.cpp \ + $$PWD/projectdata.cpp \ + $$PWD/jobs.cpp \ + $$PWD/languageinfo.cpp \ + $$PWD/project.cpp \ + $$PWD/rulecommand.cpp \ + $$PWD/transformerdata.cpp + +!qbs_no_dev_install { + api_headers.files = \ + $$PWD/jobs.h \ + $$PWD/languageinfo.h \ + $$PWD/project.h \ + $$PWD/projectdata.h \ + $$PWD/rulecommand.h \ + $$PWD/runenvironment.h \ + $$PWD/transformerdata.h + api_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/api + INSTALLS += api_headers +} + +HEADERS += \ + $$PWD/changeset.h \ + $$PWD/projectfileupdater.h \ + $$PWD/qmljsrewriter.h + +SOURCES += \ + $$PWD/changeset.cpp \ + $$PWD/projectfileupdater.cpp \ + $$PWD/qmljsrewriter.cpp diff --git a/src/lib/corelib/api/changeset.cpp b/src/lib/corelib/api/changeset.cpp new file mode 100644 index 00000000..218e18fb --- /dev/null +++ b/src/lib/corelib/api/changeset.cpp @@ -0,0 +1,372 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "changeset.h" + +namespace QbsQmlJS { + +ChangeSet::ChangeSet() + : m_string(nullptr), m_error(false) +{ +} + +ChangeSet::ChangeSet(QList operations) + : m_string(nullptr), m_operationList(std::move(operations)), m_error(false) +{ +} + +static bool overlaps(int posA, int lengthA, int posB, int lengthB) { + if (lengthB > 0) { + return + // right edge of B contained in A + (posA < posB + lengthB && posA + lengthA >= posB + lengthB) + // left edge of B contained in A + || (posA <= posB && posA + lengthA > posB) + // A contained in B + || (posB < posA && posB + lengthB > posA + lengthA); + } + return (posB > posA && posB < posA + lengthA); +} + +bool ChangeSet::hasOverlap(int pos, int length) +{ + QListIterator i(m_operationList); + while (i.hasNext()) { + const EditOp &cmd = i.next(); + + switch (cmd.type) { + case EditOp::Replace: + if (overlaps(pos, length, cmd.pos1, cmd.length1)) + return true; + break; + + case EditOp::Move: + if (overlaps(pos, length, cmd.pos1, cmd.length1)) + return true; + if (cmd.pos2 > pos && cmd.pos2 < pos + length) + return true; + break; + + case EditOp::Insert: + if (cmd.pos1 > pos && cmd.pos1 < pos + length) + return true; + break; + + case EditOp::Remove: + if (overlaps(pos, length, cmd.pos1, cmd.length1)) + return true; + break; + + case EditOp::Flip: + if (overlaps(pos, length, cmd.pos1, cmd.length1)) + return true; + if (overlaps(pos, length, cmd.pos2, cmd.length2)) + return true; + break; + + case EditOp::Copy: + if (overlaps(pos, length, cmd.pos1, cmd.length1)) + return true; + if (cmd.pos2 > pos && cmd.pos2 < pos + length) + return true; + break; + + case EditOp::Unset: + break; + } + } + + return false; +} + +bool ChangeSet::empty() const +{ + return m_operationList.empty(); +} + +QList ChangeSet::operationList() const +{ + return m_operationList; +} + +void ChangeSet::clear() +{ + m_string = nullptr; + m_operationList.clear(); + m_error = false; +} + +bool ChangeSet::replace_helper(int pos, int length, const QString &replacement) +{ + if (hasOverlap(pos, length)) + m_error = true; + + EditOp cmd(EditOp::Replace); + cmd.pos1 = pos; + cmd.length1 = length; + cmd.text = replacement; + m_operationList.push_back(cmd); + + return !m_error; +} + +bool ChangeSet::move_helper(int pos, int length, int to) +{ + if (hasOverlap(pos, length) + || hasOverlap(to, 0) + || overlaps(pos, length, to, 0)) + m_error = true; + + EditOp cmd(EditOp::Move); + cmd.pos1 = pos; + cmd.length1 = length; + cmd.pos2 = to; + m_operationList.push_back(cmd); + + return !m_error; +} + +bool ChangeSet::insert(int pos, const QString &text) +{ + Q_ASSERT(pos >= 0); + + if (hasOverlap(pos, 0)) + m_error = true; + + EditOp cmd(EditOp::Insert); + cmd.pos1 = pos; + cmd.text = text; + m_operationList.push_back(cmd); + + return !m_error; +} + +bool ChangeSet::replace(const Range &range, const QString &replacement) +{ return replace(range.start, range.end, replacement); } + +bool ChangeSet::remove(const Range &range) +{ return remove(range.start, range.end); } + +bool ChangeSet::move(const Range &range, int to) +{ return move(range.start, range.end, to); } + +bool ChangeSet::flip(const Range &range1, const Range &range2) +{ return flip(range1.start, range1.end, range2.start, range2.end); } + +bool ChangeSet::copy(const Range &range, int to) +{ return copy(range.start, range.end, to); } + +bool ChangeSet::replace(int start, int end, const QString &replacement) +{ return replace_helper(start, end - start, replacement); } + +bool ChangeSet::remove(int start, int end) +{ return remove_helper(start, end - start); } + +bool ChangeSet::move(int start, int end, int to) +{ return move_helper(start, end - start, to); } + +bool ChangeSet::flip(int start1, int end1, int start2, int end2) +{ return flip_helper(start1, end1 - start1, start2, end2 - start2); } + +bool ChangeSet::copy(int start, int end, int to) +{ return copy_helper(start, end - start, to); } + +bool ChangeSet::remove_helper(int pos, int length) +{ + if (hasOverlap(pos, length)) + m_error = true; + + EditOp cmd(EditOp::Remove); + cmd.pos1 = pos; + cmd.length1 = length; + m_operationList.push_back(cmd); + + return !m_error; +} + +bool ChangeSet::flip_helper(int pos1, int length1, int pos2, int length2) +{ + if (hasOverlap(pos1, length1) + || hasOverlap(pos2, length2) + || overlaps(pos1, length1, pos2, length2)) + m_error = true; + + EditOp cmd(EditOp::Flip); + cmd.pos1 = pos1; + cmd.length1 = length1; + cmd.pos2 = pos2; + cmd.length2 = length2; + m_operationList.push_back(cmd); + + return !m_error; +} + +bool ChangeSet::copy_helper(int pos, int length, int to) +{ + if (hasOverlap(pos, length) + || hasOverlap(to, 0) + || overlaps(pos, length, to, 0)) + m_error = true; + + EditOp cmd(EditOp::Copy); + cmd.pos1 = pos; + cmd.length1 = length; + cmd.pos2 = to; + m_operationList.push_back(cmd); + + return !m_error; +} + +void ChangeSet::doReplace(const EditOp &replace_helper, QList *replaceList) +{ + Q_ASSERT(replace_helper.type == EditOp::Replace); + + { + QMutableListIterator i(*replaceList); + while (i.hasNext()) { + EditOp &c = i.next(); + if (replace_helper.pos1 <= c.pos1) + c.pos1 += replace_helper.text.size(); + if (replace_helper.pos1 < c.pos1) + c.pos1 -= replace_helper.length1; + } + } + + if (m_string) { + m_string->replace(replace_helper.pos1, replace_helper.length1, replace_helper.text); + } +} + +void ChangeSet::convertToReplace(const EditOp &op, QList *replaceList) +{ + EditOp replace1(EditOp::Replace); + EditOp replace2(EditOp::Replace); + + switch (op.type) { + case EditOp::Replace: + replaceList->push_back(op); + break; + + case EditOp::Move: + replace1.pos1 = op.pos1; + replace1.length1 = op.length1; + replaceList->push_back(replace1); + + replace2.pos1 = op.pos2; + replace2.text = textAt(op.pos1, op.length1); + replaceList->push_back(replace2); + break; + + case EditOp::Insert: + replace1.pos1 = op.pos1; + replace1.text = op.text; + replaceList->push_back(replace1); + break; + + case EditOp::Remove: + replace1.pos1 = op.pos1; + replace1.length1 = op.length1; + replaceList->push_back(replace1); + break; + + case EditOp::Flip: + replace1.pos1 = op.pos1; + replace1.length1 = op.length1; + replace1.text = textAt(op.pos2, op.length2); + replaceList->push_back(replace1); + + replace2.pos1 = op.pos2; + replace2.length1 = op.length2; + replace2.text = textAt(op.pos1, op.length1); + replaceList->push_back(replace2); + break; + + case EditOp::Copy: + replace1.pos1 = op.pos2; + replace1.text = textAt(op.pos1, op.length1); + replaceList->push_back(replace1); + break; + + case EditOp::Unset: + break; + } +} + +bool ChangeSet::hadErrors() +{ + return m_error; +} + +void ChangeSet::apply(QString *s) +{ + m_string = s; + apply_helper(); + m_string = nullptr; +} + +QString ChangeSet::textAt(int pos, int length) +{ + if (m_string) { + return m_string->mid(pos, length); + } + return {}; +} + +void ChangeSet::apply_helper() +{ + // convert all ops to replace + QList replaceList; + { + while (!m_operationList.empty()) { + const EditOp cmd(m_operationList.front()); + m_operationList.removeFirst(); + convertToReplace(cmd, &replaceList); + } + } + + // execute replaces + while (!replaceList.empty()) { + const EditOp cmd(replaceList.front()); + replaceList.removeFirst(); + doReplace(cmd, &replaceList); + } +} + +} // namespace QbsQmlJS + diff --git a/src/lib/corelib/api/changeset.h b/src/lib/corelib/api/changeset.h new file mode 100644 index 00000000..9182cb8e --- /dev/null +++ b/src/lib/corelib/api/changeset.h @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_CHANGESET_H +#define QBS_CHANGESET_H + +#include +#include + +namespace QbsQmlJS { + +class ChangeSet +{ +public: + struct EditOp { + enum Type + { + Unset, + Replace, + Move, + Insert, + Remove, + Flip, + Copy + }; + + EditOp(): type(Unset), pos1(0), pos2(0), length1(0), length2(0) {} + EditOp(Type t): type(t), pos1(0), pos2(0), length1(0), length2(0) {} + + Type type; + int pos1; + int pos2; + int length1; + int length2; + QString text; + }; + + struct Range { + Range() + : start(0), end(0) {} + + Range(int start, int end) + : start(start), end(end) {} + + int start; + int end; + }; + +public: + ChangeSet(); + ChangeSet(QList operations); + + bool empty() const; + + QList operationList() const; + + void clear(); + + bool replace(const Range &range, const QString &replacement); + bool remove(const Range &range); + bool move(const Range &range, int to); + bool flip(const Range &range1, const Range &range2); + bool copy(const Range &range, int to); + bool replace(int start, int end, const QString &replacement); + bool remove(int start, int end); + bool move(int start, int end, int to); + bool flip(int start1, int end1, int start2, int end2); + bool copy(int start, int end, int to); + bool insert(int pos, const QString &text); + + bool hadErrors(); + + void apply(QString *s); + +private: + // length-based API. + bool replace_helper(int pos, int length, const QString &replacement); + bool move_helper(int pos, int length, int to); + bool remove_helper(int pos, int length); + bool flip_helper(int pos1, int length1, int pos2, int length2); + bool copy_helper(int pos, int length, int to); + + bool hasOverlap(int pos, int length); + QString textAt(int pos, int length); + + void doReplace(const EditOp &replace, QList *replaceList); + void convertToReplace(const EditOp &op, QList *replaceList); + + void apply_helper(); + +private: + QString *m_string; + + QList m_operationList; + bool m_error; +}; + +} // namespace QbsQmlJS + +#endif // Include guard. diff --git a/src/lib/corelib/api/internaljobs.cpp b/src/lib/corelib/api/internaljobs.cpp new file mode 100644 index 00000000..0fabc627 --- /dev/null +++ b/src/lib/corelib/api/internaljobs.cpp @@ -0,0 +1,464 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "internaljobs.h" + +#include "jobs.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class JobObserver : public ProgressObserver +{ +public: + JobObserver(InternalJob *job) : m_job(job) { } + ~JobObserver() override { delete m_timedLogger; } + + void cancel() + { + std::lock_guard lock(m_cancelMutex); + m_canceled = true; + } + +private: + void initialize(const QString &task, int maximum) override + { + QBS_ASSERT(!m_timedLogger, delete m_timedLogger); + if (m_job->timed()) + m_timedLogger = new TimedActivityLogger(m_job->logger(), task, true); + m_value = 0; + m_maximum = maximum; + emit m_job->newTaskStarted(task, maximum, m_job); + } + + void setMaximum(int maximum) override + { + m_maximum = maximum; + emit m_job->totalEffortChanged(maximum, m_job); + } + + void setProgressValue(int value) override + { + //QBS_ASSERT(value >= m_value, qDebug("old value = %d, new value = %d", m_value, value)); + //QBS_ASSERT(value <= m_maximum, qDebug("value = %d, maximum = %d", value, m_maximum)); + m_value = value; + if (value == m_maximum) { + delete m_timedLogger; + m_timedLogger = nullptr; + } + emit m_job->taskProgress(value, m_job); + } + + int progressValue() override { return m_value; } + int maximum() const override { return m_maximum; } + bool canceled() const override + { + std::lock_guard lock(m_cancelMutex); + return m_canceled; + } + + int m_value = 0; + int m_maximum = 0; + mutable std::mutex m_cancelMutex; + bool m_canceled = false; + InternalJob * const m_job; + TimedActivityLogger *m_timedLogger = nullptr; +}; + + +InternalJob::InternalJob(Logger logger, QObject *parent) + : QObject(parent) + , m_observer(new JobObserver(this)) + , m_ownsObserver(true) + , m_logger(std::move(logger)) + , m_timed(false) +{ +} + +InternalJob::~InternalJob() +{ + if (m_ownsObserver) + delete m_observer; +} + +void InternalJob::cancel() +{ + m_observer->cancel(); +} + +void InternalJob::shareObserverWith(InternalJob *otherJob) +{ + if (m_ownsObserver) { + delete m_observer; + m_ownsObserver = false; + } + m_observer = otherJob->m_observer; +} + +void InternalJob::storeBuildGraph(const TopLevelProjectPtr &project) +{ + try { + doSanityChecks(project, logger()); + TimedActivityLogger storeTimer(m_logger, Tr::tr("Storing build graph"), timed()); + project->store(logger()); + } catch (const ErrorInfo &error) { + ErrorInfo fullError = this->error(); + const auto items = error.items(); + for (const ErrorItem &item : items) + fullError.append(item); + setError(fullError); + } +} + + +/** + * Construct a new thread wrapper for a synchronous job. + * This object takes over ownership of the synchronous job. + */ +InternalJobThreadWrapper::InternalJobThreadWrapper(InternalJob *synchronousJob, QObject *parent) + : InternalJob(synchronousJob->logger(), parent) + , m_job(synchronousJob) + , m_running(false) +{ + synchronousJob->shareObserverWith(this); + m_job->moveToThread(&m_thread); + connect(m_job, &InternalJob::finished, this, &InternalJobThreadWrapper::handleFinished); + connect(m_job, &InternalJob::newTaskStarted, + this, &InternalJob::newTaskStarted); + connect(m_job, &InternalJob::taskProgress, + this, &InternalJob::taskProgress); + connect(m_job, &InternalJob::totalEffortChanged, + this, &InternalJob::totalEffortChanged); + connect(this, &InternalJobThreadWrapper::startRequested, m_job, &InternalJob::start); +} + +InternalJobThreadWrapper::~InternalJobThreadWrapper() +{ + if (m_running) { + cancel(); + while (m_running) + QCoreApplication::processEvents(); + } + m_thread.quit(); + m_thread.wait(); + delete m_job; + m_job = nullptr; +} + +void InternalJobThreadWrapper::start() +{ + setTimed(m_job->timed()); + m_thread.start(); + m_running = true; + QTimer::singleShot(0, this, &InternalJobThreadWrapper::startRequested); +} + +void InternalJobThreadWrapper::handleFinished() +{ + m_running = false; + setError(m_job->error()); + emit finished(this); +} + + +InternalSetupProjectJob::InternalSetupProjectJob(const Logger &logger) + : InternalJob(logger) +{ +} + +InternalSetupProjectJob::~InternalSetupProjectJob() = default; + +void InternalSetupProjectJob::init(const TopLevelProjectPtr &existingProject, + const SetupProjectParameters ¶meters) +{ + m_existingProject = existingProject; + m_parameters = parameters; + setTimed(parameters.logElapsedTime()); +} + +void InternalSetupProjectJob::reportError(const ErrorInfo &error) +{ + setError(error); + emit finished(this); +} + +TopLevelProjectPtr InternalSetupProjectJob::project() const +{ + return m_newProject; +} + +void InternalSetupProjectJob::start() +{ + BuildGraphLocker *bgLocker = m_existingProject ? m_existingProject->bgLocker : nullptr; + bool deleteLocker = false; + try { + const ErrorInfo err = m_parameters.expandBuildConfiguration(); + if (err.hasError()) + throw err; + const QString projectId = TopLevelProject::deriveId( + m_parameters.finalBuildConfigurationTree()); + const QString buildDir + = TopLevelProject::deriveBuildDirectory(m_parameters.buildRoot(), projectId); + if (m_existingProject && m_existingProject->buildDirectory != buildDir) + m_existingProject.reset(); + if (!m_existingProject) { + bgLocker = new BuildGraphLocker(ProjectBuildData::deriveBuildGraphFilePath(buildDir, + projectId), + logger(), m_parameters.waitLockBuildGraph(), observer()); + deleteLocker = true; + } + execute(); + if (m_existingProject) { + if (m_existingProject != m_newProject) + m_existingProject->makeModuleProvidersNonTransient(); + m_existingProject->bgLocker = nullptr; + } + m_newProject->bgLocker = bgLocker; + deleteLocker = false; + } catch (const ErrorInfo &error) { + m_newProject.reset(); + setError(error); + + // Delete the build graph locker if and only if we allocated it here. + if (deleteLocker) + delete bgLocker; + } + emit finished(this); +} + +void InternalSetupProjectJob::execute() +{ + RulesEvaluationContextPtr evalContext(new RulesEvaluationContext(logger())); + evalContext->setObserver(observer()); + + switch (m_parameters.restoreBehavior()) { + case SetupProjectParameters::ResolveOnly: + resolveProjectFromScratch(evalContext->engine()); + resolveBuildDataFromScratch(evalContext); + break; + case SetupProjectParameters::RestoreOnly: + m_newProject = restoreProject(evalContext).loadedProject; + break; + case SetupProjectParameters::RestoreAndTrackChanges: { + const BuildGraphLoadResult loadResult = restoreProject(evalContext); + m_newProject = loadResult.newlyResolvedProject; + if (!m_newProject) + m_newProject = loadResult.loadedProject; + if (!m_newProject) { + resolveProjectFromScratch(evalContext->engine()); + resolveBuildDataFromScratch(evalContext); + } else { + QBS_CHECK(m_newProject->buildData); + } + break; + } + } + + if (!m_parameters.dryRun()) + storeBuildGraph(m_newProject); + + // The evalutation context cannot be re-used for building, which runs in a different thread. + m_newProject->buildData->evaluationContext.reset(); +} + +void InternalSetupProjectJob::resolveProjectFromScratch(ScriptEngine *engine) +{ + Loader loader(engine, logger()); + loader.setSearchPaths(m_parameters.searchPaths()); + loader.setProgressObserver(observer()); + m_newProject = loader.loadProject(m_parameters); + QBS_CHECK(m_newProject); +} + +void InternalSetupProjectJob::resolveBuildDataFromScratch(const RulesEvaluationContextPtr &evalContext) +{ + TimedActivityLogger resolveLogger(logger(), QStringLiteral("Resolving build project"), timed()); + BuildDataResolver(logger()).resolveBuildData(m_newProject, evalContext); +} + +BuildGraphLoadResult InternalSetupProjectJob::restoreProject(const RulesEvaluationContextPtr &evalContext) +{ + BuildGraphLoader bgLoader(logger()); + const BuildGraphLoadResult loadResult + = bgLoader.load(m_existingProject, m_parameters, evalContext); + return loadResult; +} + +BuildGraphTouchingJob::BuildGraphTouchingJob(const Logger &logger, QObject *parent) + : InternalJob(logger, parent), m_dryRun(false) +{ +} + +BuildGraphTouchingJob::~BuildGraphTouchingJob() = default; + +void BuildGraphTouchingJob::setup(const TopLevelProjectPtr &project, + const QVector &products, bool dryRun) +{ + m_project = project; + m_products = products; + m_dryRun = dryRun; +} + +void BuildGraphTouchingJob::storeBuildGraph() +{ + if (!m_dryRun && !error().isInternalError()) + InternalJob::storeBuildGraph(m_project); +} + +InternalBuildJob::InternalBuildJob(const Logger &logger, QObject *parent) + : BuildGraphTouchingJob(logger, parent), m_executor(nullptr) +{ +} + +void InternalBuildJob::build(const TopLevelProjectPtr &project, + const QVector &products, const BuildOptions &buildOptions) +{ + setup(project, products, buildOptions.dryRun()); + setTimed(buildOptions.logElapsedTime()); + + m_executor = new Executor(logger()); + m_executor->setProject(project); + m_executor->setProducts(products); + m_executor->setBuildOptions(buildOptions); + m_executor->setProgressObserver(observer()); + + const auto executorThread = new QThread(this); + m_executor->moveToThread(executorThread); + connect(m_executor, &Executor::reportCommandDescription, + this, &BuildGraphTouchingJob::reportCommandDescription); + connect(m_executor, &Executor::reportProcessResult, + this, &BuildGraphTouchingJob::reportProcessResult); + + connect(executorThread, &QThread::started, m_executor, &Executor::build); + connect(m_executor, &Executor::finished, this, &InternalBuildJob::handleFinished); + connect(m_executor, &QObject::destroyed, executorThread, &QThread::quit); + connect(executorThread, &QThread::finished, this, &InternalBuildJob::emitFinished); + executorThread->start(); +} + +void InternalBuildJob::handleFinished() +{ + setError(m_executor->error()); + project()->buildData->evaluationContext.reset(); + storeBuildGraph(); + m_executor->deleteLater(); +} + +void InternalBuildJob::emitFinished() +{ + emit finished(this); +} + +InternalCleanJob::InternalCleanJob(const Logger &logger, QObject *parent) + : BuildGraphTouchingJob(logger, parent) +{ +} + +void InternalCleanJob::init(const TopLevelProjectPtr &project, + const QVector &products, + const CleanOptions &options) +{ + setup(project, products, options.dryRun()); + setTimed(options.logElapsedTime()); + m_options = options; +} + +void InternalCleanJob::start() +{ + try { + ArtifactCleaner cleaner(logger(), observer()); + cleaner.cleanup(project(), products(), m_options); + } catch (const ErrorInfo &error) { + setError(error); + } + storeBuildGraph(); + emit finished(this); +} + + +InternalInstallJob::InternalInstallJob(const Logger &logger) + : InternalJob(logger) +{ +} + +InternalInstallJob::~InternalInstallJob() = default; + +void InternalInstallJob::init(const TopLevelProjectPtr &project, + const QVector &products, const InstallOptions &options) +{ + m_project = project; + m_products = products; + m_options = options; + setTimed(options.logElapsedTime()); +} + +void InternalInstallJob::start() +{ + try { + ProductInstaller(m_project, m_products, m_options, observer(), logger()).install(); + } catch (const ErrorInfo &error) { + setError(error); + } + emit finished(this); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/api/internaljobs.h b/src/lib/corelib/api/internaljobs.h new file mode 100644 index 00000000..d6683594 --- /dev/null +++ b/src/lib/corelib/api/internaljobs.h @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_INTERNALJOBS_H +#define QBS_INTERNALJOBS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +class ProcessResult; +class Settings; + +namespace Internal { +class BuildGraphLoadResult; +class BuildGraphLocker; +class Executor; +class JobObserver; +class ScriptEngine; + +class InternalJob : public QObject +{ + Q_OBJECT + friend class JobObserver; +public: + ~InternalJob() override; + + void cancel(); + virtual void start() {} + ErrorInfo error() const { return m_error; } + void setError(const ErrorInfo &error) { m_error = error; } + + Logger logger() const { return m_logger; } + bool timed() const { return m_timed; } + void shareObserverWith(InternalJob *otherJob); + +protected: + explicit InternalJob(Logger logger, QObject *parent = nullptr); + + JobObserver *observer() const { return m_observer; } + void setTimed(bool timed) { m_timed = timed; } + void storeBuildGraph(const TopLevelProjectPtr &project); + +signals: + void finished(Internal::InternalJob *job); + void newTaskStarted(const QString &description, int totalEffort, Internal::InternalJob *job); + void totalEffortChanged(int totalEffort, Internal::InternalJob *job); + void taskProgress(int value, Internal::InternalJob *job); + +private: + ErrorInfo m_error; + JobObserver *m_observer; + bool m_ownsObserver; + Logger m_logger; + bool m_timed; +}; + + +class InternalJobThreadWrapper : public InternalJob +{ + Q_OBJECT +public: + InternalJobThreadWrapper(InternalJob *synchronousJob, QObject *parent = nullptr); + ~InternalJobThreadWrapper() override; + + void start() override; + InternalJob *synchronousJob() const { return m_job; } + +signals: + void startRequested(); + +private: + void handleFinished(); + + QThread m_thread; + InternalJob *m_job; + bool m_running; +}; + +class InternalSetupProjectJob : public InternalJob +{ + Q_OBJECT +public: + InternalSetupProjectJob(const Logger &logger); + ~InternalSetupProjectJob() override; + + void init(const TopLevelProjectPtr &existingProject, const SetupProjectParameters ¶meters); + void reportError(const ErrorInfo &error); + + TopLevelProjectPtr project() const; + +private: + void start() override; + void resolveProjectFromScratch(Internal::ScriptEngine *engine); + void resolveBuildDataFromScratch(const RulesEvaluationContextPtr &evalContext); + BuildGraphLoadResult restoreProject(const RulesEvaluationContextPtr &evalContext); + void execute(); + + TopLevelProjectPtr m_existingProject; + TopLevelProjectPtr m_newProject; + SetupProjectParameters m_parameters; +}; + + +class BuildGraphTouchingJob : public InternalJob +{ + Q_OBJECT +public: + const QVector &products() const { return m_products; } + const TopLevelProjectPtr &project() const { return m_project; } + +signals: + void reportCommandDescription(const QString &highlight, const QString &message); + void reportProcessResult(const qbs::ProcessResult &result); + +protected: + BuildGraphTouchingJob(const Logger &logger, QObject *parent = nullptr); + ~BuildGraphTouchingJob() override; + + void setup(const TopLevelProjectPtr &project, const QVector &products, + bool dryRun); + void storeBuildGraph(); + +private: + TopLevelProjectPtr m_project; + QVector m_products; + bool m_dryRun; +}; + + +class InternalBuildJob : public BuildGraphTouchingJob +{ + Q_OBJECT +public: + InternalBuildJob(const Logger &logger, QObject *parent = nullptr); + + void build(const TopLevelProjectPtr &project, const QVector &products, + const BuildOptions &buildOptions); + +private: + void handleFinished(); + void emitFinished(); + + Executor *m_executor; +}; + + +class InternalCleanJob : public BuildGraphTouchingJob +{ + Q_OBJECT +public: + InternalCleanJob(const Logger &logger, QObject *parent = nullptr); + + void init(const TopLevelProjectPtr &project, const QVector &products, + const CleanOptions &options); + +private: + void start() override; + + CleanOptions m_options; +}; + + +class InternalInstallJob : public InternalJob +{ + Q_OBJECT +public: + InternalInstallJob(const Logger &logger); + ~InternalInstallJob() override; + + void init(const TopLevelProjectPtr &project, const QVector &products, + const InstallOptions &options); + +private: + void start() override; + + TopLevelProjectPtr m_project; + QVector m_products; + InstallOptions m_options; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_INTERNALJOBS_H diff --git a/src/lib/corelib/api/jobs.cpp b/src/lib/corelib/api/jobs.cpp new file mode 100644 index 00000000..7a845b0a --- /dev/null +++ b/src/lib/corelib/api/jobs.cpp @@ -0,0 +1,375 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "jobs.h" + +#include "internaljobs.h" +#include "project_p.h" +#include +#include +#include + +#include +#include + +namespace qbs { +using namespace Internal; + +/*! + * \class AbstractJob + * \brief The \c AbstractJob class represents an operation relating to a \c Project. + * Concrete child classes of \c AbstractJob are created by factory functions in the \c Project + * class. The respective objects represent an operation that is started automatically + * and is considered "running" until the \c finished() signal has been emitted. Afterwards, + * callers can find out whether the operation was successful by calling \c hasError(). While + * the operation is going on, progress information is being provided via \c taskStarted() and + * \c taskProgress. + * Note that though a job is being started automatically by its factory function, you are guaranteed + * to recevieve all signals it emits if you connect to it right after getting the object from the + * creating function. + * \sa Project + */ + +/*! + * \enum AbstractJob::State + * This enum type specifies which states a job can be in. + * \value StateRunning The respective operation is ongoing. + * \value StateCanceling The job has been requested to cancel via \c AbstractJob::cancel(), + * but the \c AbstractJob::finished() signal has not been emitted yet. + * \value StateFinished The operation has finished and the \c AbstractJob::finished() signal + * has been emitted. + */ + + /*! + * \fn AbstractJob::State AbstractJob::state() const + * \brief Returns the current state of the operation. + */ + + /*! + * \fn bool AbstractJob::hasError() const + * \brief Returns true if the operation has finished with an error, otherwise returns false. + * This function should not be called before the \c finished() signal has been emitted. + */ + +/*! + * \fn void AbstractJob::taskStarted(const QString &description, int maximumProgressValue, qbs::AbstractJob *job) + * \brief Indicates that a new task has been started. + * The \a description parameter is a string intended for presentation to a user. + * The \a maximumProgressValue parameter indicates the maximum value to which subsequent values of + * \c taskProgress() will go. + * This signal is typically emitted exactly once for a job that finishes successfully. However, + * operations might emit it several times if they are made up of subtasks whose overall effort + * cannot be determined in advance. + * \sa AbstractJob::taskProgress() + */ + +/*! + * \fn void taskProgress(int newProgressValue, qbs::AbstractJob *job) + * \brief Indicates progress in executing the operation. + * The \a newProgressValue parameter represents the current progress. It is always greater than + * zero, strictly increasing and goes up to the \c maximumProgressValue argument of the last + * call to \c taskStarted(). + * \sa AbstractJob::taskStarted() + */ + + /*! + * \fn void finished(bool success, qbs::AbstractJob *job) + * \brief Indicates that the operation has finished. + * Check the \a success parameter to find out whether everything went fine or an error occurred. + */ + +AbstractJob::AbstractJob(InternalJob *internalJob, QObject *parent) + : QObject(parent), m_internalJob(internalJob) +{ + m_internalJob->setParent(this); + connect(m_internalJob, &InternalJob::newTaskStarted, + this, &AbstractJob::handleTaskStarted, Qt::QueuedConnection); + connect(m_internalJob, &InternalJob::totalEffortChanged, + this, &AbstractJob::handleTotalEffortChanged); + connect(m_internalJob, &InternalJob::taskProgress, + this, &AbstractJob::handleTaskProgress, Qt::QueuedConnection); + connect(m_internalJob, &InternalJob::finished, this, &AbstractJob::handleFinished); + m_state = StateRunning; +} + +bool AbstractJob::lockProject(const TopLevelProjectPtr &project) +{ + // The API is not thread-safe, so we don't need a mutex here, as the API requests come in + // synchronously. + if (project->locked) { + internalJob()->setError(tr("Cannot start a job while another one is in progress.")); + QTimer::singleShot(0, this, [this] { emit finished(false, this); }); + return false; + } + project->locked = true; + m_project = project; + return true; +} + +void AbstractJob::unlockProject() +{ + if (!m_project) + return; + QBS_ASSERT(m_project->locked, return); + m_project->locked = false; +} + +/*! + * \brief Destroys the object, canceling the operation if necessary. + */ +AbstractJob::~AbstractJob() +{ + m_internalJob->disconnect(this); + cancel(); +} + +/*! + * \brief Returns the error which caused this operation to fail, if it did fail. + */ +ErrorInfo AbstractJob::error() const +{ + if (m_error.hasError()) + return m_error; + return internalJob()->error(); +} + +/*! + * \brief Cancels this job. + * Note that the job might not finish immediately. If you need to make sure it has actually + * finished, wait for the \c finished() signal. + * \sa AbstractJob::finished(AbstractJob *); + */ +void AbstractJob::cancel() +{ + if (m_state != StateRunning) + return; + m_state = StateCanceling; + internalJob()->cancel(); +} + +void AbstractJob::handleTaskStarted(const QString &description, int maximumProgressValue) +{ + emit taskStarted(description, maximumProgressValue, this); +} + +void AbstractJob::handleTotalEffortChanged(int totalEffort) +{ + emit totalEffortChanged(totalEffort, this); +} + +void AbstractJob::handleTaskProgress(int newProgressValue) +{ + emit taskProgress(newProgressValue, this); +} + +void AbstractJob::handleFinished() +{ + QBS_ASSERT(m_state != StateFinished, return); + finish(); + m_state = StateFinished; + unlockProject(); + emit finished(!error().hasError(), this); +} + + +/*! + * \class SetupProjectJob + * \brief The \c SetupProjectJob class represents an operation that reads a qbs project file and + * creates a \c Project object from it. + * Note that this job can emit the \c taskStarted() signal more than once. + * \sa AbstractJob::taskStarted() + */ + +SetupProjectJob::SetupProjectJob(const Logger &logger, QObject *parent) + : AbstractJob(new InternalJobThreadWrapper(new InternalSetupProjectJob(logger)), parent) +{ + if (logger.logSink()->logLevel() == LoggerDebug || logger.logSink()->logLevel() == LoggerTrace) + QLoggingCategory::setFilterRules(QStringLiteral("qbs.*.debug=true")); +} + +/*! + * \brief Returns the project resulting from this operation. + * Note that the result is undefined if the job did not finish successfully. + * \sa AbstractJob::hasError() + */ +Project SetupProjectJob::project() const +{ + auto const wrapper = qobject_cast(internalJob()); + auto const job = qobject_cast(wrapper->synchronousJob()); + return Project(job->project(), job->logger()); +} + +void SetupProjectJob::resolve(const Project &existingProject, + const SetupProjectParameters ¶meters) +{ + m_existingProject = existingProject; + const TopLevelProjectPtr &existingInternalProject + = existingProject.d ? existingProject.d->internalProject : TopLevelProjectPtr(); + if (existingInternalProject && !lockProject(existingInternalProject)) + return; + auto const wrapper = qobject_cast(internalJob()); + auto const job = qobject_cast(wrapper->synchronousJob()); + job->init(existingInternalProject, parameters); + wrapper->start(); +} + +void SetupProjectJob::reportError(const ErrorInfo &error) +{ + auto const wrapper = qobject_cast(internalJob()); + auto const job = qobject_cast(wrapper->synchronousJob()); + job->reportError(error); +} + +void SetupProjectJob::finish() +{ + // If the new project was successfully created, invalidate the existing one. + // The invariant is that there must always be at most one valid Project object + // for the same build directory, so that exclusive ownership of the build graph lock + // is ensured. + // We also need to invalidate the project if an error has occurred after the build data was + // already transferred. + if (m_existingProject.isValid() + && (!error().hasError() || !m_existingProject.d->internalProject->buildData)) { + m_existingProject.d->internalProject.reset(); + } +} + +/*! + * \class ProcessResult + * \brief The \c ProcessResult class represents the result of one external program run by Qbs. + * + * The \c ProcessResult class represents all the information on one external program that was + * run by Qbs. It includes the command line used to start the program, the working directory + * as well as output and exit codes. + */ + +/*! + * \class BuildJob + * \brief The \c BuildJob class represents a build operation. + */ + +/*! + * \fn void BuildJob::reportCommandDescription(const QString &highlight, const QString &message) + * \brief Signals that a new command is being worked on. + * The \a highlight parameter is used to decide on the colors and font styles to be used to + * print the message. + * The \a message parameter is the localized message to print. + */ + +/*! + * \fn void BuildJob::reportProcessResult(const qbs::ProcessResult &result) + * \brief Signals that an external command has finished. + * The \a result parameter contains all details on the process that was run by Qbs. + */ + +BuildJob::BuildJob(const Logger &logger, QObject *parent) + : AbstractJob(new InternalBuildJob(logger), parent) +{ + connect(&LauncherInterface::instance(), &LauncherInterface::errorOccurred, + this, &BuildJob::handleLauncherError); + auto job = static_cast(internalJob()); + connect(job, &BuildGraphTouchingJob::reportCommandDescription, + this, &BuildJob::reportCommandDescription); + connect(job, &BuildGraphTouchingJob::reportProcessResult, + this, &BuildJob::reportProcessResult); +} + +void BuildJob::build(const TopLevelProjectPtr &project, const QVector &products, + const BuildOptions &options) +{ + if (!lockProject(project)) + return; + LauncherInterface::startLauncher(); + qobject_cast(internalJob())->build(project, products, options); +} + +void BuildJob::handleLauncherError(const ErrorInfo &error) +{ + setError(error); + cancel(); +} + +void BuildJob::finish() +{ + LauncherInterface::stopLauncher(); +} + + +/*! + * \class CleanJob + * \brief The \c CleanJob class represents an operation removing build artifacts. + */ + +CleanJob::CleanJob(const Logger &logger, QObject *parent) + : AbstractJob(new InternalJobThreadWrapper(new InternalCleanJob(logger)), parent) +{ +} + +void CleanJob::clean(const TopLevelProjectPtr &project, const QVector &products, + const qbs::CleanOptions &options) +{ + if (!lockProject(project)) + return; + auto wrapper = qobject_cast(internalJob()); + qobject_cast(wrapper->synchronousJob())->init(project, products, options); + wrapper->start(); +} + +/*! + * \class InstallJob + * \brief The \c InstallJob class represents an operation installing files. + */ + +InstallJob::InstallJob(const Logger &logger, QObject *parent) + : AbstractJob(new InternalJobThreadWrapper(new InternalInstallJob(logger)), parent) +{ +} + +void InstallJob::install(const TopLevelProjectPtr &project, + const QVector &products, + const InstallOptions &options) +{ + if (!lockProject(project)) + return; + auto wrapper = qobject_cast(internalJob()); + auto installJob = qobject_cast(wrapper->synchronousJob()); + installJob->init(project, products, options); + wrapper->start(); +} + +} // namespace qbs diff --git a/src/lib/corelib/api/jobs.h b/src/lib/corelib/api/jobs.h new file mode 100644 index 00000000..64929489 --- /dev/null +++ b/src/lib/corelib/api/jobs.h @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_JOBS_H +#define QBS_JOBS_H + +#include "project.h" +#include "../language/forward_decls.h" +#include "../tools/error.h" +#include "../tools/qbs_export.h" + +#include +#include +#include + +namespace qbs { +class BuildOptions; +class CleanOptions; +class InstallOptions; +class ProcessResult; +class SetupProjectParameters; +namespace Internal { +class InternalJob; +class Logger; +class ProjectPrivate; +} // namespace Internal + +class Project; + +class QBS_EXPORT AbstractJob : public QObject +{ + Q_OBJECT +public: + ~AbstractJob() override; + + enum State { StateRunning, StateCanceling, StateFinished }; + State state() const { return m_state; } + + ErrorInfo error() const; + +public slots: + void cancel(); + +protected: + AbstractJob(Internal::InternalJob *internalJob, QObject *parent); + Internal::InternalJob *internalJob() const { return m_internalJob; } + + bool lockProject(const Internal::TopLevelProjectPtr &project); + void setError(const ErrorInfo &error) { m_error = error; } + +signals: + void taskStarted(const QString &description, int maximumProgressValue, qbs::AbstractJob *job); + void totalEffortChanged(int totalEffort, qbs::AbstractJob *job); + void taskProgress(int newProgressValue, qbs::AbstractJob *job); + void finished(bool success, qbs::AbstractJob *job); + +private: + void handleTaskStarted(const QString &description, int maximumProgressValue); + void handleTotalEffortChanged(int totalEffort); + void handleTaskProgress(int newProgressValue); + void handleFinished(); + + void unlockProject(); + virtual void finish() { } + + Internal::InternalJob * const m_internalJob; + Internal::TopLevelProjectPtr m_project; + ErrorInfo m_error; + State m_state; +}; + + +class QBS_EXPORT SetupProjectJob : public AbstractJob +{ + Q_OBJECT + friend class Project; +public: + Project project() const; + +private: + SetupProjectJob(const Internal::Logger &logger, QObject *parent); + + void resolve(const Project &existingProject, const SetupProjectParameters ¶meters); + void reportError(const ErrorInfo &error); + + void finish() override; + + Project m_existingProject; +}; + +class QBS_EXPORT BuildJob : public AbstractJob +{ + Q_OBJECT + friend class Internal::ProjectPrivate; + +signals: + void reportCommandDescription(const QString &highlight, const QString &message); + void reportProcessResult(const qbs::ProcessResult &result); + +private: + BuildJob(const Internal::Logger &logger, QObject *parent); + + void build(const Internal::TopLevelProjectPtr &project, + const QVector &products, + const BuildOptions &options); + void handleLauncherError(const ErrorInfo &error); + + void finish() override; +}; + + +class QBS_EXPORT CleanJob : public AbstractJob +{ + Q_OBJECT + friend class Internal::ProjectPrivate; + +private: + CleanJob(const Internal::Logger &logger, QObject *parent); + + void clean(const Internal::TopLevelProjectPtr &project, + const QVector &products, const CleanOptions &options); +}; + +class QBS_EXPORT InstallJob : public AbstractJob +{ + Q_OBJECT + friend class Internal::ProjectPrivate; +private: + InstallJob(const Internal::Logger &logger, QObject *parent); + + void install(const Internal::TopLevelProjectPtr &project, + const QVector &products, + const InstallOptions &options); +}; + +} // namespace qbs + +#endif // QBS_JOBS_H diff --git a/src/lib/corelib/api/languageinfo.cpp b/src/lib/corelib/api/languageinfo.cpp new file mode 100644 index 00000000..505012e8 --- /dev/null +++ b/src/lib/corelib/api/languageinfo.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "languageinfo.h" + +#include +#include +#include + +#include + +namespace qbs { + +std::string LanguageInfo::qmlTypeInfo() +{ + const Internal::BuiltinDeclarations &builtins = Internal::BuiltinDeclarations::instance(); + + // Header: + std::string result; + result.append("import QtQuick.tooling 1.0\n\n"); + result.append("// This file describes the plugin-supplied types contained in the library.\n"); + result.append("// It is used for QML tooling purposes only.\n\n"); + result.append("Module {\n"); + + // Individual Components: + auto typeNames = builtins.allTypeNames(); + typeNames.sort(); + for (const QString &typeName : qAsConst(typeNames)) { + const auto typeNameString = typeName.toStdString(); + result.append(" Component {\n"); + result.append(" name: \"" + typeNameString + "\"\n"); + result.append(" exports: [ \"qbs/"); + result.append(typeNameString); + result.append(" "); + const auto v = builtins.languageVersion(); + result.append(QStringLiteral("%1.%2") + .arg(v.majorVersion()).arg(v.minorVersion()).toUtf8().data()); + result.append("\" ]\n"); + result.append(" prototype: \"QQuickItem\"\n"); + + Internal::ItemDeclaration itemDecl + = builtins.declarationsForType(builtins.typeForName(typeName)); + auto properties = itemDecl.properties(); + std::sort(std::begin(properties), std::end(properties), [] + (const Internal::PropertyDeclaration &a, const Internal::PropertyDeclaration &b) { + return a.name() < b.name(); + }); + for (const Internal::PropertyDeclaration &property : qAsConst(properties)) { + result.append(" Property { name: \""); + result.append(property.name().toUtf8().data()); + result.append("\"; "); + switch (property.type()) { + case qbs::Internal::PropertyDeclaration::UnknownType: + result.append("type: \"unknown\""); + break; + case qbs::Internal::PropertyDeclaration::Boolean: + result.append("type: \"bool\""); + break; + case qbs::Internal::PropertyDeclaration::Integer: + result.append("type: \"int\""); + break; + case qbs::Internal::PropertyDeclaration::Path: + result.append("type: \"string\""); + break; + case qbs::Internal::PropertyDeclaration::PathList: + result.append("type: \"string\"; isList: true"); + break; + case qbs::Internal::PropertyDeclaration::String: + result.append("type: \"string\""); + break; + case qbs::Internal::PropertyDeclaration::StringList: + result.append("type: \"string\"; isList: true"); + break; + case qbs::Internal::PropertyDeclaration::Variant: + result.append("type: \"QVariant\""); + break; + case qbs::Internal::PropertyDeclaration::VariantList: + result.append("type: \"QVariantList\""); + break; + } + result.append(" }\n"); // Property + } + + result.append(" }\n"); // Component + } + + // Footer: + result.append("}\n"); // Module + return result; +} + +Version LanguageInfo::qbsVersion() +{ + static const auto v = Version::fromString(QLatin1String(QBS_VERSION)); + return v; +} + +} // namespace qbs diff --git a/src/lib/corelib/api/languageinfo.h b/src/lib/corelib/api/languageinfo.h new file mode 100644 index 00000000..d0db7d5e --- /dev/null +++ b/src/lib/corelib/api/languageinfo.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LANGUAGEINFO_H +#define QBS_LANGUAGEINFO_H + +#include "../tools/qbs_export.h" + +#include + +namespace qbs { + +class Version; + +class QBS_EXPORT LanguageInfo +{ + LanguageInfo() = delete; + +public: + static std::string qmlTypeInfo(); + static Version qbsVersion(); +}; + +} // namespace qbs + +#endif // QBS_LANGUAGEINFO_H diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp new file mode 100644 index 00000000..46c73dab --- /dev/null +++ b/src/lib/corelib/api/project.cpp @@ -0,0 +1,1153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "project.h" +#include "project_p.h" + +#include "internaljobs.h" +#include "jobs.h" +#include "projectdata_p.h" +#include "projectfileupdater.h" +#include "propertymap_p.h" +#include "rulecommand_p.h" +#include "runenvironment.h" +#include "transformerdata_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static bool pluginsLoaded = false; +static std::mutex pluginsLoadedMutex; + +static void loadPlugins(const QStringList &_pluginPaths, const Logger &logger) +{ + std::lock_guard locker(pluginsLoadedMutex); + if (pluginsLoaded) + return; + + std::vector pluginPaths; + for (const QString &pluginPath : _pluginPaths) { + if (!FileInfo::exists(pluginPath)) { +#ifndef QBS_STATIC_LIB + logger.qbsWarning() << Tr::tr("Plugin path '%1' does not exist.") + .arg(QDir::toNativeSeparators(pluginPath)); +#endif + } else { + pluginPaths.push_back(pluginPath.toStdString()); + } + } + auto pluginManager = QbsPluginManager::instance(); + pluginManager->loadStaticPlugins(); + pluginManager->loadPlugins(pluginPaths, logger); + + qRegisterMetaType("qbs::ErrorInfo"); + qRegisterMetaType("qbs::ProcessResult"); + qRegisterMetaType("Internal::InternalJob *"); + qRegisterMetaType("qbs::AbstractJob *"); + pluginsLoaded = true; +} + +ProjectData ProjectPrivate::projectData() +{ + m_projectData = ProjectData(); + retrieveProjectData(m_projectData, internalProject); + m_projectData.d->buildDir = internalProject->buildDirectory; + return m_projectData; +} + +static void addDependencies(QVector &products) +{ + for (int i = 0; i < products.size(); ++i) { + const ResolvedProductPtr &product = products.at(i); + for (const ResolvedProductPtr &dependency : qAsConst(product->dependencies)) { + if (!products.contains(dependency)) + products.push_back(dependency); + } + } +} + +BuildJob *ProjectPrivate::buildProducts(const QVector &products, + const BuildOptions &options, bool needsDepencencyResolving, + QObject *jobOwner) +{ + QVector productsToBuild = products; + if (needsDepencencyResolving) + addDependencies(productsToBuild); + + const auto job = new BuildJob(logger, jobOwner); + job->build(internalProject, productsToBuild, options); + QBS_ASSERT(job->state() == AbstractJob::StateRunning,); + return job; +} + +CleanJob *ProjectPrivate::cleanProducts(const QVector &products, + const CleanOptions &options, QObject *jobOwner) +{ + const auto job = new CleanJob(logger, jobOwner); + job->clean(internalProject, products, options); + QBS_ASSERT(job->state() == AbstractJob::StateRunning,); + return job; +} + +InstallJob *ProjectPrivate::installProducts(const QVector &products, + const InstallOptions &options, bool needsDepencencyResolving, QObject *jobOwner) +{ + QVector productsToInstall = products; + if (needsDepencencyResolving) + addDependencies(productsToInstall); + const auto job = new InstallJob(logger, jobOwner); + job->install(internalProject, productsToInstall, options); + QBS_ASSERT(job->state() == AbstractJob::StateRunning,); + return job; +} + +QVector ProjectPrivate::internalProducts(const QList &products) const +{ + QVector internalProducts; + for (const ProductData &product : products) { + if (product.isEnabled()) + internalProducts.push_back(internalProduct(product)); + } + return internalProducts; +} + +static QVector enabledInternalProducts(const ResolvedProjectConstPtr &project, + bool includingNonDefault) +{ + QVector products; + for (const ResolvedProductPtr &p : project->products) { + if (p->enabled && (includingNonDefault || p->builtByDefault())) + products.push_back(p); + } + for (const auto &subProject : qAsConst(project->subProjects)) + products << enabledInternalProducts(subProject, includingNonDefault); + return products; +} + +QVector ProjectPrivate::allEnabledInternalProducts( + bool includingNonDefault) const +{ + return enabledInternalProducts(internalProject, includingNonDefault); +} + +static bool matches(const ProductData &product, const ResolvedProductConstPtr &rproduct) +{ + return product.name() == rproduct->name + && product.multiplexConfigurationId() == rproduct->multiplexConfigurationId; +} + +static ResolvedProductPtr internalProductForProject(const ResolvedProjectConstPtr &project, + const ProductData &product) +{ + for (const ResolvedProductPtr &resolvedProduct : project->products) { + if (matches(product, resolvedProduct)) + return resolvedProduct; + } + for (const auto &subProject : qAsConst(project->subProjects)) { + const ResolvedProductPtr &p = internalProductForProject(subProject, product); + if (p) + return p; + } + return {}; +} + +ResolvedProductPtr ProjectPrivate::internalProduct(const ProductData &product) const +{ + return internalProductForProject(internalProject, product); +} + +ProductData ProjectPrivate::findProductData(const ProductData &product) const +{ + for (const ProductData &p : m_projectData.allProducts()) { + if (p.name() == product.name() + && p.profile() == product.profile() + && p.multiplexConfigurationId() == product.multiplexConfigurationId()) { + return p; + } + } + return {}; +} + +QList ProjectPrivate::findProductsByName(const QString &name) const +{ + QList list; + for (const ProductData &p : m_projectData.allProducts()) { + if (p.name() == name) + list.push_back(p); + } + return list; +} + +GroupData ProjectPrivate::findGroupData(const ProductData &product, const QString &groupName) const +{ + for (const GroupData &g : product.groups()) { + if (g.name() == groupName) + return g; + } + return {}; +} + +GroupData ProjectPrivate::createGroupDataFromGroup(const GroupPtr &resolvedGroup, + const ResolvedProductConstPtr &product) +{ + GroupData group; + group.d->name = resolvedGroup->name; + group.d->prefix = resolvedGroup->prefix; + group.d->location = resolvedGroup->location; + for (const auto &sa : resolvedGroup->files) { + ArtifactData artifact = createApiSourceArtifact(sa); + setupInstallData(artifact, product); + group.d->sourceArtifacts.push_back(artifact); + } + if (resolvedGroup->wildcards) { + for (const auto &sa : resolvedGroup->wildcards->files) { + ArtifactData artifact = createApiSourceArtifact(sa); + setupInstallData(artifact, product); + group.d->sourceArtifactsFromWildcards.push_back(artifact); + } + } + std::sort(group.d->sourceArtifacts.begin(), + group.d->sourceArtifacts.end()); + std::sort(group.d->sourceArtifactsFromWildcards.begin(), + group.d->sourceArtifactsFromWildcards.end()); + group.d->properties.d->m_map = resolvedGroup->properties; + group.d->isEnabled = resolvedGroup->enabled; + group.d->isValid = true; + return group; +} + +ArtifactData ProjectPrivate::createApiSourceArtifact(const SourceArtifactConstPtr &sa) +{ + ArtifactData saApi; + saApi.d->isValid = true; + saApi.d->filePath = sa->absoluteFilePath; + saApi.d->fileTags = sa->fileTags.toStringList(); + saApi.d->isGenerated = false; + saApi.d->isTargetArtifact = false; + saApi.d->properties.d->m_map = sa->properties; + return saApi; +} + +ArtifactData ProjectPrivate::createArtifactData(const Artifact *artifact, + const ResolvedProductConstPtr &product, const ArtifactSet &targetArtifacts) +{ + ArtifactData ta; + ta.d->filePath = artifact->filePath(); + ta.d->fileTags = artifact->fileTags().toStringList(); + ta.d->properties.d->m_map = artifact->properties; + ta.d->isGenerated = artifact->artifactType == Artifact::Generated; + ta.d->isTargetArtifact = targetArtifacts.contains(const_cast(artifact)); + ta.d->isValid = true; + setupInstallData(ta, product); + return ta; +} + +void ProjectPrivate::setupInstallData(ArtifactData &artifact, + const ResolvedProductConstPtr &product) +{ + artifact.d->installData.d->isValid = true; + artifact.d->installData.d->isInstallable = artifact.properties().getModuleProperty( + StringConstants::qbsModule(), StringConstants::installProperty()).toBool(); + if (!artifact.d->installData.d->isInstallable) + return; + const QString installRoot = artifact.properties().getModuleProperty( + StringConstants::qbsModule(), StringConstants::installRootProperty()).toString(); + InstallOptions options; + options.setInstallRoot(installRoot); + artifact.d->installData.d->installRoot = installRoot; + try { + QString installFilePath = ProductInstaller::targetFilePath(product->topLevelProject(), + product->sourceDirectory, artifact.filePath(), artifact.properties().d->m_map, + options); + if (!installRoot.isEmpty()) + installFilePath.remove(0, installRoot.size()); + artifact.d->installData.d->installFilePath = installFilePath; + } catch (const ErrorInfo &e) { + logger.printWarning(e); + } +} + +void ProjectPrivate::addGroup(const ProductData &product, const QString &groupName) +{ + if (groupName.isEmpty()) + throw ErrorInfo(Tr::tr("Group has an empty name.")); + if (!product.isValid()) + throw ErrorInfo(Tr::tr("Product is invalid.")); + QList products = findProductsByName(product.name()); + if (products.empty()) + throw ErrorInfo(Tr::tr("Product '%1' does not exist.").arg(product.name())); + const auto resolvedProducts = internalProducts(products); + QBS_CHECK(products.size() == resolvedProducts.size()); + + for (const GroupPtr &resolvedGroup : resolvedProducts.front()->groups) { + if (resolvedGroup->name == groupName) { + throw ErrorInfo(Tr::tr("Group '%1' already exists in product '%2'.") + .arg(groupName, product.name()), resolvedGroup->location); + } + } + + ProjectFileGroupInserter groupInserter(products.front(), groupName); + groupInserter.apply(); +} + +ProjectPrivate::GroupUpdateContext ProjectPrivate::getGroupContext(const ProductData &product, + const GroupData &group) +{ + GroupUpdateContext context; + if (!product.isValid()) + throw ErrorInfo(Tr::tr("Product is invalid.")); + context.products = findProductsByName(product.name()); + if (context.products.empty()) + throw ErrorInfo(Tr::tr("Product '%1' does not exist.").arg(product.name())); + context.resolvedProducts = internalProducts(context.products); + + const QString groupName = group.isValid() ? group.name() : product.name(); + for (const ResolvedProductPtr &p : qAsConst(context.resolvedProducts)) { + for (const GroupPtr &g : p->groups) { + if (g->name == groupName) { + context.resolvedGroups << g; + break; + } + } + } + if (context.resolvedGroups.empty()) + throw ErrorInfo(Tr::tr("Group '%1' does not exist.").arg(groupName)); + for (const ProductData &p : qAsConst(context.products)) { + const GroupData &g = findGroupData(p, groupName); + QBS_CHECK(p.isValid()); + context.groups << g; + } + QBS_CHECK(context.resolvedProducts.size() == context.products.size()); + QBS_CHECK(context.resolvedProducts.size() == context.resolvedGroups.size()); + QBS_CHECK(context.products.size() == context.groups.size()); + return context; +} + +static bool matchesWildcard(const QString &filePath, const GroupConstPtr &group) +{ + if (!group->wildcards) + return false; + for (const QString &pattern : qAsConst(group->wildcards->patterns)) { + QString fullPattern; + if (QFileInfo(group->prefix).isAbsolute()) { + fullPattern = group->prefix; + } else { + fullPattern = QFileInfo(group->location.filePath()).absolutePath() + + QLatin1Char('/') + group->prefix; + } + fullPattern.append(QLatin1Char('/')).append(pattern); + fullPattern = QDir::cleanPath(fullPattern); + if (QRegularExpression(QRegularExpression::wildcardToRegularExpression(fullPattern)).match(filePath).hasMatch()) + return true; + } + return false; +} + +ProjectPrivate::FileListUpdateContext ProjectPrivate::getFileListContext(const ProductData &product, + const GroupData &group, const QStringList &filePaths, bool forAdding) +{ + FileListUpdateContext filesContext; + GroupUpdateContext &groupContext = filesContext.groupContext; + groupContext = getGroupContext(product, group); + + if (filePaths.empty()) + throw ErrorInfo(Tr::tr("No files supplied.")); + + QString prefix; + for (int i = 0; i < groupContext.resolvedGroups.size(); ++i) { + const GroupPtr &g = groupContext.resolvedGroups.at(i); + if (!g->prefix.isEmpty() && !g->prefix.endsWith(QLatin1Char('/'))) + throw ErrorInfo(Tr::tr("Group has non-directory prefix.")); + if (i == 0) + prefix = g->prefix; + else if (prefix != g->prefix) + throw ErrorInfo(Tr::tr("Cannot update: Group prefix depends on properties.")); + } + QString baseDirPath = QFileInfo(product.location().filePath()).dir().absolutePath() + + QLatin1Char('/') + prefix; + QDir baseDir(baseDirPath); + for (const QString &filePath : filePaths) { + const QString absPath = QDir::cleanPath(FileInfo::resolvePath(baseDirPath, filePath)); + if (filesContext.absoluteFilePaths.contains(absPath)) + throw ErrorInfo(Tr::tr("File '%1' appears more than once.").arg(absPath)); + if (forAdding && !FileInfo(absPath).exists()) + throw ErrorInfo(Tr::tr("File '%1' does not exist.").arg(absPath)); + if (matchesWildcard(absPath, groupContext.resolvedGroups.front())) { + filesContext.absoluteFilePathsFromWildcards << absPath; + } else { + filesContext.absoluteFilePaths << absPath; + filesContext.relativeFilePaths << baseDir.relativeFilePath(absPath); + } + } + + return filesContext; +} + +void ProjectPrivate::addFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths) +{ + FileListUpdateContext filesContext = getFileListContext(product, group, filePaths, true); + GroupUpdateContext &groupContext = filesContext.groupContext; + + // We do not check for entries in other groups, because such doublettes might be legitimate + // due to conditions. + for (const GroupPtr &group : qAsConst(groupContext.resolvedGroups)) { + for (const QString &filePath : qAsConst(filesContext.absoluteFilePaths)) { + for (const auto &sa : group->files) { + if (sa->absoluteFilePath == filePath) { + throw ErrorInfo(Tr::tr("File '%1' already exists in group '%2'.") + .arg(filePath, group->name)); + } + } + } + } + + ProjectFileFilesAdder adder(groupContext.products.front(), + group.isValid() ? groupContext.groups.front() : GroupData(), + filesContext.relativeFilePaths); + adder.apply(); +} + +void ProjectPrivate::removeFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths) +{ + FileListUpdateContext filesContext = getFileListContext(product, group, filePaths, false); + GroupUpdateContext &groupContext = filesContext.groupContext; + + if (!filesContext.absoluteFilePathsFromWildcards.empty()) { + throw ErrorInfo(Tr::tr("The following files cannot be removed from the project file, " + "because they match wildcard patterns: %1") + .arg(filesContext.absoluteFilePathsFromWildcards.join(QLatin1String(", ")))); + } + QStringList filesNotFound = filesContext.absoluteFilePaths; + std::vector sourceArtifacts; + for (const SourceArtifactPtr &sa : groupContext.resolvedGroups.front()->files) { + if (filesNotFound.removeOne(sa->absoluteFilePath)) + sourceArtifacts << sa; + } + if (!filesNotFound.empty()) { + throw ErrorInfo(Tr::tr("The following files are not known to qbs: %1") + .arg(filesNotFound.join(QLatin1String(", ")))); + } + + ProjectFileFilesRemover remover(groupContext.products.front(), + group.isValid() ? groupContext.groups.front() : GroupData(), + filesContext.relativeFilePaths); + remover.apply(); +} + +void ProjectPrivate::removeGroup(const ProductData &product, const GroupData &group) +{ + GroupUpdateContext context = getGroupContext(product, group); + ProjectFileGroupRemover remover(context.products.front(), context.groups.front()); + remover.apply(); + +} + +void ProjectPrivate::prepareChangeToProject() +{ + if (internalProject->locked) + throw ErrorInfo(Tr::tr("A job is currently in progress.")); + if (!m_projectData.isValid()) + retrieveProjectData(m_projectData, internalProject); +} + +RuleCommandList ProjectPrivate::ruleCommandListForTransformer(const Transformer *transformer) +{ + RuleCommandList list; + for (const AbstractCommandPtr &internalCommand : qAsConst(transformer->commands.commands())) { + RuleCommand externalCommand; + externalCommand.d->description = internalCommand->description(); + externalCommand.d->extendedDescription = internalCommand->extendedDescription(); + switch (internalCommand->type()) { + case AbstractCommand::JavaScriptCommandType: { + externalCommand.d->type = RuleCommand::JavaScriptCommandType; + const JavaScriptCommandPtr &jsCmd + = std::static_pointer_cast(internalCommand); + externalCommand.d->sourceCode = jsCmd->sourceCode(); + break; + } + case AbstractCommand::ProcessCommandType: { + externalCommand.d->type = RuleCommand::ProcessCommandType; + const ProcessCommandPtr &procCmd + = std::static_pointer_cast(internalCommand); + externalCommand.d->executable = procCmd->program(); + externalCommand.d->arguments = procCmd->arguments(); + externalCommand.d->workingDir = procCmd->workingDir(); + externalCommand.d->environment = procCmd->environment(); + break; + } + } + list << externalCommand; + } + return list; +} + +RuleCommandList ProjectPrivate::ruleCommands(const ProductData &product, + const QString &inputFilePath, const QString &outputFileTag) +{ + if (internalProject->locked) + throw ErrorInfo(Tr::tr("A job is currently in progress.")); + const ResolvedProductConstPtr resolvedProduct = internalProduct(product); + if (!resolvedProduct) + throw ErrorInfo(Tr::tr("No such product '%1'.").arg(product.name())); + if (!resolvedProduct->enabled) + throw ErrorInfo(Tr::tr("Product '%1' is disabled.").arg(product.name())); + QBS_CHECK(resolvedProduct->buildData); + const ArtifactSet &outputArtifacts = resolvedProduct->buildData->artifactsByFileTag() + .value(FileTag(outputFileTag.toLocal8Bit())); + for (const Artifact * const outputArtifact : qAsConst(outputArtifacts)) { + const TransformerConstPtr transformer = outputArtifact->transformer; + if (!transformer) + continue; + for (const Artifact * const inputArtifact : qAsConst(transformer->inputs)) { + if (inputArtifact->filePath() == inputFilePath) + return ruleCommandListForTransformer(transformer.get()); + } + } + + throw ErrorInfo(Tr::tr("No rule was found that produces an artifact tagged '%1' " + "from input file '%2'.").arg(outputFileTag, inputFilePath)); +} + +ProjectTransformerData ProjectPrivate::transformerData() +{ + if (!m_projectData.isValid()) + retrieveProjectData(m_projectData, internalProject); + ProjectTransformerData projectTransformerData; + for (const ProductData &productData : m_projectData.allProducts()) { + if (!productData.isEnabled()) + continue; + const ResolvedProductConstPtr product = internalProduct(productData); + QBS_ASSERT(!!product, continue); + QBS_ASSERT(!!product->buildData, continue); + const ArtifactSet targetArtifacts = product->targetArtifacts(); + Set allTransformers; + for (const Artifact * const a : TypeFilter(product->buildData->allNodes())) { + if (a->artifactType == Artifact::Generated) + allTransformers.insert(a->transformer.get()); + } + if (allTransformers.empty()) + continue; + ProductTransformerData productTransformerData; + for (const Transformer * const t : allTransformers) { + TransformerData tData; + Set allInputs; + for (Artifact * const a : t->outputs) { + tData.d->outputs << createArtifactData(a, product, targetArtifacts); + for (const Artifact * const child : filterByType(a->children)) + allInputs << child; + for (Artifact * const a + : RulesApplicator::collectAuxiliaryInputs(t->rule.get(), product.get())) { + if (a->artifactType == Artifact::Generated) + tData.d->inputs << createArtifactData(a, product, targetArtifacts); + } + } + for (const Artifact * const input : allInputs) + tData.d->inputs << createArtifactData(input, product, targetArtifacts); + tData.d->commands = ruleCommandListForTransformer(t); + productTransformerData << tData; + } + projectTransformerData << qMakePair(productData, productTransformerData); + } + return projectTransformerData; +} + +static bool productIsRunnable(const ResolvedProductConstPtr &product) +{ + const bool isBundle = product->moduleProperties->moduleProperty( + QStringLiteral("bundle"), QStringLiteral("isBundle")).toBool(); + const QString androidSdkPackageType = product->moduleProperties->moduleProperty( + QStringLiteral("Android.sdk"), QStringLiteral("packageType")).toString(); + const bool isAndroidApk = androidSdkPackageType == QStringLiteral("apk"); + return isRunnableArtifact(product->fileTags, isBundle, isAndroidApk); +} + +static bool productIsMultiplexed(const ResolvedProductConstPtr &product) +{ + return product->productProperties.value(StringConstants::multiplexedProperty()).toBool(); +} + +void ProjectPrivate::retrieveProjectData(ProjectData &projectData, + const ResolvedProjectConstPtr &internalProject) +{ + projectData.d->name = internalProject->name; + projectData.d->location = internalProject->location; + projectData.d->enabled = internalProject->enabled; + for (const auto &resolvedProduct : internalProject->products) { + ProductData product; + product.d->type = resolvedProduct->fileTags.toStringList(); + product.d->name = resolvedProduct->name; + product.d->targetName = resolvedProduct->targetName; + product.d->version = resolvedProduct + ->productProperties.value(StringConstants::versionProperty()).toString(); + product.d->multiplexConfigurationId = resolvedProduct->multiplexConfigurationId; + product.d->location = resolvedProduct->location; + product.d->buildDirectory = resolvedProduct->buildDirectory(); + product.d->isEnabled = resolvedProduct->enabled; + product.d->isRunnable = productIsRunnable(resolvedProduct); + product.d->isMultiplexed = productIsMultiplexed(resolvedProduct); + product.d->properties = resolvedProduct->productProperties; + product.d->moduleProperties.d->m_map = resolvedProduct->moduleProperties; + for (const GroupPtr &resolvedGroup : resolvedProduct->groups) { + if (resolvedGroup->targetOfModule.isEmpty()) + product.d->groups << createGroupDataFromGroup(resolvedGroup, resolvedProduct); + } + if (resolvedProduct->enabled) { + QBS_CHECK(resolvedProduct->buildData); + const ArtifactSet targetArtifacts = resolvedProduct->targetArtifacts(); + for (Artifact * const a + : filterByType(resolvedProduct->buildData->allNodes())) { + if (a->artifactType != Artifact::Generated) + continue; + product.d->generatedArtifacts << createArtifactData(a, resolvedProduct, + targetArtifacts); + } + const AllRescuableArtifactData &rad + = resolvedProduct->buildData->rescuableArtifactData(); + for (auto it = rad.begin(); it != rad.end(); ++it) { + ArtifactData ta; + ta.d->filePath = it.key(); + ta.d->fileTags = it.value().fileTags.toStringList(); + ta.d->properties.d->m_map = it.value().properties; + ta.d->isGenerated = true; + ta.d->isTargetArtifact = resolvedProduct->fileTags.intersects(it.value().fileTags); + ta.d->isValid = true; + setupInstallData(ta, resolvedProduct); + product.d->generatedArtifacts << ta; + } + } + for (const ResolvedProductPtr &resolvedDependentProduct + : qAsConst(resolvedProduct->dependencies)) { + product.d->dependencies << resolvedDependentProduct->fullDisplayName(); + } + std::sort(product.d->type.begin(), product.d->type.end()); + std::sort(product.d->groups.begin(), product.d->groups.end()); + std::sort(product.d->generatedArtifacts.begin(), product.d->generatedArtifacts.end()); + product.d->isValid = true; + projectData.d->products << product; + } + for (const auto &internalSubProject : qAsConst(internalProject->subProjects)) { + if (!internalSubProject->enabled) + continue; + ProjectData subProject; + retrieveProjectData(subProject, internalSubProject); + projectData.d->subProjects << subProject; + } + projectData.d->isValid = true; + std::sort(projectData.d->products.begin(), projectData.d->products.end()); + std::sort(projectData.d->subProjects.begin(), projectData.d->subProjects.end()); +} + +} // namespace Internal + +using namespace Internal; + + /*! + * \class Project + * \brief The \c Project class provides services related to a qbs project. + */ + +Project::Project(const TopLevelProjectPtr &internalProject, const Logger &logger) + : d(new ProjectPrivate(internalProject, logger)) +{ +} + +Project::Project(const Project &other) = default; + +Project::~Project() = default; + +/*! + * \brief Returns true if and only if this object was retrieved from a successful \c SetupProjectJob. + * \sa SetupProjectJob + */ +bool Project::isValid() const +{ + return d && d->internalProject; +} + +/*! + * \brief The top-level profile for building this project. + */ +QString Project::profile() const +{ + QBS_ASSERT(isValid(), return {}); + return d->internalProject->profile(); +} + +Project &Project::operator=(const Project &other) = default; + +/*! + * \brief Sets up a \c Project from a source file, possibly re-using previously stored information. + * The function will finish immediately, returning a \c SetupProjectJob which can be used to + * track the results of the operation. + * If the function is called on a valid \c Project object, the build graph will not be loaded + * from a file, but will be taken from the existing project. In that case, if resolving + * finishes successfully, the existing project will be invalidated. If resolving fails, qbs will + * try to keep the existing project valid. However, under certain circumstances, resolving the new + * project will fail at a time where existing project data has already been touched, in which case + * the existing project has to be invalidated (this could be avoided, but it would hurt performance). + * So after an unsuccessful re-resolve job, the existing project may or may not be valid anymore. + * \note The qbs plugins will only be loaded once. As a result, the value of + * \c parameters.pluginPaths will only have an effect the first time this function is called. + * Similarly, the value of \c parameters.searchPaths will not have an effect if + * a stored build graph is available. + */ +SetupProjectJob *Project::setupProject(const SetupProjectParameters ¶meters, + ILogSink *logSink, QObject *jobOwner) +{ + Logger logger(logSink); + const auto job = new SetupProjectJob(logger, jobOwner); + try { + loadPlugins(parameters.pluginPaths(), logger); + job->resolve(*this, parameters); + QBS_ASSERT(job->state() == AbstractJob::StateRunning,); + } catch (const ErrorInfo &error) { + // Throwing from here would complicate the API, so let's report the error the same way + // as all others, via AbstractJob::error(). + job->reportError(error); + } + return job; +} + +Project::Project() = default; + +/*! + * \brief Retrieves information for this project. + * Call this function if you need insight into the project structure, e.g. because you want to know + * which products or files are in it. + */ +ProjectData Project::projectData() const +{ + QBS_ASSERT(isValid(), return {}); + return d->projectData(); +} + +RunEnvironment Project::getRunEnvironment(const ProductData &product, + const InstallOptions &installOptions, + const QProcessEnvironment &environment, + const QStringList &setupRunEnvConfig, Settings *settings) const +{ + const ResolvedProductPtr resolvedProduct = d->internalProduct(product); + return RunEnvironment(resolvedProduct, d->internalProject, installOptions, environment, + setupRunEnvConfig, settings, d->logger); +} + +/*! + * \enum Project::ProductSelection + * This enum type specifies which products to include if "all" products are to be built. + * \value Project::ProdProductSelectionDefaultOnly Indicates that only those products should be + * built whose \c builtByDefault property + * is \c true. + * \value Project::ProdProductSelectionWithNonDefault Indicates that products whose + * \c builtByDefault property is \c false should + * also be built. + */ + +/*! + * \brief Causes all products of this project to be built, if necessary. + * If and only if \c producSelection is \c Project::ProductSelectionWithNonDefault, products with + * the \c builtByDefault property set to \c false will be built too. + * The function will finish immediately, returning a \c BuildJob identifiying the operation. + */ +BuildJob *Project::buildAllProducts(const BuildOptions &options, ProductSelection productSelection, + QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + const bool includingNonDefault = productSelection == ProductSelectionWithNonDefault; + return d->buildProducts(d->allEnabledInternalProducts(includingNonDefault), options, + !includingNonDefault, jobOwner); +} + +/*! + * \brief Causes the specified list of products to be built. + * Use this function if you only want to build some products, not the whole project. If any of + * the products in \a products depend on other products, those will also be built. + * The function will finish immediately, returning a \c BuildJob identifiying the operation. + */ +BuildJob *Project::buildSomeProducts(const QList &products, + const BuildOptions &options, QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + return d->buildProducts(d->internalProducts(products), options, true, jobOwner); +} + +/*! + * \brief Convenience function for \c buildSomeProducts(). + * \sa Project::buildSomeProducts(). + */ +BuildJob *Project::buildOneProduct(const ProductData &product, const BuildOptions &options, + QObject *jobOwner) const +{ + return buildSomeProducts(QList() << product, options, jobOwner); +} + +/*! + * \brief Removes the build artifacts of all products in the project. + * The function will finish immediately, returning a \c CleanJob identifiying this operation. + * \sa Project::cleanSomeProducts() + */ +CleanJob *Project::cleanAllProducts(const CleanOptions &options, QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + return d->cleanProducts(d->allEnabledInternalProducts(true), options, jobOwner); +} + +/*! + * \brief Removes the build artifacts of the given products. + * The function will finish immediately, returning a \c CleanJob identifiying this operation. + */ +CleanJob *Project::cleanSomeProducts(const QList &products, + const CleanOptions &options, QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + return d->cleanProducts(d->internalProducts(products), options, jobOwner); +} + +/*! + * \brief Convenience function for \c cleanSomeProducts(). + * \sa Project::cleanSomeProducts(). + */ +CleanJob *Project::cleanOneProduct(const ProductData &product, const CleanOptions &options, + QObject *jobOwner) const +{ + return cleanSomeProducts(QList() << product, options, jobOwner); +} + +/*! + * \brief Installs the installable files of all products in the project. + * If and only if \c producSelection is \c Project::ProductSelectionWithNonDefault, products with + * the \c builtByDefault property set to \c false will be installed too. + * The function will finish immediately, returning an \c InstallJob identifiying this operation. + */ +InstallJob *Project::installAllProducts(const InstallOptions &options, + ProductSelection productSelection, QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + const bool includingNonDefault = productSelection == ProductSelectionWithNonDefault; + return d->installProducts(d->allEnabledInternalProducts(includingNonDefault), options, + !includingNonDefault, jobOwner); +} + +/*! + * \brief Installs the installable files of the given products. + * The function will finish immediately, returning an \c InstallJob identifiying this operation. + */ +InstallJob *Project::installSomeProducts(const QList &products, + const InstallOptions &options, QObject *jobOwner) const +{ + QBS_ASSERT(isValid(), return nullptr); + return d->installProducts(d->internalProducts(products), options, true, jobOwner); +} + +/*! + * \brief Convenience function for \c installSomeProducts(). + * \sa Project::installSomeProducts(). + */ +InstallJob *Project::installOneProduct(const ProductData &product, const InstallOptions &options, + QObject *jobOwner) const +{ + return installSomeProducts(QList() << product, options, jobOwner); +} + +/*! + * \brief Updates the timestamps of all build artifacts in the given products. + * Afterwards, the build graph will have the same state as if a successful build had been done. + */ +void Project::updateTimestamps(const QList &products) +{ + QBS_ASSERT(isValid(), return); + TimestampsUpdater().updateTimestamps(d->internalProject, d->internalProducts(products), + d->logger); +} + +/*! + * \brief Finds files generated from the given file in the given product. + * If \a recursive is \c false, only files generated directly from \a file will be considered, + * otherwise the generated files are collected recursively. + * If \a tags is not empty, only generated files matching at least one of these tags will + * be considered. + */ +QStringList Project::generatedFiles(const ProductData &product, const QString &file, + bool recursive, const QStringList &tags) const +{ + QBS_ASSERT(isValid(), return {}); + const ResolvedProductConstPtr internalProduct = d->internalProduct(product); + return internalProduct->generatedFiles(file, recursive, FileTags::fromStringList(tags)); +} + +QVariantMap Project::projectConfiguration() const +{ + QBS_ASSERT(isValid(), return {}); + return d->internalProject->buildConfiguration(); +} + +std::set Project::buildSystemFiles() const +{ + QBS_ASSERT(isValid(), return {}); + return rangeTo>(d->internalProject->buildSystemFiles); +} + +RuleCommandList Project::ruleCommands(const ProductData &product, + const QString &inputFilePath, const QString &outputFileTag, ErrorInfo *error) const +{ + QBS_ASSERT(isValid(), return {}); + QBS_ASSERT(product.isValid(), return {}); + + try { + return d->ruleCommands(product, inputFilePath, outputFileTag); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +ProjectTransformerData Project::transformerData(ErrorInfo *error) const +{ + QBS_ASSERT(isValid(), return {}); + try { + return d->transformerData(); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +ErrorInfo Project::dumpNodesTree(QIODevice &outDevice, const QList &products) +{ + try { + NodeTreeDumper(outDevice).start(d->internalProducts(products)); + } catch (const ErrorInfo &e) { + return e; + } + return {}; +} + +Project::BuildGraphInfo Project::getBuildGraphInfo(const QString &bgFilePath, + const QStringList &requestedProperties) +{ + BuildGraphInfo info; + try { + const Internal::TopLevelProjectConstPtr project = BuildGraphLoader::loadProject(bgFilePath); + info.bgFilePath = bgFilePath; + info.overriddenProperties = project->overriddenValues; + info.profileData = project->profileConfigs; + std::vector> props; + for (const QString &prop : requestedProperties) { + QStringList components = prop.split(QLatin1Char('.')); + const QString propName = components.takeLast(); + props.emplace_back(components.join(QLatin1Char('.')), propName); + } + for (const auto &product : project->allProducts()) { + if (props.empty()) + break; + if (product->profile() != project->profile()) + continue; + for (auto it = props.begin(); it != props.end();) { + const QVariant value + = product->moduleProperties->moduleProperty(it->first, it->second); + if (value.isValid()) { + info.requestedProperties.insert(it->first + QLatin1Char('.') + it->second, + value); + it = props.erase(it); + } else { + ++it; + } + } + } + } catch (const ErrorInfo &e) { + info.error = e; + } + return info; +} + +Project::BuildGraphInfo Project::getBuildGraphInfo() const +{ + QBS_ASSERT(isValid(), return {}); + BuildGraphInfo info; + try { + if (d->internalProject->locked) + throw ErrorInfo(Tr::tr("A job is currently in progress.")); + info.bgFilePath = d->internalProject->buildGraphFilePath(); + info.overriddenProperties = d->internalProject->overriddenValues; + info.profileData = d->internalProject->profileConfigs; + } catch (const ErrorInfo &e) { + info.error = e; + } + return info; +} + +/*! + * \brief Adds a new empty group to the given product. + * Returns an \c ErrorInfo object for which \c hasError() is false in case of a success + * and true otherwise. In the latter case, the object will have a sensible description. + * After calling this function, it is recommended to re-fetch the project data, as other + * items can be affected. + * \sa qbs::Project::projectData() + */ +ErrorInfo Project::addGroup(const ProductData &product, const QString &groupName) +{ + try { + QBS_CHECK(isValid()); + d->prepareChangeToProject(); + d->addGroup(product, groupName); + d->internalProject->store(d->logger); + return {}; + } catch (const ErrorInfo &exception) { + auto errorInfo = exception; + errorInfo.prepend(Tr::tr("Failure adding group '%1' to product '%2'.") + .arg(groupName, product.name())); + return errorInfo; + } +} + +/*! + * \brief Adds the given files to the given product. + * If \c group is a default-constructed object, the files will be added to the product's + * "files" property, otherwise to the one of \c group. + * The file paths can be absolute or relative to the location of \c product (including a possible + * prefix in the group). The project file will always contain relative paths. + * After calling this function, it is recommended to re-fetch the project data, as other + * items can be affected. + * \sa qbs::Project::projectData() + */ +ErrorInfo Project::addFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths) +{ + try { + QBS_CHECK(isValid()); + d->prepareChangeToProject(); + d->addFiles(product, group, filePaths); + d->internalProject->store(d->logger); + return {}; + } catch (const ErrorInfo &exception) { + auto errorInfo = exception; + errorInfo.prepend(Tr::tr("Failure adding files to product.")); + return errorInfo; + } +} + +/*! + * \brief Removes the given files from the given product. + * If \c group is a default-constructed object, the files will be removed from the product's + * "files" property, otherwise from the one of \c group. + * The file paths can be absolute or relative to the location of \c product (including a possible + * prefix in the group). + * After calling this function, it is recommended to re-fetch the project data, as other + * items can be affected. + * \sa qbs::Project::projectData() + */ +ErrorInfo Project::removeFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths) +{ + try { + QBS_CHECK(isValid()); + d->prepareChangeToProject(); + d->removeFiles(product, group, filePaths); + d->internalProject->store(d->logger); + return {}; + } catch (const ErrorInfo &exception) { + auto errorInfo = exception; + errorInfo.prepend(Tr::tr("Failure removing files from product '%1'.").arg(product.name())); + return errorInfo; + } +} + +/*! + * \brief Removes the given group from the given product. + * After calling this function, it is recommended to re-fetch the project data, as other + * items can be affected. + * \sa qbs::Project::projectData() + */ +ErrorInfo Project::removeGroup(const ProductData &product, const GroupData &group) +{ + try { + QBS_CHECK(isValid()); + d->prepareChangeToProject(); + d->removeGroup(product, group); + d->internalProject->store(d->logger); + return {}; + } catch (const ErrorInfo &exception) { + auto errorInfo = exception; + errorInfo.prepend(Tr::tr("Failure removing group '%1' from product '%2'.") + .arg(group.name(), product.name())); + return errorInfo; + } +} + +} // namespace qbs diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h new file mode 100644 index 00000000..7ea7645a --- /dev/null +++ b/src/lib/corelib/api/project.h @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECT_H +#define QBS_PROJECT_H + +#include "rulecommand.h" +#include "transformerdata.h" +#include "../language/forward_decls.h" +#include "../tools/error.h" +#include "../tools/porting.h" +#include "../tools/qbs_export.h" + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QIODevice; +class QObject; +class QProcessEnvironment; +QT_END_NAMESPACE + +namespace qbs { +class BuildJob; +class BuildOptions; +class CleanJob; +class CleanOptions; +class GroupData; +class ILogSink; +class InstallJob; +class InstallOptions; +class ProductData; +class ProjectData; +class RunEnvironment; +class Settings; +class SetupProjectJob; +class SetupProjectParameters; + +namespace Internal { +class Logger; +class ProjectPrivate; +} // namespace Internal; + +class QBS_EXPORT Project +{ + friend class SetupProjectJob; + friend QHashValueType qHash(const Project &p); +public: + SetupProjectJob *setupProject(const SetupProjectParameters ¶meters, + ILogSink *logSink, QObject *jobOwner); + + Project(); + Project(const Project &other); + Project &operator=(const Project &other); + ~Project(); + + bool isValid() const; + QString profile() const; + ProjectData projectData() const; + RunEnvironment getRunEnvironment(const ProductData &product, + const InstallOptions &installOptions, + const QProcessEnvironment &environment, + const QStringList &setupRunEnvConfig, Settings *settings) const; + + enum ProductSelection { ProductSelectionDefaultOnly, ProductSelectionWithNonDefault }; + BuildJob *buildAllProducts(const BuildOptions &options, + ProductSelection productSelection = ProductSelectionDefaultOnly, + QObject *jobOwner = nullptr) const; + BuildJob *buildSomeProducts(const QList &products, const BuildOptions &options, + QObject *jobOwner = nullptr) const; + BuildJob *buildOneProduct(const ProductData &product, const BuildOptions &options, + QObject *jobOwner = nullptr) const; + + CleanJob *cleanAllProducts(const CleanOptions &options, QObject *jobOwner = nullptr) const; + CleanJob *cleanSomeProducts(const QList &products, const CleanOptions &options, + QObject *jobOwner = nullptr) const; + CleanJob *cleanOneProduct(const ProductData &product, const CleanOptions &options, + QObject *jobOwner = nullptr) const; + + InstallJob *installAllProducts(const InstallOptions &options, + ProductSelection productSelection = ProductSelectionDefaultOnly, + QObject *jobOwner = nullptr) const; + InstallJob *installSomeProducts(const QList &products, + const InstallOptions &options, + QObject *jobOwner = nullptr) const; + InstallJob *installOneProduct(const ProductData &product, const InstallOptions &options, + QObject *jobOwner = nullptr) const; + + void updateTimestamps(const QList &products); + + bool operator==(const Project &other) const { return d.data() == other.d.data(); } + + QStringList generatedFiles(const ProductData &product, const QString &file, + bool recursive, const QStringList &tags = QStringList()) const; + + QVariantMap projectConfiguration() const; + + std::set buildSystemFiles() const; + + RuleCommandList ruleCommands(const ProductData &product, const QString &inputFilePath, + const QString &outputFileTag, ErrorInfo *error = nullptr) const; + ProjectTransformerData transformerData(ErrorInfo *error = nullptr) const; + + ErrorInfo dumpNodesTree(QIODevice &outDevice, const QList &products); + + + class BuildGraphInfo + { + public: + QString bgFilePath; + QVariantMap overriddenProperties; + QVariantMap profileData; + QVariantMap requestedProperties; + ErrorInfo error; + }; + static BuildGraphInfo getBuildGraphInfo(const QString &bgFilePath, + const QStringList &requestedProperties); + + // Use with loaded project. Does not set requestedProperties. + BuildGraphInfo getBuildGraphInfo() const; + + + ErrorInfo addGroup(const ProductData &product, const QString &groupName); + ErrorInfo addFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths); + ErrorInfo removeFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths); + ErrorInfo removeGroup(const ProductData &product, const GroupData &group); + +private: + Project(const Internal::TopLevelProjectPtr &internalProject, const Internal::Logger &logger); + + QExplicitlySharedDataPointer d; +}; + +inline bool operator!=(const Project &p1, const Project &p2) { return !(p1 == p2); } +inline QHashValueType qHash(const Project &p) { return QT_PREPEND_NAMESPACE(qHash)(p.d.data()); } + +} // namespace qbs + +#endif // QBS_PROJECT_H diff --git a/src/lib/corelib/api/project_p.h b/src/lib/corelib/api/project_p.h new file mode 100644 index 00000000..60c8311f --- /dev/null +++ b/src/lib/corelib/api/project_p.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECT_P_H +#define QBS_PROJECT_P_H + +#include "projectdata.h" +#include "rulecommand.h" +#include "transformerdata.h" + +#include +#include + +#include +#include + +namespace qbs { +class BuildJob; +class BuildOptions; +class CleanJob; +class CleanOptions; +class InstallJob; +class InstallOptions; + +namespace Internal { + +class ProjectPrivate : public QSharedData +{ +public: + ProjectPrivate(TopLevelProjectPtr internalProject, Logger logger) + : internalProject(std::move(internalProject)), logger(std::move(logger)) + { + } + + ProjectData projectData(); + BuildJob *buildProducts(const QVector &products, const BuildOptions &options, + bool needsDepencencyResolving, + QObject *jobOwner); + CleanJob *cleanProducts(const QVector &products, const CleanOptions &options, + QObject *jobOwner); + InstallJob *installProducts(const QVector &products, + const InstallOptions &options, bool needsDepencencyResolving, + QObject *jobOwner); + QVector internalProducts(const QList &products) const; + QVector allEnabledInternalProducts(bool includingNonDefault) const; + ResolvedProductPtr internalProduct(const ProductData &product) const; + ProductData findProductData(const ProductData &product) const; + QList findProductsByName(const QString &name) const; + GroupData findGroupData(const ProductData &product, const QString &groupName) const; + + GroupData createGroupDataFromGroup(const GroupPtr &resolvedGroup, + const ResolvedProductConstPtr &product); + ArtifactData createApiSourceArtifact(const SourceArtifactConstPtr &sa); + ArtifactData createArtifactData(const Artifact *artifact, + const ResolvedProductConstPtr &product, + const ArtifactSet &targetArtifacts); + void setupInstallData(ArtifactData &artifact, const ResolvedProductConstPtr &product); + + struct GroupUpdateContext { + QVector resolvedProducts; + QList resolvedGroups; + QList products; + QList groups; + }; + + struct FileListUpdateContext { + GroupUpdateContext groupContext; + QStringList absoluteFilePaths; + QStringList relativeFilePaths; + QStringList absoluteFilePathsFromWildcards; // Not included in the other two lists. + }; + + GroupUpdateContext getGroupContext(const ProductData &product, const GroupData &group); + FileListUpdateContext getFileListContext(const ProductData &product, const GroupData &group, + const QStringList &filePaths, bool forAdding); + + void addGroup(const ProductData &product, const QString &groupName); + void addFiles(const ProductData &product, const GroupData &group, const QStringList &filePaths); + void removeFiles(const ProductData &product, const GroupData &group, + const QStringList &filePaths); + void removeGroup(const ProductData &product, const GroupData &group); + + void prepareChangeToProject(); + + RuleCommandList ruleCommandListForTransformer(const Transformer *transformer); + RuleCommandList ruleCommands(const ProductData &product, + const QString &inputFilePath, const QString &outputFileTag); + ProjectTransformerData transformerData(); + + TopLevelProjectPtr internalProject; + Logger logger; + +private: + void retrieveProjectData(ProjectData &projectData, + const ResolvedProjectConstPtr &internalProject); + + ProjectData m_projectData; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/api/projectdata.cpp b/src/lib/corelib/api/projectdata.cpp new file mode 100644 index 00000000..75018653 --- /dev/null +++ b/src/lib/corelib/api/projectdata.cpp @@ -0,0 +1,1020 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "projectdata.h" + +#include "projectdata_p.h" +#include "propertymap_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { + +using namespace Internal; + +template static QJsonArray toJsonArray(const QList &list, + const QStringList &moduleProperties) +{ + // We can't use transformed from stlutils.h here as QJsonArray has not the reserve() method. + QJsonArray jsonArray; + transform(list, jsonArray, [&moduleProperties](const T &v) { + return v.toJson(moduleProperties);}); + return jsonArray; +} + +static QVariant getModuleProperty(const PropertyMap &properties, const QString &fullPropertyName) +{ + const int lastDotIndex = fullPropertyName.lastIndexOf(QLatin1Char('.')); + if (lastDotIndex == -1) + return QVariant(); + return properties.getModuleProperty(fullPropertyName.left(lastDotIndex), + fullPropertyName.mid(lastDotIndex + 1)); +} + +static void addModuleProperties(QJsonObject &obj, const PropertyMap &properties, + const QStringList &propertyNames) +{ + QJsonObject propertyValues; + for (const QString &prop : propertyNames) { + const QVariant v = getModuleProperty(properties, prop); + if (v.isValid()) + propertyValues.insert(prop, QJsonValue::fromVariant(v)); + } + if (!propertyValues.isEmpty()) + obj.insert(StringConstants::modulePropertiesKey(), propertyValues); +} + +/*! + * \class GroupData + * \brief The \c GroupData class corresponds to the Group item in a qbs source file. + */ + +GroupData::GroupData() : d(new GroupDataPrivate) +{ +} + +GroupData::GroupData(const GroupData &other) = default; + +GroupData::GroupData(GroupData &&) Q_DECL_NOEXCEPT = default; + +GroupData &GroupData::operator=(const GroupData &other) = default; + +GroupData &GroupData::operator=(GroupData &&) Q_DECL_NOEXCEPT = default; + +GroupData::~GroupData() = default; + +/*! + * \brief Returns true if and only if the Group holds data that was initialized by Qbs. + */ +bool GroupData::isValid() const +{ + return d->isValid; +} + +QJsonObject GroupData::toJson(const QStringList &moduleProperties) const +{ + QJsonObject obj; + if (isValid()) { + obj.insert(StringConstants::locationKey(), location().toJson()); + obj.insert(StringConstants::nameProperty(), name()); + obj.insert(StringConstants::prefixProperty(), prefix()); + obj.insert(StringConstants::isEnabledKey(), isEnabled()); + obj.insert(QStringLiteral("source-artifacts"), toJsonArray(sourceArtifacts(), {})); + obj.insert(QStringLiteral("source-artifacts-from-wildcards"), + toJsonArray(sourceArtifactsFromWildcards(), {})); + addModuleProperties(obj, properties(), moduleProperties); + } + return obj; +} + +/*! + * \brief The location at which the group is defined in the respective source file. + */ +CodeLocation GroupData::location() const +{ + return d->location; +} + +/*! + * \brief The name of the group. + */ +QString GroupData::name() const +{ + return d->name; +} + +/*! + * \brief The prefix of the group. + */ +QString GroupData::prefix() const +{ + return d->prefix; +} + +/*! + * \brief The files listed in the group item's "files" binding. + * \note These do not include expanded wildcards. + * \sa GroupData::sourceArtifactsFromWildcards + */ +QList GroupData::sourceArtifacts() const +{ + return d->sourceArtifacts; +} + +/*! + * \brief The list of files resulting from expanding all wildcard patterns in the group. + */ +QList GroupData::sourceArtifactsFromWildcards() const +{ + return d->sourceArtifactsFromWildcards; +} + +/*! + * \brief All files in this group, regardless of how whether they were given explicitly + * or via wildcards. + * \sa GroupData::sourceArtifacts + * \sa GroupData::sourceArtifactsFromWildcards + */ +QList GroupData::allSourceArtifacts() const +{ + return sourceArtifacts() + sourceArtifactsFromWildcards(); +} + +/*! + * \brief The set of properties valid in this group. + * Typically, most of them are inherited from the respective \c Product. + */ +PropertyMap GroupData::properties() const +{ + return d->properties; +} + +/*! + * \brief Returns true if this group is enabled in Qbs + * This method returns the "condition" property of the \c Group definition. If the group is enabled + * then the files in this group will be processed, provided the product it belongs to is also + * enabled. + * + * Note that a group can be enabled, even if the product it belongs to is not. In this case + * the files in the group will not be processed. + * \sa ProductData::isEnabled() + */ +bool GroupData::isEnabled() const +{ + QBS_ASSERT(isValid(), return false); + return d->isEnabled; +} + +/*! + * \brief The paths of all files in this group. + * \sa GroupData::allSourceArtifacts + */ +QStringList GroupData::allFilePaths() const +{ + const QList &artifacts = allSourceArtifacts(); + return transformed(artifacts, [](const auto &sa) { return sa.filePath(); }); +} + +bool operator!=(const GroupData &lhs, const GroupData &rhs) +{ + return !(lhs == rhs); +} + +bool operator==(const GroupData &lhs, const GroupData &rhs) +{ + if (!lhs.isValid() && !rhs.isValid()) + return true; + + return lhs.isValid() == rhs.isValid() + && lhs.name() == rhs.name() + && lhs.location() == rhs.location() + && lhs.sourceArtifactsFromWildcards() == rhs.sourceArtifactsFromWildcards() + && lhs.sourceArtifacts() == rhs.sourceArtifacts() + && lhs.properties() == rhs.properties() + && lhs.isEnabled() == rhs.isEnabled(); +} + +bool operator<(const GroupData &lhs, const GroupData &rhs) +{ + return lhs.name() < rhs.name(); +} + + +/*! + * \class ArtifactData + * The \c ArtifactData class describes a file in a product. It is either a source file + * or it gets generated during the build process. + */ + +ArtifactData::ArtifactData() : d(new ArtifactDataPrivate) +{ +} + +ArtifactData::ArtifactData(const ArtifactData &other) = default; + +ArtifactData::ArtifactData(ArtifactData &&) Q_DECL_NOEXCEPT = default; + +ArtifactData &ArtifactData::operator=(const ArtifactData &other) = default; + +ArtifactData &ArtifactData::operator=(ArtifactData &&) Q_DECL_NOEXCEPT = default; + +ArtifactData::~ArtifactData() = default; + +/*! + * \brief Returns true if and only if this object holds data that was initialized by Qbs. + */ +bool ArtifactData::isValid() const +{ + return d->isValid; +} + +QJsonObject ArtifactData::toJson(const QStringList &moduleProperties) const +{ + QJsonObject obj; + if (isValid()) { + obj.insert(StringConstants::filePathKey(), filePath()); + obj.insert(QStringLiteral("file-tags"), QJsonArray::fromStringList(fileTags())); + obj.insert(QStringLiteral("is-generated"), isGenerated()); + obj.insert(QStringLiteral("is-executable"), isExecutable()); + obj.insert(QStringLiteral("is-target"), isTargetArtifact()); + obj.insert(QStringLiteral("install-data"), installData().toJson()); + addModuleProperties(obj, properties(), moduleProperties); + } + return obj; +} + +/*! + * \brief The full path of this file. + */ +QString ArtifactData::filePath() const +{ + return d->filePath; +} + +/*! + * \brief The tags of this file. + * Typically, this list will contain just one element. + */ +QStringList ArtifactData::fileTags() const +{ + return d->fileTags; +} + +bool ArtifactData::isGenerated() const +{ + return d->isGenerated; +} + +/*! + * \brief True if and only if this file is executable, + * either natively or through an interpreter or shell. + */ +bool ArtifactData::isExecutable() const +{ + const bool isBundle = d->properties.getModuleProperty( + QStringLiteral("bundle"), QStringLiteral("isBundle")).toBool(); + const QString androidSdkPackageType = d->properties.getModuleProperty( + QStringLiteral("Android.sdk"), QStringLiteral("packageType")).toString(); + const bool isAndroidApk = androidSdkPackageType == QStringLiteral("apk"); + return isRunnableArtifact(FileTags::fromStringList(d->fileTags), isBundle, isAndroidApk); +} + +/*! + * \brief True if and only if this artifact is a target artifact of its product. + */ +bool ArtifactData::isTargetArtifact() const +{ + QBS_ASSERT(isValid(), return false); + return d->isTargetArtifact; +} + +/*! + * \brief The properties of this file. + */ +PropertyMap ArtifactData::properties() const +{ + return d->properties; +} + +/*! + \brief The installation-related data of this artifact. + */ +InstallData ArtifactData::installData() const +{ + return d->installData; +} + +bool operator==(const ArtifactData &ad1, const ArtifactData &ad2) +{ + return ad1.filePath() == ad2.filePath() + && ad1.fileTags() == ad2.fileTags() + && ad1.isGenerated() == ad2.isGenerated() + && ad1.properties() == ad2.properties(); +} + +bool operator!=(const ArtifactData &ta1, const ArtifactData &ta2) +{ + return !(ta1 == ta2); +} + +bool operator<(const ArtifactData &ta1, const ArtifactData &ta2) +{ + return ta1.filePath() < ta2.filePath(); +} + + +/*! + * \class InstallData + * \brief The \c InstallData class provides the installation-related data of an artifact. + */ + +InstallData::InstallData() : d(new InstallDataPrivate) +{ +} + +InstallData::InstallData(const InstallData &other) = default; + +InstallData::InstallData(InstallData &&) Q_DECL_NOEXCEPT = default; + +InstallData &InstallData::operator=(const InstallData &other) = default; + +InstallData &InstallData::operator=(InstallData &&) Q_DECL_NOEXCEPT = default; + +InstallData::~InstallData() = default; + +/*! + * \brief Returns true if and only if this object holds data that was initialized by Qbs. + */ +bool InstallData::isValid() const +{ + return d->isValid; +} + +QJsonObject InstallData::toJson() const +{ + QJsonObject obj; + if (isValid()) { + obj.insert(QStringLiteral("is-installable"), isInstallable()); + if (isInstallable()) { + obj.insert(QStringLiteral("install-file-path"), installFilePath()); + obj.insert(QStringLiteral("install-root"), installRoot()); + } + } + return obj; +} + +/*! + \brief Returns true if and only if \c{qbs.install} is \c true for the artifact. + */ +bool InstallData::isInstallable() const +{ + QBS_ASSERT(isValid(), return false); + return d->isInstallable; +} + +/*! + \brief Returns the directory into which the artifact will be installed. + \note This is not necessarily the same as \c{qbs.installDir}, because \c{qbs.installSourceBase} + might have been used. + */ +QString InstallData::installDir() const +{ + QBS_ASSERT(isValid(), return {}); + return FileInfo::path(installFilePath()); +} + +/*! + \brief Returns the installed file path of the artifact. + */ +QString InstallData::installFilePath() const +{ + QBS_ASSERT(isValid(), return {}); + return d->installFilePath; +} + +/*! + \brief Returns the value of \c{qbs.installRoot} for the artifact. + */ +QString InstallData::installRoot() const +{ + QBS_ASSERT(isValid(), return {}); + return d->installRoot; +} + +/*! + \brief Returns the local installation directory of the artifact, that is \c installDir() + prepended by \c installRoot(). + */ +QString InstallData::localInstallDir() const +{ + return QDir::cleanPath(installRoot() + QLatin1Char('/') + installDir()); +} + +/*! + \brief Returns the local installed file path of the artifact, that is \c installFilePath() + prepended by \c installRoot(). + */ +QString InstallData::localInstallFilePath() const +{ + return QDir::cleanPath(installRoot() + QLatin1Char('/') + installFilePath()); +} + +/*! + * \class ProductData + * \brief The \c ProductData class corresponds to the Product item in a qbs source file. + */ + +ProductData::ProductData() : d(new ProductDataPrivate) +{ +} + +ProductData::ProductData(const ProductData &other) = default; + +ProductData::ProductData(ProductData &&) Q_DECL_NOEXCEPT = default; + +ProductData &ProductData::operator=(const ProductData &other) = default; + +ProductData &ProductData::operator=(ProductData &&) Q_DECL_NOEXCEPT = default; + +ProductData::~ProductData() = default; + +/*! + * \brief Returns true if and only if the Product holds data that was initialized by Qbs. + */ +bool ProductData::isValid() const +{ + return d->isValid; +} + +QJsonObject ProductData::toJson(const QStringList &propertyNames) const +{ + QJsonObject obj; + if (!isValid()) + return obj; + obj.insert(StringConstants::typeProperty(), QJsonArray::fromStringList(type())); + obj.insert(StringConstants::dependenciesProperty(), + QJsonArray::fromStringList(dependencies())); + obj.insert(StringConstants::nameProperty(), name()); + obj.insert(StringConstants::fullDisplayNameKey(), fullDisplayName()); + obj.insert(QStringLiteral("target-name"), targetName()); + obj.insert(StringConstants::versionProperty(), version()); + obj.insert(QStringLiteral("multiplex-configuration-id"), multiplexConfigurationId()); + obj.insert(StringConstants::locationKey(), location().toJson()); + obj.insert(StringConstants::buildDirectoryKey(), buildDirectory()); + obj.insert(QStringLiteral("generated-artifacts"), toJsonArray(generatedArtifacts(), + propertyNames)); + obj.insert(QStringLiteral("target-executable"), targetExecutable()); + QJsonArray groupArray; + for (const GroupData &g : groups()) { + const QStringList groupPropNames = g.properties() == moduleProperties() + ? QStringList() : propertyNames; + groupArray << g.toJson(groupPropNames); + } + obj.insert(QStringLiteral("groups"), groupArray); + obj.insert(QStringLiteral("properties"), QJsonObject::fromVariantMap(properties())); + obj.insert(StringConstants::isEnabledKey(), isEnabled()); + obj.insert(QStringLiteral("is-runnable"), isRunnable()); + obj.insert(QStringLiteral("is-multiplexed"), isMultiplexed()); + addModuleProperties(obj, moduleProperties(), propertyNames); + return obj; +} + +/*! + * \brief The product type, which is the list of file tags matching the product's target artifacts. + */ +const QStringList &ProductData::type() const +{ + return d->type; +} + +/*! + * \brief The names of dependent products. + */ +const QStringList &ProductData::dependencies() const +{ + return d->dependencies; +} + +/*! + * \brief The name of the product as given in the qbs source file. + */ +const QString &ProductData::name() const +{ + return d->name; +} + +/*! + The name of the product as given in the qbs source file, plus information + about which properties it was multiplexed on and the values of these properties. + If the product was not multiplexed, the returned value is the same as \c name(). + */ +QString ProductData::fullDisplayName() const +{ + return ResolvedProduct::fullDisplayName(name(), multiplexConfigurationId()); +} + +/*! + * \brief The base name of the product's target file as given in the qbs source file. + */ +const QString &ProductData::targetName() const +{ + return d->targetName; +} + +/*! + * \brief The version number of the product. + */ +const QString &ProductData::version() const +{ + return d->version; +} + +/*! + * \brief The profile this product will be built for. + */ +QString ProductData::profile() const +{ + return d->moduleProperties.getModuleProperty( + StringConstants::qbsModule(), + StringConstants::profileProperty()).toString(); +} + +const QString &ProductData::multiplexConfigurationId() const +{ + return d->multiplexConfigurationId; +} + +/*! + * \brief The location at which the product is defined in the source file. + */ +const CodeLocation &ProductData::location() const +{ + return d->location; +} + +/*! + * \brief The directory under which the product's generated artifacts are located. + */ +const QString &ProductData::buildDirectory() const +{ + return d->buildDirectory; +} + +/*! + * \brief All artifacts that are generated when building this product. + */ +const QList &ProductData::generatedArtifacts() const +{ + return d->generatedArtifacts; +} + +/*! + \brief This product's target artifacts. + This is a subset of \c generatedArtifacts() + */ +const QList ProductData::targetArtifacts() const +{ + QList list; + std::copy_if(d->generatedArtifacts.cbegin(), d->generatedArtifacts.cend(), + std::back_inserter(list), + [](const ArtifactData &a) { return a.isTargetArtifact(); }); + return list; +} + +/*! + * \brief The list of artifacts in this product that are to be installed. + */ +const QList ProductData::installableArtifacts() const +{ + QList artifacts; + for (const GroupData &g : qAsConst(d->groups)) { + const auto sourceArtifacts = g.allSourceArtifacts(); + for (const ArtifactData &a : sourceArtifacts) { + if (a.installData().isInstallable()) + artifacts << a; + } + } + for (const ArtifactData &a : qAsConst(d->generatedArtifacts)) { + if (a.installData().isInstallable()) + artifacts << a; + } + return artifacts; +} + +/*! + * \brief Returns the file path of the executable associated with this product. + * If the product is not an application, an empty string is returned. + */ +QString ProductData::targetExecutable() const +{ + QBS_ASSERT(isValid(), return {}); + if (d->moduleProperties.getModuleProperty(QStringLiteral("bundle"), + QStringLiteral("isBundle")).toBool()) { + const auto artifacts = targetArtifacts(); + for (const ArtifactData &ta : artifacts) { + if (ta.fileTags().contains(QLatin1String("bundle.application-executable"))) { + if (ta.installData().isInstallable()) + return ta.installData().localInstallFilePath(); + return ta.filePath(); + } + } + } + const auto artifacts = targetArtifacts(); + for (const ArtifactData &ta : artifacts) { + if (ta.isExecutable()) { + if (ta.installData().isInstallable()) + return ta.installData().localInstallFilePath(); + return ta.filePath(); + } + } + return {}; +} + +/*! + * \brief The list of \c GroupData in this product. + */ +const QList &ProductData::groups() const +{ + return d->groups; +} + +/*! + * \brief The product properties. + */ +const QVariantMap &ProductData::properties() const +{ + return d->properties; +} + +/*! + * \brief The set of properties inherited from dependent products and modules. + */ +const PropertyMap &ProductData::moduleProperties() const +{ + return d->moduleProperties; +} + +/*! + * \brief Returns true if this Product is enabled in Qbs. + * This method returns the \c condition property of the \c Product definition. If a product is + * enabled, then it will be built in the current configuration. + * \sa GroupData::isEnabled() + */ +bool ProductData::isEnabled() const +{ + QBS_ASSERT(isValid(), return false); + return d->isEnabled; +} + +bool ProductData::isRunnable() const +{ + QBS_ASSERT(isValid(), return false); + return d->isRunnable; +} + +bool ProductData::isMultiplexed() const +{ + QBS_ASSERT(isValid(), return false); + return d->isMultiplexed; +} + +bool operator==(const ProductData &lhs, const ProductData &rhs) +{ + if (!lhs.isValid() && !rhs.isValid()) + return true; + + return lhs.isValid() == rhs.isValid() + && lhs.name() == rhs.name() + && lhs.targetName() == rhs.targetName() + && lhs.type() == rhs.type() + && lhs.version() == rhs.version() + && lhs.dependencies() == rhs.dependencies() + && lhs.profile() == rhs.profile() + && lhs.multiplexConfigurationId() == rhs.multiplexConfigurationId() + && lhs.location() == rhs.location() + && lhs.groups() == rhs.groups() + && lhs.generatedArtifacts() == rhs.generatedArtifacts() + && lhs.properties() == rhs.properties() + && lhs.moduleProperties() == rhs.moduleProperties() + && lhs.isEnabled() == rhs.isEnabled() + && lhs.isMultiplexed() == rhs.isMultiplexed(); +} + +bool operator!=(const ProductData &lhs, const ProductData &rhs) +{ + return !(lhs == rhs); +} + +bool operator<(const ProductData &lhs, const ProductData &rhs) +{ + const int nameCmp = lhs.name().compare(rhs.name()); + if (nameCmp < 0) + return true; + if (nameCmp > 0) + return false; + return lhs.profile() < rhs.profile() + && lhs.multiplexConfigurationId() < rhs.multiplexConfigurationId(); +} + +/*! + * \class ProjectData + * \brief The \c ProjectData class corresponds to the \c Project item in a qbs source file. + */ + +/*! + * \fn QList ProjectData::products() const + * \brief The products in this project. + */ + +ProjectData::ProjectData() : d(new ProjectDataPrivate) +{ +} + +ProjectData::ProjectData(const ProjectData &other) = default; + +ProjectData::ProjectData(ProjectData &&) Q_DECL_NOEXCEPT = default; + +ProjectData &ProjectData::operator =(const ProjectData &other) = default; + +ProjectData &ProjectData::operator=(ProjectData &&) Q_DECL_NOEXCEPT = default; + +ProjectData::~ProjectData() = default; + +/*! + * \brief Returns true if and only if the Project holds data that was initialized by Qbs. + */ +bool ProjectData::isValid() const +{ + return d->isValid; +} + +QJsonObject ProjectData::toJson(const QStringList &moduleProperties) const +{ + QJsonObject obj; + if (!isValid()) + return obj; + obj.insert(StringConstants::nameProperty(), name()); + obj.insert(StringConstants::locationKey(), location().toJson()); + obj.insert(StringConstants::isEnabledKey(), isEnabled()); + obj.insert(StringConstants::productsKey(), toJsonArray(products(), moduleProperties)); + obj.insert(QStringLiteral("sub-projects"), toJsonArray(subProjects(), moduleProperties)); + return obj; +} + +/*! + * \brief The name of this project. + */ +const QString &ProjectData::name() const +{ + return d->name; +} + +/*! + * \brief The location at which the project is defined in a qbs source file. + */ +const CodeLocation &ProjectData::location() const +{ + return d->location; +} + +/*! + * \brief Whether the project is enabled. + * \note Disabled projects never have any products or sub-projects. + */ +bool ProjectData::isEnabled() const +{ + QBS_ASSERT(isValid(), return false); + return d->enabled; +} + +/*! + * \brief The base directory under which the build artifacts of this project will be created. + * This is only valid for the top-level project. + */ +const QString &ProjectData::buildDirectory() const +{ + return d->buildDir; +} + +/*! + * The products in this project. + * \note This also includes disabled products. + */ +const QList &ProjectData::products() const +{ + return d->products; +} + +/*! + * The sub-projects of this project. + */ +const QList &ProjectData::subProjects() const +{ + return d->subProjects; +} + +/*! + * All products in this projects and its direct and indirect sub-projects. + */ +const QList ProjectData::allProducts() const +{ + QList productList = products(); + for (const ProjectData &pd : qAsConst(d->subProjects)) + productList << pd.allProducts(); + return productList; +} + +/*! + * The artifacts of all products in this project that are to be installed. + */ +const QList ProjectData::installableArtifacts() const +{ + QList artifacts; + const auto products = allProducts(); + for (const ProductData &p : products) + artifacts << p.installableArtifacts(); + return artifacts; +} + +bool operator==(const ProjectData &lhs, const ProjectData &rhs) +{ + if (!lhs.isValid() && !rhs.isValid()) + return true; + + return lhs.isValid() == rhs.isValid() + && lhs.isEnabled() == rhs.isEnabled() + && lhs.name() == rhs.name() + && lhs.buildDirectory() == rhs.buildDirectory() + && lhs.location() == rhs.location() + && lhs.subProjects() == rhs.subProjects() + && lhs.products() == rhs.products(); +} + +bool operator!=(const ProjectData &lhs, const ProjectData &rhs) +{ + return !(lhs == rhs); +} + +bool operator<(const ProjectData &lhs, const ProjectData &rhs) +{ + return lhs.name() < rhs.name(); +} + +/*! + * \class PropertyMap + * \brief The \c PropertyMap class represents the properties of a group or a product. + */ + +PropertyMap::PropertyMap() + : d(std::make_unique()) +{ + static PropertyMapPtr defaultInternalMap = PropertyMapInternal::create(); + d->m_map = defaultInternalMap; +} + +PropertyMap::PropertyMap(const PropertyMap &other) + : d(std::make_unique(*other.d)) +{ +} + +PropertyMap::PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT = default; + +PropertyMap::~PropertyMap() = default; + +PropertyMap &PropertyMap::operator =(const PropertyMap &other) +{ + if (this != &other) + d = std::make_unique(*other.d); + return *this; +} + +PropertyMap &PropertyMap::operator =(PropertyMap &&other) Q_DECL_NOEXCEPT = default; + +/*! + * \brief Returns the names of all properties. + */ +QStringList PropertyMap::allProperties() const +{ + QStringList properties; + for (QVariantMap::ConstIterator it = d->m_map->value().constBegin(); + it != d->m_map->value().constEnd(); ++it) { + if (!it.value().canConvert()) + properties << it.key(); + } + return properties; +} + +/*! + * \brief Returns the value of the given property of a product or group. + */ +QVariant PropertyMap::getProperty(const QString &name) const +{ + return d->m_map->value().value(name); +} + +/*! + * \brief Convenience wrapper around \c PropertyMap::getModuleProperty for properties of list type. + * + */ +QStringList PropertyMap::getModulePropertiesAsStringList(const QString &moduleName, + const QString &propertyName) const +{ + const QVariantList &vl = d->m_map->moduleProperty(moduleName, propertyName).toList(); + QStringList sl; + for (const QVariant &v : vl) { + QBS_ASSERT(v.canConvert(), continue); + sl << v.toString(); + } + return sl; +} + +/*! + * \brief Returns the value of the given module property. + */ +QVariant PropertyMap::getModuleProperty(const QString &moduleName, + const QString &propertyName) const +{ + return d->m_map->moduleProperty(moduleName, propertyName); +} + +static QString mapToString(const QVariantMap &map, const QString &prefix) +{ + QStringList keys(map.keys()); + std::sort(keys.begin(), keys.end()); + QString stringRep; + for (const QString &key : qAsConst(keys)) { + const QVariant &val = map.value(key); + if (val.userType() == QMetaType::QVariantMap) { + stringRep += mapToString(val.value(), prefix + key + QLatin1Char('.')); + } else { + stringRep += QStringLiteral("%1%2: %3\n") + .arg(prefix, key, toJSLiteral(val)); + } + } + return stringRep; +} + +QString PropertyMap::toString() const +{ + return mapToString(d->m_map->value(), QString()); +} + +bool operator==(const PropertyMap &pm1, const PropertyMap &pm2) +{ + return *pm1.d->m_map == *pm2.d->m_map; +} + +bool operator!=(const PropertyMap &pm1, const PropertyMap &pm2) +{ + return !(*pm1.d->m_map == *pm2.d->m_map); +} + +} // namespace qbs diff --git a/src/lib/corelib/api/projectdata.h b/src/lib/corelib/api/projectdata.h new file mode 100644 index 00000000..9fe6445c --- /dev/null +++ b/src/lib/corelib/api/projectdata.h @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECTDATA_H +#define QBS_PROJECTDATA_H + +#include "../tools/codelocation.h" +#include "../tools/qbs_export.h" + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { +class ArtifactDataPrivate; +class GroupDataPrivate; +class InstallDataPrivate; +class ProductDataPrivate; +class ProjectPrivate; +class ProjectDataPrivate; +class PropertyMapPrivate; +} // namespace Internal + +class PropertyMap; + +QBS_EXPORT bool operator==(const PropertyMap &pm1, const PropertyMap &pm2); +QBS_EXPORT bool operator!=(const PropertyMap &pm1, const PropertyMap &pm2); + +class QBS_EXPORT PropertyMap +{ + friend class Internal::ProjectPrivate; + friend QBS_EXPORT bool operator==(const PropertyMap &, const PropertyMap &); + friend QBS_EXPORT bool operator!=(const PropertyMap &, const PropertyMap &); + +public: + PropertyMap(); + PropertyMap(const PropertyMap &other); + PropertyMap(PropertyMap &&other) Q_DECL_NOEXCEPT; + ~PropertyMap(); + + PropertyMap &operator =(const PropertyMap &other); + PropertyMap &operator =(PropertyMap &&other) Q_DECL_NOEXCEPT; + + QStringList allProperties() const; + QVariant getProperty(const QString &name) const; + + QStringList getModulePropertiesAsStringList(const QString &moduleName, + const QString &propertyName) const; + QVariant getModuleProperty(const QString &moduleName, const QString &propertyName) const; + + // For debugging. + QString toString() const; + +private: + std::unique_ptr d; +}; + +class InstallData; + +class QBS_EXPORT ArtifactData +{ + friend class Internal::ProjectPrivate; +public: + ArtifactData(); + ArtifactData(const ArtifactData &other); + ArtifactData(ArtifactData &&) Q_DECL_NOEXCEPT; + ArtifactData &operator=(const ArtifactData &other); + ArtifactData &operator=(ArtifactData &&) Q_DECL_NOEXCEPT; + ~ArtifactData(); + + bool isValid() const; + QJsonObject toJson(const QStringList &moduleProperties = {}) const; + + QString filePath() const; + QStringList fileTags() const; + bool isGenerated() const; + bool isExecutable() const; + bool isTargetArtifact() const; + PropertyMap properties() const; + InstallData installData() const; + +private: + QExplicitlySharedDataPointer d; +}; + +class QBS_EXPORT InstallData +{ + friend class Internal::ProjectPrivate; +public: + InstallData(); + InstallData(const InstallData &other); + InstallData(InstallData &&) Q_DECL_NOEXCEPT; + InstallData &operator=(const InstallData &other); + InstallData &operator=(InstallData &&) Q_DECL_NOEXCEPT; + ~InstallData(); + + bool isValid() const; + QJsonObject toJson() const; + + bool isInstallable() const; + QString installDir() const; + QString installFilePath() const; + QString installRoot() const; + QString localInstallDir() const; + QString localInstallFilePath() const; +private: + QExplicitlySharedDataPointer d; +}; + +QBS_EXPORT bool operator==(const ArtifactData &ta1, const ArtifactData &ta2); +QBS_EXPORT bool operator!=(const ArtifactData &ta1, const ArtifactData &ta2); +QBS_EXPORT bool operator<(const ArtifactData &ta1, const ArtifactData &ta2); + +class QBS_EXPORT GroupData +{ + friend class Internal::ProjectPrivate; +public: + GroupData(); + GroupData(const GroupData &other); + GroupData(GroupData &&) Q_DECL_NOEXCEPT; + GroupData &operator=(const GroupData &other); + GroupData &operator=(GroupData &&) Q_DECL_NOEXCEPT; + ~GroupData(); + + bool isValid() const; + QJsonObject toJson(const QStringList &moduleProperties = {}) const; + + CodeLocation location() const; + QString name() const; + QString prefix() const; + QList sourceArtifacts() const; + QList sourceArtifactsFromWildcards() const; + QList allSourceArtifacts() const; + PropertyMap properties() const; + bool isEnabled() const; + QStringList allFilePaths() const; + +private: + QExplicitlySharedDataPointer d; +}; + +QBS_EXPORT bool operator==(const GroupData &lhs, const GroupData &rhs); +QBS_EXPORT bool operator!=(const GroupData &lhs, const GroupData &rhs); +QBS_EXPORT bool operator<(const GroupData &lhs, const GroupData &rhs); + +class QBS_EXPORT ProductData +{ + friend class Internal::ProjectPrivate; +public: + ProductData(); + ProductData(const ProductData &other); + ProductData(ProductData &&) Q_DECL_NOEXCEPT; + ProductData &operator=(const ProductData &other); + ProductData &operator=(ProductData &&) Q_DECL_NOEXCEPT; + ~ProductData(); + + bool isValid() const; + QJsonObject toJson(const QStringList &propertyNames = {}) const; + + const QStringList &type() const; + const QStringList &dependencies() const; + const QString &name() const; + QString fullDisplayName() const; + const QString &targetName() const; + const QString &version() const; + QString profile() const; + const QString &multiplexConfigurationId() const; + const CodeLocation &location() const; + const QString &buildDirectory() const; + const QList &generatedArtifacts() const; + const QList targetArtifacts() const; + const QList installableArtifacts() const; + QString targetExecutable() const; + const QList &groups() const; + const QVariantMap &properties() const; + const PropertyMap &moduleProperties() const; + bool isEnabled() const; + bool isRunnable() const; + bool isMultiplexed() const; + +private: + QExplicitlySharedDataPointer d; +}; + +QBS_EXPORT bool operator==(const ProductData &lhs, const ProductData &rhs); +QBS_EXPORT bool operator!=(const ProductData &lhs, const ProductData &rhs); +QBS_EXPORT bool operator<(const ProductData &lhs, const ProductData &rhs); + +class QBS_EXPORT ProjectData +{ + friend class Internal::ProjectPrivate; +public: + ProjectData(); + ProjectData(const ProjectData &other); + ProjectData(ProjectData &&) Q_DECL_NOEXCEPT; + ProjectData &operator=(const ProjectData &other); + ProjectData &operator=(ProjectData &&) Q_DECL_NOEXCEPT; + ~ProjectData(); + + bool isValid() const; + QJsonObject toJson(const QStringList &moduleProperties = {}) const; + + const QString &name() const; + const CodeLocation &location() const; + bool isEnabled() const; + const QString &buildDirectory() const; + const QList &products() const; + const QList &subProjects() const; + const QList allProducts() const; + const QList installableArtifacts() const; + +private: + QExplicitlySharedDataPointer d; +}; + +QBS_EXPORT bool operator==(const ProjectData &lhs, const ProjectData &rhs); +QBS_EXPORT bool operator!=(const ProjectData &lhs, const ProjectData &rhs); +QBS_EXPORT bool operator<(const ProjectData &lhs, const ProjectData &rhs); + +} // namespace qbs + +#endif // QBS_PROJECTDATA_H diff --git a/src/lib/corelib/api/projectdata_p.h b/src/lib/corelib/api/projectdata_p.h new file mode 100644 index 00000000..e241ea92 --- /dev/null +++ b/src/lib/corelib/api/projectdata_p.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECTDATA_P_H +#define QBS_PROJECTDATA_P_H + +#include "projectdata.h" +#include + +#include + +namespace qbs { +namespace Internal { + +class InstallDataPrivate : public QSharedData +{ +public: + QString installFilePath; + QString installRoot; + bool isValid = false; + bool isInstallable = false; +}; + +class ArtifactDataPrivate : public QSharedData +{ +public: + QString filePath; + QStringList fileTags; + PropertyMap properties; + InstallData installData; + bool isValid = false; + bool isGenerated = false; + bool isTargetArtifact = false; +}; + +class GroupDataPrivate : public QSharedData +{ +public: + QString name; + QString prefix; + CodeLocation location; + QList sourceArtifacts; + QList sourceArtifactsFromWildcards; + PropertyMap properties; + bool isEnabled = false; + bool isValid = false; +}; + +class InstallableFilePrivate: public QSharedData +{ +public: + QString sourceFilePath; + QString targetFilePath; + QStringList fileTags; + bool isValid = false; +}; + +class ProductDataPrivate : public QSharedData +{ +public: + QStringList type; + QStringList dependencies; + QString name; + QString targetName; + QString version; + QString multiplexConfigurationId; + CodeLocation location; + QString buildDirectory; + QList groups; + QVariantMap properties; + PropertyMap moduleProperties; + QList generatedArtifacts; + bool isEnabled = false; + bool isRunnable = false; + bool isMultiplexed = false; + bool isValid = false; +}; + +class ProjectDataPrivate : public QSharedData +{ +public: + QString name; + CodeLocation location; + bool enabled = false; + bool isValid = false; + QList products; + QList subProjects; + QString buildDir; +}; + +inline bool isRunnableArtifact(const FileTags &fileTags, bool isBundle, bool isAndroidApk) +{ + return (fileTags.contains("application") && (!isBundle || fileTags.contains("bundle.content"))) + || fileTags.contains("bundle.application-executable") + || (fileTags.contains("android.package") && isAndroidApk) + || fileTags.contains("msi"); +} + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/api/projectfileupdater.cpp b/src/lib/corelib/api/projectfileupdater.cpp new file mode 100644 index 00000000..fa42352c --- /dev/null +++ b/src/lib/corelib/api/projectfileupdater.cpp @@ -0,0 +1,561 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "projectfileupdater.h" + +#include "projectdata.h" +#include "qmljsrewriter.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace QbsQmlJS; +using namespace AST; + +namespace qbs { +namespace Internal { + +class ItemFinder : public Visitor +{ +public: + ItemFinder(const CodeLocation &cl) : m_cl(cl), m_item(nullptr) { } + + UiObjectDefinition *item() const { return m_item; } + +private: + bool visit(UiObjectDefinition *ast) override + { + if (toCodeLocation(m_cl.filePath(), ast->firstSourceLocation()) == m_cl) { + m_item = ast; + return false; + } + return true; + } + + const CodeLocation m_cl; + UiObjectDefinition *m_item; +}; + +class FilesBindingFinder : public Visitor +{ +public: + FilesBindingFinder(const UiObjectDefinition *startItem) + : m_startItem(startItem), m_binding(nullptr) + { + } + + UiScriptBinding *binding() const { return m_binding; } + +private: + bool visit(UiObjectDefinition *ast) override + { + // We start with the direct parent of the binding, so do not descend into any + // other item. + return ast == m_startItem; + } + + bool visit(UiScriptBinding *ast) override + { + if (ast->qualifiedId->name.toString() != StringConstants::filesProperty()) + return true; + m_binding = ast; + return false; + } + + const UiObjectDefinition * const m_startItem; + UiScriptBinding *m_binding; +}; + + +ProjectFileUpdater::ProjectFileUpdater(QString projectFile) : m_projectFile(std::move(projectFile)) +{ +} + +ProjectFileUpdater::~ProjectFileUpdater() = default; + +ProjectFileUpdater::LineEndingType ProjectFileUpdater::guessLineEndingType(const QByteArray &text) +{ + char before = 0; + int lfCount = 0; + int crlfCount = 0; + int i = text.indexOf('\n'); + while (i != -1) { + if (i > 0) + before = text.at(i - 1); + if (before == '\r') + ++crlfCount; + else + ++lfCount; + i = text.indexOf('\n', i + 1); + } + if (lfCount == 0 && crlfCount == 0) + return UnknownLineEndings; + if (crlfCount == 0) + return UnixLineEndings; + if (lfCount == 0) + return WindowsLineEndings; + return MixedLineEndings; +} + +void ProjectFileUpdater::convertToUnixLineEndings(QByteArray *text, LineEndingType oldLineEndings) +{ + if (oldLineEndings == UnixLineEndings) + return; + text->replace("\r\n", "\n"); +} + +void ProjectFileUpdater::convertFromUnixLineEndings(QByteArray *text, LineEndingType newLineEndings) +{ + if (newLineEndings == WindowsLineEndings + || (newLineEndings != UnixLineEndings && HostOsInfo::isWindowsHost())) { + text->replace('\n', "\r\n"); + } +} + +void ProjectFileUpdater::apply() +{ + QFile file(m_projectFile); + if (!file.open(QFile::ReadOnly)) { + throw ErrorInfo(Tr::tr("File '%1' cannot be opened for reading: %2") + .arg(m_projectFile, file.errorString())); + } + QByteArray rawContent = file.readAll(); + const LineEndingType origLineEndingType = guessLineEndingType(rawContent); + convertToUnixLineEndings(&rawContent, origLineEndingType); + QString content = QString::fromUtf8(rawContent); + + file.close(); + Engine engine; + Lexer lexer(&engine); + lexer.setCode(content, 1); + Parser parser(&engine); + if (!parser.parse()) { + QList parserMessages = parser.diagnosticMessages(); + if (!parserMessages.empty()) { + ErrorInfo errorInfo; + errorInfo.append(Tr::tr("Failure parsing project file.")); + for (const DiagnosticMessage &msg : qAsConst(parserMessages)) + errorInfo.append(msg.message, toCodeLocation(file.fileName(), msg.loc)); + throw errorInfo; + } + } + + doApply(content, parser.ast()); + + if (!file.open(QFile::WriteOnly)) { + throw ErrorInfo(Tr::tr("File '%1' cannot be opened for writing: %2") + .arg(m_projectFile, file.errorString())); + } + file.resize(0); + rawContent = content.toUtf8(); + convertFromUnixLineEndings(&rawContent, origLineEndingType); + file.write(rawContent); +} + + +ProjectFileGroupInserter::ProjectFileGroupInserter(ProductData product, QString groupName) + : ProjectFileUpdater(product.location().filePath()) + , m_product(std::move(product)) + , m_groupName(std::move(groupName)) +{ +} + +static int extractLine(const QString &fileContent, int pos) +{ +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) + return fileContent.leftRef(pos).count(QLatin1Char('\n')); +#else + return QStringView{fileContent}.left(pos).count(QLatin1Char('\n')); +#endif +} + +void ProjectFileGroupInserter::doApply(QString &fileContent, UiProgram *ast) +{ + ItemFinder itemFinder(m_product.location()); + ast->accept(&itemFinder); + if (!itemFinder.item()) { + throw ErrorInfo(Tr::tr("The project file parser failed to find the product item."), + CodeLocation(projectFile())); + } + + ChangeSet changeSet; + Rewriter rewriter(fileContent, &changeSet, QStringList()); + QString groupItemString; + const int productItemIndentation + = int(itemFinder.item()->qualifiedTypeNameId->firstSourceLocation().startColumn - 1); + const int groupItemIndentation = productItemIndentation + 4; + const QString groupItemIndentationString = QString(groupItemIndentation, QLatin1Char(' ')); + groupItemString += groupItemIndentationString + QLatin1String("Group {\n"); + groupItemString += groupItemIndentationString + groupItemIndentationString + + QLatin1String("name: \"") + m_groupName + QLatin1String("\"\n"); + groupItemString += groupItemIndentationString + groupItemIndentationString + + QLatin1String("files: []\n"); + groupItemString += groupItemIndentationString + QLatin1Char('}'); + rewriter.addObject(itemFinder.item()->initializer, groupItemString); + + int lineOffset = 3 + 1; // Our text + a leading newline that is always added by the rewriter. + const QList &editOps = changeSet.operationList(); + QBS_CHECK(editOps.size() == 1); + const ChangeSet::EditOp &insertOp = editOps.front(); + setLineOffset(lineOffset); + + int insertionLine = extractLine(fileContent, insertOp.pos1); + for (int i = 0; i < insertOp.text.size() && insertOp.text.at(i) == QLatin1Char('\n'); ++i) + ++insertionLine; // To account for newlines prepended by the rewriter. + ++insertionLine; // To account for zero-based indexing. + setItemPosition(CodeLocation(projectFile(), insertionLine, + groupItemIndentation + 1)); + changeSet.apply(&fileContent); +} + +static QString getNodeRepresentation(const QString &fileContent, const QbsQmlJS::AST::Node *node) +{ + const quint32 start = node->firstSourceLocation().offset; + const quint32 end = node->lastSourceLocation().end(); + return fileContent.mid(start, int(end - start)); +} + +static const ChangeSet::EditOp &getEditOp(const ChangeSet &changeSet) +{ + const QList &editOps = changeSet.operationList(); + QBS_CHECK(editOps.size() == 1); + return editOps.front(); +} + +static int getLineOffsetForChangedBinding(const ChangeSet &changeSet, const QString &oldRhs) +{ + return getEditOp(changeSet).text.count(QLatin1Char('\n')) - oldRhs.count(QLatin1Char('\n')); +} + +static int getBindingLine(const ChangeSet &changeSet, const QString &fileContent) +{ + return extractLine(fileContent, getEditOp(changeSet).pos1 + 1) + 1; +} + + +ProjectFileFilesAdder::ProjectFileFilesAdder(ProductData product, GroupData group, + QStringList files) + : ProjectFileUpdater(product.location().filePath()) + , m_product(std::move(product)) + , m_group(std::move(group)) + , m_files(std::move(files)) +{ +} + +static QString &addToFilesRepr(QString &filesRepr, const QString &fileRepr, int indentation) +{ + filesRepr += QString(indentation, QLatin1Char(' ')); + filesRepr += fileRepr; + filesRepr += QLatin1String(",\n"); + return filesRepr; +} + +static QString &addToFilesRepr(QString &filesRepr, const QStringList &filePaths, int indentation) +{ + for (const QString &f : filePaths) + addToFilesRepr(filesRepr, toJSLiteral(f), indentation); + return filesRepr; +} + +static QString &completeFilesRepr(QString &filesRepr, int indentation) +{ + return filesRepr.prepend(QLatin1String("[\n")).append(QString(indentation, QLatin1Char(' '))) + .append(QLatin1Char(']')); +} + +void ProjectFileFilesAdder::doApply(QString &fileContent, UiProgram *ast) +{ + if (m_files.empty()) + return; + QStringList sortedFiles = m_files; + sortedFiles.sort(); + + // Find the item containing the "files" binding. + ItemFinder itemFinder(m_group.isValid() ? m_group.location() : m_product.location()); + ast->accept(&itemFinder); + if (!itemFinder.item()) { + throw ErrorInfo(Tr::tr("The project file parser failed to find the item."), + CodeLocation(projectFile())); + } + + const int itemIndentation + = int(itemFinder.item()->qualifiedTypeNameId->firstSourceLocation().startColumn - 1); + const int bindingIndentation = itemIndentation + 4; + const int arrayElemIndentation = bindingIndentation + 4; + + // Now get the binding itself. + FilesBindingFinder bindingFinder(itemFinder.item()); + itemFinder.item()->accept(&bindingFinder); + + ChangeSet changeSet; + Rewriter rewriter(fileContent, &changeSet, QStringList()); + + UiScriptBinding * const filesBinding = bindingFinder.binding(); + if (filesBinding) { + QString filesRepresentation; + if (filesBinding->statement->kind != QbsQmlJS::AST::Node::Kind_ExpressionStatement) + throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex.")); // TODO: rename, add new and concat. + const auto exprStatement + = static_cast(filesBinding->statement); + switch (exprStatement->expression->kind) { + case QbsQmlJS::AST::Node::Kind_ArrayLiteral: { + auto elem = static_cast(exprStatement->expression)->elements; + QStringList oldFileReprs; + while (elem) { + oldFileReprs << getNodeRepresentation(fileContent, elem->expression); + elem = elem->next; + } + + // Insert new files "sorted", but do not change the order of existing files. + const QString firstNewFileRepr = toJSLiteral(sortedFiles.front()); + while (!oldFileReprs.empty()) { + if (oldFileReprs.front() > firstNewFileRepr) + break; + addToFilesRepr(filesRepresentation, oldFileReprs.takeFirst(), arrayElemIndentation); + } + addToFilesRepr(filesRepresentation, sortedFiles, arrayElemIndentation); + while (!oldFileReprs.empty()) + addToFilesRepr(filesRepresentation, oldFileReprs.takeFirst(), arrayElemIndentation); + completeFilesRepr(filesRepresentation, bindingIndentation); + break; + } + case QbsQmlJS::AST::Node::Kind_StringLiteral: { + const auto existingElement + = static_cast(exprStatement->expression)->value.toString(); + sortedFiles << existingElement; + sortedFiles.sort(); + addToFilesRepr(filesRepresentation, sortedFiles, arrayElemIndentation); + completeFilesRepr(filesRepresentation, bindingIndentation); + break; + } + default: { + // Note that we can often do better than simply concatenating: For instance, + // in the case where the existing list is of the form ["a", "b"].concat(myProperty), + // we could keep on parsing until we find the array literal and then merge it with + // the new files, preventing cascading concat() calls. + // But this is not essential and can be implemented when we have some downtime. + const QString rhsRepr = getNodeRepresentation(fileContent, exprStatement->expression); + addToFilesRepr(filesRepresentation, sortedFiles, arrayElemIndentation); + completeFilesRepr(filesRepresentation, bindingIndentation); + + // It cannot be the other way around, since the existing right-hand side could + // have string type. + filesRepresentation += QStringLiteral(".concat(%1)").arg(rhsRepr); + + } + } + rewriter.changeBinding(itemFinder.item()->initializer, StringConstants::filesProperty(), + filesRepresentation, Rewriter::ScriptBinding); + } else { // Can happen for the product itself, for which the "files" binding is not mandatory. + QString filesRepresentation; + addToFilesRepr(filesRepresentation, sortedFiles, arrayElemIndentation); + completeFilesRepr(filesRepresentation, bindingIndentation); + const QString bindingString = QString(bindingIndentation, QLatin1Char(' ')) + + StringConstants::filesProperty(); + rewriter.addBinding(itemFinder.item()->initializer, bindingString, filesRepresentation, + Rewriter::ScriptBinding); + } + + setLineOffset(getLineOffsetForChangedBinding(changeSet, + filesBinding ? getNodeRepresentation(fileContent, filesBinding->statement) + : QString())); + const int insertionLine = getBindingLine(changeSet, fileContent); + const int insertionColumn = (filesBinding ? arrayElemIndentation : bindingIndentation) + 1; + setItemPosition(CodeLocation(projectFile(), insertionLine, insertionColumn)); + changeSet.apply(&fileContent); +} + +ProjectFileFilesRemover::ProjectFileFilesRemover(ProductData product, GroupData group, + QStringList files) + : ProjectFileUpdater(product.location().filePath()) + , m_product(std::move(product)) + , m_group(std::move(group)) + , m_files(std::move(files)) +{ +} + +void ProjectFileFilesRemover::doApply(QString &fileContent, UiProgram *ast) +{ + if (m_files.empty()) + return; + + // Find the item containing the "files" binding. + ItemFinder itemFinder(m_group.isValid() ? m_group.location() : m_product.location()); + ast->accept(&itemFinder); + if (!itemFinder.item()) { + throw ErrorInfo(Tr::tr("The project file parser failed to find the item."), + CodeLocation(projectFile())); + } + + // Now get the binding itself. + FilesBindingFinder bindingFinder(itemFinder.item()); + itemFinder.item()->accept(&bindingFinder); + if (!bindingFinder.binding()) { + throw ErrorInfo(Tr::tr("Could not find the 'files' binding in the project file."), + m_product.location()); + } + + if (bindingFinder.binding()->statement->kind != QbsQmlJS::AST::Node::Kind_ExpressionStatement) + throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex.")); + const CodeLocation bindingLocation + = toCodeLocation(projectFile(), bindingFinder.binding()->firstSourceLocation()); + + ChangeSet changeSet; + Rewriter rewriter(fileContent, &changeSet, QStringList()); + + const int itemIndentation + = int(itemFinder.item()->qualifiedTypeNameId->firstSourceLocation().startColumn - 1); + const int bindingIndentation = itemIndentation + 4; + const int arrayElemIndentation = bindingIndentation + 4; + + const auto exprStatement + = static_cast(bindingFinder.binding()->statement); + switch (exprStatement->expression->kind) { + case QbsQmlJS::AST::Node::Kind_ArrayLiteral: { + QStringList filesToRemove = m_files; + QStringList newFilesList; + auto elem = static_cast(exprStatement->expression)->elements; + while (elem) { + if (elem->expression->kind != QbsQmlJS::AST::Node::Kind_StringLiteral) { + throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex."), + bindingLocation); + } + const auto existingFile + = static_cast(elem->expression)->value.toString(); + if (!filesToRemove.removeOne(existingFile)) + newFilesList << existingFile; + elem = elem->next; + } + if (!filesToRemove.empty()) { + throw ErrorInfo(Tr::tr("The following files were not found in the 'files' list: %1") + .arg(filesToRemove.join(QLatin1String(", "))), bindingLocation); + } + QString filesString; + filesString += QLatin1String("[\n"); + for (const QString &file : qAsConst(newFilesList)) { + filesString += QString(arrayElemIndentation, QLatin1Char(' ')); + filesString += QStringLiteral("\"%1\",\n").arg(file); + } + filesString += QString(bindingIndentation, QLatin1Char(' ')); + filesString += QLatin1Char(']'); + rewriter.changeBinding(itemFinder.item()->initializer, StringConstants::filesProperty(), + filesString, Rewriter::ScriptBinding); + break; + } + case QbsQmlJS::AST::Node::Kind_StringLiteral: { + if (m_files.size() != 1) { + throw ErrorInfo(Tr::tr("Was requested to remove %1 files, but there is only " + "one in the list.").arg(m_files.size()), bindingLocation); + } + const auto existingFile + = static_cast(exprStatement->expression)->value.toString(); + if (existingFile != m_files.front()) { + throw ErrorInfo(Tr::tr("File '%1' could not be found in the 'files' list.") + .arg(m_files.front()), bindingLocation); + } + rewriter.changeBinding(itemFinder.item()->initializer, StringConstants::filesProperty(), + StringConstants::emptyArrayValue(), Rewriter::ScriptBinding); + break; + } + default: + throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex."), + bindingLocation); + } + + setLineOffset(getLineOffsetForChangedBinding(changeSet, + getNodeRepresentation(fileContent, exprStatement->expression))); + const int bindingLine = getBindingLine(changeSet, fileContent); + const int bindingColumn = (bindingFinder.binding() + ? arrayElemIndentation : bindingIndentation) + 1; + setItemPosition(CodeLocation(projectFile(), bindingLine, bindingColumn)); + changeSet.apply(&fileContent); +} + + +ProjectFileGroupRemover::ProjectFileGroupRemover(ProductData product, GroupData group) + : ProjectFileUpdater(product.location().filePath()) + , m_product(std::move(product)) + , m_group(std::move(group)) +{ +} + +void ProjectFileGroupRemover::doApply(QString &fileContent, UiProgram *ast) +{ + ItemFinder productFinder(m_product.location()); + ast->accept(&productFinder); + if (!productFinder.item()) { + throw ErrorInfo(Tr::tr("The project file parser failed to find the product item."), + CodeLocation(projectFile())); + } + + ItemFinder groupFinder(m_group.location()); + productFinder.item()->accept(&groupFinder); + if (!groupFinder.item()) { + throw ErrorInfo(Tr::tr("The project file parser failed to find the group item."), + m_product.location()); + } + + ChangeSet changeSet; + Rewriter rewriter(fileContent, &changeSet, QStringList()); + rewriter.removeObjectMember(groupFinder.item(), productFinder.item()); + + setItemPosition(m_group.location()); + const QList &editOps = changeSet.operationList(); + QBS_CHECK(editOps.size() == 1); + const ChangeSet::EditOp &op = editOps.front(); + const QString removedText = fileContent.mid(op.pos1, op.length1); + setLineOffset(-removedText.count(QLatin1Char('\n'))); + + changeSet.apply(&fileContent); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/api/projectfileupdater.h b/src/lib/corelib/api/projectfileupdater.h new file mode 100644 index 00000000..ded4e08a --- /dev/null +++ b/src/lib/corelib/api/projectfileupdater.h @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECTFILEUPDATER_H +#define QBS_PROJECTFILEUPDATER_H + +#include "projectdata.h" + +#include +#include + +#include + +namespace QbsQmlJS { namespace AST { class UiProgram; } } + +namespace qbs { +namespace Internal { + +class ProjectFileUpdater +{ +public: + virtual ~ProjectFileUpdater(); + void apply(); + + CodeLocation itemPosition() const { return m_itemPosition; } + int lineOffset() const { return m_lineOffset; } + +protected: + ProjectFileUpdater(QString projectFile); + + QString projectFile() const { return m_projectFile; } + + void setLineOffset(int offset) { m_lineOffset = offset; } + void setItemPosition(const CodeLocation &cl) { m_itemPosition = cl; } + +private: + virtual void doApply(QString &fileContent, QbsQmlJS::AST::UiProgram *ast) = 0; + + enum LineEndingType + { + UnknownLineEndings, + UnixLineEndings, + WindowsLineEndings, + MixedLineEndings + }; + + static LineEndingType guessLineEndingType(const QByteArray &text); + static void convertToUnixLineEndings(QByteArray *text, LineEndingType oldLineEndings); + static void convertFromUnixLineEndings(QByteArray *text, LineEndingType newLineEndings); + + const QString m_projectFile; + CodeLocation m_itemPosition; + int m_lineOffset = 0; +}; + + +class ProjectFileGroupInserter : public ProjectFileUpdater +{ +public: + ProjectFileGroupInserter(ProductData product, QString groupName); + +private: + void doApply(QString &fileContent, QbsQmlJS::AST::UiProgram *ast) override; + + const ProductData m_product; + const QString m_groupName; +}; + + +class ProjectFileFilesAdder : public ProjectFileUpdater +{ +public: + ProjectFileFilesAdder(ProductData product, GroupData group, QStringList files); + +private: + void doApply(QString &fileContent, QbsQmlJS::AST::UiProgram *ast) override; + + const ProductData m_product; + const GroupData m_group; + const QStringList m_files; +}; + +class ProjectFileFilesRemover : public ProjectFileUpdater +{ +public: + ProjectFileFilesRemover(ProductData product, GroupData group, + QStringList files); + +private: + void doApply(QString &fileContent, QbsQmlJS::AST::UiProgram *ast) override; + + const ProductData m_product; + const GroupData m_group; + const QStringList m_files; +}; + +class ProjectFileGroupRemover : public ProjectFileUpdater +{ +public: + ProjectFileGroupRemover(ProductData product, GroupData group); + +private: + void doApply(QString &fileContent, QbsQmlJS::AST::UiProgram *ast) override; + + const ProductData m_product; + const GroupData m_group; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/api/propertymap_p.h b/src/lib/corelib/api/propertymap_p.h new file mode 100644 index 00000000..5f592484 --- /dev/null +++ b/src/lib/corelib/api/propertymap_p.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROPERTYMAP_P_H +#define QBS_PROPERTYMAP_P_H + +#include + +namespace qbs { +namespace Internal { + +class PropertyMapPrivate +{ +public: + PropertyMapPtr m_map; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROPERTYMAP_P_H diff --git a/src/lib/corelib/api/qmljsrewriter.cpp b/src/lib/corelib/api/qmljsrewriter.cpp new file mode 100644 index 00000000..46cd10b9 --- /dev/null +++ b/src/lib/corelib/api/qmljsrewriter.cpp @@ -0,0 +1,713 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmljsrewriter.h" + +#include + +namespace QbsQmlJS { +using namespace AST; + +static QString toString(UiQualifiedId *qualifiedId, QChar delimiter = QLatin1Char('.')) +{ + QString result; + + for (UiQualifiedId *iter = qualifiedId; iter; iter = iter->next) { + if (iter != qualifiedId) + result += delimiter; + + result += iter->name; + } + + return result; +} + + +Rewriter::Rewriter(QString originalText, + ChangeSet *changeSet, + QStringList propertyOrder) + : m_originalText(std::move(originalText)) + , m_changeSet(changeSet) + , m_propertyOrder(std::move(propertyOrder)) +{ + Q_ASSERT(changeSet); +} + +Rewriter::Range Rewriter::addBinding(AST::UiObjectInitializer *ast, + const QString &propertyName, + const QString &propertyValue, + BindingType bindingType) +{ + UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, + propertyName, + m_propertyOrder); + return addBinding(ast, propertyName, propertyValue, bindingType, insertAfter); +} + +Rewriter::Range Rewriter::addBinding(AST::UiObjectInitializer *ast, + const QString &propertyName, + const QString &propertyValue, + BindingType bindingType, + UiObjectMemberList *insertAfter) +{ + SourceLocation endOfPreviousMember; + SourceLocation startOfNextMember; + + if (insertAfter == nullptr || insertAfter->member == nullptr) { + // insert as first member + endOfPreviousMember = ast->lbraceToken; + + if (ast->members && ast->members->member) + startOfNextMember = ast->members->member->firstSourceLocation(); + else + startOfNextMember = ast->rbraceToken; + } else { + endOfPreviousMember = insertAfter->member->lastSourceLocation(); + + if (insertAfter->next && insertAfter->next->member) + startOfNextMember = insertAfter->next->member->firstSourceLocation(); + else + startOfNextMember = ast->rbraceToken; + } + const bool isOneLiner = endOfPreviousMember.startLine == startOfNextMember.startLine; + bool needsPreceedingSemicolon = false; + bool needsTrailingSemicolon = false; + + if (isOneLiner) { + if (insertAfter == nullptr) { // we're inserting after an lbrace + if (ast->members) { // we're inserting before a member (and not the rbrace) + needsTrailingSemicolon = bindingType == ScriptBinding; + } + } else { // we're inserting after a member, not after the lbrace + if (endOfPreviousMember.isValid()) { // there already is a semicolon after the previous member + if (insertAfter->next && insertAfter->next->member) { // and the after us there is a member, not an rbrace, so: + needsTrailingSemicolon = bindingType == ScriptBinding; + } + } else { // there is no semicolon after the previous member (probably because there is an rbrace after us/it, so: + needsPreceedingSemicolon = true; + } + } + } + + QString newPropertyTemplate; + switch (bindingType) { + case ArrayBinding: + newPropertyTemplate = QStringLiteral("%1: [\n%2\n]"); + break; + + case ObjectBinding: + newPropertyTemplate = QStringLiteral("%1: %2"); + break; + + case ScriptBinding: + newPropertyTemplate = QStringLiteral("%1: %2"); + break; + + default: + Q_ASSERT(!"unknown property type"); + } + + if (isOneLiner) { + if (needsPreceedingSemicolon) + newPropertyTemplate.prepend(QLatin1Char(';')); + newPropertyTemplate.prepend(QLatin1Char(' ')); + if (needsTrailingSemicolon) + newPropertyTemplate.append(QLatin1Char(';')); + } else { + newPropertyTemplate.prepend(QLatin1Char('\n')); + } + + m_changeSet->insert(endOfPreviousMember.end(), + newPropertyTemplate.arg(propertyName, propertyValue)); + + return {int(endOfPreviousMember.end()), int(endOfPreviousMember.end())}; +} + +UiObjectMemberList *Rewriter::searchMemberToInsertAfter(UiObjectMemberList *members, + const QStringList &propertyOrder) +{ + const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString()); + + UiObjectMemberList *lastObjectDef = nullptr; + UiObjectMemberList *lastNonObjectDef = nullptr; + + for (UiObjectMemberList *iter = members; iter; iter = iter->next) { + UiObjectMember *member = iter->member; + int idx = -1; + + if (cast(member)) + lastObjectDef = iter; + else if (auto arrayBinding = cast(member)) + idx = propertyOrder.indexOf(toString(arrayBinding->qualifiedId)); + else if (auto objectBinding = cast(member)) + idx = propertyOrder.indexOf(toString(objectBinding->qualifiedId)); + else if (auto scriptBinding = cast(member)) + idx = propertyOrder.indexOf(toString(scriptBinding->qualifiedId)); + else if (cast(member)) + idx = propertyOrder.indexOf(QLatin1String("property")); + + if (idx < objectDefinitionInsertionPoint) + lastNonObjectDef = iter; + } + + if (lastObjectDef) + return lastObjectDef; + return lastNonObjectDef; +} + +UiArrayMemberList *Rewriter::searchMemberToInsertAfter(UiArrayMemberList *members, + const QStringList &propertyOrder) +{ + const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString()); + + UiArrayMemberList *lastObjectDef = nullptr; + UiArrayMemberList *lastNonObjectDef = nullptr; + + for (UiArrayMemberList *iter = members; iter; iter = iter->next) { + UiObjectMember *member = iter->member; + int idx = -1; + + if (cast(member)) + lastObjectDef = iter; + else if (auto arrayBinding = cast(member)) + idx = propertyOrder.indexOf(toString(arrayBinding->qualifiedId)); + else if (auto objectBinding = cast(member)) + idx = propertyOrder.indexOf(toString(objectBinding->qualifiedId)); + else if (auto scriptBinding = cast(member)) + idx = propertyOrder.indexOf(toString(scriptBinding->qualifiedId)); + else if (cast(member)) + idx = propertyOrder.indexOf(QLatin1String("property")); + + if (idx < objectDefinitionInsertionPoint) + lastNonObjectDef = iter; + } + + if (lastObjectDef) + return lastObjectDef; + return lastNonObjectDef; +} + +UiObjectMemberList *Rewriter::searchMemberToInsertAfter(UiObjectMemberList *members, + const QString &propertyName, + const QStringList &propertyOrder) +{ + if (!members) + return nullptr; // empty members + + QHash orderedMembers; + + for (UiObjectMemberList *iter = members; iter; iter = iter->next) { + UiObjectMember *member = iter->member; + + if (auto arrayBinding = cast(member)) + orderedMembers[toString(arrayBinding->qualifiedId)] = iter; + else if (auto objectBinding = cast(member)) + orderedMembers[toString(objectBinding->qualifiedId)] = iter; + else if (cast(member)) + orderedMembers[QString()] = iter; + else if (auto scriptBinding = cast(member)) + orderedMembers[toString(scriptBinding->qualifiedId)] = iter; + else if (cast(member)) + orderedMembers[QStringLiteral("property")] = iter; + } + + int idx = propertyOrder.indexOf(propertyName); + if (idx == -1) + idx = propertyOrder.indexOf(QString()); + if (idx == -1) + idx = propertyOrder.size() - 1; + + for (; idx > 0; --idx) { + const QString &prop = propertyOrder.at(idx - 1); + UiObjectMemberList *candidate = orderedMembers.value(prop, 0); + if (candidate != nullptr) + return candidate; + } + + return nullptr; +} + +void Rewriter::changeBinding(UiObjectInitializer *ast, + const QString &propertyName, + const QString &newValue, + BindingType binding) +{ + QString prefix, suffix; + int dotIdx = propertyName.indexOf(QLatin1Char('.')); + if (dotIdx != -1) { + prefix = propertyName.left(dotIdx); + suffix = propertyName.mid(dotIdx + 1); + } + + for (UiObjectMemberList *members = ast->members; members; members = members->next) { + UiObjectMember *member = members->member; + + // for non-grouped properties: + if (isMatchingPropertyMember(propertyName, member)) { + switch (binding) { + case ArrayBinding: + insertIntoArray(cast(member), newValue); + break; + + case ObjectBinding: + replaceMemberValue(member, newValue, false); + break; + + case ScriptBinding: + replaceMemberValue(member, newValue, nextMemberOnSameLine(members)); + break; + + default: + Q_ASSERT(!"Unhandled QmlRefactoring::PropertyType"); + } + + break; + // for grouped properties: + } + if (!prefix.isEmpty()) { + if (auto def = cast(member)) { + if (toString(def->qualifiedTypeNameId) == prefix) + changeBinding(def->initializer, suffix, newValue, binding); + } + } + } +} + +void Rewriter::replaceMemberValue(UiObjectMember *propertyMember, + const QString &newValue, + bool needsSemicolon) +{ + QString replacement = newValue; + int startOffset = -1; + int endOffset = -1; + if (auto objectBinding = AST::cast(propertyMember)) { + startOffset = objectBinding->qualifiedTypeNameId->identifierToken.offset; + endOffset = objectBinding->initializer->rbraceToken.end(); + } else if (auto scriptBinding = AST::cast(propertyMember)) { + startOffset = scriptBinding->statement->firstSourceLocation().offset; + endOffset = scriptBinding->statement->lastSourceLocation().end(); + } else if (auto arrayBinding = AST::cast(propertyMember)) { + startOffset = arrayBinding->lbracketToken.offset; + endOffset = arrayBinding->rbracketToken.end(); + } else if (auto publicMember = AST::cast(propertyMember)) { + if (publicMember->statement) { + startOffset = publicMember->statement->firstSourceLocation().offset; + if (publicMember->semicolonToken.isValid()) + endOffset = publicMember->semicolonToken.end(); + else + endOffset = publicMember->statement->lastSourceLocation().offset; + } else { + startOffset = publicMember->lastSourceLocation().end(); + endOffset = startOffset; + if (publicMember->semicolonToken.isValid()) + startOffset = publicMember->semicolonToken.offset; + replacement.prepend(QStringLiteral(": ")); + } + } else { + return; + } + + if (needsSemicolon) + replacement += QLatin1Char(';'); + + m_changeSet->replace(startOffset, endOffset, replacement); +} + +bool Rewriter::isMatchingPropertyMember(const QString &propertyName, + UiObjectMember *member) +{ + if (auto publicMember = cast(member)) + return publicMember->name == propertyName; + if (auto objectBinding = cast(member)) + return toString(objectBinding->qualifiedId) == propertyName; + if (auto scriptBinding = cast(member)) + return toString(scriptBinding->qualifiedId) == propertyName; + if (auto arrayBinding = cast(member)) + return toString(arrayBinding->qualifiedId) == propertyName; + return false; +} + +bool Rewriter::nextMemberOnSameLine(UiObjectMemberList *members) +{ + if (members && members->next && members->next->member) + return members->next->member->firstSourceLocation().startLine == members->member->lastSourceLocation().startLine; + return false; +} + +void Rewriter::insertIntoArray(UiArrayBinding *ast, const QString &newValue) +{ + if (!ast) + return; + + UiObjectMember *lastMember = nullptr; + for (UiArrayMemberList *iter = ast->members; iter; iter = iter->next) { + lastMember = iter->member; + } + + if (!lastMember) + return; + + const int insertionPoint = lastMember->lastSourceLocation().end(); + m_changeSet->insert(insertionPoint, QLatin1String(",\n") + newValue); +} + +void Rewriter::removeBindingByName(UiObjectInitializer *ast, const QString &propertyName) +{ + QString prefix; + int dotIdx = propertyName.indexOf(QLatin1Char('.')); + if (dotIdx != -1) + prefix = propertyName.left(dotIdx); + + for (UiObjectMemberList *it = ast->members; it; it = it->next) { + UiObjectMember *member = it->member; + + // run full name match (for ungrouped properties): + if (isMatchingPropertyMember(propertyName, member)) { + removeMember(member); + // check for grouped properties: + } else if (!prefix.isEmpty()) { + if (auto def = cast(member)) { + if (toString(def->qualifiedTypeNameId) == prefix) + removeGroupedProperty(def, propertyName); + } + } + } +} + +void Rewriter::removeGroupedProperty(UiObjectDefinition *ast, + const QString &propertyName) +{ + int dotIdx = propertyName.indexOf(QLatin1Char('.')); + if (dotIdx == -1) + return; + + const QString propName = propertyName.mid(dotIdx + 1); + + UiObjectMember *wanted = nullptr; + unsigned memberCount = 0; + for (UiObjectMemberList *it = ast->initializer->members; it; it = it->next) { + ++memberCount; + UiObjectMember *member = it->member; + + if (!wanted && isMatchingPropertyMember(propName, member)) + wanted = member; + } + + if (!wanted) + return; + if (memberCount == 1) + removeMember(ast); + else + removeMember(wanted); +} + +void Rewriter::removeMember(UiObjectMember *member) +{ + int start = member->firstSourceLocation().offset; + int end = member->lastSourceLocation().end(); + + includeSurroundingWhitespace(m_originalText, start, end); + + m_changeSet->remove(start, end); +} + +bool Rewriter::includeSurroundingWhitespace(const QString &source, int &start, int &end) +{ + bool includeStartingWhitespace = true; + bool paragraphFound = false; + bool paragraphSkipped = false; + + if (end >= 0) { + QChar c = source.at(end); + + while (c.isSpace()) { + ++end; + if (c.unicode() == 10) { + paragraphFound = true; + paragraphSkipped = true; + break; + } + if (end == source.length()) { + break; + } + + c = source.at(end); + } + + includeStartingWhitespace = paragraphFound; + } + + paragraphFound = false; + if (includeStartingWhitespace) { + while (start > 0) { + const QChar c = source.at(start - 1); + + if (c.unicode() == 10) { + paragraphFound = true; + break; + } + if (!c.isSpace()) + break; + + --start; + } + } + if (!paragraphFound && paragraphSkipped) //keep the line ending + --end; + + return paragraphFound; +} + +void Rewriter::includeLeadingEmptyLine(QStringView source, int &start) +{ + if (start == 0) + return; + + const qsizetype lineEnd = source.lastIndexOf(QChar::LineFeed, start); + if (lineEnd <= 0) + return; + const qsizetype lineStart = source.lastIndexOf(QChar::LineFeed, lineEnd - 1) + 1; + const auto line = source.mid(lineStart, lineEnd - lineStart); + if (!line.trimmed().isEmpty()) + return; + start = lineStart; +} + +void Rewriter::includeEmptyGroupedProperty(UiObjectDefinition *groupedProperty, UiObjectMember *memberToBeRemoved, int &start, int &end) +{ + if (groupedProperty->qualifiedTypeNameId && !groupedProperty->qualifiedTypeNameId->name.isEmpty() + && groupedProperty->qualifiedTypeNameId->name.at(0).isLower()) { + // grouped property + UiObjectMemberList *memberIter = groupedProperty->initializer->members; + while (memberIter) { + if (memberIter->member != memberToBeRemoved) + return; + memberIter = memberIter->next; + } + start = groupedProperty->firstSourceLocation().begin(); + end = groupedProperty->lastSourceLocation().end(); + } +} + +#if 0 +UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QStringList &propertyOrder) +{ + const int objectDefinitionInsertionPoint = propertyOrder.indexOf(QString()); + + UiObjectMemberList *lastObjectDef = nullptr; + UiObjectMemberList *lastNonObjectDef = nullptr; + + for (UiObjectMemberList *iter = members; iter; iter = iter->next) { + UiObjectMember *member = iter->member; + int idx = -1; + + if (cast(member)) + lastObjectDef = iter; + else if (UiArrayBinding *arrayBinding = cast(member)) + idx = propertyOrder.indexOf(toString(arrayBinding->qualifiedId)); + else if (UiObjectBinding *objectBinding = cast(member)) + idx = propertyOrder.indexOf(toString(objectBinding->qualifiedId)); + else if (UiScriptBinding *scriptBinding = cast(member)) + idx = propertyOrder.indexOf(toString(scriptBinding->qualifiedId)); + else if (cast(member)) + idx = propertyOrder.indexOf(QLatin1String("property")); + + if (idx < objectDefinitionInsertionPoint) + lastNonObjectDef = iter; + } + + if (lastObjectDef) + return lastObjectDef; + else + return lastNonObjectDef; +} + +UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(UiObjectMemberList *members, const QString &propertyName, const QStringList &propertyOrder) +{ + if (!members) + return nullptr; // empty members + + QHash orderedMembers; + + for (UiObjectMemberList *iter = members; iter; iter = iter->next) { + UiObjectMember *member = iter->member; + + if (UiArrayBinding *arrayBinding = cast(member)) + orderedMembers[toString(arrayBinding->qualifiedId)] = iter; + else if (UiObjectBinding *objectBinding = cast(member)) + orderedMembers[toString(objectBinding->qualifiedId)] = iter; + else if (cast(member)) + orderedMembers[QString()] = iter; + else if (UiScriptBinding *scriptBinding = cast(member)) + orderedMembers[toString(scriptBinding->qualifiedId)] = iter; + else if (cast(member)) + orderedMembers[QStringLiteral("property")] = iter; + } + + int idx = propertyOrder.indexOf(propertyName); + if (idx == -1) + idx = propertyOrder.indexOf(QString()); + if (idx == -1) + idx = propertyOrder.size() - 1; + + for (; idx > 0; --idx) { + const QString prop = propertyOrder.at(idx - 1); + UiObjectMemberList *candidate = orderedMembers.value(prop, 0); + if (candidate != 0) + return candidate; + } + + return nullptr; +} + +#endif + +void Rewriter::appendToArrayBinding(UiArrayBinding *arrayBinding, + const QString &content) +{ + UiObjectMember *lastMember = nullptr; + for (UiArrayMemberList *iter = arrayBinding->members; iter; iter = iter->next) + if (iter->member) + lastMember = iter->member; + + if (!lastMember) + return; // an array binding cannot be empty, so there will (or should) always be a last member. + + const int insertionPoint = lastMember->lastSourceLocation().end(); + + m_changeSet->insert(insertionPoint, QLatin1String(",\n") + content); +} + +Rewriter::Range Rewriter::addObject(UiObjectInitializer *ast, const QString &content) +{ + UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder); + return addObject(ast, content, insertAfter); +} + +Rewriter::Range Rewriter::addObject(UiObjectInitializer *ast, const QString &content, UiObjectMemberList *insertAfter) +{ + int insertionPoint; + QString textToInsert; + if (insertAfter && insertAfter->member) { + insertionPoint = insertAfter->member->lastSourceLocation().end(); + textToInsert += QLatin1String("\n"); + } else { + insertionPoint = ast->lbraceToken.end(); + } + + textToInsert += content; + m_changeSet->insert(insertionPoint, QLatin1String("\n") + textToInsert); + + return {insertionPoint, insertionPoint}; +} + +Rewriter::Range Rewriter::addObject(UiArrayBinding *ast, const QString &content) +{ + UiArrayMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder); + return addObject(ast, content, insertAfter); +} + +Rewriter::Range Rewriter::addObject(UiArrayBinding *ast, const QString &content, UiArrayMemberList *insertAfter) +{ + int insertionPoint; + QString textToInsert; + if (insertAfter && insertAfter->member) { + insertionPoint = insertAfter->member->lastSourceLocation().end(); + textToInsert = QLatin1String(",\n") + content; + } else { + insertionPoint = ast->lbracketToken.end(); + textToInsert += QLatin1String("\n") + content + QLatin1Char(','); + } + + m_changeSet->insert(insertionPoint, textToInsert); + + return {insertionPoint, insertionPoint}; +} + +void Rewriter::removeObjectMember(UiObjectMember *member, UiObjectMember *parent) +{ + int start = member->firstSourceLocation().offset; + int end = member->lastSourceLocation().end(); + + if (auto parentArray = cast(parent)) { + extendToLeadingOrTrailingComma(parentArray, member, start, end); + } else { + if (auto parentObjectDefinition = cast(parent)) + includeEmptyGroupedProperty(parentObjectDefinition, member, start, end); + includeSurroundingWhitespace(m_originalText, start, end); + } + + includeLeadingEmptyLine(m_originalText, start); + m_changeSet->remove(start, end); +} + +void Rewriter::extendToLeadingOrTrailingComma(UiArrayBinding *parentArray, + UiObjectMember *member, + int &start, + int &end) const +{ + UiArrayMemberList *currentMember = nullptr; + for (UiArrayMemberList *it = parentArray->members; it; it = it->next) { + if (it->member == member) { + currentMember = it; + break; + } + } + + if (!currentMember) + return; + + if (currentMember->commaToken.isValid()) { + // leading comma + start = currentMember->commaToken.offset; + if (includeSurroundingWhitespace(m_originalText, start, end)) + --end; + } else if (currentMember->next && currentMember->next->commaToken.isValid()) { + // trailing comma + end = currentMember->next->commaToken.end(); + includeSurroundingWhitespace(m_originalText, start, end); + } else { + // array with 1 element, so remove the complete binding + start = parentArray->firstSourceLocation().offset; + end = parentArray->lastSourceLocation().end(); + includeSurroundingWhitespace(m_originalText, start, end); + } +} + +} // namespace QbsQmlJS diff --git a/src/lib/corelib/api/qmljsrewriter.h b/src/lib/corelib/api/qmljsrewriter.h new file mode 100644 index 00000000..7cba699e --- /dev/null +++ b/src/lib/corelib/api/qmljsrewriter.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSREWRITER_H +#define QMLJSREWRITER_H + +#include "changeset.h" + +#include + +#include + +namespace QbsQmlJS { + +class Rewriter +{ +public: + enum BindingType { + ScriptBinding, + ObjectBinding, + ArrayBinding + }; + + using Range = ChangeSet::Range; + +public: + Rewriter(QString originalText, + ChangeSet *changeSet, + QStringList propertyOrder); + + Range addBinding(AST::UiObjectInitializer *ast, + const QString &propertyName, + const QString &propertyValue, + BindingType bindingType); + + Range addBinding(AST::UiObjectInitializer *ast, + const QString &propertyName, + const QString &propertyValue, + BindingType bindingType, + AST::UiObjectMemberList *insertAfter); + + void changeBinding(AST::UiObjectInitializer *ast, + const QString &propertyName, + const QString &newValue, + BindingType binding); + + void removeBindingByName(AST::UiObjectInitializer *ast, const QString &propertyName); + + void appendToArrayBinding(AST::UiArrayBinding *arrayBinding, + const QString &content); + + Range addObject(AST::UiObjectInitializer *ast, const QString &content); + Range addObject(AST::UiObjectInitializer *ast, const QString &content, AST::UiObjectMemberList *insertAfter); + Range addObject(AST::UiArrayBinding *ast, const QString &content); + Range addObject(AST::UiArrayBinding *ast, const QString &content, AST::UiArrayMemberList *insertAfter); + + void removeObjectMember(AST::UiObjectMember *member, AST::UiObjectMember *parent); + + static AST::UiObjectMemberList *searchMemberToInsertAfter(AST::UiObjectMemberList *members, const QStringList &propertyOrder); + static AST::UiArrayMemberList *searchMemberToInsertAfter(AST::UiArrayMemberList *members, const QStringList &propertyOrder); + static AST::UiObjectMemberList *searchMemberToInsertAfter(AST::UiObjectMemberList *members, const QString &propertyName, const QStringList &propertyOrder); + + static bool includeSurroundingWhitespace(const QString &source, int &start, int &end); + static void includeLeadingEmptyLine(QStringView source, int &start); + static void includeEmptyGroupedProperty(AST::UiObjectDefinition *groupedProperty, AST::UiObjectMember *memberToBeRemoved, int &start, int &end); + +private: + void replaceMemberValue(AST::UiObjectMember *propertyMember, + const QString &newValue, + bool needsSemicolon); + static bool isMatchingPropertyMember(const QString &propertyName, + AST::UiObjectMember *member); + static bool nextMemberOnSameLine(AST::UiObjectMemberList *members); + + void insertIntoArray(AST::UiArrayBinding* ast, const QString &newValue); + + void removeMember(AST::UiObjectMember *member); + void removeGroupedProperty(AST::UiObjectDefinition *ast, + const QString &propertyName); + + void extendToLeadingOrTrailingComma(AST::UiArrayBinding *parentArray, + AST::UiObjectMember *member, + int &start, + int &end) const; + +private: + QString m_originalText; + ChangeSet *m_changeSet; + const QStringList m_propertyOrder; +}; + +} // namespace QbsQmlJS + +#endif // QMLJSREWRITER_H diff --git a/src/lib/corelib/api/rulecommand.cpp b/src/lib/corelib/api/rulecommand.cpp new file mode 100644 index 00000000..e01cde7c --- /dev/null +++ b/src/lib/corelib/api/rulecommand.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rulecommand.h" +#include "rulecommand_p.h" + +#include + +namespace qbs { + +/*! + * \class RuleCommand + * \brief The \c RuleCommand class corresponds to a \c ProcessCommand or \c JavaScriptCommand + * in \QBS. + */ + +/*! + * \enum RuleCommand::Type + * This enum type represents the different kinds of commands. + * \value ProcessCommandType For the \QBS type \c ProcessCommand, which represents a command + * whose execution involves calling an executable. + * \value JavaScriptCommandType For the \QBS type \c JavaScriptCommand, which represents a command + * whose execution involves running a piece of JavaScript code inside \QBS. + * \value InvalidType Used to mark \c RuleCommand objects as invalid. + */ + + +RuleCommand::RuleCommand() : d(new Internal::RuleCommandPrivate) +{ +} + +RuleCommand::RuleCommand(const RuleCommand &other) = default; + +RuleCommand::~RuleCommand() = default; + +RuleCommand& RuleCommand::operator=(const RuleCommand &other) = default; + +/*! + * Returns the type of this object. If the value is \c InvalidType, the object is invalid. + */ +RuleCommand::Type RuleCommand::type() const +{ + return d->type; +} + +/*! + * Returns the human-readable description of this command that \QBS will print when + * the command executed. + */ +QString RuleCommand::description() const +{ + return d->description; +} + +/*! + * Returns the detailed description of this command that \QBS will print when + * the command is executed. + */ +QString RuleCommand::extendedDescription() const +{ + return d->extendedDescription; +} + +/*! + * Returns the source of the command if \c type() is \c JavaScriptCommandType. + * If \c type() is anything else, the behavior of this function is undefined. + */ +QString RuleCommand::sourceCode() const +{ + QBS_ASSERT(type() == JavaScriptCommandType, return {}); + return d->sourceCode; +} + +/*! + * Returns the executable that will be called when the corresponding \c ProcessCommand + * is executed. + * If \c type() is not \c ProcessCommandType, the behavior of this function is undefined. + */ +QString RuleCommand::executable() const +{ + QBS_ASSERT(type() == ProcessCommandType, return {}); + return d->executable; +} + +/*! + * Returns the command-line arguments of the executable that will be called when the + * corresponding \c ProcessCommand is executed. + * If \c type() is not \c ProcessCommandType, the behavior of this function is undefined. + */ +QStringList RuleCommand::arguments() const +{ + QBS_ASSERT(type() == ProcessCommandType, return {}); + return d->arguments; +} + +/*! + * Returns the working directory of the executable that will be called when the + * corresponding \c ProcessCommand is executed. + * If \c type() is not \c ProcessCommandType, the behavior of this function is undefined. + */ +QString RuleCommand::workingDirectory() const +{ + QBS_ASSERT(type() == ProcessCommandType, return {}); + return d->workingDir; +} + +/*! + * Returns the environment of the executable that will be called when the + * corresponding \c ProcessCommand is executed. + * If \c type() is not \c ProcessCommandType, the behavior of this function is undefined. + */ +QProcessEnvironment RuleCommand::environment() const +{ + QBS_ASSERT(type() == ProcessCommandType, return {}); + return d->environment; +} + +} // namespace qbs diff --git a/src/lib/corelib/api/rulecommand.h b/src/lib/corelib/api/rulecommand.h new file mode 100644 index 00000000..cebcfa94 --- /dev/null +++ b/src/lib/corelib/api/rulecommand.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RULECOMMAND_H +#define QBS_RULECOMMAND_H + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QProcessEnvironment; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class ProjectPrivate; +class RuleCommandPrivate; +} + +class QBS_EXPORT RuleCommand +{ + friend class Internal::ProjectPrivate; +public: + RuleCommand(); + RuleCommand(const RuleCommand &other); + ~RuleCommand(); + RuleCommand &operator=(const RuleCommand &other); + + enum Type { ProcessCommandType, JavaScriptCommandType, InvalidType }; + + + Type type() const; + QString description() const; + QString extendedDescription() const; + QString sourceCode() const; + QString executable() const; + QStringList arguments() const; + QString workingDirectory() const; + QProcessEnvironment environment() const; + +private: + QExplicitlySharedDataPointer d; +}; + + +using RuleCommandList = QList; + +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/api/rulecommand_p.h b/src/lib/corelib/api/rulecommand_p.h new file mode 100644 index 00000000..253ec405 --- /dev/null +++ b/src/lib/corelib/api/rulecommand_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RULECOMMAND_P_H +#define QBS_RULECOMMAND_P_H + +#include "rulecommand.h" + +#include +#include + +namespace qbs { +namespace Internal { + +class RuleCommandPrivate : public QSharedData +{ +public: + RuleCommandPrivate(): type(RuleCommand::InvalidType) {} + + RuleCommand::Type type; + QString description; + QString extendedDescription; + QString sourceCode; + QString executable; + QStringList arguments; + QString workingDir; + QProcessEnvironment environment; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp new file mode 100644 index 00000000..2544f549 --- /dev/null +++ b/src/lib/corelib/api/runenvironment.cpp @@ -0,0 +1,481 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "runenvironment.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +using namespace Internal; + +class RunEnvironment::RunEnvironmentPrivate +{ +public: + RunEnvironmentPrivate(ResolvedProductPtr product, TopLevelProjectConstPtr project, + InstallOptions installOptions, const QProcessEnvironment &environment, + QStringList setupRunEnvConfig, Settings *settings, Logger logger) + : resolvedProduct(std::move(product)) + , project(std::move(project)) + , installOptions(std::move(installOptions)) + , environment(environment) + , setupRunEnvConfig(std::move(setupRunEnvConfig)) + , settings(settings) + , logger(std::move(logger)) + , evalContext(this->logger) + { + } + + void checkProduct() + { + if (!resolvedProduct) + throw ErrorInfo(Tr::tr("Cannot run: No such product.")); + if (!resolvedProduct->enabled) { + throw ErrorInfo(Tr::tr("Cannot run disabled product '%1'.") + .arg(resolvedProduct->fullDisplayName())); + } + } + + const ResolvedProductPtr resolvedProduct; + const TopLevelProjectConstPtr project; + InstallOptions installOptions; + const QProcessEnvironment environment; + const QStringList setupRunEnvConfig; + Settings * const settings; + Logger logger; + RulesEvaluationContext evalContext; +}; + +RunEnvironment::RunEnvironment(const ResolvedProductPtr &product, + const TopLevelProjectConstPtr &project, const InstallOptions &installOptions, + const QProcessEnvironment &environment, const QStringList &setupRunEnvConfig, + Settings *settings, const Logger &logger) + : d(std::make_unique(product, project, installOptions, environment, + setupRunEnvConfig, settings, logger)) +{ +} + +RunEnvironment::~RunEnvironment() = default; + +int RunEnvironment::runShell(ErrorInfo *error) +{ + try { + return doRunShell(); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return -1; + } +} + +int RunEnvironment::runTarget(const QString &targetBin, const QStringList &arguments, bool dryRun, + ErrorInfo *error) +{ + try { + return doRunTarget(targetBin, arguments, dryRun); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return -1; + } +} + +const QProcessEnvironment RunEnvironment::runEnvironment(ErrorInfo *error) const +{ + try { + return getRunEnvironment(); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +const QProcessEnvironment RunEnvironment::buildEnvironment(ErrorInfo *error) const +{ + try { + return getBuildEnvironment(); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +int RunEnvironment::doRunShell() +{ + if (d->resolvedProduct) { + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, + d->project->environment).setupForBuild(); + } + + const QString productId = d->resolvedProduct ? d->resolvedProduct->name : QString(); + const QString configName = d->project->id(); + if (productId.isEmpty()) { + d->logger.qbsInfo() << Tr::tr("Starting shell for configuration '%1'.").arg(configName); + } else { + d->logger.qbsInfo() << Tr::tr("Starting shell for product '%1' in configuration '%2'.") + .arg(productId, configName); + } + const QProcessEnvironment environment = d->resolvedProduct + ? d->resolvedProduct->buildEnvironment : d->project->environment; +#if defined(Q_OS_LINUX) + clearenv(); +#endif + const auto keys = environment.keys(); + for (const QString &key : keys) + qputenv(key.toLocal8Bit().constData(), environment.value(key).toLocal8Bit()); + QString command; + if (HostOsInfo::isWindowsHost()) { + command = environment.value(QStringLiteral("COMSPEC")); + if (command.isEmpty()) + command = QStringLiteral("cmd"); + const QString prompt = environment.value(QStringLiteral("PROMPT")); + command += QLatin1String(" /k prompt [qbs] ") + prompt; + } else { + const QVariantMap qbsProps = + (d->resolvedProduct ? d->resolvedProduct->moduleProperties->value() + : d->project->buildConfiguration()) + .value(StringConstants::qbsModule()).toMap(); + const QString profileName = qbsProps.value(StringConstants::profileProperty()).toString(); + command = Preferences(d->settings, profileName).shell(); + if (command.isEmpty()) + command = environment.value(QStringLiteral("SHELL"), QStringLiteral("/bin/sh")); + + // Yes, we have to use this procedure. PS1 is not inherited from the environment. + const QString prompt = QLatin1String("qbs ") + configName + + (!productId.isEmpty() ? QLatin1Char(' ') + productId : QString()) + + QLatin1String(" $ "); + QTemporaryFile envFile; + if (envFile.open()) { + if (command.endsWith(QLatin1String("bash"))) + command += QLatin1String(" --posix"); // Teach bash some manners. + const QString promptLine = QLatin1String("PS1='") + prompt + QLatin1String("'\n"); + envFile.write(promptLine.toLocal8Bit()); + envFile.close(); + qputenv("ENV", envFile.fileName().toLocal8Bit()); + } else { + d->logger.qbsWarning() << Tr::tr("Setting custom shell prompt failed."); + } + } + + // We cannot use QProcess, since it does not do stdin forwarding. + return system(command.toLocal8Bit().constData()); +} + +static QString findExecutable(const QStringList &fileNames) +{ + const QStringList path = QString::fromLocal8Bit(qgetenv("PATH")) + .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + + for (const QString &fileName : fileNames) { + const QString exeFileName = HostOsInfo::appendExecutableSuffix(fileName); + for (const QString &ppath : path) { + const QString fullPath = ppath + QLatin1Char('/') + exeFileName; + QFileInfo fi(fullPath); + if (fi.exists() && fi.isFile() && fi.isExecutable()) + return QDir::cleanPath(fullPath); + } + } + return {}; +} + +static std::string readAaptBadgingAttribute(const std::string &line) +{ + std::regex re("^[A-Za-z\\-]+:\\s+name='(.+?)'.*$"); + std::smatch match; + if (std::regex_match(line, match, re)) + return match[1]; + return {}; +} + +static QString findMainIntent(const QString &aapt, const QString &apkFilePath) +{ + QString packageId; + QString activity; + QProcess aaptProcess; + aaptProcess.start(aapt, QStringList() + << QStringLiteral("dump") + << QStringLiteral("badging") + << apkFilePath); + if (aaptProcess.waitForFinished(-1)) { + const auto lines = aaptProcess.readAllStandardOutput().split('\n'); + for (const auto &line : lines) { + if (line.startsWith(QByteArrayLiteral("package:"))) + packageId = QString::fromStdString(readAaptBadgingAttribute(line.toStdString())); + else if (line.startsWith(QByteArrayLiteral("launchable-activity:"))) + activity = QString::fromStdString(readAaptBadgingAttribute(line.toStdString())); + } + } + + if (!packageId.isEmpty() && !activity.isEmpty()) + return packageId + QStringLiteral("/") + activity; + return {}; +} + +void RunEnvironment::printStartInfo(const QProcess &proc, bool dryRun) +{ + QString message = dryRun ? Tr::tr("Would start target.") : Tr::tr("Starting target."); + message.append(QLatin1Char(' ')).append(Tr::tr("Full command line: %1") + .arg(shellQuote(QStringList(QDir::toNativeSeparators(proc.program())) + << proc.arguments()))); + d->logger.qbsInfo() << message; +} + +int RunEnvironment::doRunTarget(const QString &targetBin, const QStringList &arguments, bool dryRun) +{ + d->checkProduct(); + const QStringList targetOS = d->resolvedProduct->moduleProperties->qbsPropertyValue( + QStringLiteral("targetOS")).toStringList(); + const QStringList toolchain = d->resolvedProduct->moduleProperties->qbsPropertyValue( + QStringLiteral("toolchain")).toStringList(); + + QString targetExecutable = targetBin; + QStringList targetArguments = arguments; + const QString completeSuffix = QFileInfo(targetBin).completeSuffix(); + + if (targetOS.contains(QLatin1String("android"))) { + const auto aapt = d->resolvedProduct->moduleProperties->moduleProperty( + QStringLiteral("Android.sdk"), QStringLiteral("aaptFilePath")).toString(); + const auto intent = findMainIntent(aapt, targetBin); + const auto sdkDir = d->resolvedProduct->moduleProperties->moduleProperty( + QStringLiteral("Android.sdk"), QStringLiteral("sdkDir")).toString(); + targetExecutable = sdkDir + QStringLiteral("/platform-tools/adb"); + + if (!dryRun) { + QProcess process; + process.setProcessChannelMode(QProcess::ForwardedChannels); + process.start(targetExecutable, QStringList() + << StringConstants::androidInstallCommand() + << QStringLiteral("-r") // replace existing application + << QStringLiteral("-t") // allow test packages + << QStringLiteral("-d") // allow version code downgrade + << targetBin); + if (!process.waitForFinished(-1)) { + if (process.error() == QProcess::FailedToStart) { + throw ErrorInfo(Tr::tr("The process '%1' could not be started: %2") + .arg(targetExecutable, process.errorString())); + } + d->logger.qbsWarning() << "QProcess error: " << process.errorString(); + return EXIT_FAILURE; + } + + targetArguments << QStringList() + << QStringLiteral("shell") + << QStringLiteral("am") + << QStringLiteral("start") + << QStringLiteral("-W") // wait for launch to complete + << QStringLiteral("-n") + << intent; + } + } else if (targetOS.contains(QLatin1String("ios")) || targetOS.contains(QLatin1String("tvos"))) { + const QString bundlePath = targetBin + StringConstants::slashDotDot(); + + if (targetOS.contains(QStringLiteral("ios-simulator")) + || targetOS.contains(QStringLiteral("tvos-simulator"))) { + const auto developerDir = d->resolvedProduct->moduleProperties->moduleProperty( + StringConstants::xcode(), QStringLiteral("developerPath")).toString(); + targetExecutable = developerDir + QStringLiteral("/usr/bin/simctl"); + const auto simulatorId = QStringLiteral("booted"); // TODO: parameterize + const auto bundleId = d->resolvedProduct->moduleProperties->moduleProperty( + QStringLiteral("bundle"), QStringLiteral("identifier")).toString(); + + if (!dryRun) { + QProcess process; + process.setProcessChannelMode(QProcess::ForwardedChannels); + process.start(targetExecutable, QStringList() + << StringConstants::simctlInstallCommand() + << simulatorId + << QDir::cleanPath(bundlePath)); + if (!process.waitForFinished(-1)) { + if (process.error() == QProcess::FailedToStart) { + throw ErrorInfo(Tr::tr("The process '%1' could not be started: %2") + .arg(targetExecutable, process.errorString())); + } + + return EXIT_FAILURE; + } + + targetArguments << QStringList() + << QStringLiteral("launch") + << QStringLiteral("--console") + << simulatorId + << bundleId + << arguments; + } + } else { + if (QFileInfo(targetExecutable = findExecutable(QStringList() + << QStringLiteral("iostool"))).isExecutable()) { + targetArguments = QStringList() + << QStringLiteral("-run") + << QStringLiteral("-bundle") + << QDir::cleanPath(bundlePath); + if (!arguments.empty()) + targetArguments << QStringLiteral("-extra-args") << arguments; + } else if (QFileInfo(targetExecutable = findExecutable(QStringList() + << QStringLiteral("ios-deploy"))).isExecutable()) { + targetArguments = QStringList() + << QStringLiteral("--no-wifi") + << QStringLiteral("--noninteractive") + << QStringLiteral("--bundle") + << QDir::cleanPath(bundlePath); + if (!arguments.empty()) + targetArguments << QStringLiteral("--args") << arguments; + } else { + d->logger.qbsLog(LoggerError) + << Tr::tr("No suitable deployment tools were found in the environment. " + "Consider installing ios-deploy."); + return EXIT_FAILURE; + } + } + } else if (targetOS.contains(QLatin1String("windows"))) { + if (completeSuffix == QLatin1String("msi")) { + targetExecutable = QLatin1String("msiexec"); + targetArguments.prepend(QDir::toNativeSeparators(targetBin)); + targetArguments.prepend(QLatin1String("/package")); + } + + // Run Windows executables through Wine when not on Windows + if (!HostOsInfo::isWindowsHost()) { + targetArguments.prepend(targetExecutable); + targetExecutable = QStringLiteral("wine"); + } + } + + if (toolchain.contains(QLatin1String("mono"))) { + targetArguments.prepend(targetExecutable); + targetExecutable = QStringLiteral("mono"); + } + + if (completeSuffix == QLatin1String("js")) { + targetExecutable = d->resolvedProduct->moduleProperties->moduleProperty( + QStringLiteral("nodejs"), QStringLiteral("interpreterFilePath")).toString(); + if (targetExecutable.isEmpty()) + // The Node.js binary is called nodejs on Debian/Ubuntu-family operating systems due to + // conflict with another package containing a binary named node + targetExecutable = findExecutable(QStringList() + << QStringLiteral("nodejs") + << QStringLiteral("node")); + targetArguments.prepend(targetBin); + } + + // Only check if the target is executable if we're not running it through another + // known application such as msiexec or wine, as we can't check in this case anyways + QFileInfo fi(targetExecutable); + if (!dryRun && targetBin == targetExecutable && (!fi.isFile() || !fi.isExecutable())) { + d->logger.qbsLog(LoggerError) << Tr::tr("File '%1' is not an executable.") + .arg(QDir::toNativeSeparators(targetExecutable)); + return EXIT_FAILURE; + } + + QProcessEnvironment env = d->environment; + env.insert(QStringLiteral("QBS_RUN_FILE_PATH"), targetBin); + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, env) + .setupForRun(d->setupRunEnvConfig); + + QProcess process; + process.setProcessEnvironment(d->resolvedProduct->runEnvironment); + process.setProcessChannelMode(QProcess::ForwardedChannels); + process.setProgram(targetExecutable); + process.setArguments(targetArguments); + printStartInfo(process, dryRun); + if (dryRun) + return EXIT_SUCCESS; + process.start(); + if (!process.waitForFinished(-1)) { + if (process.error() == QProcess::FailedToStart) { + QString errorPrefixString; +#ifdef Q_OS_UNIX + if (QFileInfo(targetExecutable).isExecutable()) { + const QString interpreter(shellInterpreter(targetExecutable)); + if (!interpreter.isEmpty()) { + errorPrefixString = Tr::tr("%1: bad interpreter: ").arg(interpreter); + } + } +#endif + throw ErrorInfo(Tr::tr("The process '%1' could not be started: %2") + .arg(targetExecutable, errorPrefixString + process.errorString())); + } + d->logger.qbsWarning() << "QProcess error: " << process.errorString(); + return EXIT_FAILURE; + } + return process.exitCode(); +} + +const QProcessEnvironment RunEnvironment::getRunEnvironment() const +{ + d->checkProduct(); + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, d->environment) + .setupForRun(d->setupRunEnvConfig); + return d->resolvedProduct->runEnvironment; +} + +const QProcessEnvironment RunEnvironment::getBuildEnvironment() const +{ + if (!d->resolvedProduct) + return d->environment; + EnvironmentScriptRunner(d->resolvedProduct.get(), &d->evalContext, d->environment) + .setupForBuild(); + return d->resolvedProduct->buildEnvironment; +} + +} // namespace qbs diff --git a/src/lib/corelib/api/runenvironment.h b/src/lib/corelib/api/runenvironment.h new file mode 100644 index 00000000..4a967ba6 --- /dev/null +++ b/src/lib/corelib/api/runenvironment.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RUNENVIRONMENT_H +#define QBS_RUNENVIRONMENT_H + +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QProcess; +class QProcessEnvironment; +QT_END_NAMESPACE + +class TestApi; + +namespace qbs { +class ErrorInfo; +class InstallOptions; +class Settings; + +namespace Internal { +class Logger; +class ResolvedProduct; +} // namespace Internal + +class QBS_EXPORT RunEnvironment +{ + friend class CommandLineFrontend; + friend class Project; + friend class ::TestApi; +public: + ~RunEnvironment(); + + int runShell(ErrorInfo *error = nullptr); + int runTarget(const QString &targetBin, const QStringList &arguments, bool dryRun, + ErrorInfo *error = nullptr); + + const QProcessEnvironment runEnvironment(ErrorInfo *error = nullptr) const; + const QProcessEnvironment buildEnvironment(ErrorInfo *error = nullptr) const; + +private: + RunEnvironment(const Internal::ResolvedProductPtr &product, + const Internal::TopLevelProjectConstPtr &project, + const InstallOptions &installOptions, + const QProcessEnvironment &environment, + const QStringList &setupRunEnvConfig, + Settings *settings, + const Internal::Logger &logger); + + int doRunShell(); + int doRunTarget(const QString &targetBin, const QStringList &arguments, bool dryRun); + void printStartInfo(const QProcess &proc, bool dryRun); + + const QProcessEnvironment getRunEnvironment() const; + const QProcessEnvironment getBuildEnvironment() const; + + class RunEnvironmentPrivate; + const std::unique_ptr d; +}; + +} // namespace qbs + +#endif // QBS_RUNENVIRONMENT_H diff --git a/src/lib/corelib/api/transformerdata.cpp b/src/lib/corelib/api/transformerdata.cpp new file mode 100644 index 00000000..9724e641 --- /dev/null +++ b/src/lib/corelib/api/transformerdata.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "transformerdata_p.h" + +#include + +namespace qbs { + +TransformerData::TransformerData() : d(new Internal::TransformerDataPrivate) { } +TransformerData::TransformerData(const TransformerData &other) = default; +TransformerData::~TransformerData() = default; + +TransformerData& TransformerData::operator=(const TransformerData &other) = default; + +QList TransformerData::inputs() const { return d->inputs; } +QList TransformerData::outputs() const { return d->outputs; } +RuleCommandList TransformerData::commands() const { return d->commands; } + +} // namespace qbs diff --git a/src/lib/corelib/api/transformerdata.h b/src/lib/corelib/api/transformerdata.h new file mode 100644 index 00000000..bdd93332 --- /dev/null +++ b/src/lib/corelib/api/transformerdata.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TRANSFORMERDATA_H +#define QBS_TRANSFORMERDATA_H + +#include "projectdata.h" +#include "rulecommand.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { +class ProjectPrivate; +class TransformerDataPrivate; +} + +class QBS_EXPORT TransformerData +{ + friend class Internal::ProjectPrivate; +public: + TransformerData(); + TransformerData(const TransformerData &other); + ~TransformerData(); + TransformerData &operator=(const TransformerData &other); + + QList inputs() const; + QList outputs() const; + RuleCommandList commands() const; + +private: + QExplicitlySharedDataPointer d; +}; + +using ProductTransformerData = QList; +using ProjectTransformerData = QList>; + +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/api/transformerdata_p.h b/src/lib/corelib/api/transformerdata_p.h new file mode 100644 index 00000000..a7ed4ee2 --- /dev/null +++ b/src/lib/corelib/api/transformerdata_p.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TRANSFORMERDATA_P_H +#define QBS_TRANSFORMERDATA_P_H + +#include "transformerdata.h" + +namespace qbs { +namespace Internal { + +class TransformerDataPrivate : public QSharedData +{ +public: + QList inputs; + QList outputs; + RuleCommandList commands; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp new file mode 100644 index 00000000..16c3621b --- /dev/null +++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "abstractcommandexecutor.h" + +#include "rulecommands.h" +#include "transformer.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { + +AbstractCommandExecutor::AbstractCommandExecutor(Logger logger, QObject *parent) + : QObject(parent) + , m_echoMode(defaultCommandEchoMode()) + , m_command(nullptr) + , m_transformer(nullptr) + , m_mainThreadScriptEngine(nullptr) + , m_dryRun(false) + , m_logger(std::move(logger)) +{ + m_watchdog.setSingleShot(true); + connect(&m_watchdog, &QTimer::timeout, + this, [this]() { + cancel(ErrorInfo{Tr::tr("Command cancelled because it exceeded the timeout.")}); + }); + connect(this, &AbstractCommandExecutor::finished, + &m_watchdog, &QTimer::stop); + +} + +void AbstractCommandExecutor::start(Transformer *transformer, AbstractCommand *cmd) +{ + m_transformer = transformer; + m_command = cmd; + doSetup(); + doReportCommandDescription(transformer->product()->fullDisplayName()); + if (doStart()) + startTimeout(); +} + +void AbstractCommandExecutor::doReportCommandDescription(const QString &productName) +{ + if (m_command->isSilent() || m_echoMode == CommandEchoModeSilent) + return; + + if (m_command->description().isEmpty()) { + m_logger.printWarning( + ErrorInfo(Tr::tr("Command is not marked silent, but has no description."), + m_command->codeLocation())); + } else { + emit reportCommandDescription(m_command->highlight(), + m_command->fullDescription(productName)); + } +} + +void AbstractCommandExecutor::startTimeout() +{ + if (!m_dryRun || m_command->ignoreDryRun()) { + const auto timeout = m_command->timeout(); + if (timeout > 0) + m_watchdog.start(timeout * 1000); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/abstractcommandexecutor.h b/src/lib/corelib/buildgraph/abstractcommandexecutor.h new file mode 100644 index 00000000..c0f14962 --- /dev/null +++ b/src/lib/corelib/buildgraph/abstractcommandexecutor.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ABSTRACTCOMMANDEXECUTOR_H +#define QBS_ABSTRACTCOMMANDEXECUTOR_H + +#include +#include +#include + +#include +#include + +namespace qbs { +class ErrorInfo; + +namespace Internal { +class AbstractCommand; +class ScriptEngine; +class Transformer; + +class AbstractCommandExecutor : public QObject +{ + Q_OBJECT +public: + explicit AbstractCommandExecutor(Internal::Logger logger, QObject *parent = nullptr); + + void setMainThreadScriptEngine(ScriptEngine *engine) { m_mainThreadScriptEngine = engine; } + void setDryRunEnabled(bool enabled) { m_dryRun = enabled; } + void setEchoMode(CommandEchoMode echoMode) { m_echoMode = echoMode; } + + virtual void cancel(const qbs::ErrorInfo &reason = {}) = 0; + + void start(Transformer *transformer, AbstractCommand *cmd); + +signals: + void reportCommandDescription(const QString &highlight, const QString &message); + void finished(const qbs::ErrorInfo &err = ErrorInfo()); // !hasError() <=> command successful + +protected: + virtual void doReportCommandDescription(const QString &productName); + AbstractCommand *command() const { return m_command; } + Transformer *transformer() const { return m_transformer; } + ScriptEngine *scriptEngine() const { return m_mainThreadScriptEngine; } + bool dryRun() const { return m_dryRun; } + Internal::Logger logger() const { return m_logger; } + CommandEchoMode m_echoMode; + +private: + virtual void doSetup() { }; + virtual bool doStart() = 0; + + void startTimeout(); + +private: + AbstractCommand *m_command; + Transformer *m_transformer; + ScriptEngine *m_mainThreadScriptEngine; + bool m_dryRun; + Internal::Logger m_logger; + QTimer m_watchdog; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ABSTRACTCOMMANDEXECUTOR_H diff --git a/src/lib/corelib/buildgraph/artifact.cpp b/src/lib/corelib/buildgraph/artifact.cpp new file mode 100644 index 00000000..8d3a8bd3 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifact.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "artifact.h" + +#include "transformer.h" +#include "buildgraphvisitor.h" +#include "productbuilddata.h" +#include "rulenode.h" +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +Artifact::Artifact() : + artifactType(ArtifactType::Unknown), + inputsScanned(false), + timestampRetrieved(false), + alwaysUpdated(false), + oldDataPossiblyPresent(true) +{ +} + +Artifact::~Artifact() +{ + for (Artifact *p : parentArtifacts()) + p->childrenAddedByScanner.remove(this); +} + +void Artifact::accept(BuildGraphVisitor *visitor) +{ + if (visitor->visit(this)) + acceptChildren(visitor); + visitor->endVisit(this); +} + +QString Artifact::toString() const +{ + return QLatin1String("ARTIFACT ") + filePath() + QLatin1String(" [") + + (!product.expired() ? product->name : QLatin1String("")) + QLatin1Char(']'); +} + +void Artifact::addFileTag(const FileTag &t) +{ + m_fileTags += t; + if (!product.expired() && product->buildData) { + product->buildData->addFileTagToArtifact(this, t); + if (product->fileTags.contains(t)) + product->buildData->addRootNode(this); + } +} + +void Artifact::removeFileTag(const FileTag &t) +{ + m_fileTags -= t; + if (!product.expired() && product->buildData) { + product->buildData->removeArtifactFromSetByFileTag(this, t); + if (product->fileTags.contains(t) && !product->fileTags.intersects(m_fileTags)) + product->buildData->removeFromRootNodes(this); + } +} + +void Artifact::setFileTags(const FileTags &newFileTags) +{ + if (product.expired() || !product->buildData) { + m_fileTags = newFileTags; + return; + } + if (m_fileTags == newFileTags) + return; + const Set addedTags = newFileTags - m_fileTags; + for (const FileTag &t : addedTags) + addFileTag(t); + const Set removedTags = m_fileTags - newFileTags; + for (const FileTag &t : removedTags) + removeFileTag(t); +} + +RuleNode *Artifact::producer() const +{ + if (artifactType == SourceFile) + return nullptr; + const auto ruleNodes = filterByType(children); + QBS_CHECK(ruleNodes.begin() != ruleNodes.end()); + return *ruleNodes.begin(); +} + +const TypeFilter Artifact::parentArtifacts() const +{ + return TypeFilter(parents); +} + +const TypeFilter Artifact::childArtifacts() const +{ + return TypeFilter(children); +} + +void Artifact::onChildDisconnected(BuildGraphNode *child) +{ + if (child->type() != BuildGraphNode::ArtifactNodeType) + return; + childrenAddedByScanner.remove(static_cast(child)); +} + +void Artifact::load(PersistentPool &pool) +{ + FileResourceBase::load(pool); + BuildGraphNode::load(pool); + children.load(pool); + + // restore parents of the loaded children + for (auto it = children.constBegin(); it != children.constEnd(); ++it) + (*it)->parents.insert(this); + + pool.load(childrenAddedByScanner); + pool.load(fileDependencies); + pool.load(properties); + pool.load(targetOfModule); + pool.load(transformer); + pool.load(m_fileTags); + pool.load(pureFileTags); + pool.load(pureProperties); + artifactType = static_cast(pool.load()); + alwaysUpdated = pool.load(); + oldDataPossiblyPresent = pool.load(); +} + +void Artifact::store(PersistentPool &pool) +{ + FileResourceBase::store(pool); + BuildGraphNode::store(pool); + // Do not store parents to avoid recursion. + children.store(pool); + pool.store(childrenAddedByScanner); + pool.store(fileDependencies); + pool.store(properties); + pool.store(targetOfModule); + pool.store(transformer); + pool.store(m_fileTags); + pool.store(pureFileTags); + pool.store(pureProperties); + pool.store(static_cast(artifactType)); + pool.store(alwaysUpdated); + pool.store(oldDataPossiblyPresent); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/artifact.h b/src/lib/corelib/buildgraph/artifact.h new file mode 100644 index 00000000..2572a3b5 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifact.h @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ARTIFACT_H +#define QBS_ARTIFACT_H + +#include "filedependency.h" +#include "buildgraphnode.h" +#include "forward_decls.h" +#include +#include +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { +class Logger; + +class Artifact; +using ArtifactSet = Set; + +/** + * The Artifact class + * + * Let artifact P be the parent of artifact C. Thus C is child of P. + * C produces P using the transformer P.transformer. + * + * + */ +class QBS_AUTOTEST_EXPORT Artifact : public FileResourceBase, public BuildGraphNode +{ +public: + Artifact(); + ~Artifact() override; + + Type type() const override { return ArtifactNodeType; } + FileType fileType() const override { return FileTypeArtifact; } + void accept(BuildGraphVisitor *visitor) override; + QString toString() const override; + + void addFileTag(const FileTag &t); + void removeFileTag(const FileTag &t); + void setFileTags(const FileTags &newFileTags); + const FileTags &fileTags() const { return m_fileTags; } + + RuleNode *producer() const; + + ArtifactSet childrenAddedByScanner; + Set fileDependencies; + TransformerPtr transformer; + PropertyMapPtr properties; + QString targetOfModule; + + // The tags set directly via an Artifact item or an outputArtifacts script, + // not the result of file taggers or fileTagsFilter groups, nor the ones inherited from + // the product. + FileTags pureFileTags; + + // The properties attached directly to an artifact in an Artifact item or outputArtifacts + // script. + std::vector> pureProperties; + + enum ArtifactType + { + Unknown = 1, + SourceFile = 2, + Generated = 4 + }; + + ArtifactType artifactType; + bool inputsScanned : 1; // Do not serialize. Will be refreshed for every build. + bool timestampRetrieved : 1; // Do not serialize. Will be refreshed for every build. + bool alwaysUpdated : 1; + bool oldDataPossiblyPresent : 1; + + const TypeFilter parentArtifacts() const; + const TypeFilter childArtifacts() const; + void onChildDisconnected(BuildGraphNode *child) override; + + bool isTargetOfModule() const { return !targetOfModule.isEmpty(); } + + void load(PersistentPool &pool) override; + void store(PersistentPool &pool) override; + +private: + FileTags m_fileTags; +}; + +template<> inline QString Set::toString(Artifact * const &artifact) const +{ + return artifact ? artifact->filePath() : QStringLiteral(""); +} +template<> inline const void *uniqueAddress(const Artifact *a) +{ + return static_cast(a); +} + +template<> inline bool hasDynamicType(const BuildGraphNode *n) +{ + return n->type() == BuildGraphNode::ArtifactNodeType; +} + +// debugging helper +inline QString toString(Artifact::ArtifactType t) +{ + switch (t) { + case Artifact::SourceFile: + return QStringLiteral("SourceFile"); + case Artifact::Generated: + return QStringLiteral("Generated"); + case Artifact::Unknown: + default: + return QStringLiteral("Unknown"); + } +} + +// debugging helper +inline QString toString(BuildGraphNode::BuildState s) +{ + switch (s) { + case BuildGraphNode::Untouched: + return QStringLiteral("Untouched"); + case BuildGraphNode::Buildable: + return QStringLiteral("Buildable"); + case BuildGraphNode::Building: + return QStringLiteral("Building"); + case BuildGraphNode::Built: + return QStringLiteral("Built"); + default: + return QStringLiteral("Unknown"); + } +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ARTIFACT_H diff --git a/src/lib/corelib/buildgraph/artifactcleaner.cpp b/src/lib/corelib/buildgraph/artifactcleaner.cpp new file mode 100644 index 00000000..6239a138 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactcleaner.cpp @@ -0,0 +1,232 @@ +#include + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "artifactcleaner.h" + +#include "artifact.h" +#include "artifactvisitor.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +static void printRemovalMessage(const QString &path, bool dryRun, const Logger &logger) +{ + if (dryRun) + logger.qbsInfo() << Tr::tr("Would remove '%1'.").arg(path); + else + logger.qbsDebug() << "Removing '" << path << "'."; +} + +static void invalidateArtifactTimestamp(Artifact *artifact) +{ + if (artifact->timestamp().isValid()) { + artifact->clearTimestamp(); + artifact->product->topLevelProject()->buildData->setDirty(); + } +} + +static void removeArtifactFromDisk(Artifact *artifact, bool dryRun, const Logger &logger) +{ + QFileInfo fileInfo(artifact->filePath()); + if (!FileInfo::fileExists(fileInfo)) { + if (!dryRun) + invalidateArtifactTimestamp(artifact); + return; + } + printRemovalMessage(fileInfo.filePath(), dryRun, logger); + if (dryRun) + return; + invalidateArtifactTimestamp(artifact); + QString errorMessage; + if (!removeFileRecursion(fileInfo, &errorMessage)) + throw ErrorInfo(errorMessage); +} + +class CleanupVisitor : public ArtifactVisitor +{ +public: + CleanupVisitor(CleanOptions options, const ProgressObserver *observer, + Logger logger) + : ArtifactVisitor(Artifact::Generated) + , m_options(std::move(options)) + , m_observer(observer) + , m_logger(std::move(logger)) + , m_hasError(false) + { + } + + void visitProduct(const ResolvedProductPtr &product) + { + m_product = product; + ArtifactVisitor::visitProduct(product); + const AllRescuableArtifactData rescuableArtifactData + = product->buildData->rescuableArtifactData(); + for (auto it = rescuableArtifactData.begin(); it != rescuableArtifactData.end(); ++it) { + Artifact tmp; + tmp.product = product; + tmp.setFilePath(it.key()); + tmp.setTimestamp(it.value().timeStamp); + removeArtifactFromDisk(&tmp, m_options.dryRun(), m_logger); + product->buildData->removeFromRescuableArtifactData(it.key()); + } + } + + const Set &directories() const { return m_directories; } + bool hasError() const { return m_hasError; } + +private: + void doVisit(Artifact *artifact) override + { + if (m_observer->canceled()) + throw ErrorInfo(Tr::tr("Cleaning up was canceled.")); + + if (artifact->product != m_product) + return; + try { + removeArtifactFromDisk(artifact, m_options.dryRun(), m_logger); + } catch (const ErrorInfo &error) { + if (!m_options.keepGoing()) + throw; + m_logger.printWarning(error); + m_hasError = true; + } + m_directories << artifact->dirPath(); + } + + const CleanOptions m_options; + const ProgressObserver * const m_observer; + Logger m_logger; + bool m_hasError; + ResolvedProductConstPtr m_product; + Set m_directories; +}; + +ArtifactCleaner::ArtifactCleaner(Logger logger, ProgressObserver *observer) + : m_logger(std::move(logger)), m_observer(observer) +{ +} + +void ArtifactCleaner::cleanup(const TopLevelProjectPtr &project, + const QVector &products, const CleanOptions &options) +{ + m_hasError = false; + + const QString configString = Tr::tr(" for configuration %1").arg(project->id()); + m_observer->initialize(Tr::tr("Cleaning up%1").arg(configString), products.size() + 1); + + Set directories; + for (const ResolvedProductPtr &product : products) { + CleanupVisitor visitor(options, m_observer, m_logger); + visitor.visitProduct(product); + directories.unite(visitor.directories()); + if (visitor.hasError()) + m_hasError = true; + m_observer->incrementProgressValue(); + } + + // Directories created during the build are not artifacts (TODO: should they be?), + // so we have to clean them up manually. + auto dirList = rangeTo(directories); + for (int i = 0; i < dirList.size(); ++i) { + const QString &dir = dirList.at(i); + if (!dir.startsWith(project->buildDirectory)) + continue; + if (FileInfo(dir).exists()) + removeEmptyDirectories(dir, options); + if (dir != project->buildDirectory) { + const QString parentDir = QDir::cleanPath(dir + StringConstants::slashDotDot()); + if (parentDir != project->buildDirectory && !dirList.contains(parentDir)) + dirList.push_back(parentDir); + } + } + m_observer->incrementProgressValue(); + + if (m_hasError) + throw ErrorInfo(Tr::tr("Failed to remove some files.")); + m_observer->setFinished(); +} + +void ArtifactCleaner::removeEmptyDirectories(const QString &rootDir, const CleanOptions &options, + bool *isEmpty) +{ + bool subTreeIsEmpty = true; + QDirIterator it(rootDir, QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoDotAndDotDot); + while (it.hasNext()) { + it.next(); + if (!it.fileInfo().isSymLink() && it.fileInfo().isDir()) + removeEmptyDirectories(it.filePath(), options, &subTreeIsEmpty); + else + subTreeIsEmpty = false; + } + if (subTreeIsEmpty) { + printRemovalMessage(rootDir, options.dryRun(), m_logger); + if (!QDir::root().rmdir(rootDir)) { + ErrorInfo error(Tr::tr("Failure to remove empty directory '%1'.").arg(rootDir)); + if (!options.keepGoing()) + throw error; + m_logger.printWarning(error); + m_hasError = true; + subTreeIsEmpty = false; + } + } + if (!subTreeIsEmpty && isEmpty) + *isEmpty = false; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/artifactcleaner.h b/src/lib/corelib/buildgraph/artifactcleaner.h new file mode 100644 index 00000000..8d0bef27 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactcleaner.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ARTIFACTCLEANER_H +#define QBS_ARTIFACTCLEANER_H + +#include + +#include +#include + +namespace qbs { +class CleanOptions; + +namespace Internal { +class ProgressObserver; + +class ArtifactCleaner +{ +public: + ArtifactCleaner(Logger logger, ProgressObserver *observer); + void cleanup(const TopLevelProjectPtr &project, const QVector &products, + const CleanOptions &options); + +private: + void removeEmptyDirectories(const QString &rootDir, const CleanOptions &options, + bool *isEmpty = nullptr); + + Logger m_logger; + bool m_hasError = false; + ProgressObserver *m_observer = nullptr; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ARTIFACTCLEANER_H diff --git a/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp b/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp new file mode 100644 index 00000000..3f3fce59 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactsscriptvalue.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "artifactsscriptvalue.h" + +#include "artifact.h" +#include "productbuilddata.h" +#include "transformer.h" + +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +enum BuildGraphScriptValueCommonPropertyKeys : quint32 { + CachedValueKey, + FileTagKey, + ProductPtrKey, +}; + +class ArtifactsScriptClass : public QScriptClass +{ +public: + ArtifactsScriptClass(QScriptEngine *engine) : QScriptClass(engine) { } + +private: + QueryFlags queryProperty(const QScriptValue &object, const QScriptString &name, + QueryFlags flags, uint *id) override + { + getProduct(object); + qbsEngine()->setNonExistingArtifactSetRequested(m_product, name.toString()); + return QScriptClass::queryProperty(object, name, flags, id); + } + + QScriptClassPropertyIterator *newIterator(const QScriptValue &object) override + { + getProduct(object); + qbsEngine()->setArtifactsEnumerated(m_product); + return QScriptClass::newIterator(object); + } + + void getProduct(const QScriptValue &object) + { + if (m_lastObjectId != object.objectId()) { + m_lastObjectId = object.objectId(); + m_product = reinterpret_cast( + object.data().property(ProductPtrKey).toVariant().value()); + } + } + + ScriptEngine *qbsEngine() const { return static_cast(engine()); } + + qint64 m_lastObjectId = 0; + const ResolvedProduct *m_product = nullptr; +}; + +static bool isRelevantArtifact(const ResolvedProduct *, const Artifact *artifact) +{ + return !artifact->isTargetOfModule(); +} +static bool isRelevantArtifact(const ResolvedModule *module, const Artifact *artifact) +{ + return artifact->targetOfModule == module->name; +} + +static ArtifactSetByFileTag artifactsMap(const ResolvedProduct *product) +{ + return product->buildData->artifactsByFileTag(); +} + +static ArtifactSetByFileTag artifactsMap(const ResolvedModule *module) +{ + return artifactsMap(module->product); +} + +static QScriptValue createArtifactsObject(const ResolvedProduct *product, ScriptEngine *engine) +{ + QScriptClass *scriptClass = engine->artifactsScriptClass(); + if (!scriptClass) { + scriptClass = new ArtifactsScriptClass(engine); + engine->setArtifactsScriptClass(scriptClass); + } + QScriptValue artifactsObj = engine->newObject(scriptClass); + QScriptValue data = engine->newObject(); + QVariant v; + v.setValue(reinterpret_cast(product)); + data.setProperty(ProductPtrKey, engine->newVariant(v)); + artifactsObj.setData(data); + return artifactsObj; +} + +static QScriptValue createArtifactsObject(const ResolvedModule *, ScriptEngine *engine) +{ + return engine->newObject(); +} + +static bool checkAndSetArtifactsMapUpToDateFlag(const ResolvedProduct *p) +{ + return p->buildData->checkAndSetJsArtifactsMapUpToDateFlag(); +} +static bool checkAndSetArtifactsMapUpToDateFlag(const ResolvedModule *) { return true; } + +static void registerArtifactsMapAccess(const ResolvedProduct *p, ScriptEngine *e, bool forceUpdate) +{ + e->setArtifactsMapRequested(p, forceUpdate); +} +static void registerArtifactsMapAccess(const ResolvedModule *, ScriptEngine *, bool) {} +static void registerArtifactsSetAccess(const ResolvedProduct *p, const FileTag &t, ScriptEngine *e) +{ + e->setArtifactSetRequestedForTag(p, t); +} +static void registerArtifactsSetAccess(const ResolvedModule *, const FileTag &, ScriptEngine *) {} + +template static QScriptValue js_artifactsForFileTag( + QScriptContext *ctx, ScriptEngine *engine, const ProductOrModule *productOrModule) +{ + const FileTag fileTag = FileTag(ctx->callee().property(FileTagKey).toString().toUtf8()); + registerArtifactsSetAccess(productOrModule, fileTag, engine); + QScriptValue result = ctx->callee().property(CachedValueKey); + if (result.isArray()) + return result; + auto artifacts = artifactsMap(productOrModule).value(fileTag); + const auto filter = [productOrModule](const Artifact *a) { + return !isRelevantArtifact(productOrModule, a); + }; + Internal::removeIf(artifacts, filter); + result = engine->newArray(uint(artifacts.size())); + ctx->callee().setProperty(CachedValueKey, result); + int k = 0; + for (const Artifact * const artifact : artifacts) + result.setProperty(k++, Transformer::translateFileConfig(engine, artifact, QString())); + return result; +} + +template static QScriptValue js_artifacts( + QScriptContext *ctx, ScriptEngine *engine, const ProductOrModule *productOrModule) +{ + QScriptValue artifactsObj = ctx->callee().property(CachedValueKey); + if (artifactsObj.isObject() && checkAndSetArtifactsMapUpToDateFlag(productOrModule)) { + registerArtifactsMapAccess(productOrModule, engine, false); + return artifactsObj; + } + registerArtifactsMapAccess(productOrModule, engine, true); + artifactsObj = createArtifactsObject(productOrModule, engine); + ctx->callee().setProperty(CachedValueKey, artifactsObj); + const auto &map = artifactsMap(productOrModule); + for (auto it = map.cbegin(); it != map.cend(); ++it) { + const auto filter = [productOrModule](const Artifact *a) { + return isRelevantArtifact(productOrModule, a); + }; + if (std::none_of(it.value().cbegin(), it.value().cend(), filter)) + continue; + QScriptValue fileTagFunc = engine->newFunction(&js_artifactsForFileTag, + productOrModule); + const QString fileTag = it.key().toString(); + fileTagFunc.setProperty(FileTagKey, fileTag); + artifactsObj.setProperty(fileTag, fileTagFunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + } + return artifactsObj; +} + +QScriptValue artifactsScriptValueForProduct(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedProduct *product) +{ + return js_artifacts(ctx, engine, product); +} + +QScriptValue artifactsScriptValueForModule(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedModule *module) +{ + return js_artifacts(ctx, engine, module); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/artifactsscriptvalue.h b/src/lib/corelib/buildgraph/artifactsscriptvalue.h new file mode 100644 index 00000000..c0da8a05 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactsscriptvalue.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ARTIFACTSSCRIPTVALUE_H +#define QBS_ARTIFACTSSCRIPTVALUE_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QScriptContext; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class ScriptEngine; + +QScriptValue artifactsScriptValueForProduct(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedProduct *product); + +QScriptValue artifactsScriptValueForModule(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedModule *module); + +} // namespace Internal +} // namespace qbs + +#endif // include guard diff --git a/src/lib/corelib/buildgraph/artifactvisitor.cpp b/src/lib/corelib/buildgraph/artifactvisitor.cpp new file mode 100644 index 00000000..22c98757 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactvisitor.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "artifactvisitor.h" + +#include "artifact.h" +#include "productbuilddata.h" +#include +#include +#include + +namespace qbs { +namespace Internal { + +ArtifactVisitor::ArtifactVisitor(int artifactType) : m_artifactType(artifactType) +{ +} + +void ArtifactVisitor::visitProduct(const ResolvedProductConstPtr &product) +{ + if (!product->buildData) + return; + for (BuildGraphNode *node : qAsConst(product->buildData->allNodes())) + node->accept(this); +} + +void ArtifactVisitor::visitProject(const ResolvedProjectConstPtr &project) +{ + for (const auto &product : project->allProducts()) + visitProduct(product); +} + +bool ArtifactVisitor::visit(RuleNode *ruleNode) +{ + Q_UNUSED(ruleNode); + return false; +} + +bool ArtifactVisitor::visit(Artifact *artifact) +{ + QBS_CHECK(artifact); + if (m_artifactType & artifact->artifactType) + doVisit(artifact); + return false; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/artifactvisitor.h b/src/lib/corelib/buildgraph/artifactvisitor.h new file mode 100644 index 00000000..89bd4429 --- /dev/null +++ b/src/lib/corelib/buildgraph/artifactvisitor.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ARTIFACTVISITOR_H +#define QBS_ARTIFACTVISITOR_H + +#include "forward_decls.h" + +#include "buildgraphvisitor.h" +#include + +#include + +namespace qbs { +namespace Internal { + +class ArtifactVisitor : public BuildGraphVisitor +{ +public: + ArtifactVisitor(int artifactType); + + void visitProduct(const ResolvedProductConstPtr &product); + void visitProject(const ResolvedProjectConstPtr &project); + bool visit(RuleNode *ruleNode) override; + bool visit(Artifact *artifact) override; + +private: + virtual void doVisit(Artifact *artifact) = 0; + + const int m_artifactType; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ARTIFACTVISITOR_H diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp new file mode 100644 index 00000000..23d141dd --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -0,0 +1,856 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "buildgraph.h" + +#include "artifact.h" +#include "artifactsscriptvalue.h" +#include "cycledetector.h" +#include "dependencyparametersscriptvalue.h" +#include "projectbuilddata.h" +#include "productbuilddata.h" +#include "rulenode.h" +#include "scriptclasspropertyiterator.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static QString childItemsProperty() { return QStringLiteral("childItems"); } +static QString exportsProperty() { return QStringLiteral("exports"); } + +// TODO: Introduce productscriptvalue.{h,cpp}. +static QScriptValue getDataForProductScriptValue(QScriptEngine *engine, + const ResolvedProduct *product) +{ + QScriptValue data = engine->newObject(); + QVariant v; + v.setValue(reinterpret_cast(product)); + data.setProperty(ProductPtrKey, engine->newVariant(v)); + return data; +} + +class ProductPropertyScriptClass : public QScriptClass +{ +public: + ProductPropertyScriptClass(QScriptEngine *engine) : QScriptClass(engine) { } + +private: + QueryFlags queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags, + uint *) override + { + if (name == StringConstants::parametersProperty()) { + m_result = object.data().property(DependencyParametersKey); + return HandlesReadAccess; + } + if (name == StringConstants::moduleNameProperty()) { + m_result = object.data().property(ModuleNameKey); + return HandlesReadAccess; + } + if (name == StringConstants::dependenciesProperty() + || name == StringConstants::artifactsProperty() + || name == exportsProperty()) { + // The prototype is not backed by a QScriptClass. + m_result = object.prototype().property(name); + return HandlesReadAccess; + } + + getProduct(object); + QBS_ASSERT(m_product, return {}); + + const auto it = m_product->productProperties.find(name); + + // It is important that we reject unknown property names. Otherwise QtScript will forward + // *everything* to us, including built-in stuff like the hasOwnProperty function. + if (it == m_product->productProperties.cend()) + return {}; + + qbsEngine()->addPropertyRequestedInScript(Property(m_product->uniqueName(), QString(), name, + it.value(), Property::PropertyInProduct)); + m_result = qbsEngine()->toScriptValue(it.value()); + return HandlesReadAccess; + } + + QScriptValue property(const QScriptValue &, const QScriptString &, uint) override + { + return m_result; + } + + QScriptClassPropertyIterator *newIterator(const QScriptValue &object) override + { + getProduct(object); + QBS_ASSERT(m_product, return nullptr); + + // These two are in the prototype and are thus common to all product script values. + std::vector additionalProperties({StringConstants::artifactsProperty(), + StringConstants::dependenciesProperty(), + exportsProperty()}); + + // The "moduleName" convenience property is only available for the "main product" in a rule, + // and the "parameters" property exists only for elements of the "dependencies" array for + // which dependency parameters are present. + if (object.data().property(ModuleNameKey).isValid()) + additionalProperties.push_back(StringConstants::moduleNameProperty()); + else if (object.data().property(DependencyParametersKey).isValid()) + additionalProperties.push_back(StringConstants::parametersProperty()); + return new ScriptClassPropertyIterator(object, m_product->productProperties, + additionalProperties); + } + + void getProduct(const QScriptValue &object) + { + if (m_lastObjectId != object.objectId()) { + m_lastObjectId = object.objectId(); + m_product = reinterpret_cast( + object.data().property(ProductPtrKey).toVariant().value()); + } + } + + ScriptEngine *qbsEngine() const { return static_cast(engine()); } + + qint64 m_lastObjectId = 0; + const ResolvedProduct *m_product = nullptr; + QScriptValue m_result; +}; + +static QScriptValue setupProjectScriptValue(ScriptEngine *engine, + const ResolvedProjectConstPtr &project) +{ + QScriptValue &obj = engine->projectScriptValue(project.get()); + if (obj.isValid()) + return obj; + obj = engine->newObject(); + obj.setProperty(StringConstants::filePathProperty(), project->location.filePath()); + obj.setProperty(StringConstants::pathProperty(), FileInfo::path(project->location.filePath())); + const QVariantMap &projectProperties = project->projectProperties(); + for (QVariantMap::const_iterator it = projectProperties.begin(); + it != projectProperties.end(); ++it) { + engine->setObservedProperty(obj, it.key(), engine->toScriptValue(it.value())); + } + engine->observer()->addProjectObjectId(obj.objectId(), project->name); + return obj; +} + +static QScriptValue setupProductScriptValue(ScriptEngine *engine, const ResolvedProduct *product); + +class DependenciesFunction +{ +public: + DependenciesFunction(ScriptEngine *engine) + : m_engine(engine) + { + } + + void init(QScriptValue &productScriptValue, QScriptValue &exportsScriptValue, + const ResolvedProduct *product) + { + QScriptValue depfunc = m_engine->newFunction(&js_internalProductDependencies, product); + productScriptValue.setProperty(StringConstants::dependenciesProperty(), depfunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + depfunc = m_engine->newFunction(&js_exportedProductDependencies, product); + exportsScriptValue.setProperty(StringConstants::dependenciesProperty(), depfunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + } + +private: + enum class DependencyType { Internal, Exported }; + static QScriptValue js_productDependencies(QScriptContext *, ScriptEngine *engine, + const ResolvedProduct *product, DependencyType depType) + { + QScriptValue result = engine->newArray(); + quint32 idx = 0; + const bool exportCase = depType == DependencyType::Exported; + std::vector productDeps; + if (exportCase) { + if (!product->exportedModule.productDependencies.empty()) { + const auto allProducts = product->topLevelProject()->allProducts(); + const auto getProductForName = [&allProducts](const QString &name) { + const auto cmp = [name](const ResolvedProductConstPtr &p) { + return p->uniqueName() == name; + }; + const auto it = std::find_if(allProducts.cbegin(), allProducts.cend(), cmp); + QBS_ASSERT(it != allProducts.cend(), return ResolvedProductPtr()); + return *it; + }; + std::transform(product->exportedModule.productDependencies.cbegin(), + product->exportedModule.productDependencies.cend(), + std::back_inserter(productDeps), getProductForName); + } + } else { + productDeps = product->dependencies; + } + for (const ResolvedProductPtr &dependency : qAsConst(productDeps)) { + QScriptValue obj = engine->newObject(engine->productPropertyScriptClass()); + obj.setPrototype(setupProductScriptValue(static_cast(engine), + dependency.get())); + const QVariantMap ¶ms + = (exportCase ? product->exportedModule.dependencyParameters.value(dependency) + : product->dependencyParameters.value(dependency)); + QScriptValue data = getDataForProductScriptValue(engine, dependency.get()); + data.setProperty(DependencyParametersKey, dependencyParametersValue( + product->uniqueName(), dependency->name, params, engine)); + obj.setData(data); + result.setProperty(idx++, obj); + } + if (exportCase) { + for (const ExportedModuleDependency &m : product->exportedModule.moduleDependencies) { + QScriptValue obj = engine->newObject(); + obj.setProperty(StringConstants::nameProperty(), m.name); + QScriptValue exportsValue = engine->newObject(); + obj.setProperty(exportsProperty(), exportsValue); + exportsValue.setProperty(StringConstants::dependenciesProperty(), + engine->newArray()); + for (auto modIt = m.moduleProperties.begin(); modIt != m.moduleProperties.end(); + ++modIt) { + const QVariantMap entries = modIt.value().toMap(); + if (entries.empty()) + continue; + QScriptValue moduleObj = engine->newObject(); + ModuleProperties::setModuleScriptValue(exportsValue, moduleObj, modIt.key()); + for (auto valIt = entries.begin(); valIt != entries.end(); ++valIt) + moduleObj.setProperty(valIt.key(), engine->toScriptValue(valIt.value())); + } + result.setProperty(idx++, obj); + } + return result; + } + for (const auto &dependency : product->modules) { + if (dependency->isProduct) + continue; + QScriptValue obj = engine->newObject(engine->modulePropertyScriptClass()); + obj.setPrototype(engine->moduleScriptValuePrototype(dependency.get())); + + // The prototype must exist already, because we set it up for all modules + // of the product in ModuleProperties::init(). + QBS_ASSERT(obj.prototype().isValid(), ;); + + const QVariantMap ¶ms = product->moduleParameters.value(dependency); + QScriptValue data = getDataForModuleScriptValue(engine, product, nullptr, + dependency.get()); + data.setProperty(DependencyParametersKey, dependencyParametersValue( + product->uniqueName(), dependency->name, params, engine)); + obj.setData(data); + result.setProperty(idx++, obj); + } + return result; + } + + static QScriptValue js_internalProductDependencies(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedProduct * const product) + { + engine->addDependenciesArrayRequested(product); + return js_productDependencies(ctx, engine, product, DependencyType::Internal); + } + + static QScriptValue js_exportedProductDependencies(QScriptContext *ctx, ScriptEngine *engine, + const ResolvedProduct * const product) + { + return js_productDependencies(ctx, engine, product, DependencyType::Exported); + } + + ScriptEngine *m_engine; +}; + +static QScriptValue setupExportedPropertyScriptValue(const ExportedProperty &property, + ScriptEngine *engine) +{ + QScriptValue propertyScriptValue = engine->newObject(); + propertyScriptValue.setProperty(StringConstants::nameProperty(), property.fullName); + propertyScriptValue.setProperty(StringConstants::typeProperty(), + PropertyDeclaration::typeString(property.type)); + propertyScriptValue.setProperty(StringConstants::sourceCodeProperty(), property.sourceCode); + propertyScriptValue.setProperty(QStringLiteral("isBuiltin"), property.isBuiltin); + return propertyScriptValue; +} + +static void setupExportedPropertiesScriptValue(QScriptValue &parentObject, + const std::vector &properties, + ScriptEngine *engine) +{ + QScriptValue propertiesScriptValue = engine->newArray(static_cast(properties.size())); + parentObject.setProperty(QStringLiteral("properties"), propertiesScriptValue); + quint32 arrayIndex = 0; + for (const ExportedProperty &p : properties) { + propertiesScriptValue.setProperty(arrayIndex++, + setupExportedPropertyScriptValue(p, engine)); + } +} + +static QScriptValue setupExportedItemScriptValue(const ExportedItem *item, ScriptEngine *engine) +{ + QScriptValue itemScriptValue = engine->newObject(); + itemScriptValue.setProperty(StringConstants::nameProperty(), item->name); + setupExportedPropertiesScriptValue(itemScriptValue, item->properties, engine); + QScriptValue childrenScriptValue = engine->newArray(static_cast(item->children.size())); + itemScriptValue.setProperty(childItemsProperty(), childrenScriptValue); + quint32 arrayIndex = 0; + for (const auto &childItem : item->children) { + childrenScriptValue.setProperty(arrayIndex++, + setupExportedItemScriptValue(childItem.get(), engine)); + } + return itemScriptValue; +} + +static QScriptValue setupExportsScriptValue(const ExportedModule &module, ScriptEngine *engine) +{ + QScriptValue exportsScriptValue = engine->newObject(); + for (auto it = module.propertyValues.cbegin(); it != module.propertyValues.cend(); ++it) + exportsScriptValue.setProperty(it.key(), engine->toScriptValue(it.value())); + setupExportedPropertiesScriptValue(exportsScriptValue, module.m_properties, engine); + QScriptValue childrenScriptValue = engine->newArray(static_cast(module.children.size())); + exportsScriptValue.setProperty(childItemsProperty(), childrenScriptValue); + quint32 arrayIndex = 0; + for (const auto &exportedItem : module.children) { + childrenScriptValue.setProperty(arrayIndex++, + setupExportedItemScriptValue(exportedItem.get(), engine)); + } + QScriptValue importsScriptValue = engine->newArray(module.importStatements.size()); + exportsScriptValue.setProperty(StringConstants::importsProperty(), importsScriptValue); + arrayIndex = 0; + for (const QString &importStatement : module.importStatements) + importsScriptValue.setProperty(arrayIndex++, importStatement); + for (auto it = module.modulePropertyValues.cbegin(); it != module.modulePropertyValues.cend(); + ++it) { + const QVariantMap entries = it.value().toMap(); + if (entries.empty()) + continue; + QScriptValue moduleObject = engine->newObject(); + ModuleProperties::setModuleScriptValue(exportsScriptValue, moduleObject, it.key()); + for (auto valIt = entries.begin(); valIt != entries.end(); ++valIt) + moduleObject.setProperty(valIt.key(), engine->toScriptValue(valIt.value())); + } + return exportsScriptValue; +} + +static QScriptValue setupProductScriptValue(ScriptEngine *engine, const ResolvedProduct *product) +{ + QScriptValue &productScriptValue = engine->productScriptValuePrototype(product); + if (productScriptValue.isValid()) + return productScriptValue; + productScriptValue = engine->newObject(); + ModuleProperties::init(productScriptValue, product); + + QScriptValue artifactsFunc = engine->newFunction(&artifactsScriptValueForProduct, product); + productScriptValue.setProperty(StringConstants::artifactsProperty(), artifactsFunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + + QScriptValue exportsScriptValue = setupExportsScriptValue(product->exportedModule, engine); + DependenciesFunction(engine).init(productScriptValue, exportsScriptValue, product); + engine->setObservedProperty(productScriptValue, exportsProperty(), exportsScriptValue); + engine->observer()->addExportsObjectId(exportsScriptValue.objectId(), product); + return productScriptValue; +} + +void setupScriptEngineForFile(ScriptEngine *engine, const FileContextBaseConstPtr &fileContext, + QScriptValue targetObject, const ObserveMode &observeMode) +{ + engine->import(fileContext, targetObject, observeMode); + JsExtensions::setupExtensions(fileContext->jsExtensions(), targetObject); +} + +void setupScriptEngineForProduct(ScriptEngine *engine, ResolvedProduct *product, + const ResolvedModule *module, QScriptValue targetObject, + bool setBuildEnvironment) +{ + QScriptValue projectScriptValue = setupProjectScriptValue(engine, product->project.lock()); + targetObject.setProperty(StringConstants::projectVar(), projectScriptValue); + + if (setBuildEnvironment) { + QVariant v; + v.setValue(&product->buildEnvironment); + engine->setProperty(StringConstants::qbsProcEnvVarInternal(), v); + } + QScriptClass *scriptClass = engine->productPropertyScriptClass(); + if (!scriptClass) { + scriptClass = new ProductPropertyScriptClass(engine); + engine->setProductPropertyScriptClass(scriptClass); + } + QScriptValue productScriptValue = engine->newObject(scriptClass); + productScriptValue.setPrototype(setupProductScriptValue(engine, product)); + targetObject.setProperty(StringConstants::productVar(), productScriptValue); + + QScriptValue data = getDataForProductScriptValue(engine, product); + // If the Rule is in a Module, set up the 'moduleName' property + if (!module->name.isEmpty()) + data.setProperty(ModuleNameKey, module->name); + productScriptValue.setData(data); +} + +bool findPath(BuildGraphNode *u, BuildGraphNode *v, QList &path) +{ + if (u == v) { + path.push_back(v); + return true; + } + + for (BuildGraphNode * const childNode : qAsConst(u->children)) { + if (findPath(childNode, v, path)) { + path.prepend(u); + return true; + } + } + + return false; +} + +/* + * Creates the build graph edge p -> c, which represents the dependency "c must be built before p". + */ +void connect(BuildGraphNode *p, BuildGraphNode *c) +{ + QBS_CHECK(p != c); + qCDebug(lcBuildGraph).noquote() << "connect" << p->toString() << "->" << c->toString(); + if (c->type() == BuildGraphNode::ArtifactNodeType) { + auto const ac = static_cast(c); + for (const Artifact *child : filterByType(p->children)) { + if (child == ac) + return; + const bool filePathsMustBeDifferent = child->artifactType == Artifact::Generated + || child->product == ac->product || child->artifactType != ac->artifactType; + if (filePathsMustBeDifferent && child->filePath() == ac->filePath()) { + throw ErrorInfo(QStringLiteral("%1 already has a child artifact %2 as " + "different object.").arg(p->toString(), + ac->filePath()), + CodeLocation(), true); + } + } + } + p->children.insert(c); + c->parents.insert(p); + p->product->topLevelProject()->buildData->setDirty(); +} + +static bool existsPath_impl(BuildGraphNode *u, BuildGraphNode *v, NodeSet *seen) +{ + if (u == v) + return true; + + if (!seen->insert(u).second) + return false; + + return Internal::any_of(u->children, [v, seen](const auto &child) { + return existsPath_impl(child, v, seen); + }); +} + +static bool existsPath(BuildGraphNode *u, BuildGraphNode *v) +{ + NodeSet seen; + return existsPath_impl(u, v, &seen); +} + +static QStringList toStringList(const QList &path) +{ + QStringList lst; + for (BuildGraphNode *node : path) + lst << node->toString(); + return lst; +} + +bool safeConnect(Artifact *u, Artifact *v) +{ + QBS_CHECK(u != v); + qCDebug(lcBuildGraph) << "safeConnect:" << relativeArtifactFileName(u) + << "->" << relativeArtifactFileName(v); + + if (existsPath(v, u)) { + QList circle; + findPath(v, u, circle); + qCDebug(lcBuildGraph) << "safeConnect: circle detected " << toStringList(circle); + return false; + } + + connect(u, v); + return true; +} + +void disconnect(BuildGraphNode *u, BuildGraphNode *v) +{ + qCDebug(lcBuildGraph).noquote() << "disconnect:" << u->toString() << v->toString(); + u->children.remove(v); + v->parents.remove(u); + u->onChildDisconnected(v); +} + +void removeGeneratedArtifactFromDisk(Artifact *artifact, const Logger &logger) +{ + if (artifact->artifactType != Artifact::Generated) + return; + removeGeneratedArtifactFromDisk(artifact->filePath(), logger); +} + +void removeGeneratedArtifactFromDisk(const QString &filePath, const Logger &logger) +{ + QFile file(filePath); + if (!file.exists()) + return; + logger.qbsDebug() << "removing " << filePath; + if (!file.remove()) + logger.qbsWarning() << QStringLiteral("Cannot remove '%1'.").arg(filePath); +} + +QString relativeArtifactFileName(const Artifact *artifact) +{ + const QString &buildDir = artifact->product->topLevelProject()->buildDirectory; + QString str = artifact->filePath(); + if (str.startsWith(buildDir)) + str.remove(0, buildDir.size()); + if (str.startsWith(QLatin1Char('/'))) + str.remove(0, 1); + return str; +} + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, + const ProjectBuildData *projectBuildData, const QString &dirPath, const QString &fileName, + bool compareByName) +{ + for (const auto &fileResource : projectBuildData->lookupFiles(dirPath, fileName)) { + if (fileResource->fileType() != FileResourceBase::FileTypeArtifact) + continue; + const auto artifact = static_cast(fileResource); + if (compareByName + ? artifact->product->uniqueName() == product->uniqueName() + : artifact->product == product) { + return artifact; + } + } + return nullptr; +} + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const QString &dirPath, + const QString &fileName, bool compareByName) +{ + return lookupArtifact(product, product->topLevelProject()->buildData.get(), dirPath, fileName, + compareByName); +} + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const QString &filePath, + bool compareByName) +{ + QString dirPath, fileName; + FileInfo::splitIntoDirectoryAndFileName(filePath, &dirPath, &fileName); + return lookupArtifact(product, dirPath, fileName, compareByName); +} + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const ProjectBuildData *buildData, + const QString &filePath, bool compareByName) +{ + QString dirPath, fileName; + FileInfo::splitIntoDirectoryAndFileName(filePath, &dirPath, &fileName); + return lookupArtifact(product, buildData, dirPath, fileName, compareByName); +} + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const Artifact *artifact, + bool compareByName) +{ + return lookupArtifact(product, artifact->dirPath(), artifact->fileName(), compareByName); +} + +Artifact *createArtifact(const ResolvedProductPtr &product, + const SourceArtifactConstPtr &sourceArtifact) +{ + const auto artifact = new Artifact; + artifact->artifactType = Artifact::SourceFile; + setArtifactData(artifact, sourceArtifact); + insertArtifact(product, artifact); + return artifact; +} + +void setArtifactData(Artifact *artifact, const SourceArtifactConstPtr &sourceArtifact) +{ + artifact->targetOfModule = sourceArtifact->targetOfModule; + artifact->setFilePath(sourceArtifact->absoluteFilePath); + artifact->setFileTags(sourceArtifact->fileTags); + artifact->properties = sourceArtifact->properties; +} + +void updateArtifactFromSourceArtifact(const ResolvedProductPtr &product, + const SourceArtifactConstPtr &sourceArtifact) +{ + Artifact * const artifact = lookupArtifact(product, sourceArtifact->absoluteFilePath, false); + QBS_CHECK(artifact); + const FileTags oldFileTags = artifact->fileTags(); + const QVariantMap oldModuleProperties = artifact->properties->value(); + setArtifactData(artifact, sourceArtifact); + if (oldFileTags != artifact->fileTags() + || oldModuleProperties != artifact->properties->value()) { + invalidateArtifactAsRuleInputIfNecessary(artifact); + } +} + +void insertArtifact(const ResolvedProductPtr &product, Artifact *artifact) +{ + qCDebug(lcBuildGraph) << "insert artifact" << artifact->filePath(); + QBS_CHECK(!artifact->product); + QBS_CHECK(!artifact->filePath().isEmpty()); + artifact->product = product; + product->topLevelProject()->buildData->insertIntoLookupTable(artifact); + product->buildData->addArtifact(artifact); +} + +void provideFullFileTagsAndProperties(Artifact *artifact) +{ + artifact->properties = artifact->product->moduleProperties; + FileTags allTags = artifact->pureFileTags.empty() + ? artifact->product->fileTagsForFileName(artifact->fileName()) : artifact->pureFileTags; + for (const auto &props : artifact->product->artifactProperties) { + if (allTags.intersects(props->fileTagsFilter())) { + artifact->properties = props->propertyMap(); + allTags += props->extraFileTags(); + break; + } + } + artifact->setFileTags(allTags); + + // Let a positive value of qbs.install imply the file tag "installable". + if (artifact->properties->qbsPropertyValue(StringConstants::installProperty()).toBool()) + artifact->addFileTag("installable"); +} + +void applyPerArtifactProperties(Artifact *artifact) +{ + if (artifact->pureProperties.empty()) + return; + QVariantMap props = artifact->properties->value(); + for (const auto &property : artifact->pureProperties) + setConfigProperty(props, property.first, property.second); + artifact->properties = artifact->properties->clone(); + artifact->properties->setValue(props); +} + +void updateGeneratedArtifacts(ResolvedProduct *product) +{ + if (!product->buildData) + return; + for (Artifact * const artifact : filterByType(product->buildData->allNodes())) { + if (artifact->artifactType == Artifact::Generated) { + const FileTags oldFileTags = artifact->fileTags(); + const QVariantMap oldModuleProperties = artifact->properties->value(); + provideFullFileTagsAndProperties(artifact); + applyPerArtifactProperties(artifact); + if (oldFileTags != artifact->fileTags() + || oldModuleProperties != artifact->properties->value()) { + invalidateArtifactAsRuleInputIfNecessary(artifact); + } + } + } +} + +// This is needed for artifacts which are inputs to rules whose outputArtifacts script +// returned an empty array for this input. Since there is no transformer, our usual change +// tracking procedure will not notice if the artifact's file tags or module properties have +// changed, so we need to force a re-run of the outputArtifacts script. +void invalidateArtifactAsRuleInputIfNecessary(Artifact *artifact) +{ + for (RuleNode * const parentRuleNode : filterByType(artifact->parents)) { + if (!parentRuleNode->rule()->isDynamic()) + continue; + bool artifactNeedsExplicitInvalidation = true; + for (Artifact * const output : filterByType(parentRuleNode->parents)) { + if (output->children.contains(artifact) + && !output->childrenAddedByScanner.contains(artifact)) { + artifactNeedsExplicitInvalidation = false; + break; + } + } + if (artifactNeedsExplicitInvalidation) + parentRuleNode->removeOldInputArtifact(artifact); + } +} + +static void doSanityChecksForProduct(const ResolvedProductConstPtr &product, + const Set &allProducts, const Logger &logger) +{ + qCDebug(lcBuildGraph) << "Sanity checking product" << product->uniqueName(); + CycleDetector cycleDetector(logger); + cycleDetector.visitProduct(product); + const ProductBuildData * const buildData = product->buildData.get(); + for (const auto &m : product->modules) + QBS_CHECK(m->product == product.get()); + qCDebug(lcBuildGraph) << "enabled:" << product->enabled << "build data:" << buildData; + if (product->enabled) + QBS_CHECK(buildData); + if (!product->buildData) + return; + for (BuildGraphNode * const node : qAsConst(buildData->rootNodes())) { + qCDebug(lcBuildGraph).noquote() << "Checking root node" << node->toString(); + QBS_CHECK(buildData->allNodes().contains(node)); + } + Set filePaths; + for (BuildGraphNode * const node : qAsConst(buildData->allNodes())) { + qCDebug(lcBuildGraph).noquote() << "Sanity checking node" << node->toString(); + QBS_CHECK(node->product == product); + for (const BuildGraphNode * const parent : qAsConst(node->parents)) + QBS_CHECK(parent->children.contains(node)); + for (BuildGraphNode * const child : qAsConst(node->children)) { + QBS_CHECK(child->parents.contains(node)); + QBS_CHECK(!child->product.expired()); + QBS_CHECK(child->product->buildData); + QBS_CHECK(child->product->buildData->allNodes().contains(child)); + QBS_CHECK(allProducts.contains(child->product.lock())); + } + + Artifact * const artifact = node->type() == BuildGraphNode::ArtifactNodeType + ? static_cast(node) : nullptr; + if (!artifact) { + QBS_CHECK(node->type() == BuildGraphNode::RuleNodeType); + auto const ruleNode = static_cast(node); + QBS_CHECK(ruleNode->rule()); + QBS_CHECK(ruleNode->rule()->product); + QBS_CHECK(ruleNode->rule()->product == ruleNode->product.get()); + QBS_CHECK(ruleNode->rule()->product == product.get()); + QBS_CHECK(contains(product->rules, std::const_pointer_cast(ruleNode->rule()))); + continue; + } + + QBS_CHECK(product->topLevelProject()->buildData->fileDependencies.contains( + artifact->fileDependencies)); + QBS_CHECK(artifact->artifactType == Artifact::SourceFile || + !filePaths.contains(artifact->filePath())); + filePaths << artifact->filePath(); + + for (Artifact * const child : qAsConst(artifact->childrenAddedByScanner)) + QBS_CHECK(artifact->children.contains(child)); + const TransformerConstPtr transformer = artifact->transformer; + if (artifact->artifactType == Artifact::SourceFile) + continue; + + const auto parentRuleNodes = filterByType(artifact->children); + QBS_CHECK(std::distance(parentRuleNodes.begin(), parentRuleNodes.end()) == 1); + + QBS_CHECK(transformer); + QBS_CHECK(transformer->rule); + QBS_CHECK(transformer->rule->product); + QBS_CHECK(transformer->rule->product == artifact->product.get()); + QBS_CHECK(transformer->rule->product == product.get()); + QBS_CHECK(transformer->outputs.contains(artifact)); + QBS_CHECK(contains(product->rules, std::const_pointer_cast(transformer->rule))); + qCDebug(lcBuildGraph) + << "The transformer has" << transformer->outputs.size() << "outputs."; + ArtifactSet transformerOutputChildren; + for (const Artifact * const output : qAsConst(transformer->outputs)) { + QBS_CHECK(output->transformer == transformer); + transformerOutputChildren.unite(ArtifactSet::filtered(output->children)); + for (const Artifact *a : filterByType(output->children)) { + for (const Artifact *other : filterByType(output->children)) { + if (other != a && other->filePath() == a->filePath() + && (other->artifactType != Artifact::SourceFile + || a->artifactType != Artifact::SourceFile + || other->product == a->product)) { + throw ErrorInfo(QStringLiteral("There is more than one artifact for " + "file '%1' in the child list for output '%2'.") + .arg(a->filePath(), output->filePath()), CodeLocation(), true); + } + } + } + } + if (lcBuildGraph().isDebugEnabled()) { + qCDebug(lcBuildGraph) << "The transformer output children are:"; + for (const Artifact * const a : qAsConst(transformerOutputChildren)) + qCDebug(lcBuildGraph) << "\t" << a->fileName(); + qCDebug(lcBuildGraph) << "The transformer inputs are:"; + for (const Artifact * const a : qAsConst(transformer->inputs)) + qCDebug(lcBuildGraph) << "\t" << a->fileName(); + } + QBS_CHECK(transformer->inputs.size() <= transformerOutputChildren.size()); + for (Artifact * const transformerInput : qAsConst(transformer->inputs)) + QBS_CHECK(transformerOutputChildren.contains(transformerInput)); + transformer->artifactsMapRequestedInPrepareScript.doSanityChecks(); + transformer->artifactsMapRequestedInCommands.doSanityChecks(); + } +} + +static void doSanityChecks(const ResolvedProjectPtr &project, + const Set &allProducts, Set &productNames, + const Logger &logger) +{ + logger.qbsDebug() << "Sanity checking project '" << project->name << "'"; + for (const ResolvedProjectPtr &subProject : qAsConst(project->subProjects)) + doSanityChecks(subProject, allProducts, productNames, logger); + + for (const auto &product : project->products) { + QBS_CHECK(product->project == project); + QBS_CHECK(product->topLevelProject() == project->topLevelProject()); + doSanityChecksForProduct(product, allProducts, logger); + QBS_CHECK(!productNames.contains(product->uniqueName())); + productNames << product->uniqueName(); + } +} + +void doSanityChecks(const ResolvedProjectPtr &project, const Logger &logger) +{ + if (qEnvironmentVariableIsEmpty("QBS_SANITY_CHECKS")) + return; + Set productNames; + const auto allProducts = rangeTo>(project->allProducts()); + doSanityChecks(project, allProducts, productNames, logger); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/buildgraph.h b/src/lib/corelib/buildgraph/buildgraph.h new file mode 100644 index 00000000..2909b06b --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraph.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_BUILDGRAPH_H +#define QBS_BUILDGRAPH_H + +#include "forward_decls.h" +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { +class BuildGraphNode; +class Logger; +class ScriptEngine; +class PrepareScriptObserver; + +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, + const ProjectBuildData *projectBuildData, + const QString &dirPath, const QString &fileName, + bool compareByName = false); +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const QString &dirPath, + const QString &fileName, bool compareByName = false); +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const ProjectBuildData *buildData, + const QString &filePath, bool compareByName = false); +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const QString &filePath, + bool compareByName = false); +Artifact *lookupArtifact(const ResolvedProductConstPtr &product, const Artifact *artifact, + bool compareByName); + +Artifact *createArtifact(const ResolvedProductPtr &product, + const SourceArtifactConstPtr &sourceArtifact); +void setArtifactData(Artifact *artifact, const SourceArtifactConstPtr &sourceArtifact); +void updateArtifactFromSourceArtifact(const ResolvedProductPtr &product, + const SourceArtifactConstPtr &sourceArtifact); +void insertArtifact(const ResolvedProductPtr &product, Artifact *artifact); +void dumpProductBuildData(const ResolvedProductConstPtr &product); +void provideFullFileTagsAndProperties(Artifact *artifact); +void applyPerArtifactProperties(Artifact *artifact); +void updateGeneratedArtifacts(ResolvedProduct *product); +void invalidateArtifactAsRuleInputIfNecessary(Artifact *artifact); + +bool findPath(BuildGraphNode *u, BuildGraphNode *v, QList &path); +void QBS_AUTOTEST_EXPORT connect(BuildGraphNode *p, BuildGraphNode *c); +bool safeConnect(Artifact *u, Artifact *v); +void removeGeneratedArtifactFromDisk(Artifact *artifact, const Logger &logger); +void removeGeneratedArtifactFromDisk(const QString &filePath, const Logger &logger); + +void disconnect(BuildGraphNode *u, BuildGraphNode *v); + +void setupScriptEngineForFile(ScriptEngine *engine, const FileContextBaseConstPtr &fileContext, + QScriptValue targetObject, const ObserveMode &observeMode); +void setupScriptEngineForProduct(ScriptEngine *engine, ResolvedProduct *product, + const ResolvedModule *module, QScriptValue targetObject, + bool setBuildEnvironment); +QString relativeArtifactFileName(const Artifact *artifact); // Debugging helpers + +void doSanityChecks(const ResolvedProjectPtr &project, const Logger &logger); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILDGRAPH_H diff --git a/src/lib/corelib/buildgraph/buildgraph.pri b/src/lib/corelib/buildgraph/buildgraph.pri new file mode 100644 index 00000000..2ed6be4f --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraph.pri @@ -0,0 +1,89 @@ +include(../../../install_prefix.pri) + +SOURCES += \ + $$PWD/abstractcommandexecutor.cpp \ + $$PWD/artifact.cpp \ + $$PWD/artifactcleaner.cpp \ + $$PWD/artifactsscriptvalue.cpp \ + $$PWD/artifactvisitor.cpp \ + $$PWD/buildgraph.cpp \ + $$PWD/buildgraphloader.cpp \ + $$PWD/buildgraphnode.cpp \ + $$PWD/cycledetector.cpp \ + $$PWD/dependencyparametersscriptvalue.cpp \ + $$PWD/depscanner.cpp \ + $$PWD/emptydirectoriesremover.cpp \ + $$PWD/environmentscriptrunner.cpp \ + $$PWD/executor.cpp \ + $$PWD/executorjob.cpp \ + $$PWD/filedependency.cpp \ + $$PWD/inputartifactscanner.cpp \ + $$PWD/jscommandexecutor.cpp \ + $$PWD/nodeset.cpp \ + $$PWD/nodetreedumper.cpp \ + $$PWD/processcommandexecutor.cpp \ + $$PWD/productbuilddata.cpp \ + $$PWD/productinstaller.cpp \ + $$PWD/projectbuilddata.cpp \ + $$PWD/qtmocscanner.cpp \ + $$PWD/rawscanneddependency.cpp \ + $$PWD/rawscanresults.cpp \ + $$PWD/requestedartifacts.cpp \ + $$PWD/requesteddependencies.cpp \ + $$PWD/rulecommands.cpp \ + $$PWD/rulegraph.cpp \ + $$PWD/rulenode.cpp \ + $$PWD/rulesapplicator.cpp \ + $$PWD/rulesevaluationcontext.cpp \ + $$PWD/timestampsupdater.cpp \ + $$PWD/transformerchangetracking.cpp \ + $$PWD/transformer.cpp + +HEADERS += \ + $$PWD/abstractcommandexecutor.h \ + $$PWD/artifact.h \ + $$PWD/artifactcleaner.h \ + $$PWD/artifactsscriptvalue.h \ + $$PWD/artifactvisitor.h \ + $$PWD/buildgraph.h \ + $$PWD/buildgraphloader.h \ + $$PWD/buildgraphnode.h \ + $$PWD/buildgraphvisitor.h \ + $$PWD/cycledetector.h \ + $$PWD/dependencyparametersscriptvalue.h \ + $$PWD/depscanner.h \ + $$PWD/emptydirectoriesremover.h \ + $$PWD/environmentscriptrunner.h \ + $$PWD/executor.h \ + $$PWD/executorjob.h \ + $$PWD/filedependency.h \ + $$PWD/forward_decls.h \ + $$PWD/inputartifactscanner.h \ + $$PWD/jscommandexecutor.h \ + $$PWD/nodeset.h \ + $$PWD/nodetreedumper.h \ + $$PWD/processcommandexecutor.h \ + $$PWD/productbuilddata.h \ + $$PWD/productinstaller.h \ + $$PWD/projectbuilddata.h \ + $$PWD/qtmocscanner.h \ + $$PWD/rawscanneddependency.h \ + $$PWD/rawscanresults.h \ + $$PWD/requestedartifacts.h \ + $$PWD/requesteddependencies.h \ + $$PWD/rescuableartifactdata.h \ + $$PWD/rulecommands.h \ + $$PWD/rulegraph.h \ + $$PWD/rulenode.h \ + $$PWD/rulesapplicator.h \ + $$PWD/rulesevaluationcontext.h \ + $$PWD/scriptclasspropertyiterator.h \ + $$PWD/timestampsupdater.h \ + $$PWD/transformerchangetracking.h \ + $$PWD/transformer.h + +!qbs_no_dev_install { + buildgraph_headers.files = $$PWD/forward_decls.h + buildgraph_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/buildgraph + INSTALLS += buildgraph_headers +} diff --git a/src/lib/corelib/buildgraph/buildgraphloader.cpp b/src/lib/corelib/buildgraph/buildgraphloader.cpp new file mode 100644 index 00000000..9d65f42e --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraphloader.cpp @@ -0,0 +1,983 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "buildgraphloader.h" + +#include "buildgraph.h" +#include "cycledetector.h" +#include "emptydirectoriesremover.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "rulenode.h" +#include "rulecommands.h" +#include "rulesevaluationcontext.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +BuildGraphLoader::BuildGraphLoader(Logger logger) : + m_logger(std::move(logger)) +{ +} + +BuildGraphLoader::~BuildGraphLoader() +{ + qDeleteAll(m_objectsToDelete); +} + +static void restoreBackPointers(const ResolvedProjectPtr &project) +{ + for (const ResolvedProductPtr &product : project->products) { + product->project = project; + if (!product->buildData) + continue; + for (BuildGraphNode * const n : qAsConst(product->buildData->allNodes())) { + if (n->type() == BuildGraphNode::ArtifactNodeType) { + project->topLevelProject()->buildData + ->insertIntoLookupTable(static_cast(n)); + } + } + } + + for (const ResolvedProjectPtr &subProject : qAsConst(project->subProjects)) { + subProject->parentProject = project; + restoreBackPointers(subProject); + } +} + +BuildGraphLoadResult BuildGraphLoader::load(const TopLevelProjectPtr &existingProject, + const SetupProjectParameters ¶meters, + const RulesEvaluationContextPtr &evalContext) +{ + m_parameters = parameters; + m_result = BuildGraphLoadResult(); + m_evalContext = evalContext; + + if (existingProject) { + QBS_CHECK(existingProject->buildData); + existingProject->buildData->evaluationContext = evalContext; + if (!checkBuildGraphCompatibility(existingProject)) + return m_result; + m_result.loadedProject = existingProject; + } else { + loadBuildGraphFromDisk(); + } + if (!m_result.loadedProject) + return m_result; + if (parameters.restoreBehavior() == SetupProjectParameters::RestoreOnly) { + for (const ErrorInfo &e : qAsConst(m_result.loadedProject->warningsEncountered)) + m_logger.printWarning(e); + return m_result; + } + QBS_CHECK(parameters.restoreBehavior() == SetupProjectParameters::RestoreAndTrackChanges); + + if (m_parameters.logElapsedTime()) { + m_wildcardExpansionEffort = 0; + m_propertyComparisonEffort = 0; + } + trackProjectChanges(); + if (m_parameters.logElapsedTime()) { + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Wildcard expansion took %1.") + .arg(elapsedTimeString(m_wildcardExpansionEffort)); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Comparing property values took %1.") + .arg(elapsedTimeString(m_propertyComparisonEffort)); + } + return m_result; +} + +TopLevelProjectConstPtr BuildGraphLoader::loadProject(const QString &bgFilePath) +{ + class LogSink : public ILogSink { + void doPrintMessage(LoggerLevel, const QString &, const QString &) override { } + } dummySink; + Logger dummyLogger(&dummySink); + BuildGraphLocker bgLocker(bgFilePath, dummyLogger, false, nullptr); + PersistentPool pool(dummyLogger); + pool.load(bgFilePath); + const TopLevelProjectPtr project = TopLevelProject::create(); + project->load(pool); + project->setBuildConfiguration(pool.headData().projectConfig); + return project; +} + +void BuildGraphLoader::loadBuildGraphFromDisk() +{ + const QString projectId = TopLevelProject::deriveId(m_parameters.finalBuildConfigurationTree()); + const QString buildDir + = TopLevelProject::deriveBuildDirectory(m_parameters.buildRoot(), projectId); + const QString buildGraphFilePath + = ProjectBuildData::deriveBuildGraphFilePath(buildDir, projectId); + + PersistentPool pool(m_logger); + qCDebug(lcBuildGraph) << "trying to load:" << buildGraphFilePath; + try { + pool.load(buildGraphFilePath); + } catch (const NoBuildGraphError &) { + if (m_parameters.restoreBehavior() == SetupProjectParameters::RestoreOnly) + throw; + m_logger.qbsInfo() + << Tr::tr("Build graph does not yet exist for configuration '%1'. " + "Starting from scratch.").arg(m_parameters.configurationName()); + return; + } catch (const ErrorInfo &loadError) { + if (!m_parameters.overrideBuildGraphData()) { + ErrorInfo fullError = loadError; + fullError.append(Tr::tr("Use the 'resolve' command to set up a new build graph.")); + throw fullError; + } + m_logger.qbsWarning() << loadError.toString(); + return; + } + + const TopLevelProjectPtr project = TopLevelProject::create(); + + // TODO: Store some meta data that will enable us to show actual progress (e.g. number of products). + m_evalContext->initializeObserver(Tr::tr("Restoring build graph from disk"), 1); + + project->load(pool); + project->buildData->evaluationContext = m_evalContext; + project->setBuildConfiguration(pool.headData().projectConfig); + project->buildDirectory = buildDir; + if (!checkBuildGraphCompatibility(project)) + return; + restoreBackPointers(project); + project->buildData->setClean(); + project->location = CodeLocation(m_parameters.projectFilePath(), project->location.line(), + project->location.column()); + m_result.loadedProject = project; + m_evalContext->incrementProgressValue(); + doSanityChecks(project, m_logger); +} + +bool BuildGraphLoader::checkBuildGraphCompatibility(const TopLevelProjectConstPtr &project) +{ + if (m_parameters.projectFilePath().isEmpty()) + m_parameters.setProjectFilePath(project->location.filePath()); + else + Loader::setupProjectFilePath(m_parameters); + if (QFileInfo(project->location.filePath()) == QFileInfo(m_parameters.projectFilePath())) + return true; + QString message = Tr::tr("Stored build graph at '%1' is for project file '%2', but " + "input file is '%3'.") + .arg(QDir::toNativeSeparators(project->buildGraphFilePath()), + QDir::toNativeSeparators(project->location.filePath()), + QDir::toNativeSeparators(m_parameters.projectFilePath())); + if (m_parameters.overrideBuildGraphData()) { + m_logger.qbsInfo() << message; + return false; + } + message.append(QLatin1Char('\n')).append(Tr::tr("Use the 'resolve' command to enforce " + "using a different project file.")); + throw ErrorInfo(message); +} + +static bool checkProductForChangedDependency(std::vector &changedProducts, + Set &seenProducts, const ResolvedProductPtr &product) +{ + if (seenProducts.contains(product)) + return false; + if (contains(changedProducts, product)) + return true; + for (const ResolvedProductPtr &dep : qAsConst(product->dependencies)) { + if (checkProductForChangedDependency(changedProducts, seenProducts, dep)) { + changedProducts << product; + return true; + } + } + seenProducts << product; + return false; +} + +// All products depending on changed products also become changed. Otherwise the output +// artifacts of the rules taking the artifacts from the dependency as inputs will be +// rebuilt due to their rule getting re-applied (as the rescued input artifacts will show +// up as newly added) and no rescue data being available. +static void makeChangedProductsListComplete(std::vector &changedProducts, + const std::vector &allRestoredProducts) +{ + Set seenProducts; + for (const ResolvedProductPtr &p : allRestoredProducts) + checkProductForChangedDependency(changedProducts, seenProducts, p); +} + +static void updateProductAndRulePointers(const ResolvedProductPtr &newProduct) +{ + std::unordered_map ruleMap; + for (BuildGraphNode *node : qAsConst(newProduct->buildData->allNodes())) { + node->product = newProduct; + const auto findNewRule = [&ruleMap, &newProduct] + (const RuleConstPtr &oldRule) -> RuleConstPtr { + const auto it = ruleMap.find(oldRule); + if (it != ruleMap.cend()) + return it->second; + for (const auto &r : qAsConst(newProduct->rules)) { + if (*r == *oldRule) { + ruleMap.insert(std::make_pair(oldRule, r)); + return r; + } + } + QBS_CHECK(false); + return {}; + }; + if (node->type() == BuildGraphNode::RuleNodeType) { + const auto ruleNode = static_cast(node); + ruleNode->setRule(findNewRule(ruleNode->rule())); + } else { + QBS_CHECK(node->type() == BuildGraphNode::ArtifactNodeType); + const auto artifact = static_cast(node); + if (artifact->artifactType == Artifact::Generated) { + QBS_CHECK(artifact->transformer); + artifact->transformer->rule = findNewRule(artifact->transformer->rule); + } + } + } +} + +void BuildGraphLoader::trackProjectChanges() +{ + TimedActivityLogger trackingTimer(m_logger, Tr::tr("Change tracking"), + m_parameters.logElapsedTime()); + const TopLevelProjectPtr &restoredProject = m_result.loadedProject; + Set buildSystemFiles = restoredProject->buildSystemFiles; + std::vector allRestoredProducts = restoredProject->allProducts(); + std::vector changedProducts; + bool reResolvingNecessary = false; + if (!checkConfigCompatibility()) + reResolvingNecessary = true; + if (hasProductFileChanged(allRestoredProducts, restoredProject->lastStartResolveTime, + buildSystemFiles, changedProducts)) { + reResolvingNecessary = true; + } + + // "External" changes, e.g. in the environment or in a JavaScript file, + // can make the list of source files in a product change without the respective file + // having been touched. In such a case, the build data for that product will have to be set up + // anew. + if (probeExecutionForced(restoredProject, allRestoredProducts) + || hasBuildSystemFileChanged(buildSystemFiles, restoredProject.get()) + || hasEnvironmentChanged(restoredProject) + || hasCanonicalFilePathResultChanged(restoredProject) + || hasFileExistsResultChanged(restoredProject) + || hasDirectoryEntriesResultChanged(restoredProject) + || hasFileLastModifiedResultChanged(restoredProject)) { + reResolvingNecessary = true; + } + + if (!reResolvingNecessary) { + for (const ErrorInfo &e : qAsConst(restoredProject->warningsEncountered)) + m_logger.printWarning(e); + return; + } + + restoredProject->buildData->setDirty(); + markTransformersForChangeTracking(allRestoredProducts); + if (!m_parameters.overrideBuildGraphData()) + m_parameters.setEnvironment(restoredProject->environment); + Loader ldr(m_evalContext->engine(), m_logger); + ldr.setSearchPaths(m_parameters.searchPaths()); + ldr.setProgressObserver(m_evalContext->observer()); + ldr.setOldProjectProbes(restoredProject->probes); + if (!m_parameters.forceProbeExecution()) + ldr.setStoredModuleProviderInfo(restoredProject->moduleProviderInfo); + ldr.setLastResolveTime(restoredProject->lastStartResolveTime); + QHash> restoredProbes; + for (const auto &restoredProduct : qAsConst(allRestoredProducts)) + restoredProbes.insert(restoredProduct->uniqueName(), restoredProduct->probes); + ldr.setOldProductProbes(restoredProbes); + if (!m_parameters.overrideBuildGraphData()) + ldr.setStoredProfiles(restoredProject->profileConfigs); + m_result.newlyResolvedProject = ldr.loadProject(m_parameters); + + std::vector allNewlyResolvedProducts + = m_result.newlyResolvedProject->allProducts(); + for (const ResolvedProductPtr &cp : qAsConst(allNewlyResolvedProducts)) + m_freshProductsByName.insert(cp->uniqueName(), cp); + + checkAllProductsForChanges(allRestoredProducts, changedProducts); + + std::shared_ptr oldBuildData; + ChildListHash childLists; + if (!changedProducts.empty()) { + oldBuildData = std::make_shared(restoredProject->buildData.get()); + for (const auto &product : qAsConst(allRestoredProducts)) { + if (!product->buildData) + continue; + + // If the product gets temporarily removed, its artifacts will get disconnected + // and this structural information will no longer be directly available from them. + for (const Artifact *a : filterByType(product->buildData->allNodes())) { + childLists.insert(a, ChildrenInfo(ArtifactSet::filtered(a->children), + a->childrenAddedByScanner)); + } + } + } + + makeChangedProductsListComplete(changedProducts, allRestoredProducts); + + // Set up build data from scratch for all changed products. This does not necessarily + // mean that artifacts will have to get rebuilt; whether this is necesessary will be decided + // an a per-artifact basis by the Executor on the next build. + QHash rescuableArtifactData; + for (const ResolvedProductPtr &product : qAsConst(changedProducts)) { + const QString name = product->uniqueName(); + m_changedSourcesByProduct.erase(name); + m_productsWhoseArtifactsNeedUpdate.remove(name); + ResolvedProductPtr freshProduct = m_freshProductsByName.value(name); + if (!freshProduct) + continue; + onProductRemoved(product, product->topLevelProject()->buildData.get(), false); + if (product->buildData) { + rescuableArtifactData.insert(product->uniqueName(), + product->buildData->rescuableArtifactData()); + } + removeOne(allRestoredProducts, product); + } + + // Move over restored build data to newly resolved project. + m_result.newlyResolvedProject->buildData.swap(restoredProject->buildData); + QBS_CHECK(m_result.newlyResolvedProject->buildData); + m_result.newlyResolvedProject->buildData->setDirty(); + + for (auto it = allNewlyResolvedProducts.begin(); it != allNewlyResolvedProducts.end();) { + const ResolvedProductPtr &newlyResolvedProduct = *it; + auto k = std::find_if(allRestoredProducts.begin(), allRestoredProducts.end(), + [&newlyResolvedProduct](const ResolvedProductPtr &restoredProduct) { + return newlyResolvedProduct->uniqueName() == restoredProduct->uniqueName(); + }); + if (k == allRestoredProducts.end()) { + ++it; + } else { + const ResolvedProductPtr &restoredProduct = *k; + if (newlyResolvedProduct->enabled) + newlyResolvedProduct->buildData.swap(restoredProduct->buildData); + if (newlyResolvedProduct->buildData) + updateProductAndRulePointers(newlyResolvedProduct); + + // Keep in list if build data still needs to be resolved. + if (!newlyResolvedProduct->enabled || newlyResolvedProduct->buildData) + it = allNewlyResolvedProducts.erase(it); + + allRestoredProducts.erase(k); + } + } + + // Products still left in the list do not exist anymore. + for (const ResolvedProductPtr &removedProduct : qAsConst(allRestoredProducts)) { + removeOne(changedProducts, removedProduct); + onProductRemoved(removedProduct, m_result.newlyResolvedProject->buildData.get()); + } + + // Products still left in the list need resolving, either because they are new + // or because they are newly enabled. + if (!allNewlyResolvedProducts.empty()) { + BuildDataResolver bpr(m_logger); + bpr.resolveProductBuildDataForExistingProject(m_result.newlyResolvedProject, + allNewlyResolvedProducts); + } + + for (const auto &kv : m_changedSourcesByProduct) { + const ResolvedProductPtr product = m_freshProductsByName.value(kv.first); + QBS_CHECK(!!product); + for (const SourceArtifactConstPtr &sa : kv.second) + updateArtifactFromSourceArtifact(product, sa); + } + + for (const QString &productName : m_productsWhoseArtifactsNeedUpdate) { + const ResolvedProductPtr product = m_freshProductsByName.value(productName); + QBS_CHECK(!!product); + updateGeneratedArtifacts(product.get()); + } + + for (const auto &changedProduct : qAsConst(changedProducts)) { + rescueOldBuildData(changedProduct, + m_freshProductsByName.value(changedProduct->uniqueName()), + childLists, rescuableArtifactData.value(changedProduct->uniqueName())); + } + + EmptyDirectoriesRemover(m_result.newlyResolvedProject.get(), m_logger) + .removeEmptyParentDirectories(m_artifactsRemovedFromDisk); + + for (FileResourceBase * const f : qAsConst(m_objectsToDelete)) { + if (f->fileType() == FileResourceBase::FileTypeArtifact) + static_cast(f)->product.reset(); // To help with the sanity checks. + } + doSanityChecks(m_result.newlyResolvedProject, m_logger); +} + +bool BuildGraphLoader::probeExecutionForced( + const TopLevelProjectConstPtr &restoredProject, + const std::vector &restoredProducts) const +{ + if (!m_parameters.forceProbeExecution()) + return false; + + if (!restoredProject->probes.empty()) + return true; + + return Internal::any_of(restoredProducts, [](const auto &p) { + return !p->probes.empty(); + }); +} + +bool BuildGraphLoader::hasEnvironmentChanged(const TopLevelProjectConstPtr &restoredProject) const +{ + if (!m_parameters.overrideBuildGraphData()) + return false; + QProcessEnvironment oldEnv = restoredProject->environment; + QProcessEnvironment newEnv = m_parameters.adjustedEnvironment(); + + static const QString ldPreloadEnvVar = QStringLiteral("LD_PRELOAD"); + // HACK. Valgrind screws up our null-build benchmarker otherwise. + // TODO: Think about a (module-provided) whitelist. + oldEnv.remove(ldPreloadEnvVar); + newEnv.remove(ldPreloadEnvVar); + + if (oldEnv != newEnv) { + qCDebug(lcBuildGraph) << "Set of environment variables changed. Must re-resolve project." + << "\nold:" << restoredProject->environment.toStringList() + << "\nnew:" << m_parameters.adjustedEnvironment().toStringList(); + return true; + } + return false; +} + +bool BuildGraphLoader::hasCanonicalFilePathResultChanged(const TopLevelProjectConstPtr &restoredProject) const +{ + for (auto it = restoredProject->canonicalFilePathResults.constBegin(); + it != restoredProject->canonicalFilePathResults.constEnd(); ++it) { + if (QFileInfo(it.key()).canonicalFilePath() != it.value()) { + qCDebug(lcBuildGraph) << "Canonical file path for file" << it.key() + << "changed, must re-resolve project."; + return true; + } + } + + return false; +} + +bool BuildGraphLoader::hasFileExistsResultChanged(const TopLevelProjectConstPtr &restoredProject) const +{ + for (QHash::ConstIterator it = restoredProject->fileExistsResults.constBegin(); + it != restoredProject->fileExistsResults.constEnd(); ++it) { + if (FileInfo(it.key()).exists() != it.value()) { + qCDebug(lcBuildGraph) << "Existence check for file" << it.key() + << "changed, must re-resolve project."; + return true; + } + } + + return false; +} + +bool BuildGraphLoader::hasDirectoryEntriesResultChanged(const TopLevelProjectConstPtr &restoredProject) const +{ + for (auto it = restoredProject->directoryEntriesResults.constBegin(); + it != restoredProject->directoryEntriesResults.constEnd(); ++it) { + if (QDir(it.key().first).entryList(static_cast(it.key().second), QDir::Name) + != it.value()) { + qCDebug(lcBuildGraph) << "Entry list for directory" << it.key().first + << static_cast(it.key().second) + << "changed, must re-resolve project."; + return true; + } + } + + return false; +} + +bool BuildGraphLoader::hasFileLastModifiedResultChanged(const TopLevelProjectConstPtr &restoredProject) const +{ + for (QHash::ConstIterator it + = restoredProject->fileLastModifiedResults.constBegin(); + it != restoredProject->fileLastModifiedResults.constEnd(); ++it) { + if (FileInfo(it.key()).lastModified() != it.value()) { + qCDebug(lcBuildGraph) << "Timestamp for file" << it.key() + << "changed, must re-resolve project."; + return true; + } + } + + return false; +} + +bool BuildGraphLoader::hasProductFileChanged(const std::vector &restoredProducts, + const FileTime &referenceTime, Set &remainingBuildSystemFiles, + std::vector &changedProducts) +{ + bool hasChanged = false; + for (const ResolvedProductPtr &product : restoredProducts) { + const QString filePath = product->location.filePath(); + const FileInfo pfi(filePath); + remainingBuildSystemFiles.remove(filePath); + if (!pfi.exists()) { + qCDebug(lcBuildGraph) << "A product was removed, must re-resolve project"; + hasChanged = true; + } else if (referenceTime < pfi.lastModified()) { + qCDebug(lcBuildGraph) << "A product was changed, must re-resolve project"; + hasChanged = true; + } else if (!contains(changedProducts, product)) { + bool foundMissingSourceFile = false; + for (const QString &file : qAsConst(product->missingSourceFiles)) { + if (FileInfo(file).exists()) { + qCDebug(lcBuildGraph) << "Formerly missing file" << file << "in product" + << product->name << "exists now, must re-resolve project"; + foundMissingSourceFile = true; + break; + } + } + if (foundMissingSourceFile) { + hasChanged = true; + changedProducts.push_back(product); + continue; + } + + AccumulatingTimer wildcardTimer(m_parameters.logElapsedTime() + ? &m_wildcardExpansionEffort : nullptr); + for (const GroupPtr &group : product->groups) { + if (!group->wildcards) + continue; + const bool reExpansionRequired = Internal::any_of(group->wildcards->dirTimeStamps, + [](const std::pair &pair) { + return FileInfo(pair.first).lastModified() > pair.second; + }); + if (!reExpansionRequired) + continue; + const Set files = group->wildcards->expandPatterns(group, + FileInfo::path(group->location.filePath()), + product->topLevelProject()->buildDirectory); + Set wcFiles; + for (const auto &sourceArtifact : group->wildcards->files) + wcFiles += sourceArtifact->absoluteFilePath; + if (files == wcFiles) + continue; + hasChanged = true; + changedProducts.push_back(product); + break; + } + } + } + + return hasChanged; +} + +bool BuildGraphLoader::hasBuildSystemFileChanged(const Set &buildSystemFiles, + const TopLevelProject *restoredProject) +{ + for (const QString &file : buildSystemFiles) { + const FileInfo fi(file); + if (!fi.exists()) { + qCDebug(lcBuildGraph) << "Project file" << file + << "no longer exists, must re-resolve project."; + return true; + } + const auto generatedChecker = [&file, restoredProject](const ModuleProviderInfo &mpi) { + return file.startsWith(mpi.outputDirPath(restoredProject->buildDirectory)); + }; + const bool fileWasCreatedByModuleProvider = + any_of(restoredProject->moduleProviderInfo.providers, generatedChecker); + const FileTime referenceTime = fileWasCreatedByModuleProvider + ? restoredProject->lastEndResolveTime : restoredProject->lastStartResolveTime; + if (referenceTime < fi.lastModified()) { + qCDebug(lcBuildGraph) << "Project file" << file << "changed, must re-resolve project."; + return true; + } + } + return false; +} + +void BuildGraphLoader::markTransformersForChangeTracking( + const std::vector &restoredProducts) +{ + for (const ResolvedProductPtr &product : restoredProducts) { + if (!product->buildData) + continue; + for (Artifact * const artifact : filterByType(product->buildData->allNodes())) { + if (artifact->transformer) { + artifact->transformer->prepareScriptNeedsChangeTracking = true; + artifact->transformer->commandsNeedChangeTracking = true; + } + } + } +} + +void BuildGraphLoader::checkAllProductsForChanges( + const std::vector &restoredProducts, + std::vector &changedProducts) +{ + for (const ResolvedProductPtr &restoredProduct : restoredProducts) { + const ResolvedProductPtr newlyResolvedProduct + = m_freshProductsByName.value(restoredProduct->uniqueName()); + if (!newlyResolvedProduct) + continue; + if (newlyResolvedProduct->enabled != restoredProduct->enabled) { + qCDebug(lcBuildGraph) << "Condition of product" << restoredProduct->uniqueName() + << "was changed, must set up build data from scratch"; + if (!contains(changedProducts, restoredProduct)) + changedProducts << restoredProduct; + continue; + } + + if (checkProductForChanges(restoredProduct, newlyResolvedProduct)) { + qCDebug(lcBuildGraph) << "Product" << restoredProduct->uniqueName() + << "was changed, must set up build data from scratch"; + if (!contains(changedProducts, restoredProduct)) + changedProducts << restoredProduct; + continue; + } + + if (checkProductForChangesInSourceFiles(restoredProduct, newlyResolvedProduct)) { + qCDebug(lcBuildGraph) << "File list of product" << restoredProduct->uniqueName() + << "was changed."; + if (!contains(changedProducts, restoredProduct)) + changedProducts << restoredProduct; + } + } +} + +bool BuildGraphLoader::checkProductForChangesInSourceFiles( + const ResolvedProductPtr &restoredProduct, const ResolvedProductPtr &newlyResolvedProduct) +{ + std::vector oldFiles = restoredProduct->allEnabledFiles(); + std::vector newFiles = newlyResolvedProduct->allEnabledFiles(); + // TODO: Also handle added and removed files in a fine-grained manner. + if (oldFiles.size() != newFiles.size()) + return true; + static const auto cmp = [](const SourceArtifactConstPtr &a1, + const SourceArtifactConstPtr &a2) { + return a1->absoluteFilePath < a2->absoluteFilePath; + }; + std::sort(oldFiles.begin(), oldFiles.end(), cmp); + std::sort(newFiles.begin(), newFiles.end(), cmp); + std::vector changedFiles; + for (int i = 0; i < int(oldFiles.size()); ++i) { + const SourceArtifactConstPtr &oldFile = oldFiles.at(i); + const SourceArtifactConstPtr &newFile = newFiles.at(i); + if (oldFile->absoluteFilePath != newFile->absoluteFilePath) + return true; + if (*oldFile != *newFile) { + qCDebug(lcBuildGraph) << "source artifact" << oldFile->absoluteFilePath << "changed"; + changedFiles.push_back(newFile); + } + } + if (!changedFiles.empty()) { + m_changedSourcesByProduct.insert(std::make_pair(restoredProduct->uniqueName(), + changedFiles)); + } + return false; +} + +static bool dependenciesAreEqual(const ResolvedProductConstPtr &p1, + const ResolvedProductConstPtr &p2) +{ + if (p1->dependencies.size() != p2->dependencies.size()) + return false; + Set names1; + Set names2; + for (const auto &dep : qAsConst(p1->dependencies)) + names1 << dep->uniqueName(); + for (const auto &dep : qAsConst(p2->dependencies)) + names2 << dep->uniqueName(); + return names1 == names2; +} + +bool BuildGraphLoader::checkProductForChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct) +{ + // This check must come first, as it can prevent build data rescuing as a side effect. + // TODO: Similar special checks must be done for Environment.getEnv() and File.exists() in + // commands (or possibly it could be reasonable to just forbid such "dynamic" constructs + // within commands). + if (checkForPropertyChanges(restoredProduct, newlyResolvedProduct)) + return true; + if (!ruleListsAreEqual(restoredProduct->rules, newlyResolvedProduct->rules)) + return true; + if (!dependenciesAreEqual(restoredProduct, newlyResolvedProduct)) + return true; + return false; +} + +bool BuildGraphLoader::checkProductForInstallInfoChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct) +{ + // These are not requested from rules at build time, but we still need to take + // them into account. + const QStringList specialProperties = QStringList() << StringConstants::installProperty() + << StringConstants::installDirProperty() << StringConstants::installPrefixProperty() + << StringConstants::installRootProperty(); + for (const QString &key : specialProperties) { + if (restoredProduct->moduleProperties->qbsPropertyValue(key) + != newlyResolvedProduct->moduleProperties->qbsPropertyValue(key)) { + qCDebug(lcBuildGraph).noquote().nospace() + << "Product property 'qbs." << key << "' changed."; + return true; + } + } + return false; +} + +bool BuildGraphLoader::checkForPropertyChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct) +{ + AccumulatingTimer propertyComparisonTimer(m_parameters.logElapsedTime() + ? &m_propertyComparisonEffort: nullptr); + qCDebug(lcBuildGraph) << "Checking for changes in properties requested in prepare scripts for " + "product" << restoredProduct->uniqueName(); + if (!restoredProduct->buildData) + return false; + + if (restoredProduct->fileTags != newlyResolvedProduct->fileTags) { + qCDebug(lcBuildGraph) << "Product type changed from" << restoredProduct->fileTags + << "to" << newlyResolvedProduct->fileTags; + return true; + } + + if (checkProductForInstallInfoChanges(restoredProduct, newlyResolvedProduct)) + return true; + if (!artifactPropertyListsAreEqual(restoredProduct->artifactProperties, + newlyResolvedProduct->artifactProperties)) { + qCDebug(lcBuildGraph) << "a fileTagFilter group changed for product" + << restoredProduct->uniqueName(); + m_productsWhoseArtifactsNeedUpdate << restoredProduct->uniqueName(); + } + if (restoredProduct->moduleProperties != newlyResolvedProduct->moduleProperties) { + qCDebug(lcBuildGraph) << "module properties changed for product" + << restoredProduct->uniqueName(); + m_productsWhoseArtifactsNeedUpdate << restoredProduct->uniqueName(); + } + return false; +} + +void BuildGraphLoader::onProductRemoved(const ResolvedProductPtr &product, + ProjectBuildData *projectBuildData, bool removeArtifactsFromDisk) +{ + qCDebug(lcBuildGraph) << "product" << product->uniqueName() << "removed."; + + removeOne(product->project->products, product); + if (product->buildData) { + for (BuildGraphNode * const node : qAsConst(product->buildData->allNodes())) { + if (node->type() == BuildGraphNode::ArtifactNodeType) { + const auto artifact = static_cast(node); + projectBuildData->removeArtifact(artifact, m_logger, removeArtifactsFromDisk, + false); + if (removeArtifactsFromDisk && artifact->artifactType == Artifact::Generated) + m_artifactsRemovedFromDisk << artifact->filePath(); + } else { + for (BuildGraphNode * const parent : qAsConst(node->parents)) + parent->children.remove(node); + node->parents.clear(); + for (BuildGraphNode * const child : qAsConst(node->children)) + child->parents.remove(node); + node->children.clear(); + } + } + } +} + +void BuildGraphLoader::replaceFileDependencyWithArtifact(const ResolvedProductPtr &fileDepProduct, + FileDependency *filedep, Artifact *artifact) +{ + qCDebug(lcBuildGraph) << "replace file dependency" << filedep->filePath() + << "with artifact of type" << toString(artifact->artifactType); + for (const ResolvedProductPtr &product : fileDepProduct->topLevelProject()->allProducts()) { + if (!product->buildData) + continue; + for (Artifact *artifactInProduct : filterByType(product->buildData->allNodes())) { + if (artifactInProduct->fileDependencies.remove(filedep)) + connect(artifactInProduct, artifact); + } + } + fileDepProduct->topLevelProject()->buildData->fileDependencies.remove(filedep); + fileDepProduct->topLevelProject()->buildData->removeFromLookupTable(filedep); + m_objectsToDelete << filedep; +} + +bool BuildGraphLoader::checkConfigCompatibility() +{ + const TopLevelProjectConstPtr restoredProject = m_result.loadedProject; + if (m_parameters.topLevelProfile().isEmpty()) + m_parameters.setTopLevelProfile(restoredProject->profile()); + if (!m_parameters.overrideBuildGraphData()) { + if (!m_parameters.overriddenValues().empty() + && m_parameters.overriddenValues() != restoredProject->overriddenValues) { + const auto toUserOutput = [](const QVariantMap &propMap) { + QString o; + for (auto it = propMap.begin(); it != propMap.end(); ++it) { + if (!o.isEmpty()) + o += QLatin1Char(' '); + o.append(it.key()).append(QLatin1Char(':')).append(toJSLiteral(it.value())); + } + return o; + }; + throw ErrorInfo(Tr::tr("Property values set on the command line differ from the " + "ones used for the previous build.\n" + "Old property values: %1\n" + "New property values: %2\n" + "Use the 'resolve' command if " + "you really want to rebuild with the new properties.") + .arg(toUserOutput(restoredProject->overriddenValues), + toUserOutput(m_parameters.overriddenValues()))); + } + m_parameters.setOverriddenValues(restoredProject->overriddenValues); + if (m_parameters.topLevelProfile() != restoredProject->profile()) { + throw ErrorInfo(Tr::tr("The current profile is '%1', but profile '%2' was used " + "when last building for configuration '%3'. Use the " + "'resolve' command if you really want to rebuild with a " + "different profile.") + .arg(m_parameters.topLevelProfile(), restoredProject->profile(), + m_parameters.configurationName())); + } + m_parameters.setTopLevelProfile(restoredProject->profile()); + m_parameters.expandBuildConfiguration(); + } + if (!m_parameters.overrideBuildGraphData()) + return true; + if (m_parameters.finalBuildConfigurationTree() != restoredProject->buildConfiguration()) + return false; + Settings settings(m_parameters.settingsDirectory()); + for (QVariantMap::ConstIterator it = restoredProject->profileConfigs.constBegin(); + it != restoredProject->profileConfigs.constEnd(); ++it) { + const Profile profile(it.key(), &settings); + const QVariantMap buildConfig = SetupProjectParameters::expandedBuildConfiguration( + profile, m_parameters.configurationName()); + const QVariantMap newConfig = SetupProjectParameters::finalBuildConfigurationTree( + buildConfig, m_parameters.overriddenValues()); + if (newConfig != it.value()) + return false; + } + return true; +} + +void BuildGraphLoader::rescueOldBuildData(const ResolvedProductConstPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct, const ChildListHash &childLists, + const AllRescuableArtifactData &existingRad) +{ + QBS_CHECK(newlyResolvedProduct); + if (!restoredProduct->buildData) + return; + if (!newlyResolvedProduct->buildData) + newlyResolvedProduct->buildData = std::make_unique(); + + qCDebug(lcBuildGraph) << "rescue data of product" << restoredProduct->uniqueName(); + QBS_CHECK(newlyResolvedProduct->buildData); + QBS_CHECK(newlyResolvedProduct->buildData->rescuableArtifactData().empty()); + newlyResolvedProduct->buildData->setRescuableArtifactData(existingRad); + + // This is needed for artifacts created by rules, which happens later in the executor. + for (Artifact * const oldArtifact + : filterByType(restoredProduct->buildData->allNodes())) { + if (!oldArtifact->transformer) + continue; + Artifact * const newArtifact = lookupArtifact(newlyResolvedProduct, oldArtifact, false); + if (!newArtifact) { + RescuableArtifactData rad; + rad.timeStamp = oldArtifact->timestamp(); + rad.knownOutOfDate = oldArtifact->transformer->markedForRerun; + rad.fileTags = oldArtifact->fileTags(); + rad.properties = oldArtifact->properties; + rad.commands = oldArtifact->transformer->commands; + rad.propertiesRequestedInPrepareScript + = oldArtifact->transformer->propertiesRequestedInPrepareScript; + rad.propertiesRequestedInCommands + = oldArtifact->transformer->propertiesRequestedInCommands; + rad.propertiesRequestedFromArtifactInPrepareScript + = oldArtifact->transformer->propertiesRequestedFromArtifactInPrepareScript; + rad.propertiesRequestedFromArtifactInCommands + = oldArtifact->transformer->propertiesRequestedFromArtifactInCommands; + rad.importedFilesUsedInPrepareScript + = oldArtifact->transformer->importedFilesUsedInPrepareScript; + rad.importedFilesUsedInCommands = oldArtifact->transformer->importedFilesUsedInCommands; + rad.depsRequestedInPrepareScript + = oldArtifact->transformer->depsRequestedInPrepareScript; + rad.depsRequestedInCommands = oldArtifact->transformer->depsRequestedInCommands; + rad.artifactsMapRequestedInPrepareScript + = oldArtifact->transformer->artifactsMapRequestedInPrepareScript; + rad.artifactsMapRequestedInCommands + = oldArtifact->transformer->artifactsMapRequestedInCommands; + rad.exportedModulesAccessedInPrepareScript + = oldArtifact->transformer->exportedModulesAccessedInPrepareScript; + rad.exportedModulesAccessedInCommands + = oldArtifact->transformer->exportedModulesAccessedInCommands; + rad.lastCommandExecutionTime = oldArtifact->transformer->lastCommandExecutionTime; + rad.lastPrepareScriptExecutionTime + = oldArtifact->transformer->lastPrepareScriptExecutionTime; + const ChildrenInfo &childrenInfo = childLists.value(oldArtifact); + for (Artifact * const child : qAsConst(childrenInfo.children)) { + rad.children.emplace_back(child->product->name, + child->product->multiplexConfigurationId, child->filePath(), + childrenInfo.childrenAddedByScanner.contains(child)); + transform(oldArtifact->fileDependencies, rad.fileDependencies, + std::mem_fn(&FileDependency::filePath)); + } + newlyResolvedProduct->buildData->addRescuableArtifactData(oldArtifact->filePath(), rad); + } + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/buildgraphloader.h b/src/lib/corelib/buildgraph/buildgraphloader.h new file mode 100644 index 00000000..c62ba7fa --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraphloader.h @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_BUILDGRAPHLOADER_H +#define QBS_BUILDGRAPHLOADER_H + +#include "forward_decls.h" + +#include "artifact.h" +#include "rescuableartifactdata.h" + +#include +#include +#include + +#include +#include + +#include + +namespace qbs { + +namespace Internal { +class FileDependency; +class FileResourceBase; +class FileTime; +class Property; + +class BuildGraphLoadResult +{ +public: + TopLevelProjectPtr newlyResolvedProject; + TopLevelProjectPtr loadedProject; +}; + + +class BuildGraphLoader +{ +public: + BuildGraphLoader(Logger logger); + ~BuildGraphLoader(); + + BuildGraphLoadResult load(const TopLevelProjectPtr &existingProject, + const SetupProjectParameters ¶meters, + const RulesEvaluationContextPtr &evalContext); + + static TopLevelProjectConstPtr loadProject(const QString &bgFilePath); + +private: + void loadBuildGraphFromDisk(); + bool checkBuildGraphCompatibility(const TopLevelProjectConstPtr &project); + void trackProjectChanges(); + bool probeExecutionForced(const TopLevelProjectConstPtr &restoredProject, + const std::vector &restoredProducts) const; + bool hasEnvironmentChanged(const TopLevelProjectConstPtr &restoredProject) const; + bool hasCanonicalFilePathResultChanged(const TopLevelProjectConstPtr &restoredProject) const; + bool hasFileExistsResultChanged(const TopLevelProjectConstPtr &restoredProject) const; + bool hasDirectoryEntriesResultChanged(const TopLevelProjectConstPtr &restoredProject) const; + bool hasFileLastModifiedResultChanged(const TopLevelProjectConstPtr &restoredProject) const; + bool hasProductFileChanged(const std::vector &restoredProducts, + const FileTime &referenceTime, + Set &remainingBuildSystemFiles, + std::vector &productsWithChangedFiles); + bool hasBuildSystemFileChanged(const Set &buildSystemFiles, + const TopLevelProject *restoredProject); + void markTransformersForChangeTracking(const std::vector &restoredProducts); + void checkAllProductsForChanges(const std::vector &restoredProducts, + std::vector &changedProducts); + bool checkProductForChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct); + bool checkProductForChangesInSourceFiles(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct); + bool checkProductForInstallInfoChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct); + bool checkForPropertyChanges(const ResolvedProductPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct); + QVariantMap propertyMapByKind(const ResolvedProductConstPtr &product, const Property &property); + void onProductRemoved(const ResolvedProductPtr &product, ProjectBuildData *projectBuildData, + bool removeArtifactsFromDisk = true); + bool checkForPropertyChanges(const TransformerPtr &restoredTrafo, + const ResolvedProductPtr &freshProduct); + bool checkForPropertyChange(const Property &restoredProperty, + const QVariantMap &newProperties); + void replaceFileDependencyWithArtifact(const ResolvedProductPtr &fileDepProduct, + FileDependency *filedep, Artifact *artifact); + bool checkConfigCompatibility(); + + struct ChildrenInfo { + ChildrenInfo() = default; + ChildrenInfo(ArtifactSet c1, ArtifactSet c2) + : children(std::move(c1)), childrenAddedByScanner(std::move(c2)) {} + ArtifactSet children; + ArtifactSet childrenAddedByScanner; + }; + using ChildListHash = QHash; + void rescueOldBuildData(const ResolvedProductConstPtr &restoredProduct, + const ResolvedProductPtr &newlyResolvedProduct, + const ChildListHash &childLists, + const AllRescuableArtifactData &existingRad); + + QMap m_freshProductsByName; + RulesEvaluationContextPtr m_evalContext; + SetupProjectParameters m_parameters; + BuildGraphLoadResult m_result; + Logger m_logger; + QStringList m_artifactsRemovedFromDisk; + std::unordered_map> m_changedSourcesByProduct; + Set m_productsWhoseArtifactsNeedUpdate; + qint64 m_wildcardExpansionEffort = 0; + qint64 m_propertyComparisonEffort = 0; + + // These must only be deleted at the end so we can still peek into the old look-up table. + QList m_objectsToDelete; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/buildgraph/buildgraphnode.cpp b/src/lib/corelib/buildgraph/buildgraphnode.cpp new file mode 100644 index 00000000..7d011d50 --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraphnode.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "buildgraphnode.h" + +#include "buildgraphvisitor.h" +#include "projectbuilddata.h" +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +BuildGraphNode::BuildGraphNode() : buildState(Untouched) +{ +} + +BuildGraphNode::~BuildGraphNode() +{ + for (BuildGraphNode *p : qAsConst(parents)) + p->children.remove(this); + for (BuildGraphNode *c : qAsConst(children)) + c->parents.remove(this); +} + +void BuildGraphNode::onChildDisconnected(BuildGraphNode *child) +{ + Q_UNUSED(child); +} + +void BuildGraphNode::acceptChildren(BuildGraphVisitor *visitor) +{ + for (BuildGraphNode *child : qAsConst(children)) + child->accept(visitor); +} + +void BuildGraphNode::load(PersistentPool &pool) +{ + serializationOp(pool); +} + +void BuildGraphNode::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/buildgraphnode.h b/src/lib/corelib/buildgraph/buildgraphnode.h new file mode 100644 index 00000000..44a0a5b1 --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraphnode.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILDGRAPHNODE_H +#define QBS_BUILDGRAPHNODE_H + +#include "nodeset.h" +#include +#include +#include + +namespace qbs { +namespace Internal { + +class BuildGraphVisitor; + +class BuildGraphNode +{ + friend NodeSet; +public: + virtual ~BuildGraphNode(); + + NodeSet parents; + NodeSet children; + WeakPointer product; + + enum BuildState + { + Untouched = 0, + Buildable, + Building, + Built + }; + + BuildState buildState; // Do not serialize. Will be refreshed for every build. + + enum Type + { + ArtifactNodeType, + RuleNodeType + }; + + virtual Type type() const = 0; + virtual void accept(BuildGraphVisitor *visitor) = 0; + virtual QString toString() const = 0; + virtual void onChildDisconnected(BuildGraphNode *child); + + bool isBuilt() const { return buildState == Built; } + + virtual void load(PersistentPool &pool); + virtual void store(PersistentPool &pool); + +protected: + explicit BuildGraphNode(); + void acceptChildren(BuildGraphVisitor *visitor); + + // Do not store parents to avoid recursion. + // Parents must be updated after loading all nodes. + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(children); + } +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILDGRAPHNODE_H diff --git a/src/lib/corelib/buildgraph/buildgraphvisitor.h b/src/lib/corelib/buildgraph/buildgraphvisitor.h new file mode 100644 index 00000000..cc2dde79 --- /dev/null +++ b/src/lib/corelib/buildgraph/buildgraphvisitor.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILDGRAPHVISITOR_H +#define QBS_BUILDGRAPHVISITOR_H + +namespace qbs { +namespace Internal { + +class Artifact; +class RuleNode; + +/*! + * \brief The BuildGraphVisitor class + * + * The return value of a visit method indicates whether the children of the current node + * are to be visited next. + */ +class BuildGraphVisitor +{ +public: + virtual ~BuildGraphVisitor() = default; + virtual bool visit(Artifact *) { return true; } + virtual void endVisit(Artifact *) { } + virtual bool visit(RuleNode *) { return true; } + virtual void endVisit(RuleNode *) { } +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILDGRAPHVISITOR_H diff --git a/src/lib/corelib/buildgraph/cycledetector.cpp b/src/lib/corelib/buildgraph/cycledetector.cpp new file mode 100644 index 00000000..5daed55f --- /dev/null +++ b/src/lib/corelib/buildgraph/cycledetector.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "cycledetector.h" + +#include "artifact.h" +#include "buildgraph.h" +#include "projectbuilddata.h" +#include "rulenode.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +CycleDetector::CycleDetector(Logger logger) + : m_parent(nullptr), m_logger(std::move(logger)) +{ +} + +void CycleDetector::visitProject(const TopLevelProjectConstPtr &project) +{ + project->accept(this); +} + +void CycleDetector::visitProduct(const ResolvedProductConstPtr &product) +{ + product->accept(this); +} + +bool CycleDetector::visit(Artifact *artifact) +{ + return visitNode(artifact); +} + +bool CycleDetector::visit(RuleNode *ruleNode) +{ + return visitNode(ruleNode); +} + +bool CycleDetector::visitNode(BuildGraphNode *node) +{ + if (Q_UNLIKELY(m_nodesInCurrentPath.contains(node))) { + ErrorInfo error(Tr::tr("Cycle in build graph detected.")); + const auto nodes = cycle(node); + for (const BuildGraphNode * const n : nodes) + error.append(n->toString()); + throw error; + } + + if (m_allNodes.contains(node)) + return false; + + m_nodesInCurrentPath += node; + m_parent = node; + for (BuildGraphNode * const child : qAsConst(node->children)) + child->accept(this); + m_nodesInCurrentPath -= node; + m_allNodes += node; + return false; +} + +QList CycleDetector::cycle(BuildGraphNode *doubleEntry) +{ + QList path; + findPath(doubleEntry, m_parent, path); + path.push_back(doubleEntry); + return path; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/cycledetector.h b/src/lib/corelib/buildgraph/cycledetector.h new file mode 100644 index 00000000..5bfb44ef --- /dev/null +++ b/src/lib/corelib/buildgraph/cycledetector.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_CYCLEDETECTOR_H +#define QBS_CYCLEDETECTOR_H + +#include "buildgraphvisitor.h" +#include "nodeset.h" +#include +#include + +namespace qbs { +namespace Internal { + +class BuildGraphNode; + +class QBS_AUTOTEST_EXPORT CycleDetector : private BuildGraphVisitor +{ +public: + CycleDetector(Logger logger); + + void visitProject(const TopLevelProjectConstPtr &project); + void visitProduct(const ResolvedProductConstPtr &product); + +private: + bool visit(Artifact *artifact) override; + bool visit(RuleNode *ruleNode) override; + + bool visitNode(BuildGraphNode *node); + + QList cycle(BuildGraphNode *doubleEntry); + + NodeSet m_allNodes; + NodeSet m_nodesInCurrentPath; + BuildGraphNode *m_parent; + Logger m_logger; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_CYCLEDETECTOR_H diff --git a/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.cpp b/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.cpp new file mode 100644 index 00000000..ac6b1dc4 --- /dev/null +++ b/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "dependencyparametersscriptvalue.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +static QScriptValue toScriptValue(ScriptEngine *engine, const QString &productName, + const QVariantMap &v, const QString &depName, + const QualifiedId &moduleName) +{ + QScriptValue obj = engine->newObject(); + bool objIdAddedToObserver = false; + for (auto it = v.begin(); it != v.end(); ++it) { + if (it.value().userType() == QMetaType::QVariantMap) { + obj.setProperty(it.key(), toScriptValue(engine, productName, it.value().toMap(), + depName, QualifiedId(moduleName) << it.key())); + } else { + if (!objIdAddedToObserver) { + objIdAddedToObserver = true; + engine->observer()->addParameterObjectId(obj.objectId(), productName, depName, + moduleName); + } + engine->setObservedProperty(obj, it.key(), engine->toScriptValue(it.value())); + } + } + return obj; +} + + +static QScriptValue toScriptValue(ScriptEngine *scriptEngine, const QString &productName, + const QVariantMap &v, const QString &depName) +{ + return toScriptValue(scriptEngine, productName, v, depName, {}); +} + +QScriptValue dependencyParametersValue(const QString &productName, const QString &dependencyName, + const QVariantMap ¶metersMap, ScriptEngine *engine) +{ + return toScriptValue(engine, productName, parametersMap, dependencyName); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.h b/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.h new file mode 100644 index 00000000..7e4287be --- /dev/null +++ b/src/lib/corelib/buildgraph/dependencyparametersscriptvalue.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_DEPENDENCYPARAMETERSSCRIPTVALUE_H +#define QBS_DEPENDENCYPARAMETERSSCRIPTVALUE_H + +#include +#include + +namespace qbs { +namespace Internal { +class ScriptEngine; + +QScriptValue dependencyParametersValue(const QString &productName, const QString &dependencyName, + const QVariantMap ¶metersMap, ScriptEngine *engine); + +} // namespace Internal +} // namespace qbs + +#endif // include guard diff --git a/src/lib/corelib/buildgraph/depscanner.cpp b/src/lib/corelib/buildgraph/depscanner.cpp new file mode 100644 index 00000000..b24ec2d9 --- /dev/null +++ b/src/lib/corelib/buildgraph/depscanner.cpp @@ -0,0 +1,270 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "depscanner.h" +#include "artifact.h" +#include "projectbuilddata.h" +#include "buildgraph.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +QString DependencyScanner::id() const +{ + if (m_id.isEmpty()) + m_id = createId(); + return m_id; +} + +static QStringList collectCppIncludePaths(const QVariantMap &modules) +{ + QStringList result; + const QVariantMap cpp = modules.value(StringConstants::cppModule()).toMap(); + if (cpp.empty()) + return result; + + result << cpp.value(QStringLiteral("includePaths")).toStringList(); + const bool useSystemHeaders + = cpp.value(QStringLiteral("treatSystemHeadersAsDependencies")).toBool(); + if (useSystemHeaders) { + result + << cpp.value(QStringLiteral("systemIncludePaths")).toStringList() + << cpp.value(QStringLiteral("distributionIncludePaths")).toStringList() + << cpp.value(QStringLiteral("compilerIncludePaths")).toStringList(); + } + result.removeDuplicates(); + return result; +} + +PluginDependencyScanner::PluginDependencyScanner(ScannerPlugin *plugin) + : m_plugin(plugin) +{ +} + +QStringList PluginDependencyScanner::collectSearchPaths(Artifact *artifact) +{ + if (m_plugin->flags & ScannerUsesCppIncludePaths) + return collectCppIncludePaths(artifact->properties->value()); + return {}; +} + +QStringList PluginDependencyScanner::collectDependencies(Artifact *artifact, FileResourceBase *file, + const char *fileTags) +{ + Q_UNUSED(artifact); + Set result; + QString baseDirOfInFilePath = file->dirPath(); + const QString &filepath = file->filePath(); + void *scannerHandle = m_plugin->open(filepath.utf16(), fileTags, ScanForDependenciesFlag); + if (!scannerHandle) + return {}; + for (;;) { + int flags = 0; + int length = 0; + const char *szOutFilePath = m_plugin->next(scannerHandle, &length, &flags); + if (szOutFilePath == nullptr) + break; + QString outFilePath = QString::fromLocal8Bit(szOutFilePath, length); + if (outFilePath.isEmpty()) + continue; + if (flags & SC_LOCAL_INCLUDE_FLAG) { + QString localFilePath = FileInfo::resolvePath(baseDirOfInFilePath, outFilePath); + if (FileInfo::exists(localFilePath)) + outFilePath = localFilePath; + } + result += outFilePath; + } + m_plugin->close(scannerHandle); + return rangeTo(result); +} + +bool PluginDependencyScanner::recursive() const +{ + return m_plugin->flags & ScannerRecursiveDependencies; +} + +const void *PluginDependencyScanner::key() const +{ + return m_plugin; +} + +QString PluginDependencyScanner::createId() const +{ + return QString::fromLatin1(m_plugin->name); +} + +bool PluginDependencyScanner::areModulePropertiesCompatible(const PropertyMapConstPtr &m1, + const PropertyMapConstPtr &m2) const +{ + // This changes when our C++ scanner starts taking defines into account. + Q_UNUSED(m1); + Q_UNUSED(m2); + return true; +} + +UserDependencyScanner::UserDependencyScanner(ResolvedScannerConstPtr scanner, + ScriptEngine *engine) + : m_scanner(std::move(scanner)), + m_engine(engine), + m_product(nullptr) +{ + m_global = m_engine->newObject(); + m_global.setPrototype(m_engine->globalObject()); + setupScriptEngineForFile(m_engine, m_scanner->scanScript.fileContext(), m_global, + ObserveMode::Disabled); // TODO: QBS-1092 +} + +QStringList UserDependencyScanner::collectSearchPaths(Artifact *artifact) +{ + return evaluate(artifact, nullptr, m_scanner->searchPathsScript); +} + +QStringList UserDependencyScanner::collectDependencies(Artifact *artifact, FileResourceBase *file, + const char *fileTags) +{ + Q_UNUSED(fileTags); + return evaluate(artifact, file, m_scanner->scanScript); +} + +bool UserDependencyScanner::recursive() const +{ + return m_scanner->recursive; +} + +const void *UserDependencyScanner::key() const +{ + return m_scanner.get(); +} + +QString UserDependencyScanner::createId() const +{ + return m_scanner->scanScript.sourceCode(); +} + +bool UserDependencyScanner::areModulePropertiesCompatible(const PropertyMapConstPtr &m1, + const PropertyMapConstPtr &m2) const +{ + // TODO: This should probably be made more fine-grained. Perhaps the Scanner item + // could declare the relevant properties, or we could figure them out automatically + // somehow. + return m1 == m2 || *m1 == *m2; +} + +class ScriptEngineActiveFlagGuard +{ + ScriptEngine *m_engine; +public: + ScriptEngineActiveFlagGuard(ScriptEngine *engine) + : m_engine(engine) + { + m_engine->setActive(true); + } + + ~ScriptEngineActiveFlagGuard() + { + m_engine->setActive(false); + } +}; + +QStringList UserDependencyScanner::evaluate(const Artifact *artifact, + const FileResourceBase *fileToScan, const PrivateScriptFunction &script) +{ + ScriptEngineActiveFlagGuard guard(m_engine); + + if (artifact->product.get() != m_product) { + m_product = artifact->product.get(); + setupScriptEngineForProduct(m_engine, artifact->product.get(), + m_scanner->module.get(), m_global, true); + } + + QScriptValueList args; + args.reserve(fileToScan ? 4 : 3); + args.push_back(m_global.property(StringConstants::projectVar())); + args.push_back(m_global.property(StringConstants::productVar())); + args.push_back(Transformer::translateFileConfig(m_engine, artifact, m_scanner->module->name)); + if (fileToScan) + args.push_back(fileToScan->filePath()); + + m_engine->setGlobalObject(m_global); + QScriptValue &function = script.scriptFunction; + if (!function.isValid() || function.engine() != m_engine) { + function = m_engine->evaluate(script.sourceCode()); + if (Q_UNLIKELY(!function.isFunction())) + throw ErrorInfo(Tr::tr("Invalid scan script."), script.location()); + } + QScriptValue result = function.call(QScriptValue(), args); + m_engine->setGlobalObject(m_global.prototype()); + m_engine->clearRequestedProperties(); + if (Q_UNLIKELY(m_engine->hasErrorOrException(result))) { + QString msg = Tr::tr("evaluating scan script: ") + m_engine->lastErrorString(result); + const CodeLocation loc = m_engine->lastErrorLocation(result, script.location()); + m_engine->clearExceptions(); + throw ErrorInfo(msg, loc); + } + QStringList list; + if (result.isArray()) { + const int count = result.property(StringConstants::lengthProperty()).toInt32(); + list.reserve(count); + for (qint32 i = 0; i < count; ++i) { + QScriptValue item = result.property(i); + if (item.isValid() && !item.isUndefined()) + list.push_back(item.toString()); + } + } + return list; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/depscanner.h b/src/lib/corelib/buildgraph/depscanner.h new file mode 100644 index 00000000..6b18004f --- /dev/null +++ b/src/lib/corelib/buildgraph/depscanner.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_DEPENDENCY_SCANNER_H +#define QBS_DEPENDENCY_SCANNER_H + +#include +#include +#include + +#include + +#include + +class ScannerPlugin; + +namespace qbs { +namespace Internal { + +class Artifact; +class FileResourceBase; +class Logger; +class ScriptEngine; + +class DependencyScanner +{ +public: + virtual ~DependencyScanner() = default; + + QString id() const; + + virtual QStringList collectSearchPaths(Artifact *artifact) = 0; + virtual QStringList collectDependencies(Artifact *artifact, FileResourceBase *file, + const char *fileTags) = 0; + virtual bool recursive() const = 0; + virtual const void *key() const = 0; + virtual bool areModulePropertiesCompatible(const PropertyMapConstPtr &m1, + const PropertyMapConstPtr &m2) const = 0; + virtual bool cacheIsPerFile() const = 0; + +private: + virtual QString createId() const = 0; + + mutable QString m_id; +}; + +class PluginDependencyScanner : public DependencyScanner +{ +public: + PluginDependencyScanner(ScannerPlugin *plugin); + +private: + QStringList collectSearchPaths(Artifact *artifact) override; + QStringList collectDependencies(Artifact *artifact, FileResourceBase *file, + const char *fileTags) override; + bool recursive() const override; + const void *key() const override; + QString createId() const override; + bool areModulePropertiesCompatible(const PropertyMapConstPtr &m1, + const PropertyMapConstPtr &m2) const override; + bool cacheIsPerFile() const override { return false; } + + ScannerPlugin* m_plugin; +}; + +class UserDependencyScanner : public DependencyScanner +{ +public: + UserDependencyScanner(ResolvedScannerConstPtr scanner, ScriptEngine *engine); + +private: + QStringList collectSearchPaths(Artifact *artifact) override; + QStringList collectDependencies(Artifact *artifact, FileResourceBase *file, + const char *fileTags) override; + bool recursive() const override; + const void *key() const override; + QString createId() const override; + bool areModulePropertiesCompatible(const PropertyMapConstPtr &m1, + const PropertyMapConstPtr &m2) const override; + bool cacheIsPerFile() const override { return true; } + + QStringList evaluate(const Artifact *artifact, const FileResourceBase *fileToScan, const PrivateScriptFunction &script); + + ResolvedScannerConstPtr m_scanner; + ScriptEngine *m_engine; + QScriptValue m_global; + ResolvedProduct *m_product; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_DEPENDENCY_SCANNER_H diff --git a/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp b/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp new file mode 100644 index 00000000..ebbcf67a --- /dev/null +++ b/src/lib/corelib/buildgraph/emptydirectoriesremover.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "emptydirectoriesremover.h" + +#include "artifact.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +EmptyDirectoriesRemover::EmptyDirectoriesRemover(const TopLevelProject *project, + Logger logger) + : m_project(project), m_logger(std::move(logger)) +{ +} + +void EmptyDirectoriesRemover::removeEmptyParentDirectories(const QStringList &artifactFilePaths) +{ + m_dirsToRemove.clear(); + m_handledDirs.clear(); + for (const QString &filePath : artifactFilePaths) + insertSorted(QFileInfo(filePath).absolutePath()); + while (!m_dirsToRemove.empty()) + removeDirIfEmpty(); +} + +void EmptyDirectoriesRemover::removeEmptyParentDirectories(const ArtifactSet &artifacts) +{ + QStringList filePaths; + for (const Artifact * const a : artifacts) { + if (a->artifactType == Artifact::Generated) + filePaths << a->filePath(); + } + removeEmptyParentDirectories(filePaths); +} + +// List is sorted so that "deeper" directories come first. +void EmptyDirectoriesRemover::insertSorted(const QString &dirPath) +{ + int i; + for (i = 0; i < m_dirsToRemove.size(); ++i) { + const QString &cur = m_dirsToRemove.at(i); + if (dirPath == cur) + return; + if (dirPath.count(QLatin1Char('/')) > cur.count(QLatin1Char('/'))) + break; + } + m_dirsToRemove.insert(i, dirPath); +} + +void EmptyDirectoriesRemover::removeDirIfEmpty() +{ + const QString dirPath = m_dirsToRemove.takeFirst(); + m_handledDirs.insert(dirPath); + QFileInfo fi(dirPath); + if (fi.isSymLink() || !fi.exists() || !dirPath.startsWith(m_project->buildDirectory) + || fi.filePath() == m_project->buildDirectory) { + return; + } + QDir dir(dirPath); + dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot); + if (dir.count() != 0) + return; + dir.cdUp(); + if (!dir.rmdir(fi.fileName())) { + m_logger.qbsWarning() << QStringLiteral("Cannot remove empty directory '%1'.") + .arg(dirPath); + return; + } + const QString parentDir = dir.path(); + if (!m_handledDirs.contains(parentDir)) + insertSorted(parentDir); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/emptydirectoriesremover.h b/src/lib/corelib/buildgraph/emptydirectoriesremover.h new file mode 100644 index 00000000..7d73fb81 --- /dev/null +++ b/src/lib/corelib/buildgraph/emptydirectoriesremover.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_EMPTYDIRECTORIESREMOVER_H +#define QBS_EMPTYDIRECTORIESREMOVER_H + +#include "forward_decls.h" + +#include +#include + +#include + +namespace qbs { +namespace Internal { +class TopLevelProject; + +class EmptyDirectoriesRemover +{ +public: + EmptyDirectoriesRemover(const TopLevelProject *project, Logger logger); + void removeEmptyParentDirectories(const QStringList &artifactFilePaths); + void removeEmptyParentDirectories(const ArtifactSet &artifacts); + +private: + void insertSorted(const QString &dirPath); + void removeDirIfEmpty(); + + const TopLevelProject * const m_project; + Logger m_logger; + QStringList m_dirsToRemove; + Set m_handledDirs; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/buildgraph/environmentscriptrunner.cpp b/src/lib/corelib/buildgraph/environmentscriptrunner.cpp new file mode 100644 index 00000000..841f39a8 --- /dev/null +++ b/src/lib/corelib/buildgraph/environmentscriptrunner.cpp @@ -0,0 +1,223 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "environmentscriptrunner.h" + +#include "buildgraph.h" +#include "rulesevaluationcontext.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class EnvProvider +{ +public: + EnvProvider(ScriptEngine *engine, const QProcessEnvironment &originalEnv) + : m_engine(engine), m_env(originalEnv) + { + QVariant v; + v.setValue(&m_env); + m_engine->setProperty(StringConstants::qbsProcEnvVarInternal(), v); + } + + ~EnvProvider() { m_engine->setProperty(StringConstants::qbsProcEnvVarInternal(), QVariant()); } + + QProcessEnvironment alteredEnvironment() const { return m_env; } + +private: + ScriptEngine * const m_engine; + QProcessEnvironment m_env; +}; + +static QList topSortModules(const QHash > &moduleChildren, + const QList &modules, + Set &seenModuleNames) +{ + QList result; + for (const ResolvedModule * const m : modules) { + if (m->name.isNull()) + continue; + result << topSortModules(moduleChildren, moduleChildren.value(m), seenModuleNames); + if (seenModuleNames.insert(m->name).second) + result.push_back(m); + } + return result; +} + +EnvironmentScriptRunner::EnvironmentScriptRunner(ResolvedProduct *product, + RulesEvaluationContext *evalContext, + const QProcessEnvironment &env) + : m_product(product), m_evalContext(evalContext), m_env(env) +{ +} + +void EnvironmentScriptRunner::setupForBuild() +{ + // TODO: Won't this fail to take changed properties into account? We probably need + // change tracking here as well. + if (!m_product->buildEnvironment.isEmpty()) + return; + m_envType = BuildEnv; + setupEnvironment(); +} + +void EnvironmentScriptRunner::setupForRun(const QStringList &config) +{ + m_envType = RunEnv; + m_runEnvConfig = config; + setupEnvironment(); +} + +void EnvironmentScriptRunner::setupEnvironment() +{ + const auto hasScript = [this](const ResolvedModuleConstPtr &m) { + return !getScript(m.get()).sourceCode().isEmpty(); + }; + const bool hasAnyScripts = Internal::any_of(m_product->modules, hasScript); + if (!hasAnyScripts) + return; + + QMap moduleMap; + for (const auto &module : m_product->modules) + moduleMap.insert(module->name, module.get()); + + QHash > moduleParents; + QHash > moduleChildren; + for (const auto &module : m_product->modules) { + for (const QString &moduleName : qAsConst(module->moduleDependencies)) { + const ResolvedModule * const depmod = moduleMap.value(moduleName); + QBS_ASSERT(depmod, return); + moduleParents[depmod].push_back(module.get()); + moduleChildren[module.get()].push_back(depmod); + } + } + + QList rootModules; + for (const auto &module : m_product->modules) { + if (moduleParents.value(module.get()).isEmpty()) { + QBS_ASSERT(module, return); + rootModules.push_back(module.get()); + } + } + + EnvProvider envProvider(engine(), m_env); + + Set seenModuleNames; + const QList &topSortedModules + = topSortModules(moduleChildren, rootModules, seenModuleNames); + const QStringList scriptFunctionArgs = m_envType == BuildEnv + ? ResolvedModule::argumentNamesForSetupBuildEnv() + : ResolvedModule::argumentNamesForSetupRunEnv(); + for (const ResolvedModule * const module : topSortedModules) { + const PrivateScriptFunction &setupScript = getScript(module); + if (setupScript.sourceCode().isEmpty()) + continue; + + RulesEvaluationContext::Scope s(m_evalContext); + QScriptValue envScriptContext = engine()->newObject(); + envScriptContext.setPrototype(engine()->globalObject()); + setupScriptEngineForProduct(engine(), m_product, module, envScriptContext, false); + const QString &productKey = StringConstants::productVar(); + const QString &projectKey = StringConstants::projectVar(); + m_evalContext->scope().setProperty(productKey, envScriptContext.property(productKey)); + m_evalContext->scope().setProperty(projectKey, envScriptContext.property(projectKey)); + if (m_envType == RunEnv) { + QScriptValue configArray = engine()->newArray(m_runEnvConfig.size()); + for (int i = 0; i < m_runEnvConfig.size(); ++i) + configArray.setProperty(i, QScriptValue(m_runEnvConfig.at(i))); + m_evalContext->scope().setProperty(QStringLiteral("config"), configArray); + } + setupScriptEngineForFile(engine(), setupScript.fileContext(), m_evalContext->scope(), + ObserveMode::Disabled); + // TODO: Cache evaluate result + QScriptValue fun = engine()->evaluate(setupScript.sourceCode(), + setupScript.location().filePath(), + setupScript.location().line()); + QBS_CHECK(fun.isFunction()); + const QScriptValueList svArgs = ScriptEngine::argumentList(scriptFunctionArgs, + m_evalContext->scope()); + const QScriptValue res = fun.call(QScriptValue(), svArgs); + engine()->releaseResourcesOfScriptObjects(); + if (Q_UNLIKELY(engine()->hasErrorOrException(res))) { + const QString scriptName = m_envType == BuildEnv + ? StringConstants::setupBuildEnvironmentProperty() + : StringConstants::setupRunEnvironmentProperty(); + throw ErrorInfo(Tr::tr("Error running %1 script for product '%2': %3") + .arg(scriptName, m_product->fullDisplayName(), + engine()->lastErrorString(res)), + engine()->lastErrorLocation(res, setupScript.location())); + } + } + + const QProcessEnvironment &newEnv = envProvider.alteredEnvironment(); + if (m_envType == BuildEnv) + m_product->buildEnvironment = newEnv; + else + m_product->runEnvironment = newEnv; +} + +ScriptEngine *EnvironmentScriptRunner::engine() const +{ + return m_evalContext->engine(); +} + +const PrivateScriptFunction &EnvironmentScriptRunner::getScript(const ResolvedModule *module) const +{ + return m_envType == BuildEnv + ? module->setupBuildEnvironmentScript + : module->setupRunEnvironmentScript; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/environmentscriptrunner.h b/src/lib/corelib/buildgraph/environmentscriptrunner.h new file mode 100644 index 00000000..22131479 --- /dev/null +++ b/src/lib/corelib/buildgraph/environmentscriptrunner.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ENVIRONMENTSCRIPTRUNNER_H +#define QBS_ENVIRONMENTSCRIPTRUNNER_H + +#include + +#include +#include + +namespace qbs { +namespace Internal { +class RulesEvaluationContext; +class ScriptEngine; + +class EnvironmentScriptRunner +{ +public: + EnvironmentScriptRunner(ResolvedProduct *product, RulesEvaluationContext *evalContext, + const QProcessEnvironment &env); + + void setupForBuild(); + void setupForRun(const QStringList &config); + +private: + void setupEnvironment(); + ScriptEngine *engine() const; + const PrivateScriptFunction &getScript(const ResolvedModule *module) const; + + ResolvedProduct * const m_product; + RulesEvaluationContext * const m_evalContext; + const QProcessEnvironment m_env; + + QStringList m_runEnvConfig; + enum EnvType { BuildEnv, RunEnv } m_envType = EnvType::BuildEnv; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp new file mode 100644 index 00000000..f0fe7d72 --- /dev/null +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -0,0 +1,1330 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "executor.h" + +#include "buildgraph.h" +#include "emptydirectoriesremover.h" +#include "environmentscriptrunner.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "cycledetector.h" +#include "executorjob.h" +#include "inputartifactscanner.h" +#include "productinstaller.h" +#include "rescuableartifactdata.h" +#include "rulecommands.h" +#include "rulenode.h" +#include "rulesevaluationcontext.h" +#include "transformerchangetracking.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +bool Executor::ComparePriority::operator() (const BuildGraphNode *x, const BuildGraphNode *y) const +{ + return x->product->buildData->buildPriority() < y->product->buildData->buildPriority(); +} + + +Executor::Executor(Logger logger, QObject *parent) + : QObject(parent) + , m_productInstaller(nullptr) + , m_logger(std::move(logger)) + , m_progressObserver(nullptr) + , m_state(ExecutorIdle) + , m_cancelationTimer(new QTimer(this)) +{ + m_inputArtifactScanContext = new InputArtifactScannerContext; + m_cancelationTimer->setSingleShot(false); + m_cancelationTimer->setInterval(1000); + connect(m_cancelationTimer, &QTimer::timeout, this, &Executor::checkForCancellation); +} + +Executor::~Executor() +{ + // jobs must be destroyed before deleting the m_inputArtifactScanContext + m_allJobs.clear(); + delete m_inputArtifactScanContext; + delete m_productInstaller; +} + +FileTime Executor::recursiveFileTime(const QString &filePath) const +{ + FileTime newest; + FileInfo fileInfo(filePath); + if (!fileInfo.exists()) { + const QString nativeFilePath = QDir::toNativeSeparators(filePath); + m_logger.qbsWarning() << Tr::tr("File '%1' not found.").arg(nativeFilePath); + return newest; + } + newest = std::max(fileInfo.lastModified(), fileInfo.lastStatusChange()); + if (!fileInfo.isDir()) + return newest; + const QStringList dirContents = QDir(filePath) + .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + for (const QString &curFileName : dirContents) { + const FileTime ft = recursiveFileTime(filePath + QLatin1Char('/') + curFileName); + if (ft > newest) + newest = ft; + } + return newest; +} + +void Executor::retrieveSourceFileTimestamp(Artifact *artifact) const +{ + QBS_CHECK(artifact->artifactType == Artifact::SourceFile); + + if (m_buildOptions.changedFiles().empty()) + artifact->setTimestamp(recursiveFileTime(artifact->filePath())); + else if (m_buildOptions.changedFiles().contains(artifact->filePath())) + artifact->setTimestamp(FileTime::currentTime()); + else if (!artifact->timestamp().isValid()) + artifact->setTimestamp(recursiveFileTime(artifact->filePath())); + + artifact->timestampRetrieved = true; + if (!artifact->timestamp().isValid()) + throw ErrorInfo(Tr::tr("Source file '%1' has disappeared.").arg(artifact->filePath())); +} + +void Executor::build() +{ + try { + m_partialBuild = size_t(m_productsToBuild.size()) != m_allProducts.size(); + doBuild(); + } catch (const ErrorInfo &e) { + handleError(e); + } +} + +void Executor::setProject(const TopLevelProjectPtr &project) +{ + m_project = project; + m_allProducts = project->allProducts(); + m_projectsByName.clear(); + m_projectsByName.insert(std::make_pair(project->name, project.get())); + for (const ResolvedProjectPtr &p : project->allSubProjects()) + m_projectsByName.insert(std::make_pair(p->name, p.get())); +} + +void Executor::setProducts(const QVector &productsToBuild) +{ + m_productsToBuild = productsToBuild; + m_productsByName.clear(); + for (const ResolvedProductPtr &p : productsToBuild) + m_productsByName.insert(std::make_pair(p->uniqueName(), p.get())); +} + +class ProductPrioritySetter +{ + const std::vector &m_allProducts; + unsigned int m_priority = 0; + Set m_seenProducts; +public: + ProductPrioritySetter(const std::vector &allProducts) // TODO: Use only products to build? + : m_allProducts(allProducts) + { + } + + void apply() + { + Set allDependencies; + for (const ResolvedProductPtr &product : m_allProducts) { + for (const ResolvedProductPtr &dep : product->dependencies) + allDependencies += dep; + } + const Set rootProducts + = rangeTo>(m_allProducts) - allDependencies; + m_priority = UINT_MAX; + m_seenProducts.clear(); + for (const ResolvedProductPtr &rootProduct : rootProducts) + traverse(rootProduct); + } + +private: + void traverse(const ResolvedProductPtr &product) + { + if (!m_seenProducts.insert(product).second) + return; + for (const ResolvedProductPtr &dependency : qAsConst(product->dependencies)) + traverse(dependency); + if (!product->buildData) + return; + product->buildData->setBuildPriority(m_priority--); + } +}; + +void Executor::doBuild() +{ + if (m_buildOptions.maxJobCount() <= 0) { + m_buildOptions.setMaxJobCount(BuildOptions::defaultMaxJobCount()); + qCDebug(lcExec) << "max job count not explicitly set, using value of" + << m_buildOptions.maxJobCount(); + } + QBS_CHECK(m_state == ExecutorIdle); + m_leaves = Leaves(); + m_error.clear(); + m_explicitlyCanceled = false; + m_activeFileTags = FileTags::fromStringList(m_buildOptions.activeFileTags()); + m_tagsOfFilesToConsider.clear(); + m_tagsNeededForFilesToConsider.clear(); + m_productsOfFilesToConsider.clear(); + m_artifactsRemovedFromDisk.clear(); + m_jobCountPerPool.clear(); + + setupJobLimits(); + + // TODO: The "filesToConsider" thing is badly designed; we should know exactly which artifact + // it is. Remove this from the BuildOptions class and introduce Project::buildSomeFiles() + // instead. + const QStringList &filesToConsider = m_buildOptions.filesToConsider(); + if (!filesToConsider.empty()) { + for (const QString &fileToConsider : filesToConsider) { + const auto &files = m_project->buildData->lookupFiles(fileToConsider); + for (const FileResourceBase * const file : files) { + if (file->fileType() != FileResourceBase::FileTypeArtifact) + continue; + auto const artifact = static_cast(file); + if (contains(m_productsToBuild, artifact->product.lock())) { + m_tagsOfFilesToConsider.unite(artifact->fileTags()); + m_productsOfFilesToConsider << artifact->product.lock(); + } + } + } + } + + setState(ExecutorRunning); + + if (m_productsToBuild.empty()) { + qCDebug(lcExec) << "No products to build, finishing."; + QTimer::singleShot(0, this, &Executor::finish); // Don't call back on the caller. + return; + } + + doSanityChecks(); + QBS_CHECK(!m_project->buildData->evaluationContext); + m_project->buildData->evaluationContext = std::make_shared(m_logger); + m_evalContext = m_project->buildData->evaluationContext; + + m_elapsedTimeRules = m_elapsedTimeScanners = m_elapsedTimeInstalling = 0; + m_evalContext->engine()->enableProfiling(m_buildOptions.logElapsedTime()); + + InstallOptions installOptions; + installOptions.setDryRun(m_buildOptions.dryRun()); + installOptions.setInstallRoot(m_productsToBuild.front()->moduleProperties + ->qbsPropertyValue(StringConstants::installRootProperty()).toString()); + installOptions.setKeepGoing(m_buildOptions.keepGoing()); + m_productInstaller = new ProductInstaller(m_project, m_productsToBuild, installOptions, + m_progressObserver, m_logger); + if (m_buildOptions.removeExistingInstallation()) + m_productInstaller->removeInstallRoot(); + + addExecutorJobs(); + syncFileDependencies(); + prepareAllNodes(); + prepareProducts(); + setupRootNodes(); + prepareReachableNodes(); + setupProgressObserver(); + initLeaves(); + if (!scheduleJobs()) { + qCDebug(lcExec) << "Nothing to do at all, finishing."; + QTimer::singleShot(0, this, &Executor::finish); // Don't call back on the caller. + } + if (m_progressObserver) + m_cancelationTimer->start(); +} + +void Executor::setBuildOptions(const BuildOptions &buildOptions) +{ + m_buildOptions = buildOptions; +} + + +void Executor::initLeaves() +{ + updateLeaves(m_roots); +} + +void Executor::updateLeaves(const NodeSet &nodes) +{ + NodeSet seenNodes; + for (BuildGraphNode * const node : nodes) + updateLeaves(node, seenNodes); +} + +void Executor::updateLeaves(BuildGraphNode *node, NodeSet &seenNodes) +{ + if (!seenNodes.insert(node).second) + return; + + // Artifacts that appear in the build graph after + // prepareBuildGraph() has been called, must be initialized. + if (node->buildState == BuildGraphNode::Untouched) { + node->buildState = BuildGraphNode::Buildable; + if (node->type() == BuildGraphNode::ArtifactNodeType) { + auto const artifact = static_cast(node); + if (artifact->artifactType == Artifact::SourceFile) + retrieveSourceFileTimestamp(artifact); + } + } + + bool isLeaf = true; + for (BuildGraphNode *child : qAsConst(node->children)) { + if (child->buildState != BuildGraphNode::Built) { + isLeaf = false; + updateLeaves(child, seenNodes); + } + } + + if (isLeaf) { + qCDebug(lcExec).noquote() << "adding leaf" << node->toString(); + m_leaves.push(node); + } +} + +// Returns true if some artifacts are still waiting to be built or currently building. +bool Executor::scheduleJobs() +{ + QBS_CHECK(m_state == ExecutorRunning); + std::vector delayedLeaves; + while (!m_leaves.empty() && !m_availableJobs.empty()) { + BuildGraphNode * const nodeToBuild = m_leaves.top(); + m_leaves.pop(); + + switch (nodeToBuild->buildState) { + case BuildGraphNode::Untouched: + QBS_ASSERT(!"untouched node in leaves list", + qDebug("%s", qPrintable(nodeToBuild->toString()))); + break; + case BuildGraphNode::Buildable: // This is the only state in which we want to build a node. + // TODO: It's a bit annoying that we have to check this here already, when we + // don't know whether the transformer needs to run at all. Investigate + // moving the whole job allocation logic to runTransformer(). + if (schedulingBlockedByJobLimit(nodeToBuild)) { + qCDebug(lcExec).noquote() << "node delayed due to occupied job pool:" + << nodeToBuild->toString(); + delayedLeaves.push_back(nodeToBuild); + } else { + nodeToBuild->accept(this); + } + break; + case BuildGraphNode::Building: + qCDebug(lcExec).noquote() << nodeToBuild->toString(); + qCDebug(lcExec) << "node is currently being built. Skipping."; + break; + case BuildGraphNode::Built: + qCDebug(lcExec).noquote() << nodeToBuild->toString(); + qCDebug(lcExec) << "node already built. Skipping."; + break; + } + } + for (BuildGraphNode * const delayedLeaf : delayedLeaves) + m_leaves.push(delayedLeaf); + return !m_leaves.empty() || !m_processingJobs.empty(); +} + +bool Executor::schedulingBlockedByJobLimit(const BuildGraphNode *node) +{ + if (node->type() != BuildGraphNode::ArtifactNodeType) + return false; + const auto artifact = static_cast(node); + if (artifact->artifactType == Artifact::SourceFile) + return false; + + const Transformer * const transformer = artifact->transformer.get(); + for (const QString &jobPool : transformer->jobPools()) { + const int currentJobCount = m_jobCountPerPool[jobPool]; + if (currentJobCount == 0) + continue; + const auto jobLimitIsExceeded = [currentJobCount, jobPool, this](const Transformer *t) { + const int maxJobCount = m_jobLimitsPerProduct.at(t->product().get()) + .getLimit(jobPool); + return maxJobCount > 0 && currentJobCount >= maxJobCount; + }; + + // Different products can set different limits. The effective limit is the minimum of what + // is set in this transformer's product and in the products of all currently + // running transformers. + if (jobLimitIsExceeded(transformer)) + return true; + const auto runningJobs = m_processingJobs.keys(); + for (const ExecutorJob * const runningJob : runningJobs) { + if (!runningJob->jobPools().contains(jobPool)) + continue; + const Transformer * const runningTransformer = runningJob->transformer(); + if (!runningTransformer) + continue; // This can happen if the ExecutorJob has already finished. + if (runningTransformer->product() == transformer->product()) + continue; // We have already checked this product's job limit. + if (jobLimitIsExceeded(runningTransformer)) + return true; + } + } + return false; +} + +bool Executor::isUpToDate(Artifact *artifact) const +{ + QBS_CHECK(artifact->artifactType == Artifact::Generated); + + qCDebug(lcUpToDateCheck) << "check" << artifact->filePath() + << artifact->timestamp().toString(); + + if (m_buildOptions.forceTimestampCheck()) { + artifact->setTimestamp(FileInfo(artifact->filePath()).lastModified()); + qCDebug(lcUpToDateCheck) << "timestamp retrieved from filesystem:" + << artifact->timestamp().toString(); + } + + if (!artifact->timestamp().isValid()) { + qCDebug(lcUpToDateCheck) << "invalid timestamp. Out of date."; + return false; + } + + for (Artifact *childArtifact : filterByType(artifact->children)) { + QBS_CHECK(!childArtifact->alwaysUpdated || childArtifact->timestamp().isValid()); + qCDebug(lcUpToDateCheck) << "child timestamp" + << childArtifact->timestamp().toString() + << childArtifact->filePath(); + if (artifact->timestamp() < childArtifact->timestamp()) + return false; + } + + for (FileDependency *fileDependency : qAsConst(artifact->fileDependencies)) { + if (!fileDependency->timestamp().isValid()) { + qCDebug(lcUpToDateCheck) << "file dependency doesn't exist" + << fileDependency->filePath(); + return false; + } + qCDebug(lcUpToDateCheck) << "file dependency timestamp" + << fileDependency->timestamp().toString() + << fileDependency->filePath(); + if (artifact->timestamp() < fileDependency->timestamp()) + return false; + } + + return true; +} + +bool Executor::mustExecuteTransformer(const TransformerPtr &transformer) const +{ + if (transformer->alwaysRun) + return true; + if (transformer->markedForRerun) { + qCDebug(lcUpToDateCheck) << "explicitly marked for re-run."; + return true; + } + + bool hasAlwaysUpdatedArtifacts = false; + bool hasUpToDateNotAlwaysUpdatedArtifacts = false; + for (Artifact *artifact : qAsConst(transformer->outputs)) { + if (isUpToDate(artifact)) { + if (artifact->alwaysUpdated) + hasAlwaysUpdatedArtifacts = true; + else + hasUpToDateNotAlwaysUpdatedArtifacts = true; + } else if (artifact->alwaysUpdated || m_buildOptions.forceTimestampCheck()) { + return true; + } + } + + if (commandsNeedRerun(transformer.get(), transformer->product().get(), m_productsByName, + m_projectsByName)) { + return true; + } + + // If all artifacts in a transformer have "alwaysUpdated" set to false, that transformer is + // run if and only if *all* of them are out of date. + return !hasAlwaysUpdatedArtifacts && !hasUpToDateNotAlwaysUpdatedArtifacts; +} + +void Executor::buildArtifact(Artifact *artifact) +{ + qCDebug(lcExec) << relativeArtifactFileName(artifact); + + QBS_CHECK(artifact->buildState == BuildGraphNode::Buildable); + + if (artifact->artifactType != Artifact::SourceFile && !checkNodeProduct(artifact)) + return; + + // skip artifacts without transformer + if (artifact->artifactType != Artifact::Generated) { + // For source artifacts, that were not reachable when initializing the build, we must + // retrieve timestamps. This can happen, if a dependency that's added during the build + // makes the source artifact reachable. + if (artifact->artifactType == Artifact::SourceFile && !artifact->timestampRetrieved) + retrieveSourceFileTimestamp(artifact); + + qCDebug(lcExec) << "artifact type" << toString(artifact->artifactType) << "Skipping."; + finishArtifact(artifact); + return; + } + + // Every generated artifact must have a transformer. + QBS_CHECK(artifact->transformer); + potentiallyRunTransformer(artifact->transformer); +} + +void Executor::executeRuleNode(RuleNode *ruleNode) +{ + AccumulatingTimer rulesTimer(m_buildOptions.logElapsedTime() ? &m_elapsedTimeRules : nullptr); + + if (!checkNodeProduct(ruleNode)) + return; + + QBS_CHECK(!m_evalContext->engine()->isActive()); + + RuleNode::ApplicationResult result; + ruleNode->apply(m_logger, m_productsByName, m_projectsByName, &result); + updateLeaves(result.createdArtifacts); + updateLeaves(result.invalidatedArtifacts); + m_artifactsRemovedFromDisk << result.removedArtifacts; + + if (m_progressObserver) { + const int transformerCount = ruleNode->transformerCount(); + if (transformerCount == 0) { + m_progressObserver->incrementProgressValue(); + } else { + m_pendingTransformersPerRule.insert(std::make_pair(ruleNode->rule().get(), + transformerCount)); + } + } + + finishNode(ruleNode); +} + +void Executor::finishJob(ExecutorJob *job, bool success) +{ + QBS_CHECK(job); + QBS_CHECK(m_state != ExecutorIdle); + + const JobMap::Iterator it = m_processingJobs.find(job); + QBS_CHECK(it != m_processingJobs.end()); + const TransformerPtr transformer = it.value(); + m_processingJobs.erase(it); + m_availableJobs.push_back(job); + updateJobCounts(transformer.get(), -1); + if (success) { + m_project->buildData->setDirty(); + for (Artifact * const artifact : qAsConst(transformer->outputs)) { + if (artifact->alwaysUpdated) { + artifact->setTimestamp(FileTime::currentTime()); + for (Artifact * const parent : artifact->parentArtifacts()) + parent->transformer->markedForRerun = true; + if (m_buildOptions.forceOutputCheck() + && !m_buildOptions.dryRun() && !FileInfo(artifact->filePath()).exists()) { + if (transformer->rule) { + if (!transformer->rule->name.isEmpty()) { + throw ErrorInfo(tr("Rule '%1' declares artifact '%2', " + "but the artifact was not produced.") + .arg(transformer->rule->name, artifact->filePath())); + } + throw ErrorInfo(tr("Rule declares artifact '%1', " + "but the artifact was not produced.") + .arg(artifact->filePath())); + } + throw ErrorInfo(tr("Transformer declares artifact '%1', " + "but the artifact was not produced.") + .arg(artifact->filePath())); + } + } else { + artifact->setTimestamp(FileInfo(artifact->filePath()).lastModified()); + } + } + finishTransformer(transformer); + } + + if (!success && !m_buildOptions.keepGoing()) + cancelJobs(); + + if (m_state == ExecutorRunning && m_progressObserver && m_progressObserver->canceled()) { + qCDebug(lcExec) << "Received cancel request; canceling build."; + m_explicitlyCanceled = true; + cancelJobs(); + } + + if (m_state == ExecutorCanceling) { + if (m_processingJobs.empty()) { + qCDebug(lcExec) << "All pending jobs are done, finishing."; + finish(); + } + return; + } + + if (!scheduleJobs()) { + qCDebug(lcExec) << "Nothing left to build; finishing."; + finish(); + } +} + +static bool allChildrenBuilt(BuildGraphNode *node) +{ + return Internal::all_of(node->children, std::mem_fn(&BuildGraphNode::isBuilt)); +} + +void Executor::finishNode(BuildGraphNode *leaf) +{ + leaf->buildState = BuildGraphNode::Built; + for (BuildGraphNode * const parent : qAsConst(leaf->parents)) { + if (parent->buildState != BuildGraphNode::Buildable) { + qCDebug(lcExec).noquote() << "parent" << parent->toString() + << "build state:" << toString(parent->buildState); + continue; + } + + if (allChildrenBuilt(parent)) { + m_leaves.push(parent); + qCDebug(lcExec).noquote() << "finishNode adds leaf" + << parent->toString() << toString(parent->buildState); + } else { + qCDebug(lcExec).noquote() << "parent" << parent->toString() + << "build state:" << toString(parent->buildState); + } + } +} + +void Executor::finishArtifact(Artifact *leaf) +{ + QBS_CHECK(leaf); + qCDebug(lcExec) << "finishArtifact" << relativeArtifactFileName(leaf); + finishNode(leaf); +} + +QString Executor::configString() const +{ + return tr(" for configuration %1").arg(m_project->id()); +} + +bool Executor::transformerHasMatchingOutputTags(const TransformerConstPtr &transformer) const +{ + if (m_activeFileTags.empty()) + return true; // No filtering requested. + + return Internal::any_of(transformer->outputs, [this](const Artifact *a) { + return artifactHasMatchingOutputTags(a); }); +} + +bool Executor::artifactHasMatchingOutputTags(const Artifact *artifact) const +{ + return m_activeFileTags.intersects(artifact->fileTags()) + || m_tagsNeededForFilesToConsider.intersects(artifact->fileTags()); +} + +bool Executor::transformerHasMatchingInputFiles(const TransformerConstPtr &transformer) const +{ + if (m_buildOptions.filesToConsider().empty()) + return true; // No filtering requested. + if (!m_productsOfFilesToConsider.contains(transformer->product())) + return false; + if (transformer->inputs.empty()) + return true; + for (const Artifact * const input : qAsConst(transformer->inputs)) { + const auto files = m_buildOptions.filesToConsider(); + for (const QString &filePath : files) { + if (input->filePath() == filePath + || input->fileTags().intersects(m_tagsNeededForFilesToConsider)) { + return true; + } + } + } + + return false; +} + +void Executor::setupJobLimits() +{ + Settings settings(m_buildOptions.settingsDirectory()); + for (const auto &p : qAsConst(m_productsToBuild)) { + const Preferences prefs(&settings, p->profile()); + const JobLimits &jobLimitsFromSettings = prefs.jobLimits(); + JobLimits effectiveJobLimits; + if (m_buildOptions.projectJobLimitsTakePrecedence()) { + effectiveJobLimits.update(jobLimitsFromSettings).update(m_buildOptions.jobLimits()) + .update(p->jobLimits); + } else { + effectiveJobLimits.update(p->jobLimits).update(jobLimitsFromSettings) + .update(m_buildOptions.jobLimits()); + } + m_jobLimitsPerProduct.insert(std::make_pair(p.get(), effectiveJobLimits)); + } +} + +void Executor::updateJobCounts(const Transformer *transformer, int diff) +{ + for (const QString &jobPool : transformer->jobPools()) + m_jobCountPerPool[jobPool] += diff; +} + +void Executor::cancelJobs() +{ + if (m_state == ExecutorCanceling) + return; + qCDebug(lcExec) << "Canceling all jobs."; + setState(ExecutorCanceling); + const auto jobs = m_processingJobs.keys(); + for (ExecutorJob *job : jobs) + job->cancel(); +} + +void Executor::setupProgressObserver() +{ + if (!m_progressObserver) + return; + int totalEffort = 1; // For the effort after the last rule application; + for (const auto &product : qAsConst(m_productsToBuild)) { + QBS_CHECK(product->buildData); + const auto filtered = filterByType(product->buildData->allNodes()); + totalEffort += std::distance(filtered.begin(), filtered.end()); + } + m_progressObserver->initialize(tr("Building%1").arg(configString()), totalEffort); +} + +void Executor::doSanityChecks() +{ + QBS_CHECK(m_project); + QBS_CHECK(!m_productsToBuild.empty()); + for (const auto &product : qAsConst(m_productsToBuild)) { + QBS_CHECK(product->buildData); + QBS_CHECK(product->topLevelProject() == m_project.get()); + } +} + +void Executor::handleError(const ErrorInfo &error) +{ + const auto items = error.items(); + for (const ErrorItem &ei : items) + m_error.append(ei); + if (m_processingJobs.empty()) + finish(); + else + cancelJobs(); +} + +void Executor::addExecutorJobs() +{ + const int count = m_buildOptions.maxJobCount(); + qCDebug(lcExec) << "preparing executor for" << count << "jobs in parallel"; + m_allJobs.reserve(count); + m_availableJobs.reserve(count); + for (int i = 1; i <= count; i++) { + m_allJobs.push_back(std::make_unique(m_logger)); + const auto job = m_allJobs.back().get(); + job->setMainThreadScriptEngine(m_evalContext->engine()); + job->setObjectName(QStringLiteral("J%1").arg(i)); + job->setDryRun(m_buildOptions.dryRun()); + job->setEchoMode(m_buildOptions.echoMode()); + m_availableJobs.push_back(job); + connect(job, &ExecutorJob::reportCommandDescription, + this, &Executor::reportCommandDescription); + connect(job, &ExecutorJob::reportProcessResult, this, &Executor::reportProcessResult); + connect(job, &ExecutorJob::finished, + this, &Executor::onJobFinished, Qt::QueuedConnection); + } +} + +void Executor::rescueOldBuildData(Artifact *artifact, bool *childrenAdded = nullptr) +{ + if (childrenAdded) + *childrenAdded = false; + if (!artifact->oldDataPossiblyPresent) + return; + artifact->oldDataPossiblyPresent = false; + if (artifact->artifactType != Artifact::Generated) + return; + + ResolvedProduct * const product = artifact->product.get(); + const RescuableArtifactData rad + = product->buildData->removeFromRescuableArtifactData(artifact->filePath()); + if (!rad.isValid()) + return; + qCDebug(lcBuildGraph) << "Attempting to rescue data of artifact" << artifact->fileName(); + + std::vector childrenToConnect; + bool canRescue = artifact->transformer->commands == rad.commands; + if (canRescue) { + ResolvedProductPtr pseudoProduct = ResolvedProduct::create(); + for (const RescuableArtifactData::ChildData &cd : rad.children) { + pseudoProduct->name = cd.productName; + pseudoProduct->multiplexConfigurationId = cd.productMultiplexId; + Artifact * const child = lookupArtifact(pseudoProduct, m_project->buildData.get(), + cd.childFilePath, true); + if (artifact->children.contains(child)) + continue; + if (!child) { + // If a child has disappeared, we must re-build even if the commands + // are the same. Example: Header file included in cpp file does not exist anymore. + canRescue = false; + qCDebug(lcBuildGraph) << "Former child artifact" << cd.childFilePath + << "does not exist anymore."; + const RescuableArtifactData childRad + = product->buildData->removeFromRescuableArtifactData(cd.childFilePath); + if (childRad.isValid()) { + m_artifactsRemovedFromDisk << artifact->filePath(); + removeGeneratedArtifactFromDisk(cd.childFilePath, m_logger); + } + } + if (!cd.addedByScanner) { + // If an artifact has disappeared from the list of children, the commands + // might need to run again. + canRescue = false; + qCDebug(lcBuildGraph) << "Former child artifact" << cd.childFilePath << + "is no longer in the list of children"; + } + if (canRescue) + childrenToConnect.push_back(child); + } + for (const QString &depPath : rad.fileDependencies) { + const auto &depList = m_project->buildData->lookupFiles(depPath); + if (depList.empty()) { + canRescue = false; + qCDebug(lcBuildGraph) << "File dependency" << depPath + << "not in the project's list of dependencies anymore."; + break; + } + const auto depFinder = [](const FileResourceBase *f) { + return f->fileType() == FileResourceBase::FileTypeDependency; + }; + const auto depIt = std::find_if(depList.cbegin(), depList.cend(), depFinder); + if (depIt == depList.cend()) { + canRescue = false; + qCDebug(lcBuildGraph) << "File dependency" << depPath + << "not in the project's list of dependencies anymore."; + break; + } + artifact->fileDependencies.insert(static_cast(*depIt)); + } + + if (canRescue) { + const TypeFilter childArtifacts(artifact->children); + const size_t newChildCount = childrenToConnect.size() + + std::distance(childArtifacts.begin(), childArtifacts.end()); + QBS_CHECK(newChildCount >= rad.children.size()); + if (newChildCount > rad.children.size()) { + canRescue = false; + qCDebug(lcBuildGraph) << "Artifact has children not present in rescue data."; + } + } + } else { + qCDebug(lcBuildGraph) << "Transformer commands changed."; + } + + if (canRescue) { + artifact->transformer->propertiesRequestedInPrepareScript + = rad.propertiesRequestedInPrepareScript; + artifact->transformer->propertiesRequestedInCommands + = rad.propertiesRequestedInCommands; + artifact->transformer->propertiesRequestedFromArtifactInPrepareScript + = rad.propertiesRequestedFromArtifactInPrepareScript; + artifact->transformer->propertiesRequestedFromArtifactInCommands + = rad.propertiesRequestedFromArtifactInCommands; + artifact->transformer->importedFilesUsedInPrepareScript + = rad.importedFilesUsedInPrepareScript; + artifact->transformer->importedFilesUsedInCommands = rad.importedFilesUsedInCommands; + artifact->transformer->depsRequestedInPrepareScript = rad.depsRequestedInPrepareScript; + artifact->transformer->depsRequestedInCommands = rad.depsRequestedInCommands; + artifact->transformer->artifactsMapRequestedInPrepareScript + = rad.artifactsMapRequestedInPrepareScript; + artifact->transformer->artifactsMapRequestedInCommands + = rad.artifactsMapRequestedInCommands; + artifact->transformer->exportedModulesAccessedInPrepareScript + = rad.exportedModulesAccessedInPrepareScript; + artifact->transformer->exportedModulesAccessedInCommands + = rad.exportedModulesAccessedInCommands; + artifact->transformer->lastCommandExecutionTime = rad.lastCommandExecutionTime; + artifact->transformer->lastPrepareScriptExecutionTime = rad.lastPrepareScriptExecutionTime; + artifact->transformer->commandsNeedChangeTracking = true; + artifact->setTimestamp(rad.timeStamp); + artifact->transformer->markedForRerun + = artifact->transformer->markedForRerun || rad.knownOutOfDate; + if (childrenAdded && !childrenToConnect.empty()) + *childrenAdded = true; + for (Artifact * const child : childrenToConnect) { + if (safeConnect(artifact, child)) + artifact->childrenAddedByScanner << child; + } + qCDebug(lcBuildGraph) << "Data was rescued."; + } else { + removeGeneratedArtifactFromDisk(artifact, m_logger); + m_artifactsRemovedFromDisk << artifact->filePath(); + qCDebug(lcBuildGraph) << "Data not rescued."; + } +} + +bool Executor::checkForUnbuiltDependencies(Artifact *artifact) +{ + bool buildingDependenciesFound = false; + NodeSet unbuiltDependencies; + for (BuildGraphNode * const dependency : qAsConst(artifact->children)) { + switch (dependency->buildState) { + case BuildGraphNode::Untouched: + case BuildGraphNode::Buildable: + qCDebug(lcExec).noquote() << "unbuilt dependency:" << dependency->toString(); + unbuiltDependencies += dependency; + break; + case BuildGraphNode::Building: { + qCDebug(lcExec).noquote() << "dependency in state 'Building':" << dependency->toString(); + buildingDependenciesFound = true; + break; + } + case BuildGraphNode::Built: + // do nothing + break; + } + } + if (!unbuiltDependencies.empty()) { + artifact->inputsScanned = false; + updateLeaves(unbuiltDependencies); + return true; + } + if (buildingDependenciesFound) { + artifact->inputsScanned = false; + return true; + } + return false; +} + +void Executor::potentiallyRunTransformer(const TransformerPtr &transformer) +{ + for (Artifact * const output : qAsConst(transformer->outputs)) { + // Rescuing build data can introduce new dependencies, potentially delaying execution of + // this transformer. + bool childrenAddedDueToRescue; + rescueOldBuildData(output, &childrenAddedDueToRescue); + if (childrenAddedDueToRescue && checkForUnbuiltDependencies(output)) + return; + } + + if (!transformerHasMatchingOutputTags(transformer)) { + qCDebug(lcExec) << "file tags do not match. Skipping."; + finishTransformer(transformer); + return; + } + + if (!transformerHasMatchingInputFiles(transformer)) { + qCDebug(lcExec) << "input files do not match. Skipping."; + finishTransformer(transformer); + return; + } + + const bool mustExecute = mustExecuteTransformer(transformer); + if (mustExecute || m_buildOptions.forceTimestampCheck()) { + for (Artifact * const output : qAsConst(transformer->outputs)) { + // Scan all input artifacts. If new dependencies were found during scanning, delay + // execution of this transformer. + InputArtifactScanner scanner(output, m_inputArtifactScanContext, m_logger); + AccumulatingTimer scanTimer(m_buildOptions.logElapsedTime() + ? &m_elapsedTimeScanners : nullptr); + scanner.scan(); + scanTimer.stop(); + if (scanner.newDependencyAdded() && checkForUnbuiltDependencies(output)) + return; + } + } + + if (!mustExecute) { + qCDebug(lcExec) << "Up to date. Skipping."; + finishTransformer(transformer); + return; + } + + if (m_buildOptions.executeRulesOnly()) + finishTransformer(transformer); + else + runTransformer(transformer); +} + +void Executor::runTransformer(const TransformerPtr &transformer) +{ + QBS_CHECK(transformer); + + // create the output directories + if (!m_buildOptions.dryRun()) { + for (Artifact * const output : qAsConst(transformer->outputs)) { + QDir outDir = QFileInfo(output->filePath()).absoluteDir(); + if (!outDir.exists() && !outDir.mkpath(StringConstants::dot())) { + throw ErrorInfo(tr("Failed to create directory '%1'.") + .arg(QDir::toNativeSeparators(outDir.absolutePath()))); + } + } + } + + QBS_CHECK(!m_availableJobs.empty()); + ExecutorJob *job = m_availableJobs.takeFirst(); + for (Artifact * const artifact : qAsConst(transformer->outputs)) + artifact->buildState = BuildGraphNode::Building; + m_processingJobs.insert(job, transformer); + updateJobCounts(transformer.get(), 1); + job->run(transformer.get()); +} + +void Executor::finishTransformer(const TransformerPtr &transformer) +{ + transformer->markedForRerun = false; + for (Artifact * const artifact : qAsConst(transformer->outputs)) { + possiblyInstallArtifact(artifact); + finishArtifact(artifact); + } + if (m_progressObserver) { + const auto it = m_pendingTransformersPerRule.find(transformer->rule.get()); + QBS_CHECK(it != m_pendingTransformersPerRule.cend()); + if (--it->second == 0) { + m_progressObserver->incrementProgressValue(); + m_pendingTransformersPerRule.erase(it); + } + } +} + +void Executor::possiblyInstallArtifact(const Artifact *artifact) +{ + AccumulatingTimer installTimer(m_buildOptions.logElapsedTime() + ? &m_elapsedTimeInstalling : nullptr); + + if (m_buildOptions.install() && !m_buildOptions.executeRulesOnly() + && (m_activeFileTags.empty() || artifactHasMatchingOutputTags(artifact)) + && artifact->properties->qbsPropertyValue(StringConstants::installProperty()) + .toBool()) { + m_productInstaller->copyFile(artifact); + } +} + +void Executor::onJobFinished(const qbs::ErrorInfo &err) +{ + try { + auto const job = qobject_cast(sender()); + QBS_CHECK(job); + if (m_evalContext->engine()->isActive()) { + qCDebug(lcExec) << "Executor job finished while rule execution is pausing. " + "Delaying slot execution."; + QTimer::singleShot(0, job, [job, err] { emit job->finished(err); }); + return; + } + + if (err.hasError()) { + if (m_buildOptions.keepGoing()) { + ErrorInfo fullWarning(err); + fullWarning.prepend(Tr::tr("Ignoring the following errors on user request:")); + m_logger.printWarning(fullWarning); + } else { + if (!m_error.hasError()) + m_error = err; // All but the first one could be due to canceling. + } + } + + finishJob(job, !err.hasError()); + } catch (const ErrorInfo &error) { + handleError(error); + } +} + +void Executor::checkForUnbuiltProducts() +{ + if (m_buildOptions.executeRulesOnly()) + return; + std::vector unbuiltProducts; + for (const ResolvedProductPtr &product : qAsConst(m_productsToBuild)) { + bool productBuilt = true; + for (BuildGraphNode *rootNode : qAsConst(product->buildData->rootNodes())) { + if (rootNode->buildState != BuildGraphNode::Built) { + productBuilt = false; + unbuiltProducts.push_back(product); + break; + } + } + if (productBuilt) { + // Any element still left after a successful build has not been re-created + // by any rule and therefore does not exist anymore as an artifact. + const AllRescuableArtifactData rad = product->buildData->rescuableArtifactData(); + for (auto it = rad.cbegin(); it != rad.cend(); ++it) { + removeGeneratedArtifactFromDisk(it.key(), m_logger); + product->buildData->removeFromRescuableArtifactData(it.key()); + m_artifactsRemovedFromDisk << it.key(); + } + } + } + + if (unbuiltProducts.empty()) { + m_logger.qbsInfo() << Tr::tr("Build done%1.").arg(configString()); + } else { + m_error.append(Tr::tr("The following products could not be built%1:").arg(configString())); + auto productNames = transformed(unbuiltProducts, [](const auto &p) { + return p->fullDisplayName(); }); + std::sort(productNames.begin(), productNames.end()); + m_error.append(productNames.join(QLatin1String(", "))); + } +} + +bool Executor::checkNodeProduct(BuildGraphNode *node) +{ + if (!m_partialBuild || contains(m_productsToBuild, node->product.lock())) + return true; + + // TODO: Turn this into a warning once we have a reliable C++ scanner. + qCDebug(lcExec).noquote() + << "Ignoring node " << node->toString() << ", which belongs to a " + "product that is not part of the list of products to build. " + "Possible reasons are an erroneous project design or a false " + "positive from a dependency scanner."; + finishNode(node); + return false; +} + +void Executor::finish() +{ + QBS_ASSERT(m_state != ExecutorIdle, /* ignore */); + QBS_ASSERT(!m_evalContext || !m_evalContext->engine()->isActive(), /* ignore */); + + checkForUnbuiltProducts(); + if (m_explicitlyCanceled) { + QString message = Tr::tr(m_buildOptions.executeRulesOnly() + ? "Rule execution canceled" : "Build canceled"); + m_error.append(Tr::tr("%1%2.").arg(message, configString())); + } + setState(ExecutorIdle); + if (m_progressObserver) { + m_progressObserver->setFinished(); + m_cancelationTimer->stop(); + } + + EmptyDirectoriesRemover(m_project.get(), m_logger) + .removeEmptyParentDirectories(m_artifactsRemovedFromDisk); + + if (m_buildOptions.logElapsedTime()) { + m_logger.qbsLog(LoggerInfo, true) << "\t" << Tr::tr("Rule execution took %1.") + .arg(elapsedTimeString(m_elapsedTimeRules)); + m_logger.qbsLog(LoggerInfo, true) << "\t" << Tr::tr("Artifact scanning took %1.") + .arg(elapsedTimeString(m_elapsedTimeScanners)); + m_logger.qbsLog(LoggerInfo, true) << "\t" << Tr::tr("Installing artifacts took %1.") + .arg(elapsedTimeString(m_elapsedTimeInstalling)); + } + + emit finished(); +} + +void Executor::checkForCancellation() +{ + QBS_ASSERT(m_progressObserver, return); + if (m_state == ExecutorRunning && m_progressObserver->canceled()) { + cancelJobs(); + if (m_evalContext->engine()->isActive()) + m_evalContext->engine()->cancel(); + } +} + +bool Executor::visit(Artifact *artifact) +{ + QBS_CHECK(artifact->buildState != BuildGraphNode::Untouched); + buildArtifact(artifact); + return false; +} + +bool Executor::visit(RuleNode *ruleNode) +{ + QBS_CHECK(ruleNode->buildState != BuildGraphNode::Untouched); + executeRuleNode(ruleNode); + return false; +} + +/** + * Sets the state of all artifacts in the graph to "untouched". + * This must be done before doing a build. + * + * Retrieves the timestamps of source artifacts. + * + * This function also fills the list of changed source files. + */ +void Executor::prepareAllNodes() +{ + for (const ResolvedProductPtr &product : m_allProducts) { + if (product->enabled) { + QBS_CHECK(product->buildData); + for (BuildGraphNode * const node : qAsConst(product->buildData->allNodes())) + node->buildState = BuildGraphNode::Untouched; + } + } + for (const ResolvedProductPtr &product : qAsConst(m_productsToBuild)) { + QBS_CHECK(product->buildData); + for (Artifact * const artifact : filterByType(product->buildData->allNodes())) + prepareArtifact(artifact); + } +} + +void Executor::syncFileDependencies() +{ + Set &globalFileDepList = m_project->buildData->fileDependencies; + for (auto it = globalFileDepList.begin(); it != globalFileDepList.end(); ) { + FileDependency * const dep = *it; + FileInfo fi(dep->filePath()); + if (fi.exists()) { + dep->setTimestamp(fi.lastModified()); + ++it; + continue; + } + qCDebug(lcBuildGraph()) << "file dependency" << dep->filePath() << "no longer exists; " + "removing from lookup table"; + m_project->buildData->removeFromLookupTable(dep); + bool isReferencedByArtifact = false; + for (const auto &product : m_allProducts) { + if (!product->buildData) + continue; + const auto artifactList = filterByType(product->buildData->allNodes()); + isReferencedByArtifact = Internal::any_of(artifactList, [dep](const Artifact *a) { + return a->fileDependencies.contains(dep); }); + // TODO: Would it be safe to mark the artifact as "not up to date" here and clear + // its list of file dependencies, rather than doing the check again in + // isUpToDate()? + if (isReferencedByArtifact) + break; + } + if (!isReferencedByArtifact) { + qCDebug(lcBuildGraph()) << "dependency is not referenced by any artifact, deleting"; + it = globalFileDepList.erase(it); + delete dep; + } else { + dep->clearTimestamp(); + ++it; + } + } +} + +void Executor::prepareArtifact(Artifact *artifact) +{ + artifact->inputsScanned = false; + artifact->timestampRetrieved = false; + + if (artifact->artifactType == Artifact::SourceFile) { + retrieveSourceFileTimestamp(artifact); + possiblyInstallArtifact(artifact); + } +} + +void Executor::setupForBuildingSelectedFiles(const BuildGraphNode *node) +{ + if (node->type() != BuildGraphNode::RuleNodeType) + return; + if (m_buildOptions.filesToConsider().empty()) + return; + if (!m_productsOfFilesToConsider.contains(node->product.lock())) + return; + const auto ruleNode = static_cast(node); + const Rule * const rule = ruleNode->rule().get(); + if (rule->inputs.intersects(m_tagsOfFilesToConsider)) { + FileTags otherInputs = rule->auxiliaryInputs; + otherInputs.unite(rule->explicitlyDependsOn).subtract(rule->excludedInputs); + m_tagsNeededForFilesToConsider.unite(otherInputs); + } else if (rule->collectedOutputFileTags().intersects(m_tagsNeededForFilesToConsider)) { + FileTags allInputs = rule->inputs; + allInputs.unite(rule->auxiliaryInputs).unite(rule->explicitlyDependsOn) + .subtract(rule->excludedInputs); + m_tagsNeededForFilesToConsider.unite(allInputs); + } +} + +/** + * Walk the build graph top-down from the roots and for each reachable node N + * - mark N as buildable. + */ +void Executor::prepareReachableNodes() +{ + for (BuildGraphNode * const root : qAsConst(m_roots)) + prepareReachableNodes_impl(root); +} + +void Executor::prepareReachableNodes_impl(BuildGraphNode *node) +{ + setupForBuildingSelectedFiles(node); + + if (node->buildState != BuildGraphNode::Untouched) + return; + + node->buildState = BuildGraphNode::Buildable; + for (BuildGraphNode *child : qAsConst(node->children)) + prepareReachableNodes_impl(child); +} + +void Executor::prepareProducts() +{ + ProductPrioritySetter prioritySetter(m_allProducts); + prioritySetter.apply(); + for (const ResolvedProductPtr &product : qAsConst(m_productsToBuild)) { + EnvironmentScriptRunner(product.get(), m_evalContext.get(), m_project->environment) + .setupForBuild(); + } +} + +void Executor::setupRootNodes() +{ + m_roots.clear(); + for (const ResolvedProductPtr &product : qAsConst(m_productsToBuild)) + m_roots += product->buildData->rootNodes(); +} + +void Executor::setState(ExecutorState s) +{ + if (m_state == s) + return; + m_state = s; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/executor.h b/src/lib/corelib/buildgraph/executor.h new file mode 100644 index 00000000..cc879e12 --- /dev/null +++ b/src/lib/corelib/buildgraph/executor.h @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILDGRAPHEXECUTOR_H +#define QBS_BUILDGRAPHEXECUTOR_H + +#include "forward_decls.h" +#include "buildgraphvisitor.h" +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE + +namespace qbs { +class ProcessResult; + +namespace Internal { +class ExecutorJob; +class FileTime; +class InputArtifactScannerContext; +class ProductInstaller; +class ProgressObserver; +class RuleNode; + +class Executor : public QObject, private BuildGraphVisitor +{ + Q_OBJECT + +public: + void build(); + + Executor(Logger logger, QObject *parent = nullptr); + ~Executor() override; + + void setProject(const TopLevelProjectPtr &project); + void setProducts(const QVector &productsToBuild); + void setBuildOptions(const BuildOptions &buildOptions); + void setProgressObserver(ProgressObserver *observer) { m_progressObserver = observer; } + + ErrorInfo error() const { return m_error; } + +signals: + void reportCommandDescription(const QString &highlight, const QString &message); + void reportProcessResult(const qbs::ProcessResult &result); + + void finished(); + +private: + void onJobFinished(const qbs::ErrorInfo &err); + void finish(); + void checkForCancellation(); + + // BuildGraphVisitor implementation + bool visit(Artifact *artifact) override; + bool visit(RuleNode *ruleNode) override; + + enum ExecutorState { ExecutorIdle, ExecutorRunning, ExecutorCanceling }; + + struct ComparePriority + { + bool operator() (const BuildGraphNode *x, const BuildGraphNode *y) const; + }; + + using Leaves = std::priority_queue, + ComparePriority>; + + void doBuild(); + void prepareAllNodes(); + void syncFileDependencies(); + void prepareArtifact(Artifact *artifact); + void setupForBuildingSelectedFiles(const BuildGraphNode *node); + void prepareReachableNodes(); + void prepareReachableNodes_impl(BuildGraphNode *node); + void prepareProducts(); + void setupRootNodes(); + void initLeaves(); + void updateLeaves(const NodeSet &nodes); + void updateLeaves(BuildGraphNode *node, NodeSet &seenNodes); + bool scheduleJobs(); + void buildArtifact(Artifact *artifact); + void executeRuleNode(RuleNode *ruleNode); + void finishJob(ExecutorJob *job, bool success); + void finishNode(BuildGraphNode *leaf); + void finishArtifact(Artifact *artifact); + void setState(ExecutorState); + void addExecutorJobs(); + void cancelJobs(); + void setupProgressObserver(); + void doSanityChecks(); + void handleError(const ErrorInfo &error); + void rescueOldBuildData(Artifact *artifact, bool *childrenAdded); + bool checkForUnbuiltDependencies(Artifact *artifact); + void potentiallyRunTransformer(const TransformerPtr &transformer); + void runTransformer(const TransformerPtr &transformer); + void finishTransformer(const TransformerPtr &transformer); + void possiblyInstallArtifact(const Artifact *artifact); + void checkForUnbuiltProducts(); + bool checkNodeProduct(BuildGraphNode *node); + + bool mustExecuteTransformer(const TransformerPtr &transformer) const; + bool isUpToDate(Artifact *artifact) const; + void retrieveSourceFileTimestamp(Artifact *artifact) const; + FileTime recursiveFileTime(const QString &filePath) const; + QString configString() const; + bool transformerHasMatchingOutputTags(const TransformerConstPtr &transformer) const; + bool artifactHasMatchingOutputTags(const Artifact *artifact) const; + bool transformerHasMatchingInputFiles(const TransformerConstPtr &transformer) const; + + void setupJobLimits(); + void updateJobCounts(const Transformer *transformer, int diff); + bool schedulingBlockedByJobLimit(const BuildGraphNode *node); + + using JobMap = QHash; + JobMap m_processingJobs; + + ProductInstaller *m_productInstaller; + RulesEvaluationContextPtr m_evalContext; + BuildOptions m_buildOptions; + Logger m_logger; + ProgressObserver *m_progressObserver; + std::vector> m_allJobs; + QList m_availableJobs; + ExecutorState m_state; + TopLevelProjectPtr m_project; + QVector m_productsToBuild; + std::vector m_allProducts; + std::unordered_map m_productsByName; + std::unordered_map m_projectsByName; + std::unordered_map m_jobCountPerPool; + std::unordered_map m_jobLimitsPerProduct; + std::unordered_map m_pendingTransformersPerRule; + NodeSet m_roots; + Leaves m_leaves; + InputArtifactScannerContext *m_inputArtifactScanContext; + ErrorInfo m_error; + bool m_explicitlyCanceled = false; + FileTags m_activeFileTags; + FileTags m_tagsOfFilesToConsider; + FileTags m_tagsNeededForFilesToConsider; + QList m_productsOfFilesToConsider; + QTimer * const m_cancelationTimer; + QStringList m_artifactsRemovedFromDisk; + bool m_partialBuild = false; + qint64 m_elapsedTimeRules = 0; + qint64 m_elapsedTimeScanners = 0; + qint64 m_elapsedTimeInstalling = 0; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILDGRAPHEXECUTOR_H diff --git a/src/lib/corelib/buildgraph/executorjob.cpp b/src/lib/corelib/buildgraph/executorjob.cpp new file mode 100644 index 00000000..bc96cbb6 --- /dev/null +++ b/src/lib/corelib/buildgraph/executorjob.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "executorjob.h" + +#include "artifact.h" +#include "jscommandexecutor.h" +#include "processcommandexecutor.h" +#include "rulecommands.h" +#include "transformer.h" +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +ExecutorJob::ExecutorJob(const Logger &logger, QObject *parent) + : QObject(parent) + , m_processCommandExecutor(new ProcessCommandExecutor(logger, this)) + , m_jsCommandExecutor(new JsCommandExecutor(logger, this)) +{ + connect(m_processCommandExecutor, &AbstractCommandExecutor::reportCommandDescription, + this, &ExecutorJob::reportCommandDescription); + connect(m_processCommandExecutor, &ProcessCommandExecutor::reportProcessResult, + this, &ExecutorJob::reportProcessResult); + connect(m_processCommandExecutor, &AbstractCommandExecutor::finished, + this, &ExecutorJob::onCommandFinished); + connect(m_jsCommandExecutor, &AbstractCommandExecutor::reportCommandDescription, + this, &ExecutorJob::reportCommandDescription); + connect(m_jsCommandExecutor, &AbstractCommandExecutor::finished, + this, &ExecutorJob::onCommandFinished); + reset(); +} + +ExecutorJob::~ExecutorJob() = default; + +void ExecutorJob::setMainThreadScriptEngine(ScriptEngine *engine) +{ + m_processCommandExecutor->setMainThreadScriptEngine(engine); + m_jsCommandExecutor->setMainThreadScriptEngine(engine); +} + +void ExecutorJob::setDryRun(bool enabled) +{ + m_processCommandExecutor->setDryRunEnabled(enabled); + m_jsCommandExecutor->setDryRunEnabled(enabled); +} + +void ExecutorJob::setEchoMode(CommandEchoMode echoMode) +{ + m_processCommandExecutor->setEchoMode(echoMode); + m_jsCommandExecutor->setEchoMode(echoMode); +} + +void ExecutorJob::run(Transformer *t) +{ + QBS_ASSERT(m_currentCommandIdx == -1, return); + + if (t->commands.empty()) { + setFinished(); + return; + } + + t->propertiesRequestedInCommands.clear(); + t->propertiesRequestedFromArtifactInCommands.clear(); + t->importedFilesUsedInCommands.clear(); + t->depsRequestedInCommands.clear(); + t->artifactsMapRequestedInCommands.clear(); + t->exportedModulesAccessedInCommands.clear(); + t->lastCommandExecutionTime = FileTime::currentTime(); + QBS_CHECK(!t->outputs.empty()); + m_processCommandExecutor->setProcessEnvironment( + (*t->outputs.cbegin())->product->buildEnvironment); + m_transformer = t; + m_jobPools = t->jobPools(); + runNextCommand(); +} + +void ExecutorJob::cancel() +{ + if (!m_currentCommandExecutor) + return; + m_error = ErrorInfo(tr("Transformer execution canceled.")); + m_currentCommandExecutor->cancel(); +} + +void ExecutorJob::runNextCommand() +{ + QBS_ASSERT(m_currentCommandIdx <= m_transformer->commands.size(), return); + ++m_currentCommandIdx; + if (m_currentCommandIdx >= m_transformer->commands.size()) { + setFinished(); + return; + } + + const AbstractCommandPtr &command = m_transformer->commands.commandAt(m_currentCommandIdx); + switch (command->type()) { + case AbstractCommand::ProcessCommandType: + m_currentCommandExecutor = m_processCommandExecutor; + break; + case AbstractCommand::JavaScriptCommandType: + m_currentCommandExecutor = m_jsCommandExecutor; + break; + default: + qFatal("Missing implementation for command type %d", command->type()); + } + + m_currentCommandExecutor->start(m_transformer, command.get()); +} + +void ExecutorJob::onCommandFinished(const ErrorInfo &err) +{ + QBS_ASSERT(m_transformer, return); + if (m_error.hasError()) { // Canceled? + setFinished(); + } else if (err.hasError()) { + m_error = err; + setFinished(); + } else { + runNextCommand(); + } +} + +void ExecutorJob::setFinished() +{ + const ErrorInfo err = m_error; + reset(); + emit finished(err); +} + +void ExecutorJob::reset() +{ + m_transformer = nullptr; + m_jobPools.clear(); + m_currentCommandExecutor = nullptr; + m_currentCommandIdx = -1; + m_error.clear(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/executorjob.h b/src/lib/corelib/buildgraph/executorjob.h new file mode 100644 index 00000000..1f8f0cd7 --- /dev/null +++ b/src/lib/corelib/buildgraph/executorjob.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_EXECUTORJOB_H +#define QBS_EXECUTORJOB_H + +#include +#include +#include +#include + +#include +#include + +namespace qbs { +class CodeLocation; +class ProcessResult; + +namespace Internal { +class AbstractCommandExecutor; +class ProductBuildData; +class JsCommandExecutor; +class Logger; +class ProcessCommandExecutor; +class ScriptEngine; +class Transformer; + +class ExecutorJob : public QObject +{ + Q_OBJECT +public: + explicit ExecutorJob(const Logger &logger, QObject *parent = nullptr); + ~ExecutorJob() override; + + void setMainThreadScriptEngine(ScriptEngine *engine); + void setDryRun(bool enabled); + void setEchoMode(CommandEchoMode echoMode); + void run(Transformer *t); + void cancel(); + const Transformer *transformer() const { return m_transformer; } + Set jobPools() const { return m_jobPools; } + +signals: + void reportCommandDescription(const QString &highlight, const QString &message); + void reportProcessResult(const qbs::ProcessResult &result); + void finished(const qbs::ErrorInfo &error = ErrorInfo()); // !hasError() <=> command successful + +private: + void runNextCommand(); + void onCommandFinished(const qbs::ErrorInfo &err); + + void setFinished(); + void reset(); + + AbstractCommandExecutor *m_currentCommandExecutor = nullptr; + ProcessCommandExecutor *m_processCommandExecutor = nullptr; + JsCommandExecutor *m_jsCommandExecutor = nullptr; + Transformer *m_transformer = nullptr; + Set m_jobPools; + int m_currentCommandIdx = 0; + ErrorInfo m_error; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_EXECUTORJOB_H diff --git a/src/lib/corelib/buildgraph/filedependency.cpp b/src/lib/corelib/buildgraph/filedependency.cpp new file mode 100644 index 00000000..cbee758c --- /dev/null +++ b/src/lib/corelib/buildgraph/filedependency.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filedependency.h" + +#include + +namespace qbs { +namespace Internal { + +FileResourceBase::FileResourceBase() = default; + +FileResourceBase::~FileResourceBase() = default; + +void FileResourceBase::setTimestamp(const FileTime &t) + +{ + m_timestamp = t; +} + +const FileTime &FileResourceBase::timestamp() const +{ + return m_timestamp; +} + +void FileResourceBase::setFilePath(const QString &filePath) +{ + m_filePath = filePath; + FileInfo::splitIntoDirectoryAndFileName(m_filePath, &m_dirPath, &m_fileName); +} + +const QString &FileResourceBase::filePath() const +{ + return m_filePath; +} + +void FileResourceBase::load(PersistentPool &pool) +{ + serializationOp(pool); + FileInfo::splitIntoDirectoryAndFileName(m_filePath, &m_dirPath, &m_fileName); +} + +void FileResourceBase::store(PersistentPool &pool) +{ + serializationOp(pool); +} + + +FileDependency::FileDependency() = default; + +FileDependency::~FileDependency() = default; + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/filedependency.h b/src/lib/corelib/buildgraph/filedependency.h new file mode 100644 index 00000000..93bfc5d0 --- /dev/null +++ b/src/lib/corelib/buildgraph/filedependency.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILEDEPENDENCY_H +#define QBS_FILEDEPENDENCY_H + +#include +#include + +namespace qbs { +namespace Internal { + +class FileResourceBase +{ +protected: + FileResourceBase(); + +public: + virtual ~FileResourceBase(); + + enum FileType { FileTypeDependency, FileTypeArtifact }; + virtual FileType fileType() const = 0; + + void setTimestamp(const FileTime &t); + const FileTime ×tamp() const; + void clearTimestamp() { m_timestamp.clear(); } + + void setFilePath(const QString &filePath); + const QString &filePath() const; + QString dirPath() const { return m_dirPath.toString(); } + QString fileName() const { return m_fileName.toString(); } + + virtual void load(PersistentPool &pool); + virtual void store(PersistentPool &pool); + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_filePath, m_timestamp); + } + + FileTime m_timestamp; + QString m_filePath; + QStringView m_dirPath; + QStringView m_fileName; +}; + +class FileDependency : public FileResourceBase +{ +public: + FileDependency(); + ~FileDependency() override; + + FileType fileType() const override { return FileTypeDependency; } +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_FILEDEPENDENCY_H diff --git a/src/lib/corelib/buildgraph/forward_decls.h b/src/lib/corelib/buildgraph/forward_decls.h new file mode 100644 index 00000000..a7627228 --- /dev/null +++ b/src/lib/corelib/buildgraph/forward_decls.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_BG_FORWARD_DECLS_H +#define QBS_BG_FORWARD_DECLS_H + +#include + +namespace qbs { +namespace Internal { + +class Artifact; +class BuildGraphNode; +class ProjectBuildData; +class ProductBuildData; +class RuleNode; + +class Transformer; +using TransformerPtr = std::shared_ptr; +using TransformerConstPtr = std::shared_ptr; + +class RulesEvaluationContext; +using RulesEvaluationContextPtr = std::shared_ptr; + +class AbstractCommand; +using AbstractCommandPtr = std::shared_ptr; + +class ProcessCommand; +using ProcessCommandPtr = std::shared_ptr; + +class JavaScriptCommand; +using JavaScriptCommandPtr = std::shared_ptr; + +template class Set; +using ArtifactSet = Set; +using NodeSet = Set; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BG_FORWARD_DECLS_H diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp new file mode 100644 index 00000000..05bbc0d4 --- /dev/null +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -0,0 +1,406 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "inputartifactscanner.h" + +#include "artifact.h" +#include "buildgraph.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "transformer.h" +#include "depscanner.h" +#include "rulesevaluationcontext.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static void resolveDepencency(const RawScannedDependency &dependency, + const ResolvedProduct *product, ResolvedDependency *result, + const QString &baseDir = QString()) +{ + QString absDirPath = baseDir.isEmpty() + ? dependency.dirPath() + : dependency.dirPath().isEmpty() + ? baseDir : FileInfo::resolvePath(baseDir, dependency.dirPath()); + if (!dependency.isClean()) + absDirPath = QDir::cleanPath(absDirPath); + + ResolvedProject *project = product->project.get(); + FileDependency *fileDependencyArtifact = nullptr; + Artifact *dependencyInProduct = nullptr; + Artifact *dependencyInOtherProduct = nullptr; + bool productOfDependencyIsDependency = false; + const auto files = project->topLevelProject() + ->buildData->lookupFiles(absDirPath, dependency.fileName()); + for (FileResourceBase *lookupResult : files) { + switch (lookupResult->fileType()) { + case FileResourceBase::FileTypeDependency: + fileDependencyArtifact = static_cast(lookupResult); + break; + case FileResourceBase::FileTypeArtifact: { + auto const foundArtifact = static_cast(lookupResult); + if (foundArtifact->product == product) { + dependencyInProduct = foundArtifact; + } else if (!productOfDependencyIsDependency) { + dependencyInOtherProduct = foundArtifact; + productOfDependencyIsDependency + = contains(product->dependencies, dependencyInOtherProduct->product.lock()); + } + break; + } + } + if (dependencyInProduct) + break; + } + + // prioritize found artifacts + if ((result->file = dependencyInProduct) + || (result->file = dependencyInOtherProduct) + || (result->file = fileDependencyArtifact)) { + result->filePath = result->file->filePath(); + + if (result->file == dependencyInOtherProduct && !productOfDependencyIsDependency) { + qCDebug(lcDepScan) << "product" << dependencyInOtherProduct->product->fullDisplayName() + << "of scanned dependency" << result->filePath + << "is not a dependency of product" << product->fullDisplayName() + << ". The file dependency might get lost during change tracking."; + } + + return; + } + + const QString &absFilePath = baseDir.isEmpty() + ? dependency.filePath() + : absDirPath + QLatin1Char('/') + dependency.fileName(); + + // TODO: We probably need a flag that tells us whether directories are allowed. + const FileInfo fi(absFilePath); + if (fi.exists(absFilePath) && !fi.isDir()) + result->filePath = absFilePath; +} + +InputArtifactScanner::InputArtifactScanner(Artifact *artifact, InputArtifactScannerContext *ctx, + Logger logger) + : m_artifact(artifact), + m_rawScanResults(artifact->product->topLevelProject()->buildData->rawScanResults), + m_context(ctx), + m_newDependencyAdded(false), + m_logger(std::move(logger)) +{ +} + +void InputArtifactScanner::scan() +{ + if (m_artifact->inputsScanned) + return; + + qCDebug(lcDepScan) << "scan inputs for" << m_artifact->filePath() << m_artifact->fileTags() + << "in product" << m_artifact->product->name; + + m_artifact->inputsScanned = true; + + // clear file dependencies; they will be regenerated + m_artifact->fileDependencies.clear(); + + // Remove all connections to children that were added by the dependency scanner. + // They will be regenerated. + const Set childrenAddedByScanner = m_artifact->childrenAddedByScanner; + m_artifact->childrenAddedByScanner.clear(); + for (Artifact * const dependency : childrenAddedByScanner) + disconnect(m_artifact, dependency); + + for (Artifact * const inputArtifact : qAsConst(m_artifact->transformer->inputs)) + scanForFileDependencies(inputArtifact); +} + +void InputArtifactScanner::scanForFileDependencies(Artifact *inputArtifact) +{ + qCDebug(lcDepScan) << "input artifact" << inputArtifact->filePath() + << inputArtifact->fileTags(); + + Set visitedFilePaths; + QList filesToScan; + filesToScan.push_back(inputArtifact); + const Set scanners = scannersForArtifact(inputArtifact); + if (scanners.empty()) + return; + m_fileTagsForScanner + = inputArtifact->fileTags().toStringList().join(QLatin1Char(',')).toLatin1(); + InputArtifactScannerContext::CacheItem *lastPerFileCacheItem = nullptr; + InputArtifactScannerContext::CacheItem *lastPerPropsCacheItem = nullptr; + while (!filesToScan.empty()) { + FileResourceBase *fileToBeScanned = filesToScan.takeFirst(); + const QString &filePathToBeScanned = fileToBeScanned->filePath(); + if (!visitedFilePaths.insert(filePathToBeScanned).second) + continue; + + for (DependencyScanner * const scanner : scanners) { + InputArtifactScannerContext::CacheItem *cacheItem; + if (scanner->cacheIsPerFile()) { + if (!lastPerFileCacheItem) + lastPerFileCacheItem = &m_context->cachePerFile[inputArtifact]; + cacheItem = lastPerFileCacheItem; + } else { + if (!lastPerPropsCacheItem) { + lastPerPropsCacheItem = &m_context->cachePerProperties + [inputArtifact->properties]; + } + cacheItem = lastPerPropsCacheItem; + } + scanForScannerFileDependencies(scanner, inputArtifact, fileToBeScanned, + scanner->recursive() ? &filesToScan : nullptr, (*cacheItem)[scanner->key()]); + } + } +} + +Set InputArtifactScanner::scannersForArtifact(const Artifact *artifact) const +{ + Set scanners; + ResolvedProduct *product = artifact->product.get(); + ScriptEngine *engine = product->topLevelProject()->buildData->evaluationContext->engine(); + QHash &scannerCache + = m_context->scannersCache[product]; + for (const FileTag &fileTag : artifact->fileTags()) { + InputArtifactScannerContext::DependencyScannerCacheItem &cache = scannerCache[fileTag]; + if (!cache.valid) { + cache.valid = true; + const auto scanners = ScannerPluginManager::scannersForFileTag(fileTag); + transform(scanners, cache.scanners, [](const auto &scanner) { + return std::make_shared(scanner); }); + for (const ResolvedScannerConstPtr &scanner : product->scanners) { + if (scanner->inputs.contains(fileTag)) { + cache.scanners.push_back( + std::make_shared(scanner, engine)); + break; + } + } + } + for (const DependencyScannerPtr &scanner : qAsConst(cache.scanners)) + scanners += scanner.get(); + } + return scanners; +} + +void InputArtifactScanner::scanForScannerFileDependencies(DependencyScanner *scanner, + Artifact *inputArtifact, FileResourceBase *fileToBeScanned, + QList *filesToScan, + InputArtifactScannerContext::ScannerResolvedDependenciesCache &cache) +{ + qCDebug(lcDepScan) << "file" << fileToBeScanned->filePath(); + + const bool cacheHit = cache.valid; + if (!cacheHit) { + cache.valid = true; + cache.searchPaths = scanner->collectSearchPaths(inputArtifact); + } + qCDebug(lcDepScan) << "include paths (cache" << (cacheHit ? "hit)" : "miss)"); + for (const QString &s : qAsConst(cache.searchPaths)) + qCDebug(lcDepScan) << " " << s; + + const QString &filePathToBeScanned = fileToBeScanned->filePath(); + RawScanResults::ScanData &scanData = m_rawScanResults.findScanData(fileToBeScanned, scanner, + m_artifact->properties); + if (scanData.lastScanTime < fileToBeScanned->timestamp()) { + try { + qCDebug(lcDepScan) << "scanning" << FileInfo::fileName(filePathToBeScanned); + scanWithScannerPlugin(scanner, inputArtifact, fileToBeScanned, &scanData.rawScanResult); + scanData.lastScanTime = FileTime::currentTime(); + } catch (const ErrorInfo &error) { + m_logger.printWarning(error); + return; + } + } + + resolveScanResultDependencies(inputArtifact, scanData.rawScanResult, filesToScan, cache); +} + +void InputArtifactScanner::resolveScanResultDependencies(const Artifact *inputArtifact, + const RawScanResult &scanResult, QList *artifactsToScan, + InputArtifactScannerContext::ScannerResolvedDependenciesCache &cache) +{ + auto getResolvedDependency = [inputArtifact, &cache](const RawScannedDependency &dependency) + -> ResolvedDependency* + { + const QString &dependencyFilePath = dependency.filePath(); + InputArtifactScannerContext::ResolvedDependencyCacheItem &cachedResolvedDependencyItem + = cache.resolvedDependenciesCache[dependency.dirPath()][dependency.fileName()]; + ResolvedDependency &resolvedDependency = cachedResolvedDependencyItem.resolvedDependency; + if (cachedResolvedDependencyItem.valid) { + if (resolvedDependency.filePath.isEmpty()) + return nullptr; + return &resolvedDependency; + } + cachedResolvedDependencyItem.valid = true; + + if (FileInfo::isAbsolute(dependencyFilePath)) { + resolveDepencency(dependency, inputArtifact->product.get(), &resolvedDependency); + if (resolvedDependency.filePath.isEmpty()) + return nullptr; + return &resolvedDependency; + } + + // try include paths + for (const QString &includePath : qAsConst(cache.searchPaths)) { + resolveDepencency(dependency, inputArtifact->product.get(), + &resolvedDependency, includePath); + if (resolvedDependency.isValid()) + return &resolvedDependency; + } + return nullptr; + }; + + for (const RawScannedDependency &dependency : scanResult.deps) { + const auto maybeResolvedDependency = getResolvedDependency(dependency); + if (!maybeResolvedDependency) { + qCWarning(lcDepScan) << "unresolved dependency " << dependency.filePath(); + continue; + } + auto &resolvedDependency = *maybeResolvedDependency; + + handleDependency(resolvedDependency); + if (artifactsToScan && resolvedDependency.file) { + if (resolvedDependency.file->fileType() == FileResourceBase::FileTypeArtifact) { + // Do not scan an artifact that is not built yet: Its contents might still change. + auto const artifactDependency = static_cast(resolvedDependency.file); + if (artifactDependency->artifactType == Artifact::SourceFile + || artifactDependency->buildState == BuildGraphNode::Built) { + artifactsToScan->push_back(artifactDependency); + } + } else { + // Add file dependency to the next round of scanning. + artifactsToScan->push_back(resolvedDependency.file); + } + } + } +} + +void InputArtifactScanner::handleDependency(ResolvedDependency &dependency) +{ + const ResolvedProductPtr product = m_artifact->product.lock(); + QBS_CHECK(m_artifact->artifactType == Artifact::Generated); + QBS_CHECK(product); + + Artifact *artifactDependency = nullptr; + FileDependency *fileDependency = nullptr; + if (dependency.file) { + switch (dependency.file->fileType()) { + case FileResourceBase::FileTypeArtifact: + artifactDependency = static_cast(dependency.file); + break; + case FileResourceBase::FileTypeDependency: + fileDependency = static_cast(dependency.file); + break; + } + } + QBS_CHECK(!dependency.file || artifactDependency || fileDependency); + + if (!dependency.file) { + // The dependency is an existing file but does not exist in the build graph. + qCDebug(lcDepScan) << "add new file dependency" << dependency.filePath; + + fileDependency = new FileDependency(); + dependency.file = fileDependency; + fileDependency->setFilePath(dependency.filePath); + product->topLevelProject()->buildData->insertFileDependency(fileDependency); + } else if (fileDependency) { + // The dependency exists in the project's list of file dependencies. + qCDebug(lcDepScan) << "add existing file dependency" << dependency.filePath; + } else if (artifactDependency->product == product) { + // The dependency is in our product. + qCDebug(lcDepScan) << "add artifact dependency" << dependency.filePath << + "(from this product)"; + } else { + // The dependency is in some other product. + ResolvedProduct * const otherProduct = artifactDependency->product; + qCDebug(lcDepScan) + << "add artifact dependency" << dependency.filePath + << " (from product" << otherProduct->uniqueName() << ')'; + } + + if (m_artifact == dependency.file) + return; + if (artifactDependency && artifactDependency->transformer == m_artifact->transformer) + return; + + if (fileDependency) { + m_artifact->fileDependencies << fileDependency; + if (!fileDependency->timestamp().isValid()) + fileDependency->setTimestamp(FileInfo(fileDependency->filePath()).lastModified()); + } else { + if (m_artifact->children.contains(artifactDependency)) + return; + if (safeConnect(m_artifact, artifactDependency)) + m_artifact->childrenAddedByScanner += artifactDependency; + m_newDependencyAdded = true; + } +} + +void InputArtifactScanner::scanWithScannerPlugin(DependencyScanner *scanner, + Artifact *inputArtifact, + FileResourceBase *fileToBeScanned, + RawScanResult *scanResult) +{ + scanResult->deps.clear(); + const QStringList &dependencies = scanner->collectDependencies( + inputArtifact, fileToBeScanned, m_fileTagsForScanner.constData()); + for (const QString &s : dependencies) + scanResult->deps.emplace_back(s); +} + +InputArtifactScannerContext::DependencyScannerCacheItem::DependencyScannerCacheItem() : valid(false) +{ +} + +InputArtifactScannerContext::DependencyScannerCacheItem::~DependencyScannerCacheItem() = default; + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.h b/src/lib/corelib/buildgraph/inputartifactscanner.h new file mode 100644 index 00000000..7b7630b6 --- /dev/null +++ b/src/lib/corelib/buildgraph/inputartifactscanner.h @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_INPUTARTIFACTSCANNER_H +#define QBS_INPUTARTIFACTSCANNER_H + +#include +#include +#include +#include + +#include +#include + +class ScannerPlugin; + +namespace qbs { +namespace Internal { + +class Artifact; +class FileResourceBase; +class RawScanResult; +class RawScanResults; +class PropertyMapInternal; + +class DependencyScanner; +using DependencyScannerPtr = std::shared_ptr; + +class ResolvedDependency +{ +public: + bool isValid() const { return !filePath.isNull(); } + + QString filePath; + FileResourceBase *file = nullptr; +}; + +class InputArtifactScannerContext +{ + struct ResolvedDependencyCacheItem + { + ResolvedDependencyCacheItem() + : valid(false) + {} + + bool valid; + ResolvedDependency resolvedDependency; + }; + + using ResolvedDependenciesCache = QHash>; + + struct ScannerResolvedDependenciesCache + { + ScannerResolvedDependenciesCache() : + valid(false) + {} + + bool valid; + QStringList searchPaths; + ResolvedDependenciesCache resolvedDependenciesCache; + }; + + struct DependencyScannerCacheItem + { + DependencyScannerCacheItem(); + ~DependencyScannerCacheItem(); + + bool valid; + QList scanners; + }; + + using CacheItem = QHash; + + QHash cachePerProperties; + QHash cachePerFile; + QHash> scannersCache; + + friend class InputArtifactScanner; +}; + +class InputArtifactScanner +{ +public: + InputArtifactScanner(Artifact *artifact, InputArtifactScannerContext *ctx, + Logger logger); + void scan(); + bool newDependencyAdded() const { return m_newDependencyAdded; } + +private: + void scanForFileDependencies(Artifact *inputArtifact); + Set scannersForArtifact(const Artifact *artifact) const; + void scanForScannerFileDependencies(DependencyScanner *scanner, + Artifact *inputArtifact, FileResourceBase *fileToBeScanned, + QList *filesToScan, + InputArtifactScannerContext::ScannerResolvedDependenciesCache &cache); + void resolveScanResultDependencies(const Artifact *inputArtifact, + const RawScanResult &scanResult, QList *artifactsToScan, + InputArtifactScannerContext::ScannerResolvedDependenciesCache &cache); + void handleDependency(ResolvedDependency &dependency); + void scanWithScannerPlugin(DependencyScanner *scanner, Artifact *inputArtifact, + FileResourceBase *fileToBeScanned, RawScanResult *scanResult); + + Artifact * const m_artifact; + RawScanResults &m_rawScanResults; + InputArtifactScannerContext *const m_context; + QByteArray m_fileTagsForScanner; + bool m_newDependencyAdded; + Logger m_logger; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_INPUTARTIFACTSCANNER_H diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.cpp b/src/lib/corelib/buildgraph/jscommandexecutor.cpp new file mode 100644 index 00000000..abebc82b --- /dev/null +++ b/src/lib/corelib/buildgraph/jscommandexecutor.cpp @@ -0,0 +1,292 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "jscommandexecutor.h" + +#include "artifact.h" +#include "buildgraph.h" +#include "rulecommands.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +struct JavaScriptCommandResult +{ + bool success = false; + QString errorMessage; + CodeLocation errorLocation; +}; + +class JsCommandExecutorThreadObject : public QObject +{ + Q_OBJECT +public: + JsCommandExecutorThreadObject(Logger logger) + : m_logger(std::move(logger)) + , m_scriptEngine(nullptr) + { + } + + const JavaScriptCommandResult &result() const + { + return m_result; + } + + void cancel(const qbs::ErrorInfo &reason) + { + m_result.success = !reason.hasError(); + m_result.errorMessage = reason.toString(); + if (m_scriptEngine) + m_scriptEngine->abortEvaluation(); + m_cancelled = true; + } + +signals: + void finished(); + +public: + void start(const JavaScriptCommand *cmd, Transformer *transformer) + { + if (m_cancelled) { + emit finished(); + return; + } + + m_running = true; + try { + doStart(cmd, transformer); + } catch (const qbs::ErrorInfo &error) { + setError(error.toString(), cmd->codeLocation()); + } + + m_running = false; + emit finished(); + } + +private: + void doStart(const JavaScriptCommand *cmd, Transformer *transformer) + { + m_result.success = true; + m_result.errorMessage.clear(); + ScriptEngine * const scriptEngine = provideScriptEngine(); + QScriptValue scope = scriptEngine->newObject(); + scope.setPrototype(scriptEngine->globalObject()); + m_scriptEngine->clearRequestedProperties(); + setupScriptEngineForFile(scriptEngine, + transformer->rule->prepareScript.fileContext(), scope, + ObserveMode::Enabled); + + QScriptValue importScopeForSourceCode; + if (!cmd->scopeName().isEmpty()) + importScopeForSourceCode = scope.property(cmd->scopeName()); + + setupScriptEngineForProduct(scriptEngine, transformer->product().get(), + transformer->rule->module.get(), scope, true); + transformer->setupInputs(scope); + transformer->setupOutputs(scope); + transformer->setupExplicitlyDependsOn(scope); + + for (QVariantMap::const_iterator it = cmd->properties().constBegin(); + it != cmd->properties().constEnd(); ++it) { + scope.setProperty(it.key(), scriptEngine->toScriptValue(it.value())); + } + + scriptEngine->setGlobalObject(scope); + if (importScopeForSourceCode.isObject()) + scriptEngine->currentContext()->pushScope(importScopeForSourceCode); + scriptEngine->evaluate(cmd->sourceCode()); + scriptEngine->releaseResourcesOfScriptObjects(); + if (importScopeForSourceCode.isObject()) + scriptEngine->currentContext()->popScope(); + scriptEngine->setGlobalObject(scope.prototype()); + transformer->propertiesRequestedInCommands + += scriptEngine->propertiesRequestedInScript(); + unite(transformer->propertiesRequestedFromArtifactInCommands, + scriptEngine->propertiesRequestedFromArtifact()); + const std::vector &importFilesUsedInCommand + = scriptEngine->importedFilesUsedInScript(); + transformer->importedFilesUsedInCommands.insert( + transformer->importedFilesUsedInCommands.cend(), + importFilesUsedInCommand.cbegin(), importFilesUsedInCommand.cend()); + transformer->depsRequestedInCommands.add(scriptEngine->productsWithRequestedDependencies()); + transformer->artifactsMapRequestedInCommands.unite(scriptEngine->requestedArtifacts()); + for (const ResolvedProduct * const p : scriptEngine->requestedExports()) { + transformer->exportedModulesAccessedInCommands.insert( + std::make_pair(p->uniqueName(), p->exportedModule)); + } + scriptEngine->clearRequestedProperties(); + if (scriptEngine->hasUncaughtException()) { + // ### We don't know the line number of the command's sourceCode property assignment. + setError(scriptEngine->uncaughtException().toString(), cmd->codeLocation()); + } + } + + void setError(const QString &errorMessage, const CodeLocation &codeLocation) + { + m_result.success = false; + m_result.errorMessage = errorMessage; + m_result.errorLocation = codeLocation; + } + + ScriptEngine *provideScriptEngine() + { + if (!m_scriptEngine) + m_scriptEngine = ScriptEngine::create(m_logger, EvalContext::JsCommand); + return m_scriptEngine.get(); + } + + Logger m_logger; + std::unique_ptr m_scriptEngine; + JavaScriptCommandResult m_result; + bool m_running = false; + bool m_cancelled = false; +}; + + +JsCommandExecutor::JsCommandExecutor(const Logger &logger, QObject *parent) + : AbstractCommandExecutor(logger, parent) + , m_thread(new QThread(this)) + , m_objectInThread(new JsCommandExecutorThreadObject(logger)) + , m_running(false) +{ + qRegisterMetaType("Transformer *"); + qRegisterMetaType("const JavaScriptCommand *"); + + m_objectInThread->moveToThread(m_thread); + connect(m_objectInThread, &JsCommandExecutorThreadObject::finished, + this, &JsCommandExecutor::onJavaScriptCommandFinished); + connect(this, &JsCommandExecutor::startRequested, + m_objectInThread, &JsCommandExecutorThreadObject::start); +} + +JsCommandExecutor::~JsCommandExecutor() +{ + waitForFinished(); + m_thread->quit(); + m_thread->wait(); + delete m_objectInThread; +} + +void JsCommandExecutor::doReportCommandDescription(const QString &productName) +{ + if ((m_echoMode == CommandEchoModeCommandLine + || m_echoMode == CommandEchoModeCommandLineWithEnvironment) + && !command()->extendedDescription().isEmpty()) { + emit reportCommandDescription(command()->highlight(), command()->extendedDescription()); + return; + } + + AbstractCommandExecutor::doReportCommandDescription(productName); +} + +void JsCommandExecutor::waitForFinished() +{ + if (!m_running) + return; + QEventLoop loop; + connect(this, &AbstractCommandExecutor::finished, &loop, &QEventLoop::quit); + loop.exec(); +} + +bool JsCommandExecutor::doStart() +{ + QBS_ASSERT(!m_running, return false); + + if (dryRun() && !command()->ignoreDryRun()) { + QTimer::singleShot(0, this, [this] { emit finished(); }); // Don't call back on the caller. + return false; + } + + m_thread->start(); + m_running = true; + emit startRequested(jsCommand(), transformer()); + return true; +} + +void JsCommandExecutor::cancel(const qbs::ErrorInfo &reason) +{ + if (m_running && (!dryRun() || command()->ignoreDryRun())) + QTimer::singleShot(0, m_objectInThread, [objectInThread = QPointer{m_objectInThread}, reason] { + if (objectInThread) + objectInThread->cancel(reason); + }); +} + +void JsCommandExecutor::onJavaScriptCommandFinished() +{ + m_running = false; + const JavaScriptCommandResult &result = m_objectInThread->result(); + ErrorInfo err; + if (!result.success) { + logger().qbsDebug() << "JS context:\n" << jsCommand()->properties(); + logger().qbsDebug() << "JS code:\n" << jsCommand()->sourceCode(); + err.append(result.errorMessage); + // ### We don't know the line number of the command's sourceCode property assignment. + err.appendBacktrace(QStringLiteral("JavaScriptCommand.sourceCode")); + err.appendBacktrace(QStringLiteral("Rule.prepare"), result.errorLocation); + } + emit finished(err); +} + +const JavaScriptCommand *JsCommandExecutor::jsCommand() const +{ + return static_cast(command()); +} + +} // namespace Internal +} // namespace qbs + +#include "jscommandexecutor.moc" diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.h b/src/lib/corelib/buildgraph/jscommandexecutor.h new file mode 100644 index 00000000..0725f0d2 --- /dev/null +++ b/src/lib/corelib/buildgraph/jscommandexecutor.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_JSCOMMANDEXECUTOR_H +#define QBS_JSCOMMANDEXECUTOR_H + +#include "abstractcommandexecutor.h" + +#include + +namespace qbs { +class CodeLocation; + +namespace Internal { +class JavaScriptCommand; +class JsCommandExecutorThreadObject; + +class JsCommandExecutor : public AbstractCommandExecutor +{ + Q_OBJECT +public: + explicit JsCommandExecutor(const Logger &logger, QObject *parent = nullptr); + ~JsCommandExecutor() override; + +signals: + void startRequested(const JavaScriptCommand *cmd, Transformer *transformer); + +private: + void onJavaScriptCommandFinished(); + + void doReportCommandDescription(const QString &productName) override; + bool doStart() override; + void cancel(const qbs::ErrorInfo &reason) override; + + void waitForFinished(); + + const JavaScriptCommand *jsCommand() const; + + QThread *m_thread; + JsCommandExecutorThreadObject *m_objectInThread; + bool m_running; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_JSCOMMANDEXECUTOR_H diff --git a/src/lib/corelib/buildgraph/nodeset.cpp b/src/lib/corelib/buildgraph/nodeset.cpp new file mode 100644 index 00000000..b9ef222e --- /dev/null +++ b/src/lib/corelib/buildgraph/nodeset.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "nodeset.h" + +#include "artifact.h" +#include "rulenode.h" +#include +#include + +namespace qbs { +namespace Internal { + +BuildGraphNode *loadBuildGraphNode(PersistentPool &pool) +{ + const auto t = pool.load(); + BuildGraphNode *node = nullptr; + switch (static_cast(t)) { + case BuildGraphNode::ArtifactNodeType: + node = pool.load(); + break; + case BuildGraphNode::RuleNodeType: + node = pool.load(); + break; + } + QBS_CHECK(node); + return node; +} + +void storeBuildGraphNode(PersistentPool &pool, const BuildGraphNode *node) +{ + pool.store(static_cast(node->type())); + pool.store(node); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/nodeset.h b/src/lib/corelib/buildgraph/nodeset.h new file mode 100644 index 00000000..469988b1 --- /dev/null +++ b/src/lib/corelib/buildgraph/nodeset.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_NODESET_H +#define QBS_NODESET_H + +#include + +#include + +namespace qbs { +namespace Internal { +class BuildGraphNode; + +BuildGraphNode *loadBuildGraphNode(PersistentPool &pool); +void storeBuildGraphNode(PersistentPool &pool, const BuildGraphNode *node); + +using NodeSet = Set; +template<> inline BuildGraphNode *NodeSet::loadElem(PersistentPool &pool) +{ + return loadBuildGraphNode(pool); +} +template<> inline void NodeSet::storeElem(PersistentPool &pool, BuildGraphNode * const &node) const +{ + storeBuildGraphNode(pool, node); +} + +template +class TypeFilter +{ + const NodeSet &m_nodes; +public: + TypeFilter(const NodeSet &nodes) + : m_nodes(nodes) + { + } + + class const_iterator + { + const NodeSet &m_nodes; + NodeSet::const_iterator m_it; + public: + using value_type = T*; + using difference_type = ptrdiff_t; + using pointer = value_type*; + using reference = value_type&; + using iterator_category = std::forward_iterator_tag; + + const_iterator(const NodeSet &nodes, const NodeSet::const_iterator &it) + : m_nodes(nodes), m_it(it) + { + while (m_it != m_nodes.constEnd() && !hasDynamicType(*m_it)) + ++m_it; + } + + bool operator==(const const_iterator &rhs) + { + return m_it == rhs.m_it; + } + + bool operator!=(const const_iterator &rhs) + { + return !(*this == rhs); + } + + const_iterator &operator++() + { + for (;;) { + ++m_it; + if (m_it == m_nodes.constEnd() || hasDynamicType(*m_it)) + return *this; + } + } + + T *operator*() const + { + return static_cast(*m_it); + } + }; + + const_iterator begin() const + { + return const_iterator(m_nodes, m_nodes.constBegin()); + } + + const_iterator end() const + { + return const_iterator(m_nodes, m_nodes.constEnd()); + } +}; + +template +const TypeFilter filterByType(const NodeSet &nodes) +{ + return TypeFilter(nodes); +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_NODESET_H diff --git a/src/lib/corelib/buildgraph/nodetreedumper.cpp b/src/lib/corelib/buildgraph/nodetreedumper.cpp new file mode 100644 index 00000000..8475a46c --- /dev/null +++ b/src/lib/corelib/buildgraph/nodetreedumper.cpp @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "nodetreedumper.h" + +#include "artifact.h" +#include "productbuilddata.h" +#include "rulenode.h" + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +static int indentWidth() { return 4; } + +NodeTreeDumper::NodeTreeDumper(QIODevice &outDevice) : m_outDevice(outDevice) +{ +} + +void NodeTreeDumper::start(const QVector &products) +{ + m_indentation = 0; + for (const ResolvedProductPtr &p : products) { + if (!p->buildData) + continue; + m_currentProduct = p; + for (Artifact * const root : p->buildData->rootArtifacts()) + root->accept(this); + m_visited.clear(); + QBS_CHECK(m_indentation == 0); + } +} + +bool NodeTreeDumper::visit(Artifact *artifact) +{ + return doVisit(artifact, artifact->fileName()); +} + +void NodeTreeDumper::endVisit(Artifact *artifact) +{ + Q_UNUSED(artifact); + doEndVisit(); +} + +bool NodeTreeDumper::visit(RuleNode *rule) +{ + return doVisit(rule, rule->toString()); +} + +void NodeTreeDumper::endVisit(RuleNode *rule) +{ + Q_UNUSED(rule); + doEndVisit(); +} + +void NodeTreeDumper::doEndVisit() +{ + unindent(); +} + +void NodeTreeDumper::indent() +{ + m_outDevice.write("\n"); + m_indentation += indentWidth(); +} + +void NodeTreeDumper::unindent() +{ + m_indentation -= indentWidth(); +} + +bool NodeTreeDumper::doVisit(BuildGraphNode *node, const QString &nodeRepr) +{ + m_outDevice.write(indentation()); + m_outDevice.write(nodeRepr.toLocal8Bit()); + indent(); + const bool wasVisited = !m_visited.insert(node).second; + return !wasVisited && node->product == m_currentProduct; +} + +QByteArray NodeTreeDumper::indentation() const +{ + return QByteArray(m_indentation, ' '); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/nodetreedumper.h b/src/lib/corelib/buildgraph/nodetreedumper.h new file mode 100644 index 00000000..38ccd6da --- /dev/null +++ b/src/lib/corelib/buildgraph/nodetreedumper.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_NODETREEDUMPER_H +#define QBS_NODETREEDUMPER_H + +#include "artifact.h" +#include "buildgraphvisitor.h" +#include + +#include + +QT_BEGIN_NAMESPACE +class QIODevice; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +class NodeTreeDumper : public BuildGraphVisitor +{ +public: + NodeTreeDumper(QIODevice &outDevice); + + void start(const QVector &products); + +private: + bool visit(Artifact *artifact) override; + void endVisit(Artifact *artifact) override; + bool visit(RuleNode *rule) override; + void endVisit(RuleNode *rule) override; + + void doEndVisit(); + void indent(); + void unindent(); + bool doVisit(BuildGraphNode *node, const QString &nodeRepr); + QByteArray indentation() const; + + QIODevice &m_outDevice; + ResolvedProductPtr m_currentProduct; + NodeSet m_visited; + int m_indentation = 0; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp new file mode 100644 index 00000000..57d69ac0 --- /dev/null +++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "processcommandexecutor.h" + +#include "artifact.h" +#include "rulecommands.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +ProcessCommandExecutor::ProcessCommandExecutor(const Logger &logger, QObject *parent) + : AbstractCommandExecutor(logger, parent) +{ + connect(&m_process, &QbsProcess::errorOccurred, + this, &ProcessCommandExecutor::onProcessError); + connect(&m_process, static_cast(&QbsProcess::finished), + this, &ProcessCommandExecutor::onProcessFinished); +} + +static QProcessEnvironment mergeEnvironments(const QProcessEnvironment &baseEnv, + const QProcessEnvironment &additionalEnv) +{ + QProcessEnvironment env = baseEnv; + + static const QStringList pathListVariables{ + StringConstants::pathEnvVar(), + QStringLiteral("LD_LIBRARY_PATH"), + QStringLiteral("DYLD_LIBRARY_PATH"), + QStringLiteral("DYLD_FRAMEWORK_PATH"), + }; + const auto keys = additionalEnv.keys(); + for (const QString &key : keys) { + QString newValue = additionalEnv.value(key); + if (pathListVariables.contains(key, HostOsInfo::fileNameCaseSensitivity())) { + const QString &oldValue = baseEnv.value(key); + if (!oldValue.isEmpty()) + newValue.append(HostOsInfo::pathListSeparator()).append(oldValue); + } + env.insert(key, newValue); + } + return env; +} + +void ProcessCommandExecutor::doSetup() +{ + ProcessCommand * const cmd = processCommand(); + const QString program = ExecutableFinder(transformer()->product(), + transformer()->product()->buildEnvironment) + .findExecutable(cmd->program(), cmd->workingDir()); + cmd->clearRelevantEnvValues(); + const auto keys = cmd->relevantEnvVars(); + for (const QString &key : keys) + cmd->addRelevantEnvValue(key, transformer()->product()->buildEnvironment.value(key)); + + m_commandEnvironment = mergeEnvironments(m_buildEnvironment, cmd->environment()); + m_program = program; + m_arguments = cmd->arguments(); + m_shellInvocation = shellQuote(QDir::toNativeSeparators(m_program), m_arguments); +} + +bool ProcessCommandExecutor::doStart() +{ + QBS_ASSERT(m_process.state() == QProcess::NotRunning, return false); + + const ProcessCommand * const cmd = processCommand(); + + m_process.setProcessEnvironment(m_commandEnvironment); + + QStringList arguments = m_arguments; + + if (dryRun() && !cmd->ignoreDryRun()) { + QTimer::singleShot(0, this, [this] { emit finished(); }); // Don't call back on the caller. + return false; + } + + const QString workingDir = QDir::fromNativeSeparators(cmd->workingDir()); + if (!workingDir.isEmpty()) { + FileInfo fi(workingDir); + if (!fi.exists() || !fi.isDir()) { + emit finished(ErrorInfo(Tr::tr("The working directory '%1' for process '%2' " + "is invalid.").arg(QDir::toNativeSeparators(workingDir), + QDir::toNativeSeparators(m_program)), + cmd->codeLocation())); + return false; + } + } + + // Automatically use response files, if the command line gets to long. + if (!cmd->responseFileUsagePrefix().isEmpty()) { + const int commandLineLength = m_shellInvocation.length(); + if (cmd->responseFileThreshold() >= 0 && commandLineLength > cmd->responseFileThreshold()) { + qCDebug(lcExec) << QString::fromUtf8("Using response file. " + "Threshold is %1. Command line length %2.") + .arg(cmd->responseFileThreshold()).arg(commandLineLength); + + // The QTemporaryFile keeps a handle on the file, even if closed. + // On Windows, some commands (e.g. msvc link.exe) won't accept that. + // We need to delete the file manually, later. + QTemporaryFile responseFile; + responseFile.setAutoRemove(false); + responseFile.setFileTemplate(QDir::tempPath() + QLatin1String("/qbsresp")); + if (!responseFile.open()) { + emit finished(ErrorInfo(Tr::tr("Cannot create response file '%1'.") + .arg(responseFile.fileName()))); + return false; + } + const auto separator = cmd->responseFileSeparator().toUtf8(); + for (int i = cmd->responseFileArgumentIndex(); i < cmd->arguments().size(); ++i) { + const QString arg = cmd->arguments().at(i); + if (arg.startsWith(cmd->responseFileUsagePrefix())) { + QFile f(arg.mid(cmd->responseFileUsagePrefix().size())); + if (!f.open(QIODevice::ReadOnly)) { + emit finished(ErrorInfo(Tr::tr("Cannot open command file '%1'.") + .arg(QDir::toNativeSeparators(f.fileName())))); + return false; + } + responseFile.write(f.readAll()); + } else { + responseFile.write(qbs::Internal::shellQuote(arg).toLocal8Bit()); + } + responseFile.write(separator); + } + responseFile.close(); + m_responseFileName = responseFile.fileName(); + arguments = arguments.mid(0, std::min(cmd->responseFileArgumentIndex(), + arguments.size())); + arguments += QDir::toNativeSeparators(cmd->responseFileUsagePrefix() + + responseFile.fileName()); + } + } + + qCDebug(lcExec) << "Running external process; full command line is:" << m_shellInvocation; + const QProcessEnvironment &additionalVariables = cmd->environment(); + qCDebug(lcExec) << "Additional environment:" << additionalVariables.toStringList(); + m_process.setWorkingDirectory(workingDir); + m_process.start(m_program, arguments); + return true; +} + +void ProcessCommandExecutor::cancel(const qbs::ErrorInfo &reason) +{ + // We don't want this command to be reported as failing, since we explicitly terminated it. + disconnect(this, &ProcessCommandExecutor::reportProcessResult, nullptr, nullptr); + + m_cancelReason = reason; + m_process.cancel(); +} + +QString ProcessCommandExecutor::filterProcessOutput(const QByteArray &_output, + const QString &filterFunctionSource) +{ + const QString output = QString::fromLocal8Bit(_output); + if (filterFunctionSource.isEmpty()) + return output; + + QScriptValue scope = scriptEngine()->newObject(); + scope.setPrototype(scriptEngine()->globalObject()); + for (QVariantMap::const_iterator it = command()->properties().constBegin(); + it != command()->properties().constEnd(); ++it) { + scope.setProperty(it.key(), scriptEngine()->toScriptValue(it.value())); + } + + TemporaryGlobalObjectSetter tgos(scope); + QScriptValue filterFunction = scriptEngine()->evaluate(QLatin1String("var f = ") + + filterFunctionSource + + QLatin1String("; f")); + if (!filterFunction.isFunction()) { + logger().printWarning(ErrorInfo(Tr::tr("Error in filter function: %1.\n%2") + .arg(filterFunctionSource, filterFunction.toString()))); + return output; + } + + QScriptValue outputArg = scriptEngine()->newArray(1); + outputArg.setProperty(0, scriptEngine()->toScriptValue(output)); + QScriptValue filteredOutput = filterFunction.call(scriptEngine()->undefinedValue(), outputArg); + if (scriptEngine()->hasErrorOrException(filteredOutput)) { + logger().printWarning(ErrorInfo(Tr::tr("Error when calling output filter function: %1") + .arg(scriptEngine()->lastErrorString(filteredOutput)), + scriptEngine()->lastErrorLocation(filteredOutput))); + return output; + } + + return filteredOutput.toString(); +} + +static QProcess::ProcessError saveToFile(const QString &filePath, const QByteArray &content) +{ + QBS_ASSERT(!filePath.isEmpty(), return QProcess::WriteError); + + QFile f(filePath); + if (!f.open(QIODevice::WriteOnly)) + return QProcess::WriteError; + + if (f.write(content) != content.size()) + return QProcess::WriteError; + f.close(); + return f.error() == QFileDevice::NoError ? QProcess::UnknownError : QProcess::WriteError; +} + +void ProcessCommandExecutor::getProcessOutput(bool stdOut, ProcessResult &result) +{ + QByteArray content; + QString filterFunction; + QString redirectPath; + QStringList *target; + if (stdOut) { + content = m_process.readAllStandardOutput(); + filterFunction = processCommand()->stdoutFilterFunction(); + redirectPath = processCommand()->stdoutFilePath(); + target = &result.d->stdOut; + } else { + content = m_process.readAllStandardError(); + filterFunction = processCommand()->stderrFilterFunction(); + redirectPath = processCommand()->stderrFilePath(); + target = &result.d->stdErr; + } + QString contentString = filterProcessOutput(content, filterFunction); + if (!redirectPath.isEmpty()) { + const QByteArray dataToWrite = filterFunction.isEmpty() ? content + : contentString.toLocal8Bit(); + const QProcess::ProcessError error = saveToFile(redirectPath, dataToWrite); + if (result.error() == QProcess::UnknownError && error != QProcess::UnknownError) + result.d->error = error; + } else { + if (!contentString.isEmpty() && contentString.endsWith(QLatin1Char('\n'))) + contentString.chop(1); + *target = contentString.split(QLatin1Char('\n'), QBS_SKIP_EMPTY_PARTS); + } +} + +void ProcessCommandExecutor::sendProcessOutput() +{ + ProcessResult result; + result.d->executableFilePath = m_program; + result.d->arguments = m_arguments; + result.d->workingDirectory = m_process.workingDirectory(); + if (result.workingDirectory().isEmpty()) + result.d->workingDirectory = QDir::currentPath(); + result.d->exitCode = m_process.exitCode(); + result.d->error = m_process.error(); + QString errorString = m_process.errorString(); + + getProcessOutput(true, result); + getProcessOutput(false, result); + + const bool processError = result.error() != QProcess::UnknownError; + const bool failureExit = quint32(m_process.exitCode()) + > quint32(processCommand()->maxExitCode()); + const bool cancelledWithError = m_cancelReason.hasError(); + result.d->success = !processError && !failureExit && !cancelledWithError; + emit reportProcessResult(result); + + if (Q_UNLIKELY(cancelledWithError)) { + emit finished(m_cancelReason); + } else if (Q_UNLIKELY(processError)) { + emit finished(ErrorInfo(errorString)); + } else if (Q_UNLIKELY(failureExit)) { + emit finished(ErrorInfo(Tr::tr("Process failed with exit code %1.") + .arg(m_process.exitCode()))); + } else { + emit finished(); + } +} + +void ProcessCommandExecutor::onProcessError() +{ + if (scriptEngine()->isActive()) { + qCDebug(lcExec) << "Command error while rule execution is pausing. " + "Delaying slot execution."; + QTimer::singleShot(0, this, &ProcessCommandExecutor::onProcessError); + return; + } + if (m_cancelReason.hasError()) + return; // Ignore. Cancel reasons will be handled by on ProcessFinished(). + switch (m_process.error()) { + case QProcess::FailedToStart: { + removeResponseFile(); + const QString binary = QDir::toNativeSeparators(processCommand()->program()); + QString errorPrefixString; +#ifdef Q_OS_UNIX + if (QFileInfo(binary).isExecutable()) { + const QString interpreter(shellInterpreter(binary)); + if (!interpreter.isEmpty()) { + errorPrefixString = Tr::tr("%1: bad interpreter: ").arg(interpreter); + } + } +#endif + emit finished(ErrorInfo(Tr::tr("The process '%1' could not be started: %2. " + "The full command line invocation was: %3") + .arg(binary, errorPrefixString + m_process.errorString(), + m_shellInvocation))); + break; + } + case QProcess::Crashed: + break; // Ignore. Will be handled by onProcessFinished(). + default: + logger().qbsWarning() << "QProcess error: " << m_process.errorString(); + } +} + +void ProcessCommandExecutor::onProcessFinished() +{ + if (scriptEngine()->isActive()) { + qCDebug(lcExec) << "Command finished while rule execution is pausing. " + "Delaying slot execution."; + QTimer::singleShot(0, this, &ProcessCommandExecutor::onProcessFinished); + return; + } + removeResponseFile(); + sendProcessOutput(); +} + +static QString environmentVariableString(const QString &key, const QString &value) +{ + QString str; + if (HostOsInfo::isWindowsHost()) + str += QStringLiteral("set "); + str += shellQuote(key + QLatin1Char('=') + value); + if (HostOsInfo::isWindowsHost()) + str += QLatin1Char('\n'); + else + str += QLatin1Char(' '); + return str; +} + +void ProcessCommandExecutor::doReportCommandDescription(const QString &productName) +{ + if (m_echoMode == CommandEchoModeCommandLine || + m_echoMode == CommandEchoModeCommandLineWithEnvironment) { + QString fullInvocation; + if (m_echoMode == CommandEchoModeCommandLineWithEnvironment) { + QStringList keys = m_commandEnvironment.keys(); + keys.sort(); + for (const QString &key : qAsConst(keys)) + fullInvocation += environmentVariableString(key, m_commandEnvironment.value(key)); + } + fullInvocation += m_shellInvocation; + emit reportCommandDescription(command()->highlight(), + !command()->extendedDescription().isEmpty() + ? command()->extendedDescription() + : fullInvocation); + return; + } + + AbstractCommandExecutor::doReportCommandDescription(productName); +} + +void ProcessCommandExecutor::removeResponseFile() +{ + if (m_responseFileName.isEmpty()) + return; + QFile::remove(m_responseFileName); + m_responseFileName.clear(); +} + +ProcessCommand *ProcessCommandExecutor::processCommand() const +{ + return static_cast(command()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.h b/src/lib/corelib/buildgraph/processcommandexecutor.h new file mode 100644 index 00000000..b0f95588 --- /dev/null +++ b/src/lib/corelib/buildgraph/processcommandexecutor.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROCESSCOMMANDEXECUTOR_H +#define QBS_PROCESSCOMMANDEXECUTOR_H + +#include "abstractcommandexecutor.h" + +#include + +#include + +namespace qbs { +class ProcessResult; + +namespace Internal { +class ProcessCommand; + +class ProcessCommandExecutor : public AbstractCommandExecutor +{ + Q_OBJECT +public: + explicit ProcessCommandExecutor(const Internal::Logger &logger, QObject *parent = nullptr); + + void setProcessEnvironment(const QProcessEnvironment &processEnvironment) { + m_buildEnvironment = processEnvironment; + } + +signals: + void reportProcessResult(const qbs::ProcessResult &result); + +private: + void onProcessError(); + void onProcessFinished(); + + void doSetup() override; + void doReportCommandDescription(const QString &productName) override; + bool doStart() override; + void cancel(const qbs::ErrorInfo &reason) override; + + void startProcessCommand(); + QString filterProcessOutput(const QByteArray &output, const QString &filterFunctionSource); + void getProcessOutput(bool stdOut, ProcessResult &result); + + void sendProcessOutput(); + void removeResponseFile(); + ProcessCommand *processCommand() const; + +private: + QString m_program; + QStringList m_arguments; + QString m_shellInvocation; + + QbsProcess m_process; + QProcessEnvironment m_buildEnvironment; + QProcessEnvironment m_commandEnvironment; + QString m_responseFileName; + qbs::ErrorInfo m_cancelReason; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROCESSCOMMANDEXECUTOR_H diff --git a/src/lib/corelib/buildgraph/productbuilddata.cpp b/src/lib/corelib/buildgraph/productbuilddata.cpp new file mode 100644 index 00000000..db51b2b9 --- /dev/null +++ b/src/lib/corelib/buildgraph/productbuilddata.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "productbuilddata.h" + +#include "artifact.h" +#include "projectbuilddata.h" +#include "rulecommands.h" +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +ProductBuildData::~ProductBuildData() +{ + qDeleteAll(m_nodes); +} + +const TypeFilter ProductBuildData::rootArtifacts() const +{ + return TypeFilter(m_roots); +} + +void ProductBuildData::addArtifact(Artifact *artifact) +{ + QBS_CHECK(m_nodes.insert(artifact).second); + addArtifactToSet(artifact); +} + +void ProductBuildData::addArtifactToSet(Artifact *artifact) +{ + std::lock_guard l(m_artifactsMapMutex); + for (const FileTag &tag : artifact->fileTags()) { + m_artifactsByFileTag[tag] += artifact; + m_jsArtifactsMapUpToDate = false; + } +} + +void ProductBuildData::removeArtifact(Artifact *artifact) +{ + m_roots.remove(artifact); + m_nodes.remove(artifact); + removeArtifactFromSet(artifact); +} + +void ProductBuildData::removeArtifactFromSetByFileTag(Artifact *artifact, const FileTag &fileTag) +{ + std::lock_guard l(m_artifactsMapMutex); + const auto it = m_artifactsByFileTag.find(fileTag); + if (it == m_artifactsByFileTag.end()) + return; + it->remove(artifact); + if (it->empty()) + m_artifactsByFileTag.erase(it); + m_jsArtifactsMapUpToDate = false; +} + +void ProductBuildData::addFileTagToArtifact(Artifact *artifact, const FileTag &tag) +{ + std::lock_guard l(m_artifactsMapMutex); + m_artifactsByFileTag[tag] += artifact; + m_jsArtifactsMapUpToDate = false; +} + +ArtifactSetByFileTag ProductBuildData::artifactsByFileTag() const +{ + std::lock_guard l(m_artifactsMapMutex); + return m_artifactsByFileTag; +} + +void ProductBuildData::setRescuableArtifactData(const AllRescuableArtifactData &rad) +{ + m_rescuableArtifactData = rad; +} + +RescuableArtifactData ProductBuildData::removeFromRescuableArtifactData(const QString &filePath) +{ + return m_rescuableArtifactData.take(filePath); +} + +void ProductBuildData::addRescuableArtifactData(const QString &filePath, + const RescuableArtifactData &rad) +{ + m_rescuableArtifactData.insert(filePath, rad); +} + +bool ProductBuildData::checkAndSetJsArtifactsMapUpToDateFlag() +{ + std::lock_guard l(m_artifactsMapMutex); + if (!m_jsArtifactsMapUpToDate) { + m_jsArtifactsMapUpToDate = true; + return false; + } + return true; +} + +void ProductBuildData::removeArtifactFromSet(Artifact *artifact) +{ + for (const FileTag &t : artifact->fileTags()) + removeArtifactFromSetByFileTag(artifact, t); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/productbuilddata.h b/src/lib/corelib/buildgraph/productbuilddata.h new file mode 100644 index 00000000..a7660af2 --- /dev/null +++ b/src/lib/corelib/buildgraph/productbuilddata.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PRODUCTBUILDDATA_H +#define QBS_PRODUCTBUILDDATA_H + +#include "artifact.h" +#include "nodeset.h" +#include "rescuableartifactdata.h" +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class Logger; + +using ArtifactSetByFileTag = QHash; + +class QBS_AUTOTEST_EXPORT ProductBuildData +{ +public: + ~ProductBuildData(); + + const TypeFilter rootArtifacts() const; + const NodeSet &allNodes() const { return m_nodes; } + const NodeSet &rootNodes() const { return m_roots; } + + void addNode(BuildGraphNode *node) { m_nodes.insert(node); } + void addRootNode(BuildGraphNode *node) { m_roots.insert(node); } + void removeFromRootNodes(BuildGraphNode *node) { m_roots.remove(node); } + void addArtifact(Artifact *artifact); + void addArtifactToSet(Artifact *artifact); + void removeArtifact(Artifact *artifact); + void removeArtifactFromSetByFileTag(Artifact *artifact, const FileTag &fileTag); + void addFileTagToArtifact(Artifact *artifact, const FileTag &tag); + + ArtifactSetByFileTag artifactsByFileTag() const; + + AllRescuableArtifactData rescuableArtifactData() const { return m_rescuableArtifactData; } + void setRescuableArtifactData(const AllRescuableArtifactData &rad); + RescuableArtifactData removeFromRescuableArtifactData(const QString &filePath); + void addRescuableArtifactData(const QString &filePath, const RescuableArtifactData &rad); + + unsigned int buildPriority() const { return m_buildPriority; } + void setBuildPriority(unsigned int prio) { m_buildPriority = prio; } + + bool checkAndSetJsArtifactsMapUpToDateFlag(); + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_nodes, m_roots, m_rescuableArtifactData, + m_artifactsByFileTag); + } + +private: + void removeArtifactFromSet(Artifact *artifact); + + NodeSet m_nodes; + NodeSet m_roots; + + // After change tracking, this is the relevant data of artifacts that were in the build data + // of the restored product, and will potentially be re-created by our rules. + // If and when that happens, the relevant data will be copied over to the newly created + // artifact. + AllRescuableArtifactData m_rescuableArtifactData; + + // Do not store, initialized in executor. Higher prioritized artifacts are built first. + unsigned int m_buildPriority = 0; + + ArtifactSetByFileTag m_artifactsByFileTag; + mutable std::mutex m_artifactsMapMutex; + + bool m_jsArtifactsMapUpToDate = true; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PRODUCTBUILDDATA_H diff --git a/src/lib/corelib/buildgraph/productinstaller.cpp b/src/lib/corelib/buildgraph/productinstaller.cpp new file mode 100644 index 00000000..80a76d7f --- /dev/null +++ b/src/lib/corelib/buildgraph/productinstaller.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "productinstaller.h" + +#include "artifact.h" +#include "productbuilddata.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +ProductInstaller::ProductInstaller(TopLevelProjectPtr project, + QVector products, InstallOptions options, + ProgressObserver *observer, Logger logger) + : m_project(std::move(project)), + m_products(std::move(products)), + m_options(std::move(options)), + m_observer(observer), + m_logger(std::move(logger)) +{ + if (!m_options.installRoot().isEmpty()) { + QFileInfo installRootFileInfo(m_options.installRoot()); + QBS_ASSERT(installRootFileInfo.isAbsolute(), /* just complain */); + if (m_options.removeExistingInstallation()) { + const QString cfp = installRootFileInfo.canonicalFilePath(); + if (cfp == QFileInfo(QDir::rootPath()).canonicalFilePath()) + throw ErrorInfo(Tr::tr("Refusing to remove root directory.")); + if (cfp == QFileInfo(QDir::homePath()).canonicalFilePath()) + throw ErrorInfo(Tr::tr("Refusing to remove home directory.")); + } + return; + } + + if (m_options.installIntoSysroot()) { + if (m_options.removeExistingInstallation()) + throw ErrorInfo(Tr::tr("Refusing to remove sysroot.")); + } + initInstallRoot(m_project.get(), m_options); +} + +void ProductInstaller::install() +{ + m_targetFilePathsMap.clear(); + + if (m_options.removeExistingInstallation()) + removeInstallRoot(); + + QList artifactsToInstall; + for (const auto &product : qAsConst(m_products)) { + QBS_CHECK(product->buildData); + for (const Artifact *artifact : filterByType(product->buildData->allNodes())) { + if (artifact->properties->qbsPropertyValue(StringConstants::installProperty()).toBool()) + artifactsToInstall.push_back(artifact); + } + } + m_observer->initialize(Tr::tr("Installing"), artifactsToInstall.size()); + + for (const Artifact * const a : qAsConst(artifactsToInstall)) { + copyFile(a); + m_observer->incrementProgressValue(); + } +} + +QString ProductInstaller::targetFilePath(const TopLevelProject *project, + const QString &productSourceDir, + const QString &sourceFilePath, const PropertyMapConstPtr &properties, + InstallOptions &options) +{ + if (!properties->qbsPropertyValue(StringConstants::installProperty()).toBool()) + return {}; + const QString relativeInstallDir + = properties->qbsPropertyValue(StringConstants::installDirProperty()).toString(); + const QString installPrefix + = properties->qbsPropertyValue(StringConstants::installPrefixProperty()).toString(); + const QString installSourceBase + = properties->qbsPropertyValue(StringConstants::installSourceBaseProperty()).toString(); + initInstallRoot(project, options); + QString targetDir = options.installRoot(); + if (targetDir.isEmpty()) + targetDir = properties->qbsPropertyValue(StringConstants::installRootProperty()).toString(); + targetDir.append(QLatin1Char('/')).append(installPrefix) + .append(QLatin1Char('/')).append(relativeInstallDir); + targetDir = QDir::cleanPath(targetDir); + + QString targetFilePath; + if (installSourceBase.isEmpty()) { + if (!targetDir.startsWith(options.installRoot())) { + throw ErrorInfo(Tr::tr("Cannot install '%1', because target directory '%2' " + "is outside of install root '%3'") + .arg(sourceFilePath, targetDir, options.installRoot())); + } + + // This has the same effect as if installSourceBase would equal the directory of the file. + targetFilePath = FileInfo::fileName(sourceFilePath); + } else { + const QString localAbsBasePath = FileInfo::resolvePath(QDir::cleanPath(productSourceDir), + QDir::cleanPath(installSourceBase)); + targetFilePath = sourceFilePath; + if (!targetFilePath.startsWith(localAbsBasePath)) { + throw ErrorInfo(Tr::tr("Cannot install '%1', because it doesn't start with the" + " value of qbs.installSourceBase '%2'.").arg(sourceFilePath, + localAbsBasePath)); + } + + // Since there is a difference between X: and X:\\ on Windows, absolute paths can sometimes + // end with a slash, so only remove an extra character if there is no ending slash + targetFilePath.remove(0, localAbsBasePath.length() + + (localAbsBasePath.endsWith(QLatin1Char('/')) ? 0 : 1)); + } + + targetFilePath.prepend(targetDir + QLatin1Char('/')); + return QDir::cleanPath(targetFilePath); +} + +void ProductInstaller::initInstallRoot(const TopLevelProject *project, + InstallOptions &options) +{ + if (!options.installRoot().isEmpty()) + return; + + options.setInstallRoot(effectiveInstallRoot(options, project)); +} + +void ProductInstaller::removeInstallRoot() +{ + const QString nativeInstallRoot = QDir::toNativeSeparators(m_options.installRoot()); + if (m_options.dryRun()) { + m_logger.qbsInfo() << Tr::tr("Would remove install root '%1'.").arg(nativeInstallRoot); + return; + } + m_logger.qbsDebug() << QStringLiteral("Removing install root '%1'.") + .arg(nativeInstallRoot); + + QString errorMessage; + if (!removeDirectoryWithContents(m_options.installRoot(), &errorMessage)) { + const QString fullErrorMessage = Tr::tr("Cannot remove install root '%1': %2") + .arg(QDir::toNativeSeparators(m_options.installRoot()), errorMessage); + handleError(fullErrorMessage); + } +} + +void ProductInstaller::copyFile(const Artifact *artifact) +{ + if (m_observer->canceled()) { + throw ErrorInfo(Tr::tr("Installation canceled for configuration '%1'.") + .arg(m_products.front()->project->topLevelProject()->id())); + } + + const QString targetFilePath = this->targetFilePath(m_project.get(), + artifact->product->sourceDirectory, artifact->filePath(), + artifact->properties, m_options); + const QString targetDir = FileInfo::path(targetFilePath); + const QString nativeFilePath = QDir::toNativeSeparators(artifact->filePath()); + const QString nativeTargetDir = QDir::toNativeSeparators(targetDir); + if (m_options.dryRun()) { + m_logger.qbsDebug() << Tr::tr("Would copy file '%1' into target directory '%2'.") + .arg(nativeFilePath, nativeTargetDir); + return; + } + m_logger.qbsDebug() << QStringLiteral("Copying file '%1' into target directory '%2'.") + .arg(nativeFilePath, nativeTargetDir); + + if (!QDir::root().mkpath(targetDir)) { + handleError(Tr::tr("Directory '%1' could not be created.").arg(nativeTargetDir)); + return; + } + QFileInfo fi(artifact->filePath()); + if (fi.isDir() && !(HostOsInfo::isAnyUnixHost() && fi.isSymLink())) { + m_logger.qbsWarning() << Tr::tr("Not recursively copying directory '%1' into target " + "directory '%2'. Install the individual file artifacts " + "instead.") + .arg(nativeFilePath, nativeTargetDir); + } + + if (m_targetFilePathsMap.contains(targetFilePath)) { + // We only want this error message when installing artifacts pointing to different file + // paths, to the same location. We do NOT want it when installing different artifacts + // pointing to the same file, to the same location. This reduces unnecessary noise: for + // example, when installing headers from a multiplexed product, the user does not need to + // do extra work to ensure the files are installed by only one of the instances. + if (artifact->filePath() != m_targetFilePathsMap[targetFilePath]) { + handleError(Tr::tr("Cannot install files '%1' and '%2' to the same location '%3'. " + "If you are attempting to install a directory hierarchy, consider " + "using the qbs.installSourceBase property.") + .arg(artifact->filePath(), m_targetFilePathsMap[targetFilePath], + targetFilePath)); + } + } + m_targetFilePathsMap.insert(targetFilePath, artifact->filePath()); + + QString errorMessage; + if (!copyFileRecursion(artifact->filePath(), targetFilePath, true, false, &errorMessage)) + handleError(Tr::tr("Installation error: %1").arg(errorMessage)); +} + +void ProductInstaller::handleError(const QString &message) +{ + if (!m_options.keepGoing()) + throw ErrorInfo(message); + m_logger.qbsWarning() << message; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/productinstaller.h b/src/lib/corelib/buildgraph/productinstaller.h new file mode 100644 index 00000000..c07e0b7c --- /dev/null +++ b/src/lib/corelib/buildgraph/productinstaller.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PRODUCT_INSTALLER_H +#define QBS_PRODUCT_INSTALLER_H + +#include "forward_decls.h" + +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { +class ProgressObserver; + +class ProductInstaller +{ +public: + ProductInstaller(TopLevelProjectPtr project, + QVector products, + InstallOptions options, ProgressObserver *observer, Logger logger); + void install(); + + static QString targetFilePath(const TopLevelProject *project, const QString &productSourceDir, + const QString &sourceFilePath, const PropertyMapConstPtr &properties, + InstallOptions &options); + static void initInstallRoot(const TopLevelProject *project, InstallOptions &options); + + void removeInstallRoot(); + void copyFile(const Artifact *artifact); + +private: + void handleError(const QString &message); + + const TopLevelProjectConstPtr m_project; + const QVector m_products; + InstallOptions m_options; + ProgressObserver * const m_observer; + Logger m_logger; + QHash m_targetFilePathsMap; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Header guard diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp new file mode 100644 index 00000000..e0e70e65 --- /dev/null +++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp @@ -0,0 +1,482 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "projectbuilddata.h" + +#include "artifact.h" +#include "buildgraph.h" +#include "buildgraphvisitor.h" +#include "productbuilddata.h" +#include "rulecommands.h" +#include "rulegraph.h" +#include "rulenode.h" +#include "rulesevaluationcontext.h" +#include "transformer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +static Set findDependentProducts(const ResolvedProductPtr &product) +{ + Set result; + for (const ResolvedProductPtr &parent : product->topLevelProject()->allProducts()) { + if (contains(parent->dependencies, product)) + result += parent; + } + return result; +} + +ProjectBuildData::ProjectBuildData(const ProjectBuildData *other) +{ + // This is needed for temporary duplication of build data when doing change tracking. + if (other) { + *this = *other; + m_doCleanupInDestructor = false; + } +} + +ProjectBuildData::~ProjectBuildData() +{ + if (!m_doCleanupInDestructor) + return; + qDeleteAll(fileDependencies); +} + +QString ProjectBuildData::deriveBuildGraphFilePath(const QString &buildDir, const QString &projectId) +{ + return buildDir + QLatin1Char('/') + projectId + QStringLiteral(".bg"); +} + +void ProjectBuildData::insertIntoLookupTable(FileResourceBase *fileres) +{ + auto &lst = m_artifactLookupTable[{fileres->fileName(), fileres->dirPath()}]; + const auto * const artifact = fileres->fileType() == FileResourceBase::FileTypeArtifact + ? static_cast(fileres) : nullptr; + if (artifact && artifact->artifactType == Artifact::Generated) { + for (const auto *file : lst) { + if (file->fileType() != FileResourceBase::FileTypeArtifact) + continue; + const auto * const otherArtifact = static_cast(file); + ErrorInfo error; + error.append(Tr::tr("Conflicting artifacts for file path '%1'.") + .arg(artifact->filePath())); + error.append(Tr::tr("The first artifact comes from product '%1'.") + .arg(otherArtifact->product->fullDisplayName()), + otherArtifact->product->location); + error.append(Tr::tr("The second artifact comes from product '%1'.") + .arg(artifact->product->fullDisplayName()), + artifact->product->location); + throw error; + } + } + QBS_CHECK(!contains(lst, fileres)); + lst.push_back(fileres); + m_isDirty = true; +} + +void ProjectBuildData::removeFromLookupTable(FileResourceBase *fileres) +{ + removeOne(m_artifactLookupTable[{fileres->fileName(), fileres->dirPath()}], fileres); +} + +const std::vector &ProjectBuildData::lookupFiles(const QString &filePath) const +{ + QString dirPath, fileName; + FileInfo::splitIntoDirectoryAndFileName(filePath, &dirPath, &fileName); + return lookupFiles(dirPath, fileName); +} + +const std::vector &ProjectBuildData::lookupFiles(const QString &dirPath, + const QString &fileName) const +{ + static const std::vector emptyResult; + const auto it = m_artifactLookupTable.find({fileName, dirPath}); + return it != m_artifactLookupTable.end() ? it->second : emptyResult; +} + +const std::vector &ProjectBuildData::lookupFiles(const Artifact *artifact) const +{ + return lookupFiles(artifact->dirPath(), artifact->fileName()); +} + +void ProjectBuildData::insertFileDependency(FileDependency *dependency) +{ + fileDependencies += dependency; + insertIntoLookupTable(dependency); +} + +static void disconnectArtifactChildren(Artifact *artifact) +{ + qCDebug(lcBuildGraph) << "disconnect children of" << relativeArtifactFileName(artifact); + for (BuildGraphNode * const child : qAsConst(artifact->children)) + child->parents.remove(artifact); + artifact->children.clear(); + artifact->childrenAddedByScanner.clear(); +} + +static void disconnectArtifactParents(Artifact *artifact) +{ + qCDebug(lcBuildGraph) << "disconnect parents of" << relativeArtifactFileName(artifact); + for (BuildGraphNode * const parent : qAsConst(artifact->parents)) { + parent->children.remove(artifact); + if (parent->type() != BuildGraphNode::ArtifactNodeType) + continue; + auto const parentArtifact = static_cast(parent); + QBS_CHECK(parentArtifact->transformer); + parentArtifact->childrenAddedByScanner.remove(artifact); + parentArtifact->transformer->inputs.remove(artifact); + parentArtifact->transformer->explicitlyDependsOn.remove(artifact); + } + + artifact->parents.clear(); +} + +static void disconnectArtifact(Artifact *artifact) +{ + disconnectArtifactChildren(artifact); + disconnectArtifactParents(artifact); +} + +/*! + * Removes the artifact and all the artifacts that depend exclusively on it. + * Example: if you remove a cpp artifact then the obj artifact is removed but + * not the resulting application (if there's more then one cpp artifact). + */ +void ProjectBuildData::removeArtifactAndExclusiveDependents(Artifact *artifact, + const Logger &logger, bool removeFromProduct, + ArtifactSet *removedArtifacts) +{ + if (removedArtifacts) + removedArtifacts->insert(artifact); + + // Iterate over a copy of the artifact's parents, because we'll change + // artifact->parents with the disconnect call. + const NodeSet parentsCopy = artifact->parents; + for (Artifact *parent : filterByType(parentsCopy)) { + bool removeParent = false; + disconnect(parent, artifact); + if (parent->children.empty()) { + removeParent = true; + } else if (parent->transformer) { + parent->transformer->inputs.remove(artifact); + removeParent = parent->transformer->inputs.empty(); + } + if (removeParent) { + removeArtifactAndExclusiveDependents(parent, logger, removeFromProduct, + removedArtifacts); + } else { + parent->clearTimestamp(); + } + } + const bool removeFromDisk = artifact->artifactType == Artifact::Generated; + removeArtifact(artifact, logger, removeFromDisk, removeFromProduct); +} + +static void removeFromRuleNodes(Artifact *artifact) +{ + for (RuleNode * const ruleNode : filterByType(artifact->parents)) + ruleNode->removeOldInputArtifact(artifact); +} + +void ProjectBuildData::removeArtifact(Artifact *artifact, + const Logger &logger, bool removeFromDisk, bool removeFromProduct) +{ + qCDebug(lcBuildGraph) << "remove artifact" << relativeArtifactFileName(artifact); + if (removeFromDisk) + removeGeneratedArtifactFromDisk(artifact, logger); + removeFromLookupTable(artifact); + removeFromRuleNodes(artifact); + disconnectArtifact(artifact); + if (artifact->transformer) + artifact->transformer->outputs.remove(artifact); + if (removeFromProduct) + artifact->product->buildData->removeArtifact(artifact); +} + +void ProjectBuildData::setDirty() +{ + qCDebug(lcBuildGraph) << "Marking build graph as dirty"; + m_isDirty = true; +} + +void ProjectBuildData::setClean() +{ + qCDebug(lcBuildGraph) << "Marking build graph as clean"; + m_isDirty = false; +} + +void ProjectBuildData::load(PersistentPool &pool) +{ + serializationOp(pool); + for (FileDependency * const dep : qAsConst(fileDependencies)) + insertIntoLookupTable(dep); + m_isDirty = false; +} + +void ProjectBuildData::store(PersistentPool &pool) +{ + serializationOp(pool); +} + + +BuildDataResolver::BuildDataResolver(Logger logger) : m_logger(std::move(logger)) +{ +} + +void BuildDataResolver::resolveBuildData(const TopLevelProjectPtr &resolvedProject, + const RulesEvaluationContextPtr &evalContext) +{ + QBS_CHECK(!resolvedProject->buildData); + m_project = resolvedProject; + resolvedProject->buildData = std::make_unique(); + resolvedProject->buildData->evaluationContext = evalContext; + const std::vector &allProducts = resolvedProject->allProducts(); + evalContext->initializeObserver(Tr::tr("Setting up build graph for configuration %1") + .arg(resolvedProject->id()), int(allProducts.size()) + 1); + for (const auto &rProduct : allProducts) { + if (rProduct->enabled) + resolveProductBuildData(rProduct); + evalContext->incrementProgressValue(); + } + evalContext->incrementProgressValue(); + doSanityChecks(resolvedProject, m_logger); +} + +void BuildDataResolver::resolveProductBuildDataForExistingProject(const TopLevelProjectPtr &project, + const std::vector &freshProducts) +{ + m_project = project; + for (const ResolvedProductPtr &product : freshProducts) { + if (product->enabled) + resolveProductBuildData(product); + } + + QHash> dependencyMap; + for (const ResolvedProductPtr &product : freshProducts) { + if (!product->enabled) + continue; + QBS_CHECK(product->buildData); + const Set dependents = findDependentProducts(product); + for (const ResolvedProductPtr &dependentProduct : dependents) { + if (!dependentProduct->enabled) + continue; + if (!contains(dependencyMap[dependentProduct], product)) + dependencyMap[dependentProduct].push_back(product); + } + } + for (auto it = dependencyMap.cbegin(); it != dependencyMap.cend(); ++it) { + if (!contains(freshProducts, it.key())) + connectRulesToDependencies(it.key(), it.value()); + } +} + +class CreateRuleNodes : public RuleGraphVisitor +{ +public: + CreateRuleNodes(const ResolvedProductPtr &product) + : m_product(product) + { + } + +private: + const ResolvedProductPtr &m_product; + QHash m_nodePerRule; + Set m_rulesOnPath; + QList m_rulePath; + + void visit(const RuleConstPtr &parentRule, const RuleConstPtr &rule) override + { + if (!m_rulesOnPath.insert(rule.get()).second) { + QString pathstr; + for (const Rule *r : qAsConst(m_rulePath)) { + pathstr += QLatin1Char('\n') + r->toString() + QLatin1Char('\t') + + r->prepareScript.location().toString(); + } + throw ErrorInfo(Tr::tr("Cycle detected in rule dependencies: %1").arg(pathstr)); + } + m_rulePath.push_back(rule.get()); + RuleNode *node = m_nodePerRule.value(rule); + if (!node) { + node = new RuleNode; + m_nodePerRule.insert(rule, node); + node->product = m_product; + node->setRule(rule); + m_product->buildData->addNode(node); + qCDebug(lcBuildGraph).noquote() << "create" << node->toString() + << "for product" << m_product->uniqueName(); + } + if (parentRule) { + RuleNode *parent = m_nodePerRule.value(parentRule); + QBS_CHECK(parent); + connect(parent, node); + } else { + m_product->buildData->addRootNode(node); + } + } + + void endVisit(const RuleConstPtr &rule) override + { + m_rulesOnPath.remove(rule.get()); + m_rulePath.removeLast(); + } +}; + +static bool areRulesCompatible(const RuleNode *ruleNode, const RuleNode *dependencyRule) +{ + const FileTags outTags = dependencyRule->rule()->collectedOutputFileTags(); + if (ruleNode->rule()->excludedInputs.intersects(outTags)) + return false; + if (ruleNode->rule()->inputsFromDependencies.intersects(outTags)) + return true; + if (!dependencyRule->product->fileTags.intersects(outTags)) + return false; + if (ruleNode->rule()->explicitlyDependsOnFromDependencies.intersects(outTags)) + return true; + return ruleNode->rule()->auxiliaryInputs.intersects(outTags); +} + +void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &product) +{ + if (product->buildData) + return; + + evalContext()->checkForCancelation(); + + product->buildData = std::make_unique(); + ArtifactSetByFileTag artifactsPerFileTag; + + for (const auto &dependency : qAsConst(product->dependencies)) { + QBS_CHECK(dependency->enabled); + resolveProductBuildData(dependency); + } + + //add qbsFile artifact + Artifact *qbsFileArtifact = lookupArtifact(product, product->location.filePath()); + if (!qbsFileArtifact) { + qbsFileArtifact = new Artifact; + qbsFileArtifact->artifactType = Artifact::SourceFile; + qbsFileArtifact->setFilePath(product->location.filePath()); + qbsFileArtifact->properties = product->moduleProperties; + insertArtifact(product, qbsFileArtifact); + } + qbsFileArtifact->addFileTag("qbs"); + artifactsPerFileTag["qbs"].insert(qbsFileArtifact); + + // read sources + for (const auto &sourceArtifact : product->allEnabledFiles()) { + QString filePath = sourceArtifact->absoluteFilePath; + if (lookupArtifact(product, filePath)) + continue; // ignore duplicate artifacts + + Artifact *artifact = createArtifact(product, sourceArtifact); + for (const FileTag &fileTag : artifact->fileTags()) + artifactsPerFileTag[fileTag].insert(artifact); + } + + RuleGraph ruleGraph; + ruleGraph.build(product->rules, product->fileTags); + CreateRuleNodes crn(product); + ruleGraph.accept(&crn); + + connectRulesToDependencies(product, product->dependencies); +} + +static bool isRootRuleNode(RuleNode *ruleNode) +{ + return ruleNode->product->buildData->rootNodes().contains(ruleNode); +} + +void BuildDataResolver::connectRulesToDependencies(const ResolvedProductPtr &product, + const std::vector &dependencies) +{ + // Connect the rules of this product to the compatible rules of all product dependencies. + // Rules that take "installable" artifacts are connected to all root rules of product + // dependencies. + std::vector ruleNodes; + for (RuleNode *ruleNode : filterByType(product->buildData->allNodes())) + ruleNodes.push_back(ruleNode); + for (const auto &dep : dependencies) { + if (!dep->buildData) + continue; + for (RuleNode *depRuleNode : filterByType(dep->buildData->allNodes())) { + for (RuleNode *ruleNode : ruleNodes) { + static const FileTag installableTag("installable"); + if (areRulesCompatible(ruleNode, depRuleNode) + || ((ruleNode->rule()->inputsFromDependencies.contains(installableTag) + || ruleNode->rule()->auxiliaryInputs.contains(installableTag) + || ruleNode->rule()->explicitlyDependsOnFromDependencies.contains( + installableTag)) + && isRootRuleNode(depRuleNode))) { + connect(ruleNode, depRuleNode); + } + } + } + } +} + +RulesEvaluationContextPtr BuildDataResolver::evalContext() const +{ + return m_project->buildData->evaluationContext; +} + +ScriptEngine *BuildDataResolver::engine() const +{ + return evalContext()->engine(); +} + +QScriptValue BuildDataResolver::scope() const +{ + return evalContext()->scope(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/projectbuilddata.h b/src/lib/corelib/buildgraph/projectbuilddata.h new file mode 100644 index 00000000..93034443 --- /dev/null +++ b/src/lib/corelib/buildgraph/projectbuilddata.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROJECTBUILDDATA_H +#define QBS_PROJECTBUILDDATA_H + +#include "forward_decls.h" +#include "rawscanresults.h" +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { +class BuildGraphNode; +class FileDependency; +class FileResourceBase; +class ScriptEngine; + +class QBS_AUTOTEST_EXPORT ProjectBuildData +{ +public: + ProjectBuildData(const ProjectBuildData *other = nullptr); + ~ProjectBuildData(); + + static QString deriveBuildGraphFilePath(const QString &buildDir, const QString &projectId); + + void insertIntoLookupTable(FileResourceBase *fileres); + void removeFromLookupTable(FileResourceBase *fileres); + + const std::vector &lookupFiles(const QString &filePath) const; + const std::vector &lookupFiles(const QString &dirPath, const QString &fileName) const; + const std::vector &lookupFiles(const Artifact *artifact) const; + void insertFileDependency(FileDependency *dependency); + void removeArtifactAndExclusiveDependents(Artifact *artifact, const Logger &logger, + bool removeFromProduct = true, ArtifactSet *removedArtifacts = nullptr); + void removeArtifact(Artifact *artifact, const Logger &logger, bool removeFromDisk = true, + bool removeFromProduct = true); + + void setDirty(); + void setClean(); + bool isDirty() const { return m_isDirty; } + + + Set fileDependencies; + RawScanResults rawScanResults; + + // do not serialize: + RulesEvaluationContextPtr evaluationContext; + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(fileDependencies, rawScanResults); + } + + using ArtifactKey = std::pair; + using ArtifactLookupTable = std::unordered_map>; + ArtifactLookupTable m_artifactLookupTable; + + bool m_doCleanupInDestructor = true; + bool m_isDirty = true; +}; + + +class BuildDataResolver +{ +public: + BuildDataResolver(Logger logger); + void resolveBuildData(const TopLevelProjectPtr &resolvedProject, + const RulesEvaluationContextPtr &evalContext); + void resolveProductBuildDataForExistingProject(const TopLevelProjectPtr &project, + const std::vector &freshProducts); + +private: + void resolveProductBuildData(const ResolvedProductPtr &product); + void connectRulesToDependencies(const ResolvedProductPtr &product, + const std::vector &dependencies); + + RulesEvaluationContextPtr evalContext() const; + ScriptEngine *engine() const; + QScriptValue scope() const; + + TopLevelProjectPtr m_project; + Logger m_logger; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROJECTBUILDDATA_H diff --git a/src/lib/corelib/buildgraph/qtmocscanner.cpp b/src/lib/corelib/buildgraph/qtmocscanner.cpp new file mode 100644 index 00000000..a911f4a5 --- /dev/null +++ b/src/lib/corelib/buildgraph/qtmocscanner.cpp @@ -0,0 +1,278 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtmocscanner.h" + +#include "artifact.h" +#include "depscanner.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "rawscanresults.h" +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +struct CommonFileTags +{ + const FileTag cpp = "cpp"; + const FileTag cppCombine = "cpp.combine"; + const FileTag hpp = "hpp"; + const FileTag moc_cpp = "moc_cpp"; + const FileTag moc_cpp_plugin = "moc_cpp_plugin"; + const FileTag moc_hpp_plugin = "moc_hpp_plugin"; + const FileTag moc_hpp = "moc_hpp"; + const FileTag objcpp = "objcpp"; + const FileTag objcppCombine = "objcpp.combine"; +}; + +Q_GLOBAL_STATIC(CommonFileTags, commonFileTags) + +class QtScanner : public DependencyScanner +{ +public: + QtScanner(const DependencyScanner &actualScanner) + : m_id(QStringLiteral("qt") + actualScanner.id()) {} + +private: + QStringList collectSearchPaths(Artifact *) override { return {}; } + QStringList collectDependencies(Artifact *, FileResourceBase *, const char *) override + { + return {}; + } + bool recursive() const override { return false; } + const void *key() const override { return nullptr; } + QString createId() const override { return m_id; } + bool areModulePropertiesCompatible(const PropertyMapConstPtr &, + const PropertyMapConstPtr &) const override + { + return true; + } + bool cacheIsPerFile() const override { return false; } + + const QString m_id; +}; + +static QString qtMocScannerJsName() { return QStringLiteral("QtMocScanner"); } + +QtMocScanner::QtMocScanner(const ResolvedProductPtr &product, QScriptValue targetScriptValue) + : m_tags(*commonFileTags()) + , m_product(product) + , m_targetScriptValue(targetScriptValue) +{ + const auto engine = static_cast(targetScriptValue.engine()); + QScriptValue scannerObj = engine->newObject(); + targetScriptValue.setProperty(qtMocScannerJsName(), scannerObj); + QScriptValue applyFunction = engine->newFunction(&js_apply, this); + scannerObj.setProperty(QStringLiteral("apply"), applyFunction); +} + +QtMocScanner::~QtMocScanner() +{ + m_targetScriptValue.setProperty(qtMocScannerJsName(), QScriptValue()); +} + +static RawScanResult runScanner(ScannerPlugin *scanner, const Artifact *artifact) +{ + const QString &filepath = artifact->filePath(); + QtScanner depScanner((PluginDependencyScanner(scanner))); + RawScanResults &rawScanResults + = artifact->product->topLevelProject()->buildData->rawScanResults; + RawScanResults::ScanData &scanData = rawScanResults.findScanData(artifact, &depScanner, + artifact->properties); + if (scanData.lastScanTime < artifact->timestamp()) { + FileTags tags = artifact->fileTags(); + if (tags.contains(commonFileTags->cppCombine)) { + tags.remove(commonFileTags->cppCombine); + tags.insert(commonFileTags->cpp); + } + if (tags.contains(commonFileTags->objcppCombine)) { + tags.remove(commonFileTags->objcppCombine); + tags.insert(commonFileTags->objcpp); + } + const QByteArray tagsForScanner = tags.toStringList().join(QLatin1Char(',')).toLatin1(); + void *opaq = scanner->open(filepath.utf16(), tagsForScanner.constData(), + ScanForDependenciesFlag | ScanForFileTagsFlag); + if (!opaq || !scanner->additionalFileTags) + return scanData.rawScanResult; + + scanData.rawScanResult.additionalFileTags.clear(); + scanData.rawScanResult.deps.clear(); + int length = 0; + const char **szFileTagsFromScanner = scanner->additionalFileTags(opaq, &length); + if (szFileTagsFromScanner) { + for (int i = length; --i >= 0;) + scanData.rawScanResult.additionalFileTags += szFileTagsFromScanner[i]; + } + + QString baseDirOfInFilePath = artifact->dirPath(); + for (;;) { + int flags = 0; + const char *szOutFilePath = scanner->next(opaq, &length, &flags); + if (szOutFilePath == nullptr) + break; + QString includedFilePath = QString::fromLocal8Bit(szOutFilePath, length); + if (includedFilePath.isEmpty()) + continue; + bool isLocalInclude = (flags & SC_LOCAL_INCLUDE_FLAG); + if (isLocalInclude) { + QString localFilePath = FileInfo::resolvePath(baseDirOfInFilePath, includedFilePath); + if (FileInfo::exists(localFilePath)) + includedFilePath = localFilePath; + } + scanData.rawScanResult.deps.emplace_back(includedFilePath); + } + + scanner->close(opaq); + scanData.lastScanTime = FileTime::currentTime(); + } + return scanData.rawScanResult; +} + +void QtMocScanner::findIncludedMocCppFiles() +{ + if (!m_includedMocCppFiles.empty()) + return; + + qCDebug(lcMocScan) << "looking for included moc_XXX.cpp files"; + + static const FileTags mocCppTags = {m_tags.cpp, m_tags.objcpp}; + for (Artifact *artifact : m_product->lookupArtifactsByFileTags(mocCppTags)) { + const RawScanResult scanResult = runScanner(m_cppScanner, artifact); + for (const RawScannedDependency &dependency : scanResult.deps) { + QString includedFileName = dependency.fileName(); + if (includedFileName.startsWith(QLatin1String("moc_")) + && includedFileName.endsWith(QLatin1String(".cpp"))) { + qCDebug(lcMocScan) << artifact->fileName() << "includes" << includedFileName; + includedFileName.remove(0, 4); + includedFileName.chop(4); + m_includedMocCppFiles.insert(includedFileName, artifact->fileName()); + } + } + } +} + +QScriptValue QtMocScanner::js_apply(QScriptContext *ctx, QScriptEngine *engine, + QtMocScanner *that) +{ + QScriptValue input = ctx->argument(0); + return that->apply(engine, attachedPointer(input)); +} + +static QScriptValue scannerCountError(QScriptEngine *engine, size_t scannerCount, + const QString &fileTag) +{ + return engine->currentContext()->throwError( + Tr::tr("There are %1 scanners for the file tag %2. " + "Expected is exactly one.").arg(scannerCount).arg(fileTag)); +} + +QScriptValue QtMocScanner::apply(QScriptEngine *engine, const Artifact *artifact) +{ + if (!m_cppScanner) { + auto scanners = ScannerPluginManager::scannersForFileTag(m_tags.cpp); + if (scanners.size() != 1) + return scannerCountError(engine, scanners.size(), m_tags.cpp.toString()); + m_cppScanner = scanners.front(); + } + + qCDebug(lcMocScan).noquote() << "scanning" << artifact->toString(); + + bool hasQObjectMacro = false; + bool mustCompile = false; + bool hasPluginMetaDataMacro = false; + const bool isHeaderFile = artifact->fileTags().contains(m_tags.hpp); + + RawScanResult scanResult = runScanner(m_cppScanner, artifact); + if (scanResult.additionalFileTags.empty() && artifact->fileTags().contains("mocable")) { + if (isHeaderFile) { + scanResult.additionalFileTags.insert(m_tags.moc_hpp); + } else if (artifact->fileTags().contains(m_tags.cpp) + || artifact->fileTags().contains(m_tags.cppCombine) + || artifact->fileTags().contains(m_tags.objcpp) + || artifact->fileTags().contains(m_tags.objcppCombine)) { + scanResult.additionalFileTags.insert(m_tags.moc_cpp); + } + } + if (!scanResult.additionalFileTags.empty()) { + if (isHeaderFile) { + if (scanResult.additionalFileTags.contains(m_tags.moc_hpp)) + hasQObjectMacro = true; + if (scanResult.additionalFileTags.contains(m_tags.moc_hpp_plugin)) { + hasQObjectMacro = true; + hasPluginMetaDataMacro = true; + } + findIncludedMocCppFiles(); + if (!m_includedMocCppFiles.contains(FileInfo::completeBaseName(artifact->fileName()))) + mustCompile = true; + } else { + if (scanResult.additionalFileTags.contains(m_tags.moc_cpp)) + hasQObjectMacro = true; + if (scanResult.additionalFileTags.contains(m_tags.moc_cpp_plugin)) { + hasQObjectMacro = true; + hasPluginMetaDataMacro = true; + } + } + } + + qCDebug(lcMocScan) << "hasQObjectMacro:" << hasQObjectMacro + << "mustCompile:" << mustCompile + << "hasPluginMetaDataMacro:" << hasPluginMetaDataMacro; + + QScriptValue obj = engine->newObject(); + obj.setProperty(QStringLiteral("hasQObjectMacro"), hasQObjectMacro); + obj.setProperty(QStringLiteral("mustCompile"), mustCompile); + obj.setProperty(QStringLiteral("hasPluginMetaDataMacro"), hasPluginMetaDataMacro); + static_cast(engine)->setUsesIo(); + return obj; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/qtmocscanner.h b/src/lib/corelib/buildgraph/qtmocscanner.h new file mode 100644 index 00000000..6455383f --- /dev/null +++ b/src/lib/corelib/buildgraph/qtmocscanner.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_QTMOCSCANNER_H +#define QBS_QTMOCSCANNER_H + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QScriptContext; +QT_END_NAMESPACE + +class ScannerPlugin; + +namespace qbs { +namespace Internal { + +class Artifact; +struct CommonFileTags; + +class QtMocScanner +{ +public: + explicit QtMocScanner(const ResolvedProductPtr &product, QScriptValue targetScriptValue); + ~QtMocScanner(); + +private: + void findIncludedMocCppFiles(); + static QScriptValue js_apply(QScriptContext *ctx, QScriptEngine *engine, QtMocScanner *that); + QScriptValue apply(QScriptEngine *engine, const Artifact *artifact); + + const CommonFileTags &m_tags; + const ResolvedProductPtr &m_product; + QScriptValue m_targetScriptValue; + QHash m_includedMocCppFiles; + ScannerPlugin *m_cppScanner = nullptr; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_QTMOCSCANNER_H diff --git a/src/lib/corelib/buildgraph/rawscanneddependency.cpp b/src/lib/corelib/buildgraph/rawscanneddependency.cpp new file mode 100644 index 00000000..bea9655e --- /dev/null +++ b/src/lib/corelib/buildgraph/rawscanneddependency.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rawscanneddependency.h" + +#include + +namespace qbs { +namespace Internal { + +RawScannedDependency::RawScannedDependency() : m_isClean(true) {} + +RawScannedDependency::RawScannedDependency(const QString &filePath) +{ + FileInfo::splitIntoDirectoryAndFileName(filePath, &m_dirPath, &m_fileName); + setClean(); +} + +QString RawScannedDependency::filePath() const +{ + return m_dirPath.isEmpty() ? m_fileName : m_dirPath + QLatin1Char('/') + m_fileName; +} + +void RawScannedDependency::setClean() +{ + m_isClean = !m_dirPath.contains(QLatin1Char('.')) && !m_dirPath.contains(QStringLiteral("//")); +} + +void RawScannedDependency::load(PersistentPool &pool) +{ + serializationOp(pool); + setClean(); +} + +void RawScannedDependency::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +bool operator==(const RawScannedDependency &d1, const RawScannedDependency &d2) +{ + return d1.dirPath() == d2.dirPath() && d1.fileName() == d2.fileName(); +} + + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rawscanneddependency.h b/src/lib/corelib/buildgraph/rawscanneddependency.h new file mode 100644 index 00000000..4871bea6 --- /dev/null +++ b/src/lib/corelib/buildgraph/rawscanneddependency.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RAWSCANNEDDEPENDENCY_H +#define QBS_RAWSCANNEDDEPENDENCY_H + +#include + +#include + +namespace qbs { +namespace Internal { +class PersistentPool; + +class RawScannedDependency +{ +public: + RawScannedDependency(); + RawScannedDependency(const QString &filePath); + + QString filePath() const; + const QString &dirPath() const { return m_dirPath; } + const QString &fileName() const { return m_fileName; } + bool isClean() const { return m_isClean; } + bool isValid() const { return !m_fileName.isEmpty(); } + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + +private: + void setClean(); + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_dirPath, m_fileName); + } + + QString m_dirPath; + QString m_fileName; + bool m_isClean = 0; +}; + +bool operator==(const RawScannedDependency &d1, const RawScannedDependency &d2); +inline bool operator!=(const RawScannedDependency &d1, const RawScannedDependency &d2) +{ + return !(d1 == d2); +} + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/buildgraph/rawscanresults.cpp b/src/lib/corelib/buildgraph/rawscanresults.cpp new file mode 100644 index 00000000..a519f685 --- /dev/null +++ b/src/lib/corelib/buildgraph/rawscanresults.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rawscanresults.h" + +#include "filedependency.h" +#include "depscanner.h" + +#include + +namespace qbs { +namespace Internal { + +RawScanResults::ScanData &RawScanResults::findScanData( + const FileResourceBase *file, + const DependencyScanner *scanner, + const PropertyMapConstPtr &moduleProperties) +{ + std::vector &scanDataForFile = m_rawScanData[file->filePath()]; + const QString &scannerId = scanner->id(); + for (auto &scanData : scanDataForFile) { + if (scannerId != scanData.scannerId) + continue; + if (!scanner->areModulePropertiesCompatible(moduleProperties, scanData.moduleProperties)) + continue; + return scanData; + } + ScanData newScanData; + newScanData.scannerId = scannerId; + newScanData.moduleProperties = moduleProperties; + scanDataForFile.push_back(std::move(newScanData)); + return scanDataForFile.back(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rawscanresults.h b/src/lib/corelib/buildgraph/rawscanresults.h new file mode 100644 index 00000000..b1089708 --- /dev/null +++ b/src/lib/corelib/buildgraph/rawscanresults.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RAWSCANRESULTS_H +#define QBS_RAWSCANRESULTS_H + +#include "rawscanneddependency.h" + +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { +class DependencyScanner; +class FileResourceBase; + +class RawScanResult +{ +public: + std::vector deps; + FileTags additionalFileTags; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(deps, additionalFileTags); + } +}; + +class RawScanResults +{ +public: + struct ScanData + { + QString scannerId; + PropertyMapConstPtr moduleProperties; + FileTime lastScanTime; + RawScanResult rawScanResult; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(scannerId, moduleProperties, lastScanTime, rawScanResult); + } + }; + + ScanData &findScanData( + const FileResourceBase *file, + const DependencyScanner *scanner, + const PropertyMapConstPtr &moduleProperties); + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_rawScanData); + } + +private: + QHash> m_rawScanData; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/buildgraph/requestedartifacts.cpp b/src/lib/corelib/buildgraph/requestedartifacts.cpp new file mode 100644 index 00000000..e4730d2f --- /dev/null +++ b/src/lib/corelib/buildgraph/requestedartifacts.cpp @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "requestedartifacts.h" + +#include "productbuilddata.h" +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +bool RequestedArtifacts::isUpToDate(const TopLevelProject *project) const +{ + if (m_requestedArtifactsPerProduct.empty()) + return true; + const std::vector &allProducts = project->allProducts(); + for (const auto &kv : m_requestedArtifactsPerProduct) { + const QString &productName = kv.first; + const auto findProduct = [productName](const ResolvedProductConstPtr &p) { + return p->uniqueName() == productName; + }; + const auto productIt = std::find_if(allProducts.begin(), allProducts.end(), findProduct); + if (productIt == allProducts.end()) { + qCDebug(lcBuildGraph) << "artifacts map not up to date: product" << productName + << "does not exist anymore"; + return false; + } + if (!kv.second.isUpToDate(productIt->get())) + return false; + } + return true; +} + +void RequestedArtifacts::setAllArtifactTags(const ResolvedProduct *product, bool forceUpdate) +{ + RequestedArtifactsPerProduct &ra = m_requestedArtifactsPerProduct[product->uniqueName()]; + if (!ra.allTags.empty() && !forceUpdate) + return; + ra.allTags.clear(); + const ArtifactSetByFileTag artifactsMap = product->buildData->artifactsByFileTag(); + for (auto it = artifactsMap.begin(); it != artifactsMap.end(); ++it) + ra.allTags.insert(it.key().toString()); +} + +void RequestedArtifacts::setArtifactsForTag(const ResolvedProduct *product, + const FileTag &tag) +{ + RequestedArtifactsPerProduct &ra = m_requestedArtifactsPerProduct[product->uniqueName()]; + QBS_ASSERT(!ra.allTags.empty(), ;); + Set &filePaths = ra.requestedTags[tag.toString()]; + for (const Artifact * const a : product->buildData->artifactsByFileTag().value(tag)) + filePaths.insert(a->filePath()); +} + +void RequestedArtifacts::setNonExistingTagRequested(const ResolvedProduct *product, + const QString &tag) +{ + RequestedArtifactsPerProduct &ra = m_requestedArtifactsPerProduct[product->uniqueName()]; + QBS_ASSERT(!ra.allTags.empty(), ;); + Set &filePaths = ra.requestedTags[tag]; + QBS_CHECK(filePaths.empty()); +} + +void RequestedArtifacts::setArtifactsEnumerated(const ResolvedProduct *product) +{ + m_requestedArtifactsPerProduct[product->uniqueName()].artifactsEnumerated = true; +} + +void RequestedArtifacts::unite(const RequestedArtifacts &other) +{ + for (const auto &kv : other.m_requestedArtifactsPerProduct) + m_requestedArtifactsPerProduct[kv.first].unite(kv.second); +} + +void RequestedArtifacts::doSanityChecks() const +{ + for (const auto &kv : m_requestedArtifactsPerProduct) + kv.second.doSanityChecks(); +} + +void RequestedArtifacts::load(PersistentPool &pool) +{ + serializationOp(pool); +} + +void RequestedArtifacts::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +bool RequestedArtifacts::RequestedArtifactsPerProduct::isUpToDate( + const ResolvedProduct *product) const +{ + if (!product->buildData) { + qCDebug(lcBuildGraph) << "artifacts map not up to date: product" << product->uniqueName() + << "is now disabled"; + return false; + } + + if (!artifactsEnumerated && requestedTags.empty()) + return true; + + const ArtifactSetByFileTag currentArtifacts = product->buildData->artifactsByFileTag(); + for (const auto &kv : requestedTags) { + const FileTag tag = FileTag(kv.first.toUtf8()); + const auto currentIt = currentArtifacts.constFind(tag); + Set currentFilePathsForTag; + if (currentIt != currentArtifacts.constEnd()) { + for (const Artifact * const a : currentIt.value()) + currentFilePathsForTag.insert(a->filePath()); + } + if (currentFilePathsForTag != kv.second) { + qCDebug(lcBuildGraph) << "artifacts map not up to date: requested artifact set for " + "file tag" << kv.first << "in product" + << product->uniqueName() << "differs from the current one"; + return false; + } + } + + if (!artifactsEnumerated) + return true; + + Set currentTags; + for (auto it = currentArtifacts.begin(); it != currentArtifacts.end(); ++it) + currentTags.insert(it.key().toString()); + if (currentTags != allTags) { + qCDebug(lcBuildGraph) << "artifacts map not up to date: overall file tags differ for " + << "product" << product->uniqueName(); + return false; + } + return true; +} + +void RequestedArtifacts::RequestedArtifactsPerProduct::unite( + const RequestedArtifactsPerProduct &other) +{ + if (allTags.empty()) { + *this = other; + return; + } + allTags = other.allTags; + for (const auto &kv : other.requestedTags) + requestedTags[kv.first] = kv.second; +} + +void RequestedArtifacts::RequestedArtifactsPerProduct::doSanityChecks() const +{ + for (const auto &kv : requestedTags) + QBS_CHECK(allTags.contains(kv.first) || kv.second.empty()); +} + +void RequestedArtifacts::RequestedArtifactsPerProduct::load(PersistentPool &pool) +{ + serializationOp(pool); +} + +void RequestedArtifacts::RequestedArtifactsPerProduct::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/requestedartifacts.h b/src/lib/corelib/buildgraph/requestedartifacts.h new file mode 100644 index 00000000..d3804ca1 --- /dev/null +++ b/src/lib/corelib/buildgraph/requestedartifacts.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_REQUESTEDARTIFACTS_H +#define QBS_REQUESTEDARTIFACTS_H + +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { +class FileTag; +class PersistentPool; + +class RequestedArtifacts +{ +public: + bool isUpToDate(const TopLevelProject *project) const; + + void clear() { m_requestedArtifactsPerProduct.clear(); } + void setAllArtifactTags(const ResolvedProduct *product, bool forceUpdate); + void setArtifactsForTag(const ResolvedProduct *product, const FileTag &tag); + void setNonExistingTagRequested(const ResolvedProduct *product, const QString &tag); + void setArtifactsEnumerated(const ResolvedProduct *product); + void unite(const RequestedArtifacts &other); + + void doSanityChecks() const; + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_requestedArtifactsPerProduct); + } + +private: + struct RequestedArtifactsPerProduct + { + Set allTags; + std::unordered_map> requestedTags; + bool artifactsEnumerated = false; + + bool isUpToDate(const ResolvedProduct *product) const; + + void unite(const RequestedArtifactsPerProduct &other); + + void doSanityChecks() const; + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(allTags, requestedTags, artifactsEnumerated); + } + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + }; + + std::unordered_map m_requestedArtifactsPerProduct; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/buildgraph/requesteddependencies.cpp b/src/lib/corelib/buildgraph/requesteddependencies.cpp new file mode 100644 index 00000000..b95c8db9 --- /dev/null +++ b/src/lib/corelib/buildgraph/requesteddependencies.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "requesteddependencies.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static Set depNamesForProduct(const ResolvedProduct *p) +{ + Set names; + for (const auto &dep : p->dependencies) + names.insert(dep->uniqueName()); + for (const auto &m : p->modules) { + if (!m->isProduct) + names.insert(m->name); + } + return names; +} + +void RequestedDependencies::set(const Set &products) +{ + m_depsPerProduct.clear(); + add(products); +} + +void RequestedDependencies::add(const Set &products) +{ + for (const ResolvedProduct * const p : products) + m_depsPerProduct[p->uniqueName()] = depNamesForProduct(p); +} + +bool RequestedDependencies::isUpToDate(const TopLevelProject *project) const +{ + if (m_depsPerProduct.empty()) + return true; + for (const auto &product : project->allProducts()) { + const auto it = m_depsPerProduct.find(product->uniqueName()); + if (it == m_depsPerProduct.cend()) + continue; + const Set newDepNames = depNamesForProduct(product.get()); + if (newDepNames != it->second) { + qCDebug(lcBuildGraph) << "dependencies list was accessed for product" + << product->fullDisplayName() << "and dependencies have changed."; + return false; + } + } + return true; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/requesteddependencies.h b/src/lib/corelib/buildgraph/requesteddependencies.h new file mode 100644 index 00000000..e9e341d4 --- /dev/null +++ b/src/lib/corelib/buildgraph/requesteddependencies.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_REQUESTEDDEPENDENCIES_H +#define QBS_REQUESTEDDEPENDENCIES_H + +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class RequestedDependencies +{ +public: + RequestedDependencies() = default; + RequestedDependencies(const Set &products) { set(products); } + void set(const Set &products); + void add(const Set &products); + void clear() { m_depsPerProduct.clear(); } + bool isUpToDate(const TopLevelProject *project) const; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_depsPerProduct); + } + +private: + struct QStringHash { std::size_t operator()(const QString &s) const { return qHash(s); } }; + std::unordered_map, QStringHash> m_depsPerProduct; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/buildgraph/rescuableartifactdata.h b/src/lib/corelib/buildgraph/rescuableartifactdata.h new file mode 100644 index 00000000..6dd10f76 --- /dev/null +++ b/src/lib/corelib/buildgraph/rescuableartifactdata.h @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RESCUABLEARTIFACTDATA_H +#define QBS_RESCUABLEARTIFACTDATA_H + +#include "forward_decls.h" +#include "requestedartifacts.h" +#include "requesteddependencies.h" +#include "rulecommands.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT RescuableArtifactData +{ +public: + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(timeStamp, children, fileDependencies, knownOutOfDate, + propertiesRequestedInPrepareScript, + propertiesRequestedInCommands, + propertiesRequestedFromArtifactInPrepareScript, + propertiesRequestedFromArtifactInCommands, + importedFilesUsedInPrepareScript, importedFilesUsedInCommands, + depsRequestedInPrepareScript, depsRequestedInCommands, + commands, artifactsMapRequestedInPrepareScript, + artifactsMapRequestedInCommands, + exportedModulesAccessedInPrepareScript, + exportedModulesAccessedInCommands, + lastPrepareScriptExecutionTime, + lastCommandExecutionTime, fileTags, properties); + } + + bool isValid() const { return !!properties; } + + struct ChildData + { + ChildData(QString n = QString(), QString m = QString(), + QString c = QString(), bool byScanner = false) + : productName(std::move(n)) + , productMultiplexId(std::move(m)) + , childFilePath(std::move(c)) + , addedByScanner(byScanner) + {} + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(productName, productMultiplexId, childFilePath, + addedByScanner); + } + + QString productName; + QString productMultiplexId; + QString childFilePath; + bool addedByScanner; + }; + + FileTime timeStamp; + std::vector children; + std::vector fileDependencies; + + // Per-Transformer data + CommandList commands; + PropertySet propertiesRequestedInPrepareScript; + PropertySet propertiesRequestedInCommands; + PropertyHash propertiesRequestedFromArtifactInPrepareScript; + PropertyHash propertiesRequestedFromArtifactInCommands; + std::vector importedFilesUsedInPrepareScript; + std::vector importedFilesUsedInCommands; + RequestedDependencies depsRequestedInPrepareScript; + RequestedDependencies depsRequestedInCommands; + RequestedArtifacts artifactsMapRequestedInPrepareScript; + RequestedArtifacts artifactsMapRequestedInCommands; + FileTime lastPrepareScriptExecutionTime; + FileTime lastCommandExecutionTime; + std::unordered_map exportedModulesAccessedInPrepareScript; + std::unordered_map exportedModulesAccessedInCommands; + bool knownOutOfDate = false; + + // Only needed for API purposes + FileTags fileTags; + PropertyMapPtr properties; + +}; +using AllRescuableArtifactData = QHash; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/buildgraph/rulecommands.cpp b/src/lib/corelib/buildgraph/rulecommands.cpp new file mode 100644 index 00000000..9eed7c71 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulecommands.cpp @@ -0,0 +1,489 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rulecommands.h" +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +static QString argumentsProperty() { return QStringLiteral("arguments"); } +static QString environmentProperty() { return QStringLiteral("environment"); } +static QString extendedDescriptionProperty() { return QStringLiteral("extendedDescription"); } +static QString highlightProperty() { return QStringLiteral("highlight"); } +static QString ignoreDryRunProperty() { return QStringLiteral("ignoreDryRun"); } +static QString maxExitCodeProperty() { return QStringLiteral("maxExitCode"); } +static QString programProperty() { return QStringLiteral("program"); } +static QString responseFileArgumentIndexProperty() +{ + return QStringLiteral("responseFileArgumentIndex"); +} +static QString responseFileThresholdProperty() { return QStringLiteral("responseFileThreshold"); } +static QString responseFileUsagePrefixProperty() +{ + return QStringLiteral("responseFileUsagePrefix"); +} +static QString responseFileSeparatorProperty() { return QStringLiteral("responseFileSeparator"); } +static QString silentProperty() { return QStringLiteral("silent"); } +static QString stderrFilePathProperty() { return QStringLiteral("stderrFilePath"); } +static QString stderrFilterFunctionProperty() { return QStringLiteral("stderrFilterFunction"); } +static QString stdoutFilePathProperty() { return QStringLiteral("stdoutFilePath"); } +static QString stdoutFilterFunctionProperty() { return QStringLiteral("stdoutFilterFunction"); } +static QString timeoutProperty() { return QStringLiteral("timeout"); } +static QString workingDirProperty() { return QStringLiteral("workingDirectory"); } + +static QString invokedSourceCode(const QScriptValue &codeOrFunction) +{ + const QString &code = codeOrFunction.toString(); + return codeOrFunction.isFunction() ? QStringLiteral("(") + code + QStringLiteral(")()") : code; +} + +AbstractCommand::AbstractCommand() + : m_description(defaultDescription()), + m_extendedDescription(defaultExtendedDescription()), + m_highlight(defaultHighLight()), + m_ignoreDryRun(defaultIgnoreDryRun()), + m_silent(defaultIsSilent()), + m_timeout(defaultTimeout()) +{ +} + +AbstractCommand::~AbstractCommand() = default; + +bool AbstractCommand::equals(const AbstractCommand *other) const +{ + return type() == other->type() + && m_description == other->m_description + && m_extendedDescription == other->m_extendedDescription + && m_highlight == other->m_highlight + && m_ignoreDryRun == other->m_ignoreDryRun + && m_silent == other->m_silent + && m_jobPool == other->m_jobPool + && m_timeout == other->m_timeout + && m_properties == other->m_properties; +} + +void AbstractCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) +{ + m_description = scriptValue->property(StringConstants::descriptionProperty()).toString(); + m_extendedDescription = scriptValue->property(extendedDescriptionProperty()).toString(); + m_highlight = scriptValue->property(highlightProperty()).toString(); + m_ignoreDryRun = scriptValue->property(ignoreDryRunProperty()).toBool(); + m_silent = scriptValue->property(silentProperty()).toBool(); + m_jobPool = scriptValue->property(StringConstants::jobPoolProperty()).toString(); + const auto timeoutScriptValue = scriptValue->property(timeoutProperty()); + if (!timeoutScriptValue.isUndefined() && !timeoutScriptValue.isNull()) + m_timeout = timeoutScriptValue.toInt32(); + m_codeLocation = codeLocation; + + m_predefinedProperties + << StringConstants::descriptionProperty() + << extendedDescriptionProperty() + << highlightProperty() + << ignoreDryRunProperty() + << StringConstants::jobPoolProperty() + << silentProperty() + << timeoutProperty(); +} + +QString AbstractCommand::fullDescription(const QString &productName) const +{ + return description() + QLatin1String(" [") + productName + QLatin1Char(']'); +} + +void AbstractCommand::load(PersistentPool &pool) +{ + serializationOp(pool); +} + +void AbstractCommand::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +void AbstractCommand::applyCommandProperties(const QScriptValue *scriptValue) +{ + QScriptValueIterator it(*scriptValue); + while (it.hasNext()) { + it.next(); + if (m_predefinedProperties.contains(it.name())) + continue; + const QVariant value = it.value().toVariant(); + if (QMetaType::Type(value.userType()) == QMetaType::QObjectStar + || it.value().scriptClass() + || it.value().data().isValid()) { + throw ErrorInfo(Tr::tr("Property '%1' has a type unsuitable for storing in a command " + "object.").arg(it.name()), m_codeLocation); + } + m_properties.insert(it.name(), value); + } +} + +static QScriptValue js_CommandBase(QScriptContext *context, QScriptEngine *engine) +{ + QScriptValue cmd = context->thisObject(); + QBS_ASSERT(context->isCalledAsConstructor(), cmd = engine->newObject()); + cmd.setProperty(StringConstants::descriptionProperty(), + engine->toScriptValue(AbstractCommand::defaultDescription())); + cmd.setProperty(extendedDescriptionProperty(), + engine->toScriptValue(AbstractCommand::defaultExtendedDescription())); + cmd.setProperty(highlightProperty(), + engine->toScriptValue(AbstractCommand::defaultHighLight())); + cmd.setProperty(ignoreDryRunProperty(), + engine->toScriptValue(AbstractCommand::defaultIgnoreDryRun())); + cmd.setProperty(silentProperty(), + engine->toScriptValue(AbstractCommand::defaultIsSilent())); + cmd.setProperty(timeoutProperty(), + engine->toScriptValue(AbstractCommand::defaultTimeout())); + return cmd; +} + +static QScriptValue js_Command(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(!context->isCalledAsConstructor())) + return context->throwError(Tr::tr("Command constructor called without new.")); + + static ProcessCommandPtr commandPrototype = ProcessCommand::create(); + + QScriptValue program = context->argument(0); + if (program.isUndefined()) + program = engine->toScriptValue(commandPrototype->program()); + QScriptValue arguments = context->argument(1); + if (arguments.isUndefined()) + arguments = engine->toScriptValue(commandPrototype->arguments()); + QScriptValue cmd = js_CommandBase(context, engine); + cmd.setProperty(StringConstants::classNameProperty(), + engine->toScriptValue(StringConstants::commandType())); + cmd.setProperty(programProperty(), program); + cmd.setProperty(argumentsProperty(), arguments); + cmd.setProperty(workingDirProperty(), + engine->toScriptValue(commandPrototype->workingDir())); + cmd.setProperty(maxExitCodeProperty(), + engine->toScriptValue(commandPrototype->maxExitCode())); + cmd.setProperty(stdoutFilterFunctionProperty(), + engine->toScriptValue(commandPrototype->stdoutFilterFunction())); + cmd.setProperty(stderrFilterFunctionProperty(), + engine->toScriptValue(commandPrototype->stderrFilterFunction())); + cmd.setProperty(responseFileThresholdProperty(), + engine->toScriptValue(commandPrototype->responseFileThreshold())); + cmd.setProperty(responseFileArgumentIndexProperty(), + engine->toScriptValue(commandPrototype->responseFileArgumentIndex())); + cmd.setProperty(responseFileUsagePrefixProperty(), + engine->toScriptValue(commandPrototype->responseFileUsagePrefix())); + cmd.setProperty(responseFileSeparatorProperty(), + engine->toScriptValue(commandPrototype->responseFileSeparator())); + cmd.setProperty(stdoutFilePathProperty(), + engine->toScriptValue(commandPrototype->stdoutFilePath())); + cmd.setProperty(stderrFilePathProperty(), + engine->toScriptValue(commandPrototype->stderrFilePath())); + cmd.setProperty(environmentProperty(), + engine->toScriptValue(commandPrototype->environment().toStringList())); + cmd.setProperty(ignoreDryRunProperty(), + engine->toScriptValue(commandPrototype->ignoreDryRun())); + return cmd; +} + + +void ProcessCommand::setupForJavaScript(QScriptValue targetObject) +{ + QBS_CHECK(targetObject.isObject()); + QScriptValue ctor = targetObject.engine()->newFunction(js_Command, 2); + targetObject.setProperty(StringConstants::commandType(), ctor); +} + +ProcessCommand::ProcessCommand() + : m_maxExitCode(0) + , m_responseFileThreshold(defaultResponseFileThreshold()) + , m_responseFileArgumentIndex(0) + , m_responseFileSeparator(QStringLiteral("\n")) +{ +} + +int ProcessCommand::defaultResponseFileThreshold() const +{ + // TODO: Non-Windows platforms likely have their own limits. Investigate. + return HostOsInfo::isWindowsHost() + ? 31000 // 32000 minus "safety offset" + : -1; +} + +void ProcessCommand::getEnvironmentFromList(const QStringList &envList) +{ + m_environment.clear(); + for (const QString &env : envList) { + const int equalsIndex = env.indexOf(QLatin1Char('=')); + if (equalsIndex <= 0 || equalsIndex == env.size() - 1) + continue; + const QString &var = env.left(equalsIndex); + const QString &value = env.mid(equalsIndex + 1); + m_environment.insert(var, value); + } +} + +bool ProcessCommand::equals(const AbstractCommand *otherAbstractCommand) const +{ + if (!AbstractCommand::equals(otherAbstractCommand)) + return false; + const auto other = static_cast(otherAbstractCommand); + return m_program == other->m_program + && m_arguments == other->m_arguments + && m_workingDir == other->m_workingDir + && m_maxExitCode == other->m_maxExitCode + && m_stdoutFilterFunction == other->m_stdoutFilterFunction + && m_stderrFilterFunction == other->m_stderrFilterFunction + && m_responseFileThreshold == other->m_responseFileThreshold + && m_responseFileArgumentIndex == other->m_responseFileArgumentIndex + && m_responseFileUsagePrefix == other->m_responseFileUsagePrefix + && m_responseFileSeparator == other->m_responseFileSeparator + && m_stdoutFilePath == other->m_stdoutFilePath + && m_stderrFilePath == other->m_stderrFilePath + && m_relevantEnvVars == other->m_relevantEnvVars + && m_relevantEnvValues == other->m_relevantEnvValues + && m_environment == other->m_environment; +} + +void ProcessCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) +{ + AbstractCommand::fillFromScriptValue(scriptValue, codeLocation); + m_program = scriptValue->property(programProperty()).toString(); + m_arguments = scriptValue->property(argumentsProperty()).toVariant().toStringList(); + m_workingDir = scriptValue->property(workingDirProperty()).toString(); + m_maxExitCode = scriptValue->property(maxExitCodeProperty()).toInt32(); + + // toString() is required, presumably due to QtScript bug that manifests itself on Windows + const QScriptValue stdoutFilterFunction + = scriptValue->property(stdoutFilterFunctionProperty()).toString(); + + m_stdoutFilterFunction = invokedSourceCode(stdoutFilterFunction); + + // toString() is required, presumably due to QtScript bug that manifests itself on Windows + const QScriptValue stderrFilterFunction + = scriptValue->property(stderrFilterFunctionProperty()).toString(); + + m_stderrFilterFunction = invokedSourceCode(stderrFilterFunction); + m_relevantEnvVars = scriptValue->property(QStringLiteral("relevantEnvironmentVariables")) + .toVariant().toStringList(); + m_responseFileThreshold = scriptValue->property(responseFileThresholdProperty()) + .toInt32(); + m_responseFileArgumentIndex = scriptValue->property(responseFileArgumentIndexProperty()) + .toInt32(); + m_responseFileUsagePrefix = scriptValue->property(responseFileUsagePrefixProperty()) + .toString(); + m_responseFileSeparator = scriptValue->property(responseFileSeparatorProperty()) + .toString(); + QStringList envList = scriptValue->property(environmentProperty()).toVariant() + .toStringList(); + getEnvironmentFromList(envList); + m_stdoutFilePath = scriptValue->property(stdoutFilePathProperty()).toString(); + m_stderrFilePath = scriptValue->property(stderrFilePathProperty()).toString(); + + m_predefinedProperties + << programProperty() + << argumentsProperty() + << workingDirProperty() + << maxExitCodeProperty() + << stdoutFilterFunctionProperty() + << stderrFilterFunctionProperty() + << responseFileThresholdProperty() + << responseFileArgumentIndexProperty() + << responseFileUsagePrefixProperty() + << environmentProperty() + << stdoutFilePathProperty() + << stderrFilePathProperty(); + applyCommandProperties(scriptValue); +} + +QStringList ProcessCommand::relevantEnvVars() const +{ + QStringList vars = m_relevantEnvVars; + if (!FileInfo::isAbsolute(program())) + vars << StringConstants::pathEnvVar(); + return vars; +} + +void ProcessCommand::addRelevantEnvValue(const QString &key, const QString &value) +{ + m_relevantEnvValues.insert(key, value); +} + +void ProcessCommand::load(PersistentPool &pool) +{ + AbstractCommand::load(pool); + serializationOp(pool); +} + +void ProcessCommand::store(PersistentPool &pool) +{ + AbstractCommand::store(pool); + serializationOp(pool); +} + +static QString currentImportScopeName(QScriptContext *context) +{ + for (; context; context = context->parentContext()) { + QScriptValue v = context->thisObject() + .property(StringConstants::importScopeNamePropertyInternal()); + if (v.isString()) + return v.toString(); + } + return {}; +} + +static QScriptValue js_JavaScriptCommand(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(!context->isCalledAsConstructor())) + return context->throwError(Tr::tr("JavaScriptCommand constructor called without new.")); + if (Q_UNLIKELY(context->argumentCount() != 0)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("JavaScriptCommand c'tor doesn't take arguments.")); + } + + static JavaScriptCommandPtr commandPrototype = JavaScriptCommand::create(); + QScriptValue cmd = js_CommandBase(context, engine); + cmd.setProperty(StringConstants::classNameProperty(), + engine->toScriptValue(StringConstants::javaScriptCommandType())); + cmd.setProperty(StringConstants::sourceCodeProperty(), + engine->toScriptValue(commandPrototype->sourceCode())); + cmd.setProperty(StringConstants::importScopeNamePropertyInternal(), + engine->toScriptValue(currentImportScopeName(context))); + + return cmd; +} + +void JavaScriptCommand::setupForJavaScript(QScriptValue targetObject) +{ + QBS_CHECK(targetObject.isObject()); + QScriptValue ctor = targetObject.engine()->newFunction(js_JavaScriptCommand, 0); + targetObject.setProperty(StringConstants::javaScriptCommandType(), ctor); +} + +JavaScriptCommand::JavaScriptCommand() = default; + +bool JavaScriptCommand::equals(const AbstractCommand *otherAbstractCommand) const +{ + if (!AbstractCommand::equals(otherAbstractCommand)) + return false; + auto const other = static_cast(otherAbstractCommand); + return m_sourceCode == other->m_sourceCode; +} + +void JavaScriptCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) +{ + AbstractCommand::fillFromScriptValue(scriptValue, codeLocation); + + const QScriptValue importScope = scriptValue->property( + StringConstants::importScopeNamePropertyInternal()); + if (importScope.isString()) + m_scopeName = importScope.toString(); + + const QScriptValue sourceCode = scriptValue->property(StringConstants::sourceCodeProperty()); + m_sourceCode = invokedSourceCode(sourceCode); + + m_predefinedProperties << StringConstants::classNameProperty() + << StringConstants::sourceCodeProperty() + << StringConstants::importScopeNamePropertyInternal(); + applyCommandProperties(scriptValue); +} + +void JavaScriptCommand::load(PersistentPool &pool) +{ + AbstractCommand::load(pool); + serializationOp(pool); +} + +void JavaScriptCommand::store(PersistentPool &pool) +{ + AbstractCommand::store(pool); + serializationOp(pool); +} + +void CommandList::load(PersistentPool &pool) +{ + m_commands.clear(); + int count = pool.load(); + m_commands.reserve(count); + while (--count >= 0) { + const auto cmdType = pool.load(); + AbstractCommandPtr cmd; + switch (cmdType) { + case AbstractCommand::JavaScriptCommandType: + cmd = pool.load(); + break; + case AbstractCommand::ProcessCommandType: + cmd = pool.load(); + break; + default: + QBS_CHECK(false); + } + addCommand(cmd); + } +} + +void CommandList::store(PersistentPool &pool) const +{ + pool.store(int(m_commands.size())); + for (const AbstractCommandPtr &cmd : m_commands) { + pool.store(static_cast(cmd->type())); + pool.store(cmd); + } +} + +bool operator==(const CommandList &l1, const CommandList &l2) +{ + if (l1.size() != l2.size()) + return false; + for (int i = 0; i < l1.size(); ++i) + if (!l1.commandAt(i)->equals(l2.commandAt(i).get())) + return false; + return true; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulecommands.h b/src/lib/corelib/buildgraph/rulecommands.h new file mode 100644 index 00000000..725cd6d8 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulecommands.h @@ -0,0 +1,237 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 Jochen Ulrich +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILDGRAPH_COMMAND_H +#define QBS_BUILDGRAPH_COMMAND_H + +#include "forward_decls.h" + +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class AbstractCommand +{ +public: + virtual ~AbstractCommand(); + + enum CommandType { + ProcessCommandType, + JavaScriptCommandType + }; + + static QString defaultDescription() { return {}; } + static QString defaultExtendedDescription() { return {}; } + static QString defaultHighLight() { return {}; } + static bool defaultIgnoreDryRun() { return false; } + static bool defaultIsSilent() { return false; } + static int defaultTimeout() { return -1; } + + virtual CommandType type() const = 0; + virtual bool equals(const AbstractCommand *other) const; + virtual void fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation); + + QString fullDescription(const QString &productName) const; + const QString description() const { return m_description; } + const QString extendedDescription() const { return m_extendedDescription; } + const QString highlight() const { return m_highlight; } + bool ignoreDryRun() const { return m_ignoreDryRun; } + bool isSilent() const { return m_silent; } + QString jobPool() const { return m_jobPool; } + CodeLocation codeLocation() const { return m_codeLocation; } + int timeout() const { return m_timeout; } + + const QVariantMap &properties() const { return m_properties; } + + virtual void load(PersistentPool &pool); + virtual void store(PersistentPool &pool); + +protected: + AbstractCommand(); + void applyCommandProperties(const QScriptValue *scriptValue); + + Set m_predefinedProperties; + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_description, m_extendedDescription, m_highlight, + m_ignoreDryRun, m_silent, m_codeLocation, m_jobPool, + m_timeout, m_properties); + } + + QString m_description; + QString m_extendedDescription; + QString m_highlight; + bool m_ignoreDryRun; + bool m_silent; + CodeLocation m_codeLocation; + QString m_jobPool; + int m_timeout; + QVariantMap m_properties; +}; + +class ProcessCommand : public AbstractCommand +{ +public: + static ProcessCommandPtr create() { return ProcessCommandPtr(new ProcessCommand); } + static void setupForJavaScript(QScriptValue targetObject); + + CommandType type() const override { return ProcessCommandType; } + bool equals(const AbstractCommand *otherAbstractCommand) const override; + void fillFromScriptValue(const QScriptValue *scriptValue, + const CodeLocation &codeLocation) override; + const QString program() const { return m_program; } + const QStringList arguments() const { return m_arguments; } + const QString workingDir() const { return m_workingDir; } + int maxExitCode() const { return m_maxExitCode; } + QString stdoutFilterFunction() const { return m_stdoutFilterFunction; } + QString stderrFilterFunction() const { return m_stderrFilterFunction; } + int responseFileThreshold() const { return m_responseFileThreshold; } + int responseFileArgumentIndex() const { return m_responseFileArgumentIndex; } + QString responseFileUsagePrefix() const { return m_responseFileUsagePrefix; } + QString responseFileSeparator() const { return m_responseFileSeparator; } + QProcessEnvironment environment() const { return m_environment; } + QStringList relevantEnvVars() const; + void clearRelevantEnvValues() { m_relevantEnvValues.clear(); } + void addRelevantEnvValue(const QString &key, const QString &value); + QString relevantEnvValue(const QString &key) const { return m_relevantEnvValues.value(key); } + QString stdoutFilePath() const { return m_stdoutFilePath; } + QString stderrFilePath() const { return m_stderrFilePath; } + + void load(PersistentPool &pool) override; + void store(PersistentPool &pool) override; + +private: + ProcessCommand(); + + int defaultResponseFileThreshold() const; + + void getEnvironmentFromList(const QStringList &envList); + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_program, m_arguments, m_environment, m_workingDir, + m_stdoutFilterFunction, m_stderrFilterFunction, + m_responseFileUsagePrefix, m_responseFileSeparator, + m_maxExitCode, m_responseFileThreshold, + m_responseFileArgumentIndex, m_relevantEnvVars, + m_relevantEnvValues, m_stdoutFilePath, m_stderrFilePath); + } + + QString m_program; + QStringList m_arguments; + QString m_workingDir; + int m_maxExitCode; + QString m_stdoutFilterFunction; + QString m_stderrFilterFunction; + int m_responseFileThreshold; // When to use response files? In bytes of (program name + arguments). + int m_responseFileArgumentIndex; + QString m_responseFileUsagePrefix; + QString m_responseFileSeparator; + QProcessEnvironment m_environment; + QStringList m_relevantEnvVars; + QProcessEnvironment m_relevantEnvValues; + QString m_stdoutFilePath; + QString m_stderrFilePath; +}; + +class JavaScriptCommand : public AbstractCommand +{ +public: + static JavaScriptCommandPtr create() { return JavaScriptCommandPtr(new JavaScriptCommand); } + static void setupForJavaScript(QScriptValue targetObject); + + CommandType type() const override { return JavaScriptCommandType; } + bool equals(const AbstractCommand *otherAbstractCommand) const override; + void fillFromScriptValue(const QScriptValue *scriptValue, + const CodeLocation &codeLocation) override; + + const QString &scopeName() const { return m_scopeName; } + const QString &sourceCode() const { return m_sourceCode; } + void setSourceCode(const QString &str) { m_sourceCode = str; } + + void load(PersistentPool &pool) override; + void store(PersistentPool &pool) override; + +private: + JavaScriptCommand(); + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_scopeName, m_sourceCode); + } + + QString m_scopeName; + QString m_sourceCode; +}; + +class CommandList +{ +public: + bool empty() const { return m_commands.empty(); } + int size() const { return m_commands.size(); } + AbstractCommandPtr commandAt(int i) const { return m_commands.at(i); } + const QList &commands() const { return m_commands; } + + void clear() { m_commands.clear(); } + void addCommand(const AbstractCommandPtr &cmd) { m_commands.push_back(cmd); } + + void load(PersistentPool &pool); + void store(PersistentPool &pool) const; +private: + QList m_commands; +}; +bool operator==(const CommandList &cl1, const CommandList &cl2); +inline bool operator!=(const CommandList &cl1, const CommandList &cl2) { return !(cl1 == cl2); } + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILDGRAPH_COMMAND_H diff --git a/src/lib/corelib/buildgraph/rulegraph.cpp b/src/lib/corelib/buildgraph/rulegraph.cpp new file mode 100644 index 00000000..3f9a4fcb --- /dev/null +++ b/src/lib/corelib/buildgraph/rulegraph.cpp @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rulegraph.h" +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +RuleGraph::RuleGraph() = default; + +void RuleGraph::build(const std::vector &rules, const FileTags &productFileTags) +{ + QMap > inputFileTagToRule; + m_rules.reserve(rules.size()); + for (const RulePtr &rule : rules) { + for (const FileTag &fileTag : rule->collectedOutputFileTags()) + m_outputFileTagToRule[fileTag].push_back(rule.get()); + insert(rule); + } + + m_parents.resize(rules.size()); + m_children.resize(rules.size()); + + for (const auto &rule : qAsConst(m_rules)) { + FileTags inFileTags = rule->inputs; + inFileTags += rule->auxiliaryInputs; + inFileTags += rule->explicitlyDependsOn; + for (const FileTag &fileTag : qAsConst(inFileTags)) { + inputFileTagToRule[fileTag].push_back(rule.get()); + for (const Rule * const producingRule : m_outputFileTagToRule.value(fileTag)) { + if (!producingRule->collectedOutputFileTags().intersects( + rule->excludedInputs)) { + connect(rule.get(), producingRule); + } + } + } + } + + QList productRules; + for (const FileTag &productFileTag : productFileTags) { + QList rules = m_outputFileTagToRule.value(productFileTag); + productRules << rules; + //### check: the rule graph must be a in valid shape! + } + for (const Rule *r : qAsConst(productRules)) + m_rootRules += r->ruleGraphId; +} + +void RuleGraph::accept(RuleGraphVisitor *visitor) const +{ + const RuleConstPtr nullParent; + for (int rootIndex : qAsConst(m_rootRules)) + traverse(visitor, nullParent, m_rules.at(rootIndex)); +} + +void RuleGraph::dump() const +{ + QByteArray indent; + std::printf("---rule graph dump:\n"); + Set rootRules; + for (const auto &rule : qAsConst(m_rules)) + if (m_parents[rule->ruleGraphId].empty()) + rootRules += rule->ruleGraphId; + for (int idx : qAsConst(rootRules)) + dump_impl(indent, idx); +} + +void RuleGraph::dump_impl(QByteArray &indent, int rootIndex) const +{ + const RuleConstPtr r = m_rules[rootIndex]; + std::printf("%s", indent.constData()); + std::printf("%s", qPrintable(r->toString())); + std::printf("\n"); + + indent.append(" "); + for (int childIndex : qAsConst(m_children[rootIndex])) + dump_impl(indent, childIndex); + indent.chop(2); +} + +int RuleGraph::insert(const RulePtr &rule) +{ + rule->ruleGraphId = int(m_rules.size()); + m_rules.push_back(rule); + return rule->ruleGraphId; +} + +void RuleGraph::connect(const Rule *creatingRule, const Rule *consumingRule) +{ + int maxIndex = std::max(creatingRule->ruleGraphId, consumingRule->ruleGraphId); + if (static_cast(m_parents.size()) <= maxIndex) { + const int c = maxIndex + 1; + m_parents.resize(c); + m_children.resize(c); + } + m_parents[consumingRule->ruleGraphId].push_back(creatingRule->ruleGraphId); + m_children[creatingRule->ruleGraphId].push_back(consumingRule->ruleGraphId); +} + +void RuleGraph::traverse(RuleGraphVisitor *visitor, const RuleConstPtr &parentRule, + const RuleConstPtr &rule) const +{ + visitor->visit(parentRule, rule); + for (int childIndex : m_children.at(rule->ruleGraphId)) + traverse(visitor, rule, m_rules.at(childIndex)); + visitor->endVisit(rule); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulegraph.h b/src/lib/corelib/buildgraph/rulegraph.h new file mode 100644 index 00000000..4ce5ecea --- /dev/null +++ b/src/lib/corelib/buildgraph/rulegraph.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RULEGRAPH_H +#define QBS_RULEGRAPH_H + +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class RuleGraphVisitor +{ +public: + virtual ~RuleGraphVisitor() = default; + virtual void visit(const RuleConstPtr &parentRule, const RuleConstPtr &rule) = 0; + virtual void endVisit(const RuleConstPtr &rule) { Q_UNUSED(rule); } +}; + +class RuleGraph +{ +public: + RuleGraph(); + + void build(const std::vector &rules, const FileTags &productFileTag); + void accept(RuleGraphVisitor *visitor) const; + + void dump() const; + +private: + void dump_impl(QByteArray &indent, int rootIndex) const; + int insert(const RulePtr &rule); + void connect(const Rule *creatingRule, const Rule *consumingRule); + void traverse(RuleGraphVisitor *visitor, const RuleConstPtr &parentRule, + const RuleConstPtr &rule) const; + +private: + QMap > m_outputFileTagToRule; + std::vector m_rules; + std::vector< std::vector > m_parents; + std::vector< std::vector > m_children; + Set m_rootRules; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_RULEGRAPH_H diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp new file mode 100644 index 00000000..0558ba14 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulenode.cpp @@ -0,0 +1,321 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "rulenode.h" + +#include "buildgraph.h" +#include "buildgraphvisitor.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "rulesapplicator.h" +#include "transformer.h" +#include "transformerchangetracking.h" + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +RuleNode::RuleNode() = default; + +RuleNode::~RuleNode() = default; + +void RuleNode::accept(BuildGraphVisitor *visitor) +{ + if (visitor->visit(this)) + acceptChildren(visitor); + visitor->endVisit(this); +} + +QString RuleNode::toString() const +{ + return QLatin1String("RULE ") + m_rule->toString() + QLatin1String(" [") + + (!product.expired() ? product->name : QLatin1String("")) + QLatin1Char(']') + + QLatin1String(" located at ") + m_rule->prepareScript.location().toString(); +} + +void RuleNode::apply(const Logger &logger, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName, + ApplicationResult *result) +{ + ArtifactSet allCompatibleInputs = currentInputArtifacts(); + const ArtifactSet explicitlyDependsOn + = RulesApplicator::collectExplicitlyDependsOn(m_rule.get(), product.get()); + const ArtifactSet auxiliaryInputs + = RulesApplicator::collectAuxiliaryInputs(m_rule.get(), product.get()); + const ArtifactSet addedInputs = allCompatibleInputs - m_oldInputArtifacts; + const ArtifactSet removedInputs = m_oldInputArtifacts - allCompatibleInputs; + const ArtifactSet changedInputs = changedInputArtifacts(allCompatibleInputs, + explicitlyDependsOn, + auxiliaryInputs); + bool upToDate = changedInputs.empty() && addedInputs.empty() && removedInputs.empty(); + + qCDebug(lcBuildGraph).noquote().nospace() + << "consider " << (m_rule->isDynamic() ? "dynamic " : "") + << (m_rule->multiplex ? "multiplex " : "") + << "rule node " << m_rule->toString() + << "\n\tchanged: " << changedInputs.toString() + << "\n\tcompatible: " << allCompatibleInputs.toString() + << "\n\tadded: " << addedInputs.toString() + << "\n\tremoved: " << removedInputs.toString(); + + ArtifactSet inputs = changedInputs; + if (m_rule->multiplex) + inputs = allCompatibleInputs; + else + inputs += addedInputs; + + for (Artifact * const input : allCompatibleInputs) { + for (const Artifact * const output : input->parentArtifacts()) { + if (output->transformer->rule != m_rule) + continue; + if (prepareScriptNeedsRerun(output->transformer.get(), + output->transformer->product().get(), + productsByName, projectsByName)) { + upToDate = false; + inputs += input; + } + break; + } + if (m_rule->multiplex) + break; + } + + // Handle rules without inputs: We want to run such a rule if and only if it has not run yet + // or its transformer is not up to date regarding the prepare script. + if (upToDate && (!m_rule->declaresInputs() || !m_rule->requiresInputs) && inputs.empty()) { + bool hasOutputs = false; + for (const Artifact * const output : filterByType(parents)) { + if (output->transformer->rule != m_rule) + continue; + hasOutputs = true; + if (prepareScriptNeedsRerun(output->transformer.get(), + output->transformer->product().get(), + productsByName, projectsByName)) { + upToDate = false; + break; + } + if (m_rule->multiplex) + break; + } + if (!hasOutputs) + upToDate = false; + } + + if (upToDate) { + qCDebug(lcExec) << "rule is up to date. Skipping."; + return; + } + + const bool mustApplyRule = !inputs.empty() || !m_rule->declaresInputs() + || !m_rule->requiresInputs; + + // For a non-multiplex rule, the removal of an input always implies that the + // corresponding outputs disappear. + // For a multiplex rule, the outputs disappear only if *all* inputs are gone *and* + // the rule requires inputs. This is exactly the opposite condition of whether to + // re-apply the rule. + const bool removedInputForcesOutputRemoval = !m_rule->multiplex || !mustApplyRule; + ArtifactSet outputArtifactsToRemove; + std::vector> connectionsToBreak; + for (Artifact * const artifact : removedInputs) { + if (!artifact) // dummy artifact + continue; + for (Artifact *parent : filterByType(artifact->parents)) { + if (parent->transformer->rule != m_rule) { + // parent was not created by our rule. + continue; + } + + // parent must always have a transformer, because it's generated. + QBS_CHECK(parent->transformer); + + // artifact is a former input of m_rule and parent was created by m_rule + // the inputs of the transformer must contain artifact + QBS_CHECK(parent->transformer->inputs.contains(artifact)); + + if (removedInputForcesOutputRemoval) + outputArtifactsToRemove += parent; + else + connectionsToBreak.emplace_back(parent, artifact); + } + disconnect(this, artifact); + } + for (const auto &connection : connectionsToBreak) + disconnect(connection.first, connection.second); + if (!outputArtifactsToRemove.empty()) { + RulesApplicator::handleRemovedRuleOutputs(inputs, outputArtifactsToRemove, + result->removedArtifacts, logger); + } + + if (mustApplyRule) { + RulesApplicator applicator(product.lock(), productsByName, projectsByName, logger); + applicator.applyRule(this, inputs, explicitlyDependsOn); + result->createdArtifacts = applicator.createdArtifacts(); + result->invalidatedArtifacts = applicator.invalidatedArtifacts(); + m_lastApplicationTime = FileTime::currentTime(); + if (applicator.ruleUsesIo()) + m_needsToConsiderChangedInputs = true; + } else { + qCDebug(lcExec).noquote() << "prepare script does not need to run"; + } + m_oldInputArtifacts = allCompatibleInputs; + m_oldExplicitlyDependsOn = explicitlyDependsOn; + m_oldAuxiliaryInputs = auxiliaryInputs; + product->topLevelProject()->buildData->setDirty(); +} + +void RuleNode::load(PersistentPool &pool) +{ + BuildGraphNode::load(pool); + serializationOp(pool); +} + +void RuleNode::store(PersistentPool &pool) +{ + BuildGraphNode::store(pool); + serializationOp(pool); +} + +int RuleNode::transformerCount() const +{ + Set transformers; + for (const Artifact * const output : filterByType(parents)) + transformers.insert(output->transformer.get()); + return int(transformers.size()); +} + +ArtifactSet RuleNode::currentInputArtifacts() const +{ + ArtifactSet s; + for (const FileTag &t : qAsConst(m_rule->inputs)) { + for (Artifact *artifact : product->lookupArtifactsByFileTag(t)) { + if (artifact->isTargetOfModule()) + continue; + if (artifact->transformer && artifact->transformer->rule == m_rule) { + // Do not add compatible artifacts as inputs that were created by this rule. + // This can e.g. happen for the ["cpp", "hpp"] -> ["hpp", "cpp", "unmocable"] rule. + continue; + } + if (artifact->fileTags().intersects(m_rule->excludedInputs)) + continue; + s += artifact; + } + } + + if (m_rule->inputsFromDependencies.empty()) + return s; + for (const FileTag &t : qAsConst(m_rule->inputsFromDependencies)) { + for (Artifact *artifact : product->lookupArtifactsByFileTag(t)) { + if (!artifact->isTargetOfModule()) + continue; + if (artifact->transformer && artifact->transformer->rule == m_rule) + continue; + if (artifact->fileTags().intersects(m_rule->excludedInputs)) + continue; + s += artifact; + } + } + + for (const auto &dep : qAsConst(product->dependencies)) { + if (!dep->buildData) + continue; + for (Artifact * const a : filterByType(dep->buildData->allNodes())) { + if (a->fileTags().intersects(m_rule->inputsFromDependencies) + && !a->fileTags().intersects(m_rule->excludedInputs)) + s += a; + } + } + + return s; +} + +ArtifactSet RuleNode::changedInputArtifacts(const ArtifactSet &allCompatibleInputs, + const ArtifactSet &explicitlyDependsOn, + const ArtifactSet &auxiliaryInputs) const +{ + ArtifactSet changedInputArtifacts; + if (explicitlyDependsOn != m_oldExplicitlyDependsOn) + return allCompatibleInputs; + if (!m_needsToConsiderChangedInputs) + return changedInputArtifacts; + + for (Artifact * const artifact : explicitlyDependsOn) { + if (artifact->timestamp() > m_lastApplicationTime) + return allCompatibleInputs; + } + if (auxiliaryInputs != m_oldAuxiliaryInputs) + return allCompatibleInputs; + for (Artifact * const artifact : auxiliaryInputs) { + if (artifact->timestamp() > m_lastApplicationTime) + return allCompatibleInputs; + } + for (Artifact * const artifact : allCompatibleInputs) { + if (artifact->timestamp() > m_lastApplicationTime) + changedInputArtifacts.insert(artifact); + } + return changedInputArtifacts; +} + +void RuleNode::removeOldInputArtifact(Artifact *artifact) +{ + if (m_oldInputArtifacts.remove(artifact)) { + qCDebug(lcBuildGraph) << "remove old input" << artifact->filePath() + << "from rule" << rule()->toString(); + m_oldInputArtifacts.insert(nullptr); + } + if (m_oldExplicitlyDependsOn.remove(artifact)) { + qCDebug(lcBuildGraph) << "remove old explicitlyDependsOn" << artifact->filePath() + << "from rule" << rule()->toString(); + m_oldExplicitlyDependsOn.insert(nullptr); + } + if (m_oldAuxiliaryInputs.remove(artifact)) { + qCDebug(lcBuildGraph) << "remove old auxiliaryInput" << artifact->filePath() + << "from rule" << rule()->toString(); + m_oldAuxiliaryInputs.insert(nullptr); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulenode.h b/src/lib/corelib/buildgraph/rulenode.h new file mode 100644 index 00000000..cfb2039d --- /dev/null +++ b/src/lib/corelib/buildgraph/rulenode.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RULENODE_H +#define QBS_RULENODE_H + +#include "artifact.h" +#include "buildgraphnode.h" +#include "forward_decls.h" +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class Logger; + +class RuleNode : public BuildGraphNode +{ +public: + RuleNode(); + ~RuleNode() override; + + void setRule(const RuleConstPtr &rule) { m_rule = rule; } + const RuleConstPtr &rule() const { return m_rule; } + + Type type() const override { return RuleNodeType; } + void accept(BuildGraphVisitor *visitor) override; + QString toString() const override; + + struct ApplicationResult + { + NodeSet createdArtifacts; + NodeSet invalidatedArtifacts; + QStringList removedArtifacts; + }; + + void apply(const Logger &logger, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName, + ApplicationResult *result); + void removeOldInputArtifact(Artifact *artifact); + + void load(PersistentPool &pool) override; + void store(PersistentPool &pool) override; + + int transformerCount() const; + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_rule, m_oldInputArtifacts, m_oldExplicitlyDependsOn, + m_oldAuxiliaryInputs, m_lastApplicationTime, + m_needsToConsiderChangedInputs); + } + + ArtifactSet currentInputArtifacts() const; + ArtifactSet changedInputArtifacts(const ArtifactSet &allCompatibleInputs, + const ArtifactSet &explicitlyDependsOn, const ArtifactSet &auxiliaryInputs) const; + + RuleConstPtr m_rule; + + // These three can contain null pointers, which represent a "dummy artifact" encoding + // the information that an artifact that used to be in here has ceased to exist. + // This is okay, because no code outside this class has access to these sets, so + // we cannot break any assumptions about non-nullness. + ArtifactSet m_oldInputArtifacts; + ArtifactSet m_oldExplicitlyDependsOn; + ArtifactSet m_oldAuxiliaryInputs; + + FileTime m_lastApplicationTime; + bool m_needsToConsiderChangedInputs = false; +}; + +template<> inline bool hasDynamicType(const BuildGraphNode *n) +{ + return n->type() == BuildGraphNode::RuleNodeType; +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_RULENODE_H diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp new file mode 100644 index 00000000..f464734b --- /dev/null +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -0,0 +1,684 @@ +#include + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "rulesapplicator.h" + +#include "buildgraph.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" +#include "qtmocscanner.h" +#include "rulecommands.h" +#include "rulenode.h" +#include "rulesevaluationcontext.h" +#include "transformer.h" +#include "transformerchangetracking.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +RulesApplicator::RulesApplicator( + ResolvedProductPtr product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName, + Logger logger) + : m_product(std::move(product)) + // m_productsByName and m_projectsByName are references, cannot move-construct + , m_productsByName(productsByName) + , m_projectsByName(projectsByName) + , m_mocScanner(nullptr) + , m_logger(std::move(logger)) +{ +} + +RulesApplicator::~RulesApplicator() +{ + delete m_mocScanner; +} + +void RulesApplicator::applyRule(RuleNode *ruleNode, const ArtifactSet &inputArtifacts, + const ArtifactSet &explicitlyDependsOn) +{ + m_ruleNode = ruleNode; + m_rule = ruleNode->rule(); + QBS_CHECK(!inputArtifacts.empty() || !m_rule->declaresInputs() || !m_rule->requiresInputs); + + m_product->topLevelProject()->buildData->setDirty(); + m_createdArtifacts.clear(); + m_invalidatedArtifacts.clear(); + m_removedArtifacts.clear(); + m_explicitlyDependsOn = explicitlyDependsOn; + RulesEvaluationContext::Scope s(evalContext().get()); + + m_completeInputSet = inputArtifacts; + if (m_rule->name.startsWith(QLatin1String("QtCoreMocRule"))) { + delete m_mocScanner; + m_mocScanner = new QtMocScanner(m_product, scope()); + } + QScriptValue prepareScriptContext = engine()->newObject(); + prepareScriptContext.setPrototype(engine()->globalObject()); + setupScriptEngineForFile(engine(), m_rule->prepareScript.fileContext(), scope(), + ObserveMode::Enabled); + setupScriptEngineForProduct(engine(), m_product.get(), m_rule->module.get(), + prepareScriptContext, true); + + engine()->clearUsesIo(); + if (m_rule->multiplex) { // apply the rule once for a set of inputs + doApply(inputArtifacts, prepareScriptContext); + } else { // apply the rule once for each input + for (Artifact * const inputArtifact : inputArtifacts) { + ArtifactSet lst; + lst += inputArtifact; + doApply(lst, prepareScriptContext); + } + } + if (engine()->usesIo()) + m_ruleUsesIo = true; +} + +void RulesApplicator::handleRemovedRuleOutputs(const ArtifactSet &inputArtifacts, + const ArtifactSet &outputArtifactsToRemove, QStringList &removedArtifacts, + const Logger &logger) +{ + ArtifactSet artifactsToRemove; + const TopLevelProject *project = nullptr; + for (Artifact * const removedArtifact : outputArtifactsToRemove) { + qCDebug(lcBuildGraph).noquote() << "dynamic rule removed output artifact" + << removedArtifact->toString(); + if (!project) + project = removedArtifact->product->topLevelProject(); + project->buildData->removeArtifactAndExclusiveDependents(removedArtifact, logger, true, + &artifactsToRemove); + } + for (Artifact * const artifact : qAsConst(artifactsToRemove)) { + QBS_CHECK(!inputArtifacts.contains(artifact)); + removedArtifacts << artifact->filePath(); + delete artifact; + } +} + +ArtifactSet RulesApplicator::collectAuxiliaryInputs(const Rule *rule, + const ResolvedProduct *product) +{ + return collectAdditionalInputs(rule->auxiliaryInputs, rule, product, + CurrentProduct | Dependencies); +} + +static void copyProperty(const QString &name, const QScriptValue &src, QScriptValue dst) +{ + dst.setProperty(name, src.property(name)); +} + +static QStringList toStringList(const ArtifactSet &artifacts) +{ + QStringList lst; + for (const Artifact * const artifact : artifacts) { + const QString str = artifact->filePath() + QLatin1String(" [") + + artifact->fileTags().toStringList().join(QLatin1String(", ")) + QLatin1Char(']'); + lst << str; + } + return lst; +} + +void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &prepareScriptContext) +{ + evalContext()->checkForCancelation(); + for (const Artifact *inputArtifact : inputArtifacts) + QBS_CHECK(!inputArtifact->fileTags().intersects(m_rule->excludedInputs)); + + qCDebug(lcBuildGraph) << "apply rule" << m_rule->toString() + << toStringList(inputArtifacts).join(QLatin1String(",\n ")); + + std::vector> ruleArtifactArtifactMap; + QList outputArtifacts; + + m_transformer = Transformer::create(); + m_transformer->rule = m_rule; + m_transformer->inputs = inputArtifacts; + m_transformer->explicitlyDependsOn = m_explicitlyDependsOn; + m_transformer->alwaysRun = m_rule->alwaysRun; + m_oldTransformer.reset(); + + engine()->clearRequestedProperties(); + + // create the output artifacts from the set of input artifacts + m_transformer->setupInputs(prepareScriptContext); + m_transformer->setupExplicitlyDependsOn(prepareScriptContext); + copyProperty(StringConstants::inputsVar(), prepareScriptContext, scope()); + copyProperty(StringConstants::inputVar(), prepareScriptContext, scope()); + copyProperty(StringConstants::explicitlyDependsOnVar(), prepareScriptContext, scope()); + copyProperty(StringConstants::productVar(), prepareScriptContext, scope()); + copyProperty(StringConstants::projectVar(), prepareScriptContext, scope()); + if (m_rule->isDynamic()) { + outputArtifacts = runOutputArtifactsScript(inputArtifacts, + ScriptEngine::argumentList(Rule::argumentNamesForOutputArtifacts(), scope())); + } else { + Set outputFilePaths; + for (const auto &ruleArtifact : m_rule->artifacts) { + const OutputArtifactInfo outputInfo = createOutputArtifactFromRuleArtifact( + ruleArtifact, inputArtifacts, &outputFilePaths); + if (!outputInfo.artifact) + continue; + outputArtifacts.push_back(outputInfo.artifact); + ruleArtifactArtifactMap.emplace_back(ruleArtifact.get(), outputInfo); + } + if (m_rule->artifacts.empty()) { + outputArtifacts.push_back(createOutputArtifactFromRuleArtifact( + nullptr, inputArtifacts, &outputFilePaths).artifact); + } + } + + const auto newOutputs = rangeTo(outputArtifacts); + const ArtifactSet oldOutputs = collectOldOutputArtifacts(inputArtifacts); + handleRemovedRuleOutputs(m_completeInputSet, oldOutputs - newOutputs, m_removedArtifacts, + m_logger); + + // The inputs become children of the rule node. Generated artifacts in the same product + // already are children, because output artifacts become children of the producing + // rule node's parent rule node. + for (Artifact * const input : inputArtifacts) { + if (input->artifactType == Artifact::SourceFile || input->product != m_ruleNode->product + || input->producer()->rule()->collectedOutputFileTags().intersects( + m_ruleNode->rule()->excludedInputs)) { + connect(m_ruleNode, input); + } else { + QBS_CHECK(m_ruleNode->children.contains(input)); + } + } + + if (outputArtifacts.empty()) + return; + + for (Artifact * const outputArtifact : qAsConst(outputArtifacts)) { + for (Artifact * const dependency : qAsConst(m_transformer->explicitlyDependsOn)) + connect(outputArtifact, dependency); + } + + if (inputArtifacts != m_transformer->inputs) + m_transformer->setupInputs(prepareScriptContext); + + // change the transformer outputs according to the bindings in Artifact + QScriptValue scriptValue; + if (!ruleArtifactArtifactMap.empty()) + engine()->setGlobalObject(prepareScriptContext); + for (auto it = ruleArtifactArtifactMap.crbegin(), end = ruleArtifactArtifactMap.crend(); + it != end; ++it) { + const RuleArtifact *ra = it->first; + if (ra->bindings.empty()) + continue; + + // expose attributes of this artifact + const OutputArtifactInfo outputInfo = it->second; + Artifact *outputArtifact = outputInfo.artifact; + outputArtifact->properties = outputArtifact->properties->clone(); + + scope().setProperty(StringConstants::fileNameProperty(), + engine()->toScriptValue(outputArtifact->filePath())); + scope().setProperty(StringConstants::fileTagsProperty(), + toScriptValue(engine(), outputArtifact->fileTags().toStringList())); + + QVariantMap artifactModulesCfg = outputArtifact->properties->value(); + for (const auto &binding : ra->bindings) { + scriptValue = engine()->evaluate(binding.code); + if (Q_UNLIKELY(engine()->hasErrorOrException(scriptValue))) { + QString msg = QStringLiteral("evaluating rule binding '%1': %2"); + throw ErrorInfo(msg.arg(binding.name.join(QLatin1Char('.')), + engine()->lastErrorString(scriptValue)), + engine()->lastErrorLocation(scriptValue, binding.location)); + } + const QVariant value = scriptValue.toVariant(); + setConfigProperty(artifactModulesCfg, binding.name, value); + outputArtifact->pureProperties.emplace_back(binding.name, value); + } + outputArtifact->properties->setValue(artifactModulesCfg); + if (!outputInfo.newlyCreated && (outputArtifact->fileTags() != outputInfo.oldFileTags + || outputArtifact->properties->value() != outputInfo.oldProperties)) { + invalidateArtifactAsRuleInputIfNecessary(outputArtifact); + } + } + if (!ruleArtifactArtifactMap.empty()) + engine()->setGlobalObject(prepareScriptContext.prototype()); + + m_transformer->setupOutputs(prepareScriptContext); + m_transformer->createCommands(engine(), m_rule->prepareScript, + ScriptEngine::argumentList(Rule::argumentNamesForPrepare(), prepareScriptContext)); + if (Q_UNLIKELY(m_transformer->commands.empty())) + throw ErrorInfo(Tr::tr("There is a rule without commands: %1.") + .arg(m_rule->toString()), m_rule->prepareScript.location()); + if (!m_oldTransformer || m_oldTransformer->outputs != m_transformer->outputs + || m_oldTransformer->inputs != m_transformer->inputs + || m_oldTransformer->explicitlyDependsOn != m_transformer->explicitlyDependsOn + || m_oldTransformer->commands != m_transformer->commands + || commandsNeedRerun(m_transformer.get(), m_product.get(), m_productsByName, + m_projectsByName)) { + for (Artifact * const output : qAsConst(outputArtifacts)) { + output->clearTimestamp(); + m_invalidatedArtifacts += output; + } + } + m_transformer->commandsNeedChangeTracking = false; +} + +ArtifactSet RulesApplicator::collectOldOutputArtifacts(const ArtifactSet &inputArtifacts) const +{ + ArtifactSet result; + for (Artifact * const a : inputArtifacts) { + for (Artifact *p : a->parentArtifacts()) { + QBS_CHECK(p->transformer); + if (p->transformer->rule == m_rule && p->transformer->inputs.contains(a)) + result += p; + } + } + return result; +} + +ArtifactSet RulesApplicator::collectAdditionalInputs(const FileTags &tags, const Rule *rule, + const ResolvedProduct *product, + InputsSources inputsSources) +{ + ArtifactSet artifacts; + for (const FileTag &fileTag : tags) { + for (Artifact *dependency : product->lookupArtifactsByFileTag(fileTag)) { + // Skip excluded inputs. + if (dependency->fileTags().intersects(rule->excludedInputs)) + continue; + + // Two cases are considered: + // 1) An artifact is considered a dependency when it's part of the current product. + // 2) An artifact marked with filesAreTargets: true inside a Group inside of a + // Module also ends up in the results returned by product->lookupArtifactsByFileTag, + // so it should be considered conceptually as a "dependent product artifact". + if ((inputsSources.testFlag(CurrentProduct) && !dependency->isTargetOfModule()) + || (inputsSources.testFlag(Dependencies) && dependency->isTargetOfModule())) { + artifacts << dependency; + } + } + + if (inputsSources.testFlag(Dependencies)) { + for (const auto &depProduct : product->dependencies) { + for (Artifact * const ta : depProduct->targetArtifacts()) { + if (ta->fileTags().contains(fileTag) + && !ta->fileTags().intersects(rule->excludedInputs)) { + artifacts << ta; + } + } + } + } + } + return artifacts; +} + +ArtifactSet RulesApplicator::collectExplicitlyDependsOn(const Rule *rule, + const ResolvedProduct *product) +{ + ArtifactSet first = collectAdditionalInputs( + rule->explicitlyDependsOn, rule, product, CurrentProduct); + ArtifactSet second = collectAdditionalInputs( + rule->explicitlyDependsOnFromDependencies, rule, product, Dependencies); + return first.unite(second); +} + +RulesApplicator::OutputArtifactInfo RulesApplicator::createOutputArtifactFromRuleArtifact( + const RuleArtifactConstPtr &ruleArtifact, const ArtifactSet &inputArtifacts, + Set *outputFilePaths) +{ + QString outputPath; + FileTags fileTags; + bool alwaysUpdated; + if (ruleArtifact) { + QScriptValue scriptValue = engine()->evaluate(ruleArtifact->filePath, + ruleArtifact->filePathLocation.filePath(), + ruleArtifact->filePathLocation.line()); + if (Q_UNLIKELY(engine()->hasErrorOrException(scriptValue))) + throw engine()->lastError(scriptValue, ruleArtifact->filePathLocation); + outputPath = scriptValue.toString(); + fileTags = ruleArtifact->fileTags; + alwaysUpdated = ruleArtifact->alwaysUpdated; + } else { + outputPath = QStringLiteral("__dummyoutput__"); + QByteArray hashInput = m_rule->toString().toLatin1(); + for (const Artifact * const input : inputArtifacts) + hashInput += input->filePath().toLatin1(); + outputPath += QLatin1String(QCryptographicHash::hash(hashInput, QCryptographicHash::Sha1) + .toHex().left(16)); + fileTags = m_rule->outputFileTags; + alwaysUpdated = false; + } + outputPath = FileInfo::resolvePath(m_product->buildDirectory(), outputPath); + if (Q_UNLIKELY(!outputFilePaths->insert(outputPath).second)) { + throw ErrorInfo(Tr::tr("Rule %1 already created '%2'.") + .arg(m_rule->toString(), outputPath)); + } + return createOutputArtifact(outputPath, fileTags, alwaysUpdated, inputArtifacts); +} + +RulesApplicator::OutputArtifactInfo RulesApplicator::createOutputArtifact(const QString &filePath, + const FileTags &fileTags, bool alwaysUpdated, const ArtifactSet &inputArtifacts) +{ + QString outputPath = filePath; + // don't let the output artifact "escape" its build dir + outputPath.replace(StringConstants::dotDot(), QStringLiteral("dotdot")); + outputPath = resolveOutPath(outputPath); + + if (m_rule->isDynamic()) { + const Set undeclaredTags = fileTags - m_rule->collectedOutputFileTags(); + if (!undeclaredTags.empty()) { + throw ErrorInfo(Tr::tr("Artifact '%1' has undeclared file tags [\"%2\"].") + .arg(outputPath, undeclaredTags.toStringList() + .join(QLatin1String("\",\""))), + m_rule->prepareScript.location()); + } + } + + OutputArtifactInfo outputInfo; + Artifact *& outputArtifact = outputInfo.artifact; + outputArtifact = lookupArtifact(m_product, outputPath); + outputInfo.newlyCreated = !outputArtifact; + if (outputArtifact) { + const Transformer * const transformer = outputArtifact->transformer.get(); + if (transformer && transformer->rule != m_rule) { + QString e = Tr::tr("Conflicting rules for producing %1 %2 \n") + .arg(outputArtifact->filePath(), + QLatin1Char('[') + + outputArtifact->fileTags().toStringList().join(QLatin1String(", ")) + + QLatin1Char(']')); + QString str = QLatin1Char('[') + m_rule->inputs.toStringList().join(QLatin1String(", ")) + + QLatin1String("] -> [") + outputArtifact->fileTags().toStringList() + .join(QLatin1String(", ")) + QLatin1Char(']'); + + e += QStringLiteral(" while trying to apply: %1:%2:%3 %4\n") + .arg(m_rule->prepareScript.location().filePath()) + .arg(m_rule->prepareScript.location().line()) + .arg(m_rule->prepareScript.location().column()) + .arg(str); + + e += QStringLiteral(" was already defined in: %1:%2:%3 %4\n") + .arg(transformer->rule->prepareScript.location().filePath()) + .arg(transformer->rule->prepareScript.location().line()) + .arg(transformer->rule->prepareScript.location().column()) + .arg(str); + + throw ErrorInfo(e); + } + if (transformer && !m_rule->multiplex && transformer->inputs != inputArtifacts) { + QBS_CHECK(inputArtifacts.size() == 1); + QBS_CHECK(transformer->inputs.size() == 1); + ErrorInfo error(Tr::tr("Conflicting instances of rule '%1':").arg(m_rule->toString()), + m_rule->prepareScript.location()); + error.append(Tr::tr("Output artifact '%1' is to be produced from input " + "artifacts '%2' and '%3', but the rule is not a multiplex rule.") + .arg(outputArtifact->filePath(), + (*transformer->inputs.cbegin())->filePath(), + (*inputArtifacts.cbegin())->filePath())); + throw error; + } + m_transformer->rescueChangeTrackingData(outputArtifact->transformer); + m_oldTransformer = outputArtifact->transformer; + outputInfo.oldFileTags = outputArtifact->fileTags(); + outputInfo.oldProperties = outputArtifact->properties->value(); + } else { + std::unique_ptr newArtifact(new Artifact); + newArtifact->artifactType = Artifact::Generated; + newArtifact->setFilePath(outputPath); + insertArtifact(m_product, newArtifact.get()); + m_createdArtifacts += newArtifact.get(); + outputArtifact = newArtifact.release(); + qCDebug(lcExec).noquote() << "rule created" << outputArtifact->toString(); + connect(outputArtifact, m_ruleNode); + } + + outputArtifact->alwaysUpdated = alwaysUpdated; + outputArtifact->pureFileTags = fileTags; + provideFullFileTagsAndProperties(outputArtifact); + if (outputInfo.newlyCreated || outputInfo.oldFileTags != outputArtifact->fileTags()) { + for (RuleNode * const parentRule : filterByType(m_ruleNode->parents)) + connect(parentRule, outputArtifact); + } + + for (Artifact * const inputArtifact : inputArtifacts) { + QBS_CHECK(outputArtifact != inputArtifact); + connect(outputArtifact, inputArtifact); + } + + outputArtifact->transformer = m_transformer; + m_transformer->outputs.insert(outputArtifact); + QBS_CHECK(m_rule->multiplex || m_transformer->inputs.size() == 1); + + return outputInfo; +} + +class RuleOutputArtifactsException : public ErrorInfo +{ +public: + using ErrorInfo::ErrorInfo; +}; + +QList RulesApplicator::runOutputArtifactsScript(const ArtifactSet &inputArtifacts, + const QScriptValueList &args) +{ + QList lst; + QScriptValue fun = engine()->evaluate(m_rule->outputArtifactsScript.sourceCode(), + m_rule->outputArtifactsScript.location().filePath(), + m_rule->outputArtifactsScript.location().line()); + if (!fun.isFunction()) + throw ErrorInfo(QStringLiteral("Function expected."), + m_rule->outputArtifactsScript.location()); + QScriptValue res = fun.call(QScriptValue(), args); + engine()->releaseResourcesOfScriptObjects(); + if (engine()->hasErrorOrException(res)) + throw engine()->lastError(res, m_rule->outputArtifactsScript.location()); + if (!res.isArray()) + throw ErrorInfo(Tr::tr("Rule.outputArtifacts must return an array of objects."), + m_rule->outputArtifactsScript.location()); + const quint32 c = res.property(StringConstants::lengthProperty()).toUInt32(); + for (quint32 i = 0; i < c; ++i) { + try { + lst.push_back(createOutputArtifactFromScriptValue(res.property(i), inputArtifacts)); + } catch (const RuleOutputArtifactsException &roae) { + ErrorInfo ei = roae; + ei.prepend(Tr::tr("Error in Rule.outputArtifacts[%1]").arg(i), + m_rule->outputArtifactsScript.location()); + throw ei; + } + } + return lst; +} + +class ArtifactBindingsExtractor +{ + struct Entry + { + Entry(QString module, QString name, QVariant value) + : module(std::move(module)), name(std::move(name)), value(std::move(value)) + {} + + QString module; + QString name; + QVariant value; + }; + std::vector m_propertyValues; + + static Set getArtifactItemPropertyNames() + { + Set s; + const auto properties = BuiltinDeclarations::instance().declarationsForType( + ItemType::Artifact).properties(); + for (const PropertyDeclaration &pd : properties) { + s.insert(pd.name()); + } + s.insert(StringConstants::explicitlyDependsOnProperty()); + return s; + } + + void extractPropertyValues(const QScriptValue &obj, const QString &moduleName = QString()) + { + QScriptValueIterator svit(obj); + while (svit.hasNext()) { + svit.next(); + const QString name = svit.name(); + if (moduleName.isEmpty()) { + // Ignore property names that are part of the Artifact item. + static const Set artifactItemPropertyNames + = getArtifactItemPropertyNames(); + if (artifactItemPropertyNames.contains(name)) + continue; + } + + const QScriptValue value = svit.value(); + if (value.isObject() && !value.isArray() && !value.isError() && !value.isRegExp()) { + QString newModuleName; + if (!moduleName.isEmpty()) + newModuleName.append(moduleName + QLatin1Char('.')); + newModuleName.append(name); + extractPropertyValues(value, newModuleName); + } else { + m_propertyValues.emplace_back(moduleName, name, value.toVariant()); + } + } + } +public: + void apply(Artifact *outputArtifact, const QScriptValue &obj) + { + extractPropertyValues(obj); + if (m_propertyValues.empty()) + return; + + outputArtifact->properties = outputArtifact->properties->clone(); + QVariantMap artifactCfg = outputArtifact->properties->value(); + for (const auto &e : m_propertyValues) { + const QStringList key{e.module, e.name}; + setConfigProperty(artifactCfg, key, e.value); + outputArtifact->pureProperties.emplace_back(key, e.value); + } + outputArtifact->properties->setValue(artifactCfg); + } +}; + +Artifact *RulesApplicator::createOutputArtifactFromScriptValue(const QScriptValue &obj, + const ArtifactSet &inputArtifacts) +{ + if (!obj.isObject()) { + throw ErrorInfo(Tr::tr("Elements of the Rule.outputArtifacts array must be " + "of Object type."), m_rule->outputArtifactsScript.location()); + } + const QString unresolvedFilePath + = obj.property(StringConstants::filePathProperty()).toVariant().toString(); + if (unresolvedFilePath.isEmpty()) { + throw RuleOutputArtifactsException( + Tr::tr("Property filePath must be a non-empty string.")); + } + const QString filePath = FileInfo::resolvePath(m_product->buildDirectory(), unresolvedFilePath); + const FileTags fileTags = FileTags::fromStringList( + obj.property(StringConstants::fileTagsProperty()).toVariant().toStringList()); + const QVariant alwaysUpdatedVar + = obj.property(StringConstants::alwaysUpdatedProperty()).toVariant(); + const bool alwaysUpdated = alwaysUpdatedVar.isValid() ? alwaysUpdatedVar.toBool() : true; + OutputArtifactInfo outputInfo = createOutputArtifact(filePath, fileTags, alwaysUpdated, + inputArtifacts); + if (outputInfo.artifact->fileTags().empty()) { + // Check the file tags after file taggers were run. + throw RuleOutputArtifactsException( + Tr::tr("Property fileTags for artifact '%1' must be a non-empty string list. " + "Alternatively, a FileTagger can be provided.") + .arg(unresolvedFilePath)); + } + const FileTags explicitlyDependsOn = FileTags::fromStringList( + obj.property(StringConstants::explicitlyDependsOnProperty()) + .toVariant().toStringList()); + for (const FileTag &tag : explicitlyDependsOn) { + for (Artifact * const dependency : m_product->lookupArtifactsByFileTag(tag)) + connect(outputInfo.artifact, dependency); + } + ArtifactBindingsExtractor().apply(outputInfo.artifact, obj); + if (!outputInfo.newlyCreated && (outputInfo.artifact->fileTags() != outputInfo.oldFileTags + || outputInfo.artifact->properties->value() != outputInfo.oldProperties)) { + invalidateArtifactAsRuleInputIfNecessary(outputInfo.artifact); + } + return outputInfo.artifact; +} + +QString RulesApplicator::resolveOutPath(const QString &path) const +{ + QString buildDir = m_product->topLevelProject()->buildDirectory; + QString result = FileInfo::resolvePath(buildDir, path); + result = QDir::cleanPath(result); + return result; +} + +const RulesEvaluationContextPtr &RulesApplicator::evalContext() const +{ + return m_product->topLevelProject()->buildData->evaluationContext; +} + +ScriptEngine *RulesApplicator::engine() const +{ + return evalContext()->engine(); +} + +QScriptValue RulesApplicator::scope() const +{ + return evalContext()->scope(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulesapplicator.h b/src/lib/corelib/buildgraph/rulesapplicator.h new file mode 100644 index 00000000..da781501 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulesapplicator.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_RULESAPPLICATOR_H +#define QBS_RULESAPPLICATOR_H + +#include "artifact.h" +#include "forward_decls.h" +#include "nodeset.h" +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { +class BuildGraphNode; +class QtMocScanner; +class ScriptEngine; + +class RulesApplicator +{ +public: + RulesApplicator(ResolvedProductPtr product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName, + Logger logger); + ~RulesApplicator(); + + const NodeSet &createdArtifacts() const { return m_createdArtifacts; } + const NodeSet &invalidatedArtifacts() const { return m_invalidatedArtifacts; } + QStringList removedArtifacts() const { return m_removedArtifacts; } + bool ruleUsesIo() const { return m_ruleUsesIo; } + + void applyRule(RuleNode *ruleNode, const ArtifactSet &inputArtifacts, + const ArtifactSet &explicitlyDependsOn); + static void handleRemovedRuleOutputs(const ArtifactSet &inputArtifacts, + const ArtifactSet &artifactsToRemove, QStringList &removedArtifacts, + const Logger &logger); + static ArtifactSet collectAuxiliaryInputs(const Rule *rule, const ResolvedProduct *product); + static ArtifactSet collectExplicitlyDependsOn(const Rule *rule, const ResolvedProduct *product); + + enum InputsSourceFlag { CurrentProduct = 1, Dependencies = 2 }; + Q_DECLARE_FLAGS(InputsSources, InputsSourceFlag) + +private: + void doApply(const ArtifactSet &inputArtifacts, QScriptValue &prepareScriptContext); + ArtifactSet collectOldOutputArtifacts(const ArtifactSet &inputArtifacts) const; + + struct OutputArtifactInfo { + Artifact *artifact = nullptr; + bool newlyCreated = false; + FileTags oldFileTags; + QVariantMap oldProperties; + }; + OutputArtifactInfo createOutputArtifactFromRuleArtifact( + const RuleArtifactConstPtr &ruleArtifact, const ArtifactSet &inputArtifacts, + Set *outputFilePaths); + OutputArtifactInfo createOutputArtifact(const QString &filePath, const FileTags &fileTags, + bool alwaysUpdated, const ArtifactSet &inputArtifacts); + QList runOutputArtifactsScript(const ArtifactSet &inputArtifacts, + const QScriptValueList &args); + Artifact *createOutputArtifactFromScriptValue(const QScriptValue &obj, + const ArtifactSet &inputArtifacts); + QString resolveOutPath(const QString &path) const; + const RulesEvaluationContextPtr &evalContext() const; + ScriptEngine *engine() const; + QScriptValue scope() const; + + static ArtifactSet collectAdditionalInputs(const FileTags &tags, + const Rule *rule, const ResolvedProduct *product, + InputsSources inputsSources); + + const ResolvedProductPtr m_product; + const std::unordered_map &m_productsByName; + const std::unordered_map &m_projectsByName; + ArtifactSet m_explicitlyDependsOn; + NodeSet m_createdArtifacts; + NodeSet m_invalidatedArtifacts; + QStringList m_removedArtifacts; + RuleNode *m_ruleNode = nullptr; + RuleConstPtr m_rule; + ArtifactSet m_completeInputSet; + TransformerPtr m_transformer; + TransformerConstPtr m_oldTransformer; + QtMocScanner *m_mocScanner; + Logger m_logger; + bool m_ruleUsesIo = false; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(RulesApplicator::InputsSources) + +} // namespace Internal +} // namespace qbs + +#endif // QBS_RULESAPPLICATOR_H diff --git a/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp new file mode 100644 index 00000000..0422b928 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulesevaluationcontext.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "rulesevaluationcontext.h" + +#include "artifact.h" +#include "rulecommands.h" +#include "transformer.h" +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +RulesEvaluationContext::RulesEvaluationContext(Logger logger) + : m_logger(std::move(logger)), + m_engine(ScriptEngine::create(m_logger, EvalContext::RuleExecution)), + m_observer(nullptr), + m_initScopeCalls(0) +{ + m_prepareScriptScope = m_engine->newObject(); + m_prepareScriptScope.setPrototype(m_engine->globalObject()); + ProcessCommand::setupForJavaScript(m_prepareScriptScope); + JavaScriptCommand::setupForJavaScript(m_prepareScriptScope); +} + +RulesEvaluationContext::~RulesEvaluationContext() = default; + +void RulesEvaluationContext::initializeObserver(const QString &description, int maximumProgress) +{ + if (m_observer) + m_observer->initialize(description, maximumProgress); +} + +void RulesEvaluationContext::incrementProgressValue() +{ + if (m_observer) + m_observer->incrementProgressValue(); +} + +void RulesEvaluationContext::checkForCancelation() +{ + if (Q_UNLIKELY(m_observer && m_observer->canceled())) + throw ErrorInfo(Tr::tr("Build canceled.")); +} + +void RulesEvaluationContext::initScope() +{ + if (m_initScopeCalls++ > 0) + return; + + m_engine->setActive(true); + m_scope = m_engine->newObject(); + m_scope.setPrototype(m_prepareScriptScope); + m_engine->setGlobalObject(m_scope); +} + +void RulesEvaluationContext::cleanupScope() +{ + QBS_CHECK(m_initScopeCalls > 0); + if (--m_initScopeCalls > 0) + return; + + m_scope = QScriptValue(); + m_engine->setGlobalObject(m_prepareScriptScope.prototype()); + m_engine->setActive(false); +} + +RulesEvaluationContext::Scope::Scope(RulesEvaluationContext *evalContext) + : m_evalContext(evalContext) +{ + evalContext->initScope(); +} + +RulesEvaluationContext::Scope::~Scope() +{ + m_evalContext->cleanupScope(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/rulesevaluationcontext.h b/src/lib/corelib/buildgraph/rulesevaluationcontext.h new file mode 100644 index 00000000..bb795549 --- /dev/null +++ b/src/lib/corelib/buildgraph/rulesevaluationcontext.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_RULESEVALUATIONCONTEXT_H +#define QBS_RULESEVALUATIONCONTEXT_H + +#include +#include + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { +class ProgressObserver; +class ScriptEngine; + +class RulesEvaluationContext +{ +public: + RulesEvaluationContext(Logger logger); + ~RulesEvaluationContext(); + + class Scope + { + public: + Scope(RulesEvaluationContext *evalContext); + ~Scope(); + + private: + RulesEvaluationContext * const m_evalContext; + }; + + ScriptEngine *engine() const { return m_engine.get(); } + QScriptValue scope() const { return m_scope; } + + void setObserver(ProgressObserver *observer) { m_observer = observer; } + ProgressObserver *observer() const { return m_observer; } + void initializeObserver(const QString &description, int maximumProgress); + void incrementProgressValue(); + void checkForCancelation(); + +private: + friend class Scope; + + void initScope(); + void cleanupScope(); + + Logger m_logger; + const std::unique_ptr m_engine; + ProgressObserver *m_observer; + unsigned int m_initScopeCalls; + QScriptValue m_scope; + QScriptValue m_prepareScriptScope; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_RULESEVALUATIONCONTEXT_H diff --git a/src/lib/corelib/buildgraph/scriptclasspropertyiterator.h b/src/lib/corelib/buildgraph/scriptclasspropertyiterator.h new file mode 100644 index 00000000..b5707223 --- /dev/null +++ b/src/lib/corelib/buildgraph/scriptclasspropertyiterator.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SCRIPTCLASSPROPERTYITERATOR_H +#define QBS_SCRIPTCLASSPROPERTYITERATOR_H + +#include + +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class ScriptClassPropertyIterator : public QScriptClassPropertyIterator +{ +public: + ScriptClassPropertyIterator(const QScriptValue &object, const QVariantMap &properties, + std::vector additionalProperties) + : QScriptClassPropertyIterator(object), + m_it(properties), + m_additionalProperties(std::move(additionalProperties)) + { + } + +private: + bool hasNext() const override + { + return m_it.hasNext() || m_index < int(m_additionalProperties.size()) - 1; + } + bool hasPrevious() const override { return m_index > -1 || m_it.hasPrevious(); } + void toFront() override { m_it.toFront(); m_index = -1; } + void toBack() override { m_it.toBack(); m_index = int(m_additionalProperties.size()) - 1; } + + void next() override + { + QBS_ASSERT(hasNext(), return); + if (m_it.hasNext()) + m_it.next(); + else + ++m_index; + } + + void previous() override + { + QBS_ASSERT(hasPrevious(), return); + if (m_index >= 0) + --m_index; + if (m_index == -1) + m_it.previous(); + } + + QScriptString name() const override + { + const QString theName = m_index >= 0 && m_index < int(m_additionalProperties.size()) + ? m_additionalProperties.at(m_index) + : m_it.key(); + return object().engine()->toStringHandle(theName); + } + + QMapIterator m_it; + const std::vector m_additionalProperties; + int m_index = -1; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_SCRIPTCLASSPROPERTYITERATOR_H diff --git a/src/lib/corelib/buildgraph/timestampsupdater.cpp b/src/lib/corelib/buildgraph/timestampsupdater.cpp new file mode 100644 index 00000000..3f5279dd --- /dev/null +++ b/src/lib/corelib/buildgraph/timestampsupdater.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "timestampsupdater.h" + +#include "artifact.h" +#include "artifactvisitor.h" +#include "productbuilddata.h" +#include "projectbuilddata.h" + +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class TimestampsUpdateVisitor : public ArtifactVisitor +{ +public: + TimestampsUpdateVisitor() + : ArtifactVisitor(Artifact::Generated), m_now(FileTime::currentTime()) {} + + void visitProduct(const ResolvedProductConstPtr &product) + { + QBS_CHECK(product->buildData); + ArtifactVisitor::visitProduct(product); + + // For target artifacts, we have to update the on-disk timestamp, because + // the executor will look at it. + for (Artifact * const targetArtifact : product->targetArtifacts()) { + if (FileInfo(targetArtifact->filePath()).exists()) + QFile(targetArtifact->filePath()).open(QIODevice::WriteOnly | QIODevice::Append); + } + } + +private: + void doVisit(Artifact *artifact) override + { + if (FileInfo(artifact->filePath()).exists()) + artifact->setTimestamp(m_now); + } + + FileTime m_now; +}; + +void TimestampsUpdater::updateTimestamps(const TopLevelProjectPtr &project, + const QVector &products, const Logger &logger) +{ + TimestampsUpdateVisitor v; + for (const ResolvedProductPtr &product : products) + v.visitProduct(product); + if (!products.empty()) + project->buildData->setDirty(); + project->store(logger); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/timestampsupdater.h b/src/lib/corelib/buildgraph/timestampsupdater.h new file mode 100644 index 00000000..8184ca70 --- /dev/null +++ b/src/lib/corelib/buildgraph/timestampsupdater.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef TIMESTAMPSUPDATER_H +#define TIMESTAMPSUPDATER_H + +#include + +#include + +namespace qbs { +namespace Internal { +class Logger; + +class TimestampsUpdater +{ +public: + void updateTimestamps(const TopLevelProjectPtr &project, + const QVector &products, const Logger &logger); +}; + +} // namespace Internal +} // namespace qbs + +#endif // TIMESTAMPSUPDATER_H diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp new file mode 100644 index 00000000..29f2bcdf --- /dev/null +++ b/src/lib/corelib/buildgraph/transformer.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "transformer.h" + +#include "artifact.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +Transformer::Transformer() : alwaysRun(false) +{ +} + +Transformer::~Transformer() = default; + +static QScriptValue js_baseName(QScriptContext *ctx, QScriptEngine *engine, + const Artifact *artifact) +{ + Q_UNUSED(ctx); + Q_UNUSED(engine); + return {FileInfo::baseName(artifact->filePath())}; +} + +static QScriptValue js_completeBaseName(QScriptContext *ctx, QScriptEngine *engine, + const Artifact *artifact) +{ + Q_UNUSED(ctx); + Q_UNUSED(engine); + return {FileInfo::completeBaseName(artifact->filePath())}; +} + +static QScriptValue js_baseDir(QScriptContext *ctx, QScriptEngine *engine, + const Artifact *artifact) +{ + Q_UNUSED(ctx); + Q_UNUSED(engine); + QString basedir; + if (artifact->artifactType == Artifact::SourceFile) { + QDir sourceDir(artifact->product->sourceDirectory); + basedir = FileInfo::path(sourceDir.relativeFilePath(artifact->filePath())); + } else { + QDir buildDir(artifact->product->buildDirectory()); + basedir = FileInfo::path(buildDir.relativeFilePath(artifact->filePath())); + } + return basedir; +} + +static QScriptValue js_children(QScriptContext *ctx, QScriptEngine *engine, const Artifact *artifact) +{ + Q_UNUSED(ctx); + QScriptValue sv = engine->newArray(); + uint idx = 0; + for (const Artifact *child : artifact->childArtifacts()) { + sv.setProperty(idx++, Transformer::translateFileConfig(static_cast(engine), + child, QString())); + } + return sv; +} + +static void setArtifactProperty(QScriptValue &obj, const QString &name, + QScriptValue (*func)(QScriptContext *, QScriptEngine *, const Artifact *), + const Artifact *artifact) +{ + obj.setProperty(name, static_cast(obj.engine())->newFunction(func, artifact), + QScriptValue::PropertyGetter); +} + +QScriptValue Transformer::translateFileConfig(ScriptEngine *scriptEngine, const Artifact *artifact, + const QString &defaultModuleName) +{ + QScriptValue obj = scriptEngine->newObject(); + attachPointerTo(obj, artifact); + ModuleProperties::init(obj, artifact); + obj.setProperty(StringConstants::fileNameProperty(), artifact->fileName()); + obj.setProperty(StringConstants::filePathProperty(), artifact->filePath()); + setArtifactProperty(obj, StringConstants::baseNameProperty(), js_baseName, artifact); + setArtifactProperty(obj, StringConstants::completeBaseNameProperty(), js_completeBaseName, + artifact); + setArtifactProperty(obj, QStringLiteral("baseDir"), js_baseDir, artifact); + setArtifactProperty(obj, QStringLiteral("children"), js_children, artifact); + const QStringList fileTags = sorted(artifact->fileTags().toStringList()); + scriptEngine->setObservedProperty(obj, StringConstants::fileTagsProperty(), + scriptEngine->toScriptValue(fileTags)); + scriptEngine->observer()->addArtifactId(obj.objectId()); + if (!defaultModuleName.isEmpty()) + obj.setProperty(StringConstants::moduleNameProperty(), defaultModuleName); + return obj; +} + +static bool compareByFilePath(const Artifact *a1, const Artifact *a2) +{ + return a1->filePath() < a2->filePath(); +} + +QScriptValue Transformer::translateInOutputs(ScriptEngine *scriptEngine, + const ArtifactSet &artifacts, + const QString &defaultModuleName) +{ + using TagArtifactsMap = QMap>; + TagArtifactsMap tagArtifactsMap; + for (Artifact *artifact : artifacts) + for (const FileTag &fileTag : artifact->fileTags()) + tagArtifactsMap[fileTag.toString()].push_back(artifact); + for (TagArtifactsMap::Iterator it = tagArtifactsMap.begin(); it != tagArtifactsMap.end(); ++it) + std::sort(it.value().begin(), it.value().end(), compareByFilePath); + + QScriptValue jsTagFiles = scriptEngine->newObject(); + for (TagArtifactsMap::const_iterator tag = tagArtifactsMap.constBegin(); tag != tagArtifactsMap.constEnd(); ++tag) { + const QList &artifacts = tag.value(); + QScriptValue jsFileConfig = scriptEngine->newArray(artifacts.size()); + int i = 0; + for (Artifact * const artifact : artifacts) { + jsFileConfig.setProperty(i++, translateFileConfig(scriptEngine, artifact, + defaultModuleName)); + } + jsTagFiles.setProperty(tag.key(), jsFileConfig); + } + + return jsTagFiles; +} + +ResolvedProductPtr Transformer::product() const +{ + if (outputs.empty()) + return {}; + return (*outputs.cbegin())->product.lock(); +} + +void Transformer::setupInputs(QScriptValue targetScriptValue, const ArtifactSet &inputs, + const QString &defaultModuleName) +{ + const auto scriptEngine = static_cast(targetScriptValue.engine()); + QScriptValue scriptValue = translateInOutputs(scriptEngine, inputs, defaultModuleName); + targetScriptValue.setProperty(StringConstants::inputsVar(), scriptValue); + QScriptValue inputScriptValue; + if (inputs.size() == 1) { + Artifact *input = *inputs.cbegin(); + const FileTags &fileTags = input->fileTags(); + QBS_ASSERT(!fileTags.empty(), return); + QScriptValue inputsForFileTag = scriptValue.property(fileTags.cbegin()->toString()); + inputScriptValue = inputsForFileTag.property(0); + } + targetScriptValue.setProperty(StringConstants::inputVar(), inputScriptValue); +} + +void Transformer::setupInputs(const QScriptValue &targetScriptValue) +{ + setupInputs(targetScriptValue, inputs, rule->module->name); +} + +void Transformer::setupOutputs(QScriptValue targetScriptValue) +{ + const auto scriptEngine = static_cast(targetScriptValue.engine()); + const QString &defaultModuleName = rule->module->name; + QScriptValue scriptValue = translateInOutputs(scriptEngine, outputs, defaultModuleName); + targetScriptValue.setProperty(StringConstants::outputsVar(), scriptValue); + QScriptValue outputScriptValue; + if (outputs.size() == 1) { + Artifact *output = *outputs.cbegin(); + const FileTags &fileTags = output->fileTags(); + QBS_ASSERT(!fileTags.empty(), return); + QScriptValue outputsForFileTag = scriptValue.property(fileTags.cbegin()->toString()); + outputScriptValue = outputsForFileTag.property(0); + } + targetScriptValue.setProperty(StringConstants::outputVar(), outputScriptValue); +} + +void Transformer::setupExplicitlyDependsOn(QScriptValue targetScriptValue) +{ + const auto scriptEngine = static_cast(targetScriptValue.engine()); + QScriptValue scriptValue = translateInOutputs(scriptEngine, explicitlyDependsOn, + rule->module->name); + targetScriptValue.setProperty(StringConstants::explicitlyDependsOnVar(), scriptValue); +} + +AbstractCommandPtr Transformer::createCommandFromScriptValue(const QScriptValue &scriptValue, + const CodeLocation &codeLocation) +{ + AbstractCommandPtr cmdBase; + if (scriptValue.isUndefined() || !scriptValue.isValid()) + return cmdBase; + QString className = scriptValue.property(StringConstants::classNameProperty()).toString(); + if (className == StringConstants::commandType()) + cmdBase = ProcessCommand::create(); + else if (className == StringConstants::javaScriptCommandType()) + cmdBase = JavaScriptCommand::create(); + if (cmdBase) + cmdBase->fillFromScriptValue(&scriptValue, codeLocation); + if (className == StringConstants::commandType()) { + auto procCmd = static_cast(cmdBase.get()); + procCmd->clearRelevantEnvValues(); + const auto envVars = procCmd->relevantEnvVars(); + for (const QString &key : envVars) + procCmd->addRelevantEnvValue(key, product()->buildEnvironment.value(key)); + } + return cmdBase; +} + +void Transformer::createCommands(ScriptEngine *engine, const PrivateScriptFunction &script, + const QScriptValueList &args) +{ + if (!script.scriptFunction.isValid() || script.scriptFunction.engine() != engine) { + script.scriptFunction = engine->evaluate(script.sourceCode(), + script.location().filePath(), + script.location().line()); + if (Q_UNLIKELY(!script.scriptFunction.isFunction())) + throw ErrorInfo(Tr::tr("Invalid prepare script."), script.location()); + } + + QScriptValue scriptValue = script.scriptFunction.call(QScriptValue(), args); + engine->releaseResourcesOfScriptObjects(); + propertiesRequestedInPrepareScript = engine->propertiesRequestedInScript(); + propertiesRequestedFromArtifactInPrepareScript = engine->propertiesRequestedFromArtifact(); + importedFilesUsedInPrepareScript = engine->importedFilesUsedInScript(); + depsRequestedInPrepareScript = engine->requestedDependencies(); + artifactsMapRequestedInPrepareScript = engine->requestedArtifacts(); + lastPrepareScriptExecutionTime = FileTime::currentTime(); + for (const ResolvedProduct * const p : engine->requestedExports()) { + exportedModulesAccessedInPrepareScript.insert(std::make_pair(p->uniqueName(), + p->exportedModule)); + } + engine->clearRequestedProperties(); + if (Q_UNLIKELY(engine->hasErrorOrException(scriptValue))) + throw engine->lastError(scriptValue, script.location()); + commands.clear(); + if (scriptValue.isArray()) { + const int count = scriptValue.property(StringConstants::lengthProperty()).toInt32(); + for (qint32 i = 0; i < count; ++i) { + QScriptValue item = scriptValue.property(i); + if (item.isValid() && !item.isUndefined()) { + const AbstractCommandPtr cmd + = createCommandFromScriptValue(item, script.location()); + if (cmd) + commands.addCommand(cmd); + } + } + } else { + const AbstractCommandPtr cmd = createCommandFromScriptValue(scriptValue, + script.location()); + if (cmd) + commands.addCommand(cmd); + } +} + +void Transformer::rescueChangeTrackingData(const TransformerConstPtr &other) +{ + if (!other) + return; + propertiesRequestedInPrepareScript = other->propertiesRequestedInPrepareScript; + propertiesRequestedInCommands = other->propertiesRequestedInCommands; + propertiesRequestedFromArtifactInPrepareScript + = other->propertiesRequestedFromArtifactInPrepareScript; + propertiesRequestedFromArtifactInCommands = other->propertiesRequestedFromArtifactInCommands; + importedFilesUsedInPrepareScript = other->importedFilesUsedInPrepareScript; + importedFilesUsedInCommands = other->importedFilesUsedInCommands; + depsRequestedInPrepareScript = other->depsRequestedInPrepareScript; + depsRequestedInCommands = other->depsRequestedInCommands; + artifactsMapRequestedInPrepareScript = other->artifactsMapRequestedInPrepareScript; + artifactsMapRequestedInCommands = other->artifactsMapRequestedInCommands; + lastCommandExecutionTime = other->lastCommandExecutionTime; + lastPrepareScriptExecutionTime = other->lastPrepareScriptExecutionTime; + prepareScriptNeedsChangeTracking = other->prepareScriptNeedsChangeTracking; + commandsNeedChangeTracking = other->commandsNeedChangeTracking; + markedForRerun = other->markedForRerun; + exportedModulesAccessedInPrepareScript = other->exportedModulesAccessedInPrepareScript; + exportedModulesAccessedInCommands = other->exportedModulesAccessedInCommands; +} + +Set Transformer::jobPools() const +{ + Set pools; + for (const AbstractCommandPtr &c : commands.commands()) { + if (!c->jobPool().isEmpty()) + pools.insert(c->jobPool()); + } + return pools; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/transformer.h b/src/lib/corelib/buildgraph/transformer.h new file mode 100644 index 00000000..8772ed86 --- /dev/null +++ b/src/lib/corelib/buildgraph/transformer.h @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TRANSFORMER_H +#define QBS_TRANSFORMER_H + +#include "artifact.h" +#include "forward_decls.h" +#include "requestedartifacts.h" +#include "requesteddependencies.h" +#include "rulecommands.h" +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { +class Artifact; +class AbstractCommand; +class Rule; + +class Transformer +{ +public: + static TransformerPtr create() { return TransformerPtr(new Transformer); } + + ~Transformer(); + + ArtifactSet inputs; // Subset of "children of all outputs". + ArtifactSet outputs; + ArtifactSet explicitlyDependsOn; + RuleConstPtr rule; + CommandList commands; + PropertySet propertiesRequestedInPrepareScript; + PropertySet propertiesRequestedInCommands; + QHash propertiesRequestedFromArtifactInPrepareScript; + QHash propertiesRequestedFromArtifactInCommands; + std::vector importedFilesUsedInPrepareScript; + std::vector importedFilesUsedInCommands; + RequestedDependencies depsRequestedInPrepareScript; + RequestedDependencies depsRequestedInCommands; + RequestedArtifacts artifactsMapRequestedInPrepareScript; + RequestedArtifacts artifactsMapRequestedInCommands; + FileTime lastPrepareScriptExecutionTime; + FileTime lastCommandExecutionTime; + std::unordered_map exportedModulesAccessedInPrepareScript; + std::unordered_map exportedModulesAccessedInCommands; + bool alwaysRun; + bool prepareScriptNeedsChangeTracking = false; + bool commandsNeedChangeTracking = false; + bool markedForRerun = false; + + static QScriptValue translateFileConfig(ScriptEngine *scriptEngine, + const Artifact *artifact, + const QString &defaultModuleName); + ResolvedProductPtr product() const; + void setupInputs(const QScriptValue &targetScriptValue); + void setupOutputs(QScriptValue targetScriptValue); + void setupExplicitlyDependsOn(QScriptValue targetScriptValue); + void createCommands(ScriptEngine *engine, const PrivateScriptFunction &script, + const QScriptValueList &args); + void rescueChangeTrackingData(const TransformerConstPtr &other); + + Set jobPools() const; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(rule, inputs, outputs, explicitlyDependsOn, + propertiesRequestedInPrepareScript, + propertiesRequestedInCommands, + propertiesRequestedFromArtifactInPrepareScript, + propertiesRequestedFromArtifactInCommands, + importedFilesUsedInPrepareScript, importedFilesUsedInCommands, + depsRequestedInPrepareScript, depsRequestedInCommands, + commands, artifactsMapRequestedInPrepareScript, + artifactsMapRequestedInCommands, + lastPrepareScriptExecutionTime, lastCommandExecutionTime, + exportedModulesAccessedInPrepareScript, + exportedModulesAccessedInCommands, + alwaysRun, prepareScriptNeedsChangeTracking, + commandsNeedChangeTracking, markedForRerun); + } + +private: + Transformer(); + AbstractCommandPtr createCommandFromScriptValue(const QScriptValue &scriptValue, + const CodeLocation &codeLocation); + + static void setupInputs(QScriptValue targetScriptValue, const ArtifactSet &inputs, + const QString &defaultModuleName); + static QScriptValue translateInOutputs(ScriptEngine *scriptEngine, + const ArtifactSet &artifacts, + const QString &defaultModuleName); +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_TRANSFORMER_H diff --git a/src/lib/corelib/buildgraph/transformerchangetracking.cpp b/src/lib/corelib/buildgraph/transformerchangetracking.cpp new file mode 100644 index 00000000..71059065 --- /dev/null +++ b/src/lib/corelib/buildgraph/transformerchangetracking.cpp @@ -0,0 +1,379 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "transformerchangetracking.h" + +#include "projectbuilddata.h" +#include "requesteddependencies.h" +#include "rulecommands.h" +#include "transformer.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class TrafoChangeTracker +{ +public: + TrafoChangeTracker(const Transformer *transformer, + const ResolvedProduct *product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName) + : m_transformer(transformer), + m_product(product), + m_productsByName(productsByName), + m_projectsByName(projectsByName) + { + } + + bool prepareScriptNeedsRerun() const; + bool commandsNeedRerun() const; + +private: + QVariantMap propertyMapByKind(const Property &property) const; + bool checkForPropertyChange(const Property &restoredProperty, + const QVariantMap &newProperties) const; + bool checkForImportFileChange(const std::vector &importedFiles, + const FileTime &referenceTime, + const char *context) const; + bool isExportedModuleUpToDate(const QString &productName, const ExportedModule &module) const; + bool areExportedModulesUpToDate( + const std::unordered_map &exportedModules) const; + const Artifact *getArtifact(const QString &filePath, const QString &productName) const; + const ResolvedProduct *getProduct(const QString &name) const; + + const Transformer * const m_transformer; + const ResolvedProduct * const m_product; + const std::unordered_map &m_productsByName; + const std::unordered_map &m_projectsByName; + mutable const ResolvedProduct * m_lastProduct = nullptr; + mutable const Artifact *m_lastArtifact = nullptr; +}; + +template static QVariantMap getParameterValue( + const QHash ¶meters, + const QString &depName) +{ + for (auto it = parameters.cbegin(); it != parameters.cend(); ++it) { + if (it.key()->name == depName) + return it.value(); + } + return {}; +} + +QVariantMap TrafoChangeTracker::propertyMapByKind(const Property &property) const +{ + switch (property.kind) { + case Property::PropertyInModule: { + const ResolvedProduct * const p = getProduct(property.productName); + return p ? p->moduleProperties->value() : QVariantMap(); + } + case Property::PropertyInProduct: { + const ResolvedProduct * const p = getProduct(property.productName); + return p ? p->productProperties : QVariantMap(); + } + case Property::PropertyInProject: { + if (property.productName == m_product->project->name) + return m_product->project->projectProperties(); + const auto it = m_projectsByName.find(property.productName); + if (it != m_projectsByName.cend()) + return it->second->projectProperties(); + return {}; + } + case Property::PropertyInParameters: { + const int sepIndex = property.moduleName.indexOf(QLatin1Char(':')); + const QString depName = property.moduleName.left(sepIndex); + const ResolvedProduct * const p = getProduct(property.productName); + if (!p) + return {}; + QVariantMap v = getParameterValue(p->dependencyParameters, depName); + if (!v.empty()) + return v; + return getParameterValue(p->moduleParameters, depName); + } + case Property::PropertyInArtifact: + default: + QBS_CHECK(false); + } + return {}; +} + +bool TrafoChangeTracker::checkForPropertyChange(const Property &restoredProperty, + const QVariantMap &newProperties) const +{ + QVariant v; + switch (restoredProperty.kind) { + case Property::PropertyInProduct: + case Property::PropertyInProject: + v = newProperties.value(restoredProperty.propertyName); + break; + case Property::PropertyInModule: + v = moduleProperty(newProperties, restoredProperty.moduleName, + restoredProperty.propertyName); + break; + case Property::PropertyInParameters: { + const int sepIndex = restoredProperty.moduleName.indexOf(QLatin1Char(':')); + QualifiedId moduleName + = QualifiedId::fromString(restoredProperty.moduleName.mid(sepIndex + 1)); + QVariantMap map = newProperties; + while (!moduleName.empty()) + map = map.value(moduleName.takeFirst()).toMap(); + v = map.value(restoredProperty.propertyName); + break; + } + case Property::PropertyInArtifact: + QBS_CHECK(false); + } + if (restoredProperty.value != v) { + qCDebug(lcBuildGraph).noquote().nospace() + << "Value for property '" << restoredProperty.moduleName << "." + << restoredProperty.propertyName << "' has changed.\n" + << "Old value was '" << restoredProperty.value << "'.\n" + << "New value is '" << v << "'."; + return true; + } + return false; +} + +bool TrafoChangeTracker::checkForImportFileChange(const std::vector &importedFiles, + const FileTime &referenceTime, + const char *context) const +{ + for (const QString &importedFile : importedFiles) { + const FileInfo fi(importedFile); + if (!fi.exists()) { + qCDebug(lcBuildGraph) << context << "imported file" << importedFile + << "is gone, need to re-run"; + return true; + } + if (fi.lastModified() > referenceTime) { + qCDebug(lcBuildGraph) << context << "imported file" << importedFile + << "has been updated, need to re-run" + << fi.lastModified() << referenceTime; + return true; + } + } + return false; +} + +bool TrafoChangeTracker::isExportedModuleUpToDate(const QString &productName, + const ExportedModule &module) const +{ + const ResolvedProduct * const product = getProduct(productName); + if (!product) { + qCDebug(lcBuildGraph) << "product" << productName + << "does not exist anymore, need to re-run"; + return false; + } + if (product->exportedModule != module) { + qCDebug(lcBuildGraph) << "exported module has changed for product" << productName + << ", need to re-run"; + return false; + } + return true; +} + +bool TrafoChangeTracker::areExportedModulesUpToDate( + const std::unordered_map &exportedModules) const +{ + return Internal::all_of(exportedModules, [this](const auto &kv) { + return isExportedModuleUpToDate(kv.first, kv.second); + }); +} + +const Artifact *TrafoChangeTracker::getArtifact(const QString &filePath, + const QString &productName) const +{ + if (m_lastArtifact && m_lastArtifact->filePath() == filePath + && m_lastArtifact->product.get()->uniqueName() == productName) { + return m_lastArtifact; + } + const ResolvedProduct * const product = getProduct(productName); + if (!product) + return nullptr; + const auto &candidates = product->topLevelProject()->buildData->lookupFiles(filePath); + const Artifact *artifact = nullptr; + for (const FileResourceBase * const candidate : candidates) { + if (candidate->fileType() == FileResourceBase::FileTypeArtifact) { + auto const a = static_cast(candidate); + if (a->product.get() == product) { + m_lastArtifact = artifact = a; + break; + } + } + } + return artifact; +} + +const ResolvedProduct *TrafoChangeTracker::getProduct(const QString &name) const +{ + if (m_lastProduct && name == m_lastProduct->uniqueName()) + return m_lastProduct; + if (name == m_product->uniqueName()) { + m_lastProduct = m_product; + return m_product; + } + const auto it = m_productsByName.find(name); + if (it != m_productsByName.cend()) { + m_lastProduct = it->second; + return it->second; + } + return nullptr; +} + +bool TrafoChangeTracker::prepareScriptNeedsRerun() const +{ + for (const Property &property : qAsConst(m_transformer->propertiesRequestedInPrepareScript)) { + if (checkForPropertyChange(property, propertyMapByKind(property))) + return true; + } + + if (checkForImportFileChange(m_transformer->importedFilesUsedInPrepareScript, + m_transformer->lastPrepareScriptExecutionTime, "prepare script")) { + return true; + } + + for (auto it = m_transformer->propertiesRequestedFromArtifactInPrepareScript.constBegin(); + it != m_transformer->propertiesRequestedFromArtifactInPrepareScript.constEnd(); ++it) { + for (const Property &property : qAsConst(it.value())) { + const Artifact * const artifact = getArtifact(it.key(), property.productName); + if (!artifact) + return true; + if (property.kind == Property::PropertyInArtifact) { + if (sorted(artifact->fileTags().toStringList()) != property.value.toStringList()) + return true; + continue; + } + if (checkForPropertyChange(property, artifact->properties->value())) + return true; + } + } + + if (!m_transformer->depsRequestedInPrepareScript.isUpToDate(m_product->topLevelProject())) + return true; + if (!m_transformer->artifactsMapRequestedInPrepareScript.isUpToDate( + m_product->topLevelProject())) { + return true; + } + if (!areExportedModulesUpToDate(m_transformer->exportedModulesAccessedInPrepareScript)) + return true; + + return false; +} + +bool TrafoChangeTracker::commandsNeedRerun() const +{ + for (const Property &property : qAsConst(m_transformer->propertiesRequestedInCommands)) { + if (checkForPropertyChange(property, propertyMapByKind(property))) + return true; + } + + for (auto it = m_transformer->propertiesRequestedFromArtifactInCommands.cbegin(); + it != m_transformer->propertiesRequestedFromArtifactInCommands.cend(); ++it) { + for (const Property &property : qAsConst(it.value())) { + const Artifact * const artifact = getArtifact(it.key(), property.productName); + if (!artifact) + return true; + if (property.kind == Property::PropertyInArtifact) { + if (sorted(artifact->fileTags().toStringList()) != property.value.toStringList()) + return true; + continue; + } + if (checkForPropertyChange(property, artifact->properties->value())) + return true; + } + } + + if (checkForImportFileChange(m_transformer->importedFilesUsedInCommands, + m_transformer->lastCommandExecutionTime, "command")) { + return true; + } + + if (!m_transformer->depsRequestedInCommands.isUpToDate(m_product->topLevelProject())) + return true; + if (!m_transformer->artifactsMapRequestedInCommands.isUpToDate(m_product->topLevelProject())) + return true; + if (!areExportedModulesUpToDate(m_transformer->exportedModulesAccessedInCommands)) + return true; + + // TODO: Also track env access in JS commands and prepare scripts + for (const AbstractCommandPtr &c : qAsConst(m_transformer->commands.commands())) { + if (c->type() != AbstractCommand::ProcessCommandType) + continue; + const ProcessCommandPtr &processCmd = std::static_pointer_cast(c); + const auto envVars = processCmd->relevantEnvVars(); + for (const QString &var : envVars) { + const QString &oldValue = processCmd->relevantEnvValue(var); + const QString &newValue = m_product->buildEnvironment.value(var); + if (oldValue != newValue) { + qCDebug(lcBuildGraph) << "need to re-run command: value of environment variable" + << var << "changed from" << oldValue << "to" << newValue + << "for command" << processCmd->program() << "in rule" + << m_transformer->rule->toString(); + return true; + } + } + } + + return false; +} + +bool prepareScriptNeedsRerun( + Transformer *transformer, const ResolvedProduct *product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName) +{ + if (!transformer->prepareScriptNeedsChangeTracking) + return false; + transformer->prepareScriptNeedsChangeTracking = false; + return TrafoChangeTracker(transformer, product, productsByName, projectsByName) + .prepareScriptNeedsRerun(); +} + +bool commandsNeedRerun(Transformer *transformer, const ResolvedProduct *product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName) +{ + if (!transformer->commandsNeedChangeTracking) + return false; + transformer->commandsNeedChangeTracking = false; + return TrafoChangeTracker(transformer, product, productsByName, projectsByName) + .commandsNeedRerun(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/buildgraph/transformerchangetracking.h b/src/lib/corelib/buildgraph/transformerchangetracking.h new file mode 100644 index 00000000..56efa458 --- /dev/null +++ b/src/lib/corelib/buildgraph/transformerchangetracking.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_TRANSFORMERCHANGETRACKING_H +#define QBS_TRANSFORMERCHANGETRACKING_H + +#include "forward_decls.h" +#include + +#include + +namespace qbs { +namespace Internal { + +bool prepareScriptNeedsRerun( + Transformer *transformer, + const ResolvedProduct *product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName); + +bool commandsNeedRerun(Transformer *transformer, + const ResolvedProduct *product, + const std::unordered_map &productsByName, + const std::unordered_map &projectsByName); + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/corelib.pro b/src/lib/corelib/corelib.pro new file mode 100644 index 00000000..afe07f48 --- /dev/null +++ b/src/lib/corelib/corelib.pro @@ -0,0 +1,43 @@ +TARGET = qbscore +include(../library.pri) +include(../bundledlibs.pri) + +qbs_use_bundled_qtscript { + include(../scriptengine/use_scriptengine.pri) +} else { + QT += script +} + +include(../pkgconfig/use_pkgconfig.pri) + +isEmpty(QBS_RELATIVE_LIBEXEC_PATH) { + win32:QBS_RELATIVE_LIBEXEC_PATH=../bin + else:QBS_RELATIVE_LIBEXEC_PATH=../libexec/qbs +} +DEFINES += QBS_RELATIVE_LIBEXEC_PATH=\\\"$${QBS_RELATIVE_LIBEXEC_PATH}\\\" + +QT += core-private network + +INCLUDEPATH += $$PWD + +include(api/api.pri) +include(buildgraph/buildgraph.pri) +include(generators/generators.pri) +include(jsextensions/jsextensions.pri) +include(language/language.pri) +include(logging/logging.pri) +include(parser/parser.pri) +include(tools/tools.pri) + +win32:LIBS += -lpsapi -lshell32 + +HEADERS += \ + qbs.h + +!qbs_no_dev_install { + qbs_h.files = qbs.h + qbs_h.path = $${QBS_INSTALL_PREFIX}/include/qbs + use_pri.files = use_installed_corelib.pri ../../../qbs_version.pri + use_pri.path = $${qbs_h.path} + INSTALLS += qbs_h use_pri +} diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs new file mode 100644 index 00000000..cf3c45cd --- /dev/null +++ b/src/lib/corelib/corelib.qbs @@ -0,0 +1,535 @@ +import qbs.Utilities + +QbsLibrary { + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["core-private", "network", "xml"] } + Depends { + name: "Qt.core5compat"; + condition: Utilities.versionCompare(Qt.core.version, "6.0.0") >= 0 + } + Depends { + name: "Qt.script" + condition: !qbsbuildconfig.useBundledQtScript + required: false + } + Depends { + name: "qbsscriptengine" + condition: qbsbuildconfig.useBundledQtScript || !Qt.script.present + } + Depends { name: "qbspkgconfig" } + name: "qbscore" + property stringList bundledQtScriptIncludes: qbsbuildconfig.useBundledQtScript + || !Qt.script.present ? qbsscriptengine.includePaths : [] + cpp.includePaths: base.concat(bundledQtScriptIncludes).concat([ + ".", + "../.." // for the plugin headers + ]) + property stringList enableUnitTestsDefines: + qbsbuildconfig.enableUnitTests ? ["QBS_ENABLE_UNIT_TESTS"] : [] + property stringList systemSettingsDirDefines: qbsbuildconfig.systemSettingsDir + ? ['QBS_SYSTEM_SETTINGS_DIR="' + qbsbuildconfig.systemSettingsDir + '"'] : [] + cpp.defines: base.concat([ + "QBS_RELATIVE_LIBEXEC_PATH=" + Utilities.cStringQuote(qbsbuildconfig.relativeLibexecPath), + "QBS_VERSION=" + Utilities.cStringQuote(version), + ]).concat(enableUnitTestsDefines).concat(systemSettingsDirDefines) + + Properties { + condition: qbs.targetOS.contains("windows") + cpp.dynamicLibraries: base.concat(["psapi", "shell32"]) + } + cpp.dynamicLibraries: base + + Properties { + condition: qbs.targetOS.contains("darwin") + cpp.frameworks: ["Foundation", "Security"] + } + + Group { + name: product.name + files: ["qbs.h"] + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + } + Group { + name: "project file updating" + prefix: "api/" + files: [ + "changeset.cpp", + "changeset.h", + "projectfileupdater.cpp", + "projectfileupdater.h", + "qmljsrewriter.cpp", + "qmljsrewriter.h", + ] + } + + Group { + name: "api" + prefix: name + '/' + files: [ + "internaljobs.cpp", + "internaljobs.h", + "jobs.cpp", + "languageinfo.cpp", + "project.cpp", + "project_p.h", + "projectdata.cpp", + "projectdata_p.h", + "propertymap_p.h", + "rulecommand.cpp", + "rulecommand_p.h", + "runenvironment.cpp", + "transformerdata.cpp", + "transformerdata_p.h", + ] + } + Group { + name: "public api headers" + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/api" + prefix: "api/" + files: [ + "jobs.h", + "languageinfo.h", + "project.h", + "projectdata.h", + "rulecommand.h", + "runenvironment.h", + "transformerdata.h", + ] + } + Group { + name: "buildgraph" + prefix: name + '/' + files: [ + "abstractcommandexecutor.cpp", + "abstractcommandexecutor.h", + "artifact.cpp", + "artifact.h", + "artifactcleaner.cpp", + "artifactcleaner.h", + "artifactsscriptvalue.cpp", + "artifactsscriptvalue.h", + "artifactvisitor.cpp", + "artifactvisitor.h", + "buildgraph.cpp", + "buildgraph.h", + "buildgraphnode.cpp", + "buildgraphnode.h", + "buildgraphloader.cpp", + "buildgraphloader.h", + "buildgraphvisitor.h", + "cycledetector.cpp", + "cycledetector.h", + "dependencyparametersscriptvalue.cpp", + "dependencyparametersscriptvalue.h", + "depscanner.cpp", + "depscanner.h", + "emptydirectoriesremover.cpp", + "emptydirectoriesremover.h", + "environmentscriptrunner.cpp", + "environmentscriptrunner.h", + "executor.cpp", + "executor.h", + "executorjob.cpp", + "executorjob.h", + "filedependency.cpp", + "filedependency.h", + "inputartifactscanner.cpp", + "inputartifactscanner.h", + "jscommandexecutor.cpp", + "jscommandexecutor.h", + "nodeset.cpp", + "nodeset.h", + "nodetreedumper.cpp", + "nodetreedumper.h", + "processcommandexecutor.cpp", + "processcommandexecutor.h", + "productbuilddata.cpp", + "productbuilddata.h", + "productinstaller.cpp", + "productinstaller.h", + "projectbuilddata.cpp", + "projectbuilddata.h", + "qtmocscanner.cpp", + "qtmocscanner.h", + "rawscanneddependency.cpp", + "rawscanneddependency.h", + "rawscanresults.cpp", + "rawscanresults.h", + "requestedartifacts.cpp", + "requestedartifacts.h", + "requesteddependencies.cpp", + "requesteddependencies.h", + "rescuableartifactdata.h", + "rulecommands.cpp", + "rulecommands.h", + "rulegraph.cpp", + "rulegraph.h", + "rulenode.cpp", + "rulenode.h", + "rulesapplicator.cpp", + "rulesapplicator.h", + "rulesevaluationcontext.cpp", + "rulesevaluationcontext.h", + "scriptclasspropertyiterator.h", + "timestampsupdater.cpp", + "timestampsupdater.h", + "transformer.cpp", + "transformer.h", + "transformerchangetracking.cpp", + "transformerchangetracking.h", + ] + } + Group { + name: "public buildgraph headers" + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/buildgraph" + files: "buildgraph/forward_decls.h" + } + Group { + name: "generators" + prefix: "generators/" + files: [ + "generatableprojectiterator.cpp", + "generatableprojectiterator.h", + "generator.cpp", + "generatordata.cpp", + "generatorutils.cpp", + "generatorutils.h", + "generatorversioninfo.cpp", + "generatorversioninfo.h", + "igeneratableprojectvisitor.h", + "ixmlnodevisitor.h", + "xmlproject.cpp", + "xmlproject.h", + "xmlprojectwriter.cpp", + "xmlprojectwriter.h", + "xmlproperty.cpp", + "xmlproperty.h", + "xmlpropertygroup.cpp", + "xmlpropertygroup.h", + "xmlworkspace.cpp", + "xmlworkspace.h", + "xmlworkspacewriter.cpp", + "xmlworkspacewriter.h", + ] + } + Group { + name: "public generator headers" + prefix: "generators/" + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/generators" + files: [ + "generator.h", + "generatordata.h", + ] + } + Group { + name: "jsextensions" + prefix: name + '/' + files: [ + "environmentextension.cpp", + "file.cpp", + "fileinfoextension.cpp", + "host.cpp", + "jsextensions.cpp", + "jsextensions.h", + "moduleproperties.cpp", + "moduleproperties.h", + "pkgconfigjs.cpp", + "pkgconfigjs.h", + "process.cpp", + "temporarydir.cpp", + "textfile.cpp", + "binaryfile.cpp", + "utilitiesextension.cpp", + "domxml.cpp", + ] + } + Group { + name: "jsextensions (Non-Darwin-specific)" + prefix: "jsextensions/" + condition: !qbs.targetOS.contains("darwin") + files: [ + "propertylist.cpp", + ] + } + Group { + name: "jsextensions (Darwin-specific)" + prefix: "jsextensions/" + condition: qbs.targetOS.contains("darwin") + files: [ + // This is ugly, but because of QBS-1592 we cannot check the platform in the header + // using Q_OS_DARWIN + "propertylist_darwin.h", + "propertylist_darwin.mm", + "propertylistutils.h", + "propertylistutils.mm", + ] + } + Group { + name: "language" + prefix: name + '/' + files: [ + "artifactproperties.cpp", + "artifactproperties.h", + "astimportshandler.cpp", + "astimportshandler.h", + "astpropertiesitemhandler.cpp", + "astpropertiesitemhandler.h", + "asttools.cpp", + "asttools.h", + "builtindeclarations.cpp", + "builtindeclarations.h", + "deprecationinfo.h", + "evaluationdata.h", + "evaluator.cpp", + "evaluator.h", + "evaluatorscriptclass.cpp", + "evaluatorscriptclass.h", + "filecontext.cpp", + "filecontext.h", + "filecontextbase.cpp", + "filecontextbase.h", + "filetags.cpp", + "filetags.h", + "identifiersearch.cpp", + "identifiersearch.h", + "item.cpp", + "item.h", + "itemdeclaration.cpp", + "itemdeclaration.h", + "itemobserver.h", + "itempool.cpp", + "itempool.h", + "itemreader.cpp", + "itemreader.h", + "itemreaderastvisitor.cpp", + "itemreaderastvisitor.h", + "itemreadervisitorstate.cpp", + "itemreadervisitorstate.h", + "itemtype.h", + "jsimports.h", + "language.cpp", + "language.h", + "loader.cpp", + "loader.h", + "moduleloader.cpp", + "moduleloader.h", + "modulemerger.cpp", + "modulemerger.h", + "moduleproviderinfo.h", + "moduleproviderloader.cpp", + "moduleproviderloader.h", + "preparescriptobserver.cpp", + "preparescriptobserver.h", + "probesresolver.cpp", + "probesresolver.h", + "projectresolver.cpp", + "projectresolver.h", + "property.cpp", + "property.h", + "propertydeclaration.cpp", + "propertydeclaration.h", + "propertymapinternal.cpp", + "propertymapinternal.h", + "qualifiedid.cpp", + "qualifiedid.h", + "resolvedfilecontext.cpp", + "resolvedfilecontext.h", + "scriptengine.cpp", + "scriptengine.h", + "scriptimporter.cpp", + "scriptimporter.h", + "scriptpropertyobserver.cpp", + "scriptpropertyobserver.h", + "value.cpp", + "value.h", + ] + } + Group { + name: "public language headers" + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/language" + files: "language/forward_decls.h" + } + Group { + name: "logging" + prefix: name + '/' + files: [ + "categories.cpp", + "categories.h", + "ilogsink.cpp", + "logger.cpp", + "logger.h", + "translator.h" + ] + } + Group { + name: "public logging headers" + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/logging" + files: "logging/ilogsink.h" + } + Group { + name: "parser" + prefix: name + '/' + files: [ + "qmlerror.cpp", + "qmlerror.h", + "qmljs.g", + "qmljsast.cpp", + "qmljsast_p.h", + "qmljsastfwd_p.h", + "qmljsastvisitor.cpp", + "qmljsastvisitor_p.h", + "qmljsengine_p.cpp", + "qmljsengine_p.h", + "qmljsglobal_p.h", + "qmljsgrammar.cpp", + "qmljsgrammar_p.h", + "qmljskeywords_p.h", + "qmljslexer.cpp", + "qmljslexer_p.h", + "qmljsmemorypool_p.h", + "qmljsparser.cpp", + "qmljsparser_p.h" + ] + } + Group { + name: "tools" + prefix: name + '/' + files: [ + "architectures.cpp", + "buildgraphlocker.cpp", + "buildgraphlocker.h", + "buildoptions.cpp", + "clangclinfo.cpp", + "clangclinfo.h", + "cleanoptions.cpp", + "codelocation.cpp", + "commandechomode.cpp", + "dynamictypecheck.h", + "error.cpp", + "executablefinder.cpp", + "executablefinder.h", + "fileinfo.cpp", + "fileinfo.h", + "filesaver.cpp", + "filesaver.h", + "filetime.cpp", + "filetime.h", + "generateoptions.cpp", + "hostosinfo.h", + "id.cpp", + "id.h", + "iosutils.h", + "joblimits.cpp", + "jsliterals.cpp", + "jsliterals.h", + "jsonhelper.h", + "installoptions.cpp", + "launcherinterface.cpp", + "launcherinterface.h", + "launcherpackets.cpp", + "launcherpackets.h", + "launchersocket.cpp", + "launchersocket.h", + "msvcinfo.cpp", + "msvcinfo.h", + "pathutils.h", + "persistence.cpp", + "persistence.h", + "porting.h", + "preferences.cpp", + "processresult.cpp", + "processresult_p.h", + "processutils.cpp", + "processutils.h", + "profile.cpp", + "profiling.cpp", + "profiling.h", + "progressobserver.cpp", + "progressobserver.h", + "projectgeneratormanager.cpp", + "qbsassert.cpp", + "qbsassert.h", + "qbspluginmanager.cpp", + "qbspluginmanager.h", + "qbsprocess.cpp", + "qbsprocess.h", + "qttools.cpp", + "qttools.h", + "scannerpluginmanager.cpp", + "scannerpluginmanager.h", + "scripttools.cpp", + "scripttools.h", + "set.h", + "settings.cpp", + "settingscreator.cpp", + "settingscreator.h", + "settingsmodel.cpp", + "settingsrepresentation.cpp", + "setupprojectparameters.cpp", + "shellutils.cpp", + "shellutils.h", + "stlutils.h", + "stringconstants.h", + "stringutils.h", + "toolchains.cpp", + "version.cpp", + "visualstudioversioninfo.cpp", + "visualstudioversioninfo.h", + "vsenvironmentdetector.cpp", + "vsenvironmentdetector.h", + "weakpointer.h", + ] + } + Group { + name: "public tools headers" + prefix: "tools/" + files: [ + "architectures.h", + "buildoptions.h", + "cleanoptions.h", + "codelocation.h", + "commandechomode.h", + "error.h", + "generateoptions.h", + "installoptions.h", + "joblimits.h", + "preferences.h", + "processresult.h", + "profile.h", + "projectgeneratormanager.h", + "qbs_export.h", + "settings.h", + "settingsmodel.h", + "settingsrepresentation.h", + "setupprojectparameters.h", + "toolchains.h", + "version.h", + ] + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + "/tools" + } + Group { + condition: qbs.targetOS.contains("macos") + name: "tools (macOS)" + prefix: "tools/" + files: [ + "applecodesignutils.cpp", + "applecodesignutils.h" + ] + } + Group { + name: "use_installed.pri" + files: [ + "use_installed_corelib.pri", + "../../../qbs_version.pri" + ] + qbs.install: qbsbuildconfig.installApiHeaders + qbs.installDir: headerInstallPrefix + } +} diff --git a/src/lib/corelib/generators/generatableprojectiterator.cpp b/src/lib/corelib/generators/generatableprojectiterator.cpp new file mode 100644 index 00000000..7267662e --- /dev/null +++ b/src/lib/corelib/generators/generatableprojectiterator.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "generatableprojectiterator.h" + +namespace qbs { + +GeneratableProjectIterator::GeneratableProjectIterator(GeneratableProject project) + : project(std::move(project)) +{ +} + +void GeneratableProjectIterator::accept(IGeneratableProjectVisitor *visitor) +{ + visitor->visitProject(project); + QMapIterator it(project.projects); + while (it.hasNext()) { + it.next(); + visitor->visitProject(it.value(), it.key()); + } + + accept(project, GeneratableProjectData(), project, visitor); +} + +void GeneratableProjectIterator::accept(const GeneratableProject &project, + const GeneratableProjectData &parentProjectData, + const GeneratableProjectData &projectData, + IGeneratableProjectVisitor *visitor) +{ + visitor->visitProjectData(project, parentProjectData, projectData); + visitor->visitProjectData(project, projectData); + QMapIterator it(projectData.data); + while (it.hasNext()) { + it.next(); + visitor->visitProjectData(parentProjectData.data.value(it.key()), it.value(), it.key()); + visitor->visitProjectData(it.value(), it.key()); + } + + for (const auto &subProject : projectData.subProjects) { + accept(project, projectData, subProject, visitor); + } + + for (const auto &productDataMap : projectData.products) { + visitor->visitProduct(project, projectData, productDataMap); + QMapIterator it(productDataMap.data); + while (it.hasNext()) { + it.next(); + visitor->visitProduct(it.value(), it.key()); + } + } +} + +} // namespace qbs diff --git a/src/lib/corelib/generators/generatableprojectiterator.h b/src/lib/corelib/generators/generatableprojectiterator.h new file mode 100644 index 00000000..993144ce --- /dev/null +++ b/src/lib/corelib/generators/generatableprojectiterator.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GENERATABLEPROJECTITERATOR_H +#define GENERATABLEPROJECTITERATOR_H + +#include "generatordata.h" +#include "igeneratableprojectvisitor.h" + +namespace qbs { + +class QBS_EXPORT GeneratableProjectIterator { + GeneratableProject project; + +public: + GeneratableProjectIterator(GeneratableProject project); + void accept(IGeneratableProjectVisitor *visitor); + +private: + void accept(const GeneratableProject &project, const GeneratableProjectData &parentProjectData, + const GeneratableProjectData &projectData, + IGeneratableProjectVisitor *visitor); +}; + +} // namespace qbs + +#endif // GENERATABLEPROJECTITERATOR_H diff --git a/src/lib/corelib/generators/generator.cpp b/src/lib/corelib/generators/generator.cpp new file mode 100644 index 00000000..d3cdce41 --- /dev/null +++ b/src/lib/corelib/generators/generator.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "generator.h" +#include +#include +#include +#include +#include +#include +#include + +namespace qbs { + +class ProjectGeneratorPrivate { +public: + QList projects; + QList buildConfigurations; + InstallOptions installOptions; + QString qbsSettingsDir; + Internal::Logger logger = Internal::Logger(nullptr); +}; + +ProjectGenerator::ProjectGenerator() + : d(std::make_unique()) +{ +} + +ProjectGenerator::~ProjectGenerator() = default; + +static QString _configurationName(const Project &project) +{ + return project.projectConfiguration() + .value(Internal::StringConstants::qbsModule()).toMap() + .value(Internal::StringConstants::configurationNameProperty()).toString(); +} + +static QString _configurationName(const QVariantMap &buildConfiguration) +{ + return buildConfiguration.value(QStringLiteral("qbs.configurationName")).toString(); +} + +ErrorInfo ProjectGenerator::generate(const QList &projects, + const QList &buildConfigurations, + const InstallOptions &installOptions, + const QString &qbsSettingsDir, + const Internal::Logger &logger) +{ + d->projects = projects; + std::sort(d->projects.begin(), d->projects.end(), + [](const Project &a, const Project &b) { + return _configurationName(a) < _configurationName(b); }); + d->buildConfigurations = buildConfigurations; + std::sort(d->buildConfigurations.begin(), d->buildConfigurations.end(), + [](const QVariantMap &a, const QVariantMap &b) { + return _configurationName(a) < _configurationName(b); }); + d->installOptions = installOptions; + d->qbsSettingsDir = qbsSettingsDir; + d->logger = logger; + try { + generate(); + } catch (const ErrorInfo &e) { + return e; + } + return {}; +} + +QList ProjectGenerator::projects() const +{ + return d->projects; +} + +QList ProjectGenerator::buildConfigurations() const +{ + return d->buildConfigurations; +} + +QVariantMap ProjectGenerator::buildConfiguration(const Project &project) const +{ + int idx = d->projects.indexOf(project); + if (idx < 0) + return {}; + return d->buildConfigurations.at(idx); +} + +QStringList ProjectGenerator::buildConfigurationCommandLine(const Project &project) const +{ + QVariantMap config = buildConfiguration(project); + + const QString name = config.take(QStringLiteral("qbs.configurationName")).toString(); + if (name.isEmpty()) + throw ErrorInfo(QStringLiteral("Can't find configuration name for project")); + + QStringList commandLineParameters; + commandLineParameters += QStringLiteral("config:") + name; + + QMapIterator it(config); + while (it.hasNext()) { + it.next(); + commandLineParameters += it.key() + QStringLiteral(":") + it.value().toString(); + } + + return commandLineParameters; +} + +// Count the number of products in the project (singular) +// Precondition: each project data (i.e. per-configuration project data) +// has the same number of products. +static int _productCount(const QList &projects) +{ + int count = -1; + for (const auto &project : projects) { + int oldCount = count; + count = project.products().size(); + QBS_CHECK(oldCount == -1 || oldCount == count); + } + return count; +} + +static int _subprojectCount(const QList &projects) +{ + int count = -1; + for (const auto &project : projects) { + int oldCount = count; + count = project.subProjects().size(); + QBS_CHECK(oldCount == -1 || oldCount == count); + } + return count; +} + +static GeneratableProjectData _reduceProjectConfigurations( + const QMap &map) { + GeneratableProjectData gproject; + + // Add the project's project data for each configuration + QMapIterator it(map); + while (it.hasNext()) { + it.next(); + gproject.data.insert(it.key(), it.value()); + } + + // Add the project's products... + for (int i = 0; i < _productCount(map.values()); ++i) { + GeneratableProductData prod; + + // once for each configuration + QMapIterator it(map); + while (it.hasNext()) { + it.next(); + prod.data.insert(it.key(), it.value().products().at(i)); + } + + gproject.products.push_back(prod); + } + + // Add the project's subprojects... + for (int i = 0; i < _subprojectCount(map.values()); ++i) { + QMap subprojectMap; + + // once for each configuration + QMapIterator it(map); + while (it.hasNext()) { + it.next(); + subprojectMap.insert(it.key(), it.value().subProjects().at(i)); + } + + gproject.subProjects.push_back(_reduceProjectConfigurations(subprojectMap)); + } + + return gproject; +} + +const GeneratableProject ProjectGenerator::project() const +{ + QMap rootProjects; + GeneratableProject proj; + for (const auto &project : qAsConst(d->projects)) { + const QString configurationName = _configurationName(project); + rootProjects.insert(configurationName, project.projectData()); + proj.projects.insert(configurationName, project); + proj.buildConfigurations.insert(configurationName, buildConfiguration(project)); + proj.commandLines.insert(configurationName, buildConfigurationCommandLine(project)); + } + auto p = _reduceProjectConfigurations(rootProjects); + proj.data = p.data; + proj.products = p.products; + proj.subProjects = p.subProjects; + proj.installOptions = d->installOptions; + return proj; +} + +QFileInfo ProjectGenerator::qbsExecutableFilePath() const +{ + const QString qbsInstallDir = QString::fromLocal8Bit(qgetenv("QBS_INSTALL_DIR")); + auto file = QFileInfo(Internal::HostOsInfo::appendExecutableSuffix(!qbsInstallDir.isEmpty() + ? qbsInstallDir + QLatin1String("/bin/qbs") + : QCoreApplication::applicationDirPath() + QLatin1String("/qbs"))); + QBS_CHECK(file.isAbsolute() && file.exists()); + return file; +} + +QString ProjectGenerator::qbsSettingsDir() const +{ + return d->qbsSettingsDir; +} + +const Internal::Logger &ProjectGenerator::logger() const +{ + return d->logger; +} + +} // namespace qbs diff --git a/src/lib/corelib/generators/generator.h b/src/lib/corelib/generators/generator.h new file mode 100644 index 00000000..a7cc56b5 --- /dev/null +++ b/src/lib/corelib/generators/generator.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GENERATORPLUGIN_H +#define GENERATORPLUGIN_H + +#include "generatordata.h" +#include +#include + +#include + +namespace qbs { + +class ProjectGeneratorPrivate; + +/*! + * \class ProjectGenerator + * \brief The \c ProjectGenerator class is an abstract base class for generators which generate + * arbitrary output given a resolved Qbs project. + */ +class QBS_EXPORT ProjectGenerator : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(ProjectGenerator) +public: + ~ProjectGenerator() override; + + /*! + * Returns the name of the generator used to create the external build system files. + */ + virtual QString generatorName() const = 0; + + ErrorInfo generate(const QList &projects, + const QList &buildConfigurations, + const InstallOptions &installOptions, + const QString &qbsSettingsDir, + const Internal::Logger &logger); + + const GeneratableProject project() const; + QFileInfo qbsExecutableFilePath() const; + QString qbsSettingsDir() const; + +protected: + ProjectGenerator(); + + const Internal::Logger &logger() const; + +private: + virtual void generate() = 0; + + QList projects() const; + QList buildConfigurations() const; + QVariantMap buildConfiguration(const Project &project) const; + QStringList buildConfigurationCommandLine(const Project &project) const; + + const std::unique_ptr d; +}; + +} // namespace qbs + +#endif // GENERATORPLUGIN_H diff --git a/src/lib/corelib/generators/generatordata.cpp b/src/lib/corelib/generators/generatordata.cpp new file mode 100644 index 00000000..25afae23 --- /dev/null +++ b/src/lib/corelib/generators/generatordata.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "generatordata.h" +#include +#include + +#include + +namespace qbs { + +QString GeneratableProductData::name() const +{ + return uniqueValue(&ProductData::name, + QStringLiteral("Products with different names per configuration are not " + "compatible with this generator. " + "Consider using the targetName property instead.")); +} + +CodeLocation GeneratableProductData::location() const +{ + return uniqueValue(&ProductData::location, + QStringLiteral("GeneratableProductData::location: internal bug; this should not happen.")); +} + +QStringList GeneratableProductData::dependencies() const +{ + return uniqueValue(&ProductData::dependencies, + QStringLiteral("Products with different dependency lists per configuration are not " + "compatible with this generator.")); +} + +QStringList GeneratableProductData::type() const +{ + return uniqueValue(&ProductData::type, + QStringLiteral("Products with different types per configuration are not " + "compatible with this generator.")); +} + +QString GeneratableProductData::buildDirectory() const +{ + return uniqueValue(&ProductData::buildDirectory, + QStringLiteral("GeneratableProductData::buildDirectory: " + "internal bug; this should not happen.")); +} + +QString GeneratableProjectData::name() const +{ + return uniqueValue(&ProjectData::name, + QStringLiteral("Projects with different names per configuration are not " + "compatible with this generator.")); +} + +CodeLocation GeneratableProjectData::location() const +{ + CodeLocation location; + QMapIterator it(data); + while (it.hasNext()) { + it.next(); + CodeLocation oldLocation = location; + location = it.value().location(); + if (oldLocation.isValid() && oldLocation != location) + throw ErrorInfo(QStringLiteral("Projects with different code locations " + "per configuration are not compatible with this " + "generator.")); + } + return location; +} + +GeneratableProjectData::Id GeneratableProjectData::uniqueName() const +{ + GeneratableProjectData::Id id; + id.value = name() + QLatin1Char('-') + location().toString(); + return id; +} + +QDir GeneratableProject::baseBuildDirectory() const +{ + Internal::Set baseBuildDirectory; + QMapIterator it(data); + while (it.hasNext()) { + it.next(); + QDir dir(it.value().buildDirectory()); + dir.cdUp(); + baseBuildDirectory.insert(dir.absolutePath()); + } + Q_ASSERT(baseBuildDirectory.size() == 1); + return *baseBuildDirectory.begin(); +} + +QFileInfo GeneratableProject::filePath() const +{ + Internal::Set filePath; + QMapIterator it(data); + while (it.hasNext()) { + it.next(); + filePath.insert(it.value().location().filePath()); + } + Q_ASSERT(filePath.size() == 1); + return QFileInfo(*filePath.begin()); +} + +bool GeneratableProject::hasMultipleConfigurations() const +{ + return projects.size() > 1; +} + +QStringList GeneratableProject::commandLine() const +{ + QStringList combinedCommandLine; + QMapIterator it(commandLines); + while (it.hasNext()) { + it.next(); + combinedCommandLine << it.value(); + } + return combinedCommandLine; +} + +} // namespace qbs diff --git a/src/lib/corelib/generators/generatordata.h b/src/lib/corelib/generators/generatordata.h new file mode 100644 index 00000000..fd9bdde3 --- /dev/null +++ b/src/lib/corelib/generators/generatordata.h @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GENERATORDATA_H +#define GENERATORDATA_H + +#include +#include +#include +#include +#include +#include +#include + +namespace qbs { + +using GeneratableProjectMap = QMap; + +template struct IMultiplexableContainer { + QMap data; + + template T uniqueValue(const std::function &func, + const QString &errorMessage) const + { + if (data.empty()) + return T(); + auto it = data.begin(), end = data.end(); + auto value = func(*it++); + for (; it != end; ++it) { + if (value != func(*it)) + throw ErrorInfo(errorMessage); + } + return value; + } + + void forEach(const std::function &func) const + { + for (auto it = data.cbegin(), end = data.cend(); it != end; ++it) + func(it.key(), it.value()); + } + + void forEach(const std::function &func) const + { + for (auto it = data.cbegin(), end = data.cend(); it != end; ++it) + func(it.key().toStdString(), it.value()); + } + + const U operator[](const QString &configurationName) const + { + return data[configurationName]; + } + + const U operator[](const std::string &configurationName) const + { + return data[QString::fromStdString(configurationName)]; + } + + bool isValid() const + { + return !data.empty(); + } + +protected: + IMultiplexableContainer() = default; +}; + +struct QBS_EXPORT GeneratableProductData : public IMultiplexableContainer { + QString name() const; + CodeLocation location() const; + QStringList dependencies() const; + QStringList type() const; + QString buildDirectory() const; +}; + +struct QBS_EXPORT GeneratableProjectData : public IMultiplexableContainer { + struct Id { + private: + friend struct GeneratableProjectData; + Id() = default; + QString value; + + public: + bool operator<(const Id &id) const { return value < id.value; } + }; + + QList subProjects; + QList products; + QString name() const; + CodeLocation location() const; + Id uniqueName() const; +}; + +struct QBS_EXPORT GeneratableProject : public GeneratableProjectData { + GeneratableProjectMap projects; + QMap buildConfigurations; + QMap commandLines; + InstallOptions installOptions; + QDir baseBuildDirectory() const; + QFileInfo filePath() const; + bool hasMultipleConfigurations() const; + QStringList commandLine() const; + + void forEach(const std::function &func) const + { + for (auto it = projects.cbegin(), end = projects.cend(); it != end; ++it) + func(it.key(), it.value()); + } + + void forEach(const std::function &func) const + { + for (auto it = projects.cbegin(), end = projects.cend(); it != end; ++it) + func(it.key().toStdString(), it.value()); + } + + const Project operator[](const QString &configurationName) const + { + return projects[configurationName]; + } + + const Project operator[](const std::string &configurationName) const + { + return projects[QString::fromStdString(configurationName)]; + } + + bool isValid() const + { + return !data.empty() && !projects.empty(); + } + + const ProjectData projectData(const QString &configurationName) const + { + return data[configurationName]; + } + + const ProjectData projectData(const std::string &configurationName) const + { + return data[QString::fromStdString(configurationName)]; + } +}; + +} // namespace qbs + +#endif // GENERATORDATA_H diff --git a/src/lib/corelib/generators/generators.pri b/src/lib/corelib/generators/generators.pri new file mode 100644 index 00000000..e9730d89 --- /dev/null +++ b/src/lib/corelib/generators/generators.pri @@ -0,0 +1,38 @@ +include(../../../install_prefix.pri) + +SOURCES += \ + $$PWD/generatableprojectiterator.cpp \ + $$PWD/generator.cpp \ + $$PWD/generatordata.cpp \ + $$PWD/generatorutils.cpp \ + $$PWD/generatorversioninfo.cpp \ + $$PWD/xmlproject.cpp \ + $$PWD/xmlprojectwriter.cpp\ + $$PWD/xmlproperty.cpp \ + $$PWD/xmlpropertygroup.cpp \ + $$PWD/xmlworkspace.cpp \ + $$PWD/xmlworkspacewriter.cpp + +HEADERS += \ + $$PWD/generatableprojectiterator.h \ + $$PWD/generator.h \ + $$PWD/generatordata.h \ + $$PWD/generatorutils.h \ + $$PWD/generatorversioninfo.h \ + $$PWD/igeneratableprojectvisitor.h \ + $$PWD/ixmlnodevisitor.h \ + $$PWD/ixmlnodevisitor.h \ + $$PWD/xmlproject.h \ + $$PWD/xmlprojectwriter.h \ + $$PWD/xmlproperty.h \ + $$PWD/xmlpropertygroup.h \ + $$PWD/xmlworkspace.h \ + $$PWD/xmlworkspacewriter.h + +!qbs_no_dev_install { + generators_headers.files = \ + $$PWD/generator.h \ + $$PWD/generatordata.h + generators_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/generators + INSTALLS += generators_headers +} diff --git a/src/lib/corelib/generators/generatorutils.cpp b/src/lib/corelib/generators/generatorutils.cpp new file mode 100644 index 00000000..c49e1fa7 --- /dev/null +++ b/src/lib/corelib/generators/generatorutils.cpp @@ -0,0 +1,263 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "generatorutils.h" + +#include + +namespace qbs { +namespace gen { +namespace utils { + +QString architectureName(Architecture arch) +{ + switch (arch) { + case Architecture::Arm: + return QStringLiteral("arm"); + case Architecture::Avr: + return QStringLiteral("avr"); + case Architecture::Mcs51: + return QStringLiteral("mcs51"); + default: + return QStringLiteral("unknown"); + } +} + +Architecture architecture(const Project &qbsProject) +{ + const auto qbsArch = qbsProject.projectConfiguration() + .value(Internal::StringConstants::qbsModule()).toMap() + .value(QStringLiteral("architecture")).toString(); + + if (qbsArch == QLatin1String("arm")) + return Architecture::Arm; + if (qbsArch == QLatin1String("avr")) + return Architecture::Avr; + if (qbsArch == QLatin1String("mcs51")) + return Architecture::Mcs51; + if (qbsArch == QLatin1String("stm8")) + return Architecture::Stm8; + if (qbsArch == QLatin1String("msp430")) + return Architecture::Msp430; + return Architecture::Unknown; +} + +QString buildConfigurationName(const Project &qbsProject) +{ + return qbsProject.projectConfiguration() + .value(Internal::StringConstants::qbsModule()).toMap() + .value(QStringLiteral("configurationName")).toString(); +} + +int debugInformation(const ProductData &qbsProduct) +{ + return qbsProduct.moduleProperties().getModuleProperty( + Internal::StringConstants::qbsModule(), + QStringLiteral("debugInformation")) + .toInt(); +} + +QString buildRootPath(const Project &qbsProject) +{ + QDir dir(qbsProject.projectData().buildDirectory()); + dir.cdUp(); + return dir.absolutePath(); +} + +QString relativeFilePath(const QString &baseDirectory, + const QString &fullFilePath) +{ + return QDir(baseDirectory).relativeFilePath(fullFilePath); +} + +QString binaryOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + return QDir(baseDirectory).relativeFilePath( + qbsProduct.buildDirectory()) + + QLatin1String("/bin"); +} + +QString objectsOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + return QDir(baseDirectory).relativeFilePath( + qbsProduct.buildDirectory()) + + QLatin1String("/obj"); +} + +QString listingOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + return QDir(baseDirectory).relativeFilePath( + qbsProduct.buildDirectory()) + + QLatin1String("/lst"); +} + +std::vector dependenciesOf(const ProductData &qbsProduct, + const GeneratableProject &genProject, + const QString &configurationName) +{ + std::vector result; + const auto &depsNames = qbsProduct.dependencies(); + for (const auto &product : qAsConst(genProject.products)) { + const auto pt = product.type(); + if (!pt.contains(QLatin1String("staticlibrary"))) + continue; + const auto pn = product.name(); + if (!depsNames.contains(pn)) + continue; + result.push_back(product.data.value(configurationName)); + } + return result; +} + +QString targetBinary(const ProductData &qbsProduct) +{ + const auto &type = qbsProduct.type(); + if (type.contains(QLatin1String("application"))) { + return QFileInfo(qbsProduct.targetExecutable()).fileName(); + } + if (type.contains(QLatin1String("staticlibrary"))) { + for (const auto &artifact : qbsProduct.targetArtifacts()) { + if (artifact.fileTags().contains(QLatin1String("staticlibrary"))) + return QFileInfo(artifact.filePath()).fileName(); + } + } + + return {}; +} + +QString targetBinaryPath(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + return binaryOutputDirectory(baseDirectory, qbsProduct) + + QLatin1Char('/') + targetBinary(qbsProduct); +} + +QString cppStringModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName) +{ + return qbsProps.getModuleProperty( + Internal::StringConstants::cppModule(), + propertyName).toString().trimmed(); +} + +bool cppBooleanModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName) +{ + return qbsProps.getModuleProperty( + Internal::StringConstants::cppModule(), + propertyName).toBool(); +} + +int cppIntegerModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName) +{ + return qbsProps.getModuleProperty( + Internal::StringConstants::cppModule(), + propertyName).toInt(); +} + +QStringList cppStringModuleProperties(const PropertyMap &qbsProps, + const QStringList &propertyNames) +{ + QStringList properties; + for (const auto &propertyName : propertyNames) { + const auto entries = qbsProps.getModuleProperty(Internal::StringConstants::cppModule(), + propertyName).toStringList(); + Internal::transform(entries, properties, [](const auto &entry) { + return entry.trimmed(); }); + } + return properties; +} + +QVariantList cppVariantModuleProperties(const PropertyMap &qbsProps, + const QStringList &propertyNames) +{ + QVariantList properties; + for (const auto &propertyName : propertyNames) { + properties << qbsProps.getModuleProperty( + Internal::StringConstants::cppModule(), + propertyName).toList(); + } + return properties; +} + +static QString parseFlagValue(const QString &flagKey, + QStringList::const_iterator &flagIt, + const QStringList::const_iterator &flagEnd) +{ + if (flagIt->contains(QLatin1Char('='))) { + // In this case an option is in form of 'flagKey='. + const auto parts = flagIt->split(QLatin1Char('=')); + if (parts.count() == 2) + return parts.at(1).trimmed(); + } else if (flagKey < *flagIt) { + // In this case an option is in form of 'flagKey'. + return flagIt->mid(flagKey.count()).trimmed(); + } else { + // In this case an option is in form of 'flagKey '. + ++flagIt; + if (flagIt < flagEnd && !flagIt->startsWith(QLatin1Char('-'))) + return (*flagIt).trimmed(); + } + return {}; +} + +QString firstFlagValue(const QStringList &flags, const QString &flagKey) +{ + const auto flagBegin = flags.cbegin(); + const auto flagEnd = flags.cend(); + auto flagIt = std::find_if(flagBegin, flagEnd, [flagKey](const QString &flag) { + return flag == flagKey || flag.startsWith(flagKey); + }); + if (flagIt == flagEnd) + return {}; + return parseFlagValue(flagKey, flagIt, flagEnd); +} + +QStringList allFlagValues(const QStringList &flags, const QString &flagKey) +{ + QStringList values; + const auto flagEnd = flags.cend(); + for (auto flagIt = flags.cbegin(); flagIt < flagEnd; ++flagIt) { + if (*flagIt == flagKey || flagIt->startsWith(flagKey)) { + const QString value = parseFlagValue(flagKey, flagIt, flagEnd); + if (!value.isEmpty()) + values.push_back(value); + } + } + return values; +} + +} // namespace utils +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/generatorutils.h b/src/lib/corelib/generators/generatorutils.h new file mode 100644 index 00000000..58e59cbf --- /dev/null +++ b/src/lib/corelib/generators/generatorutils.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_UTILS_H +#define GENERATORS_UTILS_H + +#include + +#include +#include + +namespace qbs { +namespace gen { +namespace utils { + +enum class Architecture { + Unknown = 0, + Arm = 1 << 1, + Avr = 1 << 2, + Mcs51 = 1 << 3, + Stm8 = 1 << 4, + Msp430 = 1 << 5 +}; + +Q_DECLARE_FLAGS(ArchitectureFlags, Architecture) +Q_DECLARE_OPERATORS_FOR_FLAGS(ArchitectureFlags) + +QBS_EXPORT QString architectureName(Architecture arch); +QBS_EXPORT Architecture architecture(const Project &qbsProject); +QBS_EXPORT QString buildConfigurationName(const Project &qbsProject); +QBS_EXPORT int debugInformation(const ProductData &qbsProduct); +QBS_EXPORT QString buildRootPath(const Project &qbsProject); +QBS_EXPORT QString relativeFilePath(const QString &baseDirectory, + const QString &fullFilePath); +QBS_EXPORT QString binaryOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct); +QBS_EXPORT QString objectsOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct); +QBS_EXPORT QString listingOutputDirectory(const QString &baseDirectory, + const ProductData &qbsProduct); +QBS_EXPORT std::vector dependenciesOf(const ProductData &qbsProduct, + const GeneratableProject &genProject, + const QString &configurationName); +QBS_EXPORT QString targetBinary(const ProductData &qbsProduct); +QBS_EXPORT QString targetBinaryPath(const QString &baseDirectory, + const ProductData &qbsProduct); +QBS_EXPORT QString cppStringModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName); +QBS_EXPORT bool cppBooleanModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName); +QBS_EXPORT int cppIntegerModuleProperty(const PropertyMap &qbsProps, + const QString &propertyName); +QBS_EXPORT QStringList cppStringModuleProperties(const PropertyMap &qbsProps, + const QStringList &propertyNames); +QBS_EXPORT QVariantList cppVariantModuleProperties(const PropertyMap &qbsProps, + const QStringList &propertyNames); +QBS_EXPORT QString firstFlagValue(const QStringList &flags, + const QString &flagKey); +QBS_EXPORT QStringList allFlagValues(const QStringList &flags, + const QString &flagKey); + +template +bool inBounds(const T &value, const T &low, const T &high) +{ + return !(value < low) && !(high < value); +} + +} // namespace utils +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_UTILS_H diff --git a/src/lib/corelib/generators/generatorversioninfo.cpp b/src/lib/corelib/generators/generatorversioninfo.cpp new file mode 100644 index 00000000..c5c8db03 --- /dev/null +++ b/src/lib/corelib/generators/generatorversioninfo.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "generatorversioninfo.h" + +namespace qbs { +namespace gen { + +int VersionInfo::marketingVersion() const +{ + return m_version.majorVersion(); +} + +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/generatorversioninfo.h b/src/lib/corelib/generators/generatorversioninfo.h new file mode 100644 index 00000000..5c867326 --- /dev/null +++ b/src/lib/corelib/generators/generatorversioninfo.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GENERATORS_VERSION_INFO_H +#define GENERATORS_VERSION_INFO_H + +#include "generatorutils.h" + +#include +#include + +#include + +namespace qbs { +namespace gen { + +class QBS_EXPORT VersionInfo +{ +public: + constexpr VersionInfo(const Version &version, utils::ArchitectureFlags archs) + : m_version(version), m_archs(archs) + { + } + + constexpr bool operator<(const VersionInfo &other) const { return m_version < other.m_version; } + constexpr bool operator==(const VersionInfo &other) const + { + return m_version == other.m_version && m_archs == other.m_archs; + } + + constexpr Version version() const { return m_version; } + constexpr bool containsArchitecture(utils::Architecture arch) const { return m_archs & arch; } + + int marketingVersion() const; + +private: + Version m_version; + utils::ArchitectureFlags m_archs; +}; + +inline auto qHash(const VersionInfo &info) +{ + return qHash(info.version().toString()); +} + +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_VERSION_INFO_H diff --git a/src/lib/corelib/generators/igeneratableprojectvisitor.h b/src/lib/corelib/generators/igeneratableprojectvisitor.h new file mode 100644 index 00000000..dbf73b4e --- /dev/null +++ b/src/lib/corelib/generators/igeneratableprojectvisitor.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef IGENERATABLEPROJECTVISITOR_H +#define IGENERATABLEPROJECTVISITOR_H + +#include "generatordata.h" + +namespace qbs { + +class IGeneratableProjectVisitor { +public: + virtual ~IGeneratableProjectVisitor() = default; + + // Collapsed configurations + virtual void visitProject(const GeneratableProject &project) { + Q_UNUSED(project); + } + + virtual void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &parentProjectData, + const GeneratableProjectData &projectData) { + Q_UNUSED(project); + Q_UNUSED(parentProjectData); + Q_UNUSED(projectData); + } + + virtual void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) { + Q_UNUSED(project); + Q_UNUSED(projectData); + } + + virtual void visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) { + Q_UNUSED(project); + Q_UNUSED(projectData); + Q_UNUSED(productData); + } + + // Expanded configurations + virtual void visitProject(const Project &project, const QString &configuration) { + Q_UNUSED(project); + Q_UNUSED(configuration); + } + + virtual void visitProjectData(const ProjectData &parentProjectData, + const ProjectData &projectData, + const QString &configuration) { + Q_UNUSED(parentProjectData); + Q_UNUSED(projectData); + Q_UNUSED(configuration); + } + + virtual void visitProjectData(const ProjectData &projectData, + const QString &configuration) { + Q_UNUSED(projectData); + Q_UNUSED(configuration); + } + + virtual void visitProduct(const ProductData &productData, + const QString &configuration) { + Q_UNUSED(productData); + Q_UNUSED(configuration); + } +}; + +} // namespace qbs + +#endif // IGENERATABLEPROJECTVISITOR_H diff --git a/src/lib/corelib/generators/ixmlnodevisitor.h b/src/lib/corelib/generators/ixmlnodevisitor.h new file mode 100644 index 00000000..278f4cf2 --- /dev/null +++ b/src/lib/corelib/generators/ixmlnodevisitor.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_INODE_VISITOR_H +#define GENERATORS_XML_INODE_VISITOR_H + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class Project; +class Property; +class PropertyGroup; +class Workspace; + +class QBS_EXPORT INodeVisitor +{ +public: + virtual ~INodeVisitor() = default; + + virtual void visitWorkspaceStart(const Workspace *workspace) { Q_UNUSED(workspace) } + virtual void visitWorkspaceEnd(const Workspace *workspace) { Q_UNUSED(workspace) } + + virtual void visitProjectStart(const Project *project) { Q_UNUSED(project) } + virtual void visitProjectEnd(const Project *project) { Q_UNUSED(project) } + + virtual void visitPropertyStart(const Property *property) = 0; + virtual void visitPropertyEnd(const Property *property) = 0; + + virtual void visitPropertyGroupStart(const PropertyGroup *propertyGroup) = 0; + virtual void visitPropertyGroupEnd(const PropertyGroup *propertyGroup) = 0; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_INODE_VISITOR_H diff --git a/src/lib/corelib/generators/xmlproject.cpp b/src/lib/corelib/generators/xmlproject.cpp new file mode 100644 index 00000000..e2ac951a --- /dev/null +++ b/src/lib/corelib/generators/xmlproject.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "xmlproject.h" +#include "ixmlnodevisitor.h" + +namespace qbs { +namespace gen { +namespace xml { + +void Project::accept(INodeVisitor *visitor) const +{ + visitor->visitProjectStart(this); + + for (const auto &child : children()) + child->accept(visitor); + + visitor->visitProjectEnd(this); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlproject.h b/src/lib/corelib/generators/xmlproject.h new file mode 100644 index 00000000..a7f5b2b6 --- /dev/null +++ b/src/lib/corelib/generators/xmlproject.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_PROJECT_H +#define GENERATORS_XML_PROJECT_H + +#include "xmlproperty.h" + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class QBS_EXPORT Project : public Property +{ +public: + void accept(INodeVisitor *visitor) const final; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_PROJECT_H diff --git a/src/lib/corelib/generators/xmlprojectwriter.cpp b/src/lib/corelib/generators/xmlprojectwriter.cpp new file mode 100644 index 00000000..190e1304 --- /dev/null +++ b/src/lib/corelib/generators/xmlprojectwriter.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "xmlproject.h" +#include "xmlprojectwriter.h" +#include "xmlproperty.h" +#include "xmlpropertygroup.h" + +#include +#include + +namespace qbs { +namespace gen { +namespace xml { + +ProjectWriter::ProjectWriter(std::ostream *device) + : m_device(device) +{ + m_writer = std::make_unique(&m_buffer); + m_writer->setAutoFormatting(true); +} + +bool ProjectWriter::write(const Project *project) +{ + m_buffer.clear(); + m_writer->writeStartDocument(); + project->accept(this); + m_writer->writeEndDocument(); + if (m_writer->hasError()) + return false; + m_device->write(&*std::begin(m_buffer), m_buffer.size()); + return m_device->good(); +} + +void ProjectWriter::visitPropertyStart(const Property *property) +{ + const auto value = property->value().toString(); + const auto name = QString::fromUtf8(property->name()); + m_writer->writeTextElement(name, value); +} + +void ProjectWriter::visitPropertyEnd(const Property *property) +{ + Q_UNUSED(property) +} + +void ProjectWriter::visitPropertyGroupStart(const PropertyGroup *propertyGroup) +{ + const auto name = QString::fromUtf8(propertyGroup->name()); + m_writer->writeStartElement(name); +} + +void ProjectWriter::visitPropertyGroupEnd(const PropertyGroup *propertyGroup) +{ + Q_UNUSED(propertyGroup) + m_writer->writeEndElement(); +} + +QXmlStreamWriter *ProjectWriter::writer() const +{ + return m_writer.get(); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlprojectwriter.h b/src/lib/corelib/generators/xmlprojectwriter.h new file mode 100644 index 00000000..8198de61 --- /dev/null +++ b/src/lib/corelib/generators/xmlprojectwriter.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_PROJECT_WRITER_H +#define GENERATORS_XML_PROJECT_WRITER_H + +#include "ixmlnodevisitor.h" + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class QBS_EXPORT ProjectWriter : public INodeVisitor +{ + Q_DISABLE_COPY(ProjectWriter) +public: + explicit ProjectWriter(std::ostream *device); + bool write(const Project *project); + +protected: + QXmlStreamWriter *writer() const; + +private: + void visitPropertyStart(const Property *property) final; + void visitPropertyEnd(const Property *property) final; + + void visitPropertyGroupStart(const PropertyGroup *propertyGroup) final; + void visitPropertyGroupEnd(const PropertyGroup *propertyGroup) final; + + std::ostream *m_device = nullptr; + QByteArray m_buffer; + std::unique_ptr m_writer; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_PROJECT_WRITER_H diff --git a/src/lib/corelib/generators/xmlproperty.cpp b/src/lib/corelib/generators/xmlproperty.cpp new file mode 100644 index 00000000..2fe5a014 --- /dev/null +++ b/src/lib/corelib/generators/xmlproperty.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ixmlnodevisitor.h" +#include "xmlproperty.h" + +namespace qbs { +namespace gen { +namespace xml { + +Property::Property(QByteArray name, QVariant value) +{ + setName(std::move(name)); + setValue(std::move(value)); +} + +void Property::accept(INodeVisitor *visitor) const +{ + visitor->visitPropertyStart(this); + + for (const auto &child : children()) + child->accept(visitor); + + visitor->visitPropertyEnd(this); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlproperty.h b/src/lib/corelib/generators/xmlproperty.h new file mode 100644 index 00000000..79573588 --- /dev/null +++ b/src/lib/corelib/generators/xmlproperty.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_PROPERTY_H +#define GENERATORS_XML_PROPERTY_H + +#include + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class INodeVisitor; + +class QBS_EXPORT Property +{ + Q_DISABLE_COPY(Property) +public: + Property() = default; + explicit Property(QByteArray name, QVariant value); + virtual ~Property() = default; + + QByteArray name() const { return m_name; } + void setName(QByteArray name) { m_name = std::move(name); } + + QVariant value() const { return m_value; } + void setValue(QVariant value) { m_value = std::move(value); } + + template + T *appendChild(std::unique_ptr child) { + const auto p = child.get(); + m_children.push_back(std::move(child)); + return p; + } + + template + T *appendChild(Args&&... args) { + return appendChild(std::make_unique(std::forward(args)...)); + } + + virtual void accept(INodeVisitor *visitor) const; + +protected: + const std::vector> &children() const + { return m_children; } + +private: + QByteArray m_name; + QVariant m_value; + std::vector> m_children; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_PROPERTY_H diff --git a/src/lib/corelib/generators/xmlpropertygroup.cpp b/src/lib/corelib/generators/xmlpropertygroup.cpp new file mode 100644 index 00000000..c9e6a97c --- /dev/null +++ b/src/lib/corelib/generators/xmlpropertygroup.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ixmlnodevisitor.h" +#include "xmlpropertygroup.h" + +namespace qbs { +namespace gen { +namespace xml { + +PropertyGroup::PropertyGroup(QByteArray name) +{ + setName(std::move(name)); +} + +void PropertyGroup::appendProperty(QByteArray name, QVariant value) +{ + appendChild(std::move(name), std::move(value)); +} + +void PropertyGroup::appendMultiLineProperty(QByteArray key, const QStringList &values, QChar sep) +{ + const auto line = values.join(sep); + appendProperty(std::move(key), QVariant::fromValue(line)); +} + +void PropertyGroup::accept(INodeVisitor *visitor) const +{ + visitor->visitPropertyGroupStart(this); + + for (const auto &child : children()) + child->accept(visitor); + + visitor->visitPropertyGroupEnd(this); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlpropertygroup.h b/src/lib/corelib/generators/xmlpropertygroup.h new file mode 100644 index 00000000..e7e051a8 --- /dev/null +++ b/src/lib/corelib/generators/xmlpropertygroup.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_PROPERTY_GROUP_H +#define GENERATORS_XML_PROPERTY_GROUP_H + +#include "generatorversioninfo.h" +#include "xmlproperty.h" + +#include + +#include + +namespace qbs { + +class ProductData; +class Project; + +namespace gen { +namespace xml { + +class QBS_EXPORT PropertyGroup : public Property +{ +public: + explicit PropertyGroup(QByteArray name); + + void appendProperty(QByteArray name, QVariant value); + void appendMultiLineProperty(QByteArray key, const QStringList &values, + QChar sep = QLatin1Char(',')); + + void accept(INodeVisitor *visitor) const final; +}; + +class PropertyGroupFactory +{ +public: + virtual ~PropertyGroupFactory() = default; + virtual bool canCreate(utils::Architecture arch, + const Version &version) const = 0; + + virtual std::unique_ptr create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const = 0; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_PROPERTY_GROUP_H diff --git a/src/lib/corelib/generators/xmlworkspace.cpp b/src/lib/corelib/generators/xmlworkspace.cpp new file mode 100644 index 00000000..7ce3f516 --- /dev/null +++ b/src/lib/corelib/generators/xmlworkspace.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "ixmlnodevisitor.h" +#include "xmlproperty.h" +#include "xmlpropertygroup.h" +#include "xmlworkspace.h" + +namespace qbs { +namespace gen { +namespace xml { + +Workspace::Workspace(const QString &workspacePath) + : m_baseDirectory(QFileInfo(workspacePath).absoluteDir()) +{ +} + +void Workspace::accept(INodeVisitor *visitor) const +{ + visitor->visitWorkspaceStart(this); + + for (const auto &child : children()) + child->accept(visitor); + + visitor->visitWorkspaceEnd(this); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlworkspace.h b/src/lib/corelib/generators/xmlworkspace.h new file mode 100644 index 00000000..beab22c4 --- /dev/null +++ b/src/lib/corelib/generators/xmlworkspace.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GENERATORS_XML_WWORKSPACE_H +#define GENERATORS_XML_WWORKSPACE_H + +#include "xmlproperty.h" + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class QBS_EXPORT Workspace : public Property +{ +public: + explicit Workspace(const QString &workspacePath); + void accept(INodeVisitor *visitor) const final; + + virtual void addProject(const QString &projectPath) = 0; + +protected: + const QDir m_baseDirectory; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_WWORKSPACE_H diff --git a/src/lib/corelib/generators/xmlworkspacewriter.cpp b/src/lib/corelib/generators/xmlworkspacewriter.cpp new file mode 100644 index 00000000..d21b63c4 --- /dev/null +++ b/src/lib/corelib/generators/xmlworkspacewriter.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "xmlproperty.h" +#include "xmlpropertygroup.h" +#include "xmlworkspace.h" +#include "xmlworkspacewriter.h" + +#include +#include + +namespace qbs { +namespace gen { +namespace xml { + +WorkspaceWriter::WorkspaceWriter(std::ostream *device) + : m_device(device) +{ + m_writer = std::make_unique(&m_buffer); + m_writer->setAutoFormatting(true); +} + +bool WorkspaceWriter::write(const Workspace *workspace) +{ + m_buffer.clear(); + m_writer->writeStartDocument(); + workspace->accept(this); + m_writer->writeEndDocument(); + if (m_writer->hasError()) + return false; + m_device->write(&*std::begin(m_buffer), m_buffer.size()); + return m_device->good(); +} + +void WorkspaceWriter::visitPropertyStart(const Property *property) +{ + const auto value = property->value().toString(); + const auto name = QString::fromUtf8(property->name()); + m_writer->writeTextElement(name, value); +} + +void WorkspaceWriter::visitPropertyEnd(const Property *property) +{ + Q_UNUSED(property) +} + +void WorkspaceWriter::visitPropertyGroupStart(const PropertyGroup *propertyGroup) +{ + const auto name = QString::fromUtf8(propertyGroup->name()); + m_writer->writeStartElement(name); +} + +void WorkspaceWriter::visitPropertyGroupEnd(const PropertyGroup *propertyGroup) +{ + Q_UNUSED(propertyGroup) + m_writer->writeEndElement(); +} + +QXmlStreamWriter *WorkspaceWriter::writer() const +{ + return m_writer.get(); +} + +} // namespace xml +} // namespace gen +} // namespace qbs diff --git a/src/lib/corelib/generators/xmlworkspacewriter.h b/src/lib/corelib/generators/xmlworkspacewriter.h new file mode 100644 index 00000000..343face5 --- /dev/null +++ b/src/lib/corelib/generators/xmlworkspacewriter.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORS_XML_WORKSPACE_WRITER_H +#define GENERATORS_XML_WORKSPACE_WRITER_H + +#include "ixmlnodevisitor.h" + +#include + +#include + +namespace qbs { +namespace gen { +namespace xml { + +class QBS_EXPORT WorkspaceWriter : public INodeVisitor +{ + Q_DISABLE_COPY(WorkspaceWriter) +public: + explicit WorkspaceWriter(std::ostream *device); + bool write(const Workspace *workspace); + +protected: + QXmlStreamWriter *writer() const; + +private: + void visitPropertyStart(const Property *property) final; + void visitPropertyEnd(const Property *property) final; + + void visitPropertyGroupStart(const PropertyGroup *propertyGroup) final; + void visitPropertyGroupEnd(const PropertyGroup *propertyGroup) final; + + std::ostream *m_device = nullptr; + QByteArray m_buffer; + std::unique_ptr m_writer; +}; + +} // namespace xml +} // namespace gen +} // namespace qbs + +#endif // GENERATORS_XML_WORKSPACE_WRITER_H diff --git a/src/lib/corelib/jsextensions/binaryfile.cpp b/src/lib/corelib/jsextensions/binaryfile.cpp new file mode 100644 index 00000000..3731c4da --- /dev/null +++ b/src/lib/corelib/jsextensions/binaryfile.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Sergey Belyashov +** Copyright (C) 2017 Denis Shienkov +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +class BinaryFile : public QObject, public QScriptable, public ResourceAcquiringScriptObject +{ + Q_OBJECT +public: + enum OpenMode { + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = ReadOnly | WriteOnly + }; + Q_ENUM(OpenMode) + + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + + Q_INVOKABLE void close(); + Q_INVOKABLE QString filePath(); + Q_INVOKABLE bool atEof() const; + Q_INVOKABLE qint64 size() const; + Q_INVOKABLE void resize(qint64 size); + Q_INVOKABLE qint64 pos() const; + Q_INVOKABLE void seek(qint64 pos); + Q_INVOKABLE QVariantList read(qint64 size); + Q_INVOKABLE void write(const QVariantList &data); + +private: + explicit BinaryFile(QScriptContext *context, const QString &filePath, OpenMode mode = ReadOnly); + + bool checkForClosed() const; + + // ResourceAcquiringScriptObject implementation + void releaseResources() override; + + std::unique_ptr m_file; +}; + +QScriptValue BinaryFile::ctor(QScriptContext *context, QScriptEngine *engine) +{ + BinaryFile *t = nullptr; + switch (context->argumentCount()) { + case 0: + return context->throwError(Tr::tr("BinaryFile constructor needs " + "path of file to be opened.")); + case 1: + t = new BinaryFile(context, context->argument(0).toString()); + break; + case 2: + t = new BinaryFile(context, + context->argument(0).toString(), + static_cast(context->argument(1).toInt32())); + break; + default: + return context->throwError(Tr::tr("BinaryFile constructor takes at most two parameters.")); + } + + const auto se = static_cast(engine); + se->addResourceAcquiringScriptObject(t); + const DubiousContextList dubiousContexts { + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }; + se->checkContext(QStringLiteral("qbs.BinaryFile"), dubiousContexts); + se->setUsesIo(); + + return engine->newQObject(t, QScriptEngine::QtOwnership); +} + +BinaryFile::BinaryFile(QScriptContext *context, const QString &filePath, OpenMode mode) +{ + Q_ASSERT(thisObject().engine() == engine()); + + QIODevice::OpenMode m = QIODevice::NotOpen; + switch (mode) { + case ReadWrite: + m = QIODevice::ReadWrite; + break; + case ReadOnly: + m = QIODevice::ReadOnly; + break; + case WriteOnly: + m = QIODevice::WriteOnly; + break; + default: + context->throwError(Tr::tr("Unable to open file '%1': Undefined mode '%2'") + .arg(filePath, mode)); + return; + } + + m_file = std::make_unique(filePath); + if (Q_UNLIKELY(!m_file->open(m))) { + context->throwError(Tr::tr("Unable to open file '%1': %2") + .arg(filePath, m_file->errorString())); + m_file.reset(); + } +} + +void BinaryFile::close() +{ + if (checkForClosed()) + return; + m_file->close(); + m_file.reset(); +} + +QString BinaryFile::filePath() +{ + if (checkForClosed()) + return {}; + return QFileInfo(*m_file).absoluteFilePath(); +} + +bool BinaryFile::atEof() const +{ + if (checkForClosed()) + return true; + return m_file->atEnd(); +} + +qint64 BinaryFile::size() const +{ + if (checkForClosed()) + return -1; + return m_file->size(); +} + +void BinaryFile::resize(qint64 size) +{ + if (checkForClosed()) + return; + if (Q_UNLIKELY(!m_file->resize(size))) { + context()->throwError(Tr::tr("Could not resize '%1': %2") + .arg(m_file->fileName(), m_file->errorString())); + } +} + +qint64 BinaryFile::pos() const +{ + if (checkForClosed()) + return -1; + return m_file->pos(); +} + +void BinaryFile::seek(qint64 pos) +{ + if (checkForClosed()) + return; + if (Q_UNLIKELY(!m_file->seek(pos))) { + context()->throwError(Tr::tr("Could not seek '%1': %2") + .arg(m_file->fileName(), m_file->errorString())); + } +} + +QVariantList BinaryFile::read(qint64 size) +{ + if (checkForClosed()) + return {}; + const QByteArray bytes = m_file->read(size); + if (Q_UNLIKELY(bytes.size() == 0 && m_file->error() != QFile::NoError)) { + context()->throwError(Tr::tr("Could not read from '%1': %2") + .arg(m_file->fileName(), m_file->errorString())); + } + + return transformed(bytes, [](const char &c) { return c; }); +} + +void BinaryFile::write(const QVariantList &data) +{ + if (checkForClosed()) + return; + + const auto bytes = transformed(data, [](const QVariant &v) { + return char(v.toUInt() & 0xFF); }); + + const qint64 size = m_file->write(bytes); + if (Q_UNLIKELY(size == -1)) { + context()->throwError(Tr::tr("Could not write to '%1': %2") + .arg(m_file->fileName(), m_file->errorString())); + } +} + +bool BinaryFile::checkForClosed() const +{ + if (m_file) + return false; + if (QScriptContext *ctx = context()) + ctx->throwError(Tr::tr("Access to BinaryFile object that was already closed.")); + return true; +} + +void BinaryFile::releaseResources() +{ + close(); + deleteLater(); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionBinaryFile(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + const QScriptValue obj = engine->newQMetaObject(&BinaryFile::staticMetaObject, + engine->newFunction(&BinaryFile::ctor)); + extensionObject.setProperty(QStringLiteral("BinaryFile"), obj); +} + +Q_DECLARE_METATYPE(qbs::Internal::BinaryFile *) + +#include "binaryfile.moc" diff --git a/src/lib/corelib/jsextensions/domxml.cpp b/src/lib/corelib/jsextensions/domxml.cpp new file mode 100644 index 00000000..86e1574c --- /dev/null +++ b/src/lib/corelib/jsextensions/domxml.cpp @@ -0,0 +1,465 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 BogDan Vatra +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class XmlDomDocument; + +class XmlDomNode: public QObject, public QScriptable +{ + Q_OBJECT +public: + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + + Q_INVOKABLE bool isElement() const; + Q_INVOKABLE bool isCDATASection() const; + Q_INVOKABLE bool isText() const; + + Q_INVOKABLE QString attribute(const QString & name, const QString & defValue = QString()); + Q_INVOKABLE void setAttribute(const QString & name, const QString & value); + Q_INVOKABLE bool hasAttribute(const QString & name) const; + Q_INVOKABLE QString tagName() const; + Q_INVOKABLE void setTagName(const QString & name); + + Q_INVOKABLE QString text() const; + + Q_INVOKABLE QString data() const; + Q_INVOKABLE void setData(const QString &v) const; + + Q_INVOKABLE void clear(); + Q_INVOKABLE bool hasAttributes() const; + Q_INVOKABLE bool hasChildNodes() const; + Q_INVOKABLE QScriptValue parentNode() const; + Q_INVOKABLE QScriptValue firstChild(const QString & tagName = QString()); + Q_INVOKABLE QScriptValue lastChild(const QString & tagName = QString()) const; + Q_INVOKABLE QScriptValue previousSibling(const QString & tagName = QString()) const; + Q_INVOKABLE QScriptValue nextSibling(const QString & tagName = QString()) const; + + Q_INVOKABLE QScriptValue appendChild(const QScriptValue &newChild); + Q_INVOKABLE QScriptValue insertBefore(const QScriptValue& newChild, const QScriptValue& refChild); + Q_INVOKABLE QScriptValue insertAfter(const QScriptValue& newChild, const QScriptValue& refChild); + Q_INVOKABLE QScriptValue replaceChild(const QScriptValue& newChild, const QScriptValue& oldChild); + Q_INVOKABLE QScriptValue removeChild(const QScriptValue& oldChild); + +protected: + friend class XmlDomDocument; + XmlDomNode(const QDomNode &other = QDomNode()); + QDomNode m_domNode; +}; + +class XmlDomDocument: public XmlDomNode +{ + Q_OBJECT +public: + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + Q_INVOKABLE QScriptValue documentElement(); + Q_INVOKABLE QScriptValue createElement(const QString & tagName); + Q_INVOKABLE QScriptValue createCDATASection(const QString & value); + Q_INVOKABLE QScriptValue createTextNode(const QString & value); + + Q_INVOKABLE bool setContent(const QString & content); + Q_INVOKABLE QString toString(int indent = 1); + + Q_INVOKABLE void save(const QString & filePath, int indent = 1); + Q_INVOKABLE void load(const QString & filePath); + +protected: + XmlDomDocument(QScriptContext *context, const QString &name = QString()); + +private: + QDomDocument m_domDocument; +}; + +QScriptValue XmlDomDocument::ctor(QScriptContext *context, QScriptEngine *engine) +{ + XmlDomDocument *xml = nullptr; + switch (context->argumentCount()) { + case 0: + xml = new XmlDomDocument(context); + break; + case 1: + xml = new XmlDomDocument(context, context->argument(0).toString()); + break; + default: + return context->throwError(QStringLiteral("DomXml(QString file = QLatin1String(\"\"))")); + } + QScriptValue obj = engine->newQObject(xml, QScriptEngine::ScriptOwnership); + static_cast(engine)->setUsesIo(); + return obj; +} + +QScriptValue XmlDomDocument::documentElement() +{ + return engine()->newQObject(new XmlDomNode(m_domDocument.documentElement()), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomDocument::createElement(const QString &tagName) +{ + return engine()->newQObject(new XmlDomNode(m_domDocument.createElement(tagName)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomDocument::createCDATASection(const QString &value) +{ + return engine()->newQObject(new XmlDomNode(m_domDocument.createCDATASection(value)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomDocument::createTextNode(const QString &value) +{ + return engine()->newQObject(new XmlDomNode(m_domDocument.createTextNode(value)), QScriptEngine::ScriptOwnership); +} + +bool XmlDomDocument::setContent(const QString &content) +{ + return m_domDocument.setContent(content); +} + +QString XmlDomDocument::toString(int indent) +{ + return m_domDocument.toString(indent); +} + +void XmlDomDocument::save(const QString &filePath, int indent) +{ + QFile f(filePath); + if (!f.open(QIODevice::WriteOnly)) { + context()->throwError(QStringLiteral("unable to open '%1'") + .arg(filePath)); + return; + } + + QByteArray buff(m_domDocument.toByteArray(indent)); + if (buff.size() != f.write(buff)) + { + context()->throwError(f.errorString()); + f.close(); + return; + } + + f.close(); + if (f.error() != QFile::NoError) + context()->throwError(f.errorString()); +} + +void XmlDomDocument::load(const QString &filePath) +{ + QFile f(filePath); + if (!f.open(QIODevice::ReadOnly)) { + context()->throwError(QStringLiteral("unable to open '%1'") + .arg(filePath)); + return; + } + + QString errorMsg; + if (!m_domDocument.setContent(&f, &errorMsg)) { + context()->throwError(errorMsg); + return; + } +} + +XmlDomDocument::XmlDomDocument(QScriptContext *context, const QString &name):m_domDocument(name) +{ + Q_UNUSED(context) + m_domNode = m_domDocument; +} + +QScriptValue XmlDomNode::ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context) + return engine->newQObject(new XmlDomNode(), QScriptEngine::ScriptOwnership); +} + +bool XmlDomNode::isElement() const +{ + return m_domNode.isElement(); +} + +bool XmlDomNode::isCDATASection() const +{ + return m_domNode.isCDATASection(); +} + +bool XmlDomNode::isText() const +{ + return m_domNode.isText(); +} + +QString XmlDomNode::attribute(const QString &name, const QString &defValue) +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return defValue; + } + return el.attribute(name, defValue); +} + +void XmlDomNode::setAttribute(const QString &name, const QString &value) +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return; + } + el.setAttribute(name, value); +} + +bool XmlDomNode::hasAttribute(const QString &name) const +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return false; + } + return el.hasAttribute(name); +} + +QString XmlDomNode::tagName() const +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return {}; + } + return el.tagName(); +} + +void XmlDomNode::setTagName(const QString &name) +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return; + } + el.setTagName(name); +} + +QString XmlDomNode::text() const +{ + QDomElement el = m_domNode.toElement(); + if (el.isNull()) { + context()->throwError(QStringLiteral("Node '%1' is not an element node").arg(m_domNode.nodeName())); + return {}; + } + return el.text(); +} + +QString XmlDomNode::data() const +{ + if (m_domNode.isText()) + return m_domNode.toText().data(); + if (m_domNode.isCDATASection()) + return m_domNode.toCDATASection().data(); + if (m_domNode.isCharacterData()) + return m_domNode.toCharacterData().data(); + context()->throwError(QStringLiteral("Node '%1' is not a character data node").arg(m_domNode.nodeName())); + return {}; +} + +void XmlDomNode::setData(const QString &v) const +{ + if (m_domNode.isText()) + return m_domNode.toText().setData(v); + if (m_domNode.isCDATASection()) + return m_domNode.toCDATASection().setData(v); + if (m_domNode.isCharacterData()) + return m_domNode.toCharacterData().setData(v); + context()->throwError(QStringLiteral("Node '%1' is not a character data node").arg(m_domNode.nodeName())); +} + +void XmlDomNode::clear() +{ + m_domNode.clear(); +} + +bool XmlDomNode::hasAttributes() const +{ + return m_domNode.hasAttributes(); +} + +bool XmlDomNode::hasChildNodes() const +{ + return m_domNode.hasChildNodes(); +} + +QScriptValue XmlDomNode::parentNode() const +{ + return engine()->newQObject(new XmlDomNode(m_domNode.parentNode()), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::firstChild(const QString &tagName) +{ + if (tagName.isEmpty()) + return engine()->newQObject(new XmlDomNode(m_domNode.firstChild()), QScriptEngine::ScriptOwnership); + return engine()->newQObject(new XmlDomNode(m_domNode.firstChildElement(tagName)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::lastChild(const QString &tagName) const +{ + if (tagName.isEmpty()) + return engine()->newQObject(new XmlDomNode(m_domNode.lastChild()), QScriptEngine::ScriptOwnership); + return engine()->newQObject(new XmlDomNode(m_domNode.lastChildElement(tagName)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::previousSibling(const QString &tagName) const +{ + if (tagName.isEmpty()) + return engine()->newQObject(new XmlDomNode(m_domNode.previousSibling()), QScriptEngine::ScriptOwnership); + return engine()->newQObject(new XmlDomNode(m_domNode.previousSiblingElement(tagName)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::nextSibling(const QString &tagName) const +{ + if (tagName.isEmpty()) + return engine()->newQObject(new XmlDomNode(m_domNode.nextSibling()), QScriptEngine::ScriptOwnership); + return engine()->newQObject(new XmlDomNode(m_domNode.nextSiblingElement(tagName)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::appendChild(const QScriptValue &newChild) +{ + auto newNode = qobject_cast(newChild.toQObject()); + if (!newNode) { + context()->throwError(QStringLiteral("First argument is not a XmlDomNode object")); + return {}; + } + return engine()->newQObject(new XmlDomNode(m_domNode.appendChild(newNode->m_domNode)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::insertBefore(const QScriptValue &newChild, const QScriptValue &refChild) +{ + auto newNode = qobject_cast(newChild.toQObject()); + if (!newNode) { + context()->throwError(QStringLiteral("First argument is not a XmlDomNode object")); + return {}; + } + + auto refNode = qobject_cast(refChild.toQObject()); + if (!refNode) { + context()->throwError(QStringLiteral("Second argument is not a XmlDomNode object")); + return {}; + } + + return engine()->newQObject(new XmlDomNode(m_domNode.insertBefore(newNode->m_domNode, refNode->m_domNode)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::insertAfter(const QScriptValue &newChild, const QScriptValue &refChild) +{ + auto newNode = qobject_cast(newChild.toQObject()); + if (!newNode) { + context()->throwError(QStringLiteral("First argument is not a XmlDomNode object")); + return {}; + } + + auto refNode = qobject_cast(refChild.toQObject()); + if (!refNode) { + context()->throwError(QStringLiteral("Second argument is not a XmlDomNode object")); + return {}; + } + + return engine()->newQObject(new XmlDomNode(m_domNode.insertAfter(newNode->m_domNode, refNode->m_domNode)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::replaceChild(const QScriptValue &newChild, const QScriptValue &oldChild) +{ + auto newNode = qobject_cast(newChild.toQObject()); + if (!newNode) { + context()->throwError(QStringLiteral("First argument is not a XmlDomNode object")); + return {}; + } + + auto oldNode = qobject_cast(oldChild.toQObject()); + if (!oldNode) { + context()->throwError(QStringLiteral("Second argument is not a XmlDomNode object")); + return {}; + } + + return engine()->newQObject(new XmlDomNode(m_domNode.replaceChild(newNode->m_domNode, oldNode->m_domNode)), QScriptEngine::ScriptOwnership); +} + +QScriptValue XmlDomNode::removeChild(const QScriptValue &oldChild) +{ + auto oldNode = qobject_cast(oldChild.toQObject()); + if (!oldNode) { + context()->throwError(QStringLiteral("First argument is not a XmlDomNode object")); + return {}; + } + + return engine()->newQObject(new XmlDomNode(m_domNode.removeChild(oldNode->m_domNode)), QScriptEngine::ScriptOwnership); +} + +XmlDomNode::XmlDomNode(const QDomNode &other) +{ + m_domNode = other; +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionXml(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue docObj = engine->newQMetaObject(&XmlDomDocument::staticMetaObject, + engine->newFunction(&XmlDomDocument::ctor)); + QScriptValue nodeObj = engine->newQMetaObject(&XmlDomNode::staticMetaObject, + engine->newFunction(&XmlDomNode::ctor)); + QScriptValue contextObject = engine->newObject(); + contextObject.setProperty(QStringLiteral("DomDocument"), docObj); + contextObject.setProperty(QStringLiteral("DomElement"), nodeObj); + + extensionObject.setProperty(QStringLiteral("Xml"), contextObject); +} + +Q_DECLARE_METATYPE(qbs::Internal::XmlDomDocument *) +Q_DECLARE_METATYPE(qbs::Internal::XmlDomNode *) + +#include "domxml.moc" diff --git a/src/lib/corelib/jsextensions/environmentextension.cpp b/src/lib/corelib/jsextensions/environmentextension.cpp new file mode 100644 index 00000000..cf17c938 --- /dev/null +++ b/src/lib/corelib/jsextensions/environmentextension.cpp @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class EnvironmentExtension : public QObject, QScriptable +{ + Q_OBJECT +public: + void initializeJsExtensionEnvironment(QScriptValue extensionObject); + static QScriptValue js_ctor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_getEnv(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_putEnv(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_unsetEnv(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_currentEnv(QScriptContext *context, QScriptEngine *engine); +}; + +QScriptValue EnvironmentExtension::js_ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + return context->throwError(Tr::tr("'Environment' cannot be instantiated.")); +} + +static QProcessEnvironment *getProcessEnvironment(QScriptContext *context, QScriptEngine *engine, + const QString &func, bool doThrow = true) +{ + QVariant v = engine->property(StringConstants::qbsProcEnvVarInternal()); + auto procenv = reinterpret_cast(v.value()); + if (!procenv && doThrow) + throw context->throwError(QScriptContext::UnknownError, + QStringLiteral("%1 can only be called from ").arg(func) + + QStringLiteral("Module.setupBuildEnvironment and ") + + QStringLiteral("Module.setupRunEnvironment")); + return procenv; +} + +QScriptValue EnvironmentExtension::js_getEnv(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("getEnv expects 1 argument")); + const QProcessEnvironment env = static_cast(engine)->environment(); + const QProcessEnvironment *procenv = getProcessEnvironment(context, engine, + QStringLiteral("getEnv"), false); + if (!procenv) + procenv = &env; + + const QString name = context->argument(0).toString(); + const QString value = procenv->value(name); + return value.isNull() ? engine->undefinedValue() : value; +} + +QScriptValue EnvironmentExtension::js_putEnv(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() != 2)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("putEnv expects 2 arguments")); + getProcessEnvironment(context, engine, QStringLiteral("putEnv"))->insert( + context->argument(0).toString(), + context->argument(1).toString()); + return engine->undefinedValue(); +} + +QScriptValue EnvironmentExtension::js_unsetEnv(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("unsetEnv expects 1 argument")); + getProcessEnvironment(context, engine, QStringLiteral("unsetEnv"))->remove( + context->argument(0).toString()); + return engine->undefinedValue(); +} + +QScriptValue EnvironmentExtension::js_currentEnv(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + const QProcessEnvironment env = static_cast(engine)->environment(); + const QProcessEnvironment *procenv = getProcessEnvironment(context, engine, + QStringLiteral("currentEnv"), false); + if (!procenv) + procenv = &env; + QScriptValue envObject = engine->newObject(); + const auto keys = procenv->keys(); + for (const QString &key : keys) { + const QString keyName = HostOsInfo::isWindowsHost() ? key.toUpper() : key; + envObject.setProperty(keyName, QScriptValue(procenv->value(key))); + } + return envObject; +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionEnvironment(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue environmentObj = engine->newQMetaObject(&EnvironmentExtension::staticMetaObject, + engine->newFunction(&EnvironmentExtension::js_ctor)); + environmentObj.setProperty(QStringLiteral("getEnv"), + engine->newFunction(EnvironmentExtension::js_getEnv, 1)); + environmentObj.setProperty(QStringLiteral("putEnv"), + engine->newFunction(EnvironmentExtension::js_putEnv, 2)); + environmentObj.setProperty(QStringLiteral("unsetEnv"), + engine->newFunction(EnvironmentExtension::js_unsetEnv, 1)); + environmentObj.setProperty(QStringLiteral("currentEnv"), + engine->newFunction(EnvironmentExtension::js_currentEnv, 0)); + extensionObject.setProperty(QStringLiteral("Environment"), environmentObj); +} + +Q_DECLARE_METATYPE(qbs::Internal::EnvironmentExtension *) + +#include "environmentextension.moc" diff --git a/src/lib/corelib/jsextensions/file.cpp b/src/lib/corelib/jsextensions/file.cpp new file mode 100644 index 00000000..cddf2ffa --- /dev/null +++ b/src/lib/corelib/jsextensions/file.cpp @@ -0,0 +1,290 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class File : public QObject, QScriptable +{ + Q_OBJECT +public: + enum Filter { + Dirs = 0x001, + Files = 0x002, + Drives = 0x004, + NoSymLinks = 0x008, + AllEntries = Dirs | Files | Drives, + TypeMask = 0x00f, + + Readable = 0x010, + Writable = 0x020, + Executable = 0x040, + PermissionMask = 0x070, + + Modified = 0x080, + Hidden = 0x100, + System = 0x200, + + AccessMask = 0x3F0, + + AllDirs = 0x400, + CaseSensitive = 0x800, + NoDot = 0x2000, + NoDotDot = 0x4000, + NoDotAndDotDot = NoDot | NoDotDot, + + NoFilter = -1 + }; + Q_DECLARE_FLAGS(Filters, Filter) + Q_ENUM(Filter) + + static QScriptValue js_ctor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_copy(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_exists(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_directoryEntries(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_lastModified(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_makePath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_move(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_remove(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_canonicalFilePath(QScriptContext *context, QScriptEngine *engine); +}; + +QScriptValue File::js_ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + return context->throwError(Tr::tr("'File' cannot be instantiated.")); +} + +QScriptValue File::js_copy(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 2)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("copy expects 2 arguments")); + } + + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ + DubiousContext(EvalContext::PropertyEvaluation), + DubiousContext(EvalContext::RuleExecution, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("File.copy()"), dubiousContexts); + + const QString sourceFile = context->argument(0).toString(); + const QString targetFile = context->argument(1).toString(); + QString errorMessage; + if (Q_UNLIKELY(!copyFileRecursion(sourceFile, targetFile, true, true, &errorMessage))) + return context->throwError(errorMessage); + return true; +} + +QScriptValue File::js_exists(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("exist expects 1 argument")); + } + const QString filePath = context->argument(0).toString(); + const bool exists = FileInfo::exists(filePath); + const auto se = static_cast(engine); + se->addFileExistsResult(filePath, exists); + return exists; +} + +QScriptValue File::js_directoryEntries(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 2)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("directoryEntries expects 2 arguments")); + } + + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("File.directoryEntries()"), dubiousContexts); + + const QString path = context->argument(0).toString(); + const auto filters = static_cast(context->argument(1).toUInt32()); + QDir dir(path); + const QStringList entries = dir.entryList(filters, QDir::Name); + se->addDirectoryEntriesResult(path, filters, entries); + return qScriptValueFromSequence(engine, entries); +} + +QScriptValue File::js_remove(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("remove expects 1 argument")); + } + + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) }); + se->checkContext(QStringLiteral("File.remove()"), dubiousContexts); + + QString fileName = context->argument(0).toString(); + + QString errorMessage; + if (Q_UNLIKELY(!removeFileRecursion(QFileInfo(fileName), &errorMessage))) + return context->throwError(errorMessage); + return true; +} + +QScriptValue File::js_lastModified(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("File.lastModified() expects an argument")); + } + const QString filePath = context->argument(0).toString(); + const FileTime timestamp = FileInfo(filePath).lastModified(); + const auto se = static_cast(engine); + se->addFileLastModifiedResult(filePath, timestamp); + return timestamp.asDouble(); +} + +QScriptValue File::js_makePath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("makePath expects 1 argument")); + } + + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) }); + se->checkContext(QStringLiteral("File.makePath()"), dubiousContexts); + + return QDir::root().mkpath(context->argument(0).toString()); +} + +QScriptValue File::js_move(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 2)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("move expects 2 arguments")); + } + + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ DubiousContext(EvalContext::PropertyEvaluation) }); + se->checkContext(QStringLiteral("File.move()"), dubiousContexts); + + const QString sourceFile = context->argument(0).toString(); + const QString targetFile = context->argument(1).toString(); + const bool overwrite = context->argumentCount() > 2 ? context->argument(2).toBool() : true; + + if (Q_UNLIKELY(QFileInfo(sourceFile).isDir())) + return context->throwError(QStringLiteral("Could not move '%1' to '%2': " + "Source file path is a directory.") + .arg(sourceFile, targetFile)); + + if (Q_UNLIKELY(QFileInfo(targetFile).isDir())) { + return context->throwError(QStringLiteral("Could not move '%1' to '%2': " + "Destination file path is a directory.") + .arg(sourceFile, targetFile)); + } + + QFile f(targetFile); + if (overwrite && f.exists() && !f.remove()) + return context->throwError(QStringLiteral("Could not move '%1' to '%2': %3") + .arg(sourceFile, targetFile, f.errorString())); + + if (QFile::exists(targetFile)) + return context->throwError(QStringLiteral("Could not move '%1' to '%2': " + "Destination file exists.") + .arg(sourceFile, targetFile)); + + QFile f2(sourceFile); + if (Q_UNLIKELY(!f2.rename(targetFile))) + return context->throwError(QStringLiteral("Could not move '%1' to '%2': %3") + .arg(sourceFile, targetFile, f2.errorString())); + return true; +} + +QScriptValue File::js_canonicalFilePath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("canonicalFilePath expects 1 argument")); + } + return QFileInfo(context->argument(0).toString()).canonicalFilePath(); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionFile(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue fileObj = engine->newQMetaObject(&File::staticMetaObject, + engine->newFunction(&File::js_ctor)); + fileObj.setProperty(QStringLiteral("copy"), engine->newFunction(File::js_copy)); + fileObj.setProperty(QStringLiteral("exists"), engine->newFunction(File::js_exists)); + fileObj.setProperty(QStringLiteral("directoryEntries"), + engine->newFunction(File::js_directoryEntries)); + fileObj.setProperty(QStringLiteral("lastModified"), engine->newFunction(File::js_lastModified)); + fileObj.setProperty(QStringLiteral("makePath"), engine->newFunction(File::js_makePath)); + fileObj.setProperty(QStringLiteral("move"), engine->newFunction(File::js_move)); + fileObj.setProperty(QStringLiteral("remove"), engine->newFunction(File::js_remove)); + fileObj.setProperty(QStringLiteral("canonicalFilePath"), + engine->newFunction(File::js_canonicalFilePath)); + extensionObject.setProperty(QStringLiteral("File"), fileObj); +} + +Q_DECLARE_METATYPE(qbs::Internal::File *) + +#include "file.moc" diff --git a/src/lib/corelib/jsextensions/fileinfoextension.cpp b/src/lib/corelib/jsextensions/fileinfoextension.cpp new file mode 100644 index 00000000..a69dbc62 --- /dev/null +++ b/src/lib/corelib/jsextensions/fileinfoextension.cpp @@ -0,0 +1,350 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +// removes duplicate separators from the path +static QString uniqueSeparators(QString path) +{ + const auto it = std::unique(path.begin(), path.end(), [](QChar c1, QChar c2) { + return c1 == c2 && c1 == QLatin1Char('/'); + }); + path.resize(int(it - path.begin())); + return path; +} + +class FileInfoExtension : public QObject, QScriptable +{ + Q_OBJECT +public: + static QScriptValue js_ctor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_path(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_fileName(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_baseName(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_suffix(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_completeSuffix(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_canonicalPath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_cleanPath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_completeBaseName(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_relativePath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_resolvePath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_isAbsolutePath(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_toWindowsSeparators(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_fromWindowsSeparators(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_toNativeSeparators(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_fromNativeSeparators(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_joinPaths(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_pathListSeparator(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_pathSeparator(QScriptContext *context, QScriptEngine *engine); +}; + +QScriptValue FileInfoExtension::js_ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + return context->throwError(Tr::tr("'FileInfo' cannot be instantiated.")); +} + +QScriptValue FileInfoExtension::js_path(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("path expects 1 argument")); + } + HostOsInfo::HostOs hostOs = HostOsInfo::hostOs(); + if (context->argumentCount() > 1) { + hostOs = context->argument(1).toVariant().toStringList().contains(QLatin1String("windows")) + ? HostOsInfo::HostOsWindows : HostOsInfo::HostOsOtherUnix; + } + return FileInfo::path(context->argument(0).toString(), hostOs); +} + +QScriptValue FileInfoExtension::js_fileName(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("fileName expects 1 argument")); + } + return FileInfo::fileName(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_baseName(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("baseName expects 1 argument")); + } + return FileInfo::baseName(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_suffix(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("suffix expects 1 argument")); + } + return FileInfo::suffix(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_completeSuffix(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("completeSuffix expects 1 argument")); + } + return FileInfo::completeSuffix(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_canonicalPath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("canonicalPath expects 1 argument")); + } + return QFileInfo(context->argument(0).toString()).canonicalFilePath(); +} + +QScriptValue FileInfoExtension::js_cleanPath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("cleanPath expects 1 argument")); + } + return QDir::cleanPath(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_completeBaseName(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("completeBaseName expects 1 argument")); + } + return FileInfo::completeBaseName(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_relativePath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("relativePath expects 2 arguments")); + } + const QString baseDir = context->argument(0).toString(); + const QString filePath = context->argument(1).toString(); + if (!FileInfo::isAbsolute(baseDir)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("FileInfo.relativePath() expects an absolute path as " + "its first argument, but it is '%1'.").arg(baseDir)); + } + if (!FileInfo::isAbsolute(filePath)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("FileInfo.relativePath() expects an absolute path as " + "its second argument, but it is '%1'.").arg(filePath)); + } + return QDir(baseDir).relativeFilePath(filePath); +} + +QScriptValue FileInfoExtension::js_resolvePath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("resolvePath expects 2 arguments")); + } + const QString base = context->argument(0).toString(); + const QString rel = context->argument(1).toString(); + return FileInfo::resolvePath(base, rel); +} + +QScriptValue FileInfoExtension::js_isAbsolutePath(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("isAbsolutePath expects 1 argument")); + } + HostOsInfo::HostOs hostOs = HostOsInfo::hostOs(); + if (context->argumentCount() > 1) { + hostOs = context->argument(1).toVariant().toStringList().contains(QLatin1String("windows")) + ? HostOsInfo::HostOsWindows : HostOsInfo::HostOsOtherUnix; + } + return FileInfo::isAbsolute(context->argument(0).toString(), hostOs); +} + +QScriptValue FileInfoExtension::js_toWindowsSeparators(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("toWindowsSeparators expects 1 argument")); + } + return context->argument(0).toString().replace(QLatin1Char('/'), QLatin1Char('\\')); +} + +QScriptValue FileInfoExtension::js_fromWindowsSeparators(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("fromWindowsSeparators expects 1 argument")); + } + return context->argument(0).toString().replace(QLatin1Char('\\'), QLatin1Char('/')); +} + +QScriptValue FileInfoExtension::js_toNativeSeparators(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("toNativeSeparators expects 1 argument")); + } + return QDir::toNativeSeparators(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_fromNativeSeparators(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("fromNativeSeparators expects 1 argument")); + } + return QDir::fromNativeSeparators(context->argument(0).toString()); +} + +QScriptValue FileInfoExtension::js_joinPaths(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + QStringList paths; + for (int i = 0; i < context->argumentCount(); ++i) { + const QScriptValue value = context->argument(i); + if (!value.isUndefined() && !value.isNull()) { + const QString arg = value.toString(); + if (!arg.isEmpty()) + paths.push_back(arg); + } + } + return engine->toScriptValue(uniqueSeparators(paths.join(QLatin1Char('/')))); +} + +QScriptValue FileInfoExtension::js_pathListSeparator(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + return QString(HostOsInfo::pathListSeparator()); +} + +QScriptValue FileInfoExtension::js_pathSeparator(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + return QString(HostOsInfo::pathSeparator()); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionFileInfo(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue fileInfoObj = engine->newQMetaObject(&FileInfoExtension::staticMetaObject, + engine->newFunction(&FileInfoExtension::js_ctor)); + fileInfoObj.setProperty(StringConstants::fileInfoPath(), + engine->newFunction(FileInfoExtension::js_path)); + fileInfoObj.setProperty(StringConstants::fileInfoFileName(), + engine->newFunction(FileInfoExtension::js_fileName)); + fileInfoObj.setProperty(StringConstants::baseNameProperty(), + engine->newFunction(FileInfoExtension::js_baseName)); + fileInfoObj.setProperty(QStringLiteral("suffix"), + engine->newFunction(FileInfoExtension::js_suffix)); + fileInfoObj.setProperty(QStringLiteral("completeSuffix"), + engine->newFunction(FileInfoExtension::js_completeSuffix)); + fileInfoObj.setProperty(QStringLiteral("canonicalPath"), + engine->newFunction(FileInfoExtension::js_canonicalPath)); + fileInfoObj.setProperty(QStringLiteral("cleanPath"), + engine->newFunction(FileInfoExtension::js_cleanPath)); + fileInfoObj.setProperty(StringConstants::completeBaseNameProperty(), + engine->newFunction(FileInfoExtension::js_completeBaseName)); + fileInfoObj.setProperty(QStringLiteral("relativePath"), + engine->newFunction(FileInfoExtension::js_relativePath)); + fileInfoObj.setProperty(QStringLiteral("resolvePath"), + engine->newFunction(FileInfoExtension::js_resolvePath)); + fileInfoObj.setProperty(QStringLiteral("isAbsolutePath"), + engine->newFunction(FileInfoExtension::js_isAbsolutePath)); + fileInfoObj.setProperty(QStringLiteral("toWindowsSeparators"), + engine->newFunction(FileInfoExtension::js_toWindowsSeparators)); + fileInfoObj.setProperty(QStringLiteral("fromWindowsSeparators"), + engine->newFunction(FileInfoExtension::js_fromWindowsSeparators)); + fileInfoObj.setProperty(QStringLiteral("toNativeSeparators"), + engine->newFunction(FileInfoExtension::js_toNativeSeparators)); + fileInfoObj.setProperty(QStringLiteral("fromNativeSeparators"), + engine->newFunction(FileInfoExtension::js_fromNativeSeparators)); + fileInfoObj.setProperty(QStringLiteral("joinPaths"), + engine->newFunction(FileInfoExtension::js_joinPaths)); + fileInfoObj.setProperty(QStringLiteral("pathListSeparator"), + engine->newFunction(FileInfoExtension::js_pathListSeparator)); + fileInfoObj.setProperty(QStringLiteral("pathSeparator"), + engine->newFunction(FileInfoExtension::js_pathSeparator)); + extensionObject.setProperty(QStringLiteral("FileInfo"), fileInfoObj); +} + +Q_DECLARE_METATYPE(qbs::Internal::FileInfoExtension *) + +#include "fileinfoextension.moc" diff --git a/src/lib/corelib/jsextensions/host.cpp b/src/lib/corelib/jsextensions/host.cpp new file mode 100644 index 00000000..ebf302a8 --- /dev/null +++ b/src/lib/corelib/jsextensions/host.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2022 Raphaël Cotty +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class Host : public QObject, QScriptable +{ + Q_OBJECT +public: + static QScriptValue js_ctor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_architecture(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_os(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_platform(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osVersion(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osBuildVersion(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osVersionParts(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osVersionMajor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osVersionMinor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_osVersionPatch(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_nullDevice(QScriptContext *context, QScriptEngine *engine); +}; + +static QStringList osList() +{ + QStringList list; + for (const auto &s : HostOsInfo::canonicalOSIdentifiers(HostOsInfo::hostOSIdentifier())) + list.push_back(s); + return list; +} + +QScriptValue Host::js_ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + return context->throwError(Tr::tr("'Host' cannot be instantiated.")); +} + +QScriptValue Host::js_architecture(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + + return HostOsInfo::hostOSArchitecture(); +} + +QScriptValue Host::js_os(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + static QStringList host = osList(); + return engine->toScriptValue(host); +} + +QScriptValue Host::js_platform(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + return HostOsInfo::hostOSIdentifier(); +} + +QScriptValue Host::js_osVersion(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static QString osVersion = HostOsInfo::hostOsVersion().toString(); + return osVersion.isNull() ? engine->undefinedValue() : osVersion; +} + +QScriptValue Host::js_osBuildVersion(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static QString osBuildVersion = HostOsInfo::hostOsBuildVersion(); + return osBuildVersion.isNull() ? engine->undefinedValue() : osBuildVersion; +} + +QScriptValue Host::js_osVersionParts(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static QStringList osVersionParts = HostOsInfo::hostOsVersion().toString().split( + QStringLiteral(".")); + return qScriptValueFromSequence(engine, osVersionParts); +} + +QScriptValue Host::js_osVersionMajor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static int osVersionMajor = HostOsInfo::hostOsVersion().majorVersion(); + return osVersionMajor; +} + +QScriptValue Host::js_osVersionMinor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static int osVersionMinor = HostOsInfo::hostOsVersion().minorVersion(); + return osVersionMinor; +} + +QScriptValue Host::js_osVersionPatch(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static int osVersionPatch = HostOsInfo::hostOsVersion().patchLevel(); + return osVersionPatch; +} + +QScriptValue Host::js_nullDevice(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + Q_UNUSED(engine); + static QString nullDevice = HostOsInfo::isWindowsHost() ? QStringLiteral("NUL") : + QStringLiteral("/dev/null"); + return nullDevice; +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionHost(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue hostObj = engine->newQMetaObject(&Host::staticMetaObject, + engine->newFunction(&Host::js_ctor)); + hostObj.setProperty(QStringLiteral("architecture"), engine->newFunction(Host::js_architecture)); + hostObj.setProperty(QStringLiteral("os"), engine->newFunction(Host::js_os)); + hostObj.setProperty(QStringLiteral("platform"), engine->newFunction(Host::js_platform)); + hostObj.setProperty(QStringLiteral("osVersion"), engine->newFunction(Host::js_osVersion)); + hostObj.setProperty(QStringLiteral("osBuildVersion"), engine->newFunction( + Host::js_osBuildVersion)); + hostObj.setProperty(QStringLiteral("osVersionParts"), engine->newFunction( + Host::js_osVersionParts)); + hostObj.setProperty(QStringLiteral("osVersionMajor"), engine->newFunction( + Host::js_osVersionMajor)); + hostObj.setProperty(QStringLiteral("osVersionMinor"), engine->newFunction( + Host::js_osVersionMinor)); + hostObj.setProperty(QStringLiteral("osVersionPatch"), engine->newFunction( + Host::js_osVersionPatch)); + hostObj.setProperty(QStringLiteral("nullDevice"), engine->newFunction(Host::js_nullDevice)); + extensionObject.setProperty(QStringLiteral("Host"), hostObj); +} + +Q_DECLARE_METATYPE(qbs::Internal::Host *) + +#include "host.moc" diff --git a/src/lib/corelib/jsextensions/jsextensions.cpp b/src/lib/corelib/jsextensions/jsextensions.cpp new file mode 100644 index 00000000..30dac8e8 --- /dev/null +++ b/src/lib/corelib/jsextensions/jsextensions.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "jsextensions.h" + +#include +#include + +#include + +using InitializerMap = QMap; +static InitializerMap setupMap() +{ +#define INITIALIZER_NAME(name) initializeJsExtension##name +#define ADD_JS_EXTENSION(name) \ + void INITIALIZER_NAME(name)(QScriptValue); \ + map.insert(QStringLiteral(#name), &INITIALIZER_NAME(name)) + + InitializerMap map; + ADD_JS_EXTENSION(BinaryFile); + ADD_JS_EXTENSION(Environment); + ADD_JS_EXTENSION(File); + ADD_JS_EXTENSION(FileInfo); + ADD_JS_EXTENSION(Host); + ADD_JS_EXTENSION(PkgConfig); + ADD_JS_EXTENSION(Process); + ADD_JS_EXTENSION(PropertyList); + ADD_JS_EXTENSION(TemporaryDir); + ADD_JS_EXTENSION(TextFile); + ADD_JS_EXTENSION(Utilities); + ADD_JS_EXTENSION(Xml); + return map; +} + +namespace qbs { +namespace Internal { + +static InitializerMap &initializers() +{ + static InitializerMap theMap = setupMap(); + return theMap; +} + +void JsExtensions::setupExtensions(const QStringList &names, const QScriptValue &scope) +{ + for (const QString &name : names) + initializers().value(name)(scope); +} + +QScriptValue JsExtensions::loadExtension(QScriptEngine *engine, const QString &name) +{ + if (!hasExtension(name)) + return {}; + + QScriptValue extensionObj = engine->newObject(); + initializers().value(name)(extensionObj); + return extensionObj.property(name); +} + +bool JsExtensions::hasExtension(const QString &name) +{ + return initializers().contains(name); +} + +QStringList JsExtensions::extensionNames() +{ + return initializers().keys(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/jsextensions/jsextensions.h b/src/lib/corelib/jsextensions/jsextensions.h new file mode 100644 index 00000000..f1ebfbdc --- /dev/null +++ b/src/lib/corelib/jsextensions/jsextensions.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_JSEXTENSIONS_H +#define QBS_JSEXTENSIONS_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QScriptEngine; +class QScriptValue; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +class JsExtensions +{ +public: + static void setupExtensions(const QStringList &names, const QScriptValue &scope); + static QScriptValue loadExtension(QScriptEngine *engine, const QString &name); + static bool hasExtension(const QString &name); + static QStringList extensionNames(); +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/jsextensions/jsextensions.pri b/src/lib/corelib/jsextensions/jsextensions.pri new file mode 100644 index 00000000..0d6ec25b --- /dev/null +++ b/src/lib/corelib/jsextensions/jsextensions.pri @@ -0,0 +1,29 @@ +QT += xml + +HEADERS += \ + $$PWD/moduleproperties.h \ + $$PWD/jsextensions.h \ + $$PWD/pkgconfigjs.h + +SOURCES += \ + $$PWD/environmentextension.cpp \ + $$PWD/file.cpp \ + $$PWD/fileinfoextension.cpp \ + $$PWD/host.cpp \ + $$PWD/temporarydir.cpp \ + $$PWD/textfile.cpp \ + $$PWD/binaryfile.cpp \ + $$PWD/pkgconfigjs.cpp \ + $$PWD/process.cpp \ + $$PWD/moduleproperties.cpp \ + $$PWD/domxml.cpp \ + $$PWD/jsextensions.cpp \ + $$PWD/utilitiesextension.cpp + +darwin { + HEADERS += $$PWD/propertylistutils.h $$PWD/propertylist_darwin.h + SOURCES += $$PWD/propertylist_darwin.mm $$PWD/propertylistutils.mm + LIBS += -framework Foundation +} else { + SOURCES += $$PWD/propertylist.cpp +} diff --git a/src/lib/corelib/jsextensions/moduleproperties.cpp b/src/lib/corelib/jsextensions/moduleproperties.cpp new file mode 100644 index 00000000..f721e001 --- /dev/null +++ b/src/lib/corelib/jsextensions/moduleproperties.cpp @@ -0,0 +1,357 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "moduleproperties.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +QScriptValue getDataForModuleScriptValue(QScriptEngine *engine, const ResolvedProduct *product, + const Artifact *artifact, const ResolvedModule *module) +{ + QScriptValue data = engine->newObject(); + data.setProperty(ModuleNameKey, module->name); + QVariant v; + v.setValue(reinterpret_cast(product)); + data.setProperty(ProductPtrKey, engine->newVariant(v)); + v.setValue(reinterpret_cast(artifact)); + data.setProperty(ArtifactPtrKey, engine->newVariant(v)); + return data; +} + +static QScriptValue getModuleProperty(const ResolvedProduct *product, const Artifact *artifact, + ScriptEngine *engine, const QString &moduleName, + const QString &propertyName, bool *isPresent = nullptr) +{ + const PropertyMapConstPtr &properties = artifact ? artifact->properties + : product->moduleProperties; + QVariant value; + if (engine->isPropertyCacheEnabled()) + value = engine->retrieveFromPropertyCache(moduleName, propertyName, properties); + if (!value.isValid()) { + value = properties->moduleProperty(moduleName, propertyName, isPresent); + + // Cache the variant value. We must not cache the QScriptValue here, because it's a + // reference and the user might change the actual object. + if (engine->isPropertyCacheEnabled()) + engine->addToPropertyCache(moduleName, propertyName, properties, value); + } else if (isPresent) { + *isPresent = true; + } + + const Property p(product->uniqueName(), moduleName, propertyName, value, + Property::PropertyInModule); + if (artifact) + engine->addPropertyRequestedFromArtifact(artifact, p); + else + engine->addPropertyRequestedInScript(p); + + return engine->toScriptValue(value); +} + +class ModulePropertyScriptClass : public QScriptClass +{ +public: + ModulePropertyScriptClass(QScriptEngine *engine) + : QScriptClass(engine) + { + } + +private: + QueryFlags queryProperty(const QScriptValue &object, const QScriptString &name, + QueryFlags flags, uint *id) override + { + Q_UNUSED(flags); + Q_UNUSED(id); + + if (name == StringConstants::dependenciesProperty() + || name == StringConstants::artifactsProperty()) { + // The prototype is not backed by a QScriptClass. + m_result = object.prototype().property(name); + return HandlesReadAccess; + } + + if (name == StringConstants::parametersProperty()) { + m_result = object.data().property(DependencyParametersKey); + return HandlesReadAccess; + } + + setup(object); + QBS_ASSERT(m_product, return {}); + bool isPresent; + m_result = getModuleProperty(m_product, m_artifact, static_cast(engine()), + m_moduleName, name, &isPresent); + + // It is important that we reject unknown property names. Otherwise QtScript will forward + // *everything* to us, including built-in stuff like the hasOwnProperty function. + return isPresent ? HandlesReadAccess : QueryFlags(); + } + + QScriptValue property(const QScriptValue &, const QScriptString &, uint) override + { + return m_result; + } + + QScriptClassPropertyIterator *newIterator(const QScriptValue &object) override + { + setup(object); + QBS_ASSERT(m_artifact || m_product, return nullptr); + const PropertyMapInternal *propertyMap; + std::vector additionalProperties({StringConstants::artifactsProperty(), + StringConstants::dependenciesProperty()}); + if (m_artifact) { + propertyMap = m_artifact->properties.get(); + } else { + propertyMap = m_product->moduleProperties.get(); + if (object.data().property(DependencyParametersKey).isValid()) + additionalProperties.push_back(StringConstants::parametersProperty()); + } + return new ScriptClassPropertyIterator(object, + propertyMap->value().value(m_moduleName).toMap(), + additionalProperties); + } + + void setup(const QScriptValue &object) + { + if (m_lastObjectId != object.objectId()) { + m_lastObjectId = object.objectId(); + const QScriptValue data = object.data(); + QBS_ASSERT(data.isValid(), return); + m_moduleName = data.property(ModuleNameKey).toString(); + m_product = reinterpret_cast( + data.property(ProductPtrKey).toVariant().value()); + m_artifact = reinterpret_cast( + data.property(ArtifactPtrKey).toVariant().value()); + } + } + + qint64 m_lastObjectId = 0; + QString m_moduleName; + const ResolvedProduct *m_product = nullptr; + const Artifact *m_artifact = nullptr; + QScriptValue m_result; +}; + +static QString ptrKey() { return QStringLiteral("__internalPtr"); } +static QString typeKey() { return QStringLiteral("__type"); } +static QString artifactType() { return QStringLiteral("artifact"); } + +static QScriptValue js_moduleDependencies(QScriptContext *, ScriptEngine *engine, + const ResolvedModule *module) +{ + QScriptValue result = engine->newArray(); + quint32 idx = 0; + for (const QString &depName : qAsConst(module->moduleDependencies)) { + for (const auto &dep : module->product->modules) { + if (dep->name != depName) + continue; + QScriptValue obj = engine->newObject(engine->modulePropertyScriptClass()); + obj.setPrototype(engine->moduleScriptValuePrototype(dep.get())); + QScriptValue data = getDataForModuleScriptValue(engine, module->product, nullptr, + dep.get()); + const QVariantMap ¶ms = module->product->moduleParameters.value(dep); + data.setProperty(DependencyParametersKey, dependencyParametersValue( + module->product->uniqueName(), dep->name, params, engine)); + obj.setData(data); + result.setProperty(idx++, obj); + break; + } + } + QBS_ASSERT(idx == quint32(module->moduleDependencies.size()),;); + return result; +} + +static QScriptValue setupModuleScriptValue(ScriptEngine *engine, + const ResolvedModule *module) +{ + QScriptValue &moduleScriptValue = engine->moduleScriptValuePrototype(module); + if (moduleScriptValue.isValid()) + return moduleScriptValue; + moduleScriptValue = engine->newObject(); + QScriptValue depfunc = engine->newFunction(&js_moduleDependencies, + module); + moduleScriptValue.setProperty(StringConstants::dependenciesProperty(), depfunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + QScriptValue artifactsFunc = engine->newFunction(&artifactsScriptValueForModule, module); + moduleScriptValue.setProperty(StringConstants::artifactsProperty(), artifactsFunc, + QScriptValue::ReadOnly | QScriptValue::Undeletable + | QScriptValue::PropertyGetter); + return moduleScriptValue; +} + +void ModuleProperties::init(QScriptValue productObject, + const ResolvedProduct *product) +{ + init(productObject, product, StringConstants::productValue()); + setupModules(productObject, product, nullptr); +} + +void ModuleProperties::init(QScriptValue artifactObject, const Artifact *artifact) +{ + init(artifactObject, artifact, artifactType()); + const auto product = artifact->product; + const QVariantMap productProperties { + {StringConstants::buildDirectoryProperty(), product->buildDirectory()}, + {StringConstants::destinationDirProperty(), product->destinationDirectory}, + {StringConstants::nameProperty(), product->name}, + {StringConstants::sourceDirectoryProperty(), product->sourceDirectory}, + {StringConstants::targetNameProperty(), product->targetName}, + {StringConstants::typeProperty(), sorted(product->fileTags.toStringList())} + }; + QScriptEngine * const engine = artifactObject.engine(); + artifactObject.setProperty(StringConstants::productVar(), + engine->toScriptValue(productProperties)); + setupModules(artifactObject, artifact->product.get(), artifact); +} + +void ModuleProperties::setModuleScriptValue(QScriptValue targetObject, + const QScriptValue &moduleObject, const QString &moduleName) +{ + auto const e = static_cast(targetObject.engine()); + const QualifiedId name = QualifiedId::fromString(moduleName); + QScriptValue obj = targetObject; + for (int i = 0; i < name.size() - 1; ++i) { + QScriptValue tmp = obj.property(name.at(i)); + if (!tmp.isObject()) + tmp = e->newObject(); + obj.setProperty(name.at(i), tmp); + obj = tmp; + } + obj.setProperty(name.last(), moduleObject); + if (moduleName.size() > 1) + targetObject.setProperty(moduleName, moduleObject); +} + +void ModuleProperties::init(QScriptValue objectWithProperties, const void *ptr, + const QString &type) +{ + QScriptEngine * const engine = objectWithProperties.engine(); + objectWithProperties.setProperty(QStringLiteral("moduleProperty"), + engine->newFunction(ModuleProperties::js_moduleProperty, 2)); + objectWithProperties.setProperty(ptrKey(), engine->toScriptValue(quintptr(ptr))); + objectWithProperties.setProperty(typeKey(), type); +} + +void ModuleProperties::setupModules(QScriptValue &object, const ResolvedProduct *product, + const Artifact *artifact) +{ + const auto engine = static_cast(object.engine()); + QScriptClass *modulePropertyScriptClass = engine->modulePropertyScriptClass(); + if (!modulePropertyScriptClass) { + modulePropertyScriptClass = new ModulePropertyScriptClass(engine); + engine->setModulePropertyScriptClass(modulePropertyScriptClass); + } + for (const auto &module : product->modules) { + QScriptValue moduleObjectPrototype = setupModuleScriptValue(engine, module.get()); + QScriptValue moduleObject = engine->newObject(modulePropertyScriptClass); + moduleObject.setPrototype(moduleObjectPrototype); + moduleObject.setData(getDataForModuleScriptValue(engine, product, artifact, module.get())); + setModuleScriptValue(object, moduleObject, module->name); + } +} + +QScriptValue ModuleProperties::js_moduleProperty(QScriptContext *context, QScriptEngine *engine) +{ + try { + return moduleProperty(context, engine); + } catch (const ErrorInfo &e) { + return context->throwError(e.toString()); + } +} + +QScriptValue ModuleProperties::moduleProperty(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() < 2)) { + return context->throwError(QScriptContext::SyntaxError, + Tr::tr("Function moduleProperty() expects 2 arguments")); + } + + const QScriptValue objectWithProperties = context->thisObject(); + const QScriptValue typeScriptValue = objectWithProperties.property(typeKey()); + if (Q_UNLIKELY(!typeScriptValue.isString())) { + return context->throwError(QScriptContext::TypeError, + QStringLiteral("Internal error: __type not set up")); + } + const QScriptValue ptrScriptValue = objectWithProperties.property(ptrKey()); + if (Q_UNLIKELY(!ptrScriptValue.isNumber())) { + return context->throwError(QScriptContext::TypeError, + QStringLiteral("Internal error: __internalPtr not set up")); + } + + const void *ptr = reinterpret_cast(qscriptvalue_cast(ptrScriptValue)); + const ResolvedProduct *product = nullptr; + const Artifact *artifact = nullptr; + if (typeScriptValue.toString() == StringConstants::productValue()) { + QBS_ASSERT(ptr, return {}); + product = static_cast(ptr); + } else if (typeScriptValue.toString() == artifactType()) { + QBS_ASSERT(ptr, return {}); + artifact = static_cast(ptr); + product = artifact->product.get(); + } else { + return context->throwError(QScriptContext::TypeError, + QStringLiteral("Internal error: invalid type")); + } + + const auto qbsEngine = static_cast(engine); + const QString moduleName = context->argument(0).toString(); + const QString propertyName = context->argument(1).toString(); + return getModuleProperty(product, artifact, qbsEngine, moduleName, propertyName); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/jsextensions/moduleproperties.h b/src/lib/corelib/jsextensions/moduleproperties.h new file mode 100644 index 00000000..3fe4fbfd --- /dev/null +++ b/src/lib/corelib/jsextensions/moduleproperties.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MODULEPROPERTIES_H +#define QBS_MODULEPROPERTIES_H + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class ScriptEngine; + +enum ModulePropertiesScriptValueCommonPropertyKeys : quint32 +{ + ModuleNameKey, + ProductPtrKey, + ArtifactPtrKey, + DependencyParametersKey, +}; + +QScriptValue getDataForModuleScriptValue(QScriptEngine *engine, const ResolvedProduct *product, + const Artifact *artifact, const ResolvedModule *module); + +class ModuleProperties +{ +public: + static void init(QScriptValue productObject, const ResolvedProduct *product); + static void init(QScriptValue artifactObject, const Artifact *artifact); + static void setModuleScriptValue(QScriptValue targetObject, const QScriptValue &moduleObject, + const QString &moduleName); + +private: + static void init(QScriptValue objectWithProperties, const void *ptr, const QString &type); + static void setupModules(QScriptValue &object, const ResolvedProduct *product, + const Artifact *artifact); + + static QScriptValue js_moduleProperty(QScriptContext *context, QScriptEngine *engine); + + static QScriptValue moduleProperty(QScriptContext *context, QScriptEngine *engine); +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_MODULEPROPERTIES_H diff --git a/src/lib/corelib/jsextensions/pkgconfigjs.cpp b/src/lib/corelib/jsextensions/pkgconfigjs.cpp new file mode 100644 index 00000000..76cc3508 --- /dev/null +++ b/src/lib/corelib/jsextensions/pkgconfigjs.cpp @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pkgconfigjs.h" + +#include +#include + +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +namespace { + +template QVariantList convert(const C &c, F &&f) +{ + QVariantList result; + result.reserve(int(c.size())); + std::transform(c.begin(), c.end(), std::back_inserter(result), f); + return result; +} + +QVariantMap variablesMapToMap(const PcPackage::VariablesMap &variables) +{ + QVariantMap result; + for (const auto &item: variables) + result.insert(QString::fromStdString(item.first), QString::fromStdString(item.second)); + return result; +} + +QVariantMap packageToMap(const PcPackage &package) +{ + QVariantMap result; + result[QStringLiteral("isBroken")] = false; + result[QStringLiteral("filePath")] = QString::fromStdString(package.filePath); + result[QStringLiteral("baseFileName")] = QString::fromStdString(package.baseFileName); + result[QStringLiteral("name")] = QString::fromStdString(package.name); + result[QStringLiteral("version")] = QString::fromStdString(package.version); + result[QStringLiteral("description")] = QString::fromStdString(package.description); + result[QStringLiteral("url")] = QString::fromStdString(package.url); + + const auto flagToMap = [](const PcPackage::Flag &flag) + { + QVariantMap result; + const auto value = QString::fromStdString(flag.value); + result[QStringLiteral("type")] = QVariant::fromValue(qint32(flag.type)); + result[QStringLiteral("value")] = value; + return result; + }; + + const auto requiredVersionToMap = [](const PcPackage::RequiredVersion &version) + { + using Type = PcPackage::RequiredVersion::ComparisonType; + QVariantMap result; + result[QStringLiteral("name")] = QString::fromStdString(version.name); + const auto versionString = QString::fromStdString(version.version); + const auto qbsVersion = Version::fromString(QString::fromStdString(version.version)); + const auto nextQbsVersion = Version( + qbsVersion.majorVersion(), + qbsVersion.minorVersion(), + qbsVersion.patchLevel() + 1); + switch (version.comparison) { + case Type::LessThan: + result[QStringLiteral("versionBelow")] = versionString; + break; + case Type::GreaterThan: + result[QStringLiteral("versionAtLeast")] = nextQbsVersion.toString(); + break; + case Type::LessThanEqual: + result[QStringLiteral("versionBelow")] = nextQbsVersion.toString(); + break; + case Type::GreaterThanEqual: + result[QStringLiteral("versionAtLeast")] = versionString; + break; + case Type::Equal: + result[QStringLiteral("version")] = versionString; + break; + case Type::NotEqual: + result[QStringLiteral("versionBelow")] = versionString; + result[QStringLiteral("versionAtLeast")] = nextQbsVersion.toString(); + break; + case Type::AlwaysMatch: + break; + } + result[QStringLiteral("comparison")] = QVariant::fromValue(qint32(version.comparison)); + return result; + }; + + result[QStringLiteral("libs")] = convert(package.libs, flagToMap); + result[QStringLiteral("libsPrivate")] = convert(package.libsPrivate, flagToMap); + result[QStringLiteral("cflags")] = convert(package.cflags, flagToMap); + result[QStringLiteral("requires")] = convert(package.requiresPublic, requiredVersionToMap); + result[QStringLiteral("requiresPrivate")] = + convert(package.requiresPrivate, requiredVersionToMap); + result[QStringLiteral("conflicts")] = convert(package.conflicts, requiredVersionToMap); + result[QStringLiteral("variables")] = variablesMapToMap(package.variables); + + return result; +}; + +QVariantMap brokenPackageToMap(const PcBrokenPackage &package) +{ + QVariantMap result; + result[QStringLiteral("isBroken")] = true; + result[QStringLiteral("filePath")] = QString::fromStdString(package.filePath); + result[QStringLiteral("baseFileName")] = QString::fromStdString(package.baseFileName); + result[QStringLiteral("errorText")] = QString::fromStdString(package.errorText); + return result; +} + +QVariantMap packageVariantToMap(const PcPackageVariant &package) +{ + return package.visit([](const auto &value) { + using T = std::decay_t; + if constexpr (std::is_same_v) + return packageToMap(value); + else + return brokenPackageToMap(value); + }); +} + +PcPackage::VariablesMap envToVariablesMap(const QProcessEnvironment &env) +{ + PcPackage::VariablesMap result; + const auto keys = env.keys(); + for (const auto &key : keys) + result[key.toStdString()] = env.value(key).toStdString(); + return result; +} + +PcPackage::VariablesMap variablesFromQVariantMap(const QVariantMap &map) +{ + PcPackage::VariablesMap result; + for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) + result[it.key().toStdString()] = it.value().toString().toStdString(); + return result; +} + +std::vector stringListToStdVector(const QStringList &list) +{ + return transformed>(list, [](const auto &s) { + return s.toStdString(); }); +} + +} // namespace + +QScriptValue PkgConfigJs::ctor(QScriptContext *context, QScriptEngine *engine) +{ + try { + PkgConfigJs *e = nullptr; + switch (context->argumentCount()) { + case 0: + e = new PkgConfigJs(context, engine); + break; + case 1: + e = new PkgConfigJs(context, engine, context->argument(0).toVariant().toMap()); + break; + + default: + return context->throwError( + QStringLiteral("TextFile constructor takes at most three parameters.")); + } + + return engine->newQObject(e, QScriptEngine::ScriptOwnership); + } catch (const PcException &e) { + return context->throwError(QString::fromUtf8(e.what())); + } +} + +PkgConfigJs::PkgConfigJs( + QScriptContext *context, QScriptEngine *engine, const QVariantMap &options) : + m_pkgConfig(std::make_unique( + convertOptions(static_cast(engine)->environment(), options))) +{ + Q_UNUSED(context); + for (const auto &package : m_pkgConfig->packages()) { + m_packages.insert( + QString::fromStdString(package.getBaseFileName()), packageVariantToMap(package)); + } +} + +PkgConfig::Options PkgConfigJs::convertOptions(const QProcessEnvironment &env, const QVariantMap &map) +{ + PkgConfig::Options result; + result.libDirs = + stringListToStdVector(map.value(QStringLiteral("libDirs")).toStringList()); + result.extraPaths = + stringListToStdVector(map.value(QStringLiteral("extraPaths")).toStringList()); + result.sysroot = map.value(QStringLiteral("sysroot")).toString().toStdString(); + result.topBuildDir = map.value(QStringLiteral("topBuildDir")).toString().toStdString(); + result.allowSystemLibraryPaths = + map.value(QStringLiteral("allowSystemLibraryPaths"), false).toBool(); + const auto systemLibraryPaths = map.value(QStringLiteral("systemLibraryPaths")).toStringList(); + result.systemLibraryPaths.reserve(systemLibraryPaths.size()); + std::transform( + systemLibraryPaths.begin(), + systemLibraryPaths.end(), + std::back_inserter(result.systemLibraryPaths), + [](const QString &str){ return str.toStdString(); }); + result.disableUninstalled = map.value(QStringLiteral("disableUninstalled"), true).toBool(); + result.staticMode = map.value(QStringLiteral("staticMode"), false).toBool(); + result.mergeDependencies = map.value(QStringLiteral("mergeDependencies"), true).toBool(); + result.globalVariables = + variablesFromQVariantMap(map.value(QStringLiteral("globalVariables")).toMap()); + result.systemVariables = envToVariablesMap(env); + + return result; +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionPkgConfig(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newQMetaObject( + &PkgConfigJs::staticMetaObject, engine->newFunction(&PkgConfigJs::ctor)); + extensionObject.setProperty(QStringLiteral("PkgConfig"), obj); +} + +Q_DECLARE_METATYPE(qbs::Internal::PkgConfigJs *) diff --git a/src/lib/corelib/jsextensions/pkgconfigjs.h b/src/lib/corelib/jsextensions/pkgconfigjs.h new file mode 100644 index 00000000..462a8f2b --- /dev/null +++ b/src/lib/corelib/jsextensions/pkgconfigjs.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "tools/qbs_export.h" +#include + +#include + +#include +#include + +#include + +#include + +class QProcessEnvironment; + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT PkgConfigJs : public QObject, QScriptable +{ + Q_OBJECT +public: + + // can we trick moc here to avoid duplication? + enum class FlagType { + LibraryName = toUnderlying(PcPackage::Flag::Type::LibraryName), + LibraryPath = toUnderlying(PcPackage::Flag::Type::LibraryPath), + StaticLibraryName = toUnderlying(PcPackage::Flag::Type::StaticLibraryName), + Framework = toUnderlying(PcPackage::Flag::Type::Framework), + FrameworkPath = toUnderlying(PcPackage::Flag::Type::FrameworkPath), + LinkerFlag = toUnderlying(PcPackage::Flag::Type::LinkerFlag), + IncludePath = toUnderlying(PcPackage::Flag::Type::IncludePath), + SystemIncludePath = toUnderlying(PcPackage::Flag::Type::SystemIncludePath), + Define = toUnderlying(PcPackage::Flag::Type::Define), + CompilerFlag = toUnderlying(PcPackage::Flag::Type::CompilerFlag), + }; + Q_ENUM(FlagType); + + enum class ComparisonType { + LessThan, + GreaterThan, + LessThanEqual, + GreaterThanEqual, + Equal, + NotEqual, + AlwaysMatch + }; + Q_ENUM(ComparisonType); + + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + + explicit PkgConfigJs( + QScriptContext *context, QScriptEngine *engine, const QVariantMap &options = {}); + + Q_INVOKABLE QVariantMap packages() const { return m_packages; } + + // also used in tests + static PkgConfig::Options convertOptions(const QProcessEnvironment &env, const QVariantMap &map); + +private: + std::unique_ptr m_pkgConfig; + QVariantMap m_packages; +}; + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/jsextensions/process.cpp b/src/lib/corelib/jsextensions/process.cpp new file mode 100644 index 00000000..f0c3c470 --- /dev/null +++ b/src/lib/corelib/jsextensions/process.cpp @@ -0,0 +1,350 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#else +#include +#endif +#include +#include +#include + +namespace qbs { +namespace Internal { + +class Process : public QObject, public QScriptable, public ResourceAcquiringScriptObject +{ + Q_OBJECT +public: + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + Process(QScriptContext *context); + + Q_INVOKABLE QString getEnv(const QString &name); + Q_INVOKABLE void setEnv(const QString &name, const QString &value); + Q_INVOKABLE void setCodec(const QString &codec); + + Q_INVOKABLE QString workingDirectory(); + Q_INVOKABLE void setWorkingDirectory(const QString &dir); + + Q_INVOKABLE bool start(const QString &program, const QStringList &arguments); + Q_INVOKABLE int exec(const QString &program, const QStringList &arguments, + bool throwOnError = false); + Q_INVOKABLE void close(); + Q_INVOKABLE bool waitForFinished(int msecs = 30000); + Q_INVOKABLE void terminate(); + Q_INVOKABLE void kill(); + + Q_INVOKABLE QString readLine(); + Q_INVOKABLE bool atEnd() const; + Q_INVOKABLE QString readStdOut(); + Q_INVOKABLE QString readStdErr(); + + Q_INVOKABLE void closeWriteChannel(); + + Q_INVOKABLE void write(const QString &str); + Q_INVOKABLE void writeLine(const QString &str); + + Q_INVOKABLE int exitCode() const; + + static QScriptValue js_shellQuote(QScriptContext *context, QScriptEngine *engine); + +private: + QString findExecutable(const QString &filePath) const; + + // ResourceAcquiringScriptObject implementation + void releaseResources() override; + + std::unique_ptr m_qProcess; + QProcessEnvironment m_environment; + QString m_workingDirectory; + QTextCodec *m_codec = nullptr; +}; + +QScriptValue Process::ctor(QScriptContext *context, QScriptEngine *engine) +{ + Process *t; + switch (context->argumentCount()) { + case 0: + t = new Process(context); + break; + default: + return context->throwError(QStringLiteral("Process()")); + } + + const auto se = static_cast(engine); + se->addResourceAcquiringScriptObject(t); + const DubiousContextList dubiousContexts ({ + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("qbs.Process"), dubiousContexts); + + QScriptValue obj = engine->newQObject(t, QScriptEngine::QtOwnership); + + // Get environment + QVariant v = engine->property(StringConstants::qbsProcEnvVarInternal()); + if (v.isNull()) { + // The build environment is not initialized yet. + // This can happen if one uses Process on the RHS of a binding like Group.name. + t->m_environment = static_cast(engine)->environment(); + } else { + t->m_environment + = QProcessEnvironment(*reinterpret_cast(v.value())); + } + se->setUsesIo(); + + return obj; +} + +Process::Process(QScriptContext *context) +{ + Q_UNUSED(context); + Q_ASSERT(thisObject().engine() == engine()); + + m_qProcess = std::make_unique(); + m_codec = QTextCodec::codecForName("UTF-8"); +} + +QString Process::getEnv(const QString &name) +{ + Q_ASSERT(thisObject().engine() == engine()); + return m_environment.value(name); +} + +void Process::setEnv(const QString &name, const QString &value) +{ + Q_ASSERT(thisObject().engine() == engine()); + m_environment.insert(name, value); +} + +QString Process::workingDirectory() +{ + Q_ASSERT(thisObject().engine() == engine()); + return m_workingDirectory; +} + +void Process::setWorkingDirectory(const QString &dir) +{ + Q_ASSERT(thisObject().engine() == engine()); + m_workingDirectory = dir; +} + +bool Process::start(const QString &program, const QStringList &arguments) +{ + Q_ASSERT(thisObject().engine() == engine()); + + if (!m_workingDirectory.isEmpty()) + m_qProcess->setWorkingDirectory(m_workingDirectory); + + m_qProcess->setProcessEnvironment(m_environment); + m_qProcess->start(findExecutable(program), arguments, QIODevice::ReadWrite | QIODevice::Text); + return m_qProcess->waitForStarted(); +} + +int Process::exec(const QString &program, const QStringList &arguments, bool throwOnError) +{ + Q_ASSERT(thisObject().engine() == engine()); + + if (!start(findExecutable(program), arguments)) { + if (throwOnError) { + context()->throwError(Tr::tr("Error running '%1': %2") + .arg(program, m_qProcess->errorString())); + } + return -1; + } + m_qProcess->closeWriteChannel(); + m_qProcess->waitForFinished(-1); + if (throwOnError) { + if (m_qProcess->error() != QProcess::UnknownError + && m_qProcess->error() != QProcess::Crashed) { + context()->throwError(Tr::tr("Error running '%1': %2") + .arg(program, m_qProcess->errorString())); + } else if (m_qProcess->exitStatus() == QProcess::CrashExit || m_qProcess->exitCode() != 0) { + QString errorMessage = m_qProcess->error() == QProcess::Crashed + ? Tr::tr("Error running '%1': %2").arg(program, m_qProcess->errorString()) + : Tr::tr("Process '%1 %2' finished with exit code %3.") + .arg(program, arguments.join(QStringLiteral(" "))) + .arg(m_qProcess->exitCode()); + const QString stdOut = readStdOut(); + if (!stdOut.isEmpty()) + errorMessage.append(Tr::tr(" The standard output was:\n")).append(stdOut); + const QString stdErr = readStdErr(); + if (!stdErr.isEmpty()) + errorMessage.append(Tr::tr(" The standard error output was:\n")).append(stdErr); + context()->throwError(errorMessage); + } + } + if (m_qProcess->error() != QProcess::UnknownError) + return -1; + return m_qProcess->exitCode(); +} + +void Process::close() +{ + if (!m_qProcess) + return; + Q_ASSERT(thisObject().engine() == engine()); + m_qProcess.reset(); +} + +bool Process::waitForFinished(int msecs) +{ + Q_ASSERT(thisObject().engine() == engine()); + + if (m_qProcess->state() == QProcess::NotRunning) + return true; + return m_qProcess->waitForFinished(msecs); +} + +void Process::terminate() +{ + m_qProcess->terminate(); +} + +void Process::kill() +{ + m_qProcess->kill(); +} + +void Process::setCodec(const QString &codec) +{ + Q_ASSERT(thisObject().engine() == engine()); + const auto newCodec = QTextCodec::codecForName(qPrintable(codec)); + if (newCodec) + m_codec = newCodec; +} + +QString Process::readLine() +{ + auto result = m_codec->toUnicode(m_qProcess->readLine()); + if (!result.isEmpty() && result.back() == QLatin1Char('\n')) + result.chop(1); + return result; +} + +bool Process::atEnd() const +{ + return m_qProcess->atEnd(); +} + +QString Process::readStdOut() +{ + return m_codec->toUnicode(m_qProcess->readAllStandardOutput()); +} + +QString Process::readStdErr() +{ + return m_codec->toUnicode(m_qProcess->readAllStandardError()); +} + +void Process::closeWriteChannel() +{ + m_qProcess->closeWriteChannel(); +} + +int Process::exitCode() const +{ + return m_qProcess->exitCode(); +} + +QString Process::findExecutable(const QString &filePath) const +{ + ExecutableFinder exeFinder(ResolvedProductPtr(), m_environment); + return exeFinder.findExecutable(filePath, m_workingDirectory); +} + +void Process::releaseResources() +{ + close(); + deleteLater(); +} + +void Process::write(const QString &str) +{ + m_qProcess->write(m_codec->fromUnicode(str)); +} + +void Process::writeLine(const QString &str) +{ + m_qProcess->write(m_codec->fromUnicode(str)); + m_qProcess->putChar('\n'); +} + +QScriptValue Process::js_shellQuote(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() < 2)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("shellQuote expects at least 2 arguments")); + } + const QString program = context->argument(0).toString(); + const QStringList args = context->argument(1).toVariant().toStringList(); + HostOsInfo::HostOs hostOs = HostOsInfo::hostOs(); + if (context->argumentCount() > 2) { + hostOs = context->argument(2).toVariant().toStringList().contains(QLatin1String("windows")) + ? HostOsInfo::HostOsWindows : HostOsInfo::HostOsOtherUnix; + } + return engine->toScriptValue(shellQuote(program, args, hostOs)); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionProcess(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newQMetaObject(&Process::staticMetaObject, engine->newFunction(&Process::ctor)); + extensionObject.setProperty(QStringLiteral("Process"), obj); + obj.setProperty(QStringLiteral("shellQuote"), engine->newFunction(Process::js_shellQuote, 3)); +} + +Q_DECLARE_METATYPE(qbs::Internal::Process *) + +#include "process.moc" diff --git a/src/lib/corelib/jsextensions/propertylist.cpp b/src/lib/corelib/jsextensions/propertylist.cpp new file mode 100644 index 00000000..197d5e99 --- /dev/null +++ b/src/lib/corelib/jsextensions/propertylist.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +void initializeJsExtensionPropertyList(QScriptValue extensionObject) +{ + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newObject(); // provide a fake object + extensionObject.setProperty(QStringLiteral("PropertyList"), obj); +} diff --git a/src/lib/corelib/jsextensions/propertylist_darwin.h b/src/lib/corelib/jsextensions/propertylist_darwin.h new file mode 100644 index 00000000..27930968 --- /dev/null +++ b/src/lib/corelib/jsextensions/propertylist_darwin.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROPERTYLIST_H +#define QBS_PROPERTYLIST_H + +#include + +#include +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +void initializeJsExtensionPropertyList(QScriptValue extensionObject); + +class PropertyListPrivate; + +// We need to have this class in the header since CMake's automoc doesn't handle .mm files +class PropertyList : public QObject, public QScriptable +{ + Q_OBJECT +public: + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + PropertyList(QScriptContext *context); + ~PropertyList() override; + Q_INVOKABLE bool isEmpty() const; + Q_INVOKABLE void clear(); + Q_INVOKABLE void readFromObject(const QScriptValue &value); + Q_INVOKABLE void readFromString(const QString &input); + Q_INVOKABLE void readFromFile(const QString &filePath); + Q_INVOKABLE void readFromData(const QByteArray &data); + Q_INVOKABLE void writeToFile(const QString &filePath, const QString &plistFormat); + Q_INVOKABLE QScriptValue format() const; + Q_INVOKABLE QScriptValue toObject() const; + Q_INVOKABLE QString toString(const QString &plistFormat) const; + Q_INVOKABLE QString toXMLString() const; + Q_INVOKABLE QString toJSON(const QString &style = QString()) const; +private: + const std::unique_ptr d; +}; + +} // namespace Internal +} // namespace qbs + +Q_DECLARE_METATYPE(qbs::Internal::PropertyList *) + +#endif // QBS_PROPERTYLIST_H diff --git a/src/lib/corelib/jsextensions/propertylist_darwin.mm b/src/lib/corelib/jsextensions/propertylist_darwin.mm new file mode 100644 index 00000000..caf9feb3 --- /dev/null +++ b/src/lib/corelib/jsextensions/propertylist_darwin.mm @@ -0,0 +1,343 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "propertylist_darwin.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +// Same values as CoreFoundation and Foundation APIs +enum { + QPropertyListOpenStepFormat = 1, + QPropertyListXMLFormat_v1_0 = 100, + QPropertyListBinaryFormat_v1_0 = 200, + QPropertyListJSONFormat = 1000 // If this conflicts someday, just change it :) +}; + +namespace qbs { +namespace Internal { + +class PropertyListPrivate +{ +public: + PropertyListPrivate(); + + QVariant propertyListObject; + int propertyListFormat; + + void readFromData(QScriptContext *context, const QByteArray &data); + QByteArray writeToData(QScriptContext *context, const QString &format); +}; + +QScriptValue PropertyList::ctor(QScriptContext *context, QScriptEngine *engine) +{ + auto const se = static_cast(engine); + const DubiousContextList dubiousContexts({ + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("qbs.PropertyList"), dubiousContexts); + + auto p = new PropertyList(context); + QScriptValue obj = engine->newQObject(p, QScriptEngine::ScriptOwnership); + return obj; +} + +PropertyListPrivate::PropertyListPrivate() + : propertyListObject(), propertyListFormat(0) +{ +} + +PropertyList::~PropertyList() = default; + +PropertyList::PropertyList(QScriptContext *context) + : d(std::make_unique()) +{ + Q_UNUSED(context); + Q_ASSERT(thisObject().engine() == engine()); +} + +bool PropertyList::isEmpty() const +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + return p->d->propertyListObject.isNull(); +} + +void PropertyList::clear() +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + p->d->propertyListObject = QVariant(); + p->d->propertyListFormat = 0; +} + +void PropertyList::readFromObject(const QScriptValue &value) +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + p->d->propertyListObject = value.toVariant(); + p->d->propertyListFormat = 0; // wasn't deserialized from any external format +} + +void PropertyList::readFromString(const QString &input) +{ + readFromData(input.toUtf8()); +} + +void PropertyList::readFromFile(const QString &filePath) +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + + QFile file(filePath); + if (file.open(QIODevice::ReadOnly)) { + const QByteArray data = file.readAll(); + if (file.error() == QFile::NoError) { + p->d->readFromData(p->context(), data); + return; + } + } + + p->context()->throwError(QStringLiteral("%1: %2").arg(filePath).arg(file.errorString())); +} + +void PropertyList::readFromData(const QByteArray &data) +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + p->d->readFromData(p->context(), data); +} + +void PropertyList::writeToFile(const QString &filePath, const QString &plistFormat) +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + + QFile file(filePath); + QByteArray data = p->d->writeToData(p->context(), plistFormat); + if (Q_LIKELY(!data.isEmpty())) { + if (file.open(QIODevice::WriteOnly) && file.write(data) == data.size()) { + return; + } + } + + p->context()->throwError(QStringLiteral("%1: %2").arg(filePath).arg(file.errorString())); +} + +QScriptValue PropertyList::format() const +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + switch (p->d->propertyListFormat) + { + case QPropertyListOpenStepFormat: + return QStringLiteral("openstep"); + case QPropertyListXMLFormat_v1_0: + return QStringLiteral("xml1"); + case QPropertyListBinaryFormat_v1_0: + return QStringLiteral("binary1"); + case QPropertyListJSONFormat: + return QStringLiteral("json"); + default: + return p->engine()->undefinedValue(); + } +} + +QScriptValue PropertyList::toObject() const +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + return p->engine()->toScriptValue(p->d->propertyListObject); +} + +QString PropertyList::toString(const QString &plistFormat) const +{ + Q_ASSERT(thisObject().engine() == engine()); + auto p = qscriptvalue_cast(thisObject()); + + if (plistFormat == QLatin1String("binary1")) { + p->context()->throwError(QStringLiteral("Property list object cannot be converted to a " + "string in the binary1 format; this format can only " + "be written directly to a file")); + return {}; + } + + if (!isEmpty()) + return QString::fromUtf8(p->d->writeToData(p->context(), plistFormat)); + + return {}; +} + +QString PropertyList::toXMLString() const +{ + return toString(QStringLiteral("xml1")); +} + +QString PropertyList::toJSON(const QString &style) const +{ + QString format = QLatin1String("json"); + if (!style.isEmpty()) + format += QLatin1String("-") + style; + + return toString(format); +} + +} // namespace Internal +} // namespace qbs + +#include "propertylistutils.h" + +namespace qbs { +namespace Internal { + +void PropertyListPrivate::readFromData(QScriptContext *context, const QByteArray &data) +{ + @autoreleasepool { + NSPropertyListFormat format; + int internalFormat = 0; + NSString *errorString = nil; + id plist = [NSPropertyListSerialization propertyListWithData:data.toNSData() + options:0 + format:&format error:nil]; + if (plist) { + internalFormat = format; + } else { + NSError *error = nil; + plist = [NSJSONSerialization JSONObjectWithData:data.toNSData() + options:0 + error:&error]; + if (Q_UNLIKELY(!plist)) { + errorString = [error localizedDescription]; + } else { + internalFormat = QPropertyListJSONFormat; + } + } + + if (Q_UNLIKELY(!plist)) { + context->throwError(QString::fromNSString(errorString)); + } else { + QVariant obj = QPropertyListUtils::fromPropertyList(plist); + if (!obj.isNull()) { + propertyListObject = obj; + propertyListFormat = internalFormat; + } else { + context->throwError(QStringLiteral("error converting property list")); + } + } + } +} + +QByteArray PropertyListPrivate::writeToData(QScriptContext *context, const QString &format) +{ + @autoreleasepool { + NSError *error = nil; + NSString *errorString = nil; + NSData *data = nil; + + id obj = QPropertyListUtils::toPropertyList(propertyListObject); + if (!obj) { + context->throwError(QStringLiteral("error converting property list")); + return QByteArray(); + } + + if (format == QLatin1String("json") || format == QLatin1String("json-pretty") || + format == QLatin1String("json-compact")) { + if ([NSJSONSerialization isValidJSONObject:obj]) { + error = nil; + errorString = nil; + const NSJSONWritingOptions options = format == QLatin1String("json-pretty") + ? NSJSONWritingPrettyPrinted : 0; + data = [NSJSONSerialization dataWithJSONObject:obj + options:options + error:&error]; + if (Q_UNLIKELY(!data)) { + errorString = [error localizedDescription]; + } + } else { + errorString = @"Property list object cannot be converted to JSON data"; + } + } else if (format == QLatin1String("xml1") || format == QLatin1String("binary1")) { + const NSPropertyListFormat plistFormat = format == QLatin1String("xml1") + ? NSPropertyListXMLFormat_v1_0 + : NSPropertyListBinaryFormat_v1_0; + + error = nil; + errorString = nil; + data = [NSPropertyListSerialization dataWithPropertyList:obj + format:plistFormat + options:0 + error:&error]; + if (Q_UNLIKELY(!data)) { + errorString = [error localizedDescription]; + } + } else { + errorString = [NSString stringWithFormat:@"Property lists cannot be written in the '%s' " + @"format", format.toUtf8().constData()]; + } + + if (Q_UNLIKELY(!data)) { + context->throwError(QString::fromNSString(errorString)); + } + + return QByteArray::fromNSData(data); + } +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionPropertyList(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newQMetaObject(&PropertyList::staticMetaObject, + engine->newFunction(&PropertyList::ctor)); + extensionObject.setProperty(QStringLiteral("PropertyList"), obj); +} diff --git a/src/lib/corelib/jsextensions/propertylistutils.h b/src/lib/corelib/jsextensions/propertylistutils.h new file mode 100644 index 00000000..0fd9832c --- /dev/null +++ b/src/lib/corelib/jsextensions/propertylistutils.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2014 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPROPERTYLISTUTILS_H +#define QPROPERTYLISTUTILS_H + +#include +#import + +#if !defined(__OBJC__) || !defined(__cplusplus) +#error "This file must be included from Objective-C++" +#endif + +class QPropertyListUtils +{ + Q_DISABLE_COPY(QPropertyListUtils) + +public: + static QVariant fromPropertyList(id plist); + static id toPropertyList(const QVariant &map); + +private: + QPropertyListUtils(); +}; + +template +QMap qHashToMap(const QHash &hash) { + QMap map; + QHashIterator i(hash); + while (i.hasNext()) { + i.next(); + map.insert(i.key(), i.value()); + } + return map; +} + +#endif // QPROPERTYLISTUTILS_H diff --git a/src/lib/corelib/jsextensions/propertylistutils.mm b/src/lib/corelib/jsextensions/propertylistutils.mm new file mode 100644 index 00000000..704b1a8c --- /dev/null +++ b/src/lib/corelib/jsextensions/propertylistutils.mm @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Petroules Corporation. +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#import +#include "propertylistutils.h" +#include +#include +#include +#include + +static QVariant fromObject(id obj); +static QVariantMap fromDictionary(NSDictionary *dict); +static QVariantList fromArray(NSArray *array); + +static QVariant fromObject(id obj) +{ + QVariant value; + if (!obj) { + return value; + } else if ([obj isKindOfClass:[NSDictionary class]]) { + value = fromDictionary(obj); + } else if ([obj isKindOfClass:[NSArray class]]) { + value = fromArray(obj); + } else if ([obj isKindOfClass:[NSString class]]) { + value = QString::fromNSString(obj); + } else if ([obj isKindOfClass:[NSData class]]) { + value = QByteArray::fromNSData(obj); + } else if ([obj isKindOfClass:[NSDate class]]) { + value = QDateTime::fromNSDate(obj); + } else if ([obj isKindOfClass:[NSNumber class]]) { + if (strcmp([(NSNumber *)obj objCType], @encode(BOOL)) == 0) { + value = static_cast([obj boolValue]); + } else if (strcmp([(NSNumber *)obj objCType], @encode(signed char)) == 0) { + value = [obj charValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(unsigned char)) == 0) { + value = [obj unsignedCharValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(signed short)) == 0) { + value = [obj shortValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(unsigned short)) == 0) { + value = [obj unsignedShortValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(signed int)) == 0) { + value = [obj intValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(unsigned int)) == 0) { + value = [obj unsignedIntValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(signed long long)) == 0) { + value = [obj longLongValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(unsigned long long)) == 0) { + value = [obj unsignedLongLongValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(float)) == 0) { + value = [obj floatValue]; + } else if (strcmp([(NSNumber *)obj objCType], @encode(double)) == 0) { + value = [obj doubleValue]; + } else { + // NSDecimal or unknown + value = [obj doubleValue]; + } + } else if ([obj isKindOfClass:[NSNull class]]) { + // A null variant, close enough... + } else { + // unknown + } + + return value; +} + +static QVariantMap fromDictionary(NSDictionary *dict) +{ + QVariantMap map; + for (NSString *key in dict) + map[QString::fromNSString(key)] = fromObject([dict objectForKey:key]); + return map; +} + +static QVariantList fromArray(NSArray *array) +{ + QVariantList list; + for (id obj in array) + list.push_back(fromObject(obj)); + return list; +} + +QVariant QPropertyListUtils::fromPropertyList(id plist) +{ + return fromObject(plist); +} + +static id toObject(const QVariant &variant); +static NSDictionary *toDictionary(const QVariantMap &map); +static NSArray *toArray(const QVariantList &list); + +static id toObject(const QVariant &variant) +{ + if (variant.userType() == QMetaType::QVariantHash) { + return toDictionary(qHashToMap(variant.toHash())); + } else if (variant.userType() == QMetaType::QVariantMap) { + return toDictionary(variant.toMap()); + } else if (variant.userType() == QMetaType::QVariantList) { + return toArray(variant.toList()); + } else if (variant.userType() == QMetaType::QString) { + return variant.toString().toNSString(); + } else if (variant.userType() == QMetaType::QByteArray) { + return variant.toByteArray().toNSData(); + } else if (variant.userType() == QMetaType::QDate || + variant.userType() == QMetaType::QDateTime) { + return variant.toDateTime().toNSDate(); + } else if (variant.userType() == QMetaType::Bool) { + return variant.toBool() + ? [NSNumber numberWithBool:YES] + : [NSNumber numberWithBool:NO]; + } else if (variant.userType() == QMetaType::Char || + variant.userType() == QMetaType::Int) { + return [NSNumber numberWithInt:variant.toInt()]; + } else if (variant.userType() == QMetaType::UInt) { + return [NSNumber numberWithUnsignedInt:variant.toUInt()]; + } else if (variant.userType() == QMetaType::LongLong) { + return [NSNumber numberWithLongLong:variant.toLongLong()]; + } else if (variant.userType() == QMetaType::ULongLong) { + return [NSNumber numberWithUnsignedLongLong:variant.toULongLong()]; + } else if (variant.userType() == QMetaType::Double) { + return [NSNumber numberWithDouble:variant.toDouble()]; + } else { + return [NSNull null]; + } +} + +static NSDictionary *toDictionary(const QVariantMap &map) +{ + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + QMapIterator i(map); + while (i.hasNext()) { + i.next(); + [dict setObject:toObject(i.value()) forKey:i.key().toNSString()]; + } + return [NSDictionary dictionaryWithDictionary:dict]; +} + +static NSArray *toArray(const QVariantList &list) +{ + NSMutableArray *array = [NSMutableArray array]; + for (const QVariant &variant : list) + [array addObject:toObject(variant)]; + return [NSArray arrayWithArray:array]; +} + +id QPropertyListUtils::toPropertyList(const QVariant &variant) +{ + return toObject(variant); +} diff --git a/src/lib/corelib/jsextensions/temporarydir.cpp b/src/lib/corelib/jsextensions/temporarydir.cpp new file mode 100644 index 00000000..470d21d2 --- /dev/null +++ b/src/lib/corelib/jsextensions/temporarydir.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static bool tempDirIsCanonical() +{ +#if QT_VERSION >= 0x050c00 + return true; +#endif + return false; +} + +class TemporaryDir : public QObject, public QScriptable +{ + Q_OBJECT +public: + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + TemporaryDir(QScriptContext *context); + Q_INVOKABLE bool isValid() const; + Q_INVOKABLE QString path() const; + Q_INVOKABLE bool remove(); +private: + QTemporaryDir dir; +}; + +QScriptValue TemporaryDir::ctor(QScriptContext *context, QScriptEngine *engine) +{ + const auto se = static_cast(engine); + const DubiousContextList dubiousContexts({ + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("qbs.TemporaryDir"), dubiousContexts); + + const auto t = new TemporaryDir(context); + QScriptValue obj = engine->newQObject(t, QScriptEngine::ScriptOwnership); + return obj; +} + +TemporaryDir::TemporaryDir(QScriptContext *context) +{ + Q_UNUSED(context); + dir.setAutoRemove(false); +} + +bool TemporaryDir::isValid() const +{ + return dir.isValid(); +} + +QString TemporaryDir::path() const +{ + return tempDirIsCanonical() ? dir.path() : QFileInfo(dir.path()).canonicalFilePath(); +} + +bool TemporaryDir::remove() +{ + return dir.remove(); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionTemporaryDir(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newQMetaObject(&TemporaryDir::staticMetaObject, + engine->newFunction(&TemporaryDir::ctor)); + extensionObject.setProperty(QStringLiteral("TemporaryDir"), obj); +} + +#include "temporarydir.moc" diff --git a/src/lib/corelib/jsextensions/textfile.cpp b/src/lib/corelib/jsextensions/textfile.cpp new file mode 100644 index 00000000..04d76437 --- /dev/null +++ b/src/lib/corelib/jsextensions/textfile.cpp @@ -0,0 +1,262 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#else +#include +#endif + +#include +#include +#include + +namespace qbs { +namespace Internal { + +class TextFile : public QObject, public QScriptable, public ResourceAcquiringScriptObject +{ + Q_OBJECT +public: + enum OpenMode + { + ReadOnly = 1, + WriteOnly = 2, + ReadWrite = ReadOnly | WriteOnly, + Append = 4 + }; + Q_ENUM(OpenMode) + + static QScriptValue ctor(QScriptContext *context, QScriptEngine *engine); + + Q_INVOKABLE void close(); + Q_INVOKABLE QString filePath(); + Q_INVOKABLE void setCodec(const QString &codec); + Q_INVOKABLE QString readLine(); + Q_INVOKABLE QString readAll(); + Q_INVOKABLE bool atEof() const; + Q_INVOKABLE void truncate(); + Q_INVOKABLE void write(const QString &str); + Q_INVOKABLE void writeLine(const QString &str); + +private: + TextFile(QScriptContext *context, const QString &filePath, OpenMode mode = ReadOnly, + const QString &codec = QLatin1String("UTF-8")); + + bool checkForClosed() const; + + // ResourceAcquiringScriptObject implementation + void releaseResources() override; + + std::unique_ptr m_file; + QTextCodec *m_codec = nullptr; +}; + +QScriptValue TextFile::ctor(QScriptContext *context, QScriptEngine *engine) +{ + TextFile *t; + switch (context->argumentCount()) { + case 0: + return context->throwError(Tr::tr("TextFile constructor needs path of file to be opened.")); + case 1: + t = new TextFile(context, context->argument(0).toString()); + break; + case 2: + t = new TextFile(context, + context->argument(0).toString(), + static_cast(context->argument(1).toInt32()) + ); + break; + case 3: + t = new TextFile(context, + context->argument(0).toString(), + static_cast(context->argument(1).toInt32()), + context->argument(2).toString() + ); + break; + default: + return context->throwError(Tr::tr("TextFile constructor takes at most three parameters.")); + } + + const auto se = static_cast(engine); + se->addResourceAcquiringScriptObject(t); + const DubiousContextList dubiousContexts({ + DubiousContext(EvalContext::PropertyEvaluation, DubiousContext::SuggestMoving) + }); + se->checkContext(QStringLiteral("qbs.TextFile"), dubiousContexts); + se->setUsesIo(); + + return engine->newQObject(t, QScriptEngine::QtOwnership); +} + +TextFile::TextFile(QScriptContext *context, const QString &filePath, OpenMode mode, + const QString &codec) +{ + Q_UNUSED(codec) + Q_ASSERT(thisObject().engine() == engine()); + + m_file = std::make_unique(filePath); + const auto newCodec = QTextCodec::codecForName(qPrintable(codec)); + m_codec = newCodec ? newCodec : QTextCodec::codecForName("UTF-8"); + QIODevice::OpenMode m = QIODevice::NotOpen; + if (mode & ReadOnly) + m |= QIODevice::ReadOnly; + if (mode & WriteOnly) + m |= QIODevice::WriteOnly; + if (mode & Append) + m |= QIODevice::Append; + m |= QIODevice::Text; + if (Q_UNLIKELY(!m_file->open(m))) { + context->throwError(Tr::tr("Unable to open file '%1': %2") + .arg(filePath, m_file->errorString())); + m_file.reset(); + } +} + +void TextFile::close() +{ + if (checkForClosed()) + return; + m_file->close(); + m_file.reset(); +} + +QString TextFile::filePath() +{ + if (checkForClosed()) + return {}; + return QFileInfo(*m_file).absoluteFilePath(); +} + +void TextFile::setCodec(const QString &codec) +{ + if (checkForClosed()) + return; + const auto newCodec = QTextCodec::codecForName(qPrintable(codec)); + if (newCodec) + m_codec = newCodec; +} + +QString TextFile::readLine() +{ + if (checkForClosed()) + return {}; + auto result = m_codec->toUnicode(m_file->readLine()); + if (!result.isEmpty() && result.back() == QLatin1Char('\n')) + result.chop(1); + return result; +} + +QString TextFile::readAll() +{ + if (checkForClosed()) + return {}; + return m_codec->toUnicode(m_file->readAll()); +} + +bool TextFile::atEof() const +{ + if (checkForClosed()) + return true; + return m_file->atEnd(); +} + +void TextFile::truncate() +{ + if (checkForClosed()) + return; + m_file->resize(0); +} + +void TextFile::write(const QString &str) +{ + if (checkForClosed()) + return; + m_file->write(m_codec->fromUnicode(str)); +} + +void TextFile::writeLine(const QString &str) +{ + if (checkForClosed()) + return; + m_file->write(m_codec->fromUnicode(str)); + m_file->putChar('\n'); +} + +bool TextFile::checkForClosed() const +{ + if (m_file) + return false; + QScriptContext *ctx = context(); + if (ctx) + ctx->throwError(Tr::tr("Access to TextFile object that was already closed.")); + return true; +} + +void TextFile::releaseResources() +{ + close(); + deleteLater(); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionTextFile(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue obj = engine->newQMetaObject(&TextFile::staticMetaObject, + engine->newFunction(&TextFile::ctor)); + extensionObject.setProperty(QStringLiteral("TextFile"), obj); +} + +Q_DECLARE_METATYPE(qbs::Internal::TextFile *) + +#include "textfile.moc" diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp new file mode 100644 index 00000000..19afc6ca --- /dev/null +++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp @@ -0,0 +1,978 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(Q_OS_MACOS) || defined(Q_OS_OSX) +#include +#endif + +#ifdef __APPLE__ +#include +#include +#include +#include +#ifndef FAT_MAGIC_64 +#define FAT_MAGIC_64 0xcafebabf +#define FAT_CIGAM_64 0xbfbafeca +struct fat_arch_64 { + cpu_type_t cputype; + cpu_subtype_t cpusubtype; + uint64_t offset; + uint64_t size; + uint32_t align; + uint32_t reserved; +}; +#endif +#endif + + +#ifdef Q_OS_WIN +#include +#include +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class DummyLogSink : public ILogSink { + void doPrintMessage(LoggerLevel, const QString &, const QString &) override { } +}; + +class UtilitiesExtension : public QObject, QScriptable +{ + Q_OBJECT +public: + static QScriptValue js_ctor(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_canonicalArchitecture(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_canonicalPlatform(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_canonicalTargetArchitecture(QScriptContext *context, + QScriptEngine *engine); + static QScriptValue js_canonicalToolchain(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_cStringQuote(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_getHash(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_getNativeSetting(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_kernelVersion(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_nativeSettingGroups(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_rfc1034identifier(QScriptContext *context, QScriptEngine *engine); + + static QScriptValue js_smimeMessageContent(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_certificateInfo(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_signingIdentities(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_msvcCompilerInfo(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_clangClCompilerInfo(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_installedMSVCs(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_installedClangCls(QScriptContext *context, QScriptEngine *engine); + + static QScriptValue js_versionCompare(QScriptContext *context, QScriptEngine *engine); + + static QScriptValue js_qmlTypeInfo(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_builtinExtensionNames(QScriptContext *context, QScriptEngine *engine); + static QScriptValue js_isSharedLibrary(QScriptContext *context, QScriptEngine *engine); + + static QScriptValue js_getArchitecturesFromBinary(QScriptContext *context, + QScriptEngine *engine); +}; + +QScriptValue UtilitiesExtension::js_ctor(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(engine); + return context->throwError(Tr::tr("'Utilities' cannot be instantiated.")); +} + +QScriptValue UtilitiesExtension::js_canonicalPlatform(QScriptContext *context, + QScriptEngine *engine) +{ + const QScriptValue value = context->argument(0); + if (value.isUndefined() || value.isNull()) + return engine->toScriptValue(QStringList()); + + if (context->argumentCount() == 1 && value.isString()) { + return engine->toScriptValue([&value] { + QStringList list; + for (const auto &s : HostOsInfo::canonicalOSIdentifiers(value.toString())) + list.push_back(s); + return list; + }()); + } + + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("canonicalPlatform expects one argument of type string")); +} + +QScriptValue UtilitiesExtension::js_canonicalTargetArchitecture(QScriptContext *context, + QScriptEngine *engine) +{ + const QScriptValue arch = context->argument(0); + if (arch.isUndefined() || arch.isNull()) + return arch; + + QScriptValue endianness = context->argument(1); + if (endianness.isUndefined() || endianness.isNull()) + endianness = QString(); + const QScriptValue vendor = context->argument(2); + const QScriptValue system = context->argument(3); + const QScriptValue abi = context->argument(4); + + if (!arch.isString() || !endianness.isString() + || !vendor.isString() || !system.isString() || !abi.isString()) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("canonicalTargetArchitecture expects 1 to 5 arguments of type string")); + + return engine->toScriptValue(canonicalTargetArchitecture(arch.toString(), endianness.toString(), + vendor.toString(), + system.toString(), abi.toString())); +} + +QScriptValue UtilitiesExtension::js_canonicalArchitecture(QScriptContext *context, + QScriptEngine *engine) +{ + const QScriptValue value = context->argument(0); + if (value.isUndefined() || value.isNull()) + return value; + + if (context->argumentCount() == 1 && value.isString()) + return engine->toScriptValue(canonicalArchitecture(value.toString())); + + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("canonicalArchitecture expects one argument of type string")); +} + +QScriptValue UtilitiesExtension::js_canonicalToolchain(QScriptContext *context, + QScriptEngine *engine) +{ + QStringList toolchain; + for (int i = 0; i < context->argumentCount(); ++i) + toolchain << context->argument(i).toString(); + return engine->toScriptValue(canonicalToolchain(toolchain)); +} + +// copied from src/corelib/tools/qtools_p.h +Q_DECL_CONSTEXPR inline char toHexUpper(uint value) Q_DECL_NOTHROW +{ + return "0123456789ABCDEF"[value & 0xF]; +} + +Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW +{ + return ((c >= '0') && (c <= '9')) ? int(c - '0') : + ((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) : + ((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) : + /* otherwise */ -1; +} + +// copied from src/corelib/io/qdebug.cpp +static inline bool isPrintable(uchar c) +{ return c >= ' ' && c < 0x7f; } + +// modified +template +static inline QString escapedString(const Char *begin, int length, bool isUnicode = true) +{ + QChar quote(QLatin1Char('"')); + QString out = quote; + + bool lastWasHexEscape = false; + const Char *end = begin + length; + for (const Char *p = begin; p != end; ++p) { + // check if we need to insert "" to break an hex escape sequence + if (Q_UNLIKELY(lastWasHexEscape)) { + if (fromHex(*p) != -1) { + // yes, insert it + out += QLatin1Char('"'); + out += QLatin1Char('"'); + } + lastWasHexEscape = false; + } + + if (sizeof(Char) == sizeof(QChar)) { + // Surrogate characters are category Cs (Other_Surrogate), so isPrintable = false for them + int runLength = 0; + while (p + runLength != end && + QChar::isPrint(p[runLength]) && p[runLength] != '\\' && p[runLength] != '"') + ++runLength; + if (runLength) { + out += QString(reinterpret_cast(p), runLength); + p += runLength - 1; + continue; + } + } else if (isPrintable(*p) && *p != '\\' && *p != '"') { + QChar c = QLatin1Char(*p); + out += c; + continue; + } + + // print as an escape sequence (maybe, see below for surrogate pairs) + int buflen = 2; + ushort buf[sizeof "\\U12345678" - 1]; + buf[0] = '\\'; + + switch (*p) { + case '"': + case '\\': + buf[1] = *p; + break; + case '\b': + buf[1] = 'b'; + break; + case '\f': + buf[1] = 'f'; + break; + case '\n': + buf[1] = 'n'; + break; + case '\r': + buf[1] = 'r'; + break; + case '\t': + buf[1] = 't'; + break; + default: + if (!isUnicode) { + // print as hex escape + buf[1] = 'x'; + buf[2] = toHexUpper(uchar(*p) >> 4); + buf[3] = toHexUpper(uchar(*p)); + buflen = 4; + lastWasHexEscape = true; + break; + } + if (QChar::isHighSurrogate(*p)) { + if ((p + 1) != end && QChar::isLowSurrogate(p[1])) { + // properly-paired surrogates + uint ucs4 = QChar::surrogateToUcs4(*p, p[1]); + if (QChar::isPrint(ucs4)) { + buf[0] = *p; + buf[1] = p[1]; + buflen = 2; + } else { + buf[1] = 'U'; + buf[2] = '0'; // toHexUpper(ucs4 >> 32); + buf[3] = '0'; // toHexUpper(ucs4 >> 28); + buf[4] = toHexUpper(ucs4 >> 20); + buf[5] = toHexUpper(ucs4 >> 16); + buf[6] = toHexUpper(ucs4 >> 12); + buf[7] = toHexUpper(ucs4 >> 8); + buf[8] = toHexUpper(ucs4 >> 4); + buf[9] = toHexUpper(ucs4); + buflen = 10; + } + ++p; + break; + } + // improperly-paired surrogates, fall through + } + buf[1] = 'u'; + buf[2] = toHexUpper(ushort(*p) >> 12); + buf[3] = toHexUpper(ushort(*p) >> 8); + buf[4] = toHexUpper(*p >> 4); + buf[5] = toHexUpper(*p); + buflen = 6; + } + out += QString(reinterpret_cast(buf), buflen); + } + + out += quote; + return out; +} + +QScriptValue UtilitiesExtension::js_cStringQuote(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("cStringQuote expects 1 argument")); + } + QString value = context->argument(0).toString(); + return engine->toScriptValue(escapedString(reinterpret_cast(value.constData()), value.size())); +} + +QScriptValue UtilitiesExtension::js_getHash(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() < 1)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("getHash expects 1 argument")); + } + const QByteArray input = context->argument(0).toString().toLatin1(); + const QByteArray hash + = QCryptographicHash::hash(input, QCryptographicHash::Sha1).toHex().left(16); + return engine->toScriptValue(QString::fromLatin1(hash)); +} + +QScriptValue UtilitiesExtension::js_getNativeSetting(QScriptContext *context, QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() < 1 || context->argumentCount() > 3)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("getNativeSetting expects between 1 and 3 arguments")); + } + + QString key = context->argumentCount() > 1 ? context->argument(1).toString() : QString(); + + // We'll let empty string represent the default registry value + if (HostOsInfo::isWindowsHost() && key.isEmpty()) + key = StringConstants::dot(); + + QVariant defaultValue = context->argumentCount() > 2 ? context->argument(2).toVariant() : QVariant(); + + QSettings settings(context->argument(0).toString(), QSettings::NativeFormat); + QVariant value = settings.value(key, defaultValue); + return value.isNull() ? engine->undefinedValue() : engine->toScriptValue(value); +} + +QScriptValue UtilitiesExtension::js_kernelVersion(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + return engine->toScriptValue(QSysInfo::kernelVersion()); +} + +QScriptValue UtilitiesExtension::js_nativeSettingGroups(QScriptContext *context, + QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("nativeSettingGroups expects 1 argument")); + } + + QSettings settings(context->argument(0).toString(), QSettings::NativeFormat); + return engine->toScriptValue(settings.childGroups()); +} + +QScriptValue UtilitiesExtension::js_rfc1034identifier(QScriptContext *context, + QScriptEngine *engine) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("rfc1034Identifier expects 1 argument")); + const QString identifier = context->argument(0).toString(); + return engine->toScriptValue(HostOsInfo::rfc1034Identifier(identifier)); +} + +/** + * Reads the contents of the S/MIME message located at \p filePath. + * An equivalent command line would be: + * \code security cms -D -i -o \endcode + * or: + * \code openssl smime -verify -noverify -inform DER -in -out \endcode + * + * \note A provisioning profile is an S/MIME message whose contents are an XML property list, + * so this method can be used to read such files. + */ +QScriptValue UtilitiesExtension::js_smimeMessageContent(QScriptContext *context, + QScriptEngine *engine) +{ +#if !defined(Q_OS_MACOS) && !defined(Q_OS_OSX) + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("smimeMessageContent is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("smimeMessageContent expects 1 argument")); + + const QString filePath = context->argument(0).toString(); + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly)) + return engine->undefinedValue(); + + QByteArray content = smimeMessageContent(file.readAll()); + if (content.isEmpty()) + return engine->undefinedValue(); + return engine->toScriptValue(content); +#endif +} + +QScriptValue UtilitiesExtension::js_certificateInfo(QScriptContext *context, + QScriptEngine *engine) +{ +#if !defined(Q_OS_MACOS) && !defined(Q_OS_OSX) + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("certificateInfo is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("certificateInfo expects 1 argument")); + return engine->toScriptValue(certificateInfo(context->argument(0).toVariant().toByteArray())); +#endif +} + +// Rough command line equivalent: security find-identity -p codesigning -v +QScriptValue UtilitiesExtension::js_signingIdentities(QScriptContext *context, + QScriptEngine *engine) +{ +#if !defined(Q_OS_MACOS) && !defined(Q_OS_OSX) + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("signingIdentities is not available on this platform")); +#else + Q_UNUSED(context); + return engine->toScriptValue(identitiesProperties()); +#endif +} + +#ifdef Q_OS_WIN +// Try to detect the cross-architecture from the compiler path; prepend the host architecture +// if it is differ than the target architecture (e.g. something like x64_x86 and so forth). +static QString detectArchitecture(const QString &compilerFilePath, const QString &targetArch) +{ + const auto startIndex = compilerFilePath.lastIndexOf(QLatin1String("Host")); + if (startIndex == -1) + return targetArch; + const auto endIndex = compilerFilePath.indexOf(QLatin1Char('/'), startIndex); + if (endIndex == -1) + return targetArch; + const auto hostArch = compilerFilePath.mid(startIndex + 4, endIndex - startIndex - 4).toLower(); + if (hostArch.isEmpty() || (hostArch == targetArch)) + return targetArch; + return hostArch + QLatin1Char('_') + targetArch; +} + +static std::pair msvcCompilerInfoHelper( + const QString &compilerFilePath, + MSVC::CompilerLanguage language, + const QString &vcvarsallPath, + const QString &arch, + const QString &sdkVersion) +{ + QString detailedArch = detectArchitecture(compilerFilePath, arch); + MSVC msvc(compilerFilePath, std::move(detailedArch), sdkVersion); + VsEnvironmentDetector envdetector(vcvarsallPath); + if (!envdetector.start(&msvc)) + return { {}, QStringLiteral("Detecting the MSVC build environment failed: ") + + envdetector.errorString() }; + + try { + QVariantMap envMap; + const auto keys = msvc.environment.keys(); + for (const QString &key : keys) + envMap.insert(key, msvc.environment.value(key)); + + return { + QVariantMap { + {QStringLiteral("buildEnvironment"), envMap}, + {QStringLiteral("macros"), msvc.compilerDefines(compilerFilePath, language)}, + }, + {} + }; + } catch (const qbs::ErrorInfo &info) { + return { {}, info.toString() }; + } +} +#endif + +QScriptValue UtilitiesExtension::js_msvcCompilerInfo(QScriptContext *context, QScriptEngine *engine) +{ +#ifndef Q_OS_WIN + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("msvcCompilerInfo is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() < 3)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("msvcCompilerInfo expects 3 arguments")); + + const QString compilerFilePath = context->argument(0).toString(); + const QString compilerLanguage = context->argument(1).toString(); + const QString sdkVersion = + !context->argument(2).isNull() && !context->argument(2).isUndefined() + ? context->argument(2).toString() + : QString(); + MSVC::CompilerLanguage language; + if (compilerLanguage == QStringLiteral("c")) + language = MSVC::CLanguage; + else if (compilerLanguage == StringConstants::cppLang()) + language = MSVC::CPlusPlusLanguage; + else + return context->throwError(QScriptContext::TypeError, + QStringLiteral("msvcCompilerInfo expects \"c\" or \"cpp\" as its second argument")); + + const auto result = msvcCompilerInfoHelper( + compilerFilePath, + language, + {}, + MSVC::architectureFromClPath(compilerFilePath), + sdkVersion); + if (result.first.isEmpty()) + return context->throwError(QScriptContext::UnknownError, result.second); + return engine->toScriptValue(result.first); +#endif +} + +QScriptValue UtilitiesExtension::js_clangClCompilerInfo(QScriptContext *context, QScriptEngine *engine) +{ +#ifndef Q_OS_WIN + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("clangClCompilerInfo is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() < 5)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("clangClCompilerInfo expects 5 arguments")); + + const QString compilerFilePath = context->argument(0).toString(); + // architecture cannot be empty as vcvarsall.bat requires at least 1 arg, so fallback + // to host architecture if none is present + QString arch = !context->argument(1).isNull() && !context->argument(1).isUndefined() + ? context->argument(1).toString() + : HostOsInfo::hostOSArchitecture(); + QString vcvarsallPath = context->argument(2).toString(); + const QString compilerLanguage = + !context->argument(3).isNull() && !context->argument(3).isUndefined() + ? context->argument(3).toString() + : QString(); + const QString sdkVersion = + !context->argument(4).isNull() && !context->argument(4).isUndefined() + ? context->argument(4).toString() + : QString(); + MSVC::CompilerLanguage language; + if (compilerLanguage == QStringLiteral("c")) + language = MSVC::CLanguage; + else if (compilerLanguage == StringConstants::cppLang()) + language = MSVC::CPlusPlusLanguage; + else + return context->throwError(QScriptContext::TypeError, + QStringLiteral("clangClCompilerInfo expects \"c\" or \"cpp\" as its fourth argument")); + + const auto result = msvcCompilerInfoHelper( + compilerFilePath, language, vcvarsallPath, arch, sdkVersion); + if (result.first.isEmpty()) + return context->throwError(QScriptContext::UnknownError, result.second); + return engine->toScriptValue(result.first); +#endif +} + +QScriptValue UtilitiesExtension::js_installedMSVCs(QScriptContext *context, QScriptEngine *engine) +{ +#ifndef Q_OS_WIN + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("installedMSVCs is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() != 1)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("installedMSVCs expects 1 arguments")); + } + + const auto value0 = context->argument(0); + const auto hostArch = HostOsInfo::hostOSArchitecture(); + const auto preferredArch = !value0.isNull() && !value0.isUndefined() + ? value0.toString() + : hostArch; + + DummyLogSink dummySink; + Logger dummyLogger(&dummySink); + auto msvcs = MSVC::installedCompilers(dummyLogger); + + const auto predicate = [&preferredArch, &hostArch](const MSVC &msvc) + { + auto archPair = MSVC::getHostTargetArchPair(msvc.architecture); + return archPair.first != hostArch || preferredArch != archPair.second; + }; + Internal::removeIf(msvcs, predicate); + QVariantList result; + for (const auto &msvc: msvcs) + result.append(msvc.toVariantMap()); + return engine->toScriptValue(result); +#endif +} + +QScriptValue UtilitiesExtension::js_installedClangCls( + QScriptContext *context, QScriptEngine *engine) +{ +#ifndef Q_OS_WIN + Q_UNUSED(engine); + return context->throwError(QScriptContext::UnknownError, + QStringLiteral("installedClangCls is not available on this platform")); +#else + if (Q_UNLIKELY(context->argumentCount() != 1)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("installedClangCls expects 1 arguments")); + } + + const auto value0 = context->argument(0); + const auto path = !value0.isNull() && !value0.isUndefined() ? value0.toString() : QString(); + + DummyLogSink dummySink; + Logger dummyLogger(&dummySink); + auto compilers = ClangClInfo::installedCompilers({path}, dummyLogger); + QVariantList result; + for (const auto &compiler: compilers) + result.append(compiler.toVariantMap()); + return engine->toScriptValue(result); +#endif +} + +QScriptValue UtilitiesExtension::js_versionCompare(QScriptContext *context, QScriptEngine *engine) +{ + if (context->argumentCount() == 2) { + const QScriptValue value1 = context->argument(0); + const QScriptValue value2 = context->argument(1); + if (value1.isString() && value2.isString()) { + const auto a = Version::fromString(value1.toString()); + const auto b = Version::fromString(value2.toString()); + return engine->toScriptValue(compare(a, b)); + } + } + + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("versionCompare expects two arguments of type string")); +} + +QScriptValue UtilitiesExtension::js_qmlTypeInfo(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context); + return engine->toScriptValue(QString::fromStdString(qbs::LanguageInfo::qmlTypeInfo())); +} + +QScriptValue UtilitiesExtension::js_builtinExtensionNames(QScriptContext *context, + QScriptEngine *engine) +{ + Q_UNUSED(context); + return engine->toScriptValue(JsExtensions::extensionNames()); +} + +QScriptValue UtilitiesExtension::js_isSharedLibrary(QScriptContext *context, QScriptEngine *engine) +{ + if (context->argumentCount() == 1) { + const QScriptValue value = context->argument(0); + if (value.isString()) + return engine->toScriptValue(QLibrary::isLibrary(value.toString())); + } + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("isSharedLibrary expects one argument of type string")); +} + +#ifdef __APPLE__ +template T readInt(QIODevice *ioDevice, bool *ok, + bool swap, bool peek = false) { + const auto bytes = peek + ? ioDevice->peek(sizeof(T)) + : ioDevice->read(sizeof(T)); + if (bytes.size() != sizeof(T)) { + if (ok) + *ok = false; + return T(); + } + if (ok) + *ok = true; + T n = *reinterpret_cast(bytes.constData()); + return swap ? qbswap(n) : n; +} + +static QString archName(cpu_type_t cputype, cpu_subtype_t cpusubtype) +{ + switch (cputype) { + case CPU_TYPE_X86: + switch (cpusubtype) { + case CPU_SUBTYPE_X86_ALL: + return QStringLiteral("i386"); + default: + return {}; + } + case CPU_TYPE_X86_64: + switch (cpusubtype) { + case CPU_SUBTYPE_X86_64_ALL: + return QStringLiteral("x86_64"); + case CPU_SUBTYPE_X86_64_H: + return QStringLiteral("x86_64h"); + default: + return {}; + } + case CPU_TYPE_ARM: + switch (cpusubtype) { + case CPU_SUBTYPE_ARM_V7: + return QStringLiteral("armv7a"); + case CPU_SUBTYPE_ARM_V7S: + return QStringLiteral("armv7s"); + case CPU_SUBTYPE_ARM_V7K: + return QStringLiteral("armv7k"); + default: + return {}; + } + case CPU_TYPE_ARM64: + switch (cpusubtype) { + case CPU_SUBTYPE_ARM64_ALL: + return QStringLiteral("arm64"); + default: + return {}; + } + default: + return {}; + } +} + +static QStringList detectMachOArchs(QIODevice *device) +{ + bool ok; + bool foundMachO = false; + qint64 pos = device->pos(); + + char ar_header[SARMAG]; + if (device->read(ar_header, SARMAG) == SARMAG) { + if (strncmp(ar_header, ARMAG, SARMAG) == 0) { + while (!device->atEnd()) { + static_assert(sizeof(ar_hdr) == 60, "sizeof(ar_hdr) != 60"); + ar_hdr header; + if (device->read(reinterpret_cast(&header), + sizeof(ar_hdr)) != sizeof(ar_hdr)) + return {}; + + // If the file name is stored in the "extended format" manner, + // the real filename is prepended to the data section, so skip that many bytes + int filenameLength = 0; + if (strncmp(header.ar_name, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0) { + char arName[sizeof(header.ar_name)] = { 0 }; + memcpy(arName, header.ar_name + sizeof(AR_EFMT1) - 1, + sizeof(header.ar_name) - (sizeof(AR_EFMT1) - 1) - 1); + filenameLength = strtoul(arName, nullptr, 10); + if (device->read(filenameLength).size() != filenameLength) + return {}; + } + + switch (readInt(device, nullptr, false, true)) { + case MH_CIGAM: + case MH_CIGAM_64: + case MH_MAGIC: + case MH_MAGIC_64: + foundMachO = true; + break; + default: { + // Skip the data and go to the next archive member... + char szBuf[sizeof(header.ar_size) + 1] = { 0 }; + memcpy(szBuf, header.ar_size, sizeof(header.ar_size)); + int sz = static_cast(strtoul(szBuf, nullptr, 10)); + if (sz % 2 != 0) + ++sz; + sz -= filenameLength; + const auto data = device->read(sz); + if (data.size() != sz) + return {}; + } + } + + if (foundMachO) + break; + } + } + } + + // Wasn't an archive file, so try a fat file + if (!foundMachO && !device->seek(pos)) + return {}; + + pos = device->pos(); + + fat_header fatheader; + fatheader.magic = readInt(device, nullptr, false); + if (fatheader.magic == FAT_MAGIC || fatheader.magic == FAT_CIGAM || + fatheader.magic == FAT_MAGIC_64 || fatheader.magic == FAT_CIGAM_64) { + const bool swap = fatheader.magic == FAT_CIGAM || fatheader.magic == FAT_CIGAM_64; + const bool is64bit = fatheader.magic == FAT_MAGIC_64 || fatheader.magic == FAT_CIGAM_64; + fatheader.nfat_arch = readInt(device, &ok, swap); + if (!ok) + return {}; + + QStringList archs; + + for (uint32_t n = 0; n < fatheader.nfat_arch; ++n) { + fat_arch_64 fatarch; + static_assert(sizeof(fat_arch_64) == 32, "sizeof(fat_arch_64) != 32"); + static_assert(sizeof(fat_arch) == 20, "sizeof(fat_arch) != 20"); + const qint64 expectedBytes = is64bit ? sizeof(fat_arch_64) : sizeof(fat_arch); + if (device->read(reinterpret_cast(&fatarch), expectedBytes) != expectedBytes) + return {}; + + if (swap) { + fatarch.cputype = qbswap(fatarch.cputype); + fatarch.cpusubtype = qbswap(fatarch.cpusubtype); + } + + const QString name = archName(fatarch.cputype, fatarch.cpusubtype); + if (name.isEmpty()) { + qWarning("Unknown cputype %d and cpusubtype %d", + fatarch.cputype, fatarch.cpusubtype); + return {}; + } + archs.push_back(name); + } + + std::sort(archs.begin(), archs.end()); + return archs; + } + + // Wasn't a fat file, so we just read a thin Mach-O from the original offset + if (!device->seek(pos)) + return {}; + + bool swap = false; + mach_header header; + header.magic = readInt(device, nullptr, swap); + switch (header.magic) { + case MH_CIGAM: + case MH_CIGAM_64: + swap = true; + break; + case MH_MAGIC: + case MH_MAGIC_64: + break; + default: + return {}; + } + + header.cputype = static_cast(readInt(device, &ok, swap)); + if (!ok) + return {}; + + header.cpusubtype = static_cast(readInt(device, &ok, swap)); + if (!ok) + return {}; + + const QString name = archName(header.cputype, header.cpusubtype); + if (name.isEmpty()) { + qWarning("Unknown cputype %d and cpusubtype %d", + header.cputype, header.cpusubtype); + return {}; + } + return {name}; +} +#endif + +QScriptValue UtilitiesExtension::js_getArchitecturesFromBinary(QScriptContext *context, + QScriptEngine *engine) +{ + if (context->argumentCount() != 1) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("getArchitecturesFromBinary expects exactly one argument")); + } + const QScriptValue arg = context->argument(0); + if (!arg.isString()) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("getArchitecturesFromBinary expects a string argument")); + } + QStringList archs; +#ifdef __APPLE__ + QFile file(arg.toString()); + if (!file.open(QIODevice::ReadOnly)) { + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("Failed to open file '%1': %2") + .arg(file.fileName(), file.errorString())); + } + archs = detectMachOArchs(&file); +#endif // __APPLE__ + return engine->toScriptValue(archs); +} + +} // namespace Internal +} // namespace qbs + +void initializeJsExtensionUtilities(QScriptValue extensionObject) +{ + using namespace qbs::Internal; + QScriptEngine *engine = extensionObject.engine(); + QScriptValue environmentObj = engine->newQMetaObject(&UtilitiesExtension::staticMetaObject, + engine->newFunction(&UtilitiesExtension::js_ctor)); + environmentObj.setProperty(QStringLiteral("canonicalArchitecture"), + engine->newFunction(UtilitiesExtension::js_canonicalArchitecture, 1)); + environmentObj.setProperty(QStringLiteral("canonicalPlatform"), + engine->newFunction(UtilitiesExtension::js_canonicalPlatform, 1)); + environmentObj.setProperty(QStringLiteral("canonicalTargetArchitecture"), + engine->newFunction( + UtilitiesExtension::js_canonicalTargetArchitecture, 4)); + environmentObj.setProperty(QStringLiteral("canonicalToolchain"), + engine->newFunction(UtilitiesExtension::js_canonicalToolchain)); + environmentObj.setProperty(QStringLiteral("cStringQuote"), + engine->newFunction(UtilitiesExtension::js_cStringQuote, 1)); + environmentObj.setProperty(QStringLiteral("getHash"), + engine->newFunction(UtilitiesExtension::js_getHash, 1)); + environmentObj.setProperty(QStringLiteral("getNativeSetting"), + engine->newFunction(UtilitiesExtension::js_getNativeSetting, 3)); + environmentObj.setProperty(QStringLiteral("kernelVersion"), + engine->newFunction(UtilitiesExtension::js_kernelVersion, 0)); + environmentObj.setProperty(QStringLiteral("nativeSettingGroups"), + engine->newFunction(UtilitiesExtension::js_nativeSettingGroups, 1)); + environmentObj.setProperty(QStringLiteral("rfc1034Identifier"), + engine->newFunction(UtilitiesExtension::js_rfc1034identifier, 1)); + environmentObj.setProperty(QStringLiteral("smimeMessageContent"), + engine->newFunction(UtilitiesExtension::js_smimeMessageContent, 1)); + environmentObj.setProperty(QStringLiteral("certificateInfo"), + engine->newFunction(UtilitiesExtension::js_certificateInfo, 1)); + environmentObj.setProperty(QStringLiteral("signingIdentities"), + engine->newFunction(UtilitiesExtension::js_signingIdentities, 0)); + environmentObj.setProperty(QStringLiteral("msvcCompilerInfo"), + engine->newFunction(UtilitiesExtension::js_msvcCompilerInfo, 1)); + environmentObj.setProperty(QStringLiteral("clangClCompilerInfo"), + engine->newFunction(UtilitiesExtension::js_clangClCompilerInfo, 1)); + environmentObj.setProperty(QStringLiteral("installedMSVCs"), + engine->newFunction(UtilitiesExtension::js_installedMSVCs, 1)); + environmentObj.setProperty(QStringLiteral("installedClangCls"), + engine->newFunction(UtilitiesExtension::js_installedClangCls, 1)); + environmentObj.setProperty(QStringLiteral("versionCompare"), + engine->newFunction(UtilitiesExtension::js_versionCompare, 2)); + environmentObj.setProperty(QStringLiteral("qmlTypeInfo"), + engine->newFunction(UtilitiesExtension::js_qmlTypeInfo, 0)); + environmentObj.setProperty(QStringLiteral("builtinExtensionNames"), + engine->newFunction(UtilitiesExtension::js_builtinExtensionNames, 0)); + environmentObj.setProperty(QStringLiteral("isSharedLibrary"), + engine->newFunction(UtilitiesExtension::js_isSharedLibrary, 1)); + environmentObj.setProperty(QStringLiteral("getArchitecturesFromBinary"), + engine->newFunction(UtilitiesExtension::js_getArchitecturesFromBinary, 1)); + extensionObject.setProperty(QStringLiteral("Utilities"), environmentObj); +} + +Q_DECLARE_METATYPE(qbs::Internal::UtilitiesExtension *) + +#include "utilitiesextension.moc" diff --git a/src/lib/corelib/language/artifactproperties.cpp b/src/lib/corelib/language/artifactproperties.cpp new file mode 100644 index 00000000..011e58d8 --- /dev/null +++ b/src/lib/corelib/language/artifactproperties.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "artifactproperties.h" +#include + +namespace qbs { +namespace Internal { + +ArtifactPropertiesPtr ArtifactProperties::create() +{ + return ArtifactPropertiesPtr(new ArtifactProperties); +} + +ArtifactProperties::ArtifactProperties() = default; + +FileTags ArtifactProperties::extraFileTags() const +{ + return m_extraFileTags; +} + +void ArtifactProperties::addExtraFileTags(const FileTags &extraFileTags) +{ + m_extraFileTags.unite(extraFileTags); +} + +bool operator==(const ArtifactProperties &ap1, const ArtifactProperties &ap2) +{ + return ap1.fileTagsFilter() == ap2.fileTagsFilter() + && ap1.extraFileTags() == ap2.extraFileTags() + && !ap1.propertyMap() == !ap2.propertyMap() + && *ap1.propertyMap() == *ap2.propertyMap(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/artifactproperties.h b/src/lib/corelib/language/artifactproperties.h new file mode 100644 index 00000000..856aa80c --- /dev/null +++ b/src/lib/corelib/language/artifactproperties.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ARTIFACTPROPERTIES_H +#define QBS_ARTIFACTPROPERTIES_H + +#include "filetags.h" +#include "forward_decls.h" +#include + +namespace qbs { +namespace Internal { + +class ArtifactProperties +{ +public: + static ArtifactPropertiesPtr create(); + + void setFileTagsFilter(const FileTags &filter) { m_fileTagsFilter = filter; } + FileTags fileTagsFilter() const { return m_fileTagsFilter; } + + PropertyMapPtr propertyMap() const { return m_propertyMap; } + void setPropertyMapInternal(const PropertyMapPtr &pmap) { m_propertyMap = pmap; } + + FileTags extraFileTags() const; + void addExtraFileTags(const FileTags &extraFileTags); + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_fileTagsFilter, m_extraFileTags, m_propertyMap); + } + +private: + ArtifactProperties(); + + FileTags m_fileTagsFilter; + FileTags m_extraFileTags; + PropertyMapPtr m_propertyMap; +}; + +bool operator==(const ArtifactProperties &ap1, const ArtifactProperties &ap2); +inline bool operator!=(const ArtifactProperties &ap1, const ArtifactProperties &ap2) { + return !(ap1 == ap2); +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ARTIFACTPROPERTIES_H diff --git a/src/lib/corelib/language/astimportshandler.cpp b/src/lib/corelib/language/astimportshandler.cpp new file mode 100644 index 00000000..d634af7e --- /dev/null +++ b/src/lib/corelib/language/astimportshandler.cpp @@ -0,0 +1,305 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "astimportshandler.h" + +#include "asttools.h" +#include "builtindeclarations.h" +#include "filecontext.h" +#include "itemreadervisitorstate.h" +#include "jsextensions/jsextensions.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +ASTImportsHandler::ASTImportsHandler(ItemReaderVisitorState &visitorState, Logger &logger, + const FileContextPtr &file) + : m_visitorState(visitorState) + , m_logger(logger) + , m_file(file) + , m_directory(FileInfo::path(m_file->filePath())) +{ +} + +void ASTImportsHandler::handleImports(const QbsQmlJS::AST::UiImportList *uiImportList) +{ + const auto searchPaths = m_file->searchPaths(); + for (const QString &searchPath : searchPaths) + collectPrototypes(searchPath + QStringLiteral("/imports"), QString()); + + // files in the same directory are available as prototypes + collectPrototypes(m_directory, QString()); + + bool baseImported = false; + for (const auto *it = uiImportList; it; it = it->next) + handleImport(it->import, &baseImported); + if (!baseImported) { + QStringRef qbsref(&StringConstants::qbsModule()); + QbsQmlJS::AST::UiQualifiedId qbsURI(qbsref); + qbsURI.finish(); + QbsQmlJS::AST::UiImport imp(&qbsURI); + handleImport(&imp, &baseImported); + } + + for (auto it = m_jsImports.constBegin(); it != m_jsImports.constEnd(); ++it) + m_file->addJsImport(it.value()); +} + +void ASTImportsHandler::handleImport(const QbsQmlJS::AST::UiImport *import, bool *baseImported) +{ + QStringList importUri; + bool isBase = false; + if (import->importUri) { + importUri = toStringList(import->importUri); + isBase = (importUri.size() == 1 && importUri.front() == StringConstants::qbsModule()) + || (importUri.size() == 2 && importUri.front() == StringConstants::qbsModule() + && importUri.last() == StringConstants::baseVar()); + if (isBase) { + *baseImported = true; + checkImportVersion(import->versionToken); + } else if (import->versionToken.length) { + m_logger.printWarning(ErrorInfo(Tr::tr("Superfluous version specification."), + toCodeLocation(m_file->filePath(), import->versionToken))); + } + } + + QString as; + if (isBase) { + if (Q_UNLIKELY(!import->importId.isNull())) { + throw ErrorInfo(Tr::tr("Import of qbs.base must have no 'as '"), + toCodeLocation(m_file->filePath(), import->importIdToken)); + } + } else { + if (importUri.size() == 2 && importUri.front() == StringConstants::qbsModule()) { + const QString extensionName = importUri.last(); + if (JsExtensions::hasExtension(extensionName)) { + if (Q_UNLIKELY(!import->importId.isNull())) { + throw ErrorInfo(Tr::tr("Import of built-in extension '%1' " + "must not have 'as' specifier.").arg(extensionName), + toCodeLocation(m_file->filePath(), import->asToken)); + } + if (Q_UNLIKELY(m_file->jsExtensions().contains(extensionName))) { + m_logger.printWarning(ErrorInfo(Tr::tr("Built-in extension '%1' already " + "imported.").arg(extensionName), + toCodeLocation(m_file->filePath(), + import->importToken))); + } else { + m_file->addJsExtension(extensionName); + } + return; + } + } + + if (import->importId.isNull()) { + if (!import->fileName.isNull()) { + throw ErrorInfo(Tr::tr("File imports require 'as '"), + toCodeLocation(m_file->filePath(), import->importToken)); + } + if (importUri.empty()) { + throw ErrorInfo(Tr::tr("Invalid import URI."), + toCodeLocation(m_file->filePath(), import->importToken)); + } + as = importUri.last(); + } else { + as = import->importId.toString(); + } + + if (Q_UNLIKELY(JsExtensions::hasExtension(as))) + throw ErrorInfo(Tr::tr("Cannot reuse the name of built-in extension '%1'.").arg(as), + toCodeLocation(m_file->filePath(), import->importIdToken)); + if (Q_UNLIKELY(!m_importAsNames.insert(as).second)) { + throw ErrorInfo(Tr::tr("Cannot import into the same name more than once."), + toCodeLocation(m_file->filePath(), import->importIdToken)); + } + } + + if (!import->fileName.isNull()) { + QString filePath = FileInfo::resolvePath(m_directory, import->fileName.toString()); + + QFileInfo fi(filePath); + if (Q_UNLIKELY(!fi.exists())) + throw ErrorInfo(Tr::tr("Cannot find imported file %0.") + .arg(QDir::toNativeSeparators(filePath)), + CodeLocation(m_file->filePath(), import->fileNameToken.startLine, + import->fileNameToken.startColumn)); + filePath = fi.canonicalFilePath(); + if (fi.isDir()) { + collectPrototypesAndJsCollections(filePath, as, + toCodeLocation(m_file->filePath(), import->fileNameToken)); + } else { + if (filePath.endsWith(QStringLiteral(".js"), Qt::CaseInsensitive)) { + JsImport &jsImport = m_jsImports[as]; + jsImport.scopeName = as; + jsImport.filePaths.push_back(filePath); + jsImport.location + = toCodeLocation(m_file->filePath(), import->firstSourceLocation()); + } else if (filePath.endsWith(QStringLiteral(".qbs"), Qt::CaseInsensitive)) { + m_typeNameToFile.insert(QStringList(as), filePath); + } else { + throw ErrorInfo(Tr::tr("Can only import .qbs and .js files"), + CodeLocation(m_file->filePath(), import->fileNameToken.startLine, + import->fileNameToken.startColumn)); + } + } + } else if (!importUri.empty()) { + const QString importPath = isBase + ? QStringLiteral("qbs/base") : importUri.join(QDir::separator()); + bool found = m_typeNameToFile.contains(importUri); + if (!found) { + const auto searchPaths = m_file->searchPaths(); + for (const QString &searchPath : searchPaths) { + const QFileInfo fi(FileInfo::resolvePath( + FileInfo::resolvePath(searchPath, + StringConstants::importsDir()), + importPath)); + if (fi.isDir()) { + // ### versioning, qbsdir file, etc. + const QString &resultPath = fi.absoluteFilePath(); + collectPrototypesAndJsCollections(resultPath, as, + toCodeLocation(m_file->filePath(), import->fileNameToken)); + found = true; + break; + } + } + } + if (Q_UNLIKELY(!found)) { + throw ErrorInfo(Tr::tr("import %1 not found") + .arg(importUri.join(QLatin1Char('.'))), + toCodeLocation(m_file->filePath(), import->fileNameToken)); + } + } +} + +Version ASTImportsHandler::readImportVersion(const QString &str, const CodeLocation &location) +{ + const Version v = Version::fromString(str); + if (Q_UNLIKELY(!v.isValid())) + throw ErrorInfo(Tr::tr("Cannot parse version number in import statement."), location); + if (Q_UNLIKELY(v.patchLevel() != 0)) { + throw ErrorInfo(Tr::tr("Version number in import statement cannot have more than " + "two components."), location); + } + return v; +} + +bool ASTImportsHandler::addPrototype(const QString &fileName, const QString &filePath, + const QString &as, bool needsCheck) +{ + if (needsCheck && fileName.size() <= 4) + return false; + + const QString componentName = fileName.left(fileName.size() - 4); + // ### validate componentName + + if (needsCheck && !componentName.at(0).isUpper()) + return false; + + QStringList prototypeName; + if (!as.isEmpty()) + prototypeName.push_back(as); + prototypeName.push_back(componentName); + if (!m_typeNameToFile.contains(prototypeName)) + m_typeNameToFile.insert(prototypeName, filePath); + return true; +} + +void ASTImportsHandler::checkImportVersion(const QbsQmlJS::AST::SourceLocation &versionToken) const +{ + if (!versionToken.length) + return; + const QString importVersionString + = m_file->content().mid(versionToken.offset, versionToken.length); + const Version importVersion = readImportVersion(importVersionString, + toCodeLocation(m_file->filePath(), versionToken)); + if (Q_UNLIKELY(importVersion != BuiltinDeclarations::instance().languageVersion())) + throw ErrorInfo(Tr::tr("Incompatible qbs language version %1. This is version %2.").arg( + importVersionString, + BuiltinDeclarations::instance().languageVersion().toString()), + toCodeLocation(m_file->filePath(), versionToken)); + +} + +void ASTImportsHandler::collectPrototypes(const QString &path, const QString &as) +{ + QStringList fileNames; // Yes, file *names*. + if (m_visitorState.findDirectoryEntries(path, &fileNames)) { + for (const QString &fileName : qAsConst(fileNames)) + addPrototype(fileName, path + QLatin1Char('/') + fileName, as, false); + return; + } + + QDirIterator dirIter(path, StringConstants::qbsFileWildcards()); + while (dirIter.hasNext()) { + const QString filePath = dirIter.next(); + const QString fileName = dirIter.fileName(); + if (addPrototype(fileName, filePath, as, true)) + fileNames << fileName; + } + m_visitorState.cacheDirectoryEntries(path, fileNames); + +} + +void ASTImportsHandler::collectPrototypesAndJsCollections(const QString &path, const QString &as, + const CodeLocation &location) +{ + collectPrototypes(path, as); + QDirIterator dirIter(path, StringConstants::jsFileWildcards()); + while (dirIter.hasNext()) { + dirIter.next(); + JsImport &jsImport = m_jsImports[as]; + if (jsImport.scopeName.isNull()) { + jsImport.scopeName = as; + jsImport.location = location; + } + jsImport.filePaths.push_back(dirIter.filePath()); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/astimportshandler.h b/src/lib/corelib/language/astimportshandler.h new file mode 100644 index 00000000..e9c2b6c2 --- /dev/null +++ b/src/lib/corelib/language/astimportshandler.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ASTIMPORTSHANDLER_H +#define QBS_ASTIMPORTSHANDLER_H + +#include "forward_decls.h" + +#include +#include + +#include +#include + +namespace qbs { +class CodeLocation; +class Version; + +namespace Internal { +class ItemReaderVisitorState; +class JsImport; +class Logger; + +class ASTImportsHandler +{ +public: + ASTImportsHandler(ItemReaderVisitorState &visitorState, Logger &logger, + const FileContextPtr &file); + + void handleImports(const QbsQmlJS::AST::UiImportList *uiImportList); + + QHash typeNameFileMap() const { return m_typeNameToFile; } + +private: + static Version readImportVersion(const QString &str, const CodeLocation &location); + + bool addPrototype(const QString &fileName, const QString &filePath, const QString &as, + bool needsCheck); + void checkImportVersion(const QbsQmlJS::AST::SourceLocation &versionToken) const; + void collectPrototypes(const QString &path, const QString &as); + void collectPrototypesAndJsCollections(const QString &path, const QString &as, + const CodeLocation &location); + void handleImport(const QbsQmlJS::AST::UiImport *import, bool *baseImported); + + ItemReaderVisitorState &m_visitorState; + Logger &m_logger; + const FileContextPtr &m_file; + const QString m_directory; + QHash m_typeNameToFile; + Set m_importAsNames; + + using JsImportsHash = QHash; + JsImportsHash m_jsImports; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/language/astpropertiesitemhandler.cpp b/src/lib/corelib/language/astpropertiesitemhandler.cpp new file mode 100644 index 00000000..b28fe7d7 --- /dev/null +++ b/src/lib/corelib/language/astpropertiesitemhandler.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "astpropertiesitemhandler.h" + +#include "item.h" +#include "value.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +ASTPropertiesItemHandler::ASTPropertiesItemHandler(Item *parentItem) : m_parentItem(parentItem) +{ +} + +void ASTPropertiesItemHandler::handlePropertiesItems() +{ + // TODO: Simply forbid Properties items to have child items and get rid of this check. + if (m_parentItem->type() != ItemType::Properties) + setupAlternatives(); +} + +void ASTPropertiesItemHandler::setupAlternatives() +{ + auto it = m_parentItem->m_children.begin(); + while (it != m_parentItem->m_children.end()) { + Item * const child = *it; + bool remove = false; + if (child->type() == ItemType::Properties) { + handlePropertiesBlock(child); + remove = m_parentItem->type() != ItemType::Export; + } + if (remove) + it = m_parentItem->m_children.erase(it); + else + ++it; + } +} + +class PropertiesBlockConverter +{ +public: + PropertiesBlockConverter(const JSSourceValue::AltProperty &condition, + const JSSourceValue::AltProperty &overrideListProperties, + Item *propertiesBlockContainer, const Item *propertiesBlock) + : m_propertiesBlockContainer(propertiesBlockContainer) + , m_propertiesBlock(propertiesBlock) + { + m_alternative.condition = condition; + m_alternative.overrideListProperties = overrideListProperties; + } + + void apply() + { + doApply(m_propertiesBlockContainer, m_propertiesBlock); + } + +private: + JSSourceValue::Alternative m_alternative; + Item * const m_propertiesBlockContainer; + const Item * const m_propertiesBlock; + + void doApply(Item *outer, const Item *inner) + { + for (auto it = inner->properties().constBegin(); + it != inner->properties().constEnd(); ++it) { + if (inner == m_propertiesBlock + && (it.key() == StringConstants::conditionProperty() + || it.key() == StringConstants::overrideListPropertiesProperty())) { + continue; + } + if (it.value()->type() == Value::ItemValueType) { + Item * const innerVal = std::static_pointer_cast(it.value())->item(); + ItemValuePtr outerVal = outer->itemProperty(it.key()); + if (!outerVal) { + outerVal = ItemValue::create(Item::create(outer->pool(), innerVal->type()), + true); + outer->setProperty(it.key(), outerVal); + } + doApply(outerVal->item(), innerVal); + } else if (it.value()->type() == Value::JSSourceValueType) { + const ValuePtr outerVal = outer->property(it.key()); + if (Q_UNLIKELY(outerVal && outerVal->type() != Value::JSSourceValueType)) { + throw ErrorInfo(Tr::tr("Incompatible value type in unconditional value at %1.") + .arg(outerVal->location().toString())); + } + doApply(it.key(), outer, std::static_pointer_cast(outerVal), + std::static_pointer_cast(it.value())); + } else { + QBS_CHECK(!"Unexpected value type in conditional value."); + } + } + } + + void doApply(const QString &propertyName, Item *item, JSSourceValuePtr value, + const JSSourceValuePtr &conditionalValue) + { + if (!value) { + value = JSSourceValue::create(true); + value->setFile(conditionalValue->file()); + item->setProperty(propertyName, value); + value->setSourceCode(StringConstants::baseVar()); + value->setSourceUsesBaseFlag(); + } + m_alternative.value = conditionalValue; + value->addAlternative(m_alternative); + } +}; + +static JSSourceValue::AltProperty getPropertyData(const Item *propertiesItem, const QString &name) +{ + const ValuePtr value = propertiesItem->property(name); + if (!value) { + if (name == StringConstants::conditionProperty()) { + throw ErrorInfo(Tr::tr("Properties.condition must be provided."), + propertiesItem->location()); + } + return JSSourceValue::AltProperty(StringConstants::falseValue(), + propertiesItem->location()); + } + if (Q_UNLIKELY(value->type() != Value::JSSourceValueType)) { + throw ErrorInfo(Tr::tr("Properties.%1 must be a value binding.").arg(name), + propertiesItem->location()); + } + if (name == StringConstants::overrideListPropertiesProperty()) { + const Item *parent = propertiesItem->parent(); + while (parent) { + if (parent->type() == ItemType::Product) + break; + parent = parent->parent(); + } + if (!parent) { + throw ErrorInfo(Tr::tr("Properties.overrideListProperties can only be set " + "in a Product item.")); + } + + } + const JSSourceValuePtr srcval = std::static_pointer_cast(value); + return JSSourceValue::AltProperty(srcval->sourceCodeForEvaluation(), srcval->location()); +} + +void ASTPropertiesItemHandler::handlePropertiesBlock(const Item *propertiesItem) +{ + const auto condition = getPropertyData(propertiesItem, StringConstants::conditionProperty()); + const auto overrideListProperties = getPropertyData(propertiesItem, + StringConstants::overrideListPropertiesProperty()); + PropertiesBlockConverter(condition, overrideListProperties, m_parentItem, + propertiesItem).apply(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/astpropertiesitemhandler.h b/src/lib/corelib/language/astpropertiesitemhandler.h new file mode 100644 index 00000000..413512ee --- /dev/null +++ b/src/lib/corelib/language/astpropertiesitemhandler.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ASTPROPERTIESITEMHANDLER_H +#define QBS_ASTPROPERTIESITEMHANDLER_H + +namespace qbs { +namespace Internal { +class Item; + +class ASTPropertiesItemHandler +{ +public: + ASTPropertiesItemHandler(Item *parentItem); + + void handlePropertiesItems(); + +private: + void setupAlternatives(); + void handlePropertiesBlock(const Item *propertiesItem); + + Item * const m_parentItem; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/language/asttools.cpp b/src/lib/corelib/language/asttools.cpp new file mode 100644 index 00000000..0d0c234c --- /dev/null +++ b/src/lib/corelib/language/asttools.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "asttools.h" +#include + +namespace qbs { +namespace Internal { + +QStringList toStringList(QbsQmlJS::AST::UiQualifiedId *qid) +{ + QStringList result; + for (; qid; qid = qid->next) + result.push_back(qid->name.toString()); + return result; +} + +CodeLocation toCodeLocation(const QString &filePath, const QbsQmlJS::AST::SourceLocation &location) +{ + return CodeLocation(filePath, location.startLine, location.startColumn); +} + +QString textOf(const QString &source, QbsQmlJS::AST::Node *node) +{ + if (!node) + return {}; + return source.mid(node->firstSourceLocation().begin(), + int(node->lastSourceLocation().end() - node->firstSourceLocation().begin())); +} + +QStringView textViewOf(const QString &source, QbsQmlJS::AST::Node *node) +{ + const quint32 firstBegin = node->firstSourceLocation().begin(); + return QStringView(source).mid(firstBegin, int(node->lastSourceLocation().end() - firstBegin)); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/asttools.h b/src/lib/corelib/language/asttools.h new file mode 100644 index 00000000..086d5929 --- /dev/null +++ b/src/lib/corelib/language/asttools.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ASTTOOLS_H +#define QBS_ASTTOOLS_H + +#include +#include +#include + +namespace qbs { +namespace Internal { + +QStringList toStringList(QbsQmlJS::AST::UiQualifiedId *qid); +CodeLocation toCodeLocation(const QString &filePath, const QbsQmlJS::AST::SourceLocation &location); +QString textOf(const QString &source, QbsQmlJS::AST::Node *node); +QStringView textViewOf(const QString &source, QbsQmlJS::AST::Node *node); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ASTTOOLS_H diff --git a/src/lib/corelib/language/builtindeclarations.cpp b/src/lib/corelib/language/builtindeclarations.cpp new file mode 100644 index 00000000..7004244f --- /dev/null +++ b/src/lib/corelib/language/builtindeclarations.cpp @@ -0,0 +1,608 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "builtindeclarations.h" + +#include "deprecationinfo.h" + +#include +#include +#include +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class AClassWithPublicConstructor : public BuiltinDeclarations { }; +Q_GLOBAL_STATIC(AClassWithPublicConstructor, theInstance) + +const char QBS_LANGUAGE_VERSION[] = "1.0"; + +BuiltinDeclarations::BuiltinDeclarations() + : m_languageVersion(Version::fromString(QLatin1String(QBS_LANGUAGE_VERSION))) + , m_typeMap(std::initializer_list>({ + { QStringLiteral("Artifact"), ItemType::Artifact }, + { QStringLiteral("Depends"), ItemType::Depends }, + { QStringLiteral("Export"), ItemType::Export }, + { QStringLiteral("FileTagger"), ItemType::FileTagger }, + { QStringLiteral("Group"), ItemType::Group }, + { QStringLiteral("JobLimit"), ItemType::JobLimit }, + { QStringLiteral("Module"), ItemType::Module }, + { QStringLiteral("ModuleProvider"), ItemType::ModuleProvider }, + { QStringLiteral("Parameter"), ItemType::Parameter }, + { QStringLiteral("Parameters"), ItemType::Parameters }, + { QStringLiteral("Probe"), ItemType::Probe }, + { QStringLiteral("Product"), ItemType::Product }, + { QStringLiteral("Profile"), ItemType::Profile }, + { QStringLiteral("Project"), ItemType::Project }, + { QStringLiteral("Properties"), ItemType::Properties }, // Callers have to handle the SubProject case. + { QStringLiteral("PropertyOptions"), ItemType::PropertyOptions }, + { QStringLiteral("Rule"), ItemType::Rule }, + { QStringLiteral("Scanner"), ItemType::Scanner }, + { QStringLiteral("SubProject"), ItemType::SubProject }, + { QStringLiteral("Transformer"), ItemType::Transformer } + })) +{ + addArtifactItem(); + addDependsItem(); + addExportItem(); + addFileTaggerItem(); + addGroupItem(); + addJobLimitItem(); + addModuleItem(); + addModuleProviderItem(); + addProbeItem(); + addProductItem(); + addProfileItem(); + addProjectItem(); + addPropertiesItem(); + addPropertyOptionsItem(); + addRuleItem(); + addSubprojectItem(); + addTransformerItem(); + addScannerItem(); +} + +const BuiltinDeclarations &BuiltinDeclarations::instance() +{ + return *theInstance; +} + +Version BuiltinDeclarations::languageVersion() const +{ + return m_languageVersion; +} + +QStringList BuiltinDeclarations::allTypeNames() const +{ + return m_typeMap.keys(); +} + +ItemDeclaration BuiltinDeclarations::declarationsForType(ItemType type) const +{ + return m_builtins.value(type); +} + +ItemType BuiltinDeclarations::typeForName(const QString &typeName, + const CodeLocation &location) const +{ + const auto it = m_typeMap.constFind(typeName); + if (it == m_typeMap.constEnd()) + throw ErrorInfo(Tr::tr("Unexpected item type '%1'.").arg(typeName), location); + return it.value(); +} + +QString BuiltinDeclarations::nameForType(ItemType itemType) const +{ + // Iterating is okay here, as this mapping is not used in hot code paths. + if (itemType == ItemType::PropertiesInSubProject) + return QStringLiteral("Properties"); + for (auto it = m_typeMap.constBegin(); it != m_typeMap.constEnd(); ++it) { + if (it.value() == itemType) + return it.key(); + } + QBS_CHECK(false); + return {}; +} + +QStringList BuiltinDeclarations::argumentNamesForScriptFunction(ItemType itemType, + const QString &scriptName) const +{ + const ItemDeclaration itemDecl = declarationsForType(itemType); + const auto properties = itemDecl.properties(); + for (const PropertyDeclaration &propDecl : properties) { + if (propDecl.name() == scriptName) + return propDecl.functionArgumentNames(); + } + QBS_CHECK(false); + return {}; +} + +void BuiltinDeclarations::insert(const ItemDeclaration &decl) +{ + m_builtins.insert(decl.type(), decl); +} + +static PropertyDeclaration conditionProperty() +{ + return PropertyDeclaration(StringConstants::conditionProperty(), PropertyDeclaration::Boolean, + StringConstants::trueValue()); +} + +static PropertyDeclaration alwaysRunProperty() +{ + return PropertyDeclaration(StringConstants::alwaysRunProperty(), PropertyDeclaration::Boolean, + StringConstants::falseValue()); +} + +static PropertyDeclaration nameProperty() +{ + return PropertyDeclaration(StringConstants::nameProperty(), PropertyDeclaration::String); +} + +static PropertyDeclaration buildDirProperty() +{ + return PropertyDeclaration(StringConstants::buildDirectoryProperty(), + PropertyDeclaration::Path); +} + +static PropertyDeclaration prepareScriptProperty() +{ + PropertyDeclaration decl(StringConstants::prepareProperty(), PropertyDeclaration::Variant, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + decl.setFunctionArgumentNames( + QStringList() + << StringConstants::projectVar() << StringConstants::productValue() + << StringConstants::inputsVar() << StringConstants::outputsVar() + << StringConstants::inputVar() << StringConstants::outputVar() + << StringConstants::explicitlyDependsOnVar()); + return decl; +} + +static PropertyDeclaration priorityProperty() +{ + return {StringConstants::priorityProperty(), PropertyDeclaration::Integer}; +} + +void BuiltinDeclarations::addArtifactItem() +{ + ItemDeclaration item(ItemType::Artifact); + PropertyDeclaration conditionDecl = conditionProperty(); + conditionDecl.setDeprecationInfo(DeprecationInfo(Version(1, 4), Tr::tr("If you need " + "dynamic artifacts, use the Rule.outputArtifacts script instead of Artifact items."))); + item << conditionDecl; + PropertyDeclaration fileNameDecl(StringConstants::fileNameProperty(), + PropertyDeclaration::String); + fileNameDecl.setDeprecationInfo(DeprecationInfo(Version(1, 4), + Tr::tr("Please use 'filePath' instead."))); + item << fileNameDecl; + item << PropertyDeclaration(StringConstants::filePathProperty(), PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::fileTagsProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::alwaysUpdatedProperty(), + PropertyDeclaration::Boolean, StringConstants::trueValue()); + insert(item); +} + +void BuiltinDeclarations::addDependsItem() +{ + ItemDeclaration item(ItemType::Depends); + item << conditionProperty(); + item << nameProperty(); + item << PropertyDeclaration(StringConstants::submodulesProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::requiredProperty(), PropertyDeclaration::Boolean, + StringConstants::trueValue()); + item << PropertyDeclaration(StringConstants::versionAtLeastProperty(), + PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::versionBelowProperty(), + PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::profilesProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::productTypesProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::limitToSubProjectProperty(), + PropertyDeclaration::Boolean, StringConstants::falseValue()); + item << PropertyDeclaration(StringConstants::multiplexConfigurationIdsProperty(), + PropertyDeclaration::StringList, QString(), + PropertyDeclaration::ReadOnlyFlag); + item << PropertyDeclaration(StringConstants::enableFallbackProperty(), + PropertyDeclaration::Boolean, StringConstants::trueValue()); + insert(item); +} + +void BuiltinDeclarations::addExportItem() +{ + ItemDeclaration item = moduleLikeItem(ItemType::Export); + item << PropertyDeclaration(StringConstants::prefixMappingProperty(), + PropertyDeclaration::Variant); + auto allowedChildTypes = item.allowedChildTypes(); + allowedChildTypes.insert(ItemType::Parameters); + allowedChildTypes.insert(ItemType::Properties); + item.setAllowedChildTypes(allowedChildTypes); + insert(item); +} + +void BuiltinDeclarations::addFileTaggerItem() +{ + ItemDeclaration item(ItemType::FileTagger); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::patternsProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::fileTagsProperty(), + PropertyDeclaration::StringList); + item << priorityProperty(); + insert(item); +} + +void BuiltinDeclarations::addGroupItem() +{ + ItemDeclaration item(ItemType::Group); + item.setAllowedChildTypes({ ItemType::Group }); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::nameProperty(), PropertyDeclaration::String, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::filesProperty(), PropertyDeclaration::PathList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::fileTagsFilterProperty(), + PropertyDeclaration::StringList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::excludeFilesProperty(), + PropertyDeclaration::PathList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::fileTagsProperty(), + PropertyDeclaration::StringList, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::prefixProperty(), PropertyDeclaration::String, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::overrideTagsProperty(), + PropertyDeclaration::Boolean, StringConstants::trueValue(), + PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::filesAreTargetsProperty(), + PropertyDeclaration::Boolean, StringConstants::falseValue(), + PropertyDeclaration::PropertyNotAvailableInConfig); + insert(item); +} + +void BuiltinDeclarations::addJobLimitItem() +{ + ItemDeclaration item(ItemType::JobLimit); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::jobPoolProperty(), PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::jobCountProperty(), PropertyDeclaration::Integer); + insert(item); +} + +void BuiltinDeclarations::addModuleItem() +{ + ItemDeclaration item = moduleLikeItem(ItemType::Module); + item << priorityProperty(); + insert(item); +} + +void BuiltinDeclarations::addModuleProviderItem() +{ + ItemDeclaration item(ItemType::ModuleProvider); + item << nameProperty() + << PropertyDeclaration(QStringLiteral("outputBaseDir"), PropertyDeclaration::String) + << PropertyDeclaration(QStringLiteral("relativeSearchPaths"), + PropertyDeclaration::StringList); + item.setAllowedChildTypes({ItemType::Probe}); + insert(item); +} + +ItemDeclaration BuiltinDeclarations::moduleLikeItem(ItemType type) +{ + ItemDeclaration item(type); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Group + << ItemType::Depends + << ItemType::FileTagger + << ItemType::JobLimit + << ItemType::Rule + << ItemType::Parameter + << ItemType::Probe + << ItemType::PropertyOptions + << ItemType::Scanner); + item << nameProperty(); + item << conditionProperty(); + PropertyDeclaration setupBuildEnvDecl(StringConstants::setupBuildEnvironmentProperty(), + PropertyDeclaration::Variant, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + setupBuildEnvDecl.setFunctionArgumentNames(QStringList{StringConstants::projectVar(), + StringConstants::productVar()}); + item << setupBuildEnvDecl; + PropertyDeclaration setupRunEnvDecl(StringConstants::setupRunEnvironmentProperty(), + PropertyDeclaration::Variant, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + setupRunEnvDecl.setFunctionArgumentNames(QStringList{StringConstants::projectVar(), + StringConstants::productVar()}); + item << setupRunEnvDecl; + item << PropertyDeclaration(StringConstants::validateProperty(), + PropertyDeclaration::Boolean, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::additionalProductTypesProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::versionProperty(), PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::presentProperty(), PropertyDeclaration::Boolean, + StringConstants::trueValue()); + return item; +} + +void BuiltinDeclarations::addProbeItem() +{ + ItemDeclaration item(ItemType::Probe); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::foundProperty(), PropertyDeclaration::Boolean, + StringConstants::falseValue()); + item << PropertyDeclaration(StringConstants::configureProperty(), PropertyDeclaration::Variant, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + insert(item); +} + +void BuiltinDeclarations::addProductItem() +{ + ItemDeclaration item(ItemType::Product); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Depends + << ItemType::Group + << ItemType::FileTagger + << ItemType::JobLimit + << ItemType::Export + << ItemType::Probe + << ItemType::Profile + << ItemType::PropertyOptions + << ItemType::Rule); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::typeProperty(), PropertyDeclaration::StringList, + StringConstants::emptyArrayValue()); + item << nameProperty(); + item << PropertyDeclaration(StringConstants::builtByDefaultProperty(), + PropertyDeclaration::Boolean, StringConstants::trueValue()); + PropertyDeclaration profilesDecl(StringConstants::profilesProperty(), + PropertyDeclaration::StringList); + profilesDecl.setDeprecationInfo(DeprecationInfo(Version::fromString(QStringLiteral("1.9.0")), + Tr::tr("Use qbs.profiles instead."))); + item << profilesDecl; + item << PropertyDeclaration(StringConstants::targetNameProperty(), PropertyDeclaration::String, + QStringLiteral("new String(name)" + ".replace(/[/\\\\?%*:|\"<>]/g, '_').valueOf()")); + item << buildDirProperty(); + item << PropertyDeclaration(StringConstants::destinationDirProperty(), + PropertyDeclaration::String, + StringConstants::buildDirectoryProperty()); + item << PropertyDeclaration(StringConstants::consoleApplicationProperty(), + PropertyDeclaration::Boolean); + item << PropertyDeclaration(StringConstants::filesProperty(), PropertyDeclaration::PathList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::excludeFilesProperty(), + PropertyDeclaration::PathList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::qbsSearchPathsProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::versionProperty(), PropertyDeclaration::String); + + item << PropertyDeclaration(StringConstants::multiplexByQbsPropertiesProperty(), + PropertyDeclaration::StringList, QStringLiteral("[\"profiles\"]")); + item << PropertyDeclaration(StringConstants::multiplexedTypeProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::aggregateProperty(), PropertyDeclaration::Boolean); + item << PropertyDeclaration(StringConstants::multiplexedProperty(), + PropertyDeclaration::Boolean, + QString(), PropertyDeclaration::ReadOnlyFlag); + item << PropertyDeclaration(StringConstants::multiplexConfigurationIdProperty(), + PropertyDeclaration::String, QString(), + PropertyDeclaration::ReadOnlyFlag); + item << PropertyDeclaration(StringConstants::qbsModuleProviders(), + PropertyDeclaration::StringList); + insert(item); +} + +void BuiltinDeclarations::addProfileItem() +{ + ItemDeclaration item(ItemType::Profile); + item << conditionProperty(); + item << nameProperty(); + item << PropertyDeclaration(StringConstants::baseProfileProperty(), + PropertyDeclaration::String); + insert(item); +} + +void BuiltinDeclarations::addProjectItem() +{ + ItemDeclaration item(ItemType::Project); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Project + << ItemType::PropertyOptions + << ItemType::SubProject + << ItemType::Product + << ItemType::Profile + << ItemType::Probe + << ItemType::FileTagger + << ItemType::JobLimit + << ItemType::Rule); + item << nameProperty(); + item << conditionProperty(); + item << buildDirProperty(); + item << PropertyDeclaration(StringConstants::minimumQbsVersionProperty(), + PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::sourceDirectoryProperty(), + PropertyDeclaration::Path); + item << PropertyDeclaration(StringConstants::profileProperty(), PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::referencesProperty(), + PropertyDeclaration::PathList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::qbsSearchPathsProperty(), + PropertyDeclaration::StringList, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + item << PropertyDeclaration(StringConstants::qbsModuleProviders(), + PropertyDeclaration::StringList); + insert(item); +} + +void BuiltinDeclarations::addPropertiesItem() +{ + ItemDeclaration item(ItemType::Properties); + item << conditionProperty(); + insert(item); +} + +void BuiltinDeclarations::addPropertyOptionsItem() +{ + ItemDeclaration item(ItemType::PropertyOptions); + item << nameProperty(); + item << PropertyDeclaration(StringConstants::allowedValuesProperty(), + PropertyDeclaration::Variant); + item << PropertyDeclaration(StringConstants::descriptionProperty(), + PropertyDeclaration::String); + item << PropertyDeclaration(StringConstants::removalVersionProperty(), + PropertyDeclaration::String); + insert(item); +} + +void BuiltinDeclarations::addRuleItem() +{ + ItemDeclaration item(ItemType::Rule); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Artifact); + item << conditionProperty(); + item << alwaysRunProperty(); + item << PropertyDeclaration(StringConstants::multiplexProperty(), PropertyDeclaration::Boolean, + StringConstants::falseValue()); + item << PropertyDeclaration(StringConstants::requiresInputsProperty(), + PropertyDeclaration::Boolean); + item << nameProperty(); + item << PropertyDeclaration(StringConstants::inputsProperty(), PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::outputFileTagsProperty(), + PropertyDeclaration::StringList); + PropertyDeclaration outputArtifactsDecl(StringConstants::outputArtifactsProperty(), + PropertyDeclaration::Variant, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + outputArtifactsDecl.setFunctionArgumentNames( + QStringList() + << StringConstants::projectVar() << StringConstants::productVar() + << StringConstants::inputsVar() << StringConstants::inputVar()); + item << outputArtifactsDecl; + PropertyDeclaration usingsDecl(QStringLiteral("usings"), PropertyDeclaration::StringList); + usingsDecl.setDeprecationInfo(DeprecationInfo(Version(1, 5), + Tr::tr("Use 'inputsFromDependencies' instead"))); + item << usingsDecl; + item << PropertyDeclaration(StringConstants::inputsFromDependenciesProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::auxiliaryInputsProperty(), + PropertyDeclaration::StringList); + PropertyDeclaration excludedAuxInputs(StringConstants::excludedAuxiliaryInputsProperty(), + PropertyDeclaration::StringList); + excludedAuxInputs.setDeprecationInfo(DeprecationInfo(Version(1, 14), + Tr::tr("Use 'excludedInputs' instead"))); + item << excludedAuxInputs; + item << PropertyDeclaration(StringConstants::excludedInputsProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::explicitlyDependsOnProperty(), + PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::explicitlyDependsOnFromDependenciesProperty(), + PropertyDeclaration::StringList); + item << prepareScriptProperty(); + insert(item); +} + +void BuiltinDeclarations::addSubprojectItem() +{ + ItemDeclaration item(ItemType::SubProject); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Project // needed, because we're adding this internally + << ItemType::PropertiesInSubProject + << ItemType::PropertyOptions); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::filePathProperty(), PropertyDeclaration::Path); + item << PropertyDeclaration(StringConstants::inheritPropertiesProperty(), + PropertyDeclaration::Boolean, + StringConstants::trueValue()); + insert(item); +} + +void BuiltinDeclarations::addTransformerItem() +{ + ItemDeclaration item(ItemType::Transformer); + item.setDeprecationInfo(DeprecationInfo(Version(1, 7), Tr::tr("Use the 'Rule' item instead."))); + item.setAllowedChildTypes(ItemDeclaration::TypeNames() + << ItemType::Artifact); + item << conditionProperty(); + item << alwaysRunProperty(); + item << PropertyDeclaration(StringConstants::inputsProperty(), PropertyDeclaration::PathList); + item << prepareScriptProperty(); + item << PropertyDeclaration(StringConstants::explicitlyDependsOnProperty(), + PropertyDeclaration::StringList); + insert(item); +} + +void BuiltinDeclarations::addScannerItem() +{ + ItemDeclaration item(ItemType::Scanner); + item << conditionProperty(); + item << PropertyDeclaration(StringConstants::inputsProperty(), PropertyDeclaration::StringList); + item << PropertyDeclaration(StringConstants::recursiveProperty(), PropertyDeclaration::Boolean, + StringConstants::falseValue()); + PropertyDeclaration searchPaths(StringConstants::searchPathsProperty(), + PropertyDeclaration::StringList); + searchPaths.setFunctionArgumentNames( + QStringList() + << StringConstants::projectVar() + << StringConstants::productVar() + << StringConstants::inputVar()); + item << searchPaths; + PropertyDeclaration scan(StringConstants::scanProperty(), PropertyDeclaration::Variant, + QString(), PropertyDeclaration::PropertyNotAvailableInConfig); + scan.setFunctionArgumentNames( + QStringList() + << StringConstants::projectVar() + << StringConstants::productVar() + << StringConstants::inputVar() + << StringConstants::filePathVar()); + item << scan; + insert(item); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/builtindeclarations.h b/src/lib/corelib/language/builtindeclarations.h new file mode 100644 index 00000000..9d7aee98 --- /dev/null +++ b/src/lib/corelib/language/builtindeclarations.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILTINDECLARATIONS_H +#define QBS_BUILTINDECLARATIONS_H + +#include "itemdeclaration.h" +#include "itemtype.h" + +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +class BuiltinDeclarations +{ +public: + static const BuiltinDeclarations &instance(); + + Version languageVersion() const; + QStringList allTypeNames() const; + ItemDeclaration declarationsForType(ItemType type) const; + ItemType typeForName(const QString &typeName, + const CodeLocation &location = CodeLocation()) const; + QString nameForType(ItemType itemType) const; + QStringList argumentNamesForScriptFunction(ItemType itemType, const QString &scriptName) const; + +protected: + BuiltinDeclarations(); + +private: + void insert(const ItemDeclaration &decl); + void addArtifactItem(); + void addDependsItem(); + void addExportItem(); + void addFileTaggerItem(); + void addGroupItem(); + void addJobLimitItem(); + void addModuleItem(); + void addModuleProviderItem(); + static ItemDeclaration moduleLikeItem(ItemType type); + void addProbeItem(); + void addProductItem(); + void addProfileItem(); + void addProjectItem(); + void addPropertiesItem(); + void addPropertyOptionsItem(); + void addRuleItem(); + void addSubprojectItem(); + void addTransformerItem(); + void addScannerItem(); + + const Version m_languageVersion; + QMap m_builtins; + const QHash m_typeMap; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_BUILTINDECLARATIONS_H diff --git a/src/lib/corelib/language/deprecationinfo.h b/src/lib/corelib/language/deprecationinfo.h new file mode 100644 index 00000000..89cd07f4 --- /dev/null +++ b/src/lib/corelib/language/deprecationinfo.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_DEPRECATIONINFO_H +#define QBS_DEPRECATIONINFO_H + +#include + +#include + +namespace qbs { +namespace Internal { + +class DeprecationInfo +{ +public: + explicit DeprecationInfo(const Version &removalVersion, + QString additionalUserInfo = QString()) + : m_removalVersion(removalVersion) + , m_additionalUserInfo(std::move(additionalUserInfo)) + {} + DeprecationInfo() = default; + + bool isValid() const { return m_removalVersion.isValid(); } + Version removalVersion() const { return m_removalVersion; } + QString additionalUserInfo() const { return m_additionalUserInfo; } + +private: + Version m_removalVersion; + QString m_additionalUserInfo; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/language/evaluationdata.h b/src/lib/corelib/language/evaluationdata.h new file mode 100644 index 00000000..791b2f23 --- /dev/null +++ b/src/lib/corelib/language/evaluationdata.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_EVALUATIONDATA_H +#define QBS_EVALUATIONDATA_H + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class Evaluator; +class Item; + +class EvaluationData +{ +public: + Evaluator *evaluator = nullptr; + const Item *item = nullptr; + mutable QHash valueCache; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_EVALUATIONDATA_H diff --git a/src/lib/corelib/language/evaluator.cpp b/src/lib/corelib/language/evaluator.cpp new file mode 100644 index 00000000..84272af2 --- /dev/null +++ b/src/lib/corelib/language/evaluator.cpp @@ -0,0 +1,286 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "evaluator.h" + +#include "evaluationdata.h" +#include "evaluatorscriptclass.h" +#include "filecontext.h" +#include "filetags.h" +#include "item.h" +#include "scriptengine.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +Evaluator::Evaluator(ScriptEngine *scriptEngine) + : m_scriptEngine(scriptEngine) + , m_scriptClass(new EvaluatorScriptClass(scriptEngine)) +{ +} + +Evaluator::~Evaluator() +{ + for (const auto &data : qAsConst(m_scriptValueMap)) + delete attachedPointer(data); + delete m_scriptClass; +} + +QScriptValue Evaluator::property(const Item *item, const QString &name) +{ + return scriptValue(item).property(name); +} + +QScriptValue Evaluator::value(const Item *item, const QString &name, bool *propertyWasSet) +{ + QScriptValue v; + evaluateProperty(&v, item, name, propertyWasSet); + return v; +} + +bool Evaluator::boolValue(const Item *item, const QString &name, + bool *propertyWasSet) +{ + return value(item, name, propertyWasSet).toBool(); +} + +int Evaluator::intValue(const Item *item, const QString &name, int defaultValue, + bool *propertyWasSet) +{ + QScriptValue v; + if (!evaluateProperty(&v, item, name, propertyWasSet)) + return defaultValue; + return v.toInt32(); +} + +FileTags Evaluator::fileTagsValue(const Item *item, const QString &name, bool *propertySet) +{ + return FileTags::fromStringList(stringListValue(item, name, propertySet)); +} + +QString Evaluator::stringValue(const Item *item, const QString &name, + const QString &defaultValue, bool *propertyWasSet) +{ + QScriptValue v; + if (!evaluateProperty(&v, item, name, propertyWasSet)) + return defaultValue; + return v.toString(); +} + +static QStringList toStringList(const QScriptValue &scriptValue) +{ + if (scriptValue.isString()) + return {scriptValue.toString()}; + if (scriptValue.isArray()) { + QStringList lst; + int i = 0; + for (;;) { + QScriptValue elem = scriptValue.property(i++); + if (!elem.isValid()) + break; + lst.push_back(elem.toString()); + } + return lst; + } + return {}; +} + +QStringList Evaluator::stringListValue(const Item *item, const QString &name, bool *propertyWasSet) +{ + const auto result = optionalStringListValue(item, name, propertyWasSet); + return result ? *result : QStringList(); +} + +std::optional Evaluator::optionalStringListValue( + const Item *item, const QString &name, bool *propertyWasSet) +{ + QScriptValue v = property(item, name); + handleEvaluationError(item, name, v); + if (propertyWasSet) + *propertyWasSet = isNonDefaultValue(item, name); + if (v.isUndefined()) + return std::nullopt; + return toStringList(v); +} + +bool Evaluator::isNonDefaultValue(const Item *item, const QString &name) const +{ + const ValueConstPtr v = item->property(name); + return v && (v->type() != Value::JSSourceValueType + || !static_cast(v.get())->isBuiltinDefaultValue()); +} + +void Evaluator::convertToPropertyType(const PropertyDeclaration &decl, const CodeLocation &loc, + QScriptValue &v) +{ + m_scriptClass->convertToPropertyType(decl, loc, v); +} + +QScriptValue Evaluator::scriptValue(const Item *item) +{ + QScriptValue &scriptValue = m_scriptValueMap[item]; + if (scriptValue.isObject()) { + // already initialized + return scriptValue; + } + + const auto edata = new EvaluationData; + edata->evaluator = this; + edata->item = item; + edata->item->setObserver(this); + + scriptValue = m_scriptEngine->newObject(m_scriptClass); + attachPointerTo(scriptValue, edata); + return scriptValue; +} + +void Evaluator::onItemPropertyChanged(Item *item) +{ + auto data = attachedPointer(m_scriptValueMap.value(item)); + if (data) + data->valueCache.clear(); +} + +void Evaluator::handleEvaluationError(const Item *item, const QString &name, + const QScriptValue &scriptValue) +{ + throwOnEvaluationError(m_scriptEngine, scriptValue, [&item, &name] () { + const ValueConstPtr &value = item->property(name); + return value ? value->location() : CodeLocation(); + }); +} + +void Evaluator::setPathPropertiesBaseDir(const QString &dirPath) +{ + m_scriptClass->setPathPropertiesBaseDir(dirPath); +} + +void Evaluator::clearPathPropertiesBaseDir() +{ + m_scriptClass->clearPathPropertiesBaseDir(); +} + +bool Evaluator::evaluateProperty(QScriptValue *result, const Item *item, const QString &name, + bool *propertyWasSet) +{ + *result = property(item, name); + handleEvaluationError(item, name, *result); + if (propertyWasSet) + *propertyWasSet = isNonDefaultValue(item, name); + return result->isValid() && !result->isUndefined(); +} + +Evaluator::FileContextScopes Evaluator::fileContextScopes(const FileContextConstPtr &file) +{ + FileContextScopes &result = m_fileContextScopesMap[file]; + if (!result.fileScope.isObject()) { + if (file->idScope()) + result.fileScope = scriptValue(file->idScope()); + else + result.fileScope = m_scriptEngine->newObject(); + result.fileScope.setProperty(StringConstants::filePathGlobalVar(), file->filePath()); + result.fileScope.setProperty(StringConstants::pathGlobalVar(), file->dirPath()); + } + if (!result.importScope.isObject()) { + try { + result.importScope = m_scriptEngine->newObject(); + setupScriptEngineForFile(m_scriptEngine, file, result.importScope, + ObserveMode::Enabled); + } catch (const ErrorInfo &e) { + result.importScope = m_scriptEngine->currentContext()->throwError(e.toString()); + } + } + return result; +} + +void Evaluator::setCachingEnabled(bool enabled) +{ + m_scriptClass->setValueCacheEnabled(enabled); +} + +PropertyDependencies Evaluator::propertyDependencies() const +{ + return m_scriptClass->propertyDependencies(); +} + +void Evaluator::clearPropertyDependencies() +{ + m_scriptClass->clearPropertyDependencies(); +} + +void throwOnEvaluationError(ScriptEngine *engine, const QScriptValue &scriptValue, + const std::function &provideFallbackCodeLocation) +{ + if (Q_LIKELY(!engine->hasErrorOrException(scriptValue))) + return; + QString message; + QString filePath; + int line = -1; + const QScriptValue value = scriptValue.isError() ? scriptValue + : engine->uncaughtException(); + if (value.isError()) { + QScriptValue v = value.property(QStringLiteral("message")); + if (v.isString()) + message = v.toString(); + v = value.property(StringConstants::fileNameProperty()); + if (v.isString()) + filePath = v.toString(); + v = value.property(QStringLiteral("lineNumber")); + if (v.isNumber()) + line = v.toInt32(); + throw ErrorInfo(message, CodeLocation(filePath, line, -1, false)); + } + message = value.toString(); + throw ErrorInfo(message, provideFallbackCodeLocation()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/evaluator.h b/src/lib/corelib/language/evaluator.h new file mode 100644 index 00000000..1e21391d --- /dev/null +++ b/src/lib/corelib/language/evaluator.h @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_EVALUATOR_H +#define QBS_EVALUATOR_H + +#include "forward_decls.h" +#include "itemobserver.h" +#include "qualifiedid.h" + +#include + +#include + +#include +#include + +namespace qbs { +namespace Internal { +class EvaluatorScriptClass; +class FileTags; +class Logger; +class PropertyDeclaration; +class ScriptEngine; + +class QBS_AUTOTEST_EXPORT Evaluator : private ItemObserver +{ + friend class SVConverter; + +public: + Evaluator(ScriptEngine *scriptEngine); + ~Evaluator() override; + + ScriptEngine *engine() const { return m_scriptEngine; } + QScriptValue property(const Item *item, const QString &name); + + QScriptValue value(const Item *item, const QString &name, bool *propertySet = nullptr); + bool boolValue(const Item *item, const QString &name, bool *propertyWasSet = nullptr); + int intValue(const Item *item, const QString &name, int defaultValue = 0, + bool *propertyWasSet = nullptr); + FileTags fileTagsValue(const Item *item, const QString &name, bool *propertySet = nullptr); + QString stringValue(const Item *item, const QString &name, + const QString &defaultValue = QString(), bool *propertyWasSet = nullptr); + QStringList stringListValue(const Item *item, const QString &name, + bool *propertyWasSet = nullptr); + std::optional optionalStringListValue(const Item *item, const QString &name, + bool *propertyWasSet = nullptr); + + void convertToPropertyType(const PropertyDeclaration& decl, const CodeLocation &loc, + QScriptValue &v); + + QScriptValue scriptValue(const Item *item); + + struct FileContextScopes + { + QScriptValue fileScope; + QScriptValue importScope; + }; + + FileContextScopes fileContextScopes(const FileContextConstPtr &file); + + void setCachingEnabled(bool enabled); + + PropertyDependencies propertyDependencies() const; + void clearPropertyDependencies(); + + void handleEvaluationError(const Item *item, const QString &name, + const QScriptValue &scriptValue); + + void setPathPropertiesBaseDir(const QString &dirPath); + void clearPathPropertiesBaseDir(); + + bool isNonDefaultValue(const Item *item, const QString &name) const; +private: + void onItemPropertyChanged(Item *item) override; + bool evaluateProperty(QScriptValue *result, const Item *item, const QString &name, + bool *propertyWasSet); + + ScriptEngine *m_scriptEngine; + EvaluatorScriptClass *m_scriptClass; + mutable QHash m_scriptValueMap; + mutable QHash m_fileContextScopesMap; +}; + +void throwOnEvaluationError(ScriptEngine *engine, const QScriptValue &scriptValue, + const std::function &provideFallbackCodeLocation); + +class EvalCacheEnabler +{ +public: + EvalCacheEnabler(Evaluator *evaluator) : m_evaluator(evaluator) + { + m_evaluator->setCachingEnabled(true); + } + + ~EvalCacheEnabler() { m_evaluator->setCachingEnabled(false); } + +private: + Evaluator * const m_evaluator; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_EVALUATOR_H diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp new file mode 100644 index 00000000..37595413 --- /dev/null +++ b/src/lib/corelib/language/evaluatorscriptclass.cpp @@ -0,0 +1,776 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "evaluatorscriptclass.h" + +#include "evaluationdata.h" +#include "evaluator.h" +#include "filecontext.h" +#include "item.h" +#include "scriptengine.h" +#include "propertydeclaration.h" +#include "value.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class SVConverter : ValueHandler +{ + EvaluatorScriptClass * const scriptClass; + ScriptEngine * const engine; + QScriptContext * const scriptContext; + const QScriptValue * const object; + Value * const valuePtr; + const Item * const itemOfProperty; + const QScriptString * const propertyName; + const EvaluationData * const data; + QScriptValue * const result; + char pushedScopesCount; + +public: + + SVConverter(EvaluatorScriptClass *esc, const QScriptValue *obj, const ValuePtr &v, + const Item *_itemOfProperty, const QScriptString *propertyName, const EvaluationData *data, + QScriptValue *result) + : scriptClass(esc) + , engine(static_cast(esc->engine())) + , scriptContext(esc->engine()->currentContext()) + , object(obj) + , valuePtr(v.get()) + , itemOfProperty(_itemOfProperty) + , propertyName(propertyName) + , data(data) + , result(result) + , pushedScopesCount(0) + { + } + + void start() + { + valuePtr->apply(this); + } + +private: + friend class AutoScopePopper; + + class AutoScopePopper + { + public: + AutoScopePopper(SVConverter *converter) + : m_converter(converter) + { + } + + ~AutoScopePopper() + { + m_converter->popScopes(); + } + + private: + SVConverter *m_converter; + }; + + void setupConvenienceProperty(const QString &conveniencePropertyName, QScriptValue *extraScope, + const QScriptValue &scriptValue) + { + if (!extraScope->isObject()) + *extraScope = engine->newObject(); + const PropertyDeclaration::Type type + = itemOfProperty->propertyDeclaration(propertyName->toString()).type(); + const bool isArray = type == PropertyDeclaration::StringList + || type == PropertyDeclaration::PathList + || type == PropertyDeclaration::Variant // TODO: Why? + || type == PropertyDeclaration::VariantList; + QScriptValue valueToSet = scriptValue; + if (isArray) { + if (!valueToSet.isValid() || valueToSet.isUndefined()) + valueToSet = engine->newArray(); + } else if (!valueToSet.isValid()) { + valueToSet = engine->undefinedValue(); + } + extraScope->setProperty(conveniencePropertyName, valueToSet); + } + + std::pair createExtraScope(const JSSourceValue *value, Item *outerItem, + QScriptValue *outerScriptValue) + { + std::pair result; + auto &extraScope = result.first; + result.second = true; + if (value->sourceUsesBase()) { + QScriptValue baseValue; + if (value->baseValue()) { + SVConverter converter(scriptClass, object, value->baseValue(), itemOfProperty, + propertyName, data, &baseValue); + converter.start(); + } + setupConvenienceProperty(StringConstants::baseVar(), &extraScope, baseValue); + } + if (value->sourceUsesOuter()) { + QScriptValue v; + if (outerItem) { + v = data->evaluator->property(outerItem, *propertyName); + if (engine->hasErrorOrException(v)) { + extraScope = engine->lastErrorValue(v); + result.second = false; + return result; + } + } else if (outerScriptValue) { + v = *outerScriptValue; + } + if (v.isValid()) + setupConvenienceProperty(StringConstants::outerVar(), &extraScope, v); + } + if (value->sourceUsesOriginal()) { + QScriptValue originalValue; + if (data->item->propertyDeclaration(propertyName->toString()).isScalar()) { + const Item *item = itemOfProperty; + if (item->type() == ItemType::Module || item->type() == ItemType::Export) { + const QString errorMessage = Tr::tr("The special value 'original' cannot " + "be used on the right-hand side of a property declaration."); + extraScope = engine->currentContext()->throwError(errorMessage); + result.second = false; + return result; + } + + // TODO: Provide a dedicated item type for not-yet-instantiated things that + // look like module instances in the AST visitor. + if (item->type() == ItemType::ModuleInstance + && !item->hasProperty(StringConstants::presentProperty())) { + const QString errorMessage = Tr::tr("Trying to assign property '%1' " + "on something that is not a module.").arg(propertyName->toString()); + extraScope = engine->currentContext()->throwError(errorMessage); + result.second = false; + return result; + } + + while (item->type() == ItemType::ModuleInstance) + item = item->prototype(); + if (item->type() != ItemType::Module && item->type() != ItemType::Export) { + const QString errorMessage = Tr::tr("The special value 'original' can only " + "be used with module properties."); + extraScope = engine->currentContext()->throwError(errorMessage); + result.second = false; + return result; + } + const ValuePtr v = item->property(*propertyName); + + // This can happen when resolving shadow products. The error will be ignored + // in that case. + if (!v) { + const QString errorMessage = Tr::tr("Error setting up 'original'."); + extraScope = engine->currentContext()->throwError(errorMessage); + result.second = false; + return result; + } + + SVConverter converter(scriptClass, object, v, item, + propertyName, data, &originalValue); + converter.start(); + } else { + originalValue = engine->newArray(0); + } + setupConvenienceProperty(StringConstants::originalVar(), &extraScope, originalValue); + } + return result; + } + + void pushScope(const QScriptValue &scope) + { + if (scope.isObject()) { + scriptContext->pushScope(scope); + ++pushedScopesCount; + } + } + + void pushItemScopes(const Item *item) + { + const Item *scope = item->scope(); + if (scope) { + pushItemScopes(scope); + pushScope(data->evaluator->scriptValue(scope)); + } + } + + void popScopes() + { + for (; pushedScopesCount; --pushedScopesCount) + scriptContext->popScope(); + } + + void handle(JSSourceValue *value) override + { + QScriptValue outerScriptValue; + for (const JSSourceValue::Alternative &alternative : value->alternatives()) { + if (alternative.value->sourceUsesOuter() + && !data->item->outerItem() + && !outerScriptValue.isValid()) { + JSSourceValueEvaluationResult sver = evaluateJSSourceValue(value, nullptr); + if (sver.hasError) { + *result = sver.scriptValue; + return; + } + outerScriptValue = sver.scriptValue; + } + JSSourceValueEvaluationResult sver = evaluateJSSourceValue(alternative.value.get(), + data->item->outerItem(), + &alternative, + value, &outerScriptValue); + if (!sver.tryNextAlternative || sver.hasError) { + *result = sver.scriptValue; + return; + } + } + *result = evaluateJSSourceValue(value, data->item->outerItem()).scriptValue; + } + + struct JSSourceValueEvaluationResult + { + QScriptValue scriptValue; + bool tryNextAlternative = true; + bool hasError = false; + }; + + void injectErrorLocation(QScriptValue &sv, const CodeLocation &loc) + { + if (sv.isError() && !engine->lastErrorLocation(sv).isValid()) + sv = engine->currentContext()->throwError(engine->lastError(sv, loc).toString()); + } + + JSSourceValueEvaluationResult evaluateJSSourceValue(const JSSourceValue *value, Item *outerItem, + const JSSourceValue::Alternative *alternative = nullptr, + JSSourceValue *elseCaseValue = nullptr, QScriptValue *outerScriptValue = nullptr) + { + JSSourceValueEvaluationResult result; + QBS_ASSERT(!alternative || value == alternative->value.get(), return result); + AutoScopePopper autoScopePopper(this); + auto maybeExtraScope = createExtraScope(value, outerItem, outerScriptValue); + if (!maybeExtraScope.second) { + result.scriptValue = maybeExtraScope.first; + result.hasError = true; + return result; + } + const Evaluator::FileContextScopes fileCtxScopes + = data->evaluator->fileContextScopes(value->file()); + if (fileCtxScopes.importScope.isError()) { + result.scriptValue = fileCtxScopes.importScope; + result.hasError = true; + return result; + } + pushScope(fileCtxScopes.fileScope); + pushItemScopes(data->item); + if (itemOfProperty->type() != ItemType::ModuleInstance) { + // Own properties of module instances must not have the instance itself in the scope. + pushScope(*object); + } + if (value->definingItem()) + pushItemScopes(value->definingItem()); + pushScope(maybeExtraScope.first); + pushScope(fileCtxScopes.importScope); + if (alternative) { + QScriptValue sv = engine->evaluate(alternative->condition.value); + if (engine->hasErrorOrException(sv)) { + result.scriptValue = sv; + result.hasError = true; + injectErrorLocation(result.scriptValue, alternative->condition.location); + return result; + } + if (sv.toBool()) { + // The condition is true. Continue evaluating the value. + result.tryNextAlternative = false; + } else { + // The condition is false. Try the next alternative or the else value. + result.tryNextAlternative = true; + return result; + } + sv = engine->evaluate(alternative->overrideListProperties.value); + if (engine->hasErrorOrException(sv)) { + result.scriptValue = sv; + result.hasError = true; + injectErrorLocation(result.scriptValue, + alternative->overrideListProperties.location); + return result; + } + if (sv.toBool()) + elseCaseValue->setIsExclusiveListValue(); + } + result.scriptValue = engine->evaluate(value->sourceCodeForEvaluation(), + value->file()->filePath(), value->line()); + return result; + } + + void handle(ItemValue *value) override + { + *result = data->evaluator->scriptValue(value->item()); + if (!result->isValid()) + qDebug() << "SVConverter returned invalid script value."; + } + + void handle(VariantValue *variantValue) override + { + *result = engine->toScriptValue(variantValue->value()); + } +}; + +bool debugProperties = false; + +enum QueryPropertyType +{ + QPTDefault, + QPTParentProperty +}; + +EvaluatorScriptClass::EvaluatorScriptClass(ScriptEngine *scriptEngine) + : QScriptClass(scriptEngine) + , m_valueCacheEnabled(false) +{ +} + +QScriptClass::QueryFlags EvaluatorScriptClass::queryProperty(const QScriptValue &object, + const QScriptString &name, + QScriptClass::QueryFlags flags, + uint *id) +{ + Q_UNUSED(flags); + + // We assume that it's safe to save the result of the query in a member of the scriptclass. + // It must be cleared in the property method before doing any further lookup. + QBS_ASSERT(m_queryResult.isNull(), return {}); + + if (debugProperties) + qDebug() << "[SC] queryProperty " << object.objectId() << " " << name; + + auto const data = attachedPointer(object); + const QString nameString = name.toString(); + if (nameString == QStringLiteral("parent")) { + *id = QPTParentProperty; + m_queryResult.data = data; + return QScriptClass::HandlesReadAccess; + } + + *id = QPTDefault; + if (!data) { + if (debugProperties) + qDebug() << "[SC] queryProperty: no data attached"; + return {}; + } + + return queryItemProperty(data, nameString); +} + +QScriptClass::QueryFlags EvaluatorScriptClass::queryItemProperty(const EvaluationData *data, + const QString &name, + bool ignoreParent) +{ + for (const Item *item = data->item; item; item = item->prototype()) { + m_queryResult.value = item->ownProperty(name); + if (m_queryResult.value) { + m_queryResult.data = data; + m_queryResult.itemOfProperty = item; + return HandlesReadAccess; + } + } + + if (!ignoreParent && data->item && data->item->parent()) { + if (debugProperties) + qDebug() << "[SC] queryProperty: query parent"; + EvaluationData parentdata = *data; + parentdata.item = data->item->parent(); + const QueryFlags qf = queryItemProperty(&parentdata, name, true); + if (qf.testFlag(HandlesReadAccess)) { + m_queryResult.foundInParent = true; + m_queryResult.data = data; + return qf; + } + } + + if (debugProperties) + qDebug() << "[SC] queryProperty: no such property"; + return {}; +} + +QString EvaluatorScriptClass::resultToString(const QScriptValue &scriptValue) +{ + return (scriptValue.isObject() + ? QStringLiteral("[Object: ") + + QString::number(scriptValue.objectId()) + QLatin1Char(']') + : scriptValue.toVariant().toString()); +} + +void EvaluatorScriptClass::collectValuesFromNextChain(const EvaluationData *data, QScriptValue *result, + const QString &propertyName, const ValuePtr &value) +{ + QScriptValueList lst; + Set oldNextChain = m_currentNextChain; + for (ValuePtr next = value; next; next = next->next()) + m_currentNextChain.insert(next.get()); + + for (ValuePtr next = value; next; next = next->next()) { + QScriptValue v = data->evaluator->property(next->definingItem(), propertyName); + const auto se = static_cast(engine()); + if (se->hasErrorOrException(v)) { + *result = se->lastErrorValue(v); + return; + } + if (v.isUndefined()) + continue; + lst << v; + if (next->type() == Value::JSSourceValueType + && std::static_pointer_cast(next)->isExclusiveListValue()) { + lst = lst.mid(lst.length() - 2); + break; + } + } + m_currentNextChain = oldNextChain; + + *result = engine()->newArray(); + quint32 k = 0; + for (const QScriptValue &v : qAsConst(lst)) { + QBS_ASSERT(!v.isError(), continue); + if (v.isArray()) { + const quint32 vlen = v.property(StringConstants::lengthProperty()).toInt32(); + for (quint32 j = 0; j < vlen; ++j) + result->setProperty(k++, v.property(j)); + } else { + result->setProperty(k++, v); + } + } +} + +static QString overriddenSourceDirectory(const Item *item, const QString &defaultValue) +{ + const VariantValuePtr v = item->variantProperty + (StringConstants::qbsSourceDirPropertyInternal()); + return v ? v->value().toString() : defaultValue; +} + +static void makeTypeError(const ErrorInfo &error, QScriptValue &v) +{ + v = v.engine()->currentContext()->throwError(QScriptContext::TypeError, + error.toString()); +} + +static void makeTypeError(const PropertyDeclaration &decl, const CodeLocation &location, + QScriptValue &v) +{ + const ErrorInfo error(Tr::tr("Value assigned to property '%1' does not have type '%2'.") + .arg(decl.name(), decl.typeString()), location); + makeTypeError(error, v); +} + +static void convertToPropertyType_impl(const QString &pathPropertiesBaseDir, const Item *item, + const PropertyDeclaration& decl, + const CodeLocation &location, QScriptValue &v) +{ + if (v.isUndefined() || v.isError()) + return; + QString srcDir; + QString actualBaseDir; + if (item && !pathPropertiesBaseDir.isEmpty()) { + const VariantValueConstPtr itemSourceDir + = item->variantProperty(QStringLiteral("sourceDirectory")); + actualBaseDir = itemSourceDir ? itemSourceDir->value().toString() : pathPropertiesBaseDir; + } + switch (decl.type()) { + case PropertyDeclaration::UnknownType: + case PropertyDeclaration::Variant: + break; + case PropertyDeclaration::Boolean: + if (!v.isBool()) + v = v.toBool(); + break; + case PropertyDeclaration::Integer: + if (!v.isNumber()) + makeTypeError(decl, location, v); + break; + case PropertyDeclaration::Path: + { + if (!v.isString()) { + makeTypeError(decl, location, v); + break; + } + const QString srcDir = item ? overriddenSourceDirectory(item, actualBaseDir) + : pathPropertiesBaseDir; + if (!srcDir.isEmpty()) + v = v.engine()->toScriptValue(QDir::cleanPath( + FileInfo::resolvePath(srcDir, v.toString()))); + break; + } + case PropertyDeclaration::String: + if (!v.isString()) + makeTypeError(decl, location, v); + break; + case PropertyDeclaration::PathList: + srcDir = item ? overriddenSourceDirectory(item, actualBaseDir) + : pathPropertiesBaseDir; + // Fall-through. + case PropertyDeclaration::StringList: + { + if (!v.isArray()) { + QScriptValue x = v.engine()->newArray(1); + x.setProperty(0, v); + v = x; + } + const quint32 c = v.property(StringConstants::lengthProperty()).toUInt32(); + for (quint32 i = 0; i < c; ++i) { + QScriptValue elem = v.property(i); + if (elem.isUndefined()) { + ErrorInfo error(Tr::tr("Element at index %1 of list property '%2' is undefined. " + "String expected.").arg(i).arg(decl.name()), location); + makeTypeError(error, v); + break; + } + if (elem.isNull()) { + ErrorInfo error(Tr::tr("Element at index %1 of list property '%2' is null. " + "String expected.").arg(i).arg(decl.name()), location); + makeTypeError(error, v); + break; + } + if (!elem.isString()) { + ErrorInfo error(Tr::tr("Element at index %1 of list property '%2' does not have " + "string type.").arg(i).arg(decl.name()), location); + makeTypeError(error, v); + break; + } + if (srcDir.isEmpty()) + continue; + elem = v.engine()->toScriptValue( + QDir::cleanPath(FileInfo::resolvePath(srcDir, elem.toString()))); + v.setProperty(i, elem); + } + break; + } + case PropertyDeclaration::VariantList: + if (!v.isArray()) { + QScriptValue x = v.engine()->newArray(1); + x.setProperty(0, v); + v = x; + } + break; + } +} + +void EvaluatorScriptClass::convertToPropertyType(const PropertyDeclaration &decl, + const CodeLocation &loc, QScriptValue &v) +{ + convertToPropertyType_impl(QString(), nullptr, decl, loc, v); +} + +void EvaluatorScriptClass::convertToPropertyType(const Item *item, const PropertyDeclaration& decl, + const Value *value, QScriptValue &v) +{ + if (value->type() == Value::VariantValueType && v.isUndefined() && !decl.isScalar()) { + v = v.engine()->newArray(); // QTBUG-51237 + return; + } + convertToPropertyType_impl(m_pathPropertiesBaseDir, item, decl, value->location(), v); +} + +class PropertyStackManager +{ +public: + PropertyStackManager(const Item *itemOfProperty, const QScriptString &name, const Value *value, + std::stack &requestedProperties, + PropertyDependencies &propertyDependencies) + : m_requestedProperties(requestedProperties) + { + if (value->type() == Value::JSSourceValueType + && (itemOfProperty->type() == ItemType::ModuleInstance + || itemOfProperty->type() == ItemType::Module + || itemOfProperty->type() == ItemType::Export)) { + const VariantValueConstPtr varValue + = itemOfProperty->variantProperty(StringConstants::nameProperty()); + if (!varValue) + return; + m_stackUpdate = true; + const QualifiedId fullPropName + = QualifiedId::fromString(varValue->value().toString()) << name.toString(); + if (!requestedProperties.empty()) + propertyDependencies[fullPropName].insert(requestedProperties.top()); + m_requestedProperties.push(fullPropName); + } + } + + ~PropertyStackManager() + { + if (m_stackUpdate) + m_requestedProperties.pop(); + } + +private: + std::stack &m_requestedProperties; + bool m_stackUpdate = false; +}; + +QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QScriptString &name, + uint id) +{ + const bool foundInParent = m_queryResult.foundInParent; + const EvaluationData *data = m_queryResult.data; + const Item * const itemOfProperty = m_queryResult.itemOfProperty; + m_queryResult.foundInParent = false; + m_queryResult.data = nullptr; + m_queryResult.itemOfProperty = nullptr; + QBS_ASSERT(data, {}); + + const auto qpt = static_cast(id); + if (qpt == QPTParentProperty) { + return data->item->parent() + ? data->evaluator->scriptValue(data->item->parent()) + : engine()->undefinedValue(); + } + + ValuePtr value; + m_queryResult.value.swap(value); + QBS_ASSERT(value, return {}); + QBS_ASSERT(m_queryResult.isNull(), return {}); + + if (debugProperties) + qDebug() << "[SC] property " << name; + + PropertyStackManager propStackmanager(itemOfProperty, name, value.get(), + m_requestedProperties, m_propertyDependencies); + + QScriptValue result; + if (m_valueCacheEnabled) { + result = data->valueCache.value(name); + if (result.isValid()) { + if (debugProperties) + qDebug() << "[SC] cache hit " << name << ": " << resultToString(result); + return result; + } + } + + if (value->next() && !m_currentNextChain.contains(value.get())) { + collectValuesFromNextChain(data, &result, name.toString(), value); + } else { + QScriptValue parentObject; + if (foundInParent) + parentObject = data->evaluator->scriptValue(data->item->parent()); + SVConverter converter(this, foundInParent ? &parentObject : &object, value, itemOfProperty, + &name, data, &result); + converter.start(); + + const PropertyDeclaration decl = data->item->propertyDeclaration(name.toString()); + convertToPropertyType(data->item, decl, value.get(), result); + } + + if (debugProperties) + qDebug() << "[SC] cache miss " << name << ": " << resultToString(result); + if (m_valueCacheEnabled) + data->valueCache.insert(name, result); + return result; +} + +class EvaluatorScriptClassPropertyIterator : public QScriptClassPropertyIterator +{ +public: + EvaluatorScriptClassPropertyIterator(const QScriptValue &object, EvaluationData *data) + : QScriptClassPropertyIterator(object), m_it(data->item->properties()) + { + } + + bool hasNext() const override + { + return m_it.hasNext(); + } + + void next() override + { + m_it.next(); + } + + bool hasPrevious() const override + { + return m_it.hasPrevious(); + } + + void previous() override + { + m_it.previous(); + } + + void toFront() override + { + m_it.toFront(); + } + + void toBack() override + { + m_it.toBack(); + } + + QScriptString name() const override + { + return object().engine()->toStringHandle(m_it.key()); + } + +private: + QMapIterator m_it; +}; + +QScriptClassPropertyIterator *EvaluatorScriptClass::newIterator(const QScriptValue &object) +{ + auto const data = attachedPointer(object); + return data ? new EvaluatorScriptClassPropertyIterator(object, data) : nullptr; +} + +void EvaluatorScriptClass::setValueCacheEnabled(bool enabled) +{ + m_valueCacheEnabled = enabled; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/evaluatorscriptclass.h b/src/lib/corelib/language/evaluatorscriptclass.h new file mode 100755 index 00000000..c234c17f --- /dev/null +++ b/src/lib/corelib/language/evaluatorscriptclass.h @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_EVALUATORSCRIPTCLASS_H +#define QBS_EVALUATORSCRIPTCLASS_H + +#include "forward_decls.h" +#include "qualifiedid.h" + +#include + +#include + +#include + +QT_BEGIN_NAMESPACE +class QScriptContext; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class EvaluationData; +class Item; +class PropertyDeclaration; +class ScriptEngine; + +class EvaluatorScriptClass : public QScriptClass +{ +public: + EvaluatorScriptClass(ScriptEngine *scriptEngine); + + QueryFlags queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id) override; + QScriptValue property(const QScriptValue &object, + const QScriptString &name, uint id) override; + QScriptClassPropertyIterator *newIterator(const QScriptValue &object) override; + + void setValueCacheEnabled(bool enabled); + + void convertToPropertyType(const PropertyDeclaration& decl, const CodeLocation &loc, + QScriptValue &v); + + PropertyDependencies propertyDependencies() const { return m_propertyDependencies; } + void clearPropertyDependencies() { m_propertyDependencies.clear(); } + + void setPathPropertiesBaseDir(const QString &dirPath) { m_pathPropertiesBaseDir = dirPath; } + void clearPathPropertiesBaseDir() { m_pathPropertiesBaseDir.clear(); } + +private: + QueryFlags queryItemProperty(const EvaluationData *data, + const QString &name, + bool ignoreParent = false); + static QString resultToString(const QScriptValue &scriptValue); + void collectValuesFromNextChain(const EvaluationData *data, QScriptValue *result, const QString &propertyName, const ValuePtr &value); + + void convertToPropertyType(const Item *item, + const PropertyDeclaration& decl, const Value *value, + QScriptValue &v); + + struct QueryResult + { + QueryResult() + : data(nullptr), itemOfProperty(nullptr) + {} + + bool isNull() const + { + static const QueryResult pristine; + return *this == pristine; + } + + bool operator==(const QueryResult &rhs) const + { + return foundInParent == rhs.foundInParent + && data == rhs.data + && itemOfProperty == rhs.itemOfProperty + && value == rhs.value; + } + + bool foundInParent = false; + const EvaluationData *data; + const Item *itemOfProperty; // The item that owns the property. + ValuePtr value; + }; + QueryResult m_queryResult; + bool m_valueCacheEnabled; + Set m_currentNextChain; + PropertyDependencies m_propertyDependencies; + std::stack m_requestedProperties; + QString m_pathPropertiesBaseDir; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_EVALUATORSCRIPTCLASS_H diff --git a/src/lib/corelib/language/filecontext.cpp b/src/lib/corelib/language/filecontext.cpp new file mode 100644 index 00000000..6daf8c87 --- /dev/null +++ b/src/lib/corelib/language/filecontext.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filecontext.h" + +#include "item.h" + +namespace qbs { +namespace Internal { + +FileContext::FileContext() + : m_idScope(nullptr) +{ +} + +FileContextPtr FileContext::create() +{ + return FileContextPtr(new FileContext); +} + +void FileContext::ensureIdScope(ItemPool *itemPool) +{ + if (!m_idScope) + m_idScope = Item::create(itemPool, ItemType::IdScope); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/filecontext.h b/src/lib/corelib/language/filecontext.h new file mode 100644 index 00000000..001e6406 --- /dev/null +++ b/src/lib/corelib/language/filecontext.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILECONTEXT_H +#define QBS_FILECONTEXT_H + +#include "filecontextbase.h" +#include "forward_decls.h" + +#include + +namespace qbs { +namespace Internal { +class Item; +class ItemPool; + +class FileContext : public FileContextBase +{ +public: + static FileContextPtr QBS_AUTOTEST_EXPORT create(); + + void setContent(const QString &content) { m_content = content; } + const QString &content() const { return m_content; } + + Item *idScope() const { return m_idScope; } + void ensureIdScope(ItemPool *itemPool); + +private: + FileContext(); + + QString m_content; + Item *m_idScope; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_FILECONTEXT_H diff --git a/src/lib/corelib/language/filecontextbase.cpp b/src/lib/corelib/language/filecontextbase.cpp new file mode 100644 index 00000000..70dd04a0 --- /dev/null +++ b/src/lib/corelib/language/filecontextbase.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filecontextbase.h" + +#include + +namespace qbs { +namespace Internal { + +QString FileContextBase::dirPath() const +{ + return FileInfo::path(m_filePath); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/filecontextbase.h b/src/lib/corelib/language/filecontextbase.h new file mode 100644 index 00000000..335e5425 --- /dev/null +++ b/src/lib/corelib/language/filecontextbase.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILECONTEXTBASE_H +#define QBS_FILECONTEXTBASE_H + +#include "jsimports.h" + +namespace qbs { +namespace Internal { + +class FileContextBase +{ +public: + void setFilePath(const QString &filePath) { m_filePath = filePath; } + QString filePath() const { return m_filePath; } + + void addJsImport(const JsImport &jsImport) { m_jsImports.push_back(jsImport); } + const JsImports &jsImports() const { return m_jsImports; } + + void addJsExtension(const QString &extension) { m_jsExtensions << extension; } + QStringList jsExtensions() const { return m_jsExtensions; } + + void setSearchPaths(const QStringList &paths) { m_searchPaths = paths; } + QStringList searchPaths() const { return m_searchPaths; } + + QString dirPath() const; + +protected: + FileContextBase() = default; + FileContextBase(const FileContextBase &other) = default; + FileContextBase(FileContextBase &&other) = default; + + QString m_filePath; + JsImports m_jsImports; + QStringList m_jsExtensions; + QStringList m_searchPaths; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_FILECONTEXTBASE_H diff --git a/src/lib/corelib/language/filetags.cpp b/src/lib/corelib/language/filetags.cpp new file mode 100644 index 00000000..83086b89 --- /dev/null +++ b/src/lib/corelib/language/filetags.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filetags.h" +#include + +#include + +namespace qbs { +namespace Internal { + +void FileTag::clear() +{ + Id::operator=(Id()); +} + +void FileTag::store(PersistentPool &pool) const +{ + pool.store(toString()); +} + +void FileTag::load(PersistentPool &pool) +{ + *this = FileTag(pool.load().toUtf8()); +} + +QDebug operator<<(QDebug debug, const FileTag &tag) +{ + QDebugStateSaver saver(debug); + return debug.resetFormat().noquote() << tag.toString(); +} + +FileTags FileTags::fromStringList(const QStringList &strings) +{ + FileTags result; + for (const QString &str : strings) + result += FileTag(str.toUtf8()); + return result; +} + +LogWriter operator <<(LogWriter w, const FileTags &tags) +{ + bool firstLoop = true; + w.write('('); + for (const FileTag &tag : tags) { + if (firstLoop) + firstLoop = false; + else + w.write(QStringLiteral(", ")); + w.write(tag.toString()); + } + w.write(')'); + return w; +} + +QDebug operator<<(QDebug debug, const FileTags &tags) +{ + QDebugStateSaver saver(debug); + return debug.resetFormat().noquote() << tags.toStringList(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/filetags.h b/src/lib/corelib/language/filetags.h new file mode 100644 index 00000000..9f712e19 --- /dev/null +++ b/src/lib/corelib/language/filetags.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILETAGS_H +#define QBS_FILETAGS_H + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { +class PersistentPool; + +class FileTag : public Id +{ +public: + FileTag() + : Id() + {} + + FileTag(const Id &other) + : Id(other) + {} + + FileTag(const char *str) + : Id(str) + {} + + explicit FileTag(const QByteArray &ba) + : Id(ba) + {} + + void clear(); + + void store(PersistentPool &pool) const; + void load(PersistentPool &pool); +}; + +template<> inline bool Set::sortAfterLoadRequired() const { return true; } +QDebug operator<<(QDebug debug, const FileTag &tag); + +class FileTags : public Set +{ +public: + FileTags() : Set() {} + FileTags(const std::initializer_list &list) : Set(list) {} + static FileTags fromStringList(const QStringList &strings); +}; + +LogWriter operator <<(LogWriter w, const FileTags &tags); +QDebug operator<<(QDebug debug, const FileTags &tags); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_FILETAGS_H + diff --git a/src/lib/corelib/language/forward_decls.h b/src/lib/corelib/language/forward_decls.h new file mode 100644 index 00000000..6ee22a5a --- /dev/null +++ b/src/lib/corelib/language/forward_decls.h @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_LANG_FORWARD_DECLS_H +#define QBS_LANG_FORWARD_DECLS_H + +#include + +namespace qbs { +namespace Internal { + +enum class ObserveMode; + +class Value; +using ValuePtr = std::shared_ptr; +using ValueConstPtr = std::shared_ptr; + +class ItemValue; +using ItemValuePtr = std::shared_ptr; +using ItemValueConstPtr = std::shared_ptr; + +class JSSourceValue; +using JSSourceValuePtr = std::shared_ptr; +using JSSourceValueConstPtr = std::shared_ptr; + +class VariantValue; +using VariantValuePtr = std::shared_ptr; +using VariantValueConstPtr = std::shared_ptr; + +class FileContext; +using FileContextPtr = std::shared_ptr; +using FileContextConstPtr = std::shared_ptr; + +class FileContextBase; +using FileContextBasePtr = std::shared_ptr; +using FileContextBaseConstPtr = std::shared_ptr; + +class Probe; +using ProbePtr = std::shared_ptr; +using ProbeConstPtr = std::shared_ptr; + +class PropertyMapInternal; +using PropertyMapPtr = std::shared_ptr; +using PropertyMapConstPtr = std::shared_ptr; + +class FileTagger; +using FileTaggerPtr = std::shared_ptr; +using FileTaggerConstPtr = std::shared_ptr; + +class ResolvedProduct; +using ResolvedProductPtr = std::shared_ptr; +using ResolvedProductConstPtr = std::shared_ptr; + +class ResolvedProject; +using ResolvedProjectPtr = std::shared_ptr; +using ResolvedProjectConstPtr = std::shared_ptr; + +class TopLevelProject; +using TopLevelProjectPtr = std::shared_ptr; +using TopLevelProjectConstPtr = std::shared_ptr; + +class ResolvedFileContext; +using ResolvedFileContextPtr = std::shared_ptr; +using ResolvedFileContextConstPtr = std::shared_ptr; + +class Rule; +using RulePtr = std::shared_ptr; +using RuleConstPtr = std::shared_ptr; + +class ResolvedScanner; +using ResolvedScannerPtr = std::shared_ptr; +using ResolvedScannerConstPtr = std::shared_ptr; + +class SourceArtifactInternal; +using SourceArtifactPtr = std::shared_ptr; +using SourceArtifactConstPtr = std::shared_ptr; + +class ScriptFunction; +using ScriptFunctionPtr = std::shared_ptr; +using ScriptFunctionConstPtr = std::shared_ptr; +class PrivateScriptFunction; + +class RuleArtifact; +using RuleArtifactPtr = std::shared_ptr; +using RuleArtifactConstPtr = std::shared_ptr; + +class ResolvedModule; +using ResolvedModulePtr = std::shared_ptr; +using ResolvedModuleConstPtr = std::shared_ptr; + +class ResolvedGroup; +using GroupPtr = std::shared_ptr; +using GroupConstPtr = std::shared_ptr; + +class ArtifactProperties; +using ArtifactPropertiesPtr = std::shared_ptr; +using ArtifactPropertiesConstPtr = std::shared_ptr; + +class ExportedItem; +using ExportedItemPtr = std::shared_ptr; +class ExportedModule; +class ExportedModuleDependency; +class ExportedProperty; +class PersistentPool; + +} // namespace Internal +} // namespace qbs + +#ifdef QT_CORE_LIB +#include "../tools/porting.h" + +#include + +namespace qbs { +namespace Internal { + +template inline static QHashValueType qHash(const std::shared_ptr &p, QHashValueType seed = 0) +{ + return ::qHash(p.get(), seed); +} + +} // namespace Internal +} // namespace qbs +#endif + +#endif // QBS_LANG_FORWARD_DECLS_H diff --git a/src/lib/corelib/language/identifiersearch.cpp b/src/lib/corelib/language/identifiersearch.cpp new file mode 100644 index 00000000..49ceab36 --- /dev/null +++ b/src/lib/corelib/language/identifiersearch.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "identifiersearch.h" +#include + +namespace qbs { +namespace Internal { + +IdentifierSearch::IdentifierSearch() = default; + +void IdentifierSearch::start(QbsQmlJS::AST::Node *node) +{ + for (auto it = m_requests.cbegin(); it != m_requests.cend(); ++it) + *it.value() = false; + m_numberOfFoundIds = 0; + node->accept(this); +} + +void IdentifierSearch::add(const QString &name, bool *found) +{ + m_requests.insert(name, found); +} + +bool IdentifierSearch::preVisit(QbsQmlJS::AST::Node *) +{ + return m_numberOfFoundIds < m_requests.size(); +} + +bool IdentifierSearch::visit(QbsQmlJS::AST::IdentifierExpression *e) +{ + bool *found = m_requests.value(e->name.toString()); + if (found && !*found) { + *found = true; + m_numberOfFoundIds++; + } + return m_numberOfFoundIds < m_requests.size(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/identifiersearch.h b/src/lib/corelib/language/identifiersearch.h new file mode 100644 index 00000000..7d99c0f1 --- /dev/null +++ b/src/lib/corelib/language/identifiersearch.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_IDENTIFIERSEARCHVISITOR_H +#define QBS_IDENTIFIERSEARCHVISITOR_H + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT IdentifierSearch : private QbsQmlJS::AST::Visitor +{ +public: + IdentifierSearch(); + void start(QbsQmlJS::AST::Node *node); + void add(const QString &name, bool *found); + +private: + bool preVisit(QbsQmlJS::AST::Node *) override; + bool visit(QbsQmlJS::AST::IdentifierExpression *e) override; + + QMap m_requests; + int m_numberOfFoundIds = 0; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_IDENTIFIERSEARCHVISITOR_H diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp new file mode 100644 index 00000000..2f23de21 --- /dev/null +++ b/src/lib/corelib/language/item.cpp @@ -0,0 +1,414 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "item.h" + +#include "builtindeclarations.h" +#include "deprecationinfo.h" +#include "filecontext.h" +#include "itemobserver.h" +#include "itempool.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +Item::Item(ItemPool *pool, ItemType type) + : m_pool(pool) + , m_observer(nullptr) + , m_prototype(nullptr) + , m_scope(nullptr) + , m_outerItem(nullptr) + , m_parent(nullptr) + , m_type(type) +{ +} + +Item *Item::create(ItemPool *pool, ItemType type) +{ + return pool->allocateItem(type); +} + +Item *Item::clone() const +{ + Item *dup = create(pool(), type()); + dup->m_id = m_id; + dup->m_location = m_location; + dup->m_prototype = m_prototype; + dup->m_scope = m_scope; + dup->m_outerItem = m_outerItem; + dup->m_parent = m_parent; + dup->m_file = m_file; + dup->m_propertyDeclarations = m_propertyDeclarations; + dup->m_modules = m_modules; + + dup->m_children.reserve(m_children.size()); + for (const Item * const child : qAsConst(m_children)) { + Item *clonedChild = child->clone(); + clonedChild->m_parent = dup; + dup->m_children.push_back(clonedChild); + } + + for (PropertyMap::const_iterator it = m_properties.constBegin(); it != m_properties.constEnd(); + ++it) { + dup->m_properties.insert(it.key(), it.value()->clone()); + } + + return dup; +} + +QString Item::typeName() const +{ + switch (type()) { + case ItemType::IdScope: return QStringLiteral("[IdScope]"); + case ItemType::ModuleInstance: return QStringLiteral("[ModuleInstance]"); + case ItemType::ModuleParameters: return QStringLiteral("[ModuleParametersInstance]"); + case ItemType::ModulePrefix: return QStringLiteral("[ModulePrefix]"); + case ItemType::Outer: return QStringLiteral("[Outer]"); + case ItemType::Scope: return QStringLiteral("[Scope]"); + default: return BuiltinDeclarations::instance().nameForType(type()); + } +} + +bool Item::hasProperty(const QString &name) const +{ + const Item *item = this; + do { + if (item->m_properties.contains(name)) + return true; + item = item->m_prototype; + } while (item); + return false; +} + +bool Item::hasOwnProperty(const QString &name) const +{ + return m_properties.contains(name); +} + +ValuePtr Item::property(const QString &name) const +{ + ValuePtr value; + const Item *item = this; + do { + if ((value = item->m_properties.value(name))) + break; + item = item->m_prototype; + } while (item); + return value; +} + +ValuePtr Item::ownProperty(const QString &name) const +{ + return m_properties.value(name); +} + +ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate) +{ + return itemProperty(name, itemTemplate, ItemValueConstPtr()); +} + +ItemValuePtr Item::itemProperty(const QString &name, const ItemValueConstPtr &value) +{ + return itemProperty(name, value->item(), value); +} + +ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate, + const ItemValueConstPtr &itemValue) +{ + const ValuePtr v = property(name); + if (v && v->type() == Value::ItemValueType) + return std::static_pointer_cast(v); + if (!itemTemplate) + return ItemValuePtr(); + const bool createdByPropertiesBlock = itemValue && itemValue->createdByPropertiesBlock(); + const ItemValuePtr result = ItemValue::create(Item::create(m_pool, itemTemplate->type()), + createdByPropertiesBlock); + setProperty(name, result); + return result; +} + +JSSourceValuePtr Item::sourceProperty(const QString &name) const +{ + ValuePtr v = property(name); + if (!v || v->type() != Value::JSSourceValueType) + return JSSourceValuePtr(); + return std::static_pointer_cast(v); +} + +VariantValuePtr Item::variantProperty(const QString &name) const +{ + ValuePtr v = property(name); + if (!v || v->type() != Value::VariantValueType) + return VariantValuePtr(); + return std::static_pointer_cast(v); +} + +bool Item::isOfTypeOrhasParentOfType(ItemType type) const +{ + const Item *item = this; + do { + if (item->type() == type) + return true; + item = item->parent(); + } while (item); + return false; +} + +PropertyDeclaration Item::propertyDeclaration(const QString &name, bool allowExpired) const +{ + auto it = m_propertyDeclarations.find(name); + if (it != m_propertyDeclarations.end()) + return it.value(); + if (allowExpired) { + it = m_expiredPropertyDeclarations.find(name); + if (it != m_expiredPropertyDeclarations.end()) + return it.value(); + } + return m_prototype ? m_prototype->propertyDeclaration(name) : PropertyDeclaration(); +} + +void Item::addModule(const Item::Module &module) +{ + const auto it = std::lower_bound(m_modules.begin(), m_modules.end(), module); + QBS_CHECK(it == m_modules.end() || (module.name != it->name && module.item != it->item)); + m_modules.insert(it, module); +} + +void Item::setObserver(ItemObserver *observer) const +{ + QBS_ASSERT(!observer || !m_observer, return); // warn if accidentally overwritten + m_observer = observer; +} + +void Item::setProperty(const QString &name, const ValuePtr &value) +{ + m_properties.insert(name, value); + if (m_observer) + m_observer->onItemPropertyChanged(this); +} + +void Item::dump() const +{ + dump(0); +} + +bool Item::isPresentModule() const +{ + // Initial value is "true" as JS source, overwritten one is always QVariant(false). + const ValueConstPtr v = property(StringConstants::presentProperty()); + return v && v->type() == Value::JSSourceValueType; +} + +void Item::setupForBuiltinType(Logger &logger) +{ + const BuiltinDeclarations &builtins = BuiltinDeclarations::instance(); + const auto properties = builtins.declarationsForType(type()).properties(); + for (const PropertyDeclaration &pd : properties) { + m_propertyDeclarations.insert(pd.name(), pd); + const ValuePtr value = m_properties.value(pd.name()); + if (!value) { + if (pd.isDeprecated()) + continue; + JSSourceValuePtr sourceValue = JSSourceValue::create(); + sourceValue->setIsBuiltinDefaultValue(); + sourceValue->setFile(file()); + sourceValue->setSourceCode(pd.initialValueSource().isEmpty() + ? StringConstants::undefinedValue() + : pd.initialValueSource()); + m_properties.insert(pd.name(), sourceValue); + } else if (pd.isDeprecated()) { + const DeprecationInfo &di = pd.deprecationInfo(); + if (di.removalVersion() <= LanguageInfo::qbsVersion()) { + QString message = Tr::tr("The property '%1' is no longer valid for %2 items. " + "It was removed in qbs %3.") + .arg(pd.name(), typeName(), di.removalVersion().toString()); + ErrorInfo error(message, value->location()); + if (!di.additionalUserInfo().isEmpty()) + error.append(di.additionalUserInfo()); + throw error; + } + QString warning = Tr::tr("The property '%1' is deprecated and will be removed in " + "qbs %2.").arg(pd.name(), di.removalVersion().toString()); + ErrorInfo error(warning, value->location()); + if (!di.additionalUserInfo().isEmpty()) + error.append(di.additionalUserInfo()); + logger.printWarning(error); + } + } +} + +void Item::copyProperty(const QString &propertyName, Item *target) const +{ + target->setProperty(propertyName, property(propertyName)); +} + +static const char *valueType(const Value *v) +{ + switch (v->type()) { + case Value::JSSourceValueType: return "JS source"; + case Value::ItemValueType: return "Item"; + case Value::VariantValueType: return "Variant"; + } + return ""; // For dumb compilers. +} + +void Item::dump(int indentation) const +{ + const QByteArray indent(indentation, ' '); + qDebug("%stype: %s, pointer value: %p", indent.constData(), qPrintable(typeName()), this); + if (!m_properties.empty()) + qDebug("%sproperties:", indent.constData()); + for (auto it = m_properties.constBegin(); it != m_properties.constEnd(); ++it) { + const QByteArray nextIndent(indentation + 4, ' '); + qDebug("%skey: %s, value type: %s", nextIndent.constData(), qPrintable(it.key()), + valueType(it.value().get())); + switch (it.value()->type()) { + case Value::JSSourceValueType: + qDebug("%svalue: %s", nextIndent.constData(), + qPrintable(std::static_pointer_cast(it.value())->sourceCodeForEvaluation())); + break; + case Value::ItemValueType: + qDebug("%svalue:", nextIndent.constData()); + std::static_pointer_cast(it.value())->item()->dump(indentation + 8); + break; + case Value::VariantValueType: + qDebug("%svalue: %s", nextIndent.constData(), + qPrintable(std::static_pointer_cast(it.value())->value().toString())); + break; + } + } + if (!m_children.empty()) + qDebug("%schildren:", indent.constData()); + for (const Item * const child : qAsConst(m_children)) + child->dump(indentation + 4); + if (prototype()) { + qDebug("%sprototype:", indent.constData()); + prototype()->dump(indentation + 4); + } +} + +void Item::removeProperty(const QString &name) +{ + m_properties.remove(name); +} + +Item *Item::child(ItemType type, bool checkForMultiple) const +{ + Item *child = nullptr; + for (Item * const currentChild : children()) { + if (currentChild->type() == type) { + if (!checkForMultiple) + return currentChild; + if (child) { + ErrorInfo error(Tr::tr("Multiple instances of item '%1' found where at most one " + "is allowed.") + .arg(BuiltinDeclarations::instance().nameForType(type))); + error.append(Tr::tr("First item"), child->location()); + error.append(Tr::tr("Second item"), currentChild->location()); + throw error; + } + child = currentChild; + } + } + return child; +} + +void Item::addChild(Item *parent, Item *child) +{ + parent->m_children.push_back(child); + child->setParent(parent); +} + +void Item::removeChild(Item *parent, Item *child) +{ + parent->m_children.removeOne(child); + child->setParent(nullptr); +} + +void Item::setPropertyDeclaration(const QString &name, const PropertyDeclaration &declaration) +{ + if (declaration.isExpired()) { + m_propertyDeclarations.remove(name); + m_expiredPropertyDeclarations.insert(name, declaration); + } else { + m_propertyDeclarations.insert(name, declaration); + } +} + +void Item::setPropertyDeclarations(const Item::PropertyDeclarationMap &decls) +{ + m_propertyDeclarations = decls; +} + +void Item::overrideProperties( + const QVariantMap &overridden, + const QualifiedId &namePrefix, + const SetupProjectParameters ¶meters, + Logger &logger) +{ + if (overridden.isEmpty()) + return; + for (QVariantMap::const_iterator it = overridden.constBegin(); it != overridden.constEnd(); + ++it) { + const PropertyDeclaration decl = propertyDeclaration(it.key()); + if (!decl.isValid()) { + ErrorInfo error(Tr::tr("Unknown property: %1.%2"). + arg(namePrefix.toString(), it.key())); + handlePropertyError(error, parameters, logger); + continue; + } + setProperty(it.key(), + VariantValue::create(PropertyDeclaration::convertToPropertyType( + it.value(), decl.type(), namePrefix, it.key()))); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/item.h b/src/lib/corelib/language/item.h new file mode 100644 index 00000000..22cf6b81 --- /dev/null +++ b/src/lib/corelib/language/item.h @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEM_H +#define QBS_ITEM_H + +#include "forward_decls.h" +#include "itemtype.h" +#include "propertydeclaration.h" +#include "qualifiedid.h" +#include +#include +#include +#include + +#include +#include + +#include + +namespace qbs { + +class SetupProjectParameters; + +namespace Internal { +class ItemObserver; +class ItemPool; +class Logger; + +class QBS_AUTOTEST_EXPORT Item : public QbsQmlJS::Managed +{ + friend class ASTPropertiesItemHandler; + friend class ItemPool; + friend class ItemReaderASTVisitor; + Q_DISABLE_COPY(Item) + Item(ItemPool *pool, ItemType type); + +public: + struct Module + { + Module() + : item(nullptr), isProduct(false), required(true) + {} + + QualifiedId name; + Item *item; + bool isProduct; + bool requiredValue = true; // base value of the required prop + bool required; + bool fallbackEnabled = true; + QVariantMap parameters; + VersionRange versionRange; + }; + using Modules = std::vector; + using PropertyDeclarationMap = QMap; + using PropertyMap = QMap; + + static Item *create(ItemPool *pool, ItemType type); + Item *clone() const; + ItemPool *pool() const { return m_pool; } + + const QString &id() const { return m_id; } + const CodeLocation &location() const { return m_location; } + Item *prototype() const { return m_prototype; } + Item *scope() const { return m_scope; } + Item *outerItem() const { return m_outerItem; } + Item *parent() const { return m_parent; } + const FileContextPtr &file() const { return m_file; } + const QList &children() const { return m_children; } + Item *child(ItemType type, bool checkForMultiple = true) const; + const PropertyMap &properties() const { return m_properties; } + const PropertyDeclarationMap &propertyDeclarations() const { return m_propertyDeclarations; } + PropertyDeclaration propertyDeclaration(const QString &name, bool allowExpired = true) const; + const Modules &modules() const { return m_modules; } + void addModule(const Module &module); + void removeModules() { m_modules.clear(); } + void setModules(const Modules &modules) { m_modules = modules; } + + ItemType type() const { return m_type; } + void setType(ItemType type) { m_type = type; } + QString typeName() const; + + bool hasProperty(const QString &name) const; + bool hasOwnProperty(const QString &name) const; + ValuePtr property(const QString &name) const; + ValuePtr ownProperty(const QString &name) const; + ItemValuePtr itemProperty(const QString &name, const Item *itemTemplate = nullptr); + ItemValuePtr itemProperty(const QString &name, const ItemValueConstPtr &value); + JSSourceValuePtr sourceProperty(const QString &name) const; + VariantValuePtr variantProperty(const QString &name) const; + bool isOfTypeOrhasParentOfType(ItemType type) const; + void setObserver(ItemObserver *observer) const; + void setProperty(const QString &name, const ValuePtr &value); + void setProperties(const PropertyMap &props) { m_properties = props; } + void removeProperty(const QString &name); + void setPropertyDeclaration(const QString &name, const PropertyDeclaration &declaration); + void setPropertyDeclarations(const PropertyDeclarationMap &decls); + void setLocation(const CodeLocation &location) { m_location = location; } + void setPrototype(Item *prototype) { m_prototype = prototype; } + void setFile(const FileContextPtr &file) { m_file = file; } + void setId(const QString &id) { m_id = id; } + void setScope(Item *item) { m_scope = item; } + void setOuterItem(Item *item) { m_outerItem = item; } + void setChildren(const QList &children) { m_children = children; } + void setParent(Item *item) { m_parent = item; } + void childrenReserve(int size) { m_children.reserve(size); } + static void addChild(Item *parent, Item *child); + static void removeChild(Item *parent, Item *child); + void dump() const; + bool isPresentModule() const; + void setupForBuiltinType(Logger &logger); + void copyProperty(const QString &propertyName, Item *target) const; + void overrideProperties( + const QVariantMap &config, + const QualifiedId &namePrefix, + const SetupProjectParameters ¶meters, + Logger &logger); + +private: + ItemValuePtr itemProperty(const QString &name, const Item *itemTemplate, + const ItemValueConstPtr &itemValue); + + void dump(int indentation) const; + + ItemPool *m_pool; + mutable ItemObserver *m_observer; + QString m_id; + CodeLocation m_location; + Item *m_prototype; + Item *m_scope; + Item *m_outerItem; + Item *m_parent; + QList m_children; + FileContextPtr m_file; + PropertyMap m_properties; + PropertyDeclarationMap m_propertyDeclarations; + PropertyDeclarationMap m_expiredPropertyDeclarations; + Modules m_modules; + ItemType m_type; +}; + +inline bool operator<(const Item::Module &m1, const Item::Module &m2) { return m1.name < m2.name; } + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEM_H diff --git a/src/lib/corelib/language/itemdeclaration.cpp b/src/lib/corelib/language/itemdeclaration.cpp new file mode 100644 index 00000000..d7230e9d --- /dev/null +++ b/src/lib/corelib/language/itemdeclaration.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "itemdeclaration.h" + +namespace qbs { +namespace Internal { + +ItemDeclaration::ItemDeclaration(ItemType type) + : m_type(type) +{ +} + +ItemDeclaration &ItemDeclaration::operator<<(const PropertyDeclaration &decl) +{ + m_properties.push_back(decl); + return *this; +} + +bool ItemDeclaration::isChildTypeAllowed(ItemType type) const +{ + if (m_type > ItemType::LastActualItem || type > ItemType::LastActualItem) + return true; + return m_allowedChildTypes.contains(type); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/itemdeclaration.h b/src/lib/corelib/language/itemdeclaration.h new file mode 100644 index 00000000..6da699d2 --- /dev/null +++ b/src/lib/corelib/language/itemdeclaration.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMDECLARATION_H +#define QBS_ITEMDECLARATION_H + +#include "deprecationinfo.h" +#include "itemtype.h" +#include "propertydeclaration.h" +#include + +#include + +namespace qbs { +namespace Internal { + +class ItemDeclaration +{ +public: + ItemDeclaration(ItemType type = ItemType::Unknown); + + ItemType type() const { return m_type; } + + using Properties = QList; + void setProperties(const Properties &props) { m_properties = props; } + Properties properties() const { return m_properties; } + + void setDeprecationInfo(const DeprecationInfo &di) { m_deprecationInfo = di; } + DeprecationInfo deprecationInfo() const { return m_deprecationInfo; } + + ItemDeclaration &operator<<(const PropertyDeclaration &decl); + + using TypeNames = Set; + void setAllowedChildTypes(const TypeNames &typeNames) { m_allowedChildTypes = typeNames; } + const TypeNames &allowedChildTypes() const { return m_allowedChildTypes; } + bool isChildTypeAllowed(ItemType type) const; + +private: + ItemType m_type; + Properties m_properties; + TypeNames m_allowedChildTypes; + DeprecationInfo m_deprecationInfo; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEMDECLARATION_H diff --git a/src/lib/corelib/language/itemobserver.h b/src/lib/corelib/language/itemobserver.h new file mode 100644 index 00000000..fca3a2d8 --- /dev/null +++ b/src/lib/corelib/language/itemobserver.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMOBSERVER_H +#define QBS_ITEMOBSERVER_H + +namespace qbs { +namespace Internal { + +class Item; + +class ItemObserver +{ +public: + virtual ~ItemObserver() = default; + virtual void onItemPropertyChanged(Item *item) = 0; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEMOBSERVER_H diff --git a/src/lib/corelib/language/itempool.cpp b/src/lib/corelib/language/itempool.cpp new file mode 100644 index 00000000..ccd22fe2 --- /dev/null +++ b/src/lib/corelib/language/itempool.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "itempool.h" +#include "item.h" + +namespace qbs { +namespace Internal { + +ItemPool::ItemPool() = default; + +ItemPool::~ItemPool() +{ + for (Item *item : m_items) + item->~Item(); +} + +Item *ItemPool::allocateItem(const ItemType &type) +{ + const auto item = new (&m_pool) Item(this, type); + m_items.push_back(item); + return item; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/itempool.h b/src/lib/corelib/language/itempool.h new file mode 100644 index 00000000..ef4be763 --- /dev/null +++ b/src/lib/corelib/language/itempool.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMPOOL_H +#define QBS_ITEMPOOL_H + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class Item; +enum class ItemType; + +class QBS_AUTOTEST_EXPORT ItemPool +{ + Q_DISABLE_COPY(ItemPool) +public: + ItemPool(); + ~ItemPool(); + + Item *allocateItem(const ItemType &type); + +private: + QbsQmlJS::MemoryPool m_pool; + std::vector m_items; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEMPOOL_H diff --git a/src/lib/corelib/language/itemreader.cpp b/src/lib/corelib/language/itemreader.cpp new file mode 100644 index 00000000..1abc5caf --- /dev/null +++ b/src/lib/corelib/language/itemreader.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "itemreader.h" + +#include "itemreadervisitorstate.h" + +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +static void makePathsCanonical(QStringList &paths) +{ + Internal::removeIf(paths, [](QString &p) { + p = QFileInfo(p).canonicalFilePath(); + return p.isEmpty(); + }); +} + +ItemReader::ItemReader(Logger &logger) + : m_visitorState(std::make_unique(logger)) +{ +} + +ItemReader::~ItemReader() = default; + +void ItemReader::setSearchPaths(const QStringList &searchPaths) +{ + m_searchPaths = searchPaths; + makePathsCanonical(m_searchPaths); + m_allSearchPaths.clear(); +} + +void ItemReader::pushExtraSearchPaths(const QStringList &extraSearchPaths) +{ + m_extraSearchPaths.push_back(extraSearchPaths); + makePathsCanonical(m_extraSearchPaths.back()); + m_allSearchPaths.clear(); +} + +void ItemReader::popExtraSearchPaths() +{ + m_extraSearchPaths.pop_back(); + m_allSearchPaths.clear(); +} + +const std::vector &ItemReader::extraSearchPathsStack() const +{ + return m_extraSearchPaths; +} + +void ItemReader::setExtraSearchPathsStack(const std::vector &s) +{ + m_extraSearchPaths = s; + m_allSearchPaths.clear(); +} + +void ItemReader::clearExtraSearchPathsStack() +{ + m_extraSearchPaths.clear(); + m_allSearchPaths.clear(); +} + +const QStringList &ItemReader::allSearchPaths() const +{ + if (m_allSearchPaths.empty()) { + std::for_each(m_extraSearchPaths.crbegin(), m_extraSearchPaths.crend(), + [this] (const QStringList &paths) { + m_allSearchPaths += paths; + }); + m_allSearchPaths += m_searchPaths; + m_allSearchPaths.removeDuplicates(); + } + return m_allSearchPaths; +} + +Item *ItemReader::readFile(const QString &filePath) +{ + AccumulatingTimer readFileTimer(m_elapsedTime != -1 ? &m_elapsedTime : nullptr); + return m_visitorState->readFile(filePath, allSearchPaths(), m_pool); +} + +Item *ItemReader::readFile(const QString &filePath, const CodeLocation &referencingLocation) +{ + try { + return readFile(filePath); + } catch (const ErrorInfo &e) { + if (e.hasLocation()) + throw; + throw ErrorInfo(e.toString(), referencingLocation); + } +} + +Set ItemReader::filesRead() const +{ + return m_visitorState->filesRead(); +} + +void ItemReader::setEnableTiming(bool on) +{ + m_elapsedTime = on ? 0 : -1; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/itemreader.h b/src/lib/corelib/language/itemreader.h new file mode 100644 index 00000000..3dc5329d --- /dev/null +++ b/src/lib/corelib/language/itemreader.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMREADER_H +#define QBS_ITEMREADER_H + +#include "forward_decls.h" +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class Item; +class ItemPool; +class ItemReaderVisitorState; + +/* + * Reads a qbs file and creates a tree of Item objects. + * + * In this stage the following steps are performed: + * - The QML/JS parser creates the AST. + * - The AST is converted to a tree of Item objects. + * + * This class is also responsible for the QMLish inheritance semantics. + */ +class ItemReader +{ +public: + ItemReader(Logger &logger); + ~ItemReader(); + + void setPool(ItemPool *pool) { m_pool = pool; } + void setSearchPaths(const QStringList &searchPaths); + void pushExtraSearchPaths(const QStringList &extraSearchPaths); + void popExtraSearchPaths(); + const std::vector &extraSearchPathsStack() const; + void setExtraSearchPathsStack(const std::vector &s); + void clearExtraSearchPathsStack(); + const QStringList &allSearchPaths() const; + + Item *readFile(const QString &filePath); + Item *readFile(const QString &filePath, const CodeLocation &referencingLocation); + + Set filesRead() const; + + void setEnableTiming(bool on); + qint64 elapsedTime() const { return m_elapsedTime; } + +private: + ItemPool *m_pool = nullptr; + QStringList m_searchPaths; + std::vector m_extraSearchPaths; + mutable QStringList m_allSearchPaths; + const std::unique_ptr m_visitorState; + qint64 m_elapsedTime = -1; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEMREADER_H diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp new file mode 100644 index 00000000..f22a1c4e --- /dev/null +++ b/src/lib/corelib/language/itemreaderastvisitor.cpp @@ -0,0 +1,405 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "itemreaderastvisitor.h" + +#include "astimportshandler.h" +#include "astpropertiesitemhandler.h" +#include "asttools.h" +#include "builtindeclarations.h" +#include "filecontext.h" +#include "identifiersearch.h" +#include "item.h" +#include "itemreadervisitorstate.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace QbsQmlJS; + +namespace qbs { +namespace Internal { + +ItemReaderASTVisitor::ItemReaderASTVisitor(ItemReaderVisitorState &visitorState, + FileContextPtr file, ItemPool *itemPool, Logger &logger) + : m_visitorState(visitorState) + , m_file(std::move(file)) + , m_itemPool(itemPool) + , m_logger(logger) +{ +} + +bool ItemReaderASTVisitor::visit(AST::UiProgram *uiProgram) +{ + ASTImportsHandler importsHandler(m_visitorState, m_logger, m_file); + importsHandler.handleImports(uiProgram->imports); + m_typeNameToFile = importsHandler.typeNameFileMap(); + return true; +} + +static ItemValuePtr findItemProperty(const Item *container, const Item *item) +{ + ItemValuePtr itemValue; + const auto &srcprops = container->properties(); + auto it = std::find_if(srcprops.begin(), srcprops.end(), [item] (const ValuePtr &v) { + return v->type() == Value::ItemValueType + && std::static_pointer_cast(v)->item() == item; + }); + if (it != srcprops.end()) + itemValue = std::static_pointer_cast(it.value()); + return itemValue; +} + +bool ItemReaderASTVisitor::visit(AST::UiObjectDefinition *ast) +{ + const QString typeName = ast->qualifiedTypeNameId->name.toString(); + const CodeLocation itemLocation = toCodeLocation(ast->qualifiedTypeNameId->identifierToken); + const Item *baseItem = nullptr; + Item *mostDerivingItem = nullptr; + + Item *item = Item::create(m_itemPool, ItemType::Unknown); + item->setFile(m_file); + item->setLocation(itemLocation); + + // Inheritance resolving, part 1: Find out our actual type name (needed for setting + // up children and alternatives). + const QStringList fullTypeName = toStringList(ast->qualifiedTypeNameId); + const QString baseTypeFileName = m_typeNameToFile.value(fullTypeName); + ItemType itemType; + if (!baseTypeFileName.isEmpty()) { + const bool isMostDerivingItem = (m_visitorState.mostDerivingItem() == nullptr); + if (isMostDerivingItem) + m_visitorState.setMostDerivingItem(item); + mostDerivingItem = m_visitorState.mostDerivingItem(); + baseItem = m_visitorState.readFile(baseTypeFileName, m_file->searchPaths(), m_itemPool); + if (isMostDerivingItem) + m_visitorState.setMostDerivingItem(nullptr); + QBS_CHECK(baseItem->type() <= ItemType::LastActualItem); + itemType = baseItem->type(); + } else { + if (fullTypeName.size() > 1) { + throw ErrorInfo(Tr::tr("Invalid item '%1'. Did you mean to set a module property?") + .arg(fullTypeName.join(QLatin1Char('.'))), itemLocation); + } + itemType = BuiltinDeclarations::instance().typeForName(typeName, itemLocation); + checkDeprecationStatus(itemType, typeName, itemLocation); + if (itemType == ItemType::Properties && m_item && m_item->type() == ItemType::SubProject) + itemType = ItemType::PropertiesInSubProject; + } + + item->m_type = itemType; + + if (m_item) + Item::addChild(m_item, item); // Add this item to the children of the parent item. + else + m_item = item; // This is the root item. + + if (ast->initializer) { + Item *mdi = m_visitorState.mostDerivingItem(); + m_visitorState.setMostDerivingItem(nullptr); + qSwap(m_item, item); + const ItemType oldInstanceItemType = m_instanceItemType; + if (itemType == ItemType::Parameters || itemType == ItemType::Depends) + m_instanceItemType = ItemType::ModuleParameters; + ast->initializer->accept(this); + m_instanceItemType = oldInstanceItemType; + qSwap(m_item, item); + m_visitorState.setMostDerivingItem(mdi); + } + + ASTPropertiesItemHandler(item).handlePropertiesItems(); + + // Inheritance resolving, part 2 (depends on alternatives having been set up). + if (baseItem) { + inheritItem(item, baseItem); + if (baseItem->file()->idScope()) { + // Make ids from the derived file visible in the base file. + // ### Do we want to turn off this feature? It's QMLish but kind of strange. + item->file()->ensureIdScope(m_itemPool); + baseItem->file()->idScope()->setPrototype(item->file()->idScope()); + + // Replace the base item with the most deriving item. + ItemValuePtr baseItemIdValue = findItemProperty(baseItem->file()->idScope(), baseItem); + if (baseItemIdValue) + baseItemIdValue->setItem(mostDerivingItem); + } + } else { + // Only the item at the top of the inheritance chain is a built-in item. + // We cannot do this in "part 1", because then the visitor would complain about duplicate + // bindings. + item->setupForBuiltinType(m_logger); + } + + return false; +} + +void ItemReaderASTVisitor::checkDuplicateBinding(Item *item, const QStringList &bindingName, + const AST::SourceLocation &sourceLocation) +{ + if (Q_UNLIKELY(item->hasOwnProperty(bindingName.last()))) { + QString msg = Tr::tr("Duplicate binding for '%1'"); + throw ErrorInfo(msg.arg(bindingName.join(QLatin1Char('.'))), + toCodeLocation(sourceLocation)); + } +} + +bool ItemReaderASTVisitor::visit(AST::UiPublicMember *ast) +{ + PropertyDeclaration p; + if (Q_UNLIKELY(ast->name.isEmpty())) + throw ErrorInfo(Tr::tr("public member without name")); + if (Q_UNLIKELY(ast->memberType.isEmpty())) + throw ErrorInfo(Tr::tr("public member without type")); + if (Q_UNLIKELY(ast->type == AST::UiPublicMember::Signal)) + throw ErrorInfo(Tr::tr("public member with signal type not supported")); + p.setName(ast->name.toString()); + p.setType(PropertyDeclaration::propertyTypeFromString(ast->memberType.toString())); + if (p.type() == PropertyDeclaration::UnknownType) { + throw ErrorInfo(Tr::tr("Unknown type '%1' in property declaration.") + .arg(ast->memberType.toString()), toCodeLocation(ast->typeToken)); + } + if (Q_UNLIKELY(!ast->typeModifier.isEmpty())) { + throw ErrorInfo(Tr::tr("public member with type modifier '%1' not supported").arg( + ast->typeModifier.toString())); + } + if (ast->isReadonlyMember) + p.setFlags(PropertyDeclaration::ReadOnlyFlag); + + m_item->m_propertyDeclarations.insert(p.name(), p); + + const JSSourceValuePtr value = JSSourceValue::create(); + value->setFile(m_file); + if (ast->statement) { + handleBindingRhs(ast->statement, value); + const QStringList bindingName(p.name()); + checkDuplicateBinding(m_item, bindingName, ast->colonToken); + } + + m_item->setProperty(p.name(), value); + return false; +} + +bool ItemReaderASTVisitor::visit(AST::UiScriptBinding *ast) +{ + QBS_CHECK(ast->qualifiedId); + QBS_CHECK(!ast->qualifiedId->name.isEmpty()); + + const QStringList bindingName = toStringList(ast->qualifiedId); + + if (bindingName.length() == 1 && bindingName.front() == QStringLiteral("id")) { + const auto * const expStmt = AST::cast(ast->statement); + if (Q_UNLIKELY(!expStmt)) + throw ErrorInfo(Tr::tr("id: must be followed by identifier")); + const auto * const idExp = AST::cast(expStmt->expression); + if (Q_UNLIKELY(!idExp || idExp->name.isEmpty())) + throw ErrorInfo(Tr::tr("id: must be followed by identifier")); + m_item->m_id = idExp->name.toString(); + m_file->ensureIdScope(m_itemPool); + ItemValueConstPtr existingId = m_file->idScope()->itemProperty(m_item->id()); + if (existingId) { + ErrorInfo e(Tr::tr("The id '%1' is not unique.").arg(m_item->id())); + e.append(Tr::tr("First occurrence is here."), existingId->item()->location()); + e.append(Tr::tr("Next occurrence is here."), m_item->location()); + throw e; + } + m_file->idScope()->setProperty(m_item->id(), ItemValue::create(m_item)); + return false; + } + + const JSSourceValuePtr value = JSSourceValue::create(); + handleBindingRhs(ast->statement, value); + + Item * const targetItem = targetItemForBinding(bindingName, value); + checkDuplicateBinding(targetItem, bindingName, ast->qualifiedId->identifierToken); + targetItem->setProperty(bindingName.last(), value); + return false; +} + +bool ItemReaderASTVisitor::handleBindingRhs(AST::Statement *statement, + const JSSourceValuePtr &value) +{ + QBS_CHECK(statement); + QBS_CHECK(value); + + if (AST::cast(statement)) + value->m_flags |= JSSourceValue::HasFunctionForm; + + value->setFile(m_file); + value->setSourceCode(textViewOf(m_file->content(), statement)); + value->setLocation(statement->firstSourceLocation().startLine, + statement->firstSourceLocation().startColumn); + + bool usesBase, usesOuter, usesOriginal; + IdentifierSearch idsearch; + idsearch.add(StringConstants::baseVar(), &usesBase); + idsearch.add(StringConstants::outerVar(), &usesOuter); + idsearch.add(StringConstants::originalVar(), &usesOriginal); + idsearch.start(statement); + if (usesBase) + value->m_flags |= JSSourceValue::SourceUsesBase; + if (usesOuter) + value->m_flags |= JSSourceValue::SourceUsesOuter; + if (usesOriginal) + value->m_flags |= JSSourceValue::SourceUsesOriginal; + return false; +} + +CodeLocation ItemReaderASTVisitor::toCodeLocation(const AST::SourceLocation &location) const +{ + return CodeLocation(m_file->filePath(), location.startLine, location.startColumn); +} + +Item *ItemReaderASTVisitor::targetItemForBinding(const QStringList &bindingName, + const JSSourceValueConstPtr &value) +{ + Item *targetItem = m_item; + const int c = bindingName.size() - 1; + for (int i = 0; i < c; ++i) { + ValuePtr v = targetItem->ownProperty(bindingName.at(i)); + if (!v) { + const ItemType itemType = i < c - 1 ? ItemType::ModulePrefix : m_instanceItemType; + Item *newItem = Item::create(m_itemPool, itemType); + newItem->setLocation(value->location()); + v = ItemValue::create(newItem); + targetItem->setProperty(bindingName.at(i), v); + } + if (Q_UNLIKELY(v->type() != Value::ItemValueType)) { + QString msg = Tr::tr("Binding to non-item property."); + throw ErrorInfo(msg, value->location()); + } + targetItem = std::static_pointer_cast(v)->item(); + } + return targetItem; +} + +void ItemReaderASTVisitor::inheritItem(Item *dst, const Item *src) +{ + int insertPos = 0; + for (Item *child : qAsConst(src->m_children)) { + dst->m_children.insert(insertPos++, child); + child->m_parent = dst; + } + + for (const PropertyDeclaration &pd : src->propertyDeclarations()) { + if (pd.flags().testFlag(PropertyDeclaration::ReadOnlyFlag) + && dst->hasOwnProperty(pd.name())) { + throw ErrorInfo(Tr::tr("Cannot set read-only property '%1'.").arg(pd.name()), + dst->property(pd.name())->location()); + } + dst->setPropertyDeclaration(pd.name(), pd); + } + + for (auto it = src->properties().constBegin(); it != src->properties().constEnd(); ++it) { + ValuePtr &v = dst->m_properties[it.key()]; + if (!v) { + v = it.value(); + continue; + } + if (v->type() == Value::ItemValueType && it.value()->type() != Value::ItemValueType) + throw ErrorInfo(Tr::tr("Binding to non-item property."), v->location()); + if (v->type() != it.value()->type()) + continue; + switch (v->type()) { + case Value::JSSourceValueType: { + JSSourceValuePtr sv = std::static_pointer_cast(v); + QBS_CHECK(!sv->baseValue()); + const JSSourceValuePtr baseValue = std::static_pointer_cast(it.value()); + sv->setBaseValue(baseValue); + for (const JSSourceValue::Alternative &alt : sv->m_alternatives) + alt.value->setBaseValue(baseValue); + break; + } + case Value::ItemValueType: + inheritItem(std::static_pointer_cast(v)->item(), + std::static_pointer_cast(it.value())->item()); + break; + default: + QBS_CHECK(!"unexpected value type"); + } + } +} + +void ItemReaderASTVisitor::checkDeprecationStatus(ItemType itemType, const QString &itemName, + const CodeLocation &itemLocation) +{ + const ItemDeclaration itemDecl = BuiltinDeclarations::instance().declarationsForType(itemType); + const DeprecationInfo &di = itemDecl.deprecationInfo(); + if (!di.isValid()) + return; + if (di.removalVersion() <= LanguageInfo::qbsVersion()) { + QString message = Tr::tr("The item '%1' cannot be used anymore. " + "It was removed in qbs %2.") + .arg(itemName, di.removalVersion().toString()); + ErrorInfo error(message, itemLocation); + if (!di.additionalUserInfo().isEmpty()) + error.append(di.additionalUserInfo()); + throw error; + } + QString warning = Tr::tr("The item '%1' is deprecated and will be removed in " + "qbs %2.").arg(itemName, di.removalVersion().toString()); + ErrorInfo error(warning, itemLocation); + if (!di.additionalUserInfo().isEmpty()) + error.append(di.additionalUserInfo()); + m_logger.printWarning(error); +} + +void ItemReaderASTVisitor::doCheckItemTypes(const Item *item) +{ + const ItemDeclaration decl = BuiltinDeclarations::instance().declarationsForType(item->type()); + for (const Item * const child : item->children()) { + if (!decl.isChildTypeAllowed(child->type())) { + throw ErrorInfo(Tr::tr("Items of type '%1' cannot contain items of type '%2'.") + .arg(item->typeName(), child->typeName()), child->location()); + } + doCheckItemTypes(child); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/itemreaderastvisitor.h b/src/lib/corelib/language/itemreaderastvisitor.h new file mode 100644 index 00000000..963b7847 --- /dev/null +++ b/src/lib/corelib/language/itemreaderastvisitor.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMREADERASTVISITOR_H +#define QBS_ITEMREADERASTVISITOR_H + +#include "forward_decls.h" +#include "itemtype.h" + +#include +#include + +#include +#include + +namespace qbs { +class CodeLocation; + +namespace Internal { +class Item; +class ItemPool; +class ItemReaderVisitorState; + +class ItemReaderASTVisitor : public QbsQmlJS::AST::Visitor +{ +public: + ItemReaderASTVisitor(ItemReaderVisitorState &visitorState, FileContextPtr file, + ItemPool *itemPool, Logger &logger); + void checkItemTypes() { doCheckItemTypes(rootItem()); } + + Item *rootItem() const { return m_item; } + +private: + bool visit(QbsQmlJS::AST::UiProgram *uiProgram) override; + bool visit(QbsQmlJS::AST::UiObjectDefinition *ast) override; + bool visit(QbsQmlJS::AST::UiPublicMember *ast) override; + bool visit(QbsQmlJS::AST::UiScriptBinding *ast) override; + + bool handleBindingRhs(QbsQmlJS::AST::Statement *statement, const JSSourceValuePtr &value); + CodeLocation toCodeLocation(const QbsQmlJS::AST::SourceLocation &location) const; + void checkDuplicateBinding(Item *item, const QStringList &bindingName, + const QbsQmlJS::AST::SourceLocation &sourceLocation); + Item *targetItemForBinding(const QStringList &binding, const JSSourceValueConstPtr &value); + static void inheritItem(Item *dst, const Item *src); + void checkDeprecationStatus(ItemType itemType, const QString &itemName, + const CodeLocation &itemLocation); + void doCheckItemTypes(const Item *item); + + ItemReaderVisitorState &m_visitorState; + const FileContextPtr m_file; + ItemPool * const m_itemPool; + Logger &m_logger; + QHash m_typeNameToFile; + Item *m_item = nullptr; + ItemType m_instanceItemType = ItemType::ModuleInstance; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_ITEMREADERASTVISITOR_H diff --git a/src/lib/corelib/language/itemreadervisitorstate.cpp b/src/lib/corelib/language/itemreadervisitorstate.cpp new file mode 100644 index 00000000..a51b7eab --- /dev/null +++ b/src/lib/corelib/language/itemreadervisitorstate.cpp @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "itemreadervisitorstate.h" + +#include "asttools.h" +#include "filecontext.h" +#include "itemreaderastvisitor.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class ASTCacheValueData : public QSharedData +{ + Q_DISABLE_COPY(ASTCacheValueData) +public: + ASTCacheValueData() + : ast(nullptr) + , processing(false) + { + } + + QString code; + QbsQmlJS::Engine engine; + QbsQmlJS::AST::UiProgram *ast; + bool processing; +}; + +class ASTCacheValue +{ +public: + ASTCacheValue() + : d(new ASTCacheValueData) + { + } + + ASTCacheValue(const ASTCacheValue &other) = default; + + void setProcessingFlag(bool b) { d->processing = b; } + bool isProcessing() const { return d->processing; } + + void setCode(const QString &code) { d->code = code; } + QString code() const { return d->code; } + + QbsQmlJS::Engine *engine() const { return &d->engine; } + + void setAst(QbsQmlJS::AST::UiProgram *ast) { d->ast = ast; } + QbsQmlJS::AST::UiProgram *ast() const { return d->ast; } + bool isValid() const { return d->ast; } + +private: + QExplicitlySharedDataPointer d; +}; + +class ItemReaderVisitorState::ASTCache : public std::unordered_map {}; + + +ItemReaderVisitorState::ItemReaderVisitorState(Logger &logger) + : m_logger(logger) + , m_astCache(std::make_unique()) +{ + +} + +ItemReaderVisitorState::~ItemReaderVisitorState() = default; + +Item *ItemReaderVisitorState::readFile(const QString &filePath, const QStringList &searchPaths, + ItemPool *itemPool) +{ + ASTCacheValue &cacheValue = (*m_astCache)[filePath]; + if (cacheValue.isValid()) { + if (Q_UNLIKELY(cacheValue.isProcessing())) + throw ErrorInfo(Tr::tr("Loop detected when importing '%1'.").arg(filePath)); + } else { + QFile file(filePath); + if (Q_UNLIKELY(!file.open(QFile::ReadOnly))) + throw ErrorInfo(Tr::tr("Cannot open '%1'.").arg(filePath)); + + m_filesRead.insert(filePath); + QTextStream stream(&file); + setupDefaultCodec(stream); + const QString &code = stream.readAll(); + QbsQmlJS::Lexer lexer(cacheValue.engine()); + lexer.setCode(code, 1); + QbsQmlJS::Parser parser(cacheValue.engine()); + + file.close(); + if (!parser.parse()) { + const QList &parserMessages = parser.diagnosticMessages(); + if (Q_UNLIKELY(!parserMessages.empty())) { + ErrorInfo err; + for (const QbsQmlJS::DiagnosticMessage &msg : parserMessages) + err.append(msg.message, toCodeLocation(filePath, msg.loc)); + throw err; + } + } + + cacheValue.setCode(code); + cacheValue.setAst(parser.ast()); + } + + const FileContextPtr file = FileContext::create(); + file->setFilePath(QFileInfo(filePath).absoluteFilePath()); + file->setContent(cacheValue.code()); + file->setSearchPaths(searchPaths); + + ItemReaderASTVisitor astVisitor(*this, file, itemPool, m_logger); + { + class ProcessingFlagManager { + public: + ProcessingFlagManager(ASTCacheValue &v) : m_cacheValue(v) { v.setProcessingFlag(true); } + ~ProcessingFlagManager() { m_cacheValue.setProcessingFlag(false); } + private: + ASTCacheValue &m_cacheValue; + } processingFlagManager(cacheValue); + cacheValue.ast()->accept(&astVisitor); + } + astVisitor.checkItemTypes(); + return astVisitor.rootItem(); +} + +void ItemReaderVisitorState::cacheDirectoryEntries(const QString &dirPath, const QStringList &entries) +{ + m_directoryEntries.insert(dirPath, entries); +} + +bool ItemReaderVisitorState::findDirectoryEntries(const QString &dirPath, QStringList *entries) const +{ + const auto it = m_directoryEntries.constFind(dirPath); + if (it == m_directoryEntries.constEnd()) + return false; + *entries = it.value(); + return true; +} + +Item *ItemReaderVisitorState::mostDerivingItem() const +{ + return m_mostDerivingItem; +} + +void ItemReaderVisitorState::setMostDerivingItem(Item *item) +{ + m_mostDerivingItem = item; +} + + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/itemreadervisitorstate.h b/src/lib/corelib/language/itemreadervisitorstate.h new file mode 100644 index 00000000..3901be16 --- /dev/null +++ b/src/lib/corelib/language/itemreadervisitorstate.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ITEMREADERVISITORSTATE_H +#define QBS_ITEMREADERVISITORSTATE_H + +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { +class Item; +class ItemPool; + +class ItemReaderVisitorState +{ +public: + ItemReaderVisitorState(Logger &logger); + ~ItemReaderVisitorState(); + + Set filesRead() const { return m_filesRead; } + + Item *readFile(const QString &filePath, const QStringList &searchPaths, ItemPool *itemPool); + + void cacheDirectoryEntries(const QString &dirPath, const QStringList &entries); + bool findDirectoryEntries(const QString &dirPath, QStringList *entries) const; + + Item *mostDerivingItem() const; + void setMostDerivingItem(Item *item); + +private: + Logger &m_logger; + Set m_filesRead; + QHash m_directoryEntries; + Item *m_mostDerivingItem = nullptr; + + class ASTCache; + const std::unique_ptr m_astCache; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/language/itemtype.h b/src/lib/corelib/language/itemtype.h new file mode 100644 index 00000000..465396f4 --- /dev/null +++ b/src/lib/corelib/language/itemtype.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ITEMTYPE_H +#define QBS_ITEMTYPE_H + +#include + +namespace qbs { +namespace Internal { + +enum class ItemType { + // Actual user-visible items. + FirstActualItem, + Artifact = FirstActualItem, + Depends, + Export, + FileTagger, + Group, + JobLimit, + Module, + ModuleProvider, + Parameter, + Parameters, + Probe, + Product, + Profile, + Project, + Properties, + PropertiesInSubProject, + PropertyOptions, + Rule, + Scanner, + SubProject, + Transformer, + LastActualItem = Transformer, + + // Internal items created mainly by the module loader. + IdScope, + ModuleInstance, + ModuleParameters, + ModulePrefix, + Outer, + Scope, + + Unknown +}; + +inline auto qHash(ItemType t) { return QT_PREPEND_NAMESPACE(qHash)(uint(t)); } + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. + diff --git a/src/lib/corelib/language/jsimports.h b/src/lib/corelib/language/jsimports.h new file mode 100644 index 00000000..a4a045f2 --- /dev/null +++ b/src/lib/corelib/language/jsimports.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_JSIMPORTS_H +#define QBS_JSIMPORTS_H + +#include +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +/** + * Represents JavaScript import of the form + * import 'fileOrDirectory' as scopeName + * + * There can be several filenames per scope + * if we import a whole directory. + */ +class JsImport +{ +public: + QString scopeName; + QStringList filePaths; + CodeLocation location; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(scopeName, filePaths, location); + } +}; +inline auto qHash(const JsImport &jsi) { return qHash(jsi.scopeName); } + +inline bool operator<(const JsImport &lhs, const JsImport &rhs) +{ + return lhs.scopeName < rhs.scopeName; +} + +inline bool operator==(const JsImport &jsi1, const JsImport &jsi2) +{ + return jsi1.scopeName == jsi2.scopeName && toSet(jsi1.filePaths) == toSet(jsi2.filePaths); +} + +using JsImports = std::vector; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_JSIMPORTS_H diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp new file mode 100644 index 00000000..3db41b8c --- /dev/null +++ b/src/lib/corelib/language/language.cpp @@ -0,0 +1,982 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "language.h" + +#include "artifactproperties.h" +#include "builtindeclarations.h" +#include "propertymapinternal.h" +#include "scriptengine.h" + +#include +#include +#include +#include +#include // TODO: Move to language? +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +template bool equals(const T *v1, const T *v2) +{ + if (v1 == v2) + return true; + if (!v1 != !v2) + return false; + return *v1 == *v2; +} + + +/*! + * \class FileTagger + * \brief The \c FileTagger class maps 1:1 to the respective item in a qbs source file. + */ + +FileTagger::FileTagger(const QStringList &patterns, FileTags fileTags, int priority) + : m_fileTags(std::move(fileTags)), m_priority(priority) +{ + setPatterns(patterns); +} + +void FileTagger::setPatterns(const QStringList &patterns) +{ + m_patterns.clear(); + for (const QString &pattern : patterns) { + QBS_CHECK(!pattern.isEmpty()); + m_patterns << QRegularExpression(QRegularExpression::wildcardToRegularExpression(pattern)); + } +} + + +bool Probe::needsReconfigure(const FileTime &referenceTime) const +{ + const auto criterion = [referenceTime](const QString &filePath) { + FileInfo fi(filePath); + return !fi.exists() || fi.lastModified() > referenceTime; + }; + return Internal::any_of(m_importedFilesUsed, criterion); +} + + +/*! + * \class SourceArtifact + * \brief The \c SourceArtifact class represents a source file. + * Everything except the file path is inherited from the surrounding \c ResolvedGroup. + * (TODO: Not quite true. Artifacts in transformers will be generated by the transformer, but are + * still represented as source artifacts. We may or may not want to change this; if we do, + * SourceArtifact could simply have a back pointer to the group in addition to the file path.) + * \sa ResolvedGroup + */ + + +/*! + * \class ResolvedGroup + * \brief The \c ResolvedGroup class corresponds to the Group item in a qbs source file. + */ + + /*! + * \variable ResolvedGroup::files + * \brief The files listed in the group item's "files" binding. + * Note that these do not include expanded wildcards. + */ + +/*! + * \variable ResolvedGroup::wildcards + * \brief Represents the wildcard elements in this group's "files" binding. + * If no wildcards are specified there, this variable is null. + * \sa SourceWildCards + */ + +/*! + * \brief Returns all files specified in the group item as source artifacts. + * This includes the expanded list of wildcards. + */ +std::vector ResolvedGroup::allFiles() const +{ + std::vector lst = files; + if (wildcards) + lst << wildcards->files; + return lst; +} + +void ResolvedGroup::load(PersistentPool &pool) +{ + serializationOp(pool); + if (wildcards) + wildcards->group = this; +} + +void ResolvedGroup::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +/*! + * \class RuleArtifact + * \brief The \c RuleArtifact class represents an Artifact item encountered in the context + * of a Rule item. + * When applying the rule, one \c Artifact object will be constructed from each \c RuleArtifact + * object. During that process, the \c RuleArtifact's bindings are evaluated and the results + * are inserted into the corresponding \c Artifact's properties. + * \sa Rule + */ + + +/*! + * \class ScriptFunction + * \brief The \c ScriptFunction class represents the JavaScript code found in the "prepare" binding + * of a \c Rule item in a qbs file. + * \sa Rule + */ + +ScriptFunction::ScriptFunction() = default; + +ScriptFunction::~ScriptFunction() = default; + + /*! + * \variable ScriptFunction::script + * \brief The actual Javascript code, taken verbatim from the qbs source file. + */ + + /*! + * \variable ScriptFunction::location + * \brief The exact location of the script in the qbs source file. + * This is mostly needed for diagnostics. + */ + +bool ScriptFunction::isValid() const +{ + return location.line() != -1; +} + +bool operator==(const ScriptFunction &a, const ScriptFunction &b) +{ + return a.sourceCode == b.sourceCode + && a.location == b.location + && equals(a.fileContext.get(), b.fileContext.get()); +} + +QStringList ResolvedModule::argumentNamesForSetupBuildEnv() +{ + static const QStringList argNames = BuiltinDeclarations::instance() + .argumentNamesForScriptFunction(ItemType::Module, + StringConstants::setupBuildEnvironmentProperty()); + return argNames; +} + +QStringList ResolvedModule::argumentNamesForSetupRunEnv() +{ + static const QStringList argNames = BuiltinDeclarations::instance() + .argumentNamesForScriptFunction(ItemType::Module, + StringConstants::setupRunEnvironmentProperty()); + return argNames; +} + +bool operator==(const ResolvedModule &m1, const ResolvedModule &m2) +{ + return m1.name == m2.name + && m1.isProduct == m2.isProduct + && toSet(m1.moduleDependencies) == toSet(m2.moduleDependencies) + && m1.setupBuildEnvironmentScript == m2.setupBuildEnvironmentScript + && m1.setupRunEnvironmentScript == m2.setupRunEnvironmentScript; +} + +RulePtr Rule::clone() const +{ + return std::make_shared(*this); +} + +QStringList Rule::argumentNamesForOutputArtifacts() +{ + static const QStringList argNames = BuiltinDeclarations::instance() + .argumentNamesForScriptFunction(ItemType::Rule, + StringConstants::outputArtifactsProperty()); + return argNames; +} + +QStringList Rule::argumentNamesForPrepare() +{ + static const QStringList argNames = BuiltinDeclarations::instance() + .argumentNamesForScriptFunction(ItemType::Rule, StringConstants::prepareProperty()); + return argNames; +} + +QString Rule::toString() const +{ + QStringList outputTagsSorted = collectedOutputFileTags().toStringList(); + outputTagsSorted.sort(); + FileTags inputTags = inputs; + inputTags.unite(inputsFromDependencies); + QStringList inputTagsSorted = inputTags.toStringList(); + inputTagsSorted.sort(); + return QLatin1Char('[') + outputTagsSorted.join(QLatin1Char(',')) + + QLatin1String("][") + + inputTagsSorted.join(QLatin1Char(',')) + QLatin1Char(']'); +} + +FileTags Rule::staticOutputFileTags() const +{ + FileTags result; + for (const auto &artifact : artifacts) + result.unite(artifact->fileTags); + return result; +} + +FileTags Rule::collectedOutputFileTags() const +{ + FileTags result = outputFileTags.empty() ? staticOutputFileTags() : outputFileTags; + for (const auto &ap : product->artifactProperties) { + if (ap->fileTagsFilter().intersects(result)) + result += ap->extraFileTags(); + } + return result; +} + +bool Rule::isDynamic() const +{ + return outputArtifactsScript.isValid(); +} + +bool Rule::declaresInputs() const +{ + return !inputs.empty() || !inputsFromDependencies.empty(); +} + +ResolvedProduct::ResolvedProduct() + : enabled(true) +{ +} + +ResolvedProduct::~ResolvedProduct() = default; + +void ResolvedProduct::accept(BuildGraphVisitor *visitor) const +{ + if (!buildData) + return; + for (BuildGraphNode * const node : qAsConst(buildData->rootNodes())) + node->accept(visitor); +} + +/*! + * \brief Returns all files of all groups as source artifacts. + * This includes the expanded list of wildcards. + */ +std::vector ResolvedProduct::allFiles() const +{ + std::vector lst; + for (const auto &group : groups) + lst << group->allFiles(); + return lst; +} + +/*! + * \brief Returns all files of all enabled groups as source artifacts. + * \sa ResolvedProduct::allFiles() + */ +std::vector ResolvedProduct::allEnabledFiles() const +{ + std::vector lst; + for (const auto &group : groups) { + if (group->enabled) + lst << group->allFiles(); + } + return lst; +} + +FileTags ResolvedProduct::fileTagsForFileName(const QString &fileName) const +{ + FileTags result; + std::unique_ptr priority; + for (const FileTaggerConstPtr &tagger : qAsConst(fileTaggers)) { + for (const QRegularExpression &pattern : tagger->patterns()) { + if (pattern.match(fileName).hasMatch()) { + if (priority) { + if (*priority != tagger->priority()) { + // The taggers are expected to be sorted by priority. + QBS_ASSERT(*priority > tagger->priority(), return result); + return result; + } + } else { + priority = std::make_unique(tagger->priority()); + } + result.unite(tagger->fileTags()); + break; + } + } + } + return result; +} + +void ResolvedProduct::load(PersistentPool &pool) +{ + serializationOp(pool); + for (const RulePtr &rule : rules) + rule->product = this; + for (const ResolvedModulePtr &module : modules) + module->product = this; +} + +void ResolvedProduct::store(PersistentPool &pool) +{ + serializationOp(pool); +} + +ArtifactSet ResolvedProduct::lookupArtifactsByFileTag(const FileTag &tag) const +{ + QBS_CHECK(buildData); + return buildData->artifactsByFileTag().value(tag); +} + +ArtifactSet ResolvedProduct::lookupArtifactsByFileTags(const FileTags &tags) const +{ + QBS_CHECK(buildData); + ArtifactSet set; + for (const FileTag &tag : tags) + set = set.unite(buildData->artifactsByFileTag().value(tag)); + return set; +} + +ArtifactSet ResolvedProduct::targetArtifacts() const +{ + QBS_CHECK(buildData); + ArtifactSet taSet; + for (Artifact * const a : buildData->rootArtifacts()) { + QBS_CHECK(a->fileTags().intersects(fileTags)); + taSet << a; + } + return taSet; +} + +TopLevelProject *ResolvedProduct::topLevelProject() const +{ + return project->topLevelProject(); +} + +QString ResolvedProduct::uniqueName(const QString &name, const QString &multiplexConfigurationId) +{ + QString result = name; + if (!multiplexConfigurationId.isEmpty()) + result.append(QLatin1Char('.')).append(multiplexConfigurationId); + return result; +} + +QString ResolvedProduct::uniqueName() const +{ + return uniqueName(name, multiplexConfigurationId); +} + +QString ResolvedProduct::fullDisplayName(const QString &name, + const QString &multiplexConfigurationId) +{ + QString result = name; + if (!multiplexConfigurationId.isEmpty()) + result.append(QLatin1Char(' ')).append(multiplexIdToString(multiplexConfigurationId)); + return result; +} + +QString ResolvedProduct::fullDisplayName() const +{ + return fullDisplayName(name, multiplexConfigurationId); +} + +QString ResolvedProduct::profile() const +{ + return moduleProperties->qbsPropertyValue(StringConstants::profileProperty()).toString(); +} + +static QStringList findGeneratedFiles(const Artifact *base, bool recursive, const FileTags &tags) +{ + QStringList result; + for (const Artifact *parent : base->parentArtifacts()) { + if (tags.empty() || parent->fileTags().intersects(tags)) + result << parent->filePath(); + if (recursive) + result << findGeneratedFiles(parent, true, tags); + } + return result; +} + +QStringList ResolvedProduct::generatedFiles(const QString &baseFile, bool recursive, + const FileTags &tags) const +{ + ProductBuildData *data = buildData.get(); + if (!data) + return {}; + + for (const Artifact *art : filterByType(data->allNodes())) { + if (art->filePath() == baseFile) + return findGeneratedFiles(art, recursive, tags); + } + return {}; +} + +QString ResolvedProduct::deriveBuildDirectoryName(const QString &name, + const QString &multiplexConfigurationId) +{ + QString dirName = uniqueName(name, multiplexConfigurationId); + const QByteArray hash = QCryptographicHash::hash(dirName.toUtf8(), QCryptographicHash::Sha1); + return HostOsInfo::rfc1034Identifier(dirName) + .append(QLatin1Char('.')) + .append(QString::fromLatin1(hash.toHex().left(8))); +} + +QString ResolvedProduct::buildDirectory() const +{ + return productProperties.value(StringConstants::buildDirectoryProperty()).toString(); +} + +bool ResolvedProduct::isInParentProject(const ResolvedProductConstPtr &other) const +{ + for (const ResolvedProject *otherParent = other->project.get(); otherParent; + otherParent = otherParent->parentProject.get()) { + if (otherParent == project.get()) + return true; + } + return false; +} + +bool ResolvedProduct::builtByDefault() const +{ + return productProperties.value(StringConstants::builtByDefaultProperty(), true).toBool(); +} + +void ResolvedProduct::cacheExecutablePath(const QString &origFilePath, const QString &fullFilePath) +{ + std::lock_guard locker(m_executablePathCacheLock); + m_executablePathCache.insert(origFilePath, fullFilePath); +} + +QString ResolvedProduct::cachedExecutablePath(const QString &origFilePath) const +{ + std::lock_guard locker(m_executablePathCacheLock); + return m_executablePathCache.value(origFilePath); +} + + +ResolvedProject::ResolvedProject() : enabled(true), m_topLevelProject(nullptr) +{ +} + +ResolvedProject::~ResolvedProject() = default; + +void ResolvedProject::accept(BuildGraphVisitor *visitor) const +{ + for (const ResolvedProductPtr &product : products) + product->accept(visitor); + for (const ResolvedProjectPtr &subProject : qAsConst(subProjects)) + subProject->accept(visitor); +} + +TopLevelProject *ResolvedProject::topLevelProject() +{ + if (m_topLevelProject) + return m_topLevelProject; + if (parentProject.expired()) { + m_topLevelProject = static_cast(this); + return m_topLevelProject; + } + m_topLevelProject = parentProject->topLevelProject(); + return m_topLevelProject; +} + +std::vector ResolvedProject::allSubProjects() const +{ + std::vector projectList = subProjects; + for (const auto &subProject : subProjects) + projectList << subProject->allSubProjects(); + return projectList; +} + +std::vector ResolvedProject::allProducts() const +{ + std::vector productList = products; + for (const auto &subProject : qAsConst(subProjects)) + productList << subProject->allProducts(); + return productList; +} + +void ResolvedProject::load(PersistentPool &pool) +{ + serializationOp(pool); + std::for_each(products.cbegin(), products.cend(), + [](const ResolvedProductPtr &p) { + if (!p->buildData) + return; + for (BuildGraphNode * const node : qAsConst(p->buildData->allNodes())) { + node->product = p; + + // restore parent links + for (BuildGraphNode * const child : qAsConst(node->children)) + child->parents.insert(node); + } + }); +} + +void ResolvedProject::store(PersistentPool &pool) +{ + serializationOp(pool); +} + + +TopLevelProject::TopLevelProject() + : bgLocker(nullptr), locked(false), lastStartResolveTime(FileTime::oldestTime()) +{ +} + +TopLevelProject::~TopLevelProject() +{ + cleanupModuleProviderOutput(); + delete bgLocker; +} + +QString TopLevelProject::deriveId(const QVariantMap &config) +{ + const QVariantMap qbsProperties = config.value(StringConstants::qbsModule()).toMap(); + const QString configurationName = qbsProperties.value( + StringConstants::configurationNameProperty()).toString(); + return configurationName; +} + +QString TopLevelProject::deriveBuildDirectory(const QString &buildRoot, const QString &id) +{ + return buildRoot + QLatin1Char('/') + id; +} + +void TopLevelProject::setBuildConfiguration(const QVariantMap &config) +{ + m_buildConfiguration = config; + m_id = deriveId(config); +} + +QString TopLevelProject::profile() const +{ + return projectProperties().value(StringConstants::profileProperty()).toString(); +} + +void TopLevelProject::makeModuleProvidersNonTransient() +{ + for (ModuleProviderInfo &m : moduleProviderInfo.providers) + m.transientOutput = false; +} + +QString TopLevelProject::buildGraphFilePath() const +{ + return ProjectBuildData::deriveBuildGraphFilePath(buildDirectory, id()); +} + +void TopLevelProject::store(Logger logger) +{ + // TODO: Use progress observer here. + + if (!buildData) + return; + if (!buildData->isDirty()) { + qCDebug(lcBuildGraph) << "build graph is unchanged in project" << id(); + return; + } + + makeModuleProvidersNonTransient(); + + const QString fileName = buildGraphFilePath(); + qCDebug(lcBuildGraph) << "storing:" << fileName; + PersistentPool pool(logger); + PersistentPool::HeadData headData; + headData.projectConfig = buildConfiguration(); + pool.setHeadData(headData); + pool.setupWriteStream(fileName); + store(pool); + pool.finalizeWriteStream(); + buildData->setClean(); +} + +void TopLevelProject::load(PersistentPool &pool) +{ + ResolvedProject::load(pool); + serializationOp(pool); + QBS_CHECK(buildData); +} + +void TopLevelProject::store(PersistentPool &pool) +{ + ResolvedProject::store(pool); + serializationOp(pool); +} + +void TopLevelProject::cleanupModuleProviderOutput() +{ + QString error; + for (const ModuleProviderInfo &m : qAsConst(moduleProviderInfo.providers)) { + if (m.transientOutput) { + if (!removeDirectoryWithContents(m.outputDirPath(buildDirectory), &error)) + qCWarning(lcBuildGraph) << "Error removing module provider output:" << error; + } + } + QDir moduleProviderBaseDir(buildDirectory + QLatin1Char('/') + + ModuleProviderInfo::outputBaseDirName()); + if (moduleProviderBaseDir.exists() && moduleProviderBaseDir.isEmpty() + && !removeDirectoryWithContents(moduleProviderBaseDir.path(), &error)) { + qCWarning(lcBuildGraph) << "Error removing module provider output:" << error; + } +} + +/*! + * \class SourceWildCards + * \brief Objects of the \c SourceWildCards class result from giving wildcards in a + * \c ResolvedGroup's "files" binding. + * \sa ResolvedGroup + */ + +/*! + * \variable SourceWildCards::prefix + * \brief Inherited from the \c ResolvedGroup + * \sa ResolvedGroup + */ + +/*! + * \variable SourceWildCards::patterns + * \brief All elements of the \c ResolvedGroup's "files" binding that contain wildcards. + * \sa ResolvedGroup + */ + +/*! + * \variable SourceWildCards::excludePatterns + * \brief Corresponds to the \c ResolvedGroup's "excludeFiles" binding. + * \sa ResolvedGroup + */ + +/*! + * \variable SourceWildCards::files + * \brief The \c SourceArtifacts resulting from the expanded list of matching files. + */ + +Set SourceWildCards::expandPatterns(const GroupConstPtr &group, + const QString &baseDir, const QString &buildDir) +{ + Set files = expandPatterns(group, patterns, baseDir, buildDir); + files -= expandPatterns(group, excludePatterns, baseDir, buildDir); + return files; +} + +Set SourceWildCards::expandPatterns(const GroupConstPtr &group, + const QStringList &patterns, const QString &baseDir, const QString &buildDir) +{ + Set files; + QString expandedPrefix = group->prefix; + if (expandedPrefix.startsWith(StringConstants::tildeSlash())) + expandedPrefix.replace(0, 1, QDir::homePath()); + for (QString pattern : patterns) { + pattern.prepend(expandedPrefix); + pattern.replace(QLatin1Char('\\'), QLatin1Char('/')); + QStringList parts = pattern.split(QLatin1Char('/'), QBS_SKIP_EMPTY_PARTS); + if (FileInfo::isAbsolute(pattern)) { + QString rootDir; + if (HostOsInfo::isWindowsHost() && pattern.at(0) != QLatin1Char('/')) { + rootDir = parts.takeFirst(); + if (!rootDir.endsWith(QLatin1Char('/'))) + rootDir.append(QLatin1Char('/')); + } else { + rootDir = QLatin1Char('/'); + } + expandPatterns(files, group, parts, rootDir, buildDir); + } else { + expandPatterns(files, group, parts, baseDir, buildDir); + } + } + + return files; +} + +void SourceWildCards::expandPatterns(Set &result, const GroupConstPtr &group, + const QStringList &parts, + const QString &baseDir, const QString &buildDir) +{ + // People might build directly in the project source directory. This is okay, since + // we keep the build data in a "container" directory. However, we must make sure we don't + // match any generated files therein as source files. + if (baseDir.startsWith(buildDir)) + return; + + dirTimeStamps.emplace_back(baseDir, FileInfo(baseDir).lastModified()); + + QStringList changed_parts = parts; + bool recursive = false; + QString part = changed_parts.takeFirst(); + + while (part == QStringLiteral("**")) { + recursive = true; + + if (changed_parts.empty()) { + part = StringConstants::star(); + break; + } + + part = changed_parts.takeFirst(); + } + + const bool isDir = !changed_parts.empty(); + + const QString &filePattern = part; + const QDirIterator::IteratorFlags itFlags = recursive + ? QDirIterator::Subdirectories + : QDirIterator::NoIteratorFlags; + QDir::Filters itFilters = isDir + ? QDir::Dirs + : QDir::Files | QDir::System + | QDir::Dirs; // This one is needed to get symbolic links to directories + + if (isDir && !FileInfo::isPattern(filePattern)) + itFilters |= QDir::Hidden; + if (filePattern != StringConstants::dotDot() && filePattern != StringConstants::dot()) + itFilters |= QDir::NoDotAndDotDot; + + QDirIterator it(baseDir, QStringList(filePattern), itFilters, itFlags); + while (it.hasNext()) { + const QString filePath = it.next(); + const QString parentDir = it.fileInfo().dir().path(); + if (parentDir.startsWith(buildDir)) + continue; // See above. + if (!isDir && it.fileInfo().isDir() && !it.fileInfo().isSymLink()) + continue; + if (isDir) { + expandPatterns(result, group, changed_parts, filePath, buildDir); + } else { + if (parentDir != baseDir) + dirTimeStamps.emplace_back(parentDir, FileInfo(baseDir).lastModified()); + result += QDir::cleanPath(filePath); + } + } +} + +template +QMap listToMap(const L &list) +{ + using V = typename L::value_type; + QMap map; + for (const V &elem : list) + map.insert(keyFromElem(elem), elem); + return map; +} + +template +bool listsAreEqual(const L &l1, const L &l2) +{ + if (l1.size() != l2.size()) + return false; + using V = typename L::value_type; + const QMap map1 = listToMap(l1); + const QMap map2 = listToMap(l2); + const auto keys = map1.keys(); + return Internal::all_of(keys, [&map1, &map2](const auto &key) { + const V &value2 = map2.value(key); + if (!value2) + return false; + return equals(map1.value(key).get(), value2.get()); + }); +} + +QString keyFromElem(const SourceArtifactPtr &sa) { return sa->absoluteFilePath; } +QString keyFromElem(const RulePtr &r) { + QString key = r->toString() + r->prepareScript.sourceCode(); + if (r->outputArtifactsScript.isValid()) + key += r->outputArtifactsScript.sourceCode(); + for (const auto &a : r->artifacts) + key += a->filePath; + return key; +} + +QString keyFromElem(const ArtifactPropertiesPtr &ap) +{ + QStringList lst = ap->fileTagsFilter().toStringList(); + lst.sort(); + return lst.join(QLatin1Char(',')); +} + +bool operator==(const SourceArtifactInternal &sa1, const SourceArtifactInternal &sa2) +{ + return sa1.absoluteFilePath == sa2.absoluteFilePath + && sa1.fileTags == sa2.fileTags + && sa1.overrideFileTags == sa2.overrideFileTags + && sa1.targetOfModule == sa2.targetOfModule + && !sa1.properties == !sa2.properties + && *sa1.properties == *sa2.properties; +} + +bool operator==(const Rule &r1, const Rule &r2) +{ + if (r1.artifacts.size() != r2.artifacts.size()) + return false; + for (size_t i = 0; i < r1.artifacts.size(); ++i) { + if (!equals(r1.artifacts.at(i).get(), r2.artifacts.at(i).get())) + return false; + } + + return r1.module->name == r2.module->name + && r1.prepareScript == r2.prepareScript + && r1.outputArtifactsScript == r2.outputArtifactsScript + && r1.inputs == r2.inputs + && r1.outputFileTags == r2.outputFileTags + && r1.auxiliaryInputs == r2.auxiliaryInputs + && r1.excludedInputs == r2.excludedInputs + && r1.inputsFromDependencies == r2.inputsFromDependencies + && r1.explicitlyDependsOn == r2.explicitlyDependsOn + && r1.explicitlyDependsOnFromDependencies == r2.explicitlyDependsOnFromDependencies + && r1.multiplex == r2.multiplex + && r1.requiresInputs == r2.requiresInputs + && r1.alwaysRun == r2.alwaysRun; +} + +bool ruleListsAreEqual(const std::vector &l1, const std::vector &l2) +{ + return listsAreEqual(l1, l2); +} + +bool operator==(const RuleArtifact &a1, const RuleArtifact &a2) +{ + return a1.filePath == a2.filePath + && a1.fileTags == a2.fileTags + && a1.alwaysUpdated == a2.alwaysUpdated + && rangeTo>(a1.bindings) == + rangeTo>(a2.bindings); +} + +bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2) +{ + return b1.code == b2.code && b1.name == b2.name; +} + +QHashValueType qHash(const RuleArtifact::Binding &b) +{ + return qHash(std::make_pair(b.code, b.name.join(QLatin1Char(',')))); +} + +bool artifactPropertyListsAreEqual(const std::vector &l1, + const std::vector &l2) +{ + return listsAreEqual(l1, l2); +} + +QString multiplexIdToString(const QString &id) +{ + return QString::fromUtf8(QByteArray::fromBase64(id.toUtf8())); +} + +bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b) +{ + return equals(a.m_sharedData.get(), b.m_sharedData.get()); +} + +bool operator==(const ExportedProperty &p1, const ExportedProperty &p2) +{ + return p1.fullName == p2.fullName + && p1.type == p2.type + && p1.sourceCode == p2.sourceCode + && p1.isBuiltin == p2.isBuiltin; +} + +bool operator==(const ExportedModuleDependency &d1, const ExportedModuleDependency &d2) +{ + return d1.name == d2.name && d1.moduleProperties == d2.moduleProperties; +} + +bool equals(const std::vector &l1, const std::vector &l2) +{ + static const auto cmp = [](const ExportedItemPtr &p1, const ExportedItemPtr &p2) { + return *p1 == *p2; + }; + return l1.size() == l2.size() && std::equal(l1.cbegin(), l1.cend(), l2.cbegin(), cmp); +} + +bool operator==(const ExportedItem &i1, const ExportedItem &i2) +{ + return i1.name == i2.name + && i1.properties == i2.properties + && equals(i1.children, i2.children); +} + +bool operator==(const ExportedModule &m1, const ExportedModule &m2) +{ + static const auto depMapsEqual = [](const QMap &m1, + const QMap &m2) { + if (m1.size() != m2.size()) + return false; + for (auto it1 = m1.cbegin(), it2 = m2.cbegin(); it1 != m1.cend(); ++it1, ++it2) { + if (it1.key()->name != it2.key()->name) + return false; + if (it1.value() != it2.value()) + return false; + } + return true; + }; + + return m1.propertyValues == m2.propertyValues + && m1.modulePropertyValues == m2.modulePropertyValues + && equals(m1.children, m2.children) + && m1.m_properties == m2.m_properties + && m1.importStatements == m2.importStatements + && m1.productDependencies.size() == m2.productDependencies.size() + && m1.productDependencies == m2.productDependencies + && depMapsEqual(m1.dependencyParameters, m2.dependencyParameters); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h new file mode 100644 index 00000000..146f00f8 --- /dev/null +++ b/src/lib/corelib/language/language.h @@ -0,0 +1,752 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LANGUAGE_H +#define QBS_LANGUAGE_H + +#include "filetags.h" +#include "forward_decls.h" +#include "jsimports.h" +#include "moduleproviderinfo.h" +#include "propertydeclaration.h" +#include "resolvedfilecontext.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QScriptEngine; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class BuildGraphLocker; +class BuildGraphLoader; +class BuildGraphVisitor; + +class FileTagger +{ +public: + static FileTaggerPtr create() { return FileTaggerPtr(new FileTagger); } + static FileTaggerPtr create(const QStringList &patterns, const FileTags &fileTags, + int priority) { + return FileTaggerPtr(new FileTagger(patterns, fileTags, priority)); + } + + const QList &patterns() const { return m_patterns; } + const FileTags &fileTags() const { return m_fileTags; } + int priority() const { return m_priority; } + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_patterns, m_fileTags, m_priority); + } + +private: + FileTagger(const QStringList &patterns, FileTags fileTags, int priority); + FileTagger() = default; + + void setPatterns(const QStringList &patterns); + + QList m_patterns; + FileTags m_fileTags; + int m_priority = 0; +}; + +class Probe +{ +public: + static ProbePtr create() { return ProbePtr(new Probe); } + static ProbeConstPtr create(const QString &globalId, + const CodeLocation &location, + bool condition, + const QString &configureScript, + const QVariantMap &properties, + const QVariantMap &initialProperties, + const std::vector &importedFilesUsed) + { + return ProbeConstPtr(new Probe(globalId, location, condition, configureScript, properties, + initialProperties, importedFilesUsed)); + } + + const QString &globalId() const { return m_globalId; } + bool condition() const { return m_condition; } + const QString &configureScript() const { return m_configureScript; } + const QVariantMap &properties() const { return m_properties; } + const QVariantMap &initialProperties() const { return m_initialProperties; } + const std::vector &importedFilesUsed() const { return m_importedFilesUsed; } + bool needsReconfigure(const FileTime &referenceTime) const; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_globalId, m_location, m_condition, m_configureScript, + m_properties, m_initialProperties, m_importedFilesUsed); + } + +private: + Probe() = default; + Probe(QString globalId, + const CodeLocation &location, + bool condition, + QString configureScript, + QVariantMap properties, + QVariantMap initialProperties, + std::vector importedFilesUsed) + : m_globalId(std::move(globalId)) + , m_location(location) + , m_configureScript(std::move(configureScript)) + , m_properties(std::move(properties)) + , m_initialProperties(std::move(initialProperties)) + , m_importedFilesUsed(std::move(importedFilesUsed)) + , m_condition(condition) + {} + + QString m_globalId; + CodeLocation m_location; + QString m_configureScript; + QVariantMap m_properties; + QVariantMap m_initialProperties; + std::vector m_importedFilesUsed; + bool m_condition = false; +}; + +class RuleArtifact +{ +public: + static RuleArtifactPtr create() { return RuleArtifactPtr(new RuleArtifact); } + + QString filePath; + FileTags fileTags; + bool alwaysUpdated; + CodeLocation location; + CodeLocation filePathLocation; + + class Binding + { + public: + QStringList name; + QString code; + CodeLocation location; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(name, code, location); + } + + bool operator<(const Binding &other) const + { + if (name == other.name) { + if (code == other.code) + return location < other.location; + return code < other.code; + } + return name < other.name; + } + }; + + std::vector bindings; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(filePath, fileTags, alwaysUpdated, location, filePathLocation, + bindings); + } + +private: + RuleArtifact() + : alwaysUpdated(true) + {} +}; +QHashValueType qHash(const RuleArtifact::Binding &b); +bool operator==(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2); +inline bool operator!=(const RuleArtifact::Binding &b1, const RuleArtifact::Binding &b2) { + return !(b1 == b2); +} +bool operator==(const RuleArtifact &a1, const RuleArtifact &a2); +inline bool operator!=(const RuleArtifact &a1, const RuleArtifact &a2) { return !(a1 == a2); } + +class SourceArtifactInternal +{ +public: + static SourceArtifactPtr create() { return SourceArtifactPtr(new SourceArtifactInternal); } + + bool isTargetOfModule() const { return !targetOfModule.isEmpty(); } + + QString absoluteFilePath; + FileTags fileTags; + bool overrideFileTags; + QString targetOfModule; + PropertyMapPtr properties; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(absoluteFilePath, fileTags, overrideFileTags, properties, + targetOfModule); + } + +private: + SourceArtifactInternal() : overrideFileTags(true) {} +}; +bool operator==(const SourceArtifactInternal &sa1, const SourceArtifactInternal &sa2); +inline bool operator!=(const SourceArtifactInternal &sa1, const SourceArtifactInternal &sa2) { + return !(sa1 == sa2); +} + +class SourceWildCards +{ +public: + Set expandPatterns(const GroupConstPtr &group, const QString &baseDir, + const QString &buildDir); + + const ResolvedGroup *group = nullptr; // The owning group. + QStringList patterns; + QStringList excludePatterns; + std::vector> dirTimeStamps; + std::vector files; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(patterns, excludePatterns, dirTimeStamps, files); + } + +private: + Set expandPatterns(const GroupConstPtr &group, const QStringList &patterns, + const QString &baseDir, const QString &buildDir); + void expandPatterns(Set &result, const GroupConstPtr &group, + const QStringList &parts, const QString &baseDir, + const QString &buildDir); +}; + +class QBS_AUTOTEST_EXPORT ResolvedGroup +{ +public: + static GroupPtr create() { return GroupPtr(new ResolvedGroup); } + + CodeLocation location; + + QString name; + bool enabled = true; + QString prefix; + std::vector files; + std::unique_ptr wildcards; + PropertyMapPtr properties; + FileTags fileTags; + QString targetOfModule; + bool overrideTags = false; + + std::vector allFiles() const; + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(name, enabled, location, prefix, files, wildcards, properties, + fileTags, targetOfModule, overrideTags); + } +}; + +class ScriptFunction +{ +public: + static ScriptFunctionPtr create() { return ScriptFunctionPtr(new ScriptFunction); } + + ~ScriptFunction(); + + QString sourceCode; + CodeLocation location; + ResolvedFileContextConstPtr fileContext; + + bool isValid() const; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(sourceCode, location, fileContext); + } + +private: + ScriptFunction(); +}; + +bool operator==(const ScriptFunction &a, const ScriptFunction &b); +inline bool operator!=(const ScriptFunction &a, const ScriptFunction &b) { return !(a == b); } + +bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b); + +class PrivateScriptFunction +{ + friend bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b); +public: + void initialize(const ScriptFunctionPtr &sharedData) { m_sharedData = sharedData; } + mutable QScriptValue scriptFunction; // not stored + + QString &sourceCode() const { return m_sharedData->sourceCode; } + CodeLocation &location() const { return m_sharedData->location; } + ResolvedFileContextConstPtr &fileContext() const { return m_sharedData->fileContext; } + bool isValid() const { return m_sharedData->isValid(); } + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_sharedData); + } + +private: + ScriptFunctionPtr m_sharedData; +}; + +bool operator==(const PrivateScriptFunction &a, const PrivateScriptFunction &b); +inline bool operator!=(const PrivateScriptFunction &a, const PrivateScriptFunction &b) +{ + return !(a == b); +} + +class ResolvedModule +{ +public: + static ResolvedModulePtr create() { return ResolvedModulePtr(new ResolvedModule); } + + QString name; + QStringList moduleDependencies; + PrivateScriptFunction setupBuildEnvironmentScript; + PrivateScriptFunction setupRunEnvironmentScript; + ResolvedProduct *product = nullptr; + bool isProduct = false; + + static QStringList argumentNamesForSetupBuildEnv(); + static QStringList argumentNamesForSetupRunEnv(); + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(name, moduleDependencies, setupBuildEnvironmentScript, + setupRunEnvironmentScript, isProduct); + } + +private: + ResolvedModule() = default; +}; +bool operator==(const ResolvedModule &m1, const ResolvedModule &m2); +inline bool operator!=(const ResolvedModule &m1, const ResolvedModule &m2) { return !(m1 == m2); } + +/** + * Per default each rule is a "non-multiplex rule". + * + * A "multiplex rule" creates one transformer that takes all + * input artifacts with the matching input file tag and creates + * one or more artifacts. (e.g. linker rule) + * + * A "non-multiplex rule" creates one transformer per matching input file. + */ +class Rule +{ +public: + static RulePtr create() { return RulePtr(new Rule); } + RulePtr clone() const; + + ResolvedProduct *product = nullptr; // The owning product. + ResolvedModuleConstPtr module; + QString name; + PrivateScriptFunction prepareScript; + FileTags outputFileTags; // unused, if artifacts is non-empty + PrivateScriptFunction outputArtifactsScript; // unused, if artifacts is non-empty + FileTags inputs; + FileTags auxiliaryInputs; + FileTags excludedInputs; + FileTags inputsFromDependencies; + FileTags explicitlyDependsOn; + FileTags explicitlyDependsOnFromDependencies; + bool multiplex = false; + bool requiresInputs = false; + std::vector artifacts; // unused, if outputFileTags/outputArtifactsScript is non-empty + bool alwaysRun = false; + + // members that we don't need to save + int ruleGraphId = -1; + + static QStringList argumentNamesForOutputArtifacts(); + static QStringList argumentNamesForPrepare(); + + QString toString() const; + FileTags staticOutputFileTags() const; + FileTags collectedOutputFileTags() const; + bool isDynamic() const; + bool declaresInputs() const; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(name, prepareScript, outputArtifactsScript, module, inputs, + outputFileTags, auxiliaryInputs, excludedInputs, + inputsFromDependencies, explicitlyDependsOn, + explicitlyDependsOnFromDependencies, multiplex, + requiresInputs, alwaysRun, artifacts); + } +private: + Rule() = default; +}; +bool operator==(const Rule &r1, const Rule &r2); +inline bool operator!=(const Rule &r1, const Rule &r2) { return !(r1 == r2); } +bool ruleListsAreEqual(const std::vector &l1, const std::vector &l2); + +class ResolvedScanner +{ +public: + static ResolvedScannerPtr create() { return ResolvedScannerPtr(new ResolvedScanner); } + + ResolvedModuleConstPtr module; + FileTags inputs; + bool recursive; + PrivateScriptFunction searchPathsScript; + PrivateScriptFunction scanScript; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(module, inputs, recursive, searchPathsScript, scanScript); + } + +private: + ResolvedScanner() : + recursive(false) + {} +}; + +class ExportedProperty +{ +public: + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(fullName, type, sourceCode, isBuiltin); + } + + QString fullName; + PropertyDeclaration::Type type = PropertyDeclaration::Type::UnknownType; + QString sourceCode; + bool isBuiltin = false; +}; + +bool operator==(const ExportedProperty &p1, const ExportedProperty &p2); +inline bool operator!=(const ExportedProperty &p1, const ExportedProperty &p2) +{ + return !(p1 == p2); +} + +class ExportedItem +{ +public: + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(name, properties, children); + } + + static ExportedItemPtr create() { return std::make_shared(); } + + QString name; + std::vector properties; + std::vector children; +}; + +bool equals(const std::vector &l1, const std::vector &l2); +bool operator==(const ExportedItem &i1, const ExportedItem &i2); +inline bool operator!=(const ExportedItem &i1, const ExportedItem &i2) { return !(i1 == i2); } + +class ExportedModuleDependency +{ +public: + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(name, moduleProperties); + }; + + QString name; + QVariantMap moduleProperties; +}; + +bool operator==(const ExportedModuleDependency &d1, const ExportedModuleDependency &d2); +inline bool operator!=(const ExportedModuleDependency &d1, const ExportedModuleDependency &d2) +{ + return !(d1 == d2); +} + +class ExportedModule +{ +public: + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(propertyValues, modulePropertyValues, children, + productDependencies, moduleDependencies, m_properties, + dependencyParameters, importStatements); + }; + + QVariantMap propertyValues; + QVariantMap modulePropertyValues; + std::vector children; + std::vector productDependencies; + std::vector moduleDependencies; + std::vector m_properties; + QMap dependencyParameters; + QStringList importStatements; +}; + +bool operator==(const ExportedModule &m1, const ExportedModule &m2); +inline bool operator!=(const ExportedModule &m1, const ExportedModule &m2) { return !(m1 == m2); } + +class TopLevelProject; +class ScriptEngine; + +class QBS_AUTOTEST_EXPORT ResolvedProduct +{ +public: + static ResolvedProductPtr create() { return ResolvedProductPtr(new ResolvedProduct); } + + ~ResolvedProduct(); + + bool enabled; + FileTags fileTags; + QString name; + QString targetName; + QString multiplexConfigurationId; + QString sourceDirectory; + QString destinationDirectory; + CodeLocation location; + WeakPointer project; + QVariantMap productProperties; + PropertyMapPtr moduleProperties; + std::vector rules; + std::vector dependencies; + QHash dependencyParameters; + std::vector fileTaggers; + JobLimits jobLimits; + std::vector modules; + QHash moduleParameters; + std::vector scanners; + std::vector groups; + std::vector probes; + std::vector artifactProperties; + QStringList missingSourceFiles; + std::unique_ptr buildData; + + ExportedModule exportedModule; + + QProcessEnvironment buildEnvironment; // must not be saved + QProcessEnvironment runEnvironment; // must not be saved + + void accept(BuildGraphVisitor *visitor) const; + std::vector allFiles() const; + std::vector allEnabledFiles() const; + FileTags fileTagsForFileName(const QString &fileName) const; + + ArtifactSet lookupArtifactsByFileTag(const FileTag &tag) const; + ArtifactSet lookupArtifactsByFileTags(const FileTags &tags) const; + ArtifactSet targetArtifacts() const; + + TopLevelProject *topLevelProject() const; + + static QString uniqueName(const QString &name, + const QString &multiplexConfigurationId); + QString uniqueName() const; + static QString fullDisplayName(const QString &name, const QString &multiplexConfigurationId); + QString fullDisplayName() const; + QString profile() const; + + QStringList generatedFiles(const QString &baseFile, bool recursive, const FileTags &tags) const; + + static QString deriveBuildDirectoryName(const QString &name, + const QString &multiplexConfigurationId); + QString buildDirectory() const; + + bool isInParentProject(const ResolvedProductConstPtr &other) const; + bool builtByDefault() const; + + void cacheExecutablePath(const QString &origFilePath, const QString &fullFilePath); + QString cachedExecutablePath(const QString &origFilePath) const; + + void load(PersistentPool &pool); + void store(PersistentPool &pool); + +private: + ResolvedProduct(); + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(enabled, fileTags, name, multiplexConfigurationId, + targetName, sourceDirectory, destinationDirectory, + missingSourceFiles, location, productProperties, + moduleProperties, rules, dependencies, dependencyParameters, + fileTaggers, modules, moduleParameters, scanners, groups, + artifactProperties, probes, exportedModule, buildData, + jobLimits); + } + + QHash m_executablePathCache; + mutable std::mutex m_executablePathCacheLock; +}; + +class QBS_AUTOTEST_EXPORT ResolvedProject +{ +public: + virtual ~ResolvedProject(); + static ResolvedProjectPtr create() { return ResolvedProjectPtr(new ResolvedProject); } + + QString name; + CodeLocation location; + bool enabled; + std::vector products; + std::vector subProjects; + WeakPointer parentProject; + + void accept(BuildGraphVisitor *visitor) const; + + void setProjectProperties(const QVariantMap &config) { m_projectProperties = config; } + const QVariantMap &projectProperties() const { return m_projectProperties; } + + TopLevelProject *topLevelProject(); + std::vector allSubProjects() const; + std::vector allProducts() const; + + virtual void load(PersistentPool &pool); + virtual void store(PersistentPool &pool); + +protected: + ResolvedProject(); + +private: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(name, location, enabled, products, subProjects, + m_projectProperties); + } + + QVariantMap m_projectProperties; + TopLevelProject *m_topLevelProject; +}; + +class QBS_AUTOTEST_EXPORT TopLevelProject : public ResolvedProject +{ + friend class BuildGraphLoader; +public: + ~TopLevelProject() override; + + static TopLevelProjectPtr create() { return TopLevelProjectPtr(new TopLevelProject); } + + static QString deriveId(const QVariantMap &config); + static QString deriveBuildDirectory(const QString &buildRoot, const QString &id); + + QString buildDirectory; // Not saved + QProcessEnvironment environment; + std::vector probes; + StoredModuleProviderInfo moduleProviderInfo; + + QHash canonicalFilePathResults; // Results of calls to "File.canonicalFilePath()." + QHash fileExistsResults; // Results of calls to "File.exists()". + QHash, QStringList> directoryEntriesResults; // Results of calls to "File.directoryEntries()". + QHash fileLastModifiedResults; // Results of calls to "File.lastModified()". + std::unique_ptr buildData; + BuildGraphLocker *bgLocker; // This holds the system-wide build graph file lock. + bool locked; // This is the API-level lock for the project instance. + + Set buildSystemFiles; + FileTime lastStartResolveTime; + FileTime lastEndResolveTime; + QList warningsEncountered; + + void setBuildConfiguration(const QVariantMap &config); + const QVariantMap &buildConfiguration() const { return m_buildConfiguration; } + QString id() const { return m_id; } + QString profile() const; + void makeModuleProvidersNonTransient(); + + QVariantMap profileConfigs; + QVariantMap overriddenValues; + + QString buildGraphFilePath() const; + void store(Logger logger); + +private: + TopLevelProject(); + + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(m_id, canonicalFilePathResults, fileExistsResults, + directoryEntriesResults, fileLastModifiedResults, environment, + probes, profileConfigs, overriddenValues, buildSystemFiles, + lastStartResolveTime, lastEndResolveTime, warningsEncountered, + buildData, moduleProviderInfo); + } + void load(PersistentPool &pool) override; + void store(PersistentPool &pool) override; + + void cleanupModuleProviderOutput(); + + QString m_id; + QVariantMap m_buildConfiguration; +}; + +bool artifactPropertyListsAreEqual(const std::vector &l1, + const std::vector &l2); + +QString multiplexIdToString(const QString &id); + +} // namespace Internal +} // namespace qbs + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(qbs::Internal::JsImport, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(qbs::Internal::RuleArtifact::Binding, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +#endif // QBS_LANGUAGE_H diff --git a/src/lib/corelib/language/language.pri b/src/lib/corelib/language/language.pri new file mode 100644 index 00000000..0b4cfbd0 --- /dev/null +++ b/src/lib/corelib/language/language.pri @@ -0,0 +1,86 @@ +include(../../../install_prefix.pri) + +HEADERS += \ + $$PWD/artifactproperties.h \ + $$PWD/astimportshandler.h \ + $$PWD/astpropertiesitemhandler.h \ + $$PWD/asttools.h \ + $$PWD/builtindeclarations.h \ + $$PWD/deprecationinfo.h \ + $$PWD/evaluationdata.h \ + $$PWD/evaluator.h \ + $$PWD/evaluatorscriptclass.h \ + $$PWD/filecontext.h \ + $$PWD/filecontextbase.h \ + $$PWD/filetags.h \ + $$PWD/forward_decls.h \ + $$PWD/identifiersearch.h \ + $$PWD/item.h \ + $$PWD/itemdeclaration.h \ + $$PWD/itemobserver.h \ + $$PWD/itempool.h \ + $$PWD/itemreader.h \ + $$PWD/itemreaderastvisitor.h \ + $$PWD/itemreadervisitorstate.h \ + $$PWD/itemtype.h \ + $$PWD/jsimports.h \ + $$PWD/language.h \ + $$PWD/loader.h \ + $$PWD/moduleloader.h \ + $$PWD/modulemerger.h \ + $$PWD/moduleproviderinfo.h \ + $$PWD/moduleproviderloader.h \ + $$PWD/preparescriptobserver.h \ + $$PWD/probesresolver.h \ + $$PWD/projectresolver.h \ + $$PWD/property.h \ + $$PWD/propertydeclaration.h \ + $$PWD/propertymapinternal.h \ + $$PWD/qualifiedid.h \ + $$PWD/resolvedfilecontext.h \ + $$PWD/scriptengine.h \ + $$PWD/scriptimporter.h \ + $$PWD/scriptpropertyobserver.h \ + $$PWD/value.h + +SOURCES += \ + $$PWD/artifactproperties.cpp \ + $$PWD/astimportshandler.cpp \ + $$PWD/astpropertiesitemhandler.cpp \ + $$PWD/asttools.cpp \ + $$PWD/builtindeclarations.cpp \ + $$PWD/evaluator.cpp \ + $$PWD/evaluatorscriptclass.cpp \ + $$PWD/filecontext.cpp \ + $$PWD/filecontextbase.cpp \ + $$PWD/filetags.cpp \ + $$PWD/identifiersearch.cpp \ + $$PWD/item.cpp \ + $$PWD/itemdeclaration.cpp \ + $$PWD/itempool.cpp \ + $$PWD/itemreader.cpp \ + $$PWD/itemreaderastvisitor.cpp \ + $$PWD/itemreadervisitorstate.cpp \ + $$PWD/language.cpp \ + $$PWD/loader.cpp \ + $$PWD/moduleloader.cpp \ + $$PWD/modulemerger.cpp \ + $$PWD/moduleproviderloader.cpp \ + $$PWD/preparescriptobserver.cpp \ + $$PWD/scriptpropertyobserver.cpp \ + $$PWD/probesresolver.cpp \ + $$PWD/projectresolver.cpp \ + $$PWD/property.cpp \ + $$PWD/propertydeclaration.cpp \ + $$PWD/propertymapinternal.cpp \ + $$PWD/qualifiedid.cpp \ + $$PWD/resolvedfilecontext.cpp \ + $$PWD/scriptengine.cpp \ + $$PWD/scriptimporter.cpp \ + $$PWD/value.cpp + +!qbs_no_dev_install { + language_headers.files = $$PWD/forward_decls.h + language_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/language + INSTALLS += language_headers +} diff --git a/src/lib/corelib/language/loader.cpp b/src/lib/corelib/language/loader.cpp new file mode 100644 index 00000000..1de84da6 --- /dev/null +++ b/src/lib/corelib/language/loader.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "loader.h" + +#include "evaluator.h" +#include "language.h" +#include "moduleloader.h" +#include "projectresolver.h" +#include "scriptengine.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +Loader::Loader(ScriptEngine *engine, Logger logger) + : m_logger(std::move(logger)) + , m_progressObserver(nullptr) + , m_engine(engine) +{ + m_logger.storeWarnings(); +} + +void Loader::setProgressObserver(ProgressObserver *observer) +{ + m_progressObserver = observer; +} + +void Loader::setSearchPaths(const QStringList &_searchPaths) +{ + QStringList searchPaths; + for (const QString &searchPath : _searchPaths) { + if (!FileInfo::exists(searchPath)) { + m_logger.qbsWarning() << Tr::tr("Search path '%1' does not exist.") + .arg(QDir::toNativeSeparators(searchPath)); + } else { + searchPaths += searchPath; + } + } + + m_searchPaths = searchPaths; +} + +void Loader::setOldProjectProbes(const std::vector &oldProbes) +{ + m_oldProjectProbes = oldProbes; +} + +void Loader::setOldProductProbes(const QHash> &oldProbes) +{ + m_oldProductProbes = oldProbes; +} + +void Loader::setStoredProfiles(const QVariantMap &profiles) +{ + m_storedProfiles = profiles; +} + +void Loader::setStoredModuleProviderInfo(const StoredModuleProviderInfo &providerInfo) +{ + m_storedModuleProviderInfo = providerInfo; +} + +TopLevelProjectPtr Loader::loadProject(const SetupProjectParameters &_parameters) +{ + SetupProjectParameters parameters = _parameters; + + if (parameters.topLevelProfile().isEmpty()) { + Settings settings(parameters.settingsDirectory()); + QString profileName = settings.defaultProfile(); + if (profileName.isEmpty()) { + m_logger.qbsDebug() << Tr::tr("No profile specified and no default profile exists. " + "Using default property values."); + profileName = Profile::fallbackName(); + } + parameters.setTopLevelProfile(profileName); + parameters.expandBuildConfiguration(); + } + + setupProjectFilePath(parameters); + QBS_CHECK(QFileInfo(parameters.projectFilePath()).isAbsolute()); + m_logger.qbsDebug() << "Using project file '" + << QDir::toNativeSeparators(parameters.projectFilePath()) << "'."; + + m_engine->setEnvironment(parameters.adjustedEnvironment()); + m_engine->clearExceptions(); + m_engine->clearImportsCache(); + m_engine->clearRequestedProperties(); + m_engine->enableProfiling(parameters.logElapsedTime()); + m_logger.clearWarnings(); + EvalContextSwitcher evalContextSwitcher(m_engine, EvalContext::PropertyEvaluation); + + QTimer cancelationTimer; + + // At this point, we cannot set a sensible total effort, because we know nothing about + // the project yet. That's why we use a placeholder here, so the user at least + // sees that an operation is starting. The real total effort will be set later when + // we have enough information. + if (m_progressObserver) { + m_progressObserver->initialize(Tr::tr("Resolving project for configuration %1") + .arg(TopLevelProject::deriveId(parameters.finalBuildConfigurationTree())), 1); + cancelationTimer.setSingleShot(false); + QObject::connect(&cancelationTimer, &QTimer::timeout, [this]() { + QBS_ASSERT(m_progressObserver, return); + if (m_progressObserver->canceled()) + m_engine->cancel(); + }); + cancelationTimer.start(1000); + } + + const FileTime resolveTime = FileTime::currentTime(); + Evaluator evaluator(m_engine); + ModuleLoader moduleLoader(&evaluator, m_logger); + moduleLoader.setProgressObserver(m_progressObserver); + moduleLoader.setSearchPaths(m_searchPaths); + moduleLoader.setOldProjectProbes(m_oldProjectProbes); + moduleLoader.setOldProductProbes(m_oldProductProbes); + moduleLoader.setLastResolveTime(m_lastResolveTime); + moduleLoader.setStoredProfiles(m_storedProfiles); + moduleLoader.setStoredModuleProviderInfo(m_storedModuleProviderInfo); + const ModuleLoaderResult loadResult = moduleLoader.load(parameters); + ProjectResolver resolver(&evaluator, loadResult, std::move(parameters), m_logger); + resolver.setProgressObserver(m_progressObserver); + const TopLevelProjectPtr project = resolver.resolve(); + project->lastStartResolveTime = resolveTime; + project->lastEndResolveTime = FileTime::currentTime(); + + // E.g. if the top-level project is disabled. + if (m_progressObserver) + m_progressObserver->setFinished(); + + return project; +} + +void Loader::setupProjectFilePath(SetupProjectParameters ¶meters) +{ + QString projectFilePath = parameters.projectFilePath(); + if (projectFilePath.isEmpty()) + projectFilePath = QDir::currentPath(); + const QFileInfo projectFileInfo(projectFilePath); + if (!projectFileInfo.exists()) + throw ErrorInfo(Tr::tr("Project file '%1' cannot be found.").arg(projectFilePath)); + if (projectFileInfo.isRelative()) + projectFilePath = projectFileInfo.absoluteFilePath(); + if (projectFileInfo.isFile()) { + parameters.setProjectFilePath(projectFilePath); + return; + } + if (!projectFileInfo.isDir()) + throw ErrorInfo(Tr::tr("Project file '%1' has invalid type.").arg(projectFilePath)); + + const QStringList &actualFileNames + = QDir(projectFilePath).entryList(StringConstants::qbsFileWildcards(), QDir::Files); + if (actualFileNames.empty()) { + QString error; + if (parameters.projectFilePath().isEmpty()) + error = Tr::tr("No project file given and none found in current directory.\n"); + else + error = Tr::tr("No project file found in directory '%1'.").arg(projectFilePath); + throw ErrorInfo(error); + } + if (actualFileNames.size() > 1) { + throw ErrorInfo(Tr::tr("More than one project file found in directory '%1'.") + .arg(projectFilePath)); + } + projectFilePath.append(QLatin1Char('/')).append(actualFileNames.front()); + + projectFilePath = QDir::current().filePath(projectFilePath); + projectFilePath = QDir::cleanPath(projectFilePath); + parameters.setProjectFilePath(projectFilePath); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/loader.h b/src/lib/corelib/language/loader.h new file mode 100644 index 00000000..2c8b0844 --- /dev/null +++ b/src/lib/corelib/language/loader.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_LOADER_H +#define QBS_LOADER_H + +#include "forward_decls.h" +#include "moduleproviderinfo.h" +#include +#include + +#include + +namespace qbs { +class Settings; +class SetupProjectParameters; +namespace Internal { +class Logger; +class ProgressObserver; +class ScriptEngine; + +class QBS_AUTOTEST_EXPORT Loader +{ +public: + Loader(ScriptEngine *engine, Logger logger); + + void setProgressObserver(ProgressObserver *observer); + void setSearchPaths(const QStringList &searchPaths); + void setOldProjectProbes(const std::vector &oldProbes); + void setOldProductProbes(const QHash> &oldProbes); + void setLastResolveTime(const FileTime &time) { m_lastResolveTime = time; } + void setStoredProfiles(const QVariantMap &profiles); + void setStoredModuleProviderInfo(const StoredModuleProviderInfo &providerInfo); + TopLevelProjectPtr loadProject(const SetupProjectParameters ¶meters); + + static void setupProjectFilePath(SetupProjectParameters ¶meters); + +private: + Logger m_logger; + ProgressObserver *m_progressObserver; + ScriptEngine * const m_engine; + QStringList m_searchPaths; + std::vector m_oldProjectProbes; + QHash> m_oldProductProbes; + StoredModuleProviderInfo m_storedModuleProviderInfo; + QVariantMap m_storedProfiles; + FileTime m_lastResolveTime; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_LOADER_H diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp new file mode 100644 index 00000000..574c03bf --- /dev/null +++ b/src/lib/corelib/language/moduleloader.cpp @@ -0,0 +1,3840 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "moduleloader.h" + +#include "builtindeclarations.h" +#include "evaluator.h" +#include "filecontext.h" +#include "item.h" +#include "itemreader.h" +#include "language.h" +#include "modulemerger.h" +#include "moduleproviderloader.h" +#include "probesresolver.h" +#include "qualifiedid.h" +#include "scriptengine.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +using MultiplexConfigurationByIdTable = QThreadStorage >; +Q_GLOBAL_STATIC(MultiplexConfigurationByIdTable, multiplexConfigurationsById); + +static bool multiplexConfigurationIntersects(const QVariantMap &lhs, const QVariantMap &rhs) +{ + QBS_CHECK(!lhs.isEmpty() && !rhs.isEmpty()); + + for (auto lhsProperty = lhs.constBegin(); lhsProperty != lhs.constEnd(); lhsProperty++) { + const auto rhsProperty = rhs.find(lhsProperty.key()); + const bool isCommonProperty = rhsProperty != rhs.constEnd(); + if (isCommonProperty && lhsProperty.value() != rhsProperty.value()) + return false; + } + + return true; +} + +class ModuleLoader::ItemModuleList : public QList {}; + +class ModuleLoader::ProductSortByDependencies +{ +public: + ProductSortByDependencies(TopLevelProjectContext &tlp) : m_tlp(tlp) + { + } + + void apply() + { + QHash> productsMap; + QList allProducts; + for (ProjectContext * const projectContext : qAsConst(m_tlp.projects)) { + for (auto &product : projectContext->products) { + allProducts.push_back(&product); + productsMap[product.name].push_back(&product); + } + } + Set allDependencies; + for (auto productContext : qAsConst(allProducts)) { + auto &productDependencies = m_dependencyMap[productContext]; + for (const auto &dep : qAsConst(productContext->info.usedProducts)) { + QBS_CHECK(!dep.name.isEmpty()); + const auto &deps = productsMap.value(dep.name); + if (dep.profile == StringConstants::star()) { + QBS_CHECK(!deps.empty()); + for (ProductContext *depProduct : deps) { + if (depProduct == productContext) + continue; + productDependencies.push_back(depProduct); + allDependencies << depProduct; + } + } else { + auto it = std::find_if(deps.begin(), deps.end(), [&dep] (ProductContext *p) { + return p->multiplexConfigurationId == dep.multiplexConfigurationId; + }); + if (it == deps.end()) { + QBS_CHECK(!productContext->multiplexConfigurationId.isEmpty()); + const QString productName = ResolvedProduct::fullDisplayName( + productContext->name, productContext->multiplexConfigurationId); + const QString depName = ResolvedProduct::fullDisplayName( + dep.name, dep.multiplexConfigurationId); + throw ErrorInfo(Tr::tr("Dependency from product '%1' to product '%2' not " + "fulfilled.").arg(productName, depName), + productContext->item->location()); + } + productDependencies.push_back(*it); + allDependencies << *it; + } + } + } + const Set rootProducts + = rangeTo>(allProducts) - allDependencies; + for (ProductContext * const rootProduct : rootProducts) + traverse(rootProduct); + if (m_sortedProducts.size() < allProducts.size()) { + for (auto const product : qAsConst(allProducts)) { + QList path; + findCycle(product, path); + } + } + QBS_CHECK(m_sortedProducts.size() == allProducts.size()); + } + + // No product at position i has dependencies to a product at position j > i. + const QList &sortedProducts() const + { + return m_sortedProducts; + } + +private: + void traverse(ModuleLoader::ProductContext *product) + { + if (!m_seenProducts.insert(product).second) + return; + for (const auto &dependency : m_dependencyMap.value(product)) + traverse(dependency); + m_sortedProducts << product; + } + + void findCycle(ModuleLoader::ProductContext *product, + QList &path) + { + if (path.contains(product)) { + ErrorInfo error(Tr::tr("Cyclic dependencies detected.")); + for (const auto * const p : path) + error.append(p->name, p->item->location()); + error.append(product->name, product->item->location()); + throw error; + } + path << product; + for (auto const dep : m_dependencyMap.value(product)) + findCycle(dep, path); + path.removeLast(); + } + + TopLevelProjectContext &m_tlp; + QHash> m_dependencyMap; + Set m_seenProducts; + QList m_sortedProducts; +}; + +class SearchPathsManager { +public: + explicit SearchPathsManager(ItemReader *itemReader) + : m_itemReader(itemReader) + , m_oldSize(itemReader->extraSearchPathsStack().size()) + { + } + SearchPathsManager(ItemReader *itemReader, const QStringList &extraSearchPaths) + : SearchPathsManager(itemReader) + { + m_itemReader->pushExtraSearchPaths(extraSearchPaths); + } + ~SearchPathsManager() + { + reset(); + } + void reset() + { + while (m_itemReader->extraSearchPathsStack().size() > m_oldSize) + m_itemReader->popExtraSearchPaths(); + } + +private: + ItemReader * const m_itemReader; + size_t m_oldSize{0}; +}; + +ModuleLoader::ModuleLoader(Evaluator *evaluator, Logger &logger) + : m_pool(nullptr) + , m_logger(logger) + , m_progressObserver(nullptr) + , m_reader(std::make_unique(logger)) + , m_evaluator(evaluator) + , m_probesResolver(std::make_unique(m_evaluator, m_logger)) + , m_moduleProviderLoader( + std::make_unique(m_reader.get(), m_evaluator, m_probesResolver.get(), + m_logger)) +{ +} + +ModuleLoader::~ModuleLoader() = default; + +void ModuleLoader::setProgressObserver(ProgressObserver *progressObserver) +{ + m_progressObserver = progressObserver; +} + +void ModuleLoader::setSearchPaths(const QStringList &searchPaths) +{ + m_reader->setSearchPaths(searchPaths); + qCDebug(lcModuleLoader) << "initial search paths:" << searchPaths; +} + +void ModuleLoader::setOldProjectProbes(const std::vector &oldProbes) +{ + m_probesResolver->setOldProjectProbes(oldProbes); +} + +void ModuleLoader::setOldProductProbes(const QHash> &oldProbes) +{ + m_probesResolver->setOldProductProbes(oldProbes); +} + +void ModuleLoader::setStoredProfiles(const QVariantMap &profiles) +{ + m_storedProfiles = profiles; +} + +void ModuleLoader::setStoredModuleProviderInfo(const StoredModuleProviderInfo &moduleProviderInfo) +{ + m_moduleProviderLoader->setStoredModuleProviderInfo(moduleProviderInfo); +} + +ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters ¶meters) +{ + TimedActivityLogger moduleLoaderTimer(m_logger, Tr::tr("ModuleLoader"), + parameters.logElapsedTime()); + qCDebug(lcModuleLoader) << "load" << parameters.projectFilePath(); + m_parameters = parameters; + m_modulePrototypes.clear(); + m_modulePrototypeEnabledInfo.clear(); + m_parameterDeclarations.clear(); + m_disabledItems.clear(); + m_reader->clearExtraSearchPathsStack(); + m_reader->setEnableTiming(parameters.logElapsedTime()); + m_moduleProviderLoader->setProjectParameters(m_parameters); + m_probesResolver->setProjectParameters(m_parameters); + m_elapsedTimePrepareProducts = m_elapsedTimeHandleProducts + = m_elapsedTimeProductDependencies = m_elapsedTimeTransitiveDependencies + = m_elapsedTimePropertyChecking = 0; + m_elapsedTimeModuleProviders = 0; + m_settings = std::make_unique(parameters.settingsDirectory()); + + const auto keys = m_parameters.overriddenValues().keys(); + for (const QString &key : keys) { + static const QStringList prefixes({ StringConstants::projectPrefix(), + QStringLiteral("projects"), + QStringLiteral("products"), QStringLiteral("modules"), + StringConstants::moduleProviders(), + StringConstants::qbsModule()}); + bool ok = false; + for (const auto &prefix : prefixes) { + if (key.startsWith(prefix + QLatin1Char('.'))) { + ok = true; + break; + } + } + if (ok) { + collectNameFromOverride(key); + continue; + } + ErrorInfo e(Tr::tr("Property override key '%1' not understood.").arg(key)); + e.append(Tr::tr("Please use one of the following:")); + e.append(QLatin1Char('\t') + Tr::tr("projects..:value")); + e.append(QLatin1Char('\t') + Tr::tr("products..:value")); + e.append(QLatin1Char('\t') + Tr::tr("modules..:value")); + e.append(QLatin1Char('\t') + Tr::tr("products..." + ":value")); + e.append(QLatin1Char('\t') + Tr::tr("moduleProviders.." + ":value")); + handlePropertyError(e, m_parameters, m_logger); + } + + ModuleLoaderResult result; + result.profileConfigs = m_storedProfiles; + m_pool = result.itemPool.get(); + m_reader->setPool(m_pool); + + const QStringList topLevelSearchPaths = parameters.finalBuildConfigurationTree() + .value(StringConstants::projectPrefix()).toMap() + .value(StringConstants::qbsSearchPathsProperty()).toStringList(); + Item *root; + { + SearchPathsManager searchPathsManager(m_reader.get(), topLevelSearchPaths); + root = loadItemFromFile(parameters.projectFilePath(), CodeLocation()); + if (!root) + return ModuleLoaderResult(); + } + + switch (root->type()) { + case ItemType::Product: + root = wrapInProjectIfNecessary(root); + break; + case ItemType::Project: + break; + default: + throw ErrorInfo(Tr::tr("The top-level item must be of type 'Project' or 'Product', but it" + " is of type '%1'.").arg(root->typeName()), root->location()); + } + + const QString buildDirectory = TopLevelProject::deriveBuildDirectory(parameters.buildRoot(), + TopLevelProject::deriveId(parameters.finalBuildConfigurationTree())); + root->setProperty(StringConstants::sourceDirectoryProperty(), + VariantValue::create(QFileInfo(root->file()->filePath()).absolutePath())); + root->setProperty(StringConstants::buildDirectoryProperty(), + VariantValue::create(buildDirectory)); + root->setProperty(StringConstants::profileProperty(), + VariantValue::create(m_parameters.topLevelProfile())); + handleTopLevelProject(&result, root, buildDirectory, + Set() << QDir::cleanPath(parameters.projectFilePath())); + result.root = root; + result.qbsFiles = m_reader->filesRead() - m_moduleProviderLoader->tempQbsFiles(); + for (auto it = m_localProfiles.cbegin(); it != m_localProfiles.cend(); ++it) + result.profileConfigs.remove(it.key()); + printProfilingInfo(); + return result; +} + +class PropertyDeclarationCheck : public ValueHandler +{ + const Set &m_disabledItems; + Set m_handledItems; + std::vector m_parentItems; + Item *m_currentModuleInstance = nullptr; + QualifiedId m_currentModuleName; + QString m_currentName; + SetupProjectParameters m_params; + Logger &m_logger; +public: + PropertyDeclarationCheck(const Set &disabledItems, + SetupProjectParameters params, Logger &logger) + : m_disabledItems(disabledItems) + , m_params(std::move(params)) + , m_logger(logger) + { + } + + void operator()(Item *item) + { + handleItem(item); + } + +private: + void handle(JSSourceValue *value) override + { + if (!value->createdByPropertiesBlock()) { + const ErrorInfo error(Tr::tr("Property '%1' is not declared.") + .arg(m_currentName), value->location()); + handlePropertyError(error, m_params, m_logger); + } + } + + void handle(ItemValue *value) override + { + if (checkItemValue(value)) + handleItem(value->item()); + } + + bool checkItemValue(ItemValue *value) + { + // TODO: Remove once QBS-1030 is fixed. + if (parentItem()->type() == ItemType::Artifact) + return false; + + if (parentItem()->type() == ItemType::Properties) + return false; + + if (parentItem()->isOfTypeOrhasParentOfType(ItemType::Export)) { + // Export item prototypes do not have instantiated modules. + // The module instances are where the Export is used. + QBS_ASSERT(m_currentModuleInstance, return false); + auto hasCurrentModuleName = [this](const Item::Module &m) { + return m.name == m_currentModuleName; + }; + if (any_of(m_currentModuleInstance->modules(), hasCurrentModuleName)) + return true; + } + + // TODO: We really should have a dedicated item type for "pre-instantiated" item values + // and only use ModuleInstance for actual module instances. + const bool itemIsModuleInstance = value->item()->type() == ItemType::ModuleInstance + && value->item()->hasProperty(StringConstants::presentProperty()); + + if (!itemIsModuleInstance + && value->item()->type() != ItemType::ModulePrefix + && (!parentItem()->file() || !parentItem()->file()->idScope() + || !parentItem()->file()->idScope()->hasProperty(m_currentName)) + && !value->createdByPropertiesBlock()) { + CodeLocation location = value->location(); + for (int i = int(m_parentItems.size() - 1); !location.isValid() && i >= 0; --i) + location = m_parentItems.at(i)->location(); + const ErrorInfo error(Tr::tr("Item '%1' is not declared. " + "Did you forget to add a Depends item?") + .arg(m_currentModuleName.toString()), location); + handlePropertyError(error, m_params, m_logger); + return false; + } + + return true; + } + + void handleItem(Item *item) + { + if (!m_handledItems.insert(item).second) + return; + if (m_disabledItems.contains(item) + || (item->type() == ItemType::ModuleInstance && !item->isPresentModule()) + || item->type() == ItemType::Properties + + // The Properties child of a SubProject item is not a regular item. + || item->type() == ItemType::PropertiesInSubProject) { + return; + } + + // If a module was found but its validate script failed, only the canonical + // module instance will have the "non-present" flag set, so we need to locate it. + if (item->type() == ItemType::ModuleInstance) { + const Item *productItem = nullptr; + for (auto it = m_parentItems.rbegin(); it != m_parentItems.rend(); ++it) { + if ((*it)->type() == ItemType::Product) { + productItem = *it; + break; + } + } + if (productItem) { + for (const Item::Module &m : productItem->modules()) { + if (m.name == m_currentModuleName) { + if (!m.item->isPresentModule()) + return; + break; + } + } + } + } + + m_parentItems.push_back(item); + for (Item::PropertyMap::const_iterator it = item->properties().constBegin(); + it != item->properties().constEnd(); ++it) { + if (item->type() == ItemType::Product && it.key() == StringConstants::moduleProviders() + && it.value()->type() == Value::ItemValueType) + continue; + const PropertyDeclaration decl = item->propertyDeclaration(it.key()); + if (decl.isValid()) { + if (!decl.isDeprecated()) + continue; + const DeprecationInfo &di = decl.deprecationInfo(); + QString message; + bool warningOnly; + if (decl.isExpired()) { + message = Tr::tr("The property '%1' can no longer be used. " + "It was removed in Qbs %2.") + .arg(decl.name(), di.removalVersion().toString()); + warningOnly = false; + } else { + message = Tr::tr("The property '%1' is deprecated and will be removed " + "in Qbs %2.").arg(decl.name(), di.removalVersion().toString()); + warningOnly = true; + } + ErrorInfo error(message, it.value()->location()); + if (!di.additionalUserInfo().isEmpty()) + error.append(di.additionalUserInfo()); + if (warningOnly) + m_logger.printWarning(error); + else + handlePropertyError(error, m_params, m_logger); + continue; + } + m_currentName = it.key(); + const QualifiedId oldModuleName = m_currentModuleName; + if (parentItem()->type() != ItemType::ModulePrefix) + m_currentModuleName.clear(); + m_currentModuleName.push_back(m_currentName); + it.value()->apply(this); + m_currentModuleName = oldModuleName; + } + m_parentItems.pop_back(); + for (Item * const child : item->children()) { + switch (child->type()) { + case ItemType::Export: + case ItemType::Depends: + case ItemType::Parameter: + case ItemType::Parameters: + break; + case ItemType::Group: + if (item->type() == ItemType::Module || item->type() == ItemType::ModuleInstance) + break; + Q_FALLTHROUGH(); + default: + handleItem(child); + } + } + + // Properties that don't refer to an existing module with a matching Depends item + // only exist in the prototype of an Export item, not in the instance. + // Example 1 - setting a property of an unknown module: Export { abc.def: true } + // Example 2 - setting a non-existing Export property: Export { blubb: true } + if (item->type() == ItemType::ModuleInstance && item->prototype()) { + Item *oldInstance = m_currentModuleInstance; + m_currentModuleInstance = item; + handleItem(item->prototype()); + m_currentModuleInstance = oldInstance; + } + } + + void handle(VariantValue *) override { /* only created internally - no need to check */ } + + Item *parentItem() const { return m_parentItems.back(); } +}; + +void ModuleLoader::handleTopLevelProject(ModuleLoaderResult *loadResult, Item *projectItem, + const QString &buildDirectory, const Set &referencedFilePaths) +{ + TopLevelProjectContext tlp; + tlp.buildDirectory = buildDirectory; + handleProject(loadResult, &tlp, projectItem, referencedFilePaths); + checkProjectNamesInOverrides(tlp); + collectProductsByName(tlp); + checkProductNamesInOverrides(); + + adjustDependenciesForMultiplexing(tlp); + + m_dependencyResolvingPass = 1; + for (ProjectContext * const projectContext : qAsConst(tlp.projects)) { + m_reader->setExtraSearchPathsStack(projectContext->searchPathsStack); + for (ProductContext &productContext : projectContext->products) { + try { + setupProductDependencies(&productContext, Set()); + } catch (const ErrorInfo &err) { + if (productContext.name.isEmpty()) + throw err; + handleProductError(err, &productContext); + } + // extraSearchPathsStack is changed during dependency resolution, check + // that we've rolled back all the changes + QBS_CHECK(m_reader->extraSearchPathsStack() == projectContext->searchPathsStack); + } + } + if (!m_productsWithDeferredDependsItems.empty() || !m_exportsWithDeferredDependsItems.empty()) { + collectProductsByType(tlp); + m_dependencyResolvingPass = 2; + + // Doing the normalization for the Export items themselves (as opposed to doing it only + // for the corresponding module instances) serves two purposes: + // (1) It makes recursive use of Depends.productTypes via Export items work; otherwise, + // we'd need an additional dependency resolving pass for every export level. + // (2) The "expanded" Depends items are available to the Exporter.qbs module. + for (Item * const exportItem : m_exportsWithDeferredDependsItems) + normalizeDependencies(nullptr, DeferredDependsContext(nullptr, exportItem)); + + for (const auto &deferredDependsData : m_productsWithDeferredDependsItems) { + ProductContext * const productContext = deferredDependsData.first; + m_reader->setExtraSearchPathsStack(productContext->project->searchPathsStack); + try { + setupProductDependencies(productContext, deferredDependsData.second); + } catch (const ErrorInfo &err) { + handleProductError(err, productContext); + } + } + } + + ProductSortByDependencies productSorter(tlp); + productSorter.apply(); + for (ProductContext * const p : productSorter.sortedProducts()) { + try { + handleProduct(p); + if (p->name.startsWith(StringConstants::shadowProductPrefix())) + tlp.probes << p->info.probes; + } catch (const ErrorInfo &err) { + handleProductError(err, p); + } + } + + loadResult->projectProbes = tlp.probes; + loadResult->storedModuleProviderInfo = m_moduleProviderLoader->storedModuleProviderInfo(); + + m_reader->clearExtraSearchPathsStack(); + AccumulatingTimer timer(m_parameters.logElapsedTime() + ? &m_elapsedTimePropertyChecking : nullptr); + PropertyDeclarationCheck check(m_disabledItems, m_parameters, m_logger); + check(projectItem); +} + +void ModuleLoader::handleProject(ModuleLoaderResult *loadResult, + TopLevelProjectContext *topLevelProjectContext, Item *projectItem, + const Set &referencedFilePaths) +{ + auto p = std::make_unique(); + auto &projectContext = *p; + projectContext.topLevelProject = topLevelProjectContext; + projectContext.result = loadResult; + ItemValuePtr itemValue = ItemValue::create(projectItem); + projectContext.scope = Item::create(m_pool, ItemType::Scope); + projectContext.scope->setFile(projectItem->file()); + projectContext.scope->setProperty(StringConstants::projectVar(), itemValue); + ProductContext dummyProductContext; + dummyProductContext.project = &projectContext; + dummyProductContext.moduleProperties = m_parameters.finalBuildConfigurationTree(); + projectItem->addModule(loadBaseModule(&dummyProductContext, projectItem)); + overrideItemProperties(projectItem, StringConstants::projectPrefix(), + m_parameters.overriddenValuesTree()); + projectContext.name = m_evaluator->stringValue(projectItem, + StringConstants::nameProperty()); + if (projectContext.name.isEmpty()) { + projectContext.name = FileInfo::baseName(projectItem->location().filePath()); + projectItem->setProperty(StringConstants::nameProperty(), + VariantValue::create(projectContext.name)); + } + overrideItemProperties(projectItem, + StringConstants::projectsOverridePrefix() + projectContext.name, + m_parameters.overriddenValuesTree()); + if (!checkItemCondition(projectItem)) { + m_disabledProjects.insert(projectContext.name); + return; + } + topLevelProjectContext->projects.push_back(p.release()); + SearchPathsManager searchPathsManager(m_reader.get(), readExtraSearchPaths(projectItem) + << projectItem->file()->dirPath()); + projectContext.searchPathsStack = m_reader->extraSearchPathsStack(); + projectContext.item = projectItem; + + const QString minVersionStr + = m_evaluator->stringValue(projectItem, StringConstants::minimumQbsVersionProperty(), + QStringLiteral("1.3.0")); + const Version minVersion = Version::fromString(minVersionStr); + if (!minVersion.isValid()) { + throw ErrorInfo(Tr::tr("The value '%1' of Project.minimumQbsVersion " + "is not a valid version string.").arg(minVersionStr), projectItem->location()); + } + if (!m_qbsVersion.isValid()) + m_qbsVersion = Version::fromString(QLatin1String(QBS_VERSION)); + if (m_qbsVersion < minVersion) { + throw ErrorInfo(Tr::tr("The project requires at least qbs version %1, but " + "this is qbs version %2.").arg(minVersion.toString(), + m_qbsVersion.toString())); + } + + for (Item * const child : projectItem->children()) + child->setScope(projectContext.scope); + + m_probesResolver->resolveProbes(&dummyProductContext, projectItem); + projectContext.topLevelProject->probes << dummyProductContext.info.probes; + + handleProfileItems(projectItem, &projectContext); + + QList multiplexedProducts; + for (Item * const child : projectItem->children()) { + if (child->type() == ItemType::Product) + multiplexedProducts << multiplexProductItem(&dummyProductContext, child); + } + for (Item * const additionalProductItem : qAsConst(multiplexedProducts)) + Item::addChild(projectItem, additionalProductItem); + + const QList originalChildren = projectItem->children(); + for (Item * const child : originalChildren) { + switch (child->type()) { + case ItemType::Product: + prepareProduct(&projectContext, child); + break; + case ItemType::SubProject: + handleSubProject(&projectContext, child, referencedFilePaths); + break; + case ItemType::Project: + copyProperties(projectItem, child); + handleProject(loadResult, topLevelProjectContext, child, referencedFilePaths); + break; + default: + break; + } + } + + const QStringList refs = m_evaluator->stringListValue( + projectItem, StringConstants::referencesProperty()); + const CodeLocation referencingLocation + = projectItem->property(StringConstants::referencesProperty())->location(); + QList additionalProjectChildren; + for (const QString &filePath : refs) { + try { + additionalProjectChildren << loadReferencedFile(filePath, referencingLocation, + referencedFilePaths, dummyProductContext); + } catch (const ErrorInfo &error) { + if (m_parameters.productErrorMode() == ErrorHandlingMode::Strict) + throw; + m_logger.printWarning(error); + } + } + for (Item * const subItem : qAsConst(additionalProjectChildren)) { + Item::addChild(projectContext.item, subItem); + switch (subItem->type()) { + case ItemType::Product: + prepareProduct(&projectContext, subItem); + break; + case ItemType::Project: + copyProperties(projectItem, subItem); + handleProject(loadResult, topLevelProjectContext, subItem, + Set(referencedFilePaths) << subItem->file()->filePath()); + break; + default: + break; + } + } +} + +QString ModuleLoader::MultiplexInfo::toIdString(size_t row) const +{ + const auto &mprow = table.at(row); + QVariantMap multiplexConfiguration; + for (size_t column = 0; column < mprow.size(); ++column) { + const QString &propertyName = properties.at(column); + const VariantValuePtr &mpvalue = mprow.at(column); + multiplexConfiguration.insert(propertyName, mpvalue->value()); + } + QString id = QString::fromUtf8(QJsonDocument::fromVariant(multiplexConfiguration) + .toJson(QJsonDocument::Compact) + .toBase64()); + // Cache for later use in:multiplexIdToVariantMap() + multiplexConfigurationsById->localData().insert(id, multiplexConfiguration); + return id; +} + +QVariantMap ModuleLoader::MultiplexInfo::multiplexIdToVariantMap(const QString &multiplexId) +{ + if (multiplexId.isEmpty()) + return QVariantMap(); + + QVariantMap result = multiplexConfigurationsById->localData().value(multiplexId); + // We assume that MultiplexInfo::toIdString() has been called for this + // particular multiplex configuration. + QBS_CHECK(!result.isEmpty()); + return result; +} + +void qbs::Internal::ModuleLoader::ModuleLoader::dump(const ModuleLoader::MultiplexInfo &mpi) +{ + QStringList header; + for (const auto &str : mpi.properties) + header << str; + qDebug() << header; + + for (const auto &row : mpi.table) { + QVariantList values; + for (const auto &elem : row) { + values << elem->value(); + } + qDebug() << values; + } +} + +ModuleLoader::MultiplexTable ModuleLoader::combine(const MultiplexTable &table, + const MultiplexRow &values) +{ + MultiplexTable result; + if (table.empty()) { + result.resize(values.size()); + for (size_t i = 0; i < values.size(); ++i) { + MultiplexRow row; + row.resize(1); + row[0] = values.at(i); + result[i] = row; + } + } else { + for (const auto &row : table) { + for (const auto &value : values) { + MultiplexRow newRow = row; + newRow.push_back(value); + result.push_back(newRow); + } + } + } + return result; +} + +ModuleLoader::MultiplexInfo ModuleLoader::extractMultiplexInfo(Item *productItem, + Item *qbsModuleItem) +{ + static const QString mpmKey = QStringLiteral("multiplexMap"); + + const QScriptValue multiplexMap = m_evaluator->value(qbsModuleItem, mpmKey); + const QStringList multiplexByQbsProperties = m_evaluator->stringListValue( + productItem, StringConstants::multiplexByQbsPropertiesProperty()); + + MultiplexInfo multiplexInfo; + multiplexInfo.aggregate = m_evaluator->boolValue( + productItem, StringConstants::aggregateProperty()); + + const QString multiplexedType = m_evaluator->stringValue( + productItem, StringConstants::multiplexedTypeProperty()); + if (!multiplexedType.isEmpty()) + multiplexInfo.multiplexedType = VariantValue::create(multiplexedType); + + Set uniqueMultiplexByQbsProperties; + for (const QString &key : multiplexByQbsProperties) { + const QString mappedKey = multiplexMap.property(key).toString(); + if (mappedKey.isEmpty()) + throw ErrorInfo(Tr::tr("There is no entry for '%1' in 'qbs.multiplexMap'.").arg(key)); + + if (!uniqueMultiplexByQbsProperties.insert(mappedKey).second) { + throw ErrorInfo(Tr::tr("Duplicate entry '%1' in Product.%2.") + .arg(mappedKey, StringConstants::multiplexByQbsPropertiesProperty()), + productItem->location()); + } + + const QScriptValue arr = m_evaluator->value(qbsModuleItem, key); + if (arr.isUndefined()) + continue; + if (!arr.isArray()) + throw ErrorInfo(Tr::tr("Property '%1' must be an array.").arg(key)); + + const quint32 arrlen = arr.property(StringConstants::lengthProperty()).toUInt32(); + if (arrlen == 0) + continue; + + MultiplexRow mprow; + mprow.resize(arrlen); + QVariantList entriesForKey; + for (quint32 i = 0; i < arrlen; ++i) { + const QVariant value = arr.property(i).toVariant(); + if (entriesForKey.contains(value)) { + throw ErrorInfo(Tr::tr("Duplicate entry '%1' in qbs.%2.") + .arg(value.toString(), key), productItem->location()); + } + entriesForKey << value; + mprow[i] = VariantValue::create(value); + } + multiplexInfo.table = combine(multiplexInfo.table, mprow); + multiplexInfo.properties.push_back(mappedKey); + } + return multiplexInfo; +} + +template +T ModuleLoader::callWithTemporaryBaseModule(ProductContext *productContext, const F &func) +{ + // Temporarily attach the qbs module here, in case we need to access one of its properties + // to evaluate properties. + const QString &qbsKey = StringConstants::qbsModule(); + Item *productItem = productContext->item; + ValuePtr qbsValue = productItem->property(qbsKey); // Retrieve now to restore later. + if (qbsValue) + qbsValue = qbsValue->clone(); + const Item::Module qbsModule = loadBaseModule(productContext, productItem); + productItem->addModule(qbsModule); + + auto &&result = func(qbsModule); + + // "Unload" the qbs module again. + if (qbsValue) + productItem->setProperty(qbsKey, qbsValue); + else + productItem->removeProperty(qbsKey); + productItem->removeModules(); + + return std::forward(result); +} + +QList ModuleLoader::multiplexProductItem(ProductContext *dummyContext, Item *productItem) +{ + QString productName; + dummyContext->item = productItem; + auto extractMultiplexInfoFromProduct + = [this, productItem, &productName](const Item::Module &qbsModule) { + // Overriding the product item properties must be done here already, because multiplexing + // properties might depend on product properties. + const QString &nameKey = StringConstants::nameProperty(); + productName = m_evaluator->stringValue(productItem, nameKey); + if (productName.isEmpty()) { + productName = FileInfo::completeBaseName(productItem->file()->filePath()); + productItem->setProperty(nameKey, VariantValue::create(productName)); + } + overrideItemProperties(productItem, StringConstants::productsOverridePrefix() + productName, + m_parameters.overriddenValuesTree()); + + return extractMultiplexInfo(productItem, qbsModule.item); + }; + const auto multiplexInfo + = callWithTemporaryBaseModule(dummyContext, + extractMultiplexInfoFromProduct); + + if (multiplexInfo.table.size() > 1) + productItem->setProperty(StringConstants::multiplexedProperty(), VariantValue::trueValue()); + + VariantValuePtr productNameValue = VariantValue::create(productName); + + Item *aggregator = multiplexInfo.aggregate ? productItem->clone() : nullptr; + QList additionalProductItems; + std::vector multiplexConfigurationIdValues; + for (size_t row = 0; row < multiplexInfo.table.size(); ++row) { + Item *item = productItem; + const auto &mprow = multiplexInfo.table.at(row); + QBS_CHECK(mprow.size() == multiplexInfo.properties.size()); + if (row > 0) { + item = productItem->clone(); + additionalProductItems.push_back(item); + } + const QString multiplexConfigurationId = multiplexInfo.toIdString(row); + const VariantValuePtr multiplexConfigurationIdValue + = VariantValue::create(multiplexConfigurationId); + if (multiplexInfo.table.size() > 1 || aggregator) { + multiplexConfigurationIdValues.push_back(multiplexConfigurationIdValue); + item->setProperty(StringConstants::multiplexConfigurationIdProperty(), + multiplexConfigurationIdValue); + } + if (multiplexInfo.multiplexedType) + item->setProperty(StringConstants::typeProperty(), multiplexInfo.multiplexedType); + for (size_t column = 0; column < mprow.size(); ++column) { + Item *qbsItem = moduleInstanceItem(item, StringConstants::qbsModule()); + const QString &propertyName = multiplexInfo.properties.at(column); + const VariantValuePtr &mpvalue = mprow.at(column); + qbsItem->setProperty(propertyName, mpvalue); + } + } + + if (aggregator) { + additionalProductItems << aggregator; + + // Add dependencies to all multiplexed instances. + for (const auto &v : multiplexConfigurationIdValues) { + Item *dependsItem = Item::create(aggregator->pool(), ItemType::Depends); + dependsItem->setProperty(StringConstants::nameProperty(), productNameValue); + dependsItem->setProperty(StringConstants::multiplexConfigurationIdProperty(), v); + dependsItem->setProperty(StringConstants::profilesProperty(), + VariantValue::create(QStringList())); + dependsItem->setFile(aggregator->file()); + dependsItem->setupForBuiltinType(m_logger); + Item::addChild(aggregator, dependsItem); + } + } + + return additionalProductItems; +} + +void ModuleLoader::normalizeDependencies(ProductContext *product, + const DeferredDependsContext &dependsContext) +{ + std::vector dependsItemsToAdd; + std::vector dependsItemsToRemove; + std::vector deferredDependsItems; + for (Item *dependsItem : dependsContext.parentItem->children()) { + if (dependsItem->type() != ItemType::Depends) + continue; + bool productTypesIsSet; + const FileTags productTypes = m_evaluator->fileTagsValue(dependsItem, + StringConstants::productTypesProperty(), &productTypesIsSet); + if (productTypesIsSet) { + bool nameIsSet; + m_evaluator->stringValue(dependsItem, StringConstants::nameProperty(), QString(), + &nameIsSet); + + // The second condition is for the case where the dependency comes from an Export item + // that has itself been normalized in the mean time. + if (nameIsSet && !dependsItem->variantProperty(StringConstants::nameProperty())) { + throw ErrorInfo(Tr::tr("The 'productTypes' and 'name' properties are mutually " + "exclusive."), dependsItem->location()); + } + + bool submodulesPropertySet; + m_evaluator->stringListValue( dependsItem, StringConstants::submodulesProperty(), + &submodulesPropertySet); + if (submodulesPropertySet) { + throw ErrorInfo(Tr::tr("The 'productTypes' and 'subModules' properties are " + "mutually exclusive."), dependsItem->location()); + } + + // We ignore the "limitToSubProject" property for dependencies from Export items, + // because we cannot make it work consistently, as the importing product is not + // yet known when normalizing via an Export item. + const bool limitToSubProject = dependsContext.parentItem->type() == ItemType::Product + && m_evaluator->boolValue(dependsItem, + StringConstants::limitToSubProjectProperty()); + static const auto hasSameSubProject + = [](const ProductContext &product, const ProductContext &other) { + for (const Item *otherParent = other.item->parent(); otherParent; + otherParent = otherParent->parent()) { + if (otherParent == product.item->parent()) + return true; + } + return false; + }; + std::vector matchingProducts; + for (const FileTag &typeTag : productTypes) { + const auto range = m_productsByType.equal_range(typeTag); + for (auto it = range.first; it != range.second; ++it) { + if (it->second != product + && (!product || it->second->name != product->name) + && (!limitToSubProject || hasSameSubProject(*product, *it->second))) { + matchingProducts.push_back(it->second); + } + } + } + if (matchingProducts.empty()) { + qCDebug(lcModuleLoader) << "Depends.productTypes does not match anything." + << dependsItem->location(); + dependsItemsToRemove.push_back(dependsItem); + continue; + } + if (dependsContext.parentItem->type() != ItemType::Export) + deferredDependsItems.push_back(dependsItem); + for (std::size_t i = 1; i < matchingProducts.size(); ++i) { + Item * const dependsClone = dependsItem->clone(); + dependsClone->setProperty(StringConstants::nameProperty(), + VariantValue::create(matchingProducts.at(i)->name)); + dependsItemsToAdd.push_back(dependsClone); + if (dependsContext.parentItem->type() != ItemType::Export) + deferredDependsItems.push_back(dependsClone); + + } + dependsItem->setProperty(StringConstants::nameProperty(), + VariantValue::create(matchingProducts.front()->name)); + } + } + for (Item * const newDependsItem : dependsItemsToAdd) + Item::addChild(dependsContext.parentItem, newDependsItem); + for (Item * const dependsItem : dependsItemsToRemove) + Item::removeChild(dependsContext.parentItem, dependsItem); + if (!deferredDependsItems.empty()) { + auto &allDeferredDependsItems + = product->deferredDependsItems[dependsContext.exportingProductItem]; + allDeferredDependsItems.insert(allDeferredDependsItems.end(), deferredDependsItems.cbegin(), + deferredDependsItems.cend()); + } +} + +void ModuleLoader::adjustDependenciesForMultiplexing(const TopLevelProjectContext &tlp) +{ + for (const ProjectContext * const project : tlp.projects) { + for (const ProductContext &product : project->products) + adjustDependenciesForMultiplexing(product); + } +} + +void ModuleLoader::adjustDependenciesForMultiplexing(const ModuleLoader::ProductContext &product) +{ + for (Item *dependsItem : product.item->children()) { + if (dependsItem->type() == ItemType::Depends) + adjustDependenciesForMultiplexing(product, dependsItem); + } +} + +void ModuleLoader::adjustDependenciesForMultiplexing(const ProductContext &product, + Item *dependsItem) +{ + const QString name = m_evaluator->stringValue(dependsItem, StringConstants::nameProperty()); + const bool productIsMultiplexed = !product.multiplexConfigurationId.isEmpty(); + if (name == product.name) { + QBS_CHECK(!productIsMultiplexed); // This product must be an aggregator. + return; + } + + bool profilesPropertyIsSet; + const QStringList profiles = m_evaluator->stringListValue(dependsItem, + StringConstants::profilesProperty(), &profilesPropertyIsSet); + + const auto productRange = m_productsByName.equal_range(name); + if (productRange.first == productRange.second) { + // Dependency is a module. Nothing to adjust. + return; + } + + std::vector multiplexedDependencies; + bool hasNonMultiplexedDependency = false; + for (auto it = productRange.first; it != productRange.second; ++it) { + if (!it->second->multiplexConfigurationId.isEmpty()) + multiplexedDependencies.push_back(it->second); + else + hasNonMultiplexedDependency = true; + } + bool hasMultiplexedDependencies = !multiplexedDependencies.empty(); + + // These are the allowed cases: + // (1) Normal dependency with no multiplexing whatsoever. + // (2) Both product and dependency are multiplexed. + // (2a) The profiles property is not set, we want to depend on the best + // matching variant. + // (2b) The profiles property is set, we want to depend on all variants + // with a matching profile. + // (3) The product is not multiplexed, but the dependency is. + // (3a) The profiles property is not set, the dependency has an aggregator. + // We want to depend on the aggregator. + // (3b) The profiles property is not set, the dependency does not have an + // aggregator. We want to depend on all the multiplexed variants. + // (3c) The profiles property is set, we want to depend on all variants + // with a matching profile regardless of whether an aggregator exists or not. + // (4) The product is multiplexed, but the dependency is not. We don't have to adapt + // any Depends items. + // (5) The product is a "shadow product". In that case, we know which product + // it should have a dependency on, and we make sure we depend on that. + + // (1) and (4) + if (!hasMultiplexedDependencies) + return; + + // (3a) + if (!productIsMultiplexed && hasNonMultiplexedDependency && !profilesPropertyIsSet) + return; + + QStringList multiplexIds; + const ShadowProductInfo shadowProductInfo = getShadowProductInfo(product); + const bool isShadowProduct = shadowProductInfo.first && shadowProductInfo.second == name; + const auto productMultiplexConfig = + MultiplexInfo::multiplexIdToVariantMap(product.multiplexConfigurationId); + + for (const ProductContext *dependency : multiplexedDependencies) { + const bool depMatchesShadowProduct = isShadowProduct + && dependency->item == product.item->parent(); + const QString depMultiplexId = dependency->multiplexConfigurationId; + if (depMatchesShadowProduct) { // (5) + dependsItem->setProperty(StringConstants::multiplexConfigurationIdsProperty(), + VariantValue::create(depMultiplexId)); + return; + } + if (productIsMultiplexed && !profilesPropertyIsSet) { // 2a + if (dependency->multiplexConfigurationId == product.multiplexConfigurationId) { + const ValuePtr &multiplexId = product.item->property( + StringConstants::multiplexConfigurationIdProperty()); + dependsItem->setProperty(StringConstants::multiplexConfigurationIdsProperty(), + multiplexId); + return; + + } + // Otherwise collect partial matches and decide later + const auto dependencyMultiplexConfig = MultiplexInfo::multiplexIdToVariantMap( + dependency->multiplexConfigurationId); + + if (multiplexConfigurationIntersects(dependencyMultiplexConfig, productMultiplexConfig)) + multiplexIds << dependency->multiplexConfigurationId; + } else { + // (2b), (3b) or (3c) + const bool profileMatch = !profilesPropertyIsSet || profiles.empty() + || profiles.contains(dependency->profileName); + if (profileMatch) + multiplexIds << depMultiplexId; + } + } + if (multiplexIds.empty()) { + const QString productName = ResolvedProduct::fullDisplayName( + product.name, product.multiplexConfigurationId); + throw ErrorInfo(Tr::tr("Dependency from product '%1' to product '%2' not fulfilled. " + "There are no eligible multiplex candidates.").arg(productName, + name), + dependsItem->location()); + } + + // In case of (2a), at most 1 match is allowed + if (productIsMultiplexed && !profilesPropertyIsSet && multiplexIds.size() > 1) { + const QString productName = ResolvedProduct::fullDisplayName( + product.name, product.multiplexConfigurationId); + QStringList candidateNames; + for (const auto &id : qAsConst(multiplexIds)) + candidateNames << ResolvedProduct::fullDisplayName(name, id); + throw ErrorInfo(Tr::tr("Dependency from product '%1' to product '%2' is ambiguous. " + "Eligible multiplex candidates: %3.").arg( + productName, name, candidateNames.join(QLatin1String(", "))), + dependsItem->location()); + } + + dependsItem->setProperty(StringConstants::multiplexConfigurationIdsProperty(), + VariantValue::create(multiplexIds)); +} + +void ModuleLoader::prepareProduct(ProjectContext *projectContext, Item *productItem) +{ + AccumulatingTimer timer(m_parameters.logElapsedTime() + ? &m_elapsedTimePrepareProducts : nullptr); + checkCancelation(); + qCDebug(lcModuleLoader) << "prepareProduct" << productItem->file()->filePath(); + + ProductContext productContext; + productContext.item = productItem; + productContext.project = projectContext; + productContext.name = m_evaluator->stringValue(productItem, StringConstants::nameProperty()); + QBS_CHECK(!productContext.name.isEmpty()); + const ItemValueConstPtr qbsItemValue = productItem->itemProperty(StringConstants::qbsModule()); + if (!!qbsItemValue && qbsItemValue->item()->hasProperty(StringConstants::profileProperty())) { + qbsItemValue->item()->setProperty(StringConstants::nameProperty(), + VariantValue::create(StringConstants::nameProperty())); + auto evaluateQbsProfileProperty = [this](const Item::Module &qbsModule) { + return m_evaluator->stringValue(qbsModule.item, + StringConstants::profileProperty(), QString()); + }; + productContext.profileName + = callWithTemporaryBaseModule(&productContext, + evaluateQbsProfileProperty); + } else { + productContext.profileName = m_parameters.topLevelProfile(); + } + productContext.multiplexConfigurationId = m_evaluator->stringValue( + productItem, StringConstants::multiplexConfigurationIdProperty()); + QBS_CHECK(!productContext.profileName.isEmpty()); + const auto it = projectContext->result->profileConfigs.constFind(productContext.profileName); + if (it == projectContext->result->profileConfigs.constEnd()) { + const Profile profile(productContext.profileName, m_settings.get(), m_localProfiles); + if (!profile.exists()) { + ErrorInfo error(Tr::tr("Profile '%1' does not exist.").arg(profile.name()), + productItem->location()); + handleProductError(error, &productContext); + return; + } + const QVariantMap buildConfig = SetupProjectParameters::expandedBuildConfiguration( + profile, m_parameters.configurationName()); + productContext.moduleProperties = SetupProjectParameters::finalBuildConfigurationTree( + buildConfig, m_parameters.overriddenValues()); + projectContext->result->profileConfigs.insert(productContext.profileName, + productContext.moduleProperties); + } else { + productContext.moduleProperties = it.value().toMap(); + } + initProductProperties(productContext); + + ItemValuePtr itemValue = ItemValue::create(productItem); + productContext.scope = Item::create(m_pool, ItemType::Scope); + productContext.scope->setProperty(StringConstants::productVar(), itemValue); + productContext.scope->setFile(productItem->file()); + productContext.scope->setScope(productContext.project->scope); + + const bool hasExportItems = mergeExportItems(productContext); + + setScopeForDescendants(productItem, productContext.scope); + + projectContext->products.push_back(productContext); + + if (!hasExportItems || getShadowProductInfo(productContext).first) + return; + + // This "shadow product" exists only to pull in a dependency on the actual product + // and nothing else, thus providing us with the pure environment that we need to + // evaluate the product's exported properties in isolation in the project resolver. + Item * const importer = Item::create(productItem->pool(), ItemType::Product); + importer->setProperty(QStringLiteral("name"), + VariantValue::create(StringConstants::shadowProductPrefix() + + productContext.name)); + importer->setFile(productItem->file()); + importer->setLocation(productItem->location()); + importer->setScope(projectContext->scope); + importer->setupForBuiltinType(m_logger); + Item * const dependsItem = Item::create(productItem->pool(), ItemType::Depends); + dependsItem->setProperty(QStringLiteral("name"), VariantValue::create(productContext.name)); + dependsItem->setProperty(QStringLiteral("required"), VariantValue::create(false)); + dependsItem->setFile(importer->file()); + dependsItem->setLocation(importer->location()); + dependsItem->setupForBuiltinType(m_logger); + Item::addChild(importer, dependsItem); + Item::addChild(productItem, importer); + prepareProduct(projectContext, importer); +} + +void ModuleLoader::setupProductDependencies(ProductContext *productContext, + const Set &deferredDependsContext) +{ + if (m_dependencyResolvingPass == 2) { + for (const DeferredDependsContext &ctx : deferredDependsContext) + normalizeDependencies(productContext, ctx); + for (const auto &deferralData : productContext->deferredDependsItems) { + for (Item * const deferredDependsItem : deferralData.second) { + + // Dependencies from Export items are handled in addProductModuleDependencies(). + if (deferredDependsItem->parent() == productContext->item) + adjustDependenciesForMultiplexing(*productContext, deferredDependsItem); + } + } + } + AccumulatingTimer timer(m_parameters.logElapsedTime() + ? &m_elapsedTimeProductDependencies : nullptr); + checkCancelation(); + Item *item = productContext->item; + qCDebug(lcModuleLoader) << "setupProductDependencies" << productContext->name + << productContext->item->location(); + + if (m_dependencyResolvingPass == 1) + setSearchPathsForProduct(productContext); + + // Module providers may push some extra search paths which we will be cleared + // by this SearchPathsManager. However, they will be also added to productContext->searchPaths + // so second pass will take that into account + SearchPathsManager searchPathsManager(m_reader.get(), productContext->searchPaths); + + DependsContext dependsContext; + dependsContext.product = productContext; + dependsContext.productDependencies = &productContext->info.usedProducts; + resolveDependencies(&dependsContext, item, productContext); + if (m_dependencyResolvingPass == 2 + || !containsKey(m_productsWithDeferredDependsItems, productContext)) { + addProductModuleDependencies(productContext); + } + productContext->project->result->productInfos[item] = productContext->info; +} + +// Leaf modules first. +// TODO: Can this be merged with addTransitiveDependencies? Looks suspiciously similar. +void ModuleLoader::createSortedModuleList(const Item::Module &parentModule, Item::Modules &modules) +{ + if (std::find_if(modules.cbegin(), modules.cend(), + [parentModule](const Item::Module &m) { return m.name == parentModule.name;}) + != modules.cend()) { + return; + } + for (const Item::Module &dep : parentModule.item->modules()) + createSortedModuleList(dep, modules); + modules.push_back(parentModule); +} + +Item::Modules ModuleLoader::modulesSortedByDependency(const Item *productItem) +{ + QBS_CHECK(productItem->type() == ItemType::Product); + Item::Modules sortedModules; + const Item::Modules &unsortedModules = productItem->modules(); + for (const Item::Module &module : unsortedModules) + createSortedModuleList(module, sortedModules); + QBS_CHECK(sortedModules.size() == unsortedModules.size()); + + // Make sure the top-level items stay the same. + for (Item::Module &s : sortedModules) { + for (const Item::Module &u : unsortedModules) { + if (s.name == u.name) { + s.item = u.item; + break; + } + } + } + return sortedModules; +} + + +template bool insertIntoSet(Set &set, const T &value) +{ + const auto insertionResult = set.insert(value); + return insertionResult.second; +} + +void ModuleLoader::setupReverseModuleDependencies(const Item::Module &module, + ModuleDependencies &deps, + QualifiedIdSet &seenModules) +{ + if (!insertIntoSet(seenModules, module.name)) + return; + for (const Item::Module &m : module.item->modules()) { + deps[m.name].insert(module.name); + setupReverseModuleDependencies(m, deps, seenModules); + } +} + +ModuleLoader::ModuleDependencies ModuleLoader::setupReverseModuleDependencies(const Item *product) +{ + ModuleDependencies deps; + QualifiedIdSet seenModules; + for (const Item::Module &m : product->modules()) + setupReverseModuleDependencies(m, deps, seenModules); + return deps; +} + +void ModuleLoader::handleProduct(ModuleLoader::ProductContext *productContext) +{ + AccumulatingTimer timer(m_parameters.logElapsedTime() ? &m_elapsedTimeHandleProducts : nullptr); + if (productContext->info.delayedError.hasError()) + return; + + Item * const item = productContext->item; + + m_reader->setExtraSearchPathsStack(productContext->project->searchPathsStack); + SearchPathsManager searchPathsManager(m_reader.get(), productContext->searchPaths); + addTransitiveDependencies(productContext); + + // It is important that dependent modules are merged after their dependency, because + // the dependent module's merger potentially needs to replace module items that were + // set by the dependency module's merger (namely, scopes of defining items; see + // ModuleMerger::replaceItemInScopes()). + Item::Modules topSortedModules = modulesSortedByDependency(item); + ModuleMerger::merge(m_logger, item, productContext->name, &topSortedModules); + + // Re-sort the modules by name. This is more stable; see QBS-818. + // The list of modules in the product now has the same order as before, + // only the items have been replaced by their merged counterparts. + Item::Modules lexicographicallySortedModules = topSortedModules; + std::sort(lexicographicallySortedModules.begin(), lexicographicallySortedModules.end()); + item->setModules(lexicographicallySortedModules); + + for (const Item::Module &module : topSortedModules) { + if (!module.item->isPresentModule()) + continue; + try { + m_probesResolver->resolveProbes(productContext, module.item); + if (module.versionRange.minimum.isValid() + || module.versionRange.maximum.isValid()) { + if (module.versionRange.maximum.isValid() + && module.versionRange.minimum >= module.versionRange.maximum) { + throw ErrorInfo(Tr::tr("Impossible version constraint [%1,%2) set for module " + "'%3'").arg(module.versionRange.minimum.toString(), + module.versionRange.maximum.toString(), + module.name.toString())); + } + const Version moduleVersion = Version::fromString( + m_evaluator->stringValue(module.item, + StringConstants::versionProperty())); + if (moduleVersion < module.versionRange.minimum) { + throw ErrorInfo(Tr::tr("Module '%1' has version %2, but it needs to be " + "at least %3.").arg(module.name.toString(), + moduleVersion.toString(), + module.versionRange.minimum.toString())); + } + if (module.versionRange.maximum.isValid() + && moduleVersion >= module.versionRange.maximum) { + throw ErrorInfo(Tr::tr("Module '%1' has version %2, but it needs to be " + "lower than %3.").arg(module.name.toString(), + moduleVersion.toString(), + module.versionRange.maximum.toString())); + } + } + } catch (const ErrorInfo &error) { + handleModuleSetupError(productContext, module, error); + if (productContext->info.delayedError.hasError()) + return; + } + } + + m_probesResolver->resolveProbes(productContext, item); + + // Module validation must happen in an extra pass, after all Probes have been resolved. + EvalCacheEnabler cacheEnabler(m_evaluator); + for (const Item::Module &module : topSortedModules) { + if (!module.item->isPresentModule()) + continue; + try { + m_evaluator->boolValue(module.item, StringConstants::validateProperty()); + for (const auto &dep : module.item->modules()) { + if (dep.requiredValue && !dep.item->isPresentModule()) { + throw ErrorInfo(Tr::tr("Module '%1' depends on module '%2', which was not " + "loaded successfully") + .arg(module.name.toString(), dep.name.toString())); + } + } + } catch (const ErrorInfo &error) { + handleModuleSetupError(productContext, module, error); + if (productContext->info.delayedError.hasError()) + return; + } + } + + if (!checkItemCondition(item)) { + const auto &exportsData = productContext->project->topLevelProject->productModules; + for (auto it = exportsData.find(productContext->name); + it != exportsData.end() && it.key() == productContext->name; ++it) { + if (it.value().multiplexId == productContext->multiplexConfigurationId) { + createNonPresentModule(productContext->name, QStringLiteral("disabled"), + it.value().exportItem); + break; + } + } + } + + checkDependencyParameterDeclarations(productContext); + copyGroupsFromModulesToProduct(*productContext); + + ModuleDependencies reverseModuleDeps; + for (Item * const child : item->children()) { + if (child->type() == ItemType::Group) { + if (reverseModuleDeps.empty()) + reverseModuleDeps = setupReverseModuleDependencies(item); + handleGroup(productContext, child, reverseModuleDeps); + } + } + productContext->project->result->productInfos[item] = productContext->info; +} + +static Item *rootPrototype(Item *item) +{ + Item *modulePrototype = item; + while (modulePrototype->prototype()) + modulePrototype = modulePrototype->prototype(); + return modulePrototype; +} + +class DependencyParameterDeclarationCheck +{ +public: + DependencyParameterDeclarationCheck(const QString &productName, const Item *productItem, + const QHash &decls) + : m_productName(productName), m_productItem(productItem), m_parameterDeclarations(decls) + { + } + + void operator()(const QVariantMap ¶meters) const + { + check(parameters, QualifiedId()); + } + +private: + void check(const QVariantMap ¶meters, const QualifiedId &moduleName) const + { + for (auto it = parameters.begin(); it != parameters.end(); ++it) { + if (it.value().userType() == QMetaType::QVariantMap) { + check(it.value().toMap(), QualifiedId(moduleName) << it.key()); + } else { + const auto &deps = m_productItem->modules(); + auto m = std::find_if(deps.begin(), deps.end(), + [&moduleName] (const Item::Module &module) { + return module.name == moduleName; + }); + + if (m == deps.end()) { + const QualifiedId fullName = QualifiedId(moduleName) << it.key(); + throw ErrorInfo(Tr::tr("Cannot set parameter '%1', " + "because '%2' does not have a dependency on '%3'.") + .arg(fullName.toString(), m_productName, moduleName.toString()), + m_productItem->location()); + } + + auto decls = m_parameterDeclarations.value(rootPrototype(m->item)); + + if (!decls.contains(it.key())) { + const QualifiedId fullName = QualifiedId(moduleName) << it.key(); + throw ErrorInfo(Tr::tr("Parameter '%1' is not declared.") + .arg(fullName.toString()), m_productItem->location()); + } + } + } + } + + bool moduleExists(const QualifiedId &name) const + { + const auto &deps = m_productItem->modules(); + return any_of(deps, [&name](const Item::Module &module) { + return module.name == name; + }); + } + + const QString &m_productName; + const Item *m_productItem; + const QHash &m_parameterDeclarations; +}; + +void ModuleLoader::checkDependencyParameterDeclarations(const ProductContext *productContext) const +{ + DependencyParameterDeclarationCheck dpdc(productContext->name, productContext->item, + m_parameterDeclarations); + for (const Item::Module &dep : productContext->item->modules()) { + if (!dep.parameters.empty()) + dpdc(dep.parameters); + } +} + +void ModuleLoader::handleModuleSetupError(ModuleLoader::ProductContext *productContext, + const Item::Module &module, const ErrorInfo &error) +{ + if (module.required) { + handleProductError(error, productContext); + } else { + qCDebug(lcModuleLoader()) << "non-required module" << module.name.toString() + << "found, but not usable in product" << productContext->name + << error.toString(); + createNonPresentModule(module.name.toString(), QStringLiteral("failed validation"), + module.item); + } +} + +void ModuleLoader::initProductProperties(const ProductContext &product) +{ + QString buildDir = ResolvedProduct::deriveBuildDirectoryName(product.name, + product.multiplexConfigurationId); + buildDir = FileInfo::resolvePath(product.project->topLevelProject->buildDirectory, buildDir); + product.item->setProperty(StringConstants::buildDirectoryProperty(), + VariantValue::create(buildDir)); + const QString sourceDir = QFileInfo(product.item->file()->filePath()).absolutePath(); + product.item->setProperty(StringConstants::sourceDirectoryProperty(), + VariantValue::create(sourceDir)); +} + +void ModuleLoader::handleSubProject(ModuleLoader::ProjectContext *projectContext, Item *projectItem, + const Set &referencedFilePaths) +{ + qCDebug(lcModuleLoader) << "handleSubProject" << projectItem->file()->filePath(); + + Item * const propertiesItem = projectItem->child(ItemType::PropertiesInSubProject); + if (!checkItemCondition(projectItem)) + return; + if (propertiesItem) { + propertiesItem->setScope(projectItem); + if (!checkItemCondition(propertiesItem)) + return; + } + + Item *loadedItem; + QString subProjectFilePath; + try { + const QString projectFileDirPath = FileInfo::path(projectItem->file()->filePath()); + const QString relativeFilePath + = m_evaluator->stringValue(projectItem, StringConstants::filePathProperty()); + subProjectFilePath = FileInfo::resolvePath(projectFileDirPath, relativeFilePath); + if (referencedFilePaths.contains(subProjectFilePath)) + throw ErrorInfo(Tr::tr("Cycle detected while loading subproject file '%1'.") + .arg(relativeFilePath), projectItem->location()); + loadedItem = loadItemFromFile(subProjectFilePath, projectItem->location()); + } catch (const ErrorInfo &error) { + if (m_parameters.productErrorMode() == ErrorHandlingMode::Strict) + throw; + m_logger.printWarning(error); + return; + } + + loadedItem = wrapInProjectIfNecessary(loadedItem); + const bool inheritProperties = m_evaluator->boolValue( + projectItem, StringConstants::inheritPropertiesProperty()); + + if (inheritProperties) + copyProperties(projectItem->parent(), loadedItem); + if (propertiesItem) { + const Item::PropertyMap &overriddenProperties = propertiesItem->properties(); + for (Item::PropertyMap::ConstIterator it = overriddenProperties.constBegin(); + it != overriddenProperties.constEnd(); ++it) { + loadedItem->setProperty(it.key(), it.value()); + } + } + + Item::addChild(projectItem, loadedItem); + projectItem->setScope(projectContext->scope); + handleProject(projectContext->result, projectContext->topLevelProject, loadedItem, + Set(referencedFilePaths) << subProjectFilePath); +} + +QList ModuleLoader::loadReferencedFile(const QString &relativePath, + const CodeLocation &referencingLocation, + const Set &referencedFilePaths, + ModuleLoader::ProductContext &dummyContext) +{ + QString absReferencePath = FileInfo::resolvePath(FileInfo::path(referencingLocation.filePath()), + relativePath); + if (FileInfo(absReferencePath).isDir()) { + QString qbsFilePath; + + QDirIterator dit(absReferencePath, StringConstants::qbsFileWildcards()); + while (dit.hasNext()) { + if (!qbsFilePath.isEmpty()) { + throw ErrorInfo(Tr::tr("Referenced directory '%1' contains more than one " + "qbs file.").arg(absReferencePath), referencingLocation); + } + qbsFilePath = dit.next(); + } + if (qbsFilePath.isEmpty()) { + throw ErrorInfo(Tr::tr("Referenced directory '%1' does not contain a qbs file.") + .arg(absReferencePath), referencingLocation); + } + absReferencePath = qbsFilePath; + } + if (referencedFilePaths.contains(absReferencePath)) + throw ErrorInfo(Tr::tr("Cycle detected while referencing file '%1'.").arg(relativePath), + referencingLocation); + Item * const subItem = loadItemFromFile(absReferencePath, referencingLocation); + if (subItem->type() != ItemType::Project && subItem->type() != ItemType::Product) { + ErrorInfo error(Tr::tr("Item type should be 'Product' or 'Project', but is '%1'.") + .arg(subItem->typeName())); + error.append(Tr::tr("Item is defined here."), subItem->location()); + error.append(Tr::tr("File is referenced here."), referencingLocation); + throw error; + } + subItem->setScope(dummyContext.project->scope); + subItem->setParent(dummyContext.project->item); + QList loadedItems; + loadedItems << subItem; + if (subItem->type() == ItemType::Product) { + handleProfileItems(subItem, dummyContext.project); + loadedItems << multiplexProductItem(&dummyContext, subItem); + } + return loadedItems; +} + +void ModuleLoader::handleGroup(ProductContext *productContext, Item *groupItem, + const ModuleDependencies &reverseDepencencies) +{ + checkCancelation(); + propagateModulesFromParent(productContext, groupItem, reverseDepencencies); + checkItemCondition(groupItem); + for (Item * const child : groupItem->children()) { + if (child->type() == ItemType::Group) + handleGroup(productContext, child, reverseDepencencies); + } +} + +void ModuleLoader::handleAllPropertyOptionsItems(Item *item) +{ + QList childItems = item->children(); + auto childIt = childItems.begin(); + while (childIt != childItems.end()) { + Item * const child = *childIt; + if (child->type() == ItemType::PropertyOptions) { + handlePropertyOptions(child); + childIt = childItems.erase(childIt); + } else { + handleAllPropertyOptionsItems(child); + ++childIt; + } + } + item->setChildren(childItems); +} + +void ModuleLoader::handlePropertyOptions(Item *optionsItem) +{ + const QString name = m_evaluator->stringValue(optionsItem, StringConstants::nameProperty()); + if (name.isEmpty()) { + throw ErrorInfo(Tr::tr("PropertyOptions item needs a name property"), + optionsItem->location()); + } + const QString description = m_evaluator->stringValue( + optionsItem, StringConstants::descriptionProperty()); + const auto removalVersion = Version::fromString(m_evaluator->stringValue(optionsItem, + StringConstants::removalVersionProperty())); + const auto allowedValues = m_evaluator->stringListValue( + optionsItem, StringConstants::allowedValuesProperty()); + + PropertyDeclaration decl = optionsItem->parent()->propertyDeclaration(name); + if (!decl.isValid()) { + decl.setName(name); + decl.setType(PropertyDeclaration::Variant); + } + decl.setDescription(description); + if (removalVersion.isValid()) { + DeprecationInfo di(removalVersion, description); + decl.setDeprecationInfo(di); + } + decl.setAllowedValues(allowedValues); + const ValuePtr property = optionsItem->parent()->property(name); + if (!property && !decl.isExpired()) { + throw ErrorInfo(Tr::tr("PropertyOptions item refers to non-existing property '%1'") + .arg(name), optionsItem->location()); + } + if (property && decl.isExpired()) { + ErrorInfo e(Tr::tr("Property '%1' was scheduled for removal in version %2, but " + "is still present.") + .arg(name, removalVersion.toString()), + property->location()); + e.append(Tr::tr("Removal version for '%1' specified here.").arg(name), + optionsItem->location()); + m_logger.printWarning(e); + } + optionsItem->parent()->setPropertyDeclaration(name, decl); +} + +static void mergeProperty(Item *dst, const QString &name, const ValuePtr &value) +{ + if (value->type() == Value::ItemValueType) { + const ItemValueConstPtr itemValue = std::static_pointer_cast(value); + const Item * const valueItem = itemValue->item(); + Item * const subItem = dst->itemProperty(name, itemValue)->item(); + for (QMap::const_iterator it = valueItem->properties().constBegin(); + it != valueItem->properties().constEnd(); ++it) + mergeProperty(subItem, it.key(), it.value()); + } else { + // If the property already exists set up the base value. + if (value->type() == Value::JSSourceValueType) { + const auto jsValue = static_cast(value.get()); + if (jsValue->isBuiltinDefaultValue()) + return; + const ValuePtr baseValue = dst->property(name); + if (baseValue) { + QBS_CHECK(baseValue->type() == Value::JSSourceValueType); + const JSSourceValuePtr jsBaseValue = std::static_pointer_cast( + baseValue->clone()); + jsValue->setBaseValue(jsBaseValue); + std::vector alternatives = jsValue->alternatives(); + jsValue->clearAlternatives(); + for (JSSourceValue::Alternative &a : alternatives) { + a.value->setBaseValue(jsBaseValue); + jsValue->addAlternative(a); + } + } + } + dst->setProperty(name, value); + } +} + +bool ModuleLoader::checkExportItemCondition(Item *exportItem, const ProductContext &productContext) +{ + class ScopeHandler { + public: + ScopeHandler(Item *exportItem, const ProductContext &productContext, Item **cachedScopeItem) + : m_exportItem(exportItem) + { + if (!*cachedScopeItem) + *cachedScopeItem = Item::create(exportItem->pool(), ItemType::Scope); + Item * const scope = *cachedScopeItem; + QBS_CHECK(productContext.item->file()); + scope->setFile(productContext.item->file()); + scope->setScope(productContext.item); + productContext.project->scope->copyProperty(StringConstants::projectVar(), scope); + productContext.scope->copyProperty(StringConstants::productVar(), scope); + QBS_CHECK(!exportItem->scope()); + exportItem->setScope(scope); + } + ~ScopeHandler() { m_exportItem->setScope(nullptr); } + + private: + Item * const m_exportItem; + } scopeHandler(exportItem, productContext, &m_tempScopeItem); + return checkItemCondition(exportItem); +} + +void ModuleLoader::printProfilingInfo() +{ + if (!m_parameters.logElapsedTime()) + return; + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Project file loading and parsing took %1.") + .arg(elapsedTimeString(m_reader->elapsedTime())); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Preparing products took %1.") + .arg(elapsedTimeString(m_elapsedTimePrepareProducts)); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Setting up product dependencies took %1.") + .arg(elapsedTimeString(m_elapsedTimeProductDependencies)); + m_logger.qbsLog(LoggerInfo, true) << "\t\t" + << Tr::tr("Running module providers took %1.") + .arg(elapsedTimeString(m_elapsedTimeModuleProviders)); + m_logger.qbsLog(LoggerInfo, true) << "\t\t" + << Tr::tr("Setting up transitive product dependencies took %1.") + .arg(elapsedTimeString(m_elapsedTimeTransitiveDependencies)); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Handling products took %1.") + .arg(elapsedTimeString(m_elapsedTimeHandleProducts)); + m_probesResolver->printProfilingInfo(); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Property checking took %1.") + .arg(elapsedTimeString(m_elapsedTimePropertyChecking)); +} + +static void mergeParameters(QVariantMap &dst, const QVariantMap &src) +{ + for (auto it = src.begin(); it != src.end(); ++it) { + if (it.value().userType() == QMetaType::QVariantMap) { + QVariant &vdst = dst[it.key()]; + QVariantMap mdst = vdst.toMap(); + mergeParameters(mdst, it.value().toMap()); + vdst = mdst; + } else { + dst[it.key()] = it.value(); + } + } +} + +static void adjustParametersScopes(Item *item, Item *scope) +{ + if (item->type() == ItemType::ModuleParameters) { + item->setScope(scope); + return; + } + + for (const auto &value : item->properties()) { + if (value->type() != Value::ItemValueType) + continue; + adjustParametersScopes(std::static_pointer_cast(value)->item(), scope); + } +} + +bool ModuleLoader::mergeExportItems(const ProductContext &productContext) +{ + std::vector exportItems; + QList children = productContext.item->children(); + + auto isExport = [](Item *item) { return item->type() == ItemType::Export; }; + std::copy_if(children.cbegin(), children.cend(), std::back_inserter(exportItems), isExport); + qbs::Internal::removeIf(children, isExport); + + // Note that we do not return if there are no Export items: The "merged" item becomes the + // "product module", which always needs to exist, regardless of whether the product sources + // actually contain an Export item or not. + if (!exportItems.empty()) + productContext.item->setChildren(children); + + Item *merged = Item::create(productContext.item->pool(), ItemType::Export); + const QString &nameKey = StringConstants::nameProperty(); + const ValuePtr nameValue = VariantValue::create(productContext.name); + merged->setProperty(nameKey, nameValue); + Set filesWithExportItem; + ProductModuleInfo pmi; + bool hasDependenciesOnProductType = false; + for (Item * const exportItem : qAsConst(exportItems)) { + checkCancelation(); + if (Q_UNLIKELY(filesWithExportItem.contains(exportItem->file()))) + throw ErrorInfo(Tr::tr("Multiple Export items in one product are prohibited."), + exportItem->location()); + exportItem->setProperty(nameKey, nameValue); + if (!checkExportItemCondition(exportItem, productContext)) + continue; + filesWithExportItem += exportItem->file(); + for (Item * const child : exportItem->children()) { + if (child->type() == ItemType::Parameters) { + adjustParametersScopes(child, child); + mergeParameters(pmi.defaultParameters, + m_evaluator->scriptValue(child).toVariant().toMap()); + } else { + if (child->type() == ItemType::Depends) { + bool productTypesIsSet; + m_evaluator->stringValue(child, StringConstants::productTypesProperty(), + QString(), &productTypesIsSet); + if (productTypesIsSet) + hasDependenciesOnProductType = true; + } + Item::addChild(merged, child); + } + } + const Item::PropertyDeclarationMap &decls = exportItem->propertyDeclarations(); + for (auto it = decls.constBegin(); it != decls.constEnd(); ++it) { + const PropertyDeclaration &newDecl = it.value(); + const PropertyDeclaration &existingDecl = merged->propertyDeclaration(it.key()); + if (existingDecl.isValid() && existingDecl.type() != newDecl.type()) { + ErrorInfo error(Tr::tr("Export item in inherited item redeclares property " + "'%1' with different type.").arg(it.key()), exportItem->location()); + handlePropertyError(error, m_parameters, m_logger); + } + merged->setPropertyDeclaration(newDecl.name(), newDecl); + } + for (QMap::const_iterator it = exportItem->properties().constBegin(); + it != exportItem->properties().constEnd(); ++it) { + mergeProperty(merged, it.key(), it.value()); + } + } + merged->setFile(exportItems.empty() + ? productContext.item->file() : exportItems.back()->file()); + merged->setLocation(exportItems.empty() + ? productContext.item->location() : exportItems.back()->location()); + Item::addChild(productContext.item, merged); + merged->setupForBuiltinType(m_logger); + pmi.exportItem = merged; + pmi.multiplexId = productContext.multiplexConfigurationId; + productContext.project->topLevelProject->productModules.insert(productContext.name, pmi); + if (hasDependenciesOnProductType) + m_exportsWithDeferredDependsItems.insert(merged); + return !exportItems.empty(); +} + +Item *ModuleLoader::loadItemFromFile(const QString &filePath, + const CodeLocation &referencingLocation) +{ + Item *item = m_reader->readFile(filePath, referencingLocation); + handleAllPropertyOptionsItems(item); + return item; +} + +void ModuleLoader::handleProfileItems(Item *item, ProjectContext *projectContext) +{ + const std::vector profileItems = collectProfileItems(item, projectContext); + for (Item * const profileItem : profileItems) { + try { + handleProfile(profileItem); + } catch (const ErrorInfo &e) { + handlePropertyError(e, m_parameters, m_logger); + } + } +} + +std::vector ModuleLoader::collectProfileItems(Item *item, ProjectContext *projectContext) +{ + QList childItems = item->children(); + std::vector profileItems; + Item * scope = item->type() == ItemType::Project ? projectContext->scope : nullptr; + for (auto it = childItems.begin(); it != childItems.end();) { + Item * const childItem = *it; + if (childItem->type() == ItemType::Profile) { + if (!scope) { + const ItemValuePtr itemValue = ItemValue::create(item); + scope = Item::create(m_pool, ItemType::Scope); + scope->setProperty(StringConstants::productVar(), itemValue); + scope->setFile(item->file()); + scope->setScope(projectContext->scope); + } + childItem->setScope(scope); + profileItems.push_back(childItem); + it = childItems.erase(it); + } else { + if (childItem->type() == ItemType::Product) { + for (Item * const profileItem : collectProfileItems(childItem, projectContext)) + profileItems.push_back(profileItem); + } + ++it; + } + } + if (!profileItems.empty()) + item->setChildren(childItems); + return profileItems; +} + +void ModuleLoader::evaluateProfileValues(const QualifiedId &namePrefix, Item *item, + Item *profileItem, QVariantMap &values) +{ + const Item::PropertyMap &props = item->properties(); + for (auto it = props.begin(); it != props.end(); ++it) { + QualifiedId name = namePrefix; + name << it.key(); + switch (it.value()->type()) { + case Value::ItemValueType: + evaluateProfileValues(name, std::static_pointer_cast(it.value())->item(), + profileItem, values); + break; + case Value::VariantValueType: + values.insert(name.join(QLatin1Char('.')), + std::static_pointer_cast(it.value())->value()); + break; + case Value::JSSourceValueType: + item->setType(ItemType::ModulePrefix); // TODO: Introduce new item type + if (item != profileItem) + item->setScope(profileItem); + values.insert(name.join(QLatin1Char('.')), + m_evaluator->value(item, it.key()).toVariant()); + break; + } + } +} + +void ModuleLoader::handleProfile(Item *profileItem) +{ + QVariantMap values; + evaluateProfileValues(QualifiedId(), profileItem, profileItem, values); + const bool condition = values.take(StringConstants::conditionProperty()).toBool(); + if (!condition) + return; + const QString profileName = values.take(StringConstants::nameProperty()).toString(); + if (profileName.isEmpty()) + throw ErrorInfo(Tr::tr("Every Profile item must have a name"), profileItem->location()); + if (profileName == Profile::fallbackName()) { + throw ErrorInfo(Tr::tr("Reserved name '%1' cannot be used for an actual profile.") + .arg(profileName), profileItem->location()); + } + if (m_localProfiles.contains(profileName)) { + throw ErrorInfo(Tr::tr("Local profile '%1' redefined.").arg(profileName), + profileItem->location()); + } + m_localProfiles.insert(profileName, values); +} + +void ModuleLoader::collectNameFromOverride(const QString &overrideString) +{ + static const auto extract = [](const QString &prefix, const QString &overrideString) { + if (!overrideString.startsWith(prefix)) + return QString(); + const int startPos = prefix.length(); + const int endPos = overrideString.lastIndexOf(StringConstants::dot()); + if (endPos == -1) + return QString(); + return overrideString.mid(startPos, endPos - startPos); + }; + const QString &projectName = extract(StringConstants::projectsOverridePrefix(), overrideString); + if (!projectName.isEmpty()) { + m_projectNamesUsedInOverrides.insert(projectName); + return; + } + const QString &productName = extract(StringConstants::productsOverridePrefix(), overrideString); + if (!productName.isEmpty()) { + m_productNamesUsedInOverrides.insert(productName.left( + productName.indexOf(StringConstants::dot()))); + return; + } +} + +void ModuleLoader::checkProjectNamesInOverrides(const ModuleLoader::TopLevelProjectContext &tlp) +{ + for (const QString &projectNameInOverride : m_projectNamesUsedInOverrides) { + if (m_disabledProjects.contains(projectNameInOverride)) + continue; + bool found = false; + for (const ProjectContext * const p : tlp.projects) { + if (p->name == projectNameInOverride) { + found = true; + break; + } + } + if (!found) { + handlePropertyError(Tr::tr("Unknown project '%1' in property override.") + .arg(projectNameInOverride), m_parameters, m_logger); + } + } +} + +void ModuleLoader::checkProductNamesInOverrides() +{ + for (const QString &productNameInOverride : m_productNamesUsedInOverrides) { + if (m_erroneousProducts.contains(productNameInOverride)) + continue; + bool found = false; + for (const auto &kv : m_productsByName) { + // In an override string such as "a.b.c:d, we cannot tell whether we have a product + // "a" and a module "b.c" or a product "a.b" and a module "c", so we need to take + // care not to emit false positives here. + if (kv.first == productNameInOverride + || kv.first.startsWith(productNameInOverride + StringConstants::dot())) { + found = true; + break; + } + } + if (!found) { + handlePropertyError(Tr::tr("Unknown product '%1' in property override.") + .arg(productNameInOverride), m_parameters, m_logger); + } + } +} + +void ModuleLoader::setSearchPathsForProduct(ModuleLoader::ProductContext *product) +{ + product->searchPaths = readExtraSearchPaths(product->item); + Settings settings(m_parameters.settingsDirectory()); + const QVariantMap profileContents = product->project->result->profileConfigs + .value(product->profileName).toMap(); + const QStringList prefsSearchPaths = Preferences(&settings, profileContents).searchPaths(); + const QStringList ¤tSearchPaths = m_reader->allSearchPaths(); + for (const QString &p : prefsSearchPaths) { + if (!currentSearchPaths.contains(p) && FileInfo(p).exists()) + product->searchPaths << p; + } +} + +ModuleLoader::ShadowProductInfo ModuleLoader::getShadowProductInfo( + const ModuleLoader::ProductContext &product) const +{ + const bool isShadowProduct = product.name.startsWith(StringConstants::shadowProductPrefix()); + return std::make_pair(isShadowProduct, isShadowProduct + ? product.name.mid(StringConstants::shadowProductPrefix().size()) + : QString()); +} + +void ModuleLoader::collectProductsByName(const TopLevelProjectContext &topLevelProject) +{ + for (ProjectContext * const project : topLevelProject.projects) { + for (ProductContext &product : project->products) + m_productsByName.insert({ product.name, &product }); + } +} + +void ModuleLoader::collectProductsByType(const ModuleLoader::TopLevelProjectContext &topLevelProject) +{ + for (ProjectContext * const project : topLevelProject.projects) { + for (ProductContext &product : project->products) { + try { + const FileTags productTags + = m_evaluator->fileTagsValue(product.item, StringConstants::typeProperty()); + for (const FileTag &tag : productTags) + m_productsByType.insert({ tag, &product}); + } catch (const ErrorInfo &) { + qCDebug(lcModuleLoader) << "product" << product.name << "has complex type " + " and won't get an entry in the type map"; + } + } + } +} + +void ModuleLoader::propagateModulesFromParent(ProductContext *productContext, Item *groupItem, + const ModuleDependencies &reverseDepencencies) +{ + QBS_CHECK(groupItem->type() == ItemType::Group); + QHash moduleInstancesForGroup; + + // Step 1: Instantiate the product's modules for the group. + for (Item::Module m : groupItem->parent()->modules()) { + Item *targetItem = moduleInstanceItem(groupItem, m.name); + targetItem->setPrototype(m.item); + + Item * const moduleScope = Item::create(targetItem->pool(), ItemType::Scope); + moduleScope->setFile(groupItem->file()); + moduleScope->setProperties(m.item->scope()->properties()); // "project", "product", ids + moduleScope->setScope(groupItem); + targetItem->setScope(moduleScope); + + targetItem->setFile(m.item->file()); + + // "parent" should point to the group/artifact parent + targetItem->setParent(groupItem->parent()); + + targetItem->setOuterItem(m.item); + + m.item = targetItem; + groupItem->addModule(m); + moduleInstancesForGroup.insert(m.name, targetItem); + } + + // Step 2: Make the inter-module references point to the instances created in step 1. + for (const Item::Module &module : groupItem->modules()) { + Item::Modules adaptedModules; + const Item::Modules &oldModules = module.item->prototype()->modules(); + for (Item::Module depMod : oldModules) { + depMod.item = moduleInstancesForGroup.value(depMod.name); + adaptedModules << depMod; + if (depMod.name.front() == module.name.front()) + continue; + const ItemValuePtr &modulePrefix = groupItem->itemProperty(depMod.name.front()); + QBS_CHECK(modulePrefix); + module.item->setProperty(depMod.name.front(), modulePrefix); + } + module.item->setModules(adaptedModules); + } + + const QualifiedIdSet &propsSetInGroup = gatherModulePropertiesSetInGroup(groupItem); + if (propsSetInGroup.empty()) + return; + productContext->info.modulePropertiesSetInGroups + .insert(std::make_pair(groupItem, propsSetInGroup)); + + // Step 3: Adapt defining items in values. This is potentially necessary if module properties + // get assigned on the group level. + for (const Item::Module &module : groupItem->modules()) { + const QualifiedIdSet &dependents = reverseDepencencies.value(module.name); + Item::Modules dependentModules; + dependentModules.reserve(int(dependents.size())); + for (const QualifiedId &depName : dependents) { + Item * const itemOfDependent = moduleInstancesForGroup.value(depName); + QBS_CHECK(itemOfDependent); + Item::Module depMod; + depMod.name = depName; + depMod.item = itemOfDependent; + dependentModules << depMod; + } + adjustDefiningItemsInGroupModuleInstances(module, dependentModules); + } +} + +static Item *createReplacementForDefiningItem(const Item *definingItem, ItemType type) +{ + Item *replacement = Item::create(definingItem->pool(), type); + replacement->setLocation(definingItem->location()); + definingItem->copyProperty(StringConstants::nameProperty(), replacement); + return replacement; +} + +void ModuleLoader::adjustDefiningItemsInGroupModuleInstances(const Item::Module &module, + const Item::Modules &dependentModules) +{ + if (!module.item->isPresentModule()) + return; + + // There are three cases: + // a) The defining item is the "main" module instance, i.e. the one instantiated in the + // product directly (or a parent group). + // b) The defining item refers to the module prototype (or the replacement of it + // created in the module merger [for products] or in this function [for parent groups]). + // c) The defining item is a different instance of the module, i.e. it was instantiated + // in some other module. + + std::unordered_map definingItemReplacements; + + Item *modulePrototype = rootPrototype(module.item->prototype()); + QBS_CHECK(modulePrototype->type() == ItemType::Module + || modulePrototype->type() == ItemType::Export); + + const Item::PropertyDeclarationMap &propDecls = modulePrototype->propertyDeclarations(); + for (const auto &decl : propDecls) { + const QString &propName = decl.name(); + + // Module properties assigned in the group are not relevant here, as nothing + // gets inherited in that case. In particular, setting a list property + // overwrites the value from the product's (or parent group's) instance completely, + // rather than appending to it (concatenation happens via outer.concat()). + ValueConstPtr propValue = module.item->ownProperty(propName); + if (propValue) + continue; + + // Find the nearest prototype instance that has the value assigned. + // The result is either an instance of a parent group (or the parent group's + // parent group and so on) or the instance of the product or the module prototype. + // In the latter case, we don't have to do anything. + const Item *instanceWithProperty = module.item; + int prototypeChainLen = 0; + do { + instanceWithProperty = instanceWithProperty->prototype(); + QBS_CHECK(instanceWithProperty); + ++prototypeChainLen; + propValue = instanceWithProperty->ownProperty(propName); + } while (!propValue); + QBS_CHECK(propValue); + + if (propValue->type() != Value::JSSourceValueType) + continue; + + bool hasDefiningItem = false; + for (ValueConstPtr v = propValue; v && !hasDefiningItem; v = v->next()) + hasDefiningItem = v->definingItem(); + if (!hasDefiningItem) + continue; + + const ValuePtr clonedValue = propValue->clone(); + for (ValuePtr v = clonedValue; v; v = v->next()) { + QBS_CHECK(v->definingItem()); + + Item *& replacement = definingItemReplacements[v->definingItem()]; + static const QString caseA = QStringLiteral("__group_case_a"); + if (v->definingItem() == instanceWithProperty + || v->definingItem()->variantProperty(caseA)) { + // Case a) + // For values whose defining item is the product's (or parent group's) instance, + // we take its scope and replace references to module instances with those from the + // group's instance. This handles cases like the following: + // Product { + // name: "theProduct" + // aModule.listProp: [name, otherModule.stringProp] + // Group { name: "theGroup"; otherModule.stringProp: name } + // ... + // } + // In the above example, aModule.listProp is set to ["theProduct", "theGroup"] + // (plus potential values from the prototype and other module instances, + // which are different Value objects in the "next chain"). + if (!replacement) { + replacement = createReplacementForDefiningItem(v->definingItem(), + v->definingItem()->type()); + Item * const scope = Item::create(v->definingItem()->pool(), ItemType::Scope); + scope->setProperties(module.item->scope()->properties()); + Item * const scopeScope + = Item::create(v->definingItem()->pool(), ItemType::Scope); + scopeScope->setProperties(v->definingItem()->scope()->scope()->properties()); + scope->setScope(scopeScope); + replacement->setScope(scope); + const Item::PropertyMap &groupScopeProperties + = module.item->scope()->scope()->properties(); + for (auto propIt = groupScopeProperties.begin(); + propIt != groupScopeProperties.end(); ++propIt) { + if (propIt.value()->type() == Value::ItemValueType) + scopeScope->setProperty(propIt.key(), propIt.value()); + } + } + replacement->setPropertyDeclaration(propName, decl); + replacement->setProperty(propName, v); + replacement->setProperty(caseA, VariantValue::invalidValue()); + } else if (v->definingItem()->type() == ItemType::Module) { + // Case b) + // For values whose defining item is the module prototype, we change the scope to + // the group's instance, analogous to what we do in + // ModuleMerger::appendPrototypeValueToNextChain(). + QBS_CHECK(!decl.isScalar()); + QBS_CHECK(!v->next()); + Item *& replacement = definingItemReplacements[v->definingItem()]; + if (!replacement) { + replacement = createReplacementForDefiningItem(v->definingItem(), + ItemType::Module); + replacement->setScope(module.item); + } + QBS_CHECK(!replacement->hasOwnProperty(caseA)); + qCDebug(lcModuleLoader).noquote().nospace() + << "replacing defining item for prototype; module is " + << module.name.toString() << module.item + << ", property is " << propName + << ", old defining item was " << v->definingItem() + << " with scope" << v->definingItem()->scope() + << ", new defining item is" << replacement + << " with scope" << replacement->scope(); + if (v->type() == Value::JSSourceValueType) { + qCDebug(lcModuleLoader) << "value source code is" + << std::static_pointer_cast(v)->sourceCode().toString(); + } + replacement->setPropertyDeclaration(propName, decl); + replacement->setProperty(propName, v); + } else { + // Look for instance scopes of other module instances in defining items and + // replace the affected values. + // This is case c) as introduced above. See ModuleMerger::replaceItemInScopes() + // for a detailed explanation. + + QBS_CHECK(v->definingItem()->scope() && v->definingItem()->scope()->scope()); + bool found = false; + for (const Item::Module &depMod : dependentModules) { + const Item *depModPrototype = depMod.item->prototype(); + for (int i = 1; i < prototypeChainLen; ++i) + depModPrototype = depModPrototype->prototype(); + if (v->definingItem()->scope()->scope() != depModPrototype) + continue; + + found = true; + Item *& replacement = definingItemReplacements[v->definingItem()]; + if (!replacement) { + replacement = createReplacementForDefiningItem(v->definingItem(), + v->definingItem()->type()); + replacement->setProperties(v->definingItem()->properties()); + for (const auto &decl : v->definingItem()->propertyDeclarations()) + replacement->setPropertyDeclaration(decl.name(), decl); + replacement->setPrototype(v->definingItem()->prototype()); + replacement->setScope(Item::create(v->definingItem()->pool(), + ItemType::Scope)); + replacement->scope()->setScope(depMod.item); + } + QBS_CHECK(!replacement->hasOwnProperty(caseA)); + qCDebug(lcModuleLoader) << "reset instance scope of module" + << depMod.name.toString() << "in property" + << propName << "of module" << module.name; + } + QBS_CHECK(found); + } + QBS_CHECK(replacement); + v->setDefiningItem(replacement); + } + module.item->setProperty(propName, clonedValue); + } +} + +void ModuleLoader::resolveDependencies(DependsContext *dependsContext, Item *item, + ProductContext *productContext) +{ + QBS_CHECK(m_dependencyResolvingPass == 1 || m_dependencyResolvingPass == 2); + + if (!productContext || m_dependencyResolvingPass == 1) { + const Item::Module baseModule = loadBaseModule(dependsContext->product, item); + item->addModule(baseModule); + } + + // Resolve all Depends items. + ItemModuleList loadedModules; + QList dependsItemPerLoadedModule; + ProductDependencies productDependencies; + const auto handleDependsItem = [&](Item *child) { + if (child->type() != ItemType::Depends) + return; + + int lastModulesCount = loadedModules.size(); + try { + resolveDependsItem(dependsContext, child->parent(), child, &loadedModules, + &productDependencies); + } catch (const ErrorInfo &e) { + if (!productContext) + throw; + handleProductError(e, productContext); + } + for (int i = lastModulesCount; i < loadedModules.size(); ++i) + dependsItemPerLoadedModule.push_back(child); + + }; + if (productContext && m_dependencyResolvingPass == 2) { + for (const auto &deferData : productContext->deferredDependsItems) { + dependsContext->exportingProductItem = deferData.first; + for (Item * const dependsItem : deferData.second) + handleDependsItem(dependsItem); + } + } else { + for (Item * const child : item->children()) + handleDependsItem(child); + } + QBS_CHECK(loadedModules.size() == dependsItemPerLoadedModule.size()); + + Item *lastDependsItem = nullptr; + for (Item * const dependsItem : dependsItemPerLoadedModule) { + if (dependsItem == lastDependsItem) + continue; + adjustParametersScopes(dependsItem, dependsItem); + forwardParameterDeclarations(dependsItem, loadedModules); + lastDependsItem = dependsItem; + } + + for (int i = 0; i < loadedModules.size(); ++i) { + Item::Module &module = loadedModules[i]; + mergeParameters(module.parameters, extractParameters(dependsItemPerLoadedModule.at(i))); + item->addModule(module); + + const QString moduleName = module.name.toString(); + std::for_each(productDependencies.begin(), productDependencies.end(), + [&module, &moduleName] (ModuleLoaderResult::ProductInfo::Dependency &dep) { + if (dep.name == moduleName) + dep.parameters = module.parameters; + }); + } + + dependsContext->productDependencies->insert( + dependsContext->productDependencies->end(), + productDependencies.cbegin(), productDependencies.cend()); +} + +class RequiredChainManager +{ +public: + RequiredChainManager(std::vector &requiredChain, bool required) + : m_requiredChain(requiredChain) + { + m_requiredChain.push_back(required); + } + + ~RequiredChainManager() { m_requiredChain.pop_back(); } + +private: + std::vector &m_requiredChain; +}; + +void ModuleLoader::resolveDependsItem(DependsContext *dependsContext, Item *parentItem, + Item *dependsItem, ItemModuleList *moduleResults, + ProductDependencies *productResults) +{ + checkCancelation(); + if (!checkItemCondition(dependsItem)) { + qCDebug(lcModuleLoader) << "Depends item disabled, ignoring."; + return; + } + bool nameIsSet; + const QString name = m_evaluator->stringValue(dependsItem, StringConstants::nameProperty(), + QString(), &nameIsSet); + bool submodulesPropertySet; + const QStringList submodules = m_evaluator->stringListValue( + dependsItem, StringConstants::submodulesProperty(), &submodulesPropertySet); + if (submodules.empty() && submodulesPropertySet) { + qCDebug(lcModuleLoader) << "Ignoring Depends item with empty submodules list."; + return; + } + if (Q_UNLIKELY(submodules.size() > 1 && !dependsItem->id().isEmpty())) { + QString msg = Tr::tr("A Depends item with more than one module cannot have an id."); + throw ErrorInfo(msg, dependsItem->location()); + } + const FallbackMode fallbackMode = m_parameters.fallbackProviderEnabled() + && m_evaluator->boolValue(dependsItem, StringConstants::enableFallbackProperty()) + ? FallbackMode::Enabled : FallbackMode::Disabled; + + QList moduleNames; + const QualifiedId nameParts = QualifiedId::fromString(name); + if (submodules.empty()) { + // Ignore explicit dependencies on the base module, which has already been loaded. + if (name == StringConstants::qbsModule()) + return; + + moduleNames << nameParts; + } else { + for (const QString &submodule : submodules) + moduleNames << nameParts + QualifiedId::fromString(submodule); + } + + Item::Module result; + bool productTypesIsSet; + m_evaluator->stringValue(dependsItem, StringConstants::productTypesProperty(), + QString(), &productTypesIsSet); + if (m_dependencyResolvingPass == 1 && productTypesIsSet) { + qCDebug(lcModuleLoader) << "queuing product" << dependsContext->product->name + << "for a second dependencies resolving pass"; + m_productsWithDeferredDependsItems[dependsContext->product].insert( + DeferredDependsContext(dependsContext->exportingProductItem, parentItem)); + return; + } + + const bool isRequiredValue = + m_evaluator->boolValue(dependsItem, StringConstants::requiredProperty()); + const bool isRequired = !productTypesIsSet + && isRequiredValue + && !contains(m_requiredChain, false); + const Version minVersion = Version::fromString( + m_evaluator->stringValue(dependsItem, + StringConstants::versionAtLeastProperty())); + const Version maxVersion = Version::fromString( + m_evaluator->stringValue(dependsItem, StringConstants::versionBelowProperty())); + const VersionRange versionRange(minVersion, maxVersion); + QStringList multiplexConfigurationIds = m_evaluator->stringListValue( + dependsItem, + StringConstants::multiplexConfigurationIdsProperty()); + if (multiplexConfigurationIds.empty()) + multiplexConfigurationIds << QString(); + + for (const QualifiedId &moduleName : qAsConst(moduleNames)) { + // Don't load the same module twice. Duplicate Depends statements can easily + // happen due to inheritance. + const auto it = std::find_if(moduleResults->begin(), moduleResults->end(), + [moduleName](const Item::Module &m) { return m.name == moduleName; }); + if (it != moduleResults->end()) { + it->required = it->required || isRequired; + it->requiredValue = it->requiredValue || isRequiredValue; + it->fallbackEnabled = it->fallbackEnabled && fallbackMode == FallbackMode::Enabled; + it->versionRange.narrowDown(versionRange); + continue; + } + + QVariantMap defaultParameters; + Item *moduleItem = loadModule(dependsContext->product, dependsContext->exportingProductItem, + parentItem, dependsItem->location(), dependsItem->id(), + moduleName, multiplexConfigurationIds.first(), fallbackMode, + isRequired, &result.isProduct, &defaultParameters); + if (!moduleItem) { + const QString productName = ResolvedProduct::fullDisplayName( + dependsContext->product->name, + dependsContext->product->multiplexConfigurationId); + if (!multiplexConfigurationIds.first().isEmpty()) { + const QString depName = ResolvedProduct::fullDisplayName( + moduleName.toString(), multiplexConfigurationIds.first()); + throw ErrorInfo(Tr::tr("Dependency from product '%1' to product '%2' not " + "fulfilled.").arg(productName, depName)); + } + ErrorInfo e(Tr::tr("Dependency '%1' not found for product '%2'.") + .arg(moduleName.toString(), productName), dependsItem->location()); + throw e; + } + if (result.isProduct && !m_dependsChain.empty() && !m_dependsChain.back().isProduct) { + throw ErrorInfo(Tr::tr("Invalid dependency on product '%1': Modules cannot depend on " + "products. You may want to turn your module into a product and " + "add the dependency in that product's Export item.") + .arg(moduleName.toString()), dependsItem->location()); + } + qCDebug(lcModuleLoader) << "module loaded:" << moduleName.toString(); + result.name = moduleName; + result.item = moduleItem; + result.requiredValue = isRequiredValue; + result.required = isRequired; + result.fallbackEnabled = fallbackMode == FallbackMode::Enabled; + result.parameters = defaultParameters; + result.versionRange = versionRange; + moduleResults->push_back(result); + if (result.isProduct) { + qCDebug(lcModuleLoader) << "product dependency loaded:" << moduleName.toString(); + bool profilesPropertyWasSet = false; + QStringList profiles = m_evaluator->stringListValue(dependsItem, + StringConstants::profilesProperty(), + &profilesPropertyWasSet); + if (profiles.empty()) { + if (profilesPropertyWasSet) + profiles.push_back(StringConstants::star()); + else + profiles.push_back(QString()); + } + for (const QString &profile : qAsConst(profiles)) { + for (const QString &multiplexId : qAsConst(multiplexConfigurationIds)) { + ModuleLoaderResult::ProductInfo::Dependency dependency; + dependency.name = moduleName.toString(); + dependency.profile = profile; + dependency.multiplexConfigurationId = multiplexId; + dependency.isRequired = isRequired; + productResults->push_back(dependency); + } + } + } + } +} + +void ModuleLoader::forwardParameterDeclarations(const Item *dependsItem, + const ItemModuleList &modules) +{ + for (auto it = dependsItem->properties().begin(); it != dependsItem->properties().end(); ++it) { + if (it.value()->type() != Value::ItemValueType) + continue; + forwardParameterDeclarations(it.key(), + std::static_pointer_cast(it.value())->item(), + modules); + } +} + +void ModuleLoader::forwardParameterDeclarations(const QualifiedId &moduleName, Item *item, + const ItemModuleList &modules) +{ + auto it = std::find_if(modules.begin(), modules.end(), [&moduleName] (const Item::Module &m) { + return m.name == moduleName; + }); + if (it != modules.end()) { + item->setPropertyDeclarations(m_parameterDeclarations.value(rootPrototype(it->item))); + } else { + for (auto it = item->properties().begin(); it != item->properties().end(); ++it) { + if (it.value()->type() != Value::ItemValueType) + continue; + forwardParameterDeclarations(QualifiedId(moduleName) << it.key(), + std::static_pointer_cast(it.value())->item(), + modules); + } + } +} + +void ModuleLoader::resolveParameterDeclarations(const Item *module) +{ + Item::PropertyDeclarationMap decls; + const auto &moduleChildren = module->children(); + for (Item *param : moduleChildren) { + if (param->type() != ItemType::Parameter) + continue; + const auto ¶mDecls = param->propertyDeclarations(); + for (auto it = paramDecls.begin(); it != paramDecls.end(); ++it) + decls.insert(it.key(), it.value()); + } + m_parameterDeclarations.insert(module, decls); +} + +static bool isItemValue(const ValuePtr &v) +{ + return v->type() == Value::ItemValueType; +} + +static Item::PropertyMap filterItemProperties(const Item::PropertyMap &properties) +{ + Item::PropertyMap result; + auto itEnd = properties.end(); + for (auto it = properties.begin(); it != itEnd; ++it) { + if (isItemValue(it.value())) + result.insert(it.key(), it.value()); + } + return result; +} + +static QVariantMap safeToVariant(const QScriptValue &v) +{ + QVariantMap result; + QScriptValueIterator it(v); + while (it.hasNext()) { + it.next(); + QScriptValue u = it.value(); + if (u.isError()) + throw ErrorInfo(u.toString()); + result[it.name()] = (u.isObject() && !u.isArray() && !u.isRegExp()) + ? safeToVariant(u) : it.value().toVariant(); + } + return result; +} + +QVariantMap ModuleLoader::extractParameters(Item *dependsItem) const +{ + QVariantMap result; + const Item::PropertyMap &itemProperties = filterItemProperties( + rootPrototype(dependsItem)->properties()); + if (itemProperties.empty()) + return result; + + auto origProperties = dependsItem->properties(); + dependsItem->setProperties(itemProperties); + QScriptValue sv = m_evaluator->scriptValue(dependsItem); + try { + result = safeToVariant(sv); + } catch (const ErrorInfo &exception) { + auto ei = exception; + ei.prepend(Tr::tr("Error in dependency parameter."), dependsItem->location()); + throw ei; + } + dependsItem->setProperties(origProperties); + return result; +} + +[[noreturn]] static void throwModuleNamePrefixError(const QualifiedId &shortName, + const QualifiedId &longName, const CodeLocation &codeLocation) +{ + throw ErrorInfo(Tr::tr("The name of module '%1' is equal to the first component of the " + "name of module '%2', which is not allowed") + .arg(shortName.toString(), longName.toString()), codeLocation); +} + +Item *ModuleLoader::moduleInstanceItem(Item *containerItem, const QualifiedId &moduleName) +{ + QBS_CHECK(!moduleName.empty()); + Item *instance = containerItem; + for (int i = 0; i < moduleName.size(); ++i) { + const QString &moduleNameSegment = moduleName.at(i); + const ValuePtr v = instance->ownProperty(moduleName.at(i)); + if (v && v->type() == Value::ItemValueType) { + instance = std::static_pointer_cast(v)->item(); + } else { + const ItemType itemType = i < moduleName.size() - 1 ? ItemType::ModulePrefix + : ItemType::ModuleInstance; + auto newItem = Item::create(m_pool, itemType); + instance->setProperty(moduleNameSegment, ItemValue::create(newItem)); + instance = newItem; + } + if (i < moduleName.size() - 1) { + if (instance->type() == ItemType::ModuleInstance) { + QualifiedId conflictingName = QStringList(moduleName.mid(0, i + 1)); + throwModuleNamePrefixError(conflictingName, moduleName, CodeLocation()); + } + QBS_CHECK(instance->type() == ItemType::ModulePrefix); + } + } + QBS_CHECK(instance != containerItem); + return instance; +} + +ModuleLoader::ProductModuleInfo *ModuleLoader::productModule(ProductContext *productContext, + const QString &name, const QString &multiplexId, bool &productNameMatch) +{ + auto &exportsData = productContext->project->topLevelProject->productModules; + const auto firstIt = exportsData.find(name); + productNameMatch = firstIt != exportsData.end(); + for (auto it = firstIt; it != exportsData.end() && it.key() == name; ++it) { + if (it.value().multiplexId == multiplexId) + return &it.value(); + } + if (multiplexId.isEmpty() && firstIt != exportsData.end()) + return &firstIt.value(); + return nullptr; +} + +ModuleLoader::ProductContext *ModuleLoader::product(ProjectContext *projectContext, + const QString &name) +{ + auto itEnd = projectContext->products.end(); + auto it = std::find_if(projectContext->products.begin(), itEnd, + [&name] (const ProductContext &ctx) { + return ctx.name == name; + }); + return it == itEnd ? nullptr : &*it; +} + +ModuleLoader::ProductContext *ModuleLoader::product(TopLevelProjectContext *tlpContext, + const QString &name) +{ + ProductContext *result = nullptr; + for (auto prj : tlpContext->projects) { + result = product(prj, name); + if (result) + break; + } + return result; +} + +class ModuleLoader::DependsChainManager +{ +public: + DependsChainManager(std::vector &dependsChain, const QualifiedId &module, + const CodeLocation &dependsLocation) + : m_dependsChain(dependsChain) + { + const bool alreadyInChain = Internal::any_of(dependsChain, + [&module](const DependsChainEntry &e) { + return e.name == module; + }); + if (alreadyInChain) { + ErrorInfo error; + error.append(Tr::tr("Cyclic dependencies detected:")); + for (const DependsChainEntry &e : qAsConst(m_dependsChain)) + error.append(e.name.toString(), e.location); + error.append(module.toString(), dependsLocation); + throw error; + } + m_dependsChain.emplace_back(module, dependsLocation); + } + + ~DependsChainManager() { m_dependsChain.pop_back(); } + +private: + std::vector &m_dependsChain; +}; + +static bool isBaseModule(QStringView fullModuleName) +{ + return fullModuleName == StringConstants::qbsModule(); +} + +class DelayedPropertyChanger +{ +public: + ~DelayedPropertyChanger() + { + applyNow(); + } + + void setLater(Item *item, const QString &name, const ValuePtr &value) + { + QBS_CHECK(m_item == nullptr); + m_item = item; + m_name = name; + m_value = value; + } + + void removeLater(Item *item, const QString &name) + { + QBS_CHECK(m_item == nullptr); + m_item = item; + m_name = name; + } + + void applyNow() + { + if (!m_item || m_name.isEmpty()) + return; + if (m_value) + m_item->setProperty(m_name, m_value); + else + m_item->removeProperty(m_name); + m_item = nullptr; + m_name.clear(); + m_value.reset(); + } + +private: + Item *m_item = nullptr; + QString m_name; + ValuePtr m_value; +}; + +Item *ModuleLoader::loadModule(ProductContext *productContext, Item *exportingProductItem, + Item *item, const CodeLocation &dependsItemLocation, + const QString &moduleId, const QualifiedId &moduleName, + const QString &multiplexId, FallbackMode fallbackMode, + bool isRequired, bool *isProductDependency, + QVariantMap *defaultParameters) +{ + qCDebug(lcModuleLoader) << "loadModule name:" << moduleName.toString() << "id:" << moduleId; + + RequiredChainManager requiredChainManager(m_requiredChain, isRequired); + DependsChainManager dependsChainManager(m_dependsChain, moduleName, dependsItemLocation); + + Item *moduleInstance = moduleId.isEmpty() + ? moduleInstanceItem(item, moduleName) + : moduleInstanceItem(item, QStringList(moduleId)); + if (moduleInstance->scope()) + return moduleInstance; // already handled + + if (Q_UNLIKELY(moduleInstance->type() == ItemType::ModulePrefix)) { + for (const Item::Module &m : item->modules()) { + if (m.name.front() == moduleName.front()) + throwModuleNamePrefixError(moduleName, m.name, dependsItemLocation); + } + } + QBS_CHECK(moduleInstance->type() == ItemType::ModuleInstance); + + // Prepare module instance for evaluating Module.condition. + DelayedPropertyChanger delayedPropertyChanger; + const QString &qbsModuleName = StringConstants::qbsModule(); + const auto fullName = moduleName.toString(); + if (!isBaseModule(fullName)) { + ItemValuePtr qbsProp = productContext->item->itemProperty(qbsModuleName); + if (qbsProp) { + ValuePtr qbsModuleValue = moduleInstance->ownProperty(qbsModuleName); + if (qbsModuleValue) + delayedPropertyChanger.setLater(moduleInstance, qbsModuleName, qbsModuleValue); + else + delayedPropertyChanger.removeLater(moduleInstance, qbsModuleName); + moduleInstance->setProperty(qbsModuleName, qbsProp); + } + } + + SearchPathsManager searchPathsManager(m_reader.get()); // paths can be added by providers + Item *modulePrototype = nullptr; + ProductModuleInfo * const pmi = productModule(productContext, fullName, + multiplexId, *isProductDependency); + if (pmi) { + m_dependsChain.back().isProduct = true; + modulePrototype = pmi->exportItem; + if (defaultParameters) + *defaultParameters = pmi->defaultParameters; + } else if (!*isProductDependency) { + modulePrototype = searchAndLoadModuleFile(productContext, dependsItemLocation, + moduleName, fallbackMode, isRequired, moduleInstance); + } + delayedPropertyChanger.applyNow(); + if (!modulePrototype) + return nullptr; + + searchPathsManager.reset(); // deps must be processed in a clean state + + instantiateModule(productContext, exportingProductItem, item, moduleInstance, modulePrototype, + moduleName, pmi); + return moduleInstance; +} + +struct PrioritizedItem +{ + PrioritizedItem(Item *item, int priority, int searchPathIndex) + : item(item), priority(priority), searchPathIndex(searchPathIndex) + { + } + + Item *item = nullptr; + int priority = 0; + int searchPathIndex = 0; +}; + +static Item *chooseModuleCandidate(const std::vector &candidates, + const QString &moduleName) +{ + auto maxIt = std::max_element(candidates.begin(), candidates.end(), + [] (const PrioritizedItem &a, const PrioritizedItem &b) { + if (a.priority < b.priority) + return true; + if (a.priority > b.priority) + return false; + return a.searchPathIndex > b.searchPathIndex; + }); + + size_t nmax = std::count_if(candidates.begin(), candidates.end(), + [maxIt] (const PrioritizedItem &i) { + return i.priority == maxIt->priority && i.searchPathIndex == maxIt->searchPathIndex; + }); + + if (nmax > 1) { + ErrorInfo e(Tr::tr("There is more than one equally prioritized candidate for module '%1'.") + .arg(moduleName)); + for (size_t i = 0; i < candidates.size(); ++i) { + const auto candidate = candidates.at(i); + if (candidate.priority == maxIt->priority) { + //: The %1 denotes the number of the candidate. + e.append(Tr::tr("candidate %1").arg(i + 1), candidates.at(i).item->location()); + } + } + throw e; + } + + return maxIt->item; +} + +Item *ModuleLoader::searchAndLoadModuleFile(ProductContext *productContext, + const CodeLocation &dependsItemLocation, const QualifiedId &moduleName, + FallbackMode fallbackMode, bool isRequired, Item *moduleInstance) +{ + auto existingPaths = findExistingModulePaths(m_reader->allSearchPaths(), moduleName); + + if (existingPaths.isEmpty()) { // no suitable names found, try to use providers + AccumulatingTimer providersTimer( + m_parameters.logElapsedTime() ? &m_elapsedTimeModuleProviders : nullptr); + auto result = m_moduleProviderLoader->executeModuleProvider( + *productContext, + dependsItemLocation, + moduleName, + fallbackMode); + if (result.providerAddedSearchPaths) { + qCDebug(lcModuleLoader) << "Re-checking for module" << moduleName.toString() + << "with newly added search paths from module provider"; + existingPaths = findExistingModulePaths(m_reader->allSearchPaths(), moduleName); + } + } + + const QString fullName = moduleName.toString(); + bool triedToLoadModule = false; + std::vector candidates; + candidates.reserve(size_t(existingPaths.size())); + for (int i = 0; i < existingPaths.size(); ++i) { + const QString &dirPath = existingPaths.at(i); + QStringList &moduleFileNames = getModuleFileNames(dirPath); + for (auto it = moduleFileNames.begin(); it != moduleFileNames.end(); ) { + const QString &filePath = *it; + const auto [module, triedToLoad] = loadModuleFile( + productContext, fullName, filePath, moduleInstance); + if (module) + candidates.emplace_back(module, 0, i); + if (!triedToLoad) + it = moduleFileNames.erase(it); + else + ++it; + triedToLoadModule = triedToLoadModule || triedToLoad; + } + } + + if (candidates.empty()) { + if (!isRequired) + return createNonPresentModule(fullName, QStringLiteral("not found"), nullptr); + if (Q_UNLIKELY(triedToLoadModule)) { + throw ErrorInfo(Tr::tr("Module %1 could not be loaded.").arg(fullName), + dependsItemLocation); + } + return nullptr; + } + + Item *moduleItem; + if (candidates.size() == 1) { + moduleItem = candidates.at(0).item; + } else { + for (auto &candidate : candidates) { + candidate.priority = m_evaluator->intValue(candidate.item, + StringConstants::priorityProperty(), + candidate.priority); + } + moduleItem = chooseModuleCandidate(candidates, fullName); + } + + const auto it = productContext->unknownProfilePropertyErrors.find(moduleItem); + if (it != productContext->unknownProfilePropertyErrors.cend()) { + const QString fullProductName = ResolvedProduct::fullDisplayName + (productContext->name, productContext->multiplexConfigurationId); + ErrorInfo error(Tr::tr("Loading module '%1' for product '%2' failed due to invalid values " + "in profile '%3':").arg(fullName, fullProductName, + productContext->profileName)); + for (const ErrorInfo &e : it->second) + error.append(e.toString()); + handlePropertyError(error, m_parameters, m_logger); + } + return moduleItem; +} + +QStringList &ModuleLoader::getModuleFileNames(const QString &dirPath) +{ + QStringList &moduleFileNames = m_moduleDirListCache[dirPath]; + if (moduleFileNames.empty()) { + QDirIterator dirIter(dirPath, StringConstants::qbsFileWildcards()); + while (dirIter.hasNext()) + moduleFileNames += dirIter.next(); + } + return moduleFileNames; +} + +static Item *findDeepestModuleInstance(Item *instance) +{ + while (instance->prototype() && instance->prototype()->type() == ItemType::ModuleInstance) + instance = instance->prototype(); + return instance; +} + +std::pair ModuleLoader::loadModuleFile( + ProductContext *productContext, const QString &fullModuleName, + const QString &filePath, Item *moduleInstance) +{ + checkCancelation(); + + qCDebug(lcModuleLoader) << "loadModuleFile" << fullModuleName << "from" << filePath; + + const auto [module, triedToLoad] = + getModulePrototype(productContext, fullModuleName, filePath); + if (!module) + return {nullptr, triedToLoad}; + + const auto key = std::make_pair(module, productContext); + const auto it = m_modulePrototypeEnabledInfo.find(key); + if (it != m_modulePrototypeEnabledInfo.end()) { + qCDebug(lcModuleLoader) << "prototype cache hit (level 2)"; + return {it.value() ? module : nullptr, triedToLoad}; + } + + // Set the name before evaluating any properties. EvaluatorScriptClass reads the module name. + module->setProperty(StringConstants::nameProperty(), VariantValue::create(fullModuleName)); + + Item *deepestModuleInstance = findDeepestModuleInstance(moduleInstance); + Item *origDeepestModuleInstancePrototype = deepestModuleInstance->prototype(); + deepestModuleInstance->setPrototype(module); + bool enabled = checkItemCondition(moduleInstance, module); + deepestModuleInstance->setPrototype(origDeepestModuleInstancePrototype); + if (!enabled) { + qCDebug(lcModuleLoader) << "condition of module" << fullModuleName << "is false"; + m_modulePrototypeEnabledInfo.insert(key, false); + return {nullptr, triedToLoad}; + } + + if (isBaseModule(fullModuleName)) + setupBaseModulePrototype(module); + else + resolveParameterDeclarations(module); + + m_modulePrototypeEnabledInfo.insert(key, true); + return {module, triedToLoad}; +} + +// Returns the module prototype item and a boolean indicating if we tried to load it from the file +std::pair ModuleLoader::getModulePrototype(ProductContext *productContext, + const QString &fullModuleName, const QString &filePath) +{ + auto &prototypeList = m_modulePrototypes[filePath]; + for (const auto &prototype : prototypeList) { + if (prototype.second == productContext->profileName) { + qCDebug(lcModuleLoader) << "prototype cache hit (level 1)"; + return {prototype.first, true}; + } + } + Item * const module = loadItemFromFile(filePath, CodeLocation()); + if (module->type() != ItemType::Module) { + qCDebug(lcModuleLoader).nospace() + << "Alleged module " << fullModuleName << " has type '" + << module->typeName() << "', so it's not a module after all."; + return {nullptr, false}; + } + prototypeList.emplace_back(module, productContext->profileName); + + // Module properties that are defined in the profile are used as default values. + // This is the reason we need to have different items per profile. + const QVariantMap profileModuleProperties + = productContext->moduleProperties.value(fullModuleName).toMap(); + for (auto it = profileModuleProperties.cbegin(); it != profileModuleProperties.cend(); ++it) { + if (Q_UNLIKELY(!module->hasProperty(it.key()))) { + productContext->unknownProfilePropertyErrors[module].emplace_back + (Tr::tr("Unknown property: %1.%2").arg(fullModuleName, it.key())); + continue; + } + const PropertyDeclaration decl = module->propertyDeclaration(it.key()); + VariantValuePtr v = VariantValue::create( + PropertyDeclaration::convertToPropertyType(it.value(), decl.type(), + QStringList(fullModuleName), it.key())); + module->setProperty(it.key(), v); + } + + return {module, true}; +} + +Item::Module ModuleLoader::loadBaseModule(ProductContext *productContext, Item *item) +{ + const QualifiedId baseModuleName(StringConstants::qbsModule()); + Item::Module baseModuleDesc; + baseModuleDesc.name = baseModuleName; + baseModuleDesc.item = loadModule(productContext, nullptr, item, CodeLocation(), QString(), + baseModuleName, QString(), FallbackMode::Disabled, true, + &baseModuleDesc.isProduct, nullptr); + if (productContext->item) { + const Item * const qbsInstanceItem + = moduleInstanceItem(productContext->item, baseModuleName); + const Item::PropertyMap &props = qbsInstanceItem->properties(); + for (auto it = props.cbegin(); it != props.cend(); ++it) { + if (it.value()->type() == Value::VariantValueType) + baseModuleDesc.item->setProperty(it.key(), it.value()); + } + } + QBS_CHECK(!baseModuleDesc.isProduct); + if (Q_UNLIKELY(!baseModuleDesc.item)) + throw ErrorInfo(Tr::tr("Cannot load base qbs module.")); + return baseModuleDesc; +} + +void ModuleLoader::setupBaseModulePrototype(Item *prototype) +{ + prototype->setProperty(QStringLiteral("hostPlatform"), + VariantValue::create(HostOsInfo::hostOSIdentifier())); + prototype->setProperty(QStringLiteral("hostArchitecture"), + VariantValue::create(HostOsInfo::hostOSArchitecture())); + prototype->setProperty(QStringLiteral("libexecPath"), + VariantValue::create(m_parameters.libexecPath())); + + const Version qbsVersion = LanguageInfo::qbsVersion(); + prototype->setProperty(QStringLiteral("versionMajor"), + VariantValue::create(qbsVersion.majorVersion())); + prototype->setProperty(QStringLiteral("versionMinor"), + VariantValue::create(qbsVersion.minorVersion())); + prototype->setProperty(QStringLiteral("versionPatch"), + VariantValue::create(qbsVersion.patchLevel())); +} + +static void collectItemsWithId_impl(Item *item, QList *result) +{ + if (!item->id().isEmpty()) + result->push_back(item); + for (Item * const child : item->children()) + collectItemsWithId_impl(child, result); +} + +static QList collectItemsWithId(Item *item) +{ + QList result; + collectItemsWithId_impl(item, &result); + return result; +} + +static std::vector> instanceItemProperties(Item *item) +{ + std::vector> result; + QualifiedId name; + const auto func = [&] (Item *item, const auto &f) -> void { + for (auto it = item->properties().begin(), end = item->properties().end(); + it != end; ++it) { + if (it.value()->type() != Value::ItemValueType) + continue; + ItemValuePtr itemValue = std::static_pointer_cast(it.value()); + if (!itemValue->item()) + continue; + name.push_back(it.key()); + if (itemValue->item()->type() == ItemType::ModulePrefix) + f(itemValue->item(), f); + else + result.emplace_back(name, itemValue); + name.removeLast(); + } + }; + func(item, func); + return result; +} + +void ModuleLoader::instantiateModule(ProductContext *productContext, Item *exportingProduct, + Item *instanceScope, Item *moduleInstance, Item *modulePrototype, + const QualifiedId &moduleName, ProductModuleInfo *productModuleInfo) +{ + Item *deepestModuleInstance = findDeepestModuleInstance(moduleInstance); + deepestModuleInstance->setPrototype(modulePrototype); + const QString fullName = moduleName.toString(); + const QString generalOverrideKey = QStringLiteral("modules.") + fullName; + const QString perProductOverrideKey = StringConstants::productsOverridePrefix() + + productContext->name + QLatin1Char('.') + fullName; + for (Item *instance = moduleInstance; instance; instance = instance->prototype()) { + overrideItemProperties(instance, generalOverrideKey, m_parameters.overriddenValuesTree()); + if (fullName == QStringLiteral("qbs")) + overrideItemProperties(instance, fullName, m_parameters.overriddenValuesTree()); + overrideItemProperties(instance, perProductOverrideKey, + m_parameters.overriddenValuesTree()); + if (instance == deepestModuleInstance) + break; + } + + moduleInstance->setFile(modulePrototype->file()); + moduleInstance->setLocation(modulePrototype->location()); + QBS_CHECK(moduleInstance->type() == ItemType::ModuleInstance); + + // create module scope + Item *moduleScope = Item::create(m_pool, ItemType::Scope); + QBS_CHECK(instanceScope->file()); + moduleScope->setFile(instanceScope->file()); + moduleScope->setScope(instanceScope); + QBS_CHECK(productContext->project->scope); + productContext->project->scope->copyProperty(StringConstants::projectVar(), moduleScope); + if (productContext->scope) + productContext->scope->copyProperty(StringConstants::productVar(), moduleScope); + else + QBS_CHECK(fullName == StringConstants::qbsModule()); // Dummy product. + + if (productModuleInfo) { + exportingProduct = productModuleInfo->exportItem->parent(); + QBS_CHECK(exportingProduct); + QBS_CHECK(exportingProduct->type() == ItemType::Product); + } + + if (exportingProduct) { + const auto exportingProductItemValue = ItemValue::create(exportingProduct); + moduleScope->setProperty(QStringLiteral("exportingProduct"), exportingProductItemValue); + + const auto importingProductItemValue = ItemValue::create(productContext->item); + moduleScope->setProperty(QStringLiteral("importingProduct"), importingProductItemValue); + + moduleScope->setProperty(StringConstants::projectVar(), + ItemValue::create(exportingProduct->parent())); + + PropertyDeclaration pd(StringConstants::qbsSourceDirPropertyInternal(), + PropertyDeclaration::String, QString(), + PropertyDeclaration::PropertyNotAvailableInConfig); + moduleInstance->setPropertyDeclaration(pd.name(), pd); + ValuePtr v = exportingProduct + ->property(StringConstants::sourceDirectoryProperty())->clone(); + moduleInstance->setProperty(pd.name(), v); + } + moduleInstance->setScope(moduleScope); + + QHash prototypeInstanceMap; + prototypeInstanceMap[modulePrototype] = moduleInstance; + + // create instances for every child of the prototype + createChildInstances(moduleInstance, modulePrototype, &prototypeInstanceMap); + + // create ids from from the prototype in the instance + if (modulePrototype->file()->idScope()) { + const auto items = collectItemsWithId(modulePrototype); + for (Item * const itemWithId : items) { + Item *idProto = itemWithId; + Item *idInstance = prototypeInstanceMap.value(idProto); + QBS_ASSERT(idInstance, continue); + ItemValuePtr idInstanceValue = ItemValue::create(idInstance); + moduleScope->setProperty(itemWithId->id(), idInstanceValue); + } + } + + // For foo.bar in modulePrototype create an item foo in moduleInstance. + for (const auto &[propertyName, itemValue] : instanceItemProperties(modulePrototype)) { + if (itemValue->item()->properties().empty()) + continue; + qCDebug(lcModuleLoader) << "The prototype of " << moduleName + << " sets properties on " << propertyName.toString(); + Item *item = moduleInstanceItem(moduleInstance, propertyName); + item->setPrototype(itemValue->item()); + if (itemValue->createdByPropertiesBlock()) { + ItemValuePtr itemValue = moduleInstance->itemProperty(propertyName.front()); + for (int i = 1; i < propertyName.size(); ++i) + itemValue = itemValue->item()->itemProperty(propertyName.at(i)); + itemValue->setCreatedByPropertiesBlock(true); + } + } + + // Resolve dependencies of this module instance. + DependsContext dependsContext; + dependsContext.product = productContext; + dependsContext.exportingProductItem = exportingProduct; + QBS_ASSERT(moduleInstance->modules().empty(), moduleInstance->removeModules()); + if (productModuleInfo) { + dependsContext.productDependencies = &productContext->productModuleDependencies[fullName]; + resolveDependencies(&dependsContext, moduleInstance); + } else if (!isBaseModule(fullName)) { + dependsContext.productDependencies = &productContext->info.usedProducts; + resolveDependencies(&dependsContext, moduleInstance); + } + + // Check readonly properties. + const auto end = moduleInstance->properties().cend(); + for (auto it = moduleInstance->properties().cbegin(); it != end; ++it) { + const PropertyDeclaration &pd = moduleInstance->propertyDeclaration(it.key()); + if (!pd.flags().testFlag(PropertyDeclaration::ReadOnlyFlag)) + continue; + throw ErrorInfo(Tr::tr("Cannot set read-only property '%1'.").arg(pd.name()), + moduleInstance->property(pd.name())->location()); + } +} + +void ModuleLoader::createChildInstances(Item *instance, Item *prototype, + QHash *prototypeInstanceMap) const +{ + instance->childrenReserve(instance->children().size() + prototype->children().size()); + + for (Item * const childPrototype : prototype->children()) { + Item *childInstance = Item::create(m_pool, childPrototype->type()); + prototypeInstanceMap->insert(childPrototype, childInstance); + childInstance->setPrototype(childPrototype); + childInstance->setFile(childPrototype->file()); + childInstance->setId(childPrototype->id()); + childInstance->setLocation(childPrototype->location()); + childInstance->setScope(instance->scope()); + Item::addChild(instance, childInstance); + createChildInstances(childInstance, childPrototype, prototypeInstanceMap); + } +} + +void ModuleLoader::checkCancelation() const +{ + if (m_progressObserver && m_progressObserver->canceled()) { + throw ErrorInfo(Tr::tr("Project resolving canceled for configuration %1.") + .arg(TopLevelProject::deriveId(m_parameters.finalBuildConfigurationTree()))); + } +} + +bool ModuleLoader::checkItemCondition(Item *item, Item *itemToDisable) +{ + if (m_evaluator->boolValue(item, StringConstants::conditionProperty())) + return true; + m_disabledItems += itemToDisable ? itemToDisable : item; + return false; +} + +QStringList ModuleLoader::readExtraSearchPaths(Item *item, bool *wasSet) +{ + QStringList result; + const QStringList paths = m_evaluator->stringListValue( + item, StringConstants::qbsSearchPathsProperty(), wasSet); + const JSSourceValueConstPtr prop = item->sourceProperty( + StringConstants::qbsSearchPathsProperty()); + + // Value can come from within a project file or as an overridden value from the user + // (e.g command line). + const QString basePath = FileInfo::path(prop ? prop->file()->filePath() + : m_parameters.projectFilePath()); + for (const QString &path : paths) + result += FileInfo::resolvePath(basePath, path); + return result; +} + +void ModuleLoader::copyProperties(const Item *sourceProject, Item *targetProject) +{ + if (!sourceProject) + return; + const QList builtinProjectProperties = BuiltinDeclarations::instance() + .declarationsForType(ItemType::Project).properties(); + Set builtinProjectPropertyNames; + for (const PropertyDeclaration &p : builtinProjectProperties) + builtinProjectPropertyNames << p.name(); + + for (Item::PropertyDeclarationMap::ConstIterator it + = sourceProject->propertyDeclarations().constBegin(); + it != sourceProject->propertyDeclarations().constEnd(); ++it) { + + // We must not inherit built-in properties such as "name", + // but there are exceptions. + if (it.key() == StringConstants::qbsSearchPathsProperty() + || it.key() == StringConstants::profileProperty() + || it.key() == StringConstants::buildDirectoryProperty() + || it.key() == StringConstants::sourceDirectoryProperty() + || it.key() == StringConstants::minimumQbsVersionProperty()) { + const JSSourceValueConstPtr &v = targetProject->sourceProperty(it.key()); + QBS_ASSERT(v, continue); + if (v->sourceCode() == StringConstants::undefinedValue()) + sourceProject->copyProperty(it.key(), targetProject); + continue; + } + + if (builtinProjectPropertyNames.contains(it.key())) + continue; + + if (targetProject->hasOwnProperty(it.key())) + continue; // Ignore stuff the target project already has. + + targetProject->setPropertyDeclaration(it.key(), it.value()); + sourceProject->copyProperty(it.key(), targetProject); + } +} + +Item *ModuleLoader::wrapInProjectIfNecessary(Item *item) +{ + if (item->type() == ItemType::Project) + return item; + Item *prj = Item::create(item->pool(), ItemType::Project); + Item::addChild(prj, item); + prj->setFile(item->file()); + prj->setLocation(item->location()); + prj->setupForBuiltinType(m_logger); + return prj; +} + +QString ModuleLoader::findExistingModulePath(const QString &searchPath, + const QualifiedId &moduleName) +{ + // isFileCaseCorrect is a very expensive call on macOS, so we cache the value for the + // modules and search paths we've already processed + auto &moduleInfo = m_existingModulePathCache[{searchPath, moduleName}]; + if (moduleInfo) + return *moduleInfo; + + QString dirPath = searchPath + QStringLiteral("/modules"); + + for (const QString &moduleNamePart : moduleName) { + dirPath = FileInfo::resolvePath(dirPath, moduleNamePart); + if (!FileInfo::exists(dirPath) || !FileInfo::isFileCaseCorrect(dirPath)) { + return *(moduleInfo = QString()); + } + } + + return *(moduleInfo = dirPath); +} + +QStringList ModuleLoader::findExistingModulePaths( + const QStringList &searchPaths, const QualifiedId &moduleName) +{ + QStringList result; + result.reserve(searchPaths.size()); + for (const auto &path: searchPaths) { + const QString dirPath = findExistingModulePath(path, moduleName); + if (!dirPath.isEmpty()) + result.append(dirPath); + } + return result; +} + +void ModuleLoader::setScopeForDescendants(Item *item, Item *scope) +{ + for (Item * const child : item->children()) { + child->setScope(scope); + setScopeForDescendants(child, scope); + } +} + +void ModuleLoader::overrideItemProperties(Item *item, const QString &buildConfigKey, + const QVariantMap &buildConfig) +{ + const QVariant buildConfigValue = buildConfig.value(buildConfigKey); + if (buildConfigValue.isNull()) + return; + item->overrideProperties(buildConfigValue.toMap(), buildConfigKey, m_parameters, m_logger); +} + +void ModuleLoader::collectAllModules(Item *item, std::vector *modules) +{ + for (const Item::Module &m : item->modules()) { + if (moduleRepresentsDisabledProduct(m)) + m.item->removeModules(); + auto it = std::find_if(modules->begin(), modules->end(), + [m] (const Item::Module &m2) { return m.name == m2.name; }); + if (it != modules->end()) { + // If a module is required somewhere, it is required in the top-level item. + if (m.required) + it->required = true; + it->versionRange.narrowDown(m.versionRange); + it->fallbackEnabled = it->fallbackEnabled && m.fallbackEnabled; + continue; + } + modules->push_back(m); + collectAllModules(m.item, modules); + } +} + +std::vector ModuleLoader::allModules(Item *item) +{ + std::vector lst; + collectAllModules(item, &lst); + return lst; +} + +bool ModuleLoader::moduleRepresentsDisabledProduct(const Item::Module &module) +{ + if (!module.isProduct) + return false; + const Item *exportItem = module.item->prototype(); + while (exportItem && exportItem->type() != ItemType::Export) + exportItem = exportItem->prototype(); + QBS_CHECK(exportItem); + Item * const productItem = exportItem->parent(); + QBS_CHECK(productItem->type() == ItemType::Product); + return m_disabledItems.contains(productItem) || !checkItemCondition(productItem); +} + +void ModuleLoader::addProductModuleDependencies(ProductContext *productContext, const QString &name) +{ + auto deps = productContext->productModuleDependencies.at(name); + QList depsToAdd; + const bool productIsMultiplexed = !productContext->multiplexConfigurationId.isEmpty(); + for (auto &dep : deps) { + const auto productRange = m_productsByName.equal_range(dep.name); + std::vector dependencies; + bool hasNonMultiplexedDependency = false; + for (auto it = productRange.first; it != productRange.second; ++it) { + if (!it->second->multiplexConfigurationId.isEmpty()) { + dependencies.push_back(it->second); + if (productIsMultiplexed && dep.profile.isEmpty()) + break; + } else { + hasNonMultiplexedDependency = true; + break; + } + } + + if (hasNonMultiplexedDependency) { + depsToAdd.push_back(dep); + continue; + } + + for (std::size_t i = 0; i < dependencies.size(); ++i) { + const bool profileMatch = dep.profile.isEmpty() + || dep.profile == StringConstants::star() + || dep.profile == dependencies.at(i)->profileName; + if (i == 0) { + if (productIsMultiplexed && dep.profile.isEmpty()) { + const ValuePtr &multiplexConfigIdProp = productContext->item->property( + StringConstants::multiplexConfigurationIdProperty()); + dep.multiplexConfigurationId = std::static_pointer_cast( + multiplexConfigIdProp)->value().toString(); + depsToAdd.push_back(dep); + break; + } + if (profileMatch) { + dep.multiplexConfigurationId = dependencies.at(i)->multiplexConfigurationId; + depsToAdd.push_back(dep); + } + } else if (profileMatch) { + ModuleLoaderResult::ProductInfo::Dependency newDependency = dep; + newDependency.multiplexConfigurationId + = dependencies.at(i)->multiplexConfigurationId; + depsToAdd << newDependency; + } + } + } + productContext->info.usedProducts.insert(productContext->info.usedProducts.end(), + depsToAdd.cbegin(), depsToAdd.cend()); +} + +static void collectProductModuleDependencies(Item *item, Set &allDeps) +{ + for (const Item::Module &m : item->modules()) { + if (m.isProduct && allDeps.insert(m.name).second) + collectProductModuleDependencies(m.item, allDeps); + } +} + +void ModuleLoader::addProductModuleDependencies(ModuleLoader::ProductContext *ctx) +{ + Set deps; + collectProductModuleDependencies(ctx->item, deps); + for (const QualifiedId &dep : deps) + addProductModuleDependencies(ctx, dep.toString()); +} + +void ModuleLoader::addTransitiveDependencies(ProductContext *ctx) +{ + AccumulatingTimer timer(m_parameters.logElapsedTime() + ? &m_elapsedTimeTransitiveDependencies : nullptr); + qCDebug(lcModuleLoader) << "addTransitiveDependencies"; + + std::vector transitiveDeps = allModules(ctx->item); + std::sort(transitiveDeps.begin(), transitiveDeps.end()); + for (const Item::Module &m : ctx->item->modules()) { + auto it = std::lower_bound(transitiveDeps.begin(), transitiveDeps.end(), m); + QBS_CHECK(it != transitiveDeps.end() && it->name == m.name); + transitiveDeps.erase(it); + } + for (const Item::Module &module : qAsConst(transitiveDeps)) { + if (module.isProduct) { + ctx->item->addModule(module); + } else { + const FallbackMode fallbackMode = module.fallbackEnabled + ? FallbackMode::Enabled : FallbackMode::Disabled; + Item::Module dep; + dep.item = loadModule(ctx, nullptr, ctx->item, ctx->item->location(), QString(), + module.name, QString(), fallbackMode, + module.required, &dep.isProduct, &dep.parameters); + if (!dep.item) { + throw ErrorInfo(Tr::tr("Module '%1' not found when setting up transitive " + "dependencies for product '%2'.").arg(module.name.toString(), + ctx->name), + ctx->item->location()); + } + dep.name = module.name; + dep.required = module.required; + dep.versionRange = module.versionRange; + dep.fallbackEnabled = fallbackMode == FallbackMode::Enabled; + ctx->item->addModule(dep); + } + } +} + +Item *ModuleLoader::createNonPresentModule(const QString &name, const QString &reason, Item *module) +{ + qCDebug(lcModuleLoader) << "Non-required module '" << name << "' not loaded (" << reason << ")." + << "Creating dummy module for presence check."; + if (!module) { + module = Item::create(m_pool, ItemType::ModuleInstance); + module->setFile(FileContext::create()); + module->setProperty(StringConstants::nameProperty(), VariantValue::create(name)); + } + module->setProperty(StringConstants::presentProperty(), VariantValue::falseValue()); + return module; +} + +void ModuleLoader::handleProductError(const ErrorInfo &error, + ModuleLoader::ProductContext *productContext) +{ + const bool alreadyHadError = productContext->info.delayedError.hasError(); + if (!alreadyHadError) { + productContext->info.delayedError.append(Tr::tr("Error while handling product '%1':") + .arg(productContext->name), + productContext->item->location()); + } + if (error.isInternalError()) { + if (alreadyHadError) { + qCDebug(lcModuleLoader()) << "ignoring subsequent internal error" << error.toString() + << "in product" << productContext->name; + return; + } + for (const auto &kv : productContext->productModuleDependencies) { + const auto rangeForName = m_productsByName.equal_range(kv.first); + for (auto rangeIt = rangeForName.first; rangeIt != rangeForName.second; ++rangeIt) { + const ProductContext * const dep = rangeIt->second; + if (dep->info.delayedError.hasError()) { + qCDebug(lcModuleLoader()) << "ignoring internal error" << error.toString() + << "in product" << productContext->name + << "assumed to be caused by erroneous dependency" + << dep->name; + return; + } + } + } + } + const auto errorItems = error.items(); + for (const ErrorItem &ei : errorItems) + productContext->info.delayedError.append(ei.description(), ei.codeLocation()); + productContext->project->result->productInfos[productContext->item] = productContext->info; + m_disabledItems << productContext->item; + m_erroneousProducts.insert(productContext->name); +} + +static void gatherAssignedProperties(ItemValue *iv, const QualifiedId &prefix, + QualifiedIdSet &properties) +{ + const Item::PropertyMap &props = iv->item()->properties(); + for (auto it = props.cbegin(); it != props.cend(); ++it) { + switch (it.value()->type()) { + case Value::JSSourceValueType: + properties << (QualifiedId(prefix) << it.key()); + break; + case Value::ItemValueType: + if (iv->item()->type() == ItemType::ModulePrefix) { + gatherAssignedProperties(std::static_pointer_cast(it.value()).get(), + QualifiedId(prefix) << it.key(), properties); + } + break; + default: + break; + } + } +} + +QualifiedIdSet ModuleLoader::gatherModulePropertiesSetInGroup(const Item *group) +{ + QualifiedIdSet propsSetInGroup; + const Item::PropertyMap &props = group->properties(); + for (auto it = props.cbegin(); it != props.cend(); ++it) { + if (it.value()->type() == Value::ItemValueType) { + gatherAssignedProperties(std::static_pointer_cast(it.value()).get(), + QualifiedId(it.key()), propsSetInGroup); + } + } + return propsSetInGroup; +} + +void ModuleLoader::markModuleTargetGroups(Item *group, const Item::Module &module) +{ + QBS_CHECK(group->type() == ItemType::Group); + if (m_evaluator->boolValue(group, StringConstants::filesAreTargetsProperty())) { + group->setProperty(StringConstants::modulePropertyInternal(), + VariantValue::create(module.name.toString())); + } + for (Item * const child : group->children()) + markModuleTargetGroups(child, module); +} + +void ModuleLoader::copyGroupsFromModuleToProduct(const ProductContext &productContext, + const Item::Module &module, + const Item *modulePrototype) +{ + for (Item * const child : modulePrototype->children()) { + if (child->type() == ItemType::Group) { + Item * const clonedGroup = child->clone(); + clonedGroup->setScope(productContext.scope); + setScopeForDescendants(clonedGroup, productContext.scope); + Item::addChild(productContext.item, clonedGroup); + markModuleTargetGroups(clonedGroup, module); + } + } +} + +void ModuleLoader::copyGroupsFromModulesToProduct(const ProductContext &productContext) +{ + for (const Item::Module &module : productContext.item->modules()) { + Item *prototype = module.item; + bool modulePassedValidation; + while ((modulePassedValidation = prototype->isPresentModule()) && prototype->prototype()) + prototype = prototype->prototype(); + if (modulePassedValidation) + copyGroupsFromModuleToProduct(productContext, module, prototype); + } +} + +QString ModuleLoaderResult::ProductInfo::Dependency::uniqueName() const +{ + return ResolvedProduct::uniqueName(name, multiplexConfigurationId); +} + +QString ModuleLoader::ProductContext::uniqueName() const +{ + return ResolvedProduct::uniqueName(name, multiplexConfigurationId); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h new file mode 100644 index 00000000..db0b51ca --- /dev/null +++ b/src/lib/corelib/language/moduleloader.h @@ -0,0 +1,459 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MODULELOADER_H +#define QBS_MODULELOADER_H + +#include "filetags.h" +#include "forward_decls.h" +#include "item.h" +#include "itempool.h" +#include "moduleproviderinfo.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace qbs { + +class CodeLocation; +class Settings; + +namespace Internal { + +class Evaluator; +class Item; +class ItemReader; +class ModuleProviderLoader; +class ProbesResolver; +class ProgressObserver; +class QualifiedId; +class SearchPathsManager; + +using ModulePropertiesPerGroup = std::unordered_map; + +struct ModuleLoaderResult +{ + ModuleLoaderResult() + : itemPool(new ItemPool), root(nullptr) + {} + + struct ProductInfo + { + struct Dependency + { + QString name; + QString profile; // "*" <=> Match all profiles. + QString multiplexConfigurationId; + QVariantMap parameters; + bool limitToSubProject = false; + bool isRequired = true; + + QString uniqueName() const; + }; + + std::vector probes; + std::vector usedProducts; + ModulePropertiesPerGroup modulePropertiesSetInGroups; + ErrorInfo delayedError; + }; + + std::shared_ptr itemPool; + Item *root; + std::unordered_map productInfos; + std::vector projectProbes; + StoredModuleProviderInfo storedModuleProviderInfo; + Set qbsFiles; + QVariantMap profileConfigs; +}; + +/* + * Loader stage II. Responsible for + * - loading modules and module dependencies, + * - project references, + * - Probe items. + */ +class ModuleLoader +{ +public: + ModuleLoader(Evaluator *evaluator, Logger &logger); + ~ModuleLoader(); + + void setProgressObserver(ProgressObserver *progressObserver); + void setSearchPaths(const QStringList &searchPaths); + void setOldProjectProbes(const std::vector &oldProbes); + void setOldProductProbes(const QHash> &oldProbes); + void setLastResolveTime(const FileTime &time) { m_lastResolveTime = time; } + void setStoredProfiles(const QVariantMap &profiles); + void setStoredModuleProviderInfo(const StoredModuleProviderInfo &moduleProviderInfo); + Evaluator *evaluator() const { return m_evaluator; } + + ModuleLoaderResult load(const SetupProjectParameters ¶meters); + +private: + friend class ModuleProviderLoader; + friend class ProbesResolver; + class ProductSortByDependencies; + + class ContextBase + { + public: + ContextBase() + : item(nullptr), scope(nullptr) + {} + + Item *item; + Item *scope; + QString name; + }; + + class ProjectContext; + + using ProductDependencies = std::vector; + + // This is the data we need to store at the point where a dependency is deferred + // in order to properly resolve the dependency in pass 2. + struct DeferredDependsContext { + DeferredDependsContext(Item *exportingProduct, Item *parent) + : exportingProductItem(exportingProduct), parentItem(parent) {} + Item *exportingProductItem = nullptr; + Item *parentItem = nullptr; + bool operator==(const DeferredDependsContext &other) const + { + return exportingProductItem == other.exportingProductItem + && parentItem == other.parentItem; + } + bool operator<(const DeferredDependsContext &other) const + { + return parentItem < other.parentItem; + } + }; + + class ProductContext : public ContextBase + { + public: + ProjectContext *project = nullptr; + ModuleLoaderResult::ProductInfo info; + QString profileName; + QString multiplexConfigurationId; + QVariantMap moduleProperties; + std::map productModuleDependencies; + std::unordered_map> unknownProfilePropertyErrors; + QStringList searchPaths; + + std::optional theModuleProviderConfig; + + // The key corresponds to DeferredDependsContext.exportingProductItem, which is the + // only value from that data structure that we still need here. + std::unordered_map> deferredDependsItems; + + QString uniqueName() const; + }; + + class TopLevelProjectContext; + + class ProjectContext : public ContextBase + { + public: + TopLevelProjectContext *topLevelProject = nullptr; + ModuleLoaderResult *result = nullptr; + std::vector products; + std::vector searchPathsStack; + }; + + struct ProductModuleInfo + { + Item *exportItem = nullptr; + QString multiplexId; + QVariantMap defaultParameters; + }; + + class TopLevelProjectContext + { + Q_DISABLE_COPY(TopLevelProjectContext) + public: + TopLevelProjectContext() = default; + ~TopLevelProjectContext() { qDeleteAll(projects); } + + std::vector projects; + QMultiHash productModules; + std::vector probes; + QString buildDirectory; + }; + + class DependsContext + { + public: + ProductContext *product = nullptr; + Item *exportingProductItem = nullptr; + ProductDependencies *productDependencies = nullptr; + }; + + void handleTopLevelProject(ModuleLoaderResult *loadResult, Item *projectItem, + const QString &buildDirectory, const Set &referencedFilePaths); + void handleProject(ModuleLoaderResult *loadResult, + TopLevelProjectContext *topLevelProjectContext, Item *projectItem, + const Set &referencedFilePaths); + + using MultiplexRow = std::vector; + using MultiplexTable = std::vector; + + struct MultiplexInfo + { + std::vector properties; + MultiplexTable table; + bool aggregate = false; + VariantValuePtr multiplexedType; + + QString toIdString(size_t row) const; + static QVariantMap multiplexIdToVariantMap(const QString &multiplexId); + }; + + void dump(const MultiplexInfo &mpi); + static MultiplexTable combine(const MultiplexTable &table, const MultiplexRow &values); + MultiplexInfo extractMultiplexInfo(Item *productItem, Item *qbsModuleItem); + QList multiplexProductItem(ProductContext *dummyContext, Item *productItem); + void normalizeDependencies(ProductContext *product, + const DeferredDependsContext &dependsContext); + void adjustDependenciesForMultiplexing(const TopLevelProjectContext &tlp); + void adjustDependenciesForMultiplexing(const ProductContext &product); + void adjustDependenciesForMultiplexing(const ProductContext &product, Item *dependsItem); + + void prepareProduct(ProjectContext *projectContext, Item *productItem); + void setupProductDependencies(ProductContext *productContext, + const Set &deferredDependsContext); + void handleProduct(ProductContext *productContext); + void checkDependencyParameterDeclarations(const ProductContext *productContext) const; + void handleModuleSetupError(ProductContext *productContext, const Item::Module &module, + const ErrorInfo &error); + void initProductProperties(const ProductContext &product); + void handleSubProject(ProjectContext *projectContext, Item *projectItem, + const Set &referencedFilePaths); + QList loadReferencedFile(const QString &relativePath, + const CodeLocation &referencingLocation, + const Set &referencedFilePaths, + ProductContext &dummyContext); + void handleAllPropertyOptionsItems(Item *item); + void handlePropertyOptions(Item *optionsItem); + + using ModuleDependencies = QHash; + void setupReverseModuleDependencies(const Item::Module &module, ModuleDependencies &deps, + QualifiedIdSet &seenModules); + ModuleDependencies setupReverseModuleDependencies(const Item *product); + void handleGroup(ProductContext *productContext, Item *groupItem, + const ModuleDependencies &reverseDepencencies); + void propagateModulesFromParent(ProductContext *productContext, Item *groupItem, + const ModuleDependencies &reverseDepencencies); + void adjustDefiningItemsInGroupModuleInstances(const Item::Module &module, + const Item::Modules &dependentModules); + + bool mergeExportItems(const ProductContext &productContext); + void resolveDependencies(DependsContext *dependsContext, Item *item, + ProductContext *productContext = nullptr); + class ItemModuleList; + void resolveDependsItem(DependsContext *dependsContext, Item *parentItem, Item *dependsItem, + ItemModuleList *moduleResults, ProductDependencies *productResults); + void forwardParameterDeclarations(const Item *dependsItem, const ItemModuleList &modules); + void forwardParameterDeclarations(const QualifiedId &moduleName, Item *item, + const ItemModuleList &modules); + void resolveParameterDeclarations(const Item *module); + QVariantMap extractParameters(Item *dependsItem) const; + Item *moduleInstanceItem(Item *containerItem, const QualifiedId &moduleName); + static ProductModuleInfo *productModule(ProductContext *productContext, const QString &name, + const QString &multiplexId, bool &productNameMatch); + static ProductContext *product(ProjectContext *projectContext, const QString &name); + static ProductContext *product(TopLevelProjectContext *tlpContext, const QString &name); + + enum class FallbackMode { Enabled, Disabled }; + Item *loadModule(ProductContext *productContext, Item *exportingProductItem, Item *item, + const CodeLocation &dependsItemLocation, const QString &moduleId, + const QualifiedId &moduleName, const QString &multiplexId, FallbackMode fallbackMode, + bool isRequired, bool *isProductDependency, QVariantMap *defaultParameters); + Item *searchAndLoadModuleFile(ProductContext *productContext, + const CodeLocation &dependsItemLocation, const QualifiedId &moduleName, + FallbackMode fallbackMode, bool isRequired, Item *moduleInstance); + QStringList &getModuleFileNames(const QString &dirPath); + std::pair loadModuleFile( + ProductContext *productContext, const QString &fullModuleName, + const QString &filePath, Item *moduleInstance); + std::pair getModulePrototype(ProductContext *productContext, + const QString &fullModuleName, const QString &filePath); + Item::Module loadBaseModule(ProductContext *productContext, Item *item); + void setupBaseModulePrototype(Item *prototype); + template + T callWithTemporaryBaseModule(ProductContext *productContext, const F &func); + void instantiateModule(ProductContext *productContext, Item *exportingProductItem, + Item *instanceScope, Item *moduleInstance, Item *modulePrototype, + const QualifiedId &moduleName, ProductModuleInfo *productModuleInfo); + void createChildInstances(Item *instance, Item *prototype, + QHash *prototypeInstanceMap) const; + void checkCancelation() const; + bool checkItemCondition(Item *item, Item *itemToDisable = nullptr); + QStringList readExtraSearchPaths(Item *item, bool *wasSet = nullptr); + void copyProperties(const Item *sourceProject, Item *targetProject); + Item *wrapInProjectIfNecessary(Item *item); + QString findExistingModulePath(const QString &searchPath, const QualifiedId &moduleName); + QStringList findExistingModulePaths( + const QStringList &searchPaths, const QualifiedId &moduleName); + + static void setScopeForDescendants(Item *item, Item *scope); + void overrideItemProperties(Item *item, const QString &buildConfigKey, + const QVariantMap &buildConfig); + void addProductModuleDependencies(ProductContext *ctx, const QString &name); + void addProductModuleDependencies(ProductContext *ctx); + void addTransitiveDependencies(ProductContext *ctx); + Item *createNonPresentModule(const QString &name, const QString &reason, Item *module); + void copyGroupsFromModuleToProduct(const ProductContext &productContext, + const Item::Module &module, const Item *modulePrototype); + void copyGroupsFromModulesToProduct(const ProductContext &productContext); + void markModuleTargetGroups(Item *group, const Item::Module &module); + bool checkExportItemCondition(Item *exportItem, const ProductContext &productContext); + + void printProfilingInfo(); + void handleProductError(const ErrorInfo &error, ProductContext *productContext); + QualifiedIdSet gatherModulePropertiesSetInGroup(const Item *group); + Item *loadItemFromFile(const QString &filePath, const CodeLocation &referencingLocation); + void collectProductsByName(const TopLevelProjectContext &topLevelProject); + void collectProductsByType(const TopLevelProjectContext &topLevelProject); + + void handleProfileItems(Item *item, ProjectContext *projectContext); + std::vector collectProfileItems(Item *item, ProjectContext *projectContext); + void evaluateProfileValues(const QualifiedId &namePrefix, Item *item, Item *profileItem, + QVariantMap &values); + void handleProfile(Item *profileItem); + void collectNameFromOverride(const QString &overrideString); + void checkProjectNamesInOverrides(const TopLevelProjectContext &tlp); + void checkProductNamesInOverrides(); + void setSearchPathsForProduct(ProductContext *product); + + Item::Modules modulesSortedByDependency(const Item *productItem); + void createSortedModuleList(const Item::Module &parentModule, Item::Modules &modules); + void collectAllModules(Item *item, std::vector *modules); + std::vector allModules(Item *item); + bool moduleRepresentsDisabledProduct(const Item::Module &module); + + using ShadowProductInfo = std::pair; + ShadowProductInfo getShadowProductInfo(const ProductContext &product) const; + + ItemPool *m_pool; + Logger &m_logger; + ProgressObserver *m_progressObserver; + const std::unique_ptr m_reader; + Evaluator *m_evaluator; + const std::unique_ptr m_probesResolver; + const std::unique_ptr m_moduleProviderLoader; + QMap m_moduleDirListCache; + QHash, std::optional> m_existingModulePathCache; + + // The keys are file paths, the values are module prototype items accompanied by a profile. + std::unordered_map>> m_modulePrototypes; + + // The keys are module prototypes and products, the values specify whether the module's + // condition is true for that product. + QHash, bool> m_modulePrototypeEnabledInfo; + + QHash m_parameterDeclarations; + Set m_disabledItems; + std::vector m_requiredChain; + + struct DependsChainEntry + { + DependsChainEntry(QualifiedId name, const CodeLocation &location) + : name(std::move(name)), location(location) + { + } + + QualifiedId name; + CodeLocation location; + bool isProduct = false; + }; + class DependsChainManager; + std::vector m_dependsChain; + + FileTime m_lastResolveTime; + QVariantMap m_storedProfiles; + QVariantMap m_localProfiles; + std::multimap m_productsByName; + std::multimap m_productsByType; + + std::unordered_map> m_productsWithDeferredDependsItems; + Set m_exportsWithDeferredDependsItems; + + SetupProjectParameters m_parameters; + std::unique_ptr m_settings; + Version m_qbsVersion; + Item *m_tempScopeItem = nullptr; + + qint64 m_elapsedTimeProbes = 0; + qint64 m_elapsedTimePrepareProducts = 0; + qint64 m_elapsedTimeProductDependencies = 0; + qint64 m_elapsedTimeModuleProviders = 0; + qint64 m_elapsedTimeTransitiveDependencies = 0; + qint64 m_elapsedTimeHandleProducts = 0; + qint64 m_elapsedTimePropertyChecking = 0; + Set m_projectNamesUsedInOverrides; + Set m_productNamesUsedInOverrides; + Set m_disabledProjects; + Set m_erroneousProducts; + + int m_dependencyResolvingPass = 0; +}; + +} // namespace Internal +} // namespace qbs + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(qbs::Internal::ModuleLoaderResult::ProductInfo, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(qbs::Internal::ModuleLoaderResult::ProductInfo::Dependency, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +#endif // QBS_MODULELOADER_H diff --git a/src/lib/corelib/language/modulemerger.cpp b/src/lib/corelib/language/modulemerger.cpp new file mode 100644 index 00000000..6ad8e225 --- /dev/null +++ b/src/lib/corelib/language/modulemerger.cpp @@ -0,0 +1,267 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "modulemerger.h" + +#include "value.h" + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +ModuleMerger::ModuleMerger(Logger &logger, Item *productItem, const QString &productName, + const Item::Modules::iterator &modulesBegin, + const Item::Modules::iterator &modulesEnd) + : m_logger(logger) + , m_productItem(productItem) + , m_mergedModule(*modulesBegin) + , m_isBaseModule(m_mergedModule.name.first() == StringConstants::qbsModule()) + , m_isShadowProduct(productName.startsWith(StringConstants::shadowProductPrefix())) + , m_modulesBegin(std::next(modulesBegin)) + , m_modulesEnd(modulesEnd) +{ + QBS_CHECK(modulesBegin->item->type() == ItemType::ModuleInstance); +} + +void ModuleMerger::replaceItemInValues(QualifiedId moduleName, Item *containerItem, Item *toReplace) +{ + QBS_CHECK(!moduleName.empty()); + QBS_CHECK(containerItem != m_mergedModule.item); + const QString moduleNamePrefix = moduleName.takeFirst(); + const Item::PropertyMap &properties = containerItem->properties(); + for (auto it = properties.begin(); it != properties.end(); ++it) { + if (it.key() != moduleNamePrefix) + continue; + Value * const val = it.value().get(); + QBS_CHECK(val); + QBS_CHECK(val->type() == Value::ItemValueType); + const auto itemVal = static_cast(val); + if (moduleName.empty()) { + QBS_CHECK(itemVal->item() == toReplace); + itemVal->setItem(m_mergedModule.item); + } else { + replaceItemInValues(moduleName, itemVal->item(), toReplace); + } + } +} + +void ModuleMerger::start() +{ + // Iterate over any module that our product depends on. These modules + // may depend on m_mergedModule and contribute property assignments. + Item::PropertyMap props; + for (auto module = m_modulesBegin; module != m_modulesEnd; module++) + mergeModule(&props, *module); + + // Module property assignments in the product have the highest priority + // and are thus prepended. + Item::Module m; + m.item = m_productItem; + mergeModule(&props, m); + + // The module's prototype is the essential unmodified module as loaded + // from the cache. + Item *moduleProto = m_mergedModule.item->prototype(); + while (moduleProto->prototype()) + moduleProto = moduleProto->prototype(); + + // The prototype item might contain default values which get appended in + // case of list properties. Scalar properties will only be set if not + // already specified above. + Item::PropertyMap mergedProps = m_mergedModule.item->properties(); + for (auto it = props.constBegin(); it != props.constEnd(); ++it) { + appendPrototypeValueToNextChain(moduleProto, it.key(), it.value()); + mergedProps[it.key()] = it.value(); + } + + m_mergedModule.item->setProperties(mergedProps); + + // Update all sibling instances of the to-be-merged module to behave identical + // to the merged module. + for (Item *moduleInstanceContainer : qAsConst(m_moduleInstanceContainers)) { + Item::Modules modules; + for (const Item::Module &dep : moduleInstanceContainer->modules()) { + const bool isTheModule = dep.name == m_mergedModule.name; + Item::Module m = dep; + if (isTheModule && m.item != m_mergedModule.item) { + QBS_CHECK(m.item->type() == ItemType::ModuleInstance); + replaceItemInValues(m.name, moduleInstanceContainer, m.item); + m.item = m_mergedModule.item; + m.required = m_mergedModule.required; + m.versionRange = m_mergedModule.versionRange; + m.fallbackEnabled = m_mergedModule.fallbackEnabled; + } + modules << m; + } + moduleInstanceContainer->setModules(modules); + } +} + +void ModuleMerger::mergeModule(Item::PropertyMap *dstProps, const Item::Module &module) +{ + const Item::Module *dep = findModule(module.item, m_mergedModule.name); + if (!dep) + return; + + const bool mergingProductItem = (module.item == m_productItem); + Item *srcItem = dep->item; + Item *origSrcItem = srcItem; + do { + if (m_seenInstances.insert(srcItem).second) { + for (auto it = srcItem->properties().constBegin(); + it != srcItem->properties().constEnd(); ++it) { + const ValuePtr &srcVal = it.value(); + if (srcVal->type() == Value::ItemValueType) + continue; + if (it.key() == StringConstants::qbsSourceDirPropertyInternal()) + continue; + const PropertyDeclaration srcDecl = srcItem->propertyDeclaration(it.key()); + if (!srcDecl.isValid()) + continue; + + // Scalar variant values could stem from product multiplexing, in which case + // the merged qbs module instance needs to get that value. + if (srcVal->type() == Value::VariantValueType + && (!srcDecl.isScalar() || !m_isBaseModule)) { + continue; + } + + ValuePtr clonedSrcVal = srcVal->clone(); + clonedSrcVal->setDefiningItem(origSrcItem); + + ValuePtr &dstVal = (*dstProps)[it.key()]; + if (dstVal) { + if (srcDecl.isScalar()) { + // Scalar properties get replaced. + if ((dstVal->type() == Value::JSSourceValueType) + && (srcVal->type() == Value::JSSourceValueType)) { + // Warn only about conflicting source code values + const JSSourceValuePtr dstJsVal = + std::static_pointer_cast(dstVal); + const JSSourceValuePtr srcJsVal = + std::static_pointer_cast(srcVal); + const bool overriddenInProduct = + m_mergedModule.item->properties().contains(it.key()); + + if (dstJsVal->sourceCode() != srcJsVal->sourceCode() + && !mergingProductItem && !overriddenInProduct + && !m_isShadowProduct) { + m_logger.qbsWarning() + << Tr::tr("Conflicting scalar values at %1 and %2.").arg( + dstJsVal->location().toString(), + srcJsVal->location().toString()); + } + } + } else { + // List properties get prepended + QBS_CHECK(!clonedSrcVal->next()); + clonedSrcVal->setNext(dstVal); + } + } + dstVal = clonedSrcVal; + } + } + srcItem = srcItem->prototype(); + } while (srcItem && srcItem->type() == ItemType::ModuleInstance); + + // Update dependency constraints + if (dep->required) + m_mergedModule.required = true; + // if one dep has fallback disabled, disable it for the merged module + m_mergedModule.fallbackEnabled = m_mergedModule.fallbackEnabled && dep->fallbackEnabled; + m_mergedModule.versionRange.narrowDown(dep->versionRange); + + // We need to touch the unmerged module instances later once more + m_moduleInstanceContainers << module.item; +} + +void ModuleMerger::appendPrototypeValueToNextChain(Item *moduleProto, const QString &propertyName, + const ValuePtr &sv) +{ + const PropertyDeclaration pd = m_mergedModule.item->propertyDeclaration(propertyName); + if (pd.isScalar()) + return; + if (!m_clonedModulePrototype) { + m_clonedModulePrototype = Item::create(moduleProto->pool(), ItemType::Module); + m_clonedModulePrototype->setScope(m_mergedModule.item); + m_clonedModulePrototype->setLocation(moduleProto->location()); + moduleProto->copyProperty(StringConstants::nameProperty(), m_clonedModulePrototype); + } + const ValuePtr &protoValue = moduleProto->property(propertyName); + QBS_CHECK(protoValue); + const ValuePtr clonedValue = protoValue->clone(); + lastInNextChain(sv)->setNext(clonedValue); + clonedValue->setDefiningItem(m_clonedModulePrototype); + m_clonedModulePrototype->setPropertyDeclaration(propertyName, pd); + m_clonedModulePrototype->setProperty(propertyName, clonedValue); +} + +ValuePtr ModuleMerger::lastInNextChain(const ValuePtr &v) +{ + ValuePtr n = v; + while (n->next()) + n = n->next(); + return n; +} + +const Item::Module *ModuleMerger::findModule(const Item *item, const QualifiedId &name) +{ + for (const auto &module : item->modules()) { + if (module.name == name) + return &module; + } + return nullptr; +} + +void ModuleMerger::merge(Logger &logger, Item *product, const QString &productName, + Item::Modules *topSortedModules) +{ + for (auto it = topSortedModules->begin(); it != topSortedModules->end(); ++it) + ModuleMerger(logger, product, productName, it, topSortedModules->end()).start(); +} + + + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/modulemerger.h b/src/lib/corelib/language/modulemerger.h new file mode 100644 index 00000000..469dc86c --- /dev/null +++ b/src/lib/corelib/language/modulemerger.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MODULEMERGER_H +#define QBS_MODULEMERGER_H + +#include "item.h" +#include "qualifiedid.h" + +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class ModuleMerger { +public: + static void merge(Logger &logger, Item *productItem, const QString &productName, + Item::Modules *topSortedModules); + +private: + ModuleMerger(Logger &logger, Item *productItem, const QString &productName, + const Item::Modules::iterator &modulesBegin, + const Item::Modules::iterator &modulesEnd); + + void appendPrototypeValueToNextChain(Item *moduleProto, const QString &propertyName, + const ValuePtr &sv); + void mergeModule(Item::PropertyMap *props, const Item::Module &m); + void replaceItemInValues(QualifiedId moduleName, Item *containerItem, Item *toReplace); + void start(); + + static ValuePtr lastInNextChain(const ValuePtr &v); + static const Item::Module *findModule(const Item *item, const QualifiedId &name); + + Logger &m_logger; + Item * const m_productItem; + Item::Module &m_mergedModule; + Item *m_clonedModulePrototype = nullptr; + Set m_seenInstances; + Set m_moduleInstanceContainers; + const bool m_isBaseModule; + const bool m_isShadowProduct; + const Item::Modules::iterator m_modulesBegin; + const Item::Modules::iterator m_modulesEnd; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_MODULEMERGER_H diff --git a/src/lib/corelib/language/moduleproviderinfo.h b/src/lib/corelib/language/moduleproviderinfo.h new file mode 100644 index 00000000..8ed6f008 --- /dev/null +++ b/src/lib/corelib/language/moduleproviderinfo.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MODULEPROVIDERINFO_H +#define QBS_MODULEPROVIDERINFO_H + +#include "qualifiedid.h" +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class ModuleProviderInfo +{ +public: + ModuleProviderInfo() = default; + ModuleProviderInfo(QualifiedId name, QVariantMap config, + QStringList searchPaths, bool transientOutput) + : name(std::move(name)) + , config(std::move(config)) + , searchPaths(std::move(searchPaths)) + , transientOutput(transientOutput) + {} + + static QString outputBaseDirName() { return QStringLiteral("genmodules"); } + static QString outputDirPath(const QString &baseDir, const QualifiedId &name) + { + return baseDir + QLatin1Char('/') + outputBaseDirName() + QLatin1Char('/') + + name.toString(); + } + QString outputDirPath(const QString &baseDir) const + { + return outputDirPath(baseDir, name); + } + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp( + reinterpret_cast(name), config, providerFile, searchPaths); + } + + QualifiedId name; + QVariantMap config; + QString providerFile; + QStringList searchPaths; + bool transientOutput = false; // Not to be serialized. +}; + +using ModuleProviderInfoList = std::vector; + +// Persistent info stored between sessions +struct StoredModuleProviderInfo +{ + using CacheKey = std::tuple; + using ModuleProvidersCache = QHash; + + ModuleProvidersCache providers; + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(providers); + } +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/language/moduleproviderloader.cpp b/src/lib/corelib/language/moduleproviderloader.cpp new file mode 100644 index 00000000..49c77b7f --- /dev/null +++ b/src/lib/corelib/language/moduleproviderloader.cpp @@ -0,0 +1,316 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "moduleproviderloader.h" + +#include "builtindeclarations.h" +#include "evaluator.h" +#include "itemreader.h" +#include "moduleloader.h" +#include "probesresolver.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +ModuleProviderLoader::ModuleProviderLoader(ItemReader *reader, Evaluator *evaluator, + ProbesResolver *probesResolver, Logger &logger) + : m_reader(reader) + , m_evaluator(evaluator) + , m_probesResolver(probesResolver) + , m_logger(logger) +{ +} + +ModuleProviderLoader::ModuleProviderResult ModuleProviderLoader::executeModuleProvider( + ProductContext &productContext, + const CodeLocation &dependsItemLocation, + const QualifiedId &moduleName, + FallbackMode fallbackMode) +{ + ModuleProviderLoader::ModuleProviderResult result; + std::vector providersToRun; + qCDebug(lcModuleLoader) << "Module" << moduleName.toString() + << "not found, checking for module providers"; + const auto providerNames = getModuleProviders(productContext.item); + if (providerNames) { + providersToRun = transformed>(*providerNames, [](const auto &name) { + return Provider{name, ModuleProviderLookup::Named}; }); + } else { + for (QualifiedId providerName = moduleName; !providerName.empty(); + providerName.pop_back()) { + providersToRun.push_back({providerName, ModuleProviderLookup::Scoped}); + } + } + result = findModuleProvider(providersToRun, productContext, dependsItemLocation); + + if (fallbackMode == FallbackMode::Enabled + && !result.providerFound + && !providerNames) { + qCDebug(lcModuleLoader) << "Specific module provider not found for" + << moduleName.toString() << ", setting up fallback."; + result = findModuleProvider( + {{moduleName, ModuleProviderLookup::Fallback}}, + productContext, + dependsItemLocation); + } + + return result; +} + +ModuleProviderLoader::ModuleProviderResult ModuleProviderLoader::findModuleProvider( + const std::vector &providers, + ProductContext &product, + const CodeLocation &dependsItemLocation) +{ + if (providers.empty()) + return {}; + QStringList allSearchPaths; + ModuleProviderResult result; + for (const auto &[name, lookupType] : providers) { + const QVariantMap config = moduleProviderConfig(product).value(name.toString()).toMap(); + ModuleProviderInfo &info = + m_storedModuleProviderInfo.providers[{name.toString(), config, int(lookupType)}]; + const bool fromCache = !info.name.isEmpty(); + if (!fromCache) { + info.name = name; + info.config = config; + info.providerFile = findModuleProviderFile(name, lookupType); + if (!info.providerFile.isEmpty()) { + qCDebug(lcModuleLoader) << "Running provider" << name << "at" << info.providerFile; + info.searchPaths = getProviderSearchPaths( + name, info.providerFile, product, config, dependsItemLocation); + info.transientOutput = m_parameters.dryRun(); + } + } + if (info.providerFile.isEmpty()) { + if (lookupType == ModuleProviderLookup::Named) + throw ErrorInfo(Tr::tr("Unknown provider '%1'").arg(name.toString())); + continue; + } + if (fromCache) + qCDebug(lcModuleLoader) << "Re-using provider" << name << "from cache"; + + result.providerFound = true; + if (info.searchPaths.empty()) { + qCDebug(lcModuleLoader) + << "Module provider did run, but did not set up any modules."; + continue; + } + qCDebug(lcModuleLoader) << "Module provider added" << info.searchPaths.size() + << "new search path(s)"; + + allSearchPaths << info.searchPaths; + } + if (allSearchPaths.isEmpty()) + return result; + + m_reader->pushExtraSearchPaths(allSearchPaths); + result.providerAddedSearchPaths = true; + + return result; +} + +QVariantMap ModuleProviderLoader::moduleProviderConfig( + ProductContext &product) +{ + if (product.theModuleProviderConfig) + return *product.theModuleProviderConfig; + QVariantMap providerConfig; + const ItemValueConstPtr configItemValue = + product.item->itemProperty(StringConstants::moduleProviders()); + if (configItemValue) { + const std::function collectMap + = [this, &providerConfig, &collectMap](const Item *item, const QualifiedId &name) { + const Item::PropertyMap &props = item->properties(); + for (auto it = props.begin(); it != props.end(); ++it) { + QVariant value; + switch (it.value()->type()) { + case Value::ItemValueType: { + const auto childItem = static_cast(it.value().get())->item(); + childItem->setScope(item->scope()); + collectMap(childItem, QualifiedId(name) << it.key()); + continue; + } + case Value::JSSourceValueType: + value = m_evaluator->value(item, it.key()).toVariant(); + break; + case Value::VariantValueType: + value = static_cast(it.value().get())->value(); + break; + } + QVariantMap m = providerConfig.value(name.toString()).toMap(); + m.insert(it.key(), value); + providerConfig.insert(name.toString(), m); + } + }; + configItemValue->item()->setScope(product.item); + collectMap(configItemValue->item(), QualifiedId()); + } + for (auto it = product.moduleProperties.begin(); it != product.moduleProperties.end(); ++it) { + if (!it.key().startsWith(QStringLiteral("moduleProviders."))) + continue; + const QString provider = it.key().mid(QStringLiteral("moduleProviders.").size()); + const QVariantMap providerConfigFromBuildConfig = it.value().toMap(); + if (providerConfigFromBuildConfig.empty()) + continue; + QVariantMap currentMapForProvider = providerConfig.value(provider).toMap(); + for (auto propIt = providerConfigFromBuildConfig.begin(); + propIt != providerConfigFromBuildConfig.end(); ++propIt) { + currentMapForProvider.insert(propIt.key(), propIt.value()); + } + providerConfig.insert(provider, currentMapForProvider); + } + return *(product.theModuleProviderConfig = std::move(providerConfig)); +} + +std::optional> ModuleProviderLoader::getModuleProviders(Item *item) +{ + while (item) { + const auto providers = + m_evaluator->optionalStringListValue(item, StringConstants::qbsModuleProviders()); + if (providers) { + return transformed>(*providers, [](const auto &provider) { + return QualifiedId::fromString(provider); }); + } + item = item->parent(); + } + return std::nullopt; +} + +QString ModuleProviderLoader::findModuleProviderFile( + const QualifiedId &name, ModuleProviderLookup lookupType) +{ + for (const QString &path : m_reader->allSearchPaths()) { + QString fullPath = FileInfo::resolvePath(path, QStringLiteral("module-providers")); + switch (lookupType) { + case ModuleProviderLookup::Named: { + const auto result = + FileInfo::resolvePath(fullPath, name.toString() + QStringLiteral(".qbs")); + if (FileInfo::exists(result)) { + fullPath = result; + break; + } + [[fallthrough]]; + } + case ModuleProviderLookup::Scoped: + for (const QString &component : name) + fullPath = FileInfo::resolvePath(fullPath, component); + fullPath = FileInfo::resolvePath(fullPath, QStringLiteral("provider.qbs")); + break; + case ModuleProviderLookup::Fallback: + fullPath = FileInfo::resolvePath(fullPath, QStringLiteral("__fallback/provider.qbs")); + break; + } + if (!FileInfo::exists(fullPath)) { + qCDebug(lcModuleLoader) << "No module provider found at" << fullPath; + continue; + } + return fullPath; + } + return {}; +} + +QStringList ModuleProviderLoader::getProviderSearchPaths( + const QualifiedId &name, + const QString &providerFile, + ProductContext &product, + const QVariantMap &moduleConfig, + const CodeLocation &location) +{ + QTemporaryFile dummyItemFile; + if (!dummyItemFile.open()) { + throw ErrorInfo(Tr::tr("Failed to create temporary file for running module provider " + "for dependency '%1': %2").arg(name.toString(), + dummyItemFile.errorString())); + } + m_tempQbsFiles << dummyItemFile.fileName(); + qCDebug(lcModuleLoader) << "Instantiating module provider at" << providerFile; + const QString projectBuildDir = product.project->item->variantProperty( + StringConstants::buildDirectoryProperty())->value().toString(); + const QString searchPathBaseDir = ModuleProviderInfo::outputDirPath(projectBuildDir, name); + QTextStream stream(&dummyItemFile); + using Qt::endl; + setupDefaultCodec(stream); + stream << "import qbs.FileInfo" << endl; + stream << "import qbs.Utilities" << endl; + stream << "import '" << providerFile << "' as Provider" << endl; + stream << "Provider {" << endl; + stream << " name: " << toJSLiteral(name.toString()) << endl; + stream << " property var config: (" << toJSLiteral(moduleConfig) << ')' << endl; + stream << " outputBaseDir: FileInfo.joinPaths(baseDirPrefix, " + " Utilities.getHash(JSON.stringify(config)))" << endl; + stream << " property string baseDirPrefix: " << toJSLiteral(searchPathBaseDir) << endl; + stream << " property stringList searchPaths: (relativeSearchPaths || [])" + " .map(function(p) { return FileInfo.joinPaths(outputBaseDir, p); })" + << endl; + stream << "}" << endl; + stream.flush(); + Item * const providerItem = + m_reader->readFile(dummyItemFile.fileName(), location); + if (providerItem->type() != ItemType::ModuleProvider) { + throw ErrorInfo(Tr::tr("File '%1' declares an item of type '%2', " + "but '%3' was expected.") + .arg(providerFile, providerItem->typeName(), + BuiltinDeclarations::instance().nameForType(ItemType::ModuleProvider))); + } + providerItem->setParent(product.item); + providerItem->overrideProperties(moduleConfig, name.toString(), m_parameters, m_logger); + + m_probesResolver->resolveProbes(&product, providerItem); + + EvalContextSwitcher contextSwitcher(m_evaluator->engine(), EvalContext::ModuleProvider); + return m_evaluator->stringListValue(providerItem, QStringLiteral("searchPaths")); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/moduleproviderloader.h b/src/lib/corelib/language/moduleproviderloader.h new file mode 100644 index 00000000..b0571a54 --- /dev/null +++ b/src/lib/corelib/language/moduleproviderloader.h @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MODULEPROVIDERLOADER_H +#define MODULEPROVIDERLOADER_H + +#include "moduleloader.h" +#include "moduleproviderinfo.h" +#include "probesresolver.h" + +#include +#include + +namespace qbs { +namespace Internal { + +class Logger; + +class ModuleProviderLoader +{ +public: + using ProductContext = ModuleLoader::ProductContext; + using FallbackMode = ModuleLoader::FallbackMode; + explicit ModuleProviderLoader(ItemReader *itemReader, Evaluator *evaluator, + ProbesResolver *probesResolver, Logger &logger); + + enum class ModuleProviderLookup { Scoped, Named, Fallback }; + + struct Provider + { + QualifiedId name; + ModuleProviderLookup lookup; + }; + + struct ModuleProviderResult + { + ModuleProviderResult() = default; + ModuleProviderResult(bool ran, bool added) + : providerFound(ran), providerAddedSearchPaths(added) {} + bool providerFound = false; + bool providerAddedSearchPaths = false; + }; + + const StoredModuleProviderInfo &storedModuleProviderInfo() const + { + return m_storedModuleProviderInfo; + } + + void setStoredModuleProviderInfo(StoredModuleProviderInfo moduleProviderInfo) + { + m_storedModuleProviderInfo = std::move(moduleProviderInfo); + } + + void setProjectParameters(SetupProjectParameters parameters) + { + m_parameters = std::move(parameters); + } + + ModuleProviderResult executeModuleProvider( + ProductContext &productContext, + const CodeLocation &dependsItemLocation, + const QualifiedId &moduleName, + FallbackMode fallbackMode); + ModuleProviderResult findModuleProvider( + const std::vector &providers, + ProductContext &product, + const CodeLocation &dependsItemLocation); + QVariantMap moduleProviderConfig(ProductContext &product); + + const Set &tempQbsFiles() const { return m_tempQbsFiles; } + + std::optional> getModuleProviders(Item *item); + +private: + QString findModuleProviderFile(const QualifiedId &name, ModuleProviderLookup lookupType); + QStringList getProviderSearchPaths( + const QualifiedId &name, + const QString &providerFile, + ProductContext &product, + const QVariantMap &moduleConfig, + const CodeLocation &location); + +private: + ItemReader *const m_reader{nullptr}; + Evaluator *const m_evaluator{nullptr}; + ProbesResolver *const m_probesResolver{nullptr}; + + SetupProjectParameters m_parameters; + Logger &m_logger; + StoredModuleProviderInfo m_storedModuleProviderInfo; + Set m_tempQbsFiles; +}; + +} // namespace Internal +} // namespace qbs + +#endif // MODULEPROVIDERLOADER_H diff --git a/src/lib/corelib/language/preparescriptobserver.cpp b/src/lib/corelib/language/preparescriptobserver.cpp new file mode 100644 index 00000000..632cbfb5 --- /dev/null +++ b/src/lib/corelib/language/preparescriptobserver.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "preparescriptobserver.h" + +#include "property.h" +#include "scriptengine.h" + +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +PrepareScriptObserver::PrepareScriptObserver(ScriptEngine *engine, UnobserveMode unobserveMode) + : ScriptPropertyObserver(engine, unobserveMode) +{ +} + +void PrepareScriptObserver::onPropertyRead(const QScriptValue &object, const QString &name, + const QScriptValue &value) +{ + const auto objectId = object.objectId(); + const auto projectIt = m_projectObjectIds.find(objectId); + if (projectIt != m_projectObjectIds.cend()) { + engine()->addPropertyRequestedInScript( + Property(projectIt->second, QString(), name, value.toVariant(), + Property::PropertyInProject)); + return; + } + if (m_importIds.contains(objectId)) { + engine()->addImportRequestedInScript(object.objectId()); + return; + } + const auto exportsIt = m_exportsObjectIds.find(value.objectId()); + if (exportsIt != m_exportsObjectIds.cend()) { + engine()->addRequestedExport(exportsIt->second); + return; + } + const auto it = m_parameterObjects.find(objectId); + if (it != m_parameterObjects.cend()) { + engine()->addPropertyRequestedInScript( + Property(it->second.first, it->second.second, name, value.toVariant(), + Property::PropertyInParameters)); + } + if (name == StringConstants::fileTagsProperty() && m_artifactIds.contains(objectId)) { + const Artifact * const artifact = attachedPointer(object); + QBS_CHECK(artifact); + const Property p(artifact->product->uniqueName(), QString(), name, value.toVariant(), + Property::PropertyInArtifact); + engine()->addPropertyRequestedFromArtifact(artifact, p); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/preparescriptobserver.h b/src/lib/corelib/language/preparescriptobserver.h new file mode 100644 index 00000000..36e395ef --- /dev/null +++ b/src/lib/corelib/language/preparescriptobserver.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PREPARESCRIPTOBSERVER_H +#define QBS_PREPARESCRIPTOBSERVER_H + +#include "qualifiedid.h" +#include "scriptpropertyobserver.h" + +#include + +#include + +#include + +namespace qbs { +namespace Internal { +class ResolvedProduct; +class ScriptEngine; + +class PrepareScriptObserver : public ScriptPropertyObserver +{ +public: + PrepareScriptObserver(ScriptEngine *engine, UnobserveMode unobserveMode); + + void addProjectObjectId(qint64 projectId, const QString &projectName) + { + m_projectObjectIds.insert(std::make_pair(projectId, projectName)); + } + + void addExportsObjectId(qint64 exportsId, const ResolvedProduct *product) + { + m_exportsObjectIds.insert(std::make_pair(exportsId, product)); + } + + void addArtifactId(qint64 artifactId) { m_artifactIds.insert(artifactId); } + bool addImportId(qint64 importId) { return m_importIds.insert(importId).second; } + void clearImportIds() { m_importIds.clear(); } + void addParameterObjectId(qint64 id, const QString &productName, const QString &depName, + const QualifiedId &moduleName) + { + const QString depAndModuleName = depName + QLatin1Char(':') + moduleName.toString(); + const auto value = std::make_pair(productName, depAndModuleName); + m_parameterObjects.insert(std::make_pair(id, value)); + } + +private: + void onPropertyRead(const QScriptValue &object, const QString &name, + const QScriptValue &value) override; + + std::unordered_map m_projectObjectIds; + std::unordered_map> m_parameterObjects; + std::unordered_map m_exportsObjectIds; + Set m_importIds; + Set m_artifactIds; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/language/probesresolver.cpp b/src/lib/corelib/language/probesresolver.cpp new file mode 100644 index 00000000..05908015 --- /dev/null +++ b/src/lib/corelib/language/probesresolver.cpp @@ -0,0 +1,299 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2022 Raphaël Cotty +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "probesresolver.h" + +#include "builtindeclarations.h" +#include "evaluator.h" +#include "filecontext.h" +#include "item.h" +#include "itemreader.h" +#include "language.h" +#include "modulemerger.h" +#include "qualifiedid.h" +#include "scriptengine.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +static QString probeGlobalId(Item *probe) +{ + QString id; + + for (Item *obj = probe; obj; obj = obj->prototype()) { + if (!obj->id().isEmpty()) { + id = obj->id(); + break; + } + } + + if (id.isEmpty()) + return {}; + + QBS_CHECK(probe->file()); + return id + QLatin1Char('_') + probe->file()->filePath(); +} + +ProbesResolver::ProbesResolver(Evaluator *evaluator, Logger &logger) + : m_evaluator(evaluator) + , m_logger(logger) +{ +} + +void ProbesResolver::setProjectParameters(SetupProjectParameters parameters) +{ + m_parameters = std::move(parameters); + m_elapsedTimeProbes = m_probesEncountered = m_probesRun = m_probesCachedCurrent + = m_probesCachedOld = 0; +} + +void ProbesResolver::setOldProjectProbes(const std::vector &oldProbes) +{ + m_oldProjectProbes.clear(); + for (const ProbeConstPtr& probe : oldProbes) + m_oldProjectProbes[probe->globalId()] << probe; +} + +void ProbesResolver::setOldProductProbes( + const QHash> &oldProbes) +{ + m_oldProductProbes = oldProbes; +} + +void ProbesResolver::resolveProbes(ModuleLoader::ProductContext *productContext, Item *item) +{ + AccumulatingTimer probesTimer(m_parameters.logElapsedTime() ? &m_elapsedTimeProbes : nullptr); + EvalContextSwitcher evalContextSwitcher(m_evaluator->engine(), EvalContext::ProbeExecution); + for (Item * const child : item->children()) + if (child->type() == ItemType::Probe) + resolveProbe(productContext, item, child); +} + +void ProbesResolver::resolveProbe(ModuleLoader::ProductContext *productContext, Item *parent, + Item *probe) +{ + qCDebug(lcModuleLoader) << "Resolving Probe at " << probe->location().toString(); + ++m_probesEncountered; + const QString &probeId = probeGlobalId(probe); + if (Q_UNLIKELY(probeId.isEmpty())) + throw ErrorInfo(Tr::tr("Probe.id must be set."), probe->location()); + const JSSourceValueConstPtr configureScript + = probe->sourceProperty(StringConstants::configureProperty()); + QBS_CHECK(configureScript); + if (Q_UNLIKELY(configureScript->sourceCode() == StringConstants::undefinedValue())) + throw ErrorInfo(Tr::tr("Probe.configure must be set."), probe->location()); + using ProbeProperty = std::pair; + std::vector probeBindings; + QVariantMap initialProperties; + for (Item *obj = probe; obj; obj = obj->prototype()) { + const Item::PropertyMap &props = obj->properties(); + for (auto it = props.cbegin(); it != props.cend(); ++it) { + const QString &name = it.key(); + if (name == StringConstants::configureProperty()) + continue; + const QScriptValue value = m_evaluator->value(probe, name); + probeBindings << ProbeProperty(name, value); + if (name != StringConstants::conditionProperty()) + initialProperties.insert(name, value.toVariant()); + } + } + ScriptEngine * const engine = m_evaluator->engine(); + QScriptValue configureScope; + const bool condition = m_evaluator->boolValue(probe, StringConstants::conditionProperty()); + const QString &sourceCode = configureScript->sourceCode().toString(); + ProbeConstPtr resolvedProbe; + if (parent->type() == ItemType::Project + || productContext->name.startsWith(StringConstants::shadowProductPrefix())) { + resolvedProbe = findOldProjectProbe(probeId, condition, initialProperties, sourceCode); + } else { + const QString &uniqueProductName = productContext->uniqueName(); + resolvedProbe + = findOldProductProbe(uniqueProductName, condition, initialProperties, sourceCode); + } + if (!resolvedProbe) { + resolvedProbe = findCurrentProbe(probe->location(), condition, initialProperties); + if (resolvedProbe) { + qCDebug(lcModuleLoader) << "probe results cached from current run"; + ++m_probesCachedCurrent; + } + } else { + qCDebug(lcModuleLoader) << "probe results cached from earlier run"; + ++m_probesCachedOld; + } + std::vector importedFilesUsedInConfigure; + if (!condition) { + qCDebug(lcModuleLoader) << "Probe disabled; skipping"; + } else if (!resolvedProbe) { + ++m_probesRun; + qCDebug(lcModuleLoader) << "configure script needs to run"; + const Evaluator::FileContextScopes fileCtxScopes + = m_evaluator->fileContextScopes(configureScript->file()); + engine->currentContext()->pushScope(fileCtxScopes.fileScope); + engine->currentContext()->pushScope(fileCtxScopes.importScope); + configureScope = engine->newObject(); + for (const ProbeProperty &b : probeBindings) + configureScope.setProperty(b.first, b.second); + engine->currentContext()->pushScope(configureScope); + engine->clearRequestedProperties(); + QScriptValue sv = engine->evaluate(configureScript->sourceCodeForEvaluation()); + engine->currentContext()->popScope(); + engine->currentContext()->popScope(); + engine->currentContext()->popScope(); + engine->releaseResourcesOfScriptObjects(); + if (Q_UNLIKELY(engine->hasErrorOrException(sv))) + throw ErrorInfo(engine->lastErrorString(sv), configureScript->location()); + importedFilesUsedInConfigure = engine->importedFilesUsedInScript(); + } else { + importedFilesUsedInConfigure = resolvedProbe->importedFilesUsed(); + } + QVariantMap properties; + for (const ProbeProperty &b : probeBindings) { + QVariant newValue; + if (resolvedProbe) { + newValue = resolvedProbe->properties().value(b.first); + } else { + if (condition) { + QScriptValue v = configureScope.property(b.first); + m_evaluator->convertToPropertyType(probe->propertyDeclaration( + b.first), probe->location(), v); + if (Q_UNLIKELY(engine->hasErrorOrException(v))) + throw ErrorInfo(engine->lastError(v)); + newValue = v.toVariant(); + } else { + newValue = initialProperties.value(b.first); + } + } + if (newValue != b.second.toVariant()) + probe->setProperty(b.first, VariantValue::create(newValue)); + if (!resolvedProbe) + properties.insert(b.first, newValue); + } + if (!resolvedProbe) { + resolvedProbe = Probe::create(probeId, probe->location(), condition, + sourceCode, properties, initialProperties, + importedFilesUsedInConfigure); + m_currentProbes[probe->location()] << resolvedProbe; + } + productContext->info.probes << resolvedProbe; +} + +ProbeConstPtr ProbesResolver::findOldProjectProbe( + const QString &globalId, + bool condition, + const QVariantMap &initialProperties, + const QString &sourceCode) const +{ + if (m_parameters.forceProbeExecution()) + return {}; + + for (const ProbeConstPtr &oldProbe : m_oldProjectProbes.value(globalId)) { + if (probeMatches(oldProbe, condition, initialProperties, sourceCode, CompareScript::Yes)) + return oldProbe; + } + + return {}; +} + +ProbeConstPtr ProbesResolver::findOldProductProbe( + const QString &productName, + bool condition, + const QVariantMap &initialProperties, + const QString &sourceCode) const +{ + if (m_parameters.forceProbeExecution()) + return {}; + + for (const ProbeConstPtr &oldProbe : m_oldProductProbes.value(productName)) { + if (probeMatches(oldProbe, condition, initialProperties, sourceCode, CompareScript::Yes)) + return oldProbe; + } + + return {}; +} + +ProbeConstPtr ProbesResolver::findCurrentProbe( + const CodeLocation &location, + bool condition, + const QVariantMap &initialProperties) const +{ + const std::vector &cachedProbes = m_currentProbes.value(location); + for (const ProbeConstPtr &probe : cachedProbes) { + if (probeMatches(probe, condition, initialProperties, QString(), CompareScript::No)) + return probe; + } + return {}; +} + +bool ProbesResolver::probeMatches(const ProbeConstPtr &probe, bool condition, + const QVariantMap &initialProperties, const QString &configureScript, + CompareScript compareScript) const +{ + return probe->condition() == condition + && probe->initialProperties() == initialProperties + && (compareScript == CompareScript::No + || (probe->configureScript() == configureScript + && !probe->needsReconfigure(m_lastResolveTime))); +} + +void ProbesResolver::printProfilingInfo() +{ + if (!m_parameters.logElapsedTime()) + return; + m_logger.qbsLog(LoggerInfo, true) << "\t\t" + << Tr::tr("Running Probes took %1.") + .arg(elapsedTimeString(m_elapsedTimeProbes)); + m_logger.qbsLog(LoggerInfo, true) << "\t\t" + << Tr::tr("%1 probes encountered, %2 configure scripts executed, " + "%3 re-used from current run, %4 re-used from earlier run.") + .arg(m_probesEncountered).arg(m_probesRun).arg(m_probesCachedCurrent) + .arg(m_probesCachedOld); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/probesresolver.h b/src/lib/corelib/language/probesresolver.h new file mode 100644 index 00000000..1aeec27c --- /dev/null +++ b/src/lib/corelib/language/probesresolver.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2022 Raphaël Cotty +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PROBESRESOLVER_H +#define PROBESRESOLVER_H + +#include "moduleloader.h" + +namespace qbs { +namespace Internal { + +class ProbesResolver +{ +public: + explicit ProbesResolver(Evaluator *evaluator, Logger &logger); + void setProjectParameters(SetupProjectParameters parameters); + void setOldProjectProbes(const std::vector &oldProbes); + void setOldProductProbes(const QHash> &oldProbes); + void resolveProbes(ModuleLoader::ProductContext *productContext, Item *item); + void resolveProbe(ModuleLoader::ProductContext *productContext, Item *parent, Item *probe); + void printProfilingInfo(); + +private: + ProbeConstPtr findOldProjectProbe(const QString &globalId, bool condition, + const QVariantMap &initialProperties, + const QString &sourceCode) const; + ProbeConstPtr findOldProductProbe(const QString &productName, bool condition, + const QVariantMap &initialProperties, + const QString &sourceCode) const; + ProbeConstPtr findCurrentProbe(const CodeLocation &location, bool condition, + const QVariantMap &initialProperties) const; + enum class CompareScript { No, Yes }; + bool probeMatches(const ProbeConstPtr &probe, bool condition, + const QVariantMap &initialProperties, const QString &configureScript, + CompareScript compareScript) const; + + qint64 m_elapsedTimeProbes = 0; + quint64 m_probesEncountered = 0; + quint64 m_probesRun = 0; + quint64 m_probesCachedCurrent = 0; + quint64 m_probesCachedOld = 0; + + SetupProjectParameters m_parameters; + Evaluator *m_evaluator = nullptr; + Logger &m_logger; + QHash> m_oldProjectProbes; + QHash> m_oldProductProbes; + FileTime m_lastResolveTime; + QHash> m_currentProbes; +}; + +} // namespace Internal +} // namespace qbs + +#endif // PROBESRESOLVER_H diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp new file mode 100644 index 00000000..d7ae11aa --- /dev/null +++ b/src/lib/corelib/language/projectresolver.cpp @@ -0,0 +1,1920 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "projectresolver.h" + +#include "artifactproperties.h" +#include "builtindeclarations.h" +#include "evaluator.h" +#include "filecontext.h" +#include "item.h" +#include "language.h" +#include "propertymapinternal.h" +#include "resolvedfilecontext.h" +#include "scriptengine.h" +#include "value.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +extern bool debugProperties; + +static const FileTag unknownFileTag() +{ + static const FileTag tag("unknown-file-tag"); + return tag; +} + +struct ProjectResolver::ProjectContext +{ + ProjectContext *parentContext = nullptr; + ResolvedProjectPtr project; + std::vector fileTaggers; + std::vector rules; + JobLimits jobLimits; + ResolvedModulePtr dummyModule; +}; + +struct ProjectResolver::ProductContext +{ + ResolvedProductPtr product; + QString buildDirectory; + Item *item = nullptr; + using ArtifactPropertiesInfo = std::pair>; + QHash artifactPropertiesPerFilter; + ProjectResolver::FileLocations sourceArtifactLocations; + GroupConstPtr currentGroup; +}; + +struct ProjectResolver::ModuleContext +{ + ResolvedModulePtr module; + JobLimits jobLimits; +}; + +class CancelException { }; + + +ProjectResolver::ProjectResolver(Evaluator *evaluator, ModuleLoaderResult loadResult, + SetupProjectParameters setupParameters, Logger &logger) + : m_evaluator(evaluator) + , m_logger(logger) + , m_engine(m_evaluator->engine()) + , m_progressObserver(nullptr) + , m_setupParams(std::move(setupParameters)) + , m_loadResult(std::move(loadResult)) +{ + QBS_CHECK(FileInfo::isAbsolute(m_setupParams.buildRoot())); +} + +ProjectResolver::~ProjectResolver() = default; + +void ProjectResolver::setProgressObserver(ProgressObserver *observer) +{ + m_progressObserver = observer; +} + +static void checkForDuplicateProductNames(const TopLevelProjectConstPtr &project) +{ + const std::vector allProducts = project->allProducts(); + for (size_t i = 0; i < allProducts.size(); ++i) { + const ResolvedProductConstPtr product1 = allProducts.at(i); + const QString productName = product1->uniqueName(); + for (size_t j = i + 1; j < allProducts.size(); ++j) { + const ResolvedProductConstPtr product2 = allProducts.at(j); + if (product2->uniqueName() == productName) { + ErrorInfo error; + error.append(Tr::tr("Duplicate product name '%1'.").arg(product1->name)); + error.append(Tr::tr("First product defined here."), product1->location); + error.append(Tr::tr("Second product defined here."), product2->location); + throw error; + } + } + } +} + +TopLevelProjectPtr ProjectResolver::resolve() +{ + TimedActivityLogger projectResolverTimer(m_logger, Tr::tr("ProjectResolver"), + m_setupParams.logElapsedTime()); + qCDebug(lcProjectResolver) << "resolving" << m_loadResult.root->file()->filePath(); + + m_productContext = nullptr; + m_moduleContext = nullptr; + m_elapsedTimeModPropEval = m_elapsedTimeAllPropEval = m_elapsedTimeGroups = 0; + TopLevelProjectPtr tlp; + try { + tlp = resolveTopLevelProject(); + printProfilingInfo(); + } catch (const CancelException &) { + throw ErrorInfo(Tr::tr("Project resolving canceled for configuration '%1'.") + .arg(TopLevelProject::deriveId(m_setupParams.finalBuildConfigurationTree()))); + } + return tlp; +} + +void ProjectResolver::checkCancelation() const +{ + if (m_progressObserver && m_progressObserver->canceled()) + throw CancelException(); +} + +QString ProjectResolver::verbatimValue(const ValueConstPtr &value, bool *propertyWasSet) const +{ + QString result; + if (value && value->type() == Value::JSSourceValueType) { + const JSSourceValueConstPtr sourceValue = std::static_pointer_cast( + value); + result = sourceCodeForEvaluation(sourceValue); + if (propertyWasSet) + *propertyWasSet = !sourceValue->isBuiltinDefaultValue(); + } else { + if (propertyWasSet) + *propertyWasSet = false; + } + return result; +} + +QString ProjectResolver::verbatimValue(Item *item, const QString &name, bool *propertyWasSet) const +{ + return verbatimValue(item->property(name), propertyWasSet); +} + +void ProjectResolver::ignoreItem(Item *item, ProjectContext *projectContext) +{ + Q_UNUSED(item); + Q_UNUSED(projectContext); +} + +static void makeSubProjectNamesUniqe(const ResolvedProjectPtr &parentProject) +{ + Set subProjectNames; + Set projectsInNeedOfNameChange; + for (const ResolvedProjectPtr &p : qAsConst(parentProject->subProjects)) { + if (!subProjectNames.insert(p->name).second) + projectsInNeedOfNameChange << p; + makeSubProjectNamesUniqe(p); + } + while (!projectsInNeedOfNameChange.empty()) { + auto it = projectsInNeedOfNameChange.begin(); + while (it != projectsInNeedOfNameChange.end()) { + const ResolvedProjectPtr p = *it; + p->name += QLatin1Char('_'); + if (subProjectNames.insert(p->name).second) { + it = projectsInNeedOfNameChange.erase(it); + } else { + ++it; + } + } + } +} + +TopLevelProjectPtr ProjectResolver::resolveTopLevelProject() +{ + if (m_progressObserver) + m_progressObserver->setMaximum(int(m_loadResult.productInfos.size())); + const TopLevelProjectPtr project = TopLevelProject::create(); + project->buildDirectory = TopLevelProject::deriveBuildDirectory(m_setupParams.buildRoot(), + TopLevelProject::deriveId(m_setupParams.finalBuildConfigurationTree())); + project->buildSystemFiles = m_loadResult.qbsFiles; + project->profileConfigs = m_loadResult.profileConfigs; + project->probes = m_loadResult.projectProbes; + project->moduleProviderInfo = m_loadResult.storedModuleProviderInfo; + ProjectContext projectContext; + projectContext.project = project; + + resolveProject(m_loadResult.root, &projectContext); + ErrorInfo accumulatedErrors; + for (const ErrorInfo &e : m_queuedErrors) + appendError(accumulatedErrors, e); + if (accumulatedErrors.hasError()) + throw accumulatedErrors; + + project->setBuildConfiguration(m_setupParams.finalBuildConfigurationTree()); + project->overriddenValues = m_setupParams.overriddenValues(); + project->canonicalFilePathResults = m_engine->canonicalFilePathResults(); + project->fileExistsResults = m_engine->fileExistsResults(); + project->directoryEntriesResults = m_engine->directoryEntriesResults(); + project->fileLastModifiedResults = m_engine->fileLastModifiedResults(); + project->environment = m_engine->environment(); + project->buildSystemFiles.unite(m_engine->imports()); + makeSubProjectNamesUniqe(project); + resolveProductDependencies(projectContext); + collectExportedProductDependencies(); + checkForDuplicateProductNames(project); + + for (const ResolvedProductPtr &product : project->allProducts()) { + if (!product->enabled) + continue; + + applyFileTaggers(product); + matchArtifactProperties(product, product->allEnabledFiles()); + + // Let a positive value of qbs.install imply the file tag "installable". + for (const SourceArtifactPtr &artifact : product->allFiles()) { + if (artifact->properties->qbsPropertyValue(StringConstants::installProperty()).toBool()) + artifact->fileTags += "installable"; + } + } + project->warningsEncountered = m_logger.warnings(); + return project; +} + +void ProjectResolver::resolveProject(Item *item, ProjectContext *projectContext) +{ + checkCancelation(); + + if (projectContext->parentContext) + projectContext->project->enabled = projectContext->parentContext->project->enabled; + projectContext->project->location = item->location(); + try { + resolveProjectFully(item, projectContext); + } catch (const ErrorInfo &error) { + if (!projectContext->project->enabled) { + qCDebug(lcProjectResolver) << "error resolving project" + << projectContext->project->location << error.toString(); + return; + } + if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict) + throw; + m_logger.printWarning(error); + } +} + +void ProjectResolver::resolveProjectFully(Item *item, ProjectResolver::ProjectContext *projectContext) +{ + projectContext->project->enabled = projectContext->project->enabled + && m_evaluator->boolValue(item, StringConstants::conditionProperty()); + projectContext->project->name = m_evaluator->stringValue(item, StringConstants::nameProperty()); + if (projectContext->project->name.isEmpty()) + projectContext->project->name = FileInfo::baseName(item->location().filePath()); // FIXME: Must also be changed in item? + QVariantMap projectProperties; + if (!projectContext->project->enabled) { + projectProperties.insert(StringConstants::profileProperty(), + m_evaluator->stringValue(item, + StringConstants::profileProperty())); + projectContext->project->setProjectProperties(projectProperties); + return; + } + + projectContext->dummyModule = ResolvedModule::create(); + + for (Item::PropertyDeclarationMap::const_iterator it + = item->propertyDeclarations().constBegin(); + it != item->propertyDeclarations().constEnd(); ++it) { + if (it.value().flags().testFlag(PropertyDeclaration::PropertyNotAvailableInConfig)) + continue; + const ValueConstPtr v = item->property(it.key()); + QBS_ASSERT(v && v->type() != Value::ItemValueType, continue); + projectProperties.insert(it.key(), m_evaluator->value(item, it.key()).toVariant()); + } + projectContext->project->setProjectProperties(projectProperties); + + static const ItemFuncMap mapping = { + { ItemType::Project, &ProjectResolver::resolveProject }, + { ItemType::SubProject, &ProjectResolver::resolveSubProject }, + { ItemType::Product, &ProjectResolver::resolveProduct }, + { ItemType::Probe, &ProjectResolver::ignoreItem }, + { ItemType::FileTagger, &ProjectResolver::resolveFileTagger }, + { ItemType::JobLimit, &ProjectResolver::resolveJobLimit }, + { ItemType::Rule, &ProjectResolver::resolveRule }, + { ItemType::PropertyOptions, &ProjectResolver::ignoreItem } + }; + + for (Item * const child : item->children()) { + try { + callItemFunction(mapping, child, projectContext); + } catch (const ErrorInfo &e) { + m_queuedErrors.push_back(e); + } + } + + for (const ResolvedProductPtr &product : projectContext->project->products) + postProcess(product, projectContext); +} + +void ProjectResolver::resolveSubProject(Item *item, ProjectResolver::ProjectContext *projectContext) +{ + ProjectContext subProjectContext = createProjectContext(projectContext); + + Item * const projectItem = item->child(ItemType::Project); + if (projectItem) { + resolveProject(projectItem, &subProjectContext); + return; + } + + // No project item was found, which means the project was disabled. + subProjectContext.project->enabled = false; + Item * const propertiesItem = item->child(ItemType::PropertiesInSubProject); + if (propertiesItem) { + subProjectContext.project->name + = m_evaluator->stringValue(propertiesItem, StringConstants::nameProperty()); + } +} + +class ProjectResolver::ProductContextSwitcher +{ +public: + ProductContextSwitcher(ProjectResolver *resolver, ProductContext *newContext, + ProgressObserver *progressObserver) + : m_resolver(resolver), m_progressObserver(progressObserver) + { + QBS_CHECK(!m_resolver->m_productContext); + m_resolver->m_productContext = newContext; + } + + ~ProductContextSwitcher() + { + if (m_progressObserver) + m_progressObserver->incrementProgressValue(); + m_resolver->m_productContext = nullptr; + } + +private: + ProjectResolver * const m_resolver; + ProgressObserver * const m_progressObserver; +}; + +void ProjectResolver::resolveProduct(Item *item, ProjectContext *projectContext) +{ + checkCancelation(); + m_evaluator->clearPropertyDependencies(); + ProductContext productContext; + productContext.item = item; + ResolvedProductPtr product = ResolvedProduct::create(); + product->enabled = projectContext->project->enabled; + product->moduleProperties = PropertyMapInternal::create(); + product->project = projectContext->project; + productContext.product = product; + product->location = item->location(); + ProductContextSwitcher contextSwitcher(this, &productContext, m_progressObserver); + try { + resolveProductFully(item, projectContext); + } catch (const ErrorInfo &e) { + QString mainErrorString = !product->name.isEmpty() + ? Tr::tr("Error while handling product '%1':").arg(product->name) + : Tr::tr("Error while handling product:"); + ErrorInfo fullError(mainErrorString, item->location()); + appendError(fullError, e); + if (!product->enabled) { + qCDebug(lcProjectResolver) << fullError.toString(); + return; + } + if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict) + throw fullError; + m_logger.printWarning(fullError); + m_logger.printWarning(ErrorInfo(Tr::tr("Product '%1' had errors and was disabled.") + .arg(product->name), item->location())); + product->enabled = false; + } +} + +void ProjectResolver::resolveProductFully(Item *item, ProjectContext *projectContext) +{ + const ResolvedProductPtr product = m_productContext->product; + m_productItemMap.insert(product, item); + projectContext->project->products.push_back(product); + product->name = m_evaluator->stringValue(item, StringConstants::nameProperty()); + + // product->buildDirectory() isn't valid yet, because the productProperties map is not ready. + m_productContext->buildDirectory + = m_evaluator->stringValue(item, StringConstants::buildDirectoryProperty()); + product->multiplexConfigurationId + = m_evaluator->stringValue(item, StringConstants::multiplexConfigurationIdProperty()); + qCDebug(lcProjectResolver) << "resolveProduct" << product->uniqueName(); + m_productsByName.insert(product->uniqueName(), product); + product->enabled = product->enabled + && m_evaluator->boolValue(item, StringConstants::conditionProperty()); + ModuleLoaderResult::ProductInfo &pi = m_loadResult.productInfos[item]; + if (pi.delayedError.hasError()) { + ErrorInfo errorInfo; + + // First item is "main error", gets prepended again in the catch clause. + const QList &items = pi.delayedError.items(); + for (int i = 1; i < items.size(); ++i) + errorInfo.append(items.at(i)); + + pi.delayedError.clear(); + throw errorInfo; + } + gatherProductTypes(product.get(), item); + product->targetName = m_evaluator->stringValue(item, StringConstants::targetNameProperty()); + product->sourceDirectory = m_evaluator->stringValue( + item, StringConstants::sourceDirectoryProperty()); + product->destinationDirectory = m_evaluator->stringValue( + item, StringConstants::destinationDirProperty()); + + if (product->destinationDirectory.isEmpty()) { + product->destinationDirectory = m_productContext->buildDirectory; + } else { + product->destinationDirectory = FileInfo::resolvePath( + product->topLevelProject()->buildDirectory, + product->destinationDirectory); + } + product->probes = pi.probes; + createProductConfig(product.get()); + product->productProperties.insert(StringConstants::destinationDirProperty(), + product->destinationDirectory); + ModuleProperties::init(m_evaluator->scriptValue(item), product.get()); + + QList subItems = item->children(); + const ValuePtr filesProperty = item->property(StringConstants::filesProperty()); + if (filesProperty) { + Item *fakeGroup = Item::create(item->pool(), ItemType::Group); + fakeGroup->setFile(item->file()); + fakeGroup->setLocation(item->location()); + fakeGroup->setScope(item); + fakeGroup->setProperty(StringConstants::nameProperty(), VariantValue::create(product->name)); + fakeGroup->setProperty(StringConstants::filesProperty(), filesProperty); + fakeGroup->setProperty(StringConstants::excludeFilesProperty(), + item->property(StringConstants::excludeFilesProperty())); + fakeGroup->setProperty(StringConstants::overrideTagsProperty(), + VariantValue::falseValue()); + fakeGroup->setupForBuiltinType(m_logger); + subItems.prepend(fakeGroup); + } + + static const ItemFuncMap mapping = { + { ItemType::Depends, &ProjectResolver::ignoreItem }, + { ItemType::Rule, &ProjectResolver::resolveRule }, + { ItemType::FileTagger, &ProjectResolver::resolveFileTagger }, + { ItemType::JobLimit, &ProjectResolver::resolveJobLimit }, + { ItemType::Group, &ProjectResolver::resolveGroup }, + { ItemType::Product, &ProjectResolver::resolveShadowProduct }, + { ItemType::Export, &ProjectResolver::resolveExport }, + { ItemType::Probe, &ProjectResolver::ignoreItem }, + { ItemType::PropertyOptions, &ProjectResolver::ignoreItem } + }; + + for (Item * const child : qAsConst(subItems)) + callItemFunction(mapping, child, projectContext); + + for (const ProjectContext *p = projectContext; p; p = p->parentContext) { + JobLimits tempLimits = p->jobLimits; + product->jobLimits = tempLimits.update(product->jobLimits); + } + + resolveModules(item, projectContext); + + for (const FileTag &t : qAsConst(product->fileTags)) + m_productsByType[t].push_back(product); +} + +void ProjectResolver::resolveModules(const Item *item, ProjectContext *projectContext) +{ + JobLimits jobLimits; + for (const Item::Module &m : item->modules()) + resolveModule(m.name, m.item, m.isProduct, m.parameters, jobLimits, projectContext); + for (int i = 0; i < jobLimits.count(); ++i) { + const JobLimit &moduleJobLimit = jobLimits.jobLimitAt(i); + if (m_productContext->product->jobLimits.getLimit(moduleJobLimit.pool()) == -1) + m_productContext->product->jobLimits.setJobLimit(moduleJobLimit); + } +} + +void ProjectResolver::resolveModule(const QualifiedId &moduleName, Item *item, bool isProduct, + const QVariantMap ¶meters, JobLimits &jobLimits, + ProjectContext *projectContext) +{ + checkCancelation(); + if (!item->isPresentModule()) + return; + + ModuleContext * const oldModuleContext = m_moduleContext; + ModuleContext moduleContext; + moduleContext.module = ResolvedModule::create(); + m_moduleContext = &moduleContext; + + const ResolvedModulePtr &module = moduleContext.module; + module->name = moduleName.toString(); + module->isProduct = isProduct; + module->product = m_productContext->product.get(); + module->setupBuildEnvironmentScript.initialize( + scriptFunctionValue(item, StringConstants::setupBuildEnvironmentProperty())); + module->setupRunEnvironmentScript.initialize( + scriptFunctionValue(item, StringConstants::setupRunEnvironmentProperty())); + + for (const Item::Module &m : item->modules()) { + if (m.item->isPresentModule()) + module->moduleDependencies += m.name.toString(); + } + + m_productContext->product->modules.push_back(module); + if (!parameters.empty()) + m_productContext->product->moduleParameters[module] = parameters; + + static const ItemFuncMap mapping { + { ItemType::Group, &ProjectResolver::ignoreItem }, + { ItemType::Rule, &ProjectResolver::resolveRule }, + { ItemType::FileTagger, &ProjectResolver::resolveFileTagger }, + { ItemType::JobLimit, &ProjectResolver::resolveJobLimit }, + { ItemType::Scanner, &ProjectResolver::resolveScanner }, + { ItemType::PropertyOptions, &ProjectResolver::ignoreItem }, + { ItemType::Depends, &ProjectResolver::ignoreItem }, + { ItemType::Parameter, &ProjectResolver::ignoreItem }, + { ItemType::Properties, &ProjectResolver::ignoreItem }, + { ItemType::Probe, &ProjectResolver::ignoreItem } + }; + for (Item *child : item->children()) + callItemFunction(mapping, child, projectContext); + for (int i = 0; i < moduleContext.jobLimits.count(); ++i) { + const JobLimit &newJobLimit = moduleContext.jobLimits.jobLimitAt(i); + const int oldLimit = jobLimits.getLimit(newJobLimit.pool()); + if (oldLimit == -1 || oldLimit > newJobLimit.limit()) + jobLimits.setJobLimit(newJobLimit); + } + + m_moduleContext = oldModuleContext; +} + +void ProjectResolver::gatherProductTypes(ResolvedProduct *product, Item *item) +{ + product->fileTags = m_evaluator->fileTagsValue(item, StringConstants::typeProperty()); + for (const Item::Module &m : item->modules()) { + if (m.item->isPresentModule()) { + product->fileTags += m_evaluator->fileTagsValue(m.item, + StringConstants::additionalProductTypesProperty()); + } + } + item->setProperty(StringConstants::typeProperty(), + VariantValue::create(sorted(product->fileTags.toStringList()))); +} + +SourceArtifactPtr ProjectResolver::createSourceArtifact(const ResolvedProductPtr &rproduct, + const QString &fileName, const GroupPtr &group, bool wildcard, + const CodeLocation &filesLocation, FileLocations *fileLocations, + ErrorInfo *errorInfo) +{ + const QString &baseDir = FileInfo::path(group->location.filePath()); + const QString absFilePath = QDir::cleanPath(FileInfo::resolvePath(baseDir, fileName)); + if (!wildcard && !FileInfo(absFilePath).exists()) { + if (errorInfo) + errorInfo->append(Tr::tr("File '%1' does not exist.").arg(absFilePath), filesLocation); + rproduct->missingSourceFiles << absFilePath; + return {}; + } + if (group->enabled && fileLocations) { + CodeLocation &loc = (*fileLocations)[std::make_pair(group->targetOfModule, absFilePath)]; + if (loc.isValid()) { + if (errorInfo) { + errorInfo->append(Tr::tr("Duplicate source file '%1'.").arg(absFilePath)); + errorInfo->append(Tr::tr("First occurrence is here."), loc); + errorInfo->append(Tr::tr("Next occurrence is here."), filesLocation); + } + return {}; + } + loc = filesLocation; + } + SourceArtifactPtr artifact = SourceArtifactInternal::create(); + artifact->absoluteFilePath = absFilePath; + artifact->fileTags = group->fileTags; + artifact->overrideFileTags = group->overrideTags; + artifact->properties = group->properties; + artifact->targetOfModule = group->targetOfModule; + (wildcard ? group->wildcards->files : group->files).push_back(artifact); + return artifact; +} + +static QualifiedIdSet propertiesToEvaluate(std::deque initialProps, + const PropertyDependencies &deps) +{ + std::deque remainingProps = std::move(initialProps); + QualifiedIdSet allProperties; + while (!remainingProps.empty()) { + const QualifiedId prop = remainingProps.front(); + remainingProps.pop_front(); + const auto insertResult = allProperties.insert(prop); + if (!insertResult.second) + continue; + transform(deps.value(prop), remainingProps, [](const QualifiedId &id) { return id; }); + } + return allProperties; +} + +QVariantMap ProjectResolver::resolveAdditionalModuleProperties(const Item *group, + const QVariantMap ¤tValues) +{ + // Step 1: Retrieve the properties directly set in the group + const ModulePropertiesPerGroup &mp = mapValue( + m_loadResult.productInfos, m_productContext->item).modulePropertiesSetInGroups; + const auto it = mp.find(group); + if (it == mp.end()) + return {}; + const QualifiedIdSet &propsSetInGroup = it->second; + + // Step 2: Gather all properties that depend on these properties. + const QualifiedIdSet &propsToEval = propertiesToEvaluate( + rangeTo>(propsSetInGroup), + m_evaluator->propertyDependencies()); + + // Step 3: Evaluate all these properties and replace their values in the map + QVariantMap modulesMap = currentValues; + QHash propsPerModule; + for (auto fullPropName : propsToEval) { + const QString moduleName + = QualifiedId(fullPropName.mid(0, fullPropName.size() - 1)).toString(); + propsPerModule[moduleName] << fullPropName.last(); + } + EvalCacheEnabler cachingEnabler(m_evaluator); + m_evaluator->setPathPropertiesBaseDir(m_productContext->product->sourceDirectory); + for (const Item::Module &module : group->modules()) { + const QString &fullModName = module.name.toString(); + const QStringList propsForModule = propsPerModule.take(fullModName); + if (propsForModule.empty()) + continue; + QVariantMap reusableValues = modulesMap.value(fullModName).toMap(); + for (const QString &prop : qAsConst(propsForModule)) + reusableValues.remove(prop); + modulesMap.insert(fullModName, + evaluateProperties(module.item, module.item, reusableValues, true, true)); + } + m_evaluator->clearPathPropertiesBaseDir(); + return modulesMap; +} + +void ProjectResolver::resolveGroup(Item *item, ProjectContext *projectContext) +{ + checkCancelation(); + const bool parentEnabled = m_productContext->currentGroup + ? m_productContext->currentGroup->enabled + : m_productContext->product->enabled; + const bool isEnabled = parentEnabled + && m_evaluator->boolValue(item, StringConstants::conditionProperty()); + try { + resolveGroupFully(item, projectContext, isEnabled); + } catch (const ErrorInfo &error) { + if (!isEnabled) { + qCDebug(lcProjectResolver) << "error resolving group at" << item->location() + << error.toString(); + return; + } + if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict) + throw; + m_logger.printWarning(error); + } +} + +void ProjectResolver::resolveGroupFully(Item *item, ProjectResolver::ProjectContext *projectContext, + bool isEnabled) +{ + AccumulatingTimer groupTimer(m_setupParams.logElapsedTime() + ? &m_elapsedTimeGroups : nullptr); + + const auto getGroupPropertyMap = [this, item](const ArtifactProperties *existingProps) { + PropertyMapPtr moduleProperties; + bool newPropertyMapRequired = false; + if (existingProps) + moduleProperties = existingProps->propertyMap(); + if (!moduleProperties) { + newPropertyMapRequired = true; + moduleProperties = m_productContext->currentGroup + ? m_productContext->currentGroup->properties + : m_productContext->product->moduleProperties; + } + const QVariantMap newModuleProperties + = resolveAdditionalModuleProperties(item, moduleProperties->value()); + if (!newModuleProperties.empty()) { + if (newPropertyMapRequired) + moduleProperties = PropertyMapInternal::create(); + moduleProperties->setValue(newModuleProperties); + } + return moduleProperties; + }; + + QStringList files = m_evaluator->stringListValue(item, StringConstants::filesProperty()); + bool fileTagsSet; + const FileTags fileTags = m_evaluator->fileTagsValue(item, StringConstants::fileTagsProperty(), + &fileTagsSet); + const QStringList fileTagsFilter + = m_evaluator->stringListValue(item, StringConstants::fileTagsFilterProperty()); + if (!fileTagsFilter.empty()) { + if (Q_UNLIKELY(!files.empty())) + throw ErrorInfo(Tr::tr("Group.files and Group.fileTagsFilters are exclusive."), + item->location()); + + if (!isEnabled) + return; + + ProductContext::ArtifactPropertiesInfo &apinfo + = m_productContext->artifactPropertiesPerFilter[fileTagsFilter]; + if (apinfo.first) { + const auto it = std::find_if(apinfo.second.cbegin(), apinfo.second.cend(), + [item](const CodeLocation &loc) { + return item->location().filePath() == loc.filePath(); + }); + if (it != apinfo.second.cend()) { + ErrorInfo error(Tr::tr("Conflicting fileTagsFilter in Group items.")); + error.append(Tr::tr("First item"), *it); + error.append(Tr::tr("Second item"), item->location()); + throw error; + } + } else { + apinfo.first = ArtifactProperties::create(); + apinfo.first->setFileTagsFilter(FileTags::fromStringList(fileTagsFilter)); + m_productContext->product->artifactProperties.push_back(apinfo.first); + } + apinfo.second.push_back(item->location()); + apinfo.first->setPropertyMapInternal(getGroupPropertyMap(apinfo.first.get())); + apinfo.first->addExtraFileTags(fileTags); + return; + } + QStringList patterns; + for (int i = files.size(); --i >= 0;) { + if (FileInfo::isPattern(files[i])) + patterns.push_back(files.takeAt(i)); + } + GroupPtr group = ResolvedGroup::create(); + bool prefixWasSet = false; + group->prefix = m_evaluator->stringValue(item, StringConstants::prefixProperty(), QString(), + &prefixWasSet); + if (!prefixWasSet && m_productContext->currentGroup) + group->prefix = m_productContext->currentGroup->prefix; + if (!group->prefix.isEmpty()) { + for (auto it = files.rbegin(), end = files.rend(); it != end; ++it) + it->prepend(group->prefix); + } + group->location = item->location(); + group->enabled = isEnabled; + group->properties = getGroupPropertyMap(nullptr); + group->fileTags = fileTags; + group->overrideTags = m_evaluator->boolValue(item, StringConstants::overrideTagsProperty()); + if (group->overrideTags && fileTagsSet) { + if (group->fileTags.empty() ) + group->fileTags.insert(unknownFileTag()); + } else if (m_productContext->currentGroup) { + group->fileTags.unite(m_productContext->currentGroup->fileTags); + } + + const CodeLocation filesLocation = item->property(StringConstants::filesProperty())->location(); + const VariantValueConstPtr moduleProp = item->variantProperty( + StringConstants::modulePropertyInternal()); + if (moduleProp) + group->targetOfModule = moduleProp->value().toString(); + ErrorInfo fileError; + if (!patterns.empty()) { + group->wildcards = std::make_unique(); + SourceWildCards *wildcards = group->wildcards.get(); + wildcards->group = group.get(); + wildcards->excludePatterns = m_evaluator->stringListValue( + item, StringConstants::excludeFilesProperty()); + wildcards->patterns = patterns; + const Set files = wildcards->expandPatterns(group, + FileInfo::path(item->file()->filePath()), + projectContext->project->topLevelProject()->buildDirectory); + for (const QString &fileName : files) + createSourceArtifact(m_productContext->product, fileName, group, true, filesLocation, + &m_productContext->sourceArtifactLocations, &fileError); + } + + for (const QString &fileName : qAsConst(files)) { + createSourceArtifact(m_productContext->product, fileName, group, false, filesLocation, + &m_productContext->sourceArtifactLocations, &fileError); + } + if (fileError.hasError()) { + if (group->enabled) { + if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict) + throw ErrorInfo(fileError); + m_logger.printWarning(fileError); + } else { + qCDebug(lcProjectResolver) << "error for disabled group:" << fileError.toString(); + } + } + group->name = m_evaluator->stringValue(item, StringConstants::nameProperty()); + if (group->name.isEmpty()) + group->name = Tr::tr("Group %1").arg(m_productContext->product->groups.size()); + m_productContext->product->groups.push_back(group); + + class GroupContextSwitcher { + public: + GroupContextSwitcher(ProductContext &context, const GroupConstPtr &newGroup) + : m_context(context), m_oldGroup(context.currentGroup) { + m_context.currentGroup = newGroup; + } + ~GroupContextSwitcher() { m_context.currentGroup = m_oldGroup; } + private: + ProductContext &m_context; + const GroupConstPtr m_oldGroup; + }; + GroupContextSwitcher groupSwitcher(*m_productContext, group); + for (Item * const childItem : item->children()) + resolveGroup(childItem, projectContext); +} + +void ProjectResolver::adaptExportedPropertyValues(const Item *shadowProductItem) +{ + ExportedModule &m = m_productContext->product->exportedModule; + const QVariantList prefixList = m.propertyValues.take( + StringConstants::prefixMappingProperty()).toList(); + const QString shadowProductName = m_evaluator->stringValue( + shadowProductItem, StringConstants::nameProperty()); + const QString shadowProductBuildDir = m_evaluator->stringValue( + shadowProductItem, StringConstants::buildDirectoryProperty()); + QVariantMap prefixMap; + for (const QVariant &v : prefixList) { + const QVariantMap o = v.toMap(); + prefixMap.insert(o.value(QStringLiteral("prefix")).toString(), + o.value(QStringLiteral("replacement")).toString()); + } + const auto valueRefersToImportingProduct + = [shadowProductName, shadowProductBuildDir](const QString &value) { + return value.toLower().contains(shadowProductName.toLower()) + || value.contains(shadowProductBuildDir); + }; + static const auto stringMapper = [](const QVariantMap &mappings, const QString &value) + -> QString { + for (auto it = mappings.cbegin(); it != mappings.cend(); ++it) { + if (value.startsWith(it.key())) + return it.value().toString() + value.mid(it.key().size()); + } + return value; + }; + const auto stringListMapper = [&valueRefersToImportingProduct]( + const QVariantMap &mappings, const QStringList &value) -> QStringList { + QStringList result; + result.reserve(value.size()); + for (const QString &s : value) { + if (!valueRefersToImportingProduct(s)) + result.push_back(stringMapper(mappings, s)); + } + return result; + }; + const std::function mapper + = [&stringListMapper, &mapper]( + const QVariantMap &mappings, const QVariant &value) -> QVariant { + switch (static_cast(value.userType())) { + case QMetaType::QString: + return stringMapper(mappings, value.toString()); + case QMetaType::QStringList: + return stringListMapper(mappings, value.toStringList()); + case QMetaType::QVariantMap: { + QVariantMap m = value.toMap(); + for (auto it = m.begin(); it != m.end(); ++it) + it.value() = mapper(mappings, it.value()); + return m; + } + default: + return value; + } + }; + for (auto it = m.propertyValues.begin(); it != m.propertyValues.end(); ++it) + it.value() = mapper(prefixMap, it.value()); + for (auto it = m.modulePropertyValues.begin(); it != m.modulePropertyValues.end(); ++it) + it.value() = mapper(prefixMap, it.value()); + for (ExportedModuleDependency &dep : m.moduleDependencies) { + for (auto it = dep.moduleProperties.begin(); it != dep.moduleProperties.end(); ++it) + it.value() = mapper(prefixMap, it.value()); + } +} + +void ProjectResolver::collectExportedProductDependencies() +{ + ResolvedProductPtr dummyProduct = ResolvedProduct::create(); + dummyProduct->enabled = false; + for (const auto &exportingProductInfo : qAsConst(m_productExportInfo)) { + const ResolvedProductPtr exportingProduct = exportingProductInfo.first; + if (!exportingProduct->enabled) + continue; + Item * const importingProductItem = exportingProductInfo.second; + std::vector directDepNames; + for (const Item::Module &m : importingProductItem->modules()) { + if (m.name.toString() == exportingProduct->name) { + for (const Item::Module &dep : m.item->modules()) { + if (dep.isProduct) + directDepNames.push_back(dep.name.toString()); + } + break; + } + } + const ModuleLoaderResult::ProductInfo &importingProductInfo + = mapValue(m_loadResult.productInfos, importingProductItem); + const ProductDependencyInfos &depInfos + = getProductDependencies(dummyProduct, importingProductInfo); + for (const auto &dep : depInfos.dependencies) { + if (dep.product == exportingProduct) + continue; + + // Filter out indirect dependencies. + // TODO: Depends items using "profile" or "productTypes" will not work. + if (!contains(directDepNames, dep.product->name)) + continue; + + if (!contains(exportingProduct->exportedModule.productDependencies, + dep.product->uniqueName())) { + exportingProduct->exportedModule.productDependencies.push_back( + dep.product->uniqueName()); + } + if (!dep.parameters.isEmpty()) { + exportingProduct->exportedModule.dependencyParameters.insert(dep.product, + dep.parameters); + } + } + auto &productDeps = exportingProduct->exportedModule.productDependencies; + std::sort(productDeps.begin(), productDeps.end()); + } +} + +void ProjectResolver::resolveShadowProduct(Item *item, ProjectResolver::ProjectContext *) +{ + if (!m_productContext->product->enabled) + return; + for (const auto &m : item->modules()) { + if (m.name.toString() != m_productContext->product->name) + continue; + collectPropertiesForExportItem(m.item); + for (const auto &dep : m.item->modules()) + collectPropertiesForModuleInExportItem(dep); + break; + } + try { + adaptExportedPropertyValues(item); + } catch (const ErrorInfo &) {} + m_productExportInfo.emplace_back(m_productContext->product, item); +} + +void ProjectResolver::setupExportedProperties(const Item *item, const QString &namePrefix, + std::vector &properties) +{ + const auto &props = item->properties(); + for (auto it = props.cbegin(); it != props.cend(); ++it) { + const QString qualifiedName = namePrefix.isEmpty() + ? it.key() : namePrefix + QLatin1Char('.') + it.key(); + if ((item->type() == ItemType::Export || item->type() == ItemType::Properties) + && qualifiedName == StringConstants::prefixMappingProperty()) { + continue; + } + const ValuePtr &v = it.value(); + if (v->type() == Value::ItemValueType) { + setupExportedProperties(std::static_pointer_cast(v)->item(), + qualifiedName, properties); + continue; + } + ExportedProperty exportedProperty; + exportedProperty.fullName = qualifiedName; + exportedProperty.type = item->propertyDeclaration(it.key()).type(); + if (v->type() == Value::VariantValueType) { + exportedProperty.sourceCode = toJSLiteral( + std::static_pointer_cast(v)->value()); + } else { + QBS_CHECK(v->type() == Value::JSSourceValueType); + const JSSourceValue * const sv = static_cast(v.get()); + exportedProperty.sourceCode = sv->sourceCode().toString(); + } + const ItemDeclaration itemDecl + = BuiltinDeclarations::instance().declarationsForType(item->type()); + PropertyDeclaration propertyDecl; + const auto itemProperties = itemDecl.properties(); + for (const PropertyDeclaration &decl : itemProperties) { + if (decl.name() == it.key()) { + propertyDecl = decl; + exportedProperty.isBuiltin = true; + break; + } + } + + // Do not add built-in properties that were left at their default value. + if (!exportedProperty.isBuiltin || m_evaluator->isNonDefaultValue(item, it.key())) + properties.push_back(exportedProperty); + } + + // Order the list of properties, so the output won't look so random. + static const auto less = [](const ExportedProperty &p1, const ExportedProperty &p2) -> bool { + const int p1ComponentCount = p1.fullName.count(QLatin1Char('.')); + const int p2ComponentCount = p2.fullName.count(QLatin1Char('.')); + if (p1.isBuiltin && !p2.isBuiltin) + return true; + if (!p1.isBuiltin && p2.isBuiltin) + return false; + if (p1ComponentCount < p2ComponentCount) + return true; + if (p1ComponentCount > p2ComponentCount) + return false; + return p1.fullName < p2.fullName; + }; + std::sort(properties.begin(), properties.end(), less); +} + +static bool usesImport(const ExportedProperty &prop, const QRegularExpression ®ex) +{ + return prop.sourceCode.indexOf(regex) != -1; +} + +static bool usesImport(const ExportedItem &item, const QRegularExpression ®ex) +{ + return any_of(item.properties, + [regex](const ExportedProperty &p) { return usesImport(p, regex); }) + || any_of(item.children, + [regex](const ExportedItemPtr &child) { return usesImport(*child, regex); }); +} + +static bool usesImport(const ExportedModule &module, const QString &name) +{ + // Imports are used in three ways: + // (1) var f = new TextFile(...); + // (2) var path = FileInfo.joinPaths(...) + // (3) var obj = DataCollection; + const QString pattern = QStringLiteral("\\b%1\\b"); + + const QRegularExpression regex(pattern.arg(name)); // std::regex is much slower + return any_of(module.m_properties, + [regex](const ExportedProperty &p) { return usesImport(p, regex); }) + || any_of(module.children, + [regex](const ExportedItemPtr &child) { return usesImport(*child, regex); }); +} + +static QString getLineAtLocation(const CodeLocation &loc, const QString &content) +{ + int pos = 0; + int currentLine = 1; + while (currentLine < loc.line()) { + while (content.at(pos++) != QLatin1Char('\n')) + ; + ++currentLine; + } + const int eolPos = content.indexOf(QLatin1Char('\n'), pos); + return content.mid(pos, eolPos - pos); +} + +void ProjectResolver::resolveExport(Item *exportItem, ProjectContext *) +{ + ExportedModule &exportedModule = m_productContext->product->exportedModule; + setupExportedProperties(exportItem, QString(), exportedModule.m_properties); + static const auto cmpFunc = [](const ExportedProperty &p1, const ExportedProperty &p2) { + return p1.fullName < p2.fullName; + }; + std::sort(exportedModule.m_properties.begin(), exportedModule.m_properties.end(), cmpFunc); + + transform(exportItem->children(), exportedModule.children, + [&exportedModule, this](const auto &child) { + return resolveExportChild(child, exportedModule); }); + + for (const JsImport &jsImport : exportItem->file()->jsImports()) { + if (usesImport(exportedModule, jsImport.scopeName)) { + exportedModule.importStatements << getLineAtLocation(jsImport.location, + exportItem->file()->content()); + } + } + const auto builtInImports = JsExtensions::extensionNames(); + for (const QString &builtinImport: builtInImports) { + if (usesImport(exportedModule, builtinImport)) + exportedModule.importStatements << QStringLiteral("import qbs.") + builtinImport; + } + exportedModule.importStatements.sort(); +} + +// TODO: This probably wouldn't be necessary if we had item serialization. +std::unique_ptr ProjectResolver::resolveExportChild(const Item *item, + const ExportedModule &module) +{ + std::unique_ptr exportedItem(new ExportedItem); + + // This is the type of the built-in base item. It may turn out that we need to support + // derived items under Export. In that case, we probably need a new Item member holding + // the original type name. + exportedItem->name = item->typeName(); + + transform(item->children(), exportedItem->children, [&module, this](const auto &child) { + return resolveExportChild(child, module); }); + + setupExportedProperties(item, QString(), exportedItem->properties); + return exportedItem; +} + +QString ProjectResolver::sourceCodeAsFunction(const JSSourceValueConstPtr &value, + const PropertyDeclaration &decl) const +{ + QString &scriptFunction = m_scriptFunctions[std::make_pair(value->sourceCode(), + decl.functionArgumentNames())]; + if (!scriptFunction.isNull()) + return scriptFunction; + const QString args = decl.functionArgumentNames().join(QLatin1Char(',')); + if (value->hasFunctionForm()) { + // Insert the argument list. + scriptFunction = value->sourceCodeForEvaluation(); + scriptFunction.insert(10, args); + // Remove the function application "()" that has been + // added in ItemReaderASTVisitor::visitStatement. + scriptFunction.chop(2); + } else { + scriptFunction = QLatin1String("(function(") + args + QLatin1String("){return ") + + value->sourceCode().toString() + QLatin1String(";})"); + } + return scriptFunction; +} + +QString ProjectResolver::sourceCodeForEvaluation(const JSSourceValueConstPtr &value) const +{ + QString &code = m_sourceCode[value->sourceCode()]; + if (!code.isNull()) + return code; + code = value->sourceCodeForEvaluation(); + return code; +} + +ScriptFunctionPtr ProjectResolver::scriptFunctionValue(Item *item, const QString &name) const +{ + JSSourceValuePtr value = item->sourceProperty(name); + ScriptFunctionPtr &script = m_scriptFunctionMap[value ? value->location() : CodeLocation()]; + if (!script.get()) { + script = ScriptFunction::create(); + const PropertyDeclaration decl = item->propertyDeclaration(name); + script->sourceCode = sourceCodeAsFunction(value, decl); + script->location = value->location(); + script->fileContext = resolvedFileContext(value->file()); + } + return script; +} + +ResolvedFileContextPtr ProjectResolver::resolvedFileContext(const FileContextConstPtr &ctx) const +{ + ResolvedFileContextPtr &result = m_fileContextMap[ctx]; + if (!result) + result = ResolvedFileContext::create(*ctx); + return result; +} + +void ProjectResolver::resolveRule(Item *item, ProjectContext *projectContext) +{ + checkCancelation(); + + if (!m_evaluator->boolValue(item, StringConstants::conditionProperty())) + return; + + RulePtr rule = Rule::create(); + + // read artifacts + bool hasArtifactChildren = false; + for (Item * const child : item->children()) { + if (Q_UNLIKELY(child->type() != ItemType::Artifact)) { + throw ErrorInfo(Tr::tr("'Rule' can only have children of type 'Artifact'."), + child->location()); + } + hasArtifactChildren = true; + resolveRuleArtifact(rule, child); + } + + rule->name = m_evaluator->stringValue(item, StringConstants::nameProperty()); + rule->prepareScript.initialize(scriptFunctionValue(item, StringConstants::prepareProperty())); + rule->outputArtifactsScript.initialize(scriptFunctionValue( + item, StringConstants::outputArtifactsProperty())); + rule->outputFileTags = m_evaluator->fileTagsValue( + item, StringConstants::outputFileTagsProperty()); + if (rule->outputArtifactsScript.isValid()) { + if (hasArtifactChildren) + throw ErrorInfo(Tr::tr("The Rule.outputArtifacts script is not allowed in rules " + "that contain Artifact items."), + item->location()); + } + if (!hasArtifactChildren && rule->outputFileTags.empty()) { + throw ErrorInfo(Tr::tr("A rule needs to have Artifact items or a non-empty " + "outputFileTags property."), item->location()); + } + rule->multiplex = m_evaluator->boolValue(item, StringConstants::multiplexProperty()); + rule->alwaysRun = m_evaluator->boolValue(item, StringConstants::alwaysRunProperty()); + rule->inputs = m_evaluator->fileTagsValue(item, StringConstants::inputsProperty()); + rule->inputsFromDependencies + = m_evaluator->fileTagsValue(item, StringConstants::inputsFromDependenciesProperty()); + bool requiresInputsSet = false; + rule->requiresInputs = m_evaluator->boolValue(item, StringConstants::requiresInputsProperty(), + &requiresInputsSet); + if (!requiresInputsSet) + rule->requiresInputs = rule->declaresInputs(); + rule->auxiliaryInputs + = m_evaluator->fileTagsValue(item, StringConstants::auxiliaryInputsProperty()); + rule->excludedInputs + = m_evaluator->fileTagsValue(item, StringConstants::excludedInputsProperty()); + if (rule->excludedInputs.empty()) { + rule->excludedInputs = m_evaluator->fileTagsValue( + item, StringConstants::excludedAuxiliaryInputsProperty()); + } + rule->explicitlyDependsOn + = m_evaluator->fileTagsValue(item, StringConstants::explicitlyDependsOnProperty()); + rule->explicitlyDependsOnFromDependencies = m_evaluator->fileTagsValue( + item, StringConstants::explicitlyDependsOnFromDependenciesProperty()); + rule->module = m_moduleContext ? m_moduleContext->module : projectContext->dummyModule; + if (!rule->multiplex && !rule->declaresInputs()) { + throw ErrorInfo(Tr::tr("Rule has no inputs, but is not a multiplex rule."), + item->location()); + } + if (!rule->multiplex && !rule->requiresInputs) { + throw ErrorInfo(Tr::tr("Rule.requiresInputs is false for non-multiplex rule."), + item->location()); + } + if (!rule->declaresInputs() && rule->requiresInputs) { + throw ErrorInfo(Tr::tr("Rule.requiresInputs is true, but the rule " + "does not declare any input tags."), item->location()); + } + if (m_productContext) { + rule->product = m_productContext->product.get(); + m_productContext->product->rules.push_back(rule); + } else { + projectContext->rules.push_back(rule); + } +} + +void ProjectResolver::resolveRuleArtifact(const RulePtr &rule, Item *item) +{ + RuleArtifactPtr artifact = RuleArtifact::create(); + rule->artifacts.push_back(artifact); + artifact->location = item->location(); + + if (const auto sourceProperty = item->sourceProperty(StringConstants::filePathProperty())) + artifact->filePathLocation = sourceProperty->location(); + + artifact->filePath = verbatimValue(item, StringConstants::filePathProperty()); + artifact->fileTags = m_evaluator->fileTagsValue(item, StringConstants::fileTagsProperty()); + artifact->alwaysUpdated = m_evaluator->boolValue(item, + StringConstants::alwaysUpdatedProperty()); + + QualifiedIdSet seenBindings; + for (Item *obj = item; obj; obj = obj->prototype()) { + for (QMap::const_iterator it = obj->properties().constBegin(); + it != obj->properties().constEnd(); ++it) + { + if (it.value()->type() != Value::ItemValueType) + continue; + resolveRuleArtifactBinding(artifact, + std::static_pointer_cast(it.value())->item(), + QStringList(it.key()), &seenBindings); + } + } +} + +void ProjectResolver::resolveRuleArtifactBinding(const RuleArtifactPtr &ruleArtifact, + Item *item, + const QStringList &namePrefix, + QualifiedIdSet *seenBindings) +{ + for (QMap::const_iterator it = item->properties().constBegin(); + it != item->properties().constEnd(); ++it) + { + const QStringList name = QStringList(namePrefix) << it.key(); + if (it.value()->type() == Value::ItemValueType) { + resolveRuleArtifactBinding(ruleArtifact, + std::static_pointer_cast(it.value())->item(), name, + seenBindings); + } else if (it.value()->type() == Value::JSSourceValueType) { + const auto insertResult = seenBindings->insert(name); + if (!insertResult.second) + continue; + JSSourceValuePtr sourceValue = std::static_pointer_cast(it.value()); + RuleArtifact::Binding rab; + rab.name = name; + rab.code = sourceCodeForEvaluation(sourceValue); + rab.location = sourceValue->location(); + ruleArtifact->bindings.push_back(rab); + } else { + QBS_ASSERT(!"unexpected value type", continue); + } + } +} + +void ProjectResolver::resolveFileTagger(Item *item, ProjectContext *projectContext) +{ + checkCancelation(); + if (!m_evaluator->boolValue(item, StringConstants::conditionProperty())) + return; + std::vector &fileTaggers = m_productContext + ? m_productContext->product->fileTaggers + : projectContext->fileTaggers; + const QStringList patterns = m_evaluator->stringListValue(item, + StringConstants::patternsProperty()); + if (patterns.empty()) + throw ErrorInfo(Tr::tr("FileTagger.patterns must be a non-empty list."), item->location()); + + const FileTags fileTags = m_evaluator->fileTagsValue(item, StringConstants::fileTagsProperty()); + if (fileTags.empty()) + throw ErrorInfo(Tr::tr("FileTagger.fileTags must not be empty."), item->location()); + + for (const QString &pattern : patterns) { + if (pattern.isEmpty()) + throw ErrorInfo(Tr::tr("A FileTagger pattern must not be empty."), item->location()); + } + + const int priority = m_evaluator->intValue(item, StringConstants::priorityProperty()); + fileTaggers.push_back(FileTagger::create(patterns, fileTags, priority)); +} + +void ProjectResolver::resolveJobLimit(Item *item, ProjectResolver::ProjectContext *projectContext) +{ + if (!m_evaluator->boolValue(item, StringConstants::conditionProperty())) + return; + const QString jobPool = m_evaluator->stringValue(item, StringConstants::jobPoolProperty()); + if (jobPool.isEmpty()) + throw ErrorInfo(Tr::tr("A JobLimit item needs to have a non-empty '%1' property.") + .arg(StringConstants::jobPoolProperty()), item->location()); + bool jobCountWasSet; + const int jobCount = m_evaluator->intValue(item, StringConstants::jobCountProperty(), -1, + &jobCountWasSet); + if (!jobCountWasSet) { + throw ErrorInfo(Tr::tr("A JobLimit item needs to have a '%1' property.") + .arg(StringConstants::jobCountProperty()), item->location()); + } + if (jobCount < 0) { + throw ErrorInfo(Tr::tr("A JobLimit item must have a non-negative '%1' property.") + .arg(StringConstants::jobCountProperty()), item->location()); + } + JobLimits &jobLimits = m_moduleContext + ? m_moduleContext->jobLimits + : m_productContext ? m_productContext->product->jobLimits + : projectContext->jobLimits; + JobLimit jobLimit(jobPool, jobCount); + const int oldLimit = jobLimits.getLimit(jobPool); + if (oldLimit == -1 || oldLimit > jobCount) + jobLimits.setJobLimit(jobLimit); +} + +void ProjectResolver::resolveScanner(Item *item, ProjectResolver::ProjectContext *projectContext) +{ + checkCancelation(); + if (!m_evaluator->boolValue(item, StringConstants::conditionProperty())) { + qCDebug(lcProjectResolver) << "scanner condition is false"; + return; + } + + ResolvedScannerPtr scanner = ResolvedScanner::create(); + scanner->module = m_moduleContext ? m_moduleContext->module : projectContext->dummyModule; + scanner->inputs = m_evaluator->fileTagsValue(item, StringConstants::inputsProperty()); + scanner->recursive = m_evaluator->boolValue(item, StringConstants::recursiveProperty()); + scanner->searchPathsScript.initialize(scriptFunctionValue( + item, StringConstants::searchPathsProperty())); + scanner->scanScript.initialize(scriptFunctionValue(item, StringConstants::scanProperty())); + m_productContext->product->scanners.push_back(scanner); +} + +ProjectResolver::ProductDependencyInfos ProjectResolver::getProductDependencies( + const ResolvedProductConstPtr &product, const ModuleLoaderResult::ProductInfo &productInfo) +{ + ProductDependencyInfos result; + result.dependencies.reserve(productInfo.usedProducts.size()); + for (const auto &dependency : productInfo.usedProducts) { + QBS_CHECK(!dependency.name.isEmpty()); + if (dependency.profile == StringConstants::star()) { + for (const ResolvedProductPtr &p : qAsConst(m_productsByName)) { + if (p->name != dependency.name || p == product || !p->enabled + || (dependency.limitToSubProject && !product->isInParentProject(p))) { + continue; + } + result.dependencies.emplace_back(p, dependency.parameters); + } + } else { + ResolvedProductPtr usedProduct = m_productsByName.value(dependency.uniqueName()); + const QString depDisplayName = ResolvedProduct::fullDisplayName(dependency.name, + dependency.multiplexConfigurationId); + if (!usedProduct) { + throw ErrorInfo(Tr::tr("Product '%1' depends on '%2', which does not exist.") + .arg(product->fullDisplayName(), depDisplayName), + product->location); + } + if (!dependency.profile.isEmpty() && usedProduct->profile() != dependency.profile) { + usedProduct.reset(); + for (const ResolvedProductPtr &p : qAsConst(m_productsByName)) { + if (p->name == dependency.name && p->profile() == dependency.profile) { + usedProduct = p; + break; + } + } + if (!usedProduct) { + throw ErrorInfo(Tr::tr("Product '%1' depends on '%2', which does not exist " + "for the requested profile '%3'.") + .arg(product->fullDisplayName(), depDisplayName, + dependency.profile), + product->location); + } + } + if (!usedProduct->enabled) { + if (!dependency.isRequired) + continue; + ErrorInfo e; + e.append(Tr::tr("Product '%1' depends on '%2',") + .arg(product->name, usedProduct->name), product->location); + e.append(Tr::tr("but product '%1' is disabled.").arg(usedProduct->name), + usedProduct->location); + if (m_setupParams.productErrorMode() == ErrorHandlingMode::Strict) + throw e; + result.hasDisabledDependency = true; + } + result.dependencies.emplace_back(usedProduct, dependency.parameters); + } + } + return result; +} + +void ProjectResolver::matchArtifactProperties(const ResolvedProductPtr &product, + const std::vector &artifacts) +{ + for (const SourceArtifactPtr &artifact : artifacts) { + for (const auto &artifactProperties : product->artifactProperties) { + if (!artifact->isTargetOfModule() + && artifact->fileTags.intersects(artifactProperties->fileTagsFilter())) { + artifact->properties = artifactProperties->propertyMap(); + } + } + } +} + +void ProjectResolver::printProfilingInfo() +{ + if (!m_setupParams.logElapsedTime()) + return; + m_logger.qbsLog(LoggerInfo, true) << "\t" << Tr::tr("All property evaluation took %1.") + .arg(elapsedTimeString(m_elapsedTimeAllPropEval)); + m_logger.qbsLog(LoggerInfo, true) << "\t" << Tr::tr("Module property evaluation took %1.") + .arg(elapsedTimeString(m_elapsedTimeModPropEval)); + m_logger.qbsLog(LoggerInfo, true) << "\t" + << Tr::tr("Resolving groups (without module property " + "evaluation) took %1.") + .arg(elapsedTimeString(m_elapsedTimeGroups)); +} + +class TempScopeSetter +{ +public: + TempScopeSetter(Item * item, Item *newScope) : m_item(item), m_oldScope(item->scope()) + { + item->setScope(newScope); + } + ~TempScopeSetter() { m_item->setScope(m_oldScope); } +private: + Item * const m_item; + Item * const m_oldScope; +}; + +void ProjectResolver::collectPropertiesForExportItem(Item *productModuleInstance) +{ + if (!productModuleInstance->isPresentModule()) + return; + Item * const exportItem = productModuleInstance->prototype(); + QBS_CHECK(exportItem && exportItem->type() == ItemType::Export); + TempScopeSetter tempScopeSetter(exportItem, productModuleInstance->scope()); + const ItemDeclaration::Properties exportDecls = BuiltinDeclarations::instance() + .declarationsForType(ItemType::Export).properties(); + ExportedModule &exportedModule = m_productContext->product->exportedModule; + const auto &props = exportItem->properties(); + for (auto it = props.begin(); it != props.end(); ++it) { + const auto match + = [it](const PropertyDeclaration &decl) { return decl.name() == it.key(); }; + if (it.key() != StringConstants::prefixMappingProperty() && + std::find_if(exportDecls.begin(), exportDecls.end(), match) != exportDecls.end()) { + continue; + } + if (it.value()->type() == Value::ItemValueType) { + collectPropertiesForExportItem(it.key(), it.value(), productModuleInstance, + exportedModule.modulePropertyValues); + } else { + evaluateProperty(exportItem, it.key(), it.value(), exportedModule.propertyValues, + false); + } + } +} + +// Collects module properties assigned to in other (higher-level) modules. +void ProjectResolver::collectPropertiesForModuleInExportItem(const Item::Module &module) +{ + if (!module.item->isPresentModule()) + return; + ExportedModule &exportedModule = m_productContext->product->exportedModule; + if (module.isProduct || module.name.first() == StringConstants::qbsModule()) + return; + const auto checkName = [module](const ExportedModuleDependency &d) { + return module.name.toString() == d.name; + }; + if (any_of(exportedModule.moduleDependencies, checkName)) + return; + + Item *modulePrototype = module.item->prototype(); + while (modulePrototype && modulePrototype->type() != ItemType::Module) + modulePrototype = modulePrototype->prototype(); + if (!modulePrototype) // Can happen for broken products in relaxed mode. + return; + TempScopeSetter tempScopeSetter(modulePrototype, module.item->scope()); + const Item::PropertyMap &props = modulePrototype->properties(); + ExportedModuleDependency dep; + dep.name = module.name.toString(); + for (auto it = props.begin(); it != props.end(); ++it) { + if (it.value()->type() == Value::ItemValueType) + collectPropertiesForExportItem(it.key(), it.value(), module.item, dep.moduleProperties); + } + exportedModule.moduleDependencies.push_back(dep); + + for (const auto &dep : module.item->modules()) + collectPropertiesForModuleInExportItem(dep); +} + +static bool hasDependencyCycle(Set *checked, + Set *branch, + const ResolvedProductPtr &product, + ErrorInfo *error) +{ + if (branch->contains(product.get())) + return true; + if (checked->contains(product.get())) + return false; + checked->insert(product.get()); + branch->insert(product.get()); + for (const ResolvedProductPtr &dep : qAsConst(product->dependencies)) { + if (hasDependencyCycle(checked, branch, dep, error)) { + error->prepend(dep->name, dep->location); + return true; + } + } + branch->remove(product.get()); + return false; +} + +using DependencyMap = QHash>; +void gatherDependencies(ResolvedProduct *product, DependencyMap &dependencies) +{ + if (dependencies.contains(product)) + return; + // Hold locally because the QHash references aren't stable in Qt6. + Set productDeps = dependencies[product]; + for (const ResolvedProductPtr &dep : qAsConst(product->dependencies)) { + productDeps << dep.get(); + gatherDependencies(dep.get(), dependencies); + productDeps += dependencies.value(dep.get()); + } + // Now that we gathered the dependencies, put them in the map. + dependencies[product] = std::move(productDeps); +} + + + +static DependencyMap allDependencies(const std::vector &products) +{ + DependencyMap dependencies; + for (const ResolvedProductPtr &product : products) + gatherDependencies(product.get(), dependencies); + return dependencies; +} + +void ProjectResolver::resolveProductDependencies(const ProjectContext &projectContext) +{ + // Resolve all inter-product dependencies. + const std::vector allProducts = projectContext.project->allProducts(); + bool disabledDependency = false; + for (const ResolvedProductPtr &rproduct : allProducts) { + if (!rproduct->enabled) + continue; + Item *productItem = m_productItemMap.value(rproduct); + const ModuleLoaderResult::ProductInfo &productInfo + = mapValue(m_loadResult.productInfos, productItem); + const ProductDependencyInfos &depInfos = getProductDependencies(rproduct, productInfo); + if (depInfos.hasDisabledDependency) + disabledDependency = true; + for (const auto &dep : depInfos.dependencies) { + if (!contains(rproduct->dependencies, dep.product)) + rproduct->dependencies.push_back(dep.product); + if (!dep.parameters.empty()) + rproduct->dependencyParameters.insert(dep.product, dep.parameters); + } + } + + // Check for cyclic dependencies. + Set checked; + for (const ResolvedProductPtr &rproduct : allProducts) { + Set branch; + ErrorInfo error; + if (hasDependencyCycle(&checked, &branch, rproduct, &error)) { + error.prepend(rproduct->name, rproduct->location); + error.prepend(Tr::tr("Cyclic dependencies detected.")); + throw error; + } + } + + // Mark all products as disabled that have a disabled dependency. + if (disabledDependency && m_setupParams.productErrorMode() == ErrorHandlingMode::Relaxed) { + const DependencyMap allDeps = allDependencies(allProducts); + DependencyMap allDepsReversed; + for (auto it = allDeps.constBegin(); it != allDeps.constEnd(); ++it) { + for (ResolvedProduct *dep : qAsConst(it.value())) + allDepsReversed[dep] << it.key(); + } + for (auto it = allDepsReversed.constBegin(); it != allDepsReversed.constEnd(); ++it) { + if (it.key()->enabled) + continue; + for (ResolvedProduct * const dependingProduct : qAsConst(it.value())) { + if (dependingProduct->enabled) { + m_logger.qbsWarning() << Tr::tr("Disabling product '%1', because it depends on " + "disabled product '%2'.") + .arg(dependingProduct->name, it.key()->name); + dependingProduct->enabled = false; + } + } + } + } +} + +void ProjectResolver::postProcess(const ResolvedProductPtr &product, + ProjectContext *projectContext) const +{ + product->fileTaggers << projectContext->fileTaggers; + std::sort(std::begin(product->fileTaggers), std::end(product->fileTaggers), + [] (const FileTaggerConstPtr &a, const FileTaggerConstPtr &b) { + return a->priority() > b->priority(); + }); + for (const RulePtr &rule : projectContext->rules) { + RulePtr clonedRule = rule->clone(); + clonedRule->product = product.get(); + product->rules.push_back(clonedRule); + } +} + +void ProjectResolver::applyFileTaggers(const ResolvedProductPtr &product) const +{ + for (const SourceArtifactPtr &artifact : product->allEnabledFiles()) + applyFileTaggers(artifact, product); +} + +void ProjectResolver::applyFileTaggers(const SourceArtifactPtr &artifact, + const ResolvedProductConstPtr &product) +{ + if (!artifact->overrideFileTags || artifact->fileTags.empty()) { + const QString fileName = FileInfo::fileName(artifact->absoluteFilePath); + const FileTags fileTags = product->fileTagsForFileName(fileName); + artifact->fileTags.unite(fileTags); + if (artifact->fileTags.empty()) + artifact->fileTags.insert(unknownFileTag()); + qCDebug(lcProjectResolver) << "adding file tags" << artifact->fileTags + << "to" << fileName; + } +} + +QVariantMap ProjectResolver::evaluateModuleValues(Item *item, bool lookupPrototype) +{ + AccumulatingTimer modPropEvalTimer(m_setupParams.logElapsedTime() + ? &m_elapsedTimeModPropEval : nullptr); + QVariantMap moduleValues; + for (const Item::Module &module : item->modules()) { + if (!module.item->isPresentModule()) + continue; + const QString fullName = module.name.toString(); + moduleValues[fullName] = evaluateProperties(module.item, lookupPrototype, true); + } + + return moduleValues; +} + +QVariantMap ProjectResolver::evaluateProperties(Item *item, bool lookupPrototype, bool checkErrors) +{ + const QVariantMap tmplt; + return evaluateProperties(item, item, tmplt, lookupPrototype, checkErrors); +} + +QVariantMap ProjectResolver::evaluateProperties(const Item *item, const Item *propertiesContainer, + const QVariantMap &tmplt, bool lookupPrototype, bool checkErrors) +{ + AccumulatingTimer propEvalTimer(m_setupParams.logElapsedTime() + ? &m_elapsedTimeAllPropEval : nullptr); + QVariantMap result = tmplt; + for (QMap::const_iterator it = propertiesContainer->properties().begin(); + it != propertiesContainer->properties().end(); ++it) { + checkCancelation(); + evaluateProperty(item, it.key(), it.value(), result, checkErrors); + } + return lookupPrototype && propertiesContainer->prototype() + ? evaluateProperties(item, propertiesContainer->prototype(), result, true, checkErrors) + : result; +} + +void ProjectResolver::evaluateProperty(const Item *item, const QString &propName, + const ValuePtr &propValue, QVariantMap &result, bool checkErrors) +{ + switch (propValue->type()) { + case Value::ItemValueType: + { + // Ignore items. Those point to module instances + // and are handled in evaluateModuleValues(). + break; + } + case Value::JSSourceValueType: + { + if (result.contains(propName)) + break; + const PropertyDeclaration pd = item->propertyDeclaration(propName); + if (pd.flags().testFlag(PropertyDeclaration::PropertyNotAvailableInConfig)) { + break; + } + const QScriptValue scriptValue = m_evaluator->property(item, propName); + if (checkErrors && Q_UNLIKELY(m_evaluator->engine()->hasErrorOrException(scriptValue))) { + throw ErrorInfo(m_evaluator->engine()->lastError(scriptValue, + propValue->location())); + } + + // NOTE: Loses type information if scriptValue.isUndefined == true, + // as such QScriptValues become invalid QVariants. + QVariant v; + if (scriptValue.isFunction()) { + v = scriptValue.toString(); + } else { + v = scriptValue.toVariant(); + QVariantMap m = v.toMap(); + if (m.contains(StringConstants::importScopeNamePropertyInternal())) { + QVariantMap tmp = m; + m = scriptValue.prototype().toVariant().toMap(); + for (auto it = tmp.begin(); it != tmp.end(); ++it) + m.insert(it.key(), it.value()); + v = m; + } + } + + if (pd.type() == PropertyDeclaration::Path && v.isValid()) { + v = v.toString(); + } else if (pd.type() == PropertyDeclaration::PathList + || pd.type() == PropertyDeclaration::StringList) { + v = v.toStringList(); + } else if (pd.type() == PropertyDeclaration::VariantList) { + v = v.toList(); + } + checkAllowedValues(v, propValue->location(), pd, propName); + result[propName] = v; + break; + } + case Value::VariantValueType: + { + if (result.contains(propName)) + break; + VariantValuePtr vvp = std::static_pointer_cast(propValue); + QVariant v = vvp->value(); + + const PropertyDeclaration pd = item->propertyDeclaration(propName); + if (v.isNull() && !pd.isScalar()) // QTBUG-51237 + v = QStringList(); + + checkAllowedValues(v, propValue->location(), pd, propName); + result[propName] = v; + break; + } + } +} + +void ProjectResolver::checkAllowedValues( + const QVariant &value, const CodeLocation &loc, const PropertyDeclaration &decl, + const QString &key) const +{ + const auto type = decl.type(); + if (type != PropertyDeclaration::String && type != PropertyDeclaration::StringList) + return; + + if (value.isNull()) + return; + + const auto &allowedValues = decl.allowedValues(); + if (allowedValues.isEmpty()) + return; + + const auto checkValue = [this, &loc, &allowedValues, &key](const QString &value) + { + if (!allowedValues.contains(value)) { + const auto message = Tr::tr("Value '%1' is not allowed for property '%2'.") + .arg(value, key); + ErrorInfo error(message, loc); + handlePropertyError(error, m_setupParams, m_logger); + } + }; + + if (type == PropertyDeclaration::StringList) { + const auto strings = value.toStringList(); + for (const auto &string: strings) { + checkValue(string); + } + } else if (type == PropertyDeclaration::String) { + checkValue(value.toString()); + } +} + +void ProjectResolver::collectPropertiesForExportItem(const QualifiedId &moduleName, + const ValuePtr &value, Item *moduleInstance, QVariantMap &moduleProps) +{ + QBS_CHECK(value->type() == Value::ItemValueType); + Item * const itemValueItem = std::static_pointer_cast(value)->item(); + if (itemValueItem->type() == ItemType::ModuleInstance) { + struct EvalPreparer { + EvalPreparer(Item *valueItem, Item *moduleInstance, const QualifiedId &moduleName) + : valueItem(valueItem), oldScope(valueItem->scope()), + hadName(!!valueItem->variantProperty(StringConstants::nameProperty())) + { + valueItem->setScope(moduleInstance); + if (!hadName) { + // EvaluatorScriptClass expects a name here. + valueItem->setProperty(StringConstants::nameProperty(), + VariantValue::create(moduleName.toString())); + } + } + ~EvalPreparer() + { + valueItem->setScope(oldScope); + if (!hadName) + valueItem->setProperty(StringConstants::nameProperty(), VariantValuePtr()); + } + Item * const valueItem; + Item * const oldScope; + const bool hadName; + }; + EvalPreparer ep(itemValueItem, moduleInstance, moduleName); + moduleProps.insert(moduleName.toString(), evaluateProperties(itemValueItem, false, false)); + return; + } + QBS_CHECK(itemValueItem->type() == ItemType::ModulePrefix); + const Item::PropertyMap &props = itemValueItem->properties(); + for (auto it = props.begin(); it != props.end(); ++it) { + QualifiedId fullModuleName = moduleName; + fullModuleName << it.key(); + collectPropertiesForExportItem(fullModuleName, it.value(), moduleInstance, moduleProps); + } +} + +void ProjectResolver::createProductConfig(ResolvedProduct *product) +{ + EvalCacheEnabler cachingEnabler(m_evaluator); + m_evaluator->setPathPropertiesBaseDir(m_productContext->product->sourceDirectory); + product->moduleProperties->setValue(evaluateModuleValues(m_productContext->item)); + product->productProperties = evaluateProperties(m_productContext->item, m_productContext->item, + QVariantMap(), true, true); + m_evaluator->clearPathPropertiesBaseDir(); +} + +void ProjectResolver::callItemFunction(const ItemFuncMap &mappings, Item *item, + ProjectContext *projectContext) +{ + const ItemFuncPtr f = mappings.value(item->type()); + QBS_CHECK(f); + if (item->type() == ItemType::Project) { + ProjectContext subProjectContext = createProjectContext(projectContext); + (this->*f)(item, &subProjectContext); + } else { + (this->*f)(item, projectContext); + } +} + +ProjectResolver::ProjectContext ProjectResolver::createProjectContext(ProjectContext *parentProjectContext) const +{ + ProjectContext subProjectContext; + subProjectContext.parentContext = parentProjectContext; + subProjectContext.project = ResolvedProject::create(); + parentProjectContext->project->subProjects.push_back(subProjectContext.project); + subProjectContext.project->parentProject = parentProjectContext->project; + return subProjectContext; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/projectresolver.h b/src/lib/corelib/language/projectresolver.h new file mode 100644 index 00000000..52d83553 --- /dev/null +++ b/src/lib/corelib/language/projectresolver.h @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PROJECTRESOLVER_H +#define PROJECTRESOLVER_H + +#include "filetags.h" +#include "itemtype.h" +#include "moduleloader.h" +#include "qualifiedid.h" + +#include +#include + +#include +#include +#include + +#include +#include + +namespace qbs { +class JobLimits; +namespace Internal { + +class Evaluator; +class Item; +class ProgressObserver; +class ScriptEngine; + +class ProjectResolver +{ +public: + ProjectResolver(Evaluator *evaluator, ModuleLoaderResult loadResult, + SetupProjectParameters setupParameters, Logger &logger); + ~ProjectResolver(); + + void setProgressObserver(ProgressObserver *observer); + TopLevelProjectPtr resolve(); + + static void applyFileTaggers(const SourceArtifactPtr &artifact, + const ResolvedProductConstPtr &product); + + using FileLocations = QHash, CodeLocation>; + static SourceArtifactPtr createSourceArtifact(const ResolvedProductPtr &rproduct, + const QString &fileName, const GroupPtr &group, bool wildcard, + const CodeLocation &filesLocation = CodeLocation(), + FileLocations *fileLocations = nullptr, ErrorInfo *errorInfo = nullptr); + +private: + struct ProjectContext; + struct ProductContext; + struct ModuleContext; + class ProductContextSwitcher; + + void checkCancelation() const; + QString verbatimValue(const ValueConstPtr &value, bool *propertyWasSet = nullptr) const; + QString verbatimValue(Item *item, const QString &name, bool *propertyWasSet = nullptr) const; + ScriptFunctionPtr scriptFunctionValue(Item *item, const QString &name) const; + ResolvedFileContextPtr resolvedFileContext(const FileContextConstPtr &ctx) const; + void ignoreItem(Item *item, ProjectContext *projectContext); + TopLevelProjectPtr resolveTopLevelProject(); + void resolveProject(Item *item, ProjectContext *projectContext); + void resolveProjectFully(Item *item, ProjectContext *projectContext); + void resolveSubProject(Item *item, ProjectContext *projectContext); + void resolveProduct(Item *item, ProjectContext *projectContext); + void resolveProductFully(Item *item, ProjectContext *projectContext); + void resolveModules(const Item *item, ProjectContext *projectContext); + void resolveModule(const QualifiedId &moduleName, Item *item, bool isProduct, + const QVariantMap ¶meters, JobLimits &jobLimits, + ProjectContext *projectContext); + void gatherProductTypes(ResolvedProduct *product, Item *item); + QVariantMap resolveAdditionalModuleProperties(const Item *group, + const QVariantMap ¤tValues); + void resolveGroup(Item *item, ProjectContext *projectContext); + void resolveGroupFully(Item *item, ProjectContext *projectContext, bool isEnabled); + void resolveShadowProduct(Item *item, ProjectContext *); + void resolveExport(Item *exportItem, ProjectContext *); + std::unique_ptr resolveExportChild(const Item *item, + const ExportedModule &module); + void resolveRule(Item *item, ProjectContext *projectContext); + void resolveRuleArtifact(const RulePtr &rule, Item *item); + void resolveRuleArtifactBinding(const RuleArtifactPtr &ruleArtifact, Item *item, + const QStringList &namePrefix, + QualifiedIdSet *seenBindings); + void resolveFileTagger(Item *item, ProjectContext *projectContext); + void resolveJobLimit(Item *item, ProjectContext *projectContext); + void resolveScanner(Item *item, ProjectContext *projectContext); + void resolveProductDependencies(const ProjectContext &projectContext); + void postProcess(const ResolvedProductPtr &product, ProjectContext *projectContext) const; + void applyFileTaggers(const ResolvedProductPtr &product) const; + QVariantMap evaluateModuleValues(Item *item, bool lookupPrototype = true); + QVariantMap evaluateProperties(Item *item, bool lookupPrototype, bool checkErrors); + QVariantMap evaluateProperties(const Item *item, const Item *propertiesContainer, + const QVariantMap &tmplt, bool lookupPrototype, + bool checkErrors); + void evaluateProperty(const Item *item, const QString &propName, const ValuePtr &propValue, + QVariantMap &result, bool checkErrors); + void checkAllowedValues( + const QVariant &v, const CodeLocation &loc, const PropertyDeclaration &decl, + const QString &key) const; + void createProductConfig(ResolvedProduct *product); + ProjectContext createProjectContext(ProjectContext *parentProjectContext) const; + void adaptExportedPropertyValues(const Item *shadowProductItem); + void collectExportedProductDependencies(); + + struct ProductDependencyInfo + { + ProductDependencyInfo(ResolvedProductPtr product, + QVariantMap parameters = QVariantMap()) + : product(std::move(product)), parameters(std::move(parameters)) + { + } + + ResolvedProductPtr product; + QVariantMap parameters; + }; + + struct ProductDependencyInfos + { + std::vector dependencies; + bool hasDisabledDependency = false; + }; + + ProductDependencyInfos getProductDependencies(const ResolvedProductConstPtr &product, + const ModuleLoaderResult::ProductInfo &productInfo); + QString sourceCodeAsFunction(const JSSourceValueConstPtr &value, + const PropertyDeclaration &decl) const; + QString sourceCodeForEvaluation(const JSSourceValueConstPtr &value) const; + static void matchArtifactProperties(const ResolvedProductPtr &product, + const std::vector &artifacts); + void printProfilingInfo(); + + void collectPropertiesForExportItem(Item *productModuleInstance); + void collectPropertiesForModuleInExportItem(const Item::Module &module); + + void collectPropertiesForExportItem(const QualifiedId &moduleName, + const ValuePtr &value, Item *moduleInstance, QVariantMap &moduleProps); + void setupExportedProperties(const Item *item, const QString &namePrefix, + std::vector &properties); + + Evaluator *m_evaluator = nullptr; + Logger &m_logger; + ScriptEngine *m_engine = nullptr; + ProgressObserver *m_progressObserver = nullptr; + ProductContext *m_productContext = nullptr; + ModuleContext *m_moduleContext = nullptr; + QMap m_productsByName; + QHash > m_productsByType; + QHash m_productItemMap; + mutable QHash m_fileContextMap; + mutable QHash m_scriptFunctionMap; + mutable QHash, QString> m_scriptFunctions; + mutable QHash m_sourceCode; + const SetupProjectParameters m_setupParams; + ModuleLoaderResult m_loadResult; + Set m_groupLocationWarnings; + std::vector> m_productExportInfo; + std::vector m_queuedErrors; + qint64 m_elapsedTimeModPropEval = 0; + qint64 m_elapsedTimeAllPropEval = 0; + qint64 m_elapsedTimeGroups = 0; + + typedef void (ProjectResolver::*ItemFuncPtr)(Item *item, ProjectContext *projectContext); + using ItemFuncMap = QMap; + void callItemFunction(const ItemFuncMap &mappings, Item *item, ProjectContext *projectContext); +}; + +} // namespace Internal +} // namespace qbs + +#endif // PROJECTRESOLVER_H diff --git a/src/lib/corelib/language/property.cpp b/src/lib/corelib/language/property.cpp new file mode 100644 index 00000000..8349e201 --- /dev/null +++ b/src/lib/corelib/language/property.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "property.h" + +namespace qbs { +namespace Internal { + +bool operator<(const Property &p1, const Property &p2) +{ + int cmpResult = QString::compare(p1.productName, p2.productName); + if (cmpResult < 0) + return true; + if (cmpResult > 0) + return false; + cmpResult = QString::compare(p1.moduleName, p2.moduleName); + if (cmpResult < 0) + return true; + if (cmpResult > 0) + return false; + return p1.propertyName < p2.propertyName; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/property.h b/src/lib/corelib/language/property.h new file mode 100644 index 00000000..302973d1 --- /dev/null +++ b/src/lib/corelib/language/property.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROPERTY_H +#define QBS_PROPERTY_H + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class Property +{ +public: + enum Kind + { + PropertyInModule, + PropertyInProduct, + PropertyInProject, + PropertyInParameters, + PropertyInArtifact, + }; + + Property() + : kind(PropertyInModule) + { + } + + Property(QString product, QString module, QString property, + QVariant v, Kind k) + : productName(std::move(product)) + , moduleName(std::move(module)) + , propertyName(std::move(property)) + , value(std::move(v)) + , kind(k) + { + } + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(productName, moduleName, propertyName, value, kind); + } + + QString productName; // In case of kind == PropertyInProject, this is the project name. + QString moduleName; + QString propertyName; + QVariant value; + Kind kind; +}; + +inline bool operator==(const Property &p1, const Property &p2) +{ + return p1.productName == p2.productName && p1.moduleName == p2.moduleName + && p1.propertyName == p2.propertyName; +} +bool operator<(const Property &p1, const Property &p2); + +inline auto qHash(const Property &p) +{ + return QT_PREPEND_NAMESPACE(qHash)(p.productName + p.moduleName + p.propertyName); +} + +using PropertySet = Set; +using PropertyHash = QHash; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/language/propertydeclaration.cpp b/src/lib/corelib/language/propertydeclaration.cpp new file mode 100644 index 00000000..2dbe41af --- /dev/null +++ b/src/lib/corelib/language/propertydeclaration.cpp @@ -0,0 +1,303 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "propertydeclaration.h" + +#include "deprecationinfo.h" +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +// returns QMetaType::UnknownType for types that do not need conversion +static QMetaType::Type variantType(PropertyDeclaration::Type t) +{ + switch (t) { + case PropertyDeclaration::UnknownType: + break; + case PropertyDeclaration::Boolean: + return QMetaType::Bool; + case PropertyDeclaration::Integer: + return QMetaType::Int; + case PropertyDeclaration::Path: + return QMetaType::QString; + case PropertyDeclaration::PathList: + return QMetaType::QStringList; + case PropertyDeclaration::String: + return QMetaType::QString; + case PropertyDeclaration::StringList: + return QMetaType::QStringList; + case PropertyDeclaration::VariantList: + return QMetaType::QVariantList; + case PropertyDeclaration::Variant: + break; + } + return QMetaType::UnknownType; +} + +class PropertyDeclarationData : public QSharedData +{ +public: + PropertyDeclarationData() + : type(PropertyDeclaration::UnknownType) + , flags(PropertyDeclaration::DefaultFlags) + { + } + + QString name; + PropertyDeclaration::Type type; + PropertyDeclaration::Flags flags; + QStringList allowedValues; + QString description; + QString initialValueSource; + QStringList functionArgumentNames; + DeprecationInfo deprecationInfo; +}; + + +PropertyDeclaration::PropertyDeclaration() + : d(new PropertyDeclarationData) +{ +} + +PropertyDeclaration::PropertyDeclaration(const QString &name, Type type, + const QString &initialValue, Flags flags) + : d(new PropertyDeclarationData) +{ + d->name = name; + d->type = type; + d->initialValueSource = initialValue; + d->flags = flags; +} + +PropertyDeclaration::PropertyDeclaration(const PropertyDeclaration &other) = default; + +PropertyDeclaration::~PropertyDeclaration() = default; + +PropertyDeclaration &PropertyDeclaration::operator=(const PropertyDeclaration &other) = default; + +bool PropertyDeclaration::isValid() const +{ + return d && d->type != UnknownType; +} + +bool PropertyDeclaration::isScalar() const +{ + // ### Should be determined by a PropertyOption in the future. + return d->type != PathList && d->type != StringList && d->type != VariantList; +} + +static QString boolString() { return QStringLiteral("bool"); } +static QString intString() { return QStringLiteral("int"); } +static QString pathListString() { return QStringLiteral("pathList"); } +static QString stringString() { return QStringLiteral("string"); } +static QString stringListString() { return QStringLiteral("stringList"); } +static QString varString() { return QStringLiteral("var"); } +static QString variantString() { return QStringLiteral("variant"); } +static QString varListString() { return QStringLiteral("varList"); } + +PropertyDeclaration::Type PropertyDeclaration::propertyTypeFromString(const QString &typeName) +{ + if (typeName == boolString()) + return PropertyDeclaration::Boolean; + if (typeName == intString()) + return PropertyDeclaration::Integer; + if (typeName == StringConstants::pathType()) + return PropertyDeclaration::Path; + if (typeName == pathListString()) + return PropertyDeclaration::PathList; + if (typeName == stringString()) + return PropertyDeclaration::String; + if (typeName == stringListString()) + return PropertyDeclaration::StringList; + if (typeName == varString() || typeName == variantString()) + return PropertyDeclaration::Variant; + if (typeName == varListString()) + return PropertyDeclaration::VariantList; + return PropertyDeclaration::UnknownType; +} + +QString PropertyDeclaration::typeString() const +{ + return typeString(type()); +} + +QString PropertyDeclaration::typeString(PropertyDeclaration::Type t) +{ + switch (t) { + case Boolean: return boolString(); + case Integer: return intString(); + case Path: return StringConstants::pathType(); + case PathList: return pathListString(); + case String: return stringString(); + case StringList: return stringListString(); + case Variant: return variantString(); + case VariantList: return varListString(); + case UnknownType: return QStringLiteral("unknown"); + } + Q_UNREACHABLE(); // For stupid compilers. +} + +const QString &PropertyDeclaration::name() const +{ + return d->name; +} + +void PropertyDeclaration::setName(const QString &name) +{ + d->name = name; +} + +PropertyDeclaration::Type PropertyDeclaration::type() const +{ + return d->type; +} + +void PropertyDeclaration::setType(PropertyDeclaration::Type t) +{ + d->type = t; +} + +PropertyDeclaration::Flags PropertyDeclaration::flags() const +{ + return d->flags; +} + +void PropertyDeclaration::setFlags(Flags f) +{ + d->flags = f; +} + +const QStringList &PropertyDeclaration::allowedValues() const +{ + return d->allowedValues; +} + +void PropertyDeclaration::setAllowedValues(const QStringList &v) +{ + d->allowedValues = v; +} + +const QString &PropertyDeclaration::description() const +{ + return d->description; +} + +void PropertyDeclaration::setDescription(const QString &str) +{ + d->description = str; +} + +const QString &PropertyDeclaration::initialValueSource() const +{ + return d->initialValueSource; +} + +void PropertyDeclaration::setInitialValueSource(const QString &str) +{ + d->initialValueSource = str; +} + +const QStringList &PropertyDeclaration::functionArgumentNames() const +{ + return d->functionArgumentNames; +} + +void PropertyDeclaration::setFunctionArgumentNames(const QStringList &lst) +{ + d->functionArgumentNames = lst; +} + +bool PropertyDeclaration::isDeprecated() const +{ + return d->deprecationInfo.isValid(); +} + +bool PropertyDeclaration::isExpired() const +{ + return isDeprecated() && deprecationInfo().removalVersion() <= LanguageInfo::qbsVersion(); +} + +const DeprecationInfo &PropertyDeclaration::deprecationInfo() const +{ + return d->deprecationInfo; +} + +void PropertyDeclaration::setDeprecationInfo(const DeprecationInfo &deprecationInfo) +{ + d->deprecationInfo = deprecationInfo; +} + +// see also: EvaluatorScriptClass::convertToPropertyType() +QVariant PropertyDeclaration::convertToPropertyType(const QVariant &v, Type t, + const QStringList &namePrefix, const QString &key) +{ + if (v.isNull() || !v.isValid()) + return v; + const auto vt = variantType(t); + if (vt == QMetaType::UnknownType) + return v; + + // Handle the foo,bar,bla stringlist syntax. + if (t == PropertyDeclaration::StringList && v.userType() == QMetaType::QString) + return v.toString().split(QLatin1Char(',')); + + QVariant c = v; + if (!qVariantConvert(c, vt)) { + QStringList name = namePrefix; + name << key; + throw ErrorInfo(Tr::tr("Value '%1' of property '%2' has incompatible type.") + .arg(v.toString(), name.join(QLatin1Char('.')))); + } + return c; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/propertydeclaration.h b/src/lib/corelib/language/propertydeclaration.h new file mode 100644 index 00000000..137315d1 --- /dev/null +++ b/src/lib/corelib/language/propertydeclaration.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROPERTYDECLARATION_H +#define QBS_PROPERTYDECLARATION_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class DeprecationInfo; +class PropertyDeclarationData; + +class PropertyDeclaration +{ +public: + enum Type + { + UnknownType, + Boolean, + Integer, + Path, + PathList, + String, + StringList, + Variant, + VariantList, + }; + + enum Flag + { + DefaultFlags = 0, + ReadOnlyFlag = 0x1, + PropertyNotAvailableInConfig = 0x2 // Is this property part of a project, product or file configuration? + }; + Q_DECLARE_FLAGS(Flags, Flag) + + PropertyDeclaration(); + PropertyDeclaration(const QString &name, Type type, const QString &initialValue = QString(), + Flags flags = DefaultFlags); + PropertyDeclaration(const PropertyDeclaration &other); + ~PropertyDeclaration(); + + PropertyDeclaration &operator=(const PropertyDeclaration &other); + + bool isValid() const; + bool isScalar() const; + + static Type propertyTypeFromString(const QString &typeName); + QString typeString() const; + static QString typeString(Type t); + + const QString &name() const; + void setName(const QString &name); + + Type type() const; + void setType(Type t); + + Flags flags() const; + void setFlags(Flags f); + + const QStringList &allowedValues() const; + void setAllowedValues(const QStringList &v); + + const QString &description() const; + void setDescription(const QString &str); + + const QString &initialValueSource() const; + void setInitialValueSource(const QString &str); + + const QStringList &functionArgumentNames() const; + void setFunctionArgumentNames(const QStringList &lst); + + bool isDeprecated() const; + bool isExpired() const; + const DeprecationInfo &deprecationInfo() const; + void setDeprecationInfo(const DeprecationInfo &deprecationInfo); + + static QVariant convertToPropertyType( + const QVariant &v, Type t, const QStringList &namePrefix, const QString &key); + +private: + QSharedDataPointer d; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROPERTYDECLARATION_H diff --git a/src/lib/corelib/language/propertymapinternal.cpp b/src/lib/corelib/language/propertymapinternal.cpp new file mode 100644 index 00000000..fe0f672c --- /dev/null +++ b/src/lib/corelib/language/propertymapinternal.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "propertymapinternal.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { + +/*! + * \class PropertyMapInternal + * \brief The \c PropertyMapInternal class contains a set of properties and their values. + * An instance of this class is attached to every \c ResolvedProduct. + * \c ResolvedGroups inherit their properties from the respective \c ResolvedProduct, \c SourceArtifacts + * inherit theirs from the respective \c ResolvedGroup. \c ResolvedGroups can override the value of an + * inherited property, \c SourceArtifacts cannot. If a property value is overridden, a new + * \c PropertyMapInternal object is allocated, otherwise the pointer is shared. + * \sa ResolvedGroup + * \sa ResolvedProduct + * \sa SourceArtifact + */ +PropertyMapInternal::PropertyMapInternal() = default; + +PropertyMapInternal::PropertyMapInternal(const PropertyMapInternal &other) = default; + +QVariant PropertyMapInternal::moduleProperty(const QString &moduleName, const QString &key, + bool *isPresent) const +{ + return ::qbs::Internal::moduleProperty(m_value, moduleName, key, isPresent); +} + +QVariant PropertyMapInternal::qbsPropertyValue(const QString &key) const +{ + return moduleProperty(StringConstants::qbsModule(), key); +} + +QVariant PropertyMapInternal::property(const QStringList &name) const +{ + return getConfigProperty(m_value, name); +} + +void PropertyMapInternal::setValue(const QVariantMap &map) +{ + m_value = map; +} + +QVariant moduleProperty(const QVariantMap &properties, const QString &moduleName, + const QString &key, bool *isPresent) +{ + const auto moduleIt = properties.find(moduleName); + if (moduleIt == properties.end()) { + if (isPresent) + *isPresent = false; + return {}; + } + const QVariantMap &moduleMap = moduleIt.value().toMap(); + const auto propertyIt = moduleMap.find(key); + if (propertyIt == moduleMap.end()) { + if (isPresent) + *isPresent = false; + return {}; + } + if (isPresent) + *isPresent = true; + return propertyIt.value(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/propertymapinternal.h b/src/lib/corelib/language/propertymapinternal.h new file mode 100644 index 00000000..83e18ba4 --- /dev/null +++ b/src/lib/corelib/language/propertymapinternal.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROPERTYMAPINTERNAL_H +#define QBS_PROPERTYMAPINTERNAL_H + +#include "forward_decls.h" +#include +#include +#include + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT PropertyMapInternal +{ +public: + static PropertyMapPtr create() { return PropertyMapPtr(new PropertyMapInternal); } + PropertyMapPtr clone() const { return PropertyMapPtr(new PropertyMapInternal(*this)); } + + const QVariantMap &value() const { return m_value; } + QVariant moduleProperty(const QString &moduleName, + const QString &key, bool *isPresent = nullptr) const; + QVariant qbsPropertyValue(const QString &key) const; // Convenience function. + QVariant property(const QStringList &name) const; + void setValue(const QVariantMap &value); + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_value); + } + +private: + friend bool operator==(const PropertyMapInternal &lhs, const PropertyMapInternal &rhs); + + PropertyMapInternal(); + PropertyMapInternal(const PropertyMapInternal &other); + + QVariantMap m_value; +}; + +inline bool operator==(const PropertyMapInternal &lhs, const PropertyMapInternal &rhs) +{ + return lhs.m_value == rhs.m_value; +} + +QVariant QBS_AUTOTEST_EXPORT moduleProperty(const QVariantMap &properties, + const QString &moduleName, + const QString &key, bool *isPresent = nullptr); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROPERTYMAPINTERNAL_H diff --git a/src/lib/corelib/language/qualifiedid.cpp b/src/lib/corelib/language/qualifiedid.cpp new file mode 100644 index 00000000..9eb0e946 --- /dev/null +++ b/src/lib/corelib/language/qualifiedid.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qualifiedid.h" + +#include + +namespace qbs { +namespace Internal { + +QualifiedId::QualifiedId() = default; + +QualifiedId::QualifiedId(const QString &singlePartName) + : QStringList(singlePartName) +{ +} + +QualifiedId::QualifiedId(const QStringList &nameParts) + : QStringList(nameParts) +{ +} + +QualifiedId QualifiedId::fromString(const QString &str) +{ + return QualifiedId(str.split(QLatin1Char('.'))); +} + +QString QualifiedId::toString() const +{ + return join(QLatin1Char('.')); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/qualifiedid.h b/src/lib/corelib/language/qualifiedid.h new file mode 100644 index 00000000..7e8b388d --- /dev/null +++ b/src/lib/corelib/language/qualifiedid.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_QUALIFIEDID_H +#define QBS_QUALIFIEDID_H + +#include + +#include +#include + + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT QualifiedId : public QStringList +{ +public: + QualifiedId(); + QualifiedId(const QString &singlePartName); + QualifiedId(const QStringList &nameParts); + + static QualifiedId fromString(const QString &str); + QString toString() const; +}; + +inline auto qHash(const QualifiedId &qid) { return qHash(qid.toString()); } + +using QualifiedIdSet = Set; + +// Values are the properties with a dependency on the key property +using PropertyDependencies = QHash; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_QUALIFIEDID_H diff --git a/src/lib/corelib/language/resolvedfilecontext.cpp b/src/lib/corelib/language/resolvedfilecontext.cpp new file mode 100644 index 00000000..db63a8ef --- /dev/null +++ b/src/lib/corelib/language/resolvedfilecontext.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "resolvedfilecontext.h" + +#include "jsimports.h" +#include + +namespace qbs { +namespace Internal { + +ResolvedFileContext::ResolvedFileContext(const FileContextBase &ctx) + : FileContextBase(ctx) +{ +} + +bool operator==(const ResolvedFileContext &a, const ResolvedFileContext &b) +{ + return a.filePath() == b.filePath() + && toSet(a.jsExtensions()) == toSet(b.jsExtensions()) + && sorted(a.jsImports()) == sorted(b.jsImports()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/resolvedfilecontext.h b/src/lib/corelib/language/resolvedfilecontext.h new file mode 100644 index 00000000..d783cf72 --- /dev/null +++ b/src/lib/corelib/language/resolvedfilecontext.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_RESOLVEDFILECONTEXT_H +#define QBS_RESOLVEDFILECONTEXT_H + +#include "forward_decls.h" +#include "filecontextbase.h" +#include + +namespace qbs { +namespace Internal { + +class ResolvedFileContext : public FileContextBase +{ +public: + static ResolvedFileContextPtr create() + { + return ResolvedFileContextPtr(new ResolvedFileContext); + } + + static ResolvedFileContextPtr create(const FileContextBase &baseContext) + { + return ResolvedFileContextPtr(new ResolvedFileContext(baseContext)); + } + + template void completeSerializationOp(PersistentPool &pool) + { + pool.serializationOp(m_filePath, m_jsExtensions, m_searchPaths, m_jsImports); + } +private: + ResolvedFileContext() = default; + ResolvedFileContext(const FileContextBase &ctx); +}; + +bool operator==(const ResolvedFileContext &a, const ResolvedFileContext &b); +inline bool operator!=(const ResolvedFileContext &a, const ResolvedFileContext &b) +{ return !(a == b); } + +} // namespace Internal +} // namespace qbs + +#endif // QBS_RESOLVEDFILECONTEXT_H diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp new file mode 100644 index 00000000..0614f31f --- /dev/null +++ b/src/lib/corelib/language/scriptengine.cpp @@ -0,0 +1,830 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "scriptengine.h" + +#include "filecontextbase.h" +#include "jsimports.h" +#include "propertymapinternal.h" +#include "scriptimporter.h" +#include "preparescriptobserver.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +static QString getterFuncHelperProperty() { return QStringLiteral("qbsdata"); } + +const bool debugJSImports = false; + +bool operator==(const ScriptEngine::PropertyCacheKey &lhs, + const ScriptEngine::PropertyCacheKey &rhs) +{ + return lhs.m_propertyMap == rhs.m_propertyMap + && lhs.m_moduleName == rhs.m_moduleName + && lhs.m_propertyName == rhs.m_propertyName; +} + + + +static inline QHashValueType combineHash(QHashValueType h1, QHashValueType h2, QHashValueType seed) +{ + // stolen from qHash(QPair) + return ((h1 << 16) | (h1 >> 16)) ^ h2 ^ seed; +} + +QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed = 0) +{ + return combineHash(qHash(k.m_moduleName), + combineHash(qHash(k.m_propertyName), qHash(k.m_propertyMap), seed), seed); +} + +std::mutex ScriptEngine::m_creationDestructionMutex; + +ScriptEngine::ScriptEngine(Logger &logger, EvalContext evalContext, PrivateTag) + : m_scriptImporter(new ScriptImporter(this)), + m_modulePropertyScriptClass(nullptr), + m_propertyCacheEnabled(true), m_active(false), m_logger(logger), m_evalContext(evalContext), + m_observer(new PrepareScriptObserver(this, UnobserveMode::Disabled)) +{ + setProcessEventsInterval(1000); // For the cancelation mechanism to work. + m_cancelationError = currentContext()->throwValue(tr("Execution canceled")); + QScriptValue objectProto = globalObject().property(QStringLiteral("Object")); + m_definePropertyFunction = objectProto.property(QStringLiteral("defineProperty")); + QBS_ASSERT(m_definePropertyFunction.isFunction(), /* ignore */); + m_emptyFunction = evaluate(QStringLiteral("(function(){})")); + QBS_ASSERT(m_emptyFunction.isFunction(), /* ignore */); + // Initially push a new context to turn off scope chain insanity mode. + QScriptEngine::pushContext(); + installQbsBuiltins(); + extendJavaScriptBuiltins(); +} + +std::unique_ptr ScriptEngine::create(Logger &logger, EvalContext evalContext) +{ + std::lock_guard lock(m_creationDestructionMutex); + return std::make_unique(logger, evalContext, PrivateTag()); +} + +ScriptEngine::~ScriptEngine() +{ + m_creationDestructionMutex.lock(); + connect(this, &QObject::destroyed, std::bind(&std::mutex::unlock, &m_creationDestructionMutex)); + + releaseResourcesOfScriptObjects(); + delete (m_scriptImporter); + if (m_elapsedTimeImporting != -1) { + m_logger.qbsLog(LoggerInfo, true) << Tr::tr("Setting up imports took %1.") + .arg(elapsedTimeString(m_elapsedTimeImporting)); + } + delete m_modulePropertyScriptClass; + delete m_productPropertyScriptClass; +} + +void ScriptEngine::import(const FileContextBaseConstPtr &fileCtx, QScriptValue &targetObject, + ObserveMode observeMode) +{ + installImportFunctions(); + m_currentDirPathStack.push(FileInfo::path(fileCtx->filePath())); + m_extensionSearchPathsStack.push(fileCtx->searchPaths()); + m_observeMode = observeMode; + + for (const JsImport &jsImport : fileCtx->jsImports()) + import(jsImport, targetObject); + if (m_observeMode == ObserveMode::Enabled) { + for (QScriptValue &sv : m_requireResults) + observeImport(sv); + m_requireResults.clear(); + } + + m_currentDirPathStack.pop(); + m_extensionSearchPathsStack.pop(); + uninstallImportFunctions(); +} + +void ScriptEngine::import(const JsImport &jsImport, QScriptValue &targetObject) +{ + QBS_ASSERT(targetObject.isObject(), return); + QBS_ASSERT(targetObject.engine() == this, return); + + if (debugJSImports) + qDebug() << "[ENGINE] import into " << jsImport.scopeName; + + QScriptValue jsImportValue = m_jsImportCache.value(jsImport); + if (jsImportValue.isValid()) { + if (debugJSImports) + qDebug() << "[ENGINE] " << jsImport.filePaths << " (cache hit)"; + } else { + if (debugJSImports) + qDebug() << "[ENGINE] " << jsImport.filePaths << " (cache miss)"; + jsImportValue = newObject(); + for (const QString &filePath : jsImport.filePaths) + importFile(filePath, jsImportValue); + m_jsImportCache.insert(jsImport, jsImportValue); + std::vector &filePathsForScriptValue + = m_filePathsPerImport[jsImportValue.objectId()]; + transform(jsImport.filePaths, filePathsForScriptValue, [](const auto &fp) { + return fp; }); + } + + QScriptValue sv = newObject(); + sv.setPrototype(jsImportValue); + sv.setProperty(StringConstants::importScopeNamePropertyInternal(), jsImport.scopeName); + targetObject.setProperty(jsImport.scopeName, sv); + if (m_observeMode == ObserveMode::Enabled) + observeImport(jsImportValue); +} + +void ScriptEngine::observeImport(QScriptValue &jsImport) +{ + if (!m_observer->addImportId(jsImport.objectId())) + return; + QScriptValueIterator it(jsImport); + while (it.hasNext()) { + it.next(); + if (it.flags() & QScriptValue::PropertyGetter) + continue; + QScriptValue property = it.value(); + if (!property.isFunction()) + continue; + setObservedProperty(jsImport, it.name(), property); + } +} + +void ScriptEngine::clearImportsCache() +{ + m_jsImportCache.clear(); +} + +void ScriptEngine::checkContext(const QString &operation, + const DubiousContextList &dubiousContexts) +{ + for (const DubiousContext &info : dubiousContexts) { + if (info.context != evalContext()) + continue; + QString warning; + switch (info.context) { + case EvalContext::PropertyEvaluation: + warning = Tr::tr("Suspicious use of %1 during property evaluation.").arg(operation); + if (info.suggestion == DubiousContext::SuggestMoving) + warning += QLatin1Char(' ') + Tr::tr("Should this call be in a Probe instead?"); + break; + case EvalContext::RuleExecution: + warning = Tr::tr("Suspicious use of %1 during rule execution.").arg(operation); + if (info.suggestion == DubiousContext::SuggestMoving) { + warning += QLatin1Char(' ') + + Tr::tr("Should this call be in a JavaScriptCommand instead?"); + } + break; + case EvalContext::ModuleProvider: + case EvalContext::ProbeExecution: + case EvalContext::JsCommand: + QBS_ASSERT(false, continue); + break; + } + m_logger.printWarning(ErrorInfo(warning, currentContext()->backtrace())); + return; + } +} + +void ScriptEngine::addPropertyRequestedFromArtifact(const Artifact *artifact, + const Property &property) +{ + m_propertiesRequestedFromArtifact[artifact->filePath()] << property; +} + +void ScriptEngine::addImportRequestedInScript(qint64 importValueId) +{ + // Import list is assumed to be small, so let's not use a set. + if (!contains(m_importsRequestedInScript, importValueId)) + m_importsRequestedInScript.push_back(importValueId); +} + +std::vector ScriptEngine::importedFilesUsedInScript() const +{ + std::vector files; + for (qint64 usedImport : m_importsRequestedInScript) { + const auto it = m_filePathsPerImport.find(usedImport); + QBS_CHECK(it != m_filePathsPerImport.cend()); + const std::vector &filePathsForImport = it->second; + for (const QString &fp : filePathsForImport) + if (!contains(files, fp)) + files.push_back(fp); + } + return files; +} + +void ScriptEngine::enableProfiling(bool enable) +{ + m_elapsedTimeImporting = enable ? 0 : -1; +} + +void ScriptEngine::addToPropertyCache(const QString &moduleName, const QString &propertyName, + const PropertyMapConstPtr &propertyMap, const QVariant &value) +{ + m_propertyCache.insert(PropertyCacheKey(moduleName, propertyName, propertyMap), value); +} + +QVariant ScriptEngine::retrieveFromPropertyCache(const QString &moduleName, + const QString &propertyName, const PropertyMapConstPtr &propertyMap) +{ + return m_propertyCache.value(PropertyCacheKey(moduleName, propertyName, propertyMap)); +} + +void ScriptEngine::defineProperty(QScriptValue &object, const QString &name, + const QScriptValue &descriptor) +{ + QScriptValue arguments = newArray(); + arguments.setProperty(0, object); + arguments.setProperty(1, name); + arguments.setProperty(2, descriptor); + QScriptValue result = m_definePropertyFunction.call(QScriptValue(), arguments); + QBS_ASSERT(!hasErrorOrException(result), qDebug() << name << result.toString()); +} + +static QScriptValue js_observedGet(QScriptContext *context, QScriptEngine *, + ScriptPropertyObserver * const observer) +{ + const QScriptValue data = context->callee().property(getterFuncHelperProperty()); + const QScriptValue value = data.property(2); + observer->onPropertyRead(data.property(0), data.property(1).toVariant().toString(), value); + return value; +} + +void ScriptEngine::setObservedProperty(QScriptValue &object, const QString &name, + const QScriptValue &value) +{ + QScriptValue data = newArray(); + data.setProperty(0, object); + data.setProperty(1, name); + data.setProperty(2, value); + QScriptValue getterFunc = newFunction(js_observedGet, + static_cast(m_observer.get())); + getterFunc.setProperty(getterFuncHelperProperty(), data); + object.setProperty(name, getterFunc, QScriptValue::PropertyGetter); + if (m_observer->unobserveMode() == UnobserveMode::Enabled) + m_observedProperties.emplace_back(object, name, value); +} + +void ScriptEngine::unobserveProperties() +{ + for (auto &elem : m_observedProperties) { + QScriptValue &object = std::get<0>(elem); + const QString &name = std::get<1>(elem); + const QScriptValue &value = std::get<2>(elem); + object.setProperty(name, QScriptValue(), QScriptValue::PropertyGetter); + object.setProperty(name, value, QScriptValue::PropertyFlags()); + } + m_observedProperties.clear(); +} + +static QScriptValue js_deprecatedGet(QScriptContext *context, QScriptEngine *qtengine) +{ + const auto engine = static_cast(qtengine); + const QScriptValue data = context->callee().property(getterFuncHelperProperty()); + engine->logger().qbsWarning() + << ScriptEngine::tr("Property %1 is deprecated. Please use %2 instead.").arg( + data.property(0).toString(), data.property(1).toString()); + return data.property(2); +} + +void ScriptEngine::setDeprecatedProperty(QScriptValue &object, const QString &oldName, + const QString &newName, const QScriptValue &value) +{ + QScriptValue data = newArray(); + data.setProperty(0, oldName); + data.setProperty(1, newName); + data.setProperty(2, value); + QScriptValue getterFunc = newFunction(js_deprecatedGet); + getterFunc.setProperty(getterFuncHelperProperty(), data); + object.setProperty(oldName, getterFunc, QScriptValue::PropertyGetter + | QScriptValue::SkipInEnumeration); +} + +QProcessEnvironment ScriptEngine::environment() const +{ + return m_environment; +} + +void ScriptEngine::setEnvironment(const QProcessEnvironment &env) +{ + m_environment = env; +} + +void ScriptEngine::importFile(const QString &filePath, QScriptValue &targetObject) +{ + AccumulatingTimer importTimer(m_elapsedTimeImporting != -1 ? &m_elapsedTimeImporting : nullptr); + QScriptValue &evaluationResult = m_jsFileCache[filePath]; + if (evaluationResult.isValid()) { + ScriptImporter::copyProperties(evaluationResult, targetObject); + return; + } + QFile file(filePath); + if (Q_UNLIKELY(!file.open(QFile::ReadOnly))) + throw ErrorInfo(tr("Cannot open '%1'.").arg(filePath)); + QTextStream stream(&file); + setupDefaultCodec(stream); + const QString sourceCode = stream.readAll(); + file.close(); + m_currentDirPathStack.push(FileInfo::path(filePath)); + evaluationResult = m_scriptImporter->importSourceCode(sourceCode, filePath, targetObject); + m_currentDirPathStack.pop(); +} + +static QString findExtensionDir(const QStringList &searchPaths, const QString &extensionPath) +{ + for (const QString &searchPath : searchPaths) { + const QString dirPath = searchPath + QStringLiteral("/imports/") + extensionPath; + QFileInfo fi(dirPath); + if (fi.exists() && fi.isDir()) + return dirPath; + } + return {}; +} + +static QScriptValue mergeExtensionObjects(const QScriptValueList &lst) +{ + QScriptValue result; + for (const QScriptValue &v : lst) { + if (!result.isValid()) { + result = v; + continue; + } + QScriptValueIterator svit(v); + while (svit.hasNext()) { + svit.next(); + result.setProperty(svit.name(), svit.value()); + } + } + return result; +} + +static QScriptValue loadInternalExtension(QScriptContext *context, ScriptEngine *engine, + const QString &uri) +{ + const QString name = uri.mid(4); // remove the "qbs." part + QScriptValue extensionObj = JsExtensions::loadExtension(engine, name); + if (!extensionObj.isValid()) { + return context->throwError(ScriptEngine::tr("loadExtension: " + "cannot load extension '%1'.").arg(uri)); + } + return extensionObj; +} + +QScriptValue ScriptEngine::js_loadExtension(QScriptContext *context, QScriptEngine *qtengine) +{ + if (context->argumentCount() < 1) { + return context->throwError( + ScriptEngine::tr("The loadExtension function requires " + "an extension name.")); + } + + const auto engine = static_cast(qtengine); + ErrorInfo deprWarning(Tr::tr("The loadExtension() function is deprecated and will be " + "removed in a future version of Qbs. Use require() " + "instead."), context->backtrace()); + engine->logger().printWarning(deprWarning); + + return js_require(context, qtengine); +} + +QScriptValue ScriptEngine::js_loadFile(QScriptContext *context, QScriptEngine *qtengine) +{ + if (context->argumentCount() < 1) { + return context->throwError( + ScriptEngine::tr("The loadFile function requires a file path.")); + } + + const auto engine = static_cast(qtengine); + ErrorInfo deprWarning(Tr::tr("The loadFile() function is deprecated and will be " + "removed in a future version of Qbs. Use require() " + "instead."), context->backtrace()); + engine->logger().printWarning(deprWarning); + + return js_require(context, qtengine); +} + +QScriptValue ScriptEngine::js_require(QScriptContext *context, QScriptEngine *qtengine) +{ + const auto engine = static_cast(qtengine); + if (context->argumentCount() < 1) { + return context->throwError( + ScriptEngine::tr("The require function requires a module name or path.")); + } + + const QString moduleName = context->argument(0).toString(); + + // First try to load a named module if the argument doesn't look like a file path + if (!moduleName.contains(QLatin1Char('/'))) { + if (engine->m_extensionSearchPathsStack.empty()) + return context->throwError( + ScriptEngine::tr("require: internal error. No search paths.")); + + if (engine->m_logger.debugEnabled()) { + engine->m_logger.qbsDebug() + << "[require] loading extension " << moduleName; + } + + QString moduleNameAsPath = moduleName; + moduleNameAsPath.replace(QLatin1Char('.'), QLatin1Char('/')); + const QStringList searchPaths = engine->m_extensionSearchPathsStack.top(); + const QString dirPath = findExtensionDir(searchPaths, moduleNameAsPath); + if (dirPath.isEmpty()) { + if (moduleName.startsWith(QStringLiteral("qbs."))) + return loadInternalExtension(context, engine, moduleName); + } else { + QDirIterator dit(dirPath, StringConstants::jsFileWildcards(), + QDir::Files | QDir::Readable); + QScriptValueList values; + std::vector filePaths; + try { + while (dit.hasNext()) { + const QString filePath = dit.next(); + if (engine->m_logger.debugEnabled()) { + engine->m_logger.qbsDebug() + << "[require] importing file " << filePath; + } + QScriptValue obj = engine->newObject(); + engine->importFile(filePath, obj); + values << obj; + filePaths.push_back(filePath); + } + } catch (const ErrorInfo &e) { + return context->throwError(e.toString()); + } + + if (!values.empty()) { + const QScriptValue mergedValue = mergeExtensionObjects(values); + engine->m_requireResults.push_back(mergedValue); + engine->m_filePathsPerImport[mergedValue.objectId()] = filePaths; + return mergedValue; + } + } + + // The module name might be a file name component, which is assumed to be to a JavaScript + // file located in the current directory search path; try that next + } + + if (engine->m_currentDirPathStack.empty()) { + return context->throwError( + ScriptEngine::tr("require: internal error. No current directory.")); + } + + QScriptValue result; + try { + const QString filePath = FileInfo::resolvePath(engine->m_currentDirPathStack.top(), + moduleName); + result = engine->newObject(); + engine->importFile(filePath, result); + static const QString scopeNamePrefix = QStringLiteral("_qbs_scope_"); + const QString scopeName = scopeNamePrefix + QString::number(qHash(filePath), 16); + result.setProperty(StringConstants::importScopeNamePropertyInternal(), scopeName); + context->thisObject().setProperty(scopeName, result); + engine->m_requireResults.push_back(result); + engine->m_filePathsPerImport[result.objectId()] = { filePath }; + } catch (const ErrorInfo &e) { + result = context->throwError(e.toString()); + } + + return result; +} + +QScriptClass *ScriptEngine::modulePropertyScriptClass() const +{ + return m_modulePropertyScriptClass; +} + +void ScriptEngine::setModulePropertyScriptClass(QScriptClass *modulePropertyScriptClass) +{ + m_modulePropertyScriptClass = modulePropertyScriptClass; +} + +void ScriptEngine::addResourceAcquiringScriptObject(ResourceAcquiringScriptObject *obj) +{ + m_resourceAcquiringScriptObjects.push_back(obj); +} + +void ScriptEngine::releaseResourcesOfScriptObjects() +{ + if (m_resourceAcquiringScriptObjects.empty()) + return; + std::for_each(m_resourceAcquiringScriptObjects.begin(), m_resourceAcquiringScriptObjects.end(), + std::mem_fn(&ResourceAcquiringScriptObject::releaseResources)); + m_resourceAcquiringScriptObjects.clear(); +} + +void ScriptEngine::addCanonicalFilePathResult(const QString &filePath, + const QString &resultFilePath) +{ + if (gatherFileResults()) + m_canonicalFilePathResult.insert(filePath, resultFilePath); +} + +void ScriptEngine::addFileExistsResult(const QString &filePath, bool exists) +{ + if (gatherFileResults()) + m_fileExistsResult.insert(filePath, exists); +} + +void ScriptEngine::addDirectoryEntriesResult(const QString &path, QDir::Filters filters, + const QStringList &entries) +{ + if (gatherFileResults()) { + m_directoryEntriesResult.insert( + std::pair(path, static_cast(filters)), + entries); + } +} + +void ScriptEngine::addFileLastModifiedResult(const QString &filePath, const FileTime &fileTime) +{ + if (gatherFileResults()) + m_fileLastModifiedResult.insert(filePath, fileTime); +} + +Set ScriptEngine::imports() const +{ + Set filePaths; + for (auto it = m_jsImportCache.cbegin(); it != m_jsImportCache.cend(); ++it) { + const JsImport &jsImport = it.key(); + for (const QString &filePath : jsImport.filePaths) + filePaths << filePath; + } + for (const auto &kv : m_filePathsPerImport) { + for (const QString &fp : kv.second) + filePaths << fp; + } + return filePaths; +} + +QScriptValueList ScriptEngine::argumentList(const QStringList &argumentNames, + const QScriptValue &context) +{ + QScriptValueList result; + for (const auto &name : argumentNames) + result += context.property(name); + return result; +} + +CodeLocation ScriptEngine::lastErrorLocation(const QScriptValue &v, + const CodeLocation &fallbackLocation) const +{ + const QScriptValue &errorVal = lastErrorValue(v); + const CodeLocation errorLoc(errorVal.property(StringConstants::fileNameProperty()).toString(), + errorVal.property(QStringLiteral("lineNumber")).toInt32(), + errorVal.property(QStringLiteral("expressionCaretOffset")).toInt32(), + false); + return errorLoc.isValid() ? errorLoc : fallbackLocation; +} + +ErrorInfo ScriptEngine::lastError(const QScriptValue &v, const CodeLocation &fallbackLocation) const +{ + const QString msg = lastErrorString(v); + CodeLocation errorLocation = lastErrorLocation(v); + if (errorLocation.isValid()) + return ErrorInfo(msg, errorLocation); + const QStringList backtrace = uncaughtExceptionBacktraceOrEmpty(); + if (!backtrace.empty()) { + ErrorInfo e(msg, backtrace); + if (e.hasLocation()) + return e; + } + return ErrorInfo(msg, fallbackLocation); +} + +void ScriptEngine::cancel() +{ + QTimer::singleShot(0, this, [this] { abort(); }); +} + +void ScriptEngine::abort() +{ + abortEvaluation(m_cancelationError); +} + +bool ScriptEngine::gatherFileResults() const +{ + return evalContext() == EvalContext::PropertyEvaluation + || evalContext() == EvalContext::ProbeExecution; +} + +class JSTypeExtender +{ +public: + JSTypeExtender(ScriptEngine *engine, const QString &typeName) + : m_engine(engine) + { + m_proto = engine->globalObject().property(typeName) + .property(QStringLiteral("prototype")); + QBS_ASSERT(m_proto.isObject(), return); + m_descriptor = engine->newObject(); + } + + void addFunction(const QString &name, const QString &code) + { + QScriptValue f = m_engine->evaluate(code); + QBS_ASSERT(f.isFunction(), return); + m_descriptor.setProperty(QStringLiteral("value"), f); + m_engine->defineProperty(m_proto, name, m_descriptor); + } + +private: + ScriptEngine *const m_engine; + QScriptValue m_proto; + QScriptValue m_descriptor; +}; + +static QScriptValue js_consoleError(QScriptContext *context, QScriptEngine *engine, Logger *logger) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("console.error() expects 1 argument")); + logger->qbsLog(LoggerError) << context->argument(0).toString(); + return engine->undefinedValue(); +} + +static QScriptValue js_consoleWarn(QScriptContext *context, QScriptEngine *engine, Logger *logger) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("console.warn() expects 1 argument")); + logger->qbsWarning() << context->argument(0).toString(); + return engine->undefinedValue(); +} + +static QScriptValue js_consoleInfo(QScriptContext *context, QScriptEngine *engine, Logger *logger) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("console.info() expects 1 argument")); + logger->qbsInfo() << context->argument(0).toString(); + return engine->undefinedValue(); +} + +static QScriptValue js_consoleDebug(QScriptContext *context, QScriptEngine *engine, Logger *logger) +{ + if (Q_UNLIKELY(context->argumentCount() != 1)) + return context->throwError(QScriptContext::SyntaxError, + QStringLiteral("console.debug() expects 1 argument")); + logger->qbsDebug() << context->argument(0).toString(); + return engine->undefinedValue(); +} + +static QScriptValue js_consoleLog(QScriptContext *context, QScriptEngine *engine, Logger *logger) +{ + return js_consoleDebug(context, engine, logger); +} + +void ScriptEngine::installQbsBuiltins() +{ + globalObject().setProperty(StringConstants::qbsModule(), m_qbsObject = newObject()); + + globalObject().setProperty(QStringLiteral("console"), m_consoleObject = newObject()); + installConsoleFunction(QStringLiteral("debug"), &js_consoleDebug); + installConsoleFunction(QStringLiteral("error"), &js_consoleError); + installConsoleFunction(QStringLiteral("info"), &js_consoleInfo); + installConsoleFunction(QStringLiteral("log"), &js_consoleLog); + installConsoleFunction(QStringLiteral("warn"), &js_consoleWarn); +} + +void ScriptEngine::extendJavaScriptBuiltins() +{ + JSTypeExtender arrayExtender(this, QStringLiteral("Array")); + arrayExtender.addFunction(QStringLiteral("contains"), + QStringLiteral("(function(e){return this.indexOf(e) !== -1;})")); + arrayExtender.addFunction(QStringLiteral("containsAll"), + QStringLiteral("(function(e){var $this = this;" + "return e.every(function (v) { return $this.contains(v) });})")); + arrayExtender.addFunction(QStringLiteral("containsAny"), + QStringLiteral("(function(e){var $this = this;" + "return e.some(function (v) { return $this.contains(v) });})")); + arrayExtender.addFunction(QStringLiteral("uniqueConcat"), + QStringLiteral("(function(other){" + "var r = this.concat();" + "var s = {};" + "r.forEach(function(x){ s[x] = true; });" + "other.forEach(function(x){" + "if (!s[x]) {" + "s[x] = true;" + "r.push(x);" + "}" + "});" + "return r;})")); + + JSTypeExtender stringExtender(this, QStringLiteral("String")); + stringExtender.addFunction(QStringLiteral("contains"), + QStringLiteral("(function(e){return this.indexOf(e) !== -1;})")); + stringExtender.addFunction(QStringLiteral("startsWith"), + QStringLiteral("(function(e){return this.slice(0, e.length) === e;})")); + stringExtender.addFunction(QStringLiteral("endsWith"), + QStringLiteral("(function(e){return this.slice(-e.length) === e;})")); +} + +void ScriptEngine::installFunction(const QString &name, int length, QScriptValue *functionValue, + FunctionSignature f, QScriptValue *targetObject = nullptr) +{ + if (!functionValue->isValid()) + *functionValue = newFunction(f, length); + (targetObject ? *targetObject : globalObject()).setProperty(name, *functionValue); +} + +void ScriptEngine::installQbsFunction(const QString &name, int length, FunctionSignature f) +{ + QScriptValue functionValue; + installFunction(name, length, &functionValue, f, &m_qbsObject); +} + +void ScriptEngine::installConsoleFunction(const QString &name, + QScriptValue (*f)(QScriptContext *, QScriptEngine *, Logger *)) +{ + m_consoleObject.setProperty(name, newFunction(f, &m_logger)); +} + +static QString loadFileString() { return QStringLiteral("loadFile"); } +static QString loadExtensionString() { return QStringLiteral("loadExtension"); } +static QString requireString() { return QStringLiteral("require"); } + +void ScriptEngine::installImportFunctions() +{ + installFunction(loadFileString(), 1, &m_loadFileFunction, js_loadFile); + installFunction(loadExtensionString(), 1, &m_loadExtensionFunction, js_loadExtension); + installFunction(requireString(), 1, &m_requireFunction, js_require); +} + +void ScriptEngine::uninstallImportFunctions() +{ + globalObject().setProperty(loadFileString(), QScriptValue()); + globalObject().setProperty(loadExtensionString(), QScriptValue()); + globalObject().setProperty(requireString(), QScriptValue()); +} + +ScriptEngine::PropertyCacheKey::PropertyCacheKey(QString moduleName, + QString propertyName, PropertyMapConstPtr propertyMap) + : m_moduleName(std::move(moduleName)) + , m_propertyName(std::move(propertyName)) + , m_propertyMap(std::move(propertyMap)) +{ +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/scriptengine.h b/src/lib/corelib/language/scriptengine.h new file mode 100644 index 00000000..68e346b6 --- /dev/null +++ b/src/lib/corelib/language/scriptengine.h @@ -0,0 +1,388 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SCRIPTENGINE_H +#define QBS_SCRIPTENGINE_H + +#include "forward_decls.h" +#include "property.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { +class Artifact; +class JsImport; +class PrepareScriptObserver; +class ScriptImporter; +class ScriptPropertyObserver; + +enum class EvalContext { + PropertyEvaluation, ProbeExecution, ModuleProvider, RuleExecution, JsCommand +}; +class DubiousContext +{ +public: + enum Suggestion { NoSuggestion, SuggestMoving }; + DubiousContext(EvalContext c, Suggestion s = NoSuggestion) : context(c), suggestion(s) { } + EvalContext context; + Suggestion suggestion; +}; +using DubiousContextList = std::vector; + + +/* + * ScriptObject that acquires resources, for example a file handle. + * The ScriptObject should have QtOwnership and deleteLater() itself in releaseResources. + */ +class ResourceAcquiringScriptObject +{ +public: + virtual ~ResourceAcquiringScriptObject() = default; + virtual void releaseResources() = 0; +}; + +enum class ObserveMode { Enabled, Disabled }; + +class QBS_AUTOTEST_EXPORT ScriptEngine : public QScriptEngine +{ + Q_OBJECT + struct PrivateTag {}; +public: + ScriptEngine(Logger &logger, EvalContext evalContext, PrivateTag); + ~ScriptEngine() override; + + static std::unique_ptr create(Logger &logger, EvalContext evalContext); + + Logger &logger() const { return m_logger; } + void import(const FileContextBaseConstPtr &fileCtx, QScriptValue &targetObject, + ObserveMode observeMode); + void clearImportsCache(); + + void setEvalContext(EvalContext c) { m_evalContext = c; } + EvalContext evalContext() const { return m_evalContext; } + void checkContext(const QString &operation, const DubiousContextList &dubiousContexts); + + void addPropertyRequestedInScript(const Property &property) { + m_propertiesRequestedInScript += property; + } + void addDependenciesArrayRequested(const ResolvedProduct *p) + { + m_productsWithRequestedDependencies.insert(p); + } + void setArtifactsMapRequested(const ResolvedProduct *product, bool forceUpdate) + { + m_requestedArtifacts.setAllArtifactTags(product, forceUpdate); + } + void setArtifactSetRequestedForTag(const ResolvedProduct *product, const FileTag &tag) + { + m_requestedArtifacts.setArtifactsForTag(product, tag); + } + void setNonExistingArtifactSetRequested(const ResolvedProduct *product, const QString &tag) + { + m_requestedArtifacts.setNonExistingTagRequested(product, tag); + } + void setArtifactsEnumerated(const ResolvedProduct *product) + { + m_requestedArtifacts.setArtifactsEnumerated(product); + } + void addPropertyRequestedFromArtifact(const Artifact *artifact, const Property &property); + void addRequestedExport(const ResolvedProduct *product) { m_requestedExports.insert(product); } + void clearRequestedProperties() { + m_propertiesRequestedInScript.clear(); + m_propertiesRequestedFromArtifact.clear(); + m_importsRequestedInScript.clear(); + m_productsWithRequestedDependencies.clear(); + m_requestedArtifacts.clear(); + m_requestedExports.clear(); + } + PropertySet propertiesRequestedInScript() const { return m_propertiesRequestedInScript; } + QHash propertiesRequestedFromArtifact() const { + return m_propertiesRequestedFromArtifact; + } + Set productsWithRequestedDependencies() const + { + return m_productsWithRequestedDependencies; + } + RequestedDependencies requestedDependencies() const + { + return RequestedDependencies(m_productsWithRequestedDependencies); + } + RequestedArtifacts requestedArtifacts() const { return m_requestedArtifacts; } + Set requestedExports() const { return m_requestedExports; } + + void addImportRequestedInScript(qint64 importValueId); + std::vector importedFilesUsedInScript() const; + + void setUsesIo() { m_usesIo = true; } + void clearUsesIo() { m_usesIo = false; } + bool usesIo() const { return m_usesIo; } + + void enableProfiling(bool enable); + + void setPropertyCacheEnabled(bool enable) { m_propertyCacheEnabled = enable; } + bool isPropertyCacheEnabled() const { return m_propertyCacheEnabled; } + void addToPropertyCache(const QString &moduleName, const QString &propertyName, + const PropertyMapConstPtr &propertyMap, const QVariant &value); + QVariant retrieveFromPropertyCache(const QString &moduleName, const QString &propertyName, + const PropertyMapConstPtr &propertyMap); + + void defineProperty(QScriptValue &object, const QString &name, const QScriptValue &descriptor); + void setObservedProperty(QScriptValue &object, const QString &name, const QScriptValue &value); + void unobserveProperties(); + void setDeprecatedProperty(QScriptValue &object, const QString &name, const QString &newName, + const QScriptValue &value); + PrepareScriptObserver *observer() const { return m_observer.get(); } + + QProcessEnvironment environment() const; + void setEnvironment(const QProcessEnvironment &env); + void addCanonicalFilePathResult(const QString &filePath, const QString &resultFilePath); + void addFileExistsResult(const QString &filePath, bool exists); + void addDirectoryEntriesResult(const QString &path, QDir::Filters filters, + const QStringList &entries); + void addFileLastModifiedResult(const QString &filePath, const FileTime &fileTime); + QHash canonicalFilePathResults() const { return m_canonicalFilePathResult; } + QHash fileExistsResults() const { return m_fileExistsResult; } + QHash, QStringList> directoryEntriesResults() const + { + return m_directoryEntriesResult; + } + + QHash fileLastModifiedResults() const { return m_fileLastModifiedResult; } + Set imports() const; + static QScriptValueList argumentList(const QStringList &argumentNames, + const QScriptValue &context); + + QStringList uncaughtExceptionBacktraceOrEmpty() const { + return hasUncaughtException() ? uncaughtExceptionBacktrace() : QStringList(); + } + bool hasErrorOrException(const QScriptValue &v) const { + return v.isError() || hasUncaughtException(); + } + QScriptValue lastErrorValue(const QScriptValue &v) const { + return v.isError() ? v : uncaughtException(); + } + QString lastErrorString(const QScriptValue &v) const { return lastErrorValue(v).toString(); } + CodeLocation lastErrorLocation(const QScriptValue &v, + const CodeLocation &fallbackLocation = CodeLocation()) const; + ErrorInfo lastError(const QScriptValue &v, + const CodeLocation &fallbackLocation = CodeLocation()) const; + + void cancel(); + + // The active flag is different from QScriptEngine::isEvaluating. + // It is set and cleared externally for example by the rule execution code. + bool isActive() const { return m_active; } + void setActive(bool on) { m_active = on; } + + using QScriptEngine::newFunction; + + template >, + typename = std::enable_if_t>, + typename = std::enable_if_t>> + > QScriptValue newFunction(QScriptValue (*signature)(QScriptContext *, E, T), T arg) { + return QScriptEngine::newFunction( + reinterpret_cast(signature), + reinterpret_cast(const_cast< + std::add_pointer_t< + std::remove_const_t< + std::remove_pointer_t>>>(arg))); + } + + QScriptClass *modulePropertyScriptClass() const; + void setModulePropertyScriptClass(QScriptClass *modulePropertyScriptClass); + + QScriptClass *productPropertyScriptClass() const { return m_productPropertyScriptClass; } + void setProductPropertyScriptClass(QScriptClass *productPropertyScriptClass) + { + m_productPropertyScriptClass = productPropertyScriptClass; + } + + QScriptClass *artifactsScriptClass() const { return m_artifactsScriptClass; } + void setArtifactsScriptClass(QScriptClass *artifactsScriptClass) + { + m_artifactsScriptClass = artifactsScriptClass; + } + + void addResourceAcquiringScriptObject(ResourceAcquiringScriptObject *obj); + void releaseResourcesOfScriptObjects(); + + QScriptValue &productScriptValuePrototype(const ResolvedProduct *product) + { + return m_productScriptValues[product]; + } + + QScriptValue &projectScriptValue(const ResolvedProject *project) + { + return m_projectScriptValues[project]; + } + + QScriptValue &moduleScriptValuePrototype(const ResolvedModule *module) + { + return m_moduleScriptValues[module]; + } + +private: + QScriptValue newFunction(FunctionWithArgSignature signature, void *arg) Q_DECL_EQ_DELETE; + + void abort(); + + bool gatherFileResults() const; + + void installQbsBuiltins(); + void extendJavaScriptBuiltins(); + void installFunction(const QString &name, int length, QScriptValue *functionValue, + FunctionSignature f, QScriptValue *targetObject); + void installQbsFunction(const QString &name, int length, FunctionSignature f); + void installConsoleFunction(const QString &name, + QScriptValue (*f)(QScriptContext *, QScriptEngine *, Logger *)); + void installImportFunctions(); + void uninstallImportFunctions(); + void import(const JsImport &jsImport, QScriptValue &targetObject); + void observeImport(QScriptValue &jsImport); + void importFile(const QString &filePath, QScriptValue &targetObject); + static QScriptValue js_loadExtension(QScriptContext *context, QScriptEngine *qtengine); + static QScriptValue js_loadFile(QScriptContext *context, QScriptEngine *qtengine); + static QScriptValue js_require(QScriptContext *context, QScriptEngine *qtengine); + + class PropertyCacheKey + { + public: + PropertyCacheKey(QString moduleName, QString propertyName, + PropertyMapConstPtr propertyMap); + private: + const QString m_moduleName; + const QString m_propertyName; + const PropertyMapConstPtr m_propertyMap; + + friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs); + friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed); + }; + + friend bool operator==(const PropertyCacheKey &lhs, const PropertyCacheKey &rhs); + friend QHashValueType qHash(const ScriptEngine::PropertyCacheKey &k, QHashValueType seed); + + static std::mutex m_creationDestructionMutex; + ScriptImporter *m_scriptImporter; + QScriptClass *m_modulePropertyScriptClass; + QScriptClass *m_productPropertyScriptClass = nullptr; + QScriptClass *m_artifactsScriptClass = nullptr; + QHash m_jsImportCache; + std::unordered_map m_jsFileCache; + bool m_propertyCacheEnabled; + bool m_active; + QHash m_propertyCache; + PropertySet m_propertiesRequestedInScript; + QHash m_propertiesRequestedFromArtifact; + Logger &m_logger; + QScriptValue m_definePropertyFunction; + QScriptValue m_emptyFunction; + QProcessEnvironment m_environment; + QHash m_canonicalFilePathResult; + QHash m_fileExistsResult; + QHash, QStringList> m_directoryEntriesResult; + QHash m_fileLastModifiedResult; + std::stack m_currentDirPathStack; + std::stack m_extensionSearchPathsStack; + QScriptValue m_loadFileFunction; + QScriptValue m_loadExtensionFunction; + QScriptValue m_requireFunction; + QScriptValue m_qbsObject; + QScriptValue m_consoleObject; + QScriptValue m_cancelationError; + qint64 m_elapsedTimeImporting = -1; + bool m_usesIo = false; + EvalContext m_evalContext; + std::vector m_resourceAcquiringScriptObjects; + const std::unique_ptr m_observer; + std::vector> m_observedProperties; + std::vector m_requireResults; + std::unordered_map> m_filePathsPerImport; + std::vector m_importsRequestedInScript; + Set m_productsWithRequestedDependencies; + RequestedArtifacts m_requestedArtifacts; + Set m_requestedExports; + ObserveMode m_observeMode = ObserveMode::Disabled; + std::unordered_map m_productScriptValues; + std::unordered_map m_projectScriptValues; + std::unordered_map m_moduleScriptValues; +}; + +class EvalContextSwitcher +{ +public: + EvalContextSwitcher(ScriptEngine *engine, EvalContext newContext) + : m_engine(engine), m_oldContext(engine->evalContext()) + { + engine->setEvalContext(newContext); + } + + ~EvalContextSwitcher() { m_engine->setEvalContext(m_oldContext); } + +private: + ScriptEngine * const m_engine; + const EvalContext m_oldContext; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_SCRIPTENGINE_H diff --git a/src/lib/corelib/language/scriptimporter.cpp b/src/lib/corelib/language/scriptimporter.cpp new file mode 100644 index 00000000..40162eb1 --- /dev/null +++ b/src/lib/corelib/language/scriptimporter.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "scriptimporter.h" + +#include "evaluator.h" +#include "scriptengine.h" + +#include +#include +#include +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class IdentifierExtractor : private QbsQmlJS::AST::Visitor +{ +public: + void start(QbsQmlJS::AST::Node *node) + { + m_first = true; + m_barrier = false; + m_suffix += QLatin1String("\nreturn {"); + if (node) + node->accept(this); + m_suffix += QLatin1String("}})()"); + } + + const QString &suffix() const { return m_suffix; } + +private: + bool visit(QbsQmlJS::AST::SourceElements *) override + { + // Only consider the top level of source elements. + if (m_barrier) + return false; + m_barrier = true; + return true; + } + + void endVisit(QbsQmlJS::AST::SourceElements *) override + { + m_barrier = false; + } + + bool visit(QbsQmlJS::AST::FunctionSourceElement *fse) override + { + add(fse->declaration->name); + return false; + } + + bool visit(QbsQmlJS::AST::VariableDeclaration *vd) override + { + add(vd->name); + return false; + } + + void add(QStringView name) + { + if (m_first) { + m_first = false; + m_suffix.reserve(m_suffix.length() + name.length() * 2 + 1); + } else { + m_suffix.reserve(m_suffix.length() + name.length() * 2 + 2); + m_suffix += QLatin1Char(','); + } + // ugly, but qt5 does not have append overload for QStringView + m_suffix.append(name.data(), name.size()); + m_suffix.append(QLatin1Char(':')); + m_suffix.append(name.data(), name.size()); + } + + bool m_first = false; + bool m_barrier = false; + QString m_suffix; +}; + + +ScriptImporter::ScriptImporter(ScriptEngine *scriptEngine) + : m_engine(scriptEngine) +{ +} + +QScriptValue ScriptImporter::importSourceCode(const QString &sourceCode, const QString &filePath, + QScriptValue &targetObject) +{ + Q_ASSERT(targetObject.isObject()); + // The targetObject doesn't get overwritten but enhanced by the contents of the .js file. + // This is necessary for library imports that consist of multiple js files. + + QString &code = m_sourceCodeCache[filePath]; + if (code.isEmpty()) { + QbsQmlJS::Engine engine; + QbsQmlJS::Lexer lexer(&engine); + lexer.setCode(sourceCode, 1, false); + QbsQmlJS::Parser parser(&engine); + if (!parser.parseProgram()) { + throw ErrorInfo(parser.errorMessage(), CodeLocation(filePath, parser.errorLineNumber(), + parser.errorColumnNumber())); + } + + IdentifierExtractor extractor; + extractor.start(parser.rootNode()); + code = QLatin1String("(function(){\n") + sourceCode + extractor.suffix(); + } + + QScriptValue result = m_engine->evaluate(code, filePath, 0); + throwOnEvaluationError(m_engine, result, [&filePath] () { return CodeLocation(filePath, 0); }); + copyProperties(result, targetObject); + return result; +} + +void ScriptImporter::copyProperties(const QScriptValue &src, QScriptValue &dst) +{ + QScriptValueIterator it(src); + while (it.hasNext()) { + it.next(); + dst.setProperty(it.name(), it.value()); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/scriptimporter.h b/src/lib/corelib/language/scriptimporter.h new file mode 100644 index 00000000..8cff0938 --- /dev/null +++ b/src/lib/corelib/language/scriptimporter.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SCRIPTIMPORTER_H +#define SCRIPTIMPORTER_H + +#include + +#include + +namespace qbs { +namespace Internal { + +class ScriptEngine; + +class ScriptImporter +{ +public: + ScriptImporter(ScriptEngine *scriptEngine); + QScriptValue importSourceCode(const QString &sourceCode, const QString &filePath, QScriptValue &targetObject); + + static void copyProperties(const QScriptValue &src, QScriptValue &dst); + +private: + ScriptEngine *m_engine; + QHash m_sourceCodeCache; +}; + +} // namespace Internal +} // namespace qbs + +#endif // SCRIPTIMPORTER_H diff --git a/src/lib/corelib/language/scriptpropertyobserver.cpp b/src/lib/corelib/language/scriptpropertyobserver.cpp new file mode 100644 index 00000000..4b2a0faf --- /dev/null +++ b/src/lib/corelib/language/scriptpropertyobserver.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "scriptpropertyobserver.h" + +#include "scriptengine.h" + +namespace qbs { +namespace Internal { + +ScriptPropertyObserver::~ScriptPropertyObserver() +{ + if (m_unobserveMode == UnobserveMode::Enabled) + m_engine->unobserveProperties(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/scriptpropertyobserver.h b/src/lib/corelib/language/scriptpropertyobserver.h new file mode 100644 index 00000000..7fb362b9 --- /dev/null +++ b/src/lib/corelib/language/scriptpropertyobserver.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SCRIPTPROPERTYOBSERVER_H +#define QBS_SCRIPTPROPERTYOBSERVER_H + +#include + +QT_BEGIN_NAMESPACE +class QScriptValue; +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class ScriptEngine; + +enum class UnobserveMode { Enabled, Disabled }; + +class ScriptPropertyObserver +{ +public: + ScriptPropertyObserver(ScriptEngine *engine, UnobserveMode unobserveMode) + : m_engine(engine), m_unobserveMode(unobserveMode) + {} + + UnobserveMode unobserveMode() const { return m_unobserveMode; } + + virtual ~ScriptPropertyObserver(); + + virtual void onPropertyRead(const QScriptValue &object, const QString &name, + const QScriptValue &value) = 0; + +protected: + ScriptEngine * engine() const { return m_engine; } + +private: + ScriptEngine * const m_engine; + const UnobserveMode m_unobserveMode; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_SCRIPTPROPERTYOBSERVER_H diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp new file mode 100644 index 00000000..5a4da2c8 --- /dev/null +++ b/src/lib/corelib/language/value.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "value.h" + +#include "filecontext.h" +#include "item.h" + +#include +#include + +namespace qbs { +namespace Internal { + +Value::Value(Type t, bool createdByPropertiesBlock) + : m_type(t), m_definingItem(nullptr), m_createdByPropertiesBlock(createdByPropertiesBlock) +{ +} + +Value::Value(const Value &other) + : m_type(other.m_type), + m_definingItem(other.m_definingItem), + m_next(other.m_next ? other.m_next->clone() : ValuePtr()), + m_createdByPropertiesBlock(other.m_createdByPropertiesBlock) +{ +} + +Value::~Value() = default; + +Item *Value::definingItem() const +{ + return m_definingItem; +} + +void Value::setDefiningItem(Item *item) +{ + m_definingItem = item; +} + +ValuePtr Value::next() const +{ + return m_next; +} + +void Value::setNext(const ValuePtr &next) +{ + QBS_ASSERT(next.get() != this, return); + QBS_CHECK(type() != VariantValueType); + m_next = next; +} + + +JSSourceValue::JSSourceValue(bool createdByPropertiesBlock) + : Value(JSSourceValueType, createdByPropertiesBlock) + , m_line(-1) + , m_column(-1) +{ +} + +JSSourceValue::JSSourceValue(const JSSourceValue &other) : Value(other) +{ + m_sourceCode = other.m_sourceCode; + m_line = other.m_line; + m_column = other.m_column; + m_file = other.m_file; + m_flags = other.m_flags; + m_baseValue = other.m_baseValue + ? std::static_pointer_cast(other.m_baseValue->clone()) + : JSSourceValuePtr(); + m_alternatives = transformed>( + other.m_alternatives, [](const auto &alternative) { + return alternative.clone(); }); +} + +JSSourceValuePtr JSSourceValue::create(bool createdByPropertiesBlock) +{ + return std::make_shared(createdByPropertiesBlock); +} + +JSSourceValue::~JSSourceValue() = default; + +ValuePtr JSSourceValue::clone() const +{ + return std::make_shared(*this); +} + +QString JSSourceValue::sourceCodeForEvaluation() const +{ + if (!hasFunctionForm()) + return m_sourceCode.toString(); + + // rewrite blocks to be able to use return statements in property assignments + static const QString prefix = QStringLiteral("(function()"); + static const QString suffix = QStringLiteral(")()"); + return prefix + m_sourceCode.toString() + suffix; +} + +void JSSourceValue::setLocation(int line, int column) +{ + m_line = line; + m_column = column; +} + +CodeLocation JSSourceValue::location() const +{ + return CodeLocation(m_file->filePath(), m_line, m_column); +} + +void JSSourceValue::setHasFunctionForm(bool b) +{ + if (b) + m_flags |= HasFunctionForm; + else + m_flags &= ~HasFunctionForm; +} + +void JSSourceValue::clearAlternatives() +{ + m_alternatives.clear(); +} + +void JSSourceValue::setDefiningItem(Item *item) +{ + Value::setDefiningItem(item); + for (const JSSourceValue::Alternative &a : m_alternatives) + a.value->setDefiningItem(item); +} + +ItemValue::ItemValue(Item *item, bool createdByPropertiesBlock) + : Value(ItemValueType, createdByPropertiesBlock) + , m_item(item) +{ + QBS_CHECK(m_item); +} + +ItemValuePtr ItemValue::create(Item *item, bool createdByPropertiesBlock) +{ + return std::make_shared(item, createdByPropertiesBlock); +} + +ValuePtr ItemValue::clone() const +{ + return create(m_item->clone(), createdByPropertiesBlock()); +} + +VariantValue::VariantValue(QVariant v) + : Value(VariantValueType, false) + , m_value(std::move(v)) +{ +} + +VariantValuePtr VariantValue::create(const QVariant &v) +{ + if (!v.isValid()) + return invalidValue(); + if (static_cast(v.userType()) == QMetaType::Bool) + return v.toBool() ? VariantValue::trueValue() : VariantValue::falseValue(); + return std::make_shared(v); +} + +ValuePtr VariantValue::clone() const +{ + return std::make_shared(*this); +} + +const VariantValuePtr &VariantValue::falseValue() +{ + static const VariantValuePtr v = std::make_shared(false); + return v; +} + +const VariantValuePtr &VariantValue::trueValue() +{ + static const VariantValuePtr v = std::make_shared(true); + return v; +} + +const VariantValuePtr &VariantValue::invalidValue() +{ + static const VariantValuePtr v = std::make_shared(QVariant()); + return v; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h new file mode 100644 index 00000000..5f6b5ca1 --- /dev/null +++ b/src/lib/corelib/language/value.h @@ -0,0 +1,231 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_VALUE_H +#define QBS_VALUE_H + +#include "forward_decls.h" +#include +#include + +#include + +namespace qbs { +namespace Internal { +class Item; +class ValueHandler; + +class Value +{ +public: + enum Type + { + JSSourceValueType, + ItemValueType, + VariantValueType + }; + + Value(Type t, bool createdByPropertiesBlock); + Value(const Value &other); + virtual ~Value(); + + Type type() const { return m_type; } + virtual void apply(ValueHandler *) = 0; + virtual ValuePtr clone() const = 0; + virtual CodeLocation location() const { return {}; } + + Item *definingItem() const; + virtual void setDefiningItem(Item *item); + + ValuePtr next() const; + void setNext(const ValuePtr &next); + + bool createdByPropertiesBlock() const { return m_createdByPropertiesBlock; } + void setCreatedByPropertiesBlock(bool b) { m_createdByPropertiesBlock = b; } + void clearCreatedByPropertiesBlock() { m_createdByPropertiesBlock = false; } + +private: + Type m_type; + Item *m_definingItem; + ValuePtr m_next; + bool m_createdByPropertiesBlock; +}; + +class ValueHandler +{ +public: + virtual void handle(JSSourceValue *value) = 0; + virtual void handle(ItemValue *value) = 0; + virtual void handle(VariantValue *value) = 0; +}; + +class JSSourceValue : public Value +{ + friend class ItemReaderASTVisitor; + + enum Flag + { + NoFlags = 0x00, + SourceUsesBase = 0x01, + SourceUsesOuter = 0x02, + SourceUsesOriginal = 0x04, + HasFunctionForm = 0x08, + ExclusiveListValue = 0x10, + BuiltinDefaultValue = 0x20, + }; + Q_DECLARE_FLAGS(Flags, Flag) + +public: + explicit JSSourceValue(bool createdByPropertiesBlock); + JSSourceValue(const JSSourceValue &other); + + static JSSourceValuePtr QBS_AUTOTEST_EXPORT create(bool createdByPropertiesBlock = false); + ~JSSourceValue() override; + + void apply(ValueHandler *handler) override { handler->handle(this); } + ValuePtr clone() const override; + + void setSourceCode(QStringView sourceCode) { m_sourceCode = sourceCode; } + QStringView sourceCode() const { return m_sourceCode; } + QString sourceCodeForEvaluation() const; + + void setLocation(int line, int column); + int line() const { return m_line; } + int column() const { return m_column; } + CodeLocation location() const override; + + void setFile(const FileContextPtr &file) { m_file = file; } + const FileContextPtr &file() const { return m_file; } + + void setSourceUsesBaseFlag() { m_flags |= SourceUsesBase; } + bool sourceUsesBase() const { return m_flags.testFlag(SourceUsesBase); } + bool sourceUsesOuter() const { return m_flags.testFlag(SourceUsesOuter); } + bool sourceUsesOriginal() const { return m_flags.testFlag(SourceUsesOriginal); } + bool hasFunctionForm() const { return m_flags.testFlag(HasFunctionForm); } + void setHasFunctionForm(bool b); + void setIsExclusiveListValue() { m_flags |= ExclusiveListValue; } + bool isExclusiveListValue() { return m_flags.testFlag(ExclusiveListValue); } + void setIsBuiltinDefaultValue() { m_flags |= BuiltinDefaultValue; } + bool isBuiltinDefaultValue() const { return m_flags.testFlag(BuiltinDefaultValue); } + + const JSSourceValuePtr &baseValue() const { return m_baseValue; } + void setBaseValue(const JSSourceValuePtr &v) { m_baseValue = v; } + + struct Alternative + { + struct PropertyData + { + PropertyData() = default; + PropertyData(QString v, const CodeLocation &l) : value(std::move(v)), location(l) {} + QString value; + CodeLocation location; + }; + + Alternative() = default; + Alternative(PropertyData c, PropertyData o, JSSourceValuePtr v) + : condition(std::move(c)), overrideListProperties(std::move(o)), value(std::move(v)) {} + Alternative clone() const + { + return Alternative(condition, overrideListProperties, + std::static_pointer_cast(value->clone())); + } + + PropertyData condition; + PropertyData overrideListProperties; + JSSourceValuePtr value; + }; + using AltProperty = Alternative::PropertyData; + + const std::vector &alternatives() const { return m_alternatives; } + void addAlternative(const Alternative &alternative) { m_alternatives.push_back(alternative); } + void clearAlternatives(); + + void setDefiningItem(Item *item) override; + +private: + QStringView m_sourceCode; + int m_line; + int m_column; + FileContextPtr m_file; + Flags m_flags; + JSSourceValuePtr m_baseValue; + std::vector m_alternatives; +}; + + +class ItemValue : public Value +{ +public: + ItemValue(Item *item, bool createdByPropertiesBlock); + static ItemValuePtr create(Item *item, bool createdByPropertiesBlock = false); + + Item *item() const { return m_item; } + void setItem(Item *item) { m_item = item; } + +private: + void apply(ValueHandler *handler) override { handler->handle(this); } + ValuePtr clone() const override; + + Item *m_item; +}; + + +class VariantValue : public Value +{ +public: + explicit VariantValue(QVariant v); + static VariantValuePtr create(const QVariant &v = QVariant()); + + void apply(ValueHandler *handler) override { handler->handle(this); } + ValuePtr clone() const override; + + const QVariant &value() const { return m_value; } + + static const VariantValuePtr &falseValue(); + static const VariantValuePtr &trueValue(); + static const VariantValuePtr &invalidValue(); + +private: + QVariant m_value; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_VALUE_H diff --git a/src/lib/corelib/logging/categories.cpp b/src/lib/corelib/logging/categories.cpp new file mode 100644 index 00000000..0f844f5b --- /dev/null +++ b/src/lib/corelib/logging/categories.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "categories.h" + +namespace qbs { +namespace Internal { + +Q_LOGGING_CATEGORY(lcBuildGraph, "qbs.buildgraph", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcDepScan, "qbs.depscan", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcExec, "qbs.exec", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcMocScan, "qbs.mocscan", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcModuleLoader, "qbs.moduleloader", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcPluginManager, "qbs.pluginmanager", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcProjectResolver, "qbs.projectresolver", QtCriticalMsg) +Q_LOGGING_CATEGORY(lcUpToDateCheck, "qbs.uptodate", QtCriticalMsg) + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/logging/categories.h b/src/lib/corelib/logging/categories.h new file mode 100644 index 00000000..40c69845 --- /dev/null +++ b/src/lib/corelib/logging/categories.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CATEGORIES_H +#define CATEGORIES_H + +#include + +namespace qbs { +namespace Internal { + +Q_DECLARE_LOGGING_CATEGORY(lcBuildGraph) +Q_DECLARE_LOGGING_CATEGORY(lcDepScan) +Q_DECLARE_LOGGING_CATEGORY(lcExec) +Q_DECLARE_LOGGING_CATEGORY(lcMocScan) +Q_DECLARE_LOGGING_CATEGORY(lcModuleLoader) +Q_DECLARE_LOGGING_CATEGORY(lcPluginManager) +Q_DECLARE_LOGGING_CATEGORY(lcProjectResolver) +Q_DECLARE_LOGGING_CATEGORY(lcUpToDateCheck) + +} // namespace Internal +} // namespace qbs + +#endif // CATEGORIES_H diff --git a/src/lib/corelib/logging/ilogsink.cpp b/src/lib/corelib/logging/ilogsink.cpp new file mode 100644 index 00000000..20cf52bc --- /dev/null +++ b/src/lib/corelib/logging/ilogsink.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "ilogsink.h" + +#include + +#include + +#include + +namespace qbs { + +QString logLevelTag(LoggerLevel level) +{ + if (level == LoggerInfo) + return {}; + QString str = logLevelName(level).toUpper(); + if (!str.isEmpty()) + str.append(QLatin1String(": ")); + return str; +} + +QString logLevelName(LoggerLevel level) +{ + switch (level) { + case qbs::LoggerError: + return QStringLiteral("error"); + case qbs::LoggerWarning: + return QStringLiteral("warning"); + case qbs::LoggerInfo: + return QStringLiteral("info"); + case qbs::LoggerDebug: + return QStringLiteral("debug"); + case qbs::LoggerTrace: + return QStringLiteral("trace"); + default: + break; + } + return {}; +} + +class ILogSink::ILogSinkPrivate +{ +public: + LoggerLevel logLevel = defaultLogLevel(); + std::mutex mutex; +}; + +ILogSink::ILogSink() : d(std::make_unique()) +{ +} + +ILogSink::~ILogSink() = default; + +void ILogSink::setLogLevel(LoggerLevel level) +{ + d->logLevel = level; +} + +LoggerLevel ILogSink::logLevel() const +{ + return d->logLevel; +} + +void ILogSink::printWarning(const ErrorInfo &warning) +{ + if (willPrint(LoggerWarning)) { + d->mutex.lock(); + doPrintWarning(warning); + d->mutex.unlock(); + } +} + +void ILogSink::printMessage(LoggerLevel level, const QString &message, const QString &tag, + bool force) +{ + if (force || willPrint(level)) { + d->mutex.lock(); + doPrintMessage(level, message, tag); + d->mutex.unlock(); + } +} + +void ILogSink::doPrintWarning(const ErrorInfo &warning) +{ + doPrintMessage(LoggerWarning, warning.toString(), QString()); +} + +} // namespace qbs diff --git a/src/lib/corelib/logging/ilogsink.h b/src/lib/corelib/logging/ilogsink.h new file mode 100644 index 00000000..0a055abc --- /dev/null +++ b/src/lib/corelib/logging/ilogsink.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ILOGSINK_H +#define QBS_ILOGSINK_H + +#include "../tools/qbs_export.h" + +#include + +#include + +namespace qbs { +class ErrorInfo; + +enum LoggerLevel +{ + LoggerMinLevel, + LoggerError = LoggerMinLevel, + LoggerWarning, + LoggerInfo, + LoggerDebug, + LoggerTrace, + LoggerMaxLevel = LoggerTrace +}; + +inline LoggerLevel defaultLogLevel() { return LoggerInfo; } +QBS_EXPORT QString logLevelTag(LoggerLevel level); +QBS_EXPORT QString logLevelName(LoggerLevel level); + +class QBS_EXPORT ILogSink +{ + Q_DISABLE_COPY(ILogSink) +public: + ILogSink(); + virtual ~ILogSink(); + + void setLogLevel(LoggerLevel level); + LoggerLevel logLevel() const; + + bool willPrint(LoggerLevel level) const { return level <= logLevel(); } + + void printWarning(const ErrorInfo &warning); + void printMessage(LoggerLevel level, const QString &message, + const QString &tag = QString(), bool force = false); + +private: + virtual void doPrintWarning(const ErrorInfo &warning); + virtual void doPrintMessage(LoggerLevel level, const QString &message, + const QString &tag) = 0; + + class ILogSinkPrivate; + const std::unique_ptr d; +}; + +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/logging/logger.cpp b/src/lib/corelib/logging/logger.cpp new file mode 100644 index 00000000..d4f51cd3 --- /dev/null +++ b/src/lib/corelib/logging/logger.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if defined(_MSC_VER) && _MSC_VER > 0 +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "logger.h" + +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +LogWriter::LogWriter(ILogSink *logSink, LoggerLevel level, bool force) + : m_logSink(logSink), m_level(level), m_force(force) +{} + +LogWriter::LogWriter(const LogWriter &other) + : m_logSink(other.m_logSink) + , m_level(other.m_level) + , m_message(other.m_message) + , m_tag(other.m_tag) + , m_force(other.m_force) +{ + other.m_message.clear(); +} + +LogWriter::~LogWriter() +{ + if (!m_message.isEmpty()) + m_logSink->printMessage(m_level, m_message, m_tag, m_force); +} + +const LogWriter &LogWriter::operator=(const LogWriter &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + m_logSink = other.m_logSink; + m_level = other.m_level; + m_message = other.m_message; + m_tag = other.m_tag; + m_force = other.m_force; + other.m_message.clear(); + return *this; +} + +void LogWriter::write(char c) +{ + write(QLatin1Char(c)); +} + +void LogWriter::write(const char *str) +{ + write(QLatin1String(str)); +} + +void LogWriter::write(const QChar &c) +{ + if (m_force || m_logSink->logLevel() >= m_level) + m_message.append(c); +} + +void LogWriter::write(const QString &message) +{ + if (m_force || m_logSink->logLevel() >= m_level) + m_message += message; +} + +void LogWriter::setMessageTag(const QString &tag) +{ + m_tag = tag; +} + +LogWriter operator<<(LogWriter w, const char *str) +{ + w.write(str); + return w; +} + +LogWriter operator<<(LogWriter w, const QByteArray &byteArray) +{ + w.write(byteArray.data()); + return w; +} + +LogWriter operator<<(LogWriter w, const QString &str) +{ + w.write(str); + return w; +} + +LogWriter operator<<(LogWriter w, const QStringList &strList) +{ + w.write('['); + for (int i = 0; i < strList.size(); ++i) { + w.write(strList.at(i)); + if (i != strList.size() - 1) + w.write(QStringLiteral(", ")); + } + w.write(']'); + return w; +} + +LogWriter operator<<(LogWriter w, const Internal::Set &strSet) +{ + bool firstLoop = true; + w.write('('); + for (const QString &str : strSet) { + if (firstLoop) + firstLoop = false; + else + w.write(QStringLiteral(", ")); + w.write(str); + } + w.write(')'); + return w; +} + +LogWriter operator<<(LogWriter w, const QVariant &variant) +{ + QString str = QLatin1String(variant.typeName()) + QLatin1Char('('); + if (variant.userType() == QMetaType::QVariantList) { + bool firstLoop = true; + const auto list = variant.toList(); + for (const QVariant &item : list) { + str += item.toString(); + if (firstLoop) + firstLoop = false; + else + str += QLatin1String(", "); + } + } else { + str += variant.toString(); + } + str += QLatin1Char(')'); + w.write(str); + return w; +} + +LogWriter operator<<(LogWriter w, int n) +{ + w.write(QString::number(n)); + return w; +} + +LogWriter operator<<(LogWriter w, qint64 n) +{ + w.write(QString::number(n)); + return w; +} + +LogWriter operator<<(LogWriter w, bool b) +{ + w.write(QString::fromLatin1(b ? "true" : "false")); + return w; +} + +LogWriter operator<<(LogWriter w, const MessageTag &tag) +{ + w.setMessageTag(tag.tag()); + return w; +} + +Logger::Logger(ILogSink *logger) : m_logSink(logger) +{ +} + +bool Logger::debugEnabled() const +{ + return m_logSink->willPrint(LoggerDebug); +} + +bool Logger::traceEnabled() const +{ + return m_logSink->willPrint(LoggerTrace); +} + +void Logger::printWarning(const ErrorInfo &warning) +{ + if (m_storeWarnings) + m_warnings.push_back(warning); + logSink()->printWarning(warning); +} + +LogWriter Logger::qbsLog(LoggerLevel level, bool force) const +{ + return LogWriter(m_logSink, level, force); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/logging/logger.h b/src/lib/corelib/logging/logger.h new file mode 100644 index 00000000..389dc7e0 --- /dev/null +++ b/src/lib/corelib/logging/logger.h @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LOGGER_H +#define QBS_LOGGER_H + +#include "ilogsink.h" + +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QVariant; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +template class Set; + +// Note that while these classes are not part of the API, we export some stuff for use by +// our command line tools for the sake of a uniform logging approach. + +class QBS_EXPORT LogWriter +{ +public: + LogWriter(ILogSink *logSink, LoggerLevel level, bool force = false); + + // log writer has move semantics and the last instance of + // a << chain prints the accumulated data + LogWriter(const LogWriter &other); + ~LogWriter(); + const LogWriter &operator=(const LogWriter &other); // NOLINT + + void write(char c); + void write(const char *str); + void write(const QChar &c); + void write(const QString &message); + + void setMessageTag(const QString &tag); + +private: + ILogSink *m_logSink; + LoggerLevel m_level; + mutable QString m_message; + QString m_tag; + bool m_force; +}; + +class QBS_EXPORT MessageTag +{ +public: + explicit MessageTag(QString tag) : m_tag(std::move(tag)) {} + + const QString &tag() const { return m_tag; } + +private: + QString m_tag; +}; + +QBS_EXPORT LogWriter operator<<(LogWriter w, const char *str); +QBS_EXPORT LogWriter operator<<(LogWriter w, const QByteArray &byteArray); +QBS_EXPORT LogWriter operator<<(LogWriter w, const QString &str); +QBS_EXPORT LogWriter operator<<(LogWriter w, const QStringList &strList); +QBS_EXPORT LogWriter operator<<(LogWriter w, const Internal::Set &strSet); +QBS_EXPORT LogWriter operator<<(LogWriter w, const QVariant &variant); +QBS_EXPORT LogWriter operator<<(LogWriter w, int n); +QBS_EXPORT LogWriter operator<<(LogWriter w, qint64 n); +QBS_EXPORT LogWriter operator<<(LogWriter w, bool b); +QBS_EXPORT LogWriter operator<<(LogWriter w, const MessageTag &tag); + + +class QBS_EXPORT Logger +{ +public: + Logger(ILogSink *logSink = 0); + + ILogSink *logSink() const { return m_logSink; } + + bool debugEnabled() const; + bool traceEnabled() const; + + void printWarning(const ErrorInfo &warning); + QList warnings() const { return m_warnings; } + void clearWarnings() { m_warnings.clear(); } + void storeWarnings() { m_storeWarnings = true; } + + LogWriter qbsLog(LoggerLevel level, bool force = false) const; + LogWriter qbsWarning() const { return qbsLog(LoggerWarning); } + LogWriter qbsInfo() const { return qbsLog(LoggerInfo); } + LogWriter qbsDebug() const { return qbsLog(LoggerDebug); } + LogWriter qbsTrace() const { return qbsLog(LoggerTrace); } + +private: + ILogSink *m_logSink; + QList m_warnings; + bool m_storeWarnings = false; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_LOGGER_H diff --git a/src/lib/corelib/logging/logging.pri b/src/lib/corelib/logging/logging.pri new file mode 100644 index 00000000..3a4379a9 --- /dev/null +++ b/src/lib/corelib/logging/logging.pri @@ -0,0 +1,18 @@ +include(../../../install_prefix.pri) + +HEADERS += \ + $$PWD/categories.h \ + $$PWD/logger.h \ + $$PWD/translator.h \ + $$PWD/ilogsink.h + +SOURCES += \ + $$PWD/categories.cpp \ + $$PWD/logger.cpp \ + $$PWD/ilogsink.cpp + +!qbs_no_dev_install { + logging_headers.files = $$PWD/ilogsink.h + logging_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/logging + INSTALLS += logging_headers +} diff --git a/src/lib/corelib/logging/translator.h b/src/lib/corelib/logging/translator.h new file mode 100644 index 00000000..122457e5 --- /dev/null +++ b/src/lib/corelib/logging/translator.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_TRANSLATOR_H +#define QBS_TRANSLATOR_H + +#include + +#include + +namespace qbs { +namespace Internal { + +class QBS_EXPORT Tr // Name intended to be short. Exported for use by command line tools. +{ + Q_DECLARE_TR_FUNCTIONS(Qbs) +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_TRANSLATOR_H diff --git a/src/lib/corelib/parser/parser.pri b/src/lib/corelib/parser/parser.pri new file mode 100644 index 00000000..e6a8a534 --- /dev/null +++ b/src/lib/corelib/parser/parser.pri @@ -0,0 +1,21 @@ +HEADERS += \ + $$PWD/qmljsast_p.h \ + $$PWD/qmljsastfwd_p.h \ + $$PWD/qmljsastvisitor_p.h \ + $$PWD/qmljsengine_p.h \ + $$PWD/qmljsgrammar_p.h \ + $$PWD/qmljslexer_p.h \ + $$PWD/qmljsmemorypool_p.h \ + $$PWD/qmljsparser_p.h \ + $$PWD/qmljsglobal_p.h \ + $$PWD/qmlerror.h \ + $$PWD/qmljskeywords_p.h \ + +SOURCES += \ + $$PWD/qmljsast.cpp \ + $$PWD/qmljsastvisitor.cpp \ + $$PWD/qmljsengine_p.cpp \ + $$PWD/qmljsgrammar.cpp \ + $$PWD/qmljslexer.cpp \ + $$PWD/qmljsparser.cpp \ + $$PWD/qmlerror.cpp \ diff --git a/src/lib/corelib/parser/qmlerror.cpp b/src/lib/corelib/parser/qmlerror.cpp new file mode 100644 index 00000000..d9fbdd70 --- /dev/null +++ b/src/lib/corelib/parser/qmlerror.cpp @@ -0,0 +1,297 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlerror.h" + +#include + +#include +#include +#include + +#include + +namespace QbsQmlJS { + +/*! + \class QmlError + \since 5.0 + \inmodule QtQml + \brief The QmlError class encapsulates a QML error. + + QmlError includes a textual description of the error, as well + as location information (the file, line, and column). The toString() + method creates a single-line, human-readable string containing all of + this information, for example: + \code + file:///home/user/test.qml:7:8: Invalid property assignment: double expected + \endcode + + You can use qDebug() or qWarning() to output errors to the console. This method + will attempt to open the file indicated by the error + and include additional contextual information. + \code + file:///home/user/test.qml:7:8: Invalid property assignment: double expected + y: "hello" + ^ + \endcode + + Note that the QtQuick 1 version is named QDeclarativeError + + \sa QQuickView::errors(), QmlComponent::errors() +*/ +class QmlErrorPrivate +{ +public: + QmlErrorPrivate(); + + QUrl url; + QString description; + int line; + int column; +}; + +QmlErrorPrivate::QmlErrorPrivate() +: line(-1), column(-1) +{ +} + +/*! + Creates an empty error object. +*/ +QmlError::QmlError() +: d(nullptr) +{ +} + +/*! + Creates a copy of \a other. +*/ +QmlError::QmlError(const QmlError &other) +: d(nullptr) +{ + *this = other; +} + +/*! + Assigns \a other to this error object. +*/ +QmlError &QmlError::operator=(const QmlError &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + if (!other.d) { + delete d; + d = nullptr; + } else { + if (!d) d = new QmlErrorPrivate; + d->url = other.d->url; + d->description = other.d->description; + d->line = other.d->line; + d->column = other.d->column; + } + return *this; +} + +/*! + \internal +*/ +QmlError::~QmlError() +{ + delete d; d = nullptr; +} + +/*! + Returns true if this error is valid, otherwise false. +*/ +bool QmlError::isValid() const +{ + return d != nullptr; +} + +/*! + Returns the url for the file that caused this error. +*/ +QUrl QmlError::url() const +{ + if (d) return d->url; + return {}; +} + +/*! + Sets the \a url for the file that caused this error. +*/ +void QmlError::setUrl(const QUrl &url) +{ + if (!d) d = new QmlErrorPrivate; + d->url = url; +} + +/*! + Returns the error description. +*/ +QString QmlError::description() const +{ + if (d) return d->description; + return {}; +} + +/*! + Sets the error \a description. +*/ +void QmlError::setDescription(const QString &description) +{ + if (!d) d = new QmlErrorPrivate; + d->description = description; +} + +/*! + Returns the error line number. +*/ +int QmlError::line() const +{ + if (d) return d->line; + return -1; +} + +/*! + Sets the error \a line number. +*/ +void QmlError::setLine(int line) +{ + if (!d) d = new QmlErrorPrivate; + d->line = line; +} + +/*! + Returns the error column number. +*/ +int QmlError::column() const +{ + if (d) return d->column; + return -1; +} + +/*! + Sets the error \a column number. +*/ +void QmlError::setColumn(int column) +{ + if (!d) d = new QmlErrorPrivate; + d->column = column; +} + +/*! + Returns the error as a human readable string. +*/ +QString QmlError::toString() const +{ + QString rv; + if (url().isEmpty()) { + rv = QStringLiteral(""); + } else if (line() != -1) { + rv = url().toString() + QLatin1Char(':') + QString::number(line()); + if (column() != -1) + rv += QLatin1Char(':') + QString::number(column()); + } else { + rv = url().toString(); + } + + rv += QLatin1String(": ") + description(); + + return rv; +} + +} // namespace QbsQmlJS + +QT_BEGIN_NAMESPACE + +using namespace QbsQmlJS; + +/*! + \relates QmlError + \fn QDebug operator<<(QDebug debug, const QmlError &error) + + Outputs a human readable version of \a error to \a debug. +*/ + +QDebug operator<<(QDebug debug, const QmlError &error) +{ + debug << qPrintable(error.toString()); + + QUrl url = error.url(); + + if (error.line() > 0 && url.scheme() == QLatin1String("file")) { + QString file = url.toLocalFile(); + QFile f(file); + if (f.open(QIODevice::ReadOnly)) { + QByteArray data = f.readAll(); + QTextStream stream(data, QIODevice::ReadOnly); + qbs::setupDefaultCodec(stream); + const QString code = stream.readAll(); + const QStringList lines = code.split(QLatin1Char('\n')); + + if (lines.size() >= error.line()) { + const QString &line = lines.at(error.line() - 1); + debug << "\n " << qPrintable(line); + + if (error.column() > 0) { + int column = std::max(0, error.column() - 1); + column = std::min(column, line.length()); + + QByteArray ind; + ind.reserve(column); + for (int i = 0; i < column; ++i) { + const QChar ch = line.at(i); + if (ch.isSpace()) + ind.append(ch.unicode()); + else + ind.append(' '); + } + ind.append('^'); + debug << "\n " << ind.constData(); + } + } + } + } + return debug; +} + +QT_END_NAMESPACE diff --git a/src/lib/corelib/parser/qmlerror.h b/src/lib/corelib/parser/qmlerror.h new file mode 100644 index 00000000..cfac506b --- /dev/null +++ b/src/lib/corelib/parser/qmlerror.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLERROR_H +#define QQMLERROR_H + + + +#include +#include + +QT_BEGIN_NAMESPACE +class QDebug; +QT_END_NAMESPACE + +namespace QbsQmlJS { + +class QmlErrorPrivate; +class QmlError +{ +public: + QmlError(); + QmlError(const QmlError &); + QmlError &operator=(const QmlError &); + ~QmlError(); + + bool isValid() const; + + QUrl url() const; + void setUrl(const QUrl &); + QString description() const; + void setDescription(const QString &); + int line() const; + void setLine(int); + int column() const; + void setColumn(int); + + QString toString() const; +private: + QmlErrorPrivate *d; +}; + +} // namespace QbsQmlJS + +QT_BEGIN_NAMESPACE +QDebug operator<<(QDebug debug, const QbsQmlJS::QmlError &error); +Q_DECLARE_TYPEINFO(QbsQmlJS::QmlError, Q_MOVABLE_TYPE); +QT_END_NAMESPACE + +#endif // QQMLERROR_H diff --git a/src/lib/corelib/parser/qmljs.g b/src/lib/corelib/parser/qmljs.g new file mode 100644 index 00000000..b9d533ad --- /dev/null +++ b/src/lib/corelib/parser/qmljs.g @@ -0,0 +1,3023 @@ +----------------------------------------------------------------------------- +-- +-- Copyright (C) 2016 The Qt Company Ltd. +-- Contact: https://www.qt.io/licensing/ +-- +-- This file is part of Qbs. +-- +-- $QT_BEGIN_LICENSE:LGPL$ +-- Commercial License Usage +-- Licensees holding valid commercial Qt licenses may use this file in +-- accordance with the commercial license agreement provided with the +-- Software or, alternatively, in accordance with the terms contained in +-- a written agreement between you and The Qt Company. For licensing terms +-- and conditions see https://www.qt.io/terms-conditions. For further +-- information use the contact form at https://www.qt.io/contact-us. +-- +-- GNU Lesser General Public License Usage +-- Alternatively, this file may be used under the terms of the GNU Lesser +-- General Public License version 3 as published by the Free Software +-- Foundation and appearing in the file LICENSE.LGPL3 included in the +-- packaging of this file. Please review the following information to +-- ensure the GNU Lesser General Public License version 3 requirements +-- will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +-- +-- GNU General Public License Usage +-- Alternatively, this file may be used under the terms of the GNU +-- General Public License version 2.0 or (at your option) the GNU General +-- Public license version 3 or any later version approved by the KDE Free +-- Qt Foundation. The licenses are as published by the Free Software +-- Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +-- included in the packaging of this file. Please review the following +-- information to ensure the GNU General Public License requirements will +-- be met: https://www.gnu.org/licenses/gpl-2.0.html and +-- https://www.gnu.org/licenses/gpl-3.0.html. +-- +-- $QT_END_LICENSE$ +-- +----------------------------------------------------------------------------- + +%parser QmlJSGrammar +%decl qmljsparser_p.h +%impl qdeclarativejsparser.cpp +%expect 2 +%expect-rr 2 + +%token T_AND "&" T_AND_AND "&&" T_AND_EQ "&=" +%token T_BREAK "break" T_CASE "case" T_CATCH "catch" +%token T_COLON ":" T_COMMA "," T_CONTINUE "continue" +%token T_DEFAULT "default" T_DELETE "delete" T_DIVIDE_ "/" +%token T_DIVIDE_EQ "/=" T_DO "do" T_DOT "." +%token T_ELSE "else" T_EQ "=" T_EQ_EQ "==" +%token T_EQ_EQ_EQ "===" T_FINALLY "finally" T_FOR "for" +%token T_FUNCTION "function" T_GE ">=" T_GT ">" +%token T_GT_GT ">>" T_GT_GT_EQ ">>=" T_GT_GT_GT ">>>" +%token T_GT_GT_GT_EQ ">>>=" T_IDENTIFIER "identifier" T_IF "if" +%token T_IN "in" T_INSTANCEOF "instanceof" T_LBRACE "{" +%token T_LBRACKET "[" T_LE "<=" T_LPAREN "(" +%token T_LT "<" T_LT_LT "<<" T_LT_LT_EQ "<<=" +%token T_MINUS "-" T_MINUS_EQ "-=" T_MINUS_MINUS "--" +%token T_NEW "new" T_NOT "!" T_NOT_EQ "!=" +%token T_NOT_EQ_EQ "!==" T_NUMERIC_LITERAL "numeric literal" T_OR "|" +%token T_OR_EQ "|=" T_OR_OR "||" T_PLUS "+" +%token T_PLUS_EQ "+=" T_PLUS_PLUS "++" T_QUESTION "?" +%token T_RBRACE "}" T_RBRACKET "]" T_REMAINDER "%" +%token T_REMAINDER_EQ "%=" T_RETURN "return" T_RPAREN ")" +%token T_SEMICOLON ";" T_AUTOMATIC_SEMICOLON T_STAR "*" +%token T_STAR_EQ "*=" T_STRING_LITERAL "string literal" +%token T_PROPERTY "property" T_SIGNAL "signal" T_READONLY "readonly" +%token T_SWITCH "switch" T_THIS "this" T_THROW "throw" +%token T_TILDE "~" T_TRY "try" T_TYPEOF "typeof" +%token T_VAR "var" T_VOID "void" T_WHILE "while" +%token T_WITH "with" T_XOR "^" T_XOR_EQ "^=" +%token T_NULL "null" T_TRUE "true" T_FALSE "false" +%token T_CONST "const" +%token T_DEBUGGER "debugger" +%token T_RESERVED_WORD "reserved word" +%token T_MULTILINE_STRING_LITERAL "multiline string literal" +%token T_COMMENT "comment" + +--- context keywords. +%token T_PUBLIC "public" +%token T_IMPORT "import" +%token T_AS "as" +%token T_ON "on" + +%token T_ERROR + +--- feed tokens +%token T_FEED_UI_PROGRAM +%token T_FEED_UI_OBJECT_MEMBER +%token T_FEED_JS_STATEMENT +%token T_FEED_JS_EXPRESSION +%token T_FEED_JS_SOURCE_ELEMENT +%token T_FEED_JS_PROGRAM + +%nonassoc SHIFT_THERE +%nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY T_READONLY +%nonassoc REDUCE_HERE + +%start TopLevel + +/./**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +#include "qmljsengine_p.h" +#include "qmljslexer_p.h" +#include "qmljsast_p.h" +#include "qmljsmemorypool_p.h" + +./ + +/:/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// This file is automatically generated from qmljs.g. +// Changes will be lost. +// + +#ifndef QMLJSPARSER_P_H +#define QMLJSPARSER_P_H + +#include "qmljsglobal_p.h" +#include "qmljsgrammar_p.h" +#include "qmljsast_p.h" +#include "qmljsengine_p.h" +#include + +#include +#include + +namespace QbsQmlJS { + +class Engine; + +class QBS_AUTOTEST_EXPORT Parser: protected $table +{ +public: + union Value { + int ival; + double dval; + AST::ArgumentList *ArgumentList; + AST::CaseBlock *CaseBlock; + AST::CaseClause *CaseClause; + AST::CaseClauses *CaseClauses; + AST::Catch *Catch; + AST::DefaultClause *DefaultClause; + AST::ElementList *ElementList; + AST::Elision *Elision; + AST::ExpressionNode *Expression; + AST::Finally *Finally; + AST::FormalParameterList *FormalParameterList; + AST::FunctionBody *FunctionBody; + AST::FunctionDeclaration *FunctionDeclaration; + AST::Node *Node; + AST::PropertyName *PropertyName; + AST::PropertyNameAndValueList *PropertyNameAndValueList; + AST::SourceElement *SourceElement; + AST::SourceElements *SourceElements; + AST::Statement *Statement; + AST::StatementList *StatementList; + AST::Block *Block; + AST::VariableDeclaration *VariableDeclaration; + AST::VariableDeclarationList *VariableDeclarationList; + + AST::UiProgram *UiProgram; + AST::UiImportList *UiImportList; + AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; + AST::UiPublicMember *UiPublicMember; + AST::UiObjectDefinition *UiObjectDefinition; + AST::UiObjectInitializer *UiObjectInitializer; + AST::UiObjectBinding *UiObjectBinding; + AST::UiScriptBinding *UiScriptBinding; + AST::UiArrayBinding *UiArrayBinding; + AST::UiObjectMember *UiObjectMember; + AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; + AST::UiQualifiedId *UiQualifiedId; + }; + +public: + Parser(Engine *engine); + ~Parser(); + + // parse a UI program + bool parse() { return parse(T_FEED_UI_PROGRAM); } + bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } + bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } + bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } + bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } + bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } + + AST::UiProgram *ast() const + { return AST::cast(program); } + + AST::Statement *statement() const + { + if (! program) + return nullptr; + + return program->statementCast(); + } + + AST::ExpressionNode *expression() const + { + if (! program) + return nullptr; + + return program->expressionCast(); + } + + AST::UiObjectMember *uiObjectMember() const + { + if (! program) + return nullptr; + + return program->uiObjectMemberCast(); + } + + AST::Node *rootNode() const + { return program; } + + QList diagnosticMessages() const + { return diagnostic_messages; } + + inline DiagnosticMessage diagnosticMessage() const + { + foreach (const DiagnosticMessage &d, diagnostic_messages) { + if (d.kind != DiagnosticMessage::Warning) + return d; + } + + return DiagnosticMessage(); + } + + inline QString errorMessage() const + { return diagnosticMessage().message; } + + inline int errorLineNumber() const + { return diagnosticMessage().loc.startLine; } + + inline int errorColumnNumber() const + { return diagnosticMessage().loc.startColumn; } + +protected: + bool parse(int startToken); + + void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline QStringRef &stringRef(int index) + { return string_stack [tos + index - 1]; } + + inline AST::SourceLocation &loc(int index) + { return location_stack [tos + index - 1]; } + + AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); + +protected: + Engine *driver; + MemoryPool *pool; + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + AST::SourceLocation *location_stack; + QStringRef *string_stack; + + AST::Node *program; + + // error recovery + enum { TOKEN_BUFFER_SIZE = 3 }; + + struct SavedToken { + int token = 0; + double dval = 0.0; + AST::SourceLocation loc; + QStringRef spell; + }; + + double yylval = 0.0; + QStringRef yytokenspell; + AST::SourceLocation yylloc; + AST::SourceLocation yyprevlloc; + + SavedToken token_buffer[TOKEN_BUFFER_SIZE]; + SavedToken *first_token; + SavedToken *last_token; + + QList diagnostic_messages; +}; + +} // end of namespace QbsQmlJS + + +:/ + + +/. + +#include "qmljsparser_p.h" +#include + +// +// This file is automatically generated from qmljs.g. +// Changes will be lost. +// + +using namespace QmlJS; + +QT_QML_BEGIN_NAMESPACE + +void Parser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + string_stack = reinterpret_cast (realloc(string_stack, stack_size * sizeof(QStringRef))); +} + +Parser::Parser(Engine *engine): + driver(engine), + pool(engine->pool()), + tos(0), + stack_size(0), + sym_stack(0), + state_stack(0), + location_stack(0), + string_stack(0), + first_token(0), + last_token(0) +{ +} + +Parser::~Parser() +{ + if (stack_size) { + free(sym_stack); + free(state_stack); + free(location_stack); + free(string_stack); + } +} + +static inline AST::SourceLocation location(Lexer *lexer) +{ + AST::SourceLocation loc; + loc.offset = lexer->tokenOffset(); + loc.length = lexer->tokenLength(); + loc.startLine = lexer->tokenStartLine(); + loc.startColumn = lexer->tokenStartColumn(); + return loc; +} + +AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) +{ + QVarLengthArray nameIds; + QVarLengthArray locations; + + AST::ExpressionNode *it = expr; + while (AST::FieldMemberExpression *m = AST::cast(it)) { + nameIds.append(m->name); + locations.append(m->identifierToken); + it = m->base; + } + + if (AST::IdentifierExpression *idExpr = AST::cast(it)) { + AST::UiQualifiedId *q = new (pool) AST::UiQualifiedId(idExpr->name); + q->identifierToken = idExpr->identifierToken; + + AST::UiQualifiedId *currentId = q; + for (int i = nameIds.size() - 1; i != -1; --i) { + currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); + currentId->identifierToken = locations[i]; + } + + return currentId->finish(); + } + + return nullptr; +} + +bool Parser::parse(int startToken) +{ + Lexer *lexer = driver->lexer(); + bool hadErrors = false; + int yytoken = -1; + int action = 0; + + token_buffer[0].token = startToken; + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + tos = -1; + program = 0; + + do { + if (++tos == stack_size) + reallocateStack(); + + state_stack[tos] = action; + + _Lcheck_token: + if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + + if (first_token == last_token) { + yytoken = lexer->lex(); + yylval = lexer->tokenValue(); + yytokenspell = lexer->tokenSpell(); + yylloc = location(lexer); + } else { + yytoken = first_token->token; + yylval = first_token->dval; + yytokenspell = first_token->spell; + yylloc = first_token->loc; + ++first_token; + } + } + + action = t_action(action, yytoken); + if (action > 0) { + if (action != ACCEPT_STATE) { + yytoken = -1; + sym(1).dval = yylval; + stringRef(1) = yytokenspell; + loc(1) = yylloc; + } else { + --tos; + return ! hadErrors; + } + } else if (action < 0) { + const int r = -action - 1; + tos -= rhs[r]; + + switch (r) { +./ + +-------------------------------------------------------------------------------------------------------- +-- Declarative UI +-------------------------------------------------------------------------------------------------------- + +TopLevel: T_FEED_UI_PROGRAM UiProgram ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_STATEMENT Statement ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_EXPRESSION Expression ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_SOURCE_ELEMENT SourceElement ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_UI_OBJECT_MEMBER UiObjectMember ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +TopLevel: T_FEED_JS_PROGRAM Program ; +/. +case $rule_number: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; +./ + +UiProgram: UiImportListOpt UiRootMember ; +/. +case $rule_number: { + sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, + sym(2).UiObjectMemberList->finish()); +} break; +./ + +UiImportListOpt: Empty ; +UiImportListOpt: UiImportList ; +/. +case $rule_number: { + sym(1).Node = sym(1).UiImportList->finish(); +} break; +./ + +UiImportList: UiImport ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); +} break; +./ + +UiImportList: UiImportList UiImport ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); +} break; +./ + +ImportId: MemberExpression ; + +UiImport: UiImportHead T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->semicolonToken = loc(2); +} break; +./ + +UiImport: UiImportHead T_NUMERIC_LITERAL T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_NUMERIC_LITERAL T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->semicolonToken = loc(3); +} break; +./ + +UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_NUMERIC_LITERAL T_AS JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->asToken = loc(3); + sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = stringRef(4); + sym(1).UiImport->semicolonToken = loc(5); +} break; +./ + +UiImport: UiImportHead T_AS JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiImport: UiImportHead T_AS JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + sym(1).UiImport->asToken = loc(2); + sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = stringRef(3); + sym(1).UiImport->semicolonToken = loc(4); +} break; +./ + + +UiImportHead: T_IMPORT ImportId ; +/. +case $rule_number: { + AST::UiImport *node = 0; + + if (AST::StringLiteral *importIdLiteral = AST::cast(sym(2).Expression)) { + node = new (pool) AST::UiImport(importIdLiteral->value); + node->fileNameToken = loc(2); + } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { + node = new (pool) AST::UiImport(qualifiedId); + node->fileNameToken = loc(2); + } + + sym(1).Node = node; + + if (node) { + node->importToken = loc(1); + } else { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id or a string literal"))); + + return false; // ### remove me + } +} break; +./ + +Empty: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +UiRootMember: UiObjectDefinition ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; +./ + +UiObjectMemberList: UiObjectMember ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; +./ + +UiObjectMemberList: UiObjectMemberList UiObjectMember ; +/. +case $rule_number: { + AST::UiObjectMemberList *node = new (pool) AST:: UiObjectMemberList( + sym(1).UiObjectMemberList, sym(2).UiObjectMember); + sym(1).Node = node; +} break; +./ + +UiArrayMemberList: UiObjectDefinition ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); +} break; +./ + +UiArrayMemberList: UiArrayMemberList T_COMMA UiObjectDefinition ; +/. +case $rule_number: { + AST::UiArrayMemberList *node = new (pool) AST::UiArrayMemberList( + sym(1).UiArrayMemberList, sym(3).UiObjectMember); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectInitializer: T_LBRACE T_RBRACE ; +/. +case $rule_number: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer((AST::UiObjectMemberList*)0); + node->lbraceToken = loc(1); + node->rbraceToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectInitializer: T_LBRACE UiObjectMemberList T_RBRACE ; +/. +case $rule_number: { + AST::UiObjectInitializer *node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiObjectDefinition: UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectDefinition *node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, + sym(2).UiObjectInitializer); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiObjectDefinition ; + +UiObjectMember: UiQualifiedId T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; +/. +case $rule_number: { + AST::UiArrayBinding *node = new (pool) AST::UiArrayBinding( + sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); + node->colonToken = loc(2); + node->lbracketToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiQualifiedId T_COLON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiObjectMember: UiQualifiedId T_ON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiObjectBinding *node = new (pool) AST::UiObjectBinding( + sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + node->hasOnToken = true; + sym(1).Node = node; +} break; +./ + +UiScriptStatement: Block ; +UiScriptStatement: EmptyStatement ; +UiScriptStatement: ExpressionStatement ; +UiScriptStatement: IfStatement ; +UiScriptStatement: WithStatement ; +UiScriptStatement: SwitchStatement ; +UiScriptStatement: TryStatement ; + +UiObjectMember: UiQualifiedId T_COLON UiScriptStatement ; +/. +case $rule_number: +{ + AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding( + sym(1).UiQualifiedId, sym(3).Statement); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiPropertyType: T_VAR ; +UiPropertyType: T_RESERVED_WORD ; +UiPropertyType: T_IDENTIFIER ; + +UiParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +UiParameterListOpt: UiParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; +./ + +UiParameterList: UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + node->propertyTypeToken = loc(1); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->parameters = sym(4).UiParameterList; + node->semicolonToken = loc(6); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), + sym(5).Statement); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); + propertyName->identifierToken = loc(6); + propertyName->next = 0; + + AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding( + propertyName, sym(9).UiArrayMemberList->finish()); + binding->colonToken = loc(7); + binding->lbracketToken = loc(8); + binding->rbracketToken = loc(10); + + node->binding = binding; + + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; +/. +case $rule_number: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); // insert a fake ';' before ':' + + AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); + propertyName->identifierToken = loc(3); + propertyName->next = 0; + + AST::UiObjectBinding *binding = new (pool) AST::UiObjectBinding( + propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); + binding->colonToken = loc(4); + + node->binding = binding; + + sym(1).Node = node; +} break; +./ + +UiObjectMember: FunctionDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; +./ + +UiObjectMember: VariableStatement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; +./ + +JsIdentifier: T_IDENTIFIER; + +JsIdentifier: T_PROPERTY ; +JsIdentifier: T_SIGNAL ; +JsIdentifier: T_READONLY ; +JsIdentifier: T_ON ; + +-------------------------------------------------------------------------------------------------------- +-- Expressions +-------------------------------------------------------------------------------------------------------- + +PrimaryExpression: T_THIS ; +/. +case $rule_number: { + AST::ThisExpression *node = new (pool) AST::ThisExpression(); + node->thisToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: JsIdentifier ; +/. +case $rule_number: { + AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_NULL ; +/. +case $rule_number: { + AST::NullExpression *node = new (pool) AST::NullExpression(); + node->nullToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_TRUE ; +/. +case $rule_number: { + AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); + node->trueToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_FALSE ; +/. +case $rule_number: { + AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); + node->falseToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_MULTILINE_STRING_LITERAL ; +/.case $rule_number:./ + +PrimaryExpression: T_STRING_LITERAL ; +/. +case $rule_number: { + AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_DIVIDE_ ; +/: +#define J_SCRIPT_REGEXPLITERAL_RULE1 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(Lexer::NoPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; // ### remove me + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_DIVIDE_EQ ; +/: +#define J_SCRIPT_REGEXPLITERAL_RULE2 $rule_number +:/ +/. +case $rule_number: { + bool rx = lexer->scanRegExp(Lexer::EqualPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + AST::RegExpLiteral *node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); + node->lbracketToken = loc(1); + node->rbracketToken = loc(2); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET Elision T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_COMMA T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + (AST::Elision *) 0); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACKET ElementList T_COMMA Elision T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + sym(4).Elision->finish()); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; +./ + +-- PrimaryExpression: T_LBRACE T_RBRACE ; +-- /. +-- case $rule_number: { +-- sym(1).Node = new (pool) AST::ObjectLiteral(); +-- } break; +-- ./ + +PrimaryExpression: T_LBRACE PropertyNameAndValueListOpt T_RBRACE ; +/. +case $rule_number: { + AST::ObjectLiteral *node = 0; + if (sym(2).Node) + node = new (pool) AST::ObjectLiteral( + sym(2).PropertyNameAndValueList->finish ()); + else + node = new (pool) AST::ObjectLiteral(); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LBRACE PropertyNameAndValueList T_COMMA T_RBRACE ; +/. +case $rule_number: { + AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( + sym(2).PropertyNameAndValueList->finish ()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(4); + sym(1).Node = node; +} break; +./ + +PrimaryExpression: T_LPAREN Expression T_RPAREN ; +/. +case $rule_number: { + AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); + node->lparenToken = loc(1); + node->rparenToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiQualifiedId: MemberExpression ; +/. +case $rule_number: { + if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, + QLatin1String("Ignored annotation"))); + + sym(1).Expression = mem->base; + } + + if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { + sym(1).UiQualifiedId = qualifiedId; + } else { + sym(1).UiQualifiedId = 0; + + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QLatin1String("Expected a qualified name id"))); + + return false; // ### recover + } +} break; +./ + +ElementList: AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); +} break; +./ + +ElementList: Elision AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); +} break; +./ + +ElementList: ElementList T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, + (AST::Elision *) 0, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ElementList: ElementList T_COMMA Elision AssignmentExpression ; +/. +case $rule_number: { + AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), + sym(4).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +Elision: T_COMMA ; +/. +case $rule_number: { + AST::Elision *node = new (pool) AST::Elision(); + node->commaToken = loc(1); + sym(1).Node = node; +} break; +./ + +Elision: Elision T_COMMA ; +/. +case $rule_number: { + AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +PropertyNameAndValueList: PropertyName T_COLON AssignmentExpression ; +/. +case $rule_number: { + AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( + sym(1).PropertyName, sym(3).Expression); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +PropertyNameAndValueList: PropertyNameAndValueList T_COMMA PropertyName T_COLON AssignmentExpression ; +/. +case $rule_number: { + AST::PropertyNameAndValueList *node = new (pool) AST::PropertyNameAndValueList( + sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); + node->commaToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +PropertyName: T_IDENTIFIER %prec SHIFT_THERE ; +/. +case $rule_number: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: T_SIGNAL ; +/.case $rule_number:./ + +PropertyName: T_PROPERTY ; +/. +case $rule_number: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: T_STRING_LITERAL ; +/. +case $rule_number: { + AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: T_NUMERIC_LITERAL ; +/. +case $rule_number: { + AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +PropertyName: ReservedIdentifier ; +/. +case $rule_number: { + AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +./ + +ReservedIdentifier: T_BREAK ; +ReservedIdentifier: T_CASE ; +ReservedIdentifier: T_CATCH ; +ReservedIdentifier: T_CONTINUE ; +ReservedIdentifier: T_DEFAULT ; +ReservedIdentifier: T_DELETE ; +ReservedIdentifier: T_DO ; +ReservedIdentifier: T_ELSE ; +ReservedIdentifier: T_FALSE ; +ReservedIdentifier: T_FINALLY ; +ReservedIdentifier: T_FOR ; +ReservedIdentifier: T_FUNCTION ; +ReservedIdentifier: T_IF ; +ReservedIdentifier: T_IN ; +ReservedIdentifier: T_INSTANCEOF ; +ReservedIdentifier: T_NEW ; +ReservedIdentifier: T_NULL ; +ReservedIdentifier: T_RETURN ; +ReservedIdentifier: T_SWITCH ; +ReservedIdentifier: T_THIS ; +ReservedIdentifier: T_THROW ; +ReservedIdentifier: T_TRUE ; +ReservedIdentifier: T_TRY ; +ReservedIdentifier: T_TYPEOF ; +ReservedIdentifier: T_VAR ; +ReservedIdentifier: T_VOID ; +ReservedIdentifier: T_WHILE ; +ReservedIdentifier: T_CONST ; +ReservedIdentifier: T_DEBUGGER ; +ReservedIdentifier: T_RESERVED_WORD ; +ReservedIdentifier: T_WITH ; + +PropertyIdentifier: JsIdentifier ; +PropertyIdentifier: ReservedIdentifier ; + +MemberExpression: PrimaryExpression ; +MemberExpression: FunctionExpression ; + +MemberExpression: MemberExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +MemberExpression: MemberExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +MemberExpression: T_NEW MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); + node->newToken = loc(1); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + sym(1).Node = node; +} break; +./ + +NewExpression: MemberExpression ; + +NewExpression: T_NEW NewExpression ; +/. +case $rule_number: { + AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); + node->newToken = loc(1); + sym(1).Node = node; +} break; +./ + +CallExpression: MemberExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_LPAREN ArgumentListOpt T_RPAREN ; +/. +case $rule_number: { + AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_LBRACKET Expression T_RBRACKET ; +/. +case $rule_number: { + AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; +./ + +CallExpression: CallExpression T_DOT PropertyIdentifier ; +/. +case $rule_number: { + AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +ArgumentListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ArgumentListOpt: ArgumentList ; +/. +case $rule_number: { + sym(1).Node = sym(1).ArgumentList->finish(); +} break; +./ + +ArgumentList: AssignmentExpression ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); +} break; +./ + +ArgumentList: ArgumentList T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +LeftHandSideExpression: NewExpression ; +LeftHandSideExpression: CallExpression ; +PostfixExpression: LeftHandSideExpression ; + +PostfixExpression: LeftHandSideExpression T_PLUS_PLUS ; +/. +case $rule_number: { + AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); + node->incrementToken = loc(2); + sym(1).Node = node; +} break; +./ + +PostfixExpression: LeftHandSideExpression T_MINUS_MINUS ; +/. +case $rule_number: { + AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); + node->decrementToken = loc(2); + sym(1).Node = node; +} break; +./ + +UnaryExpression: PostfixExpression ; + +UnaryExpression: T_DELETE UnaryExpression ; +/. +case $rule_number: { + AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); + node->deleteToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_VOID UnaryExpression ; +/. +case $rule_number: { + AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); + node->voidToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_TYPEOF UnaryExpression ; +/. +case $rule_number: { + AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); + node->typeofToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_PLUS_PLUS UnaryExpression ; +/. +case $rule_number: { + AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); + node->incrementToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_MINUS_MINUS UnaryExpression ; +/. +case $rule_number: { + AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); + node->decrementToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_PLUS UnaryExpression ; +/. +case $rule_number: { + AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); + node->plusToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_MINUS UnaryExpression ; +/. +case $rule_number: { + AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); + node->minusToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_TILDE UnaryExpression ; +/. +case $rule_number: { + AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); + node->tildeToken = loc(1); + sym(1).Node = node; +} break; +./ + +UnaryExpression: T_NOT UnaryExpression ; +/. +case $rule_number: { + AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); + node->notToken = loc(1); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: UnaryExpression ; + +MultiplicativeExpression: MultiplicativeExpression T_STAR UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mul, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_DIVIDE_ UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Div, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +MultiplicativeExpression: MultiplicativeExpression T_REMAINDER UnaryExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mod, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AdditiveExpression: MultiplicativeExpression ; + +AdditiveExpression: AdditiveExpression T_PLUS MultiplicativeExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Add, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AdditiveExpression: AdditiveExpression T_MINUS MultiplicativeExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Sub, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: AdditiveExpression ; + +ShiftExpression: ShiftExpression T_LT_LT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::LShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::RShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ShiftExpression: ShiftExpression T_GT_GT_GT AdditiveExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::URShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: ShiftExpression ; + +RelationalExpression: RelationalExpression T_LT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_GT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_LE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_GE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpression: RelationalExpression T_IN ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::In, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: ShiftExpression ; + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GT ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_LE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_GE ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +RelationalExpressionNotIn: RelationalExpressionNotIn T_INSTANCEOF ShiftExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: RelationalExpression ; + +EqualityExpression: EqualityExpression T_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_EQ_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpression: EqualityExpression T_NOT_EQ_EQ RelationalExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: RelationalExpressionNotIn ; + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ RelationalExpressionNotIn; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_EQ_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +EqualityExpressionNotIn: EqualityExpressionNotIn T_NOT_EQ_EQ RelationalExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseANDExpression: EqualityExpression ; + +BitwiseANDExpression: BitwiseANDExpression T_AND EqualityExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseANDExpressionNotIn: EqualityExpressionNotIn ; + +BitwiseANDExpressionNotIn: BitwiseANDExpressionNotIn T_AND EqualityExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseXORExpression: BitwiseANDExpression ; + +BitwiseXORExpression: BitwiseXORExpression T_XOR BitwiseANDExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseXORExpressionNotIn: BitwiseANDExpressionNotIn ; + +BitwiseXORExpressionNotIn: BitwiseXORExpressionNotIn T_XOR BitwiseANDExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseORExpression: BitwiseXORExpression ; + +BitwiseORExpression: BitwiseORExpression T_OR BitwiseXORExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +BitwiseORExpressionNotIn: BitwiseXORExpressionNotIn ; + +BitwiseORExpressionNotIn: BitwiseORExpressionNotIn T_OR BitwiseXORExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalANDExpression: BitwiseORExpression ; + +LogicalANDExpression: LogicalANDExpression T_AND_AND BitwiseORExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalANDExpressionNotIn: BitwiseORExpressionNotIn ; + +LogicalANDExpressionNotIn: LogicalANDExpressionNotIn T_AND_AND BitwiseORExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalORExpression: LogicalANDExpression ; + +LogicalORExpression: LogicalORExpression T_OR_OR LogicalANDExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +LogicalORExpressionNotIn: LogicalANDExpressionNotIn ; + +LogicalORExpressionNotIn: LogicalORExpressionNotIn T_OR_OR LogicalANDExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +ConditionalExpression: LogicalORExpression ; + +ConditionalExpression: LogicalORExpression T_QUESTION AssignmentExpression T_COLON AssignmentExpression ; +/. +case $rule_number: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +ConditionalExpressionNotIn: LogicalORExpressionNotIn ; + +ConditionalExpressionNotIn: LogicalORExpressionNotIn T_QUESTION AssignmentExpressionNotIn T_COLON AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; +./ + +AssignmentExpression: ConditionalExpression ; + +AssignmentExpression: LeftHandSideExpression AssignmentOperator AssignmentExpression ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AssignmentExpressionNotIn: ConditionalExpressionNotIn ; + +AssignmentExpressionNotIn: LeftHandSideExpression AssignmentOperator AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; +./ + +AssignmentOperator: T_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::Assign; +} break; +./ + +AssignmentOperator: T_STAR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceMul; +} break; +./ + +AssignmentOperator: T_DIVIDE_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceDiv; +} break; +./ + +AssignmentOperator: T_REMAINDER_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceMod; +} break; +./ + +AssignmentOperator: T_PLUS_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceAdd; +} break; +./ + +AssignmentOperator: T_MINUS_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceSub; +} break; +./ + +AssignmentOperator: T_LT_LT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceLeftShift; +} break; +./ + +AssignmentOperator: T_GT_GT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceRightShift; +} break; +./ + +AssignmentOperator: T_GT_GT_GT_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceURightShift; +} break; +./ + +AssignmentOperator: T_AND_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceAnd; +} break; +./ + +AssignmentOperator: T_XOR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceXor; +} break; +./ + +AssignmentOperator: T_OR_EQ ; +/. +case $rule_number: { + sym(1).ival = QSOperator::InplaceOr; +} break; +./ + +Expression: AssignmentExpression ; + +Expression: Expression T_COMMA AssignmentExpression ; +/. +case $rule_number: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ExpressionOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ExpressionOpt: Expression ; + +ExpressionNotIn: AssignmentExpressionNotIn ; + +ExpressionNotIn: ExpressionNotIn T_COMMA AssignmentExpressionNotIn ; +/. +case $rule_number: { + AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +ExpressionNotInOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +ExpressionNotInOpt: ExpressionNotIn ; + +Statement: Block ; +Statement: VariableStatement ; +Statement: EmptyStatement ; +Statement: ExpressionStatement ; +Statement: IfStatement ; +Statement: IterationStatement ; +Statement: ContinueStatement ; +Statement: BreakStatement ; +Statement: ReturnStatement ; +Statement: WithStatement ; +Statement: LabelledStatement ; +Statement: SwitchStatement ; +Statement: ThrowStatement ; +Statement: TryStatement ; +Statement: DebuggerStatement ; + + +Block: T_LBRACE StatementListOpt T_RBRACE ; +/. +case $rule_number: { + AST::Block *node = new (pool) AST::Block(sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +StatementList: Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); +} break; +./ + +StatementList: StatementList Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); +} break; +./ + +StatementListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +StatementListOpt: StatementList ; +/. +case $rule_number: { + sym(1).Node = sym(1).StatementList->finish (); +} break; +./ + +VariableStatement: VariableDeclarationKind VariableDeclarationList T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +VariableStatement: VariableDeclarationKind VariableDeclarationList T_SEMICOLON ; +/. +case $rule_number: { + AST::VariableStatement *node = new (pool) AST::VariableStatement( + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + node->declarationKindToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +VariableDeclarationKind: T_CONST ; +/. +case $rule_number: { + sym(1).ival = T_CONST; +} break; +./ + +VariableDeclarationKind: T_VAR ; +/. +case $rule_number: { + sym(1).ival = T_VAR; +} break; +./ + +VariableDeclarationList: VariableDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; +./ + +VariableDeclarationList: VariableDeclarationList T_COMMA VariableDeclaration ; +/. +case $rule_number: { + AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; +./ + +VariableDeclarationListNotIn: VariableDeclarationListNotIn T_COMMA VariableDeclarationNotIn ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); +} break; +./ + +VariableDeclaration: JsIdentifier InitialiserOpt ; +/. +case $rule_number: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +VariableDeclarationNotIn: JsIdentifier InitialiserNotInOpt ; +/. +case $rule_number: { + AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +Initialiser: T_EQ AssignmentExpression ; +/. +case $rule_number: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; +./ + +InitialiserOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserOpt: Initialiser ; + +InitialiserNotIn: T_EQ AssignmentExpressionNotIn ; +/. +case $rule_number: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; +./ + +InitialiserNotInOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +InitialiserNotInOpt: InitialiserNotIn ; + +EmptyStatement: T_SEMICOLON ; +/. +case $rule_number: { + AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); + node->semicolonToken = loc(1); + sym(1).Node = node; +} break; +./ + +ExpressionStatement: Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ExpressionStatement: Expression T_SEMICOLON ; +/. +case $rule_number: { + AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement T_ELSE Statement ; +/. +case $rule_number: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(6); + sym(1).Node = node; +} break; +./ + +IfStatement: T_IF T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + + +IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +IterationStatement: T_DO Statement T_WHILE T_LPAREN Expression T_RPAREN T_SEMICOLON ; +/. +case $rule_number: { + AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_WHILE T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN ExpressionNotInOpt T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationListNotIn T_SEMICOLON ExpressionOpt T_SEMICOLON ExpressionOpt T_RPAREN Statement ; +/. +case $rule_number: { + AST::LocalForStatement *node = new (pool) AST::LocalForStatement( + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN LeftHandSideExpression T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; +} break; +./ + +IterationStatement: T_FOR T_LPAREN T_VAR VariableDeclarationNotIn T_IN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; +} break; +./ + +ContinueStatement: T_CONTINUE T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE T_SEMICOLON ; +/. +case $rule_number: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +ContinueStatement: T_CONTINUE JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ContinueStatement: T_CONTINUE JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +BreakStatement: T_BREAK T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK T_SEMICOLON ; +/. +case $rule_number: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +BreakStatement: T_BREAK JsIdentifier T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +BreakStatement: T_BREAK JsIdentifier T_SEMICOLON ; +/. +case $rule_number: { + AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +ReturnStatement: T_RETURN ExpressionOpt T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ReturnStatement: T_RETURN ExpressionOpt T_SEMICOLON ; +/. +case $rule_number: { + AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +WithStatement: T_WITH T_LPAREN Expression T_RPAREN Statement ; +/. +case $rule_number: { + AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +SwitchStatement: T_SWITCH T_LPAREN Expression T_RPAREN CaseBlock ; +/. +case $rule_number: { + AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; +./ + +CaseBlock: T_LBRACE CaseClausesOpt DefaultClause CaseClausesOpt T_RBRACE ; +/. +case $rule_number: { + AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; +} break; +./ + +CaseClauses: CaseClause ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); +} break; +./ + +CaseClauses: CaseClauses CaseClause ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); +} break; +./ + +CaseClausesOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +CaseClausesOpt: CaseClauses ; +/. +case $rule_number: { + sym(1).Node = sym(1).CaseClauses->finish (); +} break; +./ + +CaseClause: T_CASE Expression T_COLON StatementListOpt ; +/. +case $rule_number: { + AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; +} break; +./ + +DefaultClause: T_DEFAULT T_COLON StatementListOpt ; +/. +case $rule_number: { + AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +LabelledStatement: T_SIGNAL T_COLON Statement ; +/.case $rule_number:./ + +LabelledStatement: T_PROPERTY T_COLON Statement ; +/. +case $rule_number: { + AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +LabelledStatement: T_IDENTIFIER T_COLON Statement ; +/. +case $rule_number: { + AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +./ + +ThrowStatement: T_THROW Expression T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +ThrowStatement: T_THROW Expression T_SEMICOLON ; +/. +case $rule_number: { + AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Catch ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Finally ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +TryStatement: T_TRY Block Catch Finally ; +/. +case $rule_number: { + AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; +./ + +Catch: T_CATCH T_LPAREN JsIdentifier T_RPAREN Block ; +/. +case $rule_number: { + AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; +./ + +Finally: T_FINALLY Block ; +/. +case $rule_number: { + AST::Finally *node = new (pool) AST::Finally(sym(2).Block); + node->finallyToken = loc(1); + sym(1).Node = node; +} break; +./ + +DebuggerStatement: T_DEBUGGER T_AUTOMATIC_SEMICOLON ; -- automatic semicolon +DebuggerStatement: T_DEBUGGER T_SEMICOLON ; +/. +case $rule_number: { + AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; +./ + +FunctionDeclaration: T_FUNCTION JsIdentifier T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; +./ + +FunctionExpression: T_FUNCTION IdentifierOpt T_LPAREN FormalParameterListOpt T_RPAREN T_LBRACE FunctionBodyOpt T_RBRACE ; +/. +case $rule_number: { + AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + if (! stringRef(2).isNull()) + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; +./ + +FormalParameterList: JsIdentifier ; +/. +case $rule_number: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +FormalParameterList: FormalParameterList T_COMMA JsIdentifier ; +/. +case $rule_number: { + AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); + node->commaToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ + +FormalParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FormalParameterListOpt: FormalParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).FormalParameterList->finish (); +} break; +./ + +FunctionBodyOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +FunctionBodyOpt: FunctionBody ; + +FunctionBody: SourceElements ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); +} break; +./ + +Program: Empty ; + +Program: SourceElements ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); +} break; +./ + +SourceElements: SourceElement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); +} break; +./ + +SourceElements: SourceElements SourceElement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); +} break; +./ + +SourceElement: Statement ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); +} break; +./ + +SourceElement: FunctionDeclaration ; +/. +case $rule_number: { + sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); +} break; +./ + +IdentifierOpt: ; +/. +case $rule_number: { + stringRef(1) = QStringRef(); +} break; +./ + +IdentifierOpt: JsIdentifier ; + +PropertyNameAndValueListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +PropertyNameAndValueListOpt: PropertyNameAndValueList ; + +/. + } // switch + action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); + } // if + } while (action != 0); + + if (first_token == last_token) { + const int errorState = state_stack[tos]; + + // automatic insertion of `;' + if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { + SavedToken &tk = token_buffer[0]; + tk.token = yytoken; + tk.dval = yylval; + tk.spell = yytokenspell; + tk.loc = yylloc; + + yylloc = yyprevlloc; + yylloc.offset += yylloc.length; + yylloc.startColumn += yylloc.length; + yylloc.length = 0; + + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); + //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); + + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + yytoken = T_SEMICOLON; + yylval = 0; + + action = errorState; + + goto _Lcheck_token; + } + + hadErrors = true; + + token_buffer[0].token = yytoken; + token_buffer[0].dval = yylval; + token_buffer[0].spell = yytokenspell; + token_buffer[0].loc = yylloc; + + token_buffer[1].token = yytoken = lexer->lex(); + token_buffer[1].dval = yylval = lexer->tokenValue(); + token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); + token_buffer[1].loc = yylloc = location(lexer); + + if (t_action(errorState, yytoken)) { + QString msg; + int token = token_buffer[0].token; + if (token < 0 || token >= TERMINAL_COUNT) + msg = qApp->translate("QmlParser", "Syntax error"); + else + msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + action = errorState; + goto _Lcheck_token; + } + + static int tokens[] = { + T_PLUS, + T_EQ, + + T_COMMA, + T_COLON, + T_SEMICOLON, + + T_RPAREN, T_RBRACKET, T_RBRACE, + + T_NUMERIC_LITERAL, + T_IDENTIFIER, + + T_LPAREN, T_LBRACKET, T_LBRACE, + + EOF_SYMBOL + }; + + for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { + int a = t_action(errorState, *tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = *tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + first_token = &token_buffer[0]; + last_token = &token_buffer[2]; + + action = errorState; + goto _Lcheck_token; + } + } + + for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { + if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || + tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || + tk == T_FEED_JS_SOURCE_ELEMENT) + continue; + + int a = t_action(errorState, tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + action = errorState; + goto _Lcheck_token; + } + } + + const QString msg = qApp->translate("QmlParser", "Syntax error"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + } + + return false; +} + +QT_QML_END_NAMESPACE + + +./ +/: +#endif // QMLJSPARSER_P_H +:/ diff --git a/src/lib/corelib/parser/qmljsast.cpp b/src/lib/corelib/parser/qmljsast.cpp new file mode 100644 index 00000000..8c87f80b --- /dev/null +++ b/src/lib/corelib/parser/qmljsast.cpp @@ -0,0 +1,925 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmljsast_p.h" + +#include "qmljsastvisitor_p.h" + +namespace QbsQmlJS { +namespace AST { + +void Node::accept(Visitor *visitor) +{ + if (visitor->preVisit(this)) { + accept0(visitor); + } + visitor->postVisit(this); +} + +void Node::accept(Node *node, Visitor *visitor) +{ + if (node) + node->accept(visitor); +} + +ExpressionNode *Node::expressionCast() +{ + return nullptr; +} + +BinaryExpression *Node::binaryExpressionCast() +{ + return nullptr; +} + +Statement *Node::statementCast() +{ + return nullptr; +} + +UiObjectMember *Node::uiObjectMemberCast() +{ + return nullptr; +} + +ExpressionNode *ExpressionNode::expressionCast() +{ + return this; +} + +BinaryExpression *BinaryExpression::binaryExpressionCast() +{ + return this; +} + +Statement *Statement::statementCast() +{ + return this; +} + +UiObjectMember *UiObjectMember::uiObjectMemberCast() +{ + return this; +} + +void NestedExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + visitor->endVisit(this); +} + +void ThisExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void IdentifierExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NullExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void TrueLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void FalseLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void StringLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NumericLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void RegExpLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ArrayLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + accept(elision, visitor); + } + + visitor->endVisit(this); +} + +void ObjectLiteral::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(properties, visitor); + } + + visitor->endVisit(this); +} + +void ElementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ElementList *it = this; it; it = it->next) { + accept(it->elision, visitor); + accept(it->expression, visitor); + } + } + + visitor->endVisit(this); +} + +void Elision::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + // ### + } + + visitor->endVisit(this); +} + +void PropertyNameAndValueList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (PropertyNameAndValueList *it = this; it; it = it->next) { + accept(it->name, visitor); + accept(it->value, visitor); + } + } + + visitor->endVisit(this); +} + +void IdentifierPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void StringLiteralPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void NumericLiteralPropertyName::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ArrayMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void FieldMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void NewMemberExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(arguments, visitor); + } + + visitor->endVisit(this); +} + +void NewExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void CallExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + accept(arguments, visitor); + } + + visitor->endVisit(this); +} + +void ArgumentList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (ArgumentList *it = this; it; it = it->next) { + accept(it->expression, visitor); + } + } + + visitor->endVisit(this); +} + +void PostIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void PostDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(base, visitor); + } + + visitor->endVisit(this); +} + +void DeleteExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void VoidExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TypeOfExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreIncrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void PreDecrementExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryPlusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void UnaryMinusExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TildeExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void NotExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void BinaryExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(left, visitor); + accept(right, visitor); + } + + visitor->endVisit(this); +} + +void ConditionalExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); + } + + visitor->endVisit(this); +} + +void Expression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(left, visitor); + accept(right, visitor); + } + + visitor->endVisit(this); +} + +void Block::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void StatementList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (StatementList *it = this; it; it = it->next) { + accept(it->statement, visitor); + } + } + + visitor->endVisit(this); +} + +void VariableStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declarations, visitor); + } + + visitor->endVisit(this); +} + +void VariableDeclarationList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (VariableDeclarationList *it = this; it; it = it->next) { + accept(it->declaration, visitor); + } + } + + visitor->endVisit(this); +} + +void VariableDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void EmptyStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ExpressionStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void IfStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(ok, visitor); + accept(ko, visitor); + } + + visitor->endVisit(this); +} + +void DoWhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void WhileStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(initialiser, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declarations, visitor); + accept(condition, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(initialiser, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void LocalForEachStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declaration, visitor); + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ContinueStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void BreakStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void ReturnStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void WithStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void SwitchStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(block, visitor); + } + + visitor->endVisit(this); +} + +void CaseBlock::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(clauses, visitor); + accept(defaultClause, visitor); + accept(moreClauses, visitor); + } + + visitor->endVisit(this); +} + +void CaseClauses::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (CaseClauses *it = this; it; it = it->next) { + accept(it->clause, visitor); + } + } + + visitor->endVisit(this); +} + +void CaseClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void DefaultClause::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statements, visitor); + } + + visitor->endVisit(this); +} + +void LabelledStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void ThrowStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(expression, visitor); + } + + visitor->endVisit(this); +} + +void TryStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(catchExpression, visitor); + accept(finallyExpression, visitor); + } + + visitor->endVisit(this); +} + +void Catch::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void Finally::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void FunctionDeclaration::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(formals, visitor); + accept(body, visitor); + } + + visitor->endVisit(this); +} + +void FunctionExpression::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(formals, visitor); + accept(body, visitor); + } + + visitor->endVisit(this); +} + +void FormalParameterList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + // ### + } + + visitor->endVisit(this); +} + +void FunctionBody::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + } + + visitor->endVisit(this); +} + +void Program::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(elements, visitor); + } + + visitor->endVisit(this); +} + +void SourceElements::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (SourceElements *it = this; it; it = it->next) { + accept(it->element, visitor); + } + } + + visitor->endVisit(this); +} + +void FunctionSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(declaration, visitor); + } + + visitor->endVisit(this); +} + +void StatementSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void DebuggerStatement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void UiProgram::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(imports, visitor); + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiPublicMember::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(statement, visitor); + accept(binding, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectDefinition::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectInitializer::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(qualifiedTypeNameId, visitor); + accept(initializer, visitor); + } + + visitor->endVisit(this); +} + +void UiScriptBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(statement, visitor); + } + + visitor->endVisit(this); +} + +void UiArrayBinding::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(qualifiedId, visitor); + accept(members, visitor); + } + + visitor->endVisit(this); +} + +void UiObjectMemberList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (UiObjectMemberList *it = this; it; it = it->next) + accept(it->member, visitor); + } + + visitor->endVisit(this); +} + +void UiArrayMemberList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + for (UiArrayMemberList *it = this; it; it = it->next) + accept(it->member, visitor); + } + + visitor->endVisit(this); +} + +void UiQualifiedId::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + } + + visitor->endVisit(this); +} + +void UiImport::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(importUri, visitor); + } + + visitor->endVisit(this); +} + +void UiImportList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(import, visitor); + accept(next, visitor); + } + + visitor->endVisit(this); +} + +void UiSourceElement::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(sourceElement, visitor); + } + + visitor->endVisit(this); +} + +} // namespace AST +} // namespace QbsQmlJS diff --git a/src/lib/corelib/parser/qmljsast_p.h b/src/lib/corelib/parser/qmljsast_p.h new file mode 100644 index 00000000..e2ba6850 --- /dev/null +++ b/src/lib/corelib/parser/qmljsast_p.h @@ -0,0 +1,2637 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSAST_P_H +#define QMLJSAST_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmljsastvisitor_p.h" +#include "qmljsglobal_p.h" +#include "qmljsmemorypool_p.h" + +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + +namespace QbsQmlJS { + +#define QMLJS_DECLARE_AST_NODE(name) \ + enum { K = Kind_##name }; + +namespace QSOperator // ### rename +{ + +enum Op { + Add, + And, + InplaceAnd, + Assign, + BitAnd, + BitOr, + BitXor, + InplaceSub, + Div, + InplaceDiv, + Equal, + Ge, + Gt, + In, + InplaceAdd, + InstanceOf, + Le, + LShift, + InplaceLeftShift, + Lt, + Mod, + InplaceMod, + Mul, + InplaceMul, + NotEqual, + Or, + InplaceOr, + RShift, + InplaceRightShift, + StrictEqual, + StrictNotEqual, + Sub, + URShift, + InplaceURightShift, + InplaceXor +}; + +} // namespace QSOperator + +namespace AST { + +template +_T1 cast(_T2 *ast) +{ + if (ast && ast->kind == static_cast<_T1>(nullptr)->K) + return static_cast<_T1>(ast); + + return nullptr; +} + +class QML_PARSER_EXPORT Node: public Managed +{ +public: + enum Kind { + Kind_Undefined, + + Kind_ArgumentList, + Kind_ArrayLiteral, + Kind_ArrayMemberExpression, + Kind_BinaryExpression, + Kind_Block, + Kind_BreakStatement, + Kind_CallExpression, + Kind_CaseBlock, + Kind_CaseClause, + Kind_CaseClauses, + Kind_Catch, + Kind_ConditionalExpression, + Kind_ContinueStatement, + Kind_DebuggerStatement, + Kind_DefaultClause, + Kind_DeleteExpression, + Kind_DoWhileStatement, + Kind_ElementList, + Kind_Elision, + Kind_EmptyStatement, + Kind_Expression, + Kind_ExpressionStatement, + Kind_FalseLiteral, + Kind_FieldMemberExpression, + Kind_Finally, + Kind_ForEachStatement, + Kind_ForStatement, + Kind_FormalParameterList, + Kind_FunctionBody, + Kind_FunctionDeclaration, + Kind_FunctionExpression, + Kind_FunctionSourceElement, + Kind_IdentifierExpression, + Kind_IdentifierPropertyName, + Kind_IfStatement, + Kind_LabelledStatement, + Kind_LocalForEachStatement, + Kind_LocalForStatement, + Kind_NewExpression, + Kind_NewMemberExpression, + Kind_NotExpression, + Kind_NullExpression, + Kind_NumericLiteral, + Kind_NumericLiteralPropertyName, + Kind_ObjectLiteral, + Kind_PostDecrementExpression, + Kind_PostIncrementExpression, + Kind_PreDecrementExpression, + Kind_PreIncrementExpression, + Kind_Program, + Kind_PropertyName, + Kind_PropertyNameAndValueList, + Kind_RegExpLiteral, + Kind_ReturnStatement, + Kind_SourceElement, + Kind_SourceElements, + Kind_StatementList, + Kind_StatementSourceElement, + Kind_StringLiteral, + Kind_StringLiteralPropertyName, + Kind_SwitchStatement, + Kind_ThisExpression, + Kind_ThrowStatement, + Kind_TildeExpression, + Kind_TrueLiteral, + Kind_TryStatement, + Kind_TypeOfExpression, + Kind_UnaryMinusExpression, + Kind_UnaryPlusExpression, + Kind_VariableDeclaration, + Kind_VariableDeclarationList, + Kind_VariableStatement, + Kind_VoidExpression, + Kind_WhileStatement, + Kind_WithStatement, + Kind_NestedExpression, + + Kind_UiArrayBinding, + Kind_UiImport, + Kind_UiImportList, + Kind_UiObjectBinding, + Kind_UiObjectDefinition, + Kind_UiObjectInitializer, + Kind_UiObjectMemberList, + Kind_UiArrayMemberList, + Kind_UiProgram, + Kind_UiParameterList, + Kind_UiPublicMember, + Kind_UiQualifiedId, + Kind_UiScriptBinding, + Kind_UiSourceElement + }; + + inline Node() + : kind(Kind_Undefined) {} + + // NOTE: node destructors are never called, + // instead we block free the memory + // (see the NodePool class) + virtual ~Node() = default; + + virtual ExpressionNode *expressionCast(); + virtual BinaryExpression *binaryExpressionCast(); + virtual Statement *statementCast(); + virtual UiObjectMember *uiObjectMemberCast(); + + void accept(Visitor *visitor); + static void accept(Node *node, Visitor *visitor); + + inline static void acceptChild(Node *node, Visitor *visitor) + { return accept(node, visitor); } // ### remove + + virtual void accept0(Visitor *visitor) = 0; + virtual SourceLocation firstSourceLocation() const = 0; + virtual SourceLocation lastSourceLocation() const = 0; + +// attributes + int kind; +}; + +class QML_PARSER_EXPORT ExpressionNode: public Node +{ +public: + ExpressionNode() = default; + + ExpressionNode *expressionCast() override; +}; + +class QML_PARSER_EXPORT Statement: public Node +{ +public: + Statement() = default; + + Statement *statementCast() override; +}; + +class QML_PARSER_EXPORT NestedExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NestedExpression) + + NestedExpression(ExpressionNode *expression) + : expression(expression) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lparenToken; } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + +// attributes + ExpressionNode *expression; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ThisExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(ThisExpression) + + ThisExpression() { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return thisToken; } + + SourceLocation lastSourceLocation() const override + { return thisToken; } + +// attributes + SourceLocation thisToken; +}; + +class QML_PARSER_EXPORT IdentifierExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(IdentifierExpression) + + IdentifierExpression(const QStringRef &n): + name (n) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return identifierToken; } + +// attributes + QStringRef name; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT NullExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NullExpression) + + NullExpression() { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return nullToken; } + + SourceLocation lastSourceLocation() const override + { return nullToken; } + +// attributes + SourceLocation nullToken; +}; + +class QML_PARSER_EXPORT TrueLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(TrueLiteral) + + TrueLiteral() { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return trueToken; } + + SourceLocation lastSourceLocation() const override + { return trueToken; } + +// attributes + SourceLocation trueToken; +}; + +class QML_PARSER_EXPORT FalseLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(FalseLiteral) + + FalseLiteral() { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return falseToken; } + + SourceLocation lastSourceLocation() const override + { return falseToken; } + +// attributes + SourceLocation falseToken; +}; + +class QML_PARSER_EXPORT NumericLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NumericLiteral) + + NumericLiteral(double v): + value(v) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + double value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT StringLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(StringLiteral) + + StringLiteral(const QStringRef &v): + value (v) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + QStringRef value; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT RegExpLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(RegExpLiteral) + + RegExpLiteral(const QStringRef &p, int f): + pattern (p), flags (f) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return literalToken; } + + SourceLocation lastSourceLocation() const override + { return literalToken; } + +// attributes: + QStringRef pattern; + int flags; + SourceLocation literalToken; +}; + +class QML_PARSER_EXPORT ArrayLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(ArrayLiteral) + + ArrayLiteral(Elision *e): + elements (nullptr), elision (e) + { kind = K; } + + ArrayLiteral(ElementList *elts): + elements (elts), elision (nullptr) + { kind = K; } + + ArrayLiteral(ElementList *elts, Elision *e): + elements (elts), elision (e) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbracketToken; } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + +// attributes + ElementList *elements; + Elision *elision; + SourceLocation lbracketToken; + SourceLocation commaToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT ObjectLiteral: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(ObjectLiteral) + + ObjectLiteral(): + properties (nullptr) { kind = K; } + + ObjectLiteral(PropertyNameAndValueList *plist): + properties (plist) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + PropertyNameAndValueList *properties; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT Elision: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(Elision) + + Elision(): + next (this) { kind = K; } + + Elision(Elision *previous) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return commaToken; } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : commaToken; } + + inline Elision *finish () + { + Elision *front = next; + next = nullptr; + return front; + } + +// attributes + Elision *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT ElementList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(ElementList) + + ElementList(Elision *e, ExpressionNode *expr): + elision (e), expression (expr), next (this) + { kind = K; } + + ElementList(ElementList *previous, Elision *e, ExpressionNode *expr): + elision (e), expression (expr) + { + kind = K; + next = previous->next; + previous->next = this; + } + + inline ElementList *finish () + { + ElementList *front = next; + next = nullptr; + return front; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { + if (elision) + return elision->firstSourceLocation(); + return expression->firstSourceLocation(); + } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return expression->lastSourceLocation(); + } + +// attributes + Elision *elision; + ExpressionNode *expression; + ElementList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT PropertyName: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(PropertyName) + + PropertyName() { kind = K; } + + SourceLocation firstSourceLocation() const override + { return propertyNameToken; } + + SourceLocation lastSourceLocation() const override + { return propertyNameToken; } + +// attributes + SourceLocation propertyNameToken; +}; + +class QML_PARSER_EXPORT PropertyNameAndValueList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(PropertyNameAndValueList) + + PropertyNameAndValueList(PropertyName *n, ExpressionNode *v): + name (n), value (v), next (this) + { kind = K; } + + PropertyNameAndValueList(PropertyNameAndValueList *previous, PropertyName *n, ExpressionNode *v): + name (n), value (v) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return name->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return value->lastSourceLocation(); + } + + inline PropertyNameAndValueList *finish () + { + PropertyNameAndValueList *front = next; + next = nullptr; + return front; + } + +// attributes + PropertyName *name; + ExpressionNode *value; + PropertyNameAndValueList *next; + SourceLocation colonToken; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName +{ +public: + QMLJS_DECLARE_AST_NODE(IdentifierPropertyName) + + IdentifierPropertyName(const QStringRef &n): + id (n) { kind = K; } + + void accept0(Visitor *visitor) override; + +// attributes + QStringRef id; +}; + +class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName +{ +public: + QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName) + + StringLiteralPropertyName(const QStringRef &n): + id (n) { kind = K; } + + void accept0(Visitor *visitor) override; + +// attributes + QStringRef id; +}; + +class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName +{ +public: + QMLJS_DECLARE_AST_NODE(NumericLiteralPropertyName) + + NumericLiteralPropertyName(double n): + id (n) { kind = K; } + + void accept0(Visitor *visitor) override; + +// attributes + double id; +}; + +class QML_PARSER_EXPORT ArrayMemberExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(ArrayMemberExpression) + + ArrayMemberExpression(ExpressionNode *b, ExpressionNode *e): + base (b), expression (e) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + +// attributes + ExpressionNode *base; + ExpressionNode *expression; + SourceLocation lbracketToken; + SourceLocation rbracketToken; +}; + +class QML_PARSER_EXPORT FieldMemberExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(FieldMemberExpression) + + FieldMemberExpression(ExpressionNode *b, const QStringRef &n): + base (b), name (n) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return identifierToken; } + + // attributes + ExpressionNode *base; + QStringRef name; + SourceLocation dotToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT NewMemberExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NewMemberExpression) + + NewMemberExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return newToken; } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + + // attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation newToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT NewExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NewExpression) + + NewExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return newToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation newToken; +}; + +class QML_PARSER_EXPORT CallExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(CallExpression) + + CallExpression(ExpressionNode *b, ArgumentList *a): + base (b), arguments (a) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return rparenToken; } + +// attributes + ExpressionNode *base; + ArgumentList *arguments; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ArgumentList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(ArgumentList) + + ArgumentList(ExpressionNode *e): + expression (e), next (this) + { kind = K; } + + ArgumentList(ArgumentList *previous, ExpressionNode *e): + expression (e) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return expression->lastSourceLocation(); + } + + inline ArgumentList *finish () + { + ArgumentList *front = next; + next = nullptr; + return front; + } + +// attributes + ExpressionNode *expression; + ArgumentList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT PostIncrementExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(PostIncrementExpression) + + PostIncrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return incrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PostDecrementExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(PostDecrementExpression) + + PostDecrementExpression(ExpressionNode *b): + base (b) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return base->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return decrementToken; } + +// attributes + ExpressionNode *base; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT DeleteExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(DeleteExpression) + + DeleteExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return deleteToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation deleteToken; +}; + +class QML_PARSER_EXPORT VoidExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(VoidExpression) + + VoidExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return voidToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation voidToken; +}; + +class QML_PARSER_EXPORT TypeOfExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(TypeOfExpression) + + TypeOfExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return typeofToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation typeofToken; +}; + +class QML_PARSER_EXPORT PreIncrementExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(PreIncrementExpression) + + PreIncrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return incrementToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation incrementToken; +}; + +class QML_PARSER_EXPORT PreDecrementExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(PreDecrementExpression) + + PreDecrementExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return decrementToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation decrementToken; +}; + +class QML_PARSER_EXPORT UnaryPlusExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(UnaryPlusExpression) + + UnaryPlusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return plusToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation plusToken; +}; + +class QML_PARSER_EXPORT UnaryMinusExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(UnaryMinusExpression) + + UnaryMinusExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return minusToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation minusToken; +}; + +class QML_PARSER_EXPORT TildeExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(TildeExpression) + + TildeExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return tildeToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation tildeToken; +}; + +class QML_PARSER_EXPORT NotExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(NotExpression) + + NotExpression(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return notToken; } + + SourceLocation lastSourceLocation() const override + { return expression->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + SourceLocation notToken; +}; + +class QML_PARSER_EXPORT BinaryExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(BinaryExpression) + + BinaryExpression(ExpressionNode *l, int o, ExpressionNode *r): + left (l), op (o), right (r) + { kind = K; } + + BinaryExpression *binaryExpressionCast() override; + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return left->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + int op; + ExpressionNode *right; + SourceLocation operatorToken; +}; + +class QML_PARSER_EXPORT ConditionalExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(ConditionalExpression) + + ConditionalExpression(ExpressionNode *e, ExpressionNode *t, ExpressionNode *f): + expression (e), ok (t), ko (f) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return ko->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + ExpressionNode *ok; + ExpressionNode *ko; + SourceLocation questionToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT Expression: public ExpressionNode // ### rename +{ +public: + QMLJS_DECLARE_AST_NODE(Expression) + + Expression(ExpressionNode *l, ExpressionNode *r): + left (l), right (r) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return left->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return right->lastSourceLocation(); } + +// attributes + ExpressionNode *left; + ExpressionNode *right; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT Block: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(Block) + + Block(StatementList *slist): + statements (slist) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + + // attributes + StatementList *statements; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT StatementList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(StatementList) + + StatementList(Statement *stmt): + statement (stmt), next (this) + { kind = K; } + + StatementList(StatementList *previous, Statement *stmt): + statement (stmt) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return statement->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : statement->lastSourceLocation(); } + + inline StatementList *finish () + { + StatementList *front = next; + next = nullptr; + return front; + } + +// attributes + Statement *statement; + StatementList *next; +}; + +class QML_PARSER_EXPORT VariableStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(VariableStatement) + + VariableStatement(VariableDeclarationList *vlist): + declarations (vlist) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return declarationKindToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + VariableDeclarationList *declarations; + SourceLocation declarationKindToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT VariableDeclaration: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(VariableDeclaration) + + VariableDeclaration(const QStringRef &n, ExpressionNode *e): + name (n), expression (e), readOnly(false) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return expression ? expression->lastSourceLocation() : identifierToken; } + +// attributes + QStringRef name; + ExpressionNode *expression; + bool readOnly; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT VariableDeclarationList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(VariableDeclarationList) + + VariableDeclarationList(VariableDeclaration *decl): + declaration (decl), next (this) + { kind = K; } + + VariableDeclarationList(VariableDeclarationList *previous, VariableDeclaration *decl): + declaration (decl) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return declaration->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { + if (next) + return next->lastSourceLocation(); + return declaration->lastSourceLocation(); + } + + inline VariableDeclarationList *finish (bool readOnly) + { + VariableDeclarationList *front = next; + next = nullptr; + if (readOnly) { + VariableDeclarationList *vdl; + for (vdl = front; vdl != nullptr; vdl = vdl->next) + vdl->declaration->readOnly = true; + } + return front; + } + +// attributes + VariableDeclaration *declaration; + VariableDeclarationList *next; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT EmptyStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(EmptyStatement) + + EmptyStatement() { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return semicolonToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ExpressionStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ExpressionStatement) + + ExpressionStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return expression->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT IfStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(IfStatement) + + IfStatement(ExpressionNode *e, Statement *t, Statement *f = 0): + expression (e), ok (t), ko (f) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return ifToken; } + + SourceLocation lastSourceLocation() const override + { + if (ko) + return ko->lastSourceLocation(); + + return ok->lastSourceLocation(); + } + +// attributes + ExpressionNode *expression; + Statement *ok; + Statement *ko; + SourceLocation ifToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation elseToken; +}; + +class QML_PARSER_EXPORT DoWhileStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(DoWhileStatement) + + DoWhileStatement(Statement *stmt, ExpressionNode *e): + statement (stmt), expression (e) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return doToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + Statement *statement; + ExpressionNode *expression; + SourceLocation doToken; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT WhileStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(WhileStatement) + + WhileStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return whileToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation whileToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ForStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ForStatement) + + ForStatement(ExpressionNode *i, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + initialiser (i), condition (c), expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *initialiser; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT LocalForStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(LocalForStatement) + + LocalForStatement(VariableDeclarationList *vlist, ExpressionNode *c, ExpressionNode *e, Statement *stmt): + declarations (vlist), condition (c), expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + VariableDeclarationList *declarations; + ExpressionNode *condition; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation firstSemicolonToken; + SourceLocation secondSemicolonToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ForEachStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ForEachStatement) + + ForEachStatement(ExpressionNode *i, ExpressionNode *e, Statement *stmt): + initialiser (i), expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *initialiser; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation inToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT LocalForEachStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(LocalForEachStatement) + + LocalForEachStatement(VariableDeclaration *v, ExpressionNode *e, Statement *stmt): + declaration (v), expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return forToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + VariableDeclaration *declaration; + ExpressionNode *expression; + Statement *statement; + SourceLocation forToken; + SourceLocation lparenToken; + SourceLocation varToken; + SourceLocation inToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT ContinueStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ContinueStatement) + + ContinueStatement(const QStringRef &l = QStringRef()): + label (l) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return continueToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + QStringRef label; + SourceLocation continueToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT BreakStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(BreakStatement) + + BreakStatement(const QStringRef &l): + label (l) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return breakToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + + // attributes + QStringRef label; + SourceLocation breakToken; + SourceLocation identifierToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT ReturnStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ReturnStatement) + + ReturnStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return returnToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + ExpressionNode *expression; + SourceLocation returnToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT WithStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(WithStatement) + + WithStatement(ExpressionNode *e, Statement *stmt): + expression (e), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return withToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + ExpressionNode *expression; + Statement *statement; + SourceLocation withToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseBlock: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(CaseBlock) + + CaseBlock(CaseClauses *c, DefaultClause *d = 0, CaseClauses *r = 0): + clauses (c), defaultClause (d), moreClauses (r) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + CaseClauses *clauses; + DefaultClause *defaultClause; + CaseClauses *moreClauses; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT SwitchStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(SwitchStatement) + + SwitchStatement(ExpressionNode *e, CaseBlock *b): + expression (e), block (b) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return switchToken; } + + SourceLocation lastSourceLocation() const override + { return block->rbraceToken; } + +// attributes + ExpressionNode *expression; + CaseBlock *block; + SourceLocation switchToken; + SourceLocation lparenToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT CaseClause: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(CaseClause) + + CaseClause(ExpressionNode *e, StatementList *slist): + expression (e), statements (slist) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return caseToken; } + + SourceLocation lastSourceLocation() const override + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + ExpressionNode *expression; + StatementList *statements; + SourceLocation caseToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT CaseClauses: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(CaseClauses) + + CaseClauses(CaseClause *c): + clause (c), next (this) + { kind = K; } + + CaseClauses(CaseClauses *previous, CaseClause *c): + clause (c) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return clause->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : clause->lastSourceLocation(); } + + inline CaseClauses *finish () + { + CaseClauses *front = next; + next = nullptr; + return front; + } + +//attributes + CaseClause *clause; + CaseClauses *next; +}; + +class QML_PARSER_EXPORT DefaultClause: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(DefaultClause) + + DefaultClause(StatementList *slist): + statements (slist) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return defaultToken; } + + SourceLocation lastSourceLocation() const override + { return statements ? statements->lastSourceLocation() : colonToken; } + +// attributes + StatementList *statements; + SourceLocation defaultToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT LabelledStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(LabelledStatement) + + LabelledStatement(const QStringRef &l, Statement *stmt): + label (l), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + QStringRef label; + Statement *statement; + SourceLocation identifierToken; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT ThrowStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(ThrowStatement) + + ThrowStatement(ExpressionNode *e): + expression (e) { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return throwToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + + // attributes + ExpressionNode *expression; + SourceLocation throwToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT Catch: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(Catch) + + Catch(const QStringRef &n, Block *stmt): + name (n), statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return catchToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + QStringRef name; + Block *statement; + SourceLocation catchToken; + SourceLocation lparenToken; + SourceLocation identifierToken; + SourceLocation rparenToken; +}; + +class QML_PARSER_EXPORT Finally: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(Finally) + + Finally(Block *stmt): + statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return finallyToken; } + + SourceLocation lastSourceLocation() const override + { return statement ? statement->lastSourceLocation() : finallyToken; } + +// attributes + Block *statement; + SourceLocation finallyToken; +}; + +class QML_PARSER_EXPORT TryStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(TryStatement) + + TryStatement(Statement *stmt, Catch *c, Finally *f): + statement (stmt), catchExpression (c), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Finally *f): + statement (stmt), catchExpression (nullptr), finallyExpression (f) + { kind = K; } + + TryStatement(Statement *stmt, Catch *c): + statement (stmt), catchExpression (c), finallyExpression (nullptr) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return tryToken; } + + SourceLocation lastSourceLocation() const override + { + if (finallyExpression) + return finallyExpression->statement->rbraceToken; + else if (catchExpression) + return catchExpression->statement->rbraceToken; + + return statement->lastSourceLocation(); + } + +// attributes + Statement *statement; + Catch *catchExpression; + Finally *finallyExpression; + SourceLocation tryToken; +}; + +class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode +{ +public: + QMLJS_DECLARE_AST_NODE(FunctionExpression) + + FunctionExpression(const QStringRef &n, FormalParameterList *f, FunctionBody *b): + name (n), formals (f), body (b) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return functionToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + QStringRef name; + FormalParameterList *formals; + FunctionBody *body; + SourceLocation functionToken; + SourceLocation identifierToken; + SourceLocation lparenToken; + SourceLocation rparenToken; + SourceLocation lbraceToken; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression +{ +public: + QMLJS_DECLARE_AST_NODE(FunctionDeclaration) + + FunctionDeclaration(const QStringRef &n, FormalParameterList *f, FunctionBody *b): + FunctionExpression(n, f, b) + { kind = K; } + + void accept0(Visitor *visitor) override; +}; + +class QML_PARSER_EXPORT FormalParameterList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(FormalParameterList) + + FormalParameterList(const QStringRef &n): + name (n), next (this) + { kind = K; } + + FormalParameterList(FormalParameterList *previous, const QStringRef &n): + name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : identifierToken; } + + inline FormalParameterList *finish () + { + FormalParameterList *front = next; + next = nullptr; + return front; + } + +// attributes + QStringRef name; + FormalParameterList *next; + SourceLocation commaToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT SourceElement: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(SourceElement) + + inline SourceElement() + { kind = K; } +}; + +class QML_PARSER_EXPORT SourceElements: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(SourceElements) + + SourceElements(SourceElement *elt): + element (elt), next (this) + { kind = K; } + + SourceElements(SourceElements *previous, SourceElement *elt): + element (elt) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return element->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : element->lastSourceLocation(); } + + inline SourceElements *finish () + { + SourceElements *front = next; + next = nullptr; + return front; + } + +// attributes + SourceElement *element; + SourceElements *next; +}; + +class QML_PARSER_EXPORT FunctionBody: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(FunctionBody) + + FunctionBody(SourceElements *elts): + elements (elts) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return elements ? elements->firstSourceLocation() : SourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return elements ? elements->lastSourceLocation() : SourceLocation(); } + +// attributes + SourceElements *elements; +}; + +class QML_PARSER_EXPORT Program: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(Program) + + Program(SourceElements *elts): + elements (elts) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return elements ? elements->firstSourceLocation() : SourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return elements ? elements->lastSourceLocation() : SourceLocation(); } + +// attributes + SourceElements *elements; +}; + +class QML_PARSER_EXPORT FunctionSourceElement: public SourceElement +{ +public: + QMLJS_DECLARE_AST_NODE(FunctionSourceElement) + + FunctionSourceElement(FunctionDeclaration *f): + declaration (f) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return declaration->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return declaration->lastSourceLocation(); } + +// attributes + FunctionDeclaration *declaration; +}; + +class QML_PARSER_EXPORT StatementSourceElement: public SourceElement +{ +public: + QMLJS_DECLARE_AST_NODE(StatementSourceElement) + + StatementSourceElement(Statement *stmt): + statement (stmt) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return statement->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + +// attributes + Statement *statement; +}; + +class QML_PARSER_EXPORT DebuggerStatement: public Statement +{ +public: + QMLJS_DECLARE_AST_NODE(DebuggerStatement) + + DebuggerStatement() + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return debuggerToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + SourceLocation debuggerToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiQualifiedId: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiQualifiedId) + + UiQualifiedId(const QStringRef &name) + : next(this), name(name) + { kind = K; } + + UiQualifiedId(UiQualifiedId *previous, const QStringRef &name) + : name(name) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiQualifiedId *finish() + { + UiQualifiedId *head = next; + next = nullptr; + return head; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return identifierToken; } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : identifierToken; } + +// attributes + UiQualifiedId *next; + QStringRef name; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT UiImport: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiImport) + + UiImport(const QStringRef &fileName) + : fileName(fileName), importUri(nullptr) + { kind = K; } + + UiImport(UiQualifiedId *uri) + : importUri(uri) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return importToken; } + + SourceLocation lastSourceLocation() const override + { return semicolonToken; } + +// attributes + QStringRef fileName; + UiQualifiedId *importUri; + QStringRef importId; + SourceLocation importToken; + SourceLocation fileNameToken; + SourceLocation versionToken; + SourceLocation asToken; + SourceLocation importIdToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiImportList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiImportList) + + UiImportList(UiImport *import) + : import(import), + next(this) + { kind = K; } + + UiImportList(UiImportList *previous, UiImport *import) + : import(import) + { + kind = K; + next = previous->next; + previous->next = this; + } + + UiImportList *finish() + { + UiImportList *head = next; + next = nullptr; + return head; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return import->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : import->lastSourceLocation(); } + +// attributes + UiImport *import; + UiImportList *next; +}; + +class QML_PARSER_EXPORT UiObjectMember: public Node +{ +public: + SourceLocation firstSourceLocation() const override = 0; + SourceLocation lastSourceLocation() const override = 0; + + UiObjectMember *uiObjectMemberCast() override; +}; + +class QML_PARSER_EXPORT UiObjectMemberList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiObjectMemberList) + + UiObjectMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiObjectMemberList(UiObjectMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return member->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } + + UiObjectMemberList *finish() + { + UiObjectMemberList *head = next; + next = nullptr; + return head; + } + +// attributes + UiObjectMemberList *next; + UiObjectMember *member; +}; + +class QML_PARSER_EXPORT UiProgram: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiProgram) + + UiProgram(UiImportList *imports, UiObjectMemberList *members) + : imports(imports), members(members) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { + if (imports) + return imports->firstSourceLocation(); + else if (members) + return members->firstSourceLocation(); + return {}; + } + + SourceLocation lastSourceLocation() const override + { + if (members) + return members->lastSourceLocation(); + else if (imports) + return imports->lastSourceLocation(); + return {}; + } + +// attributes + UiImportList *imports; + UiObjectMemberList *members; +}; + +class QML_PARSER_EXPORT UiArrayMemberList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiArrayMemberList) + + UiArrayMemberList(UiObjectMember *member) + : next(this), member(member) + { kind = K; } + + UiArrayMemberList(UiArrayMemberList *previous, UiObjectMember *member) + : member(member) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return member->firstSourceLocation(); } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : member->lastSourceLocation(); } + + UiArrayMemberList *finish() + { + UiArrayMemberList *head = next; + next = nullptr; + return head; + } + +// attributes + UiArrayMemberList *next; + UiObjectMember *member; + SourceLocation commaToken; +}; + +class QML_PARSER_EXPORT UiObjectInitializer: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiObjectInitializer) + + UiObjectInitializer(UiObjectMemberList *members) + : members(members) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return lbraceToken; } + + SourceLocation lastSourceLocation() const override + { return rbraceToken; } + +// attributes + SourceLocation lbraceToken; + UiObjectMemberList *members; + SourceLocation rbraceToken; +}; + +class QML_PARSER_EXPORT UiParameterList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiParameterList) + + UiParameterList(const QStringRef &t, const QStringRef &n): + type (t), name (n), next (this) + { kind = K; } + + UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): + type (t), name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + void accept0(Visitor *) override {} + + SourceLocation firstSourceLocation() const override + { return propertyTypeToken; } + + SourceLocation lastSourceLocation() const override + { return next ? next->lastSourceLocation() : identifierToken; } + + inline UiParameterList *finish () + { + UiParameterList *front = next; + next = nullptr; + return front; + } + +// attributes + QStringRef type; + QStringRef name; + UiParameterList *next; + SourceLocation commaToken; + SourceLocation propertyTypeToken; + SourceLocation identifierToken; +}; + +class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiPublicMember) + + UiPublicMember(const QStringRef &memberType, + const QStringRef &name) + : type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr) + { kind = K; } + + UiPublicMember(const QStringRef &memberType, + const QStringRef &name, + Statement *statement) + : type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { + if (defaultToken.isValid()) + return defaultToken; + else if (readonlyToken.isValid()) + return readonlyToken; + + return propertyToken; + } + + SourceLocation lastSourceLocation() const override + { + if (binding) + return binding->lastSourceLocation(); + if (statement) + return statement->lastSourceLocation(); + + return semicolonToken; + } + +// attributes + enum { Signal, Property } type; + QStringRef typeModifier; + QStringRef memberType; + QStringRef name; + Statement *statement; // initialized with a JS expression + UiObjectMember *binding; // initialized with a QML object or array. + bool isDefaultMember; + bool isReadonlyMember; + UiParameterList *parameters; + SourceLocation defaultToken; + SourceLocation readonlyToken; + SourceLocation propertyToken; + SourceLocation typeModifierToken; + SourceLocation typeToken; + SourceLocation identifierToken; + SourceLocation colonToken; + SourceLocation semicolonToken; +}; + +class QML_PARSER_EXPORT UiObjectDefinition: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiObjectDefinition) + + UiObjectDefinition(UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedTypeNameId(qualifiedTypeNameId), initializer(initializer) + { kind = K; } + + void accept0(Visitor *visitor) override; + + SourceLocation firstSourceLocation() const override + { return qualifiedTypeNameId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return initializer->rbraceToken; } + +// attributes + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; +}; + +class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiSourceElement) + + UiSourceElement(Node *sourceElement) + : sourceElement(sourceElement) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { + if (const auto funDecl = cast(sourceElement)) + return funDecl->firstSourceLocation(); + else if (const auto varStmt = cast(sourceElement)) + return varStmt->firstSourceLocation(); + + return {}; + } + + SourceLocation lastSourceLocation() const override + { + if (const auto funDecl = cast(sourceElement)) + return funDecl->lastSourceLocation(); + else if (const auto varStmt = cast(sourceElement)) + return varStmt->lastSourceLocation(); + + return {}; + } + + void accept0(Visitor *visitor) override; + + +// attributes + Node *sourceElement; +}; + +class QML_PARSER_EXPORT UiObjectBinding: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiObjectBinding) + + UiObjectBinding(UiQualifiedId *qualifiedId, + UiQualifiedId *qualifiedTypeNameId, + UiObjectInitializer *initializer) + : qualifiedId(qualifiedId), + qualifiedTypeNameId(qualifiedTypeNameId), + initializer(initializer), + hasOnToken(false) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { + if (hasOnToken && qualifiedTypeNameId) + return qualifiedTypeNameId->identifierToken; + + return qualifiedId->identifierToken; + } + + SourceLocation lastSourceLocation() const override + { return initializer->rbraceToken; } + + void accept0(Visitor *visitor) override; + + +// attributes + UiQualifiedId *qualifiedId; + UiQualifiedId *qualifiedTypeNameId; + UiObjectInitializer *initializer; + SourceLocation colonToken; + bool hasOnToken; +}; + +class QML_PARSER_EXPORT UiScriptBinding: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiScriptBinding) + + UiScriptBinding(UiQualifiedId *qualifiedId, + Statement *statement) + : qualifiedId(qualifiedId), + statement(statement) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return qualifiedId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return statement->lastSourceLocation(); } + + void accept0(Visitor *visitor) override; + +// attributes + UiQualifiedId *qualifiedId; + Statement *statement; + SourceLocation colonToken; +}; + +class QML_PARSER_EXPORT UiArrayBinding: public UiObjectMember +{ +public: + QMLJS_DECLARE_AST_NODE(UiArrayBinding) + + UiArrayBinding(UiQualifiedId *qualifiedId, + UiArrayMemberList *members) + : qualifiedId(qualifiedId), + members(members) + { kind = K; } + + SourceLocation firstSourceLocation() const override + { return qualifiedId->identifierToken; } + + SourceLocation lastSourceLocation() const override + { return rbracketToken; } + + void accept0(Visitor *visitor) override; + +// attributes + UiQualifiedId *qualifiedId; + UiArrayMemberList *members; + SourceLocation colonToken; + SourceLocation lbracketToken; + SourceLocation rbracketToken; +}; + +} // namespace AST +} // namespace QbsQmlJS + +#endif diff --git a/src/lib/corelib/parser/qmljsastfwd_p.h b/src/lib/corelib/parser/qmljsastfwd_p.h new file mode 100644 index 00000000..f032f352 --- /dev/null +++ b/src/lib/corelib/parser/qmljsastfwd_p.h @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSAST_FWD_P_H +#define QMLJSAST_FWD_P_H + +#include "qmljsglobal_p.h" + +#include + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +namespace QbsQmlJS { +namespace AST { + +class SourceLocation +{ +public: + SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) + : offset(offset), length(length), + startLine(line), startColumn(column) + { } + + bool isValid() const { return length != 0; } + + quint32 begin() const { return offset; } + quint32 end() const { return offset + length; } + +// attributes + // ### encode + quint32 offset; + quint32 length; + quint32 startLine; + quint32 startColumn; +}; + +class Visitor; +class Node; +class ExpressionNode; +class Statement; +class ThisExpression; +class IdentifierExpression; +class NullExpression; +class TrueLiteral; +class FalseLiteral; +class NumericLiteral; +class StringLiteral; +class RegExpLiteral; +class ArrayLiteral; +class ObjectLiteral; +class ElementList; +class Elision; +class PropertyNameAndValueList; +class PropertyName; +class IdentifierPropertyName; +class StringLiteralPropertyName; +class NumericLiteralPropertyName; +class ArrayMemberExpression; +class FieldMemberExpression; +class NewMemberExpression; +class NewExpression; +class CallExpression; +class ArgumentList; +class PostIncrementExpression; +class PostDecrementExpression; +class DeleteExpression; +class VoidExpression; +class TypeOfExpression; +class PreIncrementExpression; +class PreDecrementExpression; +class UnaryPlusExpression; +class UnaryMinusExpression; +class TildeExpression; +class NotExpression; +class BinaryExpression; +class ConditionalExpression; +class Expression; // ### rename +class Block; +class StatementList; +class VariableStatement; +class VariableDeclarationList; +class VariableDeclaration; +class EmptyStatement; +class ExpressionStatement; +class IfStatement; +class DoWhileStatement; +class WhileStatement; +class ForStatement; +class LocalForStatement; +class ForEachStatement; +class LocalForEachStatement; +class ContinueStatement; +class BreakStatement; +class ReturnStatement; +class WithStatement; +class SwitchStatement; +class CaseBlock; +class CaseClauses; +class CaseClause; +class DefaultClause; +class LabelledStatement; +class ThrowStatement; +class TryStatement; +class Catch; +class Finally; +class FunctionDeclaration; +class FunctionExpression; +class FormalParameterList; +class FunctionBody; +class Program; +class SourceElements; +class SourceElement; +class FunctionSourceElement; +class StatementSourceElement; +class DebuggerStatement; +class NestedExpression; + +// ui elements +class UiProgram; +class UiImportList; +class UiImport; +class UiPublicMember; +class UiObjectDefinition; +class UiObjectInitializer; +class UiObjectBinding; +class UiScriptBinding; +class UiSourceElement; +class UiArrayBinding; +class UiObjectMember; +class UiObjectMemberList; +class UiArrayMemberList; +class UiQualifiedId; + +} // namespace AST +} // namespace QbsQmlJS + +#endif diff --git a/src/lib/corelib/parser/qmljsastvisitor.cpp b/src/lib/corelib/parser/qmljsastvisitor.cpp new file mode 100644 index 00000000..f034a147 --- /dev/null +++ b/src/lib/corelib/parser/qmljsastvisitor.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmljsastvisitor_p.h" + +namespace QbsQmlJS { +namespace AST { + +Visitor::Visitor() = default; + +Visitor::~Visitor() = default; + +} // namespace AST +} // namespace QbsQmlJS diff --git a/src/lib/corelib/parser/qmljsastvisitor_p.h b/src/lib/corelib/parser/qmljsastvisitor_p.h new file mode 100644 index 00000000..bec174c6 --- /dev/null +++ b/src/lib/corelib/parser/qmljsastvisitor_p.h @@ -0,0 +1,326 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSASTVISITOR_P_H +#define QMLJSASTVISITOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmljsastfwd_p.h" +#include "qmljsglobal_p.h" +#include + +namespace QbsQmlJS { +namespace AST { + +class QBS_AUTOTEST_EXPORT Visitor +{ +public: + Visitor(); + virtual ~Visitor(); + + virtual bool preVisit(Node *) { return true; } + virtual void postVisit(Node *) {} + + // Ui + virtual bool visit(UiProgram *) { return true; } + virtual bool visit(UiImportList *) { return true; } + virtual bool visit(UiImport *) { return true; } + virtual bool visit(UiPublicMember *) { return true; } + virtual bool visit(UiSourceElement *) { return true; } + virtual bool visit(UiObjectDefinition *) { return true; } + virtual bool visit(UiObjectInitializer *) { return true; } + virtual bool visit(UiObjectBinding *) { return true; } + virtual bool visit(UiScriptBinding *) { return true; } + virtual bool visit(UiArrayBinding *) { return true; } + virtual bool visit(UiObjectMemberList *) { return true; } + virtual bool visit(UiArrayMemberList *) { return true; } + virtual bool visit(UiQualifiedId *) { return true; } + + virtual void endVisit(UiProgram *) {} + virtual void endVisit(UiImportList *) {} + virtual void endVisit(UiImport *) {} + virtual void endVisit(UiPublicMember *) {} + virtual void endVisit(UiSourceElement *) {} + virtual void endVisit(UiObjectDefinition *) {} + virtual void endVisit(UiObjectInitializer *) {} + virtual void endVisit(UiObjectBinding *) {} + virtual void endVisit(UiScriptBinding *) {} + virtual void endVisit(UiArrayBinding *) {} + virtual void endVisit(UiObjectMemberList *) {} + virtual void endVisit(UiArrayMemberList *) {} + virtual void endVisit(UiQualifiedId *) {} + + // QbsQmlJS + virtual bool visit(ThisExpression *) { return true; } + virtual void endVisit(ThisExpression *) {} + + virtual bool visit(IdentifierExpression *) { return true; } + virtual void endVisit(IdentifierExpression *) {} + + virtual bool visit(NullExpression *) { return true; } + virtual void endVisit(NullExpression *) {} + + virtual bool visit(TrueLiteral *) { return true; } + virtual void endVisit(TrueLiteral *) {} + + virtual bool visit(FalseLiteral *) { return true; } + virtual void endVisit(FalseLiteral *) {} + + virtual bool visit(StringLiteral *) { return true; } + virtual void endVisit(StringLiteral *) {} + + virtual bool visit(NumericLiteral *) { return true; } + virtual void endVisit(NumericLiteral *) {} + + virtual bool visit(RegExpLiteral *) { return true; } + virtual void endVisit(RegExpLiteral *) {} + + virtual bool visit(ArrayLiteral *) { return true; } + virtual void endVisit(ArrayLiteral *) {} + + virtual bool visit(ObjectLiteral *) { return true; } + virtual void endVisit(ObjectLiteral *) {} + + virtual bool visit(ElementList *) { return true; } + virtual void endVisit(ElementList *) {} + + virtual bool visit(Elision *) { return true; } + virtual void endVisit(Elision *) {} + + virtual bool visit(PropertyNameAndValueList *) { return true; } + virtual void endVisit(PropertyNameAndValueList *) {} + + virtual bool visit(NestedExpression *) { return true; } + virtual void endVisit(NestedExpression *) {} + + virtual bool visit(IdentifierPropertyName *) { return true; } + virtual void endVisit(IdentifierPropertyName *) {} + + virtual bool visit(StringLiteralPropertyName *) { return true; } + virtual void endVisit(StringLiteralPropertyName *) {} + + virtual bool visit(NumericLiteralPropertyName *) { return true; } + virtual void endVisit(NumericLiteralPropertyName *) {} + + virtual bool visit(ArrayMemberExpression *) { return true; } + virtual void endVisit(ArrayMemberExpression *) {} + + virtual bool visit(FieldMemberExpression *) { return true; } + virtual void endVisit(FieldMemberExpression *) {} + + virtual bool visit(NewMemberExpression *) { return true; } + virtual void endVisit(NewMemberExpression *) {} + + virtual bool visit(NewExpression *) { return true; } + virtual void endVisit(NewExpression *) {} + + virtual bool visit(CallExpression *) { return true; } + virtual void endVisit(CallExpression *) {} + + virtual bool visit(ArgumentList *) { return true; } + virtual void endVisit(ArgumentList *) {} + + virtual bool visit(PostIncrementExpression *) { return true; } + virtual void endVisit(PostIncrementExpression *) {} + + virtual bool visit(PostDecrementExpression *) { return true; } + virtual void endVisit(PostDecrementExpression *) {} + + virtual bool visit(DeleteExpression *) { return true; } + virtual void endVisit(DeleteExpression *) {} + + virtual bool visit(VoidExpression *) { return true; } + virtual void endVisit(VoidExpression *) {} + + virtual bool visit(TypeOfExpression *) { return true; } + virtual void endVisit(TypeOfExpression *) {} + + virtual bool visit(PreIncrementExpression *) { return true; } + virtual void endVisit(PreIncrementExpression *) {} + + virtual bool visit(PreDecrementExpression *) { return true; } + virtual void endVisit(PreDecrementExpression *) {} + + virtual bool visit(UnaryPlusExpression *) { return true; } + virtual void endVisit(UnaryPlusExpression *) {} + + virtual bool visit(UnaryMinusExpression *) { return true; } + virtual void endVisit(UnaryMinusExpression *) {} + + virtual bool visit(TildeExpression *) { return true; } + virtual void endVisit(TildeExpression *) {} + + virtual bool visit(NotExpression *) { return true; } + virtual void endVisit(NotExpression *) {} + + virtual bool visit(BinaryExpression *) { return true; } + virtual void endVisit(BinaryExpression *) {} + + virtual bool visit(ConditionalExpression *) { return true; } + virtual void endVisit(ConditionalExpression *) {} + + virtual bool visit(Expression *) { return true; } + virtual void endVisit(Expression *) {} + + virtual bool visit(Block *) { return true; } + virtual void endVisit(Block *) {} + + virtual bool visit(StatementList *) { return true; } + virtual void endVisit(StatementList *) {} + + virtual bool visit(VariableStatement *) { return true; } + virtual void endVisit(VariableStatement *) {} + + virtual bool visit(VariableDeclarationList *) { return true; } + virtual void endVisit(VariableDeclarationList *) {} + + virtual bool visit(VariableDeclaration *) { return true; } + virtual void endVisit(VariableDeclaration *) {} + + virtual bool visit(EmptyStatement *) { return true; } + virtual void endVisit(EmptyStatement *) {} + + virtual bool visit(ExpressionStatement *) { return true; } + virtual void endVisit(ExpressionStatement *) {} + + virtual bool visit(IfStatement *) { return true; } + virtual void endVisit(IfStatement *) {} + + virtual bool visit(DoWhileStatement *) { return true; } + virtual void endVisit(DoWhileStatement *) {} + + virtual bool visit(WhileStatement *) { return true; } + virtual void endVisit(WhileStatement *) {} + + virtual bool visit(ForStatement *) { return true; } + virtual void endVisit(ForStatement *) {} + + virtual bool visit(LocalForStatement *) { return true; } + virtual void endVisit(LocalForStatement *) {} + + virtual bool visit(ForEachStatement *) { return true; } + virtual void endVisit(ForEachStatement *) {} + + virtual bool visit(LocalForEachStatement *) { return true; } + virtual void endVisit(LocalForEachStatement *) {} + + virtual bool visit(ContinueStatement *) { return true; } + virtual void endVisit(ContinueStatement *) {} + + virtual bool visit(BreakStatement *) { return true; } + virtual void endVisit(BreakStatement *) {} + + virtual bool visit(ReturnStatement *) { return true; } + virtual void endVisit(ReturnStatement *) {} + + virtual bool visit(WithStatement *) { return true; } + virtual void endVisit(WithStatement *) {} + + virtual bool visit(SwitchStatement *) { return true; } + virtual void endVisit(SwitchStatement *) {} + + virtual bool visit(CaseBlock *) { return true; } + virtual void endVisit(CaseBlock *) {} + + virtual bool visit(CaseClauses *) { return true; } + virtual void endVisit(CaseClauses *) {} + + virtual bool visit(CaseClause *) { return true; } + virtual void endVisit(CaseClause *) {} + + virtual bool visit(DefaultClause *) { return true; } + virtual void endVisit(DefaultClause *) {} + + virtual bool visit(LabelledStatement *) { return true; } + virtual void endVisit(LabelledStatement *) {} + + virtual bool visit(ThrowStatement *) { return true; } + virtual void endVisit(ThrowStatement *) {} + + virtual bool visit(TryStatement *) { return true; } + virtual void endVisit(TryStatement *) {} + + virtual bool visit(Catch *) { return true; } + virtual void endVisit(Catch *) {} + + virtual bool visit(Finally *) { return true; } + virtual void endVisit(Finally *) {} + + virtual bool visit(FunctionDeclaration *) { return true; } + virtual void endVisit(FunctionDeclaration *) {} + + virtual bool visit(FunctionExpression *) { return true; } + virtual void endVisit(FunctionExpression *) {} + + virtual bool visit(FormalParameterList *) { return true; } + virtual void endVisit(FormalParameterList *) {} + + virtual bool visit(FunctionBody *) { return true; } + virtual void endVisit(FunctionBody *) {} + + virtual bool visit(Program *) { return true; } + virtual void endVisit(Program *) {} + + virtual bool visit(SourceElements *) { return true; } + virtual void endVisit(SourceElements *) {} + + virtual bool visit(FunctionSourceElement *) { return true; } + virtual void endVisit(FunctionSourceElement *) {} + + virtual bool visit(StatementSourceElement *) { return true; } + virtual void endVisit(StatementSourceElement *) {} + + virtual bool visit(DebuggerStatement *) { return true; } + virtual void endVisit(DebuggerStatement *) {} +}; + +} // namespace AST +} // namespace QbsQmlJS + +#endif // QMLJSASTVISITOR_P_H diff --git a/src/lib/corelib/parser/qmljsengine_p.cpp b/src/lib/corelib/parser/qmljsengine_p.cpp new file mode 100644 index 00000000..67da0982 --- /dev/null +++ b/src/lib/corelib/parser/qmljsengine_p.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmljsengine_p.h" +#include "qmljsglobal_p.h" + +#include +#include +#include + +namespace QbsQmlJS { + +static int toDigit(char c) +{ + if ((c >= '0') && (c <= '9')) + return c - '0'; + if ((c >= 'a') && (c <= 'z')) + return 10 + c - 'a'; + if ((c >= 'A') && (c <= 'Z')) + return 10 + c - 'A'; + return -1; +} + +double integerFromString(const char *buf, int size, int radix) +{ + if (size == 0) + return qSNaN(); + + double sign = 1.0; + int i = 0; + if (buf[0] == '+') { + ++i; + } else if (buf[0] == '-') { + sign = -1.0; + ++i; + } + + if (((size-i) >= 2) && (buf[i] == '0')) { + if (((buf[i+1] == 'x') || (buf[i+1] == 'X')) + && (radix < 34)) { + if ((radix != 0) && (radix != 16)) + return 0; + radix = 16; + i += 2; + } else { + if (radix == 0) { + radix = 8; + ++i; + } + } + } else if (radix == 0) { + radix = 10; + } + + int j = i; + for ( ; i < size; ++i) { + int d = toDigit(buf[i]); + if ((d == -1) || (d >= radix)) + break; + } + double result; + if (j == i) { + if (!qstrcmp(buf, "Infinity")) + result = qInf(); + else + result = qSNaN(); + } else { + result = 0; + double multiplier = 1; + for (--i ; i >= j; --i, multiplier *= radix) + result += toDigit(buf[i]) * multiplier; + } + result *= sign; + return result; +} + +double integerFromString(const QString &str, int radix) +{ + QByteArray ba = str.trimmed().toLatin1(); + return integerFromString(ba.constData(), ba.size(), radix); +} + + +Engine::Engine() = default; + +Engine::~Engine() = default; + +void Engine::setCode(const QString &code) +{ _code = code; } + +void Engine::addComment(int pos, int len, int line, int col) +{ if (len > 0) _comments.append(QbsQmlJS::AST::SourceLocation(pos, len, line, col)); } + +QList Engine::comments() const +{ return _comments; } + +Lexer *Engine::lexer() const +{ return _lexer; } + +void Engine::setLexer(Lexer *lexer) +{ _lexer = lexer; } + +void Engine::setDirectives(Directives *directives) +{ _directives = directives; } + +Directives *Engine::directives() const +{ return _directives; } + +MemoryPool *Engine::pool() +{ return &_pool; } + +QStringRef Engine::newStringRef(const QString &text) +{ + const int pos = _extraCode.length(); + _extraCode += text; + return QStringRef(&_extraCode).mid(pos, text.length()); +} + +QStringRef Engine::newStringRef(const QChar *chars, int size) +{ return newStringRef(QString(chars, size)); } + +} // end of namespace QbsQmlJS diff --git a/src/lib/corelib/parser/qmljsengine_p.h b/src/lib/corelib/parser/qmljsengine_p.h new file mode 100644 index 00000000..2a616126 --- /dev/null +++ b/src/lib/corelib/parser/qmljsengine_p.h @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSENGINE_P_H +#define QMLJSENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmljsglobal_p.h" +#include "qmljsastfwd_p.h" +#include "qmljsmemorypool_p.h" +#include + +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + +#include +#include + +namespace QbsQmlJS { + +class Lexer; +class Directives; +class MemoryPool; + +class QML_PARSER_EXPORT DiagnosticMessage +{ +public: + enum Kind { Warning, Error }; + + DiagnosticMessage() + : kind(Error) {} + + DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, QString message) + : kind(kind), loc(loc), message(std::move(message)) {} + + bool isWarning() const + { return kind == Warning; } + + bool isError() const + { return kind == Error; } + + Kind kind; + AST::SourceLocation loc; + QString message; +}; + +class QBS_AUTOTEST_EXPORT Engine +{ + Lexer *_lexer{nullptr}; + Directives *_directives{nullptr}; + MemoryPool _pool; + QList _comments; + QString _extraCode; + QString _code; + +public: + Engine(); + ~Engine(); + + void setCode(const QString &code); + + void addComment(int pos, int len, int line, int col); + QList comments() const; + + Lexer *lexer() const; + void setLexer(Lexer *lexer); + + void setDirectives(Directives *directives); + Directives *directives() const; + + MemoryPool *pool(); + + inline QStringRef midRef(int position, int size) + { + return QStringRef(&_code).mid(position, size); + } + + QStringRef newStringRef(const QString &s); + QStringRef newStringRef(const QChar *chars, int size); +}; + +double integerFromString(const char *buf, int size, int radix); + +} // end of namespace QbsQmlJS + +#endif // QMLJSENGINE_P_H diff --git a/src/lib/corelib/parser/qmljsglobal_p.h b/src/lib/corelib/parser/qmljsglobal_p.h new file mode 100644 index 00000000..c3d198ea --- /dev/null +++ b/src/lib/corelib/parser/qmljsglobal_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QMLJSGLOBAL_P_H +#define QMLJSGLOBAL_P_H + +#include + +// Force QML_PARSER_EXPORT to be always empty. +#ifndef QT_CREATOR +# define QT_CREATOR +#endif +#ifdef QML_BUILD_STATIC_LIB +# undef QML_BUILD_STATIC_LIB +#endif +#define QML_BUILD_STATIC_LIB 1 + +#ifdef QT_CREATOR +# ifdef QMLJS_BUILD_DIR +# define QML_PARSER_EXPORT Q_DECL_EXPORT +# elif QML_BUILD_STATIC_LIB +# define QML_PARSER_EXPORT +# else +# define QML_PARSER_EXPORT Q_DECL_IMPORT +# endif // QMLJS_BUILD_DIR + +#else // !QT_CREATOR +# if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) + // QmlDevTools is a static library +# define QML_PARSER_EXPORT +# else +# define QML_PARSER_EXPORT Q_AUTOTEST_EXPORT +# endif +#endif // QT_CREATOR + +#endif // QMLJSGLOBAL_P_H diff --git a/src/lib/corelib/parser/qmljsgrammar.cpp b/src/lib/corelib/parser/qmljsgrammar.cpp new file mode 100644 index 00000000..75b4a488 --- /dev/null +++ b/src/lib/corelib/parser/qmljsgrammar.cpp @@ -0,0 +1,1017 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This file was generated by qlalr - DO NOT EDIT! +#include "qmljsgrammar_p.h" + +namespace QbsQmlJS { + +const char *const QmlJSGrammar::spell [] = { + "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ",", "continue", + "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", + "finally", "for", "function", ">=", ">", ">>", ">>=", ">>>", ">>>=", "identifier", + "if", "in", "instanceof", "{", "[", "<=", "(", "<", "<<", "<<=", + "-", "-=", "--", "new", "!", "!=", "!==", "numeric literal", "|", "|=", + "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", + ")", ";", 0, "*", "*=", "string literal", "property", "signal", "readonly", "switch", + "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", + "^=", "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "comment", "public", + "import", "as", "on", 0, 0, 0, 0, 0, 0, 0, + 0, 0 +}; + +const short QmlJSGrammar::lhs [] = { + 102, 102, 102, 102, 102, 102, 103, 109, 109, 112, + 112, 114, 113, 113, 113, 113, 113, 113, 113, 113, + 116, 111, 110, 119, 119, 120, 120, 121, 121, 118, + 107, 107, 107, 107, 123, 123, 123, 123, 123, 123, + 123, 107, 131, 131, 131, 132, 132, 133, 133, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 117, 117, 117, 117, + 117, 136, 136, 136, 136, 136, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 136, 136, 136, 122, + 138, 138, 138, 138, 137, 137, 140, 140, 142, 142, + 142, 142, 142, 142, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, + 143, 143, 143, 143, 143, 144, 144, 115, 115, 115, + 115, 115, 147, 147, 148, 148, 148, 148, 146, 146, + 149, 149, 150, 150, 151, 151, 151, 152, 152, 152, + 152, 152, 152, 152, 152, 152, 152, 153, 153, 153, + 153, 154, 154, 154, 155, 155, 155, 155, 156, 156, + 156, 156, 156, 156, 156, 157, 157, 157, 157, 157, + 157, 158, 158, 158, 158, 158, 159, 159, 159, 159, + 159, 160, 160, 161, 161, 162, 162, 163, 163, 164, + 164, 165, 165, 166, 166, 167, 167, 168, 168, 169, + 169, 170, 170, 171, 171, 141, 141, 172, 172, 173, + 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, + 173, 105, 105, 174, 174, 175, 175, 176, 176, 104, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 104, 104, 104, 104, 124, 185, 185, 184, 184, 135, + 135, 186, 186, 187, 187, 189, 189, 188, 190, 193, + 191, 191, 194, 192, 192, 125, 126, 126, 127, 127, + 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, + 178, 179, 179, 179, 179, 180, 180, 128, 129, 195, + 195, 198, 198, 196, 196, 199, 197, 181, 181, 181, + 182, 182, 130, 130, 130, 200, 201, 183, 183, 134, + 145, 205, 205, 202, 202, 203, 203, 206, 108, 108, + 207, 207, 106, 106, 204, 204, 139, 139, 208 +}; + +const short QmlJSGrammar::rhs [] = { + 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 2, 1, 2, 2, 3, 3, 5, 5, 4, 4, + 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, + 1, 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 0, 22, 0, 175, 242, + 206, 214, 210, 154, 226, 202, 3, 139, 73, 155, + 218, 222, 143, 172, 153, 158, 138, 192, 179, 0, + 80, 81, 76, 345, 67, 347, 0, 0, 0, 0, + 78, 0, 0, 74, 77, 71, 0, 0, 68, 70, + 69, 79, 72, 0, 75, 0, 0, 168, 0, 0, + 155, 174, 157, 156, 0, 0, 0, 170, 171, 169, + 173, 0, 203, 0, 0, 0, 0, 193, 0, 0, + 0, 0, 0, 0, 183, 0, 0, 0, 177, 178, + 176, 181, 185, 184, 182, 180, 195, 194, 196, 0, + 211, 0, 207, 0, 0, 149, 136, 148, 137, 105, + 106, 107, 132, 108, 133, 109, 110, 111, 112, 113, + 114, 115, 116, 117, 118, 119, 120, 121, 134, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 135, + 0, 0, 147, 243, 150, 0, 151, 0, 152, 146, + 0, 239, 232, 230, 237, 238, 236, 235, 241, 234, + 233, 231, 240, 227, 0, 215, 0, 0, 219, 0, + 0, 223, 0, 0, 149, 141, 0, 140, 0, 145, + 159, 0, 346, 334, 335, 0, 332, 0, 333, 0, + 336, 250, 257, 256, 264, 252, 0, 253, 337, 0, + 344, 254, 255, 260, 258, 341, 338, 343, 261, 0, + 272, 0, 0, 0, 0, 345, 67, 0, 347, 68, + 244, 286, 69, 0, 0, 0, 273, 0, 0, 262, + 263, 0, 251, 259, 287, 288, 331, 342, 0, 302, + 303, 304, 305, 0, 298, 299, 300, 301, 328, 329, + 0, 0, 0, 0, 0, 291, 292, 248, 246, 208, + 216, 212, 228, 204, 249, 0, 155, 220, 224, 197, + 186, 0, 0, 205, 0, 0, 0, 0, 198, 0, + 0, 0, 0, 0, 190, 188, 191, 189, 187, 200, + 199, 201, 0, 213, 0, 209, 0, 247, 155, 0, + 229, 244, 245, 0, 244, 0, 0, 294, 0, 0, + 0, 296, 0, 217, 0, 0, 221, 0, 0, 225, + 284, 0, 276, 285, 279, 0, 283, 0, 244, 277, + 0, 244, 0, 0, 295, 0, 0, 0, 297, 346, + 334, 0, 0, 336, 0, 330, 0, 320, 0, 0, + 0, 290, 0, 289, 0, 348, 0, 104, 266, 269, + 0, 105, 272, 108, 133, 110, 111, 76, 115, 116, + 67, 117, 120, 74, 77, 68, 244, 69, 79, 123, + 72, 125, 75, 127, 128, 273, 130, 131, 135, 0, + 97, 0, 0, 99, 103, 101, 88, 100, 102, 0, + 98, 87, 267, 265, 143, 144, 149, 0, 142, 0, + 319, 0, 306, 307, 0, 318, 0, 0, 0, 309, + 314, 312, 315, 0, 0, 313, 314, 0, 310, 0, + 311, 268, 317, 0, 268, 316, 0, 321, 322, 0, + 268, 323, 324, 0, 0, 325, 0, 0, 0, 326, + 327, 161, 160, 0, 0, 0, 293, 0, 0, 0, + 308, 281, 274, 0, 282, 278, 0, 280, 270, 0, + 271, 275, 91, 0, 0, 95, 82, 0, 84, 93, + 0, 85, 94, 96, 86, 92, 83, 0, 89, 165, + 163, 167, 164, 162, 166, 339, 6, 340, 4, 2, + 65, 90, 0, 0, 68, 70, 69, 31, 5, 0, + 66, 0, 45, 44, 43, 0, 0, 58, 0, 59, + 35, 36, 37, 38, 40, 41, 62, 39, 0, 45, + 0, 0, 0, 0, 0, 54, 0, 55, 0, 0, + 26, 0, 0, 63, 27, 0, 30, 28, 24, 0, + 29, 25, 0, 56, 0, 57, 143, 0, 60, 64, + 0, 0, 0, 0, 61, 0, 52, 46, 53, 47, + 0, 0, 0, 0, 49, 0, 50, 51, 48, 0, + 0, 143, 268, 0, 0, 42, 105, 272, 108, 133, + 110, 111, 76, 115, 116, 67, 117, 120, 74, 77, + 68, 244, 69, 79, 123, 72, 125, 75, 127, 128, + 273, 130, 131, 135, 0, 32, 33, 0, 34, 8, + 0, 10, 0, 9, 0, 1, 21, 12, 0, 13, + 0, 14, 0, 19, 20, 0, 15, 16, 0, 17, + 18, 11, 23, 7, 349 +}; + +const short QmlJSGrammar::goto_default [] = { + 7, 625, 207, 196, 205, 508, 496, 624, 643, 495, + 623, 621, 626, 22, 622, 18, 507, 549, 539, 546, + 541, 526, 191, 195, 197, 201, 233, 208, 230, 530, + 570, 569, 200, 232, 26, 474, 473, 356, 355, 9, + 354, 357, 107, 17, 145, 24, 13, 144, 19, 25, + 57, 23, 8, 28, 27, 269, 15, 263, 10, 259, + 12, 261, 11, 260, 20, 267, 21, 268, 14, 262, + 258, 299, 411, 264, 265, 202, 193, 192, 204, 203, + 229, 194, 360, 359, 231, 463, 462, 321, 322, 465, + 324, 464, 323, 419, 423, 426, 422, 421, 441, 442, + 185, 199, 181, 184, 198, 206, 0 +}; + +const short QmlJSGrammar::action_index [] = { + 360, 1257, 2491, 2491, 2393, 982, 78, 84, 145, -102, + 81, 64, 68, 210, -102, 306, 54, -102, -102, 620, + 59, 128, 268, 244, -102, -102, -102, 521, 205, 1257, + -102, -102, -102, 442, -102, 2197, 1819, 1257, 1257, 1257, + -102, 682, 1257, -102, -102, -102, 1257, 1257, -102, -102, + -102, -102, -102, 1257, -102, 1257, 1257, -102, 1257, 1257, + 95, 188, -102, -102, 1257, 1257, 1257, -102, -102, -102, + 191, 1257, 313, 1257, 1257, 1257, 1257, 521, 1257, 1257, + 1257, 1257, 1257, 1257, 196, 1257, 1257, 1257, 151, 146, + 116, 167, 174, 182, 186, 189, 521, 429, 521, 1257, + 45, 1257, 41, 2099, 1257, 1257, -102, -102, -102, -102, + -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, + 125, 1257, -102, -102, 58, 46, -102, 1257, -102, -102, + 1257, -102, -102, -102, -102, -102, -102, -102, -102, -102, + -102, -102, -102, -102, 1257, 17, 1257, 1257, 75, 71, + 1257, -102, 2099, 1257, 1257, -102, 154, -102, 51, -102, + -102, 55, -102, 288, 72, 57, -102, 297, -102, 62, + 2491, -102, -102, -102, -102, -102, 232, -102, -102, 60, + -102, -102, -102, -102, -102, -102, 2491, -102, -102, 458, + -102, 470, 89, 2393, 49, 442, 69, 47, 2687, 65, + 1257, -102, 61, 43, 1257, 40, -102, 39, 82, -102, + -102, 442, -102, -102, -102, -102, -102, -102, 102, -102, + -102, -102, -102, 98, -102, -102, -102, -102, -102, -102, + 76, 63, 1257, 92, 93, -102, -102, 1348, -102, 88, + 66, 48, -102, 304, 80, 77, 560, 187, 86, 400, + 271, 442, 1257, 302, 1257, 1257, 1257, 1257, 407, 1257, + 1257, 1257, 1257, 1257, 253, 257, 272, 281, 278, 362, + 358, 337, 1257, 48, 1257, 73, 1257, -102, 620, 1257, + -102, 1257, 56, 44, 1257, 42, 2393, -102, 1257, 117, + 2393, -102, 1257, 38, 1257, 1257, 187, 74, 1257, -102, + 70, 118, 22, -102, -102, 1257, -102, 442, 1257, -102, + 67, 1257, 79, 2393, -102, 1257, 112, 2393, -102, -25, + 442, -48, -20, 2491, -41, -102, 2393, -102, 1257, 113, + 2393, 2, 2393, -102, 3, 11, -34, -102, -102, 2393, + -30, 504, 19, 450, 114, 1257, 2393, 20, -16, 414, + -1, -31, 772, -3, -4, -102, 1443, -102, 87, -35, + -5, 1257, 0, 30, 1257, 33, 1257, 14, 15, 1257, + -102, 2295, 1, -102, -102, -102, -102, -102, -102, 1257, + -102, -102, -102, -102, 226, -102, 1257, -6, -102, 2393, + -102, 96, -102, -102, 2393, -102, 1257, 101, 36, -102, + 53, -102, 29, 91, 1257, -102, 24, 23, -102, -24, + -102, 2393, -102, 100, 2393, -102, 250, -102, -102, 90, + 2393, 16, -102, 10, 12, -102, 442, -12, 4, -102, + -102, -102, -102, 1257, 111, 2393, -102, 1257, 105, 2393, + -102, 6, -102, 214, -102, -102, 1257, -102, -102, 354, + -102, -102, -102, 85, 1537, -102, -102, 1631, -102, -102, + 1725, -102, -102, -102, -102, -102, -102, 135, -102, -102, + -102, -102, -102, -102, -102, -102, -102, 2491, -102, -102, + -102, 159, -10, 890, 202, -11, 18, -102, -102, 222, + -102, 199, -102, -102, -102, 359, 211, -102, 1910, -102, + -102, -102, -102, -102, -102, -102, -102, -102, 183, -13, + 349, 175, -2, 344, 282, -102, -17, -102, 800, 124, + -102, -18, 890, -102, -102, 1074, -102, -102, -102, 1166, + -102, -102, 208, -102, 1910, -102, 369, -18, -102, -102, + 204, 341, 9, 1910, -102, 203, -102, 177, -102, -8, + -51, 309, 206, 442, -102, 83, -102, -102, -102, 2001, + 800, 369, 2589, 1819, 34, -102, 436, 25, 493, 108, + 1257, 2393, 26, 7, 409, 28, 8, 598, 32, 31, + -102, 1443, -102, 87, 5, 21, 1257, 52, 37, 1257, + 50, 1257, 35, 13, 134, -102, -102, 27, -102, -102, + 710, -102, 266, -38, 890, -102, -102, 115, 300, -102, + 176, -102, 122, -102, -102, 442, -102, -102, 126, -102, + -102, -102, -102, -102, -102, + + -107, -3, -98, 4, 7, 280, 3, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -35, + -107, -107, -107, -107, -107, -107, -107, -107, -107, 78, + -107, -107, -107, 20, -107, -107, -22, 15, 86, 72, + -107, 193, 175, -107, -107, -107, 174, 170, -107, -107, + -107, -107, -107, 118, -107, 144, 145, -107, 127, 156, + -107, -107, -107, -107, 162, 165, 166, -107, -107, -107, + -107, 149, -107, 137, 136, 135, 134, -107, 181, 180, + 179, 173, 53, 117, -107, 81, 95, 90, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, 103, + -107, 101, -107, 194, 92, 58, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, 32, -107, -107, -107, -107, -107, 16, -107, -107, + 49, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, 70, -107, 109, 34, -107, -107, + 45, -107, 216, 60, 100, -107, -107, -107, -107, -107, + -107, -107, -107, 44, -107, -107, -107, 47, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, 48, -107, -107, 35, + -107, 39, -107, 56, -107, 79, -107, -107, 83, -107, + 76, -107, -107, -107, 89, 69, -107, -107, -107, -107, + -107, -2, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, 19, -107, -107, -107, -107, 105, -107, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -13, 195, -107, 218, 212, 215, 228, -107, 114, + 87, 121, 124, 107, -107, -107, -107, -107, -107, -107, + -107, -107, 198, -107, 221, -107, 236, -107, -107, 237, + -107, 128, -107, -107, 184, -107, 36, -107, 24, -107, + 102, -107, 192, -107, 234, 238, -107, -107, 224, -107, + -107, -107, -107, -107, -107, 191, -107, 93, 99, -107, + -107, 108, -107, 88, -107, 84, -107, 91, -107, -107, + 141, -107, -107, -23, -107, -107, 59, -107, 57, -107, + 55, -107, 54, -107, -107, -107, -107, -107, -107, 46, + -107, 31, -107, 30, -107, 169, 37, -107, -107, 68, + -107, -107, 85, -107, -107, -107, 73, -107, -107, -107, + -107, 66, -107, 52, 98, -107, 104, -107, -107, 43, + -107, 40, -107, -107, -107, -107, -107, -107, -107, 42, + -107, -107, -107, -107, -107, -107, 106, -107, -107, 62, + -107, -107, -107, -107, 63, -107, 65, -107, -107, -107, + -107, -107, -30, -107, 67, -107, -19, -107, -107, -107, + -107, 94, -107, -107, 97, -107, -107, -107, -107, -107, + 75, -50, -107, -107, 25, -107, 28, -107, 29, -107, + -107, -107, -107, 41, -107, 64, -107, 38, -107, 51, + -107, -107, -107, -107, -107, -107, 33, -107, -107, 122, + -107, -107, -107, -107, 61, -107, -107, 163, -107, -107, + 50, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -107, -107, -107, -107, -107, -107, -107, 82, -107, -107, + -107, -107, -107, -12, -107, -107, -107, -107, -107, -107, + -107, -15, -107, -107, -107, -5, -107, -107, 297, -107, + -107, -107, -107, -107, -107, -107, -107, -107, -107, -107, + -9, -26, -107, -11, -107, -107, -107, -107, 183, -107, + -107, -107, 288, -107, -107, 283, -107, -107, -107, 390, + -107, -107, -107, -107, 321, -107, -107, -8, -107, -107, + 11, 18, -107, 305, -107, -107, -107, 1, -107, -107, + -107, 14, -4, 0, -107, -107, -107, -107, -107, 337, + 217, -107, 22, 279, 9, -107, 8, -107, 6, -107, + 153, 17, -107, -107, 5, -107, -107, 96, -107, -107, + -107, 13, -107, -107, -107, -107, 23, -107, 10, 77, + -107, 71, -107, -107, -107, -107, -107, 12, -107, -107, + 21, -107, -107, 26, 148, -107, -107, -107, 27, -107, + -107, -107, -107, -107, -107, -10, -107, -107, -107, -107, + -107, -107, -107, -107, -107 +}; + +const short QmlJSGrammar::action_info [] = { + 572, 416, -124, -103, -121, 348, 346, -126, 399, 575, + 389, 340, 342, 343, 345, 545, 563, 538, 352, 391, + 257, 401, 533, 466, 531, 403, -132, -113, -124, 424, + 431, 430, -132, -113, 424, 346, 444, 440, -103, -121, + -129, 416, 71, 257, 348, 440, 446, 565, 448, 457, + 453, 457, 620, 335, 408, 560, 511, -129, 424, -126, + 545, 164, 141, 440, 141, 99, 147, 545, 414, 420, + 440, 453, 409, 440, 272, 453, 346, 164, 170, 416, + 187, 318, 71, 348, 644, 257, 292, 325, 296, 272, + 0, 183, 0, 477, -102, 190, 443, 0, 0, 252, + 141, 427, 306, 0, 0, 304, 149, 434, 141, 141, + 444, 179, 99, 141, 292, 236, 0, 189, 457, 141, + 141, 141, 0, 0, 101, 141, 327, 294, 331, 0, + 172, 0, 542, 141, 0, 0, 314, 62, 301, 333, + 315, 478, 542, 141, 577, 576, 428, 101, 63, 173, + 249, 248, 254, 251, 256, 255, 58, 413, 412, 247, + 246, 418, 141, 242, 241, 459, 0, 59, 620, 249, + 248, 455, 337, 350, 172, 249, 248, 310, 166, 328, + 543, 142, 167, 634, 633, 58, 58, 640, 639, 312, + 615, 58, 85, 173, 86, 488, 59, 59, 172, 85, + 64, 86, 59, 64, 512, 87, 512, 85, 0, 86, + 177, 85, 87, 86, 85, 554, 86, 173, 518, 406, + 87, 85, 469, 86, 87, 103, 0, 87, 512, 579, + 85, 529, 86, 512, 87, 512, 0, 637, 636, 567, + 141, 172, 0, 87, 104, 65, 105, 0, 65, 0, + 514, 66, 514, 0, 66, 545, 64, 0, 141, 0, + 173, 513, 406, 513, 568, 566, 0, 635, 0, 555, + 553, 0, 519, 517, 514, 470, 468, 514, 85, 514, + 86, 514, 85, 172, 86, 513, 0, 0, 513, 536, + 513, 87, 513, 235, 234, 87, 85, 85, 86, 86, + 0, 65, 173, 85, 174, 86, 85, 66, 86, 87, + 87, 438, 437, 630, 580, 0, 87, 34, 0, 87, + 274, 275, 274, 275, 73, 74, 34, 631, 629, 34, + 0, 73, 74, 0, 0, 0, 0, 0, 34, 0, + 0, 0, 0, 537, 535, 0, 0, 276, 277, 276, + 277, 75, 76, 0, 48, 50, 49, 628, 75, 76, + 279, 280, 0, 48, 50, 49, 48, 50, 49, 281, + 34, 0, 282, 34, 283, 48, 50, 49, 34, 0, + 45, 279, 280, 34, 172, 279, 280, 0, 34, 45, + 281, 0, 45, 282, 281, 283, 0, 282, 0, 283, + 0, 45, -90, 173, 0, 174, 0, 48, 50, 49, + 48, 50, 49, 0, 0, 48, 50, 49, 0, 0, + 48, 50, 49, 279, 280, 48, 50, 49, 0, 0, + 279, 280, 281, 45, 0, 282, 45, 283, 34, 281, + 0, 45, 282, 34, 283, -345, 45, 0, 0, 0, + -345, 45, 78, 79, 6, 5, 4, 1, 3, 2, + 80, 81, 0, 0, 82, 34, 83, 0, 0, 0, + 0, 34, 0, 0, 0, 48, 50, 49, 0, 34, + 48, 50, 49, 0, 0, 0, 0, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 240, 239, 34, + 0, 45, 48, 50, 49, 0, 45, 0, 48, 50, + 49, 245, 244, 0, 0, 0, 48, 50, 49, 240, + 239, 0, 34, 0, 48, 50, 49, 0, 45, 0, + 0, 245, 244, 34, 45, 0, 48, 50, 49, 0, + 0, 0, 45, 0, 78, 79, 0, 0, 0, 0, + 45, 0, 80, 81, 245, 244, 82, 0, 83, 48, + 50, 49, 45, 151, 0, 240, 239, 0, 0, 0, + 48, 50, 49, 152, 0, 0, 0, 153, 0, 0, + 0, 0, 0, 0, 0, 45, 154, 0, 155, 0, + 0, 308, 0, 0, 0, 0, 45, 0, 0, 156, + 0, 157, 62, 0, 0, 0, 0, 0, 0, 158, + 30, 31, 159, 63, 0, 0, 0, 0, 160, 0, + 33, 0, 0, 151, 161, 0, 0, 34, 0, 0, + 0, 35, 36, 152, 37, 0, 0, 153, 0, 0, + 162, 41, 0, 0, 0, 44, 154, 0, 155, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 156, + 0, 157, 62, 51, 48, 50, 49, 0, 52, 158, + 0, 0, 159, 63, 0, 0, 0, 0, 160, 43, + 54, 32, 0, 0, 161, 40, 0, 0, 0, 0, + 45, 0, 0, 0, 30, 31, 0, 0, 0, 0, + 162, 0, 0, 0, 33, 0, 0, 0, 0, 0, + 0, 34, 0, 0, 0, 35, 36, 0, 37, 0, + 0, 0, 30, 31, 0, 41, 0, 0, 0, 44, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, + 0, 0, 0, 35, 36, 0, 37, 51, 48, 50, + 49, 0, 52, 503, 0, 0, 0, 44, 0, 0, + 0, 0, 0, 43, 54, 32, 0, 0, 0, 40, + 0, 0, 0, 0, 45, 51, 48, 50, 49, 0, + 52, 0, 0, 0, 30, 31, 0, 0, 0, 0, + 0, 43, 54, 32, 33, 0, 0, 40, 0, 0, + 0, 34, 45, 0, 0, 35, 36, 0, 37, 0, + 0, 0, 30, 31, 0, 41, 0, 0, 0, 44, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, + 0, 0, 0, 35, 36, 0, 37, 51, 48, 50, + 49, 0, 52, 503, 0, 0, 0, 44, 0, 0, + 0, 0, 0, 43, 54, 32, 0, 0, 0, 40, + 0, 0, 0, 0, 45, 51, 48, 50, 49, 0, + 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, + 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 30, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, + 0, 0, 0, 35, 36, 0, 37, 0, 0, 0, + 0, 0, 0, 503, 0, 0, 0, 44, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 51, 48, 50, 49, 0, + 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, + 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 502, 0, 30, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, + 0, 34, 0, 0, 0, 35, 36, 0, 37, 0, + 0, 0, 0, 0, 0, 503, 0, 0, 0, 44, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 51, 504, 506, + 505, 0, 52, 0, 0, 0, 0, 226, 0, 0, + 0, 0, 0, 43, 54, 32, 210, 0, 0, 40, + 0, 0, 0, 0, 45, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 502, 0, 30, 31, 0, 0, + 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, + 0, 0, 0, 34, 0, 0, 0, 35, 36, 0, + 37, 0, 0, 0, 0, 0, 0, 503, 0, 0, + 0, 44, 0, 0, 0, 0, 0, 0, 0, 547, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, + 504, 506, 505, 0, 52, 0, 0, 0, 0, 226, + 0, 0, 0, 0, 0, 43, 54, 32, 210, 0, + 0, 40, 0, 0, 0, 0, 45, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 502, 0, 30, 31, + 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, + 0, 0, 0, 0, 0, 34, 0, 0, 0, 35, + 36, 0, 37, 0, 0, 0, 0, 0, 0, 503, + 0, 0, 0, 44, 0, 0, 0, 0, 0, 0, + 0, 550, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 51, 504, 506, 505, 0, 52, 0, 0, 0, + 0, 226, 0, 0, 0, 0, 0, 43, 54, 32, + 210, 0, 0, 40, 0, 0, 0, 0, 45, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, + 35, 36, 0, 37, 0, 0, 0, 38, 0, 39, + 41, 42, 0, 0, 44, 0, 0, 0, 46, 0, + 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 51, 48, 50, 49, 0, 52, 0, 53, + 0, 55, 0, 56, 0, 0, 0, 0, 43, 54, + 32, 0, 0, 0, 40, 0, 0, 0, 0, 45, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 0, 0, 34, 0, 0, + 0, 35, 36, 0, 37, 0, 0, 0, 38, 0, + 39, 41, 42, 0, 0, 44, 0, 0, 0, 46, + 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 51, 48, 50, 49, 0, 52, 0, + 53, 0, 55, 271, 56, 0, 0, 0, 0, 43, + 54, 32, 0, 0, 0, 40, 0, 0, 0, 0, + 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -122, 0, 0, 0, 29, 30, 31, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, + 0, 0, 34, 0, 0, 0, 35, 36, 0, 37, + 0, 0, 0, 38, 0, 39, 41, 42, 0, 0, + 44, 0, 0, 0, 46, 0, 47, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 51, 48, + 50, 49, 0, 52, 0, 53, 0, 55, 0, 56, + 0, 0, 0, 0, 43, 54, 32, 0, 0, 0, + 40, 0, 0, 0, 0, 45, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 483, 0, 0, 29, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, + 35, 36, 0, 37, 0, 0, 0, 38, 0, 39, + 41, 42, 0, 0, 44, 0, 0, 0, 46, 0, + 47, 0, 0, 486, 0, 0, 0, 0, 0, 0, + 0, 0, 51, 48, 50, 49, 0, 52, 0, 53, + 0, 55, 0, 56, 0, 0, 0, 0, 43, 54, + 32, 0, 0, 0, 40, 0, 0, 0, 0, 45, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 475, + 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, + 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, + 34, 0, 0, 0, 35, 36, 0, 37, 0, 0, + 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, + 0, 0, 46, 0, 47, 0, 0, 481, 0, 0, + 0, 0, 0, 0, 0, 0, 51, 48, 50, 49, + 0, 52, 0, 53, 0, 55, 0, 56, 0, 0, + 0, 0, 43, 54, 32, 0, 0, 0, 40, 0, + 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 483, 0, 0, 29, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, + 0, 0, 0, 0, 34, 0, 0, 0, 35, 36, + 0, 37, 0, 0, 0, 38, 0, 39, 41, 42, + 0, 0, 44, 0, 0, 0, 46, 0, 47, 0, + 0, 484, 0, 0, 0, 0, 0, 0, 0, 0, + 51, 48, 50, 49, 0, 52, 0, 53, 0, 55, + 0, 56, 0, 0, 0, 0, 43, 54, 32, 0, + 0, 0, 40, 0, 0, 0, 0, 45, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 475, 0, 0, + 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 0, 0, 0, 0, 0, 0, 34, 0, + 0, 0, 35, 36, 0, 37, 0, 0, 0, 38, + 0, 39, 41, 42, 0, 0, 44, 0, 0, 0, + 46, 0, 47, 0, 0, 476, 0, 0, 0, 0, + 0, 0, 0, 0, 51, 48, 50, 49, 0, 52, + 0, 53, 0, 55, 0, 56, 0, 0, 0, 0, + 43, 54, 32, 0, 0, 0, 40, 0, 0, 0, + 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 34, + 217, 0, 0, 218, 36, 0, 37, 0, 0, 0, + 38, 0, 39, 41, 42, 0, 0, 44, 0, 0, + 0, 46, 0, 47, 0, 0, 0, 0, 0, 0, + 0, 221, 0, 0, 0, 51, 48, 50, 49, 223, + 52, 0, 53, 225, 55, 0, 56, 0, 228, 0, + 0, 43, 54, 32, 0, 0, 0, 40, 0, 0, + 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, + 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, + 34, 217, 0, 0, 582, 583, 0, 37, 0, 0, + 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, + 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 221, 0, 0, 0, 51, 48, 50, 49, + 223, 52, 0, 53, 225, 55, 0, 56, 0, 228, + 0, 0, 43, 54, 32, 0, 0, 0, 40, 0, + 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 109, 110, 111, 0, 0, 113, 115, + 116, 0, 0, 117, 0, 118, 0, 0, 0, 120, + 121, 122, 0, 0, 0, 0, 0, 0, 34, 123, + 124, 125, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 126, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 129, 0, + 0, 0, 0, 0, 0, 48, 50, 49, 130, 131, + 132, 0, 134, 135, 136, 137, 138, 139, 0, 0, + 127, 133, 119, 112, 114, 128, 0, 0, 0, 0, + 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 109, 110, 111, 0, 0, 113, 115, 116, 0, + 0, 117, 0, 118, 0, 0, 0, 120, 121, 122, + 0, 0, 0, 0, 0, 0, 393, 123, 124, 125, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 126, 0, 0, 0, 394, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 129, 0, 0, 0, + 0, 0, 398, 395, 397, 0, 130, 131, 132, 0, + 134, 135, 136, 137, 138, 139, 0, 0, 127, 133, + 119, 112, 114, 128, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, + 110, 111, 0, 0, 113, 115, 116, 0, 0, 117, + 0, 118, 0, 0, 0, 120, 121, 122, 0, 0, + 0, 0, 0, 0, 393, 123, 124, 125, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 126, 0, + 0, 0, 394, 0, 0, 0, 0, 0, 0, 0, + 396, 0, 0, 0, 129, 0, 0, 0, 0, 0, + 398, 395, 397, 0, 130, 131, 132, 0, 134, 135, + 136, 137, 138, 139, 0, 0, 127, 133, 119, 112, + 114, 128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 209, 0, 0, + 0, 0, 211, 0, 29, 30, 31, 213, 0, 0, + 0, 0, 0, 0, 214, 33, 0, 0, 0, 0, + 0, 0, 216, 217, 0, 0, 218, 36, 0, 37, + 0, 0, 0, 38, 0, 39, 41, 42, 0, 0, + 44, 0, 0, 0, 46, 0, 47, 0, 0, 0, + 0, 0, 220, 0, 221, 0, 0, 0, 51, 219, + 222, 49, 223, 52, 224, 53, 225, 55, 226, 56, + 227, 228, 0, 0, 43, 54, 32, 210, 212, 0, + 40, 0, 0, 0, 0, 45, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 209, 0, 0, 0, 0, + 211, 0, 29, 30, 31, 213, 0, 0, 0, 0, + 0, 0, 214, 215, 0, 0, 0, 0, 0, 0, + 216, 217, 0, 0, 218, 36, 0, 37, 0, 0, + 0, 38, 0, 39, 41, 42, 0, 0, 44, 0, + 0, 0, 46, 0, 47, 0, 0, 0, 0, 0, + 220, 0, 221, 0, 0, 0, 51, 219, 222, 49, + 223, 52, 224, 53, 225, 55, 226, 56, 227, 228, + 0, 0, 43, 54, 32, 210, 212, 0, 40, 0, + 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 586, 110, 111, 0, 0, 588, 115, + 590, 30, 31, 591, 0, 118, 0, 0, 0, 120, + 593, 594, 0, 0, 0, 0, 0, 0, 595, 596, + 124, 125, 218, 36, 0, 37, 0, 0, 0, 38, + 0, 39, 597, 42, 0, 0, 599, 0, 0, 0, + 46, 0, 47, 0, 0, 0, 0, 0, 601, 0, + 221, 0, 0, 0, 603, 600, 602, 49, 604, 605, + 606, 53, 608, 609, 610, 611, 612, 613, 0, 0, + 598, 607, 592, 587, 589, 128, 40, 0, 0, 0, + 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 361, 110, 111, 0, 0, 363, 115, 365, 30, + 31, 366, 0, 118, 0, 0, 0, 120, 368, 369, + 0, 0, 0, 0, 0, 0, 370, 371, 124, 125, + 218, 36, 0, 37, 0, 0, 0, 38, 0, 39, + 372, 42, 0, 0, 374, 0, 0, 0, 46, 0, + 47, 0, -268, 0, 0, 0, 376, 0, 221, 0, + 0, 0, 378, 375, 377, 49, 379, 380, 381, 53, + 383, 384, 385, 386, 387, 388, 0, 0, 373, 382, + 367, 362, 364, 128, 40, 0, 0, 0, 0, 45, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 16, 528, 320, 532, 534, 638, 552, 497, 498, 499, + 516, 559, 619, 461, 515, 574, 302, 472, 487, 250, + 182, 243, 253, 238, 358, 573, 436, 309, 616, 578, + 571, 618, 439, 562, 627, 182, 150, 641, 307, 250, + 561, 458, 632, 447, 454, 243, 238, 450, 402, 445, + 238, 449, 237, 460, 243, 148, 353, 351, 250, 186, + 349, 347, 188, 176, 410, 415, 456, 425, 417, 436, + 433, 143, 467, 169, 439, 429, 302, 358, 344, 302, + 392, 400, 390, 182, 171, 358, 237, 336, 163, 482, + 334, 439, 436, 338, 339, 140, 358, 146, 404, 358, + 485, 60, 302, 0, 311, 0, 94, 0, 320, 404, + 0, 302, 0, 0, 0, 0, 0, 0, 60, 60, + 60, 452, 490, 0, 0, 60, 60, 451, 180, 60, + 405, 302, 165, 88, 60, 60, 489, 461, 60, 146, + 285, 405, 90, 60, 178, 146, 60, 89, 451, 60, + 407, 60, 60, 266, 452, 60, 186, 60, 270, 102, + 288, 501, 60, 100, 642, 60, 60, 284, 494, 60, + 95, 330, 60, 168, 286, 60, 432, 287, 61, 435, + 332, 329, 60, 60, 60, 60, 0, 302, 98, 97, + 96, 77, 60, 60, 451, 452, 501, 60, 480, 540, + 303, 60, 479, 180, 60, 72, 404, 70, 471, 106, + 60, 0, 67, 60, 60, 68, 69, 60, 60, 180, + 493, 60, 60, 60, 492, 491, 93, 60, 60, 60, + 501, 106, 92, 91, 84, 108, 0, 617, 405, 298, + 60, 341, 0, 60, 270, 270, 60, 0, 270, 0, + 0, 270, 273, 0, 0, 313, 305, 108, 175, 293, + 60, 326, 0, 60, 0, 270, 60, 289, 270, 60, + 290, 270, 298, 278, 270, 0, 60, 270, 0, 0, + 295, 270, 60, 291, 298, 298, 298, 270, 548, 270, + 270, 270, 556, 501, 319, 540, 501, 614, 0, 316, + 509, 501, 0, 509, 544, 0, 297, 300, 317, 0, + 0, 0, 500, 510, 0, 500, 510, 0, 472, 520, + 521, 522, 523, 527, 524, 525, 564, 520, 521, 522, + 523, 527, 524, 525, 556, 0, 0, 0, 0, 0, + 0, 557, 558, 520, 521, 522, 523, 527, 524, 525, + 581, 0, 0, 0, 0, 0, 0, 584, 585, 520, + 521, 522, 523, 527, 524, 525, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 551, 0, 0, 0, 0, + 0, 0, 0, 501, 0, 0, 0, 0, 0, 0, + 509, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 500, 510, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 +}; + +const short QmlJSGrammar::action_check [] = { + 8, 36, 7, 7, 7, 36, 7, 7, 7, 60, + 7, 36, 60, 33, 55, 33, 7, 34, 16, 8, + 36, 55, 24, 17, 37, 55, 7, 7, 7, 5, + 7, 55, 7, 7, 5, 7, 20, 33, 7, 7, + 7, 36, 1, 36, 36, 33, 36, 29, 60, 36, + 36, 36, 90, 31, 60, 66, 66, 7, 5, 7, + 33, 2, 8, 33, 8, 48, 8, 33, 7, 33, + 33, 36, 7, 33, 1, 36, 7, 2, 7, 36, + 8, 7, 1, 36, 0, 36, 48, 17, 8, 1, + -1, 36, -1, 8, 7, 33, 6, -1, -1, 36, + 8, 10, 60, -1, -1, 61, 60, 7, 8, 8, + 20, 60, 48, 8, 48, 55, -1, 60, 36, 8, + 8, 8, -1, -1, 79, 8, 8, 79, 61, -1, + 15, -1, 8, 8, -1, -1, 50, 42, 61, 60, + 54, 56, 8, 8, 61, 62, 55, 79, 53, 34, + 61, 62, 60, 77, 61, 62, 40, 61, 62, 61, + 62, 60, 8, 61, 62, 60, -1, 51, 90, 61, + 62, 60, 60, 60, 15, 61, 62, 60, 50, 61, + 56, 56, 54, 61, 62, 40, 40, 61, 62, 2, + 56, 40, 25, 34, 27, 60, 51, 51, 15, 25, + 12, 27, 51, 12, 29, 38, 29, 25, -1, 27, + 56, 25, 38, 27, 25, 7, 27, 34, 7, 36, + 38, 25, 8, 27, 38, 15, -1, 38, 29, 7, + 25, 29, 27, 29, 38, 29, -1, 61, 62, 36, + 8, 15, -1, 38, 34, 57, 36, -1, 57, -1, + 75, 63, 75, -1, 63, 33, 12, -1, 8, -1, + 34, 86, 36, 86, 61, 62, -1, 91, -1, 61, + 62, -1, 61, 62, 75, 61, 62, 75, 25, 75, + 27, 75, 25, 15, 27, 86, -1, -1, 86, 7, + 86, 38, 86, 61, 62, 38, 25, 25, 27, 27, + -1, 57, 34, 25, 36, 27, 25, 63, 27, 38, + 38, 61, 62, 47, 92, -1, 38, 29, -1, 38, + 18, 19, 18, 19, 18, 19, 29, 61, 62, 29, + -1, 18, 19, -1, -1, -1, -1, -1, 29, -1, + -1, -1, -1, 61, 62, -1, -1, 45, 46, 45, + 46, 45, 46, -1, 66, 67, 68, 91, 45, 46, + 23, 24, -1, 66, 67, 68, 66, 67, 68, 32, + 29, -1, 35, 29, 37, 66, 67, 68, 29, -1, + 92, 23, 24, 29, 15, 23, 24, -1, 29, 92, + 32, -1, 92, 35, 32, 37, -1, 35, -1, 37, + -1, 92, 33, 34, -1, 36, -1, 66, 67, 68, + 66, 67, 68, -1, -1, 66, 67, 68, -1, -1, + 66, 67, 68, 23, 24, 66, 67, 68, -1, -1, + 23, 24, 32, 92, -1, 35, 92, 37, 29, 32, + -1, 92, 35, 29, 37, 36, 92, -1, -1, -1, + 36, 92, 23, 24, 94, 95, 96, 97, 98, 99, + 31, 32, -1, -1, 35, 29, 37, -1, -1, -1, + -1, 29, -1, -1, -1, 66, 67, 68, -1, 29, + 66, 67, 68, -1, -1, -1, -1, 29, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 61, 62, 29, + -1, 92, 66, 67, 68, -1, 92, -1, 66, 67, + 68, 61, 62, -1, -1, -1, 66, 67, 68, 61, + 62, -1, 29, -1, 66, 67, 68, -1, 92, -1, + -1, 61, 62, 29, 92, -1, 66, 67, 68, -1, + -1, -1, 92, -1, 23, 24, -1, -1, -1, -1, + 92, -1, 31, 32, 61, 62, 35, -1, 37, 66, + 67, 68, 92, 3, -1, 61, 62, -1, -1, -1, + 66, 67, 68, 13, -1, -1, -1, 17, -1, -1, + -1, -1, -1, -1, -1, 92, 26, -1, 28, -1, + -1, 31, -1, -1, -1, -1, 92, -1, -1, 39, + -1, 41, 42, -1, -1, -1, -1, -1, -1, 49, + 12, 13, 52, 53, -1, -1, -1, -1, 58, -1, + 22, -1, -1, 3, 64, -1, -1, 29, -1, -1, + -1, 33, 34, 13, 36, -1, -1, 17, -1, -1, + 80, 43, -1, -1, -1, 47, 26, -1, 28, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, + -1, 41, 42, 65, 66, 67, 68, -1, 70, 49, + -1, -1, 52, 53, -1, -1, -1, -1, 58, 81, + 82, 83, -1, -1, 64, 87, -1, -1, -1, -1, + 92, -1, -1, -1, 12, 13, -1, -1, -1, -1, + 80, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, + -1, -1, 12, 13, -1, 43, -1, -1, -1, 47, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, 65, 66, 67, + 68, -1, 70, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, + -1, -1, -1, -1, 92, 65, 66, 67, 68, -1, + 70, -1, -1, -1, 12, 13, -1, -1, -1, -1, + -1, 81, 82, 83, 22, -1, -1, 87, -1, -1, + -1, 29, 92, -1, -1, 33, 34, -1, 36, -1, + -1, -1, 12, 13, -1, 43, -1, -1, -1, 47, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, 65, 66, 67, + 68, -1, 70, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, + -1, -1, -1, -1, 92, 65, 66, 67, 68, -1, + 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, + -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, + 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, + -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 10, -1, 12, 13, -1, -1, -1, -1, + -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, + -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, + 68, -1, 70, -1, -1, -1, -1, 75, -1, -1, + -1, -1, -1, 81, 82, 83, 84, -1, -1, 87, + -1, -1, -1, -1, 92, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 10, -1, 12, 13, -1, -1, + -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, + -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, + 36, -1, -1, -1, -1, -1, -1, 43, -1, -1, + -1, 47, -1, -1, -1, -1, -1, -1, -1, 55, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, + 66, 67, 68, -1, 70, -1, -1, -1, -1, 75, + -1, -1, -1, -1, -1, 81, 82, 83, 84, -1, + -1, 87, -1, -1, -1, -1, 92, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 10, -1, 12, 13, + -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, + -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, + 34, -1, 36, -1, -1, -1, -1, -1, -1, 43, + -1, -1, -1, 47, -1, -1, -1, -1, -1, -1, + -1, 55, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 65, 66, 67, 68, -1, 70, -1, -1, -1, + -1, 75, -1, -1, -1, -1, -1, 81, 82, 83, + 84, -1, -1, 87, -1, -1, -1, -1, 92, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, + -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, 92, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, + 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, + -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, + 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, + -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, + 72, -1, 74, 75, 76, -1, -1, -1, -1, 81, + 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, + 92, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, -1, -1, -1, 11, 12, 13, -1, -1, -1, + -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, + -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, + 67, 68, -1, 70, -1, 72, -1, 74, -1, 76, + -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, + 87, -1, -1, -1, -1, 92, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, + -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, 92, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, + -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, 56, -1, -1, + -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, + -1, 70, -1, 72, -1, 74, -1, 76, -1, -1, + -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, + -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, + -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, + -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, + -1, -1, 87, -1, -1, -1, -1, 92, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, + 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, + -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, + -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, + -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, + 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, + -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, + -1, 72, -1, 74, -1, 76, -1, -1, -1, -1, + 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, + -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + 30, -1, -1, 33, 34, -1, 36, -1, -1, -1, + 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, + -1, 51, -1, 53, -1, -1, -1, -1, -1, -1, + -1, 61, -1, -1, -1, 65, 66, 67, 68, 69, + 70, -1, 72, 73, 74, -1, 76, -1, 78, -1, + -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, + -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, + -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, + 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, + -1, -1, 61, -1, -1, -1, 65, 66, 67, 68, + 69, 70, -1, 72, 73, 74, -1, 76, -1, 78, + -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, + -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, + 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, + 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, + 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 43, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, + -1, -1, -1, -1, -1, 66, 67, 68, 69, 70, + 71, -1, 73, 74, 75, 76, 77, 78, -1, -1, + 81, 82, 83, 84, 85, 86, -1, -1, -1, -1, + -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, + -1, 14, -1, 16, -1, -1, -1, 20, 21, 22, + -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, + -1, -1, 65, 66, 67, -1, 69, 70, 71, -1, + 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, + 83, 84, 85, 86, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, + 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, + -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, + -1, -1, -1, -1, 29, 30, 31, 32, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, + -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, + 55, -1, -1, -1, 59, -1, -1, -1, -1, -1, + 65, 66, 67, -1, 69, 70, 71, -1, 73, 74, + 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, + 85, 86, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, + -1, -1, 9, -1, 11, 12, 13, 14, -1, -1, + -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, + -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, + -1, -1, 59, -1, 61, -1, -1, -1, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, -1, -1, 81, 82, 83, 84, 85, -1, + 87, -1, -1, -1, -1, 92, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, + 9, -1, 11, 12, 13, 14, -1, -1, -1, -1, + -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, + 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, + 59, -1, 61, -1, -1, -1, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + -1, -1, 81, 82, 83, 84, 85, -1, 87, -1, + -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, + 11, 12, 13, 14, -1, 16, -1, -1, -1, 20, + 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, + 31, 32, 33, 34, -1, 36, -1, -1, -1, 40, + -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, + 51, -1, 53, -1, -1, -1, -1, -1, 59, -1, + 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, -1, -1, + 81, 82, 83, 84, 85, 86, 87, -1, -1, -1, + -1, 92, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 4, 5, 6, -1, -1, 9, 10, 11, 12, + 13, 14, -1, 16, -1, -1, -1, 20, 21, 22, + -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, 55, -1, -1, -1, 59, -1, 61, -1, + -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, + 83, 84, 85, 86, 87, -1, -1, -1, -1, 92, + -1, -1, -1, -1, -1, -1, -1, -1, -1, + + 3, 13, 15, 29, 15, 15, 15, 105, 4, 2, + 15, 19, 9, 15, 29, 15, 3, 39, 3, 2, + 15, 15, 3, 15, 2, 29, 3, 3, 19, 15, + 29, 19, 22, 15, 13, 15, 71, 11, 2, 2, + 29, 3, 15, 15, 3, 15, 15, 22, 2, 99, + 15, 22, 4, 2, 15, 39, 2, 2, 2, 15, + 3, 2, 15, 3, 2, 2, 2, 97, 3, 3, + 3, 39, 39, 39, 22, 94, 3, 2, 101, 3, + 40, 39, 39, 15, 39, 2, 4, 3, 39, 39, + 2, 22, 3, 2, 15, 3, 2, 39, 13, 2, + 39, 48, 3, -1, 2, -1, 53, -1, 15, 13, + -1, 3, -1, -1, -1, -1, -1, -1, 48, 48, + 48, 50, 50, -1, -1, 48, 48, 50, 50, 48, + 45, 3, 62, 52, 48, 48, 50, 15, 48, 39, + 53, 45, 52, 48, 44, 39, 48, 52, 50, 48, + 44, 48, 48, 48, 50, 48, 15, 48, 53, 58, + 53, 13, 48, 60, 16, 48, 48, 53, 50, 48, + 53, 72, 48, 64, 53, 48, 82, 53, 51, 82, + 72, 88, 48, 48, 48, 48, -1, 3, 54, 54, + 54, 54, 48, 48, 50, 50, 13, 48, 35, 16, + 72, 48, 39, 50, 48, 56, 13, 51, 86, 15, + 48, -1, 50, 48, 48, 50, 50, 48, 48, 50, + 50, 48, 48, 48, 50, 50, 53, 48, 48, 48, + 13, 15, 53, 53, 53, 41, -1, 20, 45, 48, + 48, 100, -1, 48, 53, 53, 48, -1, 53, -1, + -1, 53, 57, -1, -1, 63, 72, 41, 42, 61, + 48, 70, -1, 48, -1, 53, 48, 55, 53, 48, + 55, 53, 48, 55, 53, -1, 48, 53, -1, -1, + 59, 53, 48, 55, 48, 48, 48, 53, 5, 53, + 53, 53, 13, 13, 70, 16, 13, 18, -1, 65, + 20, 13, -1, 20, 16, -1, 70, 70, 70, -1, + -1, -1, 32, 33, -1, 32, 33, -1, 39, 22, + 23, 24, 25, 26, 27, 28, 21, 22, 23, 24, + 25, 26, 27, 28, 13, -1, -1, -1, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 13, -1, -1, -1, -1, -1, -1, 20, 21, 22, + 23, 24, 25, 26, 27, 28, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 5, -1, -1, -1, -1, + -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, + 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 32, 33, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1 +}; + +} // end of namespace QbsQmlJS diff --git a/src/lib/corelib/parser/qmljsgrammar_p.h b/src/lib/corelib/parser/qmljsgrammar_p.h new file mode 100644 index 00000000..aa41562d --- /dev/null +++ b/src/lib/corelib/parser/qmljsgrammar_p.h @@ -0,0 +1,210 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// This file was generated by qlalr - DO NOT EDIT! +#ifndef QMLJSGRAMMAR_P_H +#define QMLJSGRAMMAR_P_H + +#include + +namespace QbsQmlJS { + +class QmlJSGrammar +{ +public: + enum VariousConstants { + EOF_SYMBOL = 0, + REDUCE_HERE = 101, + SHIFT_THERE = 100, + T_AND = 1, + T_AND_AND = 2, + T_AND_EQ = 3, + T_AS = 91, + T_AUTOMATIC_SEMICOLON = 62, + T_BREAK = 4, + T_CASE = 5, + T_CATCH = 6, + T_COLON = 7, + T_COMMA = 8, + T_COMMENT = 88, + T_CONST = 84, + T_CONTINUE = 9, + T_DEBUGGER = 85, + T_DEFAULT = 10, + T_DELETE = 11, + T_DIVIDE_ = 12, + T_DIVIDE_EQ = 13, + T_DO = 14, + T_DOT = 15, + T_ELSE = 16, + T_EQ = 17, + T_EQ_EQ = 18, + T_EQ_EQ_EQ = 19, + T_ERROR = 93, + T_FALSE = 83, + T_FEED_JS_EXPRESSION = 97, + T_FEED_JS_PROGRAM = 99, + T_FEED_JS_SOURCE_ELEMENT = 98, + T_FEED_JS_STATEMENT = 96, + T_FEED_UI_OBJECT_MEMBER = 95, + T_FEED_UI_PROGRAM = 94, + T_FINALLY = 20, + T_FOR = 21, + T_FUNCTION = 22, + T_GE = 23, + T_GT = 24, + T_GT_GT = 25, + T_GT_GT_EQ = 26, + T_GT_GT_GT = 27, + T_GT_GT_GT_EQ = 28, + T_IDENTIFIER = 29, + T_IF = 30, + T_IMPORT = 90, + T_IN = 31, + T_INSTANCEOF = 32, + T_LBRACE = 33, + T_LBRACKET = 34, + T_LE = 35, + T_LPAREN = 36, + T_LT = 37, + T_LT_LT = 38, + T_LT_LT_EQ = 39, + T_MINUS = 40, + T_MINUS_EQ = 41, + T_MINUS_MINUS = 42, + T_MULTILINE_STRING_LITERAL = 87, + T_NEW = 43, + T_NOT = 44, + T_NOT_EQ = 45, + T_NOT_EQ_EQ = 46, + T_NULL = 81, + T_NUMERIC_LITERAL = 47, + T_ON = 92, + T_OR = 48, + T_OR_EQ = 49, + T_OR_OR = 50, + T_PLUS = 51, + T_PLUS_EQ = 52, + T_PLUS_PLUS = 53, + T_PROPERTY = 66, + T_PUBLIC = 89, + T_QUESTION = 54, + T_RBRACE = 55, + T_RBRACKET = 56, + T_READONLY = 68, + T_REMAINDER = 57, + T_REMAINDER_EQ = 58, + T_RESERVED_WORD = 86, + T_RETURN = 59, + T_RPAREN = 60, + T_SEMICOLON = 61, + T_SIGNAL = 67, + T_STAR = 63, + T_STAR_EQ = 64, + T_STRING_LITERAL = 65, + T_SWITCH = 69, + T_THIS = 70, + T_THROW = 71, + T_TILDE = 72, + T_TRUE = 82, + T_TRY = 73, + T_TYPEOF = 74, + T_VAR = 75, + T_VOID = 76, + T_WHILE = 77, + T_WITH = 78, + T_XOR = 79, + T_XOR_EQ = 80, + + ACCEPT_STATE = 644, + RULE_COUNT = 349, + STATE_COUNT = 645, + TERMINAL_COUNT = 102, + NON_TERMINAL_COUNT = 107, + + GOTO_INDEX_OFFSET = 645, + GOTO_INFO_OFFSET = 2789, + GOTO_CHECK_OFFSET = 2789 + }; + + static const char *const spell[]; + static const short lhs[]; + static const short rhs[]; + static const short goto_default[]; + static const short action_default[]; + static const short action_index[]; + static const short action_info[]; + static const short action_check[]; + + static inline int nt_action (int state, int nt) + { + const int yyn = action_index [GOTO_INDEX_OFFSET + state] + nt; + if (yyn < 0 || action_check [GOTO_CHECK_OFFSET + yyn] != nt) + return goto_default [nt]; + + return action_info [GOTO_INFO_OFFSET + yyn]; + } + + static inline int t_action (int state, int token) + { + const int yyn = action_index [state] + token; + + if (yyn < 0 || action_check [yyn] != token) + return - action_default [state]; + + return action_info [yyn]; + } +}; + + +} // namespace QbsQmlJS + +#endif // QMLJSGRAMMAR_P_H + diff --git a/src/lib/corelib/parser/qmljskeywords_p.h b/src/lib/corelib/parser/qmljskeywords_p.h new file mode 100644 index 00000000..77abdada --- /dev/null +++ b/src/lib/corelib/parser/qmljskeywords_p.h @@ -0,0 +1,862 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSKEYWORDS_P_H +#define QMLJSKEYWORDS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +namespace QbsQmlJS { + +static inline int classify2(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 's') { + return qmlMode ? Lexer::T_AS : Lexer::T_RESERVED_WORD; + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'o') { + return Lexer::T_DO; + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'f') { + return Lexer::T_IF; + } + else if (s[1].unicode() == 'n') { + return Lexer::T_IN; + } + } + else if (qmlMode && s[0].unicode() == 'o') { + if (s[1].unicode() == 'n') { + return Lexer::T_ON; + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify3(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'r') { + return Lexer::T_FOR; + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + return Lexer::T_INT; + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'w') { + return Lexer::T_NEW; + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'y') { + return Lexer::T_TRY; + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'r') { + return Lexer::T_VAR; + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify4(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + return Lexer::T_BYTE; + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_CASE; + } + } + } + else if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'r') { + return Lexer::T_CHAR; + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'l') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 'e') { + return Lexer::T_ELSE; + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'm') { + return Lexer::T_ENUM; + } + } + } + } + else if (s[0].unicode() == 'g') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'o') { + return Lexer::T_GOTO; + } + } + } + } + else if (s[0].unicode() == 'l') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'g') { + return Lexer::T_LONG; + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'l') { + return Lexer::T_NULL; + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 's') { + return Lexer::T_THIS; + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'e') { + return Lexer::T_TRUE; + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'd') { + return Lexer::T_VOID; + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'h') { + return Lexer::T_WITH; + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify5(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'e') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'k') { + return Lexer::T_BREAK; + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + return Lexer::T_CATCH; + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 's') { + return Lexer::T_CLASS; + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 't') { + return Lexer::T_CONST; + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 's') { + if (s[4].unicode() == 'e') { + return Lexer::T_FALSE; + } + } + } + } + else if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + return Lexer::T_FINAL; + } + } + } + } + else if (s[1].unicode() == 'l') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + return Lexer::T_FLOAT; + } + } + } + } + } + else if (s[0].unicode() == 's') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'r') { + if (s[4].unicode() == 't') { + return Lexer::T_SHORT; + } + } + } + } + else if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + return Lexer::T_SUPER; + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + return Lexer::T_THROW; + } + } + } + } + } + else if (s[0].unicode() == 'w') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + return Lexer::T_WHILE; + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify6(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'e') { + return Lexer::T_DELETE; + } + } + } + } + } + else if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'u') { + if (s[3].unicode() == 'b') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'e') { + return Lexer::T_DOUBLE; + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return Lexer::T_EXPORT; + } + } + } + } + } + } + else if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 't') { + return qmlMode ? Lexer::T_IMPORT : Lexer::T_RESERVED_WORD; + } + } + } + } + } + } + else if (s[0].unicode() == 'n') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'i') { + if (s[4].unicode() == 'v') { + if (s[5].unicode() == 'e') { + return Lexer::T_NATIVE; + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return qmlMode ? Lexer::T_PUBLIC : Lexer::T_RESERVED_WORD; + } + } + } + } + } + } + else if (s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'n') { + return Lexer::T_RETURN; + } + } + } + } + } + } + else if (s[0].unicode() == 's') { + if (qmlMode && s[1].unicode() == 'i') { + if (s[2].unicode() == 'g') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'l') { + return Lexer::T_SIGNAL; + } + } + } + } + } + else if (s[1].unicode() == 't') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'c') { + return Lexer::T_STATIC; + } + } + } + } + } + else if (s[1].unicode() == 'w') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'c') { + if (s[5].unicode() == 'h') { + return Lexer::T_SWITCH; + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'h') { + if (s[2].unicode() == 'r') { + if (s[3].unicode() == 'o') { + if (s[4].unicode() == 'w') { + if (s[5].unicode() == 's') { + return Lexer::T_THROWS; + } + } + } + } + } + else if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'f') { + return Lexer::T_TYPEOF; + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify7(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'b') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'n') { + return Lexer::T_BOOLEAN; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'f') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'u') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 't') { + return Lexer::T_DEFAULT; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'e') { + if (s[1].unicode() == 'x') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'n') { + if (s[5].unicode() == 'd') { + if (s[6].unicode() == 's') { + return Lexer::T_EXTENDS; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'i') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 'l') { + if (s[5].unicode() == 'l') { + if (s[6].unicode() == 'y') { + return Lexer::T_FINALLY; + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'a') { + if (s[2].unicode() == 'c') { + if (s[3].unicode() == 'k') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + return Lexer::T_PACKAGE; + } + } + } + } + } + } + else if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'i') { + if (s[3].unicode() == 'v') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 't') { + if (s[6].unicode() == 'e') { + return Lexer::T_PRIVATE; + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify8(const QChar *s, bool qmlMode) { + if (s[0].unicode() == 'a') { + if (s[1].unicode() == 'b') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'a') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 't') { + return Lexer::T_ABSTRACT; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'c') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'i') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'u') { + if (s[7].unicode() == 'e') { + return Lexer::T_CONTINUE; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'd') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'b') { + if (s[3].unicode() == 'u') { + if (s[4].unicode() == 'g') { + if (s[5].unicode() == 'g') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'r') { + return Lexer::T_DEBUGGER; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'f') { + if (s[1].unicode() == 'u') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + return Lexer::T_FUNCTION; + } + } + } + } + } + } + } + } + else if (qmlMode && s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 'p') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'y') { + return Lexer::T_PROPERTY; + } + } + } + } + } + } + } + } + else if (qmlMode && s[0].unicode() == 'r') { + if (s[1].unicode() == 'e') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'd') { + if (s[4].unicode() == 'o') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'y') { + return Lexer::T_READONLY; + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'v') { + if (s[1].unicode() == 'o') { + if (s[2].unicode() == 'l') { + if (s[3].unicode() == 'a') { + if (s[4].unicode() == 't') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'l') { + if (s[7].unicode() == 'e') { + return Lexer::T_VOLATILE; + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify9(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'n') { + if (s[2].unicode() == 't') { + if (s[3].unicode() == 'e') { + if (s[4].unicode() == 'r') { + if (s[5].unicode() == 'f') { + if (s[6].unicode() == 'a') { + if (s[7].unicode() == 'c') { + if (s[8].unicode() == 'e') { + return Lexer::T_INTERFACE; + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 'p') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'o') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'c') { + if (s[6].unicode() == 't') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'd') { + return Lexer::T_PROTECTED; + } + } + } + } + } + } + } + } + } + else if (s[0].unicode() == 't') { + if (s[1].unicode() == 'r') { + if (s[2].unicode() == 'a') { + if (s[3].unicode() == 'n') { + if (s[4].unicode() == 's') { + if (s[5].unicode() == 'i') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + return Lexer::T_TRANSIENT; + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify10(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 'i') { + if (s[1].unicode() == 'm') { + if (s[2].unicode() == 'p') { + if (s[3].unicode() == 'l') { + if (s[4].unicode() == 'e') { + if (s[5].unicode() == 'm') { + if (s[6].unicode() == 'e') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 't') { + if (s[9].unicode() == 's') { + return Lexer::T_IMPLEMENTS; + } + } + } + } + } + } + } + } + } + else if (s[1].unicode() == 'n') { + if (s[2].unicode() == 's') { + if (s[3].unicode() == 't') { + if (s[4].unicode() == 'a') { + if (s[5].unicode() == 'n') { + if (s[6].unicode() == 'c') { + if (s[7].unicode() == 'e') { + if (s[8].unicode() == 'o') { + if (s[9].unicode() == 'f') { + return Lexer::T_INSTANCEOF; + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +static inline int classify12(const QChar *s, bool /*qmlMode*/) { + if (s[0].unicode() == 's') { + if (s[1].unicode() == 'y') { + if (s[2].unicode() == 'n') { + if (s[3].unicode() == 'c') { + if (s[4].unicode() == 'h') { + if (s[5].unicode() == 'r') { + if (s[6].unicode() == 'o') { + if (s[7].unicode() == 'n') { + if (s[8].unicode() == 'i') { + if (s[9].unicode() == 'z') { + if (s[10].unicode() == 'e') { + if (s[11].unicode() == 'd') { + return Lexer::T_SYNCHRONIZED; + } + } + } + } + } + } + } + } + } + } + } + } + return Lexer::T_IDENTIFIER; +} + +int Lexer::classify(const QChar *s, int n, bool qmlMode) { + switch (n) { + case 2: return classify2(s, qmlMode); + case 3: return classify3(s, qmlMode); + case 4: return classify4(s, qmlMode); + case 5: return classify5(s, qmlMode); + case 6: return classify6(s, qmlMode); + case 7: return classify7(s, qmlMode); + case 8: return classify8(s, qmlMode); + case 9: return classify9(s, qmlMode); + case 10: return classify10(s, qmlMode); + case 12: return classify12(s, qmlMode); + default: return Lexer::T_IDENTIFIER; + } // switch +} + +} // namespace QbsQmlJS + +#endif // QMLJSKEYWORDS_P_H diff --git a/src/lib/corelib/parser/qmljslexer.cpp b/src/lib/corelib/parser/qmljslexer.cpp new file mode 100644 index 00000000..684be931 --- /dev/null +++ b/src/lib/corelib/parser/qmljslexer.cpp @@ -0,0 +1,1155 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmljslexer_p.h" +#include "qmljsengine_p.h" +#include "qmljsmemorypool_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +Q_CORE_EXPORT double qstrntod(const char *s00, int len, char const **se, bool *ok); +#else +Q_CORE_EXPORT double qstrntod(const char *s00, qsizetype len, char const **se, bool *ok); +#endif +QT_END_NAMESPACE + +namespace QbsQmlJS { + +static int regExpFlagFromChar(const QChar &ch) +{ + switch (ch.unicode()) { + case 'g': return Lexer::RegExp_Global; + case 'i': return Lexer::RegExp_IgnoreCase; + case 'm': return Lexer::RegExp_Multiline; + } + return 0; +} + +static unsigned char convertHex(ushort c) +{ + if (c >= '0' && c <= '9') + return (c - '0'); + if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + return (c - 'A' + 10); +} + +static QChar convertHex(QChar c1, QChar c2) +{ + return QChar{(convertHex(c1.unicode()) << 4) + convertHex(c2.unicode())}; +} + +static QChar convertUnicode(QChar c1, QChar c2, QChar c3, QChar c4) +{ + return QChar{uchar((convertHex(c3.unicode()) << 4) + convertHex(c4.unicode())), + uchar((convertHex(c1.unicode()) << 4) + convertHex(c2.unicode()))}; +} + +Lexer::Lexer(Engine *engine) + : _engine(engine) + , _codePtr(nullptr) + , _lastLinePtr(nullptr) + , _tokenLinePtr(nullptr) + , _tokenStartPtr(nullptr) + , _char(QLatin1Char('\n')) + , _errorCode(NoError) + , _currentLineNumber(0) + , _tokenValue(0) + , _parenthesesState(IgnoreParentheses) + , _parenthesesCount(0) + , _stackToken(-1) + , _patternFlags(0) + , _tokenKind(0) + , _tokenLength(0) + , _tokenLine(0) + , _validTokenText(false) + , _prohibitAutomaticSemicolon(false) + , _restrictedKeyword(false) + , _terminator(false) + , _followsClosingBrace(false) + , _delimited(true) + , _qmlMode(true) +{ + if (engine) + engine->setLexer(this); +} + +bool Lexer::qmlMode() const +{ + return _qmlMode; +} + +QString Lexer::code() const +{ + return _code; +} + +void Lexer::setCode(const QString &code, int lineno, bool qmlMode) +{ + if (_engine) + _engine->setCode(code); + + _qmlMode = qmlMode; + _code = code; + _tokenText.clear(); + _tokenText.reserve(1024); + _errorMessage.clear(); + _tokenSpell = QStringRef(); + + _codePtr = code.unicode(); + _lastLinePtr = _codePtr; + _tokenLinePtr = _codePtr; + _tokenStartPtr = _codePtr; + + _char = QLatin1Char('\n'); + _errorCode = NoError; + + _currentLineNumber = lineno; + _tokenValue = 0; + + // parentheses state + _parenthesesState = IgnoreParentheses; + _parenthesesCount = 0; + + _stackToken = -1; + + _patternFlags = 0; + _tokenLength = 0; + _tokenLine = lineno; + + _validTokenText = false; + _prohibitAutomaticSemicolon = false; + _restrictedKeyword = false; + _terminator = false; + _followsClosingBrace = false; + _delimited = true; +} + +void Lexer::scanChar() +{ + _char = *_codePtr++; + + if (_char == QLatin1Char('\n')) { + _lastLinePtr = _codePtr; // points to the first character after the newline + ++_currentLineNumber; + } +} + +int Lexer::lex() +{ + const int previousTokenKind = _tokenKind; + + _tokenSpell = QStringRef(); + _tokenKind = scanToken(); + _tokenLength = int(_codePtr - _tokenStartPtr - 1); + + _delimited = false; + _restrictedKeyword = false; + _followsClosingBrace = (previousTokenKind == T_RBRACE); + + // update the flags + switch (_tokenKind) { + case T_LBRACE: + case T_SEMICOLON: + case T_COLON: + _delimited = true; + break; + + case T_IF: + case T_FOR: + case T_WHILE: + case T_WITH: + _parenthesesState = CountParentheses; + _parenthesesCount = 0; + break; + + case T_DO: + _parenthesesState = BalancedParentheses; + break; + + case T_CONTINUE: + case T_BREAK: + case T_RETURN: + case T_THROW: + _restrictedKeyword = true; + break; + } // switch + + // update the parentheses state + switch (_parenthesesState) { + case IgnoreParentheses: + break; + + case CountParentheses: + if (_tokenKind == T_RPAREN) { + --_parenthesesCount; + if (_parenthesesCount == 0) + _parenthesesState = BalancedParentheses; + } else if (_tokenKind == T_LPAREN) { + ++_parenthesesCount; + } + break; + + case BalancedParentheses: + _parenthesesState = IgnoreParentheses; + break; + } // switch + + return _tokenKind; +} + +bool Lexer::isUnicodeEscapeSequence(const QChar *chars) +{ + return isHexDigit(chars[0]) + && isHexDigit(chars[1]) + && isHexDigit(chars[2]) + && isHexDigit(chars[3]); +} + +QChar Lexer::decodeUnicodeEscapeCharacter(bool *ok) +{ + if (_char == QLatin1Char('u') && isUnicodeEscapeSequence(&_codePtr[0])) { + scanChar(); // skip u + + const QChar c1 = _char; + scanChar(); + + const QChar c2 = _char; + scanChar(); + + const QChar c3 = _char; + scanChar(); + + const QChar c4 = _char; + scanChar(); + + if (ok) + *ok = true; + + return convertUnicode(c1, c2, c3, c4); + } + + *ok = false; + return {}; +} + +int Lexer::scanToken() +{ + if (_stackToken != -1) { + int tk = _stackToken; + _stackToken = -1; + return tk; + } + + _terminator = false; + +again: + _validTokenText = false; + _tokenLinePtr = _lastLinePtr; + + while (_char.isSpace()) { + if (_char == QLatin1Char('\n')) { + _tokenLinePtr = _codePtr; + + if (_restrictedKeyword) { + // automatic semicolon insertion + _tokenLine = _currentLineNumber; + _tokenStartPtr = _codePtr - 1; // ### TODO: insert it before the optional \r sequence. + return T_SEMICOLON; + } + _terminator = true; + syncProhibitAutomaticSemicolon(); + } + + scanChar(); + } + + _tokenStartPtr = _codePtr - 1; + _tokenLine = _currentLineNumber; + + if (_char.isNull()) + return EOF_SYMBOL; + + const QChar ch = _char; + scanChar(); + + switch (ch.unicode()) { + case '~': return T_TILDE; + case '}': return T_RBRACE; + + case '|': + if (_char == QLatin1Char('|')) { + scanChar(); + return T_OR_OR; + } else if (_char == QLatin1Char('=')) { + scanChar(); + return T_OR_EQ; + } + return T_OR; + + case '{': return T_LBRACE; + + case '^': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_XOR_EQ; + } + return T_XOR; + + case ']': return T_RBRACKET; + case '[': return T_LBRACKET; + case '?': return T_QUESTION; + + case '>': + if (_char == QLatin1Char('>')) { + scanChar(); + if (_char == QLatin1Char('>')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_GT_GT_GT_EQ; + } + return T_GT_GT_GT; + } + if (_char == QLatin1Char('=')) { + scanChar(); + return T_GT_GT_EQ; + } + return T_GT_GT; + } else if (_char == QLatin1Char('=')) { + scanChar(); + return T_GE; + } + return T_GT; + + case '=': + if (_char == QLatin1Char('=')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_EQ_EQ_EQ; + } + return T_EQ_EQ; + } + return T_EQ; + + case '<': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_LE; + } else if (_char == QLatin1Char('<')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_LT_LT_EQ; + } + return T_LT_LT; + } + return T_LT; + + case ';': return T_SEMICOLON; + case ':': return T_COLON; + + case '/': + if (_char == QLatin1Char('*')) { + scanChar(); + while (!_char.isNull()) { + if (_char == QLatin1Char('*')) { + scanChar(); + if (_char == QLatin1Char('/')) { + scanChar(); + + if (_engine) { + _engine->addComment(tokenOffset() + 2, + int(_codePtr - _tokenStartPtr - 1 - 4), + tokenStartLine(), tokenStartColumn() + 2); + } + + goto again; + } + } else { + scanChar(); + } + } + } else if (_char == QLatin1Char('/')) { + while (!_char.isNull() && _char != QLatin1Char('\n')) { + scanChar(); + } + if (_engine) { + _engine->addComment(tokenOffset() + 2, int(_codePtr - _tokenStartPtr - 1 - 2), + tokenStartLine(), tokenStartColumn() + 2); + } + goto again; + } if (_char == QLatin1Char('=')) { + scanChar(); + return T_DIVIDE_EQ; + } + return T_DIVIDE_; + + case '.': + if (_char.isDigit()) { + QVarLengthArray chars; + + chars.append(ch.unicode()); // append the `.' + + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); + } + + if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { + if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && + _codePtr[1].isDigit())) { + + chars.append(_char.unicode()); + scanChar(); // consume `e' + + if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { + chars.append(_char.unicode()); + scanChar(); // consume the sign + } + + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); + } + } + } + + const char *begin = chars.constData(); + const char *end = nullptr; + bool ok = false; + + _tokenValue = qstrntod(begin, chars.size(), &end, &ok); + + if (end - begin != chars.size()) { + _errorCode = IllegalExponentIndicator; + _errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number"); + return T_ERROR; + } + + return T_NUMERIC_LITERAL; + } + return T_DOT; + + case '-': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_MINUS_EQ; + } else if (_char == QLatin1Char('-')) { + scanChar(); + + if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { + _stackToken = T_MINUS_MINUS; + return T_SEMICOLON; + } + + return T_MINUS_MINUS; + } + return T_MINUS; + + case ',': return T_COMMA; + + case '+': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_PLUS_EQ; + } else if (_char == QLatin1Char('+')) { + scanChar(); + + if (_terminator && !_delimited && !_prohibitAutomaticSemicolon) { + _stackToken = T_PLUS_PLUS; + return T_SEMICOLON; + } + + return T_PLUS_PLUS; + } + return T_PLUS; + + case '*': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_STAR_EQ; + } + return T_STAR; + + case ')': return T_RPAREN; + case '(': return T_LPAREN; + + case '&': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_AND_EQ; + } else if (_char == QLatin1Char('&')) { + scanChar(); + return T_AND_AND; + } + return T_AND; + + case '%': + if (_char == QLatin1Char('=')) { + scanChar(); + return T_REMAINDER_EQ; + } + return T_REMAINDER; + + case '!': + if (_char == QLatin1Char('=')) { + scanChar(); + if (_char == QLatin1Char('=')) { + scanChar(); + return T_NOT_EQ_EQ; + } + return T_NOT_EQ; + } + return T_NOT; + + case '\'': + case '"': { + const QChar quote = ch; + bool multilineStringLiteral = false; + + const QChar *startCode = _codePtr; + + if (_engine) { + while (!_char.isNull()) { + if (_char == QLatin1Char('\n') || _char == QLatin1Char('\\')) { + break; + } + if (_char == quote) { + _tokenSpell = _engine->midRef( + int(startCode - _code.unicode() - 1), int(_codePtr - startCode)); + scanChar(); + + return T_STRING_LITERAL; + } + scanChar(); + } + } + + _validTokenText = true; + _tokenText.resize(0); + startCode--; + while (startCode != _codePtr - 1) + _tokenText += *startCode++; + + while (! _char.isNull()) { + if (_char == QLatin1Char('\n')) { + multilineStringLiteral = true; + _tokenText += _char; + scanChar(); + } else if (_char == quote) { + scanChar(); + + if (_engine) + _tokenSpell = _engine->newStringRef(_tokenText); + + return multilineStringLiteral ? T_MULTILINE_STRING_LITERAL : T_STRING_LITERAL; + } else if (_char == QLatin1Char('\\')) { + scanChar(); + + QChar u; + bool ok = false; + + switch (_char.unicode()) { + // unicode escape sequence + case 'u': + u = decodeUnicodeEscapeCharacter(&ok); + if (! ok) + u = _char; + break; + + // hex escape sequence + case 'x': + case 'X': + if (isHexDigit(_codePtr[0]) && isHexDigit(_codePtr[1])) { + scanChar(); + + const QChar c1 = _char; + scanChar(); + + const QChar c2 = _char; + scanChar(); + + u = convertHex(c1, c2); + } else { + u = _char; + } + break; + + // single character escape sequence + case '\\': u = QLatin1Char('\\'); scanChar(); break; + case '\'': u = QLatin1Char('\''); scanChar(); break; + case '\"': u = QLatin1Char('\"'); scanChar(); break; + case 'b': u = QLatin1Char('\b'); scanChar(); break; + case 'f': u = QLatin1Char('\f'); scanChar(); break; + case 'n': u = QLatin1Char('\n'); scanChar(); break; + case 'r': u = QLatin1Char('\r'); scanChar(); break; + case 't': u = QLatin1Char('\t'); scanChar(); break; + case 'v': u = QLatin1Char('\v'); scanChar(); break; + + case '0': + if (! _codePtr[1].isDigit()) { + scanChar(); + u = QLatin1Char('\0'); + } else { + // ### parse deprecated octal escape sequence ? + u = _char; + } + break; + + case '\r': + while (_char == QLatin1Char('\r')) + scanChar(); + + if (_char == QLatin1Char('\n')) { + u = _char; + scanChar(); + } else { + u = QLatin1Char('\n'); + } + + break; + + case '\n': + u = _char; + scanChar(); + break; + + default: + // non escape character + u = _char; + scanChar(); + } + + _tokenText += u; + } else { + _tokenText += _char; + scanChar(); + } + } + + _errorCode = UnclosedStringLiteral; + _errorMessage = QCoreApplication::translate("QmlParser", "Unclosed string at end of line"); + return T_ERROR; + } + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return scanNumber(ch); + + default: + if (ch.isLetter() || ch == QLatin1Char('$') || ch == QLatin1Char('_') || (ch == QLatin1Char('\\') && _char == QLatin1Char('u'))) { + bool identifierWithEscapeChars = false; + if (ch == QLatin1Char('\\')) { + identifierWithEscapeChars = true; + _tokenText.resize(0); + bool ok = false; + _tokenText += decodeUnicodeEscapeCharacter(&ok); + _validTokenText = true; + if (! ok) { + _errorCode = IllegalUnicodeEscapeSequence; + _errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence"); + return T_ERROR; + } + } + while (true) { + if (_char.isLetterOrNumber() || _char == QLatin1Char('$') || _char == QLatin1Char('_')) { + if (identifierWithEscapeChars) + _tokenText += _char; + + scanChar(); + } else if (_char == QLatin1Char('\\') && _codePtr[0] == QLatin1Char('u')) { + if (! identifierWithEscapeChars) { + identifierWithEscapeChars = true; + _tokenText.resize(0); + _tokenText.insert(0, _tokenStartPtr, int(_codePtr - _tokenStartPtr - 1)); + _validTokenText = true; + } + + scanChar(); // skip '\\' + bool ok = false; + _tokenText += decodeUnicodeEscapeCharacter(&ok); + if (! ok) { + _errorCode = IllegalUnicodeEscapeSequence; + _errorMessage = QCoreApplication::translate("QmlParser", "Illegal unicode escape sequence"); + return T_ERROR; + } + } else { + _tokenLength = int(_codePtr - _tokenStartPtr - 1); + + int kind = T_IDENTIFIER; + + if (! identifierWithEscapeChars) + kind = classify(_tokenStartPtr, _tokenLength, _qmlMode); + + if (_engine) { + if (kind == T_IDENTIFIER && identifierWithEscapeChars) { + _tokenSpell = _engine->newStringRef(_tokenText); + } else { + _tokenSpell = _engine->midRef( + int(_tokenStartPtr - _code.unicode()), _tokenLength); + } + } + + return kind; + } + } + } + + break; + } + + return T_ERROR; +} + +int Lexer::scanNumber(QChar ch) +{ + if (ch != QLatin1Char('0')) { + double integer = ch.unicode() - '0'; + + QChar n = _char; + const QChar *code = _codePtr; + while (n.isDigit()) { + integer = integer * 10 + (n.unicode() - '0'); + n = *code++; + } + + if (n != QLatin1Char('.') && n != QLatin1Char('e') && n != QLatin1Char('E')) { + if (code != _codePtr) { + _codePtr = code - 1; + scanChar(); + } + _tokenValue = integer; + return T_NUMERIC_LITERAL; + } + } + + QVarLengthArray chars; + chars.append(ch.unicode()); + + if (ch == QLatin1Char('0') && (_char == QLatin1Char('x') || _char == QLatin1Char('X'))) { + // parse hex integer literal + + chars.append(_char.unicode()); + scanChar(); // consume `x' + + while (isHexDigit(_char)) { + chars.append(_char.unicode()); + scanChar(); + } + + _tokenValue = integerFromString(chars.constData(), chars.size(), 16); + return T_NUMERIC_LITERAL; + } + + // decimal integer literal + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); // consume the digit + } + + if (_char == QLatin1Char('.')) { + chars.append(_char.unicode()); + scanChar(); // consume `.' + + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); + } + + if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { + if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && + _codePtr[1].isDigit())) { + + chars.append(_char.unicode()); + scanChar(); // consume `e' + + if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { + chars.append(_char.unicode()); + scanChar(); // consume the sign + } + + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); + } + } + } + } else if (_char == QLatin1Char('e') || _char == QLatin1Char('E')) { + if (_codePtr[0].isDigit() || ((_codePtr[0] == QLatin1Char('+') || _codePtr[0] == QLatin1Char('-')) && + _codePtr[1].isDigit())) { + + chars.append(_char.unicode()); + scanChar(); // consume `e' + + if (_char == QLatin1Char('+') || _char == QLatin1Char('-')) { + chars.append(_char.unicode()); + scanChar(); // consume the sign + } + + while (_char.isDigit()) { + chars.append(_char.unicode()); + scanChar(); + } + } + } + + if (chars.size() == 1) { + // if we ended up with a single digit, then it was a '0' + _tokenValue = 0; + return T_NUMERIC_LITERAL; + } + + const char *begin = chars.constData(); + const char *end = nullptr; + bool ok = false; + + _tokenValue = qstrntod(begin, chars.size(), &end, &ok); + + if (end - begin != chars.size()) { + _errorCode = IllegalExponentIndicator; + _errorMessage = QCoreApplication::translate("QmlParser", "Illegal syntax for exponential number"); + return T_ERROR; + } + + return T_NUMERIC_LITERAL; +} + +bool Lexer::scanRegExp(RegExpBodyPrefix prefix) +{ + _tokenText.resize(0); + _validTokenText = true; + _patternFlags = 0; + + if (prefix == EqualPrefix) + _tokenText += QLatin1Char('='); + + while (true) { + switch (_char.unicode()) { + case 0: // eof + case '\n': case '\r': // line terminator + _errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression literal"); + return false; + + case '/': + scanChar(); + + // scan the flags + _patternFlags = 0; + while (isIdentLetter(_char)) { + int flag = regExpFlagFromChar(_char); + if (flag == 0) { + _errorMessage = QCoreApplication::translate("QmlParser", "Invalid regular expression flag '%0'") + .arg(QChar(_char)); + return false; + } + _patternFlags |= flag; + scanChar(); + } + + _tokenLength = int(_codePtr - _tokenStartPtr - 1); + return true; + + case '\\': + // regular expression backslash sequence + _tokenText += _char; + scanChar(); + + if (_char.isNull() || isLineTerminator()) { + _errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence"); + return false; + } + + _tokenText += _char; + scanChar(); + break; + + case '[': + // regular expression class + _tokenText += _char; + scanChar(); + + while (! _char.isNull() && ! isLineTerminator()) { + if (_char == QLatin1Char(']')) + break; + if (_char == QLatin1Char('\\')) { + // regular expression backslash sequence + _tokenText += _char; + scanChar(); + + if (_char.isNull() || isLineTerminator()) { + _errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression backslash sequence"); + return false; + } + + _tokenText += _char; + scanChar(); + } else { + _tokenText += _char; + scanChar(); + } + } + + if (_char != QLatin1Char(']')) { + _errorMessage = QCoreApplication::translate("QmlParser", "Unterminated regular expression class"); + return false; + } + + _tokenText += _char; + scanChar(); // skip ] + break; + + default: + _tokenText += _char; + scanChar(); + } // switch + } // while + + return false; +} + +bool Lexer::isLineTerminator() const +{ + return (_char == QLatin1Char('\n') || _char == QLatin1Char('\r')); +} + +bool Lexer::isIdentLetter(QChar ch) +{ + // ASCII-biased, since all reserved words are ASCII, aand hence the + // bulk of content to be parsed. + if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) + || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')) + || ch == QLatin1Char('$') + || ch == QLatin1Char('_')) + return true; + if (ch.unicode() < 128) + return false; + return ch.isLetterOrNumber(); +} + +bool Lexer::isDecimalDigit(ushort c) +{ + return (c >= '0' && c <= '9'); +} + +bool Lexer::isHexDigit(QChar c) +{ + return ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) + || (c >= QLatin1Char('a') && c <= QLatin1Char('f')) + || (c >= QLatin1Char('A') && c <= QLatin1Char('F'))); +} + +bool Lexer::isOctalDigit(ushort c) +{ + return (c >= '0' && c <= '7'); +} + +int Lexer::tokenEndLine() const +{ + return _currentLineNumber; +} + +int Lexer::tokenEndColumn() const +{ + return int(_codePtr - _lastLinePtr); +} + +QString Lexer::tokenText() const +{ + if (_validTokenText) + return _tokenText; + + if (_tokenKind == T_STRING_LITERAL) + return QString(_tokenStartPtr + 1, _tokenLength - 2); + + return QString(_tokenStartPtr, _tokenLength); +} + +Lexer::Error Lexer::errorCode() const +{ + return _errorCode; +} + +QString Lexer::errorMessage() const +{ + return _errorMessage; +} + +void Lexer::syncProhibitAutomaticSemicolon() +{ + if (_parenthesesState == BalancedParentheses) { + // we have seen something like "if (foo)", which means we should + // never insert an automatic semicolon at this point, since it would + // then be expanded into an empty statement (ECMA-262 7.9.1) + _prohibitAutomaticSemicolon = true; + _parenthesesState = IgnoreParentheses; + } else { + _prohibitAutomaticSemicolon = false; + } +} + +bool Lexer::prevTerminator() const +{ + return _terminator; +} + +bool Lexer::followsClosingBrace() const +{ + return _followsClosingBrace; +} + +bool Lexer::canInsertAutomaticSemicolon(int token) const +{ + return token == T_RBRACE + || token == EOF_SYMBOL + || _terminator + || _followsClosingBrace; +} + +bool Lexer::scanDirectives(Directives *directives) +{ + if (_qmlMode) { + // the directives are a Javascript-only extension. + return false; + } + + lex(); // fetch the first token + + if (_tokenKind != T_DOT) + return true; + + do { + lex(); // skip T_DOT + + const int lineNumber = tokenStartLine(); + + if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) + return false; // expected a valid QML/JS directive + + const QString directiveName = tokenText(); + + if (! (directiveName == QLatin1String("pragma") || + directiveName == QLatin1String("import"))) + return false; // not a valid directive name + + // it must be a pragma or an import directive. + if (directiveName == QLatin1String("pragma")) { + // .pragma library + if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) + return false; // expected `library + + // we found a .pragma library directive + directives->pragmaLibrary(); + + } else { + Q_ASSERT(directiveName == QLatin1String("import")); + lex(); // skip .import + + QString pathOrUri; + QString version; + bool fileImport = false; // file or uri import + + if (_tokenKind == T_STRING_LITERAL) { + // .import T_STRING_LITERAL as T_IDENTIFIER + + fileImport = true; + pathOrUri = tokenText(); + + } else if (_tokenKind == T_IDENTIFIER) { + // .import T_IDENTIFIER (. T_IDENTIFIER)* T_NUMERIC_LITERAL as T_IDENTIFIER + + pathOrUri = tokenText(); + + lex(); // skip the first T_IDENTIFIER + for (; _tokenKind == T_DOT; lex()) { + if (lex() != T_IDENTIFIER) + return false; + + pathOrUri += QLatin1Char('.'); + pathOrUri += tokenText(); + } + + if (_tokenKind != T_NUMERIC_LITERAL) + return false; // expected the module version number + + version = tokenText(); + } + + // + // recognize the mandatory `as' followed by the module name + // + if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as"))) + return false; // expected `as' + + if (lex() != T_IDENTIFIER) + return false; // expected module name + + const QString module = tokenText(); + + if (fileImport) + directives->importFile(pathOrUri, module); + else + directives->importModule(pathOrUri, version, module); + } + + if (tokenStartLine() != lineNumber) + return false; // the directives cannot span over multiple lines + + // fetch the first token after the .pragma/.import directive + lex(); + } while (_tokenKind == T_DOT); + + return true; +} + +} // namespace QbsQmlJS + +#include "qmljskeywords_p.h" diff --git a/src/lib/corelib/parser/qmljslexer_p.h b/src/lib/corelib/parser/qmljslexer_p.h new file mode 100644 index 00000000..aef68e0c --- /dev/null +++ b/src/lib/corelib/parser/qmljslexer_p.h @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSLEXER_P_H +#define QMLJSLEXER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmljsglobal_p.h" +#include "qmljsgrammar_p.h" +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) +#include +#endif + +namespace QbsQmlJS { + +class Engine; + +class QML_PARSER_EXPORT Directives { +public: + virtual ~Directives() = default; + + virtual void pragmaLibrary() + { + } + + virtual void importFile(const QString &jsfile, const QString &module) + { + Q_UNUSED(jsfile); + Q_UNUSED(module); + } + + virtual void importModule(const QString &uri, const QString &version, const QString &module) + { + Q_UNUSED(uri); + Q_UNUSED(version); + Q_UNUSED(module); + } +}; + +class QBS_AUTOTEST_EXPORT Lexer: public QmlJSGrammar +{ +public: + enum { + T_ABSTRACT = T_RESERVED_WORD, + T_BOOLEAN = T_RESERVED_WORD, + T_BYTE = T_RESERVED_WORD, + T_CHAR = T_RESERVED_WORD, + T_CLASS = T_RESERVED_WORD, + T_DOUBLE = T_RESERVED_WORD, + T_ENUM = T_RESERVED_WORD, + T_EXPORT = T_RESERVED_WORD, + T_EXTENDS = T_RESERVED_WORD, + T_FINAL = T_RESERVED_WORD, + T_FLOAT = T_RESERVED_WORD, + T_GOTO = T_RESERVED_WORD, + T_IMPLEMENTS = T_RESERVED_WORD, + T_INT = T_RESERVED_WORD, + T_INTERFACE = T_RESERVED_WORD, + T_LET = T_RESERVED_WORD, + T_LONG = T_RESERVED_WORD, + T_NATIVE = T_RESERVED_WORD, + T_PACKAGE = T_RESERVED_WORD, + T_PRIVATE = T_RESERVED_WORD, + T_PROTECTED = T_RESERVED_WORD, + T_SHORT = T_RESERVED_WORD, + T_STATIC = T_RESERVED_WORD, + T_SUPER = T_RESERVED_WORD, + T_SYNCHRONIZED = T_RESERVED_WORD, + T_THROWS = T_RESERVED_WORD, + T_TRANSIENT = T_RESERVED_WORD, + T_VOLATILE = T_RESERVED_WORD, + T_YIELD = T_RESERVED_WORD + }; + + enum Error { + NoError, + IllegalCharacter, + UnclosedStringLiteral, + IllegalEscapeSequence, + IllegalUnicodeEscapeSequence, + UnclosedComment, + IllegalExponentIndicator, + IllegalIdentifier + }; + + enum RegExpBodyPrefix { + NoPrefix, + EqualPrefix + }; + + enum RegExpFlag { + RegExp_Global = 0x01, + RegExp_IgnoreCase = 0x02, + RegExp_Multiline = 0x04 + }; + +public: + Lexer(Engine *engine); + + bool qmlMode() const; + + QString code() const; + void setCode(const QString &code, int lineno, bool qmlMode = true); + + int lex(); + + bool scanRegExp(RegExpBodyPrefix prefix = NoPrefix); + bool scanDirectives(Directives *directives); + + int regExpFlags() const { return _patternFlags; } + QString regExpPattern() const { return _tokenText; } + + int tokenKind() const { return _tokenKind; } + int tokenOffset() const { return _tokenStartPtr - _code.unicode(); } + int tokenLength() const { return _tokenLength; } + + int tokenStartLine() const { return _tokenLine; } + int tokenStartColumn() const { return _tokenStartPtr - _tokenLinePtr + 1; } + + int tokenEndLine() const; + int tokenEndColumn() const; + + inline QStringRef tokenSpell() const { return _tokenSpell; } + double tokenValue() const { return _tokenValue; } + QString tokenText() const; + + Error errorCode() const; + QString errorMessage() const; + + bool prevTerminator() const; + bool followsClosingBrace() const; + bool canInsertAutomaticSemicolon(int token) const; + + enum ParenthesesState { + IgnoreParentheses, + CountParentheses, + BalancedParentheses + }; + +protected: + int classify(const QChar *s, int n, bool qmlMode); + +private: + inline void scanChar(); + int scanToken(); + int scanNumber(QChar ch); + + bool isLineTerminator() const; + static bool isIdentLetter(QChar c); + static bool isDecimalDigit(ushort c); + static bool isHexDigit(QChar c); + static bool isOctalDigit(ushort c); + static bool isUnicodeEscapeSequence(const QChar *chars); + + void syncProhibitAutomaticSemicolon(); + QChar decodeUnicodeEscapeCharacter(bool *ok); + +private: + Engine *_engine; + + QString _code; + QString _tokenText; + QString _errorMessage; + QStringRef _tokenSpell; + + const QChar *_codePtr; + const QChar *_lastLinePtr; + const QChar *_tokenLinePtr; + const QChar *_tokenStartPtr; + + QChar _char; + Error _errorCode; + + int _currentLineNumber; + double _tokenValue; + + // parentheses state + ParenthesesState _parenthesesState; + int _parenthesesCount; + + int _stackToken; + + int _patternFlags; + int _tokenKind; + int _tokenLength; + int _tokenLine; + + bool _validTokenText; + bool _prohibitAutomaticSemicolon; + bool _restrictedKeyword; + bool _terminator; + bool _followsClosingBrace; + bool _delimited; + bool _qmlMode; +}; + +} // namespace QbsQmlJS + +#endif // LEXER_H diff --git a/src/lib/corelib/parser/qmljsmemorypool_p.h b/src/lib/corelib/parser/qmljsmemorypool_p.h new file mode 100644 index 00000000..f7de7bbf --- /dev/null +++ b/src/lib/corelib/parser/qmljsmemorypool_p.h @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLJSMEMORYPOOL_P_H +#define QMLJSMEMORYPOOL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qmljsglobal_p.h" + +#include +#include +#include + +#include + +namespace QbsQmlJS { + +class QML_PARSER_EXPORT MemoryPool : public QSharedData +{ + MemoryPool(const MemoryPool &other); + void operator =(const MemoryPool &other); + +public: + MemoryPool() + : _blocks(nullptr), + _allocatedBlocks(0), + _blockCount(-1), + _ptr(nullptr), + _end(nullptr) + { } + + ~MemoryPool() + { + if (_blocks) { + for (int i = 0; i < _allocatedBlocks; ++i) { + if (char *b = _blocks[i]) + free(b); + } + + free(_blocks); + } + } + + inline void *allocate(size_t size) + { + size = (size + 7) & ~7; + if (_ptr && (_ptr + size < _end)) { + void *addr = _ptr; + _ptr += size; + return addr; + } + return allocate_helper(size); + } + + void reset() + { + _blockCount = -1; + _ptr = _end = nullptr; + } + +private: + void *allocate_helper(size_t size) + { + Q_ASSERT(size < BLOCK_SIZE); + + if (++_blockCount == _allocatedBlocks) { + if (! _allocatedBlocks) + _allocatedBlocks = DEFAULT_BLOCK_COUNT; + else + _allocatedBlocks *= 2; + + _blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks); + + for (int index = _blockCount; index < _allocatedBlocks; ++index) + _blocks[index] = nullptr; + } + + char *&block = _blocks[_blockCount]; + + if (! block) + block = (char *) malloc(BLOCK_SIZE); + + _ptr = block; + _end = _ptr + BLOCK_SIZE; + + void *addr = _ptr; + _ptr += size; + return addr; + } + +private: + char **_blocks; + int _allocatedBlocks; + int _blockCount; + char *_ptr; + char *_end; + + enum + { + BLOCK_SIZE = 8 * 1024, + DEFAULT_BLOCK_COUNT = 8 + }; +}; + +class QML_PARSER_EXPORT Managed +{ + Managed(const Managed &other); + void operator = (const Managed &other); + +public: + Managed() = default; + ~Managed() = default; + + void *operator new(size_t size, MemoryPool *pool) { return pool->allocate(size); } + void operator delete(void *) {} + void operator delete(void *, MemoryPool *) {} +}; + +} // namespace QbsQmlJS + +#endif diff --git a/src/lib/corelib/parser/qmljsparser.cpp b/src/lib/corelib/parser/qmljsparser.cpp new file mode 100644 index 00000000..d2c87c7c --- /dev/null +++ b/src/lib/corelib/parser/qmljsparser.cpp @@ -0,0 +1,1819 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +#include "qmljsengine_p.h" +#include "qmljslexer_p.h" +#include "qmljsast_p.h" +#include "qmljsmemorypool_p.h" + + + +#include "qmljsparser_p.h" +#include + +// +// This file is automatically generated from qmljs.g. +// Changes will be lost. +// + +namespace QbsQmlJS { + +void Parser::reallocateStack() +{ + if (! stack_size) + stack_size = 128; + else + stack_size <<= 1; + + sym_stack = reinterpret_cast (realloc(sym_stack, stack_size * sizeof(Value))); + state_stack = reinterpret_cast (realloc(state_stack, stack_size * sizeof(int))); + location_stack = reinterpret_cast (realloc(location_stack, stack_size * sizeof(AST::SourceLocation))); + string_stack = reinterpret_cast (realloc( + static_cast(string_stack), stack_size * sizeof(QStringRef))); +} + +Parser::Parser(Engine *engine): + driver(engine), + pool(engine->pool()), + tos(0), + stack_size(0), + sym_stack(nullptr), + state_stack(nullptr), + location_stack(nullptr), + string_stack(nullptr), + program(nullptr), + first_token(nullptr), + last_token(nullptr) +{ +} + +Parser::~Parser() +{ + if (stack_size) { + free(sym_stack); + free(state_stack); + free(location_stack); + free(string_stack); + } +} + +static inline AST::SourceLocation location(Lexer *lexer) +{ + AST::SourceLocation loc; + loc.offset = lexer->tokenOffset(); + loc.length = lexer->tokenLength(); + loc.startLine = lexer->tokenStartLine(); + loc.startColumn = lexer->tokenStartColumn(); + return loc; +} + +AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) +{ + QVarLengthArray nameIds; + QVarLengthArray locations; + + AST::ExpressionNode *it = expr; + while (const auto m = AST::cast(it)) { + nameIds.append(m->name); + locations.append(m->identifierToken); + it = m->base; + } + + if (const auto idExpr = AST::cast(it)) { + const auto q = new (pool) AST::UiQualifiedId(idExpr->name); + q->identifierToken = idExpr->identifierToken; + + AST::UiQualifiedId *currentId = q; + for (int i = nameIds.size() - 1; i != -1; --i) { + currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]); + currentId->identifierToken = locations[i]; + } + + return currentId->finish(); + } + + return nullptr; +} + +bool Parser::parse(int startToken) +{ + Lexer *lexer = driver->lexer(); + bool hadErrors = false; + int yytoken = -1; + int action = 0; + + token_buffer[0].token = startToken; + first_token = &token_buffer[0]; + if (startToken == T_FEED_JS_PROGRAM) { + Directives ignoreDirectives; + Directives *directives = driver->directives(); + if (!directives) + directives = &ignoreDirectives; + lexer->scanDirectives(directives); + token_buffer[1].token = lexer->tokenKind(); + token_buffer[1].dval = lexer->tokenValue(); + token_buffer[1].loc = location(lexer); + token_buffer[1].spell = lexer->tokenSpell(); + last_token = &token_buffer[2]; + } else { + last_token = &token_buffer[1]; + } + + tos = -1; + program = nullptr; + + do { + if (++tos == stack_size) + reallocateStack(); + + state_stack[tos] = action; + + _Lcheck_token: + if (yytoken == -1 && -TERMINAL_COUNT != action_index[action]) { + yyprevlloc = yylloc; + + if (first_token == last_token) { + yytoken = lexer->lex(); + yylval = lexer->tokenValue(); + yytokenspell = lexer->tokenSpell(); + yylloc = location(lexer); + } else { + yytoken = first_token->token; + yylval = first_token->dval; + yytokenspell = first_token->spell; + yylloc = first_token->loc; + ++first_token; + } + } + + action = t_action(action, yytoken); + if (action > 0) { + if (action != ACCEPT_STATE) { + yytoken = -1; + sym(1).dval = yylval; + stringRef(1) = yytokenspell; + loc(1) = yylloc; + } else { + --tos; + return ! hadErrors; + } + } else if (action < 0) { + const int r = -action - 1; + tos -= rhs[r]; + + switch (r) { + +case 0: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 1: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 2: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 3: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 4: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 5: { + sym(1).Node = sym(2).Node; + program = sym(1).Node; +} break; + +case 6: { + sym(1).UiProgram = new (pool) AST::UiProgram(sym(1).UiImportList, + sym(2).UiObjectMemberList->finish()); +} break; + +case 8: { + sym(1).Node = sym(1).UiImportList->finish(); +} break; + +case 9: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImport); +} break; + +case 10: { + sym(1).Node = new (pool) AST::UiImportList(sym(1).UiImportList, sym(2).UiImport); +} break; + +case 13: { + sym(1).UiImport->semicolonToken = loc(2); +} break; + +case 15: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->semicolonToken = loc(3); +} break; + +case 17: { + sym(1).UiImport->versionToken = loc(2); + sym(1).UiImport->asToken = loc(3); + sym(1).UiImport->importIdToken = loc(4); + sym(1).UiImport->importId = stringRef(4); + sym(1).UiImport->semicolonToken = loc(5); +} break; + +case 19: { + sym(1).UiImport->asToken = loc(2); + sym(1).UiImport->importIdToken = loc(3); + sym(1).UiImport->importId = stringRef(3); + sym(1).UiImport->semicolonToken = loc(4); +} break; + +case 20: { + AST::UiImport *node = nullptr; + + if (const auto importIdLiteral = AST::cast(sym(2).Expression)) { + node = new (pool) AST::UiImport(importIdLiteral->value); + node->fileNameToken = loc(2); + } else if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(2).Expression)) { + node = new (pool) AST::UiImport(qualifiedId); + node->fileNameToken = loc(2); + } + + sym(1).Node = node; + + if (node) { + node->importToken = loc(1); + } else { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QStringLiteral("Expected a qualified name id or a string literal"))); + + return false; // ### remove me + } +} break; + +case 21: { + sym(1).Node = nullptr; +} break; + +case 22: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; + +case 23: { + sym(1).Node = new (pool) AST::UiObjectMemberList(sym(1).UiObjectMember); +} break; + +case 24: { + const auto node = new (pool) AST:: UiObjectMemberList( + sym(1).UiObjectMemberList, sym(2).UiObjectMember); + sym(1).Node = node; +} break; + +case 25: { + sym(1).Node = new (pool) AST::UiArrayMemberList(sym(1).UiObjectMember); +} break; + +case 26: { + const auto node = new (pool) AST::UiArrayMemberList( + sym(1).UiArrayMemberList, sym(3).UiObjectMember); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 27: { + const auto node = new (pool) AST::UiObjectInitializer(nullptr); + node->lbraceToken = loc(1); + node->rbraceToken = loc(2); + sym(1).Node = node; +} break; + +case 28: { + const auto node = new (pool) AST::UiObjectInitializer(sym(2).UiObjectMemberList->finish()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 29: { + const auto node = new (pool) AST::UiObjectDefinition(sym(1).UiQualifiedId, + sym(2).UiObjectInitializer); + sym(1).Node = node; +} break; + +case 31: { + const auto node = new (pool) AST::UiArrayBinding( + sym(1).UiQualifiedId, sym(4).UiArrayMemberList->finish()); + node->colonToken = loc(2); + node->lbracketToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; + +case 32: { + const auto node = new (pool) AST::UiObjectBinding( + sym(1).UiQualifiedId, sym(3).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 33: { + const auto node = new (pool) AST::UiObjectBinding( + sym(3).UiQualifiedId, sym(1).UiQualifiedId, sym(4).UiObjectInitializer); + node->colonToken = loc(2); + node->hasOnToken = true; + sym(1).Node = node; +} break; + +case 41: +{ + const auto node = new (pool) AST::UiScriptBinding( + sym(1).UiQualifiedId, sym(3).Statement); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 45: { + sym(1).Node = nullptr; +} break; + +case 46: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; + +case 47: { + const auto node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + node->propertyTypeToken = loc(1); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; + +case 48: { + const auto node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; + +case 50: { + const auto node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->parameters = sym(4).UiParameterList; + node->semicolonToken = loc(6); + sym(1).Node = node; +} break; + +case 52: { + const auto node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 54: { + const auto node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; + +case 56: { + const auto node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); + sym(1).Node = node; +} break; + +case 58: { + const auto node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; + +case 59: { + const auto node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), + sym(5).Statement); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 60: { + const auto node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isReadonlyMember = true; + node->readonlyToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; + +case 61: { + const auto node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + sym(6).Statement); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->propertyToken = loc(2); + node->typeToken = loc(3); + node->identifierToken = loc(4); + node->colonToken = loc(5); + sym(1).Node = node; +} break; + +case 62: { + const auto node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + node->typeModifier = stringRef(2); + node->propertyToken = loc(1); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(6); + node->semicolonToken = loc(7); // insert a fake ';' before ':' + + const auto propertyName = new (pool) AST::UiQualifiedId(stringRef(6)); + propertyName->identifierToken = loc(6); + propertyName->next = nullptr; + + const auto binding = new (pool) AST::UiArrayBinding( + propertyName, sym(9).UiArrayMemberList->finish()); + binding->colonToken = loc(7); + binding->lbracketToken = loc(8); + binding->rbracketToken = loc(10); + + node->binding = binding; + + sym(1).Node = node; +} break; + +case 63: { + const auto node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->semicolonToken = loc(4); // insert a fake ';' before ':' + + const auto propertyName = new (pool) AST::UiQualifiedId(stringRef(3)); + propertyName->identifierToken = loc(3); + propertyName->next = nullptr; + + const auto binding = new (pool) AST::UiObjectBinding( + propertyName, sym(5).UiQualifiedId, sym(6).UiObjectInitializer); + binding->colonToken = loc(4); + + node->binding = binding; + + sym(1).Node = node; +} break; + +case 64: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; + +case 65: { + sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); +} break; + +case 71: { + const auto node = new (pool) AST::ThisExpression(); + node->thisToken = loc(1); + sym(1).Node = node; +} break; + +case 72: { + const auto node = new (pool) AST::IdentifierExpression(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 73: { + const auto node = new (pool) AST::NullExpression(); + node->nullToken = loc(1); + sym(1).Node = node; +} break; + +case 74: { + const auto node = new (pool) AST::TrueLiteral(); + node->trueToken = loc(1); + sym(1).Node = node; +} break; + +case 75: { + const auto node = new (pool) AST::FalseLiteral(); + node->falseToken = loc(1); + sym(1).Node = node; +} break; + +case 76: { + const auto node = new (pool) AST::NumericLiteral(sym(1).dval); + node->literalToken = loc(1); + sym(1).Node = node; +} break; +case 77: +case 78: { + const auto node = new (pool) AST::StringLiteral(stringRef(1)); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 79: { + bool rx = lexer->scanRegExp(Lexer::NoPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; // ### remove me + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + const auto node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 80: { + bool rx = lexer->scanRegExp(Lexer::EqualPrefix); + if (!rx) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); + return false; + } + + loc(1).length = lexer->tokenLength(); + yylloc = loc(1); // adjust the location of the current token + + const auto node = new (pool) AST::RegExpLiteral( + driver->newStringRef(lexer->regExpPattern()), lexer->regExpFlags()); + node->literalToken = loc(1); + sym(1).Node = node; +} break; + +case 81: { + const auto node = new (pool) AST::ArrayLiteral(static_cast(nullptr)); + node->lbracketToken = loc(1); + node->rbracketToken = loc(2); + sym(1).Node = node; +} break; + +case 82: { + const auto node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; + +case 83: { + const auto node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); + node->lbracketToken = loc(1); + node->rbracketToken = loc(3); + sym(1).Node = node; +} break; + +case 84: { + const auto node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), nullptr); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 85: { + const auto node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), + sym(4).Elision->finish()); + node->lbracketToken = loc(1); + node->commaToken = loc(3); + node->rbracketToken = loc(5); + sym(1).Node = node; +} break; + +case 86: { + AST::ObjectLiteral *node = nullptr; + if (sym(2).Node) + node = new (pool) AST::ObjectLiteral( + sym(2).PropertyNameAndValueList->finish ()); + else + node = new (pool) AST::ObjectLiteral(); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 87: { + const auto node = new (pool) AST::ObjectLiteral( + sym(2).PropertyNameAndValueList->finish ()); + node->lbraceToken = loc(1); + node->rbraceToken = loc(4); + sym(1).Node = node; +} break; + +case 88: { + const auto node = new (pool) AST::NestedExpression(sym(2).Expression); + node->lparenToken = loc(1); + node->rparenToken = loc(3); + sym(1).Node = node; +} break; + +case 89: { + if (const auto *mem = AST::cast(sym(1).Expression)) { + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, + QStringLiteral("Ignored annotation"))); + + sym(1).Expression = mem->base; + } + + if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(1).Expression)) { + sym(1).UiQualifiedId = qualifiedId; + } else { + sym(1).UiQualifiedId = nullptr; + + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, loc(1), + QStringLiteral("Expected a qualified name id"))); + + return false; // ### recover + } +} break; + +case 90: { + sym(1).Node = new (pool) AST::ElementList(nullptr, sym(1).Expression); +} break; + +case 91: { + sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); +} break; + +case 92: { + const auto node = new (pool) AST::ElementList(sym(1).ElementList, nullptr, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 93: { + const auto node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), + sym(4).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 94: { + const auto node = new (pool) AST::Elision(); + node->commaToken = loc(1); + sym(1).Node = node; +} break; + +case 95: { + const auto node = new (pool) AST::Elision(sym(1).Elision); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 96: { + const auto node = new (pool) AST::PropertyNameAndValueList( + sym(1).PropertyName, sym(3).Expression); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 97: { + const auto node = new (pool) AST::PropertyNameAndValueList( + sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); + node->commaToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 98: { + const auto node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; +case 99: +case 100: { + const auto node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 101: { + const auto node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 102: { + const auto node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 103: { + const auto node = new (pool) AST::IdentifierPropertyName(stringRef(1)); + node->propertyNameToken = loc(1); + sym(1).Node = node; +} break; + +case 139: { + const auto node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 140: { + const auto node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 141: { + const auto node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); + node->newToken = loc(1); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + sym(1).Node = node; +} break; + +case 143: { + const auto node = new (pool) AST::NewExpression(sym(2).Expression); + node->newToken = loc(1); + sym(1).Node = node; +} break; + +case 144: { + const auto node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 145: { + const auto node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 146: { + const auto node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); + node->lbracketToken = loc(2); + node->rbracketToken = loc(4); + sym(1).Node = node; +} break; + +case 147: { + const auto node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); + node->dotToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 148: { + sym(1).Node = nullptr; +} break; + +case 149: { + sym(1).Node = sym(1).ArgumentList->finish(); +} break; + +case 150: { + sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); +} break; + +case 151: { + const auto node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 155: { + const auto node = new (pool) AST::PostIncrementExpression(sym(1).Expression); + node->incrementToken = loc(2); + sym(1).Node = node; +} break; + +case 156: { + const auto node = new (pool) AST::PostDecrementExpression(sym(1).Expression); + node->decrementToken = loc(2); + sym(1).Node = node; +} break; + +case 158: { + const auto node = new (pool) AST::DeleteExpression(sym(2).Expression); + node->deleteToken = loc(1); + sym(1).Node = node; +} break; + +case 159: { + const auto node = new (pool) AST::VoidExpression(sym(2).Expression); + node->voidToken = loc(1); + sym(1).Node = node; +} break; + +case 160: { + const auto node = new (pool) AST::TypeOfExpression(sym(2).Expression); + node->typeofToken = loc(1); + sym(1).Node = node; +} break; + +case 161: { + const auto node = new (pool) AST::PreIncrementExpression(sym(2).Expression); + node->incrementToken = loc(1); + sym(1).Node = node; +} break; + +case 162: { + const auto node = new (pool) AST::PreDecrementExpression(sym(2).Expression); + node->decrementToken = loc(1); + sym(1).Node = node; +} break; + +case 163: { + const auto node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); + node->plusToken = loc(1); + sym(1).Node = node; +} break; + +case 164: { + const auto node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); + node->minusToken = loc(1); + sym(1).Node = node; +} break; + +case 165: { + const auto node = new (pool) AST::TildeExpression(sym(2).Expression); + node->tildeToken = loc(1); + sym(1).Node = node; +} break; + +case 166: { + const auto node = new (pool) AST::NotExpression(sym(2).Expression); + node->notToken = loc(1); + sym(1).Node = node; +} break; + +case 168: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mul, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 169: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Div, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 170: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Mod, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 172: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Add, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 173: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Sub, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 175: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::LShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 176: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::RShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 177: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::URShift, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 179: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 180: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 181: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 182: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 183: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 184: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::In, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 186: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Lt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 187: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Gt, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 188: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Le, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 189: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Ge, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 190: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::InstanceOf, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 192: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 193: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 194: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 195: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 197: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Equal, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 198: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::NotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 199: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 200: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::StrictNotEqual, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 202: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 204: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitAnd, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 206: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 208: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitXor, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 210: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 212: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::BitOr, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 214: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 216: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::And, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 218: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 220: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + QSOperator::Or, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 222: { + const auto node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 224: { + const auto node = new (pool) AST::ConditionalExpression(sym(1).Expression, + sym(3).Expression, sym(5).Expression); + node->questionToken = loc(2); + node->colonToken = loc(4); + sym(1).Node = node; +} break; + +case 226: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 228: { + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, + sym(2).ival, sym(3).Expression); + node->operatorToken = loc(2); + sym(1).Node = node; +} break; + +case 229: { + sym(1).ival = QSOperator::Assign; +} break; + +case 230: { + sym(1).ival = QSOperator::InplaceMul; +} break; + +case 231: { + sym(1).ival = QSOperator::InplaceDiv; +} break; + +case 232: { + sym(1).ival = QSOperator::InplaceMod; +} break; + +case 233: { + sym(1).ival = QSOperator::InplaceAdd; +} break; + +case 234: { + sym(1).ival = QSOperator::InplaceSub; +} break; + +case 235: { + sym(1).ival = QSOperator::InplaceLeftShift; +} break; + +case 236: { + sym(1).ival = QSOperator::InplaceRightShift; +} break; + +case 237: { + sym(1).ival = QSOperator::InplaceURightShift; +} break; + +case 238: { + sym(1).ival = QSOperator::InplaceAnd; +} break; + +case 239: { + sym(1).ival = QSOperator::InplaceXor; +} break; + +case 240: { + sym(1).ival = QSOperator::InplaceOr; +} break; + +case 242: { + const auto node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 243: { + sym(1).Node = nullptr; +} break; + +case 246: { + const auto node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 247: { + sym(1).Node = nullptr; +} break; + +case 264: { + const auto node = new (pool) AST::Block(sym(2).StatementList); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 265: { + sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); +} break; + +case 266: { + sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); +} break; + +case 267: { + sym(1).Node = nullptr; +} break; + +case 268: { + sym(1).Node = sym(1).StatementList->finish (); +} break; + +case 270: { + const auto node = new (pool) AST::VariableStatement( + sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); + node->declarationKindToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 271: { + sym(1).ival = T_CONST; +} break; + +case 272: { + sym(1).ival = T_VAR; +} break; + +case 273: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; + +case 274: { + const auto node = new (pool) AST::VariableDeclarationList( + sym(1).VariableDeclarationList, sym(3).VariableDeclaration); + node->commaToken = loc(2); + sym(1).Node = node; +} break; + +case 275: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); +} break; + +case 276: { + sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); +} break; + +case 277: { + const auto node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 278: { + const auto node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 279: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; + +case 280: { + sym(1).Node = nullptr; +} break; + +case 282: { + // ### TODO: AST for initializer + sym(1) = sym(2); +} break; + +case 283: { + sym(1).Node = nullptr; +} break; + +case 285: { + const auto node = new (pool) AST::EmptyStatement(); + node->semicolonToken = loc(1); + sym(1).Node = node; +} break; + +case 287: { + const auto node = new (pool) AST::ExpressionStatement(sym(1).Expression); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 288: { + const auto node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + node->elseToken = loc(6); + sym(1).Node = node; +} break; + +case 289: { + const auto node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); + node->ifToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 291: { + const auto node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); + node->doToken = loc(1); + node->whileToken = loc(3); + node->lparenToken = loc(4); + node->rparenToken = loc(6); + node->semicolonToken = loc(7); + sym(1).Node = node; +} break; + +case 292: { + const auto node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); + node->whileToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 293: { + const auto node = new (pool) AST::ForStatement(sym(3).Expression, + sym(5).Expression, sym(7).Expression, sym(9).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->firstSemicolonToken = loc(4); + node->secondSemicolonToken = loc(6); + node->rparenToken = loc(8); + sym(1).Node = node; +} break; + +case 294: { + const auto node = new (pool) AST::LocalForStatement( + sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, + sym(8).Expression, sym(10).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->firstSemicolonToken = loc(5); + node->secondSemicolonToken = loc(7); + node->rparenToken = loc(9); + sym(1).Node = node; +} break; + +case 295: { + const auto node = new (pool) AST::ForEachStatement(sym(3).Expression, + sym(5).Expression, sym(7).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->inToken = loc(4); + node->rparenToken = loc(6); + sym(1).Node = node; +} break; + +case 296: { + const auto node = new (pool) AST::LocalForEachStatement( + sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); + node->forToken = loc(1); + node->lparenToken = loc(2); + node->varToken = loc(3); + node->inToken = loc(5); + node->rparenToken = loc(7); + sym(1).Node = node; +} break; + +case 298: { + const auto node = new (pool) AST::ContinueStatement(); + node->continueToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 300: { + const auto node = new (pool) AST::ContinueStatement(stringRef(2)); + node->continueToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 302: { + const auto node = new (pool) AST::BreakStatement(QStringRef()); + node->breakToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 304: { + const auto node = new (pool) AST::BreakStatement(stringRef(2)); + node->breakToken = loc(1); + node->identifierToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 306: { + const auto node = new (pool) AST::ReturnStatement(sym(2).Expression); + node->returnToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 307: { + const auto node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); + node->withToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 308: { + const auto node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); + node->switchToken = loc(1); + node->lparenToken = loc(2); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 309: { + const auto node = new (pool) AST::CaseBlock(sym(2).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(3); + sym(1).Node = node; +} break; + +case 310: { + const auto node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); + node->lbraceToken = loc(1); + node->rbraceToken = loc(5); + sym(1).Node = node; +} break; + +case 311: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); +} break; + +case 312: { + sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); +} break; + +case 313: { + sym(1).Node = nullptr; +} break; + +case 314: { + sym(1).Node = sym(1).CaseClauses->finish (); +} break; + +case 315: { + const auto node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); + node->caseToken = loc(1); + node->colonToken = loc(3); + sym(1).Node = node; +} break; + +case 316: { + const auto node = new (pool) AST::DefaultClause(sym(3).StatementList); + node->defaultToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; +case 317: +case 318: { + const auto node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 319: { + const auto node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); + node->identifierToken = loc(1); + node->colonToken = loc(2); + sym(1).Node = node; +} break; + +case 321: { + const auto node = new (pool) AST::ThrowStatement(sym(2).Expression); + node->throwToken = loc(1); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 322: { + const auto node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 323: { + const auto node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 324: { + const auto node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); + node->tryToken = loc(1); + sym(1).Node = node; +} break; + +case 325: { + const auto node = new (pool) AST::Catch(stringRef(3), sym(5).Block); + node->catchToken = loc(1); + node->lparenToken = loc(2); + node->identifierToken = loc(3); + node->rparenToken = loc(4); + sym(1).Node = node; +} break; + +case 326: { + const auto node = new (pool) AST::Finally(sym(2).Block); + node->finallyToken = loc(1); + sym(1).Node = node; +} break; + +case 328: { + const auto node = new (pool) AST::DebuggerStatement(); + node->debuggerToken = loc(1); + node->semicolonToken = loc(2); + sym(1).Node = node; +} break; + +case 329: { + const auto node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; + +case 330: { + const auto node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); + node->functionToken = loc(1); + if (! stringRef(2).isNull()) + node->identifierToken = loc(2); + node->lparenToken = loc(3); + node->rparenToken = loc(5); + node->lbraceToken = loc(6); + node->rbraceToken = loc(8); + sym(1).Node = node; +} break; + +case 331: { + const auto node = new (pool) AST::FormalParameterList(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 332: { + const auto node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); + node->commaToken = loc(2); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; + +case 333: { + sym(1).Node = nullptr; +} break; + +case 334: { + sym(1).Node = sym(1).FormalParameterList->finish (); +} break; + +case 335: { + sym(1).Node = nullptr; +} break; + +case 337: { + sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); +} break; + +case 339: { + sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); +} break; + +case 340: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); +} break; + +case 341: { + sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); +} break; + +case 342: { + sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); +} break; + +case 343: { + sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); +} break; + +case 344: { + stringRef(1) = QStringRef(); +} break; + +case 346: { + sym(1).Node = nullptr; +} break; + + } // switch + action = nt_action(state_stack[tos], lhs[r] - TERMINAL_COUNT); + } // if + } while (action != 0); + + if (first_token == last_token) { + const int errorState = state_stack[tos]; + + // automatic insertion of `;' + if (yytoken != -1 && t_action(errorState, T_AUTOMATIC_SEMICOLON) && lexer->canInsertAutomaticSemicolon(yytoken)) { + SavedToken &tk = token_buffer[0]; + tk.token = yytoken; + tk.dval = yylval; + tk.spell = yytokenspell; + tk.loc = yylloc; + + yylloc = yyprevlloc; + yylloc.offset += yylloc.length; + yylloc.startColumn += yylloc.length; + yylloc.length = 0; + + //const QString msg = qApp->translate("QmlParser", "Missing `;'"); + //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); + + first_token = &token_buffer[0]; + last_token = &token_buffer[1]; + + yytoken = T_SEMICOLON; + yylval = 0; + + action = errorState; + + goto _Lcheck_token; + } + + hadErrors = true; + + token_buffer[0].token = yytoken; + token_buffer[0].dval = yylval; + token_buffer[0].spell = yytokenspell; + token_buffer[0].loc = yylloc; + + token_buffer[1].token = yytoken = lexer->lex(); + token_buffer[1].dval = yylval = lexer->tokenValue(); + token_buffer[1].spell = yytokenspell = lexer->tokenSpell(); + token_buffer[1].loc = yylloc = location(lexer); + + if (t_action(errorState, yytoken)) { + QString msg; + int token = token_buffer[0].token; + if (token < 0 || token >= TERMINAL_COUNT) + msg = qApp->translate("QmlParser", "Syntax error"); + else + msg = qApp->translate("QmlParser", "Unexpected token `%1'").arg(QLatin1String(spell[token])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + action = errorState; + goto _Lcheck_token; + } + + static int tokens[] = { + T_PLUS, + T_EQ, + + T_COMMA, + T_COLON, + T_SEMICOLON, + + T_RPAREN, T_RBRACKET, T_RBRACE, + + T_NUMERIC_LITERAL, + T_IDENTIFIER, + + T_LPAREN, T_LBRACKET, T_LBRACE, + + EOF_SYMBOL + }; + + for (int *tk = tokens; *tk != EOF_SYMBOL; ++tk) { + int a = t_action(errorState, *tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[*tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = *tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + first_token = &token_buffer[0]; + last_token = &token_buffer[2]; + + action = errorState; + goto _Lcheck_token; + } + } + + for (int tk = 1; tk < TERMINAL_COUNT; ++tk) { + if (tk == T_AUTOMATIC_SEMICOLON || tk == T_FEED_UI_PROGRAM || + tk == T_FEED_JS_STATEMENT || tk == T_FEED_JS_EXPRESSION || + tk == T_FEED_JS_SOURCE_ELEMENT) + continue; + + int a = t_action(errorState, tk); + if (a > 0 && t_action(a, yytoken)) { + const QString msg = qApp->translate("QmlParser", "Expected token `%1'").arg(QLatin1String(spell[tk])); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + + yytoken = tk; + yylval = 0; + yylloc = token_buffer[0].loc; + yylloc.length = 0; + + action = errorState; + goto _Lcheck_token; + } + } + + const QString msg = qApp->translate("QmlParser", "Syntax error"); + diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, token_buffer[0].loc, msg)); + } + + return false; +} + +} // namespace QbsQmlJS diff --git a/src/lib/corelib/parser/qmljsparser_p.h b/src/lib/corelib/parser/qmljsparser_p.h new file mode 100644 index 00000000..c761bb25 --- /dev/null +++ b/src/lib/corelib/parser/qmljsparser_p.h @@ -0,0 +1,241 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +// +// This file is automatically generated from qmljs.g. +// Changes will be lost. +// + +#ifndef QMLJSPARSER_P_H +#define QMLJSPARSER_P_H + +#include "qmljsglobal_p.h" +#include "qmljsgrammar_p.h" +#include "qmljsast_p.h" +#include "qmljsengine_p.h" +#include + +#include +#include + +namespace QbsQmlJS { + +class Engine; + +class QBS_AUTOTEST_EXPORT Parser: protected QmlJSGrammar +{ +public: + union Value { + int ival; + double dval; + AST::ArgumentList *ArgumentList; + AST::CaseBlock *CaseBlock; + AST::CaseClause *CaseClause; + AST::CaseClauses *CaseClauses; + AST::Catch *Catch; + AST::DefaultClause *DefaultClause; + AST::ElementList *ElementList; + AST::Elision *Elision; + AST::ExpressionNode *Expression; + AST::Finally *Finally; + AST::FormalParameterList *FormalParameterList; + AST::FunctionBody *FunctionBody; + AST::FunctionDeclaration *FunctionDeclaration; + AST::Node *Node; + AST::PropertyName *PropertyName; + AST::PropertyNameAndValueList *PropertyNameAndValueList; + AST::SourceElement *SourceElement; + AST::SourceElements *SourceElements; + AST::Statement *Statement; + AST::StatementList *StatementList; + AST::Block *Block; + AST::VariableDeclaration *VariableDeclaration; + AST::VariableDeclarationList *VariableDeclarationList; + + AST::UiProgram *UiProgram; + AST::UiImportList *UiImportList; + AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; + AST::UiPublicMember *UiPublicMember; + AST::UiObjectDefinition *UiObjectDefinition; + AST::UiObjectInitializer *UiObjectInitializer; + AST::UiObjectBinding *UiObjectBinding; + AST::UiScriptBinding *UiScriptBinding; + AST::UiArrayBinding *UiArrayBinding; + AST::UiObjectMember *UiObjectMember; + AST::UiObjectMemberList *UiObjectMemberList; + AST::UiArrayMemberList *UiArrayMemberList; + AST::UiQualifiedId *UiQualifiedId; + }; + +public: + Parser(Engine *engine); + ~Parser(); + + // parse a UI program + bool parse() { return parse(T_FEED_UI_PROGRAM); } + bool parseStatement() { return parse(T_FEED_JS_STATEMENT); } + bool parseExpression() { return parse(T_FEED_JS_EXPRESSION); } + bool parseSourceElement() { return parse(T_FEED_JS_SOURCE_ELEMENT); } + bool parseUiObjectMember() { return parse(T_FEED_UI_OBJECT_MEMBER); } + bool parseProgram() { return parse(T_FEED_JS_PROGRAM); } + + AST::UiProgram *ast() const + { return AST::cast(program); } + + AST::Statement *statement() const + { + if (! program) + return nullptr; + + return program->statementCast(); + } + + AST::ExpressionNode *expression() const + { + if (! program) + return nullptr; + + return program->expressionCast(); + } + + AST::UiObjectMember *uiObjectMember() const + { + if (! program) + return nullptr; + + return program->uiObjectMemberCast(); + } + + AST::Node *rootNode() const + { return program; } + + QList diagnosticMessages() const + { return diagnostic_messages; } + + inline DiagnosticMessage diagnosticMessage() const + { + foreach (const DiagnosticMessage &d, diagnostic_messages) { + if (d.kind != DiagnosticMessage::Warning) + return d; + } + + return DiagnosticMessage(); + } + + inline QString errorMessage() const + { return diagnosticMessage().message; } + + inline int errorLineNumber() const + { return diagnosticMessage().loc.startLine; } + + inline int errorColumnNumber() const + { return diagnosticMessage().loc.startColumn; } + +protected: + bool parse(int startToken); + + void reallocateStack(); + + inline Value &sym(int index) + { return sym_stack [tos + index - 1]; } + + inline QStringRef &stringRef(int index) + { return string_stack [tos + index - 1]; } + + inline AST::SourceLocation &loc(int index) + { return location_stack [tos + index - 1]; } + + AST::UiQualifiedId *reparseAsQualifiedId(AST::ExpressionNode *expr); + +protected: + Engine *driver; + MemoryPool *pool; + int tos; + int stack_size; + Value *sym_stack; + int *state_stack; + AST::SourceLocation *location_stack; + QStringRef *string_stack; + + AST::Node *program; + + // error recovery + enum { TOKEN_BUFFER_SIZE = 3 }; + + struct SavedToken { + int token = 0; + double dval = 0.0; + AST::SourceLocation loc; + QStringRef spell; + }; + + double yylval = 0.0; + QStringRef yytokenspell; + AST::SourceLocation yylloc; + AST::SourceLocation yyprevlloc; + + SavedToken token_buffer[TOKEN_BUFFER_SIZE]; + SavedToken *first_token; + SavedToken *last_token; + + QList diagnostic_messages; +}; + +} // end of namespace QbsQmlJS + + + +#define J_SCRIPT_REGEXPLITERAL_RULE1 79 + +#define J_SCRIPT_REGEXPLITERAL_RULE2 80 + +#endif // QMLJSPARSER_P_H diff --git a/src/lib/corelib/qbs.h b/src/lib/corelib/qbs.h new file mode 100644 index 00000000..867051c4 --- /dev/null +++ b/src/lib/corelib/qbs.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_H +#define QBS_H + +#include "api/jobs.h" +#include "api/languageinfo.h" +#include "api/project.h" +#include "api/projectdata.h" +#include "api/rulecommand.h" +#include "api/runenvironment.h" +#include "logging/ilogsink.h" +#include "tools/architectures.h" +#include "tools/buildoptions.h" +#include "tools/cleanoptions.h" +#include "tools/codelocation.h" +#include "tools/commandechomode.h" +#include "tools/error.h" +#include "tools/generateoptions.h" +#include "tools/installoptions.h" +#include "tools/preferences.h" +#include "tools/processresult.h" +#include "tools/profile.h" +#include "tools/projectgeneratormanager.h" +#include "tools/settings.h" +#include "tools/settingsmodel.h" +#include "tools/settingsrepresentation.h" +#include "tools/setupprojectparameters.h" +#include "tools/toolchains.h" +#include "tools/version.h" + +#endif // QBS_H diff --git a/src/lib/corelib/tools/applecodesignutils.cpp b/src/lib/corelib/tools/applecodesignutils.cpp new file mode 100644 index 00000000..feae266b --- /dev/null +++ b/src/lib/corelib/tools/applecodesignutils.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "applecodesignutils.h" +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +QByteArray smimeMessageContent(const QByteArray &data) +{ + QCFType decoder = NULL; + if (CMSDecoderCreate(&decoder) != noErr) + return {}; + + if (CMSDecoderUpdateMessage(decoder, data.constData(), data.size()) != noErr) + return {}; + + if (CMSDecoderFinalizeMessage(decoder) != noErr) + return {}; + + QCFType content = NULL; + if (CMSDecoderCopyContent(decoder, &content) != noErr) + return {}; + + return QByteArray::fromCFData(content); +} + +QVariantMap certificateInfo(const QByteArray &data) +{ + const QSslCertificate cert(data, QSsl::Der); + + // Also potentially useful, but these are for signing pkgs which aren't used here + // 1.2.840.113635.100.4.9 - 3rd Party Mac Developer Installer: + // 1.2.840.113635.100.4.13 - Developer ID Installer: + const auto extensions = cert.extensions(); + for (const auto &extension : extensions) { + if (extension.name() == QStringLiteral("extendedKeyUsage")) { + if (!extension.value().toStringList().contains(QStringLiteral("Code Signing"))) + return {}; + } + } + + const auto subjectInfo = [](const QSslCertificate &cert) { + QVariantMap map; + const auto attributes = cert.subjectInfoAttributes(); + for (const auto &attr : attributes) + map.insert(QString::fromUtf8(attr), cert.subjectInfo(attr).front()); + return map; + }; + + return { + {QStringLiteral("SHA1"), cert.digest(QCryptographicHash::Sha1).toHex().toUpper()}, + {QStringLiteral("subjectInfo"), subjectInfo(cert)}, + {QStringLiteral("validBefore"), cert.effectiveDate()}, + {QStringLiteral("validAfter"), cert.expiryDate()} + }; +} + +QVariantMap identitiesProperties() +{ + // Apple documentation states that the Sec* family of functions are not thread-safe on macOS + // https://developer.apple.com/library/mac/documentation/Security/Reference/certifkeytrustservices/ + static std::mutex securityMutex; + std::lock_guard locker(securityMutex); + Q_UNUSED(locker); + + const void *keys[] = {kSecClass, kSecMatchLimit, kSecAttrCanSign}; + const void *values[] = {kSecClassIdentity, kSecMatchLimitAll, kCFBooleanTrue}; + QCFType query = CFDictionaryCreate(kCFAllocatorDefault, + keys, + values, + sizeof(keys) / sizeof(keys[0]), + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + QCFType result = NULL; + if (SecItemCopyMatching(query, &result) != errSecSuccess) + return {}; + + QVariantMap items; + const auto tryAppend = [&](SecIdentityRef identity) { + if (!identity) + return; + + QCFType certificate = NULL; + if (SecIdentityCopyCertificate(identity, &certificate) != errSecSuccess) + return; + + QCFType certificateData = SecCertificateCopyData(certificate); + if (!certificateData) + return; + + auto props = certificateInfo(QByteArray::fromRawCFData(certificateData)); + if (!props.empty()) + items.insert(props[QStringLiteral("SHA1")].toString(), props); + }; + + if (CFGetTypeID(result) == SecIdentityGetTypeID()) { + tryAppend((SecIdentityRef)result.operator const void *()); + } else if (CFGetTypeID(result) == CFArrayGetTypeID()) { + for (CFIndex i = 0; i < CFArrayGetCount((CFArrayRef)result.operator const void *()); ++i) + tryAppend((SecIdentityRef)CFArrayGetValueAtIndex(result.as(), i)); + } + + return items; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/applecodesignutils.h b/src/lib/corelib/tools/applecodesignutils.h new file mode 100644 index 00000000..4ee8e165 --- /dev/null +++ b/src/lib/corelib/tools/applecodesignutils.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_APPLECODESIGNUTILS_H +#define QBS_APPLECODESIGNUTILS_H + +#include "qbs_export.h" +#include + +namespace qbs { +namespace Internal { + +QByteArray smimeMessageContent(const QByteArray &data); +QVariantMap certificateInfo(const QByteArray &data); +QVariantMap identitiesProperties(); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_APPLECODESIGNUTILS_H diff --git a/src/lib/corelib/tools/architectures.cpp b/src/lib/corelib/tools/architectures.cpp new file mode 100644 index 00000000..cf9fec27 --- /dev/null +++ b/src/lib/corelib/tools/architectures.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "architectures.h" + +#include "stringconstants.h" + +#include +#include + +namespace qbs { + +using namespace Internal; + +QString canonicalTargetArchitecture(const QString &architecture, + const QString &endianness, + const QString &vendor, + const QString &system, + const QString &abi) +{ + const QString arch = canonicalArchitecture(architecture); + const bool isApple = (vendor == QStringLiteral("apple") + || system == QStringLiteral("darwin") + || system == QStringLiteral("macosx") + || system == QStringLiteral("ios") + || system == QStringLiteral("tvos") + || system == QStringLiteral("watchos") + || abi == QStringLiteral("macho")); + const bool isQnx = (system == QStringLiteral("nto") + || abi.startsWith(QStringLiteral("qnx"))); + + if (arch == QStringLiteral("armv7a")) { + if (isApple) + return StringConstants::armv7Arch(); + if (isQnx) + return StringConstants::armArch(); + } + + if (arch == StringConstants::arm64Arch() && isQnx) + return StringConstants::aarch64Arch(); + + if (arch == StringConstants::x86Arch()) { + if (isQnx) + return StringConstants::i586Arch(); + return StringConstants::i386Arch(); + } + + if (arch == StringConstants::mipsArch() || arch == StringConstants::mips64Arch()) { + if (endianness == QStringLiteral("big")) + return arch + QStringLiteral("eb"); + if (endianness == QStringLiteral("little")) + return arch + QStringLiteral("el"); + } + + if (arch == StringConstants::ppcArch()) + return StringConstants::powerPcArch(); + + if (arch == StringConstants::ppc64Arch() && endianness == QStringLiteral("little")) + return arch + QStringLiteral("le"); + + return arch; +} + +QString canonicalArchitecture(const QString &architecture) +{ + QMap archMap; + archMap.insert(StringConstants::x86Arch(), QStringList() + << StringConstants::i386Arch() + << QStringLiteral("i486") + << StringConstants::i586Arch() + << QStringLiteral("i686") + << QStringLiteral("ia32") + << QStringLiteral("ia-32") + << QStringLiteral("x86_32") + << QStringLiteral("x86-32") + << QStringLiteral("intel32") + << QStringLiteral("mingw32")); + + archMap.insert(StringConstants::x86_64Arch(), QStringList() + << QStringLiteral("x86-64") + << QStringLiteral("x64") + << StringConstants::amd64Arch() + << QStringLiteral("ia32e") + << QStringLiteral("em64t") + << QStringLiteral("intel64") + << QStringLiteral("mingw64")); + + archMap.insert(StringConstants::arm64Arch(), QStringList() + << StringConstants::aarch64Arch()); + + archMap.insert(QStringLiteral("ia64"), QStringList() + << QStringLiteral("ia-64") + << QStringLiteral("itanium")); + + archMap.insert(StringConstants::ppcArch(), QStringList() + << StringConstants::powerPcArch()); + + archMap.insert(StringConstants::ppc64Arch(), QStringList() + << QStringLiteral("ppc64le") + << QStringLiteral("powerpc64") + << QStringLiteral("powerpc64le")); + + archMap.insert(StringConstants::mipsArch(), QStringList() + << QStringLiteral("mipseb") + << QStringLiteral("mipsel")); + + archMap.insert(StringConstants::mips64Arch(), QStringList() + << QStringLiteral("mips64eb") + << QStringLiteral("mips64el")); + + QMapIterator i(archMap); + while (i.hasNext()) { + i.next(); + if (i.value().contains(architecture.toLower())) + return i.key(); + } + + return architecture; + +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/architectures.h b/src/lib/corelib/tools/architectures.h new file mode 100644 index 00000000..03852069 --- /dev/null +++ b/src/lib/corelib/tools/architectures.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_ARCHITECTURES_H +#define QBS_ARCHITECTURES_H + +#include "qbs_export.h" + +#include + +namespace qbs { + +QBS_EXPORT QString canonicalTargetArchitecture(const QString &architecture, + const QString &endianness, + const QString &vendor, + const QString &system, + const QString &abi); + +QBS_EXPORT QString canonicalArchitecture(const QString &architecture); + +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/tools/buildgraphlocker.cpp b/src/lib/corelib/tools/buildgraphlocker.cpp new file mode 100644 index 00000000..28a58e3f --- /dev/null +++ b/src/lib/corelib/tools/buildgraphlocker.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "buildgraphlocker.h" + +#include "error.h" +#include "hostosinfo.h" +#include "processutils.h" +#include "progressobserver.h" +#include "stringconstants.h" + +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +DirectoryManager::DirectoryManager(QString dir, Logger logger) + : m_dir(std::move(dir)), m_logger(std::move(logger)) +{ + rememberCreatedDirectories(); +} + +DirectoryManager::~DirectoryManager() +{ + removeEmptyCreatedDirectories(); +} + +void DirectoryManager::rememberCreatedDirectories() +{ + QString parentDir = m_dir; + while (!QFileInfo::exists(parentDir)) { + m_createdParentDirs.push(parentDir); + parentDir = QDir::cleanPath(parentDir + StringConstants::slashDotDot()); + } +} + +void DirectoryManager::removeEmptyCreatedDirectories() +{ + QDir root = QDir::root(); + while (!m_createdParentDirs.empty()) { + const QString parentDir = m_createdParentDirs.front(); + m_createdParentDirs.pop(); + QDirIterator it(parentDir, QDir::AllEntries | QDir::NoDotAndDotDot | QDir::System, + QDirIterator::Subdirectories); + if (it.hasNext()) + break; + if (!root.rmdir(parentDir) && m_logger.logSink()) { + m_logger.printWarning(ErrorInfo(Tr::tr("Failed to remove empty directory '%1'.") + .arg(parentDir))); + } + } +} + +static void tryCreateBuildDirectory(const QString &buildDir, const QString &buildGraphFilePath) +{ + if (!QDir::root().mkpath(buildDir)) { + throw ErrorInfo(Tr::tr("Cannot lock build graph file '%1': Failed to create directory.") + .arg(buildGraphFilePath)); + } +} + +static bool appNamesAreEqual(const QString &app1, const QString &app2) +{ + return QString::compare(app1, app2, HostOsInfo::fileNameCaseSensitivity()) == 0; +} + +BuildGraphLocker::BuildGraphLocker(const QString &buildGraphFilePath, const Logger &logger, + bool waitIndefinitely, ProgressObserver *observer) + : m_lockFile(buildGraphFilePath + QStringLiteral(".lock")) + , m_logger(logger) + , m_dirManager(QFileInfo(buildGraphFilePath).absolutePath(), logger) +{ + if (waitIndefinitely) + m_logger.qbsDebug() << "Waiting to acquire lock file..."; + m_lockFile.setStaleLockTime(0); + int attemptsToGetInfo = 0; + do { + if (observer && observer->canceled()) + break; + tryCreateBuildDirectory(m_dirManager.dir(), buildGraphFilePath); + if (m_lockFile.tryLock(250)) + return; + switch (m_lockFile.error()) { + case QLockFile::LockFailedError: { + if (waitIndefinitely) + continue; + qint64 pid; + QString hostName; + QString appName; + if (m_lockFile.getLockInfo(&pid, &hostName, &appName)) { + if (appNamesAreEqual(appName, processNameByPid(pid))) { + throw ErrorInfo(Tr::tr("Cannot lock build graph file '%1': " + "Already locked by '%2' (PID %3).") + .arg(buildGraphFilePath, appName).arg(pid)); + } + + // The process id was reused by some other process. + m_logger.qbsInfo() << Tr::tr("Removing stale lock file."); + m_lockFile.removeStaleLockFile(); + } + break; + } + case QLockFile::PermissionError: + throw ErrorInfo(Tr::tr("Cannot lock build graph file '%1': Permission denied.") + .arg(buildGraphFilePath)); + case QLockFile::UnknownError: + case QLockFile::NoError: + throw ErrorInfo(Tr::tr("Cannot lock build graph file '%1' (reason unknown).") + .arg(buildGraphFilePath)); + } + } while (++attemptsToGetInfo < 10 || waitIndefinitely); + + // This very unlikely case arises if tryLock() repeatedly returns LockFailedError + // with the subsequent getLockInfo() failing as well. + throw ErrorInfo(Tr::tr("Cannot lock build graph file '%1' (reason unknown).") + .arg(buildGraphFilePath)); +} + +BuildGraphLocker::~BuildGraphLocker() +{ + m_lockFile.unlock(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/buildgraphlocker.h b/src/lib/corelib/tools/buildgraphlocker.h new file mode 100644 index 00000000..f85fc076 --- /dev/null +++ b/src/lib/corelib/tools/buildgraphlocker.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_BUILDGRAPHLOCKER_H +#define QBS_BUILDGRAPHLOCKER_H + +#include + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class ProgressObserver; + +class DirectoryManager +{ +public: + DirectoryManager(QString dir, Logger logger); + ~DirectoryManager(); + QString dir() const { return m_dir; } + +private: + void rememberCreatedDirectories(); + void removeEmptyCreatedDirectories(); + + std::queue m_createdParentDirs; + const QString m_dir; + Logger m_logger; +}; + +class BuildGraphLocker +{ +public: + explicit BuildGraphLocker(const QString &buildGraphFilePath, const Logger &logger, + bool waitIndefinitely, ProgressObserver *observer); + ~BuildGraphLocker(); + +private: + QLockFile m_lockFile; + Logger m_logger; + DirectoryManager m_dirManager; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/tools/buildoptions.cpp b/src/lib/corelib/tools/buildoptions.cpp new file mode 100644 index 00000000..e4e9ba17 --- /dev/null +++ b/src/lib/corelib/tools/buildoptions.cpp @@ -0,0 +1,463 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "buildoptions.h" + +#include "jsonhelper.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { + +class BuildOptionsPrivate : public QSharedData +{ +public: + BuildOptionsPrivate() + : maxJobCount(0), dryRun(false), keepGoing(false), forceTimestampCheck(false), + forceOutputCheck(false), + logElapsedTime(false), echoMode(defaultCommandEchoMode()), install(true), + removeExistingInstallation(false), onlyExecuteRules(false) + { + } + + QStringList changedFiles; + QStringList filesToConsider; + QStringList activeFileTags; + JobLimits jobLimits; + QString settingsDir; + int maxJobCount; + bool dryRun; + bool keepGoing; + bool forceTimestampCheck; + bool forceOutputCheck; + bool logElapsedTime; + CommandEchoMode echoMode; + bool install; + bool removeExistingInstallation; + bool onlyExecuteRules; + bool jobLimitsFromProjectTakePrecedence = false; +}; + +} // namespace Internal + +/*! + * \class BuildOptions + * \brief The \c BuildOptions class comprises parameters that influence the behavior of + * build and clean operations. + */ + +/*! + * \brief Creates a \c BuildOptions object and initializes its members to sensible default values. + */ +BuildOptions::BuildOptions() : d(new Internal::BuildOptionsPrivate) +{ +} + +BuildOptions::BuildOptions(const BuildOptions &other) = default; + +BuildOptions &BuildOptions::operator=(const BuildOptions &other) = default; + +BuildOptions::~BuildOptions() = default; + +/*! + * \brief If non-empty, qbs pretends that only these files have changed. + * By default, this list is empty. + */ +QStringList BuildOptions::changedFiles() const +{ + return d->changedFiles; +} + +/*! + * \brief If the given list is empty, qbs will pretend only the listed files are changed. + * \note The list elements must be absolute file paths. + */ +void BuildOptions::setChangedFiles(const QStringList &changedFiles) +{ + d->changedFiles = changedFiles; +} + +/*! + * \brief The list of files to consider. + * \sa setFilesToConsider. + * By default, this list is empty. + */ +QStringList BuildOptions::filesToConsider() const +{ + return d->filesToConsider; +} + +/*! + * \brief If the given list is non-empty, qbs will run only commands whose rule has at least one + * of these files as an input. + * \note The list elements must be absolute file paths. + */ +void BuildOptions::setFilesToConsider(const QStringList &files) +{ + d->filesToConsider = files; +} + +/*! + * \brief The list of active file tags. + * \sa setActiveFileTags + */ +QStringList BuildOptions::activeFileTags() const +{ + return d->activeFileTags; +} + +/*! + * \brief Set the list of active file tags. + * If this list is non-empty, then every transformer with non-matching output file tags is skipped. + * E.g. call \c setFilesToConsider() with "foo.cpp" and \c setActiveFileTags() with "obj" to + * run the compiler on foo.cpp without further processing like linking. + * \sa activeFileTags + */ +void BuildOptions::setActiveFileTags(const QStringList &fileTags) +{ + d->activeFileTags = fileTags; +} + +/*! + * \brief Returns the default value for \c maxJobCount. + * This value will be used when \c maxJobCount has not been set explicitly. + */ +int BuildOptions::defaultMaxJobCount() +{ + return QThread::idealThreadCount(); +} + +/*! + * \brief Returns the maximum number of build commands to run concurrently. + * If the value is not valid (i.e. <= 0), a sensible one will be derived at build time + * from the number of available processor cores at build time. + * The default is 0. + * \sa BuildOptions::defaultMaxJobCount + */ +int BuildOptions::maxJobCount() const +{ + return d->maxJobCount; +} + +/*! + * \brief Controls how many build commands can be run in parallel. + * A value <= 0 leaves the decision to qbs. + */ +void BuildOptions::setMaxJobCount(int jobCount) +{ + d->maxJobCount = jobCount; +} + +/*! + * \brief The base directory for qbs settings. + * This value is used to locate profiles and preferences. + */ +QString BuildOptions::settingsDirectory() const +{ + return d->settingsDir; +} + +/*! + * \brief Sets the base directory for qbs settings. + * \param settingsBaseDir Will be used to locate profiles and preferences. + */ +void BuildOptions::setSettingsDirectory(const QString &settingsBaseDir) +{ + d->settingsDir = settingsBaseDir; +} + +JobLimits BuildOptions::jobLimits() const +{ + return d->jobLimits; +} + +void BuildOptions::setJobLimits(const JobLimits &jobLimits) +{ + d->jobLimits = jobLimits; +} + +bool BuildOptions::projectJobLimitsTakePrecedence() const +{ + return d->jobLimitsFromProjectTakePrecedence; +} + +void BuildOptions::setProjectJobLimitsTakePrecedence(bool toggle) +{ + d->jobLimitsFromProjectTakePrecedence = toggle; +} + +/*! + * \brief Returns true iff qbs will not actually execute any commands, but just show what + * would happen. + * The default is false. + */ +bool BuildOptions::dryRun() const +{ + return d->dryRun; +} + +/*! + * \brief Controls whether qbs will actually build something. + * If the argument is true, qbs will just emit information about what it would do. Otherwise, + * the build is actually done. + * \note After you build with this setting enabled, the next call to \c build() on the same + * \c Project object will do nothing, since the internal state needs to be updated the same way + * as if an actual build had happened. You'll need to create a new \c Project object to do + * a real build afterwards. + */ +void BuildOptions::setDryRun(bool dryRun) +{ + d->dryRun = dryRun; +} + +/*! + * \brief Returns true iff a build will continue after an error. + * E.g. a failed compile command will result in a warning message being printed, instead of + * stopping the build process right away. However, there might still be fatal errors after which the + * build process cannot continue. + * The default is \c false. + */ +bool BuildOptions::keepGoing() const +{ + return d->keepGoing; +} + +/*! + * \brief Controls whether a qbs will try to continue building after an error has occurred. + */ +void BuildOptions::setKeepGoing(bool keepGoing) +{ + d->keepGoing = keepGoing; +} + +/*! + * \brief Returns true if qbs is to use physical timestamps instead of the timestamps stored in the + * build graph. + * The default is \c false. + */ +bool BuildOptions::forceTimestampCheck() const +{ + return d->forceTimestampCheck; +} + +/*! + * \brief Controls whether qbs should use physical timestamps for up-to-date checks. + */ +void BuildOptions::setForceTimestampCheck(bool enabled) +{ + d->forceTimestampCheck = enabled; +} + +/*! + * \brief Returns true if qbs will test whether rules actually create their + * declared output artifacts. + * The default is \c false. + */ +bool BuildOptions::forceOutputCheck() const +{ + return d->forceOutputCheck; +} + +/*! + * \brief Controls whether qbs should test whether rules actually create their + * declared output artifacts. Enabling this may introduce some small I/O overhead during the build. + */ +void BuildOptions::setForceOutputCheck(bool enabled) +{ + d->forceOutputCheck = enabled; +} + +/*! + * \brief Returns true iff the time the operation takes will be logged. + * The default is \c false. + */ +bool BuildOptions::logElapsedTime() const +{ + return d->logElapsedTime; +} + +/*! + * \brief Controls whether the build time will be measured and logged. + */ +void BuildOptions::setLogElapsedTime(bool log) +{ + d->logElapsedTime = log; +} + +/*! + * \brief The kind of output that is displayed when executing commands. + */ +CommandEchoMode BuildOptions::echoMode() const +{ + return d->echoMode; +} + +/*! + * \brief Controls the kind of output that is displayed when executing commands. + */ +void BuildOptions::setEchoMode(CommandEchoMode echoMode) +{ + d->echoMode = echoMode; +} + +/*! + * \brief Returns true iff installation should happen as part of the build. + * The default is \c true. + */ +bool BuildOptions::install() const +{ + return d->install; +} + +/*! + * \brief Controls whether to install artifacts as part of the build process. + */ +void BuildOptions::setInstall(bool install) +{ + d->install = install; +} + +/*! + * \brief Returns true iff an existing installation will be removed prior to building. + * The default is false. + */ +bool BuildOptions::removeExistingInstallation() const +{ + return d->removeExistingInstallation; +} + +/*! + * Controls whether to remove an existing installation before installing. + * \note qbs may do some safety checks and refuse to remove certain directories such as + * a user's home directory. You should still be careful with this option, since it + * deletes recursively. + */ +void BuildOptions::setRemoveExistingInstallation(bool removeExisting) +{ + d->removeExistingInstallation = removeExisting; +} + +/*! + * \brief Returns true iff instead of a full build, only the rules of the project will be run. + * The default is false. + */ +bool BuildOptions::executeRulesOnly() const +{ + return d->onlyExecuteRules; +} + +/*! + * If \a onlyRules is \c true, then no artifacts are built, but only rules are being executed. + * \note If the project contains highly dynamic rules that depend on output artifacts of child + * rules being already present, then the associated build job may fail even though + * the project is perfectly valid. Callers need to take this into consideration. + */ +void BuildOptions::setExecuteRulesOnly(bool onlyRules) +{ + d->onlyExecuteRules = onlyRules; +} + + +bool operator==(const BuildOptions &bo1, const BuildOptions &bo2) +{ + return bo1.changedFiles() == bo2.changedFiles() + && bo1.dryRun() == bo2.dryRun() + && bo1.keepGoing() == bo2.keepGoing() + && bo1.logElapsedTime() == bo2.logElapsedTime() + && bo1.echoMode() == bo2.echoMode() + && bo1.maxJobCount() == bo2.maxJobCount() + && bo1.install() == bo2.install() + && bo1.removeExistingInstallation() == bo2.removeExistingInstallation(); +} + +namespace Internal { +template<> JobLimits fromJson(const QJsonValue &limitsData) +{ + JobLimits limits; + const QJsonArray &limitsArray = limitsData.toArray(); + for (const QJsonValue &v : limitsArray) { + const QJsonObject limitData = v.toObject(); + QString pool; + int limit = 0; + setValueFromJson(pool, limitData, "pool"); + setValueFromJson(limit, limitData, "limit"); + if (!pool.isEmpty() && limit > 0) + limits.setJobLimit(pool, limit); + } + return limits; +} + +template<> CommandEchoMode fromJson(const QJsonValue &modeData) +{ + const QString modeString = modeData.toString(); + if (modeString == QLatin1String("silent")) + return CommandEchoModeSilent; + if (modeString == QLatin1String("command-line")) + return CommandEchoModeCommandLine; + if (modeString == QLatin1String("command-line-with-environment")) + return CommandEchoModeCommandLineWithEnvironment; + return CommandEchoModeSummary; +} +} // namespace Internal + +qbs::BuildOptions qbs::BuildOptions::fromJson(const QJsonObject &data) +{ + using namespace Internal; + BuildOptions opt; + setValueFromJson(opt.d->changedFiles, data, "changed-files"); + setValueFromJson(opt.d->filesToConsider, data, "files-to-consider"); + setValueFromJson(opt.d->activeFileTags, data, "active-file-tags"); + setValueFromJson(opt.d->jobLimits, data, "job-limits"); + setValueFromJson(opt.d->maxJobCount, data, "max-job-count"); + setValueFromJson(opt.d->dryRun, data, "dry-run"); + setValueFromJson(opt.d->keepGoing, data, "keep-going"); + setValueFromJson(opt.d->forceTimestampCheck, data, "check-timestamps"); + setValueFromJson(opt.d->forceOutputCheck, data, "check-outputs"); + setValueFromJson(opt.d->logElapsedTime, data, "log-time"); + setValueFromJson(opt.d->echoMode, data, "command-echo-mode"); + setValueFromJson(opt.d->install, data, "install"); + setValueFromJson(opt.d->removeExistingInstallation, data, "clean-install-root"); + setValueFromJson(opt.d->onlyExecuteRules, data, "only-execute-rules"); + setValueFromJson(opt.d->jobLimitsFromProjectTakePrecedence, data, "enforce-project-job-limits"); + return opt; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/buildoptions.h b/src/lib/corelib/tools/buildoptions.h new file mode 100644 index 00000000..59b87237 --- /dev/null +++ b/src/lib/corelib/tools/buildoptions.h @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_BUILDOPTIONS_H +#define QBS_BUILDOPTIONS_H + +#include "qbs_export.h" + +#include "commandechomode.h" +#include "joblimits.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QJsonObject; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { class BuildOptionsPrivate; } + +class QBS_EXPORT BuildOptions +{ +public: + BuildOptions(); + BuildOptions(const BuildOptions &other); + BuildOptions &operator=(const BuildOptions &other); + ~BuildOptions(); + + static BuildOptions fromJson(const QJsonObject &data); + + QStringList filesToConsider() const; + void setFilesToConsider(const QStringList &files); + + QStringList changedFiles() const; + void setChangedFiles(const QStringList &changedFiles); + + QStringList activeFileTags() const; + void setActiveFileTags(const QStringList &fileTags); + + static int defaultMaxJobCount(); + int maxJobCount() const; + void setMaxJobCount(int jobCount); + + QString settingsDirectory() const; + void setSettingsDirectory(const QString &settingsBaseDir); + + JobLimits jobLimits() const; + void setJobLimits(const JobLimits &jobLimits); + + bool projectJobLimitsTakePrecedence() const; + void setProjectJobLimitsTakePrecedence(bool toggle); + + bool dryRun() const; + void setDryRun(bool dryRun); + + bool keepGoing() const; + void setKeepGoing(bool keepGoing); + + bool forceTimestampCheck() const; + void setForceTimestampCheck(bool enabled); + + bool forceOutputCheck() const; + void setForceOutputCheck(bool enabled); + + bool logElapsedTime() const; + void setLogElapsedTime(bool log); + + CommandEchoMode echoMode() const; + void setEchoMode(CommandEchoMode echoMode); + + bool install() const; + void setInstall(bool install); + + bool removeExistingInstallation() const; + void setRemoveExistingInstallation(bool removeExisting); + + bool executeRulesOnly() const; + void setExecuteRulesOnly(bool onlyRules); + +private: + QSharedDataPointer d; +}; + +bool operator==(const BuildOptions &bo1, const BuildOptions &bo2); +inline bool operator!=(const BuildOptions &bo1, const BuildOptions &bo2) { return !(bo1 == bo2); } + +} // namespace qbs + +#endif // QBS_BUILDOPTIONS_H diff --git a/src/lib/corelib/tools/clangclinfo.cpp b/src/lib/corelib/tools/clangclinfo.cpp new file mode 100644 index 00000000..a9a1cb44 --- /dev/null +++ b/src/lib/corelib/tools/clangclinfo.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "clangclinfo.h" + +#include "hostosinfo.h" +#include "msvcinfo.h" +#include "stlutils.h" + +namespace qbs { +namespace Internal { + +static std::vector compatibleMsvcs(Logger &logger) +{ + auto msvcs = MSVCInstallInfo::installedMSVCs(logger); + auto filter = [](const MSVCInstallInfo &info) + { + const auto versions = info.version.split(QLatin1Char('.')); + if (versions.empty()) + return true; + bool ok = false; + const int major = versions.at(0).toInt(&ok); + return !(ok && major >= 15); // support MSVC2017 and above + }; + Internal::removeIf(msvcs, filter); + for (const auto &msvc: msvcs) { + auto vcvarsallPath = msvc.findVcvarsallBat(); + if (vcvarsallPath.isEmpty()) + continue; + } + return msvcs; +} + +static QString findCompatibleVcsarsallBat(const std::vector &msvcs) +{ + for (const auto &msvc: msvcs) { + const auto vcvarsallPath = msvc.findVcvarsallBat(); + if (!vcvarsallPath.isEmpty()) + return vcvarsallPath; + } + return {}; +} + +static QString wow6432Key() +{ +#ifdef Q_OS_WIN64 + return QStringLiteral("\\Wow6432Node"); +#else + return {}; +#endif +} + +static QString getToolchainInstallPath(const QFileInfo &compiler) +{ + return compiler.path(); // 1 level up +} + +QVariantMap ClangClInfo::toVariantMap() const +{ + return { + {QStringLiteral("toolchainInstallPath"), toolchainInstallPath}, + {QStringLiteral("vcvarsallPath"), vcvarsallPath}, + }; +} + +ClangClInfo ClangClInfo::fromCompilerFilePath(const QString &path, Logger &logger) +{ + const auto compilerName = QStringLiteral("clang-cl"); + const auto vcvarsallPath = findCompatibleVcsarsallBat(compatibleMsvcs(logger)); + if (vcvarsallPath.isEmpty()) { + logger.qbsWarning() + << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.") + .arg(compilerName); + return {}; + } + + return {getToolchainInstallPath(QFileInfo(path)), vcvarsallPath}; +} + +std::vector ClangClInfo::installedCompilers( + const std::vector &extraPaths, Logger &logger) +{ + std::vector compilerPaths; + compilerPaths.reserve(extraPaths.size()); + std::copy_if(extraPaths.begin(), extraPaths.end(), + std::back_inserter(compilerPaths), + [](const QString &path){ return !path.isEmpty(); }); + const auto compilerName = HostOsInfo::appendExecutableSuffix(QStringLiteral("clang-cl")); + + const QSettings registry( + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE%1\\LLVM\\LLVM").arg(wow6432Key()), + QSettings::NativeFormat); + const auto key = QStringLiteral("."); + if (registry.contains(key)) { + const auto compilerPath = QDir::fromNativeSeparators(registry.value(key).toString()) + + QStringLiteral("/bin/") + compilerName; + if (QFileInfo::exists(compilerPath)) + compilerPaths.push_back(compilerPath); + } + + // this branch can be useful in case user had two LLVM installations (e.g. 32bit & 64bit) + // but uninstalled one - in that case, registry will be empty + static const char * const envVarCandidates[] = {"ProgramFiles", "ProgramFiles(x86)"}; + for (const auto &envVar : envVarCandidates) { + const auto value + = QDir::fromNativeSeparators(QString::fromLocal8Bit(qgetenv(envVar))); + const auto compilerPath = value + QStringLiteral("/LLVM/bin/") + compilerName; + if (QFileInfo::exists(compilerPath) && !contains(compilerPaths, compilerPath)) + compilerPaths.push_back(compilerPath); + } + + const auto msvcs = compatibleMsvcs(logger); + const auto vcvarsallPath = findCompatibleVcsarsallBat(msvcs); + if (vcvarsallPath.isEmpty()) { + logger.qbsWarning() + << Tr::tr("%1 requires installed Visual Studio 2017 or newer, but none was found.") + .arg(compilerName); + return {}; + } + + std::vector result; + result.reserve(compilerPaths.size() + msvcs.size()); + transform(compilerPaths, result, [&vcvarsallPath](const auto &path) { + return ClangClInfo{getToolchainInstallPath(QFileInfo(path)), vcvarsallPath}; }); + + // If we didn't find custom LLVM installation, try to find if it's installed with Visual Studio + for (const auto &msvc : msvcs) { + const auto compilerPath = QStringLiteral("%1/VC/Tools/Llvm/bin/%2") + .arg(msvc.installDir, compilerName); + if (QFileInfo::exists(compilerPath)) { + const auto vcvarsallPath = msvc.findVcvarsallBat(); + if (vcvarsallPath.isEmpty()) { + logger.qbsWarning() + << Tr::tr("Found LLVM in %1, but vcvarsall.bat is missing.") + .arg(msvc.installDir); + } + + result.push_back({getToolchainInstallPath(QFileInfo(compilerPath)), vcvarsallPath}); + } + } + + return result; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/clangclinfo.h b/src/lib/corelib/tools/clangclinfo.h new file mode 100644 index 00000000..76ae169f --- /dev/null +++ b/src/lib/corelib/tools/clangclinfo.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Ivan Komissarov (abbapoh@gmail.com) +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_CLANGCLINFO_H +#define QBS_CLANGCLINFO_H + +#include "logging/logger.h" + +#include + +#include + +namespace qbs { +namespace Internal { + +class ClangClInfo +{ +public: + QString toolchainInstallPath; + QString vcvarsallPath; + + bool isEmpty() const { return toolchainInstallPath.isEmpty() && vcvarsallPath.isEmpty(); } + + QBS_EXPORT QVariantMap toVariantMap() const; + + QBS_EXPORT static ClangClInfo fromCompilerFilePath(const QString &path, Logger &logger); + QBS_EXPORT static std::vector installedCompilers( + const std::vector &extraPaths, qbs::Internal::Logger &logger); +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_CLANGCLINFO_H diff --git a/src/lib/corelib/tools/cleanoptions.cpp b/src/lib/corelib/tools/cleanoptions.cpp new file mode 100644 index 00000000..affc9b3f --- /dev/null +++ b/src/lib/corelib/tools/cleanoptions.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "cleanoptions.h" + +#include "jsonhelper.h" + +#include + +namespace qbs { +namespace Internal { + +class CleanOptionsPrivate : public QSharedData +{ +public: + CleanOptionsPrivate() + : dryRun(false), + keepGoing(false), logElapsedTime(false) + { } + + bool dryRun; + bool keepGoing; + bool logElapsedTime; +}; + +} // namespace Internal + +/*! + * \class CleanOptions + * \brief The \c CleanOptions class comprises parameters that influence the behavior of + * cleaning operations. + */ + +/*! + * \enum CleanOptions::CleanType + * This enum type specifies which kind of build artifacts to remove. + * \value CleanupAll Indicates that all files created by the build process should be removed. + * \value CleanupTemporaries Indicates that only intermediate build artifacts should be removed. + * If, for example, the product to clean up for is a Linux shared library, the .so file + * would be left on the disk, but the .o files would be removed. + */ + +CleanOptions::CleanOptions() : d(new Internal::CleanOptionsPrivate) +{ +} + +CleanOptions::CleanOptions(const CleanOptions &other) = default; + +CleanOptions::CleanOptions(CleanOptions &&other) Q_DECL_NOEXCEPT = default; + +CleanOptions &CleanOptions::operator=(const CleanOptions &other) = default; + +CleanOptions &CleanOptions::operator=(CleanOptions &&other) Q_DECL_NOEXCEPT = default; + +CleanOptions::~CleanOptions() = default; + +/*! + * \brief Returns true iff qbs will not actually remove any files, but just show what would happen. + * The default is false. + */ +bool CleanOptions::dryRun() const +{ + return d->dryRun; +} + +/*! + * \brief Controls whether clean-up will actually take place. + * If the argument is true, then qbs will emit information about which files would be removed + * instead of actually doing it. + */ +void CleanOptions::setDryRun(bool dryRun) +{ + d->dryRun = dryRun; +} + +/*! + * Returns true iff clean-up will continue if an error occurs. + * The default is false. + */ +bool CleanOptions::keepGoing() const +{ + return d->keepGoing; +} + +/*! + * \brief Controls whether to abort on errors. + * If the argument is true, then if a file cannot be removed e.g. due to a permission problem, + * a warning will be printed and the clean-up will continue. If the argument is false, + * then the clean-up will abort immediately in case of an error. + */ +void CleanOptions::setKeepGoing(bool keepGoing) +{ + d->keepGoing = keepGoing; +} + +/*! + * \brief Returns true iff the time the operation takes will be logged. + * The default is false. + */ +bool CleanOptions::logElapsedTime() const +{ + return d->logElapsedTime; +} + +/*! + * \brief Controls whether the clean-up time will be measured and logged. + */ +void CleanOptions::setLogElapsedTime(bool log) +{ + d->logElapsedTime = log; +} + +qbs::CleanOptions qbs::CleanOptions::fromJson(const QJsonObject &data) +{ + CleanOptions opt; + using namespace Internal; + setValueFromJson(opt.d->dryRun, data, "dry-run"); + setValueFromJson(opt.d->keepGoing, data, "keep-going"); + setValueFromJson(opt.d->logElapsedTime, data, "log-time"); + return opt; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/cleanoptions.h b/src/lib/corelib/tools/cleanoptions.h new file mode 100644 index 00000000..7827697b --- /dev/null +++ b/src/lib/corelib/tools/cleanoptions.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_CLEANOPTIONS_H +#define QBS_CLEANOPTIONS_H + +#include "qbs_export.h" + +#include + +QT_BEGIN_NAMESPACE +class QJsonObject; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { class CleanOptionsPrivate; } + +class QBS_EXPORT CleanOptions +{ +public: + CleanOptions(); + CleanOptions(const CleanOptions &other); + CleanOptions(CleanOptions &&other) Q_DECL_NOEXCEPT; + CleanOptions &operator=(const CleanOptions &other); + CleanOptions &operator=(CleanOptions &&other) Q_DECL_NOEXCEPT; + ~CleanOptions(); + + static CleanOptions fromJson(const QJsonObject &data); + + bool dryRun() const; + void setDryRun(bool dryRun); + + bool keepGoing() const; + void setKeepGoing(bool keepGoing); + + bool logElapsedTime() const; + void setLogElapsedTime(bool log); + +private: + QSharedDataPointer d; +}; + +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/codelocation.cpp b/src/lib/corelib/tools/codelocation.cpp new file mode 100644 index 00000000..ebfd5edc --- /dev/null +++ b/src/lib/corelib/tools/codelocation.cpp @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "codelocation.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace qbs { + +class CodeLocation::CodeLocationPrivate : public QSharedData +{ +public: + void load(Internal::PersistentPool &pool) + { + pool.load(filePath); + pool.load(line); + pool.load(column); + } + + void store(Internal::PersistentPool &pool) const + { + pool.store(filePath); + pool.store(line); + pool.store(column); + } + + QString filePath; + int line = 0; + int column = 0; +}; + +CodeLocation::CodeLocation() = default; + +CodeLocation::CodeLocation(const QString &aFilePath, int aLine, int aColumn, bool checkPath) + : d(new CodeLocationPrivate) +{ + QBS_ASSERT(!checkPath || Internal::FileInfo::isAbsolute(aFilePath), qDebug() << aFilePath); + d->filePath = aFilePath; + d->line = aLine; + d->column = aColumn; +} + +CodeLocation::CodeLocation(const CodeLocation &other) = default; + +CodeLocation &CodeLocation::operator=(const CodeLocation &other) = default; + +CodeLocation::~CodeLocation() = default; + +QString CodeLocation::filePath() const +{ + return d ? d->filePath : QString(); +} + +int CodeLocation::line() const +{ + return d ? d->line : -1; +} + +int CodeLocation::column() const +{ + return d ? d->column : -1; +} + +bool CodeLocation::isValid() const +{ + return !filePath().isEmpty(); +} + +QString CodeLocation::toString() const +{ + QString str; + if (isValid()) { + str = QDir::toNativeSeparators(filePath()); + QString lineAndColumn; + if (line() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+$")))) + lineAndColumn += QLatin1Char(':') + QString::number(line()); + if (column() > 0 && !str.contains(QRegularExpression(QStringLiteral(":[0-9]+:[0-9]+$")))) + lineAndColumn += QLatin1Char(':') + QString::number(column()); + str += lineAndColumn; + } + return str; +} + +QJsonObject CodeLocation::toJson() const +{ + QJsonObject obj; + if (!filePath().isEmpty()) + obj.insert(Internal::StringConstants::filePathKey(), filePath()); + if (line() != -1) + obj.insert(QStringLiteral("line"), line()); + if (column() != -1) + obj.insert(QStringLiteral("column"), column()); + return obj; +} + +void CodeLocation::load(Internal::PersistentPool &pool) +{ + const bool isValid = pool.load(); + if (!isValid) + return; + d = new CodeLocationPrivate; + pool.load(*d); +} + +void CodeLocation::store(Internal::PersistentPool &pool) const +{ + if (d) { + pool.store(true); + pool.store(*d); + } else { + pool.store(false); + } +} + +bool operator==(const CodeLocation &cl1, const CodeLocation &cl2) +{ + if (cl1.d == cl2.d) + return true; + return cl1.filePath() == cl2.filePath() && cl1.line() == cl2.line() + && cl1.column() == cl2.column(); +} + +bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2) +{ + return !(cl1 == cl2); +} + +QDebug operator<<(QDebug debug, const CodeLocation &location) +{ + return debug << location.toString(); +} + +bool operator<(const CodeLocation &cl1, const CodeLocation &cl2) +{ + return cl1.toString() < cl2.toString(); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/codelocation.h b/src/lib/corelib/tools/codelocation.h new file mode 100644 index 00000000..158b9076 --- /dev/null +++ b/src/lib/corelib/tools/codelocation.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SOURCELOCATION_H +#define QBS_SOURCELOCATION_H + +#include "qbs_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QDataStream; +class QJsonObject; +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { class PersistentPool; } + +class QBS_EXPORT CodeLocation +{ + friend QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2); +public: + CodeLocation(); + explicit CodeLocation(const QString &aFilePath, int aLine = -1, int aColumn = -1, + bool checkPath = true); + CodeLocation(const CodeLocation &other); + CodeLocation &operator=(const CodeLocation &other); + ~CodeLocation(); + + QString filePath() const; + int line() const; + int column() const; + + bool isValid() const; + QString toString() const; + QJsonObject toJson() const; + + void load(Internal::PersistentPool &pool); + void store(Internal::PersistentPool &pool) const; + +private: + class CodeLocationPrivate; + QExplicitlySharedDataPointer d; +}; + +QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2); +QBS_EXPORT bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2); +QBS_EXPORT bool operator<(const CodeLocation &cl1, const CodeLocation &cl2); + +inline auto qHash(const CodeLocation &cl) { return qHash(cl.toString()); } + +QDebug operator<<(QDebug debug, const CodeLocation &location); + +} // namespace qbs + +#endif // QBS_SOURCELOCATION_H diff --git a/src/lib/corelib/tools/commandechomode.cpp b/src/lib/corelib/tools/commandechomode.cpp new file mode 100644 index 00000000..c47ddb5b --- /dev/null +++ b/src/lib/corelib/tools/commandechomode.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "commandechomode.h" + +#include +#include + +/*! + * \enum CommandEchoMode + * This enum type specifies the kind of output to display when executing commands. + * \value CommandEchoModeSilent Indicates that no output will be printed. + * \value CommandEchoModeSummary Indicates that descriptions will be printed. + * \value CommandEchoModeCommandLine Indidcates that full command line invocations will be printed. + * \value CommandEchoModeCommandLineWithEnvironment Indidcates that full command line invocations, + * including environment variables, will be printed. + */ + +namespace qbs { + +CommandEchoMode defaultCommandEchoMode() +{ + return CommandEchoModeSummary; +} + +QString commandEchoModeName(CommandEchoMode mode) +{ + switch (mode) { + case CommandEchoModeSilent: + return QStringLiteral("silent"); + case CommandEchoModeSummary: + return QStringLiteral("summary"); + case CommandEchoModeCommandLine: + return QStringLiteral("command-line"); + case CommandEchoModeCommandLineWithEnvironment: + return QStringLiteral("command-line-with-environment"); + default: + break; + } + return {}; +} + +CommandEchoMode commandEchoModeFromName(const QString &name) +{ + CommandEchoMode mode = defaultCommandEchoMode(); + for (int i = 0; i < CommandEchoModeInvalid; ++i) { + if (commandEchoModeName(static_cast(i)) == name) { + mode = static_cast(i); + break; + } + } + + return mode; +} + +QStringList allCommandEchoModeStrings() +{ + QStringList result; + for (int i = 0; i < CommandEchoModeInvalid; ++i) + result << commandEchoModeName(static_cast(i)); + return result; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/commandechomode.h b/src/lib/corelib/tools/commandechomode.h new file mode 100644 index 00000000..e7b31556 --- /dev/null +++ b/src/lib/corelib/tools/commandechomode.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_COMMANDECHOMODE_H +#define QBS_COMMANDECHOMODE_H + +#include "qbs_export.h" +#include +#include + +namespace qbs { + +enum CommandEchoMode { + CommandEchoModeSilent, + CommandEchoModeSummary, + CommandEchoModeCommandLine, + CommandEchoModeCommandLineWithEnvironment, + CommandEchoModeInvalid, +}; + +QBS_EXPORT CommandEchoMode defaultCommandEchoMode(); +QBS_EXPORT QString commandEchoModeName(CommandEchoMode mode); +QBS_EXPORT CommandEchoMode commandEchoModeFromName(const QString &name); +QBS_EXPORT QStringList allCommandEchoModeStrings(); + +} // namespace qbs + +#endif // QBS_COMMANDECHOMODE_H + diff --git a/src/lib/corelib/tools/dynamictypecheck.h b/src/lib/corelib/tools/dynamictypecheck.h new file mode 100644 index 00000000..b8756c57 --- /dev/null +++ b/src/lib/corelib/tools/dynamictypecheck.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef QBS_DYNAMICTYPECHECK_H +#define QBS_DYNAMICTYPECHECK_H + +namespace qbs { +namespace Internal { + +// Generic implementation would use dynamic_cast. Don't implement unless it becomes necessary. +template inline bool hasDynamicType(const StaticType *); + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/error.cpp b/src/lib/corelib/tools/error.cpp new file mode 100644 index 00000000..2ff36d1d --- /dev/null +++ b/src/lib/corelib/tools/error.cpp @@ -0,0 +1,340 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "error.h" + +#include "persistence.h" +#include "qttools.h" +#include "stringconstants.h" +#include "setupprojectparameters.h" +#include "logging/logger.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace qbs { + +class ErrorItem::ErrorItemPrivate : public QSharedData +{ +public: + template + void serializationOp(Internal::PersistentPool &pool) + { + pool.serializationOp(description, codeLocation, isBacktraceItem); + } + + void load(Internal::PersistentPool &pool) + { + serializationOp(pool); + } + + void store(Internal::PersistentPool &pool) + { + serializationOp(pool); + } + + QString description; + CodeLocation codeLocation; + bool isBacktraceItem = false; +}; + +/*! + * \class ErrorData + * \brief The \c ErrorData class describes (part of) an error resulting from a qbs operation. + * It is always delivered as part of an \c Error. + * \sa Error + */ + +ErrorItem::ErrorItem() : d(new ErrorItemPrivate) +{ +} + +ErrorItem::ErrorItem(ErrorItem &&rhs) noexcept = default; + +ErrorItem::ErrorItem(const QString &description, const CodeLocation &codeLocation, + bool isBacktraceItem) + : d(new ErrorItemPrivate) +{ + d->description = description; + d->codeLocation = codeLocation; + d->isBacktraceItem = isBacktraceItem; +} + +ErrorItem::ErrorItem(const ErrorItem &rhs) = default; + +ErrorItem &ErrorItem::operator=(const ErrorItem &other) = default; +ErrorItem &ErrorItem::operator=(ErrorItem &&other) noexcept = default; + +ErrorItem::~ErrorItem() = default; + +QString ErrorItem::description() const +{ + return d->description; +} + +CodeLocation ErrorItem::codeLocation() const +{ + return d->codeLocation; +} + +bool ErrorItem::isBacktraceItem() const +{ + return d->isBacktraceItem; +} + +void ErrorItem::load(Internal::PersistentPool &pool) +{ + pool.load(*d); +} + +void ErrorItem::store(Internal::PersistentPool &pool) const +{ + pool.store(*d); +} + +/*! + * \fn const QString &ErrorData::description() const + * \brief A general description of the error. + */ + + /*! + * \fn const QString &ErrorData::codeLocation() const + * \brief The location at which file in which the error occurred. + * \note This information might not be applicable, in which case location().isValid() returns false + */ + +/*! + * \brief A full textual description of the error using all available information. + */ +QString ErrorItem::toString() const +{ + QString str = codeLocation().toString(); + if (!str.isEmpty()) + str += QLatin1Char(' '); + return str += description(); +} + +QJsonObject ErrorItem::toJson() const +{ + QJsonObject data; + data.insert(Internal::StringConstants::descriptionProperty(), description()); + data.insert(Internal::StringConstants::locationKey(), codeLocation().toJson()); + return data; +} + + +class ErrorInfo::ErrorInfoPrivate : public QSharedData +{ +public: + ErrorInfoPrivate() : internalError(false) { } + + template + void completeSerializationOp(Internal::PersistentPool &pool) + { + pool.serializationOp(items, internalError); + } + + QList items; + bool internalError; +}; + +/*! + * \class Error + * \brief Represents an error resulting from a qbs operation. + * It is made up of one or more \c ErrorData objects. + * \sa ErrorData + */ + +ErrorInfo::ErrorInfo() : d(new ErrorInfoPrivate) +{ +} + +ErrorInfo::ErrorInfo(const ErrorInfo &rhs) = default; + +ErrorInfo::ErrorInfo(ErrorInfo &&rhs) noexcept = default; + +ErrorInfo::ErrorInfo(const QString &description, const CodeLocation &location, bool internalError) + : d(new ErrorInfoPrivate) +{ + append(description, location); + d->internalError = internalError; +} + +ErrorInfo::ErrorInfo(const QString &description, const QStringList &backtrace) + : d(new ErrorInfoPrivate) +{ + append(description); + for (const QString &traceLine : backtrace) { + static const std::regex regexp("^(.+) at (.+):(\\-?[0-9]+)$"); + std::smatch match; + const std::string tl = traceLine.toStdString(); + if (std::regex_match(tl, match, regexp)) { + const QString message = QString::fromStdString(match[1]), + file = QString::fromStdString(match[2]), + line = QString::fromStdString(match[3]); + const CodeLocation location(file, line.toInt()); + appendBacktrace(message, location); + } + } +} + +ErrorInfo &ErrorInfo::operator=(ErrorInfo &&other) noexcept = default; + +ErrorInfo &ErrorInfo::operator =(const ErrorInfo &other) = default; + +ErrorInfo::~ErrorInfo() = default; + +void ErrorInfo::appendBacktrace(const QString &description, const CodeLocation &location) +{ + d->items.push_back(ErrorItem(description, location, true)); +} + +void ErrorInfo::append(const ErrorItem &item) +{ + d->items.push_back(item); +} + +void ErrorInfo::append(const QString &description, const CodeLocation &location) +{ + d->items.push_back(ErrorItem(description, location)); +} + +void ErrorInfo::prepend(const QString &description, const CodeLocation &location) +{ + d->items.prepend(ErrorItem(description, location)); +} + +/*! + * \brief A list of concrete error description. + * Most often, there will be one element in this list, but there can be more e.g. to illustrate + * how an error condition propagates through several source files. + */ +const QList ErrorInfo::items() const +{ + return d->items; +} + +void ErrorInfo::clear() +{ + d->items.clear(); +} + +/*! + * \brief A complete textual description of the error. + * All "sub-errors" will be represented. + * \sa Error::entries() + */ +QString ErrorInfo::toString() const +{ + QStringList lines; + for (const ErrorItem &e : qAsConst(d->items)) { + if (e.isBacktraceItem()) { + QString line; + if (!e.description().isEmpty()) + line.append(QStringLiteral(" at %1").arg(e.description())); + if (e.codeLocation().isValid()) + line.append(QStringLiteral(" in %1").arg(e.codeLocation().toString())); + if (!line.isEmpty()) + lines.push_back(QLatin1Char('\t') + line); + } else { + lines.push_back(e.toString()); + } + } + return lines.join(QLatin1Char('\n')); +} + +QJsonObject ErrorInfo::toJson() const +{ + QJsonObject data; + data.insert(QLatin1String("is-internal"), isInternalError()); + QJsonArray itemsArray; + for (const ErrorItem &item : items()) + itemsArray.append(item.toJson()); + data.insert(QLatin1String("items"), itemsArray); + return data; +} + +/*! + * \brief Returns true if this error represents a bug in qbs, false otherwise. + */ +bool ErrorInfo::isInternalError() const +{ + return d->internalError; +} + +bool ErrorInfo::hasLocation() const +{ + return Internal::any_of(d->items, [](const ErrorItem &ei) { + return ei.codeLocation().isValid(); }); +} + +void ErrorInfo::load(Internal::PersistentPool &pool) +{ + pool.load(*d); +} + +void ErrorInfo::store(Internal::PersistentPool &pool) const +{ + pool.store(*d); +} + +void appendError(ErrorInfo &dst, const ErrorInfo &src) +{ + const QList &sourceItems = src.items(); + for (const ErrorItem &item : sourceItems) + dst.append(item); +} + +void handlePropertyError( + const ErrorInfo &error, const SetupProjectParameters ¶ms, Internal::Logger &logger) +{ + if (params.propertyCheckingMode() == ErrorHandlingMode::Strict) + throw error; + logger.printWarning(error); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/error.h b/src/lib/corelib/tools/error.h new file mode 100644 index 00000000..4c6370b1 --- /dev/null +++ b/src/lib/corelib/tools/error.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_ERROR +#define QBS_ERROR + +#include "codelocation.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QJsonObject; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class PersistentPool; +class Logger; +} // namespace Internal +class CodeLocation; + +class SetupProjectParameters; + +class QBS_EXPORT ErrorItem +{ + friend class ErrorInfo; +public: + ErrorItem(); + ErrorItem(const ErrorItem &rhs); + ErrorItem(ErrorItem &&rhs) noexcept; + ErrorItem &operator=(const ErrorItem &other); + ErrorItem &operator=(ErrorItem &&other) noexcept; + ~ErrorItem(); + + QString description() const; + CodeLocation codeLocation() const; + QString toString() const; + QJsonObject toJson() const; + + bool isBacktraceItem() const; + + void load(Internal::PersistentPool &pool); + void store(Internal::PersistentPool &pool) const; + +private: + ErrorItem(const QString &description, const CodeLocation &codeLocation, + bool isBacktraceItem = false); + + class ErrorItemPrivate; + QExplicitlySharedDataPointer d; +}; + +class QBS_EXPORT ErrorInfo +{ +public: + ErrorInfo(); + ErrorInfo(const ErrorInfo &rhs); + ErrorInfo(ErrorInfo &&rhs) noexcept; + ErrorInfo(const QString &description, const CodeLocation &location = CodeLocation(), + bool internalError = false); + ErrorInfo(const QString &description, const QStringList &backtrace); + ErrorInfo &operator=(const ErrorInfo &other); + ErrorInfo &operator=(ErrorInfo &&other) noexcept; + ~ErrorInfo(); + + void appendBacktrace(const QString &description, const CodeLocation &location = CodeLocation()); + void append(const ErrorItem &item); + void append(const QString &description, const CodeLocation &location = CodeLocation()); + void prepend(const QString &description, const CodeLocation &location = CodeLocation()); + const QList items() const; + bool hasError() const { return !items().empty(); } + void clear(); + QString toString() const; + QJsonObject toJson() const; + bool isInternalError() const; + bool hasLocation() const; + + void load(Internal::PersistentPool &pool); + void store(Internal::PersistentPool &pool) const; + +private: + class ErrorInfoPrivate; + QSharedDataPointer d; +}; + +void appendError(ErrorInfo &dst, const ErrorInfo &src); +void handlePropertyError( + const ErrorInfo &error, const SetupProjectParameters ¶ms, Internal::Logger &logger); + +inline auto qHash(const ErrorInfo &e) { return qHash(e.toString()); } +inline bool operator==(const ErrorInfo &e1, const ErrorInfo &e2) { + return e1.toString() == e2.toString(); +} + +} // namespace qbs + +Q_DECLARE_METATYPE(qbs::ErrorInfo) + +#endif // QBS_ERROR diff --git a/src/lib/corelib/tools/executablefinder.cpp b/src/lib/corelib/tools/executablefinder.cpp new file mode 100644 index 00000000..5bf53155 --- /dev/null +++ b/src/lib/corelib/tools/executablefinder.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "executablefinder.h" + +#include "fileinfo.h" +#include "hostosinfo.h" +#include "qttools.h" +#include "stringconstants.h" + +#include + +#include + +namespace qbs { +namespace Internal { + +static QStringList populateExecutableSuffixes() +{ + QStringList result; + result << QString(); + if (HostOsInfo::isWindowsHost()) { + result << QStringLiteral(".com") << QStringLiteral(".exe") + << QStringLiteral(".bat") << QStringLiteral(".cmd"); + } + return result; +} + +QStringList ExecutableFinder::m_executableSuffixes = populateExecutableSuffixes(); + +ExecutableFinder::ExecutableFinder(ResolvedProductPtr product, const QProcessEnvironment &env) + : m_product(std::move(product)) + , m_environment(env) // QProcessEnvironment doesn't have move-ctor, copy here +{ +} + +QString ExecutableFinder::findExecutable(const QString &path, const QString &workingDirPath) +{ + QString filePath = QDir::fromNativeSeparators(path); + //if (FileInfo::fileName(filePath) == filePath) + if (!FileInfo::isAbsolute(filePath)) + return findInPath(filePath, workingDirPath); + if (HostOsInfo::isWindowsHost()) + return findBySuffix(filePath); + return filePath; +} + +QString ExecutableFinder::findBySuffix(const QString &filePath) const +{ + QString fullProgramPath = cachedFilePath(filePath); + if (!fullProgramPath.isEmpty()) + return fullProgramPath; + + fullProgramPath = filePath; + qCDebug(lcExec) << "looking for executable by suffix" << fullProgramPath; + const QString emptyDirectory; + candidateCheck(emptyDirectory, fullProgramPath, fullProgramPath); + cacheFilePath(filePath, fullProgramPath); + return fullProgramPath; + +} + +bool ExecutableFinder::candidateCheck(const QString &directory, const QString &program, + QString &fullProgramPath) const +{ + for (const QString &suffix : qAsConst(m_executableSuffixes)) { + QString candidate = directory + program + suffix; + qCDebug(lcExec) << "candidate:" << candidate; + QFileInfo fi(candidate); + if (fi.isFile() && fi.isExecutable()) { + fullProgramPath = candidate; + return true; + } + } + return false; +} + +QString ExecutableFinder::findInPath(const QString &filePath, const QString &workingDirPath) const +{ + QString fullProgramPath = cachedFilePath(filePath); + if (!fullProgramPath.isEmpty()) + return fullProgramPath; + + fullProgramPath = filePath; + qCDebug(lcExec) << "looking for executable in PATH" << fullProgramPath; + QStringList pathEnv = m_environment.value(StringConstants::pathEnvVar()) + .split(HostOsInfo::pathListSeparator(), QBS_SKIP_EMPTY_PARTS); + if (HostOsInfo::isWindowsHost()) + pathEnv.prepend(StringConstants::dot()); + for (QString directory : qAsConst(pathEnv)) { + if (directory == StringConstants::dot()) + directory = workingDirPath; + if (!directory.isEmpty()) { + const QChar lastChar = directory.at(directory.size() - 1); + if (lastChar != QLatin1Char('/') && lastChar != QLatin1Char('\\')) + directory.append(QLatin1Char('/')); + } + if (candidateCheck(directory, fullProgramPath, fullProgramPath)) + break; + } + cacheFilePath(filePath, fullProgramPath); + return fullProgramPath; +} + +QString ExecutableFinder::cachedFilePath(const QString &filePath) const +{ + return m_product ? m_product->cachedExecutablePath(filePath) : QString(); +} + +void ExecutableFinder::cacheFilePath(const QString &filePath, const QString &fullFilePath) const +{ + if (m_product) + m_product->cacheExecutablePath(filePath, fullFilePath); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/executablefinder.h b/src/lib/corelib/tools/executablefinder.h new file mode 100644 index 00000000..ae834d91 --- /dev/null +++ b/src/lib/corelib/tools/executablefinder.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_EXECUTABLEFINDER_H +#define QBS_EXECUTABLEFINDER_H + +#include + +#include + +namespace qbs { +namespace Internal { + +/*! + * \brief Helper class for finding an executable in the PATH of the build environment. + */ +class ExecutableFinder +{ +public: + ExecutableFinder(ResolvedProductPtr product, const QProcessEnvironment &env); + + QString findExecutable(const QString &path, const QString &workingDirPath); + +private: + static QStringList m_executableSuffixes; + QString findBySuffix(const QString &filePath) const; + bool candidateCheck(const QString &directory, const QString &program, + QString &fullProgramPath) const; + QString findInPath(const QString &filePath, const QString &workingDirPath) const; + + QString cachedFilePath(const QString &filePath) const; + void cacheFilePath(const QString &filePaht, const QString &filePath) const; + + ResolvedProductPtr m_product; + const QProcessEnvironment m_environment; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_EXECUTABLEFINDER_H diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp new file mode 100644 index 00000000..f56762c0 --- /dev/null +++ b/src/lib/corelib/tools/fileinfo.cpp @@ -0,0 +1,603 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fileinfo.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#if defined(Q_OS_UNIX) +#include +#include +#include +#elif defined(Q_OS_WIN) +#include +#endif + +namespace qbs { +namespace Internal { + +QString FileInfo::fileName(const QString &fp) +{ + int last = fp.lastIndexOf(QLatin1Char('/')); + if (last < 0) + return fp; + return fp.mid(last + 1); +} + +QString FileInfo::baseName(const QString &fp) +{ + QString fn = fileName(fp); + int dot = fn.indexOf(QLatin1Char('.')); + if (dot < 0) + return fn; + return fn.mid(0, dot); +} + +QString FileInfo::completeBaseName(const QString &fp) +{ + QString fn = fileName(fp); + int dot = fn.lastIndexOf(QLatin1Char('.')); + if (dot < 0) + return fn; + return fn.mid(0, dot); +} + +QString FileInfo::suffix(const QString &fp) +{ + QString fn = fileName(fp); + int dot = fn.lastIndexOf(QLatin1Char('.')); + if (dot < 0) + return fn; + return fn.mid(dot + 1); +} + +QString FileInfo::completeSuffix(const QString &fp) +{ + QString fn = fileName(fp); + int dot = fn.indexOf(QLatin1Char('.')); + if (dot < 0) + return fn; + return fn.mid(dot + 1); +} + +QString FileInfo::path(const QString &fp, HostOsInfo::HostOs hostOs) +{ + if (fp.isEmpty()) + return {}; + int last = fp.lastIndexOf(QLatin1Char('/')); + if (last < 0) + return StringConstants::dot(); + QString p = QDir::cleanPath(fp.mid(0, last)); + if (p.isEmpty() || (hostOs == HostOsInfo::HostOsWindows && p.length() == 2 && p.at(0).isLetter() + && p.at(1) == QLatin1Char(':'))) { + // Make sure we don't return Windows drive roots without an ending slash. + // Those paths are considered relative. + p.append(QLatin1Char('/')); + } + return p; +} + +void FileInfo::splitIntoDirectoryAndFileName(const QString &filePath, QString *dirPath, QString *fileName) +{ + int idx = filePath.lastIndexOf(QLatin1Char('/')); + if (idx < 0) { + dirPath->clear(); + *fileName = filePath; + return; + } + *dirPath = filePath.left(idx); + *fileName = filePath.mid(idx + 1); +} + +void FileInfo::splitIntoDirectoryAndFileName(const QString &filePath, QStringView *dirPath, QStringView *fileName) +{ + int idx = filePath.lastIndexOf(QLatin1Char('/')); + if (idx < 0) { + *dirPath = QStringView(); + *fileName = QStringView(filePath); + return; + } + *dirPath = QStringView(filePath).left(idx); + *fileName = QStringView(filePath).mid(idx + 1); +} + +bool FileInfo::exists(const QString &fp) +{ + return FileInfo(fp).exists(); +} + +// Whether a path is the special "current drive path" path type, +// which is neither truly relative nor absolute +static bool isCurrentDrivePath(const QString &path, HostOsInfo::HostOs hostOs) +{ + return hostOs == HostOsInfo::HostOsWindows + ? path.size() == 2 && path.at(1) == QLatin1Char(':') && path.at(0).isLetter() + : false; +} + +// from creator/src/shared/proparser/ioutils.cpp +bool FileInfo::isAbsolute(const QString &path, HostOsInfo::HostOs hostOs) +{ + const int n = path.size(); + if (n == 0) + return false; + const QChar at0 = path.at(0); + if (at0 == QLatin1Char('/')) + return true; + if (hostOs == HostOsInfo::HostOsWindows) { + if (at0 == QLatin1Char('\\')) + return true; + // Unlike QFileInfo, this won't accept a relative path with a drive letter. + // Such paths result in a royal mess anyway ... + if (n >= 3 && path.at(1) == QLatin1Char(':') && at0.isLetter() + && (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\'))) + return true; + } + return false; +} + +bool FileInfo::isPattern(QStringView str) +{ + return Internal::any_of(str, [](const auto &ch) { + return (ch == QLatin1Char('*') || ch == QLatin1Char('?') || ch == QLatin1Char(']') + || ch == QLatin1Char('[')); + }); +} + +/** + * Concatenates the paths \a base and \a rel. + * Base must be an absolute path. + * Double dots at the start of \a rel are handled. + * This function assumes that both paths are clean, that is they don't contain + * double slashes or redundant dot parts. + */ +QString FileInfo::resolvePath(const QString &base, const QString &rel, HostOsInfo::HostOs hostOs) +{ + QBS_ASSERT(isAbsolute(base, hostOs) && !isCurrentDrivePath(rel, hostOs), + qDebug("base: %s, rel: %s", qPrintable(base), qPrintable(rel)); + return {}); + if (isAbsolute(rel, hostOs)) + return rel; + if (rel.size() == 1 && rel.at(0) == QLatin1Char('.')) + return base; + if (rel.size() == 1 && rel.at(0) == QLatin1Char('~')) + return QDir::homePath(); + if (rel.startsWith(StringConstants::tildeSlash())) + return QDir::homePath() + rel.mid(1); + + QString r = base; + if (r.endsWith(QLatin1Char('/'))) + r.chop(1); + + QString s = rel; + while (s.startsWith(QStringLiteral("../"))) { + s.remove(0, 3); + int idx = r.lastIndexOf(QLatin1Char('/')); + if (idx >= 0) + r.truncate(idx); + } + if (s == StringConstants::dotDot()) { + int idx = r.lastIndexOf(QLatin1Char('/')); + if (idx >= 0) + r.truncate(idx); + s.clear(); + } + if (!s.isEmpty() || isCurrentDrivePath(r, hostOs)) { + r.reserve(r.length() + 1 + s.length()); + r += QLatin1Char('/'); + r += s; + } + return r; +} + +#ifdef Q_OS_WIN +static QString prependLongPathPrefix(const QString &absolutePath) +{ + QString nativePath = QDir::toNativeSeparators(absolutePath); + if (nativePath.startsWith(QStringLiteral("\\\\"))) + nativePath.remove(0, 1).prepend(QLatin1String("UNC")); + nativePath.prepend(QLatin1String("\\\\?\\")); + return nativePath; +} +#endif + +bool FileInfo::isFileCaseCorrect(const QString &filePath) +{ +#if defined(Q_OS_WIN) + // QFileInfo::canonicalFilePath() does not return the real case of the file path on Windows. + QFileInfo fi(filePath); + const QString absolute = prependLongPathPrefix(fi.absoluteFilePath()); + WIN32_FIND_DATA fd; + HANDLE hFindFile = ::FindFirstFile((wchar_t*)absolute.utf16(), &fd); + if (hFindFile == INVALID_HANDLE_VALUE) + return false; + const QString actualFileName = QString::fromWCharArray(fd.cFileName); + FindClose(hFindFile); + return actualFileName == fi.fileName(); +#elif defined(Q_OS_DARWIN) + QFileInfo fi(filePath); + return fi.fileName() == fileName(fi.canonicalFilePath()); +#else + Q_UNUSED(filePath) + return true; +#endif +} + +bool FileInfo::fileExists(const QFileInfo &fi) +{ + return fi.isSymLink() || fi.exists(); +} + +#if defined(Q_OS_WIN) + +#define z(x) reinterpret_cast(const_cast(&x)) + +FileInfo::FileInfo(const QString &fileName) +{ + static_assert(sizeof(FileInfo::InternalStatType) == sizeof(WIN32_FILE_ATTRIBUTE_DATA), + "FileInfo::InternalStatType has wrong size."); + + QString filePath = fileName; + + // The extended-length path prefix cannot be used with a relative path, so make it absolute + if (!isAbsolute(filePath)) + filePath = QDir::currentPath() + QDir::separator() + filePath; + + filePath = prependLongPathPrefix(QDir::cleanPath(filePath)); + if (!GetFileAttributesEx(reinterpret_cast(filePath.utf16()), + GetFileExInfoStandard, &m_stat)) + { + ZeroMemory(z(m_stat), sizeof(WIN32_FILE_ATTRIBUTE_DATA)); + z(m_stat)->dwFileAttributes = INVALID_FILE_ATTRIBUTES; + } +} + +bool FileInfo::exists() const +{ + return z(m_stat)->dwFileAttributes != INVALID_FILE_ATTRIBUTES; +} + +FileTime FileInfo::lastModified() const +{ + const FileTime::InternalType* ft_it; + ft_it = reinterpret_cast(&z(m_stat)->ftLastWriteTime); + return {*ft_it}; +} + +FileTime FileInfo::lastStatusChange() const +{ + return lastModified(); +} + +bool FileInfo::isDir() const +{ + return exists() && z(m_stat)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; +} + +static QString resolveSymlinks(const QString &fileName) +{ + QFileInfo fi(fileName); + while (fi.isSymLink()) + fi.setFile(fi.dir(), fi.symLinkTarget()); + return fi.absoluteFilePath(); +} + +QString applicationDirPath() +{ + static const QString appDirPath = FileInfo::path(resolveSymlinks(QCoreApplication::applicationFilePath())); + return appDirPath; +} + +#elif defined(Q_OS_UNIX) + +namespace GetFileTimes { + +enum TimeType { LastModified, LastStatusChanged }; + +// SFINAE magic inspired by +// https://github.com/qt/qtbase/blob/5.13/src/corelib/io/qfilesystemengine_unix.cpp +template< + TimeType type, + typename T, + std::enable_if_t<(&T::st_mtim, &T::st_ctim, true), int> = 0> +static inline FileTime get(const T &stat) +{ + if constexpr (type == LastModified) + return stat.st_mtim; + else if constexpr (type == LastStatusChanged) + return stat.st_ctim; +} + +// we are interested in real members, not compatibility macros +# if defined(st_mtimespec) +# undef st_mtimespec +# endif + +# if defined(st_ctimespec) +# undef st_ctimespec +# endif + +template< + TimeType type, + typename T, + std::enable_if_t<(&T::st_mtimespec, &T::st_ctimespec, true), int> = 0> +static inline FileTime get(const T &stat) +{ + if constexpr (type == LastModified) + return stat.st_mtimespec; + else if constexpr (type == LastStatusChanged) + return stat.st_ctimespec; +} + +# if defined(st_mtimensec) +# undef st_mtimensec +# endif + +# if defined(st_ctimensec) +# undef st_ctimensec +# endif + +template< + TimeType type, + typename T, + std::enable_if_t<(&T::st_mtimensec, &T::st_ctimensec, true), int> = 0> +static inline FileTime get(const T &stat) +{ + if constexpr (type == LastModified) + return FileTime::InternalType{stat.st_mtime, stat.st_mtimensec}; + else if constexpr (type == LastStatusChanged) + return FileTime::InternalType{stat.st_ctime, stat.st_ctimensec}; +} + +} // namespace GetFileTimes + +FileInfo::FileInfo(const QString &fileName) +{ + if (stat(fileName.toLocal8Bit().constData(), &m_stat) == -1) { + m_stat.st_mtime = 0; + m_stat.st_mode = 0; + } +} + +bool FileInfo::exists() const +{ + return m_stat.st_mode != 0; +} + +FileTime FileInfo::lastModified() const +{ + return GetFileTimes::get(m_stat); +} + +FileTime FileInfo::lastStatusChange() const +{ + return GetFileTimes::get(m_stat); +} + +bool FileInfo::isDir() const +{ + return S_ISDIR(m_stat.st_mode); +} + +#endif + +// adapted from qtc/plugins/vcsbase/cleandialog.cpp +bool removeFileRecursion(const QFileInfo &f, QString *errorMessage) +{ + if (!FileInfo::fileExists(f)) + return true; + if (f.isDir() && !f.isSymLink()) { + const QDir dir(f.absoluteFilePath()); + + // QDir::System is needed for broken symlinks. + const auto fileInfos = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot + | QDir::Hidden | QDir::System); + for (const QFileInfo &fi : fileInfos) + removeFileRecursion(fi, errorMessage); + QDir parent = f.absoluteDir(); + if (!parent.rmdir(f.fileName())) { + errorMessage->append(Tr::tr("The directory %1 could not be deleted."). + arg(QDir::toNativeSeparators(f.absoluteFilePath()))); + return false; + } + } else { + QFile file(f.absoluteFilePath()); + file.setPermissions(f.permissions() | QFile::WriteUser); + if (!file.remove()) { + if (!errorMessage->isEmpty()) + errorMessage->append(QLatin1Char('\n')); + errorMessage->append(Tr::tr("The file %1 could not be deleted."). + arg(QDir::toNativeSeparators(f.absoluteFilePath()))); + return false; + } + } + return true; +} + +bool removeDirectoryWithContents(const QString &path, QString *errorMessage) +{ + QFileInfo f(path); + if (f.exists() && !f.isDir()) { + *errorMessage = Tr::tr("%1 is not a directory.").arg(QDir::toNativeSeparators(path)); + return false; + } + return removeFileRecursion(f, errorMessage); +} + +/*! + * Returns the stored link target of the symbolic link \a{filePath}. + * Unlike QFileInfo::symLinkTarget, this will not make the link target an absolute path. + */ +static QByteArray storedLinkTarget(const QString &filePath) +{ + QByteArray result; + +#ifdef Q_OS_UNIX + const QByteArray nativeFilePath = QFile::encodeName(filePath); + ssize_t len; + while (true) { + struct stat sb{}; + if (lstat(nativeFilePath.constData(), &sb)) { + qWarning("storedLinkTarget: lstat for %s failed with error code %d", + nativeFilePath.constData(), errno); + return {}; + } + + result.resize(sb.st_size); + len = readlink(nativeFilePath.constData(), result.data(), sb.st_size + 1); + if (len < 0) { + qWarning("storedLinkTarget: readlink for %s failed with error code %d", + nativeFilePath.constData(), errno); + return {}; + } + + if (len < sb.st_size) { + result.resize(len); + break; + } + if (len == sb.st_size) + break; + } +#else + Q_UNUSED(filePath); +#endif // Q_OS_UNIX + + return result; +} + +static bool createSymLink(const QByteArray &path1, const QString &path2) +{ +#ifdef Q_OS_UNIX + const QByteArray newPath = QFile::encodeName(path2); + unlink(newPath.constData()); + return symlink(path1.constData(), newPath.constData()) == 0; +#else + Q_UNUSED(path1); + Q_UNUSED(path2); + return false; +#endif // Q_OS_UNIX +} + +/*! + Copies the directory specified by \a srcFilePath recursively to \a tgtFilePath. + \a tgtFilePath will contain the target directory, which will be created. Example usage: + + \code + QString error; + book ok = Utils::FileUtils::copyRecursively("/foo/bar", "/foo/baz", &error); + if (!ok) + qDebug() << error; + \endcode + + This will copy the contents of /foo/bar into to the baz directory under /foo, + which will be created in the process. + + \return Whether the operation succeeded. + \note Function was adapted from qtc/src/libs/fileutils.cpp +*/ + +bool copyFileRecursion(const QString &srcFilePath, const QString &tgtFilePath, + bool preserveSymLinks, bool copyDirectoryContents, QString *errorMessage) +{ + QFileInfo srcFileInfo(srcFilePath); + QFileInfo tgtFileInfo(tgtFilePath); + const QString targetDirPath = tgtFileInfo.absoluteDir().path(); + if (!QDir::root().mkpath(targetDirPath)) { + *errorMessage = Tr::tr("The directory '%1' could not be created.") + .arg(QDir::toNativeSeparators(targetDirPath)); + return false; + } + if (HostOsInfo::isAnyUnixHost() && preserveSymLinks && srcFileInfo.isSymLink()) { + // For now, disable symlink preserving copying on Windows. + // MS did a good job to prevent people from using symlinks - even if they are supported. + if (!createSymLink(storedLinkTarget(srcFilePath), tgtFilePath)) { + *errorMessage = Tr::tr("The symlink '%1' could not be created.") + .arg(tgtFilePath); + return false; + } + } else if (srcFileInfo.isDir()) { + if (copyDirectoryContents) { + QDir sourceDir(srcFilePath); + const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs + | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System); + for (const QString &fileName : fileNames) { + const QString newSrcFilePath = srcFilePath + QLatin1Char('/') + fileName; + const QString newTgtFilePath = tgtFilePath + QLatin1Char('/') + fileName; + if (!copyFileRecursion(newSrcFilePath, newTgtFilePath, preserveSymLinks, + copyDirectoryContents, errorMessage)) + return false; + } + } else { + if (tgtFileInfo.exists() && srcFileInfo.lastModified() <= tgtFileInfo.lastModified()) + return true; + return QDir::root().mkpath(tgtFilePath); + } + } else { + if (tgtFileInfo.exists() && srcFileInfo.lastModified() <= tgtFileInfo.lastModified()) + return true; + QFile file(srcFilePath); + QFile targetFile(tgtFilePath); + if (targetFile.exists()) { + targetFile.setPermissions(targetFile.permissions() | QFile::WriteUser); + if (!targetFile.remove()) { + *errorMessage = Tr::tr("Could not remove file '%1'. %2") + .arg(QDir::toNativeSeparators(tgtFilePath), targetFile.errorString()); + } + } + if (!file.copy(tgtFilePath)) { + *errorMessage = Tr::tr("Could not copy file '%1' to '%2'. %3") + .arg(QDir::toNativeSeparators(srcFilePath), QDir::toNativeSeparators(tgtFilePath), + file.errorString()); + return false; + } + } + return true; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h new file mode 100644 index 00000000..f0a09a16 --- /dev/null +++ b/src/lib/corelib/tools/fileinfo.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILEINFO_H +#define QBS_FILEINFO_H + +#include "filetime.h" +#include "hostosinfo.h" +#include "qbs_export.h" + +#if defined(Q_OS_UNIX) +#include +#endif + +#include + +QT_FORWARD_DECLARE_CLASS(QFileInfo) + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT FileInfo +{ +public: + FileInfo(const QString &fileName); + + bool exists() const; + FileTime lastModified() const; + FileTime lastStatusChange() const; + bool isDir() const; + + static QString fileName(const QString &fp); + static QString baseName(const QString &fp); + static QString completeBaseName(const QString &fp); + static QString suffix(const QString &fp); + static QString completeSuffix(const QString &fp); + static QString path(const QString &fp, HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()); + static void splitIntoDirectoryAndFileName(const QString &filePath, QString *dirPath, QString *fileName); + static void splitIntoDirectoryAndFileName(const QString &filePath, QStringView *dirPath, QStringView *fileName); + static bool exists(const QString &fp); + static bool isAbsolute(const QString &fp, HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()); + static bool isPattern(QStringView str); + static QString resolvePath(const QString &base, const QString &rel, + HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()); + static bool isFileCaseCorrect(const QString &filePath); + + // Symlink-correct check. + static bool fileExists(const QFileInfo &fi); + +private: +#if defined(Q_OS_WIN) + struct InternalStatType + { + quint8 z[36]; + }; +#elif defined(Q_OS_UNIX) + using InternalStatType = struct stat; +#else +# error unknown platform +#endif + InternalStatType m_stat{}; +}; + +bool removeFileRecursion(const QFileInfo &f, QString *errorMessage); + +// FIXME: Used by tests. +bool QBS_EXPORT removeDirectoryWithContents(const QString &path, QString *errorMessage); +bool QBS_EXPORT copyFileRecursion(const QString &sourcePath, const QString &targetPath, + bool preserveSymLinks, bool copyDirectoryContents, QString *errorMessage); + +} // namespace Internal +} // namespace qbs + +#endif diff --git a/src/lib/corelib/tools/filesaver.cpp b/src/lib/corelib/tools/filesaver.cpp new file mode 100644 index 00000000..3459ac55 --- /dev/null +++ b/src/lib/corelib/tools/filesaver.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filesaver.h" +#include "stlutils.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +FileSaver::FileSaver(std::string filePath, bool overwriteIfUnchanged) + : m_filePath(std::move(filePath)), m_overwriteIfUnchanged(overwriteIfUnchanged) +{ +} + +std::ostream *FileSaver::device() +{ + return m_memoryDevice.get(); +} + +bool FileSaver::open() +{ + if (!m_overwriteIfUnchanged) { + std::ifstream file(utf8_to_native_path(m_filePath)); + if (file.is_open()) + m_oldFileContents.assign(std::istreambuf_iterator(file), + std::istreambuf_iterator()); + else + m_oldFileContents.clear(); + } + + m_memoryDevice = std::make_shared(); + return true; +} + +bool FileSaver::commit() +{ + if (!device()) + return false; + + device()->flush(); + if (!device()->good()) + return false; + + const std::string newFileContents = m_memoryDevice->str(); + if (!m_overwriteIfUnchanged && m_oldFileContents == newFileContents) + return true; // no need to write unchanged data + + const std::string tempFilePath = m_filePath + "~"; + std::ofstream tempFile(utf8_to_native_path(tempFilePath)); + if (!tempFile.is_open()) + return false; + + tempFile.write(newFileContents.data(), newFileContents.size()); + tempFile.close(); + if (!tempFile.good()) + return false; + + if (Internal::rename(tempFilePath, m_filePath) != 0) { + if (errno != EEXIST) + return false; + if (Internal::unlink(m_filePath) != 0) + return false; + return Internal::rename(tempFilePath, m_filePath) == 0; + } + + return true; +} + +bool FileSaver::write(std::string_view data) +{ + return Internal::fwrite(data.data(), data.size(), device()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/filesaver.h b/src/lib/corelib/tools/filesaver.h new file mode 100644 index 00000000..06f11eba --- /dev/null +++ b/src/lib/corelib/tools/filesaver.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FILESAVER_H +#define FILESAVER_H + +#include "qbs_export.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +/*! + * QSaveFile wrapper which doesn't update the target file if the contents are unchanged. + */ +class QBS_EXPORT FileSaver { +public: + FileSaver(std::string filePath, bool overwriteIfUnchanged = false); + + std::ostream *device(); + bool open(); + bool commit(); + bool write(std::string_view data); + +private: + std::string m_oldFileContents; + std::shared_ptr m_memoryDevice; + const std::string m_filePath; + const bool m_overwriteIfUnchanged; +}; + +} // namespace Internal +} // namespace qbs + +#endif // FILESAVER_H diff --git a/src/lib/corelib/tools/filetime.cpp b/src/lib/corelib/tools/filetime.cpp new file mode 100644 index 00000000..4ccb5731 --- /dev/null +++ b/src/lib/corelib/tools/filetime.cpp @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "filetime.h" + +#include + +#ifdef Q_OS_WIN +#include +#else +#include +#endif + +namespace qbs { +namespace Internal { + +#if defined(Q_OS_WIN) + +FileTime::FileTime() +{ + static_assert(sizeof(FileTime::InternalType) == sizeof(FILETIME), + "FileTime::InternalType has wrong size."); + m_fileTime = 0; +} + +FileTime::FileTime(const FileTime::InternalType &ft) : m_fileTime(ft) +{ +} + +int FileTime::compare(const FileTime &other) const +{ + auto const t1 = reinterpret_cast(&m_fileTime); + auto const t2 = reinterpret_cast(&other.m_fileTime); + return CompareFileTime(t1, t2); +} + +void FileTime::clear() +{ + m_fileTime = 0; +} + +bool FileTime::isValid() const +{ + return *this != FileTime(); +} + +FileTime FileTime::currentTime() +{ + FileTime result; + SYSTEMTIME st; + GetSystemTime(&st); + auto const ft = reinterpret_cast(&result.m_fileTime); + SystemTimeToFileTime(&st, ft); + return result; +} + +FileTime FileTime::oldestTime() +{ + SYSTEMTIME st = { + 1601, + 1, + 5, + 2, + 0, + 0, + 0, + 0 + }; + FileTime result; + auto const ft = reinterpret_cast(&result.m_fileTime); + SystemTimeToFileTime(&st, ft); + return result; +} + +double FileTime::asDouble() const +{ + return static_cast(m_fileTime); +} + +QString FileTime::toString() const +{ + auto const ft = reinterpret_cast(&m_fileTime); + SYSTEMTIME stUTC, stLocal; + FileTimeToSystemTime(ft, &stUTC); + SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); + const QString result = QStringLiteral("%1.%2.%3 %4:%5:%6") + .arg(stLocal.wDay, 2, 10, QLatin1Char('0')).arg(stLocal.wMonth, 2, 10, QLatin1Char('0')).arg(stLocal.wYear) + .arg(stLocal.wHour, 2, 10, QLatin1Char('0')).arg(stLocal.wMinute, 2, 10, QLatin1Char('0')).arg(stLocal.wSecond, 2, 10, QLatin1Char('0')); + return result; +} + +#else // defined(Q_OS_WIN) + +// based on https://github.com/qt/qtbase/blob/5.13/src/corelib/kernel/qelapsedtimer_unix.cpp +// for details why it is implemented this way, see Qt source code +# if !defined(CLOCK_REALTIME) +# define CLOCK_REALTIME 0 +static inline void qbs_clock_gettime(int, struct timespec *ts) +{ + // support clock_gettime with gettimeofday + struct timeval tv; + gettimeofday(&tv, 0); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; +} + +# ifdef _POSIX_MONOTONIC_CLOCK +# undef _POSIX_MONOTONIC_CLOCK +# define _POSIX_MONOTONIC_CLOCK -1 +# endif +# else +static inline void qbs_clock_gettime(clockid_t clock, struct timespec *ts) +{ + clock_gettime(clock, ts); +} +# endif + +FileTime::FileTime() +{ + m_fileTime = {0, 0}; +} + +FileTime::FileTime(const FileTime::InternalType &ft) : m_fileTime(ft) +{ + if (m_fileTime.tv_sec == 0) + m_fileTime.tv_nsec = 0; // stat() sets only the first member to 0 for non-existing files. +} + +int FileTime::compare(const FileTime &other) const +{ + if (m_fileTime.tv_sec < other.m_fileTime.tv_sec) + return -1; + if (m_fileTime.tv_sec > other.m_fileTime.tv_sec) + return 1; + if (m_fileTime.tv_nsec < other.m_fileTime.tv_nsec) + return -1; + if (m_fileTime.tv_nsec > other.m_fileTime.tv_nsec) + return 1; + return 0; +} + +void FileTime::clear() +{ + m_fileTime = { 0, 0 }; +} + +bool FileTime::isValid() const +{ + return *this != FileTime(); +} + +FileTime FileTime::currentTime() +{ + InternalType t; + qbs_clock_gettime(CLOCK_REALTIME, &t); + return t; +} + +FileTime FileTime::oldestTime() +{ + return FileTime({1, 0}); +} + +double FileTime::asDouble() const +{ + return static_cast(m_fileTime.tv_sec); +} + +QString FileTime::toString() const +{ + QDateTime dt; + dt.setMSecsSinceEpoch(m_fileTime.tv_sec * 1000 + m_fileTime.tv_nsec / 1000000); + return dt.toString(Qt::ISODateWithMs); +} + +#endif // defined(Q_OS_WIN) + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/filetime.h b/src/lib/corelib/tools/filetime.h new file mode 100644 index 00000000..a0d4d2d7 --- /dev/null +++ b/src/lib/corelib/tools/filetime.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_FILETIME_H +#define QBS_FILETIME_H + +#include "persistence.h" + +#include +#include + +#if defined(Q_OS_UNIX) +#include +#endif // Q_OS_UNIX + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT FileTime +{ +public: +#if defined(Q_OS_UNIX) + using InternalType = timespec; +#elif defined(Q_OS_WIN) + using InternalType = quint64; +#else +# error unknown platform +#endif + + FileTime(); + FileTime(const InternalType &ft); + + bool operator<(const FileTime &rhs) const { return compare(rhs) < 0; } + bool operator>(const FileTime &rhs) const { return compare(rhs) > 0; } + bool operator<=(const FileTime &rhs) const { return !operator>(rhs); } + bool operator>=(const FileTime &rhs) const { return !operator<(rhs); } + bool operator==(const FileTime &rhs) const { return compare(rhs) == 0; } + bool operator!= (const FileTime &rhs) const { return !operator==(rhs); } + int compare(const FileTime &other) const; + + void clear(); + bool isValid() const; + QString toString() const; + + static FileTime currentTime(); + static FileTime oldestTime(); + + double asDouble() const; + + template void completeSerializationOp(PersistentPool &pool) + { +#if !defined(Q_OS_WIN) + pool.serializationOp(m_fileTime.tv_sec, m_fileTime.tv_nsec); +#else + pool.serializationOp(m_fileTime); +#endif + } + +private: + InternalType m_fileTime{}; +}; + +} // namespace Internal +} // namespace qbs + +QT_BEGIN_NAMESPACE + +inline QDebug operator<<(QDebug dbg, const qbs::Internal::FileTime &t) +{ + dbg.nospace() << t.toString(); + return dbg.space(); +} + +QT_END_NAMESPACE + +#endif // QBS_FILETIME_H diff --git a/src/lib/corelib/tools/generateoptions.cpp b/src/lib/corelib/tools/generateoptions.cpp new file mode 100644 index 00000000..596e0acb --- /dev/null +++ b/src/lib/corelib/tools/generateoptions.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "generateoptions.h" + +#include +#include + +namespace qbs { +namespace Internal { + +class GenerateOptionsPrivate : public QSharedData +{ +public: + GenerateOptionsPrivate() + : generatorName() + {} + + QString generatorName; +}; + +} // namespace Internal + +/*! + * \class GenerateOptions + * \brief The \c GenerateOptions class comprises parameters that influence the behavior of + * generate operations. + */ + +GenerateOptions::GenerateOptions() : d(new Internal::GenerateOptionsPrivate) +{ +} + +GenerateOptions::GenerateOptions(const GenerateOptions &other) = default; + +GenerateOptions &GenerateOptions::operator=(const GenerateOptions &other) = default; + +GenerateOptions::~GenerateOptions() = default; + +/*! + * Returns the name of the generator used to create the external build system files. + * The default is empty. + */ +QString GenerateOptions::generatorName() const +{ + return d->generatorName; +} + +/*! + * \brief Sets the name of the generator used to create the external build system files. + */ +void GenerateOptions::setGeneratorName(const QString &generatorName) +{ + d->generatorName = generatorName; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/generateoptions.h b/src/lib/corelib/tools/generateoptions.h new file mode 100644 index 00000000..869b9a57 --- /dev/null +++ b/src/lib/corelib/tools/generateoptions.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_GENERATEOPTIONS_H +#define QBS_GENERATEOPTIONS_H + +#include "qbs_export.h" + +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { class GenerateOptionsPrivate; } + +class QBS_EXPORT GenerateOptions +{ +public: + GenerateOptions(); + GenerateOptions(const GenerateOptions &other); + GenerateOptions &operator=(const GenerateOptions &other); + ~GenerateOptions(); + + QString generatorName() const; + void setGeneratorName(const QString &generatorName); + +private: + QSharedDataPointer d; +}; + +} // namespace qbs + +#endif // QBS_GENERATEOPTIONS_H diff --git a/src/lib/corelib/tools/hostosinfo.h b/src/lib/corelib/tools/hostosinfo.h new file mode 100644 index 00000000..32817f73 --- /dev/null +++ b/src/lib/corelib/tools/hostosinfo.h @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_HOSTOSINFO_H +#define QBS_HOSTOSINFO_H + +#include "qbs_export.h" +#include "stlutils.h" +#include "version.h" + +#include +#include +#include +#include +#include + +#if defined(Q_OS_WIN) +#define QBS_HOST_EXE_SUFFIX ".exe" +#define QBS_HOST_DYNAMICLIB_PREFIX "" +#define QBS_HOST_DYNAMICLIB_SUFFIX ".dll" +#elif defined(Q_OS_DARWIN) +#define QBS_HOST_EXE_SUFFIX "" +#define QBS_HOST_DYNAMICLIB_PREFIX "lib" +#define QBS_HOST_DYNAMICLIB_SUFFIX ".dylib" +#else +#define QBS_HOST_EXE_SUFFIX "" +#define QBS_HOST_DYNAMICLIB_PREFIX "lib" +#define QBS_HOST_DYNAMICLIB_SUFFIX ".so" +#endif // Q_OS_WIN + +namespace qbs { +namespace Internal { + +class HostOsInfo +{ +public: + // Add more as needed. + enum HostOs { HostOsWindows, HostOsLinux, HostOsMacos, HostOsOtherUnix, HostOsOther }; + + static inline QString hostOSIdentifier(); + static inline QString hostOSArchitecture(); + static inline std::vector hostOSIdentifiers(); + static inline std::vector canonicalOSIdentifiers(const QString &os); + static inline HostOs hostOs(); + + static inline Version hostOsVersion() { + Version v; + if (HostOsInfo::isWindowsHost()) { + QSettings settings(QStringLiteral("HKEY_LOCAL_MACHINE\\Software\\" + "Microsoft\\Windows NT\\CurrentVersion"), + QSettings::NativeFormat); + v = v.fromString(settings.value(QStringLiteral("CurrentVersion")).toString() + + QLatin1Char('.') + + settings.value(QStringLiteral("CurrentBuildNumber")).toString()); + Q_ASSERT(v.isValid()); + } else if (HostOsInfo::isMacosHost()) { + QSettings settings(QStringLiteral("/System/Library/CoreServices/SystemVersion.plist"), + QSettings::NativeFormat); + v = v.fromString(settings.value(QStringLiteral("ProductVersion")).toString()); + Q_ASSERT(v.isValid()); + } + return v; + } + + static QString hostOsBuildVersion() { + QString v; + if (HostOsInfo::isWindowsHost()) { + QSettings settings(QStringLiteral("HKEY_LOCAL_MACHINE\\Software\\" + "Microsoft\\Windows NT\\CurrentVersion"), + QSettings::NativeFormat); + v = settings.value(QStringLiteral("CurrentBuildNumber")).toString(); + } else if (HostOsInfo::isMacosHost()) { + QSettings serverSettings(QStringLiteral( + "/System/Library/CoreServices/ServerVersion.plist"), + QSettings::NativeFormat); + v = serverSettings.value(QStringLiteral("ProductBuildVersion")).toString(); + if (v.isNull()) { + QSettings systemSettings(QStringLiteral( + "/System/Library/CoreServices/SystemVersion.plist"), + QSettings::NativeFormat); + v = systemSettings.value(QStringLiteral("ProductBuildVersion")).toString(); + } + } + return v; + } + + static bool isWindowsHost() { return hostOs() == HostOsWindows; } + static bool isLinuxHost() { return hostOs() == HostOsLinux; } + static bool isMacosHost() { return hostOs() == HostOsMacos; } + static inline bool isAnyUnixHost(); + static inline QString rfc1034Identifier(const QString &str); + + static QString appendExecutableSuffix(const QString &executable) + { + QString finalName = executable; + if (isWindowsHost()) + finalName += QLatin1String(QBS_HOST_EXE_SUFFIX); + return finalName; + } + + static QString stripExecutableSuffix(const QString &executable) + { + constexpr QLatin1String suffix(QBS_HOST_EXE_SUFFIX, sizeof(QBS_HOST_EXE_SUFFIX) - 1); + return !suffix.isEmpty() && executable.endsWith(suffix) + ? executable.chopped(suffix.size()) : executable; + } + + static QString dynamicLibraryName(const QString &libraryBaseName) + { + return QLatin1String(QBS_HOST_DYNAMICLIB_PREFIX) + libraryBaseName + + QLatin1String(QBS_HOST_DYNAMICLIB_SUFFIX); + } + + static Qt::CaseSensitivity fileNameCaseSensitivity() + { + return isWindowsHost() ? Qt::CaseInsensitive: Qt::CaseSensitive; + } + + static QString libraryPathEnvironmentVariable() + { + if (isWindowsHost()) + return QStringLiteral("PATH"); + if (isMacosHost()) + return QStringLiteral("DYLD_LIBRARY_PATH"); + return QStringLiteral("LD_LIBRARY_PATH"); + } + + static QChar pathListSeparator(HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()) + { + return hostOs == HostOsWindows ? QLatin1Char(';') : QLatin1Char(':'); + } + + static QChar pathSeparator(HostOsInfo::HostOs hostOs = HostOsInfo::hostOs()) + { + return hostOs == HostOsWindows ? QLatin1Char('\\') : QLatin1Char('/'); + } + + static Qt::KeyboardModifier controlModifier() + { + return isMacosHost() ? Qt::MetaModifier : Qt::ControlModifier; + } +}; + +QString HostOsInfo::hostOSIdentifier() +{ +#if defined(__APPLE__) + return QStringLiteral("macos"); +#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) + return QStringLiteral("windows"); +#elif defined(_AIX) + return QStringLiteral("aix"); +#elif defined(hpux) || defined(__hpux) + return QStringLiteral("hpux"); +#elif defined(__sun) || defined(sun) + return QStringLiteral("solaris"); +#elif defined(__linux__) || defined(__linux) + return QStringLiteral("linux"); +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) + return QStringLiteral("freebsd"); +#elif defined(__NetBSD__) + return QStringLiteral("netbsd"); +#elif defined(__OpenBSD__) + return QStringLiteral("openbsd"); +#elif defined(__GNU__) + return QStringLiteral("hurd"); +#elif defined(__HAIKU__) + return QStringLiteral("haiku"); +#else + #warning "Qbs has not been ported to this OS - see http://qbs.io/" + return {}; +#endif +} + +QString HostOsInfo::hostOSArchitecture() +{ + const auto cpuArch = QSysInfo::currentCpuArchitecture(); + if (cpuArch == QLatin1String("i386")) + return QStringLiteral("x86"); + return cpuArch; +} + +std::vector HostOsInfo::hostOSIdentifiers() +{ + return canonicalOSIdentifiers(hostOSIdentifier()); +} + +std::vector HostOsInfo::canonicalOSIdentifiers(const QString &name) +{ + std::vector list { name }; + if (contains({u"ios-simulator"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("ios")); + if (contains({u"tvos-simulator"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("tvos")); + if (contains({u"watchos-simulator"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("watchos")); + if (contains({u"macos", u"ios", u"tvos", u"watchos"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("darwin")); + if (contains({u"darwin", u"freebsd", u"netbsd", u"openbsd"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("bsd")); + if (contains({u"android"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("linux")); + + // Note: recognized non-Unix platforms include: windows, haiku, vxworks + if (contains({u"bsd", u"aix", u"hpux", u"solaris", u"linux", u"hurd", u"qnx", u"integrity"}, name)) + list << canonicalOSIdentifiers(QStringLiteral("unix")); + + return list; +} + +HostOsInfo::HostOs HostOsInfo::hostOs() +{ +#if defined(Q_OS_WIN) + return HostOsWindows; +#elif defined(Q_OS_LINUX) + return HostOsLinux; +#elif defined(Q_OS_DARWIN) + return HostOsMacos; +#elif defined(Q_OS_UNIX) + return HostOsOtherUnix; +#else + return HostOsOther; +#endif +} + +bool HostOsInfo::isAnyUnixHost() +{ +#ifdef Q_OS_UNIX + return true; +#else + return false; +#endif +} + +QString HostOsInfo::rfc1034Identifier(const QString &str) +{ + QString s = str; + for (QChar &ch : s) { + const char c = ch.toLatin1(); + + const bool okChar = (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z') || c == '-' || c == '.'; + if (!okChar) + ch = QChar::fromLatin1('-'); + } + return s; +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_HOSTOSINFO_H diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp new file mode 100644 index 00000000..cca75551 --- /dev/null +++ b/src/lib/corelib/tools/id.cpp @@ -0,0 +1,284 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "id.h" +#include "qbsassert.h" + +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +/*! + \class qbs::Internal::Id + + \brief The class Id encapsulates an identifier that is unique + within a specific running process, using the qbs library. + + \c{Id} is used as facility to identify objects of interest + in a more typesafe and faster manner than a plain \c QString or + \c QByteArray would provide. + + An id is internally represented as a 32 bit integer (its \c UID) + and associated with a plain 7-bit-clean ASCII name used + for display and persistency. + + This class is copied from Qt Creator. +*/ + +class StringHolder +{ +public: + StringHolder() = default; + + StringHolder(const char *s, int length) + : n(length), str(s) + { + if (!n) + length = n = int(qstrlen(s)); + h = 0; + while (length--) { + h = (h << 4) + *s++; + h ^= (h & 0xf0000000) >> 23; + h &= 0x0fffffff; + } + } + int n = 0; + const char *str = nullptr; + uint h = 0; +}; + +static bool operator==(const StringHolder &sh1, const StringHolder &sh2) +{ + // sh.n is unlikely to discriminate better than the hash. + return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0; +} + + +QHashValueType qHash(const StringHolder &sh) +{ + return sh.h; +} + +struct IdCache : public QHash +{ +#ifndef QBS_ALLOW_STATIC_LEAKS + ~IdCache() + { + for (IdCache::iterator it = begin(); it != end(); ++it) + delete[](const_cast(it.key().str)); + } +#endif +}; + + +static int firstUnusedId = Id::IdsPerPlugin * Id::ReservedPlugins; + +static QHash stringFromId; +static IdCache idFromString; +static std::mutex mutex; + +static QByteArray getStringFromId(int id) +{ + std::lock_guard lock(mutex); + return stringFromId.value(id).str; +} + +static int theId(const char *str, int n = 0) +{ + QBS_ASSERT(str && *str, return 0); + StringHolder sh(str, n); + std::lock_guard lock(mutex); + int res = idFromString.value(sh, 0); + if (res == 0) { + res = firstUnusedId++; + sh.str = qstrdup(sh.str); + idFromString[sh] = res; + stringFromId[res] = sh; + } + return res; +} + +static int theId(const QByteArray &ba) +{ + return theId(ba.constData(), ba.size()); +} + +/*! + \fn qbs::Internal::Id(int uid) + + \brief Constructs an id given a UID. + + The UID is an integer value that is unique within the running + process. + + It is the callers responsibility to ensure the uniqueness of + the passed integer. The recommended approach is to use + \c{registerId()} with an value taken from the plugin's + private range. + + \sa registerId() + +*/ + +/*! + Constructs an id given its associated name. The internal + representation will be unspecified, but consistent within a + process. + +*/ +Id::Id(const char *name) + : m_id(theId(name, 0)) +{} + +/*! + \overload + +*/ +Id::Id(const QByteArray &name) + : m_id(theId(name)) +{} + +/*! + Returns an internal representation of the id. +*/ + +QByteArray Id::name() const +{ + return getStringFromId(m_id); +} + +/*! + Returns a string representation of the id suitable + for UI display. + + This should not be used to create a persistent version + of the Id, use \c{toSetting()} instead. + + \sa fromString(), toSetting() +*/ + +QString Id::toString() const +{ + return QString::fromUtf8(getStringFromId(m_id)); +} + +/*! + Returns a persistent value representing the id which is + suitable to be stored in QSettings. + + \sa fromSetting() +*/ + +QVariant Id::toSetting() const +{ + return QString::fromUtf8(getStringFromId(m_id)); +} + +/*! + Reconstructs an id from a persistent value. + + \sa toSetting() +*/ + +Id Id::fromSetting(const QVariant &variant) +{ + const QByteArray ba = variant.toString().toUtf8(); + if (ba.isEmpty()) + return {}; + return {theId(ba)}; +} + +/*! + Constructs a derived id. + + This can be used to construct groups of ids logically + belonging together. The associated internal name + will be generated by appending \c{suffix}. +*/ + +Id Id::withSuffix(int suffix) const +{ + const QByteArray ba = name() + QByteArray::number(suffix); + return {ba.constData()}; +} + +/*! + \overload +*/ + +Id Id::withSuffix(const char *suffix) const +{ + const QByteArray ba = name() + suffix; + return {ba.constData()}; +} + +/*! + Constructs a derived id. + + This can be used to construct groups of ids logically + belonging together. The associated internal name + will be generated by prepending \c{prefix}. +*/ + +Id Id::withPrefix(const char *prefix) const +{ + const QByteArray ba = prefix + name(); + return {ba.constData()}; +} + +bool Id::operator==(const char *name) const +{ + const auto string = getStringFromId(m_id); + if (!string.isNull() && name) + return strcmp(string.data(), name) == 0; + return false; +} + +bool Id::alphabeticallyBefore(Id other) const +{ + return toString().compare(other.toString(), Qt::CaseInsensitive) < 0; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/id.h b/src/lib/corelib/tools/id.h new file mode 100644 index 00000000..845ed60d --- /dev/null +++ b/src/lib/corelib/tools/id.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TOOLS_ID_H +#define QBS_TOOLS_ID_H + +#include "qbs_export.h" +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +class QBS_AUTOTEST_EXPORT Id +{ +public: + enum { IdsPerPlugin = 10000, ReservedPlugins = 1000 }; + + Id() : m_id(0) {} + Id(int uid) : m_id(uid) {} + Id(const char *name); + explicit Id(const QByteArray &name); + + Id withSuffix(int suffix) const; + Id withSuffix(const char *name) const; + Id withPrefix(const char *name) const; + + QByteArray name() const; + QString toString() const; // Avoid. + QVariant toSetting() const; // Good to use. + bool isValid() const { return m_id; } + bool operator==(Id id) const { return m_id == id.m_id; } + bool operator==(const char *name) const; + bool operator!=(Id id) const { return m_id != id.m_id; } + bool operator!=(const char *name) const { return !operator==(name); } + bool operator<(Id id) const { return m_id < id.m_id; } + bool operator>(Id id) const { return m_id > id.m_id; } + bool alphabeticallyBefore(Id other) const; + int uniqueIdentifier() const { return m_id; } + static Id fromUniqueIdentifier(int uid) { return {uid}; } + static Id fromSetting(const QVariant &variant); // Good to use. + +private: + // Intentionally unimplemented + Id(const QLatin1String &); + int m_id; +}; + +inline QHashValueType qHash(const Id &id) { return id.uniqueIdentifier(); } + +} // namespace Internal +} // namespace qbs + +Q_DECLARE_METATYPE(qbs::Internal::Id) +Q_DECLARE_METATYPE(QList) + +#endif // QBS_TOOLS_ID_H diff --git a/src/lib/corelib/tools/installoptions.cpp b/src/lib/corelib/tools/installoptions.cpp new file mode 100644 index 00000000..5e112e6d --- /dev/null +++ b/src/lib/corelib/tools/installoptions.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "installoptions.h" + +#include "jsonhelper.h" +#include "stringconstants.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +class InstallOptionsPrivate : public QSharedData +{ +public: + InstallOptionsPrivate() + : useSysroot(false), removeExisting(false), dryRun(false), + keepGoing(false), logElapsedTime(false) + {} + + QString installRoot; + bool useSysroot; + bool removeExisting; + bool dryRun; + bool keepGoing; + bool logElapsedTime; +}; + +QString effectiveInstallRoot(const InstallOptions &options, const TopLevelProject *project) +{ + const QString installRoot = options.installRoot(); + if (!installRoot.isEmpty()) + return installRoot; + + if (options.installIntoSysroot()) { + return project->buildConfiguration().value(StringConstants::qbsModule()).toMap() + .value(QStringLiteral("sysroot")).toString(); + } + return project->buildConfiguration().value(StringConstants::qbsModule()).toMap() + .value(StringConstants::installRootProperty()).toString(); +} + +} // namespace Internal + +/*! + * \class InstallOptions + * \brief The \c InstallOptions class comprises parameters that influence the behavior of + * install operations. + */ + +InstallOptions::InstallOptions() : d(new Internal::InstallOptionsPrivate) +{ +} + +InstallOptions::InstallOptions(const InstallOptions &other) = default; + +InstallOptions::InstallOptions(InstallOptions &&other) Q_DECL_NOEXCEPT = default; + +InstallOptions &InstallOptions::operator=(const InstallOptions &other) = default; + +InstallOptions &InstallOptions::operator=(InstallOptions &&other) Q_DECL_NOEXCEPT = default; + +InstallOptions::~InstallOptions() = default; + +/*! + * \brief The default install root, relative to the build directory. + */ +QString InstallOptions::defaultInstallRoot() +{ + return QStringLiteral("install-root"); +} + +/*! + * Returns the base directory for the installation. + * The \c qbs.installPrefix path is relative to this root. If the string is empty, either the value of + * qbs.sysroot or "/install-root" will be used, depending on what \c installIntoSysroot() + * returns. + * The default is empty. + */ +QString InstallOptions::installRoot() const +{ + return d->installRoot; +} + +/*! + * \brief Sets the base directory for the installation. + * \note The argument must either be an empty string or an absolute path to a directory + * (which might not yet exist, in which case it will be created). + */ +void InstallOptions::setInstallRoot(const QString &installRoot) +{ + d->installRoot = QDir::cleanPath(installRoot); + if (!QDir(installRoot).isRoot()) { + while (d->installRoot.endsWith(QLatin1Char('/'))) + d->installRoot.chop(1); + } +} + +/*! + * Returns whether to use the sysroot as the default install root. + * The default is false. + */ +bool InstallOptions::installIntoSysroot() const +{ + return d->useSysroot; +} + +void InstallOptions::setInstallIntoSysroot(bool useSysroot) +{ + d->useSysroot = useSysroot; +} + +/*! + * \brief Returns true iff an existing installation will be removed prior to installing. + * The default is false. + */ +bool InstallOptions::removeExistingInstallation() const +{ + return d->removeExisting; +} + +/*! + * Controls whether to remove an existing installation before installing. + * \note qbs may do some safety checks and refuse to remove certain directories such as + * a user's home directory. You should still be careful with this option, since it + * deletes recursively. + */ +void InstallOptions::setRemoveExistingInstallation(bool removeExisting) +{ + d->removeExisting = removeExisting; +} + +/*! + * \brief Returns true iff qbs will not actually copy any files, but just show what would happen. + * The default is false. + */ +bool InstallOptions::dryRun() const +{ + return d->dryRun; +} + +/*! + * \brief Controls whether installation will actually take place. + * If the argument is true, then qbs will emit information about which files would be copied + * instead of actually doing it. + */ +void InstallOptions::setDryRun(bool dryRun) +{ + d->dryRun = dryRun; +} + +/*! + * Returns true iff installation will continue if an error occurs. + * The default is false. + */ +bool InstallOptions::keepGoing() const +{ + return d->keepGoing; +} + +/*! + * \brief Controls whether to abort on errors. + * If the argument is true, then if a file cannot be copied e.g. due to a permission problem, + * a warning will be printed and the installation will continue. If the argument is false, + * then the installation will abort immediately in case of an error. + */ +void InstallOptions::setKeepGoing(bool keepGoing) +{ + d->keepGoing = keepGoing; +} + +/*! + * \brief Returns true iff the time the operation takes will be logged. + * The default is false. + */ +bool InstallOptions::logElapsedTime() const +{ + return d->logElapsedTime; +} + +/*! + * \brief Controls whether the installation time will be measured and logged. + */ +void InstallOptions::setLogElapsedTime(bool logElapsedTime) +{ + d->logElapsedTime = logElapsedTime; +} + +qbs::InstallOptions qbs::InstallOptions::fromJson(const QJsonObject &data) +{ + using namespace Internal; + InstallOptions opt; + setValueFromJson(opt.d->installRoot, data, "install-root"); + setValueFromJson(opt.d->useSysroot, data, "use-sysroot"); + setValueFromJson(opt.d->removeExisting, data, "clean-install-root"); + setValueFromJson(opt.d->dryRun, data, "dry-run"); + setValueFromJson(opt.d->keepGoing, data, "keep-going"); + setValueFromJson(opt.d->logElapsedTime, data, "log-time"); + return opt; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/installoptions.h b/src/lib/corelib/tools/installoptions.h new file mode 100644 index 00000000..16511aa3 --- /dev/null +++ b/src/lib/corelib/tools/installoptions.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_INSTALLOPTIONS_H +#define QBS_INSTALLOPTIONS_H + +#include "qbs_export.h" + +#include + +QT_BEGIN_NAMESPACE +class QJsonObject; +class QString; +QT_END_NAMESPACE + +namespace qbs { +class InstallOptions; +namespace Internal { +class InstallOptionsPrivate; +class TopLevelProject; +QString effectiveInstallRoot(const InstallOptions &options, const TopLevelProject *project); +} + +class QBS_EXPORT InstallOptions +{ +public: + InstallOptions(); + InstallOptions(const InstallOptions &other); + InstallOptions(InstallOptions &&other) Q_DECL_NOEXCEPT; + InstallOptions &operator=(const InstallOptions &other); + InstallOptions &operator=(InstallOptions &&other) Q_DECL_NOEXCEPT; + ~InstallOptions(); + + static InstallOptions fromJson(const QJsonObject &data); + + static QString defaultInstallRoot(); + QString installRoot() const; + void setInstallRoot(const QString &installRoot); + + bool installIntoSysroot() const; + void setInstallIntoSysroot(bool useSysroot); + + bool removeExistingInstallation() const; + void setRemoveExistingInstallation(bool removeExisting); + + bool dryRun() const; + void setDryRun(bool dryRun); + + bool keepGoing() const; + void setKeepGoing(bool keepGoing); + + bool logElapsedTime() const; + void setLogElapsedTime(bool logElapsedTime); + +private: + QSharedDataPointer d; +}; + +} // namespace qbs + +#endif // QBS_INSTALLOPTIONS_H diff --git a/src/lib/corelib/tools/iosutils.h b/src/lib/corelib/tools/iosutils.h new file mode 100644 index 00000000..69957a82 --- /dev/null +++ b/src/lib/corelib/tools/iosutils.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_IOSUTILS_H +#define QBS_IOSUTILS_H + +#include +#include +#include + +#if defined(_WIN32) && defined(_MSC_VER) +#include +#include +#define QBS_RENAME_IMPL ::_wrename +#define QBS_UNLINK_IMPL ::_wunlink +using qbs_filesystem_path_string_type = std::wstring; +#else +#include +#define QBS_RENAME_IMPL ::rename +#define QBS_UNLINK_IMPL ::unlink +using qbs_filesystem_path_string_type = std::string; +#endif + +namespace qbs { +namespace Internal { + +static inline bool fwrite(const char *values, size_t nitems, std::ostream *stream) +{ + if (!stream) + return false; + stream->write(values, nitems); + return stream->good(); +} + +template +bool fwrite(const C &container, std::ostream *stream) +{ + return fwrite(&*(std::begin(container)), container.size(), stream); +} + +static inline bool fwrite(const char *s, std::ostream *stream) +{ + return fwrite(s, strlen(s), stream); +} + +static inline qbs_filesystem_path_string_type utf8_to_native_path(const std::string &str) +{ +#if defined(_WIN32) && defined(_MSC_VER) + const int size = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); + std::wstring result(size, 0); + MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), result.data(), size); + return result; +#else + return str; +#endif +} + +static inline int rename(const std::string &oldName, const std::string &newName) +{ + const auto wOldName = utf8_to_native_path(oldName); + const auto wNewName = utf8_to_native_path(newName); + return QBS_RENAME_IMPL(wOldName.c_str(), wNewName.c_str()); +} + +static inline int unlink(const std::string &name) +{ + const auto wName = utf8_to_native_path(name); + return QBS_UNLINK_IMPL(wName.c_str()); +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_IOSUTILS_H diff --git a/src/lib/corelib/tools/joblimits.cpp b/src/lib/corelib/tools/joblimits.cpp new file mode 100644 index 00000000..54c8c98b --- /dev/null +++ b/src/lib/corelib/tools/joblimits.cpp @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "joblimits.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +static int transformLimit(int limitFromUser) +{ + return limitFromUser == 0 + ? std::numeric_limits::max() + : limitFromUser < -1 ? -1 + : limitFromUser; +} + +class JobLimitPrivate : public QSharedData +{ +public: + JobLimitPrivate(const QString &pool, int limit) + : jobLimit(std::make_pair(pool, transformLimit(limit))) + { + } + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(jobLimit); + } + std::pair jobLimit; +}; + +class JobLimitsPrivate : public QSharedData +{ +public: + template void serializationOp(PersistentPool &pool) + { + pool.serializationOp(jobLimits); + } + std::vector jobLimits; +}; + +} // namespace Internal + +JobLimit::JobLimit() : JobLimit(QString(), -1) +{ +} +JobLimit::JobLimit(const QString &pool, int limit) : d(new Internal::JobLimitPrivate(pool, limit)) +{ +} +JobLimit::JobLimit(const JobLimit &other) = default; +JobLimit &JobLimit::operator=(const JobLimit &other) = default; +JobLimit::~JobLimit() = default; +QString JobLimit::pool() const { return d->jobLimit.first; } +int JobLimit::limit() const { return d->jobLimit.second; } + +void JobLimit::load(Internal::PersistentPool &pool) +{ + d->serializationOp(pool); +} + +void JobLimit::store(Internal::PersistentPool &pool) +{ + d->serializationOp(pool); +} + +JobLimits::JobLimits() : d(new Internal::JobLimitsPrivate) { } +JobLimits::JobLimits(const JobLimits &other) = default; +JobLimits &JobLimits::operator=(const JobLimits &other) = default; +JobLimits::~JobLimits() = default; + +void JobLimits::setJobLimit(const JobLimit &limit) +{ + for (auto ¤tLimit : d->jobLimits) { + if (currentLimit.pool() == limit.pool()) { + if (currentLimit.limit() != limit.limit()) + currentLimit = limit; + return; + } + } + d->jobLimits.push_back(limit); +} + +void JobLimits::setJobLimit(const QString &pool, int limit) +{ + setJobLimit(JobLimit(pool, limit)); +} + +int JobLimits::getLimit(const QString &pool) const +{ + for (const JobLimit &l : d->jobLimits) { + if (l.pool() == pool) + return l.limit(); + } + return -1; +} + +bool JobLimits::isEmpty() const +{ + return d->jobLimits.empty(); +} + +int JobLimits::count() const +{ + return int(d->jobLimits.size()); +} + +JobLimit JobLimits::jobLimitAt(int i) const +{ + return d->jobLimits.at(i); +} + +JobLimits &JobLimits::update(const JobLimits &other) +{ + if (isEmpty()) { + *this = other; + } else { + for (int i = 0; i < other.count(); ++i) { + const JobLimit &l = other.jobLimitAt(i); + if (l.limit() != -1) + setJobLimit(l); + } + } + return *this; +} + +void JobLimits::load(Internal::PersistentPool &pool) +{ + d->serializationOp(pool); +} + +void JobLimits::store(Internal::PersistentPool &pool) +{ + d->serializationOp(pool); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/joblimits.h b/src/lib/corelib/tools/joblimits.h new file mode 100644 index 00000000..de95f551 --- /dev/null +++ b/src/lib/corelib/tools/joblimits.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_JOB_LIMITS_H +#define QBS_JOB_LIMITS_H + +#include "qbs_export.h" + +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class JobLimitPrivate; +class JobLimitsPrivate; +class PersistentPool; +} + +class QBS_EXPORT JobLimit +{ +public: + JobLimit(); + JobLimit(const QString &pool, int limit); + JobLimit(const JobLimit &other); + JobLimit &operator=(const JobLimit &other); + ~JobLimit(); + + QString pool() const; + int limit() const; + + void load(Internal::PersistentPool &pool); + void store(Internal::PersistentPool &pool); +private: + QSharedDataPointer d; +}; + +class QBS_EXPORT JobLimits +{ +public: + JobLimits(); + JobLimits(const JobLimits &other); + JobLimits &operator=(const JobLimits &other); + ~JobLimits(); + + void setJobLimit(const JobLimit &limit); + void setJobLimit(const QString &pool, int limit); + int getLimit(const QString &pool) const; + bool hasLimit(const QString &pool) const { return getLimit(pool) != -1; } + bool isEmpty() const; + + int count() const; + JobLimit jobLimitAt(int i) const; + + JobLimits &update(const JobLimits &other); + + void load(Internal::PersistentPool &pool); + void store(Internal::PersistentPool &pool); +private: + QSharedDataPointer d; +}; + +} // namespace qbs + +#endif // include guard diff --git a/src/lib/corelib/tools/jsliterals.cpp b/src/lib/corelib/tools/jsliterals.cpp new file mode 100644 index 00000000..647bdc64 --- /dev/null +++ b/src/lib/corelib/tools/jsliterals.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "jsliterals.h" + +#include +#include + +#include + +namespace qbs { + +QString toJSLiteral(const bool b) +{ + return b ? Internal::StringConstants::trueValue() : Internal::StringConstants::falseValue(); +} + +QString toJSLiteral(const QString &str) +{ + QString js = str; + js.replace(QRegularExpression(QLatin1String("([\\\\\"])")), QLatin1String("\\\\1")); + js.prepend(QLatin1Char('"')); + js.append(QLatin1Char('"')); + return js; +} + +QString toJSLiteral(const QStringList &strs) +{ + QString js = QStringLiteral("["); + for (int i = 0; i < strs.size(); ++i) { + if (i != 0) + js.append(QLatin1String(", ")); + js.append(toJSLiteral(strs.at(i))); + } + js.append(QLatin1Char(']')); + return js; +} + +QString toJSLiteral(const QVariant &val) +{ + if (!val.isValid()) + return Internal::StringConstants::undefinedValue(); + if (val.userType() == QMetaType::QVariantList || val.userType() == QMetaType::QStringList) { + QString res; + const auto list = val.toList(); + for (const QVariant &child : list) { + if (res.length()) res.append(QLatin1String(", ")); + res.append(toJSLiteral(child)); + } + res.prepend(QLatin1Char('[')); + res.append(QLatin1Char(']')); + return res; + } + if (val.userType() == QMetaType::QVariantMap) { + const QVariantMap &vm = val.toMap(); + QString str = QStringLiteral("{"); + for (QVariantMap::const_iterator it = vm.begin(); it != vm.end(); ++it) { + if (it != vm.begin()) + str += QLatin1Char(','); + str += toJSLiteral(it.key()) + QLatin1Char(':') + toJSLiteral(it.value()); + } + str += QLatin1Char('}'); + return str; + } + if (val.userType() == QMetaType::Bool) + return toJSLiteral(val.toBool()); + if (qVariantCanConvert(val, QMetaType::QString)) + return toJSLiteral(val.toString()); + return QStringLiteral("Unconvertible type %1").arg(QLatin1String(val.typeName())); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/jsliterals.h b/src/lib/corelib/tools/jsliterals.h new file mode 100644 index 00000000..7286ca5d --- /dev/null +++ b/src/lib/corelib/tools/jsliterals.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_JSLITERALS_H +#define QBS_JSLITERALS_H + +#include "qbs_export.h" + +#include +#include +#include + +namespace qbs { + +QBS_EXPORT QString toJSLiteral(const bool b); +QBS_EXPORT QString toJSLiteral(const QString &str); +QBS_EXPORT QString toJSLiteral(const QStringList &strs); +QBS_EXPORT QString toJSLiteral(const QVariant &val); + +} // namespace qbs + +#endif // QBS_JSLITERALS_H diff --git a/src/lib/corelib/tools/jsonhelper.h b/src/lib/corelib/tools/jsonhelper.h new file mode 100644 index 00000000..cb911c45 --- /dev/null +++ b/src/lib/corelib/tools/jsonhelper.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_JSON_HELPER_H +#define QBS_JSON_HELPER_H + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +template inline T fromJson(const QJsonValue &v); +template<> inline bool fromJson(const QJsonValue &v) { return v.toBool(); } +template<> inline int fromJson(const QJsonValue &v) { return v.toInt(); } +template<> inline QString fromJson(const QJsonValue &v) { return v.toString(); } +template<> inline QStringList fromJson(const QJsonValue &v) +{ + const QJsonArray &jsonList = v.toArray(); + return transformed(jsonList, [](const auto &v) { return v.toString(); }); +} +template<> inline QVariantMap fromJson(const QJsonValue &v) { return v.toObject().toVariantMap(); } +template<> inline QProcessEnvironment fromJson(const QJsonValue &v) +{ + const QJsonObject obj = v.toObject(); + QProcessEnvironment env; + for (auto it = obj.begin(); it != obj.end(); ++it) + env.insert(it.key(), it.value().toString()); + return env; +} + +template inline void setValueFromJson(T &targetValue, const QJsonObject &data, + const char *jsonProperty) +{ + const auto it = data.find(QLatin1String(jsonProperty)); + if (it != data.end()) + targetValue = fromJson(*it); +} + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/launcherinterface.cpp b/src/lib/corelib/tools/launcherinterface.cpp new file mode 100644 index 00000000..cd877c15 --- /dev/null +++ b/src/lib/corelib/tools/launcherinterface.cpp @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launcherinterface.h" + +#include "launcherpackets.h" +#include "launchersocket.h" +#include "qbsassert.h" +#include +#include + +#include +#include +#include +#include +#include + +#ifdef Q_OS_UNIX +#include +#endif + +namespace qbs { +namespace Internal { + +class LauncherProcess : public QProcess +{ +public: + LauncherProcess(QObject *parent) : QProcess(parent) + { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_UNIX) + setChildProcessModifier([this] { setupChildProcess_impl(); }); +#endif + } + +private: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + void setupChildProcess() override + { + setupChildProcess_impl(); + } +#endif + + void setupChildProcess_impl() + { +#ifdef Q_OS_UNIX + const auto pid = static_cast(processId()); + setpgid(pid, pid); +#endif + } +}; + +static QString launcherSocketName() +{ + return QStringLiteral("qbs_processlauncher-%1") + .arg(QString::number(qApp->applicationPid())); +} + +LauncherInterface::LauncherInterface() + : m_server(new QLocalServer(this)), m_socket(new LauncherSocket(this)) +{ + QObject::connect(m_server, &QLocalServer::newConnection, + this, &LauncherInterface::handleNewConnection); +} + +LauncherInterface &LauncherInterface::instance() +{ + static LauncherInterface p; + return p; +} + +LauncherInterface::~LauncherInterface() +{ + m_server->disconnect(); +} + +void LauncherInterface::doStart() +{ + if (++m_startRequests > 1) + return; + const QString &socketName = launcherSocketName(); + QLocalServer::removeServer(socketName); + if (!m_server->listen(socketName)) { + emit errorOccurred(ErrorInfo(m_server->errorString())); + return; + } + m_process = new LauncherProcess(this); + connect(m_process, &QProcess::errorOccurred, this, &LauncherInterface::handleProcessError); + connect(m_process, + static_cast(&QProcess::finished), + this, &LauncherInterface::handleProcessFinished); + connect(m_process, &QProcess::readyReadStandardError, + this, &LauncherInterface::handleProcessStderr); + m_process->start(qApp->applicationDirPath() + QLatin1Char('/') + + QLatin1String(QBS_RELATIVE_LIBEXEC_PATH) + + QLatin1String("/qbs_processlauncher"), + QStringList(m_server->fullServerName())); +} + +void LauncherInterface::doStop() +{ + if (--m_startRequests > 0) + return; + m_server->close(); + if (!m_process) + return; + m_process->disconnect(); + m_socket->shutdown(); + m_process->waitForFinished(3000); + m_process->deleteLater(); + m_process = nullptr; +} + +void LauncherInterface::handleNewConnection() +{ + QLocalSocket * const socket = m_server->nextPendingConnection(); + if (!socket) + return; + m_server->close(); + m_socket->setSocket(socket); +} + +void LauncherInterface::handleProcessError() +{ + if (m_process->error() == QProcess::FailedToStart) { + const QString launcherPathForUser + = QDir::toNativeSeparators(QDir::cleanPath(m_process->program())); + emit errorOccurred(ErrorInfo(Tr::tr("Failed to start process launcher at '%1': %2") + .arg(launcherPathForUser, m_process->errorString()))); + } +} + +void LauncherInterface::handleProcessFinished() +{ + emit errorOccurred(ErrorInfo(Tr::tr("Process launcher closed unexpectedly: %1") + .arg(m_process->errorString()))); +} + +void LauncherInterface::handleProcessStderr() +{ + qDebug() << "[launcher]" << m_process->readAllStandardError(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/launcherinterface.h b/src/lib/corelib/tools/launcherinterface.h new file mode 100644 index 00000000..f3aca9bf --- /dev/null +++ b/src/lib/corelib/tools/launcherinterface.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LAUNCHERINTERFACE_H +#define QBS_LAUNCHERINTERFACE_H + +#include + +QT_BEGIN_NAMESPACE +class QLocalServer; +QT_END_NAMESPACE + +namespace qbs { +class ErrorInfo; +namespace Internal { +class LauncherProcess; +class LauncherSocket; + +class LauncherInterface : public QObject +{ + Q_OBJECT +public: + static LauncherInterface &instance(); + ~LauncherInterface() override; + + static void startLauncher() { instance().doStart(); } + static void stopLauncher() { instance().doStop(); } + static LauncherSocket *socket() { return instance().m_socket; } + +signals: + void errorOccurred(const ErrorInfo &error); + +private: + LauncherInterface(); + + void doStart(); + void doStop(); + void handleNewConnection(); + void handleProcessError(); + void handleProcessFinished(); + void handleProcessStderr(); + + QLocalServer * const m_server; + LauncherSocket * const m_socket; + LauncherProcess * m_process = nullptr; + int m_startRequests = 0; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/launcherpackets.cpp b/src/lib/corelib/tools/launcherpackets.cpp new file mode 100644 index 00000000..9c7946d7 --- /dev/null +++ b/src/lib/corelib/tools/launcherpackets.cpp @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launcherpackets.h" + +#include +#include + +namespace qbs { +namespace Internal { + +LauncherPacket::~LauncherPacket() = default; + +QByteArray LauncherPacket::serialize() const +{ + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + stream << static_cast(0) << static_cast(type) << token; + doSerialize(stream); + stream.device()->reset(); + stream << static_cast(data.size() - sizeof(int)); + return data; +} + +void LauncherPacket::deserialize(const QByteArray &data) +{ + QDataStream stream(data); + doDeserialize(stream); +} + + +StartProcessPacket::StartProcessPacket(quintptr token) + : LauncherPacket(LauncherPacketType::StartProcess, token) +{ +} + +void StartProcessPacket::doSerialize(QDataStream &stream) const +{ + stream << command << arguments << workingDir << env; +} + +void StartProcessPacket::doDeserialize(QDataStream &stream) +{ + stream >> command >> arguments >> workingDir >> env; +} + + +StopProcessPacket::StopProcessPacket(quintptr token) + : LauncherPacket(LauncherPacketType::StopProcess, token) +{ +} + +void StopProcessPacket::doSerialize(QDataStream &stream) const +{ + Q_UNUSED(stream); +} + +void StopProcessPacket::doDeserialize(QDataStream &stream) +{ + Q_UNUSED(stream); +} + + +ProcessErrorPacket::ProcessErrorPacket(quintptr token) + : LauncherPacket(LauncherPacketType::ProcessError, token) +{ +} + +void ProcessErrorPacket::doSerialize(QDataStream &stream) const +{ + stream << static_cast(error) << errorString; +} + +void ProcessErrorPacket::doDeserialize(QDataStream &stream) +{ + quint8 e; + stream >> e; + error = static_cast(e); + stream >> errorString; +} + + +ProcessFinishedPacket::ProcessFinishedPacket(quintptr token) + : LauncherPacket(LauncherPacketType::ProcessFinished, token) +{ +} + +void ProcessFinishedPacket::doSerialize(QDataStream &stream) const +{ + stream << errorString << stdOut << stdErr + << static_cast(exitStatus) << static_cast(error) + << exitCode; +} + +void ProcessFinishedPacket::doDeserialize(QDataStream &stream) +{ + stream >> errorString >> stdOut >> stdErr; + quint8 val; + stream >> val; + exitStatus = static_cast(val); + stream >> val; + error = static_cast(val); + stream >> exitCode; +} + +ShutdownPacket::ShutdownPacket() : LauncherPacket(LauncherPacketType::Shutdown, 0) { } +void ShutdownPacket::doSerialize(QDataStream &stream) const { Q_UNUSED(stream); } +void ShutdownPacket::doDeserialize(QDataStream &stream) { Q_UNUSED(stream); } + +void PacketParser::setDevice(QIODevice *device) +{ + m_stream.setDevice(device); + m_sizeOfNextPacket = -1; +} + +bool PacketParser::parse() +{ + static const int commonPayloadSize = static_cast(1 + sizeof(quintptr)); + if (m_sizeOfNextPacket == -1) { + if (m_stream.device()->bytesAvailable() < static_cast(sizeof m_sizeOfNextPacket)) + return false; + m_stream >> m_sizeOfNextPacket; + if (m_sizeOfNextPacket < commonPayloadSize) + throw InvalidPacketSizeException(m_sizeOfNextPacket); + } + if (m_stream.device()->bytesAvailable() < m_sizeOfNextPacket) + return false; + quint8 type; + m_stream >> type; + m_type = static_cast(type); + m_stream >> m_token; + m_packetData = m_stream.device()->read(m_sizeOfNextPacket - commonPayloadSize); + m_sizeOfNextPacket = -1; + return true; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/launcherpackets.h b/src/lib/corelib/tools/launcherpackets.h new file mode 100644 index 00000000..b3eac432 --- /dev/null +++ b/src/lib/corelib/tools/launcherpackets.h @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LAUNCHERPACKETS_H +#define QBS_LAUNCHERPACKETS_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +enum class LauncherPacketType { + Shutdown, StartProcess, StopProcess, ProcessError, ProcessFinished +}; + +class PacketParser +{ +public: + class InvalidPacketSizeException + { + public: + InvalidPacketSizeException(int size) : size(size) { } + const int size; + }; + + void setDevice(QIODevice *device); + bool parse(); + LauncherPacketType type() const { return m_type; } + quintptr token() const { return m_token; } + const QByteArray &packetData() const { return m_packetData; } + +private: + QDataStream m_stream; + LauncherPacketType m_type = LauncherPacketType::Shutdown; + quintptr m_token = 0; + QByteArray m_packetData; + int m_sizeOfNextPacket = -1; +}; + +class LauncherPacket +{ +public: + virtual ~LauncherPacket(); + + template static Packet extractPacket(quintptr token, const QByteArray &data) + { + Packet p(token); + p.deserialize(data); + return p; + } + + QByteArray serialize() const; + void deserialize(const QByteArray &data); + + const LauncherPacketType type; + const quintptr token = 0; + +protected: + LauncherPacket(LauncherPacketType type, quintptr token) : type(type), token(token) { } + +private: + virtual void doSerialize(QDataStream &stream) const = 0; + virtual void doDeserialize(QDataStream &stream) = 0; +}; + +class StartProcessPacket : public LauncherPacket +{ +public: + StartProcessPacket(quintptr token); + + QString command; + QStringList arguments; + QString workingDir; + QStringList env; + +private: + void doSerialize(QDataStream &stream) const override; + void doDeserialize(QDataStream &stream) override; +}; + +class StopProcessPacket : public LauncherPacket +{ +public: + StopProcessPacket(quintptr token); + +private: + void doSerialize(QDataStream &stream) const override; + void doDeserialize(QDataStream &stream) override; +}; + +class ShutdownPacket : public LauncherPacket +{ +public: + ShutdownPacket(); + +private: + void doSerialize(QDataStream &stream) const override; + void doDeserialize(QDataStream &stream) override; +}; + +class ProcessErrorPacket : public LauncherPacket +{ +public: + ProcessErrorPacket(quintptr token); + + QProcess::ProcessError error = QProcess::UnknownError; + QString errorString; + +private: + void doSerialize(QDataStream &stream) const override; + void doDeserialize(QDataStream &stream) override; +}; + +class ProcessFinishedPacket : public LauncherPacket +{ +public: + ProcessFinishedPacket(quintptr token); + + QString errorString; + QByteArray stdOut; + QByteArray stdErr; + QProcess::ExitStatus exitStatus = QProcess::ExitStatus::NormalExit; + QProcess::ProcessError error = QProcess::ProcessError::UnknownError; + int exitCode = 0; + +private: + void doSerialize(QDataStream &stream) const override; + void doDeserialize(QDataStream &stream) override; +}; + +} // namespace Internal +} // namespace qbs + +Q_DECLARE_METATYPE(qbs::Internal::LauncherPacketType); + +#endif // Include guard diff --git a/src/lib/corelib/tools/launchersocket.cpp b/src/lib/corelib/tools/launchersocket.cpp new file mode 100644 index 00000000..1489af1e --- /dev/null +++ b/src/lib/corelib/tools/launchersocket.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launchersocket.h" + +#include "qbsassert.h" +#include "qttools.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +LauncherSocket::LauncherSocket(QObject *parent) : QObject(parent) +{ + qRegisterMetaType(); + qRegisterMetaType("quintptr"); +} + +void LauncherSocket::sendData(const QByteArray &data) +{ + if (!isReady()) + return; + std::lock_guard locker(m_requestsMutex); + m_requests.push_back(data); + if (m_requests.size() == 1) + QTimer::singleShot(0, this, &LauncherSocket::handleRequests); +} + +void LauncherSocket::shutdown() +{ + const auto socket = m_socket.exchange(nullptr); + if (!socket) + return; + socket->disconnect(); + socket->write(ShutdownPacket().serialize()); + socket->waitForBytesWritten(1000); + socket->deleteLater(); +} + +void LauncherSocket::setSocket(QLocalSocket *socket) +{ + QBS_ASSERT(!m_socket, return); + m_socket.store(socket); + m_packetParser.setDevice(m_socket); + connect(m_socket, +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + static_cast(&QLocalSocket::error), +#else + &QLocalSocket::errorOccurred, +#endif + this, &LauncherSocket::handleSocketError); + connect(m_socket, &QLocalSocket::readyRead, + this, &LauncherSocket::handleSocketDataAvailable); + connect(m_socket, &QLocalSocket::disconnected, + this, &LauncherSocket::handleSocketDisconnected); + emit ready(); +} + +void LauncherSocket::handleSocketError() +{ + auto socket = m_socket.load(); + if (socket->error() != QLocalSocket::PeerClosedError) + handleError(Tr::tr("Socket error: %1").arg(socket->errorString())); +} + +void LauncherSocket::handleSocketDataAvailable() +{ + try { + if (!m_packetParser.parse()) + return; + } catch (const PacketParser::InvalidPacketSizeException &e) { + handleError(Tr::tr("Internal protocol error: invalid packet size %1.").arg(e.size)); + return; + } + switch (m_packetParser.type()) { + case LauncherPacketType::ProcessError: + case LauncherPacketType::ProcessFinished: + emit packetArrived(m_packetParser.type(), m_packetParser.token(), + m_packetParser.packetData()); + break; + default: + handleError(Tr::tr("Internal protocol error: invalid packet type %1.") + .arg(static_cast(m_packetParser.type()))); + return; + } + handleSocketDataAvailable(); +} + +void LauncherSocket::handleSocketDisconnected() +{ + handleError(Tr::tr("Launcher socket closed unexpectedly")); +} + +void LauncherSocket::handleError(const QString &error) +{ + const auto socket = m_socket.exchange(nullptr); + socket->disconnect(); + socket->deleteLater(); + emit errorOccurred(error); +} + +void LauncherSocket::handleRequests() +{ + const auto socket = m_socket.load(); + QBS_ASSERT(socket, return); + std::lock_guard locker(m_requestsMutex); + for (const QByteArray &request : qAsConst(m_requests)) + socket->write(request); + m_requests.clear(); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/launchersocket.h b/src/lib/corelib/tools/launchersocket.h new file mode 100644 index 00000000..2eb2c3f6 --- /dev/null +++ b/src/lib/corelib/tools/launchersocket.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LAUNCHERSOCKET_H +#define QBS_LAUNCHERSOCKET_H + +#include "launcherpackets.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QLocalSocket; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class LauncherInterface; + +class LauncherSocket : public QObject +{ + Q_OBJECT + friend class LauncherInterface; +public: + bool isReady() const { return m_socket.load(); } + void sendData(const QByteArray &data); + +signals: + void ready(); + void errorOccurred(const QString &error); + void packetArrived(qbs::Internal::LauncherPacketType type, quintptr token, + const QByteArray &payload); + +private: + LauncherSocket(QObject *parent); + + void setSocket(QLocalSocket *socket); + void shutdown(); + + void handleSocketError(); + void handleSocketDataAvailable(); + void handleSocketDisconnected(); + void handleError(const QString &error); + void handleRequests(); + + std::atomic m_socket{nullptr}; + PacketParser m_packetParser; + std::vector m_requests; + std::mutex m_requestsMutex; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/msvcinfo.cpp b/src/lib/corelib/tools/msvcinfo.cpp new file mode 100644 index 00000000..418a76ba --- /dev/null +++ b/src/lib/corelib/tools/msvcinfo.cpp @@ -0,0 +1,729 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "msvcinfo.h" +#include "visualstudioversioninfo.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_WIN +#include +#endif + +#include +#include +#include + +using namespace qbs; +using namespace qbs::Internal; + +static std::recursive_mutex envMutex; + +static QString mkStr(const char *s) { return QString::fromLocal8Bit(s); } +static QString mkStr(const QByteArray &ba) { return mkStr(ba.constData()); } + +class TemporaryEnvChanger +{ +public: + TemporaryEnvChanger(const QProcessEnvironment &envChanges) : m_locker(envMutex) + { + QProcessEnvironment currentEnv = QProcessEnvironment::systemEnvironment(); + const auto keys = envChanges.keys(); + for (const QString &key : keys) { + m_changesToRestore.insert(key, currentEnv.value(key)); + qputenv(qPrintable(key), qPrintable(envChanges.value(key))); + } + } + + ~TemporaryEnvChanger() + { + const auto keys = m_changesToRestore.keys(); + for (const QString &key : keys) + qputenv(qPrintable(key), qPrintable(m_changesToRestore.value(key))); + } + +private: + QProcessEnvironment m_changesToRestore; + std::lock_guard m_locker; +}; + +static QByteArray runProcess(const QString &exeFilePath, const QStringList &args, + const QProcessEnvironment &env = QProcessEnvironment(), + bool allowFailure = false, + const QByteArray &pipeData = QByteArray()) +{ + TemporaryEnvChanger envChanger(env); + QProcess process; + process.start(exeFilePath, args); + if (!process.waitForStarted()) + throw ErrorInfo(mkStr("Could not start %1 (%2)").arg(exeFilePath, process.errorString())); + if (!pipeData.isEmpty()) { + process.write(pipeData); + process.closeWriteChannel(); + } + if (!process.waitForFinished(-1) || process.exitStatus() != QProcess::NormalExit) + throw ErrorInfo(mkStr("Could not run %1 (%2)").arg(exeFilePath, process.errorString())); + if (process.exitCode() != 0 && !allowFailure) { + ErrorInfo e(mkStr("Process '%1' failed with exit code %2.") + .arg(exeFilePath).arg(process.exitCode())); + const QByteArray stdErr = process.readAllStandardError(); + if (!stdErr.isEmpty()) + e.append(mkStr("stderr was: %1").arg(mkStr(stdErr))); + const QByteArray stdOut = process.readAllStandardOutput(); + if (!stdOut.isEmpty()) + e.append(mkStr("stdout was: %1").arg(mkStr(stdOut))); + throw e; + } + return process.readAllStandardOutput().trimmed(); +} + +class DummyFile { +public: + DummyFile(QString fp) : filePath(std::move(fp)) { } + ~DummyFile() { QFile::remove(filePath); } + const QString filePath; +}; + +#ifdef Q_OS_WIN +static QStringList parseCommandLine(const QString &commandLine) +{ + const auto buf = std::make_unique(size_t(commandLine.size()) + 1); + buf[size_t(commandLine.toWCharArray(buf.get()))] = 0; + int argCount = 0; + const auto argsDeleter = [](LPWSTR *p){ LocalFree(p); }; + const auto args = std::unique_ptr( + CommandLineToArgvW(buf.get(), &argCount), argsDeleter); + if (!args) + throw ErrorInfo(mkStr("Could not parse command line arguments: ") + commandLine); + QStringList list; + list.reserve(argCount); + for (int i = 0; i < argCount; ++i) + list.push_back(QString::fromWCharArray(args[size_t(i)])); + return list; +} +#endif + +static QVariantMap getMsvcDefines(const QString &compilerFilePath, + const QProcessEnvironment &compilerEnv, + MSVC::CompilerLanguage language) +{ +#ifdef Q_OS_WIN + QString backendSwitch, languageSwitch; + switch (language) { + case MSVC::CLanguage: + backendSwitch = QStringLiteral("/B1"); + languageSwitch = QStringLiteral("/TC"); + break; + case MSVC::CPlusPlusLanguage: + backendSwitch = QStringLiteral("/Bx"); + languageSwitch = QStringLiteral("/TP"); + break; + } + const QByteArray commands("set MSC_CMD_FLAGS\n"); + QStringList out = QString::fromLocal8Bit(runProcess(compilerFilePath, QStringList() + << QStringLiteral("/nologo") + << backendSwitch + << qEnvironmentVariable("COMSPEC") + << QStringLiteral("/c") + << languageSwitch + << QStringLiteral("NUL"), + compilerEnv, true, commands)).split(QLatin1Char('\n')); + + auto findResult = std::find_if(out.cbegin(), out.cend(), [] (const QString &line) { + return line.startsWith(QLatin1String("MSC_CMD_FLAGS=")); + }); + if (findResult == out.cend()) { + throw ErrorInfo(QStringLiteral("Unexpected compiler frontend output: ") + + out.join(QLatin1Char('\n'))); + } + + QVariantMap map; + const QStringList args = parseCommandLine(findResult->trimmed()); + for (const QString &arg : args) { + if (!arg.startsWith(QStringLiteral("-D"))) + continue; + int idx = arg.indexOf(QLatin1Char('='), 2); + if (idx > 2) + map.insert(arg.mid(2, idx - 2), arg.mid(idx + 1)); + else + map.insert(arg.mid(2), QVariant()); + } + + return map; +#else + Q_UNUSED(compilerFilePath); + Q_UNUSED(compilerEnv); + Q_UNUSED(language); + return {}; +#endif +} + +/*! + \internal + clang-cl does not support gcc and msvc ways to dump a macros, so we have to use original + clang.exe directly +*/ +static QVariantMap getClangClDefines( + const QString &compilerFilePath, + const QProcessEnvironment &compilerEnv, + MSVC::CompilerLanguage language, + const QString &arch) +{ +#ifdef Q_OS_WIN + QFileInfo clInfo(compilerFilePath); + QFileInfo clangInfo(clInfo.absolutePath() + QLatin1String("/clang-cl.exe")); + if (!clangInfo.exists()) + throw ErrorInfo(QStringLiteral("%1 does not exist").arg(clangInfo.absoluteFilePath())); + + QStringList args = { + QStringLiteral("/d1PP"), // dump macros + QStringLiteral("/E") // preprocess to stdout + }; + + if (language == MSVC::CLanguage) + args.append(QStringLiteral("/TC")); + else if (language == MSVC::CPlusPlusLanguage) + args.append(QStringLiteral("/TP")); + + if (arch == QLatin1String("x86")) + args.append(QStringLiteral("-m32")); + else if (arch == QLatin1String("x86_64")) + args.append(QStringLiteral("-m64")); + + args.append(QStringLiteral("NUL")); // filename + + const auto lines = QString::fromLocal8Bit( + runProcess( + clangInfo.absoluteFilePath(), + args, + compilerEnv, + true)).split(QLatin1Char('\n')); + QVariantMap result; + for (const auto &line: lines) { + static const auto defineString = QLatin1String("#define "); + if (!line.startsWith(defineString)) + continue; + QStringView view(line.data() + defineString.size()); + const auto it = std::find(view.begin(), view.end(), QLatin1Char(' ')); + if (it == view.end()) { + throw ErrorInfo(QStringLiteral("Unexpected compiler frontend output: ") + + lines.join(QLatin1Char('\n'))); + } + QStringView key(view.begin(), it); + QStringView value(it + 1, view.end()); + result.insert(key.toString(), value.isEmpty() ? QVariant() : QVariant(value.toString())); + } + if (result.isEmpty()) { + throw ErrorInfo(QStringLiteral("Cannot determine macroses from compiler frontend output: ") + + lines.join(QLatin1Char('\n'))); + } + return result; +#else + Q_UNUSED(compilerFilePath); + Q_UNUSED(compilerEnv); + Q_UNUSED(language); + Q_UNUSED(arch); + return {}; +#endif +} + +static QString formatVswhereOutput(const QString &out, const QString &err) +{ + QString ret; + if (!out.isEmpty()) { + ret.append(Tr::tr("stdout")).append(QLatin1String(":\n")); + const auto lines = out.split(QLatin1Char('\n')); + for (const QString &line : lines) + ret.append(QLatin1Char('\t')).append(line).append(QLatin1Char('\n')); + } + if (!err.isEmpty()) { + ret.append(Tr::tr("stderr")).append(QLatin1String(":\n")); + const auto lines = err.split(QLatin1Char('\n')); + for (const QString &line : lines) + ret.append(QLatin1Char('\t')).append(line).append(QLatin1Char('\n')); + } + return ret; +} + +static QString wow6432Key() +{ +#ifdef Q_OS_WIN64 + return QStringLiteral("\\Wow6432Node"); +#else + return {}; +#endif +} + +static QString vswhereFilePath() +{ + static const std::vector envVarCandidates{"ProgramFiles", "ProgramFiles(x86)"}; + for (const char * const envVar : envVarCandidates) { + const QString value = QDir::fromNativeSeparators(QString::fromLocal8Bit(qgetenv(envVar))); + const QString cmd = value + + QStringLiteral("/Microsoft Visual Studio/Installer/vswhere.exe"); + if (QFileInfo(cmd).exists()) + return cmd; + } + return {}; +} + +enum class ProductType { VisualStudio, BuildTools }; +static std::vector retrieveInstancesFromVSWhere( + ProductType productType, Logger &logger) +{ + std::vector result; + const QString cmd = vswhereFilePath(); + if (cmd.isEmpty()) + return result; + QProcess vsWhere; + QStringList args = productType == ProductType::VisualStudio + ? QStringList({QStringLiteral("-all"), QStringLiteral("-legacy"), + QStringLiteral("-prerelease")}) + : QStringList({QStringLiteral("-products"), + QStringLiteral("Microsoft.VisualStudio.Product.BuildTools")}); + args << QStringLiteral("-format") << QStringLiteral("json") << QStringLiteral("-utf8"); + vsWhere.start(cmd, args); + if (!vsWhere.waitForStarted(-1)) + return result; + if (!vsWhere.waitForFinished(-1)) { + logger.qbsWarning() << Tr::tr("The vswhere tool failed to run").append(QLatin1String(": ")) + .append(vsWhere.errorString()); + return result; + } + if (vsWhere.exitCode() != 0) { + const QString stdOut = QString::fromLocal8Bit(vsWhere.readAllStandardOutput()); + const QString stdErr = QString::fromLocal8Bit(vsWhere.readAllStandardError()); + logger.qbsWarning() << Tr::tr("The vswhere tool failed to run").append(QLatin1String(".\n")) + .append(formatVswhereOutput(stdOut, stdErr)); + return result; + } + QJsonParseError parseError{}; + QJsonDocument jsonOutput = QJsonDocument::fromJson(vsWhere.readAllStandardOutput(), + &parseError); + if (parseError.error != QJsonParseError::NoError) { + logger.qbsWarning() << Tr::tr("The vswhere tool produced invalid JSON output: %1") + .arg(parseError.errorString()); + return result; + } + const auto jsonArray = jsonOutput.array(); + for (const QJsonValue &v : jsonArray) { + const QJsonObject o = v.toObject(); + MSVCInstallInfo info; + info.version = o.value(QStringLiteral("installationVersion")).toString(); + if (productType == ProductType::BuildTools) { + // For build tools, the version is e.g. "15.8.28010.2036", rather than "15.0". + const int dotIndex = info.version.indexOf(QLatin1Char('.')); + if (dotIndex != -1) + info.version = info.version.left(dotIndex); + } + info.installDir = o.value(QStringLiteral("installationPath")).toString(); + if (!info.version.isEmpty() && !info.installDir.isEmpty()) + result.push_back(info); + } + return result; +} + +static std::vector installedMSVCsFromVsWhere(Logger &logger) +{ + const std::vector vsInstallations + = retrieveInstancesFromVSWhere(ProductType::VisualStudio, logger); + const std::vector buildToolInstallations + = retrieveInstancesFromVSWhere(ProductType::BuildTools, logger); + std::vector all; + std::copy(vsInstallations.begin(), vsInstallations.end(), std::back_inserter(all)); + std::copy(buildToolInstallations.begin(), buildToolInstallations.end(), + std::back_inserter(all)); + return all; +} + +static std::vector installedMSVCsFromRegistry() +{ + std::vector result; + + // Detect Visual Studio + const QSettings vsRegistry( + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key() + + QStringLiteral("\\Microsoft\\VisualStudio\\SxS\\VS7"), + QSettings::NativeFormat); + const auto vsNames = vsRegistry.childKeys(); + for (const QString &vsName : vsNames) { + MSVCInstallInfo entry; + entry.version = vsName; + entry.installDir = vsRegistry.value(vsName).toString(); + result.push_back(entry); + } + + // Detect Visual C++ Build Tools + QSettings vcbtRegistry( + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key() + + QStringLiteral("\\Microsoft\\VisualCppBuildTools"), + QSettings::NativeFormat); + const QStringList &vcbtRegistryChildGroups = vcbtRegistry.childGroups(); + for (const QString &childGroup : vcbtRegistryChildGroups) { + vcbtRegistry.beginGroup(childGroup); + bool ok; + int installed = vcbtRegistry.value(QStringLiteral("Installed")).toInt(&ok); + if (ok && installed) { + MSVCInstallInfo entry; + entry.version = childGroup; + const QSettings vsRegistry( + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE") + wow6432Key() + + QStringLiteral("\\Microsoft\\VisualStudio\\") + childGroup + + QStringLiteral("\\Setup\\VC"), + QSettings::NativeFormat); + entry.installDir = vsRegistry.value(QStringLiteral("ProductDir")).toString(); + result.push_back(entry); + } + vcbtRegistry.endGroup(); + } + + return result; +} + +/* + Returns the list of compilers present in all MSVC installations + (Visual Studios or Build Tools) without the architecture, e.g. + [VC\Tools\MSVC\14.16.27023, VC\Tools\MSVC\14.14.26428, ...] +*/ +static std::vector installedCompilersHelper(Logger &logger) +{ + std::vector msvcs; + std::vector installInfos = installedMSVCsFromVsWhere(logger); + if (installInfos.empty()) + installInfos = installedMSVCsFromRegistry(); + for (const MSVCInstallInfo &installInfo : installInfos) { + MSVC msvc; + msvc.internalVsVersion = Version::fromString(installInfo.version, true); + if (!msvc.internalVsVersion.isValid()) + continue; + + QDir vsInstallDir(installInfo.installDir); + msvc.vsInstallPath = vsInstallDir.absolutePath(); + if (vsInstallDir.dirName() != QStringLiteral("VC") + && !vsInstallDir.cd(QStringLiteral("VC"))) { + continue; + } + + msvc.version = QString::number(Internal::VisualStudioVersionInfo( + msvc.internalVsVersion).marketingVersion()); + if (msvc.version.isEmpty()) { + logger.qbsWarning() + << Tr::tr("Unknown MSVC version %1 found.").arg(installInfo.version); + continue; + } + + if (msvc.internalVsVersion.majorVersion() < 15) { + QDir vcInstallDir = vsInstallDir; + if (!vcInstallDir.cd(QStringLiteral("bin"))) + continue; + msvc.vcInstallPath = vcInstallDir.absolutePath(); + msvcs.push_back(msvc); + } else { + QDir vcInstallDir = vsInstallDir; + vcInstallDir.cd(QStringLiteral("Tools/MSVC")); + const auto vcVersionStrs = vcInstallDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + std::vector vcVersions; + vcVersions.reserve(vcVersionStrs.size()); + for (const QString &vcVersionStr : vcVersionStrs) { + const Version vcVersion = Version::fromString(vcVersionStr); + if (!vcVersion.isValid()) + continue; + vcVersions.push_back(vcVersion); + } + // sort the versions so the new one comes first + std::sort(vcVersions.begin(), vcVersions.end(), std::greater<>()); + + for (const Version &vcVersion : vcVersions) { + QDir specificVcInstallDir = vcInstallDir; + if (!specificVcInstallDir.cd(vcVersion.toString()) + || !specificVcInstallDir.cd(QStringLiteral("bin"))) { + continue; + } + msvc.vcInstallPath = specificVcInstallDir.absolutePath(); + msvcs.push_back(msvc); + } + } + } + return msvcs; +} + +void MSVC::init() +{ + determineCompilerVersion(); +} + +/*! + \internal + Returns the architecture detected from the compiler path. +*/ +QString MSVC::architectureFromClPath(const QString &clPath) +{ + const auto parentDir = QFileInfo(clPath).absolutePath(); + const auto parentDirName = QFileInfo(parentDir).fileName().toLower(); + // can be the case when cl.exe is present within the Windows SDK installation... but can it? + if (parentDirName == QLatin1String("bin")) + return QStringLiteral("x86"); + return parentDirName; +} + +QString MSVC::vcVariablesVersionFromBinPath(const QString &binPath) +{ + const auto binDirName = QFileInfo(binPath).fileName().toLower(); + // the case when cl.exe is present within the Windows SDK installation + if (binDirName == QLatin1String("bin")) + return {}; + // binPath is something like + // Microsoft Visual Studio 14.0/VC/bin/amd64_x86 + // or + // Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64 + QDir dir(binPath); + dir.cdUp(); + // older Visual Studios do not support multiple compiler versions + if (dir.dirName().toLower() == QLatin1String("bin")) + return {}; + dir.cdUp(); + dir.cdUp(); + return dir.dirName(); +} + +QString MSVC::canonicalArchitecture(const QString &arch) +{ + if (arch == QLatin1String("x64") || arch == QLatin1String("amd64")) + return QStringLiteral("x86_64"); + return arch; +} + +std::pair MSVC::getHostTargetArchPair(const QString &arch) +{ + QString hostArch; + QString targetArch; + const int index = arch.indexOf(QLatin1Char('_')); + if (index != -1) { + hostArch = arch.mid(0, index); + targetArch = arch.mid(index); + } else { + hostArch = arch; + targetArch = arch; + } + return {canonicalArchitecture(hostArch), canonicalArchitecture(targetArch)}; +} + +QString MSVC::binPathForArchitecture(const QString &arch) const +{ + QString archSubDir; + if (arch != StringConstants::x86Arch()) + archSubDir = arch; + return QDir::cleanPath(vcInstallPath + QLatin1Char('/') + pathPrefix + QLatin1Char('/') + + archSubDir); +} + +static QString clExeSuffix() { return QStringLiteral("/cl.exe"); } + +QString MSVC::clPathForArchitecture(const QString &arch) const +{ + return binPathForArchitecture(arch) + clExeSuffix(); +} + +QVariantMap MSVC::compilerDefines(const QString &compilerFilePath, + MSVC::CompilerLanguage language) const +{ + const auto compilerName = QFileInfo(compilerFilePath).fileName().toLower(); + if (compilerName == QLatin1String("clang-cl.exe")) + return getClangClDefines(compilerFilePath, environment, language, architecture); + return getMsvcDefines(compilerFilePath, environment, language); +} + +std::vector MSVC::findSupportedArchitectures(const MSVC &msvc) +{ + std::vector result; + auto addResult = [&result](const MSVCArchInfo &ai) { + if (QFile::exists(ai.binPath + QLatin1String("/cl.exe"))) + result.push_back(ai); + }; + if (msvc.internalVsVersion.majorVersion() < 15) { + static const QStringList knownArchitectures = QStringList() + << QStringLiteral("x86") + << QStringLiteral("amd64_x86") + << QStringLiteral("amd64") + << QStringLiteral("x86_amd64") + << QStringLiteral("ia64") + << QStringLiteral("x86_ia64") + << QStringLiteral("x86_arm") + << QStringLiteral("amd64_arm"); + for (const QString &knownArchitecture : knownArchitectures) { + MSVCArchInfo ai; + ai.arch = knownArchitecture; + ai.binPath = msvc.binPathForArchitecture(knownArchitecture); + addResult(ai); + } + } else { + QDir vcInstallDir(msvc.vcInstallPath); + const auto hostArchs = vcInstallDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const QString &hostArch : hostArchs) { + QDir subdir = vcInstallDir; + if (!subdir.cd(hostArch)) + continue; + const QString shortHostArch = hostArch.mid(4).toLower(); + const auto archs = subdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (const QString &arch : archs) { + MSVCArchInfo ai; + ai.binPath = subdir.absoluteFilePath(arch); + if (shortHostArch == arch) + ai.arch = arch; + else + ai.arch = shortHostArch + QLatin1Char('_') + arch; + addResult(ai); + } + } + } + return result; +} + +QVariantMap MSVC::toVariantMap() const +{ + return { + {QStringLiteral("version"), version}, + {QStringLiteral("internalVsVersion"), internalVsVersion.toString()}, + {QStringLiteral("vsInstallPath"), vsInstallPath}, + {QStringLiteral("vcInstallPath"), vcInstallPath}, + {QStringLiteral("binPath"), binPath}, + {QStringLiteral("architecture"), architecture}, + }; +} + +/*! + \internal + Returns the list of all compilers present in all MSVC installations + separated by host/target arch, e.g. + [ + VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64, + VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86, + VC\Tools\MSVC\14.16.27023\bin\Hostx64\arm, + VC\Tools\MSVC\14.16.27023\bin\Hostx64\arm64, + VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64, + ... + ] + \note that MSVC.architecture can be either "x64" or "amd64" (depending on the MSVC version) + in case of 64-bit platform (but we use the "x86_64" name...) +*/ +std::vector MSVC::installedCompilers(Logger &logger) +{ + std::vector msvcs; + const auto instMsvcs = installedCompilersHelper(logger); + for (const MSVC &msvc : instMsvcs) { + if (msvc.internalVsVersion.majorVersion() < 15) { + // Check existence of various install scripts + const QString vcvars32bat = msvc.vcInstallPath + QLatin1String("/vcvars32.bat"); + if (!QFileInfo(vcvars32bat).isFile()) + continue; + } + + const auto ais = findSupportedArchitectures(msvc); + transform(ais, msvcs, [&msvc](const auto &ai) { + MSVC specificMSVC = msvc; + specificMSVC.architecture = ai.arch; + specificMSVC.binPath = ai.binPath; + return specificMSVC; + }); + } + return msvcs; +} + +void MSVC::determineCompilerVersion() +{ + QString cppFilePath; + { + QTemporaryFile cppFile(QDir::tempPath() + QLatin1String("/qbsXXXXXX.cpp")); + cppFile.setAutoRemove(false); + if (!cppFile.open()) { + throw ErrorInfo(mkStr("Could not create temporary file (%1)") + .arg(cppFile.errorString())); + } + cppFilePath = cppFile.fileName(); + cppFile.write("_MSC_FULL_VER"); + cppFile.close(); + } + DummyFile fileDeleter(cppFilePath); + + std::lock_guard locker(envMutex); + const QByteArray origPath = qgetenv("PATH"); + qputenv("PATH", environment.value(StringConstants::pathEnvVar()).toLatin1() + ';' + origPath); + QByteArray versionStr = runProcess( + binPath + clExeSuffix(), + QStringList() << QStringLiteral("/nologo") << QStringLiteral("/EP") + << QDir::toNativeSeparators(cppFilePath)); + qputenv("PATH", origPath); + compilerVersion = Version(versionStr.mid(0, 2).toInt(), versionStr.mid(2, 2).toInt(), + versionStr.mid(4).toInt()); +} + +QString MSVCInstallInfo::findVcvarsallBat() const +{ + static const auto vcvarsall2017 = QStringLiteral("VC/Auxiliary/Build/vcvarsall.bat"); + // 2015, 2013 and 2012 + static const auto vcvarsallOld = QStringLiteral("VC/vcvarsall.bat"); + QDir dir(installDir); + if (dir.exists(vcvarsall2017)) + return dir.absoluteFilePath(vcvarsall2017); + if (dir.exists(vcvarsallOld)) + return dir.absoluteFilePath(vcvarsallOld); + return {}; +} + +std::vector MSVCInstallInfo::installedMSVCs(Logger &logger) +{ + const auto installInfos = installedMSVCsFromVsWhere(logger); + if (installInfos.empty()) + return installedMSVCsFromRegistry(); + return installInfos; +} diff --git a/src/lib/corelib/tools/msvcinfo.h b/src/lib/corelib/tools/msvcinfo.h new file mode 100644 index 00000000..efaf0b6c --- /dev/null +++ b/src/lib/corelib/tools/msvcinfo.h @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MSVCINFO_H +#define QBS_MSVCINFO_H + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class Logger; + +struct MSVCArchInfo +{ + QString arch; + QString binPath; +}; + +/** + * Represents one MSVC installation for one specific target architecture. + * There are potentially multiple MSVCs in one Visual Studio installation. + */ +class MSVC +{ +public: + enum CompilerLanguage { + CLanguage = 0, + CPlusPlusLanguage = 1 + }; + + QString version; + Version internalVsVersion; + Version compilerVersion; + QString vsInstallPath; + QString vcInstallPath; + QString binPath; + QString pathPrefix; + QString architecture; + QString sdkVersion; + QProcessEnvironment environment; + + MSVC() = default; + + MSVC(const QString &clPath, QString arch, QString sdkVersion = {}): + architecture(std::move(arch)), + sdkVersion(std::move(sdkVersion)) + { + QDir parentDir = QFileInfo(clPath).dir(); + binPath = parentDir.absolutePath(); + QString parentDirName = parentDir.dirName().toLower(); + if (parentDirName != QLatin1String("bin")) + parentDir.cdUp(); + vcInstallPath = parentDir.path(); + } + + QBS_EXPORT void init(); + QBS_EXPORT static QString architectureFromClPath(const QString &clPath); + QBS_EXPORT static QString vcVariablesVersionFromBinPath(const QString &binPath); + QBS_EXPORT static QString canonicalArchitecture(const QString &arch); + QBS_EXPORT static std::pair getHostTargetArchPair(const QString &arch); + QBS_EXPORT QString binPathForArchitecture(const QString &arch) const; + QBS_EXPORT QString clPathForArchitecture(const QString &arch) const; + QBS_EXPORT QVariantMap compilerDefines(const QString &compilerFilePath, + CompilerLanguage language) const; + + QBS_EXPORT static std::vector findSupportedArchitectures(const MSVC &msvc); + + QBS_EXPORT QVariantMap toVariantMap() const; + + QBS_EXPORT static std::vector installedCompilers(Logger &logger); + +private: + void determineCompilerVersion(); +}; + +class WinSDK : public MSVC +{ +public: + bool isDefault = false; + + WinSDK() + { + pathPrefix = QStringLiteral("bin"); + } +}; + +struct QBS_EXPORT MSVCInstallInfo +{ + QString version; + QString installDir; + + QString findVcvarsallBat() const; + + static std::vector installedMSVCs(Logger &logger); +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_MSVCINFO_H diff --git a/src/lib/corelib/tools/pathutils.h b/src/lib/corelib/tools/pathutils.h new file mode 100644 index 00000000..55dbc1c6 --- /dev/null +++ b/src/lib/corelib/tools/pathutils.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PATHUTILS_H +#define QBS_PATHUTILS_H + +#include "hostosinfo.h" +#include "qbs_export.h" + +namespace qbs { +namespace Internal { + +class PathUtils +{ +public: + static QString toNativeSeparators(const QString &s, + HostOsInfo::HostOs os = HostOsInfo::hostOs()) + { + QString value = s; + if (os == HostOsInfo::HostOsWindows) + value.replace(QLatin1Char('/'), HostOsInfo::pathSeparator(os)); + return value; + } +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PATHUTILS_H diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp new file mode 100644 index 00000000..95211e89 --- /dev/null +++ b/src/lib/corelib/tools/persistence.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "persistence.h" + +#include "fileinfo.h" +#include +#include + +#include + +namespace qbs { +namespace Internal { + +static const char QBS_PERSISTENCE_MAGIC[] = "QBSPERSISTENCE-130"; + +NoBuildGraphError::NoBuildGraphError(const QString &filePath) + : ErrorInfo(Tr::tr("Build graph not found for configuration '%1'. Expected location was '%2'.") + .arg(FileInfo::completeBaseName(filePath), QDir::toNativeSeparators(filePath))) +{ +} + +PersistentPool::PersistentPool(Logger &logger) : m_logger(logger) +{ + Q_UNUSED(m_logger); + m_stream.setVersion(QDataStream::Qt_4_8); +} + +PersistentPool::~PersistentPool() = default; + +void PersistentPool::load(const QString &filePath) +{ + std::unique_ptr file(new QFile(filePath)); + if (!file->exists()) + throw NoBuildGraphError(filePath); + if (!file->open(QFile::ReadOnly)) { + throw ErrorInfo(Tr::tr("Could not open open build graph file '%1': %2") + .arg(filePath, file->errorString())); + } + + m_stream.setDevice(file.get()); + QByteArray magic; + m_stream >> magic; + if (magic != QBS_PERSISTENCE_MAGIC) { + m_stream.setDevice(nullptr); + throw ErrorInfo(Tr::tr("Cannot use stored build graph at '%1': Incompatible file format. " + "Expected magic token '%2', got '%3'.") + .arg(filePath, QLatin1String(QBS_PERSISTENCE_MAGIC), + QString::fromLatin1(magic))); + } + + m_stream >> m_headData.projectConfig; + m_file = std::move(file); + m_loadedRaw.clear(); + m_loaded.clear(); + m_storageIndices.clear(); + m_stringStorage.clear(); + m_inverseStringStorage.clear(); +} + +void PersistentPool::setupWriteStream(const QString &filePath) +{ + QString dirPath = FileInfo::path(filePath); + if (!FileInfo::exists(dirPath) && !QDir().mkpath(dirPath)) { + throw ErrorInfo(Tr::tr("Failure storing build graph: Cannot create directory '%1'.") + .arg(dirPath)); + } + + if (QFile::exists(filePath) && !QFile::remove(filePath)) { + throw ErrorInfo(Tr::tr("Failure storing build graph: Cannot remove old file '%1'") + .arg(filePath)); + } + QBS_CHECK(!QFile::exists(filePath)); + std::unique_ptr file(new QFile(filePath)); + if (!file->open(QFile::WriteOnly)) { + throw ErrorInfo(Tr::tr("Failure storing build graph: " + "Cannot open file '%1' for writing: %2").arg(filePath, file->errorString())); + } + + m_stream.setDevice(file.get()); + m_file = std::move(file); + m_stream << QByteArray(qstrlen(QBS_PERSISTENCE_MAGIC), 0) << m_headData.projectConfig; + m_lastStoredObjectId = 0; + m_lastStoredStringId = 0; + m_lastStoredEnvId = 0; + m_lastStoredStringListId = 0; +} + +void PersistentPool::finalizeWriteStream() +{ + if (m_stream.status() != QDataStream::Ok) + throw ErrorInfo(Tr::tr("Failure serializing build graph.")); + m_stream.device()->seek(0); + m_stream << QByteArray(QBS_PERSISTENCE_MAGIC); + if (m_stream.status() != QDataStream::Ok) + throw ErrorInfo(Tr::tr("Failure serializing build graph.")); + const auto file = static_cast(m_stream.device()); + if (!file->flush()) { + file->close(); + file->remove(); + throw ErrorInfo(Tr::tr("Failure serializing build graph: %1").arg(file->errorString())); + } +} + +void PersistentPool::storeVariant(const QVariant &variant) +{ + const auto type = static_cast(variant.userType()); + m_stream << type; + switch (type) { + case QMetaType::QString: + store(variant.toString()); + break; + case QMetaType::QStringList: + store(variant.toStringList()); + break; + case QMetaType::QVariantList: + store(variant.toList()); + break; + case QMetaType::QVariantMap: + store(variant.toMap()); + break; + default: + m_stream << variant; + } +} + +QVariant PersistentPool::loadVariant() +{ + const auto type = load(); + QVariant value; + switch (type) { + case QMetaType::QString: + value = load(); + break; + case QMetaType::QStringList: + value = load(); + break; + case QMetaType::QVariantList: + value = load(); + break; + case QMetaType::QVariantMap: + value = load(); + break; + default: + m_stream >> value; + } + return value; +} + +void PersistentPool::clear() +{ + m_loaded.clear(); + m_storageIndices.clear(); + m_stringStorage.clear(); + m_inverseStringStorage.clear(); +} + +void PersistentPool::doLoadValue(QString &s) +{ + m_stream >> s; +} + +void PersistentPool::doLoadValue(QStringList &l) +{ + int size; + m_stream >> size; + for (int i = 0; i < size; ++i) + l << load(); +} + +void PersistentPool::doLoadValue(QProcessEnvironment &env) +{ + const auto keys = load(); + for (const QString &key : keys) + env.insert(key, load()); +} + +void PersistentPool::doStoreValue(const QString &s) +{ + m_stream << s; +} + +void PersistentPool::doStoreValue(const QStringList &l) +{ + m_stream << int(l.size()); + for (const QString &s : l) + store(s); +} + +void PersistentPool::doStoreValue(const QProcessEnvironment &env) +{ + const QStringList &keys = env.keys(); + store(keys); + for (const QString &key : keys) + store(env.value(key)); +} + +const PersistentPool::PersistentObjectId PersistentPool::ValueNotFoundId; +const PersistentPool::PersistentObjectId PersistentPool::EmptyValueId; + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h new file mode 100644 index 00000000..b7aa543a --- /dev/null +++ b/src/lib/corelib/tools/persistence.h @@ -0,0 +1,548 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PERSISTENCE +#define QBS_PERSISTENCE + +#include "error.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class NoBuildGraphError : public ErrorInfo +{ +public: + NoBuildGraphError(const QString &filePath); +}; + +template +struct PPHelper; + +class PersistentPool +{ +public: + PersistentPool(Logger &logger); + ~PersistentPool(); + + class HeadData + { + public: + QVariantMap projectConfig; + }; + + template void store(const Types &...args) + { + (... , PPHelper::store(args, this)); + } + + template void load(Types &...args) + { + (... , PPHelper::load(args, this)); + } + template T load() { + T tmp; + PPHelper::load(tmp, this); + return tmp; + } + + enum OpType { Store, Load }; + template void serializationOp(const Types &...args) + { + static_assert(type == Store); + store(args...); + } + template void serializationOp(Types &...args) + { + if constexpr(type == Store) + store(args...); + else + load(args...); + } + + void load(const QString &filePath); + void setupWriteStream(const QString &filePath); + void finalizeWriteStream(); + void clear(); + + const HeadData &headData() const { return m_headData; } + void setHeadData(const HeadData &hd) { m_headData = hd; } + +private: + using PersistentObjectId = int; + + template T *idLoad(); + template std::shared_ptr idLoadS(); + template T idLoadValue(); + + void doLoadValue(QString &s); + void doLoadValue(QStringList &l); + void doLoadValue(QProcessEnvironment &env); + + template void storeSharedObject(const T *object); + + void storeVariant(const QVariant &variant); + QVariant loadVariant(); + + template void idStoreValue(const T &value); + + void doStoreValue(const QString &s); + void doStoreValue(const QStringList &l); + void doStoreValue(const QProcessEnvironment &env); + + template std::vector &idStorage(); + template QHash &idMap(); + template PersistentObjectId &lastStoredId(); + + static const PersistentObjectId ValueNotFoundId = -1; + static const PersistentObjectId EmptyValueId = -2; + + std::unique_ptr m_file; + QDataStream m_stream; + HeadData m_headData; + std::vector m_loadedRaw; + std::vector> m_loaded; + std::unordered_map m_storageIndices; + PersistentObjectId m_lastStoredObjectId = 0; + + std::vector m_stringStorage; + QHash m_inverseStringStorage; + PersistentObjectId m_lastStoredStringId = 0; + std::vector m_envStorage; + QHash m_inverseEnvStorage; + PersistentObjectId m_lastStoredEnvId = 0; + std::vector m_stringListStorage; + QHash m_inverseStringListStorage; + PersistentObjectId m_lastStoredStringListId = 0; + Logger &m_logger; + + template + friend struct PPHelper; +}; + +template inline const void *uniqueAddress(const T *t) { return t; } + +template inline void PersistentPool::storeSharedObject(const T *object) +{ + if (!object) { + m_stream << -1; + return; + } + const void * const addr = uniqueAddress(object); + const auto found = m_storageIndices.find(addr); + if (found == m_storageIndices.end()) { + PersistentObjectId id = m_lastStoredObjectId++; + m_storageIndices[addr] = id; + m_stream << id; + store(*object); + } else { + m_stream << found->second; + } +} + +template inline T *PersistentPool::idLoad() +{ + PersistentObjectId id; + m_stream >> id; + + if (id < 0) + return nullptr; + + if (id < static_cast(m_loadedRaw.size())) + return static_cast(m_loadedRaw.at(id)); + + auto i = m_loadedRaw.size(); + m_loadedRaw.resize(id + 1); + for (; i < m_loadedRaw.size(); ++i) + m_loadedRaw[i] = nullptr; + + const auto t = new T; + m_loadedRaw[id] = t; + load(*t); + return t; +} + +template<> inline std::vector &PersistentPool::idStorage() { return m_stringStorage; } +template<> inline QHash &PersistentPool::idMap() +{ + return m_inverseStringStorage; +} +template<> inline PersistentPool::PersistentObjectId &PersistentPool::lastStoredId() +{ + return m_lastStoredStringId; +} +template<> inline std::vector &PersistentPool::idStorage() +{ + return m_stringListStorage; +} +template<> inline QHash &PersistentPool::idMap() +{ + return m_inverseStringListStorage; +} +template<> inline PersistentPool::PersistentObjectId &PersistentPool::lastStoredId() +{ + return m_lastStoredStringListId; +} +template<> inline std::vector &PersistentPool::idStorage() +{ + return m_envStorage; +} +template<> inline QHash +&PersistentPool::idMap() +{ + return m_inverseEnvStorage; +} +template<> inline PersistentPool::PersistentObjectId +&PersistentPool::lastStoredId() +{ + return m_lastStoredEnvId; +} + +template inline std::shared_ptr PersistentPool::idLoadS() +{ + PersistentObjectId id; + m_stream >> id; + + if (id < 0) + return std::shared_ptr(); + + if (id < static_cast(m_loaded.size())) + return std::static_pointer_cast(m_loaded.at(id)); + + m_loaded.resize(id + 1); + const std::shared_ptr t = T::create(); + m_loaded[id] = t; + load(*t); + return t; +} + +template inline T PersistentPool::idLoadValue() +{ + int id; + m_stream >> id; + if (id == EmptyValueId) + return T(); + QBS_CHECK(id >= 0); + if (id >= static_cast(idStorage().size())) { + T value; + doLoadValue(value); + idStorage().resize(id + 1); + idStorage()[id] = value; + return value; + } + return idStorage().at(id); +} + +template +void PersistentPool::idStoreValue(const T &value) +{ + if (value.isEmpty()) { + m_stream << EmptyValueId; + return; + } + int id = idMap().value(value, ValueNotFoundId); + if (id < 0) { + id = lastStoredId()++; + idMap().insert(value, id); + m_stream << id; + doStoreValue(value); + } else { + m_stream << id; + } +} + +// We need a helper class template, because we require partial specialization for some of +// the aggregate types, which is not possible with function templates. +// The generic implementation assumes that T is of class type and has load() and store() +// member functions. +template +struct PPHelper +{ + static void store(const T &object, PersistentPool *pool) + { + const_cast(object).store(*pool); + } + static void load(T &object, PersistentPool *pool) + { + object.load(*pool); + } +}; + +/***** Specializations of Helper class *****/ + +template +struct PPHelper)>>> +{ + static void store(const T &value, PersistentPool *pool) + { + const_cast(value).template completeSerializationOp(*pool); + } + static void load(T &value, PersistentPool *pool) + { + value.template completeSerializationOp(*pool); + } +}; + +template struct PPHelper>> +{ + static void store(const T &value, PersistentPool *pool) { pool->m_stream << value; } + static void load(T &value, PersistentPool *pool) { pool->m_stream >> value; } +}; + +template<> struct PPHelper +{ + static void store(long value, PersistentPool *pool) { pool->m_stream << qint64(value); } + static void load(long &value, PersistentPool *pool) + { + qint64 v; + pool->m_stream >> v; + value = long(v); + } +}; + +template struct PPHelper>> +{ + using U = std::underlying_type_t; + static void store(const T &value, PersistentPool *pool) + { + pool->m_stream << static_cast(value); + } + static void load(T &value, PersistentPool *pool) + { + pool->m_stream >> reinterpret_cast(value); + } +}; + +template struct PPHelper> +{ + static void store(const std::shared_ptr &value, PersistentPool *pool) + { + pool->store(value.get()); + } + static void load(std::shared_ptr &value, PersistentPool *pool) + { + value = pool->idLoadS>(); + } +}; + +template struct PPHelper> +{ + static void store(const std::unique_ptr &value, PersistentPool *pool) + { + pool->store(value.get()); + } + static void load(std::unique_ptr &ptr, PersistentPool *pool) + { + ptr.reset(pool->idLoad>()); + } +}; + +template struct PPHelper +{ + static void store(const T *value, PersistentPool *pool) { pool->storeSharedObject(value); } + static void load(T* &value, PersistentPool *pool) { value = pool->idLoad(); } +}; + +template struct PPHelper + || std::is_same_v || std::is_same_v>> +{ + static void store(const T &v, PersistentPool *pool) { pool->idStoreValue(v); } + static void load(T &v, PersistentPool *pool) { v = pool->idLoadValue(); } +}; + +template<> struct PPHelper +{ + static void store(const QVariant &v, PersistentPool *pool) { pool->storeVariant(v); } + static void load(QVariant &v, PersistentPool *pool) { v = pool->loadVariant(); } +}; + +template<> struct PPHelper +{ + static void store(const QRegularExpression &re, PersistentPool *pool) + { + pool->store(re.pattern()); + } + static void load(QRegularExpression &re, PersistentPool *pool) + { + re.setPattern(pool->load()); + } +}; + +template struct PPHelper> +{ + static void store(const std::pair &pair, PersistentPool *pool) + { + pool->store(pair.first); + pool->store(pair.second); + } + static void load(std::pair &pair, PersistentPool *pool) + { + pool->load(pair.first); + pool->load(pair.second); + } +}; + +template struct PPHelper> +{ + template + static void storeHelper( + std::index_sequence, const std::tuple &tuple, PersistentPool *pool) + { + (pool->store(std::get(tuple)), ...); + } + + static void store(const std::tuple &tuple, PersistentPool *pool) + { + storeHelper(std::make_index_sequence(), tuple, pool); + } + + template + static void loadHelper( + std::index_sequence, std::tuple &tuple, PersistentPool *pool) + { + (pool->load(std::get(tuple)), ...); + } + + static void load(std::tuple &tuple, PersistentPool * pool) + { + loadHelper(std::make_index_sequence(), tuple, pool); + } +}; + +template struct PPHelper> +{ + using Int = typename QFlags::Int; + static void store(const QFlags &flags, PersistentPool *pool) + { + pool->store(flags); + } + static void load(QFlags &flags, PersistentPool *pool) + { + flags = QFlags(pool->load()); + } +}; + +template struct IsSimpleContainer : std::false_type { }; +template struct IsSimpleContainer> : std::true_type { }; +template<> struct IsSimpleContainer : std::false_type { }; +template struct IsSimpleContainer> : std::true_type { }; + +template struct PPHelper::value>> +{ + static void store(const T &container, PersistentPool *pool) + { + pool->store(int(container.size())); + for (auto it = container.cbegin(); it != container.cend(); ++it) + pool->store(*it); + } + static void load(T &container, PersistentPool *pool) + { + const int count = pool->load(); + container.clear(); + container.reserve(count); + for (int i = count; --i >= 0;) + container.push_back(pool->load()); + } +}; + +template struct IsKeyValueContainer : std::false_type { }; +template struct IsKeyValueContainer> : std::true_type { }; +template struct IsKeyValueContainer> : std::true_type { }; + +template +struct PPHelper::value>> +{ + static void store(const T &container, PersistentPool *pool) + { + pool->store(int(container.size())); + for (auto it = container.cbegin(); it != container.cend(); ++it) { + pool->store(it.key()); + pool->store(it.value()); + } + } + static void load(T &container, PersistentPool *pool) + { + container.clear(); + const int count = pool->load(); + for (int i = 0; i < count; ++i) { + const auto &key = pool->load(); + const auto &value = pool->load(); + container.insert(key, value); + } + } +}; + +template +struct PPHelper> +{ + static void store(const std::unordered_map &map, PersistentPool *pool) + { + pool->store(quint32(map.size())); + for (auto it = map.cbegin(); it != map.cend(); ++it) + pool->store(*it); + } + static void load(std::unordered_map &map, PersistentPool *pool) + { + map.clear(); + const auto count = pool->load(); + for (std::size_t i = 0; i < count; ++i) + map.insert(pool->load>()); + } +}; + +} // namespace Internal +} // namespace qbs + +#endif diff --git a/src/lib/corelib/tools/porting.h b/src/lib/corelib/tools/porting.h new file mode 100644 index 00000000..37582e8d --- /dev/null +++ b/src/lib/corelib/tools/porting.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_TOOLS_PORTING_H +#define QBS_TOOLS_PORTING_H + +#include + +namespace qbs { + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +using QHashValueType = uint; +#else +using QHashValueType = size_t; +#endif + +} + +#endif diff --git a/src/lib/corelib/tools/preferences.cpp b/src/lib/corelib/tools/preferences.cpp new file mode 100644 index 00000000..fe669e16 --- /dev/null +++ b/src/lib/corelib/tools/preferences.cpp @@ -0,0 +1,203 @@ +#include + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "preferences.h" + +#include "buildoptions.h" +#include "hostosinfo.h" +#include "profile.h" +#include "stringconstants.h" + +namespace qbs { + +/*! + * \class Preferences + * \brief The \c Preferences class gives access to all general qbs preferences. + * If a non-empty \c profileName is given, the profile's preferences take precedence over global + * ones. Otherwise, the global preferences are used. + */ +Preferences::Preferences(Settings *settings, QString profileName) + : m_settings(settings), m_profile(std::move(profileName)) +{ +} + +Preferences::Preferences(Settings *settings, QVariantMap profileContents) + : m_settings(settings), m_profileContents(std::move(profileContents)) +{ +} + +/*! + * \brief Returns true <=> colored output should be used for printing messages. + * This is only relevant for command-line frontends. + */ +bool Preferences::useColoredOutput() const +{ + return getPreference(QStringLiteral("useColoredOutput"), true).toBool(); +} + +/*! + * \brief Returns the number of parallel jobs to use for building. + * Uses a sensible default value if there is no such setting. + */ +int Preferences::jobs() const +{ + return getPreference(QStringLiteral("jobs"), BuildOptions::defaultMaxJobCount()).toInt(); +} + +/*! + * \brief Returns the shell to use for the "qbs shell" command. + * This is only relevant for command-line frontends. + */ +QString Preferences::shell() const +{ + return getPreference(QStringLiteral("shell")).toString(); +} + +/*! + * \brief Returns the default build directory used by Qbs if none is specified. + */ +QString Preferences::defaultBuildDirectory() const +{ + return getPreference(QStringLiteral("defaultBuildDirectory")).toString(); +} + +/*! + * \brief Returns the default echo mode used by Qbs if none is specified. + */ +CommandEchoMode Preferences::defaultEchoMode() const +{ + return commandEchoModeFromName(getPreference(QStringLiteral("defaultEchoMode")).toString()); +} + +/*! + * \brief Returns the list of paths where qbs looks for modules and imports. + * In addition to user-supplied locations, they will also be looked up at \c{baseDir}/share/qbs. + */ +QStringList Preferences::searchPaths(const QString &baseDir) const +{ + return pathList(Internal::StringConstants::qbsSearchPathsProperty(), + baseDir + QLatin1String("/share/qbs")); +} + +/*! + * \brief Returns the list of paths where qbs looks for plugins. + * In addition to user-supplied locations, they will be looked up at \c{baseDir}/qbs/plugins. + */ +QStringList Preferences::pluginPaths(const QString &baseDir) const +{ + return pathList(QStringLiteral("pluginsPath"), baseDir + QStringLiteral("/qbs/plugins")); +} + +/*! + * \brief Returns the per-pool job limits. + */ +JobLimits Preferences::jobLimits() const +{ + const QString prefix = QStringLiteral("preferences.jobLimit"); + JobLimits limits; + const auto keys = m_settings->allKeysWithPrefix(prefix, Settings::allScopes()); + for (const QString &key : keys) { + limits.setJobLimit(key, m_settings->value(prefix + QLatin1Char('.') + key, + Settings::allScopes()).toInt()); + } + const QString fullPrefix = prefix + QLatin1Char('.'); + if (!m_profile.isEmpty()) { + Profile p(m_profile, m_settings, m_profileContents); + const auto keys = p.allKeys(Profile::KeySelectionRecursive); + for (const QString &key : keys) { + if (!key.startsWith(fullPrefix)) + continue; + const QString jobPool = key.mid(fullPrefix.size()); + const int limit = p.value(key).toInt(); + if (limit >= 0) + limits.setJobLimit(jobPool, limit); + } + } + return limits; +} + +QVariant Preferences::getPreference(const QString &key, const QVariant &defaultValue) const +{ + static const QString keyPrefix = QStringLiteral("preferences"); + const QString fullKey = keyPrefix + QLatin1Char('.') + key; + const bool isSearchPaths = key == Internal::StringConstants::qbsSearchPathsProperty(); + if (!m_profile.isEmpty()) { + QVariant value = Profile(m_profile, m_settings).value(fullKey); + if (value.isValid()) { + if (isSearchPaths) { // Merge with top-level value. + value = value.toStringList() + m_settings->value( + fullKey, scopesForSearchPaths()).toStringList(); + } + return value; + } + } + + QVariant value = m_profileContents.value(keyPrefix).toMap().value(key); + if (value.isValid()) { + if (isSearchPaths) {// Merge with top-level value + value = value.toStringList() + m_settings->value( + fullKey, scopesForSearchPaths()).toStringList(); + } + return value; + } + + return m_settings->value(fullKey, + isSearchPaths ? scopesForSearchPaths() : Settings::allScopes(), + defaultValue); +} + +QStringList Preferences::pathList(const QString &key, const QString &defaultValue) const +{ + QStringList paths = getPreference(key).toStringList(); + paths << defaultValue; + return paths; +} + +bool Preferences::ignoreSystemSearchPaths() const +{ + return getPreference(QStringLiteral("ignoreSystemSearchPaths")).toBool(); +} + +Settings::Scopes Preferences::scopesForSearchPaths() const +{ + return ignoreSystemSearchPaths() ? Settings::UserScope : Settings::allScopes(); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/preferences.h b/src/lib/corelib/tools/preferences.h new file mode 100644 index 00000000..2824ebf2 --- /dev/null +++ b/src/lib/corelib/tools/preferences.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PREFERENCES_H +#define QBS_PREFERENCES_H + +#include "qbs_export.h" + +#include "commandechomode.h" +#include "joblimits.h" +#include "settings.h" + +#include +#include + +namespace qbs { +class Settings; + +class QBS_EXPORT Preferences +{ +public: + explicit Preferences(Settings *settings, QString profileName = QString()); + Preferences(Settings *settings, QVariantMap profileContents); + + bool useColoredOutput() const; + int jobs() const; + QString shell() const; + QString defaultBuildDirectory() const; + CommandEchoMode defaultEchoMode() const; + QStringList searchPaths(const QString &baseDir = QString()) const; + QStringList pluginPaths(const QString &baseDir = QString()) const; + JobLimits jobLimits() const; + +private: + QVariant getPreference(const QString &key, const QVariant &defaultValue = QVariant()) const; + QStringList pathList(const QString &key, const QString &defaultValue) const; + + bool ignoreSystemSearchPaths() const; + Settings::Scopes scopesForSearchPaths() const; + + Settings *m_settings; + QString m_profile; + QVariantMap m_profileContents; +}; + +} // namespace qbs + + +#endif // Header guard diff --git a/src/lib/corelib/tools/processresult.cpp b/src/lib/corelib/tools/processresult.cpp new file mode 100644 index 00000000..d5591a7e --- /dev/null +++ b/src/lib/corelib/tools/processresult.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "processresult.h" +#include "processresult_p.h" + +#include +#include + +/*! + * \class SetupProjectParameters + * \brief The \c ProcessResult class describes a finished qbs process command. + */ + +namespace qbs { + +ProcessResult::ProcessResult() : d(new Internal::ProcessResultPrivate) +{ +} + +ProcessResult::ProcessResult(const ProcessResult &other) = default; + +ProcessResult &ProcessResult::operator=(const ProcessResult &other) = default; + +ProcessResult::~ProcessResult() = default; + +/*! + * \brief Returns true iff the command finished successfully. + */ +bool ProcessResult::success() const +{ + return d->success; +} + +/*! + * \brief Returns the file path of the executable that was run. + */ +QString ProcessResult::executableFilePath() const +{ + return d->executableFilePath; +} + +/*! + * \brief Returns the command-line arguments with which the command was invoked. + */ +QStringList ProcessResult::arguments() const +{ + return d->arguments; +} + +/*! + * \brief Returns the working directory of the invoked command. + */ +QString ProcessResult::workingDirectory() const +{ + return d->workingDirectory; +} + +/*! + * \brief Returns the error status of the process. If no error occurred, the value + * is \c Process::UnknownError. + */ +QProcess::ProcessError ProcessResult::error() const +{ + return d->error; +} + +/*! + * \brief Returns the exit code of the command. + */ +int ProcessResult::exitCode() const +{ + return d->exitCode; +} + +/*! + * \brief Returns the data the command wrote to the standard output channel. + */ +QStringList ProcessResult::stdOut() const +{ + return d->stdOut; +} + +/*! + * \brief Returns the data the command wrote to the standard error channel. + */ +QStringList ProcessResult::stdErr() const +{ + return d->stdErr; +} + +static QJsonValue processErrorToJson(QProcess::ProcessError error) +{ + switch (error) { + case QProcess::FailedToStart: return QLatin1String("failed-to-start"); + case QProcess::Crashed: return QLatin1String("crashed"); + case QProcess::Timedout: return QLatin1String("timed-out"); + case QProcess::WriteError: return QLatin1String("write-error"); + case QProcess::ReadError: return QLatin1String("read-error"); + case QProcess::UnknownError: return QStringLiteral("unknown-error"); + } + return {}; // For dumb compilers. +} + +QJsonObject qbs::ProcessResult::toJson() const +{ + return QJsonObject{ + {QStringLiteral("success"), success()}, + {QStringLiteral("executable-file-path"), executableFilePath()}, + {QStringLiteral("arguments"), QJsonArray::fromStringList(arguments())}, + {QStringLiteral("working-directory"), workingDirectory()}, + {QStringLiteral("error"), processErrorToJson(error())}, + {QStringLiteral("exit-code"), exitCode()}, + {QStringLiteral("stdout"), QJsonArray::fromStringList(stdOut())}, + {QStringLiteral("stderr"), QJsonArray::fromStringList(stdErr())} + }; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/processresult.h b/src/lib/corelib/tools/processresult.h new file mode 100644 index 00000000..3870a3ae --- /dev/null +++ b/src/lib/corelib/tools/processresult.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROCESSRESULT_H +#define QBS_PROCESSRESULT_H + +#include "qbs_export.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QJsonObject; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class ProcessCommandExecutor; +class ProcessResultPrivate; +} + +class QBS_EXPORT ProcessResult +{ + friend class qbs::Internal::ProcessCommandExecutor; +public: + ProcessResult(); + ProcessResult(const ProcessResult &other); + ProcessResult &operator=(const ProcessResult &other); + ~ProcessResult(); + + QJsonObject toJson() const; + + bool success() const; + QString executableFilePath() const; + QStringList arguments() const; + QString workingDirectory() const; + QProcess::ProcessError error() const; + int exitCode() const; + QStringList stdOut() const; + QStringList stdErr() const; + +private: + QExplicitlySharedDataPointer d; +}; + +} // namespace qbs + +Q_DECLARE_METATYPE(qbs::ProcessResult) + +#endif // QBS_PROCESSRESULT_H diff --git a/src/lib/corelib/tools/processresult_p.h b/src/lib/corelib/tools/processresult_p.h new file mode 100644 index 00000000..69ccb859 --- /dev/null +++ b/src/lib/corelib/tools/processresult_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROCESSRESULT_P_H +#define QBS_PROCESSRESULT_P_H + +#include +#include +#include + +namespace qbs { +namespace Internal { +class ProcessResultPrivate : public QSharedData +{ +public: + bool success = false; + + QString executableFilePath; + QStringList arguments; + QString workingDirectory; + + QProcess::ProcessError error = QProcess::ProcessError::UnknownError; + int exitCode = 0; + QStringList stdOut; + QStringList stdErr; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/tools/processutils.cpp b/src/lib/corelib/tools/processutils.cpp new file mode 100644 index 00000000..02608cc9 --- /dev/null +++ b/src/lib/corelib/tools/processutils.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "processutils.h" + +#if defined(Q_OS_WIN) +# define PSAPI_VERSION 1 // To use GetModuleFileNameEx from Psapi.lib on all Win versions. +# include +# include +#elif defined(Q_OS_DARWIN) +# include +#elif defined(Q_OS_LINUX) +# include "fileinfo.h" +# include +# include +#elif defined(Q_OS_BSD4) +# include +# include +# include +# include +# if !defined(Q_OS_NETBSD) +# include +# endif +#else +# error Missing implementation of processNameByPid for this platform. +#endif + +namespace qbs { +namespace Internal { + +QString processNameByPid(qint64 pid) +{ +#if defined(Q_OS_WIN) + HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, DWORD(pid)); + if (!hProcess) + return {}; + wchar_t buf[UNICODE_STRING_MAX_CHARS]; + const DWORD length = GetModuleFileNameEx(hProcess, NULL, buf, sizeof(buf) / sizeof(wchar_t)); + CloseHandle(hProcess); + if (!length) + return {}; + QString name = QString::fromWCharArray(buf, length); + int i = name.lastIndexOf(QLatin1Char('\\')); + if (i >= 0) + name.remove(0, i + 1); + i = name.lastIndexOf(QLatin1Char('.')); + if (i >= 0) + name.truncate(i); + return name; +#elif defined(Q_OS_DARWIN) + char name[1024]; + proc_name(pid, name, sizeof(name) / sizeof(char)); + return QString::fromUtf8(name); +#elif defined(Q_OS_LINUX) + char exePath[64]; + char buf[PATH_MAX]; + memset(buf, 0, sizeof(buf)); + std::sprintf(exePath, "/proc/%lld/exe", pid); + if (readlink(exePath, buf, sizeof(buf)) < 0) + return {}; + return FileInfo::fileName(QString::fromUtf8(buf)); +#elif defined(Q_OS_BSD4) +# if defined(Q_OS_NETBSD) + struct kinfo_proc2 kp; + int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc2), 1 }; +# elif defined(Q_OS_OPENBSD) + struct kinfo_proc kp; + int mib[6] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc), 1 }; +# else + struct kinfo_proc kp; + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)pid }; +# endif + size_t len = sizeof(kp); + u_int mib_len = sizeof(mib)/sizeof(u_int); + + if (sysctl(mib, mib_len, &kp, &len, NULL, 0) < 0) + return {}; + +# if defined(Q_OS_OPENBSD) || defined(Q_OS_NETBSD) + if (kp.p_pid != pid) + return {}; + QString name = QFile::decodeName(kp.p_comm); +# else + if (kp.ki_pid != pid) + return {}; + QString name = QFile::decodeName(kp.ki_comm); +# endif + return name; + +#else + Q_UNUSED(pid); + return {}; +#endif +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/processutils.h b/src/lib/corelib/tools/processutils.h new file mode 100644 index 00000000..14ab1381 --- /dev/null +++ b/src/lib/corelib/tools/processutils.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROCESSUTILS_H +#define QBS_PROCESSUTILS_H + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +QString QBS_AUTOTEST_EXPORT processNameByPid(qint64 pid); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROCESSUTILS_H + diff --git a/src/lib/corelib/tools/profile.cpp b/src/lib/corelib/tools/profile.cpp new file mode 100644 index 00000000..2eac2509 --- /dev/null +++ b/src/lib/corelib/tools/profile.cpp @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "profile.h" +#include "qbsassert.h" +#include "settings.h" +#include "stringconstants.h" + +#include +#include + +namespace qbs { + +/*! + * \class Profile + * \brief The \c Profile class gives access to the settings of a given profile. + */ + + /*! + * \enum Profile::KeySelection + * This enum type specifies whether to enumerate keys recursively. + * \value KeySelectionRecursive Indicates that key enumeration should happen recursively, i.e. + * it should go up the base profile chain. + * \value KeySelectionNonRecursive Indicates that only keys directly attached to a profile + * should be listed. + */ + +/*! + * \brief Creates an object giving access to the settings for profile \c name. + */ +Profile::Profile(QString name, Settings *settings, QVariantMap profiles) + : m_name(std::move(name)), + m_settings(settings), + m_values(profiles.value(m_name).toMap()), + m_profiles(std::move(profiles)) +{ + QBS_ASSERT(m_name == cleanName(m_name), return); +} + +bool Profile::exists() const +{ + return m_name == fallbackName() || !m_values.empty() + || !m_settings->allKeysWithPrefix(profileKey(), Settings::allScopes()).empty(); +} + +/*! + * \brief Returns the value for property \c key in this profile. + */ +QVariant Profile::value(const QString &key, const QVariant &defaultValue, ErrorInfo *error) const +{ + try { + return possiblyInheritedValue(key, defaultValue, QStringList()); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +/*! + * \brief Gives value \c value to the property \c key in this profile. + */ +void Profile::setValue(const QString &key, const QVariant &value) +{ + m_settings->setValue(fullyQualifiedKey(key), value); + + if (key == baseProfileKey()) { + QBS_ASSERT(value.toString() == cleanName(value.toString()), return); + } +} + +/*! + * \brief Removes a key and the associated value from this profile. + */ +void Profile::remove(const QString &key) +{ + m_settings->remove(fullyQualifiedKey(key)); +} + +/*! + * \brief Returns the name of this profile. + */ +QString Profile::name() const +{ + return m_name; +} + +/*! + * \brief Returns all property keys in this profile. + * If and only if selection is Profile::KeySelectionRecursive, this will also list keys defined + * in base profiles. + */ +QStringList Profile::allKeys(KeySelection selection, ErrorInfo *error) const +{ + try { + return allKeysInternal(selection, QStringList()); + } catch (const ErrorInfo &e) { + if (error) + *error = e; + return {}; + } +} + +/*! + * \brief Returns the name of this profile's base profile. + * The returned value is empty if the profile does not have a base profile. + */ +QString Profile::baseProfile() const +{ + return localValue(baseProfileKey()).toString(); +} + +/*! + * \brief Sets a new base profile for this profile. + */ +void Profile::setBaseProfile(const QString &baseProfile) +{ + setValue(baseProfileKey(), baseProfile); +} + +/*! + * \brief Removes this profile's base profile setting. + */ +void Profile::removeBaseProfile() +{ + remove(baseProfileKey()); +} + +/*! + * \brief Removes this profile from the settings. + */ +void Profile::removeProfile() +{ + m_settings->remove(profileKey()); +} + +/*! + * \brief Returns a string suitiable as a profile name. + * Removes all dots and replaces them with hyphens. + */ +QString Profile::cleanName(const QString &name) +{ + QString newName = name; + return newName.replace(QLatin1Char('.'), QLatin1Char('-')); +} + +QString Profile::profileKey() const +{ + return Internal::StringConstants::profilesSettingsPrefix() + m_name; +} + +QString Profile::baseProfileKey() +{ + return Internal::StringConstants::baseProfileProperty(); +} + +void Profile::checkBaseProfileExistence(const Profile &baseProfile) const +{ + if (!baseProfile.exists()) + throw ErrorInfo(Internal::Tr::tr("Profile \"%1\" has a non-existent base profile \"%2\".").arg( + name(), baseProfile.name())); +} + +QVariant Profile::localValue(const QString &key) const +{ + QVariant val = m_values.value(key); + if (!val.isValid()) + val = m_settings->value(fullyQualifiedKey(key), Settings::allScopes()); + return val; +} + +QString Profile::fullyQualifiedKey(const QString &key) const +{ + return profileKey() + QLatin1Char('.') + key; +} + +QVariant Profile::possiblyInheritedValue(const QString &key, const QVariant &defaultValue, + QStringList profileChain) const +{ + extendAndCheckProfileChain(profileChain); + const QVariant v = localValue(key); + if (v.isValid()) + return v; + const QString baseProfileName = baseProfile(); + if (baseProfileName.isEmpty()) + return defaultValue; + Profile parentProfile(baseProfileName, m_settings, m_profiles); + checkBaseProfileExistence(parentProfile); + return parentProfile.possiblyInheritedValue(key, defaultValue, profileChain); +} + +QStringList Profile::allKeysInternal(Profile::KeySelection selection, + QStringList profileChain) const +{ + extendAndCheckProfileChain(profileChain); + QStringList keys = m_values.keys(); + if (keys.empty()) + keys = m_settings->allKeysWithPrefix(profileKey(), Settings::allScopes()); + if (selection == KeySelectionNonRecursive) + return keys; + const QString baseProfileName = baseProfile(); + if (baseProfileName.isEmpty()) + return keys; + Profile parentProfile(baseProfileName, m_settings, m_profiles); + checkBaseProfileExistence(parentProfile); + keys += parentProfile.allKeysInternal(KeySelectionRecursive, profileChain); + keys.removeDuplicates(); + keys.removeOne(baseProfileKey()); + keys.sort(); + return keys; +} + +void Profile::extendAndCheckProfileChain(QStringList &chain) const +{ + chain << m_name; + if (Q_UNLIKELY(chain.count(m_name) > 1)) { + throw ErrorInfo(Internal::Tr::tr("Circular profile inheritance. Cycle is '%1'.") + .arg(chain.join(QLatin1String(" -> ")))); + } +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/profile.h b/src/lib/corelib/tools/profile.h new file mode 100644 index 00000000..b7fc7ff6 --- /dev/null +++ b/src/lib/corelib/tools/profile.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROFILE_H +#define QBS_PROFILE_H + +#include "qbs_export.h" + +#include +#include +#include + +namespace qbs { +class ErrorInfo; +class Settings; + +class QBS_EXPORT Profile +{ +public: + Profile(QString name, Settings *settings, QVariantMap profiles = QVariantMap()); + + bool exists() const; + QVariant value(const QString &key, const QVariant &defaultValue = QVariant(), + ErrorInfo *error = nullptr) const; + void setValue(const QString &key, const QVariant &value); + void remove(const QString &key); + + QString name() const; + + QString baseProfile() const; + void setBaseProfile(const QString &baseProfile); + void removeBaseProfile(); + + void removeProfile(); + + enum KeySelection { KeySelectionRecursive, KeySelectionNonRecursive }; + QStringList allKeys(KeySelection selection, ErrorInfo *error = nullptr) const; + + static QString cleanName(const QString &name); + + static QString fallbackName() { return QStringLiteral("none"); } + +private: + static QString baseProfileKey(); + void checkBaseProfileExistence(const Profile &baseProfile) const; + QString profileKey() const; + QVariant localValue(const QString &key) const; + QString fullyQualifiedKey(const QString &key) const; + QVariant possiblyInheritedValue(const QString &key, const QVariant &defaultValue, + QStringList profileChain) const; + QStringList allKeysInternal(KeySelection selection, QStringList profileChain) const; + void extendAndCheckProfileChain(QStringList &chain) const; + + QString m_name; + Settings *m_settings; + QVariantMap m_values; + QVariantMap m_profiles; +}; + +namespace Internal { +// Exported for autotests. +class QBS_EXPORT TemporaryProfile { +public: + TemporaryProfile(const QString &name, Settings *settings) : p(name, settings) {} + ~TemporaryProfile() { p.removeProfile(); } + + Profile p; +}; +} // namespace Internal + +} // namespace qbs + +#endif // Header guard diff --git a/src/lib/corelib/tools/profiling.cpp b/src/lib/corelib/tools/profiling.cpp new file mode 100644 index 00000000..db64a73c --- /dev/null +++ b/src/lib/corelib/tools/profiling.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "profiling.h" + +#include +#include + +#include + +namespace qbs { +namespace Internal { + +class TimedActivityLogger::TimedActivityLoggerPrivate +{ +public: + Logger logger; + QString activity; + QElapsedTimer timer; +}; + +TimedActivityLogger::TimedActivityLogger(const Logger &logger, const QString &activity, + bool enabled) + : d(nullptr) +{ + if (!enabled) + return; + d = std::make_unique(); + d->logger = logger; + d->activity = activity; + d->logger.qbsLog(LoggerInfo, true) << Tr::tr("Starting activity '%2'.").arg(activity); + d->timer.start(); +} + +void TimedActivityLogger::finishActivity() +{ + if (!d) + return; + const QString timeString = elapsedTimeString(d->timer.elapsed()); + d->logger.qbsLog(LoggerInfo, true) + << Tr::tr("Activity '%2' took %3.").arg(d->activity, timeString); + d.reset(); +} + +TimedActivityLogger::~TimedActivityLogger() +{ + finishActivity(); +} + +AccumulatingTimer::AccumulatingTimer(qint64 *elapsedTime) : m_elapsedTime(elapsedTime) +{ + if (elapsedTime) + m_timer.start(); +} + +AccumulatingTimer::~AccumulatingTimer() +{ + stop(); +} + +void AccumulatingTimer::stop() +{ + if (!m_timer.isValid()) + return; + *m_elapsedTime += m_timer.elapsed(); + m_timer.invalidate(); +} + +QString elapsedTimeString(qint64 elapsedTimeInMs) +{ + qint64 ms = elapsedTimeInMs; + qint64 s = ms/1000; + ms -= s*1000; + qint64 m = s/60; + s -= m*60; + const qint64 h = m/60; + m -= h*60; + QString timeString = QStringLiteral("%1ms").arg(ms); + if (h || m || s) + timeString.prepend(QStringLiteral("%1s, ").arg(s)); + if (h || m) + timeString.prepend(QStringLiteral("%1m, ").arg(m)); + if (h) + timeString.prepend(QStringLiteral("%1h, ").arg(h)); + return timeString; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/profiling.h b/src/lib/corelib/tools/profiling.h new file mode 100644 index 00000000..c6fc9ede --- /dev/null +++ b/src/lib/corelib/tools/profiling.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROFILING_H +#define QBS_PROFILING_H + +#include + +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class Logger; + +QString elapsedTimeString(qint64 elapsedTimeInMs); + +class TimedActivityLogger +{ +public: + TimedActivityLogger(const Logger &logger, const QString &activity, bool enabled); + void finishActivity(); + ~TimedActivityLogger(); + +private: + class TimedActivityLoggerPrivate; + std::unique_ptr d; +}; + +class AccumulatingTimer +{ +public: + AccumulatingTimer(qint64 *elapsedTime); + ~AccumulatingTimer(); + void stop(); + +private: + QElapsedTimer m_timer; + qint64 * const m_elapsedTime; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Header guard diff --git a/src/lib/corelib/tools/progressobserver.cpp b/src/lib/corelib/tools/progressobserver.cpp new file mode 100644 index 00000000..49787fd2 --- /dev/null +++ b/src/lib/corelib/tools/progressobserver.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "progressobserver.h" + +namespace qbs { +namespace Internal { + +/*! + * \class ProgressObserver + * The \c ProgressObserver class is used in long running qbs operations. It serves two purposes: + * Firstly, it allows operations to indicate progress to a client. Secondly, a client can + * signal to an operation that is should exit prematurely. + * Clients of the qbs library are supposed to subclass this class and implement the virtual + * functions in a way that lets users know about the current operation and its progress. + */ + +/*! + * \fn virtual void initialize(const QString &task, int maximum) = 0 + * \brief Indicates that a new operation is starting. + * Library code calls this function to indicate that it is starting a new task. + * The \a task parameter is a textual description of that task suitable for presentation to a user. + * The \a maximum parameter is an estimate of the maximum effort the operation is going to take. + * This is helpful if the client wants to set up some sort of progress bar showing the + * percentage of the work already done. + */ + +/*! + * \fn virtual void setProgressValue(int value) = 0 + * \brief Sets the new progress value. + * Library code calls this function to indicate that the current operation has progressed. + * It will try hard to ensure that \a value will not exceed \c maximum(). + * \sa ProgressObserver::maximum(). + */ + +/*! + * \fn virtual int progressValue() = 0 + * \brief The current progress value. + * Will typically reflect the \a value from the last call to \c setProgressValue() and should not + * exceed \c maximum(). + * \sa setProgressvalue() + * \sa maximum() + */ + +void ProgressObserver::incrementProgressValue(int increment) +{ + setProgressValue(progressValue() + increment); +} + +/*! + * \fn virtual bool canceled() const = 0 + * \brief Indicates whether the current operation should be canceled. + * Library code will periodically call this function and abort the current operation + * if it returns true. + */ + +/*! + * \fn virtual int maximum() const = 0 + * \brief The expected maximum progress value. + * This will typically be the value of \c maximum passed to \c initialize(). + * \sa ProgressObserver::initialize() + */ + +void ProgressObserver::setFinished() +{ + setProgressValue(maximum()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/progressobserver.h b/src/lib/corelib/tools/progressobserver.h new file mode 100644 index 00000000..fc49d9ee --- /dev/null +++ b/src/lib/corelib/tools/progressobserver.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_PROGRESSOBSERVER_H +#define QBS_PROGRESSOBSERVER_H + +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +class ProgressObserver +{ +public: + virtual ~ProgressObserver() = default; + + virtual void initialize(const QString &task, int maximum) = 0; + virtual void setProgressValue(int value) = 0; + virtual int progressValue() = 0; + virtual bool canceled() const = 0; + virtual void setMaximum(int maximum) = 0; + virtual int maximum() const = 0; + + void incrementProgressValue(int increment = 1); + + // Call this to ensure that the progress bar always goes to 100%. + void setFinished(); +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PROGRESSOBSERVER_H diff --git a/src/lib/corelib/tools/projectgeneratormanager.cpp b/src/lib/corelib/tools/projectgeneratormanager.cpp new file mode 100644 index 00000000..53d72bcd --- /dev/null +++ b/src/lib/corelib/tools/projectgeneratormanager.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "projectgeneratormanager.h" + +#include +#include +#include +#include + +#include +#include + +namespace qbs { + +using namespace Internal; + +ProjectGeneratorManager::~ProjectGeneratorManager() = default; + +ProjectGeneratorManager *ProjectGeneratorManager::instance() +{ + static ProjectGeneratorManager generatorPlugin; + return &generatorPlugin; +} + +ProjectGeneratorManager::ProjectGeneratorManager() = default; + +QStringList ProjectGeneratorManager::loadedGeneratorNames() +{ + return instance()->m_generators.keys(); +} + +std::shared_ptr ProjectGeneratorManager::findGenerator(const QString &generatorName) +{ + return instance()->m_generators.value(generatorName); +} + +void ProjectGeneratorManager::registerGenerator(const std::shared_ptr &generator) +{ + if (!findGenerator(generator->generatorName())) + instance()->m_generators.insert(generator->generatorName(), generator); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/projectgeneratormanager.h b/src/lib/corelib/tools/projectgeneratormanager.h new file mode 100644 index 00000000..1efe593f --- /dev/null +++ b/src/lib/corelib/tools/projectgeneratormanager.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PROJECTGENERATORMANAGER_H +#define QBS_PROJECTGENERATORMANAGER_H + +#include + +#include +#include +#include + +namespace qbs { +class ProjectGenerator; + +class QBS_EXPORT ProjectGeneratorManager +{ +public: + ~ProjectGeneratorManager(); + static ProjectGeneratorManager *instance(); + static QStringList loadedGeneratorNames(); + static std::shared_ptr findGenerator(const QString &generatorName); + static void registerGenerator(const std::shared_ptr &generator); + +private: + ProjectGeneratorManager(); + +private: + QMap > m_generators; +}; + +} // namespace qbs + +#endif diff --git a/src/lib/corelib/tools/qbs_export.h b/src/lib/corelib/tools/qbs_export.h new file mode 100644 index 00000000..164aa418 --- /dev/null +++ b/src/lib/corelib/tools/qbs_export.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_EXPORT_H +#define QBS_EXPORT_H + +#if defined(_WIN32) || defined(WIN32) +# define QBS_DECL_EXPORT __declspec(dllexport) +# define QBS_DECL_IMPORT __declspec(dllimport) +#else +# define QBS_DECL_EXPORT __attribute__((visibility("default"))) +# define QBS_DECL_IMPORT __attribute__((visibility("default"))) +# endif + +#ifdef QBS_STATIC_LIB +# define QBS_EXPORT +# define QBS_AUTOTEST_EXPORT +#else +# ifdef QBS_LIBRARY +# define QBS_EXPORT QBS_DECL_EXPORT +# ifdef QBS_ENABLE_UNIT_TESTS +# define QBS_AUTOTEST_EXPORT QBS_DECL_EXPORT +# else +# define QBS_AUTOTEST_EXPORT +# endif +# else +# define QBS_EXPORT QBS_DECL_IMPORT +# ifdef QBS_ENABLE_UNIT_TESTS +# define QBS_AUTOTEST_EXPORT QBS_DECL_IMPORT +# else +# define QBS_AUTOTEST_EXPORT +# endif +# endif +#endif + +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(disable: 4251) +#endif + +#endif // Include guard. diff --git a/src/lib/corelib/tools/qbsassert.cpp b/src/lib/corelib/tools/qbsassert.cpp new file mode 100644 index 00000000..a6cfd610 --- /dev/null +++ b/src/lib/corelib/tools/qbsassert.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbsassert.h" +#include "error.h" + +#include + +namespace qbs { +namespace Internal { + +void writeAssertLocation(const char *condition, const char *file, int line) +{ + qDebug("SOFT ASSERT: %s in %s:%d", condition, file, line); +} + +void throwAssertLocation(const char *condition, const char *file, int line) +{ + throw ErrorInfo(QStringLiteral("ASSERT: %1").arg(QLatin1String(condition)), + CodeLocation(QString::fromLocal8Bit(file), line, -1, false), true); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/qbsassert.h b/src/lib/corelib/tools/qbsassert.h new file mode 100644 index 00000000..e8dfcacf --- /dev/null +++ b/src/lib/corelib/tools/qbsassert.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_QBSASSERT_H +#define QBS_QBSASSERT_H + +#include "qbs_export.h" + +namespace qbs { +namespace Internal { + +QBS_EXPORT void writeAssertLocation(const char *condition, const char *file, int line); +[[noreturn]] QBS_EXPORT void throwAssertLocation(const char *condition, const char *file, int line); + +} // namespace Internal +} // namespace qbs + +#define QBS_ASSERT(cond, action)\ + if (Q_LIKELY(cond)) {} else {\ + ::qbs::Internal::writeAssertLocation(#cond, __FILE__, __LINE__); action;\ + } do {} while (0) + +// The do {} while (0) is here to enforce the use of a semicolon after QBS_ASSERT. +// action can also be continue or break. Copied from qtcassert.h in Qt Creator. + +#define QBS_CHECK(cond)\ + do {\ + if (Q_LIKELY(cond)) {} else {\ + ::qbs::Internal::throwAssertLocation(#cond, __FILE__, __LINE__);\ + }\ + } while (0) + +#endif // QBS_QBSASSERT_H diff --git a/src/lib/corelib/tools/qbspluginmanager.cpp b/src/lib/corelib/tools/qbspluginmanager.cpp new file mode 100644 index 00000000..d4e92e22 --- /dev/null +++ b/src/lib/corelib/tools/qbspluginmanager.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbspluginmanager.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +namespace Internal { + +struct QbsPlugin { + QbsPluginLoadFunction load; + QbsPluginUnloadFunction unload; + bool loaded; +}; + +class QbsPluginManagerPrivate { +public: + std::vector staticPlugins; + std::vector libs; +}; + +QbsPluginManager::QbsPluginManager() + : d(new QbsPluginManagerPrivate) +{ +} + +QbsPluginManager::~QbsPluginManager() +{ + unloadStaticPlugins(); + + for (QLibrary * const lib : qAsConst(d->libs)) { + auto unload = reinterpret_cast(lib->resolve("QbsPluginUnload")); + if (unload) + unload(); + lib->unload(); + delete lib; + } +} + +QbsPluginManager *QbsPluginManager::instance() +{ + static QbsPluginManager instance; + return &instance; +} + +void QbsPluginManager::registerStaticPlugin(QbsPluginLoadFunction load, + QbsPluginUnloadFunction unload) +{ + if (none_of(d->staticPlugins, [&load](const QbsPlugin &p) { return p.load == load; })) + d->staticPlugins.push_back(QbsPlugin { load, unload, false }); +} + +void QbsPluginManager::loadStaticPlugins() +{ + for (const auto &plugin : d->staticPlugins) { + if (!plugin.loaded && plugin.load) + plugin.load(); + } +} + +void QbsPluginManager::unloadStaticPlugins() +{ + for (auto &plugin : d->staticPlugins) { + if (plugin.loaded && plugin.unload) + plugin.unload(); + } + + d->staticPlugins.clear(); +} + +void QbsPluginManager::loadPlugins(const std::vector &pluginPaths, + const Logger &logger) +{ + QStringList filters; + + if (HostOsInfo::isWindowsHost()) + filters << QStringLiteral("*.dll"); + else if (HostOsInfo::isMacosHost()) + filters << QStringLiteral("*.bundle") << QStringLiteral("*.dylib"); + else + filters << QStringLiteral("*.so"); + + for (const std::string &pluginPath : pluginPaths) { + const QString qtPluginPath = QString::fromStdString(pluginPath); + qCDebug(lcPluginManager) << "loading plugins from" + << QDir::toNativeSeparators(qtPluginPath); + QDirIterator it(qtPluginPath, filters, QDir::Files); + while (it.hasNext()) { + const QString fileName = it.next(); + std::unique_ptr lib(new QLibrary(fileName)); + if (!lib->load()) { + logger.qbsWarning() << Tr::tr("plugin manager: Cannot load plugin '%1': %2") + .arg(QDir::toNativeSeparators(fileName), lib->errorString()); + continue; + } + + auto load = reinterpret_cast(lib->resolve("QbsPluginLoad")); + if (load) { + load(); + qCDebug(lcPluginManager) << "plugin" << QDir::toNativeSeparators(fileName) + << "loaded."; + d->libs.push_back(lib.release()); + } else { + logger.qbsWarning() << Tr::tr("plugin manager: not a qbs plugin"); + } + } + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/qbspluginmanager.h b/src/lib/corelib/tools/qbspluginmanager.h new file mode 100644 index 00000000..1113c413 --- /dev/null +++ b/src/lib/corelib/tools/qbspluginmanager.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PLUGINS_H +#define QBS_PLUGINS_H + +#include "qbs_export.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { +class Logger; + +typedef void (*QbsPluginLoadFunction)(); +typedef void (*QbsPluginUnloadFunction)(); + +class QbsPluginManagerPrivate; + +class QBS_EXPORT QbsPluginManager +{ +public: + ~QbsPluginManager(); + static QbsPluginManager *instance(); + void registerStaticPlugin(QbsPluginLoadFunction, QbsPluginUnloadFunction); + void loadStaticPlugins(); + void unloadStaticPlugins(); + void loadPlugins(const std::vector &paths, const Logger &logger); + +protected: + QbsPluginManager(); + +private: + std::unique_ptr d; +}; + +} // namespace Internal +} // namespace qbs + +#ifdef QBS_STATIC_LIB +#define QBS_REGISTER_STATIC_PLUGIN(exportmacro, name, load, unload) \ + extern "C" bool qbs_static_plugin_register_##name = [] { \ + qbs::Internal::QbsPluginManager::instance()->registerStaticPlugin(load, unload); \ + return true; \ + }(); +#else +#define QBS_REGISTER_STATIC_PLUGIN(exportmacro, name, load, unload) \ + exportmacro void QbsPluginLoad() { load(); } \ + exportmacro void QbsPluginUnload() { unload(); } +#endif + +#endif diff --git a/src/lib/corelib/tools/qbsprocess.cpp b/src/lib/corelib/tools/qbsprocess.cpp new file mode 100644 index 00000000..de2590e8 --- /dev/null +++ b/src/lib/corelib/tools/qbsprocess.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qbsprocess.h" + +#include "launcherinterface.h" +#include "launchersocket.h" +#include "qbsassert.h" + +#include + +#include +#include + +namespace qbs { +namespace Internal { + +QbsProcess::QbsProcess(QObject *parent) : QObject(parent) +{ + connect(LauncherInterface::socket(), &LauncherSocket::ready, + this, &QbsProcess::handleSocketReady); + connect(LauncherInterface::socket(), &LauncherSocket::errorOccurred, + this, &QbsProcess::handleSocketError); + connect(LauncherInterface::socket(), &LauncherSocket::packetArrived, + this, &QbsProcess::handlePacket); +} + +void QbsProcess::start(const QString &command, const QStringList &arguments) +{ + if (m_socketError) { + m_error = QProcess::FailedToStart; + emit errorOccurred(m_error); + return; + } + m_command = command; + m_arguments = arguments; + m_state = QProcess::Starting; + if (LauncherInterface::socket()->isReady()) + doStart(); +} + +void QbsProcess::doStart() +{ + m_state = QProcess::Running; + StartProcessPacket p(token()); + p.command = m_command; + p.arguments = m_arguments; + p.env = m_environment.toStringList(); + p.workingDir = m_workingDirectory; + sendPacket(p); +} + +void QbsProcess::cancel() +{ + switch (m_state) { + case QProcess::NotRunning: + break; + case QProcess::Starting: + m_errorString = Tr::tr("Process canceled before it was started."); + m_error = QProcess::FailedToStart; + m_state = QProcess::NotRunning; + emit errorOccurred(m_error); + break; + case QProcess::Running: + sendPacket(StopProcessPacket(token())); + break; + } +} + +QByteArray QbsProcess::readAllStandardOutput() +{ + return readAndClear(m_stdout); +} + +QByteArray QbsProcess::readAllStandardError() +{ + return readAndClear(m_stderr); +} + +void QbsProcess::sendPacket(const LauncherPacket &packet) +{ + LauncherInterface::socket()->sendData(packet.serialize()); +} + +QByteArray QbsProcess::readAndClear(QByteArray &data) +{ + const QByteArray tmp = data; + data.clear(); + return tmp; +} + +void QbsProcess::handlePacket(LauncherPacketType type, quintptr token, const QByteArray &payload) +{ + if (token != this->token()) + return; + switch (type) { + case LauncherPacketType::ProcessError: + handleErrorPacket(payload); + break; + case LauncherPacketType::ProcessFinished: + handleFinishedPacket(payload); + break; + default: + QBS_ASSERT(false, break); + } +} + +void QbsProcess::handleSocketReady() +{ + m_socketError = false; + if (m_state == QProcess::Starting) + doStart(); +} + +void QbsProcess::handleSocketError(const QString &message) +{ + m_socketError = true; + m_errorString = Tr::tr("Internal socket error: %1").arg(message); + if (m_state != QProcess::NotRunning) { + m_state = QProcess::NotRunning; + m_error = QProcess::FailedToStart; + emit errorOccurred(m_error); + } +} + +void QbsProcess::handleErrorPacket(const QByteArray &packetData) +{ + QBS_ASSERT(m_state != QProcess::NotRunning, return); + const auto packet = LauncherPacket::extractPacket(token(), packetData); + m_error = packet.error; + m_errorString = packet.errorString; + m_state = QProcess::NotRunning; + emit errorOccurred(m_error); +} + +void QbsProcess::handleFinishedPacket(const QByteArray &packetData) +{ + QBS_ASSERT(m_state == QProcess::Running, return); + m_state = QProcess::NotRunning; + const auto packet = LauncherPacket::extractPacket(token(), packetData); + m_exitCode = packet.exitCode; + m_stdout = packet.stdOut; + m_stderr = packet.stdErr; + m_errorString = packet.errorString; + emit finished(m_exitCode); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/qbsprocess.h b/src/lib/corelib/tools/qbsprocess.h new file mode 100644 index 00000000..3314e3d3 --- /dev/null +++ b/src/lib/corelib/tools/qbsprocess.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_QBSPROCESS_H +#define QBS_QBSPROCESS_H + +#include "launcherpackets.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class QbsProcess : public QObject +{ + Q_OBJECT +public: + explicit QbsProcess(QObject *parent = nullptr); + + QProcess::ProcessState state() const { return m_state; } + void setProcessEnvironment(const QProcessEnvironment &env) { m_environment = env; } + void setWorkingDirectory(const QString &workingDir) { m_workingDirectory = workingDir; } + QString workingDirectory() const { return m_workingDirectory; } + void start(const QString &command, const QStringList &arguments); + void cancel(); + QByteArray readAllStandardOutput(); + QByteArray readAllStandardError(); + int exitCode() const { return m_exitCode; } + QProcess::ProcessError error() const { return m_error; } + QString errorString() const { return m_errorString; } + +signals: + void errorOccurred(QProcess::ProcessError error); + void finished(int exitCode); + +private: + void doStart(); + void sendPacket(const LauncherPacket &packet); + QByteArray readAndClear(QByteArray &data); + + void handleSocketError(const QString &message); + void handlePacket(qbs::Internal::LauncherPacketType type, quintptr token, + const QByteArray &payload); + void handleErrorPacket(const QByteArray &packetData); + void handleFinishedPacket(const QByteArray &packetData); + void handleSocketReady(); + + quintptr token() const { return reinterpret_cast(this); } + + QString m_command; + QStringList m_arguments; + QProcessEnvironment m_environment; + QString m_workingDirectory; + QByteArray m_stdout; + QByteArray m_stderr; + QString m_errorString; + QProcess::ProcessError m_error = QProcess::UnknownError; + QProcess::ProcessState m_state = QProcess::NotRunning; + int m_exitCode = 0; + int m_connectionAttempts = 0; + bool m_socketError = false; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBSPROCESS_H diff --git a/src/lib/corelib/tools/qttools.cpp b/src/lib/corelib/tools/qttools.cpp new file mode 100644 index 00000000..40e0d077 --- /dev/null +++ b/src/lib/corelib/tools/qttools.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qttools.h" +#include "porting.h" + +#include + +namespace std { + +size_t hash::operator()(const QVariant &v) const noexcept +{ + switch (v.userType()) { + case QMetaType::UnknownType: return 0; + case QMetaType::Bool: return std::hash()(v.toBool()); + case QMetaType::Int: return std::hash()(v.toInt()); + case QMetaType::UInt: return std::hash()(v.toUInt()); + case QMetaType::QString: return std::hash()(v.toString()); + case QMetaType::QStringList: return std::hash()(v.toStringList()); + case QMetaType::QVariantList: return std::hash()(v.toList()); + case QMetaType::QVariantMap: return std::hash()(v.toMap()); + case QMetaType::QVariantHash: return std::hash()(v.toHash()); + default: + QBS_ASSERT("Unsupported variant type" && false, return 0); + } +} + +} // namespace std + +QT_BEGIN_NAMESPACE + +qbs::QHashValueType qHash(const QStringList &list) +{ + qbs::QHashValueType s = 0; + for (const QString &n : list) + s ^= qHash(n) + 0x9e3779b9 + (s << 6) + (s >> 2); + return s; +} + +qbs::QHashValueType qHash(const QProcessEnvironment &env) +{ + return qHash(env.toStringList()); +} + +QT_END_NAMESPACE diff --git a/src/lib/corelib/tools/qttools.h b/src/lib/corelib/tools/qttools.h new file mode 100644 index 00000000..bc1210d5 --- /dev/null +++ b/src/lib/corelib/tools/qttools.h @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBSQTTOOLS_H +#define QBSQTTOOLS_H + +#include +#include +#include + +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QProcessEnvironment; +QT_END_NAMESPACE + +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +#define QBS_SKIP_EMPTY_PARTS QString::SkipEmptyParts +#else +#define QBS_SKIP_EMPTY_PARTS Qt::SkipEmptyParts +#endif + +namespace std { +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +template<> struct hash { + std::size_t operator()(const QString &s) const { return qHash(s); } +}; +#endif + +template struct hash> +{ + size_t operator()(const pair &x) const + { + return std::hash()(x.first) ^ std::hash()(x.second); + } +}; + +template +struct hash> +{ +private: + template + static size_t helper(std::index_sequence, const std::tuple &tuple) noexcept + { + size_t seed = 0; + (qbs::Internal::hashCombineHelper(seed, std::get(tuple)), ...); + return seed; + } + +public: + size_t operator()(const std::tuple & tuple) const noexcept + { + return helper(std::make_index_sequence(), tuple); + } +}; + + +template<> struct hash +{ + std::size_t operator()(const QStringList &s) const noexcept + { + return qbs::Internal::hashRange(s); + } +}; + +template<> struct hash +{ + size_t operator()(const QVariant &v) const noexcept; +}; + +template<> struct hash +{ + size_t operator()(const QVariantList &v) const noexcept + { + return qbs::Internal::hashRange(v); + } +}; + +template<> struct hash +{ + size_t operator()(const QVariantMap &v) const noexcept + { + return qbs::Internal::hashRange(v); + } +}; + +template<> struct hash +{ + size_t operator()(const QVariantHash &v) const noexcept + { + return qbs::Internal::hashRange(v); + } +}; + +} // namespace std + +QT_BEGIN_NAMESPACE + +qbs::QHashValueType qHash(const QStringList &list); +qbs::QHashValueType qHash(const QProcessEnvironment &env); + +template +qbs::QHashValueType qHash(const std::tuple &tuple) +{ + return std::hash>()(tuple) % std::numeric_limits::max(); +} + +inline qbs::QHashValueType qHash(const QVariant &v) +{ + return std::hash()(v) % std::numeric_limits::max(); +} + +inline qbs::QHashValueType qHash(const QVariantMap &v) +{ + return std::hash()(v) % std::numeric_limits::max(); +} + +inline qbs::QHashValueType qHash(const QVariantHash &v) +{ + return std::hash()(v) % std::numeric_limits::max(); +} + +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +namespace Qt { +inline QTextStream &endl(QTextStream &stream) { return stream << QT_PREPEND_NAMESPACE(endl); } +} // namespace Qt +#endif + +QT_END_NAMESPACE + +namespace qbs { + +template +QSet toSet(const QList &list) +{ +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + return list.toSet(); +#else + return QSet(list.begin(), list.end()); +#endif +} + +template +QList toList(const QSet &set) +{ +#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) + return set.toList(); +#else + return QList(set.begin(), set.end()); +#endif +} + +template +QHash &unite(QHash &h, const QHash &other) +{ +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + return h.unite(other); +#else + h.insert(other); + return h; +#endif +} + +inline void setupDefaultCodec(QTextStream &stream) +{ +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + stream.setCodec("UTF-8"); +#else + Q_UNUSED(stream); +#endif +} + +inline bool qVariantCanConvert(const QVariant &variant, int typeId) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return variant.canConvert(QMetaType(typeId)); +#else + return variant.canConvert(typeId); // deprecated in Qt6 +#endif +} + +inline bool qVariantConvert(QVariant &variant, int typeId) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return variant.convert(QMetaType(typeId)); +#else + return variant.convert(typeId); // deprecated in Qt6 +#endif +} + +} // namespace qbs + +#endif // QBSQTTOOLS_H diff --git a/src/lib/corelib/tools/scannerpluginmanager.cpp b/src/lib/corelib/tools/scannerpluginmanager.cpp new file mode 100644 index 00000000..378f0e11 --- /dev/null +++ b/src/lib/corelib/tools/scannerpluginmanager.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "scannerpluginmanager.h" + +#include + +#include + +namespace qbs { +namespace Internal { + +class ScannerPluginManagerPrivate { +public: + std::map> scannerPlugins; +}; + +ScannerPluginManager::~ScannerPluginManager() = default; + +ScannerPluginManager *ScannerPluginManager::instance() +{ + static ScannerPluginManager scannerPlugin; + return &scannerPlugin; +} + +ScannerPluginManager::ScannerPluginManager() + : d(new ScannerPluginManagerPrivate) +{ +} + +std::vector ScannerPluginManager::scannersForFileTag(const FileTag &fileTag) +{ + auto it = instance()->d->scannerPlugins.find(fileTag); + if (it != instance()->d->scannerPlugins.cend()) + return it->second; + return {}; +} + +void ScannerPluginManager::registerPlugins(ScannerPlugin **plugins) +{ + for (int i = 0; plugins[i] != nullptr; ++i) { + const FileTags &fileTags = FileTags::fromStringList( + QString::fromLatin1(plugins[i]->fileTags).split(QLatin1Char(','))); + for (const FileTag &tag : fileTags) + d->scannerPlugins[tag].push_back(plugins[i]); + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/scannerpluginmanager.h b/src/lib/corelib/tools/scannerpluginmanager.h new file mode 100644 index 00000000..d6dfce86 --- /dev/null +++ b/src/lib/corelib/tools/scannerpluginmanager.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_PLUGINS_SCANNER_H +#define QBS_PLUGINS_SCANNER_H + +#include "qbs_export.h" + +#include +#include + +class ScannerPlugin; + +namespace qbs { +namespace Internal { + +class FileTag; +class ScannerPluginManagerPrivate; + +class QBS_EXPORT ScannerPluginManager +{ +public: + ~ScannerPluginManager(); + static ScannerPluginManager *instance(); + static std::vector scannersForFileTag(const FileTag &fileTag); + void registerPlugins(ScannerPlugin **plugins); + +private: + ScannerPluginManager(); + std::unique_ptr d; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_PLUGINS_SCANNER_H diff --git a/src/lib/corelib/tools/scripttools.cpp b/src/lib/corelib/tools/scripttools.cpp new file mode 100644 index 00000000..ed88520f --- /dev/null +++ b/src/lib/corelib/tools/scripttools.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "scripttools.h" + +#include + +#include + +namespace qbs { +namespace Internal { + +void setConfigProperty(QVariantMap &cfg, const QStringList &name, const QVariant &value) +{ + if (name.length() == 1) { + cfg.insert(name.front(), value); + } else { + QVariant &subCfg = cfg[name.front()]; + QVariantMap subCfgMap = subCfg.toMap(); + setConfigProperty(subCfgMap, name.mid(1), value); + subCfg = subCfgMap; + } +} + +QVariant getConfigProperty(const QVariantMap &cfg, const QStringList &name) +{ + if (name.length() == 1) + return cfg.value(name.front()); + return getConfigProperty(cfg.value(name.front()).toMap(), name.mid(1)); +} + +TemporaryGlobalObjectSetter::TemporaryGlobalObjectSetter(const QScriptValue &object) +{ + QScriptEngine *engine = object.engine(); + m_oldGlobalObject = engine->globalObject(); + engine->setGlobalObject(object); +} + +TemporaryGlobalObjectSetter::~TemporaryGlobalObjectSetter() +{ + m_oldGlobalObject.engine()->setGlobalObject(m_oldGlobalObject); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/scripttools.h b/src/lib/corelib/tools/scripttools.h new file mode 100644 index 00000000..4a258b98 --- /dev/null +++ b/src/lib/corelib/tools/scripttools.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SCRIPTTOOLS_H +#define QBS_SCRIPTTOOLS_H + +#include + +#include +#include + +#include +#include +#include + +namespace qbs { +namespace Internal { + +template +QScriptValue toScriptValue(QScriptEngine *scriptEngine, const C &container) +{ + QScriptValue v = scriptEngine->newArray(container.size()); + int i = 0; + for (const typename C::value_type &item : container) + v.setProperty(i++, scriptEngine->toScriptValue(item)); + return v; +} + +void setConfigProperty(QVariantMap &cfg, const QStringList &name, const QVariant &value); +QVariant QBS_AUTOTEST_EXPORT getConfigProperty(const QVariantMap &cfg, const QStringList &name); + +template +void attachPointerTo(QScriptValue &scriptValue, T *ptr) +{ + QVariant v; + v.setValue(reinterpret_cast(ptr)); + scriptValue.setData(scriptValue.engine()->newVariant(v)); +} + +template +T *attachedPointer(const QScriptValue &scriptValue) +{ + const auto ptr = scriptValue.data().toVariant().value(); + return reinterpret_cast(ptr); +} + +class TemporaryGlobalObjectSetter +{ +public: + TemporaryGlobalObjectSetter(const QScriptValue &object); + ~TemporaryGlobalObjectSetter(); + +private: + QScriptValue m_oldGlobalObject; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_SCRIPTTOOLS_H diff --git a/src/lib/corelib/tools/set.h b/src/lib/corelib/tools/set.h new file mode 100644 index 00000000..46117561 --- /dev/null +++ b/src/lib/corelib/tools/set.h @@ -0,0 +1,400 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SET_H +#define QBS_SET_H + +#include +#include +#include + +#ifdef QT_CORE_LIB +#include +#include +#endif + +#include +#include +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +template class Set; +template Set operator&(const Set &set1, const Set &set2); +template Set operator-(const Set &set1, const Set &set2); + +namespace helper { +template struct SortAfterLoad { static const bool required = false; }; +template struct SortAfterLoad { static const bool required = true; }; +template struct SortAfterLoad> { static const bool required = true; }; +} + +template class Set +{ +public: + using const_iterator = typename std::vector::const_iterator; + using iterator = typename std::vector::iterator; + using reverse_iterator = typename std::vector::reverse_iterator; + using const_reverse_iterator = typename std::vector::const_reverse_iterator; + using size_type = typename std::vector::size_type; + using value_type = T; + using difference_type = typename std::vector::difference_type; + using pointer = typename std::vector::pointer; + using const_pointer = typename std::vector::const_pointer; + using reference = typename std::vector::reference; + using const_reference = typename std::vector::const_reference; + + iterator begin() { return m_data.begin(); } + iterator end() { return m_data.end(); } + reverse_iterator rbegin() { return m_data.rbegin(); } + reverse_iterator rend() { return m_data.rend(); } + const_reverse_iterator rbegin() const { return m_data.rbegin(); } + const_reverse_iterator rend() const { return m_data.rend(); } + const_reverse_iterator crbegin() const { return m_data.crbegin(); } + const_reverse_iterator crend() const { return m_data.crend(); } + const_iterator begin() const { return m_data.begin(); } + const_iterator end() const { return m_data.end(); } + const_iterator cbegin() const { return m_data.cbegin(); } + const_iterator cend() const { return m_data.cend(); } + const_iterator constBegin() const { return m_data.cbegin(); } + const_iterator constEnd() const { return m_data.cend(); } + + Set() = default; + Set(const std::initializer_list &list); + template + Set(InputIterator first, InputIterator last); + + Set &unite(const Set &other); + Set &operator+=(const Set &other) { return unite(other); } + Set &operator|=(const Set &other) { return unite(other); } + + Set &subtract(const Set &other); + Set &operator-=(const Set &other) { return subtract(other); } + + Set &intersect(const Set &other); + Set &operator&=(const Set &other) { return intersect(other); } + Set &operator&=(const T &v) { return intersect(Set{ v }); } + + iterator find(const T &v) { return binaryFind(m_data.begin(), m_data.end(), v); } + const_iterator find(const T &v) const { return binaryFind(m_data.cbegin(), m_data.cend(), v); } + std::pair insert(const T &v); + Set &operator+=(const T &v) { insert(v); return *this; } + Set &operator|=(const T &v) { return operator+=(v); } + Set &operator<<(const T &v) { return operator+=(v); } + + bool contains(const T &v) const { return std::binary_search(cbegin(), cend(), v); } + bool contains(const Set &other) const; + bool empty() const { return m_data.empty(); } + size_type size() const { return m_data.size(); } + size_type capacity() const { return m_data.capacity(); } + bool intersects(const Set &other) const; + + bool remove(const T &v); + void operator-=(const T &v) { remove(v); } + iterator erase(iterator it) { return m_data.erase(it); } + iterator erase(iterator first, iterator last) { return m_data.erase(first, last); } + + void clear() { m_data.clear(); } + void reserve(size_type size) { m_data.reserve(size); } + + void swap(Set &other) { m_data.swap(other.m_data); } + + void load(PersistentPool &pool); + void store(PersistentPool &pool) const; + +#ifdef QT_CORE_LIB + QStringList toStringList() const; + QString toString(const T& value) const { return value.toString(); } + QString toString() const; +#endif + + template static Set filtered(const Set &s); + + bool operator==(const Set &other) const { return m_data == other.m_data; } + bool operator!=(const Set &other) const { return m_data != other.m_data; } + +private: + friend Set operator&<>(const Set &set1, const Set &set2); + friend Set operator-<>(const Set &set1, const Set &set2); + + void sort() { std::sort(m_data.begin(), m_data.end()); } + T loadElem(PersistentPool &pool) { return pool.load(); } + void storeElem(PersistentPool &pool, const T &v) const { pool.store(v); } + bool sortAfterLoadRequired() const { return helper::SortAfterLoad::required; } + iterator asMutableIterator(const_iterator cit); + + std::vector m_data; +}; + +template Set::Set(const std::initializer_list &list) : m_data(list) +{ + sort(); + const auto last = std::unique(m_data.begin(), m_data.end()); + m_data.erase(last, m_data.end()); +} + +template +template +Set::Set(InputIterator first, InputIterator last) +{ + reserveIfForwardIterator(&m_data, first, last); + std::copy(first, last, std::back_inserter(m_data)); + sort(); +} + +template Set &Set::intersect(const Set &other) +{ + auto it = begin(); + auto otherIt = other.cbegin(); + while (it != end()) { + if (otherIt == other.cend()) { + m_data.erase(it, end()); + break; + } + if (*it < *otherIt) { + it = erase(it); + continue; + } + if (!(*otherIt < *it)) + ++it; + ++otherIt; + } + return *this; +} + +template std::pair::iterator, bool> Set::insert(const T &v) +{ + const auto it = std::lower_bound(m_data.begin(), m_data.end(), v); + if (it == m_data.end() || v < *it) + return std::make_pair(m_data.insert(it, v), true); + return std::make_pair(it, false); +} + +template bool Set::contains(const Set &other) const +{ + auto it = cbegin(); + auto otherIt = other.cbegin(); + while (otherIt != other.cend()) { + if (it == cend() || *otherIt < *it) + return false; + if (!(*it < *otherIt)) + ++otherIt; + ++it; + } + return true; +} + +template bool Set::intersects(const Set &other) const +{ + auto it = cbegin(); + auto itOther = other.cbegin(); + while (it != cend() && itOther != other.cend()) { + if (*it < *itOther) + ++it; + else if (*itOther < *it) + ++itOther; + else + return true; + } + return false; +} + +template Set &Set::unite(const Set &other) +{ + if (other.empty()) + return *this; + if (empty()) { + m_data = other.m_data; + return *this; + } + auto lowerBound = m_data.begin(); + for (auto otherIt = other.cbegin(); otherIt != other.cend(); ++otherIt) { + lowerBound = std::lower_bound(lowerBound, m_data.end(), *otherIt); + if (lowerBound == m_data.end()) { + m_data.reserve(size() + std::distance(otherIt, other.cend())); + std::copy(otherIt, other.cend(), std::back_inserter(m_data)); + return *this; + } + if (*otherIt < *lowerBound) + lowerBound = m_data.insert(lowerBound, *otherIt); + } + return *this; +} + +template bool Set::remove(const T &v) +{ + const auto it = std::lower_bound(m_data.cbegin(), m_data.cend(), v); + if (it != m_data.cend() && !(v < *it)) { + m_data.erase(asMutableIterator(it)); + return true; + } + return false; +} + +template void Set::load(PersistentPool &pool) +{ + clear(); + int i = pool.load(); + reserve(i); + for (; --i >= 0;) + m_data.push_back(loadElem(pool)); + if (sortAfterLoadRequired()) + sort(); +} + +template void Set::store(PersistentPool &pool) const +{ + pool.store(static_cast(size())); + std::for_each(m_data.cbegin(), m_data.cend(), + std::bind(&Set::storeElem, this, std::ref(pool), std::placeholders::_1)); +} + +#ifdef QT_CORE_LIB +template QStringList Set::toStringList() const +{ + return transformed(*this, [this](const T &e) { return toString(e); }); +} + +template QString Set::toString() const +{ + return QLatin1Char('[') + toStringList().join(QLatin1String(", ")) + QLatin1Char(']'); +} + +template<> inline QString Set::toString(const QString &value) const { return value; } + +#endif + +template +typename Set::iterator Set::asMutableIterator(typename Set::const_iterator cit) +{ + const auto offset = std::distance(cbegin(), cit); + return begin() + offset; +} + +template template Set Set::filtered(const Set &s) +{ + static_assert(std::is_pointer_v, "Set::filtered() assumes pointer types"); + static_assert(std::is_pointer_v, "Set::filtered() assumes pointer types"); + Set filteredSet; + for (auto &u : s) { + if (hasDynamicType>(u)) + filteredSet.m_data.push_back(static_cast(u)); + } + return filteredSet; +} + +template Set &Set::subtract(const Set &other) +{ + if (empty() || other.empty()) + return *this; + auto lowerBound = m_data.begin(); + for (auto otherIt = other.cbegin(); otherIt != other.cend(); ++otherIt) { + lowerBound = std::lower_bound(lowerBound, m_data.end(), *otherIt); + if (lowerBound == m_data.end()) + return *this; + if (!(*otherIt < *lowerBound)) + lowerBound = m_data.erase(lowerBound); + } + return *this; +} + +template Set operator+(const Set &set1, const Set &set2) +{ + Set result = set1; + return result += set2; +} + +template Set operator|(const Set &set1, const Set &set2) +{ + return set1 + set2; +} + +template Set operator-(const Set &set1, const Set &set2) +{ + if (set1.empty() || set2.empty()) + return set1; + Set result; + auto it1 = set1.cbegin(); + auto it2 = set2.cbegin(); + while (it1 != set1.cend()) { + if (it2 == set2.cend()) { + std::copy(it1, set1.cend(), std::back_inserter(result.m_data)); + break; + } + if (*it1 < *it2) { + result.m_data.push_back(*it1++); + } else if (*it2 < *it1) { + ++it2; + } else { + ++it1; + ++it2; + } + } + return result; +} + +template Set operator&(const Set &set1, const Set &set2) +{ + Set result; + auto it1 = set1.cbegin(); + auto it2 = set2.cbegin(); + while (it1 != set1.cend() && it2 != set2.cend()) { + if (*it1 < *it2) { + ++it1; + continue; + } + if (*it2 < *it1) { + ++it2; + continue; + } + result.m_data.push_back(*it1); + ++it1; + ++it2; + } + return result; +} + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/settings.cpp b/src/lib/corelib/tools/settings.cpp new file mode 100644 index 00000000..8b22c45e --- /dev/null +++ b/src/lib/corelib/tools/settings.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "settings.h" + +#include "error.h" +#include "profile.h" +#include "settingscreator.h" + +#include +#include +#include + +#include + +#include + +namespace qbs { +using namespace Internal; + +QString Settings::defaultSystemSettingsBaseDir() +{ + switch (HostOsInfo::hostOs()) { + case HostOsInfo::HostOsWindows: { + const char key[] = "ALLUSERSAPPDATA"; + if (qEnvironmentVariableIsSet(key)) + return QLatin1String(key); + return QStringLiteral("C:/ProgramData"); + } + case HostOsInfo::HostOsMacos: + return QStringLiteral("/Library/Application Support"); + case HostOsInfo::HostOsLinux: + case HostOsInfo::HostOsOtherUnix: + return QStringLiteral("/etc/xdg"); + default: + return {}; + } +} + +static QString systemSettingsBaseDir() +{ +#ifdef QBS_ENABLE_UNIT_TESTS + const char key[] = "QBS_AUTOTEST_SYSTEM_SETTINGS_DIR"; + if (qEnvironmentVariableIsSet(key)) + return QLatin1String(qgetenv(key)); +#endif +#ifdef QBS_SYSTEM_SETTINGS_DIR + return QLatin1String(QBS_SYSTEM_SETTINGS_DIR); +#else + return Settings::defaultSystemSettingsBaseDir() + QStringLiteral("/qbs"); +#endif +} + +Settings::Settings(const QString &baseDir) : Settings(baseDir, systemSettingsBaseDir()) { } + +Settings::Settings(const QString &baseDir, const QString &systemBaseDir) + : m_settings(SettingsCreator(baseDir).getQSettings()), + m_systemSettings(std::make_unique(systemBaseDir + QStringLiteral("/qbs.conf"), + QSettings::IniFormat)), + m_baseDir(baseDir) +{ + // Actual qbs settings are stored transparently within a group, because QSettings + // can see non-qbs fallback settings e.g. from QtProject that we're not interested in. + m_settings->beginGroup(QStringLiteral("org/qt-project/qbs")); +} + +Settings::~Settings() = default; + +QVariant Settings::value(const QString &key, Scopes scopes, const QVariant &defaultValue) const +{ + QVariant userValue; + if (scopes & UserScope) + userValue = m_settings->value(internalRepresentation(key)); + QVariant systemValue; + if (scopes & SystemScope) + systemValue = m_systemSettings->value(internalRepresentation(key)); + if (!userValue.isValid()) { + if (systemValue.isValid()) + return systemValue; + return defaultValue; + } + if (!systemValue.isValid()) + return userValue; + if (static_cast(userValue.userType()) == QMetaType::QStringList) + return userValue.toStringList() + systemValue.toStringList(); + if (static_cast(userValue.userType()) == QMetaType::QVariantList) + return userValue.toList() + systemValue.toList(); + return userValue; +} + +QStringList Settings::allKeys(Scopes scopes) const +{ + QStringList keys; + if (scopes & UserScope) + keys = m_settings->allKeys(); + if (scopes & SystemScope) + keys += m_systemSettings->allKeys(); + fixupKeys(keys); + return keys; +} + +QStringList Settings::directChildren(const QString &parentGroup, Scope scope) const +{ + QSettings * const settings = settingsForScope(scope); + settings->beginGroup(internalRepresentation(parentGroup)); + QStringList children = settings->childGroups(); + children << settings->childKeys(); + settings->endGroup(); + fixupKeys(children); + return children; +} + +QStringList Settings::allKeysWithPrefix(const QString &group, Scopes scopes) const +{ + QStringList keys; + if (scopes & UserScope) { + m_settings->beginGroup(internalRepresentation(group)); + keys = m_settings->allKeys(); + m_settings->endGroup(); + } + if (scopes & SystemScope) { + m_systemSettings->beginGroup(internalRepresentation(group)); + keys += m_systemSettings->allKeys(); + m_systemSettings->endGroup(); + } + fixupKeys(keys); + return keys; +} + +void Settings::setValue(const QString &key, const QVariant &value) +{ + if (key.startsWith(StringConstants::profilesSettingsPrefix() + Profile::fallbackName())) { + throw ErrorInfo(Tr::tr("Invalid use of special profile name '%1'.") + .arg(Profile::fallbackName())); + } + targetForWriting()->setValue(internalRepresentation(key), value); + checkForWriteError(); +} + +void Settings::remove(const QString &key) +{ + targetForWriting()->remove(internalRepresentation(key)); + checkForWriteError(); +} + +void Settings::clear() +{ + targetForWriting()->clear(); + checkForWriteError(); +} + +void Settings::sync() +{ + targetForWriting()->sync(); +} + +QString Settings::defaultProfile() const +{ + return value(QStringLiteral("defaultProfile"), allScopes()).toString(); +} + +QStringList Settings::profiles() const +{ + QStringList result; + if (m_scopeForWriting == UserScope) { + m_settings->beginGroup(StringConstants::profilesSettingsKey()); + result = m_settings->childGroups(); + m_settings->endGroup(); + } + m_systemSettings->beginGroup(StringConstants::profilesSettingsKey()); + result += m_systemSettings->childGroups(); + m_systemSettings->endGroup(); + result.removeDuplicates(); + return result; +} + +QString Settings::fileName() const +{ + return targetForWriting()->fileName(); +} + +QString Settings::internalRepresentation(const QString &externalKey) const +{ + QString internalKey = externalKey; + return internalKey.replace(QLatin1Char('.'), QLatin1Char('/')); +} + +QString Settings::externalRepresentation(const QString &internalKey) const +{ + QString externalKey = internalKey; + return externalKey.replace(QLatin1Char('/'), QLatin1Char('.')); +} + +void Settings::fixupKeys(QStringList &keys) const +{ + keys.sort(); + keys.removeDuplicates(); + for (auto &key : keys) + key = externalRepresentation(key); +} + +QSettings *Settings::settingsForScope(Settings::Scope scope) const +{ + return scope == UserScope ? m_settings.get() : m_systemSettings.get(); +} + +QSettings *Settings::targetForWriting() const +{ + return settingsForScope(m_scopeForWriting); +} + +void Settings::checkForWriteError() +{ + if (m_scopeForWriting == SystemScope && m_systemSettings->status() == QSettings::NoError) { + sync(); + if (m_systemSettings->status() == QSettings::AccessError) + throw ErrorInfo(Tr::tr("Failure writing system settings file '%1': " + "You do not have permission to write to that location.") + .arg(fileName())); + } +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/settings.h b/src/lib/corelib/tools/settings.h new file mode 100644 index 00000000..4ea148af --- /dev/null +++ b/src/lib/corelib/tools/settings.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETTINGS_H +#define QBS_SETTINGS_H + +#include "qbs_export.h" + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace qbs { + +class QBS_EXPORT Settings +{ +public: + // The "pure" base directory without any version scope. Empty string means "system default". + Settings(const QString &baseDir); + Settings(const QString &baseDir, const QString &systemBaseDir); + + ~Settings(); + + enum Scope { UserScope = 0x1, SystemScope = 0x2 }; + Q_DECLARE_FLAGS(Scopes, Scope) + static Scopes allScopes() { return {UserScope, SystemScope}; } + + QVariant value(const QString &key, Scopes scopes, + const QVariant &defaultValue = QVariant()) const; + QStringList allKeys(Scopes scopes) const; + QStringList directChildren(const QString &parentGroup, Scope scope) const; // Keys and groups. + QStringList allKeysWithPrefix(const QString &group, Scopes scopes) const; + void setValue(const QString &key, const QVariant &value); + void remove(const QString &key); + void clear(); + void sync(); + + void setScopeForWriting(Scope scope) { m_scopeForWriting = scope; } + Scope scopeForWriting() const { return m_scopeForWriting; } + + QString defaultProfile() const; + QStringList profiles() const; + + QString fileName() const; + QString baseDirectory() const { return m_baseDir; } // As passed into the constructor. + + static QString defaultSystemSettingsBaseDir(); + +private: + QString internalRepresentation(const QString &externalKey) const; + QString externalRepresentation(const QString &internalKey) const; + void fixupKeys(QStringList &keys) const; + QSettings *settingsForScope(Scope scope) const; + QSettings *targetForWriting() const; + void checkForWriteError(); + + const std::unique_ptr m_settings; + const std::unique_ptr m_systemSettings; + const QString m_baseDir; + Scope m_scopeForWriting = UserScope; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(Settings::Scopes) + +} // namespace qbs + +#endif // QBS_SETTINGS_H diff --git a/src/lib/corelib/tools/settingscreator.cpp b/src/lib/corelib/tools/settingscreator.cpp new file mode 100644 index 00000000..f94ae6f1 --- /dev/null +++ b/src/lib/corelib/tools/settingscreator.cpp @@ -0,0 +1,126 @@ +#include +#include + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "settingscreator.h" + +#include "fileinfo.h" +#include "hostosinfo.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +static QSettings::Format format() +{ + return HostOsInfo::isWindowsHost() ? QSettings::IniFormat : QSettings::NativeFormat; +} + + +SettingsCreator::SettingsCreator(QString baseDir) + : m_settingsBaseDir(std::move(baseDir)) + , m_qbsVersion(Version::fromString(QLatin1String(QBS_VERSION))) +{ +} + +std::unique_ptr SettingsCreator::getQSettings() +{ + createQSettings(); + migrate(); + return std::move(m_settings); +} + +void SettingsCreator::migrate() +{ + if (!m_settings->allKeys().empty()) // We already have settings for this qbs version. + return; + + m_settings.reset(); + + // Find settings from highest qbs version lower than this one and copy all settings data. + const Version thePredecessor = predecessor(); + QString oldSettingsDir = m_settingsBaseDir; + if (thePredecessor.isValid()) + oldSettingsDir.append(QLatin1String("/qbs/")).append(thePredecessor.toString()); + const QString oldSettingsFilePath = oldSettingsDir + QLatin1Char('/') + m_settingsFileName; + if (QFileInfo::exists(oldSettingsFilePath) + && (!QDir::root().mkpath(m_newSettingsDir) + || !QFile::copy(oldSettingsFilePath, m_newSettingsFilePath))) { + qWarning() << "Error in settings migration: Could not copy" << oldSettingsFilePath + << "to" << m_newSettingsFilePath; + } + + m_settings = std::make_unique(m_newSettingsFilePath, format()); +} + +void SettingsCreator::createQSettings() +{ + std::unique_ptr tmp(m_settingsBaseDir.isEmpty() + ? new QSettings(format(), QSettings::UserScope, QStringLiteral("QtProject"), + QStringLiteral("qbs")) + : new QSettings(m_settingsBaseDir + QLatin1String("/qbs.conf"), format())); + const QFileInfo fi(tmp->fileName()); + m_settingsBaseDir = fi.path(); + m_newSettingsDir = m_settingsBaseDir + QLatin1String("/qbs/") + m_qbsVersion.toString(); + m_settingsFileName = fi.fileName(); + m_newSettingsFilePath = m_newSettingsDir + QLatin1Char('/') + m_settingsFileName; + m_settings = std::make_unique(m_newSettingsFilePath, tmp->format()); +} + +Version SettingsCreator::predecessor() const +{ + QDirIterator dit(m_settingsBaseDir + QLatin1String("/qbs")); + Version thePredecessor; + while (dit.hasNext()) { + dit.next(); + const auto currentVersion = Version::fromString(dit.fileName()); + if (currentVersion > thePredecessor && currentVersion < m_qbsVersion) + thePredecessor = currentVersion; + } + return thePredecessor; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/settingscreator.h b/src/lib/corelib/tools/settingscreator.h new file mode 100644 index 00000000..ab491105 --- /dev/null +++ b/src/lib/corelib/tools/settingscreator.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETTINGSCREATOR_H +#define QBS_SETTINGSCREATOR_H + +#include "version.h" + +#include + +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +class SettingsCreator +{ +public: + SettingsCreator(QString baseDir); + + std::unique_ptr getQSettings(); + +private: + void migrate(); + void createQSettings(); + Version predecessor() const; + + QString m_settingsBaseDir; + QString m_newSettingsDir; + QString m_settingsFileName; + QString m_newSettingsFilePath; + std::unique_ptr m_settings; + const Version m_qbsVersion; +}; + + +} // namespace Internal +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/tools/settingsmodel.cpp b/src/lib/corelib/tools/settingsmodel.cpp new file mode 100644 index 00000000..31aa0f5f --- /dev/null +++ b/src/lib/corelib/tools/settingsmodel.cpp @@ -0,0 +1,398 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "settingsmodel.h" +#include "settingsrepresentation.h" + +#include +#include +#include +#include +#include + +#include +#include + +#ifdef QT_GUI_LIB +#include +#endif + +#include + +namespace qbs { +namespace Internal { + +struct Node +{ + Node() : parent(nullptr), isFromSettings(true) {} + ~Node() { qDeleteAll(children); } + + QString uniqueChildName() const; + bool hasDirectChildWithName(const QString &name) const; + + QString name; + QString value; + Node *parent; + QList children; + bool isFromSettings; +}; + +QString Node::uniqueChildName() const +{ + QString newName = QStringLiteral("newkey"); + bool unique; + do { + unique = true; + for (const Node *childNode : qAsConst(children)) { + if (childNode->name == newName) { + unique = false; + newName += QLatin1Char('_'); + break; + } + } + } while (!unique); + return newName; +} + +bool Node::hasDirectChildWithName(const QString &name) const +{ + return Internal::any_of(children, [&name](const auto &child){ + return child->name == name; + }); +} + +} // namespace Internal + +using Internal::Node; + +class SettingsModel::SettingsModelPrivate +{ +public: + SettingsModelPrivate() : dirty(false), editable(true) {} + + void readSettings(); + void addNodeFromSettings(Node *parentNode, const QString &fullyQualifiedName); + void addNode(Node *parentNode, const QString ¤tNamePart, + const QStringList &restOfName, const QVariant &value); + void doSave(const Node *node, const QString &prefix); + Node *indexToNode(const QModelIndex &index); + + Settings::Scope scope() const { return settings->scopeForWriting(); } + + Node rootNode; + std::unique_ptr settings; + QVariantMap additionalProperties; + bool dirty; + bool editable; +}; + +SettingsModel::SettingsModel(const QString &settingsDir, Settings::Scope scope, QObject *parent) + : QAbstractItemModel(parent), + d(std::make_unique()) +{ + d->settings = std::make_unique(settingsDir); + d->settings->setScopeForWriting(scope); + d->readSettings(); +} + +SettingsModel::~SettingsModel() = default; + +void SettingsModel::reload() +{ + beginResetModel(); + d->readSettings(); + endResetModel(); +} + +void SettingsModel::save() +{ + if (!d->dirty) + return; + d->settings->clear(); + d->doSave(&d->rootNode, QString()); + d->dirty = false; +} + +void SettingsModel::updateSettingsDir(const QString &settingsDir) +{ + const Settings::Scope scope = d->scope(); + beginResetModel(); + d->settings = std::make_unique(settingsDir); + d->settings->setScopeForWriting(scope); + d->readSettings(); + endResetModel(); +} + +void SettingsModel::addNewKey(const QModelIndex &parent) +{ + Node *parentNode = d->indexToNode(parent); + if (!parentNode) + return; + const auto newNode = new Node; + newNode->parent = parentNode; + newNode->name = parentNode->uniqueChildName(); + beginInsertRows(parent, parentNode->children.size(), parentNode->children.size()); + parentNode->children << newNode; + endInsertRows(); + d->dirty = true; +} + +void SettingsModel::removeKey(const QModelIndex &index) +{ + Node * const node = d->indexToNode(index); + if (!node || node == &d->rootNode) + return; + const int positionInParent = node->parent->children.indexOf(node); + beginRemoveRows(parent(index), positionInParent, positionInParent); + node->parent->children.removeAt(positionInParent); + delete node; + endRemoveRows(); + d->dirty = true; +} + +bool SettingsModel::hasUnsavedChanges() const +{ + return d->dirty; +} + +void SettingsModel::setEditable(bool isEditable) +{ + d->editable = isEditable; +} + +void SettingsModel::setAdditionalProperties(const QVariantMap &properties) +{ + d->additionalProperties = properties; + reload(); +} + +Qt::ItemFlags SettingsModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + const Qt::ItemFlags flags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + if (index.column() == keyColumn()) { + if (d->editable) + return flags | Qt::ItemIsEditable; + return flags; + } + if (index.column() == valueColumn()) { + const Node * const node = d->indexToNode(index); + if (!node) + return Qt::NoItemFlags; + + // Only leaf nodes have values. + return d->editable && node->children.empty() ? flags | Qt::ItemIsEditable : flags; + } + return {}; +} + +QVariant SettingsModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation != Qt::Horizontal) + return {}; + if (role != Qt::DisplayRole) + return {}; + if (section == keyColumn()) + return tr("Key"); + if (section == valueColumn()) + return tr("Value"); + return {}; +} + +int SettingsModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return 2; +} + +int SettingsModel::rowCount(const QModelIndex &parent) const +{ + if (parent.column() > 0) + return 0; + const Node * const node = d->indexToNode(parent); + Q_ASSERT(node); + return node->children.size(); +} + +QVariant SettingsModel::data(const QModelIndex &index, int role) const +{ + if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ForegroundRole) + return {}; + const Node * const node = d->indexToNode(index); + if (!node) + return {}; + if (role == Qt::ForegroundRole) { +#ifdef QT_GUI_LIB + if (index.column() == valueColumn() && !node->isFromSettings) + return QBrush(Qt::red); +#endif + return {}; + } + if (index.column() == keyColumn()) + return node->name; + if (index.column() == valueColumn() && node->children.empty()) + return node->value; + return {}; +} + +bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid() || role != Qt::EditRole) + return false; + Node * const node = d->indexToNode(index); + if (!node) + return false; + const QString valueString = value.toString(); + QString *toChange = nullptr; + if (index.column() == keyColumn() && !valueString.isEmpty() + && !node->parent->hasDirectChildWithName(valueString) + && !(node->parent->parent == &d->rootNode + && node->parent->name == Internal::StringConstants::profilesSettingsKey() + && valueString == Profile::fallbackName())) { + toChange = &node->name; + } else if (index.column() == valueColumn() && valueString != node->value) { + toChange = &node->value; + } + + if (toChange) { + *toChange = valueString; + emit dataChanged(index, index); + d->dirty = true; + } + return toChange; +} + +QModelIndex SettingsModel::index(int row, int column, const QModelIndex &parent) const +{ + const Node * const parentNode = d->indexToNode(parent); + Q_ASSERT(parentNode); + if (parentNode->children.size() <= row) + return {}; + return createIndex(row, column, parentNode->children.at(row)); +} + +QModelIndex SettingsModel::parent(const QModelIndex &child) const +{ + const auto childNode = static_cast(child.internalPointer()); + Q_ASSERT(childNode); + Node * const parentNode = childNode->parent; + if (parentNode == &d->rootNode) + return {}; + const Node * const grandParentNode = parentNode->parent; + Q_ASSERT(grandParentNode); + return createIndex(grandParentNode->children.indexOf(parentNode), 0, parentNode); +} + + +void SettingsModel::SettingsModelPrivate::readSettings() +{ + qDeleteAll(rootNode.children); + rootNode.children.clear(); + const auto topLevelKeys = settings->directChildren(QString(), scope()); + for (const QString &topLevelKey : topLevelKeys) + addNodeFromSettings(&rootNode, topLevelKey); + for (QVariantMap::ConstIterator it = additionalProperties.constBegin(); + it != additionalProperties.constEnd(); ++it) { + const QStringList nameAsList = it.key().split(QLatin1Char('.'), QBS_SKIP_EMPTY_PARTS); + addNode(&rootNode, nameAsList.front(), nameAsList.mid(1), it.value()); + } + dirty = false; +} + +static Node *createNode(Node *parentNode, const QString &name) +{ + const auto node = new Node; + node->name = name; + node->parent = parentNode; + parentNode->children.push_back(node); + return node; +} + +void SettingsModel::SettingsModelPrivate::addNodeFromSettings(Node *parentNode, + const QString &fullyQualifiedName) +{ + const QString &nodeName + = fullyQualifiedName.mid(fullyQualifiedName.lastIndexOf(QLatin1Char('.')) + 1); + Node * const node = createNode(parentNode, nodeName); + node->value = settingsValueToRepresentation(settings->value(fullyQualifiedName, scope())); + const auto childKeys = settings->directChildren(fullyQualifiedName, scope()); + for (const QString &childKey : childKeys) + addNodeFromSettings(node, fullyQualifiedName + QLatin1Char('.') + childKey); + dirty = true; +} + +void SettingsModel::SettingsModelPrivate::addNode(qbs::Internal::Node *parentNode, + const QString ¤tNamePart, const QStringList &restOfName, const QVariant &value) +{ + Node *currentNode = nullptr; + for (Node * const n : qAsConst(parentNode->children)) { + if (n->name == currentNamePart) { + currentNode = n; + break; + } + } + if (!currentNode) + currentNode = createNode(parentNode, currentNamePart); + if (restOfName.empty()) { + currentNode->value = settingsValueToRepresentation(value); + currentNode->isFromSettings = false; + } else { + addNode(currentNode, restOfName.front(), restOfName.mid(1), value); + } +} + +void SettingsModel::SettingsModelPrivate::doSave(const Node *node, const QString &prefix) +{ + if (node->children.empty()) { + settings->setValue(prefix + node->name, representationToSettingsValue(node->value)); + return; + } + + const QString newPrefix = prefix + node->name + QLatin1Char('.'); + for (const Node * const child : qAsConst(node->children)) + doSave(child, newPrefix); +} + +Node *SettingsModel::SettingsModelPrivate::indexToNode(const QModelIndex &index) +{ + return index.isValid() ? static_cast(index.internalPointer()) : &rootNode; +} + + +} // namespace qbs diff --git a/src/lib/corelib/tools/settingsmodel.h b/src/lib/corelib/tools/settingsmodel.h new file mode 100644 index 00000000..63651d30 --- /dev/null +++ b/src/lib/corelib/tools/settingsmodel.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETTINGSMODEL_H +#define QBS_SETTINGSMODEL_H + +#include +#include + +#include +#include + +#include + +namespace qbs { + +class QBS_EXPORT SettingsModel : public QAbstractItemModel +{ + Q_OBJECT +public: + SettingsModel(const QString &settingsDir, Settings::Scope scope, QObject *parent = nullptr); + ~SettingsModel() override; + + int keyColumn() const { return 0; } + int valueColumn() const { return 1; } + bool hasUnsavedChanges() const; + + void setEditable(bool isEditable); + void setAdditionalProperties(const QVariantMap &properties); // Flat map. + void reload(); + void save(); + void updateSettingsDir(const QString &settingsDir); + + void addNewKey(const QModelIndex &parent); + void removeKey(const QModelIndex &index); + + Qt::ItemFlags flags(const QModelIndex &index) const override; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + +private: + class SettingsModelPrivate; + const std::unique_ptr d; +}; + +} // namespace qbs + +#endif // QBS_SETTINGSMODEL_H diff --git a/src/lib/corelib/tools/settingsrepresentation.cpp b/src/lib/corelib/tools/settingsrepresentation.cpp new file mode 100644 index 00000000..7790f1aa --- /dev/null +++ b/src/lib/corelib/tools/settingsrepresentation.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "settingsrepresentation.h" + +#include "jsliterals.h" + +#include +#include + +namespace qbs { + +QString settingsValueToRepresentation(const QVariant &value) +{ + return toJSLiteral(value); +} + +static QVariant variantFromString(const QString &str, bool &ok) +{ + // ### use Qt5's JSON reader at some point. + QScriptEngine engine; + QScriptValue sv = engine.evaluate(QLatin1String("(function(){return ") + + str + QLatin1String(";})()")); + ok = !sv.isError(); + return sv.toVariant(); +} + +QVariant representationToSettingsValue(const QString &representation) +{ + bool ok; + QVariant variant = variantFromString(representation, ok); + + // We have no floating-point properties, so this is most likely intended to be a string. + if (static_cast(variant.userType()) == QMetaType::Float + || static_cast(variant.userType()) == QMetaType::Double) { + variant = variantFromString(QLatin1Char('"') + representation + QLatin1Char('"'), ok); + } + + if (ok) + return variant; + + // If it's not valid JavaScript, interpret the value as a string. + return representation; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/settingsrepresentation.h b/src/lib/corelib/tools/settingsrepresentation.h new file mode 100644 index 00000000..9ebd64d3 --- /dev/null +++ b/src/lib/corelib/tools/settingsrepresentation.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SETTINGSREPRESENTATION_H +#define QBS_SETTINGSREPRESENTATION_H + +#include + +#include +#include + +namespace qbs { + +QBS_EXPORT QString settingsValueToRepresentation(const QVariant &value); +QBS_EXPORT QVariant representationToSettingsValue(const QString &representation); + +} // namespace qbs + +#endif // QBS_SETTINGSREPRESENTATION_H diff --git a/src/lib/corelib/tools/setupprojectparameters.cpp b/src/lib/corelib/tools/setupprojectparameters.cpp new file mode 100644 index 00000000..a06ffc4b --- /dev/null +++ b/src/lib/corelib/tools/setupprojectparameters.cpp @@ -0,0 +1,691 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "setupprojectparameters.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +/*! + * \class SetupProjectParameters + * \brief The \c SetupProjectParameters class comprises data required to set up a qbs project. + */ + +class SetupProjectParametersPrivate : public QSharedData +{ +public: + SetupProjectParametersPrivate() + : overrideBuildGraphData(false) + , dryRun(false) + , logElapsedTime(false) + , forceProbeExecution(false) + , waitLockBuildGraph(false) + , restoreBehavior(SetupProjectParameters::RestoreAndTrackChanges) + , propertyCheckingMode(ErrorHandlingMode::Strict) + , productErrorMode(ErrorHandlingMode::Strict) + { + } + + QString projectFilePath; + QString topLevelProfile; + QString configurationName = QLatin1String("default"); + QString buildRoot; + QStringList searchPaths; + QStringList pluginPaths; + QString libexecPath; + QString settingsBaseDir; + QVariantMap overriddenValues; + QVariantMap buildConfiguration; + mutable QVariantMap buildConfigurationTree; + mutable QVariantMap overriddenValuesTree; + mutable QVariantMap finalBuildConfigTree; + bool overrideBuildGraphData; + bool dryRun; + bool logElapsedTime; + bool forceProbeExecution; + bool waitLockBuildGraph; + bool fallbackProviderEnabled = true; + SetupProjectParameters::RestoreBehavior restoreBehavior; + ErrorHandlingMode propertyCheckingMode; + ErrorHandlingMode productErrorMode; + QProcessEnvironment environment; +}; + +} // namespace Internal + +SetupProjectParameters::SetupProjectParameters() : d(new Internal::SetupProjectParametersPrivate) +{ +} + +SetupProjectParameters::SetupProjectParameters(const SetupProjectParameters &other) = default; + +SetupProjectParameters::SetupProjectParameters( + SetupProjectParameters &&other) Q_DECL_NOEXCEPT = default; + +SetupProjectParameters::~SetupProjectParameters() = default; + +SetupProjectParameters &SetupProjectParameters::operator=( + const SetupProjectParameters &other) = default; + +namespace Internal { +template<> ErrorHandlingMode fromJson(const QJsonValue &v) +{ + if (v.toString() == QLatin1String("relaxed")) + return ErrorHandlingMode::Relaxed; + return ErrorHandlingMode::Strict; +} + +template<> SetupProjectParameters::RestoreBehavior fromJson(const QJsonValue &v) +{ + const QString value = v.toString(); + if (value == QLatin1String("restore-only")) + return SetupProjectParameters::RestoreOnly; + if (value == QLatin1String("resolve-only")) + return SetupProjectParameters::ResolveOnly; + return SetupProjectParameters::RestoreAndTrackChanges; +} +} // namespace Internal + +SetupProjectParameters SetupProjectParameters::fromJson(const QJsonObject &data) +{ + using namespace Internal; + SetupProjectParameters params; + setValueFromJson(params.d->topLevelProfile, data, "top-level-profile"); + setValueFromJson(params.d->configurationName, data, "configuration-name"); + setValueFromJson(params.d->projectFilePath, data, "project-file-path"); + setValueFromJson(params.d->buildRoot, data, "build-root"); + setValueFromJson(params.d->settingsBaseDir, data, "settings-directory"); + setValueFromJson(params.d->overriddenValues, data, "overridden-properties"); + setValueFromJson(params.d->dryRun, data, "dry-run"); + setValueFromJson(params.d->logElapsedTime, data, "log-time"); + setValueFromJson(params.d->forceProbeExecution, data, "force-probe-execution"); + setValueFromJson(params.d->waitLockBuildGraph, data, "wait-lock-build-graph"); + setValueFromJson(params.d->fallbackProviderEnabled, data, "fallback-provider-enabled"); + setValueFromJson(params.d->environment, data, "environment"); + setValueFromJson(params.d->restoreBehavior, data, "restore-behavior"); + setValueFromJson(params.d->propertyCheckingMode, data, "error-handling-mode"); + params.d->productErrorMode = params.d->propertyCheckingMode; + return params; +} + +SetupProjectParameters &SetupProjectParameters::operator=(SetupProjectParameters &&other) Q_DECL_NOEXCEPT = default; + +/*! + * \brief Returns the name of the top-level profile for building the project. + */ +QString SetupProjectParameters::topLevelProfile() const +{ + return d->topLevelProfile; +} + +/*! + * \brief Sets the top-level profile for building the project. + */ +void SetupProjectParameters::setTopLevelProfile(const QString &profile) +{ + d->buildConfigurationTree.clear(); + d->finalBuildConfigTree.clear(); + d->topLevelProfile = profile; +} + +/*! + * Returns the name of the current project build configuration. + */ +QString SetupProjectParameters::configurationName() const +{ + return d->configurationName; +} + +/*! + * Sets the name of the current project build configuration to an arbitrary user-specified name, + * \a configurationName. + */ +void SetupProjectParameters::setConfigurationName(const QString &configurationName) +{ + d->buildConfigurationTree.clear(); + d->finalBuildConfigTree.clear(); + d->configurationName = configurationName; +} + +/*! + * \brief Returns the absolute path to the qbs project file. + * This file typically has a ".qbs" suffix. + */ +QString SetupProjectParameters::projectFilePath() const +{ + return d->projectFilePath; +} + +/*! + * \brief Sets the path to the main project file. + * \note The argument must be an absolute file path. + */ +void SetupProjectParameters::setProjectFilePath(const QString &projectFilePath) +{ + d->projectFilePath = projectFilePath; + + const QString canonicalProjectFilePath = QFileInfo(d->projectFilePath).canonicalFilePath(); + if (!canonicalProjectFilePath.isEmpty()) + d->projectFilePath = canonicalProjectFilePath; +} + +/*! + * \brief Returns the base path of where to put the build artifacts and store the build graph. + */ +QString SetupProjectParameters::buildRoot() const +{ + return d->buildRoot; +} + +/*! + * \brief Sets the base path of where to put the build artifacts and store the build graph. + * The same base path can be used for several build profiles of the same project without them + * interfering with each other. + * It might look as if this parameter would not be needed at the time of setting up the project, + * but keep in mind that the project information could already exist on disk, in which case + * loading it will be much faster than setting up the project from scratch. + * \note The argument must be an absolute path to a directory. + */ +void SetupProjectParameters::setBuildRoot(const QString &buildRoot) +{ + d->buildRoot = buildRoot; + + // Calling mkpath() may be necessary to get the canonical build root, but if we do it, + // it must be reverted immediately afterwards as not to create directories needlessly, + // e.g in the case of a dry run build. + Internal::DirectoryManager dirManager(buildRoot, Internal::Logger()); + + // We don't do error checking here, as this is not a convenient place to report an error. + // If creation of the build directory is not possible, we will get sensible error messages + // later, e.g. from the code that attempts to store the build graph. + QDir::root().mkpath(buildRoot); + + const QString canonicalBuildRoot = QFileInfo(d->buildRoot).canonicalFilePath(); + if (!canonicalBuildRoot.isEmpty()) + d->buildRoot = canonicalBuildRoot; +} + +/*! + * \brief Where to look for modules and items to import. + */ +QStringList SetupProjectParameters::searchPaths() const +{ + return d->searchPaths; +} + +/*! + * \brief Sets the information about where to look for modules and items to import. + * \note The elements of the list must be absolute paths to directories. + */ +void SetupProjectParameters::setSearchPaths(const QStringList &searchPaths) +{ + d->searchPaths = searchPaths; +} + +/*! + * \brief Where to look for plugins. + */ +QStringList SetupProjectParameters::pluginPaths() const +{ + return d->pluginPaths; +} + +/*! + * \brief Sets the information about where to look for plugins. + * \note The elements of the list must be absolute paths to directories. + */ +void SetupProjectParameters::setPluginPaths(const QStringList &pluginPaths) +{ + d->pluginPaths = pluginPaths; +} + +/*! + * \brief Where to look for internal binaries. + */ +QString SetupProjectParameters::libexecPath() const +{ + return d->libexecPath; +} + +/*! + * \brief Sets the information about where to look for internal binaries. + * \note \p libexecPath must be an absolute path. + */ +void SetupProjectParameters::setLibexecPath(const QString &libexecPath) +{ + d->libexecPath = libexecPath; +} + +/*! + * \brief The base directory for qbs settings. + * This value is used to locate profiles and preferences. + */ +QString SetupProjectParameters::settingsDirectory() const +{ + return d->settingsBaseDir; +} + +/*! + * \brief Sets the base directory for qbs settings. + * \param settingsBaseDir Will be used to locate profiles and preferences. + */ +void SetupProjectParameters::setSettingsDirectory(const QString &settingsBaseDir) +{ + d->settingsBaseDir = settingsBaseDir; +} + +/*! + * Returns the overridden values of the build configuration. + */ +QVariantMap SetupProjectParameters::overriddenValues() const +{ + return d->overriddenValues; +} + +/*! + * Set the overridden values of the build configuration. + */ +void SetupProjectParameters::setOverriddenValues(const QVariantMap &values) +{ + d->overriddenValues = values; + d->overriddenValuesTree.clear(); + d->finalBuildConfigTree.clear(); +} + +static void provideValuesTree(const QVariantMap &values, QVariantMap *valueTree) +{ + if (!valueTree->empty() || values.empty()) + return; + + valueTree->clear(); + for (QVariantMap::const_iterator it = values.constBegin(); it != values.constEnd(); ++it) { + const QString &name = it.key(); + int idx = name.lastIndexOf(QLatin1Char('.')); + const QStringList nameElements = (idx == -1) + ? QStringList() << name + : QStringList() << name.left(idx) << name.mid(idx + 1); + Internal::setConfigProperty(*valueTree, nameElements, it.value()); + } +} + +QVariantMap SetupProjectParameters::overriddenValuesTree() const +{ + provideValuesTree(d->overriddenValues, &d->overriddenValuesTree); + return d->overriddenValuesTree; +} + +/*! + * \brief Returns the build configuration. + * Overridden values are not taken into account. + */ +QVariantMap SetupProjectParameters::buildConfiguration() const +{ + return d->buildConfiguration; +} + +/*! + * \brief Returns the build configuration in tree form. + * Overridden values are not taken into account. + */ +QVariantMap SetupProjectParameters::buildConfigurationTree() const +{ + provideValuesTree(d->buildConfiguration, &d->buildConfigurationTree); + return d->buildConfigurationTree; +} + +static QVariantMap expandedBuildConfigurationInternal(const Profile &profile, + const QString &configurationName) +{ + QVariantMap buildConfig; + + // (1) Values from profile, if given. + if (profile.exists() && profile.name() != Profile::fallbackName()) { + ErrorInfo err; + const QStringList profileKeys = profile.allKeys(Profile::KeySelectionRecursive, &err); + if (err.hasError()) + throw err; + if (profileKeys.empty()) + throw ErrorInfo(Internal::Tr::tr("Unknown or empty profile '%1'.").arg(profile.name())); + for (const QString &profileKey : profileKeys) { + buildConfig.insert(profileKey, profile.value(profileKey, QVariant(), &err)); + if (err.hasError()) + throw err; + } + } + + // (2) Build configuration name. + if (configurationName.isEmpty()) + throw ErrorInfo(Internal::Tr::tr("No build configuration name set.")); + buildConfig.insert(QStringLiteral("qbs.configurationName"), configurationName); + return buildConfig; +} + + +QVariantMap SetupProjectParameters::expandedBuildConfiguration(const Profile &profile, + const QString &configurationName, ErrorInfo *errorInfo) +{ + try { + return expandedBuildConfigurationInternal(profile, configurationName); + } catch (const ErrorInfo &err) { + if (errorInfo) + *errorInfo = err; + return {}; + } +} + + +/*! + * \brief Expands the build configuration. + * + * Expansion is the process by which the build configuration is completed based on the settings + * in \c settingsDirectory(). E.g. the information configured in a profile is filled into the build + * configuration by this step. + * + * This method returns an Error. The list of entries in this error will be empty is the + * expansion was successful. + */ +ErrorInfo SetupProjectParameters::expandBuildConfiguration() +{ + ErrorInfo err; + Settings settings(d->settingsBaseDir); + Profile profile(topLevelProfile(), &settings); + QVariantMap expandedConfig = expandedBuildConfiguration(profile, configurationName(), &err); + if (err.hasError()) + return err; + if (d->buildConfiguration != expandedConfig) { + d->buildConfigurationTree.clear(); + d->buildConfiguration = expandedConfig; + } + return err; +} + +QVariantMap SetupProjectParameters::finalBuildConfigurationTree(const QVariantMap &buildConfig, + const QVariantMap &overriddenValues) +{ + QVariantMap flatBuildConfig = buildConfig; + for (QVariantMap::ConstIterator it = overriddenValues.constBegin(); + it != overriddenValues.constEnd(); ++it) { + flatBuildConfig.insert(it.key(), it.value()); + } + + QVariantMap buildConfigTree; + provideValuesTree(flatBuildConfig, &buildConfigTree); + return buildConfigTree; +} + +/*! + * \brief Returns the build configuration in tree form, with overridden values taken into account. + */ +QVariantMap SetupProjectParameters::finalBuildConfigurationTree() const +{ + if (d->finalBuildConfigTree.empty()) { + d->finalBuildConfigTree = finalBuildConfigurationTree(buildConfiguration(), + overriddenValues()); + } + return d->finalBuildConfigTree; +} + + /*! + * \brief if true, qbs will not store the build graph of the resolved project. + */ +bool SetupProjectParameters::dryRun() const +{ + return d->dryRun; +} + + /*! + * \brief Controls whether the build graph will be stored. + * If the argument is true, qbs will not store the build graph after resolving the project. + * The default is false. + */ +void SetupProjectParameters::setDryRun(bool dryRun) +{ + d->dryRun = dryRun; +} + + /*! + * \brief Returns true iff the time the operation takes should be logged + */ +bool SetupProjectParameters::logElapsedTime() const +{ + return d->logElapsedTime; +} + +/*! + * Controls whether to log the time taken up for resolving the project. + * The default is false. + */ +void SetupProjectParameters::setLogElapsedTime(bool logElapsedTime) +{ + d->logElapsedTime = logElapsedTime; +} + + +/*! + * \brief Returns true iff probes should be re-run. + */ +bool SetupProjectParameters::forceProbeExecution() const +{ + return d->forceProbeExecution; +} + +/*! + * Controls whether to re-run probes even if they do not appear to be outdated. + * This option only has an effect if \c restoreBehavior() is \c RestoreAndTrackChanges. + */ +void SetupProjectParameters::setForceProbeExecution(bool force) +{ + d->forceProbeExecution = force; +} + +/*! + * \brief Returns true if qbs should wait for the build graph lock to become available, + * otherwise qbs will exit immediately if the lock cannot be acquired. + */ +bool SetupProjectParameters::waitLockBuildGraph() const +{ + return d->waitLockBuildGraph; +} + +/*! + * Controls whether to wait indefinitely for the build graph lock to be released. + * This allows multiple conflicting qbs processes to be spawned simultaneously. + */ +void SetupProjectParameters::setWaitLockBuildGraph(bool wait) +{ + d->waitLockBuildGraph = wait; +} + +/*! + * \brief Returns true if qbs should fall back to pkg-config if a dependency is not found. + */ +bool SetupProjectParameters::fallbackProviderEnabled() const +{ + return d->fallbackProviderEnabled; +} + +/*! + * Controls whether to fall back to pkg-config if a dependency is not found. + */ +void SetupProjectParameters::setFallbackProviderEnabled(bool enable) +{ + d->fallbackProviderEnabled = enable; +} + +/*! + * \brief Gets the environment used while resolving the project. + */ +QProcessEnvironment SetupProjectParameters::environment() const +{ + return d->environment; +} + +/*! + * \brief Sets the environment used while resolving the project. + */ +void SetupProjectParameters::setEnvironment(const QProcessEnvironment &env) +{ + d->environment = env; +} + +QProcessEnvironment SetupProjectParameters::adjustedEnvironment() const +{ + QProcessEnvironment result = environment(); + const QVariantMap environmentFromProfile + = buildConfigurationTree().value(QStringLiteral("buildEnvironment")).toMap(); + for (QVariantMap::const_iterator it = environmentFromProfile.begin(); + it != environmentFromProfile.end(); ++it) { + result.insert(it.key(), it.value().toString()); + } + return result; +} + + +/*! + * \enum SetupProjectParamaters::RestoreBehavior + * This enum type specifies how to deal with existing on-disk build information. + * \value RestoreOnly Indicates that a stored build graph is to be loaded and the information + * therein assumed to be up to date. It is then considered an error if no + * such build graph exists. + * \value ResolveOnly Indicates that no attempt should be made to restore an existing build graph. + * Instead, the project is to be resolved from scratch. + * \value RestoreAndTrackChanges Indicates that the build graph should be restored from disk + * if possible and otherwise set up from scratch. In the first case, + * (parts of) the project might still be re-resolved if certain + * parameters have changed (e.g. environment variables used in the + * project files). + */ + + +/*! + * Returns information about how restored build data will be handled. + */ +SetupProjectParameters::RestoreBehavior SetupProjectParameters::restoreBehavior() const +{ + return d->restoreBehavior; +} + +/*! + * Controls how restored build data will be handled. + */ +void SetupProjectParameters::setRestoreBehavior(SetupProjectParameters::RestoreBehavior behavior) +{ + d->restoreBehavior = behavior; +} + +/*! + * Returns true if and only if environment, project file path and overridden property values + * should be taken from this object even if a build graph already exists. + * If this function returns \c false and a build graph exists, then it is an error to provide a + * project file path or overridden property values that differ from the respective values + * in the build graph. + */ +bool SetupProjectParameters::overrideBuildGraphData() const +{ + return d->overrideBuildGraphData; +} + +/*! + * If \c doOverride is true, then environment, project file path and overridden property values + * are taken from this object rather than from the build graph. + * The default is \c false. + */ +void SetupProjectParameters::setOverrideBuildGraphData(bool doOverride) +{ + d->overrideBuildGraphData = doOverride; +} + +/*! + * \enum ErrorHandlingMode + * This enum type specifies how \QBS should behave if errors occur during project resolving. + * \value ErrorHandlingMode::Strict Project resolving will stop with an error message. + * \value ErrorHandlingMode::Relaxed Project resolving will continue (if possible), and a warning + * will be printed. + */ + +/*! + * Indicates how to handle unknown properties. + */ +ErrorHandlingMode SetupProjectParameters::propertyCheckingMode() const +{ + return d->propertyCheckingMode; +} + +/*! + * Controls how to handle unknown properties. + * The default is \c PropertyCheckingRelaxed. + */ +void SetupProjectParameters::setPropertyCheckingMode(ErrorHandlingMode mode) +{ + d->propertyCheckingMode = mode; +} + +/*! + * \brief Indicates how errors occurring during product resolving are handled. + */ +ErrorHandlingMode SetupProjectParameters::productErrorMode() const +{ + return d->productErrorMode; +} + +/*! + * \brief Specifies whether an error occurring during product resolving should be fatal or not. + * \note Not all errors can be ignored; this setting is mainly intended for things such as + * missing dependencies or references to non-existing source files. + */ +void SetupProjectParameters::setProductErrorMode(ErrorHandlingMode mode) +{ + d->productErrorMode = mode; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/setupprojectparameters.h b/src/lib/corelib/tools/setupprojectparameters.h new file mode 100644 index 00000000..2617a34c --- /dev/null +++ b/src/lib/corelib/tools/setupprojectparameters.h @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_SETUPPROJECTPARAMETERS_H +#define QBS_SETUPPROJECTPARAMETERS_H + +#include "qbs_export.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QProcessEnvironment; +using QVariantMap = QMap; +QT_END_NAMESPACE + +namespace qbs { + +class Profile; +class Settings; + +namespace Internal { class SetupProjectParametersPrivate; } + +enum class ErrorHandlingMode { Strict, Relaxed }; + +class QBS_EXPORT SetupProjectParameters +{ +public: + SetupProjectParameters(); + SetupProjectParameters(const SetupProjectParameters &other); + SetupProjectParameters(SetupProjectParameters &&other) Q_DECL_NOEXCEPT; + ~SetupProjectParameters(); + + SetupProjectParameters &operator=(const SetupProjectParameters &other); + SetupProjectParameters &operator=(SetupProjectParameters &&other) Q_DECL_NOEXCEPT; + + static SetupProjectParameters fromJson(const QJsonObject &data); + + QString topLevelProfile() const; + void setTopLevelProfile(const QString &profile); + + QString configurationName() const; + void setConfigurationName(const QString &configurationName); + + QString projectFilePath() const; + void setProjectFilePath(const QString &projectFilePath); + + QString buildRoot() const; + void setBuildRoot(const QString &buildRoot); + + QStringList searchPaths() const; + void setSearchPaths(const QStringList &searchPaths); + + QStringList pluginPaths() const; + void setPluginPaths(const QStringList &pluginPaths); + + QString libexecPath() const; + void setLibexecPath(const QString &libexecPath); + + QString settingsDirectory() const; + void setSettingsDirectory(const QString &settingsBaseDir); + + QVariantMap overriddenValues() const; + void setOverriddenValues(const QVariantMap &values); + QVariantMap overriddenValuesTree() const; + + static QVariantMap expandedBuildConfiguration(const Profile &profile, + const QString &configurationName, + ErrorInfo *errorInfo = nullptr); + ErrorInfo expandBuildConfiguration(); + QVariantMap buildConfiguration() const; + QVariantMap buildConfigurationTree() const; + + static QVariantMap finalBuildConfigurationTree(const QVariantMap &buildConfig, + const QVariantMap &overriddenValues); + QVariantMap finalBuildConfigurationTree() const; + + bool overrideBuildGraphData() const; + void setOverrideBuildGraphData(bool doOverride); + + bool dryRun() const; + void setDryRun(bool dryRun); + + bool logElapsedTime() const; + void setLogElapsedTime(bool logElapsedTime); + + bool forceProbeExecution() const; + void setForceProbeExecution(bool force); + + bool waitLockBuildGraph() const; + void setWaitLockBuildGraph(bool wait); + + bool fallbackProviderEnabled() const; + void setFallbackProviderEnabled(bool enable); + + QProcessEnvironment environment() const; + void setEnvironment(const QProcessEnvironment &env); + QProcessEnvironment adjustedEnvironment() const; + + enum RestoreBehavior { RestoreOnly, ResolveOnly, RestoreAndTrackChanges }; + RestoreBehavior restoreBehavior() const; + void setRestoreBehavior(RestoreBehavior behavior); + + ErrorHandlingMode propertyCheckingMode() const; + void setPropertyCheckingMode(ErrorHandlingMode mode); + + ErrorHandlingMode productErrorMode() const; + void setProductErrorMode(ErrorHandlingMode mode); + +private: + QSharedDataPointer d; +}; + +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/shellutils.cpp b/src/lib/corelib/tools/shellutils.cpp new file mode 100644 index 00000000..d032aeca --- /dev/null +++ b/src/lib/corelib/tools/shellutils.cpp @@ -0,0 +1,262 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "shellutils.h" + +#include "pathutils.h" +#include "qttools.h" + +#include +#include +#include + +namespace qbs { +namespace Internal { + +QString shellInterpreter(const QString &filePath) { + QFile file(filePath); + if (file.open(QIODevice::ReadOnly)) { + QTextStream ts(&file); + const QString shebang = ts.readLine(); + if (shebang.startsWith(QLatin1String("#!"))) { + return (shebang.mid(2).split(QRegularExpression(QStringLiteral("\\s")), + QBS_SKIP_EMPTY_PARTS) << QString()).front(); + } + } + + return {}; +} + +// isSpecialChar, hasSpecialChars, shellQuoteUnix, shellQuoteWin: +// all from qtbase/qmake/library/ioutils.cpp + +inline static bool isSpecialChar(ushort c, const uchar (&iqm)[16]) +{ + return (c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7))); +} + +inline static bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16]) +{ + for (auto it = arg.crbegin(), end = arg.crend(); it != end; ++it) { + if (isSpecialChar(it->unicode(), iqm)) + return true; + } + return false; +} + +static QString shellQuoteUnix(const QString &arg) +{ + // Chars that should be quoted (TM). This includes: + static const uchar iqm[] = { + 0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8, + 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78 + }; // 0-32 \'"$`<>|;&(){}*?#!~[] + + if (!arg.length()) + return QStringLiteral("''"); + + QString ret(arg); + if (hasSpecialChars(ret, iqm)) { + ret.replace(QLatin1Char('\''), QLatin1String("'\\''")); + ret.prepend(QLatin1Char('\'')); + ret.append(QLatin1Char('\'')); + } + return ret; +} + +static QString shellQuoteWin(const QString &arg) +{ + // Chars that should be quoted (TM). This includes: + // - control chars & space + // - the shell meta chars "&()<>^| + // - the potential separators ,;= + static const uchar iqm[] = { + 0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 + }; + // Shell meta chars that need escaping. + static const uchar ism[] = { + 0x00, 0x00, 0x00, 0x00, 0x40, 0x03, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 + }; // &()<>^| + + if (!arg.length()) + return QStringLiteral("\"\""); + + QString ret(arg); + if (hasSpecialChars(ret, iqm)) { + // The process-level standard quoting allows escaping quotes with backslashes (note + // that backslashes don't escape themselves, unless they are followed by a quote). + // Consequently, quotes are escaped and their preceding backslashes are doubled. + ret.replace(QRegularExpression(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\"")); + // Trailing backslashes must be doubled as well, as they are followed by a quote. + ret.replace(QRegularExpression(QLatin1String("(\\\\+)$")), QLatin1String("\\1\\1")); + // However, the shell also interprets the command, and no backslash-escaping exists + // there - a quote always toggles the quoting state, but is nonetheless passed down + // to the called process verbatim. In the unquoted state, the circumflex escapes + // meta chars (including itself and quotes), and is removed from the command. + bool quoted = true; + for (int i = 0; i < ret.length(); i++) { + QChar c = ret.unicode()[i]; + if (c.unicode() == '"') + quoted = !quoted; + else if (!quoted && isSpecialChar(c.unicode(), ism)) + ret.insert(i++, QLatin1Char('^')); + } + if (!quoted) + ret.append(QLatin1Char('^')); + ret.append(QLatin1Char('"')); + ret.prepend(QLatin1Char('"')); + } + return ret; +} + +QString shellQuote(const QString &arg, HostOsInfo::HostOs os) +{ + return os == HostOsInfo::HostOsWindows ? shellQuoteWin(arg) : shellQuoteUnix(arg); +} + +std::string shellQuote(const std::string &arg, HostOsInfo::HostOs os) +{ + return shellQuote(QString::fromStdString(arg), os).toStdString(); +} + +QString shellQuote(const QStringList &args, HostOsInfo::HostOs os) +{ + QString result; + if (!args.empty()) { + result += shellQuote(args.at(0), os); + for (int i = 1; i < args.size(); ++i) + result += QLatin1Char(' ') + shellQuote(args.at(i), os); + } + return result; +} + +std::string shellQuote(const std::vector &args, HostOsInfo::HostOs os) +{ + std::string result; + if (!args.empty()) { + auto it = args.cbegin(); + const auto end = args.cend(); + result += shellQuote(*it++, os); + for (; it != end; ++it) { + result.push_back(' '); + result.append(shellQuote(*it, os)); + } + } + return result; +} + +QString shellQuote(const QString &program, const QStringList &args, HostOsInfo::HostOs os) +{ + QString result = shellQuote(program, os); + if (!args.empty()) + result += QLatin1Char(' ') + shellQuote(args, os); + return result; +} + +void CommandLine::setProgram(const QString &program, bool raw) +{ + m_program = program; + m_isRawProgram = raw; +} + +void CommandLine::setProgram(const std::string &program, bool raw) +{ + m_program = QString::fromStdString(program); + m_isRawProgram = raw; +} + +void CommandLine::appendArgument(const QString &value) +{ + m_arguments.emplace_back(value); +} + +void CommandLine::appendArgument(const std::string &value) +{ + m_arguments.emplace_back(QString::fromStdString(value)); +} + +void CommandLine::appendArguments(const QList &args) +{ + for (const QString &arg : args) + appendArgument(arg); +} + +void CommandLine::appendRawArgument(const QString &value) +{ + Argument arg(value); + arg.shouldQuote = false; + m_arguments.push_back(arg); +} + +void CommandLine::appendRawArgument(const std::string &value) +{ + appendRawArgument(QString::fromStdString(value)); +} + +void CommandLine::appendPathArgument(const QString &value) +{ + Argument arg(value); + arg.isFilePath = true; + m_arguments.push_back(arg); +} + +void CommandLine::clearArguments() +{ + m_arguments.clear(); +} + +QString CommandLine::toCommandLine(HostOsInfo::HostOs os) const +{ + QString result = PathUtils::toNativeSeparators(m_program, os); + if (!m_isRawProgram) + result = shellQuote(result, os); + for (const Argument &arg : m_arguments) { + const QString value = arg.isFilePath + ? PathUtils::toNativeSeparators(arg.value, os) + : arg.value; + result += QLatin1Char(' ') + (arg.shouldQuote ? shellQuote(value, os) : value); + } + return result; +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/shellutils.h b/src/lib/corelib/tools/shellutils.h new file mode 100644 index 00000000..f4ad3504 --- /dev/null +++ b/src/lib/corelib/tools/shellutils.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Petroules Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_SHELLUTILS_H +#define QBS_SHELLUTILS_H + +#include "qbs_export.h" +#include "hostosinfo.h" +#include + +#include + +namespace qbs { +namespace Internal { + +QBS_EXPORT QString shellInterpreter(const QString &filePath); +QBS_EXPORT std::string shellQuote(const std::string &arg, HostOsInfo::HostOs os = HostOsInfo::hostOs()); +QBS_EXPORT QString shellQuote(const QString &arg, HostOsInfo::HostOs os = HostOsInfo::hostOs()); +QBS_EXPORT QString shellQuote(const QStringList &args, + HostOsInfo::HostOs os = HostOsInfo::hostOs()); +QBS_EXPORT std::string shellQuote(const std::vector &args, + HostOsInfo::HostOs os = HostOsInfo::hostOs()); +QBS_EXPORT QString shellQuote(const QString &program, const QStringList &args, + HostOsInfo::HostOs os = HostOsInfo::hostOs()); + +class QBS_EXPORT CommandLine +{ +public: + void setProgram(const QString &program, bool raw = false); + void setProgram(const std::string &program, bool raw = false); + void appendArgument(const QString &value); + void appendArgument(const std::string &value); + void appendArguments(const QList &args); + void appendRawArgument(const QString &value); + void appendRawArgument(const std::string &value); + void appendPathArgument(const QString &value); + void clearArguments(); + QString toCommandLine(HostOsInfo::HostOs os = HostOsInfo::hostOs()) const; + +private: + struct Argument + { + Argument(QString value = QString()) : value(std::move(value)) { } + QString value; + bool isFilePath = false; + bool shouldQuote = true; + }; + + bool m_isRawProgram = false; + QString m_program; + std::vector m_arguments; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_SHELLUTILS_H diff --git a/src/lib/corelib/tools/stlutils.h b/src/lib/corelib/tools/stlutils.h new file mode 100644 index 00000000..70e3f2b6 --- /dev/null +++ b/src/lib/corelib/tools/stlutils.h @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_STLUTILS_H +#define QBS_STLUTILS_H + +#include +#include + +namespace qbs { +namespace Internal { + +template +C sorted(const C &container) +{ + C result = container; + std::sort(std::begin(result), std::end(result)); + return result; +} + +template +To transformed(const From &from, Op op) +{ + To to; + to.reserve(int(from.size())); + std::transform(std::cbegin(from), std::cend(from), std::back_inserter(to), std::move(op)); + return to; +} + +template +void transform(C &&container, Op op) +{ + std::transform(std::begin(container), std::end(container), std::begin(container), + std::move(op)); +} + +template +void transform(const From &from, To &&to, Op op) +{ + std::transform(std::cbegin(from), std::cend(from), std::back_inserter(to), std::move(op)); +} + +template +bool contains(const C &container, const T &v) +{ + const auto &end = std::cend(container); + return std::find(std::cbegin(container), end, v) != end; +} + +template +bool contains(const T (&container)[N], const U &v) +{ + const auto &end = std::cend(container); + return std::find(std::cbegin(container), end, v) != end; +} + +template +bool containsKey(const C &container, const typename C::key_type &v) +{ + const auto &end = container.cend(); + return container.find(v) != end; +} + +template +typename C::mapped_type mapValue( + const C &container, + const typename C::key_type &key, + const typename C::mapped_type &value = typename C::mapped_type()) +{ + const auto end = container.cend(); + const auto it = container.find(key); + return it != end ? it->second : value; +} + +template +bool removeOne(C &container, const typename C::value_type &v) +{ + auto end = std::end(container); + auto it = std::find(std::begin(container), end, v); + if (it == end) + return false; + container.erase(it); + return true; +} + +template +void removeAll(C &container, const typename C::value_type &v) +{ + container.erase(std::remove(std::begin(container), std::end(container), v), + std::end(container)); +} + +template +void removeIf(C &container, const Pred &pred) +{ + container.erase(std::remove_if(std::begin(container), std::end(container), pred), + std::end(container)); +} + +template +bool any_of(const Container &container, const UnaryPredicate &predicate) +{ + return std::any_of(std::begin(container), std::end(container), predicate); +} + +template +bool all_of(const Container &container, const UnaryPredicate &predicate) +{ + return std::all_of(std::begin(container), std::end(container), predicate); +} + +template +bool none_of(const Container &container, const UnaryPredicate &predicate) +{ + return std::none_of(std::begin(container), std::end(container), predicate); +} + +template +It binaryFind(It begin, It end, const T &value, Compare comp) +{ + const auto it = std::lower_bound(begin, end, value, comp); + if (it == end || comp(value, *it)) + return end; + return it; +} + +template +It binaryFind(It begin, It end, const T &value) +{ + return binaryFind(begin, end, value, std::less()); +} + +template +C &operator<<(C &container, const typename C::value_type &v) +{ + container.push_back(v); + return container; +} + +template +C &operator<<(C &container, const C &other) +{ + container.insert(container.end(), other.cbegin(), other.cend()); + return container; +} + +// based on http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0814r0.pdf +template +void hashCombineHelper(size_t &seed, const T &val) +{ + seed ^= std::hash()(val) + 0x9e3779b9 + (seed << 6) + (seed >> 2); +} + +template +size_t hashCombine(const Types &... args) +{ + size_t seed = 0; + (hashCombineHelper(seed, args), ...); // create hash value with seed over all args return seed; + return seed; +} + +template +size_t hashRange(It first, It last) +{ + size_t seed = 0; + for (; first != last; ++first) + hashCombineHelper(seed, *first); + + return seed; +} + +template +size_t hashRange(R &&range) +{ + return hashRange(std::begin(range), std::end(range)); +} + +// based on qcontainertools_impl.h +template +using IfIsForwardIterator_t = typename std::enable_if_t< + std::is_convertible_v< + typename std::iterator_traits::iterator_category, std::forward_iterator_tag>, + bool>; + +template +using IfIsNotForwardIterator = typename std::enable_if_t< + !std::is_convertible_v< + typename std::iterator_traits::iterator_category, std::forward_iterator_tag>, + bool>; + +template = true> +void reserveIfForwardIterator(Container *, InputIterator, InputIterator) +{ +} + +template = true> +void reserveIfForwardIterator(Container *c, ForwardIterator f, ForwardIterator l) +{ + c->reserve(static_cast(std::distance(f, l))); +} + +// similar to ranges::to proposal +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1206r1.pdf +template +C rangeTo(R &&r) +{ + return C(std::begin(r), std::end(r)); +} + +template +constexpr std::underlying_type_t toUnderlying(Enum e) noexcept +{ + return static_cast>(e); +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_STLUTILS_H diff --git a/src/lib/corelib/tools/stringconstants.h b/src/lib/corelib/tools/stringconstants.h new file mode 100644 index 00000000..f40bfa4a --- /dev/null +++ b/src/lib/corelib/tools/stringconstants.h @@ -0,0 +1,262 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_STRINGCONSTANTS_H +#define QBS_STRINGCONSTANTS_H + +#include + +#define QBS_CONSTANT(type, name, value) \ + static const type &name() { \ + static const type var{QLatin1String(value)}; \ + return var; \ + } +#define QBS_STRING_CONSTANT(name, value) QBS_CONSTANT(QString, name, value) +#define QBS_STRINGLIST_CONSTANT(name, value) QBS_CONSTANT(QStringList, name, value) + +namespace qbs { +namespace Internal { + +class StringConstants +{ +public: + static const QString &cppModule() { return cpp(); } + static const QString &qbsModule() { return qbs(); } + + QBS_STRING_CONSTANT(aggregateProperty, "aggregate") + QBS_STRING_CONSTANT(additionalProductTypesProperty, "additionalProductTypes") + QBS_STRING_CONSTANT(allowedValuesProperty, "allowedValues") + QBS_STRING_CONSTANT(alwaysUpdatedProperty, "alwaysUpdated") + QBS_STRING_CONSTANT(alwaysRunProperty, "alwaysRun") + QBS_STRING_CONSTANT(artifactsProperty, "artifacts") + QBS_STRING_CONSTANT(auxiliaryInputsProperty, "auxiliaryInputs") + QBS_STRING_CONSTANT(baseNameProperty, "baseName") + QBS_STRING_CONSTANT(baseProfileProperty, "baseProfile") + QBS_STRING_CONSTANT(buildDirectoryProperty, "buildDirectory") + QBS_STRING_CONSTANT(buildDirectoryKey, "build-directory") + QBS_STRING_CONSTANT(builtByDefaultProperty, "builtByDefault") + QBS_STRING_CONSTANT(classNameProperty, "className") + QBS_STRING_CONSTANT(completeBaseNameProperty, "completeBaseName") + QBS_STRING_CONSTANT(conditionProperty, "condition") + QBS_STRING_CONSTANT(configurationNameProperty, "configurationName") + QBS_STRING_CONSTANT(configureProperty, "configure") + QBS_STRING_CONSTANT(consoleApplicationProperty, "consoleApplication") + QBS_STRING_CONSTANT(dependenciesProperty, "dependencies") + QBS_STRING_CONSTANT(descriptionProperty, "description") + QBS_STRING_CONSTANT(destinationDirProperty, "destinationDirectory") + QBS_STRING_CONSTANT(excludeFilesProperty, "excludeFiles") + QBS_STRING_CONSTANT(excludedAuxiliaryInputsProperty, "excludedAuxiliaryInputs") + QBS_STRING_CONSTANT(excludedInputsProperty, "excludedInputs") + static const QString &explicitlyDependsOnProperty() { return explicitlyDependsOn(); } + static const QString &explicitlyDependsOnFromDependenciesProperty() { + return explicitlyDependsOnFromDependencies(); + } + QBS_STRING_CONSTANT(enableFallbackProperty, "enableFallback") + static const QString &fileNameProperty() { return fileName(); } + static const QString &filePathProperty() { return filePath(); } + static const QString &filePathVar() { return filePath(); } + QBS_STRING_CONSTANT(filePathKey, "file-path") + QBS_STRING_CONSTANT(fileTagsFilterProperty, "fileTagsFilter") + QBS_STRING_CONSTANT(fileTagsProperty, "fileTags") + QBS_STRING_CONSTANT(filesProperty, "files") + QBS_STRING_CONSTANT(filesAreTargetsProperty, "filesAreTargets") + QBS_STRING_CONSTANT(foundProperty, "found") + QBS_STRING_CONSTANT(fullDisplayNameKey, "full-display-name") + QBS_STRING_CONSTANT(imports, "imports") + static const QString &importsDir() { return imports(); } + static const QString &importsProperty() { return imports(); } + QBS_STRING_CONSTANT(inheritPropertiesProperty, "inheritProperties") + static const QString &inputsProperty() { return inputs(); } + QBS_STRING_CONSTANT(inputsFromDependenciesProperty, "inputsFromDependencies") + static const QString &installProperty() { return install(); } + QBS_STRING_CONSTANT(installRootProperty, "installRoot") + QBS_STRING_CONSTANT(installPrefixProperty, "installPrefix") + QBS_STRING_CONSTANT(installDirProperty, "installDir") + QBS_STRING_CONSTANT(installSourceBaseProperty, "installSourceBase") + QBS_STRING_CONSTANT(isEnabledKey, "is-enabled") + QBS_STRING_CONSTANT(jobCountProperty, "jobCount") + QBS_STRING_CONSTANT(jobPoolProperty, "jobPool") + QBS_STRING_CONSTANT(lengthProperty, "length") + QBS_STRING_CONSTANT(limitToSubProjectProperty, "limitToSubProject") + QBS_STRING_CONSTANT(locationKey, "location") + QBS_STRING_CONSTANT(messageKey, "message") + QBS_STRING_CONSTANT(minimumQbsVersionProperty, "minimumQbsVersion") + QBS_STRING_CONSTANT(moduleNameProperty, "moduleName") + QBS_STRING_CONSTANT(modulePropertiesKey, "module-properties") + QBS_STRING_CONSTANT(moduleProviders, "moduleProviders") + QBS_STRING_CONSTANT(multiplexByQbsPropertiesProperty, "multiplexByQbsProperties") + QBS_STRING_CONSTANT(multiplexConfigurationIdProperty, "multiplexConfigurationId") + QBS_STRING_CONSTANT(multiplexConfigurationIdsProperty, "multiplexConfigurationIds") + QBS_STRING_CONSTANT(multiplexProperty, "multiplex") + QBS_STRING_CONSTANT(multiplexedProperty, "multiplexed") + QBS_STRING_CONSTANT(multiplexedTypeProperty, "multiplexedType") + QBS_STRING_CONSTANT(nameProperty, "name") + QBS_STRING_CONSTANT(outputArtifactsProperty, "outputArtifacts") + QBS_STRING_CONSTANT(outputFileTagsProperty, "outputFileTags") + QBS_STRING_CONSTANT(overrideTagsProperty, "overrideTags") + QBS_STRING_CONSTANT(overrideListPropertiesProperty, "overrideListProperties") + QBS_STRING_CONSTANT(parametersProperty, "parameters") + static const QString &pathProperty() { return path(); } + QBS_STRING_CONSTANT(patternsProperty, "patterns") + QBS_STRING_CONSTANT(prefixMappingProperty, "prefixMapping") + QBS_STRING_CONSTANT(prefixProperty, "prefix") + QBS_STRING_CONSTANT(prepareProperty, "prepare") + QBS_STRING_CONSTANT(presentProperty, "present") + QBS_STRING_CONSTANT(priorityProperty, "priority") + QBS_STRING_CONSTANT(profileProperty, "profile") + static const QString &profilesProperty() { return profiles(); } + QBS_STRING_CONSTANT(productTypesProperty, "productTypes") + QBS_STRING_CONSTANT(productsKey, "products") + QBS_STRING_CONSTANT(qbsModuleProviders, "qbsModuleProviders") + QBS_STRING_CONSTANT(qbsSearchPathsProperty, "qbsSearchPaths") + QBS_STRING_CONSTANT(referencesProperty, "references") + QBS_STRING_CONSTANT(recursiveProperty, "recursive") + QBS_STRING_CONSTANT(requiredProperty, "required") + QBS_STRING_CONSTANT(requiresInputsProperty, "requiresInputs") + QBS_STRING_CONSTANT(removalVersionProperty, "removalVersion") + QBS_STRING_CONSTANT(scanProperty, "scan") + QBS_STRING_CONSTANT(searchPathsProperty, "searchPaths") + QBS_STRING_CONSTANT(setupBuildEnvironmentProperty, "setupBuildEnvironment") + QBS_STRING_CONSTANT(setupRunEnvironmentProperty, "setupRunEnvironment") + QBS_STRING_CONSTANT(shadowProductPrefix, "__shadow__") + QBS_STRING_CONSTANT(sourceCodeProperty, "sourceCode") + QBS_STRING_CONSTANT(sourceDirectoryProperty, "sourceDirectory") + QBS_STRING_CONSTANT(submodulesProperty, "submodules") + QBS_STRING_CONSTANT(targetNameProperty, "targetName") + static const QString &typeProperty() { return type(); } + QBS_STRING_CONSTANT(type, "type") + QBS_STRING_CONSTANT(validateProperty, "validate") + QBS_STRING_CONSTANT(versionProperty, "version") + QBS_STRING_CONSTANT(versionAtLeastProperty, "versionAtLeast") + QBS_STRING_CONSTANT(versionBelowProperty, "versionBelow") + + QBS_STRING_CONSTANT(importScopeNamePropertyInternal, "_qbs_importScopeName") + QBS_STRING_CONSTANT(modulePropertyInternal, "__module") + QBS_STRING_CONSTANT(qbsSourceDirPropertyInternal, "_qbs_sourceDir") + static const char *qbsProcEnvVarInternal() { return "_qbs_procenv"; } + + static const QString &projectPrefix() { return project(); } + static const QString &productValue() { return product(); } + + QBS_STRING_CONSTANT(projectsOverridePrefix, "projects.") + QBS_STRING_CONSTANT(productsOverridePrefix, "products.") + + QBS_STRING_CONSTANT(baseVar, "base") + static const QString &explicitlyDependsOnVar() { return explicitlyDependsOn(); } + QBS_STRING_CONSTANT(inputVar, "input") + static const QString &inputsVar() { return inputs(); } + QBS_STRING_CONSTANT(originalVar, "original") + QBS_STRING_CONSTANT(outerVar, "outer") + QBS_STRING_CONSTANT(outputVar, "output") + QBS_STRING_CONSTANT(outputsVar, "outputs") + static const QString &productVar() { return product(); } + static const QString &projectVar() { return project(); } + + static const QString &filePathGlobalVar() { return filePath(); } + static const QString &pathGlobalVar() { return path(); } + + static const QString &pathType() { return path(); } + + static const QString &fileInfoFileName() { return fileName(); } + static const QString &fileInfoPath() { return path(); } + + static const QString &androidInstallCommand() { return install(); } + static const QString &simctlInstallCommand() { return install(); } + + static const QString &profilesSettingsKey() { return profiles(); } + + QBS_STRING_CONSTANT(emptyArrayValue, "[]") + QBS_STRING_CONSTANT(falseValue, "false") + QBS_STRING_CONSTANT(trueValue, "true") + QBS_STRING_CONSTANT(undefinedValue, "undefined") + + QBS_STRING_CONSTANT(javaScriptCommandType, "JavaScriptCommand") + QBS_STRING_CONSTANT(commandType, "Command") + + QBS_STRING_CONSTANT(pathEnvVar, "PATH") + + QBS_STRING_CONSTANT(dot, ".") + QBS_STRING_CONSTANT(dotDot, "..") + QBS_STRING_CONSTANT(slashDotDot, "/..") + QBS_STRING_CONSTANT(star, "*") + QBS_STRING_CONSTANT(tildeSlash, "~/") + + QBS_STRINGLIST_CONSTANT(qbsFileWildcards, "*.qbs") + QBS_STRINGLIST_CONSTANT(jsFileWildcards, "*.js") + + static const QString &cppLang() { return cpp(); } + + QBS_STRING_CONSTANT(xcode, "xcode") + + QBS_STRING_CONSTANT(aarch64Arch, "aarch64") + QBS_STRING_CONSTANT(amd64Arch, "amd64") + QBS_STRING_CONSTANT(armArch, "arm") + QBS_STRING_CONSTANT(arm64Arch, "arm64") + QBS_STRING_CONSTANT(armv7Arch, "armv7") + QBS_STRING_CONSTANT(i386Arch, "i386") + QBS_STRING_CONSTANT(i586Arch, "i586") + QBS_STRING_CONSTANT(mipsArch, "mips") + QBS_STRING_CONSTANT(mips64Arch, "mips64") + QBS_STRING_CONSTANT(powerPcArch, "powerpc") + QBS_STRING_CONSTANT(ppcArch, "ppc") + QBS_STRING_CONSTANT(ppc64Arch, "ppc64") + QBS_STRING_CONSTANT(x86Arch, "x86") + QBS_STRING_CONSTANT(x86_64Arch, "x86_64") + + QBS_STRING_CONSTANT(profilesSettingsPrefix, "profiles.") + +private: + QBS_STRING_CONSTANT(cpp, "cpp") + QBS_STRING_CONSTANT(explicitlyDependsOn, "explicitlyDependsOn") + QBS_STRING_CONSTANT(explicitlyDependsOnFromDependencies, "explicitlyDependsOnFromDependencies") + QBS_STRING_CONSTANT(fileName, "fileName") + QBS_STRING_CONSTANT(filePath, "filePath") + QBS_STRING_CONSTANT(inputs, "inputs") + QBS_STRING_CONSTANT(install, "install") + QBS_STRING_CONSTANT(path, "path") + QBS_STRING_CONSTANT(product, "product") + QBS_STRING_CONSTANT(profiles, "profiles") + QBS_STRING_CONSTANT(project, "project") + QBS_STRING_CONSTANT(qbs, "qbs") +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/lib/corelib/tools/stringutils.h b/src/lib/corelib/tools/stringutils.h new file mode 100644 index 00000000..59acdccb --- /dev/null +++ b/src/lib/corelib/tools/stringutils.h @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_STRINGUTILS_H +#define QBS_STRINGUTILS_H + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +template +typename C::value_type join(const C &container, const typename C::value_type &separator) +{ + typename C::value_type out; + if (!container.empty()) { + auto it = container.cbegin(); + auto end = container.cend(); + out.append(*it++); + for (; it != end; ++it) { + out.append(separator); + out.append(*it); + } + } + return out; +} + +template +typename C::value_type join(const C &container, typename C::value_type::value_type separator) +{ + typename C::value_type s; + s.push_back(separator); + return join(container, s); +} + +static inline std::string trimmed(const std::string &s) +{ + // trim from start + static const auto ltrim = [](std::string &s) -> std::string & { + s.erase(s.begin(), std::find_if(s.begin(), s.end(), + [](char c){ return !std::isspace(c); })); + return s; + }; + + // trim from end + static const auto rtrim = [](std::string &s) -> std::string & { + s.erase(std::find_if(s.rbegin(), s.rend(), + [](char c){ return !std::isspace(c); }).base(), s.end()); + return s; + }; + + // trim from both ends + static const auto trim = [](std::string &s) -> std::string & { + return ltrim(rtrim(s)); + }; + + std::string copy = s; + return trim(copy); +} + +static inline bool startsWith(const std::string &subject, const std::string &s) +{ + if (s.size() <= subject.size()) + return std::equal(s.begin(), s.end(), subject.begin()); + return false; +} + +static inline bool startsWith(const std::string &subject, char c) +{ + std::string s; + s.push_back(c); + return startsWith(subject, s); +} + +static inline bool endsWith(const std::string &subject, const std::string &s) +{ + if (s.size() <= subject.size()) + return std::equal(s.rbegin(), s.rend(), subject.rbegin()); + return false; +} + +static inline bool endsWith(const std::string &subject, char c) +{ + std::string s; + s.push_back(c); + return endsWith(subject, s); +} + +} // namespace Internal +} // namespace qbs + +#ifdef Q_DECLARE_METATYPE +Q_DECLARE_METATYPE(std::string) +#endif + +#endif // QBS_STRINGUTILS_H diff --git a/src/lib/corelib/tools/toolchains.cpp b/src/lib/corelib/tools/toolchains.cpp new file mode 100644 index 00000000..6263fb19 --- /dev/null +++ b/src/lib/corelib/tools/toolchains.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "toolchains.h" + +#include "stringconstants.h" + +#include + +#include + +namespace qbs { + +namespace Internal { +static const QString clangToolchain() { return QStringLiteral("clang"); } +static const QString clangClToolchain() { return QStringLiteral("clang-cl"); } +static const QString gccToolchain() { return QStringLiteral("gcc"); } +static const QString llvmToolchain() { return QStringLiteral("llvm"); } +static const QString mingwToolchain() { return QStringLiteral("mingw"); } +static const QString msvcToolchain() { return QStringLiteral("msvc"); } +} + +using namespace Internal; + +QStringList canonicalToolchain(const QStringList &toolchain) +{ + static const QStringList knownToolchains { + StringConstants::xcode(), + clangToolchain(), + llvmToolchain(), + mingwToolchain(), + gccToolchain(), + clangClToolchain(), + msvcToolchain() + }; + + // Canonicalize each toolchain in the toolchain list, + // which gets us the aggregate canonicalized (unsorted) list + QStringList toolchains; + for (const QString &toolchainName : toolchain) + toolchains << canonicalToolchain(toolchainName); + toolchains.removeDuplicates(); + + // Find all known toolchains in the canonicalized list, + // removing them from the main list as we go. + QStringList usedKnownToolchains; + for (int i = 0; i < toolchains.size(); ++i) { + if (knownToolchains.contains(toolchains[i])) { + usedKnownToolchains << toolchains[i]; + toolchains.removeAt(i--); + } + } + + // Sort the list of known toolchains into their canonical order. + std::sort(usedKnownToolchains.begin(), usedKnownToolchains.end(), []( + const QString &a, + const QString &b) { + return knownToolchains.indexOf(a) < knownToolchains.indexOf(b); + }); + + // Re-add the known toolchains to the main list (the custom ones go first). + toolchains << usedKnownToolchains; + + // The toolchain list still needs further validation as it may contain mututally exclusive + // toolchain types (for example, llvm and msvc). + return toolchains; +} + +QStringList canonicalToolchain(const QString &name) +{ + const QString &toolchainName = name.toLower(); + QStringList toolchains(toolchainName); + if (toolchainName == StringConstants::xcode()) + toolchains << canonicalToolchain(clangToolchain()); + else if (toolchainName == clangToolchain()) + toolchains << canonicalToolchain(llvmToolchain()); + else if (toolchainName == llvmToolchain() || + toolchainName == mingwToolchain()) { + toolchains << canonicalToolchain(QStringLiteral("gcc")); + } else if (toolchainName == clangClToolchain()) { + toolchains << canonicalToolchain(msvcToolchain()); + } + return toolchains; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/toolchains.h b/src/lib/corelib/tools/toolchains.h new file mode 100644 index 00000000..b8d2c8ee --- /dev/null +++ b/src/lib/corelib/tools/toolchains.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_TOOLCHAINS_H +#define QBS_TOOLCHAINS_H + +#include "qbs_export.h" +#include + +namespace qbs { + +QBS_EXPORT QStringList canonicalToolchain(const QStringList &toolchain); +QBS_EXPORT QStringList canonicalToolchain(const QString &toolchainName); + +} // namespace qbs + +#endif // Include guard. diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri new file mode 100644 index 00000000..1fdacc01 --- /dev/null +++ b/src/lib/corelib/tools/tools.pri @@ -0,0 +1,147 @@ +include(../../../install_prefix.pri) + +INCLUDEPATH += $$PWD/../.. # for plugins + +QBS_SYSTEM_SETTINGS_DIR = $$(QBS_SYSTEM_SETTINGS_DIR) +!isEmpty(QBS_SYSTEM_SETTINGS_DIR) { + DEFINES += QBS_SYSTEM_SETTINGS_DIR=\\\"$$QBS_SYSTEM_SETTINGS_DIR\\\" +} + +HEADERS += \ + $$PWD/architectures.h \ + $$PWD/buildgraphlocker.h \ + $$PWD/clangclinfo.h \ + $$PWD/codelocation.h \ + $$PWD/commandechomode.h \ + $$PWD/dynamictypecheck.h \ + $$PWD/error.h \ + $$PWD/executablefinder.h \ + $$PWD/fileinfo.h \ + $$PWD/filesaver.h \ + $$PWD/filetime.h \ + $$PWD/generateoptions.h \ + $$PWD/id.h \ + $$PWD/iosutils.h \ + $$PWD/joblimits.h \ + $$PWD/jsliterals.h \ + $$PWD/jsonhelper.h \ + $$PWD/launcherinterface.h \ + $$PWD/launcherpackets.h \ + $$PWD/launchersocket.h \ + $$PWD/msvcinfo.h \ + $$PWD/persistence.h \ + $$PWD/porting.h \ + $$PWD/scannerpluginmanager.h \ + $$PWD/scripttools.h \ + $$PWD/set.h \ + $$PWD/settings.h \ + $$PWD/settingsmodel.h \ + $$PWD/settingsrepresentation.h \ + $$PWD/pathutils.h \ + $$PWD/preferences.h \ + $$PWD/profile.h \ + $$PWD/profiling.h \ + $$PWD/processresult.h \ + $$PWD/processresult_p.h \ + $$PWD/processutils.h \ + $$PWD/progressobserver.h \ + $$PWD/projectgeneratormanager.h \ + $$PWD/qbspluginmanager.h \ + $$PWD/qbsprocess.h \ + $$PWD/shellutils.h \ + $$PWD/stlutils.h \ + $$PWD/stringutils.h \ + $$PWD/toolchains.h \ + $$PWD/hostosinfo.h \ + $$PWD/buildoptions.h \ + $$PWD/installoptions.h \ + $$PWD/cleanoptions.h \ + $$PWD/setupprojectparameters.h \ + $$PWD/weakpointer.h \ + $$PWD/qbs_export.h \ + $$PWD/qbsassert.h \ + $$PWD/qttools.h \ + $$PWD/settingscreator.h \ + $$PWD/stringconstants.h \ + $$PWD/version.h \ + $$PWD/visualstudioversioninfo.h \ + $$PWD/vsenvironmentdetector.h + +SOURCES += \ + $$PWD/architectures.cpp \ + $$PWD/buildgraphlocker.cpp \ + $$PWD/clangclinfo.cpp \ + $$PWD/codelocation.cpp \ + $$PWD/commandechomode.cpp \ + $$PWD/error.cpp \ + $$PWD/executablefinder.cpp \ + $$PWD/fileinfo.cpp \ + $$PWD/filesaver.cpp \ + $$PWD/filetime.cpp \ + $$PWD/generateoptions.cpp \ + $$PWD/id.cpp \ + $$PWD/joblimits.cpp \ + $$PWD/jsliterals.cpp \ + $$PWD/launcherinterface.cpp \ + $$PWD/launcherpackets.cpp \ + $$PWD/launchersocket.cpp \ + $$PWD/msvcinfo.cpp \ + $$PWD/persistence.cpp \ + $$PWD/scannerpluginmanager.cpp \ + $$PWD/scripttools.cpp \ + $$PWD/settings.cpp \ + $$PWD/settingsmodel.cpp \ + $$PWD/settingsrepresentation.cpp \ + $$PWD/preferences.cpp \ + $$PWD/processresult.cpp \ + $$PWD/processutils.cpp \ + $$PWD/profile.cpp \ + $$PWD/profiling.cpp \ + $$PWD/progressobserver.cpp \ + $$PWD/projectgeneratormanager.cpp \ + $$PWD/qbspluginmanager.cpp \ + $$PWD/qbsprocess.cpp \ + $$PWD/shellutils.cpp \ + $$PWD/buildoptions.cpp \ + $$PWD/installoptions.cpp \ + $$PWD/cleanoptions.cpp \ + $$PWD/setupprojectparameters.cpp \ + $$PWD/qbsassert.cpp \ + $$PWD/qttools.cpp \ + $$PWD/settingscreator.cpp \ + $$PWD/toolchains.cpp \ + $$PWD/version.cpp \ + $$PWD/visualstudioversioninfo.cpp \ + $$PWD/vsenvironmentdetector.cpp + +osx { + HEADERS += $$PWD/applecodesignutils.h + SOURCES += $$PWD/applecodesignutils.cpp + LIBS += -framework Security +} + +!qbs_no_dev_install { + tools_headers.files = \ + $$PWD/architectures.h \ + $$PWD/buildoptions.h \ + $$PWD/cleanoptions.h \ + $$PWD/codelocation.h \ + $$PWD/commandechomode.h \ + $$PWD/error.h \ + $$PWD/generateoptions.h \ + $$PWD/installoptions.h \ + $$PWD/joblimits.h \ + $$PWD/preferences.h \ + $$PWD/processresult.h \ + $$PWD/profile.h \ + $$PWD/projectgeneratormanager.h \ + $$PWD/qbs_export.h \ + $$PWD/settings.h \ + $$PWD/settingsmodel.h \ + $$PWD/settingsrepresentation.h \ + $$PWD/setupprojectparameters.h \ + $$PWD/toolchains.h \ + $$PWD/version.h + tools_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/tools + INSTALLS += tools_headers +} diff --git a/src/lib/corelib/tools/version.cpp b/src/lib/corelib/tools/version.cpp new file mode 100644 index 00000000..719bc386 --- /dev/null +++ b/src/lib/corelib/tools/version.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "version.h" + +#include +#include + +namespace qbs { + +Version Version::fromString(const QString &versionString, bool buildNumberAllowed) +{ + QString pattern = QStringLiteral("(\\d+)"); // At least one number. + for (int i = 0; i < 2; ++i) + pattern += QStringLiteral("(?:\\.(\\d+))?"); // Followed by a dot and a number up to two times. + if (buildNumberAllowed) + pattern += QStringLiteral("(?:[-.](\\d+))?"); // And possibly a dash or dot followed by the build number. + const QRegularExpression rex(QRegularExpression::anchoredPattern(pattern)); + const QRegularExpressionMatch match = rex.match(versionString); + if (!match.hasMatch()) + return Version{}; + const int majorNr = match.captured(1).toInt(); + const int minorNr = match.lastCapturedIndex() >= 2 ? match.captured(2).toInt() : 0; + const int patchNr = match.lastCapturedIndex() >= 3 ? match.captured(3).toInt() : 0; + const int buildNr = match.lastCapturedIndex() >= 4 ? match.captured(4).toInt() : 0; + return Version{majorNr, minorNr, patchNr, buildNr}; +} + +QString Version::toString(const QChar &separator, const QChar &buildSeparator) const +{ + if (m_build) { + return QStringLiteral("%1%5%2%5%3%6%4") + .arg(QString::number(m_major), QString::number(m_minor), + QString::number(m_patch), QString::number(m_build), + separator, buildSeparator); + } + return QStringLiteral("%1%4%2%4%3") + .arg(QString::number(m_major), QString::number(m_minor), + QString::number(m_patch), separator); +} + +VersionRange &VersionRange::narrowDown(const VersionRange &other) +{ + if (other.minimum > minimum) + minimum = other.minimum; + if (other.maximum.isValid() && other.maximum < maximum) + maximum = other.maximum; + return *this; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/version.h b/src/lib/corelib/tools/version.h new file mode 100644 index 00000000..7b2d23eb --- /dev/null +++ b/src/lib/corelib/tools/version.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_VERSION_H +#define QBS_VERSION_H + +#include "qbs_export.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { + +class Version +{ +public: + constexpr explicit Version(int majorVersion = 0, int minorVersion = 0, int patchLevel = 0, + int buildNr = 0) + : m_major(majorVersion), m_minor(minorVersion), m_patch(patchLevel), m_build(buildNr) + { } + + constexpr bool isValid() const { return m_major || m_minor || m_patch || m_build; } + + constexpr int majorVersion() const { return m_major; } + constexpr void setMajorVersion(int majorVersion) { m_major = majorVersion; } + + constexpr int minorVersion() const { return m_minor; } + constexpr void setMinorVersion(int minorVersion) { m_minor = minorVersion;} + + constexpr int patchLevel() const { return m_patch; } + constexpr void setPatchLevel(int patchLevel) { m_patch = patchLevel; } + + constexpr int buildNumber() const { return m_build; } + constexpr void setBuildNumber(int nr) { m_build = nr; } + + static QBS_EXPORT Version fromString(const QString &versionString, bool buildNumberAllowed = false); + QString QBS_EXPORT toString(const QChar &separator = QLatin1Char('.'), + const QChar &buildSeparator = QLatin1Char('-')) const; + +private: + int m_major; + int m_minor; + int m_patch; + int m_build; +}; + +class VersionRange +{ +public: + constexpr VersionRange() = default; + constexpr VersionRange(const Version &minVersion, const Version &maxVersion) + : minimum(minVersion), maximum(maxVersion) + { } + + Version minimum; + Version maximum; // exclusive + + VersionRange &narrowDown(const VersionRange &other); +}; + +constexpr inline int compare(const Version &lhs, const Version &rhs) +{ + if (lhs.majorVersion() < rhs.majorVersion()) + return -1; + if (lhs.majorVersion() > rhs.majorVersion()) + return 1; + if (lhs.minorVersion() < rhs.minorVersion()) + return -1; + if (lhs.minorVersion() > rhs.minorVersion()) + return 1; + if (lhs.patchLevel() < rhs.patchLevel()) + return -1; + if (lhs.patchLevel() > rhs.patchLevel()) + return 1; + if (lhs.buildNumber() < rhs.buildNumber()) + return -1; + if (lhs.buildNumber() > rhs.buildNumber()) + return 1; + return 0; +} + +constexpr inline bool operator==(const Version &lhs, const Version &rhs) +{ return compare(lhs, rhs) == 0; } +constexpr inline bool operator!=(const Version &lhs, const Version &rhs) +{ return !operator==(lhs, rhs); } +constexpr inline bool operator<(const Version &lhs, const Version &rhs) +{ return compare(lhs, rhs) < 0; } +constexpr inline bool operator>(const Version &lhs, const Version &rhs) +{ return compare(lhs, rhs) > 0; } +constexpr inline bool operator<=(const Version &lhs, const Version &rhs) +{ return !operator>(lhs, rhs); } +constexpr inline bool operator>=(const Version &lhs, const Version &rhs) +{ return !operator<(lhs, rhs); } + +} // namespace qbs + +#endif // QBS_VERSION_H diff --git a/src/lib/corelib/tools/visualstudioversioninfo.cpp b/src/lib/corelib/tools/visualstudioversioninfo.cpp new file mode 100644 index 00000000..9ea86aae --- /dev/null +++ b/src/lib/corelib/tools/visualstudioversioninfo.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "visualstudioversioninfo.h" +#include +#include +#include + +namespace qbs { +namespace Internal { + +VisualStudioVersionInfo::VisualStudioVersionInfo() = default; + +VisualStudioVersionInfo::VisualStudioVersionInfo(const Version &version) + : m_version(version) +{ + QBS_CHECK(version.minorVersion() == 0 || version == Version(7, 1) + || version.majorVersion() >= 15); +} + +std::set VisualStudioVersionInfo::knownVersions() +{ + static const std::set known = { + Version(17), Version(16), Version(15), Version(14), Version(12), Version(11), + Version(10), Version(9), Version(8), Version(7, 1), Version(7), Version(6) + }; + return known; +} + +bool VisualStudioVersionInfo::operator<(const VisualStudioVersionInfo &other) const +{ + return m_version < other.m_version; +} + +bool VisualStudioVersionInfo::operator==(const VisualStudioVersionInfo &other) const +{ + return m_version == other.m_version; +} + +bool VisualStudioVersionInfo::usesMsBuild() const +{ + return m_version.majorVersion() >= 10; +} + +bool VisualStudioVersionInfo::usesVcBuild() const +{ + return m_version.majorVersion() <= 9; +} + +bool VisualStudioVersionInfo::usesSolutions() const +{ + return m_version.majorVersion() >= 7; +} + +Version VisualStudioVersionInfo::version() const +{ + return m_version; +} + +int VisualStudioVersionInfo::marketingVersion() const +{ + switch (m_version.majorVersion()) { + case 6: + return 6; + case 7: + switch (m_version.minorVersion()) { + case 0: + return 2002; + case 1: + return 2003; + default: + Q_UNREACHABLE(); + } + break; + case 8: + return 2005; + case 9: + return 2008; + case 10: + return 2010; + case 11: + return 2012; + case 12: + return 2013; + case 14: + return 2015; + case 15: + return 2017; + case 16: + return 2019; + case 17: + return 2022; + default: + qWarning() << QStringLiteral("unrecognized Visual Studio version: ") + << m_version.toString(); + return 0; + } +} + +QString VisualStudioVersionInfo::solutionVersion() const +{ + // Visual Studio 2012 finally stabilized the solution version + if (m_version >= Version(11)) + return QStringLiteral("12.00"); + + if (m_version >= Version(8)) + return QStringLiteral("%1.00").arg(m_version.majorVersion() + 1); + + if (m_version >= Version(7, 1)) + return QStringLiteral("8.00"); + + if (m_version >= Version(7)) + return QStringLiteral("7.00"); + + // these versions do not use solution files + // Visual Studio 6 uses .dsw files which are format version 6.00 but these are different + Q_ASSERT(!usesSolutions()); + Q_UNREACHABLE(); +} + +QString VisualStudioVersionInfo::toolsVersion() const +{ + // "https://msdn.microsoft.com/en-us/library/bb383796.aspx" + // Starting in Visual Studio 2013, the MSBuild Toolset version is the same as the Visual Studio + // version number"... again + if (m_version >= Version(12)) + return QStringLiteral("%1.0").arg(m_version.majorVersion()); + + if (m_version >= Version(10)) + return QStringLiteral("4.0"); + + // pre-MSBuild + return QStringLiteral("%1,00").arg(m_version.majorVersion()); +} + +QString VisualStudioVersionInfo::platformToolsetVersion() const +{ + static std::pair table[] = { + {17, QStringLiteral("v143")}, // VS 2022 + {16, QStringLiteral("v142")}, // VS 2019 + {15, QStringLiteral("v141")} // VS 2017 + }; + for (const auto &p : table) { + if (p.first == m_version.majorVersion()) + return p.second; + } + return QStringLiteral("v%1").arg(m_version.majorVersion() * 10); +} + +QHashValueType qHash(const VisualStudioVersionInfo &info) +{ + return qHash(info.version().toString()); +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/visualstudioversioninfo.h b/src/lib/corelib/tools/visualstudioversioninfo.h new file mode 100644 index 00000000..92eecb38 --- /dev/null +++ b/src/lib/corelib/tools/visualstudioversioninfo.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_VISUALSTUDIOVERSIONINFO_H +#define QBS_VISUALSTUDIOVERSIONINFO_H + +#include "qbs_export.h" + +#include +#include + +#include + +#include + +namespace qbs { +namespace Internal { + +class QBS_EXPORT VisualStudioVersionInfo +{ +public: + VisualStudioVersionInfo(); + VisualStudioVersionInfo(const Version &version); + + static std::set knownVersions(); + + bool operator<(const VisualStudioVersionInfo &other) const; + bool operator==(const VisualStudioVersionInfo &other) const; + + bool usesMsBuild() const; + bool usesVcBuild() const; + bool usesSolutions() const; + + Version version() const; + int marketingVersion() const; + + QString solutionVersion() const; + QString toolsVersion() const; + QString platformToolsetVersion() const; + +private: + Version m_version; +}; + +QHashValueType qHash(const VisualStudioVersionInfo &info); + +} // namespace Internal +} // namespace qbs + +#endif // QBS_VISUALSTUDIOVERSIONINFO_H diff --git a/src/lib/corelib/tools/vsenvironmentdetector.cpp b/src/lib/corelib/tools/vsenvironmentdetector.cpp new file mode 100644 index 00000000..5bcbd93b --- /dev/null +++ b/src/lib/corelib/tools/vsenvironmentdetector.cpp @@ -0,0 +1,287 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "vsenvironmentdetector.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef Q_OS_WIN +#include +#include +#endif + +namespace qbs { +namespace Internal { + +static QString windowsSystem32Path() +{ +#ifdef Q_OS_WIN + wchar_t str[UNICODE_STRING_MAX_CHARS]; + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, 0, str))) + return QString::fromUtf16(reinterpret_cast(str)); +#endif + return {}; +} + +VsEnvironmentDetector::VsEnvironmentDetector(QString vcvarsallPath) + : m_windowsSystemDirPath(windowsSystem32Path()) + , m_vcvarsallPath(std::move(vcvarsallPath)) +{ +} + +bool VsEnvironmentDetector::start(MSVC *msvc) +{ + return start(std::vector{ msvc }); +} + +bool VsEnvironmentDetector::start(std::vector msvcs) +{ + std::sort(msvcs.begin(), msvcs.end(), [] (const MSVC *a, const MSVC *b) -> bool { + return a->vcInstallPath < b->vcInstallPath; + }); + + std::vector compatibleMSVCs; + QString lastVcInstallPath; + bool someMSVCDetected = false; + for (MSVC * const msvc : msvcs) { + if (lastVcInstallPath != msvc->vcInstallPath) { + lastVcInstallPath = msvc->vcInstallPath; + if (!compatibleMSVCs.empty()) { + if (startDetection(compatibleMSVCs)) + someMSVCDetected = true; + compatibleMSVCs.clear(); + } + } + compatibleMSVCs.push_back(msvc); + } + if (startDetection(compatibleMSVCs)) + someMSVCDetected = true; + return someMSVCDetected; +} + +QString VsEnvironmentDetector::findVcVarsAllBat(const MSVC &msvc, + std::vector &searchedPaths) const +{ + // ### We can only rely on MSVC.vcInstallPath being set + // when this is called from utilitiesextension.cpp :-( + // If we knew the vsInstallPath at this point we could just use that + // instead of searching for vcvarsall.bat candidates. + QDir dir(msvc.vcInstallPath); + for (;;) { + if (!dir.cdUp()) + return {}; + if (dir.dirName() == QLatin1String("VC")) + break; + } + const QString vcvarsallbat = QStringLiteral("vcvarsall.bat"); + QString path = vcvarsallbat; + QString fullPath = dir.absoluteFilePath(path); + if (dir.exists(path)) + return fullPath; + searchedPaths.push_back(fullPath); + path = QStringLiteral("Auxiliary/Build/") + vcvarsallbat; + fullPath = dir.absoluteFilePath(path); + if (dir.exists(path)) + return fullPath; + searchedPaths.push_back(fullPath); + return {}; +} + +bool VsEnvironmentDetector::startDetection(const std::vector &compatibleMSVCs) +{ + std::vector searchedPaths; + + if (!m_vcvarsallPath.isEmpty() && !QFileInfo::exists(m_vcvarsallPath)) { + m_errorString = Tr::tr("%1 does not exist.").arg(m_vcvarsallPath); + return false; + } + + const auto vcvarsallbat = !m_vcvarsallPath.isEmpty() + ? m_vcvarsallPath + : findVcVarsAllBat(**compatibleMSVCs.begin(), searchedPaths); + if (vcvarsallbat.isEmpty()) { + if (!searchedPaths.empty()) { + m_errorString = Tr::tr( + "Cannot find 'vcvarsall.bat' at any of the following locations:\n\t") + + join(searchedPaths, QStringLiteral("\n\t")); + } else { + m_errorString = Tr::tr("Cannot find 'vcvarsall.bat'."); + } + return false; + } + + QTemporaryFile tmpFile(QDir::tempPath() + QLatin1Char('/') + QStringLiteral("XXXXXX.bat")); + if (!tmpFile.open()) { + m_errorString = Tr::tr("Cannot open temporary file '%1' for writing.").arg( + tmpFile.fileName()); + return false; + } + + writeBatchFile(&tmpFile, vcvarsallbat, compatibleMSVCs); + tmpFile.flush(); + + QProcess process; + static const QString shellFilePath = QStringLiteral("cmd.exe"); + process.start(shellFilePath, QStringList() + << QStringLiteral("/C") << tmpFile.fileName()); + if (!process.waitForStarted()) { + m_errorString = Tr::tr("Failed to start '%1'.").arg(shellFilePath); + return false; + } + process.waitForFinished(-1); + if (process.exitStatus() != QProcess::NormalExit) { + m_errorString = Tr::tr("Process '%1' did not exit normally.").arg(shellFilePath); + return false; + } + if (process.exitCode() != 0) { + m_errorString = Tr::tr("Failed to detect Visual Studio environment."); + return false; + } + parseBatOutput(process.readAllStandardOutput(), compatibleMSVCs); + return true; + +} + +static void batClearVars(QTextStream &s, const QStringList &varnames) +{ + for (const QString &varname : varnames) + s << "set " << varname << '=' << Qt::endl; +} + +static void batPrintVars(QTextStream &s, const QStringList &varnames) +{ + for (const QString &varname : varnames) + s << "echo " << varname << "=%" << varname << '%' << Qt::endl; +} + +static QString vcArchitecture(const MSVC *msvc) +{ + QString vcArch = msvc->architecture; + if (msvc->architecture == StringConstants::armv7Arch()) + vcArch = StringConstants::armArch(); + if (msvc->architecture == StringConstants::x86_64Arch()) + vcArch = StringConstants::amd64Arch(); + + const QString hostPrefixes[] = { + StringConstants::x86Arch(), + QStringLiteral("amd64_"), + QStringLiteral("x86_") + }; + for (const QString &hostPrefix : hostPrefixes) { + if (QFile::exists(msvc->clPathForArchitecture(hostPrefix + vcArch))) { + vcArch.prepend(hostPrefix); + break; + } + } + + return vcArch; +} + +void VsEnvironmentDetector::writeBatchFile(QIODevice *device, const QString &vcvarsallbat, + const std::vector &msvcs) const +{ + const QStringList varnames = QStringList() << StringConstants::pathEnvVar() + << QStringLiteral("INCLUDE") << QStringLiteral("LIB") << QStringLiteral("WindowsSdkDir") + << QStringLiteral("WindowsSDKVersion") << QStringLiteral("VSINSTALLDIR"); + QTextStream s(device); + using Qt::endl; + s << "@echo off" << endl; + // Avoid execution of powershell (in vsdevcmd.bat), which is not in the cleared PATH + s << "set VSCMD_SKIP_SENDTELEMETRY=1" << endl; + for (const MSVC *msvc : msvcs) { + s << "echo --" << msvc->architecture << "--" << endl + << "setlocal" << endl; + batClearVars(s, varnames); + s << "set PATH=" << m_windowsSystemDirPath << endl; // vcvarsall.bat needs tools from here + s << "call \"" << vcvarsallbat << "\" " << vcArchitecture(msvc); + if (!msvc->sdkVersion.isEmpty()) + s << " " << msvc->sdkVersion; + const auto vcVarsVer = MSVC::vcVariablesVersionFromBinPath(msvc->binPath); + if (!vcVarsVer.isEmpty()) + s << " -vcvars_ver=" << vcVarsVer; + s << " || exit /b 1" << endl; + batPrintVars(s, varnames); + s << "endlocal" << endl; + } +} + +void VsEnvironmentDetector::parseBatOutput(const QByteArray &output, std::vector msvcs) +{ + QString arch; + QProcessEnvironment *targetEnv = nullptr; + const auto lines = output.split('\n'); + for (QByteArray line : lines) { + line = line.trimmed(); + if (line.isEmpty()) + continue; + + if (line.startsWith("--") && line.endsWith("--")) { + line.remove(0, 2); + line.chop(2); + arch = QString::fromLocal8Bit(line); + targetEnv = &msvcs.front()->environment; + msvcs.erase(msvcs.begin()); + } else { + int idx = line.indexOf('='); + if (idx < 0) + continue; + QBS_CHECK(targetEnv); + const QString name = QString::fromLocal8Bit(line.left(idx)); + QString value = QString::fromLocal8Bit(line.mid(idx + 1)); + if (name.compare(StringConstants::pathEnvVar(), Qt::CaseInsensitive) == 0) + value.remove(m_windowsSystemDirPath); + if (value.endsWith(QLatin1Char(';'))) + value.chop(1); + targetEnv->insert(name, value); + } + } +} + +} // namespace Internal +} // namespace qbs diff --git a/src/lib/corelib/tools/vsenvironmentdetector.h b/src/lib/corelib/tools/vsenvironmentdetector.h new file mode 100644 index 00000000..39bea07d --- /dev/null +++ b/src/lib/corelib/tools/vsenvironmentdetector.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_VSENVIRONMENTDETECTOR_H +#define QBS_VSENVIRONMENTDETECTOR_H + +#include "qbs_export.h" +#include "msvcinfo.h" + +#include + +QT_BEGIN_NAMESPACE +class QIODevice; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { + +class MSVC; + +class QBS_EXPORT VsEnvironmentDetector +{ +public: + explicit VsEnvironmentDetector(QString vcvarsallPath = {}); + + bool start(MSVC *msvc); + bool start(std::vector msvcs); + QString errorString() const { return m_errorString; } + +private: + QString findVcVarsAllBat(const MSVC &msvc, std::vector &searchedPaths) const; + bool startDetection(const std::vector &compatibleMSVCs); + void writeBatchFile(QIODevice *device, const QString &vcvarsallbat, const std::vector &msvcs) const; + void parseBatOutput(const QByteArray &output, std::vector msvcs); + + const QString m_windowsSystemDirPath; + const QString m_vcvarsallPath; + const QString m_vcVariablesVersion; + QString m_errorString; +}; + +} // namespace Internal +} // namespace qbs + +#endif // QBS_VSENVIRONMENTDETECTOR_H diff --git a/src/lib/corelib/tools/weakpointer.h b/src/lib/corelib/tools/weakpointer.h new file mode 100644 index 00000000..fecae682 --- /dev/null +++ b/src/lib/corelib/tools/weakpointer.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_WEAKPOINTER_H +#define QBS_WEAKPOINTER_H + +#include + +namespace qbs { +namespace Internal { + +template class WeakPointer : public std::weak_ptr +{ +public: + WeakPointer() : std::weak_ptr() {} + WeakPointer(const std::shared_ptr &sharedPointer) : std::weak_ptr(sharedPointer) {} + template WeakPointer(const std::shared_ptr &sp) : std::weak_ptr(sp) { } + + T *get() const { auto p = std::weak_ptr::lock(); return p.get(); } + operator bool() const { return !std::weak_ptr::expired(); } + bool operator!() const { return std::weak_ptr::expired(); } + operator T*() const { return checkedData(); } + T *operator->() const { return checkedData(); } + T operator*() const { return *checkedData(); } + +private: + T *checkedData() const { + T * const d = get(); + Q_ASSERT(d); // Calling code is not expecting this situation. + return d; + } +}; + +template bool operator==(const WeakPointer &a, const WeakPointer &b) +{ + return a.get() == b.get(); +} + +template bool operator!=(const WeakPointer &a, const WeakPointer &b) +{ + return a.get() != b.get(); +} + +template bool operator==(const WeakPointer &a, + const std::shared_ptr &b) +{ + return a.lock() == b; +} + +template bool operator!=(const WeakPointer &a, + const std::shared_ptr &b) +{ + return a.lock() != b; +} + +} // namespace Internal +} // namespace qbs + +#endif // QBS_WEAKPOINTER_H diff --git a/src/lib/corelib/use_corelib.pri b/src/lib/corelib/use_corelib.pri new file mode 100644 index 00000000..e1d74ca0 --- /dev/null +++ b/src/lib/corelib/use_corelib.pri @@ -0,0 +1,47 @@ +include(../../../qbs_version.pri) +include(../../library_dirname.pri) +include(../scriptengine/use_scriptengine.pri) + +isEmpty(QBSLIBDIR) { + QBSLIBDIR = $$OUT_PWD/../../../$${QBS_LIBRARY_DIRNAME} +} + +unix { + LIBS += -L$$QBSLIBDIR -lqbscore +} + +isEmpty(QBS_RPATH): QBS_RPATH = ../$$QBS_LIBRARY_DIRNAME +!qbs_disable_rpath { + linux-*: QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,\$\$ORIGIN/$${QBS_RPATH}\' + macx: QMAKE_LFLAGS += -Wl,-rpath,@loader_path/$${QBS_RPATH} +} + +!CONFIG(static, static|shared) { + QBSCORELIBSUFFIX = $$QBS_VERSION_MAJ +} + +win32 { + CONFIG(debug, debug|release) { + QBSCORELIB = qbscored$$QBSCORELIBSUFFIX + } + CONFIG(release, debug|release) { + QBSCORELIB = qbscore$$QBSCORELIBSUFFIX + } + msvc { + LIBS += /LIBPATH:$$QBSLIBDIR + QBSCORELIB = $${QBSCORELIB}.lib + LIBS += Shell32.lib + } else { + LIBS += -L$${QBSLIBDIR} + QBSCORELIB = lib$${QBSCORELIB} + } + LIBS += $$QBSCORELIB +} + +INCLUDEPATH += \ + $$PWD + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} +qbs_enable_unit_tests:DEFINES += QBS_ENABLE_UNIT_TESTS diff --git a/src/lib/corelib/use_installed_corelib.pri b/src/lib/corelib/use_installed_corelib.pri new file mode 100644 index 00000000..48e020c7 --- /dev/null +++ b/src/lib/corelib/use_installed_corelib.pri @@ -0,0 +1,37 @@ +include(qbs_version.pri) + +QBSLIBDIR=$${PWD}/../../lib +unix { + LIBS += -L$$QBSLIBDIR -lqbscore +} + +!qbs_disable_rpath:unix:QMAKE_LFLAGS += -Wl,-rpath,$${QBSLIBDIR} + +!CONFIG(static, static|shared) { + QBSCORELIBSUFFIX = $$QBS_VERSION_MAJ +} + +win32 { + CONFIG(debug, debug|release) { + QBSCORELIB = qbscored$$QBSCORELIBSUFFIX + } + CONFIG(release, debug|release) { + QBSCORELIB = qbscore$$QBSCORELIBSUFFIX + } + msvc { + LIBS += /LIBPATH:$$QBSLIBDIR + QBSCORELIB = $${QBSCORELIB}.lib + LIBS += Shell32.lib + } else { + LIBS += -L$${QBSLIBDIR} + QBSCORELIB = lib$${QBSCORELIB} + } + LIBS += $$QBSCORELIB +} + +INCLUDEPATH += $${PWD} + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} +qbs_enable_unit_tests:DEFINES += QBS_ENABLE_UNIT_TESTS diff --git a/src/lib/library.pri b/src/lib/library.pri new file mode 100644 index 00000000..7d12e107 --- /dev/null +++ b/src/lib/library.pri @@ -0,0 +1,32 @@ +include(library_base.pri) + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} else { + DEFINES += QBS_LIBRARY +} + +qbs_disable_rpath { + osx:QMAKE_LFLAGS_SONAME = -Wl,-install_name,$$QBS_INSTALL_PREFIX/$$QBS_LIBRARY_DIRNAME/ +} else { + osx:QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/ +} + +linux { + # Turn off absurd qmake's soname "logic" and directly add the linker flag. + QMAKE_LFLAGS_SONAME = + QMAKE_LFLAGS += -Wl,-soname=lib$${TARGET}.so.$${QBS_VERSION_MAJ}.$${QBS_VERSION_MIN} +} + +win32 { + dlltarget.path = $${QBS_INSTALL_PREFIX}/bin + INSTALLS += dlltarget +} + +!win32|!qbs_no_dev_install { + !isEmpty(QBS_LIB_INSTALL_DIR): \ + target.path = $${QBS_LIB_INSTALL_DIR} + else: \ + target.path = $${QBS_INSTALL_PREFIX}/$${QBS_LIBRARY_DIRNAME} + INSTALLS += target +} diff --git a/src/lib/library_base.pri b/src/lib/library_base.pri new file mode 100644 index 00000000..1fde46e3 --- /dev/null +++ b/src/lib/library_base.pri @@ -0,0 +1,21 @@ +include(../library_dirname.pri) +include(../install_prefix.pri) + +TEMPLATE = lib +QT = core +!isEmpty(QBS_DLLDESTDIR):DLLDESTDIR = $${QBS_DLLDESTDIR} +else:DLLDESTDIR = ../../../bin +!isEmpty(QBS_DESTDIR):DESTDIR = $${QBS_DESTDIR} +else:DESTDIR = ../../../$${QBS_LIBRARY_DIRNAME} + +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_PROCESS_COMBINED_ARGUMENT_START +qbs_enable_unit_tests:DEFINES += QBS_ENABLE_UNIT_TESTS +INCLUDEPATH += $${PWD}/../ +contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols +win32:CONFIG(debug, debug|release):TARGET = $${TARGET}d +CONFIG(debug, debug|release):DEFINES += QT_STRICT_ITERATORS +CONFIG += c++17 +CONFIG += create_prl + +include(../../qbs_version.pri) +VERSION = $${QBS_VERSION} diff --git a/src/lib/libs.qbs b/src/lib/libs.qbs new file mode 100644 index 00000000..10890bb4 --- /dev/null +++ b/src/lib/libs.qbs @@ -0,0 +1,8 @@ +Project { + references: [ + "corelib/corelib.qbs", + "msbuild/msbuild.qbs", + "pkgconfig/pkgconfig.qbs", + "scriptengine/scriptengine.qbs", + ] +} diff --git a/src/lib/msbuild/CMakeLists.txt b/src/lib/msbuild/CMakeLists.txt new file mode 100644 index 00000000..c908ed2d --- /dev/null +++ b/src/lib/msbuild/CMakeLists.txt @@ -0,0 +1,72 @@ +set(SOLUTION_SOURCES + ivisualstudiosolutionproject.cpp + ivisualstudiosolutionproject.h + visualstudiosolutionfileproject.cpp + visualstudiosolutionfileproject.h + visualstudiosolutionfolderproject.cpp + visualstudiosolutionfolderproject.h + visualstudiosolution.cpp + visualstudiosolution.h + visualstudiosolutionglobalsection.cpp + visualstudiosolutionglobalsection.h + ) +list_transform_prepend(SOLUTION_SOURCES solution/) + +set(MSBUILD_SOURCES + imsbuildgroup.cpp + imsbuildgroup.h + imsbuildnode.cpp + imsbuildnode.h + imsbuildnodevisitor.h + msbuildimport.cpp + msbuildimport.h + msbuildimportgroup.cpp + msbuildimportgroup.h + msbuilditem.cpp + msbuilditem.h + msbuilditemdefinitiongroup.cpp + msbuilditemdefinitiongroup.h + msbuilditemgroup.cpp + msbuilditemgroup.h + msbuilditemmetadata.cpp + msbuilditemmetadata.h + msbuildproject.cpp + msbuildproject.h + msbuildproperty.cpp + msbuildproperty.h + msbuildpropertybase.cpp + msbuildpropertybase.h + msbuildpropertygroup.cpp + msbuildpropertygroup.h + ) +list_transform_prepend(MSBUILD_SOURCES msbuild/) + +set(MSBUILD_ITEMS_SOURCES + msbuildclcompile.cpp + msbuildclcompile.h + msbuildclinclude.cpp + msbuildclinclude.h + msbuildfileitem.cpp + msbuildfileitem.h + msbuildfilter.cpp + msbuildfilter.h + msbuildlink.cpp + msbuildlink.h + msbuildnone.cpp + msbuildnone.h + ) +list_transform_prepend(MSBUILD_ITEMS_SOURCES msbuild/items/) + +set(IO_SOURCES + msbuildprojectwriter.cpp + msbuildprojectwriter.h + visualstudiosolutionwriter.cpp + visualstudiosolutionwriter.h + ) +list_transform_prepend(IO_SOURCES io/) + +add_qbs_library(qbsmsbuild + STATIC + DEPENDS qbscore + SOURCES ${SOLUTION_SOURCES} ${MSBUILD_SOURCES} ${MSBUILD_ITEMS_SOURCES} ${IO_SOURCES} + ) diff --git a/src/lib/msbuild/io/msbuildprojectwriter.cpp b/src/lib/msbuild/io/msbuildprojectwriter.cpp new file mode 100644 index 00000000..986458a7 --- /dev/null +++ b/src/lib/msbuild/io/msbuildprojectwriter.cpp @@ -0,0 +1,235 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildprojectwriter.h" + +#include "../msbuild/imsbuildnodevisitor.h" +#include "../msbuild/msbuildimport.h" +#include "../msbuild/msbuildimportgroup.h" +#include "../msbuild/msbuilditem.h" +#include "../msbuild/msbuilditemdefinitiongroup.h" +#include "../msbuild/msbuilditemgroup.h" +#include "../msbuild/msbuilditemmetadata.h" +#include "../msbuild/msbuildproject.h" +#include "../msbuild/msbuildproperty.h" +#include "../msbuild/msbuildpropertygroup.h" + +#include + +#include + +namespace qbs { + +static const QString kMSBuildSchemaURI = + QStringLiteral("http://schemas.microsoft.com/developer/msbuild/2003"); + +class MSBuildProjectWriterPrivate : public IMSBuildNodeVisitor +{ +public: + std::ostream *device = nullptr; + QByteArray buffer; + std::unique_ptr writer; + + void visitStart(const MSBuildImport *import) override; + void visitEnd(const MSBuildImport *import) override; + + void visitStart(const MSBuildImportGroup *importGroup) override; + void visitEnd(const MSBuildImportGroup *importGroup) override; + + void visitStart(const MSBuildItem *item) override; + void visitEnd(const MSBuildItem *item) override; + + void visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) override; + void visitEnd(const MSBuildItemDefinitionGroup *itemDefinitionGroup) override; + + void visitStart(const MSBuildItemGroup *itemGroup) override; + void visitEnd(const MSBuildItemGroup *itemGroup) override; + + void visitStart(const MSBuildItemMetadata *itemMetadata) override; + void visitEnd(const MSBuildItemMetadata *itemMetadata) override; + + void visitStart(const MSBuildProject *project) override; + void visitEnd(const MSBuildProject *project) override; + + void visitStart(const MSBuildProperty *property) override; + void visitEnd(const MSBuildProperty *property) override; + + void visitStart(const MSBuildPropertyGroup *propertyGroup) override; + void visitEnd(const MSBuildPropertyGroup *propertyGroup) override; +}; + +MSBuildProjectWriter::MSBuildProjectWriter(std::ostream *device) + : d(std::make_unique()) +{ + d->device = device; + d->writer = std::make_unique(&d->buffer); + d->writer->setAutoFormatting(true); +} + +MSBuildProjectWriter::~MSBuildProjectWriter() = default; + +bool MSBuildProjectWriter::write(const MSBuildProject *project) +{ + d->buffer.clear(); + d->writer->writeStartDocument(); + project->accept(d.get()); + d->writer->writeEndDocument(); + if (d->writer->hasError()) + return false; + d->device->write(&*std::begin(d->buffer), d->buffer.size()); + return d->device->good(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildImport *import) +{ + writer->writeStartElement(QStringLiteral("Import")); + writer->writeAttribute(QStringLiteral("Project"), import->project()); + if (!import->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), import->condition()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildImport *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildImportGroup *importGroup) +{ + writer->writeStartElement(QStringLiteral("ImportGroup")); + if (!importGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), importGroup->condition()); + if (!importGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), importGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildImportGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItem *item) +{ + writer->writeStartElement(item->name()); + if (!item->include().isEmpty()) + writer->writeAttribute(QStringLiteral("Include"), item->include()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItem *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) +{ + writer->writeStartElement(QStringLiteral("ItemDefinitionGroup")); + if (!itemDefinitionGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), itemDefinitionGroup->condition()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemDefinitionGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemGroup *itemGroup) +{ + writer->writeStartElement(QStringLiteral("ItemGroup")); + if (!itemGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), itemGroup->condition()); + if (!itemGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), itemGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemGroup *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildItemMetadata *itemMetadata) +{ + QString stringValue; + if (itemMetadata->value().userType() == QMetaType::Bool) { + stringValue = itemMetadata->value().toBool() + ? QStringLiteral("True") + : QStringLiteral("False"); + } else { + stringValue = itemMetadata->value().toString(); + } + writer->writeTextElement(itemMetadata->name(), stringValue); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildItemMetadata *) +{ +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildProject *project) +{ + writer->writeStartElement(QStringLiteral("Project")); + if (!project->defaultTargets().isEmpty()) + writer->writeAttribute(QStringLiteral("DefaultTargets"), project->defaultTargets()); + if (!project->toolsVersion().isEmpty()) + writer->writeAttribute(QStringLiteral("ToolsVersion"), project->toolsVersion()); + writer->writeAttribute(QStringLiteral("xmlns"), kMSBuildSchemaURI); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildProject *) +{ + writer->writeEndElement(); +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildProperty *property) +{ + QString stringValue; + if (property->value().userType() == QMetaType::Bool) + stringValue = property->value().toBool() ? QStringLiteral("True") : QStringLiteral("False"); + else + stringValue = property->value().toString(); + writer->writeTextElement(property->name(), stringValue); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildProperty *) +{ +} + +void MSBuildProjectWriterPrivate::visitStart(const MSBuildPropertyGroup *propertyGroup) +{ + writer->writeStartElement(QStringLiteral("PropertyGroup")); + if (!propertyGroup->condition().isEmpty()) + writer->writeAttribute(QStringLiteral("Condition"), propertyGroup->condition()); + if (!propertyGroup->label().isEmpty()) + writer->writeAttribute(QStringLiteral("Label"), propertyGroup->label()); +} + +void MSBuildProjectWriterPrivate::visitEnd(const MSBuildPropertyGroup *) +{ + writer->writeEndElement(); +} + +} // namespace qbs diff --git a/src/lib/msbuild/io/msbuildprojectwriter.h b/src/lib/msbuild/io/msbuildprojectwriter.h new file mode 100644 index 00000000..9feb347c --- /dev/null +++ b/src/lib/msbuild/io/msbuildprojectwriter.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROJECTWRITER_H +#define MSBUILDPROJECTWRITER_H + +#include + +#include + +#include + +namespace qbs { + +class MSBuildProject; +class MSBuildProjectWriterPrivate; + +class MSBuildProjectWriter +{ + Q_DISABLE_COPY(MSBuildProjectWriter) +public: + explicit MSBuildProjectWriter(std::ostream *device); + ~MSBuildProjectWriter(); + + bool write(const MSBuildProject *project); + +private: + const std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDPROJECTWRITER_H diff --git a/src/lib/msbuild/io/visualstudiosolutionwriter.cpp b/src/lib/msbuild/io/visualstudiosolutionwriter.cpp new file mode 100644 index 00000000..625489ac --- /dev/null +++ b/src/lib/msbuild/io/visualstudiosolutionwriter.cpp @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionwriter.h" + +#include "../solution/visualstudiosolutionfileproject.h" +#include "../solution/visualstudiosolutionfolderproject.h" +#include "../solution/visualstudiosolutionglobalsection.h" +#include "../solution/visualstudiosolution.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +namespace qbs { + +using namespace Internal; + +class VisualStudioSolutionWriterPrivate +{ +public: + std::ostream *device = nullptr; + std::string baseDir; +}; + +VisualStudioSolutionWriter::VisualStudioSolutionWriter(std::ostream *device) + : d(new VisualStudioSolutionWriterPrivate) +{ + d->device = device; +} + +VisualStudioSolutionWriter::~VisualStudioSolutionWriter() = default; + +std::string VisualStudioSolutionWriter::projectBaseDirectory() const +{ + return d->baseDir; +} + +void VisualStudioSolutionWriter::setProjectBaseDirectory(const std::string &dir) +{ + d->baseDir = dir; +} + +bool VisualStudioSolutionWriter::write(const VisualStudioSolution *solution) +{ + auto &out = *d->device; + out << u8"Microsoft Visual Studio Solution File, Format Version " + << solution->versionInfo().solutionVersion().toStdString() + << u8"\n# Visual Studio " + << solution->versionInfo().version().majorVersion() + << u8"\n"; + + const auto fileProjects = solution->fileProjects(); + for (const auto &project : fileProjects) { + auto projectFilePath = project->filePath().toStdString(); + + // Try to make the project file path relative to the + // solution file path if we're writing to a file device + if (!d->baseDir.empty()) { + const QDir solutionDir(QString::fromStdString(d->baseDir)); + projectFilePath = Internal::PathUtils::toNativeSeparators( + solutionDir.relativeFilePath(QString::fromStdString(projectFilePath)), + Internal::HostOsInfo::HostOsWindows).toStdString(); + } + + out << u8"Project(\"" + << project->projectTypeGuid().toString().toStdString() + << u8"\") = \"" + << QFileInfo(QString::fromStdString(projectFilePath)).baseName().toStdString() + << u8"\", \"" + << projectFilePath + << u8"\", \"" + << project->guid().toString().toStdString() + << u8"\"\n"; + + const auto dependencies = solution->dependencies(project); + if (!dependencies.empty()) { + out << u8"\tProjectSection(ProjectDependencies) = postProject\n"; + + for (const auto &dependency : dependencies) + out << u8"\t\t" + << dependency->guid().toString().toStdString() + << u8" = " + << dependency->guid().toString().toStdString() + << u8"\n"; + + out << u8"\tEndProjectSection\n"; + } + + out << u8"EndProject\n"; + } + + const auto folderProjects = solution->folderProjects(); + for (const auto &project : folderProjects) { + out << u8"Project(\"" + << project->projectTypeGuid().toString().toStdString() + << u8"\") = \"" + << project->name().toStdString() + << u8"\", \"" + << project->name().toStdString() + << u8"\", \"" + << project->guid().toString().toStdString() + << u8"\"\n"; + + out << u8"EndProject\n"; + } + + out << u8"Global\n"; + + const auto globalSections = solution->globalSections(); + for (const auto &globalSection : globalSections) { + out << u8"\tGlobalSection(" + << globalSection->name().toStdString() + << u8") = " + << (globalSection->isPost() ? u8"postSolution" : u8"preSolution") + << u8"\n"; + for (const auto &property : globalSection->properties()) + out << u8"\t\t" + << property.first.toStdString() + << u8" = " + << property.second.toStdString() + << u8"\n"; + + out << u8"\tEndGlobalSection\n"; + } + + out << u8"EndGlobal\n"; + + return out.good(); +} + +} // namespace qbs diff --git a/src/lib/msbuild/io/visualstudiosolutionwriter.h b/src/lib/msbuild/io/visualstudiosolutionwriter.h new file mode 100644 index 00000000..62ab45ea --- /dev/null +++ b/src/lib/msbuild/io/visualstudiosolutionwriter.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONWRITER_H +#define VISUALSTUDIOSOLUTIONWRITER_H + +#include +#include +#include + +#include + +namespace qbs { + +namespace Internal { class VisualStudioVersionInfo; } + +class VisualStudioSolution; +class VisualStudioSolutionWriterPrivate; + +class VisualStudioSolutionWriter +{ + Q_DISABLE_COPY(VisualStudioSolutionWriter) +public: + explicit VisualStudioSolutionWriter(std::ostream *device); + ~VisualStudioSolutionWriter(); + + std::string projectBaseDirectory() const; + void setProjectBaseDirectory(const std::string &dir); + + bool write(const VisualStudioSolution *solution); + +private: + void addDefaultGlobalSections(); + + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONWRITER_H diff --git a/src/lib/msbuild/msbuild.pro b/src/lib/msbuild/msbuild.pro new file mode 100644 index 00000000..f724df79 --- /dev/null +++ b/src/lib/msbuild/msbuild.pro @@ -0,0 +1,58 @@ +TARGET = qbsmsbuild +include(../staticlibrary.pri) +include(../corelib/use_corelib.pri) + +HEADERS += \ + io/msbuildprojectwriter.h \ + io/visualstudiosolutionwriter.h \ + msbuild/imsbuildgroup.h \ + msbuild/imsbuildnode.h \ + msbuild/imsbuildnodevisitor.h \ + msbuild/items/msbuildclcompile.h \ + msbuild/items/msbuildclinclude.h \ + msbuild/items/msbuildfileitem.h \ + msbuild/items/msbuildfilter.h \ + msbuild/items/msbuildlink.h \ + msbuild/items/msbuildnone.h \ + msbuild/msbuildimport.h \ + msbuild/msbuildimportgroup.h \ + msbuild/msbuilditem.h \ + msbuild/msbuilditemdefinitiongroup.h \ + msbuild/msbuilditemgroup.h \ + msbuild/msbuilditemmetadata.h \ + msbuild/msbuildproject.h \ + msbuild/msbuildproperty.h \ + msbuild/msbuildpropertybase.h \ + msbuild/msbuildpropertygroup.h \ + solution/ivisualstudiosolutionproject.h \ + solution/visualstudiosolution.h \ + solution/visualstudiosolutionfileproject.h \ + solution/visualstudiosolutionfolderproject.h \ + solution/visualstudiosolutionglobalsection.h + +SOURCES += \ + io/msbuildprojectwriter.cpp \ + io/visualstudiosolutionwriter.cpp \ + msbuild/imsbuildgroup.cpp \ + msbuild/imsbuildnode.cpp \ + msbuild/items/msbuildclcompile.cpp \ + msbuild/items/msbuildclinclude.cpp \ + msbuild/items/msbuildfileitem.cpp \ + msbuild/items/msbuildfilter.cpp \ + msbuild/items/msbuildlink.cpp \ + msbuild/items/msbuildnone.cpp \ + msbuild/msbuildimport.cpp \ + msbuild/msbuildimportgroup.cpp \ + msbuild/msbuilditem.cpp \ + msbuild/msbuilditemdefinitiongroup.cpp \ + msbuild/msbuilditemgroup.cpp \ + msbuild/msbuilditemmetadata.cpp \ + msbuild/msbuildproject.cpp \ + msbuild/msbuildproperty.cpp \ + msbuild/msbuildpropertybase.cpp \ + msbuild/msbuildpropertygroup.cpp \ + solution/ivisualstudiosolutionproject.cpp \ + solution/visualstudiosolution.cpp \ + solution/visualstudiosolutionfileproject.cpp \ + solution/visualstudiosolutionfolderproject.cpp \ + solution/visualstudiosolutionglobalsection.cpp diff --git a/src/lib/msbuild/msbuild.qbs b/src/lib/msbuild/msbuild.qbs new file mode 100644 index 00000000..505b977b --- /dev/null +++ b/src/lib/msbuild/msbuild.qbs @@ -0,0 +1,86 @@ +QbsStaticLibrary { + Depends { name: "cpp" } + Depends { name: "qbscore" } + name: "qbsmsbuild" + cpp.visibility: "default" + cpp.includePaths: base.concat([ + ".", + "../corelib", // for some header-only functions in tools + ]) + + Group { + name: "Solution Object Model" + prefix: "solution/" + files: [ + "ivisualstudiosolutionproject.cpp", + "ivisualstudiosolutionproject.h", + "visualstudiosolutionfileproject.cpp", + "visualstudiosolutionfileproject.h", + "visualstudiosolutionfolderproject.cpp", + "visualstudiosolutionfolderproject.h", + "visualstudiosolution.cpp", + "visualstudiosolution.h", + "visualstudiosolutionglobalsection.cpp", + "visualstudiosolutionglobalsection.h", + ] + } + Group { + name: "MSBuild Object Model" + prefix: "msbuild/" + files: [ + "imsbuildgroup.cpp", + "imsbuildgroup.h", + "imsbuildnode.cpp", + "imsbuildnode.h", + "imsbuildnodevisitor.h", + "msbuildimport.cpp", + "msbuildimport.h", + "msbuildimportgroup.cpp", + "msbuildimportgroup.h", + "msbuilditem.cpp", + "msbuilditem.h", + "msbuilditemdefinitiongroup.cpp", + "msbuilditemdefinitiongroup.h", + "msbuilditemgroup.cpp", + "msbuilditemgroup.h", + "msbuilditemmetadata.cpp", + "msbuilditemmetadata.h", + "msbuildproject.cpp", + "msbuildproject.h", + "msbuildproperty.cpp", + "msbuildproperty.h", + "msbuildpropertybase.cpp", + "msbuildpropertybase.h", + "msbuildpropertygroup.cpp", + "msbuildpropertygroup.h", + ] + } + Group { + name: "MSBuild Object Model Items" + prefix: "msbuild/items/" + files: [ + "msbuildclcompile.cpp", + "msbuildclcompile.h", + "msbuildclinclude.cpp", + "msbuildclinclude.h", + "msbuildfileitem.cpp", + "msbuildfileitem.h", + "msbuildfilter.cpp", + "msbuildfilter.h", + "msbuildlink.cpp", + "msbuildlink.h", + "msbuildnone.cpp", + "msbuildnone.h", + ] + } + Group { + name: "Visual Studio Object Model I/O" + prefix: "io/" + files: [ + "msbuildprojectwriter.cpp", + "msbuildprojectwriter.h", + "visualstudiosolutionwriter.cpp", + "visualstudiosolutionwriter.h", + ] + } +} diff --git a/src/lib/msbuild/msbuild/imsbuildgroup.cpp b/src/lib/msbuild/msbuild/imsbuildgroup.cpp new file mode 100644 index 00000000..81078ecb --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildgroup.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "imsbuildgroup.h" +#include "msbuildproject.h" + +namespace qbs { + +class IMSBuildGroupPrivate +{ +public: + QString condition; +}; + +IMSBuildGroup::IMSBuildGroup(MSBuildProject *parent) + : QObject(parent) + , d(new IMSBuildGroupPrivate) +{ +} + +IMSBuildGroup::~IMSBuildGroup() = default; + +QString IMSBuildGroup::condition() const +{ + return d->condition; +} + +void IMSBuildGroup::setCondition(const QString &condition) +{ + d->condition = condition; +} + +IMSBuildItemGroup::IMSBuildItemGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/imsbuildgroup.h b/src/lib/msbuild/msbuild/imsbuildgroup.h new file mode 100644 index 00000000..3d911564 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildgroup.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDGROUP_H +#define IMSBUILDGROUP_H + +#include + +#include + +namespace qbs { + +class MSBuildProject; +class IMSBuildGroupPrivate; + +class IMSBuildGroup : public QObject +{ + Q_OBJECT +public: + explicit IMSBuildGroup(MSBuildProject *parent = nullptr); + ~IMSBuildGroup() override; + + QString condition() const; + void setCondition(const QString &condition); + +private: + std::unique_ptr d; +}; + +class IMSBuildItemGroup : public IMSBuildGroup +{ + Q_OBJECT +public: + explicit IMSBuildItemGroup(MSBuildProject *parent = nullptr); +}; + +} // namespace qbs + +#endif // IMSBUILDGROUP_H diff --git a/src/lib/msbuild/msbuild/imsbuildnode.cpp b/src/lib/msbuild/msbuild/imsbuildnode.cpp new file mode 100644 index 00000000..f563f7b0 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnode.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "imsbuildnode.h" + +namespace qbs { + +IMSBuildNode::~IMSBuildNode() = default; + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/imsbuildnode.h b/src/lib/msbuild/msbuild/imsbuildnode.h new file mode 100644 index 00000000..67fb1008 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnode.h @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDNODE_H +#define IMSBUILDNODE_H + +namespace qbs { + +class IMSBuildNodeVisitor; + +class IMSBuildNode +{ +public: + virtual ~IMSBuildNode(); + virtual void accept(IMSBuildNodeVisitor *visitor) const = 0; +}; + +} // namespace qbs + +#endif // IMSBUILDNODE_H diff --git a/src/lib/msbuild/msbuild/imsbuildnodevisitor.h b/src/lib/msbuild/msbuild/imsbuildnodevisitor.h new file mode 100644 index 00000000..84239d64 --- /dev/null +++ b/src/lib/msbuild/msbuild/imsbuildnodevisitor.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IMSBUILDNODEVISITOR_H +#define IMSBUILDNODEVISITOR_H + +namespace qbs { + +class MSBuildImport; +class MSBuildImportGroup; +class MSBuildItem; +class MSBuildItemDefinitionGroup; +class MSBuildItemGroup; +class MSBuildItemMetadata; +class MSBuildProject; +class MSBuildProperty; +class MSBuildPropertyGroup; + +class IMSBuildNodeVisitor +{ +public: + virtual ~IMSBuildNodeVisitor() = default; + + virtual void visitStart(const MSBuildImport *import) = 0; + virtual void visitEnd(const MSBuildImport *import) = 0; + + virtual void visitStart(const MSBuildImportGroup *importGroup) = 0; + virtual void visitEnd(const MSBuildImportGroup *importGroup) = 0; + + virtual void visitStart(const MSBuildItem *item) = 0; + virtual void visitEnd(const MSBuildItem *item) = 0; + + virtual void visitStart(const MSBuildItemDefinitionGroup *itemDefinitionGroup) = 0; + virtual void visitEnd(const MSBuildItemDefinitionGroup *itemDefinitionGroup) = 0; + + virtual void visitStart(const MSBuildItemGroup *itemGroup) = 0; + virtual void visitEnd(const MSBuildItemGroup *itemGroup) = 0; + + virtual void visitStart(const MSBuildItemMetadata *itemMetadata) = 0; + virtual void visitEnd(const MSBuildItemMetadata *itemMetadata) = 0; + + virtual void visitStart(const MSBuildProject *project) = 0; + virtual void visitEnd(const MSBuildProject *project) = 0; + + virtual void visitStart(const MSBuildProperty *property) = 0; + virtual void visitEnd(const MSBuildProperty *property) = 0; + + virtual void visitStart(const MSBuildPropertyGroup *propertyGroup) = 0; + virtual void visitEnd(const MSBuildPropertyGroup *propertyGroup) = 0; +}; + +} // namespace qbs + +#endif // IMSBUILDNODEVISITOR_H diff --git a/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp b/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp new file mode 100644 index 00000000..d8a58745 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclcompile.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildclcompile.h" + +namespace qbs { + +static const QString MSBuildClCompileItemName = QStringLiteral("ClCompile"); + +MSBuildClCompile::MSBuildClCompile(IMSBuildItemGroup *parent) + : MSBuildFileItem(MSBuildClCompileItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildclcompile.h b/src/lib/msbuild/msbuild/items/msbuildclcompile.h new file mode 100644 index 00000000..8c326a03 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclcompile.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDCLCOMPILE_H +#define MSBUILDCLCOMPILE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildClCompile : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildClCompile) +public: + explicit MSBuildClCompile(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDCLCOMPILE_H diff --git a/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp b/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp new file mode 100644 index 00000000..d9c61bec --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclinclude.cpp @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildclinclude.h" + +namespace qbs { + +static const QString MSBuildClIncludeItemName = QStringLiteral("ClInclude"); + +MSBuildClInclude::MSBuildClInclude(IMSBuildItemGroup *parent) + : MSBuildFileItem(MSBuildClIncludeItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildclinclude.h b/src/lib/msbuild/msbuild/items/msbuildclinclude.h new file mode 100644 index 00000000..77d8e0ff --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildclinclude.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDCLINCLUDE_H +#define MSBUILDCLINCLUDE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildClInclude : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildClInclude) +public: + explicit MSBuildClInclude(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDCLINCLUDE_H diff --git a/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp b/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp new file mode 100644 index 00000000..4cbb01d0 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfileitem.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfileitem.h" + +#include +#include "../msbuilditemmetadata.h" + +namespace qbs { + +class MSBuildFileItemPrivate +{ +public: + std::unique_ptr filter; +}; + +MSBuildFileItem::MSBuildFileItem(const QString &name, IMSBuildItemGroup *parent) + : MSBuildItem(name, parent) + , d(new MSBuildFileItemPrivate) +{ + d->filter = std::make_unique(QStringLiteral("Filter"), QVariant()); +} + +MSBuildFileItem::~MSBuildFileItem() = default; + +QString MSBuildFileItem::filePath() const +{ + return include(); +} + +void MSBuildFileItem::setFilePath(const QString &filePath) +{ + setInclude(filePath); +} + +QString MSBuildFileItem::filterName() const +{ + return d->filter->value().toString(); +} + +void MSBuildFileItem::setFilterName(const QString &filterName) +{ + d->filter->setValue(filterName); + d->filter->setParent(!filterName.isEmpty() ? this : nullptr); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildfileitem.h b/src/lib/msbuild/msbuild/items/msbuildfileitem.h new file mode 100644 index 00000000..f34ac119 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfileitem.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDFILEITEM_H +#define MSBUILDFILEITEM_H + +#include "../msbuilditem.h" + +namespace qbs { + +class MSBuildFileItemPrivate; + +class MSBuildFileItem : public MSBuildItem +{ +public: + ~MSBuildFileItem() override; + + QString filePath() const; + void setFilePath(const QString &filePath); + + QString filterName() const; + void setFilterName(const QString &filterName); + +protected: + explicit MSBuildFileItem(const QString &name, IMSBuildItemGroup *parent = nullptr); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDFILEITEM_H diff --git a/src/lib/msbuild/msbuild/items/msbuildfilter.cpp b/src/lib/msbuild/msbuild/items/msbuildfilter.cpp new file mode 100644 index 00000000..0b9c2c86 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfilter.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfilter.h" +#include "../msbuilditemmetadata.h" +#include +#include + +namespace qbs { + +static const QString MSBuildFilterItemName = QStringLiteral("Filter"); + +class MSBuildFilterPrivate +{ +public: + QUuid identifier; + QList extensions; + bool parseFiles = true; + bool sourceControlFiles = true; + MSBuildItemMetadata *identifierMetadata = nullptr; + MSBuildItemMetadata *extensionsMetadata = nullptr; +}; + +MSBuildFilter::MSBuildFilter(IMSBuildItemGroup *parent) + : MSBuildItem(MSBuildFilterItemName, parent) + , d(new MSBuildFilterPrivate) +{ + d->identifierMetadata = new MSBuildItemMetadata(QStringLiteral("UniqueIdentifier"), + QVariant(), this); + d->extensionsMetadata = new MSBuildItemMetadata(QStringLiteral("Extensions"), + QVariant(), this); + setIdentifier(QUuid::createUuid()); +} + +MSBuildFilter::MSBuildFilter(const QString &name, + const QList &extensions, + IMSBuildItemGroup *parent) + : MSBuildFilter(parent) +{ + setInclude(name); + setExtensions(extensions); +} + +MSBuildFilter::~MSBuildFilter() = default; + +QUuid MSBuildFilter::identifier() const +{ + return d->identifier; +} + +void MSBuildFilter::setIdentifier(const QUuid &identifier) +{ + d->identifier = identifier; + d->identifierMetadata->setValue(identifier.toString()); +} + +QList MSBuildFilter::extensions() const +{ + return d->extensions; +} + +void MSBuildFilter::setExtensions(const QList &extensions) +{ + d->extensions = extensions; + d->extensionsMetadata->setValue(QStringList(extensions).join( + Internal::HostOsInfo::pathListSeparator( + Internal::HostOsInfo::HostOsWindows))); +} + +bool MSBuildFilter::parseFiles() const +{ + return d->parseFiles; +} + +void MSBuildFilter::setParseFiles(bool parseFiles) +{ + d->parseFiles = parseFiles; +} + +bool MSBuildFilter::sourceControlFiles() const +{ + return d->sourceControlFiles; +} + +void MSBuildFilter::setSourceControlFiles(bool sourceControlFiles) +{ + d->sourceControlFiles = sourceControlFiles; +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildfilter.h b/src/lib/msbuild/msbuild/items/msbuildfilter.h new file mode 100644 index 00000000..fb977f1c --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildfilter.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDFILTER_H +#define MSBUILDFILTER_H + +#include "../msbuilditem.h" + +namespace qbs { + +class IMSBuildItemGroup; +class MSBuildFilterPrivate; + +class MSBuildFilter : public MSBuildItem +{ + Q_OBJECT +public: + explicit MSBuildFilter(IMSBuildItemGroup *parent = nullptr); + MSBuildFilter(const QString &name, const QList &extensions, + IMSBuildItemGroup *parent = nullptr); + ~MSBuildFilter() override; + + QUuid identifier() const; + void setIdentifier(const QUuid &identifier); + + QList extensions() const; + void setExtensions(const QList &extensions); + + bool parseFiles() const; + void setParseFiles(bool parseFiles); + + bool sourceControlFiles() const; + void setSourceControlFiles(bool sourceControlFiles); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDFILTER_H diff --git a/src/lib/msbuild/msbuild/items/msbuildlink.cpp b/src/lib/msbuild/msbuild/items/msbuildlink.cpp new file mode 100644 index 00000000..cae1a63a --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildlink.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildlink.h" + +#include "../imsbuildgroup.h" + +namespace qbs { + +static const QString MSBuildLinkItemName = QStringLiteral("Link"); + +MSBuildLink::MSBuildLink(IMSBuildItemGroup *parent) + : MSBuildItem(MSBuildLinkItemName, parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildlink.h b/src/lib/msbuild/msbuild/items/msbuildlink.h new file mode 100644 index 00000000..3d7a3ab4 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildlink.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDLINK_H +#define MSBUILDLINK_H + +#include "../msbuilditem.h" + +namespace qbs { + +class IMSBuildItemGroup; + +class MSBuildLink : public MSBuildItem +{ + Q_OBJECT +public: + explicit MSBuildLink(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDLINK_H diff --git a/src/lib/msbuild/msbuild/items/msbuildnone.cpp b/src/lib/msbuild/msbuild/items/msbuildnone.cpp new file mode 100644 index 00000000..a590c6e9 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildnone.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildnone.h" + +namespace qbs { + +MSBuildNone::MSBuildNone(IMSBuildItemGroup *parent) + : MSBuildFileItem(QStringLiteral("None"), parent) +{ +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/items/msbuildnone.h b/src/lib/msbuild/msbuild/items/msbuildnone.h new file mode 100644 index 00000000..3779da04 --- /dev/null +++ b/src/lib/msbuild/msbuild/items/msbuildnone.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDNONE_H +#define MSBUILDNONE_H + +#include "msbuildfileitem.h" + +namespace qbs { + +class MSBuildNone : public MSBuildFileItem +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildNone) +public: + explicit MSBuildNone(IMSBuildItemGroup *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDNONE_H diff --git a/src/lib/msbuild/msbuild/msbuildimport.cpp b/src/lib/msbuild/msbuild/msbuildimport.cpp new file mode 100644 index 00000000..000af449 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimport.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildimport.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimportgroup.h" +#include "msbuildproject.h" + +namespace qbs { + +class MSBuildImportPrivate +{ +public: + QString project; + QString condition; +}; + +MSBuildImport::MSBuildImport(MSBuildProject *parent) + : QObject(parent) + , d(new MSBuildImportPrivate) +{ +} + +MSBuildImport::MSBuildImport(MSBuildImportGroup *parent) + : QObject(parent) + , d(new MSBuildImportPrivate) +{ +} + +MSBuildImport::~MSBuildImport() = default; + +QString MSBuildImport::project() const +{ + return d->project; +} + +void MSBuildImport::setProject(const QString &project) +{ + d->project = project; +} + +QString MSBuildImport::condition() const +{ + return d->condition; +} + +void MSBuildImport::setCondition(const QString &condition) +{ + d->condition = condition; +} + +void MSBuildImport::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildimport.h b/src/lib/msbuild/msbuild/msbuildimport.h new file mode 100644 index 00000000..65f9bc05 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimport.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef MSBUILDIMPORT_H +#define MSBUILDIMPORT_H + +#include +#include "imsbuildnode.h" + +#include + +namespace qbs { + +class MSBuildImportGroup; +class MSBuildImportPrivate; +class MSBuildProject; + +/*! + * \brief The MSBuildImport class represents an MSBuild Import element. + * + * https://msdn.microsoft.com/en-us/library/92x05xfs.aspx + */ +class MSBuildImport : public QObject, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildImport) +public: + explicit MSBuildImport(MSBuildProject *parent); + explicit MSBuildImport(MSBuildImportGroup *parent); + ~MSBuildImport() override; + + QString project() const; + void setProject(const QString &project); + + QString condition() const; + void setCondition(const QString &condition); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDIMPORT_H diff --git a/src/lib/msbuild/msbuild/msbuildimportgroup.cpp b/src/lib/msbuild/msbuild/msbuildimportgroup.cpp new file mode 100644 index 00000000..d84d8178 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimportgroup.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildimportgroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimport.h" + +namespace qbs { + +class MSBuildImportGroupPrivate +{ +public: + QString label; +}; + +MSBuildImportGroup::MSBuildImportGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) + , d(new MSBuildImportGroupPrivate) +{ +} + +MSBuildImportGroup::~MSBuildImportGroup() = default; + +QString MSBuildImportGroup::label() const +{ + return d->label; +} + +void MSBuildImportGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildImportGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto import = qobject_cast(child)) + import->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildimportgroup.h b/src/lib/msbuild/msbuild/msbuildimportgroup.h new file mode 100644 index 00000000..a21cb5a5 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildimportgroup.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDIMPORTGROUP_H +#define MSBUILDIMPORTGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildImportGroupPrivate; + +/*! + * \brief The MSBuildImportGroup class represents an MSBuild ImportGroup element. + * + * https://msdn.microsoft.com/en-us/library/ff606262.aspx + */ +class MSBuildImportGroup : public IMSBuildGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildImportGroup) +public: + explicit MSBuildImportGroup(MSBuildProject *parent = nullptr); + ~MSBuildImportGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDIMPORTGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditem.cpp b/src/lib/msbuild/msbuild/msbuilditem.cpp new file mode 100644 index 00000000..ed181a45 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditem.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditem.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditemdefinitiongroup.h" +#include "msbuilditemgroup.h" +#include "msbuilditemmetadata.h" + +namespace qbs { + +class MSBuildItemPrivate +{ +public: + QString name = QStringLiteral("Item"); + QString include; +}; + +MSBuildItem::MSBuildItem(const QString &name, IMSBuildItemGroup *parent) + : QObject(parent) + , d(new MSBuildItemPrivate) +{ + setName(name); +} + +MSBuildItem::~MSBuildItem() = default; + +QString MSBuildItem::name() const +{ + return d->name; +} + +void MSBuildItem::setName(const QString &name) +{ + d->name = name; +} + +QString MSBuildItem::include() const +{ + return d->include; +} + +void MSBuildItem::setInclude(const QString &include) +{ + d->include = include; +} + +void MSBuildItem::appendProperty(const QString &name, const QVariant &value) +{ + new MSBuildItemMetadata(name, value, this); +} + +void MSBuildItem::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto itemMetadata = qobject_cast(child)) + itemMetadata->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditem.h b/src/lib/msbuild/msbuild/msbuilditem.h new file mode 100644 index 00000000..d01a357a --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditem.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEM_H +#define MSBUILDITEM_H + +#include +#include "imsbuildnode.h" + +#include + +namespace qbs { + +class IMSBuildItemGroup; +class MSBuildItemDefinitionGroup; +class MSBuildItemGroup; +class MSBuildItemPrivate; + +/*! + * \brief The MSBuildItem class represents an MSBuild Item element. + * + * https://msdn.microsoft.com/en-us/library/ms164283.aspx + */ +class MSBuildItem : public QObject, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildItem(const QString &name, IMSBuildItemGroup *parent = nullptr); + ~MSBuildItem() override; + + QString name() const; + void setName(const QString &name); + + QString include() const; + void setInclude(const QString &include); + + void appendProperty(const QString &name, const QVariant &value); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDITEM_H diff --git a/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp new file mode 100644 index 00000000..1479577c --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemdefinitiongroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +namespace qbs { + +MSBuildItemDefinitionGroup::MSBuildItemDefinitionGroup(MSBuildProject *parent) + : IMSBuildItemGroup(parent) +{ +} + +MSBuildItemDefinitionGroup::~MSBuildItemDefinitionGroup() = default; + +void MSBuildItemDefinitionGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto item = qobject_cast(child)) + item->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h new file mode 100644 index 00000000..3c324699 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemdefinitiongroup.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMDEFINITIONGROUP_H +#define MSBUILDITEMDEFINITIONGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildItemDefinitionGroupPrivate; + +/*! + * \brief The MSBuildItemDefinitionGroup class represents an MSBuild ItemDefinitionGroup element. + * + * https://msdn.microsoft.com/en-us/library/bb629392.aspx + */ +class MSBuildItemDefinitionGroup : public IMSBuildItemGroup, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildItemDefinitionGroup(MSBuildProject *parent = nullptr); + ~MSBuildItemDefinitionGroup() override; + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDITEMDEFINITIONGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditemgroup.cpp b/src/lib/msbuild/msbuild/msbuilditemgroup.cpp new file mode 100644 index 00000000..48f91970 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemgroup.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemgroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +#include + +namespace qbs { + +class MSBuildItemGroupPrivate +{ +public: + QString label; +}; + +MSBuildItemGroup::MSBuildItemGroup(MSBuildProject *parent) + : IMSBuildItemGroup(parent) + , d(new MSBuildItemGroupPrivate) +{ +} + +MSBuildItemGroup::~MSBuildItemGroup() = default; + +QString MSBuildItemGroup::label() const +{ + return d->label; +} + +void MSBuildItemGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildItemGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const MSBuildItem *item = qobject_cast(child)) + item->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemgroup.h b/src/lib/msbuild/msbuild/msbuilditemgroup.h new file mode 100644 index 00000000..bbbdb0e6 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemgroup.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMGROUP_H +#define MSBUILDITEMGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +#include + +namespace qbs { + +class MSBuildProject; +class MSBuildItemGroupPrivate; + +/*! + * \brief The MSBuildItemGroup class represents an MSBuild ItemGroup element. + * + * https://msdn.microsoft.com/en-us/library/646dk05y.aspx + */ +class MSBuildItemGroup : public IMSBuildItemGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildItemGroup) +public: + explicit MSBuildItemGroup(MSBuildProject *parent = nullptr); + ~MSBuildItemGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDITEMGROUP_H diff --git a/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp b/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp new file mode 100644 index 00000000..2f315287 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemmetadata.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuilditemmetadata.h" + +#include "imsbuildnodevisitor.h" +#include "msbuilditem.h" + +namespace qbs { + +MSBuildItemMetadata::MSBuildItemMetadata(MSBuildItem *parent) + : MSBuildPropertyBase(parent) +{ +} + +MSBuildItemMetadata::MSBuildItemMetadata(const QString &name, const QVariant &value, + MSBuildItem *parent) + : MSBuildItemMetadata(parent) +{ + setName(name); + setValue(value); +} + +void MSBuildItemMetadata::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuilditemmetadata.h b/src/lib/msbuild/msbuild/msbuilditemmetadata.h new file mode 100644 index 00000000..cfde125b --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuilditemmetadata.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDITEMMETADATA_H +#define MSBUILDITEMMETADATA_H + +#include "imsbuildnode.h" +#include "msbuildpropertybase.h" + +namespace qbs { + +class MSBuildItem; + +/*! + * \brief The MSBuildItemMetadata class represents an MSBuild ItemMetadata element. + * + * https://msdn.microsoft.com/en-us/library/ms164284.aspx + */ +class MSBuildItemMetadata : public MSBuildPropertyBase, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildItemMetadata) +public: + explicit MSBuildItemMetadata(MSBuildItem *parent = nullptr); + MSBuildItemMetadata(const QString &name, const QVariant &value = QVariant(), + MSBuildItem *parent = nullptr); + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDITEMMETADATA_H diff --git a/src/lib/msbuild/msbuild/msbuildproject.cpp b/src/lib/msbuild/msbuild/msbuildproject.cpp new file mode 100644 index 00000000..11b5b81e --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproject.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildproject.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildimport.h" +#include "msbuildimportgroup.h" +#include "msbuilditemdefinitiongroup.h" +#include "msbuilditemgroup.h" +#include "msbuildpropertygroup.h" + +namespace qbs { + +class MSBuildProjectPrivate +{ +public: + QString defaultTargets; + QString toolsVersion; +}; + +MSBuildProject::MSBuildProject(QObject *parent) + : QObject(parent) + , d(new MSBuildProjectPrivate) +{ +} + +MSBuildProject::~MSBuildProject() = default; + +QString MSBuildProject::defaultTargets() const +{ + return d->defaultTargets; +} + +void MSBuildProject::setDefaultTargets(const QString &defaultTargets) +{ + d->defaultTargets = defaultTargets; +} + +QString MSBuildProject::toolsVersion() const +{ + return d->toolsVersion; +} + +void MSBuildProject::setToolsVersion(const QString &toolsVersion) +{ + d->toolsVersion = toolsVersion; +} + +void MSBuildProject::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const auto node = qobject_cast(child)) + node->accept(visitor); + else if (const auto node = qobject_cast(child)) + node->accept(visitor); + else if (const auto node = qobject_cast(child)) + node->accept(visitor); + else if (const auto node = qobject_cast(child)) + node->accept(visitor); + else if (const auto node = qobject_cast(child)) + node->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildproject.h b/src/lib/msbuild/msbuild/msbuildproject.h new file mode 100644 index 00000000..5281f615 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproject.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROJECT_H +#define MSBUILDPROJECT_H + +#include +#include "imsbuildnode.h" + +#include + +namespace qbs { + +class MSBuildProjectPrivate; + +/*! + * \brief The MSBuildProject class represents an MSBuild Project element. + * + * https://msdn.microsoft.com/en-us/library/bcxfsh87.aspx + */ +class MSBuildProject : public QObject, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildProject) +public: + explicit MSBuildProject(QObject *parent = nullptr); + ~MSBuildProject() override; + + QString defaultTargets() const; + void setDefaultTargets(const QString &defaultTargets); + + QString toolsVersion() const; + void setToolsVersion(const QString &toolsVersion); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDPROJECT_H diff --git a/src/lib/msbuild/msbuild/msbuildproperty.cpp b/src/lib/msbuild/msbuild/msbuildproperty.cpp new file mode 100644 index 00000000..fd6942d0 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproperty.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildproperty.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildpropertygroup.h" + +namespace qbs { + +MSBuildProperty::MSBuildProperty(MSBuildPropertyGroup *parent) + : MSBuildPropertyBase(parent) +{ +} + +MSBuildProperty::MSBuildProperty(const QString &name, const QVariant &value, + MSBuildPropertyGroup *parent) + : MSBuildProperty(parent) +{ + setName(name); + setValue(value); +} + +void MSBuildProperty::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildproperty.h b/src/lib/msbuild/msbuild/msbuildproperty.h new file mode 100644 index 00000000..4fd36b27 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildproperty.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROPERTY_H +#define MSBUILDPROPERTY_H + +#include "imsbuildnode.h" +#include "msbuildpropertybase.h" + +namespace qbs { + +class MSBuildPropertyGroup; + +/*! + * \brief The MSBuildProperty class represents an MSBuild Property element. + * + * https://msdn.microsoft.com/en-us/library/ms164288.aspx + */ +class MSBuildProperty : public MSBuildPropertyBase, public IMSBuildNode +{ + Q_OBJECT +public: + explicit MSBuildProperty(MSBuildPropertyGroup *parent = nullptr); + MSBuildProperty(const QString &name, const QVariant &value = QVariant(), + MSBuildPropertyGroup *parent = nullptr); + + void accept(IMSBuildNodeVisitor *visitor) const override; +}; + +} // namespace qbs + +#endif // MSBUILDPROPERTY_H diff --git a/src/lib/msbuild/msbuild/msbuildpropertybase.cpp b/src/lib/msbuild/msbuild/msbuildpropertybase.cpp new file mode 100644 index 00000000..3a8affd3 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertybase.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildpropertybase.h" + +namespace qbs { + +class MSBuildPropertyBasePrivate +{ +public: + QString condition; + QString name; + QVariant value; +}; + +MSBuildPropertyBase::MSBuildPropertyBase(QObject *parent) + : QObject(parent) + , d(new MSBuildPropertyBasePrivate) +{ +} + +MSBuildPropertyBase::~MSBuildPropertyBase() = default; + +QString MSBuildPropertyBase::condition() const +{ + return d->condition; +} + +void MSBuildPropertyBase::setCondition(const QString &condition) +{ + d->condition = condition; +} + +QString MSBuildPropertyBase::name() const +{ + return d->name; +} + +void MSBuildPropertyBase::setName(const QString &name) +{ + d->name = name; +} + +QVariant MSBuildPropertyBase::value() const +{ + return d->value; +} + +void MSBuildPropertyBase::setValue(const QVariant &value) +{ + d->value = value; +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildpropertybase.h b/src/lib/msbuild/msbuild/msbuildpropertybase.h new file mode 100644 index 00000000..b4d25f82 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertybase.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROPERTYBASE_H +#define MSBUILDPROPERTYBASE_H + +#include +#include + +#include + +namespace qbs { + +class MSBuildPropertyBasePrivate; + +class MSBuildPropertyBase : public QObject +{ + Q_OBJECT +protected: + explicit MSBuildPropertyBase(QObject *parent = nullptr); + +public: + ~MSBuildPropertyBase() override; + + QString condition() const; + void setCondition(const QString &condition); + + QString name() const; + void setName(const QString &name); + + QVariant value() const; + void setValue(const QVariant &value); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDPROPERTYBASE_H diff --git a/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp b/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp new file mode 100644 index 00000000..5acb73da --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertygroup.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildpropertygroup.h" + +#include "imsbuildnodevisitor.h" +#include "msbuildproperty.h" + +namespace qbs { + +class MSBuildPropertyGroupPrivate +{ +public: + QString condition; + QString label; +}; + +MSBuildPropertyGroup::MSBuildPropertyGroup(MSBuildProject *parent) + : IMSBuildGroup(parent) + , d(new MSBuildPropertyGroupPrivate) +{ +} + +MSBuildPropertyGroup::~MSBuildPropertyGroup() = default; + +QString MSBuildPropertyGroup::label() const +{ + return d->label; +} + +void MSBuildPropertyGroup::setLabel(const QString &label) +{ + d->label = label; +} + +void MSBuildPropertyGroup::appendProperty(const QString &name, const QVariant &value) +{ + new MSBuildProperty(name, value, this); +} + +void MSBuildPropertyGroup::accept(IMSBuildNodeVisitor *visitor) const +{ + visitor->visitStart(this); + + for (const auto &child : children()) { + if (const MSBuildProperty *property = qobject_cast(child)) + property->accept(visitor); + } + + visitor->visitEnd(this); +} + +} // namespace qbs diff --git a/src/lib/msbuild/msbuild/msbuildpropertygroup.h b/src/lib/msbuild/msbuild/msbuildpropertygroup.h new file mode 100644 index 00000000..60bdb008 --- /dev/null +++ b/src/lib/msbuild/msbuild/msbuildpropertygroup.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDPROPERTYGROUP_H +#define MSBUILDPROPERTYGROUP_H + +#include "imsbuildgroup.h" +#include "imsbuildnode.h" + +namespace qbs { + +class MSBuildProject; +class MSBuildPropertyGroupPrivate; + +/*! + * \brief The MSBuildPropertyGroup class represents an MSBuild PropertyGroup element. + * + * https://msdn.microsoft.com/en-us/library/t4w159bs.aspx + */ +class MSBuildPropertyGroup : public IMSBuildGroup, public IMSBuildNode +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildPropertyGroup) +public: + explicit MSBuildPropertyGroup(MSBuildProject *parent = nullptr); + ~MSBuildPropertyGroup() override; + + QString label() const; + void setLabel(const QString &label); + + void appendProperty(const QString &name, const QVariant &value); + + void accept(IMSBuildNodeVisitor *visitor) const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDPROPERTYGROUP_H diff --git a/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp b/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp new file mode 100644 index 00000000..4623b5d4 --- /dev/null +++ b/src/lib/msbuild/solution/ivisualstudiosolutionproject.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "ivisualstudiosolutionproject.h" + +namespace qbs { + +class IVisualStudioSolutionProjectPrivate +{ +public: + QUuid guid = QUuid::createUuid(); + QString name; + QString filePath; +}; + +IVisualStudioSolutionProject::IVisualStudioSolutionProject(QObject *parent) + : QObject(parent) + , d(new IVisualStudioSolutionProjectPrivate) +{ +} + +IVisualStudioSolutionProject::~IVisualStudioSolutionProject() = default; + +QUuid IVisualStudioSolutionProject::guid() const +{ + return d->guid; +} + +void IVisualStudioSolutionProject::setGuid(const QUuid &guid) +{ + d->guid = guid; +} + +QString IVisualStudioSolutionProject::name() const +{ + return d->name; +} + +void IVisualStudioSolutionProject::setName(const QString &name) +{ + d->name = name; +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/ivisualstudiosolutionproject.h b/src/lib/msbuild/solution/ivisualstudiosolutionproject.h new file mode 100644 index 00000000..6f8574ae --- /dev/null +++ b/src/lib/msbuild/solution/ivisualstudiosolutionproject.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef IVISUALSTUDIOSOLUTIONPROJECT_H +#define IVISUALSTUDIOSOLUTIONPROJECT_H + +#include +#include +#include + +#include + +namespace qbs { + +class IVisualStudioSolutionProjectPrivate; + +class IVisualStudioSolutionProject : public QObject +{ + Q_OBJECT +protected: + explicit IVisualStudioSolutionProject(QObject *parent = nullptr); + +public: + ~IVisualStudioSolutionProject() override; + + virtual QUuid projectTypeGuid() const = 0; + + QUuid guid() const; + void setGuid(const QUuid &guid); + + virtual QString name() const; + void setName(const QString &name); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // IVISUALSTUDIOSOLUTIONPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolution.cpp b/src/lib/msbuild/solution/visualstudiosolution.cpp new file mode 100644 index 00000000..89b26664 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolution.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolution.h" + +#include "visualstudiosolutionfileproject.h" +#include "visualstudiosolutionfolderproject.h" + +#include + +#include + +namespace qbs { + +class VisualStudioSolutionPrivate +{ +public: + VisualStudioSolutionPrivate(const Internal::VisualStudioVersionInfo &versionInfo) + : versionInfo(versionInfo) { } + const Internal::VisualStudioVersionInfo versionInfo; + QList projects; + QMap> dependencies; + QList globalSections; +}; + +VisualStudioSolution::VisualStudioSolution(const Internal::VisualStudioVersionInfo &versionInfo, + QObject *parent) + : QObject(parent) + , d(new VisualStudioSolutionPrivate(versionInfo)) +{ +} + +VisualStudioSolution::~VisualStudioSolution() = default; + +Internal::VisualStudioVersionInfo VisualStudioSolution::versionInfo() const +{ + return d->versionInfo; +} + +QList VisualStudioSolution::projects() const +{ + return d->projects; +} + +QList VisualStudioSolution::fileProjects() const +{ + QList list; + for (const auto &project : qAsConst(d->projects)) + if (auto fileProject = qobject_cast(project)) + list.push_back(fileProject); + return list; +} + +QList VisualStudioSolution::folderProjects() const +{ + QList list; + for (const auto &project : qAsConst(d->projects)) + if (auto folderProject = qobject_cast(project)) + list.push_back(folderProject); + return list; +} + +void VisualStudioSolution::appendProject(IVisualStudioSolutionProject *project) +{ + d->projects.push_back(project); +} + +QList VisualStudioSolution::dependencies( + VisualStudioSolutionFileProject *project) const +{ + return d->dependencies.value(project); +} + +void VisualStudioSolution::addDependency(VisualStudioSolutionFileProject *project, + VisualStudioSolutionFileProject *dependency) +{ + d->dependencies[project].push_back(dependency); +} + +QList VisualStudioSolution::globalSections() const +{ + return d->globalSections; +} + +void VisualStudioSolution::appendGlobalSection(VisualStudioSolutionGlobalSection *globalSection) +{ + d->globalSections.push_back(globalSection); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolution.h b/src/lib/msbuild/solution/visualstudiosolution.h new file mode 100644 index 00000000..ba304c00 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolution.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTION_H +#define VISUALSTUDIOSOLUTION_H + +#include + +#include + +namespace qbs { + +namespace Internal { class VisualStudioVersionInfo; } + +class MSBuildProject; + +class IVisualStudioSolutionProject; +class VisualStudioSolutionFileProject; +class VisualStudioSolutionFolderProject; +class VisualStudioSolutionGlobalSection; + +class VisualStudioSolutionPrivate; + +class VisualStudioSolution : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(VisualStudioSolution) +public: + explicit VisualStudioSolution(const Internal::VisualStudioVersionInfo &versionInfo, + QObject *parent = nullptr); + ~VisualStudioSolution() override; + + Internal::VisualStudioVersionInfo versionInfo() const; + + QList projects() const; + QList fileProjects() const; + QList folderProjects() const; + void appendProject(IVisualStudioSolutionProject *project); + void removeProject(const IVisualStudioSolutionProject *project); + void clearProjects(); + + QList dependencies( + VisualStudioSolutionFileProject *project) const; + void addDependency(VisualStudioSolutionFileProject *project, + VisualStudioSolutionFileProject *dependency); + + QList globalSections() const; + void appendGlobalSection(VisualStudioSolutionGlobalSection *globalSection); + +private: + void addDefaultGlobalSections(); + + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTION_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp b/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp new file mode 100644 index 00000000..7a67ce22 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfileproject.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionfileproject.h" + +#include + +namespace qbs { + +class VisualStudioSolutionFileProjectPrivate +{ +public: + QString filePath; +}; + +VisualStudioSolutionFileProject::VisualStudioSolutionFileProject(const QString &filePath, + QObject *parent) + : IVisualStudioSolutionProject(parent) + , d(new VisualStudioSolutionFileProjectPrivate) +{ + setFilePath(filePath); +} + +VisualStudioSolutionFileProject::~VisualStudioSolutionFileProject() = default; + +QString VisualStudioSolutionFileProject::name() const +{ + const auto projectName = IVisualStudioSolutionProject::name(); + if (projectName.isEmpty()) + return QFileInfo(filePath()).baseName(); + return projectName; +} + +QUuid VisualStudioSolutionFileProject::projectTypeGuid() const +{ + return QUuid::fromString(QStringLiteral("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}")); // C++ +} + +QString VisualStudioSolutionFileProject::filePath() const +{ + return d->filePath; +} + +void VisualStudioSolutionFileProject::setFilePath(const QString &filePath) +{ + d->filePath = filePath; +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionfileproject.h b/src/lib/msbuild/solution/visualstudiosolutionfileproject.h new file mode 100644 index 00000000..2039146b --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfileproject.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONFILEPROJECT_H +#define VISUALSTUDIOSOLUTIONFILEPROJECT_H + +#include +#include "ivisualstudiosolutionproject.h" + +#include + +namespace qbs { + +class VisualStudioSolutionFileProjectPrivate; + +class VisualStudioSolutionFileProject : public IVisualStudioSolutionProject +{ + Q_OBJECT +public: + explicit VisualStudioSolutionFileProject(const QString &filePath, QObject *parent = nullptr); + ~VisualStudioSolutionFileProject() override; + + QString name() const override; + + QString filePath() const; + void setFilePath(const QString &filePath); + + QUuid projectTypeGuid() const override; + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONFILEPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp new file mode 100644 index 00000000..8b099704 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionfolderproject.h" + +#include + +namespace qbs { + +VisualStudioSolutionFolderProject::VisualStudioSolutionFolderProject(QObject *parent) + : IVisualStudioSolutionProject(parent) +{ +} + +QUuid VisualStudioSolutionFolderProject::projectTypeGuid() const +{ + return QUuid::fromString(QStringLiteral("{2150E333-8FDC-42A3-9474-1A3956D46DE8}")); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h new file mode 100644 index 00000000..a7fd180c --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionfolderproject.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONFOLDERPROJECT_H +#define VISUALSTUDIOSOLUTIONFOLDERPROJECT_H + +#include +#include "ivisualstudiosolutionproject.h" + +namespace qbs { + +class VisualStudioSolutionFolderProject : public IVisualStudioSolutionProject +{ + Q_OBJECT +public: + explicit VisualStudioSolutionFolderProject(QObject *parent); + + QUuid projectTypeGuid() const override; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONFOLDERPROJECT_H diff --git a/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp new file mode 100644 index 00000000..5cbb0cd6 --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudiosolutionglobalsection.h" + +#include +#include + +namespace qbs { + +class VisualStudioSolutionGlobalSectionPrivate +{ +public: + QString name; + std::vector> properties; + bool post = false; +}; + +VisualStudioSolutionGlobalSection::VisualStudioSolutionGlobalSection(const QString &name, + QObject *parent) + : QObject(parent) + , d(new VisualStudioSolutionGlobalSectionPrivate) +{ + setName(name); +} + +VisualStudioSolutionGlobalSection::~VisualStudioSolutionGlobalSection() = default; + +QString VisualStudioSolutionGlobalSection::name() const +{ + return d->name; +} + +void VisualStudioSolutionGlobalSection::setName(const QString &name) +{ + d->name = name; +} + +bool VisualStudioSolutionGlobalSection::isPost() const +{ + return d->post; +} + +void VisualStudioSolutionGlobalSection::setPost(bool post) +{ + d->post = post; +} + +std::vector > VisualStudioSolutionGlobalSection::properties() const +{ + return d->properties; +} + +void VisualStudioSolutionGlobalSection::appendProperty(const QString &key, const QString &value) +{ + d->properties.emplace_back(key, value); +} + +} // namespace qbs diff --git a/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h new file mode 100644 index 00000000..6d383e7d --- /dev/null +++ b/src/lib/msbuild/solution/visualstudiosolutionglobalsection.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOSOLUTIONGLOBALSECTION_H +#define VISUALSTUDIOSOLUTIONGLOBALSECTION_H + +#include + +#include + +namespace qbs { + +class VisualStudioSolutionGlobalSectionPrivate; + +class VisualStudioSolutionGlobalSection : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(VisualStudioSolutionGlobalSection) +public: + explicit VisualStudioSolutionGlobalSection(const QString &name, QObject *parent = nullptr); + ~VisualStudioSolutionGlobalSection() override; + + QString name() const; + void setName(const QString &name); + + bool isPost() const; + void setPost(bool post); + + std::vector > properties() const; + void appendProperty(const QString &key, const QString &value); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOSOLUTIONGLOBALSECTION_H diff --git a/src/lib/msbuild/use_installed_msbuild.pri b/src/lib/msbuild/use_installed_msbuild.pri new file mode 100644 index 00000000..af89b255 --- /dev/null +++ b/src/lib/msbuild/use_installed_msbuild.pri @@ -0,0 +1,20 @@ +include(use_installed_corelib.pri) + +LIBNAME=qbsmsbuild + +unix:LIBS += -l$${LIBNAME} + +win32 { + CONFIG(debug, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}d$${QBSCORELIBSUFFIX} + } + CONFIG(release, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}$${QBSCORELIBSUFFIX} + } + msvc { + QBSMSBUILDLIB = $${QBSMSBUILDLIB}.lib + } else { + QBSMSBUILDLIB = lib$${QBSMSBUILDLIB} + } + LIBS += $${QBSMSBUILDLIB} +} diff --git a/src/lib/msbuild/use_msbuild.pri b/src/lib/msbuild/use_msbuild.pri new file mode 100644 index 00000000..bb69968d --- /dev/null +++ b/src/lib/msbuild/use_msbuild.pri @@ -0,0 +1,38 @@ +include(../../library_dirname.pri) + +isEmpty(QBSLIBDIR) { + QBSLIBDIR = $${OUT_PWD}/../../../$${QBS_LIBRARY_DIRNAME} +} + +LIBNAME=qbsmsbuild + +unix { + LIBS += -L$${QBSLIBDIR} -l$${LIBNAME} +} + +win32 { + CONFIG(debug, debug|release) { + QBSMSBUILDLIB = $${LIBNAME}d + } + CONFIG(release, debug|release) { + QBSMSBUILDLIB = $${LIBNAME} + } + msvc { + LIBS += /LIBPATH:$$QBSLIBDIR + QBSMSBUILDLIB = $${QBSMSBUILDLIB}.lib + LIBS += Shell32.lib + } else { + LIBS += -L$${QBSLIBDIR} + QBSMSBUILDLIB = lib$${QBSMSBUILDLIB} + } + LIBS += $${QBSMSBUILDLIB} +} + +INCLUDEPATH += \ + $$PWD + +CONFIG += depend_includepath + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} diff --git a/src/lib/pkgconfig/CMakeLists.txt b/src/lib/pkgconfig/CMakeLists.txt new file mode 100644 index 00000000..c82edac1 --- /dev/null +++ b/src/lib/pkgconfig/CMakeLists.txt @@ -0,0 +1,32 @@ +set(SOURCES + pcpackage.cpp + pcpackage.h + pcparser.cpp + pcparser.h + pkgconfig.cpp + pkgconfig.h +) +list_transform_prepend(SOLUTION_SOURCES solution/) + +if(APPLE OR MINGW) + set(HAS_STD_FILESYSTEM "0") +else() + set(HAS_STD_FILESYSTEM "1") +endif() + +set(QBS_PKGCONFIG_PUBLIC_DEPENDS "") +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + set(QBS_PKGCONFIG_PUBLIC_DEPENDS "stdc++fs") +endif() + +add_qbs_library(qbspkgconfig + STATIC + DEFINES + "PKG_CONFIG_PC_PATH=\"${CMAKE_INSTALL_PREFIX}/${QBS_LIBDIR_NAME}/pkgconfig:${CMAKE_INSTALL_PREFIX}/share/pkgconfig:/usr/${QBS_LIBDIR_NAME}/pkgconfig/:/usr/share/pkgconfig/\"" + "PKG_CONFIG_SYSTEM_LIBRARY_PATH=\"/usr/${QBS_LIBDIR_NAME}\"" + "HAS_STD_FILESYSTEM=${HAS_STD_FILESYSTEM}" + PUBLIC_DEFINES + "QBS_PC_WITH_QT_SUPPORT=1" + PUBLIC_DEPENDS Qt${QT_VERSION_MAJOR}::Core ${QBS_PKGCONFIG_PUBLIC_DEPENDS} qbsvariant + SOURCES ${SOURCES} +) diff --git a/src/lib/pkgconfig/pcpackage.cpp b/src/lib/pkgconfig/pcpackage.cpp new file mode 100644 index 00000000..984936bd --- /dev/null +++ b/src/lib/pkgconfig/pcpackage.cpp @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pcpackage.h" + +#include + +namespace qbs { + +using ComparisonType = PcPackage::RequiredVersion::ComparisonType; + +std::string_view PcPackage::Flag::typeToString(Type t) +{ + switch (t) { + case Type::LibraryName: return "LibraryName"; + case Type::StaticLibraryName: return "StaticLibraryName"; + case Type::LibraryPath: return "LibraryPath"; + case Type::Framework: return "Framework"; + case Type::FrameworkPath: return "FrameworkPath"; + case Type::LinkerFlag: return "LinkerFlag"; + case Type::IncludePath: return "IncludePath"; + case Type::SystemIncludePath: return "SystemIncludePath"; + case Type::DirAfterIncludePath: return "DirAfterIncludePath"; + case Type::Define: return "Define"; + case Type::CompilerFlag: return "CompilerFlag"; + } + return {}; +} + +std::optional PcPackage::Flag::typeFromString(std::string_view s) +{ + if (s == "LibraryName") + return Type::LibraryName; + if (s == "StaticLibraryName") + return Type::StaticLibraryName; + if (s == "LibraryPath") + return Type::LibraryPath; + if (s == "Framework") + return Type::Framework; + if (s == "FrameworkPath") + return Type::FrameworkPath; + if (s == "LinkerFlag") + return Type::LinkerFlag; + if (s == "IncludePath") + return Type::IncludePath; + if (s == "SystemIncludePath") + return Type::SystemIncludePath; + if (s == "DirAfterIncludePath") + return Type::DirAfterIncludePath; + if (s == "Define") + return Type::Define; + if (s == "CompilerFlag") + return Type::CompilerFlag; + return std::nullopt; +} + +std::string_view PcPackage::RequiredVersion::comparisonToString(ComparisonType t) +{ + switch (t) { + case ComparisonType::LessThan: return "LessThan"; + case ComparisonType::GreaterThan: return "GreaterThan"; + case ComparisonType::LessThanEqual: return "LessThanEqual"; + case ComparisonType::GreaterThanEqual: return "GreaterThanEqual"; + case ComparisonType::Equal: return "Equal"; + case ComparisonType::NotEqual: return "NotEqual"; + case ComparisonType::AlwaysMatch: return "AlwaysMatch"; + } + return {}; +} + +std::optional PcPackage::RequiredVersion::comparisonFromString(std::string_view s) +{ + if (s == "LessThan") + return ComparisonType::LessThan; + if (s == "GreaterThan") + return ComparisonType::GreaterThan; + if (s == "LessThanEqual") + return ComparisonType::LessThanEqual; + if (s == "GreaterThanEqual") + return ComparisonType::GreaterThanEqual; + if (s == "Equal") + return ComparisonType::Equal; + if (s == "NotEqual") + return ComparisonType::NotEqual; + if (s == "AlwaysMatch") + return ComparisonType::AlwaysMatch; + return std::nullopt; +} + +PcPackage PcPackage::prependSysroot(std::string_view sysroot) && +{ + PcPackage package(std::move(*this)); + + const auto doAppend = [](std::vector flags, std::string_view sysroot) + { + if (sysroot.empty()) + return flags; + for (auto &flag : flags) { + if (flag.type == Flag::Type::IncludePath + || flag.type == Flag::Type::SystemIncludePath + || flag.type == Flag::Type::DirAfterIncludePath + || flag.type == Flag::Type::LibraryPath) { + flag.value = std::string(sysroot) + std::move(flag.value); + } + } + return flags; + }; + + package.libs = doAppend(std::move(package.libs), sysroot); + package.libsPrivate = doAppend(std::move(package.libsPrivate), sysroot); + package.cflags = doAppend(std::move(package.cflags), sysroot); + return package; +} + +PcPackage PcPackage::removeSystemLibraryPaths( + const std::unordered_set &libraryPaths) && +{ + PcPackage package(std::move(*this)); + if (libraryPaths.empty()) + return package; + + const auto doRemove = [&libraryPaths](std::vector flags) + { + const auto predicate = [&libraryPaths](const Flag &flag) + { + return flag.type == Flag::Type::LibraryPath && libraryPaths.count(flag.value); + }; + flags.erase(std::remove_if(flags.begin(), flags.end(), predicate), flags.end()); + return flags; + }; + package.libs = doRemove(package.libs); + package.libsPrivate = doRemove(package.libsPrivate); + return package; +} + +} // namespace qbs diff --git a/src/lib/pkgconfig/pcpackage.h b/src/lib/pkgconfig/pcpackage.h new file mode 100644 index 00000000..9d86816a --- /dev/null +++ b/src/lib/pkgconfig/pcpackage.h @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PC_PACKAGE_H +#define PC_PACKAGE_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace qbs { + +class PcPackage +{ +public: + struct Flag + { + enum class Type { + LibraryName = (1 << 0), + StaticLibraryName = (1 << 1), + LibraryPath = (1 << 2), + Framework = (1 << 3), + FrameworkPath = (1 << 4), + LinkerFlag = (1 << 5), // this is a lie, this is DriverLinkerFlags + IncludePath = (1 << 6), + SystemIncludePath = (1 << 7), + DirAfterIncludePath = (1 << 8), + Define = (1 << 9), + CompilerFlag = (1 << 10), + }; + Type type{Type::CompilerFlag}; + std::string value; + + static std::string_view typeToString(Type t); + static std::optional typeFromString(std::string_view s); + }; + + struct RequiredVersion + { + enum class ComparisonType { + LessThan, + GreaterThan, + LessThanEqual, + GreaterThanEqual, + Equal, + NotEqual, + AlwaysMatch + }; + + std::string name; + ComparisonType comparison{ComparisonType::GreaterThanEqual}; + std::string version; + + static std::string_view comparisonToString(ComparisonType t); + static std::optional comparisonFromString(std::string_view s); + }; + + std::string filePath; + std::string baseFileName; + std::string name; + std::string version; + std::string description; + std::string url; + + std::vector libs; + std::vector libsPrivate; + std::vector cflags; + + std::vector requiresPublic; + std::vector requiresPrivate; + std::vector conflicts; + + using VariablesMap = std::map>; + VariablesMap variables; + + bool uninstalled{false}; + + PcPackage prependSysroot(std::string_view sysroot) &&; + PcPackage removeSystemLibraryPaths(const std::unordered_set &libraryPaths) &&; +}; + +class PcBrokenPackage +{ +public: + std::string filePath; + std::string baseFileName; + std::string errorText; +}; + +class PcPackageVariant: public Variant::variant +{ +public: + using Base = Variant::variant; + using Base::Base; + + bool isValid() const noexcept { return index() == 0; } + bool isBroken() const noexcept { return index() == 1; } + + const PcPackage &asPackage() const { return Variant::get(*this); } + PcPackage &asPackage() { return Variant::get(*this); } + + const PcBrokenPackage &asBrokenPackage() const { return Variant::get(*this); } + PcBrokenPackage &asBrokenPackage() { return Variant::get(*this); } + + template + decltype(auto) visit(F &&f) const + { + return Variant::visit(std::forward(f), static_cast(*this)); + } + + template + decltype(auto) visit(F &&f) + { + return Variant::visit(std::forward(f), static_cast(*this)); + } + + const std::string &getBaseFileName() const + { + return visit([](auto &&value) noexcept -> const std::string & { + return value.baseFileName; + }); + } +}; + +class PcException: public std::runtime_error +{ +public: + explicit PcException(const std::string &message) : std::runtime_error(message) {} +}; + +inline bool operator==(const PcPackage::Flag &lhs, const PcPackage::Flag &rhs) +{ + return lhs.type == rhs.type && lhs.value == rhs.value; +} + +inline bool operator!=(const PcPackage::Flag &lhs, const PcPackage::Flag &rhs) +{ + return !(lhs == rhs); +} + +} // namespace qbs + +namespace std { +template<> struct hash +{ + size_t operator()(const qbs::PcPackage::Flag &v) const noexcept + { + return hash()(v.value) + size_t(v.type); + } +}; +} // namespace std + +#endif // PC_PACKAGE_H diff --git a/src/lib/pkgconfig/pcparser.cpp b/src/lib/pkgconfig/pcparser.cpp new file mode 100644 index 00000000..388363af --- /dev/null +++ b/src/lib/pkgconfig/pcparser.cpp @@ -0,0 +1,781 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pcparser.h" + +#include "pkgconfig.h" + +#if HAS_STD_FILESYSTEM +# if __has_include() +# include +# else +# include +// We need the alias from std::experimental::filesystem to std::filesystem +namespace std { + namespace filesystem = experimental::filesystem; +} +# endif +#else +#include +#endif + +#include +#include +#include +#include + +namespace qbs { + +namespace { + +// workaround for a missing ctor before c++20 +template +std::string_view makeStringView(It begin, It end) +{ + if (begin == end) + return {}; + return std::string_view(&*begin, std::distance(begin, end)); +} + +bool readOneLine(std::ifstream &file, std::string &line) +{ + bool quoted = false; + bool comment = false; + int n_read = 0; + + line = {}; + + while (true) { + char c; + file.get(c); + const bool ok = file.good(); + + if (!ok) { + if (quoted) + line += '\\'; + + return n_read > 0; + } + n_read++; + + if (c == '\r') { + n_read--; + continue; + } + + if (quoted) { + quoted = false; + + switch (c) { + case '#': + line += '#'; + break; + case '\n': + break; + default: + line += '\\'; + line += c; + break; + } + } else { + switch (c) { + case '#': + comment = true; + break; + case '\\': + if (!comment) + quoted = true; + break; + case '\n': + return n_read > 0; + default: + if (!comment) + line += c; + break; + } + } + } + + return n_read > 0; +} + +std::string_view trimmed(std::string_view str) +{ + const auto predicate = [](int c){ return std::isspace(c); }; + const auto left = std::find_if_not(str.begin(), str.end(), predicate); + const auto right = std::find_if_not(str.rbegin(), str.rend(), predicate).base(); + if (right <= left) + return {}; + return makeStringView(left, right); +} + +// based on https://opensource.apple.com/source/distcc/distcc-31.0.81/popt/poptparse.c.auto.html +std::optional> splitCommand(std::string_view s) +{ + std::vector result; + std::string arg; + + char quote = '\0'; + + for (auto it = s.begin(), end = s.end(); it != end; ++it) { + if (quote == *it) { + quote = '\0'; + } else if (quote != '\0') { + if (*it == '\\') { + ++it; + if (it == s.end()) + return std::nullopt; + + if (*it != quote) + arg += '\\'; + } + arg += *it; + } else if (isspace(*it)) { + if (!arg.empty()) { + result.push_back(arg); + arg.clear(); + } + } else { + switch (*it) { + case '"': + case '\'': + quote = *it; + break; + case '\\': + ++it; + if (it == s.end()) + return std::nullopt; + [[fallthrough]]; + default: + arg += *it; + break; + } + } + } + + if (!arg.empty()) + result.push_back(arg); + + return result; +} + +bool startsWith(std::string_view haystack, std::string_view needle) +{ + return haystack.size() >= needle.size() && haystack.compare(0, needle.size(), needle) == 0; +} + +bool endsWith(std::string_view haystack, std::string_view needle) +{ + return haystack.size() >= needle.size() + && haystack.compare(haystack.size() - needle.size(), needle.size(), needle) == 0; +} + +[[noreturn]] void raizeUnknownComparisonException(const PcPackage &pkg, std::string_view verName, std::string_view comp) +{ + std::string message; + message += "Unknown version comparison operator '"; + message += comp; + message += "' after package name '"; + message += verName; + message += "' in file '"; + message += pkg.filePath; + message += "'"; + throw PcException(message); +} + +[[noreturn]] void raiseDuplicateFieldException(std::string_view fieldName, std::string_view path) +{ + std::string message; + message += fieldName; + message += " field occurs twice in '"; + message += path; + message += "'"; + throw PcException(message); +} + +[[noreturn]] void raizeEmptyPackageNameException(const PcPackage &pkg) +{ + std::string message; + message += "Empty package name in Requires or Conflicts in file '"; + message += pkg.filePath; + message += "'"; + throw PcException(message); +} + +[[noreturn]] void raizeNoVersionException(const PcPackage &pkg, std::string_view verName) +{ + std::string message; + message += "Comparison operator but no version after package name '"; + message += verName; + message += "' in file '"; + message += pkg.filePath; + message += "'"; + throw PcException(message); +} + +[[noreturn]] void raizeDuplicateVariableException(const PcPackage &pkg, std::string_view variable) +{ + std::string message; + message += "Duplicate definition of variable '"; + message += variable; + message += "' in '"; + message += pkg.filePath; + throw PcException(message); +} + +[[noreturn]] void raizeUndefinedVariableException(const PcPackage &pkg, std::string_view variable) +{ + std::string message; + message += "Variable '"; + message += variable; + message += "' not defined in '"; + message += pkg.filePath; + throw PcException(message); +} + +bool isModuleSeparator(char c) { return c == ',' || std::isspace(c); } +bool isModuleOperator(char c) { return c == '<' || c == '>' || c == '!' || c == '='; } + +// A module list is a list of modules with optional version specification, +// separated by commas and/or spaces. Commas are treated just like whitespace, +// in order to allow stuff like: Requires: @FRIBIDI_PC@, glib, gmodule +// where @FRIBIDI_PC@ gets substituted to nothing or to 'fribidi' + +std::vector splitModuleList(std::string_view str) +{ + enum class State { + // put numbers to help interpret lame debug spew ;-) + OutsideModule = 0, + InModuleName = 1, + BeforeOperator = 2, + InOperator = 3, + AfterOperator = 4, + InModuleVersion = 5 + }; + + std::vector result; + State state = State::OutsideModule; + State last_state = State::OutsideModule; + + auto start = str.begin(); + const auto end = str.end(); + auto p = start; + + while (p != end) { + + switch (state) { + case State::OutsideModule: + if (!isModuleSeparator(*p)) + state = State::InModuleName; + break; + + case State::InModuleName: + if (std::isspace(*p)) { + // Need to look ahead to determine next state + auto s = p; + while (s != end && std::isspace (*s)) + ++s; + + state = State::OutsideModule; + if (s != end && isModuleOperator(*s)) + state = State::BeforeOperator; + } + else if (isModuleSeparator(*p)) + state = State::OutsideModule; // comma precludes any operators + break; + + case State::BeforeOperator: + // We know an operator is coming up here due to lookahead from + // IN_MODULE_NAME + if (std::isspace(*p)) + ; // no change + else if (isModuleOperator(*p)) + state = State::InOperator; + break; + + case State::InOperator: + if (!isModuleOperator(*p)) + state = State::AfterOperator; + break; + + case State::AfterOperator: + if (!std::isspace(*p)) + state = State::InModuleVersion; + break; + + case State::InModuleVersion: + if (isModuleSeparator(*p)) + state = State::OutsideModule; + break; + + default: + break; + } + + if (state == State::OutsideModule && last_state != State::OutsideModule) { + // We left a module + while (start != end && isModuleSeparator(*start)) + ++start; + + std::string module(&*start, p - start); + result.push_back(module); + + // reset start + start = p; + } + + last_state = state; + ++p; + } + + if (p != start) { + // get the last module + while (start != end && isModuleSeparator(*start)) + ++start; + std::string module(&*start, p - start); + result.push_back(module); + } + + return result; +} + +PcPackage::RequiredVersion::ComparisonType comparisonFromString( + const PcPackage &pkg, std::string_view verName, std::string_view comp) +{ + using ComparisonType = PcPackage::RequiredVersion::ComparisonType; + if (comp.empty()) + return ComparisonType::AlwaysMatch; + if (comp == "=") + return ComparisonType::Equal; + if (comp == ">=") + return ComparisonType::GreaterThanEqual; + if (comp == "<=") + return ComparisonType::LessThanEqual; + if (comp == ">") + return ComparisonType::GreaterThan; + if (comp == "<") + return ComparisonType::LessThan; + if (comp == "!=") + return ComparisonType::NotEqual; + + raizeUnknownComparisonException(pkg, verName, comp); +} + +std::string baseName(const std::string_view &filePath) +{ + auto pos = filePath.rfind('/'); + const auto fileName = + pos == std::string_view::npos ? std::string_view() : filePath.substr(pos + 1); + pos = fileName.rfind('.'); + return std::string(pos == std::string_view::npos + ? std::string_view() + : fileName.substr(0, pos)); +} + +} // namespace + +PcParser::PcParser(const PkgConfig &pkgConfig) + : m_pkgConfig(pkgConfig) +{ + +} + +PcPackageVariant PcParser::parsePackageFile(const std::string &path) +try +{ + PcPackage package; + + if (path.empty()) + return package; + + std::ifstream file(path); + + if (!file.is_open()) + throw PcException(std::string("Can't open file ") + path); + + package.baseFileName = baseName(path); +#if HAS_STD_FILESYSTEM + const auto fsPath = std::filesystem::path(path); + package.filePath = fsPath.generic_string(); + package.variables["pcfiledir"] = fsPath.parent_path().generic_string(); +#else + QFileInfo fileInfo(QString::fromStdString(path)); + package.filePath = fileInfo.absoluteFilePath().toStdString(); + package.variables["pcfiledir"] = fileInfo.absolutePath().toStdString(); +#endif + + std::string line; + while (readOneLine(file, line)) + parseLine(package, line); + return package; +} catch(const PcException &ex) { + return PcBrokenPackage{path, baseName(path), ex.what()}; +} + +std::string PcParser::trimAndSubstitute(const PcPackage &pkg, std::string_view str) const +{ + str = trimmed(str); + + std::string result; + + while (!str.empty()) { + if (startsWith(str, "$$")) { + // escaped $ + result += '$'; + str.remove_prefix(2); // cut "$$" + } else if (startsWith(str, "${")) { + // variable + str.remove_prefix(2); // cut "${" + const auto it = std::find(str.begin(), str.end(), '}'); + // funny, original pkg-config simply reads all available memory here + if (it == str.end()) + throw PcException("Missing closing '}'"); + + const std::string_view varname = str.substr(0, std::distance(str.begin(), it)); + + // past brace + str.remove_prefix(varname.size()); + str.remove_prefix(1); + + const auto varval = m_pkgConfig.packageGetVariable(pkg, varname); + + if (!varval) + raizeUndefinedVariableException(pkg, varname); + + result += *varval; + } else { + result += str.front(); + str.remove_prefix(1); + } + } + + return result; +} + +void PcParser::parseStringField( + PcPackage &pkg, + std::string &field, + std::string_view fieldName, + std::string_view str) +{ + if (!field.empty()) + raiseDuplicateFieldException(fieldName, pkg.filePath); + + field = trimAndSubstitute(pkg, str); +} + +void PcParser::parseLibs( + PcPackage &pkg, + std::vector &libs, + std::string_view fieldName, + std::string_view str) +{ + // Strip out -l and -L flags, put them in a separate list. + + if (!libs.empty()) + raiseDuplicateFieldException(fieldName, pkg.filePath); + + const auto trimmed = trimAndSubstitute(pkg, str); + + const auto argv = splitCommand(trimmed); + if (!trimmed.empty() && !argv) + throw PcException("Couldn't parse Libs field into an argument vector"); + + libs = doParseLibs(*argv); +} + +std::vector PcParser::doParseLibs(const std::vector &argv) +{ + std::vector libs; + libs.reserve(argv.size()); + + for (auto it = argv.begin(), end = argv.end(); it != end; ++it) { + PcPackage::Flag flag; + const auto escapedArgument = trimmed(*it); + std::string_view arg(escapedArgument); + + // -lib: is used by the C# compiler for libs; it's not an -l flag. + if (startsWith(arg, "-l") && !startsWith(arg, "-lib:")) { + arg.remove_prefix(2); + arg = trimmed(arg); + + flag.type = PcPackage::Flag::Type::LibraryName; + flag.value += arg; + } else if (startsWith(arg, "-L")) { + arg.remove_prefix(2); + arg = trimmed(arg); + + flag.type = PcPackage::Flag::Type::LibraryPath; + flag.value += arg; + } else if ((arg == "-framework" /*|| arg == "-Wl,-framework"*/) && it + 1 != end) { + // macOS has a -framework Foo which is really one option, + // so we join those to avoid having -framework Foo + // -framework Bar being changed into -framework Foo Bar + // later + const auto framework = trimmed(*(it + 1)); + flag.type = PcPackage::Flag::Type::Framework; + flag.value += framework; + ++it; + } else if (startsWith(arg, "-F")) { + arg.remove_prefix(2); + arg = trimmed(arg); + + flag.type = PcPackage::Flag::Type::FrameworkPath; + flag.value += arg; + + } else if (!startsWith(arg, "-") && (endsWith(arg, ".a") || endsWith(arg, ".lib"))) { + flag.type = PcPackage::Flag::Type::StaticLibraryName; + flag.value += arg; + } else if (!arg.empty()) { + flag.type = PcPackage::Flag::Type::LinkerFlag; + flag.value += arg; + } else { + continue; + } + libs.push_back(flag); + } + return libs; +} + +void PcParser::parseCFlags(PcPackage &pkg, std::string_view str) +{ + // Strip out -I, -D, -isystem and idirafter flags, put them in a separate lists. + + if (!pkg.cflags.empty()) + raiseDuplicateFieldException("Cflags", pkg.filePath); + + const auto command = trimAndSubstitute(pkg, str); + + const auto argv = splitCommand(command); + if (!command.empty() && !argv) + throw PcException("Couldn't parse Cflags field into an argument vector"); + + std::vector cflags; + cflags.reserve(argv->size()); + + for (auto it = argv->begin(), end = argv->end(); it != end; ++it) { + PcPackage::Flag flag; + const auto escapedArgument = trimmed(*it); + std::string_view arg(escapedArgument); + + if (startsWith(arg, "-I")) { + arg.remove_prefix(2); + arg = trimmed(arg); + + flag.type = PcPackage::Flag::Type::IncludePath; + flag.value += arg; + } else if (startsWith(arg, "-D")) { + arg.remove_prefix(2); + arg = trimmed(arg); + + flag.type = PcPackage::Flag::Type::Define; + flag.value += arg; + } else if (arg == "-isystem" && it + 1 != end) { + flag.type = PcPackage::Flag::Type::SystemIncludePath; + flag.value = trimmed(*(it + 1)); + ++it; + } else if (arg == "-idirafter" && it + 1 != end) { + flag.type = PcPackage::Flag::Type::DirAfterIncludePath; + flag.value = trimmed(*(it + 1)); + ++it; + } else if (!arg.empty()) { + flag.type = PcPackage::Flag::Type::CompilerFlag; + flag.value += arg; + } else { + continue; + } + cflags.push_back(flag); + } + pkg.cflags = std::move(cflags); +} + +std::vector PcParser::parseModuleList(PcPackage &pkg, std::string_view str) +{ + using ComparisonType = PcPackage::RequiredVersion::ComparisonType; + + std::vector result; + auto split = splitModuleList(str); + + for (auto &module: split) { + PcPackage::RequiredVersion ver; + + auto p = module.begin(); + const auto end = module.end(); + + ver.comparison = ComparisonType::AlwaysMatch; + + auto start = p; + + while (p != end && !std::isspace(*p)) + ++p; + + const auto name = makeStringView(start, p); + + if (name.empty()) + raizeEmptyPackageNameException(pkg); + + ver.name = std::string(name); + + while (p != end && std::isspace(*p)) + ++p; + + start = p; + + while (p != end && !std::isspace(*p)) + ++p; + + const auto comp = makeStringView(start, p); + ver.comparison = comparisonFromString(pkg, ver.name, comp); + + while (p != end && std::isspace(*p)) + ++p; + + start = p; + + while (p != end && !std::isspace(*p)) + ++p; + + const auto version = makeStringView(start, p); + + while (p != end && std::isspace(*p)) + ++p; + + if (ver.comparison != ComparisonType::AlwaysMatch && version.empty()) + raizeNoVersionException(pkg, ver.name); + + ver.version = std::string(version); + + result.push_back(ver); + } + + return result; +} + +void PcParser::parseVersionsField( + PcPackage &pkg, + std::vector &modules, + std::string_view fieldName, + std::string_view str) +{ + if (!modules.empty()) + raiseDuplicateFieldException(fieldName, pkg.filePath); + + const auto trimmed = trimAndSubstitute(pkg, str); + modules = parseModuleList(pkg, trimmed.c_str()); +} + +void PcParser::parseLine(PcPackage &pkg, std::string_view str) +{ + str = trimmed(str); + if (str.empty()) + return; + + auto getFirstWord = [](std::string_view s) { + size_t pos = 0; + for (; pos < s.size(); ++pos) { + auto p = s.data() + pos; + if (!((*p >= 'A' && *p <= 'Z') || + (*p >= 'a' && *p <= 'z') || + (*p >= '0' && *p <= '9') || + *p == '_' || *p == '.')) { + break; + } + } + return s.substr(0, pos); + }; + + const auto tag = getFirstWord(str); + + str.remove_prefix(tag.size()); // cut tag + str = trimmed(str); + + if (str.empty()) + return; + + if (str.front() == ':') { + // keyword + str.remove_prefix(1); // cut ':' + str = trimmed(str); + + if (tag == "Name") + parseStringField(pkg, pkg.name, tag, str); + else if (tag == "Description") + parseStringField(pkg, pkg.description, tag, str); + else if (tag == "Version") + parseStringField(pkg, pkg.version, tag, str); + else if (tag == "Requires.private") + parseVersionsField(pkg, pkg.requiresPrivate, tag, str); + else if (tag == "Requires") + parseVersionsField(pkg, pkg.requiresPublic, tag, str); + else if (tag == "Libs.private") + parseLibs(pkg, pkg.libsPrivate, "Libs.private", str); + else if (tag == "Libs") + parseLibs(pkg, pkg.libs, "Libs", str); + else if (tag == "Cflags" || tag == "CFlags") + parseCFlags(pkg, str); + else if (tag == "Conflicts") + parseVersionsField(pkg, pkg.conflicts, tag, str); + else if (tag == "URL") + parseStringField(pkg, pkg.url, tag, str); + else { + // we don't error out on unknown keywords because they may + // represent additions to the .pc file format from future + // versions of pkg-config. + return; + } + } else if (str.front() == '=') { + // variable + + str.remove_prefix(1); // cut '=' + str = trimmed(str); + + // TODO: support guesstimating of the prefix variable (pkg-config's --define-prefix option) + // from doc: "try to override the value of prefix for each .pc file found with a + // guesstimated value based on the location of the .pc file" + // https://gitlab.freedesktop.org/pkg-config/pkg-config/-/blob/pkg-config-0.29.2/parse.c#L998 + // This option is disabled by default, and Qbs doesn't allow to override it yet, so we can + // ignore this feature for now + + const auto value = trimAndSubstitute(pkg, str); + if (!pkg.variables.insert({std::string(tag), value}).second) + raizeDuplicateVariableException(pkg, tag); + } +} + +} // namespace qbs diff --git a/src/lib/pkgconfig/pcparser.h b/src/lib/pkgconfig/pcparser.h new file mode 100644 index 00000000..ffdf86aa --- /dev/null +++ b/src/lib/pkgconfig/pcparser.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PC_PARSER_H +#define PC_PARSER_H + +#include "pcpackage.h" + +namespace qbs { + +class PkgConfig; + +class PcParser +{ +public: + explicit PcParser(const PkgConfig &pkgConfig); + + PcPackageVariant parsePackageFile(const std::string &path); + +private: + std::string trimAndSubstitute(const PcPackage &pkg, std::string_view str) const; + void parseStringField( + PcPackage &pkg, + std::string &field, + std::string_view fieldName, + std::string_view str); + void parseLibs( + PcPackage &pkg, + std::vector &libs, + std::string_view fieldName, + std::string_view str); + std::vector doParseLibs(const std::vector &argv); + void parseCFlags(PcPackage &pkg, std::string_view str); + std::vector parseModuleList(PcPackage &pkg, std::string_view str); + void parseVersionsField( + PcPackage &pkg, + std::vector &modules, + std::string_view fieldName, + std::string_view str); + void parseLine(PcPackage &pkg, std::string_view str); + +private: + const PkgConfig &m_pkgConfig; +}; + +} // namespace qbs + +#endif // PC_PARSER_H diff --git a/src/lib/pkgconfig/pkgconfig.cpp b/src/lib/pkgconfig/pkgconfig.cpp new file mode 100644 index 00000000..b2c3d4d7 --- /dev/null +++ b/src/lib/pkgconfig/pkgconfig.cpp @@ -0,0 +1,494 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pkgconfig.h" +#include "pcparser.h" + +#if HAS_STD_FILESYSTEM +# if __has_include() +# include +# else +# include +// We need the alias from std::experimental::filesystem to std::filesystem +namespace std { + namespace filesystem = experimental::filesystem; +} +# endif +#else +# include +# include +#endif + +#include +#include + +namespace qbs { + +namespace { + +std::string varToEnvVar(std::string_view pkg, std::string_view var) +{ + auto result = std::string("PKG_CONFIG_"); + result += pkg; + result += '_'; + result += var; + + for (char &p : result) { + int c = std::toupper(p); + + if (!std::isalnum(c)) + c = '_'; + + p = char(c); + } + + return result; +} + +std::vector split(std::string_view str, const char delim) +{ + std::vector result; + size_t prev = 0; + size_t pos = 0; + do { + pos = str.find(delim, prev); + if (pos == std::string::npos) pos = str.length(); + std::string token(str.substr(prev, pos - prev)); + if (!token.empty()) + result.push_back(token); + prev = pos + 1; + } while (pos < str.length() && prev < str.length()); + return result; +} + +constexpr inline char listSeparator() noexcept +{ +#if defined(WIN32) + return ';'; +#else + return ':'; +#endif +} + +// based on https://stackoverflow.com/a/33135699/295518 +int compareVersions(std::string_view v1, std::string_view v2) +{ + for (size_t i = 0, j = 0; i < v1.length() || j < v2.length(); ) { + size_t acc1 = 0; + size_t acc2 = 0; + + while (i < v1.length() && v1[i] != '.') { + acc1 = acc1 * 10 + (v1[i] - '0'); + i++; + } + while (j < v2.length() && v2[j] != '.') { + acc2 = acc2 * 10 + (v2[j] - '0'); + j++; + } + + if (acc1 < acc2) + return -1; + if (acc1 > acc2) + return +1; + + ++i; + ++j; + } + return 0; +} + +using ComparisonType = PcPackage::RequiredVersion::ComparisonType; + +bool versionTest(ComparisonType comparison, std::string_view a, std::string_view b) +{ + switch (comparison) { + case ComparisonType::LessThan: return compareVersions(a, b) < 0; + case ComparisonType::GreaterThan: return compareVersions(a, b) > 0; + case ComparisonType::LessThanEqual: return compareVersions(a, b) <= 0; + case ComparisonType::GreaterThanEqual: return compareVersions(a, b) >= 0; + case ComparisonType::Equal: return compareVersions(a, b) == 0; + case ComparisonType::NotEqual: return compareVersions(a, b) != 0; + case ComparisonType::AlwaysMatch: return true; + } + + return false; +} + +[[noreturn]] void raizeUnknownPackageException(std::string_view package) +{ + std::string message; + message += "Can't find package '"; + message += package; + message += "'"; + throw PcException(message); +} + +template +C &operator<<(C &container, const C &other) +{ + container.insert(container.end(), other.cbegin(), other.cend()); + return container; +} + +} // namespace + +PkgConfig::PkgConfig() + : PkgConfig(Options()) +{ +} + +PkgConfig::PkgConfig(Options options) + : m_options(std::move(options)) +{ + if (m_options.libDirs.empty()) + m_options.libDirs = split(PKG_CONFIG_PC_PATH, listSeparator()); + + if (m_options.topBuildDir.empty()) + m_options.topBuildDir = "$(top_builddir)"; // pkg-config sets this for automake =) + + if (m_options.systemLibraryPaths.empty()) + m_options.systemLibraryPaths = split(PKG_CONFIG_SYSTEM_LIBRARY_PATH, ':'); + + // this is weird on Windows, but that's what pkg-config does + if (m_options.sysroot.empty()) + m_options.globalVariables["pc_sysrootdir"] = "/"; + else + m_options.globalVariables["pc_sysrootdir"] = m_options.sysroot; + m_options.globalVariables["pc_top_builddir"] = m_options.topBuildDir; + + m_packages = findPackages(); +} + +const PcPackageVariant &PkgConfig::getPackage(std::string_view baseFileName) const +{ + // heterogeneous comparator so we can search the package using string_view + const auto lessThan = [](const PcPackageVariant &package, const std::string_view &name) + { + return package.visit([name](auto &&value) noexcept { + return value.baseFileName < name; + }); + }; + + const auto testPackage = [baseFileName](const PcPackageVariant &package) { + return package.visit([baseFileName](auto &&value) noexcept { + return baseFileName != value.baseFileName; + }); + }; + + const auto it = std::lower_bound(m_packages.begin(), m_packages.end(), baseFileName, lessThan); + if (it == m_packages.end() || testPackage(*it)) + raizeUnknownPackageException(baseFileName); + return *it; +} + +std::optional PkgConfig::packageGetVariable( + const PcPackage &pkg, std::string_view var) const +{ + std::optional result; + + if (var.empty()) + return result; + + const auto &globals = m_options.globalVariables; + if (auto it = globals.find(var); it != globals.end()) + result = it->second; + + // Allow overriding specific variables using an environment variable of the + // form PKG_CONFIG_$PACKAGENAME_$VARIABLE + if (!pkg.baseFileName.empty()) { + const std::string envVariable = varToEnvVar(pkg.baseFileName, var); + const auto it = m_options.systemVariables.find(envVariable); + if (it != m_options.systemVariables.end()) + result = it->second; + } + + if (!result) { + if (const auto it = pkg.variables.find(var); it != pkg.variables.end()) + result = it->second; + } + + return result; +} + +#if HAS_STD_FILESYSTEM +std::vector getPcFilePaths(const std::vector &searchPaths) +{ + std::vector paths; + + for (const auto &searchPath : searchPaths) { + if (!std::filesystem::exists(std::filesystem::directory_entry(searchPath).status())) + continue; + const auto dir = std::filesystem::directory_iterator(searchPath); + std::copy_if( + std::filesystem::begin(dir), + std::filesystem::end(dir), + std::back_inserter(paths), + [](const auto &entry) { return entry.path().extension() == ".pc"; } + ); + } + std::vector result; + std::transform( + std::begin(paths), + std::end(paths), + std::back_inserter(result), + [](const auto &path) { return path.generic_string(); } + ); + return result; +} +#else +std::vector getPcFilePaths(const std::vector &searchPaths) +{ + std::vector result; + for (const auto &path : searchPaths) { + QDir dir(QString::fromStdString(path)); + const auto paths = dir.entryList({QStringLiteral("*.pc")}); + std::transform( + std::begin(paths), + std::end(paths), + std::back_inserter(result), + [&dir](const auto &path) { return dir.filePath(path).toStdString(); } + ); + } + return result; +} +#endif + +PcBrokenPackage makeMissingDependency( + const PcPackage &package, const PcPackage::RequiredVersion &depVersion) +{ + std::string message; + message += "Package "; + message += package.name; + message += " requires package "; + message += depVersion.name; + message += " but it is not found"; + return PcBrokenPackage{ + package.filePath, package.baseFileName, std::move(message)}; +} + +PcBrokenPackage makeBrokenDependency( + const PcPackage &package, const PcPackage::RequiredVersion &depVersion) +{ + std::string message; + message += "Package "; + message += package.name; + message += " requires package "; + message += depVersion.name; + message += " but it is broken"; + return PcBrokenPackage{ + package.filePath, package.baseFileName, std::move(message)}; +} + +PcBrokenPackage makeVersionMismatchDependency( + const PcPackage &package, + const PcPackage &depPackage, + const PcPackage::RequiredVersion &depVersion) +{ + std::string message; + message += "Package "; + message += package.name; + message += " requires version "; + message += PcPackage::RequiredVersion::comparisonToString( + depVersion.comparison); + message += depVersion.version; + message += " but "; + message += depPackage.version; + message += " is present"; + return PcBrokenPackage{ + package.filePath, package.baseFileName, std::move(message)}; +} + +PkgConfig::Packages PkgConfig::mergeDependencies(const PkgConfig::Packages &packages) const +{ + std::unordered_map packageHash; + + struct MergedHashEntry + { + PcPackageVariant package; // merged package or broken package + std::vector deps; // unmerged transitive deps, including Package itself + }; + std::unordered_map mergedHash; + + for (const auto &package: packages) + packageHash[package.getBaseFileName()] = &package; + + auto func = [&](const PcPackageVariant &package, auto &f) -> const MergedHashEntry & + { + const auto it = mergedHash.find(package.getBaseFileName()); + if (it != mergedHash.end()) + return it->second; + + auto &entry = mergedHash[package.getBaseFileName()]; + + auto visitor = [&](auto &&package) -> PcPackageVariant { + + using T = std::decay_t; + if constexpr (std::is_same_v) { // NOLINT + + using Flags = std::vector; + + // returns true if multiple copies of the flag can present in the same package + // we can't properly merge flags that have multiple parameters except for + // -framework which we handle correctly. + auto canHaveDuplicates = [](const PcPackage::Flag::Type &type) { + return type == PcPackage::Flag::Type::LinkerFlag + || type == PcPackage::Flag::Type::CompilerFlag; + }; + + std::unordered_set visitedFlags; + // appends only those flags to the target that were not seen before (except for + // ones that can have duplicates) + auto mergeFlags = [&](Flags &target, const Flags &source) + { + for (const auto &flag: source) { + if (canHaveDuplicates(flag.type) || visitedFlags.insert(flag).second) + target.push_back(flag); + } + }; + + std::unordered_set visitedDeps; + + PcPackage result; + // copy only meta info for now + result.filePath = package.filePath; + result.baseFileName = package.baseFileName; + result.name = package.name; + result.version = package.version; + result.description = package.description; + result.url = package.url; + result.variables = package.variables; + + auto allDependencies = package.requiresPublic; + if (m_options.staticMode) + allDependencies << package.requiresPrivate; + + for (const auto &dependency: allDependencies) { + const auto it = packageHash.find(dependency.name); + if (it == packageHash.end()) + return makeMissingDependency(result, dependency); + + const auto childEntry = f(*it->second, f); + if (childEntry.package.isBroken()) + return makeBrokenDependency(result, dependency); + + const auto &mergedPackage = childEntry.package.asPackage(); + const bool versionOk = versionTest( + dependency.comparison, mergedPackage.version, dependency.version); + if (!versionOk) + return makeVersionMismatchDependency(result, mergedPackage, dependency); + + for (const auto *dep: childEntry.deps) { + if (visitedDeps.insert(dep).second) + entry.deps.push_back(dep); + } + } + + entry.deps.push_back(&package); + + for (const auto *dep: entry.deps) { + mergeFlags(result.libs, dep->libs); + mergeFlags(result.cflags, dep->cflags); + } + + return result; + } + return package; + }; + entry.package = package.visit(visitor); + + return entry; + }; + + for (const auto &package: packages) + func(package, func); + + Packages result; + for (auto &[key, value]: mergedHash) + result.push_back(std::move(value.package)); + return result; +} + +PkgConfig::Packages PkgConfig::findPackages() const +{ + Packages result; + PcParser parser(*this); + + const auto systemLibraryPaths = !m_options.allowSystemLibraryPaths ? + std::unordered_set( + m_options.systemLibraryPaths.begin(), + m_options.systemLibraryPaths.end()) : std::unordered_set(); + + auto allSearchPaths = m_options.extraPaths; + allSearchPaths.insert( + allSearchPaths.end(), m_options.libDirs.begin(), m_options.libDirs.end()); + const auto pcFilePaths = getPcFilePaths(allSearchPaths); + + for (const auto &pcFilePath : pcFilePaths) { + if (m_options.disableUninstalled) { + if (pcFilePath.find("-uninstalled.pc") != std::string::npos) + continue; + } + + auto pkg = parser.parsePackageFile(pcFilePath); + pkg.visit([&](auto &value) { + using T = std::decay_t; + if constexpr (std::is_same_v) { // NOLINT + value = std::move(value) + // Weird, but pkg-config removes libs first and only then appends + // sysroot. Looks like sysroot has to be used with + // allowSystemLibraryPaths: true + .removeSystemLibraryPaths(systemLibraryPaths) + .prependSysroot(m_options.sysroot); + } + }); + result.emplace_back(std::move(pkg)); + } + + if (m_options.mergeDependencies) + result = mergeDependencies(result); + + const auto lessThanPackage = [](const PcPackageVariant &lhs, const PcPackageVariant &rhs) + { + return lhs.getBaseFileName() < rhs.getBaseFileName(); + }; + std::sort(result.begin(), result.end(), lessThanPackage); + return result; +} + +} // namespace qbs diff --git a/src/lib/pkgconfig/pkgconfig.h b/src/lib/pkgconfig/pkgconfig.h new file mode 100644 index 00000000..c1cc634e --- /dev/null +++ b/src/lib/pkgconfig/pkgconfig.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2021 Ivan Komissarov (abbapoh@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PKGCONFIG_H +#define PKGCONFIG_H + +#include "pcpackage.h" + +namespace qbs { + +class PkgConfig +{ +public: + struct Options { + using VariablesMap = PcPackage::VariablesMap; + + std::vector libDirs; // PKG_CONFIG_LIBDIR + std::vector extraPaths; // PKG_CONFIG_PATH + std::string sysroot; // PKG_CONFIG_SYSROOT_DIR + std::string topBuildDir; // PKG_CONFIG_TOP_BUILD_DIR + bool allowSystemLibraryPaths{false}; // PKG_CONFIG_ALLOW_SYSTEM_LIBS + std::vector systemLibraryPaths; // PKG_CONFIG_SYSTEM_LIBRARY_PATH + bool disableUninstalled{true}; // PKG_CONFIG_DISABLE_UNINSTALLED + bool staticMode{false}; + bool mergeDependencies{true}; + VariablesMap globalVariables; + VariablesMap systemVariables; + }; + + using Packages = std::vector; + + explicit PkgConfig(); + explicit PkgConfig(Options options); + + const Options &options() const { return m_options; } + const Packages &packages() const { return m_packages; } + const PcPackageVariant &getPackage(std::string_view baseFileName) const; + + std::optional packageGetVariable( + const PcPackage &pkg, std::string_view var) const; + +private: + Packages findPackages() const; + Packages mergeDependencies(const Packages &packages) const; + +private: + Options m_options; + + Packages m_packages; +}; + +} // namespace qbs + +#endif // PKGCONFIG_H diff --git a/src/lib/pkgconfig/pkgconfig.pro b/src/lib/pkgconfig/pkgconfig.pro new file mode 100644 index 00000000..dcabf0ba --- /dev/null +++ b/src/lib/pkgconfig/pkgconfig.pro @@ -0,0 +1,25 @@ +TARGET = qbspkgconfig +include(../staticlibrary.pri) +include(../../shared/variant/variant.pri) + +DEFINES += \ + PKG_CONFIG_PC_PATH=\\\"/usr/lib/pkgconfig:/usr/share/pkgconfig\\\" \ + PKG_CONFIG_SYSTEM_LIBRARY_PATH=\\\"/usr/$${QBS_LIBRARY_DIRNAME}/\\\" \ + QBS_PC_WITH_QT_SUPPORT=1 + +macos|win32-g++ { + DEFINES += HAS_STD_FILESYSTEM=0 +} else { + DEFINES += HAS_STD_FILESYSTEM=1 +} + +HEADERS += \ + pcpackage.h \ + pcparser.h \ + pkgconfig.h + +SOURCES += \ + pcpackage.cpp \ + pcparser.cpp \ + pkgconfig.cpp \ + diff --git a/src/lib/pkgconfig/pkgconfig.qbs b/src/lib/pkgconfig/pkgconfig.qbs new file mode 100644 index 00000000..a32eb775 --- /dev/null +++ b/src/lib/pkgconfig/pkgconfig.qbs @@ -0,0 +1,68 @@ +import qbs.FileInfo +import qbs.Utilities + +QbsStaticLibrary { + Depends { name: "cpp" } + Depends { name: "qbsbuildconfig" } + Depends { name: "qbsvariant" } + + property stringList pcPaths: { + var result = []; + result.push(FileInfo.joinPaths(qbs.installPrefix, qbsbuildconfig.libDirName, "pkgconfig")); + result.push(FileInfo.joinPaths(qbs.installPrefix, "share", "pkgconfig")); + if (qbs.hostOS.contains("unix")) { + result.push("/usr/lib/pkgconfig/") + result.push("/usr/share/pkgconfig/") + } + return result + } + readonly property stringList pcPathsString: pcPaths.join(qbs.pathListSeparator) + + property bool withQtSupport: true + + readonly property stringList publicDefines: { + var result = []; + if (withQtSupport) + result.push("QBS_PC_WITH_QT_SUPPORT=1") + else + result.push("QBS_PC_WITH_QT_SUPPORT=0") + return result; + } + + name: "qbspkgconfig" + + files: [ + "pcpackage.cpp", + "pcpackage.h", + "pcparser.cpp", + "pcparser.h", + "pkgconfig.cpp", + "pkgconfig.h", + ] + + cpp.defines: { + var result = [ + "PKG_CONFIG_PC_PATH=\"" + pcPathsString + "\"", + "PKG_CONFIG_SYSTEM_LIBRARY_PATH=\"/usr/" + qbsbuildconfig.libDirName + "\"", + ] + if ((qbs.targetOS.contains("darwin") + && Utilities.versionCompare(cpp.minimumMacosVersion, "10.15") < 0) + || qbs.toolchain.contains("mingw")) + result.push("HAS_STD_FILESYSTEM=0") + else + result.push("HAS_STD_FILESYSTEM=1") + result = result.concat(publicDefines); + return result + } + + Export { + Depends { name: "cpp" } + Depends { name: "qbsvariant" } + cpp.defines: exportingProduct.publicDefines + cpp.staticLibraries: { + if (qbs.toolchainType === "gcc" && cpp.compilerVersionMajor < 9) + return ["stdc++fs"]; + return []; + } + } +} diff --git a/src/lib/pkgconfig/use_pkgconfig.pri b/src/lib/pkgconfig/use_pkgconfig.pri new file mode 100644 index 00000000..4620aec7 --- /dev/null +++ b/src/lib/pkgconfig/use_pkgconfig.pri @@ -0,0 +1,52 @@ +include(../../library_dirname.pri) +include(../../shared/variant/variant.pri) + +isEmpty(QBSLIBDIR) { + QBSLIBDIR = $${OUT_PWD}/../../../$${QBS_LIBRARY_DIRNAME} +} + +QBSPKGCONFIG_LIBNAME=qbspkgconfig + +unix { + LIBS += -L$${QBSLIBDIR} -l$${QBSPKGCONFIG_LIBNAME} +} + +win32 { + CONFIG(debug, debug|release) { + QBSPKGCONFIG_LIB = $${QBSPKGCONFIG_LIBNAME}d + } + CONFIG(release, debug|release) { + QBSPKGCONFIG_LIB = $${QBSPKGCONFIG_LIBNAME} + } + msvc { + LIBS += /LIBPATH:$$QBSLIBDIR + QBSPKGCONFIG_LIB = $${QBSPKGCONFIG_LIB}.lib + LIBS += Shell32.lib + } else { + LIBS += -L$${QBSLIBDIR} + QBSPKGCONFIG_LIB = lib$${QBSPKGCONFIG_LIB} + } + LIBS += $${QBSPKGCONFIG_LIB} +} + +gcc:!clang { + isEmpty(COMPILER_VERSION) { + COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion") + COMPILER_MAJOR_VERSION = $$str_member($$COMPILER_VERSION) + lessThan(COMPILER_MAJOR_VERSION, 9) { + LIBS += -lstdc++fs + } + } +} + +INCLUDEPATH += \ + $$PWD + +CONFIG += depend_includepath + +CONFIG(static, static|shared) { + DEFINES += QBS_STATIC_LIB +} + +DEFINES += \ + QBS_PC_WITH_QT_SUPPORT=1 diff --git a/src/lib/scriptengine/CMakeLists.txt b/src/lib/scriptengine/CMakeLists.txt new file mode 100644 index 00000000..7e5a60d6 --- /dev/null +++ b/src/lib/scriptengine/CMakeLists.txt @@ -0,0 +1,367 @@ +set(QT_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../shared/qtscript/src/") + +if (UNIX) + set(_USE_SYSTEM_MALLOC NO) +else() + set(_USE_SYSTEM_MALLOC YES) +endif (UNIX) + +set(JAVASCRIPT_CORE_INCLUDES + assembler + bytecode + bytecompiler + debugger + interpreter + jit + parser + pcre + profiler + runtime + wrec + wtf + wtf/unicode + yarr + API + ForwardingHeaders + generated +) +list_transform_prepend(JAVASCRIPT_CORE_INCLUDES "${QT_SCRIPT_PATH}/3rdparty/javascriptcore/JavaScriptCore/") + +set(QT_SCRIPT_PUBLIC_INCLUDES + "${CMAKE_CURRENT_SOURCE_DIR}/include" + "${CMAKE_CURRENT_BINARY_DIR}/include" +) + +set(QT_SCRIPT_INCLUDES + "${QT_SCRIPT_PATH}/3rdparty/javascriptcore" + "${QT_SCRIPT_PATH}/3rdparty/javascriptcore/JavaScriptCore" + "${QT_SCRIPT_PATH}/script" + "${QT_SCRIPT_PATH}/script/api" + "${QT_SCRIPT_PATH}/script/parser" + "${CMAKE_CURRENT_BINARY_DIR}/include/QtScript/${QT_VERSION}/QtScript" +) + +set(QT_SCRIPT_DEFINES + "QT_BUILD_SCRIPT_LIB" + "QT_NO_USING_NAMESPACE" + "JSC=QTJSC" + "jscyyparse=qtjscyyparse" + "jscyylex=qtjscyylex" + "jscyyerror=qtjscyyerror" + "WTF=QTWTF" + "LOG_DISABLED=1" + "WTF_USE_JAVASCRIPTCORE_BINDINGS=1" + "WTF_CHANGES=1" + "JS_NO_EXPORT" + + # JavaScriptCore + "BUILDING_QT__" + "BUILDING_JavaScriptCore" + "BUILDING_WTF" + "ENABLE_JIT=0" + "ENABLE_YARR_JIT=0" + "ENABLE_YARR=0" + + # WebKit + "WTF_USE_ACCELERATED_COMPOSITING" +) + +if (APPLE) + list(APPEND QT_SCRIPT_DEFINES "ENABLE_JSC_MULTIPLE_THREADS=0") +elseif(WIN32) + list(APPEND QT_SCRIPT_DEFINES "NOMINMAX" "_CRT_RAND_S") +endif() + +if (MSVC) + set(QT_SCRIPT_CXX_FLAGS "/wd4018" "/wd4146" "/wd4244" "/wd4267" "/wd4291" + "/wd4334" "/wd4344" "/wd4396" "/wd4503" "/wd4800" "/wd4819" "/wd4996") +else() + set(QT_SCRIPT_CXX_FLAGS "-fno-strict-aliasing" "-w" + "-Wall" "-Wreturn-type" "-Wcast-align" "-Wchar-subscripts" + "-Wformat-security" "-Wreturn-type" "-Wno-unused-parameter" + "-Wno-sign-compare" "-Wno-switch" "-Wno-switch-enum" "-Wundef" + "-Wmissing-noreturn" "-Winit-self" "-Wno-deprecated" "-Wno-suggest-attribute=noreturn" + "-Wno-nonnull-compare" "-pthread") +endif() + +set(QT_SCRIPT_PUBLIC_DEPENDS Qt${QT_VERSION_MAJOR}::Core) +if (UNIX) + list(APPEND QT_SCRIPT_PUBLIC_DEPENDS "pthread") +elseif(WIN32) + list(APPEND QT_SCRIPT_PUBLIC_DEPENDS "winmm") +endif() + +set(PCRE_SOURCES + pcre_compile.cpp + pcre_exec.cpp + pcre_tables.cpp + pcre_ucp_searchfuncs.cpp + pcre_xclass.cpp +) +list_transform_prepend(PCRE_SOURCES "${QT_SCRIPT_PATH}/3rdparty/javascriptcore/JavaScriptCore/pcre/") + +if (NOT _USE_SYSTEM_MALLOC) + set(SYSTEM_MALLOC_SOURCES + wtf/TCSystemAlloc.cpp + ) + list_transform_prepend(SYSTEM_MALLOC_SOURCES "${QT_SCRIPT_PATH}/3rdparty/javascriptcore/JavaScriptCore/") + +else() + set(SYSTEM_MALLOC_SOURCES "") + list(APPEND QT_SCRIPT_DEFINES "USE_SYSTEM_MALLOC") +endif() + +set(JAVASCRIPT_CORE_SOURCES + API/JSBase.cpp + API/JSCallbackConstructor.cpp + API/JSCallbackFunction.cpp + API/JSCallbackObject.cpp + API/JSClassRef.cpp + API/JSContextRef.cpp + API/JSObjectRef.cpp + API/JSStringRef.cpp + API/JSValueRef.cpp + API/OpaqueJSString.cpp + assembler/ARMAssembler.cpp + assembler/MacroAssemblerARM.cpp + bytecode/CodeBlock.cpp + bytecode/JumpTable.cpp + bytecode/Opcode.cpp + bytecode/SamplingTool.cpp + bytecode/StructureStubInfo.cpp + bytecompiler/BytecodeGenerator.cpp + bytecompiler/NodesCodegen.cpp + debugger/DebuggerActivation.cpp + debugger/DebuggerCallFrame.cpp + debugger/Debugger.cpp + generated/Grammar.cpp + interpreter/CallFrame.cpp + interpreter/Interpreter.cpp + interpreter/RegisterFile.cpp + parser/Lexer.cpp + parser/Nodes.cpp + parser/ParserArena.cpp + parser/Parser.cpp + profiler/Profile.cpp + profiler/ProfileGenerator.cpp + profiler/ProfileNode.cpp + profiler/Profiler.cpp + runtime/ArgList.cpp + runtime/Arguments.cpp + runtime/ArrayConstructor.cpp + runtime/ArrayPrototype.cpp + runtime/BooleanConstructor.cpp + runtime/BooleanObject.cpp + runtime/BooleanPrototype.cpp + runtime/CallData.cpp + runtime/Collector.cpp + runtime/CommonIdentifiers.cpp + runtime/Completion.cpp + runtime/ConstructData.cpp + runtime/DateConstructor.cpp + runtime/DateConversion.cpp + runtime/DateInstance.cpp + runtime/DatePrototype.cpp + runtime/ErrorConstructor.cpp + runtime/Error.cpp + runtime/ErrorInstance.cpp + runtime/ErrorPrototype.cpp + runtime/ExceptionHelpers.cpp + runtime/Executable.cpp + runtime/FunctionConstructor.cpp + runtime/FunctionPrototype.cpp + runtime/GetterSetter.cpp + runtime/GlobalEvalFunction.cpp + runtime/Identifier.cpp + runtime/InitializeThreading.cpp + runtime/InternalFunction.cpp + runtime/JSActivation.cpp + runtime/JSAPIValueWrapper.cpp + runtime/JSArray.cpp + runtime/JSByteArray.cpp + runtime/JSCell.cpp + runtime/JSFunction.cpp + runtime/JSGlobalData.cpp + runtime/JSGlobalObject.cpp + runtime/JSGlobalObjectFunctions.cpp + runtime/JSImmediate.cpp + runtime/JSLock.cpp + runtime/JSNotAnObject.cpp + runtime/JSNumberCell.cpp + runtime/JSObject.cpp + runtime/JSONObject.cpp + runtime/JSPropertyNameIterator.cpp + runtime/JSStaticScopeObject.cpp + runtime/JSString.cpp + runtime/JSValue.cpp + runtime/JSVariableObject.cpp + runtime/JSWrapperObject.cpp + runtime/LiteralParser.cpp + runtime/Lookup.cpp + runtime/MarkStackPosix.cpp + runtime/MarkStackSymbian.cpp + runtime/MarkStackWin.cpp + runtime/MarkStack.cpp + runtime/MathObject.cpp + runtime/NativeErrorConstructor.cpp + runtime/NativeErrorPrototype.cpp + runtime/NumberConstructor.cpp + runtime/NumberObject.cpp + runtime/NumberPrototype.cpp + runtime/ObjectConstructor.cpp + runtime/ObjectPrototype.cpp + runtime/Operations.cpp + runtime/PropertyDescriptor.cpp + runtime/PropertyNameArray.cpp + runtime/PropertySlot.cpp + runtime/PrototypeFunction.cpp + runtime/RegExpConstructor.cpp + runtime/RegExp.cpp + runtime/RegExpObject.cpp + runtime/RegExpPrototype.cpp + runtime/ScopeChain.cpp + runtime/SmallStrings.cpp + runtime/StringConstructor.cpp + runtime/StringObject.cpp + runtime/StringPrototype.cpp + runtime/StructureChain.cpp + runtime/Structure.cpp + runtime/TimeoutChecker.cpp + runtime/UString.cpp + runtime/UStringImpl.cpp + wtf/Assertions.cpp + wtf/ByteArray.cpp + wtf/CurrentTime.cpp + wtf/DateMath.cpp + wtf/dtoa.cpp + wtf/FastMalloc.cpp + wtf/HashTable.cpp + wtf/MainThread.cpp + wtf/qt/MainThreadQt.cpp + wtf/qt/ThreadingQt.cpp + wtf/RandomNumber.cpp + wtf/RefCountedLeakCounter.cpp + wtf/ThreadingNone.cpp + wtf/Threading.cpp + wtf/TypeTraits.cpp + wtf/unicode/CollatorDefault.cpp + wtf/unicode/icu/CollatorICU.cpp + wtf/unicode/UTF8.cpp +) +list_transform_prepend(JAVASCRIPT_CORE_SOURCES "${QT_SCRIPT_PATH}/3rdparty/javascriptcore/JavaScriptCore/") + +set(API_SOURCES + qscriptable.cpp + qscriptable.h + qscriptable_p.h + qscriptclass.cpp + qscriptclass.h + qscriptclasspropertyiterator.cpp + qscriptclasspropertyiterator.h + qscriptcontext.cpp + qscriptcontext.h + qscriptcontextinfo.cpp + qscriptcontextinfo.h + qscriptcontext_p.h + qscriptengineagent.cpp + qscriptengineagent.h + qscriptengineagent_p.h + qscriptengine.cpp + qscriptengine.h + qscriptengine_p.h + qscriptextensioninterface.h + qscriptextensionplugin.cpp + qscriptextensionplugin.h + qscriptprogram.cpp + qscriptprogram.h + qscriptprogram_p.h + qscriptstring.cpp + qscriptstring.h + qscriptstring_p.h + qscriptvalue.cpp + qscriptvalue.h + qscriptvalueiterator.cpp + qscriptvalueiterator.h + qscriptvalue_p.h + qtscriptglobal.h +) +list_transform_prepend(API_SOURCES "${QT_SCRIPT_PATH}/script/api/") + +set(BRIDGE_SOURCES + qscriptactivationobject.cpp + qscriptactivationobject_p.h + qscriptclassobject.cpp + qscriptclassobject_p.h + qscriptfunction.cpp + qscriptfunction_p.h + qscriptglobalobject.cpp + qscriptglobalobject_p.h + qscriptobject.cpp + qscriptobject_p.h + qscriptqobject.cpp + qscriptqobject_p.h + qscriptstaticscopeobject.cpp + qscriptstaticscopeobject_p.h + qscriptvariant.cpp + qscriptvariant_p.h +) +list_transform_prepend(BRIDGE_SOURCES "${QT_SCRIPT_PATH}/script/bridge/") + +set(PARSER_SOURCES + qscriptast.cpp + qscriptastfwd_p.h + qscriptast_p.h + qscriptastvisitor.cpp + qscriptastvisitor_p.h + qscriptgrammar.cpp + qscriptgrammar_p.h + qscriptlexer.cpp + qscriptlexer_p.h + qscriptsyntaxchecker.cpp + qscriptsyntaxchecker_p.h +) +list_transform_prepend(PARSER_SOURCES "${QT_SCRIPT_PATH}/script/parser/") + +find_package(Perl) + +get_target_property(_QT_MOC_EXECUTABLE Qt${QT_VERSION_MAJOR}::moc IMPORTED_LOCATION) +get_filename_component(_QT_LIBEXEC_DIRECTORY ${_QT_MOC_EXECUTABLE} DIRECTORY) + +file(GLOB API_HEADERS "${QT_SCRIPT_PATH}/script/api/*.h") + +set(EXTERNAL_DEPENDS "") +if(APPLE) + set(EXTERNAL_DEPENDS "-framework CoreFoundation") +endif() + +if(WIN32) + set(EXTERNAL_DEPENDS "winmm") +endif() + +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/QtScript/qscriptengine.h" + COMMAND ${PERL_EXECUTABLE} "${_QT_LIBEXEC_DIRECTORY}/syncqt.pl" + -minimal + -version "${QT_VERSION}" + -outdir ${CMAKE_CURRENT_BINARY_DIR} + "${QT_SCRIPT_PATH}/.." + BYPRODUCTS + DEPENDS ${API_HEADERS} + ) + +add_qbs_library(qbsscriptengine + DEFINES ${QT_SCRIPT_DEFINES} + DEPENDS Qt${QT_VERSION_MAJOR}::CorePrivate Qt6Core5Compat ${EXTERNAL_DEPENDS} + PUBLIC_DEPENDS ${QT_SCRIPT_PUBLIC_DEPENDS} + INCLUDES ${QT_SCRIPT_PUBLIC_INCLUDES} ${QT_SCRIPT_INCLUDES} ${JAVASCRIPT_CORE_INCLUDES} + PUBLIC_INCLUDES ${QT_SCRIPT_PUBLIC_INCLUDES} + SOURCES + "${CMAKE_CURRENT_BINARY_DIR}/include/QtScript/qscriptengine.h" + ${PCRE_SOURCES} + ${SYSTEM_MALLOC_SOURCES} + ${JAVASCRIPT_CORE_SOURCES} + ${API_SOURCES} + ${BRIDGE_SOURCES} + ${PARSER_SOURCES} + ) +target_compile_options(qbsscriptengine PRIVATE ${QT_SCRIPT_CXX_FLAGS}) diff --git a/src/lib/scriptengine/scriptengine.pro b/src/lib/scriptengine/scriptengine.pro new file mode 100644 index 00000000..34fd5a5f --- /dev/null +++ b/src/lib/scriptengine/scriptengine.pro @@ -0,0 +1,98 @@ +TARGET = qbsscriptengine +include(../library.pri) + +QT = core-private + +versionAtLeast(QT_VERSION, 6.0.0) { + QT += core5compat +} + +DEFINES += QT_BUILD_SCRIPT_LIB + +DEFINES += JSC=QTJSC jscyyparse=qtjscyyparse jscyylex=qtjscyylex jscyyerror=qtjscyyerror WTF=QTWTF +DEFINES += QT_NO_USING_NAMESPACE + +CONFIG += building-libs + +GENERATED_SOURCES_DIR = generated + +CONFIG += QTDIR_build +include(../../shared/qtscript/src/3rdparty/javascriptcore/WebKit.pri) + +# Disable a few warnings on Windows. +# These are in addition to the ones disabled in WebKit.pri +msvc: QMAKE_CXXFLAGS += -wd4396 -wd4099 +else: QMAKE_CXXFLAGS += -Wno-deprecated + +# We cannot afford -O0 for QtScript even in debug builds. +QMAKE_CXXFLAGS_DEBUG += -O2 + +darwin { + DEFINES += ENABLE_JSC_MULTIPLE_THREADS=0 + contains(QT_CONFIG, coreservices) { + LIBS_PRIVATE += -framework CoreServices + } else { + LIBS_PRIVATE += -framework CoreFoundation + } +} +win32 { + LIBS += -lwinmm +} + +# Suppress 'LEAK' messages (see QTBUG-18201) +DEFINES += LOG_DISABLED=1 + +JAVASCRIPTCORE_JIT = no +include(../../shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/JavaScriptCore.pri) + +# This line copied from WebCore.pro +DEFINES += WTF_USE_JAVASCRIPTCORE_BINDINGS=1 WTF_CHANGES=1 + +CONFIG(release, debug|release): DEFINES += NDEBUG + +# Avoid JSC C API functions being exported. +DEFINES += JS_NO_EXPORT + +!build_pass { + versionAtLeast(QT_VERSION, 6.1.0) { + qtPrepareLibExecTool(QMAKE_SYNCQT, syncqt, , system) + } else { + qtPrepareTool(QMAKE_SYNCQT, syncqt, , system) + } + QMAKE_SYNCQT += \ + -minimal -version $$[QT_VERSION] \ + -outdir $$system_quote($$system_path($$OUT_PWD)) \ + $$system_quote($$system_path($$clean_path($$PWD/../../shared/qtscript))) + !system($$QMAKE_SYNCQT): error("Failed to execute syncqt for the bundled QtScript module.") +} + +INCLUDEPATH += \ + $$PWD/include \ + $$OUT_PWD/include \ + $$OUT_PWD/include/QtScript/$$[QT_VERSION]/QtScript \ + $$PWD/../../shared/qtscript/src/script \ + $$PWD/../../shared/qtscript/src/script/api + +include(../../shared/qtscript/src/script/api/api.pri) +include(../../shared/qtscript/src/script/parser/parser.pri) + +BRIDGESRCDIR = ../../shared/qtscript/src/script/bridge +SOURCES += \ + $$BRIDGESRCDIR/qscriptactivationobject.cpp \ + $$BRIDGESRCDIR/qscriptclassobject.cpp \ + $$BRIDGESRCDIR/qscriptfunction.cpp \ + $$BRIDGESRCDIR/qscriptglobalobject.cpp \ + $$BRIDGESRCDIR/qscriptobject.cpp \ + $$BRIDGESRCDIR/qscriptqobject.cpp \ + $$BRIDGESRCDIR/qscriptstaticscopeobject.cpp \ + $$BRIDGESRCDIR/qscriptvariant.cpp + +HEADERS += \ + $$BRIDGESRCDIR/qscriptactivationobject_p.h \ + $$BRIDGESRCDIR/qscriptclassobject_p.h \ + $$BRIDGESRCDIR/qscriptfunction_p.h \ + $$BRIDGESRCDIR/qscriptglobalobject_p.h \ + $$BRIDGESRCDIR/qscriptobject_p.h \ + $$BRIDGESRCDIR/qscriptqobject_p.h \ + $$BRIDGESRCDIR/qscriptstaticscopeobject_p.h \ + $$BRIDGESRCDIR/qscriptvariant_p.h diff --git a/src/lib/scriptengine/scriptengine.qbs b/src/lib/scriptengine/scriptengine.qbs new file mode 100644 index 00000000..fcbd6ffa --- /dev/null +++ b/src/lib/scriptengine/scriptengine.qbs @@ -0,0 +1,464 @@ +import qbs.File +import qbs.FileInfo +import qbs.Probes +import qbs.Process +import qbs.Utilities + +Project { + QbsLibrary { + condition: qbsbuildconfig.useBundledQtScript || !Qt.script.present + Depends { + name: "Qt.script" + condition: !qbsbuildconfig.useBundledQtScript + required: false + } + Depends { name: "QtScriptFwdHeaders" } + Depends { name: "cpp" } + Depends { name: "Qt"; submodules: ["core-private"] } + Depends { + name: "Qt.core5compat"; + condition: Utilities.versionCompare(Qt.core.version, "6.0.0") >= 0 + } + name: "qbsscriptengine" + + generatePkgConfigFile: false + generateQbsModule: false + + property bool useSystemMalloc: !qbs.targetOS.contains("macos") + && !qbs.targetOS.contains("unix") + property string qtscriptPath: "../../shared/qtscript/src/" + cpp.includePaths: { + var result = base.concat( + ".", + "include" + ); + + var jscBaseDir = qtscriptPath + "3rdparty/javascriptcore"; + result.push(jscBaseDir); + jscBaseDir += "/JavaScriptCore"; + result.push(jscBaseDir); + + var jscSubDirs = [ + "assembler", + "bytecode", + "bytecompiler", + "debugger", + "interpreter", + "jit", + "parser", + "pcre", + "profiler", + "runtime", + "wrec", + "wtf", + "wtf/unicode", + "yarr", + "API", + "ForwardingHeaders", + "generated"]; + result = result.concat(jscSubDirs.map(function(s) { return jscBaseDir + '/' + s; })); + + result.push(qtscriptPath + "script"); + result.push(qtscriptPath + "script/api"); + result.push(qtscriptPath + "script/parser"); + result = result.concat(QtScriptFwdHeaders.publicIncludePaths, + QtScriptFwdHeaders.privateIncludePaths); + return result; + } + cpp.defines: { + var result = base.concat([ + "QT_BUILD_SCRIPT_LIB", "QT_NO_USING_NAMESPACE", + "JSC=QTJSC", "jscyyparse=qtjscyyparse", "jscyylex=qtjscyylex", + "jscyyerror=qtjscyyerror", + "WTF=QTWTF", + "LOG_DISABLED=1", + "WTF_USE_JAVASCRIPTCORE_BINDINGS=1", "WTF_CHANGES=1", + "JS_NO_EXPORT"]); + if (qbs.buildVariant != "debug") + result.push("NDEBUG"); + if (qbs.targetOS.contains("macos")) + result.push("ENABLE_JSC_MULTIPLE_THREADS=0"); + + // JavaScriptCore + result.push("BUILDING_QT__", "BUILDING_JavaScriptCore", "BUILDING_WTF", + "ENABLE_JIT=0", "ENABLE_YARR_JIT=0", "ENABLE_YARR=0"); + if (qbs.targetOS.contains("windows")) { + // Prevent definition of min, max macros in windows.h + result.push("NOMINMAX"); + // Enables rand_s + result.push("_CRT_RAND_S"); + } + + // WebKit + result.push("WTF_USE_ACCELERATED_COMPOSITING"); + if (useSystemMalloc) + result.push("USE_SYSTEM_MALLOC"); + + result = result.filter(function(value) { + return value !== "QT_RESTRICTED_CAST_FROM_ASCII" + && value !== "QT_NO_CAST_FROM_BYTEARRAY" + && value !== "QT_NO_CAST_FROM_ASCII"; + }) + return result; + } + cpp.cxxFlags: { + var result = base; + if (qbs.toolchain.contains("gcc")) { + result.push("-fno-strict-aliasing", + "-Wall", "-Wreturn-type", "-Wcast-align", "-Wchar-subscripts", + "-Wformat-security", "-Wreturn-type", "-Wno-unused-parameter", + "-Wno-sign-compare", "-Wno-switch", "-Wno-switch-enum", "-Wundef", + "-Wmissing-noreturn", "-Winit-self", "-Wno-deprecated", + "-Wno-suggest-attribute=noreturn", "-Wno-nonnull-compare"); + } else if (qbs.toolchain.contains("msvc")) { + result.push("-wd4291", "-wd4344", "-wd4396", "-wd4503", "-wd4800", "-wd4819", + "-wd4996"); + } + if (qbs.targetOS.contains("unix")) + result.push("-pthread"); + + return result; + } + cpp.warningLevel: "none" + cpp.optimization: "fast" // We cannot afford -O0 for QtScript even in debug builds. + cpp.frameworks: base.concat(qbs.targetOS.contains("darwin") ? ["CoreFoundation"] : []) + Properties { + condition: qbs.targetOS.contains("unix") + cpp.dynamicLibraries: base.concat(["pthread"]) + } + Properties { + condition: qbs.targetOS.contains("windows") + cpp.dynamicLibraries: base.concat(["winmm"]) + } + + Group { + name: "pcre" + prefix: qtscriptPath + "3rdparty/javascriptcore/JavaScriptCore/pcre/" + files: [ + "pcre_compile.cpp", + "pcre_exec.cpp", + "pcre_tables.cpp", + "pcre_ucp_searchfuncs.cpp", + "pcre_xclass.cpp", + ] + } + + Group { + name: "system malloc replacement" + prefix: qtscriptPath + "3rdparty/javascriptcore/JavaScriptCore/" + condition: !useSystemMalloc + files: [ + "wtf/TCSystemAlloc.cpp", + ] + } + + Group { + name: "JavaScriptCore" + prefix: qtscriptPath + "3rdparty/javascriptcore/JavaScriptCore/" + files: [ + "API/JSBase.cpp", + "API/JSCallbackConstructor.cpp", + "API/JSCallbackFunction.cpp", + "API/JSCallbackObject.cpp", + "API/JSClassRef.cpp", + "API/JSContextRef.cpp", + "API/JSObjectRef.cpp", + "API/JSStringRef.cpp", + "API/JSValueRef.cpp", + "API/OpaqueJSString.cpp", + "assembler/ARMAssembler.cpp", + "assembler/MacroAssemblerARM.cpp", + "bytecode/CodeBlock.cpp", + "bytecode/JumpTable.cpp", + "bytecode/Opcode.cpp", + "bytecode/SamplingTool.cpp", + "bytecode/StructureStubInfo.cpp", + "bytecompiler/BytecodeGenerator.cpp", + "bytecompiler/NodesCodegen.cpp", + "debugger/DebuggerActivation.cpp", + "debugger/DebuggerCallFrame.cpp", + "debugger/Debugger.cpp", + "generated/Grammar.cpp", + "interpreter/CallFrame.cpp", + "interpreter/Interpreter.cpp", + "interpreter/RegisterFile.cpp", + "parser/Lexer.cpp", + "parser/Nodes.cpp", + "parser/ParserArena.cpp", + "parser/Parser.cpp", + "profiler/Profile.cpp", + "profiler/ProfileGenerator.cpp", + "profiler/ProfileNode.cpp", + "profiler/Profiler.cpp", + "runtime/ArgList.cpp", + "runtime/Arguments.cpp", + "runtime/ArrayConstructor.cpp", + "runtime/ArrayPrototype.cpp", + "runtime/BooleanConstructor.cpp", + "runtime/BooleanObject.cpp", + "runtime/BooleanPrototype.cpp", + "runtime/CallData.cpp", + "runtime/Collector.cpp", + "runtime/CommonIdentifiers.cpp", + "runtime/Completion.cpp", + "runtime/ConstructData.cpp", + "runtime/DateConstructor.cpp", + "runtime/DateConversion.cpp", + "runtime/DateInstance.cpp", + "runtime/DatePrototype.cpp", + "runtime/ErrorConstructor.cpp", + "runtime/Error.cpp", + "runtime/ErrorInstance.cpp", + "runtime/ErrorPrototype.cpp", + "runtime/ExceptionHelpers.cpp", + "runtime/Executable.cpp", + "runtime/FunctionConstructor.cpp", + "runtime/FunctionPrototype.cpp", + "runtime/GetterSetter.cpp", + "runtime/GlobalEvalFunction.cpp", + "runtime/Identifier.cpp", + "runtime/InitializeThreading.cpp", + "runtime/InternalFunction.cpp", + "runtime/JSActivation.cpp", + "runtime/JSAPIValueWrapper.cpp", + "runtime/JSArray.cpp", + "runtime/JSByteArray.cpp", + "runtime/JSCell.cpp", + "runtime/JSFunction.cpp", + "runtime/JSGlobalData.cpp", + "runtime/JSGlobalObject.cpp", + "runtime/JSGlobalObjectFunctions.cpp", + "runtime/JSImmediate.cpp", + "runtime/JSLock.cpp", + "runtime/JSNotAnObject.cpp", + "runtime/JSNumberCell.cpp", + "runtime/JSObject.cpp", + "runtime/JSONObject.cpp", + "runtime/JSPropertyNameIterator.cpp", + "runtime/JSStaticScopeObject.cpp", + "runtime/JSString.cpp", + "runtime/JSValue.cpp", + "runtime/JSVariableObject.cpp", + "runtime/JSWrapperObject.cpp", + "runtime/LiteralParser.cpp", + "runtime/Lookup.cpp", + "runtime/MarkStackPosix.cpp", + "runtime/MarkStackSymbian.cpp", + "runtime/MarkStackWin.cpp", + "runtime/MarkStack.cpp", + "runtime/MathObject.cpp", + "runtime/NativeErrorConstructor.cpp", + "runtime/NativeErrorPrototype.cpp", + "runtime/NumberConstructor.cpp", + "runtime/NumberObject.cpp", + "runtime/NumberPrototype.cpp", + "runtime/ObjectConstructor.cpp", + "runtime/ObjectPrototype.cpp", + "runtime/Operations.cpp", + "runtime/PropertyDescriptor.cpp", + "runtime/PropertyNameArray.cpp", + "runtime/PropertySlot.cpp", + "runtime/PrototypeFunction.cpp", + "runtime/RegExpConstructor.cpp", + "runtime/RegExp.cpp", + "runtime/RegExpObject.cpp", + "runtime/RegExpPrototype.cpp", + "runtime/ScopeChain.cpp", + "runtime/SmallStrings.cpp", + "runtime/StringConstructor.cpp", + "runtime/StringObject.cpp", + "runtime/StringPrototype.cpp", + "runtime/StructureChain.cpp", + "runtime/Structure.cpp", + "runtime/TimeoutChecker.cpp", + "runtime/UString.cpp", + "runtime/UStringImpl.cpp", + "wtf/Assertions.cpp", + "wtf/ByteArray.cpp", + "wtf/CurrentTime.cpp", + "wtf/DateMath.cpp", + "wtf/dtoa.cpp", + "wtf/FastMalloc.cpp", + "wtf/HashTable.cpp", + "wtf/MainThread.cpp", + "wtf/qt/MainThreadQt.cpp", + "wtf/qt/ThreadingQt.cpp", + "wtf/RandomNumber.cpp", + "wtf/RefCountedLeakCounter.cpp", + "wtf/ThreadingNone.cpp", + "wtf/Threading.cpp", + "wtf/TypeTraits.cpp", + "wtf/unicode/CollatorDefault.cpp", + "wtf/unicode/icu/CollatorICU.cpp", + "wtf/unicode/UTF8.cpp", + ] + } + Group { + name: "api" + prefix: qtscriptPath + "script/api/" + files: [ + "qscriptable.cpp", + "qscriptable.h", + "qscriptable_p.h", + "qscriptclass.cpp", + "qscriptclass.h", + "qscriptclasspropertyiterator.cpp", + "qscriptclasspropertyiterator.h", + "qscriptcontext.cpp", + "qscriptcontext.h", + "qscriptcontextinfo.cpp", + "qscriptcontextinfo.h", + "qscriptcontext_p.h", + "qscriptengineagent.cpp", + "qscriptengineagent.h", + "qscriptengineagent_p.h", + "qscriptengine.cpp", + "qscriptengine.h", + "qscriptengine_p.h", + "qscriptextensioninterface.h", + "qscriptextensionplugin.cpp", + "qscriptextensionplugin.h", + "qscriptprogram.cpp", + "qscriptprogram.h", + "qscriptprogram_p.h", + "qscriptstring.cpp", + "qscriptstring.h", + "qscriptstring_p.h", + "qscriptvalue.cpp", + "qscriptvalue.h", + "qscriptvalueiterator.cpp", + "qscriptvalueiterator.h", + "qscriptvalue_p.h", + "qtscriptglobal.h", + ] + } + Group { + name: "bridge" + prefix: qtscriptPath + "script/bridge/" + files: [ + "qscriptactivationobject.cpp", + "qscriptactivationobject_p.h", + "qscriptclassobject.cpp", + "qscriptclassobject_p.h", + "qscriptfunction.cpp", + "qscriptfunction_p.h", + "qscriptglobalobject.cpp", + "qscriptglobalobject_p.h", + "qscriptobject.cpp", + "qscriptobject_p.h", + "qscriptqobject.cpp", + "qscriptqobject_p.h", + "qscriptstaticscopeobject.cpp", + "qscriptstaticscopeobject_p.h", + "qscriptvariant.cpp", + "qscriptvariant_p.h", + ] + } + Group { + name: "parser" + prefix: qtscriptPath + "script/parser/" + files: [ + "qscriptast.cpp", + "qscriptastfwd_p.h", + "qscriptast_p.h", + "qscriptastvisitor.cpp", + "qscriptastvisitor_p.h", + "qscriptgrammar.cpp", + "qscriptgrammar_p.h", + "qscriptlexer.cpp", + "qscriptlexer_p.h", + "qscriptsyntaxchecker.cpp", + "qscriptsyntaxchecker_p.h", + ] + } + + Export { + Depends { name: "QtScriptFwdHeaders" } + Depends { name: "cpp" } + property stringList includePaths: [exportingProduct.sourceDirectory + "/include"] + .concat(QtScriptFwdHeaders.publicIncludePaths) + Properties { + condition: qbs.targetOS.contains("unix") + cpp.dynamicLibraries: base.concat(["pthread"]) + } + Properties { + condition: qbs.targetOS.contains("windows") + cpp.dynamicLibraries: base.concat(["winmm"]) + } + } + } + Product { + type: ["hpp"] + name: "QtScriptFwdHeaders" + condition: qbsbuildconfig.useBundledQtScript || !Qt.script.present + Depends { name: "qbsbuildconfig" } + Depends { + name: "Qt.script" + condition: !qbsbuildconfig.useBundledQtScript + required: false + } + Depends { name: "Qt.core" } + Group { + files: [ + "../../shared/qtscript/src/script/api/*.h" + ] + fileTags: ["qtscriptheader"] + } + Probes.BinaryProbe { + id: perlProbe + names: "perl" + } + property string perlPath: perlProbe.found ? perlProbe.filePath : undefined + Rule { + multiplex: true + inputs: ["qtscriptheader"] + Artifact { + filePath: "include/QtScript/qscriptengine.h" + fileTags: ["hpp"] + } + prepare: { + var syncQtPath; + if (Utilities.versionCompare(product.Qt.core.version, "6.1") >= 0) { + syncQtPath = FileInfo.joinPaths(product.Qt.core.libExecPath, "syncqt.pl"); + } else { + syncQtPath = FileInfo.joinPaths(product.Qt.core.binPath, "syncqt.pl"); + } + if (!File.exists(syncQtPath)) { + // syncqt.pl is not in Qt's bin path. We might have a developer build. + // As we don't provide QT_HOST_BINS/src in our Qt modules we must + // kindly ask qmake. + var qmake = FileInfo.joinPaths(product.Qt.core.binPath, + "qmake" + product.cpp.executableSuffix); + var p = new Process(); + if (p.exec(qmake, ["-query", "QT_HOST_BINS/src"]) !== 0) + throw new Error("Error while querying qmake."); + syncQtPath = FileInfo.joinPaths(p.readStdOut().replace(/\r?\n/, ''), + "syncqt.pl"); + } + var qtScriptSrcPath = FileInfo.cleanPath( + FileInfo.path(inputs["qtscriptheader"][0].filePath) + "/../../.."); + console.info("qtScriptSrcPath: " + qtScriptSrcPath); + var cmd = new Command(product.perlPath, [ + syncQtPath, + "-minimal", + "-version", product.Qt.core.version, + "-outdir", FileInfo.cleanPath( + FileInfo.path(output.filePath) + "/../.."), + qtScriptSrcPath + ]); + cmd.description = "creating forwarding headers for the bundled QtScript module."; + return cmd; + } + } + Export { + Depends { name: "Qt.core" } + property stringList publicIncludePaths: [ + FileInfo.joinPaths(exportingProduct.buildDirectory, "include") + ] + property stringList privateIncludePaths: [ + FileInfo.joinPaths(exportingProduct.buildDirectory, "include", + "QtScript", Qt.core.version, "QtScript") + ] + } + } +} diff --git a/src/lib/scriptengine/use_scriptengine.pri b/src/lib/scriptengine/use_scriptengine.pri new file mode 100644 index 00000000..9981b442 --- /dev/null +++ b/src/lib/scriptengine/use_scriptengine.pri @@ -0,0 +1,30 @@ +include(../bundledlibs.pri) + +qbs_use_bundled_qtscript:!qbs_do_not_link_bundled_qtscript { + include(../../library_dirname.pri) + isEmpty(QBSLIBDIR) { + QBSLIBDIR = $$shadowed($$PWD/../../../$${QBS_LIBRARY_DIRNAME}) + } + + versionAtLeast(QT_VERSION, 6.0.0) { + QT *= core5compat + } + + LIBS += -L$$QBSLIBDIR + macos { + LIBS += -lqbsscriptengine + } + else { + LIBS += -lqbsscriptengine$$qtPlatformTargetSuffix() + } + + isEmpty(QBS_RPATH): QBS_RPATH = ../$$QBS_LIBRARY_DIRNAME + !qbs_disable_rpath { + linux-*: QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,\$\$ORIGIN/$${QBS_RPATH}\' + macos: QMAKE_LFLAGS += -Wl,-rpath,@loader_path/$${QBS_RPATH} + } +} + +INCLUDEPATH += \ + $$PWD/include \ + $$shadowed($$PWD/include) diff --git a/src/lib/staticlibrary.pri b/src/lib/staticlibrary.pri new file mode 100644 index 00000000..57f780b7 --- /dev/null +++ b/src/lib/staticlibrary.pri @@ -0,0 +1,4 @@ +include(library_base.pri) + +CONFIG += staticlib +DEFINES += QBS_STATIC_LIB diff --git a/src/libexec/CMakeLists.txt b/src/libexec/CMakeLists.txt new file mode 100644 index 00000000..dcf87ae8 --- /dev/null +++ b/src/libexec/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(qbs_processlauncher) diff --git a/src/libexec/libexec.pri b/src/libexec/libexec.pri new file mode 100644 index 00000000..a5cd2c59 --- /dev/null +++ b/src/libexec/libexec.pri @@ -0,0 +1,11 @@ +include(../install_prefix.pri) + +win32:LIBEXEC_BASE_DIR=bin +else:LIBEXEC_BASE_DIR=libexec/qbs + +!isEmpty(QBS_LIBEXEC_DESTDIR):DESTDIR=$${QBS_LIBEXEC_DESTDIR} +else:DESTDIR=../../../$$LIBEXEC_BASE_DIR + +!isEmpty(QBS_LIBEXEC_INSTALL_DIR):target.path = $${QBS_LIBEXEC_INSTALL_DIR} +else:target.path = $${QBS_INSTALL_PREFIX}/$$LIBEXEC_BASE_DIR +INSTALLS += target diff --git a/src/libexec/libexec.pro b/src/libexec/libexec.pro new file mode 100644 index 00000000..75b1d084 --- /dev/null +++ b/src/libexec/libexec.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +SUBDIRS += qbs_processlauncher diff --git a/src/libexec/libexec.qbs b/src/libexec/libexec.qbs new file mode 100644 index 00000000..edf08148 --- /dev/null +++ b/src/libexec/libexec.qbs @@ -0,0 +1,5 @@ +Project { + references: [ + "qbs_processlauncher/qbs_processlauncher.qbs", + ] +} diff --git a/src/libexec/qbs_processlauncher/CMakeLists.txt b/src/libexec/qbs_processlauncher/CMakeLists.txt new file mode 100644 index 00000000..03ab07cb --- /dev/null +++ b/src/libexec/qbs_processlauncher/CMakeLists.txt @@ -0,0 +1,25 @@ +set(SOURCES + launcherlogging.cpp + launcherlogging.h + launchersockethandler.cpp + launchersockethandler.h + processlauncher-main.cpp + ) + +set(PATH_TO_PROTOCOL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../lib/corelib/tools") +set(PROTOCOL_SOURCES + launcherpackets.cpp + launcherpackets.h + ) +list_transform_prepend(PROTOCOL_SOURCES ${PATH_TO_PROTOCOL_SOURCES}/) + +add_qbs_app(qbs_processlauncher + DESTINATION ${QBS_LIBEXEC_INSTALL_DIR} + DEPENDS Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network + INCLUDES ${PATH_TO_PROTOCOL_SOURCES} + SOURCES ${SOURCES} ${PROTOCOL_SOURCES} + ) +set_target_properties(qbs_processlauncher PROPERTIES + BUILD_RPATH "${QBS_LIBEXEC_RPATH}" + INSTALL_RPATH "${QBS_LIBEXEC_RPATH}" + ) diff --git a/src/libexec/qbs_processlauncher/launcherlogging.cpp b/src/libexec/qbs_processlauncher/launcherlogging.cpp new file mode 100644 index 00000000..81a4a4a0 --- /dev/null +++ b/src/libexec/qbs_processlauncher/launcherlogging.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launcherlogging.h" + +namespace qbs { +namespace Internal { +Q_LOGGING_CATEGORY(launcherLog, "qbs.launcher", QtWarningMsg) +} +} diff --git a/src/libexec/qbs_processlauncher/launcherlogging.h b/src/libexec/qbs_processlauncher/launcherlogging.h new file mode 100644 index 00000000..356433a9 --- /dev/null +++ b/src/libexec/qbs_processlauncher/launcherlogging.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QBS_LAUCHERLOGGING_H +#define QBS_LAUCHERLOGGING_H + +#include +#include + +namespace qbs { +namespace Internal { +Q_DECLARE_LOGGING_CATEGORY(launcherLog) +template void logDebug(const T &msg) { qCDebug(launcherLog) << msg; } +template void logWarn(const T &msg) { qCWarning(launcherLog) << msg; } +template void logError(const T &msg) { qCCritical(launcherLog) << msg; } +} +} + +#endif // Include guard diff --git a/src/libexec/qbs_processlauncher/launchersockethandler.cpp b/src/libexec/qbs_processlauncher/launchersockethandler.cpp new file mode 100644 index 00000000..637362b8 --- /dev/null +++ b/src/libexec/qbs_processlauncher/launchersockethandler.cpp @@ -0,0 +1,295 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launchersockethandler.h" + +#include "launcherlogging.h" + +#include +#include +#include +#include + +namespace qbs { +namespace Internal { + +class Process : public QProcess +{ + Q_OBJECT +public: + Process(quintptr token, QObject *parent = nullptr) : + QProcess(parent), m_token(token), m_stopTimer(new QTimer(this)) + { + m_stopTimer->setSingleShot(true); + connect(m_stopTimer, &QTimer::timeout, this, &Process::cancel); + } + + void cancel() + { + switch (m_stopState) { + case StopState::Inactive: + m_stopState = StopState::Terminating; + m_stopTimer->start(3000); + terminate(); + break; + case StopState::Terminating: + m_stopState = StopState::Killing; + m_stopTimer->start(3000); + kill(); + break; + case StopState::Killing: + m_stopState = StopState::Inactive; + emit failedToStop(); + break; + } + } + + void stopStopProcedure() + { + m_stopState = StopState::Inactive; + m_stopTimer->stop(); + } + + quintptr token() const { return m_token; } + +signals: + void failedToStop(); + +private: + const quintptr m_token; + QTimer * const m_stopTimer; + enum class StopState { Inactive, Terminating, Killing } m_stopState = StopState::Inactive; +}; + +LauncherSocketHandler::LauncherSocketHandler(QString serverPath, QObject *parent) + : QObject(parent), + m_serverPath(std::move(serverPath)), + m_socket(new QLocalSocket(this)) +{ + m_packetParser.setDevice(m_socket); +} + +LauncherSocketHandler::~LauncherSocketHandler() +{ + m_socket->disconnect(); + if (m_socket->state() != QLocalSocket::UnconnectedState) { + logWarn("socket handler destroyed while connection was active"); + m_socket->close(); + } + for (auto it = m_processes.cbegin(); it != m_processes.cend(); ++it) + it.value()->disconnect(); +} + +void LauncherSocketHandler::start() +{ + connect(m_socket, &QLocalSocket::disconnected, + this, &LauncherSocketHandler::handleSocketClosed); + connect(m_socket, &QLocalSocket::readyRead, this, &LauncherSocketHandler::handleSocketData); + connect(m_socket, +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) + static_cast(&QLocalSocket::error), +#else + &QLocalSocket::errorOccurred, +#endif + this, &LauncherSocketHandler::handleSocketError); + m_socket->connectToServer(m_serverPath); +} + +void LauncherSocketHandler::handleSocketData() +{ + try { + if (!m_packetParser.parse()) + return; + } catch (const PacketParser::InvalidPacketSizeException &e) { + logWarn(QStringLiteral("Internal protocol error: invalid packet size %1.") + .arg(e.size)); + return; + } + switch (m_packetParser.type()) { + case LauncherPacketType::StartProcess: + handleStartPacket(); + break; + case LauncherPacketType::StopProcess: + handleStopPacket(); + break; + case LauncherPacketType::Shutdown: + handleShutdownPacket(); + return; + default: + logWarn(QStringLiteral("Internal protocol error: invalid packet type %1.") + .arg(static_cast(m_packetParser.type()))); + return; + } + handleSocketData(); +} + +void LauncherSocketHandler::handleSocketError() +{ + if (m_socket->error() != QLocalSocket::PeerClosedError) { + logError(QStringLiteral("socket error: %1").arg(m_socket->errorString())); + m_socket->disconnect(); + qApp->quit(); + } +} + +void LauncherSocketHandler::handleSocketClosed() +{ + for (auto it = m_processes.cbegin(); it != m_processes.cend(); ++it) { + if (it.value()->state() != QProcess::NotRunning) { + logWarn("client closed connection while process still running"); + break; + } + } + m_socket->disconnect(); + qApp->quit(); +} + +void LauncherSocketHandler::handleProcessError() +{ + Process * proc = senderProcess(); + if (proc->error() != QProcess::FailedToStart) + return; + proc->stopStopProcedure(); + ProcessErrorPacket packet(proc->token()); + packet.error = proc->error(); + packet.errorString = proc->errorString(); + sendPacket(packet); +} + +void LauncherSocketHandler::handleProcessFinished() +{ + Process * proc = senderProcess(); + proc->stopStopProcedure(); + ProcessFinishedPacket packet(proc->token()); + packet.error = proc->error(); + packet.errorString = proc->errorString(); + packet.exitCode = proc->exitCode(); + packet.exitStatus = proc->exitStatus(); + packet.stdErr = proc->readAllStandardError(); + packet.stdOut = proc->readAllStandardOutput(); + sendPacket(packet); +} + +void LauncherSocketHandler::handleStopFailure() +{ + // Process did not react to a kill signal. Rare, but not unheard of. + // Forget about the associated Process object and report process exit to the client. + Process * proc = senderProcess(); + proc->disconnect(); + m_processes.remove(proc->token()); + ProcessFinishedPacket packet(proc->token()); + packet.error = QProcess::Crashed; + packet.exitCode = -1; + packet.exitStatus = QProcess::CrashExit; + packet.stdErr = proc->readAllStandardError(); + packet.stdOut = proc->readAllStandardOutput(); + sendPacket(packet); +} + +void LauncherSocketHandler::handleStartPacket() +{ + Process *& process = m_processes[m_packetParser.token()]; + if (!process) + process = setupProcess(m_packetParser.token()); + if (process->state() != QProcess::NotRunning) { + logWarn("got start request while process was running"); + return; + } + const auto packet = LauncherPacket::extractPacket( + m_packetParser.token(), + m_packetParser.packetData()); + process->setEnvironment(packet.env); + process->setWorkingDirectory(packet.workingDir); + process->start(packet.command, packet.arguments); +} + +void LauncherSocketHandler::handleStopPacket() +{ + Process * const process = m_processes.value(m_packetParser.token()); + if (!process) { + logWarn("got stop request for unknown process"); + return; + } + if (process->state() == QProcess::NotRunning) { + // This can happen if the process finishes on its own at about the same time the client + // sends the request. + logDebug("got stop request when process was not running"); + return; + } + process->cancel(); +} + +void LauncherSocketHandler::handleShutdownPacket() +{ + logDebug("got shutdown request, closing down"); + for (auto it = m_processes.cbegin(); it != m_processes.cend(); ++it) { + it.value()->disconnect(); + if (it.value()->state() != QProcess::NotRunning) { + logWarn("got shutdown request while process was running"); + it.value()->terminate(); + } + } + m_socket->disconnect(); + qApp->quit(); +} + +void LauncherSocketHandler::sendPacket(const LauncherPacket &packet) +{ + m_socket->write(packet.serialize()); +} + +Process *LauncherSocketHandler::setupProcess(quintptr token) +{ + const auto p = new Process(token, this); + connect(p, &QProcess::errorOccurred, this, &LauncherSocketHandler::handleProcessError); + connect(p, static_cast(&QProcess::finished), + this, &LauncherSocketHandler::handleProcessFinished); + connect(p, &Process::failedToStop, this, &LauncherSocketHandler::handleStopFailure); + return p; +} + +Process *LauncherSocketHandler::senderProcess() const +{ + return static_cast(sender()); +} + +} // namespace Internal +} // namespace qbs + +#include diff --git a/src/libexec/qbs_processlauncher/launchersockethandler.h b/src/libexec/qbs_processlauncher/launchersockethandler.h new file mode 100644 index 00000000..b2d57187 --- /dev/null +++ b/src/libexec/qbs_processlauncher/launchersockethandler.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_LAUNCHERSOCKETHANDLER_H +#define QBS_LAUNCHERSOCKETHANDLER_H + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QLocalSocket; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { +class Process; + +class LauncherSocketHandler : public QObject +{ + Q_OBJECT +public: + explicit LauncherSocketHandler(QString socketPath, QObject *parent = nullptr); + ~LauncherSocketHandler() override; + + void start(); + +private: + void handleSocketData(); + void handleSocketError(); + void handleSocketClosed(); + void handleProcessError(); + void handleProcessFinished(); + void handleStopFailure(); + + void handleStartPacket(); + void handleStopPacket(); + void handleShutdownPacket(); + + void sendPacket(const LauncherPacket &packet); + + Process *setupProcess(quintptr token); + Process *senderProcess() const; + + const QString m_serverPath; + QLocalSocket * const m_socket; + PacketParser m_packetParser; + QHash m_processes; +}; + +} // namespace Internal +} // namespace qbs + +#endif // Include guard diff --git a/src/libexec/qbs_processlauncher/processlauncher-main.cpp b/src/libexec/qbs_processlauncher/processlauncher-main.cpp new file mode 100644 index 00000000..61bbfbc3 --- /dev/null +++ b/src/libexec/qbs_processlauncher/processlauncher-main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "launcherlogging.h" +#include "launchersockethandler.h" + +#include +#include + +#ifdef Q_OS_WIN +#include + +BOOL WINAPI consoleCtrlHandler(DWORD) +{ + // Ignore Ctrl-C / Ctrl-Break. Qbs will tell us to exit gracefully. + return TRUE; +} +#endif + +int main(int argc, char *argv[]) +{ +#ifdef Q_OS_WIN + SetConsoleCtrlHandler(consoleCtrlHandler, TRUE); +#endif + + QCoreApplication app(argc, argv); + if (app.arguments().size() != 2) { + qbs::Internal::logError("Need exactly one argument (path to socket)"); + return 1; + } + + qbs::Internal::LauncherSocketHandler launcher(app.arguments().constLast()); + QTimer::singleShot(0, &launcher, &qbs::Internal::LauncherSocketHandler::start); + return app.exec(); +} diff --git a/src/libexec/qbs_processlauncher/qbs_processlauncher.pro b/src/libexec/qbs_processlauncher/qbs_processlauncher.pro new file mode 100644 index 00000000..c49e52e2 --- /dev/null +++ b/src/libexec/qbs_processlauncher/qbs_processlauncher.pro @@ -0,0 +1,21 @@ +include(../libexec.pri) + +TARGET = qbs_processlauncher +CONFIG += console c++17 +CONFIG -= app_bundle +QT = core network + +TOOLS_DIR = $$PWD/../../lib/corelib/tools + +INCLUDEPATH += $$TOOLS_DIR + +HEADERS += \ + launcherlogging.h \ + launchersockethandler.h \ + $$TOOLS_DIR/launcherpackets.h + +SOURCES += \ + launcherlogging.cpp \ + launchersockethandler.cpp \ + processlauncher-main.cpp \ + $$TOOLS_DIR/launcherpackets.cpp diff --git a/src/libexec/qbs_processlauncher/qbs_processlauncher.qbs b/src/libexec/qbs_processlauncher/qbs_processlauncher.qbs new file mode 100644 index 00000000..5be05163 --- /dev/null +++ b/src/libexec/qbs_processlauncher/qbs_processlauncher.qbs @@ -0,0 +1,38 @@ +import qbs.FileInfo + +QbsProduct { + type: "application" + name: "qbs_processlauncher" + consoleApplication: true + + Depends { name: "Qt.network" } + + cpp.includePaths: base.concat(pathToProtocolSources) + + files: [ + "launcherlogging.cpp", + "launcherlogging.h", + "launchersockethandler.cpp", + "launchersockethandler.h", + "processlauncher-main.cpp", + ] + + property string pathToProtocolSources: sourceDirectory + "/../../lib/corelib/tools" + Group { + name: "protocol sources" + prefix: pathToProtocolSources + '/' + files: [ + "launcherpackets.cpp", + "launcherpackets.h", + ] + } + + Group { + fileTagsFilter: product.type + .concat(qbs.buildVariant === "debug" ? ["debuginfo_app"] : []) + qbs.install: true + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: qbsbuildconfig.libexecInstallDir +} diff --git a/src/library_dirname.pri b/src/library_dirname.pri new file mode 100644 index 00000000..5d0712d7 --- /dev/null +++ b/src/library_dirname.pri @@ -0,0 +1 @@ +isEmpty(QBS_LIBRARY_DIRNAME):QBS_LIBRARY_DIRNAME = lib diff --git a/src/packages/archive/archive.qbs b/src/packages/archive/archive.qbs new file mode 100644 index 00000000..40ebb5fb --- /dev/null +++ b/src/packages/archive/archive.qbs @@ -0,0 +1,88 @@ +import qbs.FileInfo +import qbs.ModUtils +import qbs.Process +import qbs.TextFile + +QbsProduct { + Depends { name: "qbs_processlauncher" } + Depends { name: "qbscore" } + Depends { name: "qbsscriptengine"; required: false } + Depends { name: "bundledqt"; required: false } + Depends { name: "qbs documentation"; condition: project.withDocumentation } + Depends { name: "qbs resources" } + Depends { + name: "qbs man page" + condition: qbs.targetOS.contains("unix") && project.withDocumentation + } + Depends { productTypes: ["qbsapplication", "qbsplugin"] } + Depends { productTypes: ["autotest"]; condition: includeTests } + + Depends { name: "archiver" } + + property bool includeTopLevelDir: false + property bool includeTests: false + + builtByDefault: false + name: "qbs_archive" + type: ["archiver.archive"] + targetName: "qbs-" + qbs.targetOS[0] + "-" + qbs.architecture + "-" + qbsversion.version + destinationDirectory: project.buildDirectory + + archiver.type: qbs.targetOS.contains("windows") ? "zip" : "tar" + Properties { + condition: includeTopLevelDir + archiver.workingDirectory: qbs.installRoot + "/.." + } + archiver.workingDirectory: qbs.installRoot + + Group { + name: "Licenses" + prefix: "../../../" + files: [ + "LGPL_EXCEPTION.txt", + "LICENSE.LGPLv3", + "LICENSE.LGPLv21", + "LICENSE.GPL3-EXCEPT", + ] + qbs.install: true + qbs.installDir: "share/doc/qbs" + } + + Rule { + multiplex: true + inputs: ["installable"] + inputsFromDependencies: ["installable"] + + Artifact { + filePath: "list.txt" + fileTags: ["archiver.input-list"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.excludedPathPrefixes = product.excludedPathPrefixes; + cmd.inputFilePaths = inputs.installable.map(function(a) { + return ModUtils.artifactInstalledFilePath(a); + }); + cmd.outputFilePath = output.filePath; + cmd.baseDirectory = product.moduleProperty("archiver", "workingDirectory"); + cmd.sourceCode = function() { + inputFilePaths.sort(); + var tf; + try { + tf = new TextFile(outputFilePath, TextFile.WriteOnly); + for (var i = 0; i < inputFilePaths.length; ++i) { + var relativePath = FileInfo.relativePath(baseDirectory, inputFilePaths[i]); + tf.writeLine(relativePath); + } + } finally { + if (tf) + tf.close(); + } + }; + + return [cmd]; + } + } +} diff --git a/src/packages/chocolatey/chocolatey.qbs b/src/packages/chocolatey/chocolatey.qbs new file mode 100644 index 00000000..4a0c2df4 --- /dev/null +++ b/src/packages/chocolatey/chocolatey.qbs @@ -0,0 +1,129 @@ +import qbs.Environment +import qbs.File +import qbs.FileInfo +import qbs.Probes +import qbs.TextFile +import qbs.Utilities +import qbs.Xml + +Product { + Depends { name: "qbsversion" } + + Probes.BinaryProbe { + id: choco + condition: qbs.targetOS.contains("windows") + names: ["choco"] + platformSearchPaths: { + var chocolateyInstall = Environment.getEnv("ChocolateyInstall"); + if (chocolateyInstall) + return [FileInfo.joinPaths(chocolateyInstall, "bin")]; + else + return [FileInfo.joinPaths(Environment.getEnv("PROGRAMDATA"), + "chocolatey", "bin")]; + } + } + + condition: choco.found + builtByDefault: false + name: "qbs chocolatey" + type: ["chocolatey.nupkg"] + targetName: "qbs." + qbsversion.version + destinationDirectory: project.buildDirectory + + property string chocoFilePath: choco.filePath + + Group { + files: ["qbs.nuspec"] + fileTags: ["chocolatey.nuspec"] + } + + Group { + files: ["chocolateyinstall.ps1"] + fileTags: ["powershell.source"] + } + + Group { + files: ["../../../changelogs/*"] + fileTags: ["changelog"] + } + + Rule { + inputs: ["chocolatey.nuspec", "powershell.source", "changelog"] + multiplex: true + + Artifact { + filePath: FileInfo.joinPaths(product.destinationDirectory, + product.targetName + ".nupkg") + fileTags: ["chocolatey.nupkg"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.silent = true; + cmd.qbsVersion = product.qbsversion.version; + cmd.powershellFilePath = inputs["powershell.source"][0].filePath; + cmd.nuspecFileName = inputs["chocolatey.nuspec"][0].fileName; + cmd.nuspecFilePath = inputs["chocolatey.nuspec"][0].filePath; + cmd.chocoBuildDirectory = FileInfo.joinPaths(product.buildDirectory, "choco"); + cmd.chocoOutDirectory = FileInfo.path(outputs["chocolatey.nupkg"][0].filePath); + cmd.changelogs = (inputs["changelog"] || []).map(function (a) { + return { + filePath: a.filePath, + version: a.fileName.replace(/^changes-([0-9](\.[0-9]+)*)(\.md)?$/, "$1") + }; + }).sort(function(a, b) { + return Utilities.versionCompare(b.version, a.version); + }); + cmd.sourceCode = function () { + File.makePath(chocoBuildDirectory); + File.makePath(FileInfo.joinPaths(chocoBuildDirectory, "tools")); + + var tf = new TextFile(FileInfo.joinPaths( + chocoBuildDirectory, "tools", "chocolateyinstall.ps1"), + TextFile.WriteOnly); + try { + tf.writeLine("$qbsVersion = '" + qbsVersion + "'"); + tf.writeLine(""); + var tf2 = new TextFile(powershellFilePath, TextFile.ReadOnly); + try { + tf.write(tf2.readAll()); + } finally { + tf2.close(); + } + } finally { + tf.close(); + } + + var doc = new Xml.DomDocument(); + doc.load(nuspecFilePath); + var versionNode = doc.createElement("version"); + versionNode.appendChild(doc.createTextNode(qbsVersion)); + var releaseNotesNode = doc.createElement("releaseNotes"); + + var releaseNotesText = ""; + changelogs.map(function (changelog) { + releaseNotesText += "qbs " + changelog.version + "\n\n"; + var tf = new TextFile(changelog.filePath, TextFile.ReadOnly); + try { + releaseNotesText += tf.readAll() + "\n"; + } finally { + tf.close(); + } + }); + releaseNotesNode.appendChild(doc.createTextNode(releaseNotesText.trim())); + + var metadataNode = doc.documentElement().firstChild("metadata"); + metadataNode.appendChild(versionNode); + metadataNode.appendChild(releaseNotesNode); + doc.save(FileInfo.joinPaths(chocoBuildDirectory, nuspecFileName)); + }; + var cmd2 = new Command(product.chocoFilePath, + ["pack", FileInfo.joinPaths(cmd.chocoBuildDirectory, + cmd.nuspecFileName), + "--limitoutput", + "--outputdirectory", cmd.chocoOutDirectory]); + cmd2.description = "packing choco " + inputs["chocolatey.nuspec"][0].fileName; + return [cmd, cmd2]; + } + } +} diff --git a/src/packages/chocolatey/chocolateyinstall.ps1 b/src/packages/chocolatey/chocolateyinstall.ps1 new file mode 100644 index 00000000..f55d87eb --- /dev/null +++ b/src/packages/chocolatey/chocolateyinstall.ps1 @@ -0,0 +1,23 @@ +$ErrorActionPreference = 'Stop' + +$qbsBaseUrl = "https://download.qt.io/official_releases/qbs/$qbsVersion" +$checksumType = 'md5' +$checksums = @{} +ForEach ($line in (New-Object Net.WebClient).DownloadString("$qbsBaseUrl/${checksumType}sums.txt").Split(` + "`n", [System.StringSplitOptions]::RemoveEmptyEntries)) { + $items = $line.Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries) + $checksums.Add($items[1], $items[0]) +} + +$qbs32 = "qbs-windows-x86-$qbsVersion.zip" +$qbs64 = "qbs-windows-x86_64-$qbsVersion.zip" + +Install-ChocolateyZipPackage ` + -PackageName 'qbs' ` + -Url "$qbsBaseUrl/$qbs32" ` + -UnzipLocation "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" ` + -Url64bit "$qbsBaseUrl/$qbs64" ` + -Checksum $checksums[$qbs32] ` + -ChecksumType $checksumType ` + -Checksum64 $checksums[$qbs64] ` + -ChecksumType64 $checksumType diff --git a/src/packages/chocolatey/icon.png b/src/packages/chocolatey/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..fb08b22f5f2e0aee3034f38c53966996ef3dc06d GIT binary patch literal 6915 zcmZXZWl$VV*sd2{oZud8gS)%iLLfl!AR%agu((@r4=nC(!7aF32#W-F7AL`j`?v3@ zbIzY{s(QM*Yo@BF=jpqz=k6#?4P{&`N-O{XfD2Yp&_>ij{}l{$#C<@@d<;>cy2^od zFc6m?hGit8jp?Lf=n4R!AN^O5Ub~A3B04GD6b;EXK=Bo^3Ku;FM%LJKj`WXY z`J=9dj#|Qphr6ntYopVSd7s>_`NsK&DjOu4SI`0w|1A*(NWR*Ho60)87=P5jjyZQn z#eQKXJc@oPX$J_Ra>M8e3-|T*HR@OwiVZCewiFp9MCxnV143(|O)Vbc4&;E*QP2#| zD?j@N+eZ9ld{CFlYre1W53Z5LY0WD(^4Oq`B)`03Rh>dG82naM6s?uP&1Xg6@%8>!hgT}Vua^2yd+<6*3T$^QP1L*}wJR8sgN%%vo}JC1jHv@EQjxOE zS-(S**Jhwl;xp5s92y#mjf~8fD@fpcOa*}n2m1RBG&Sjz38Gb$5_AlTY6F}TsMWL= zb@VHAVxyx!-JGo9lKLIaHrwmhm~^DNySuv(ZxW7Trk>QA;eggul#(1skIxqu4Sc-3 z(%+s{&-8vp*O81vcz`r7x}<9IG01=$A4qK|z&(T(W8)I5{PSo|}8J>WV+K zvr_`m`dVyDfF|&zM>TGIX34MFH;7I&Vn%-vLQ653sn^%Jxw&D1 zC=et8N7(b_11>ZG^p0{x?dH9vW^aBzT_vUz3yaDLQz8a4_});CiS%nRw%~{2xYCmf zQf+PR#h$>x7|iv#xfEw-X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253-Mm0ul6B_z$w&Bon+ZF8s_Vw@)J$^ZGK zSlvOEt!)o4UxO@d?DmA5E2A@Y2M{`ctX6qBG=Yzz!DM?|FuMOMeS^tPZ+_|zEDucOYS0&1o};TxIwE# z+ZnM5yLov0xR>5oTFS^0`hswgp%=B2On2pXzCUPWwHfXxz?-~H#l@in1O!cujg77F z-0-s+9=Z96`E2DjC<-E>W4&O|0E3>XO_Tr0=i`#|wgDcsn&|;NK_>x+x#G#_Opln9 zlutq;`$i&H)MkR(v?stM9zF){R-K+$K5lWwhptt${n7DK<6>ov0)zXpan^mWA3z-+ zI=Y0KWTs;cgZ~H3ZDD!< literal 0 HcmV?d00001 diff --git a/src/packages/chocolatey/qbs.nuspec b/src/packages/chocolatey/qbs.nuspec new file mode 100644 index 00000000..a0d650fc --- /dev/null +++ b/src/packages/chocolatey/qbs.nuspec @@ -0,0 +1,23 @@ + + + + + qbs + Qbs + Qt Project + qbs + Build tool that helps simplify the build process for developing projects across multiple platforms. + Qbs is a tool that helps simplify the build process for developing projects across multiple platforms. + https://wiki.qt.io/Qbs + https://code.qt.io/cgit/qbs/qbs.git + https://code.qt.io/cgit/qbs/qbs.git + https://doc.qt.io/qbs/ + http://lists.qt-project.org/mailman/listinfo/qbs + https://bugreports.qt.io/browse/QBS + qbs qt build + © 2017 The Qt Company Ltd. + http://doc.qt.io/qt-5/licensing.html + false + https://rawcdn.githack.com/qbs/qbs/v1.17.0/src/packages/chocolatey/icon.png + + diff --git a/src/packages/packages.qbs b/src/packages/packages.qbs new file mode 100644 index 00000000..d2b88ccf --- /dev/null +++ b/src/packages/packages.qbs @@ -0,0 +1,14 @@ +Project { + references: [ + "archive/archive.qbs", + "chocolatey/chocolatey.qbs", + ] + + // Virtual product for building all possible packagings + Product { + Depends { name: "qbs_archive"; required: false } + Depends { name: "qbs chocolatey"; required: false } + name: "dist" + builtByDefault: false + } +} diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt new file mode 100644 index 00000000..659468aa --- /dev/null +++ b/src/plugins/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(generator) +add_subdirectory(scanner) diff --git a/src/plugins/generator/CMakeLists.txt b/src/plugins/generator/CMakeLists.txt new file mode 100644 index 00000000..738e428b --- /dev/null +++ b/src/plugins/generator/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(clangcompilationdb) +add_subdirectory(iarew) +add_subdirectory(keiluv) +add_subdirectory(makefilegenerator) +add_subdirectory(visualstudio) diff --git a/src/plugins/generator/clangcompilationdb/CMakeLists.txt b/src/plugins/generator/clangcompilationdb/CMakeLists.txt new file mode 100644 index 00000000..237ae465 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/CMakeLists.txt @@ -0,0 +1,10 @@ +set(SOURCES + clangcompilationdbgenerator.cpp + clangcompilationdbgenerator.h + clangcompilationdbgeneratorplugin.cpp + ) + +add_qbs_plugin(clangcompilationdbgenerator + DEPENDS qbscore + SOURCES ${SOURCES} + ) diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdb.pri b/src/plugins/generator/clangcompilationdb/clangcompilationdb.pri new file mode 100644 index 00000000..7c9a7112 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdb.pri @@ -0,0 +1 @@ +qbsPluginTarget = clangcompilationdbgenerator diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdb.pro b/src/plugins/generator/clangcompilationdb/clangcompilationdb.pro new file mode 100644 index 00000000..1b534259 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdb.pro @@ -0,0 +1,11 @@ +include(clangcompilationdb.pri) +include(../../plugins.pri) + +QT = core + +HEADERS += \ + $$PWD/clangcompilationdbgenerator.h + +SOURCES += \ + $$PWD/clangcompilationdbgenerator.cpp \ + $$PWD/clangcompilationdbgeneratorplugin.cpp diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdb.qbs b/src/plugins/generator/clangcompilationdb/clangcompilationdb.qbs new file mode 100644 index 00000000..89f7c84b --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdb.qbs @@ -0,0 +1,10 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + name: "clangcompilationdbgenerator" + files: [ + "clangcompilationdbgenerator.cpp", + "clangcompilationdbgenerator.h", + "clangcompilationdbgeneratorplugin.cpp" + ] +} diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp new file mode 100644 index 00000000..fc1a36c9 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "clangcompilationdbgenerator.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace qbs { +using namespace Internal; + +const QString ClangCompilationDatabaseGenerator::DefaultDatabaseFileName = + QStringLiteral("compile_commands.json"); + +ClangCompilationDatabaseGenerator::ClangCompilationDatabaseGenerator() = default; + +QString ClangCompilationDatabaseGenerator::generatorName() const +{ + return QStringLiteral("clangdb"); +} + +void ClangCompilationDatabaseGenerator::generate() +{ + const auto projects = project().projects.values(); + for (const Project &theProject : projects) { + QJsonArray database; + const ProjectData projectData = theProject.projectData(); + const QString &buildDir = projectData.buildDirectory(); + + for (const ProductData &productData : projectData.allProducts()) { + for (const GroupData &groupData : productData.groups()) { + const auto sourceArtifacts = groupData.allSourceArtifacts(); + for (const ArtifactData &sourceArtifact : sourceArtifacts) { + if (!hasValidInputFileTag(sourceArtifact.fileTags())) + continue; + + const QString filePath = sourceArtifact.filePath(); + ErrorInfo errorInfo; + const RuleCommandList rules = theProject.ruleCommands(productData, filePath, + QStringLiteral("obj"), + &errorInfo); + + if (errorInfo.hasError()) + throw errorInfo; + + for (const RuleCommand &rule : rules) { + if (rule.type() != RuleCommand::ProcessCommandType) + continue; + database.push_back(createEntry(filePath, buildDir, rule)); + } + } + } + } + + writeProjectDatabase(QDir(buildDir).filePath(DefaultDatabaseFileName), database); + } +} + +// See http://clang.llvm.org/docs/JSONCompilationDatabase.html +QJsonObject ClangCompilationDatabaseGenerator::createEntry(const QString &filePath, + const QString &buildDir, + const RuleCommand &ruleCommand) +{ + QString workDir = ruleCommand.workingDirectory(); + if (workDir.isEmpty()) + workDir = buildDir; + + const QStringList arguments = QStringList() << ruleCommand.executable() + << ruleCommand.arguments(); + + const QJsonObject object = { + { QStringLiteral("directory"), QJsonValue(workDir) }, + { QStringLiteral("arguments"), QJsonArray::fromStringList(arguments) }, + { QStringLiteral("file"), QJsonValue(filePath) } + }; + return object; +} + +void ClangCompilationDatabaseGenerator::writeProjectDatabase(const QString &filePath, + const QJsonArray &entries) +{ + const QJsonDocument database(entries); + QFile databaseFile(filePath); + + if (!databaseFile.open(QFile::WriteOnly)) + throw ErrorInfo(Tr::tr("Cannot open '%1' for writing: %2") + .arg(filePath, databaseFile.errorString())); + + if (databaseFile.write(database.toJson()) == -1) + throw ErrorInfo(Tr::tr("Error while writing '%1': %2") + .arg(filePath, databaseFile.errorString())); +} + +bool ClangCompilationDatabaseGenerator::hasValidInputFileTag(const QStringList &fileTags) const +{ + static const QStringList validFileTags = { + QStringLiteral("c"), + QStringLiteral("cpp"), + QStringLiteral("objc"), + QStringLiteral("objcpp") + }; + + return Internal::any_of(fileTags, [](const auto &tag) { + return validFileTags.contains(tag); + }); +} + +} // namespace qbs diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.h b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.h new file mode 100644 index 00000000..5a850507 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdbgenerator.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_CLANGCOMPILATIONDATABASEGENERATOR_H +#define QBS_CLANGCOMPILATIONDATABASEGENERATOR_H + +#include + +namespace qbs { + +class SourceArtifact; +class ProjectData; + +class ClangCompilationDatabaseGenerator : public ProjectGenerator +{ +public: + ClangCompilationDatabaseGenerator(); + +private: + QString generatorName() const override; + void generate() override; + static const QString DefaultDatabaseFileName; + QJsonObject createEntry(const QString &filePath, const QString &buildDir, + const RuleCommand &ruleCommand); + void writeProjectDatabase(const QString &filePath, const QJsonArray &entries); + bool hasValidInputFileTag(const QStringList &fileTags) const; +}; + +} // namespace qbs + +#endif // QBS_VISUALSTUDIOGENERATOR_H diff --git a/src/plugins/generator/clangcompilationdb/clangcompilationdbgeneratorplugin.cpp b/src/plugins/generator/clangcompilationdb/clangcompilationdbgeneratorplugin.cpp new file mode 100644 index 00000000..c6dec555 --- /dev/null +++ b/src/plugins/generator/clangcompilationdb/clangcompilationdbgeneratorplugin.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "clangcompilationdbgenerator.h" + +#include +#include + +static void QbsClangDbGeneratorPluginLoad() +{ + qbs::ProjectGeneratorManager::registerGenerator( + std::make_shared()); +} + +static void QbsClangDbGeneratorPluginUnload() +{ +} + +#ifndef GENERATOR_EXPORT +#if defined(WIN32) || defined(_WIN32) +#define GENERATOR_EXPORT __declspec(dllexport) +#else +#define GENERATOR_EXPORT __attribute__((visibility("default"))) +#endif +#endif + +QBS_REGISTER_STATIC_PLUGIN(extern "C" GENERATOR_EXPORT, clangcompilationdbgenerator, + QbsClangDbGeneratorPluginLoad, QbsClangDbGeneratorPluginUnload) diff --git a/src/plugins/generator/generator.pro b/src/plugins/generator/generator.pro new file mode 100644 index 00000000..4a386132 --- /dev/null +++ b/src/plugins/generator/generator.pro @@ -0,0 +1,6 @@ +TEMPLATE = subdirs +SUBDIRS += clangcompilationdb +SUBDIRS += makefilegenerator +SUBDIRS += visualstudio +SUBDIRS += iarew +SUBDIRS += keiluv diff --git a/src/plugins/generator/iarew/CMakeLists.txt b/src/plugins/generator/iarew/CMakeLists.txt new file mode 100644 index 00000000..32af6e28 --- /dev/null +++ b/src/plugins/generator/iarew/CMakeLists.txt @@ -0,0 +1,119 @@ +set(COMMON_SOURCES + iarewfileversionproperty.cpp + iarewfileversionproperty.h + iarewgenerator.cpp + iarewgenerator.h + iarewgeneratorplugin.cpp + iarewoptionpropertygroup.cpp + iarewoptionpropertygroup.h + iarewproject.cpp + iarewproject.h + iarewprojectwriter.cpp + iarewprojectwriter.h + iarewsettingspropertygroup.cpp + iarewsettingspropertygroup.h + iarewsourcefilepropertygroup.cpp + iarewsourcefilepropertygroup.h + iarewsourcefilespropertygroup.cpp + iarewsourcefilespropertygroup.h + iarewtoolchainpropertygroup.cpp + iarewtoolchainpropertygroup.h + iarewutils.cpp + iarewutils.h + iarewversioninfo.h + iarewworkspace.cpp + iarewworkspace.h + iarewworkspacewriter.cpp + iarewworkspacewriter.h + ) + +set(ARCHS_ARM_SOURCES + armarchiversettingsgroup_v8.cpp + armarchiversettingsgroup_v8.h + armassemblersettingsgroup_v8.cpp + armassemblersettingsgroup_v8.h + armbuildconfigurationgroup_v8.cpp + armbuildconfigurationgroup_v8.h + armcompilersettingsgroup_v8.cpp + armcompilersettingsgroup_v8.h + armgeneralsettingsgroup_v8.cpp + armgeneralsettingsgroup_v8.h + armlinkersettingsgroup_v8.cpp + armlinkersettingsgroup_v8.h + ) +list_transform_prepend(ARCHS_ARM_SOURCES archs/arm/) + +set(ARCHS_AVR_SOURCES + avrarchiversettingsgroup_v7.cpp + avrarchiversettingsgroup_v7.h + avrassemblersettingsgroup_v7.cpp + avrassemblersettingsgroup_v7.h + avrbuildconfigurationgroup_v7.cpp + avrbuildconfigurationgroup_v7.h + avrcompilersettingsgroup_v7.cpp + avrcompilersettingsgroup_v7.h + avrgeneralsettingsgroup_v7.cpp + avrgeneralsettingsgroup_v7.h + avrlinkersettingsgroup_v7.cpp + avrlinkersettingsgroup_v7.h + ) +list_transform_prepend(ARCHS_AVR_SOURCES archs/avr/) + +set(ARCHS_MCS51_SOURCES + mcs51archiversettingsgroup_v10.cpp + mcs51archiversettingsgroup_v10.h + mcs51assemblersettingsgroup_v10.cpp + mcs51assemblersettingsgroup_v10.h + mcs51buildconfigurationgroup_v10.cpp + mcs51buildconfigurationgroup_v10.h + mcs51compilersettingsgroup_v10.cpp + mcs51compilersettingsgroup_v10.h + mcs51generalsettingsgroup_v10.cpp + mcs51generalsettingsgroup_v10.h + mcs51linkersettingsgroup_v10.cpp + mcs51linkersettingsgroup_v10.h + ) +list_transform_prepend(ARCHS_MCS51_SOURCES archs/mcs51/) + +set(ARCHS_STM8_SOURCES + stm8archiversettingsgroup_v3.cpp + stm8archiversettingsgroup_v3.h + stm8assemblersettingsgroup_v3.cpp + stm8assemblersettingsgroup_v3.h + stm8buildconfigurationgroup_v3.cpp + stm8buildconfigurationgroup_v3.h + stm8compilersettingsgroup_v3.cpp + stm8compilersettingsgroup_v3.h + stm8generalsettingsgroup_v3.cpp + stm8generalsettingsgroup_v3.h + stm8linkersettingsgroup_v3.cpp + stm8linkersettingsgroup_v3.h + ) +list_transform_prepend(ARCHS_STM8_SOURCES archs/stm8/) + +set(ARCHS_MSP430_SOURCES + msp430archiversettingsgroup_v7.cpp + msp430archiversettingsgroup_v7.h + msp430assemblersettingsgroup_v7.cpp + msp430assemblersettingsgroup_v7.h + msp430buildconfigurationgroup_v7.cpp + msp430buildconfigurationgroup_v7.h + msp430compilersettingsgroup_v7.cpp + msp430compilersettingsgroup_v7.h + msp430generalsettingsgroup_v7.cpp + msp430generalsettingsgroup_v7.h + msp430linkersettingsgroup_v7.cpp + msp430linkersettingsgroup_v7.h + ) +list_transform_prepend(ARCHS_MSP430_SOURCES archs/msp430/) + +add_qbs_plugin(iarewgenerator + DEPENDS qbscore qbsjson + SOURCES + ${COMMON_SOURCES} + ${ARCHS_ARM_SOURCES} + ${ARCHS_AVR_SOURCES} + ${ARCHS_MCS51_SOURCES} + ${ARCHS_STM8_SOURCES} + ${ARCHS_MSP430_SOURCES} + ) diff --git a/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.cpp new file mode 100644 index 00000000..cc075062 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armarchiversettingsgroup_v8.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +constexpr int kArchiverArchiveVersion = 0; +constexpr int kArchiverDataVersion = 0; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +// ArmArchiverSettingsGroup + +ArmArchiverSettingsGroup::ArmArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("IARCHIVE")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void ArmArchiverSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'IarchiveOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("IarchiveOverride"), + {1}); + // Add 'IarchiveOutput' item (Output filename). + addOptionsGroup(QByteArrayLiteral("IarchiveOutput"), + {opts.outputFile}); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.h new file mode 100644 index 00000000..c99c2eeb --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armarchiversettingsgroup_v8.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMAARCHIVERSETTINGSGROUP_V8_H +#define QBS_IAREWARMAARCHIVERSETTINGSGROUP_V8_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit ArmArchiverSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMAARCHIVERSETTINGSGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.cpp new file mode 100644 index 00000000..66c4c9ee --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.cpp @@ -0,0 +1,230 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armassemblersettingsgroup_v8.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +constexpr int kAssemblerArchiveVersion = 2; +constexpr int kAssemblerDataVersion = 10; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleAssemblerFlags(qbsProps); + enableSymbolsCaseSensitive = flags.contains(QLatin1String("-s+")); + allowAlternativeRegister = flags.contains(QLatin1String("-j")); + disableCodeMemoryDataReads = flags.contains( + QLatin1String("--no_literal_pool")); + if (flags.contains(QLatin1String("-M<>"))) + macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote; + else if (flags.contains(QLatin1String("-M()"))) + macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote; + else if (flags.contains(QLatin1String("-M[]"))) + macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote; + else if (flags.contains(QLatin1String("-M{}"))) + macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote; + } + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; + int enableSymbolsCaseSensitive = 0; + int allowAlternativeRegister = 0; + int disableCodeMemoryDataReads = 0; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (warningLevel == QLatin1String("all")) { + enableWarnings = 0; + enableAllWarnings = 0; + } else if (warningLevel == QLatin1String("none")) { + enableWarnings = 1; + enableAllWarnings = 0; + } else { + enableWarnings = 0; + enableAllWarnings = 1; + } + } + + int enableWarnings = 0; + int enableAllWarnings = 0; +}; + +} // namespace + +// ArmAssemblerSettingsGroup + +ArmAssemblerSettingsGroup::ArmAssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("AARM")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void ArmAssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {opts.enableSymbolsCaseSensitive}); + // Add 'AltRegisterNames' item (Allow alternative register names, + // mnemonics and operands). + addOptionsGroup(QByteArrayLiteral("AltRegisterNames"), + {opts.allowAlternativeRegister}); + // Add 'AsmNoLiteralPool' item (No data reads in code memory). + addOptionsGroup(QByteArrayLiteral("AsmNoLiteralPool"), + {opts.disableCodeMemoryDataReads}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {opts.macroQuoteCharacter}, 0); +} +void ArmAssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'ADebug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("ADebug"), + {opts.debugInfo}); +} + +void ArmAssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + opts.defineSymbols); + // Add 'AUserIncludes' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("AUserIncludes"), + opts.includePaths); +} + +void ArmAssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'AWarnEnable' item (Enable/disable warnings). + addOptionsGroup(QByteArrayLiteral("AWarnEnable"), + {opts.enableWarnings}); + // Add 'AWarnWhat' item (Enable/disable all warnings). + addOptionsGroup(QByteArrayLiteral("AWarnWhat"), + {opts.enableAllWarnings}); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.h new file mode 100644 index 00000000..620dcf1f --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armassemblersettingsgroup_v8.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMASSEMBLERSETTINGSGROUP_V8_H +#define QBS_IAREWARMASSEMBLERSETTINGSGROUP_V8_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmAssemblerSettingsGroup final + : public IarewSettingsPropertyGroup +{ +public: + explicit ArmAssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildLanguagePage(const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMASSEMBLERSETTINGSGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.cpp new file mode 100644 index 00000000..a16e57a4 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armarchiversettingsgroup_v8.h" +#include "armassemblersettingsgroup_v8.h" +#include "armbuildconfigurationgroup_v8.h" +#include "armcompilersettingsgroup_v8.h" +#include "armgeneralsettingsgroup_v8.h" +#include "armlinkersettingsgroup_v8.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +ArmBuildConfigurationGroup::ArmBuildConfigurationGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("ARM"); + + // Append debug info item. + const int debugBuild = gen::utils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool ArmBuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Arm + && version.majorVersion() == 8; +} + +std::unique_ptr +ArmBuildConfigurationGroupFactory::create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new ArmBuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.h new file mode 100644 index 00000000..26370c9b --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armbuildconfigurationgroup_v8.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMBUILDCONFIGURATIONGROUP_V8_H +#define QBS_IAREWARMBUILDCONFIGURATIONGROUP_V8_H + +#include + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmBuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit ArmBuildConfigurationGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class ArmBuildConfigurationGroupFactory; +}; + +class ArmBuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMBUILDCONFIGURATIONGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.cpp new file mode 100644 index 00000000..0981fade --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.cpp @@ -0,0 +1,478 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armcompilersettingsgroup_v8.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +constexpr int kCompilerArchiveVersion = 2; +constexpr int kCompilerDataVersion = 34; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Language 1 page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C11LanguageDialect + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // Language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + cLanguageDialect = cLanguageVersion.contains(QLatin1String("c89")) + ? LanguageOnePageOptions::C89LanguageDialect + : LanguageOnePageOptions::C11LanguageDialect; + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + // Exceptions, rtti, static desrtuction. + enableExceptions = !flags.contains(QLatin1String("--no_exceptions")); + enableRtti = !flags.contains(QLatin1String("--no_rtti")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + allowVla = flags.contains(QLatin1String("--vla")); + enableInlineSemantics = flags.contains(QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains(QLatin1String("--require_prototypes")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C89LanguageDialect; + LanguageConformance languageConformance = AllowIarExtension; + // C++ options. + int enableExceptions = 0; + int enableRtti = 0; + int destroyStaticObjects = 0; + int allowVla = 0; + int enableInlineSemantics = 0; + int requirePrototypes = 0; +}; + +// Language 2 page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains(QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + } + + PlainCharacter plainCharacter = SignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + // Optimizations level radio-buttons with + // combo-box on "level" widget. + + enum Strategy { + StrategyBalanced, + StrategySize, + StrategySpeed + }; + + enum Level { + LevelNone, + LevelLow, + LevelMedium, + LevelHigh + }; + + enum LevelSlave { + LevelSlave0, + LevelSlave1, + LevelSlave2, + LevelSlave3 + }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableLoopUnroll = !flags.contains( + QLatin1String("--no_unroll")); + enableFunctionInlining = !flags.contains( + QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains( + QLatin1String("--no_code_motion")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + enableStaticClustering = !flags.contains( + QLatin1String("--no_clustering")); + enableInstructionScheduling = !flags.contains( + QLatin1String("--no_scheduling")); + enableVectorization = flags.contains( + QLatin1String("--vectorize")); + disableSizeConstraints = flags.contains( + QLatin1String("--no_size_constraints")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Eight bit-field flags on "enabled optimizations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableLoopUnroll = 0; // Loop unrolling. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableTypeBasedAliasAnalysis = 0; // Type-based alias analysis. + int enableStaticClustering = 0; // Static clustering. + int enableInstructionScheduling = 0; // Instruction scheduling. + int enableVectorization = 0; // Vectorization. + + // Separate "no size constraints" checkbox. + int disableSizeConstraints = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + treatWarningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int treatWarningsAsErrors = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + enum ProcessorMode { + CpuArmMode, + CpuThumbMode + }; + + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + const QString cpuModeValue = IarewUtils::flagValue( + flags, QStringLiteral("--cpu_mode")); + if (cpuModeValue == QLatin1String("thumb")) + cpuMode = CodePageOptions::CpuThumbMode; + else if (cpuModeValue == QLatin1String("arm")) + cpuMode = CodePageOptions::CpuArmMode; + + generateReadOnlyPosIndependentCode = flags.contains( + QLatin1String("--ropi")); + generateReadWritePosIndependentCode = flags.contains( + QLatin1String("--rwpi")); + disableDynamicReadWriteInitialization = flags.contains( + QLatin1String("--no_rw_dynamic_init")); + disableCodeMemoryDataReads = flags.contains( + QLatin1String("--no_literal_pool")); + } + + ProcessorMode cpuMode = CpuThumbMode; + int generateReadOnlyPosIndependentCode = 0; + int generateReadWritePosIndependentCode = 0; + int disableDynamicReadWriteInitialization = 0; + int disableCodeMemoryDataReads = 0; +}; + +} // namespace + +// ArmCompilerSettingsGroup + +ArmCompilerSettingsGroup::ArmCompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICCARM")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); + buildCodePage(qbsProduct); +} + +void ArmCompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {opts.debugInfo}); +} + +void ArmCompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {opts.cLanguageDialect}); + // Add 'CCExt' item (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("CCLangConformance"), + {opts.languageConformance}); + // Add 'IccExceptions2' item (Enable exceptions). + addOptionsGroup(QByteArrayLiteral("IccExceptions2"), + {opts.enableExceptions}); + // Add 'IccRTTI2' item (Enable RTTI). + addOptionsGroup(QByteArrayLiteral("IccRTTI2"), + {opts.enableRtti}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {opts.destroyStaticObjects}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {opts.enableInlineSemantics}); + // Add 'CCRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {opts.requirePrototypes}); +} + +void ArmCompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'CCSignedPlainChar' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("CCSignedPlainChar"), + {opts.plainCharacter}); + // Add 'IccFloatSemantics' item + // (Floating-point semantic: strict/relaxed). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {opts.floatingPointSemantic}); +} + +void ArmCompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'CCOptStrategy', 'CCOptLevel' + // and 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("CCOptStrategy"), + {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("CCOptLevel"), + {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("CCOptLevelSlave"), + {opts.optimizationLevelSlave}); + // Add 'CCAllowList' item (Enabled optimizations: 6 check boxes). + const QString transformations = QStringLiteral("%1%2%3%4%5%6%7%8") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableLoopUnroll) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableTypeBasedAliasAnalysis) + .arg(opts.enableStaticClustering) + .arg(opts.enableInstructionScheduling) + .arg(opts.enableVectorization); + addOptionsGroup(QByteArrayLiteral("CCAllowList"), + {transformations}); + // Add 'CCOptimizationNoSizeConstraints' item (No size constraints). + addOptionsGroup(QByteArrayLiteral("CCOptimizationNoSizeConstraints"), + {opts.disableSizeConstraints}); +} + +void ArmCompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'CCDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + opts.defineSymbols); + // Add 'CCIncludePath2' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("CCIncludePath2"), + opts.includePaths); +} + +void ArmCompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"), + {opts.treatWarningsAsErrors}); +} + +void ArmCompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const CodePageOptions opts(qbsProduct); + // Add 'IProcessorMode2' item (Processor mode: arm/thumb). + addOptionsGroup(QByteArrayLiteral("IProcessorMode2"), + {opts.cpuMode}); + // Add 'CCPosIndRopi' item (Code and read-only data "ropi"). + addOptionsGroup(QByteArrayLiteral("CCPosIndRopi"), + {opts.generateReadOnlyPosIndependentCode}); + // Add 'CCPosIndRwpi' item (Read/write data "rwpi"). + addOptionsGroup(QByteArrayLiteral("CCPosIndRwpi"), + {opts.generateReadWritePosIndependentCode}); + // Add 'CCPosIndNoDynInit' item (No dynamic read/write initialization). + addOptionsGroup(QByteArrayLiteral("CCPosIndNoDynInit"), + {opts.disableDynamicReadWriteInitialization}); + // Add 'CCNoLiteralPool' item (No data reads in code memory). + addOptionsGroup(QByteArrayLiteral("CCNoLiteralPool"), + {opts.disableCodeMemoryDataReads}); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.h new file mode 100644 index 00000000..6137bc97 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armcompilersettingsgroup_v8.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMCOMPILERSETTINGSGROUP_V8_H +#define QBS_IAREWARMCOMPILERSETTINGSGROUP_V8_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmCompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit ArmCompilerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const ProductData &qbsProduct); + void buildLanguageOnePage(const ProductData &qbsProduct); + void buildLanguageTwoPage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildCodePage(const ProductData &qbsProduct); +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMCOMPILERSETTINGSGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.cpp new file mode 100644 index 00000000..a2395e3d --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.cpp @@ -0,0 +1,551 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armgeneralsettingsgroup_v8.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +constexpr int kGeneralArchiveVersion = 3; +constexpr int kGeneralDataVersion = 30; + +namespace { + +struct CpuCoreEntry final +{ + enum CpuCoreCode { + Arm7tdmi = 0, + Arm7tdmis = 1, + Arm710t = 2, + Arm720t = 3, + Arm740t = 4, + Arm7ejs = 5, + Arm9tdmi = 6, + Arm920t = 7, + Arm922t = 8, + Arm940t = 9, + Arm9e = 10, + Arm9es = 11, + Arm926ejs = 12, + Arm946es = 13, + Arm966es = 14, + Arm968es = 15, + Arm10e = 16, + Arm1020e = 17, + Arm1022e = 18, + Arm1026ejs = 19, + Arm1136j = 20, + Arm1136js = 21, + Arm1176j = 24, + Arm1176js = 25, + Xscale = 32, + XscaleIr7 = 33, + CortexM0 = 34, + CortexM0Plus = 35, + CortexM1 = 36, + CortexMs1 = 37, + CortexM3 = 38, + CortexM4 = 39, + CortexM7 = 41, + CortexR4 = 42, + CortexR5 = 44, + CortexR7 = 46, + CortexR8 = 48, + CortexR52 = 49, + CortexA5 = 50, + CortexA7 = 52, + CortexA8 = 53, + CortexA9 = 54, + CortexA15 = 55, + CortexA17 = 56, + CortexM23 = 58, + CortexM33 = 59 + }; + + // Required to compile in MSVC2015. + CpuCoreEntry(CpuCoreCode cc, QByteArray tf) + : coreCode(cc), targetFlag(std::move(tf)) + {} + + CpuCoreCode coreCode = Arm7tdmi; + QByteArray targetFlag; +}; + +// Dictionary of known ARM CPU cores and its compiler options. +const CpuCoreEntry cpusDict[] = { + {CpuCoreEntry::Arm7tdmi, "arm7tdmi"}, // same as 'sc100' + {CpuCoreEntry::Arm7tdmis, "arm7tdmi-s"}, + {CpuCoreEntry::Arm710t, "arm710t"}, + {CpuCoreEntry::Arm720t, "arm720t"}, + {CpuCoreEntry::Arm740t, "arm740t"}, + {CpuCoreEntry::Arm7ejs, "arm7ej-s"}, + {CpuCoreEntry::Arm9tdmi, "arm9tdmi"}, + {CpuCoreEntry::Arm920t, "arm920t"}, + {CpuCoreEntry::Arm922t, "arm922t"}, + {CpuCoreEntry::Arm940t, "arm940t"}, + {CpuCoreEntry::Arm9e, "arm9e"}, + {CpuCoreEntry::Arm9es, "arm9e-s"}, + {CpuCoreEntry::Arm926ejs, "arm926ej-s"}, + {CpuCoreEntry::Arm946es, "arm946e-s"}, + {CpuCoreEntry::Arm966es, "arm966e-s"}, + {CpuCoreEntry::Arm968es, "arm968e-s"}, + {CpuCoreEntry::Arm10e, "arm10e"}, + {CpuCoreEntry::Arm1020e, "arm1020e"}, + {CpuCoreEntry::Arm1022e, "arm1022e"}, + {CpuCoreEntry::Arm1026ejs, "arm1026ej-s"}, + {CpuCoreEntry::Arm1136j, "arm1136j"}, + {CpuCoreEntry::Arm1136js, "arm1136j-s"}, + {CpuCoreEntry::Arm1176j, "arm1176j"}, + {CpuCoreEntry::Arm1176js, "arm1176j-s"}, + {CpuCoreEntry::Xscale, "xscale"}, + {CpuCoreEntry::XscaleIr7, "xscale-ir7"}, + {CpuCoreEntry::CortexM0, "cortex-m0"}, + {CpuCoreEntry::CortexM0Plus, "cortex-m0+"}, // same as 'sc000' + {CpuCoreEntry::CortexM1, "cortex-m1"}, + {CpuCoreEntry::CortexMs1, "cortex-ms1"}, + {CpuCoreEntry::CortexM3, "cortex-m3"}, // same as 'sc300' + {CpuCoreEntry::CortexM4, "cortex-m4"}, + {CpuCoreEntry::CortexM7, "cortex-m7"}, + {CpuCoreEntry::CortexR4, "cortex-r4"}, + {CpuCoreEntry::CortexR5, "cortex-r5"}, + {CpuCoreEntry::CortexR7, "cortex-r7"}, + {CpuCoreEntry::CortexR8, "cortex-r8"}, + {CpuCoreEntry::CortexR52, "cortex-r52"}, + {CpuCoreEntry::CortexA5, "cortex-a5"}, + {CpuCoreEntry::CortexA7, "cortex-a7"}, + {CpuCoreEntry::CortexA8, "cortex-a8"}, + {CpuCoreEntry::CortexA9, "cortex-a9"}, + {CpuCoreEntry::CortexA15, "cortex-a15"}, + {CpuCoreEntry::CortexA17, "cortex-a17"}, + {CpuCoreEntry::CortexM23, "cortex-m23"}, + {CpuCoreEntry::CortexM33, "cortex-m33"}, +}; + +struct FpuCoreEntry final +{ + enum FpuRegistersCount { + NoFpuRegisters, + Fpu16Registers, + Fpu32Registers + }; + + enum FpuCoreCode { + NoVfp = 0, + Vfp2 = 2, + Vfp3d16 = 3, + Vfp3 = 3, + Vfp4sp = 4, + Vfp4d16 = 5, + Vfp4 = 5, + Vfp5sp = 6, + Vfp5d16 = 7, + Vfp9s = 8 + }; + + // Required to compile in MSVC2015. + FpuCoreEntry(FpuCoreCode cc, FpuRegistersCount rc, + QByteArray tf) + : coreCode(cc), regsCount(rc), targetFlag(std::move(tf)) + {} + + FpuCoreCode coreCode = NoVfp; + FpuRegistersCount regsCount = NoFpuRegisters; + QByteArray targetFlag; +}; + +// Dictionary of known ARM FPU cores and its compiler options. +const FpuCoreEntry fpusDict[] = { + {FpuCoreEntry::Vfp2, FpuCoreEntry::NoFpuRegisters, "vfpv2"}, + {FpuCoreEntry::Vfp3d16, FpuCoreEntry::Fpu16Registers, "vfpv3_d16"}, + {FpuCoreEntry::Vfp3, FpuCoreEntry::Fpu32Registers, "vfpv3"}, + {FpuCoreEntry::Vfp4sp, FpuCoreEntry::Fpu16Registers, "vfpv4_sp"}, + {FpuCoreEntry::Vfp4d16, FpuCoreEntry::Fpu16Registers, "vfpv4_d16"}, + {FpuCoreEntry::Vfp4, FpuCoreEntry::Fpu32Registers, "vfpv4"}, + {FpuCoreEntry::Vfp5sp, FpuCoreEntry::Fpu16Registers, "vfpv5_sp"}, + {FpuCoreEntry::Vfp5d16, FpuCoreEntry::Fpu16Registers, "vfpv5_d16"}, + {FpuCoreEntry::Vfp9s, FpuCoreEntry::NoFpuRegisters, "vfp9-s"}, +}; + +// Target page options. + +struct TargetPageOptions final +{ + enum Endianness { + LittleEndian, + BigEndian + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target CPU code. + const QString cpuValue = IarewUtils::flagValue( + flags, QStringLiteral("--cpu")) + .toLower(); + const auto cpuEnd = std::cend(cpusDict); + const auto cpuIt = std::find_if(std::cbegin(cpusDict), cpuEnd, + [cpuValue]( + const CpuCoreEntry &entry) { + return entry.targetFlag == cpuValue.toLatin1(); + }); + if (cpuIt != cpuEnd) + targetCpu = cpuIt->coreCode; + // Detect target FPU code. + const QString fpuValue = IarewUtils::flagValue( + flags, QStringLiteral("--fpu")) + .toLower(); + const auto fpuEnd = std::cend(fpusDict); + const auto fpuIt = std::find_if(std::cbegin(fpusDict), fpuEnd, + [fpuValue]( + const FpuCoreEntry &entry) { + return entry.targetFlag == fpuValue.toLatin1(); + }); + if (fpuIt != fpuEnd) { + targetFpu = fpuIt->coreCode; + targetFpuRegs = fpuIt->regsCount; + } + // Detect endian. + const QString prop = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("endianness")); + if (prop == QLatin1String("big")) + endianness = TargetPageOptions::BigEndian; + else if (prop == QLatin1String("little")) + endianness = TargetPageOptions::LittleEndian; + } + + CpuCoreEntry::CpuCoreCode targetCpu = CpuCoreEntry::Arm7tdmi; + FpuCoreEntry::FpuCoreCode targetFpu = FpuCoreEntry::NoVfp; + FpuCoreEntry::FpuRegistersCount targetFpuRegs = FpuCoreEntry::NoFpuRegisters; + Endianness endianness = LittleEndian; +}; + +// Library 1 page options. + +struct LibraryOnePageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter, + PrintfFullFormatter, + PrintfLargeFormatter, + PrintfSmallFormatter, + PrintfTinyFormatter + }; + + enum ScanfFormatter { + ScanfAutoFormatter, + ScanfFullFormatter, + ScanfLargeFormatter, + ScanfSmallFormatter + }; + + explicit LibraryOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (*flagIt != QLatin1String("--redirect")) + continue; + ++flagIt; + if (flagIt->startsWith(QLatin1String("_printf="), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(1).toLower(); + if (prop == QLatin1String("_printffullnomb")) + printfFormatter = LibraryOnePageOptions::PrintfFullFormatter; + else if (prop == QLatin1String("_printflargenomb")) + printfFormatter = LibraryOnePageOptions::PrintfLargeFormatter; + else if (prop == QLatin1String("_printfsmallnomb")) + printfFormatter = LibraryOnePageOptions::PrintfSmallFormatter; + else if (prop == QLatin1String("_printftiny")) + printfFormatter = LibraryOnePageOptions::PrintfTinyFormatter; + } else if (flagIt->startsWith(QLatin1String("_scanf="), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(1).toLower();; + if (prop == QLatin1String("_scanffullnomb")) + scanfFormatter = LibraryOnePageOptions::ScanfFullFormatter; + else if (prop == QLatin1String("_scanflargenomb")) + scanfFormatter = LibraryOnePageOptions::ScanfLargeFormatter; + else if (prop == QLatin1String("_scanfsmallnomb")) + scanfFormatter = LibraryOnePageOptions::ScanfSmallFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Library 2 page options. + +struct LibraryTwoPageOptions final +{ + enum HeapType { + AutomaticHeap, + AdvancedHeap, + BasicHeap, + NoFreeHeap + }; + + explicit LibraryTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + if (flags.contains(QLatin1String("--advanced_heap"))) + heapType = LibraryTwoPageOptions::AdvancedHeap; + else if (flags.contains(QLatin1String("--basic_heap"))) + heapType = LibraryTwoPageOptions::BasicHeap; + else if (flags.contains(QLatin1String("--no_free_heap"))) + heapType = LibraryTwoPageOptions::NoFreeHeap; + else + heapType = LibraryTwoPageOptions::AutomaticHeap; + } + + HeapType heapType = AutomaticHeap; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalLibrary, + FullLibrary, + CustomLibrary + }; + + enum ThreadSupport { + NoThread, + EnableThread + }; + + enum LowLevelInterface { + NoInterface, + SemihostedInterface + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + const QFileInfo dlibFileInfo(IarewUtils::flagValue( + flags, QStringLiteral("--dlib_config"))); + if (!dlibFileInfo.exists()) { + dlibType = LibraryConfigPageOptions::NoLibrary; + } else { + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QString dlibFilePath = dlibFileInfo.absoluteFilePath(); + if (dlibFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + if (dlibFilePath.endsWith(QLatin1String("dlib_config_normal.h"), + Qt::CaseInsensitive)) { + dlibType = LibraryConfigPageOptions::NormalLibrary; + } else if (dlibFilePath.endsWith( + QLatin1String("dlib_config_full.h"), + Qt::CaseInsensitive)) { + dlibType = LibraryConfigPageOptions::FullLibrary; + } else { + dlibType = LibraryConfigPageOptions::CustomLibrary; + } + + dlibConfigPath = IarewUtils::toolkitRelativeFilePath( + toolkitPath, dlibFilePath); + } else { + dlibType = LibraryConfigPageOptions::CustomLibrary; + dlibConfigPath = IarewUtils::projectRelativeFilePath( + baseDirectory, dlibFilePath); + } + } + + threadSupport = flags.contains(QLatin1String("--threaded_lib")) + ? LibraryConfigPageOptions::EnableThread + : LibraryConfigPageOptions::NoThread; + lowLevelInterface = flags.contains(QLatin1String("--semihosting")) + ? LibraryConfigPageOptions::SemihostedInterface + : LibraryConfigPageOptions::NoInterface; + } + + RuntimeLibrary dlibType = NoLibrary; + QString dlibConfigPath; + ThreadSupport threadSupport = NoThread; + LowLevelInterface lowLevelInterface = NoInterface; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +} // namespace + +// ArmGeneralSettingsGroup + +ArmGeneralSettingsGroup::ArmGeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildLibraryOptionsOnePage(qbsProduct); + buildLibraryOptionsTwoPage(qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void ArmGeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'GBECoreSlave', 'CoreVariant', 'GFPUCoreSlave2' items + // (Processor variant chooser). + addOptionsGroup(QByteArrayLiteral("GBECoreSlave"), + {opts.targetCpu}, 26); + addOptionsGroup(QByteArrayLiteral("CoreVariant"), + {opts.targetCpu}, 26); + addOptionsGroup(QByteArrayLiteral("GFPUCoreSlave2"), + {opts.targetCpu}, 26); + // Add 'FPU2', 'NrRegs' item (Floating point settings chooser). + addOptionsGroup(QByteArrayLiteral("FPU2"), + {opts.targetFpu}, 0); + addOptionsGroup(QByteArrayLiteral("NrRegs"), + {opts.targetFpuRegs}, 0); + // Add 'GEndianMode' item (Endian mode chooser). + addOptionsGroup(QByteArrayLiteral("GEndianMode"), + {opts.endianness}); +} + +void ArmGeneralSettingsGroup::buildLibraryOptionsOnePage( + const ProductData &qbsProduct) +{ + const LibraryOnePageOptions opts(qbsProduct); + // Add 'OGPrintfVariant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("OGPrintfVariant"), + {opts.printfFormatter}); + // Add 'OGScanfVariant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("OGScanfVariant"), + {opts.scanfFormatter}); +} + +void ArmGeneralSettingsGroup::buildLibraryOptionsTwoPage( + const ProductData &qbsProduct) +{ + const LibraryTwoPageOptions opts(qbsProduct); + // Add 'OgLibHeap' item (Heap selection: + // auto/advanced/basic/nofree). + addOptionsGroup(QByteArrayLiteral("OgLibHeap"), + {opts.heapType}); +} + +void ArmGeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GRuntimeLibSelect', 'GRuntimeLibSelectSlave' + // and 'RTConfigPath2' items + // (Link with runtime: none/normal/full/custom). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelect"), + {opts.dlibType}); + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelectSlave"), + {opts.dlibType}); + addOptionsGroup(QByteArrayLiteral("RTConfigPath2"), + {opts.dlibConfigPath}); + // Add 'GRuntimeLibThreads'item + // (Enable thread support in library). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibThreads"), + {opts.threadSupport}); + // Add 'GenLowLevelInterface' item (Library low-level + // interface: none/semihosted/breakpoint). + addOptionsGroup(QByteArrayLiteral("GenLowLevelInterface"), + {opts.lowLevelInterface}); +} + +void ArmGeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item + // (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {opts.binaryType}); + // Add 'ExePath' item + // (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {opts.binaryDirectory}); + // Add 'ObjPath' item + // (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {opts.objectDirectory}); + // Add 'ListPath' item + // (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {opts.listingDirectory}); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.h new file mode 100644 index 00000000..0b1564b3 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armgeneralsettingsgroup_v8.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMGENERALSETTINGSGROUP_V8_H +#define QBS_IAREWARMGENERALSETTINGSGROUP_V8_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmGeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit ArmGeneralSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildLibraryOptionsOnePage(const ProductData &qbsProduct); + void buildLibraryOptionsTwoPage(const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMGENERALSETTINGSGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.cpp b/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.cpp new file mode 100644 index 00000000..2cabac58 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.cpp @@ -0,0 +1,488 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armlinkersettingsgroup_v8.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +constexpr int kLinkerArchiveVersion = 0; +constexpr int kLinkerDataVersion = 20; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + // Accumulate config definitions (if exists). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + configDefines = IarewUtils::flagValues( + flags, QStringLiteral("--config_def")); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + if (!qbsGroup.isEnabled()) + continue; + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '--config' option). + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("--config")); + for (const auto &configPathValue : configPathValues) { + const QString fullConfigPath = configPathValue.toString(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } + } + } + + QVariantList configFilePaths; + QVariantList configDefines; +}; + +// Library page options. + +struct LibraryPageOptions final +{ + explicit LibraryPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + + // Add libraries search paths. + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList libraryPaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + for (const QString &libraryPath : libraryPaths) { + const QFileInfo libraryPathInfo(libraryPath); + const QString fullLibrarySearchPath = + libraryPathInfo.absoluteFilePath(); + if (fullLibrarySearchPath.startsWith( + toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory,fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } + } + + // Add static libraries paths. + const QStringList staticLibrariesProps = + gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + for (const QString &staticLibrary : staticLibrariesProps) { + const QFileInfo staticLibraryInfo(staticLibrary); + if (staticLibraryInfo.isAbsolute()) { + const QString fullStaticLibraryPath = + staticLibraryInfo.absoluteFilePath(); + if (fullStaticLibraryPath.startsWith( + toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullStaticLibraryPath); + staticLibraries.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullStaticLibraryPath); + staticLibraries.push_back(path); + } + } else { + staticLibraries.push_back(staticLibrary); + } + } + + // Add static libraries from product dependencies. + for (const ProductData &qbsProductDep : qbsProductDeps) { + const QString depBinaryPath = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, + qbsProductDep); + staticLibraries.push_back(depBinaryPath); + } + + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + enableRuntimeLibsSearch = !flags.contains( + QLatin1String("--no_library_search")); + } + + QString entryPoint; + QVariantList staticLibraries; + QVariantList librarySearchPaths; + int enableRuntimeLibsSearch = 0; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + debugInfo = !flags.contains(QLatin1String("--strip")); + outputFile = gen::utils::targetBinary(qbsProduct); + } + + int debugInfo = 0; + QString outputFile; +}; + +// Input page options. + +struct InputPageOptions final +{ + explicit InputPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + keepSymbols = IarewUtils::flagValues(flags, QStringLiteral("--keep")); + } + + QVariantList keepSymbols; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { + NoListing, + GenerateListing + }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = GenerateListing; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + inlineSmallRoutines = flags.contains(QLatin1String("--inline")); + mergeDuplicateSections = flags.contains( + QLatin1String("--merge_duplicate_sections")); + virtualFuncElimination = flags.contains(QLatin1String("--vfe")); + } + + int inlineSmallRoutines = 0; + int mergeDuplicateSections = 0; + int virtualFuncElimination = 0; +}; + +// Advanced page options. + +struct AdvancedPageOptions final +{ + explicit AdvancedPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + allowExceptions = !flags.contains(QLatin1String("--no_exceptions")); + } + + int allowExceptions = 0; +}; + +// Defines page options. + +struct DefinesPageOptions final +{ + explicit DefinesPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + defineSymbols = IarewUtils::flagValues( + flags, QStringLiteral("--define_symbol")); + } + + QVariantList defineSymbols; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + treatWarningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int treatWarningsAsErrors = 0; +}; + +} // namespace + +// ArmLinkerSettingsGroup + +ArmLinkerSettingsGroup::ArmLinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + setName(QByteArrayLiteral("ILINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct); + buildLibraryPage(buildRootDirectory, qbsProduct, qbsProductDeps); + buildOutputPage(qbsProduct); + buildInputPage(qbsProduct); + buildListPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildAdvancedPage(qbsProduct); + buildDefinesPage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void ArmLinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'IlinkConfigDefines' item + // (Configuration file symbol definitions). + addOptionsGroup(QByteArrayLiteral("IlinkConfigDefines"), + opts.configDefines); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add 'IlinkIcfOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("IlinkIcfOverride"), + {1}); + // Add 'IlinkIcfFile' item (Linker configuration file). + addOptionsGroup(QByteArrayLiteral("IlinkIcfFile"), + {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("--config ") + + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } +} + +void ArmLinkerSettingsGroup::buildLibraryPage( + const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + LibraryPageOptions opts(baseDirectory, qbsProduct, qbsProductDeps); + // Add 'IlinkOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("IlinkOverrideProgramEntryLabel"), + {1}); + const int select = opts.entryPoint.isEmpty() ? 1 : 0; + addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabelSelect"), + {select}); + // Add 'IlinkProgramEntryLabel' item (Entry point name). + addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabel"), + {opts.entryPoint}); + + if (!opts.staticLibraries.isEmpty()) { + // Add 'IlinkAdditionalLibs' item (Additional libraries). + addOptionsGroup(QByteArrayLiteral("IlinkAdditionalLibs"), + opts.staticLibraries); + } + + // Add 'IlinkAutoLibEnable' item + // (Automatic runtime library selection). + addOptionsGroup(QByteArrayLiteral("IlinkAutoLibEnable"), + {opts.enableRuntimeLibsSearch}); + + // Add library searh directories to the + // "Extra options page", because IAR IDE + // has not other options to add this paths. + for (QVariant &libraryPath : opts.librarySearchPaths) + libraryPath = QLatin1String("-L ") + libraryPath.toString(); + + m_extraOptions << opts.librarySearchPaths; +} + +void ArmLinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'IlinkDebugInfoEnable' item + // (Include debug information in output). + addOptionsGroup(QByteArrayLiteral("IlinkDebugInfoEnable"), + {opts.debugInfo}); + // Add 'IlinkOutputFile' item (Output filename). + addOptionsGroup(QByteArrayLiteral("IlinkOutputFile"), + {opts.outputFile}); +} + +void ArmLinkerSettingsGroup::buildInputPage( + const ProductData &qbsProduct) +{ + const InputPageOptions opts(qbsProduct); + // Add 'IlinkKeepSymbols' item (). + addOptionsGroup(QByteArrayLiteral("IlinkKeepSymbols"), + opts.keepSymbols); +} + +void ArmLinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'IlinkMapFile' item (Generate linker map file). + addOptionsGroup(QByteArrayLiteral("IlinkMapFile"), + {opts.generateMap}); +} + +void ArmLinkerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'IlinkOptInline' item (Inline small routines). + addOptionsGroup(QByteArrayLiteral("IlinkOptInline"), + {opts.inlineSmallRoutines}); + // Add 'IlinkOptMergeDuplSections'item + // (Merge duplicate sections). + addOptionsGroup(QByteArrayLiteral("IlinkOptMergeDuplSections"), + {opts.mergeDuplicateSections}); + // Add 'IlinkOptUseVfe' item + // (Perform C++ virtual functions elimination). + addOptionsGroup(QByteArrayLiteral("IlinkOptUseVfe"), + {opts.virtualFuncElimination}); +} + +void ArmLinkerSettingsGroup::buildAdvancedPage( + const ProductData &qbsProduct) +{ + const AdvancedPageOptions opts(qbsProduct); + // Add 'IlinkOptExceptionsAllow' item (Allow C++ exceptions). + addOptionsGroup(QByteArrayLiteral("IlinkOptExceptionsAllow"), + {opts.allowExceptions}); +} + +void ArmLinkerSettingsGroup::buildDefinesPage( + const ProductData &qbsProduct) +{ + const DefinesPageOptions opts(qbsProduct); + // Add 'IlinkDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("IlinkDefines"), + {opts.defineSymbols}); +} + +void ArmLinkerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'IlinkWarningsAreErrors' item + // (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("IlinkWarningsAreErrors"), + {opts.treatWarningsAsErrors}); +} + +void ArmLinkerSettingsGroup::buildExtraOptionsPage( + const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + // Add 'IlinkUseExtraOptions' and 'IlinkExtraOptions' items. + addOptionsGroup(QByteArrayLiteral("IlinkUseExtraOptions"), + {1}); + addOptionsGroup(QByteArrayLiteral("IlinkExtraOptions"), + m_extraOptions); +} + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.h b/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.h new file mode 100644 index 00000000..e86297e6 --- /dev/null +++ b/src/plugins/generator/iarew/archs/arm/armlinkersettingsgroup_v8.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWARMLINKERSETTINGSGROUP_V8_H +#define QBS_IAREWARMLINKERSETTINGSGROUP_V8_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace arm { +namespace v8 { + +class ArmLinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit ArmLinkerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryPage(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + void buildOutputPage(const ProductData &qbsProduct); + void buildInputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildAdvancedPage(const ProductData &qbsProduct); + void buildDefinesPage(const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v8 +} // namespace arm +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWARMLINKERSETTINGSGROUP_V8_H diff --git a/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp new file mode 100644 index 00000000..4e002d13 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrarchiversettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +constexpr int kArchiverArchiveVersion = 2; +constexpr int kArchiverDataVersion = 0; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +// AvrArchiverSettingsGroup + +AvrArchiverSettingsGroup::AvrArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XAR")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void AvrArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'XAROutOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XAROutOverride"), + {1}); + // Add 'OutputFile' item (Output filename). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {opts.outputFile}); +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h new file mode 100644 index 00000000..2ff667e1 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrarchiversettingsgroup_v7.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRARCHIVERSETTINGSGROUP_V7_H +#define QBS_IAREWAVRARCHIVERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrArchiverSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRARCHIVERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp new file mode 100644 index 00000000..08e86be5 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.cpp @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrassemblersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +constexpr int kAssemblerArchiveVersion = 5; +constexpr int kAssemblerDataVersion = 11; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = flags.contains(QLatin1String("-s+")); + enableMultibyteSupport = flags.contains(QLatin1String("-n")); + + if (flags.contains(QLatin1String("-M<>"))) + macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote; + else if (flags.contains(QLatin1String("-M()"))) + macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote; + else if (flags.contains(QLatin1String("-M[]"))) + macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote; + else if (flags.contains(QLatin1String("-M{}"))) + macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote; + } + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; + int enableSymbolsCaseSensitive = 0; + int enableMultibyteSupport = 0; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const auto &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (warningLevel == QLatin1String("all")) { + enableWarnings = 0; + enableAllWarnings = 0; + } else if (warningLevel == QLatin1String("none")) { + enableWarnings = 1; + enableAllWarnings = 0; + } else { + enableWarnings = 0; + enableAllWarnings = 1; + } + } + + int enableWarnings = 0; + int enableAllWarnings = 0; +}; + +} // namespace + +// AvrAssemblerSettingsGroup + +AvrAssemblerSettingsGroup::AvrAssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("AAVR")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void AvrAssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {opts.enableSymbolsCaseSensitive}); + // Add 'AsmMultiByteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("AsmMultiByteSupport"), + {opts.enableMultibyteSupport}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {opts.macroQuoteCharacter}, 0); +} + +void AvrAssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CDebug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("CDebug"), + {opts.debugInfo}); +} + +void AvrAssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + opts.defineSymbols); + // Add 'AUserIncludes' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("ANewIncludes"), + opts.includePaths); +} + +void AvrAssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'AWarnEnable' item (Enable/disable warnings). + addOptionsGroup(QByteArrayLiteral("AWarnEnable"), + {opts.enableWarnings}); + // Add 'AWarnWhat' item (Enable/disable all warnings). + addOptionsGroup(QByteArrayLiteral("AWarnWhat"), + {opts.enableAllWarnings}); +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h new file mode 100644 index 00000000..608a4265 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrassemblersettingsgroup_v7.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRASSEMBLERSETTINGSGROUP_V7_H +#define QBS_IAREWAVRASSEMBLERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrAssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrAssemblerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildLanguagePage(const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRASSEMBLERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp new file mode 100644 index 00000000..dbb5c662 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrarchiversettingsgroup_v7.h" +#include "avrassemblersettingsgroup_v7.h" +#include "avrbuildconfigurationgroup_v7.h" +#include "avrcompilersettingsgroup_v7.h" +#include "avrgeneralsettingsgroup_v7.h" +#include "avrlinkersettingsgroup_v7.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +AvrBuildConfigurationGroup::AvrBuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("AVR"); + + // Append debug info item. + const int debugBuild = gen::utils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool AvrBuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Avr + && version.majorVersion() == 7; +} + +std::unique_ptr +AvrBuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new AvrBuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h new file mode 100644 index 00000000..618cef4c --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrbuildconfigurationgroup_v7.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRBUILDCONFIGURATIONGROUP_V7_H +#define QBS_IAREWAVRBUILDCONFIGURATIONGROUP_V7_H + +#include +#include + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrBuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit AvrBuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class AvrBuildConfigurationGroupFactory; +}; + +class AvrBuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRBUILDCONFIGURATIONGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp new file mode 100644 index 00000000..26b6858f --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.cpp @@ -0,0 +1,492 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrcompilersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +constexpr int kCompilerArchiveVersion = 6; +constexpr int kCompilerDataVersion = 17; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + moduleType = flags.contains(QLatin1String("--library_module")) + ? OutputPageOptions::LibraryModule + : OutputPageOptions::ProgramModule; + debugInfo = gen::utils::debugInformation(qbsProduct); + disableErrorMessages = flags.contains( + QLatin1String("--no_ubrof_messages")); + } + + int debugInfo = 0; + int disableErrorMessages = 0; + enum ModuleType { ProgramModule, LibraryModule}; + ModuleType moduleType = ProgramModule; +}; + +// Language one page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C99LanguageDialect + }; + + enum CxxLanguageDialect { + EmbeddedCPlusPlus, + ExtendedEmbeddedCPlusPlus + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // C language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + if (cLanguageVersion.contains(QLatin1String("c89"))) + cLanguageDialect = LanguageOnePageOptions::C89LanguageDialect; + else if (cLanguageVersion.contains(QLatin1String("c99"))) + cLanguageDialect = LanguageOnePageOptions::C99LanguageDialect; + // C++ language dialect. + if (flags.contains(QLatin1String("--ec++"))) + cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus; + else if (flags.contains(QLatin1String("--eec++"))) + cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus; + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + + allowVla = flags.contains(QLatin1String("--vla")); + useCppInlineSemantics = flags.contains( + QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains( + QLatin1String("--require_prototypes")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C89LanguageDialect; + CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus; + LanguageConformance languageConformance = AllowIarExtension; + int allowVla = 0; + int useCppInlineSemantics = 0; + int requirePrototypes = 0; + int destroyStaticObjects = 0; +}; + +// Language two page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains(QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + } + + PlainCharacter plainCharacter = SignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; + int enableMultibyteSupport = 0; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + // Optimizations level radio-buttons with + // combo-box on "level" widget. + enum Strategy { + StrategyBalanced, + StrategySize, + StrategySpeed + }; + + enum Level { + LevelNone, + LevelLow, + LevelMedium, + LevelHigh + }; + + enum LevelSlave { + LevelSlave0, + LevelSlave1, + LevelSlave2, + LevelSlave3 + }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableCrossCall = !flags.contains(QLatin1String("--no_cross_call")); + enableVariableClustering = !flags.contains( + QLatin1String("--no_clustering")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + enableForceCrossCall = flags.contains( + QLatin1String("--do_cross_call")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Six bit-field flags on "enabled optimizations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableCrossCall = 0; // Cross call optimization. + int enableVariableClustering = 0; // Variable clustering. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. + // Force cross-call optimization. + int enableForceCrossCall = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + placeConstantsInRam = flags.contains(QLatin1String("-y")); + placeInitializiersInFlash = flags.contains( + QLatin1String("--initializiers_in_flash")); + forceVariablesGeneration = flags.contains( + QLatin1String("--root_variables")); + useIccA90CallingConvention = flags.contains( + QLatin1String("--version1_calls")); + lockRegistersCount = IarewUtils::flagValue( + flags, QStringLiteral("--lock_regs")).toInt(); + } + + int placeConstantsInRam = 0; + int placeInitializiersInFlash = 0; + int forceVariablesGeneration = 0; + int useIccA90CallingConvention = 0; + int lockRegistersCount = 0; +}; + +} // namespace + +// AvrCompilerSettingsGroup + +AvrCompilerSettingsGroup::AvrCompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICCAVR")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); + buildCodePage(qbsProduct); +} + +void AvrCompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {opts.debugInfo}); + // Add 'CCNoErrorMsg' item (No error messages in output files). + addOptionsGroup(QByteArrayLiteral("CCNoErrorMsg"), + {opts.disableErrorMessages}); + // Add 'CCOverrideModuleTypeDefault' item + // (Override default module type). + addOptionsGroup(QByteArrayLiteral("CCOverrideModuleTypeDefault"), + {1}); + // Add 'CCRadioModuleType' item (Module type: program/library). + addOptionsGroup(QByteArrayLiteral("CCRadioModuleType"), + {opts.moduleType}); +} + +void AvrCompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {opts.cLanguageDialect}); + // Add 'IccCppDialect' item (C++ dialect: embedded/extended). + addOptionsGroup(QByteArrayLiteral("IccCppDialect"), + {opts.cxxLanguageDialect}); + // Add 'CCExt' item (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("CCExt"), + {opts.languageConformance}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {opts.useCppInlineSemantics}); + // Add 'CCRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {opts.destroyStaticObjects}); +} + +void AvrCompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'CCCharIs' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("CCCharIs"), + {opts.plainCharacter}); + // Add 'IccFloatSemantics' item (Floatic-point + // semantics: strict/relaxed conformance). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {opts.floatingPointSemantic}); + // Add 'CCMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("CCMultibyteSupport"), + {opts.enableMultibyteSupport}); +} + +void AvrCompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'CCOptStrategy', 'CCOptLevel' and + // 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("CCOptStrategy"), + {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("CCOptLevel"), + {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("CCOptLevelSlave"), + {opts.optimizationLevelSlave}); + // Add 'CCAllowList' item + // (Enabled optimizations: 6 check boxes). + const QString bitflags = QStringLiteral("%1%2%3%4%5%6") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableCrossCall) + .arg(opts.enableVariableClustering) + .arg(opts.enableTypeBasedAliasAnalysis); + addOptionsGroup(QByteArrayLiteral("CCAllowList"), + {bitflags}); + // Add 'CCOptForceCrossCall' item + // (Always do cross call optimization). + addOptionsGroup(QByteArrayLiteral("CCOptForceCrossCall"), + {opts.enableForceCrossCall}); +} + +void AvrCompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'CCDefines' item (Defines symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + opts.defineSymbols); + // Add 'newCCIncludePaths' item + // (Additional include directories). + addOptionsGroup(QByteArrayLiteral("newCCIncludePaths"), + opts.includePaths); +} + +void AvrCompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCWarnAsError' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCWarnAsError"), + {opts.warningsAsErrors}); +} + +void AvrCompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const CodePageOptions opts(qbsProduct); + // Add 'CCConstInRAM' item (Place string literals + // and constants in initialized RAM). + addOptionsGroup(QByteArrayLiteral("CCConstInRAM"), + {opts.placeConstantsInRam}); + // Add 'CCInitInFlash' item (Place aggregate + // initializiers in flash memory). + addOptionsGroup(QByteArrayLiteral("CCInitInFlash"), + {opts.placeInitializiersInFlash}); + // Add 'CCForceVariables' item (Force generation of + // all global and static variables). + addOptionsGroup(QByteArrayLiteral("CCForceVariables"), + {opts.forceVariablesGeneration}); + // Add 'CCOldCallConv' item (Use ICCA90 1.x + // calling convention). + addOptionsGroup(QByteArrayLiteral("CCOldCallConv"), + {opts.useIccA90CallingConvention}); + // Add 'CCLockRegs' item (Number of registers to + // lock for global variables). + addOptionsGroup(QByteArrayLiteral("CCLockRegs"), + {opts.lockRegistersCount}); +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h new file mode 100644 index 00000000..2d8c53b8 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrcompilersettingsgroup_v7.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRCOMPILERSETTINGSGROUP_V7_H +#define QBS_IAREWAVRCOMPILERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrCompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrCompilerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const ProductData &qbsProduct); + void buildLanguageOnePage(const ProductData &qbsProduct); + void buildLanguageTwoPage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildCodePage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRCOMPILERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp new file mode 100644 index 00000000..f3fb8647 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.cpp @@ -0,0 +1,774 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrgeneralsettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +constexpr int kGeneralArchiveVersion = 12; +constexpr int kGeneralDataVersion = 10; + +namespace { + +struct TargetMcuEntry final +{ + QByteArray targetName; + QByteArray targetFlag; +}; + +// Dictionary of known AVR MCU's and its compiler options. +const TargetMcuEntry mcusDict[] = { + {"AT43USB320A", "at43usb320a"}, + {"AT43USB325", "at43usb325"}, + {"AT43USB326", "at43usb326"}, + {"AT43USB351M", "at43usb351m"}, + {"AT43USB353M", "at43usb353m"}, + {"AT43USB355", "at43usb355"}, + {"AT76C712", "at76c712"}, + {"AT76C713", "at76c713"}, + {"AT86RF401", "at86rf401"}, + {"AT90CAN128", "can128"}, + {"AT90CAN32", "can32"}, + {"AT90CAN64", "can64"}, + {"AT90PWM1", "pwm1"}, + {"AT90PWM161", "pwm161"}, + {"AT90PWM2", "pwm2"}, + {"AT90PWM216", "pwm216"}, + {"AT90PWM2B", "pwm2b"}, + {"AT90PWM3", "pwm3"}, + {"AT90PWM316", "pwm316"}, + {"AT90PWM3B", "pwm3b"}, + {"AT90PWM81", "pwm81"}, + {"AT90S1200", "1200"}, + {"AT90S2313", "2313"}, + {"AT90S2323", "2323"}, + {"AT90S2333", "2333"}, + {"AT90S2343", "2343"}, + {"AT90S4414", "4414"}, + {"AT90S4433", "4433"}, + {"AT90S4434", "4434"}, + {"AT90S8515", "8515"}, + {"AT90S8534", "8534"}, + {"AT90S8535", "8535"}, + {"AT90SCR050", "scr050"}, + {"AT90SCR075", "scr075"}, + {"AT90SCR100", "scr100"}, + {"AT90SCR200", "scr200"}, + {"AT90SCR400", "scr400"}, + {"AT90USB128", "usb128"}, + {"AT90USB1286", "usb1286"}, + {"AT90USB1287", "usb1287"}, + {"AT90USB162", "usb162"}, + {"AT90USB64", "usb64"}, + {"AT90USB646", "usb646"}, + {"AT90USB647", "usb647"}, + {"AT90USB82", "usb82"}, + {"AT94Kxx", "at94k"}, + {"ATA5272", "ata5272"}, + {"ATA5505", "ata5505"}, + {"ATA5700M322", "ata5700m322"}, + {"ATA5702M322", "ata5702m322"}, + {"ATA5781", "ata5781"}, + {"ATA5782", "ata5782"}, + {"ATA5783", "ata5783"}, + {"ATA5785", "ata5785"}, + {"ATA5787", "ata5787"}, + {"ATA5790", "ata5790"}, + {"ATA5790N", "ata5790n"}, + {"ATA5795", "ata5795"}, + {"ATA5830", "ata5830"}, + {"ATA5831", "ata5831"}, + {"ATA5832", "ata5832"}, + {"ATA5833", "ata5833"}, + {"ATA5835", "ata5835"}, + {"ATA6285", "ata6285"}, + {"ATA6286", "ata6286"}, + {"ATA6289", "ata6289"}, + {"ATA8210", "ata8210"}, + {"ATA8215", "ata8215"}, + {"ATA8510", "ata8510"}, + {"ATA8515", "ata8515"}, + {"ATmX224E", "mx224e"}, + {"ATmXT112SL", "mxt112sl"}, + {"ATmXT224", "mxt224"}, + {"ATmXT224E", "mxt224e"}, + {"ATmXT336S", "mxt336s"}, + {"ATmXT540S", "mxt540s"}, + {"ATmXT540S_RevA", "mxt540s_reva"}, + {"ATmXTS200", "mxts200"}, + {"ATmXTS220", "mxts220"}, + {"ATmXTS220E", "mxts220e"}, + {"ATmega007", "m007"}, + {"ATmega103", "m103"}, + {"ATmega128", "m128"}, + {"ATmega1280", "m1280"}, + {"ATmega1281", "m1281"}, + {"ATmega1284", "m1284"}, + {"ATmega1284P", "m1284p"}, + {"ATmega1284RFR2", "m1284rfr2"}, + {"ATmega128A", "m128a"}, + {"ATmega128RFA1", "m128rfa1"}, + {"ATmega128RFA2", "m128rfa2"}, + {"ATmega128RFR2", "m128rfr2"}, + {"ATmega16", "m16"}, + {"ATmega1608", "m1608"}, + {"ATmega1609", "m1609"}, + {"ATmega161", "m161"}, + {"ATmega162", "m162"}, + {"ATmega163", "m163"}, + {"ATmega164", "m164"}, + {"ATmega164A", "m164a"}, + {"ATmega164P", "m164p"}, + {"ATmega164PA", "m164pa"}, + {"ATmega165", "m165"}, + {"ATmega165A", "m165a"}, + {"ATmega165P", "m165p"}, + {"ATmega165PA", "m165pa"}, + {"ATmega168", "m168"}, + {"ATmega168A", "m168a"}, + {"ATmega168P", "m168p"}, + {"ATmega168PA", "m168pa"}, + {"ATmega168PB", "m168pb"}, + {"ATmega169", "m169"}, + {"ATmega169A", "m169a"}, + {"ATmega169P", "m169p"}, + {"ATmega169PA", "m169pa"}, + {"ATmega16A", "m16a"}, + {"ATmega16HVA", "m16hva"}, + {"ATmega16HVA2", "m16hva2"}, + {"ATmega16HVB", "m16hvb"}, + {"ATmega16M1", "m16m1"}, + {"ATmega16U2", "m16u2"}, + {"ATmega16U4", "m16u4"}, + {"ATmega2560", "m2560"}, + {"ATmega2561", "m2561"}, + {"ATmega2564RFR2", "m2564rfr2"}, + {"ATmega256RFA2", "m256rfa2"}, + {"ATmega256RFR2", "m256rfr2"}, + {"ATmega26HVG", "m26hvg"}, + {"ATmega32", "m32"}, + {"ATmega3208", "m3208"}, + {"ATmega3209", "m3209"}, + {"ATmega323", "m323"}, + {"ATmega324", "m324"}, + {"ATmega324A", "m324a"}, + {"ATmega324P", "m324p"}, + {"ATmega324PA", "m324pa"}, + {"ATmega324PB", "m324pb"}, + {"ATmega325", "m325"}, + {"ATmega3250", "m3250"}, + {"ATmega3250A", "m3250a"}, + {"ATmega3250P", "m3250p"}, + {"ATmega3250PA", "m3250pa"}, + {"ATmega325A", "m325a"}, + {"ATmega325P", "m325p"}, + {"ATmega325PA", "m325pa"}, + {"ATmega328", "m328"}, + {"ATmega328P", "m328p"}, + {"ATmega328PB", "m328pb"}, + {"ATmega329", "m329"}, + {"ATmega3290", "m3290"}, + {"ATmega3290A", "m3290a"}, + {"ATmega3290P", "m3290p"}, + {"ATmega3290PA", "m3290pa"}, + {"ATmega329A", "m329a"}, + {"ATmega329P", "m329p"}, + {"ATmega329PA", "m329pa"}, + {"ATmega32A", "m32a"}, + {"ATmega32C1", "m32c1"}, + {"ATmega32HVB", "m32hvb"}, + {"ATmega32M1", "m32m1"}, + {"ATmega32U2", "m32u2"}, + {"ATmega32U4", "m32u4"}, + {"ATmega32U6", "m32u6"}, + {"ATmega406", "m406"}, + {"ATmega48", "m48"}, + {"ATmega4808", "m4808"}, + {"ATmega4809", "m4809"}, + {"ATmega48A", "m48a"}, + {"ATmega48HVF", "m48hvf"}, + {"ATmega48P", "m48p"}, + {"ATmega48PA", "m48pa"}, + {"ATmega48PB", "m48pb"}, + {"ATmega4HVD", "m4hvd"}, + {"ATmega603", "m603"}, + {"ATmega64", "m64"}, + {"ATmega640", "m640"}, + {"ATmega644", "m644"}, + {"ATmega644A", "m644a"}, + {"ATmega644P", "m644p"}, + {"ATmega644PA", "m644pa"}, + {"ATmega644RFR2", "m644rfr2"}, + {"ATmega645", "m645"}, + {"ATmega6450", "m6450"}, + {"ATmega6450A", "m6450a"}, + {"ATmega6450P", "m6450p"}, + {"ATmega645A", "m645a"}, + {"ATmega645P", "m645p"}, + {"ATmega649", "m649"}, + {"ATmega6490", "m6490"}, + {"ATmega6490A", "m6490a"}, + {"ATmega6490P", "m6490p"}, + {"ATmega649A", "m649a"}, + {"ATmega649P", "m649p"}, + {"ATmega64A", "m64a"}, + {"ATmega64C1", "m64c1"}, + {"ATmega64HVE", "m256rfa2"}, + {"ATmega64HVE", "m64hve"}, + {"ATmega64HVE2", "m64hve2"}, + {"ATmega64M1", "m64m1"}, + {"ATmega64RFA2", "m64rfa2"}, + {"ATmega64RFR2", "m64rfr2"}, + {"ATmega8", "m8"}, + {"ATmega808", "m808"}, + {"ATmega809", "m809"}, + {"ATmega83", "m83"}, + {"ATmega8515", "m8515"}, + {"ATmega8535", "m8535"}, + {"ATmega88", "m88"}, + {"ATmega88A", "m88a"}, + {"ATmega88P", "m88p"}, + {"ATmega88PA", "m88pa"}, + {"ATmega88PB", "m88pb"}, + {"ATmega8A", "m8a"}, + {"ATmega8HVA", "m8hva"}, + {"ATmega8HVD", "m8hvd"}, + {"ATmega8U2", "m8u2"}, + {"ATtiny10", "tiny10"}, + {"ATtiny102", "tiny102"}, + {"ATtiny104", "tiny104"}, + {"ATtiny11", "tiny11"}, + {"ATtiny12", "tiny12"}, + {"ATtiny13", "tiny13"}, + {"ATtiny13A", "tiny13a"}, + {"ATtiny15", "tiny15"}, + {"ATtiny1604", "tiny1604"}, + {"ATtiny1606", "tiny1606"}, + {"ATtiny1607", "tiny1607"}, + {"ATtiny1614", "tiny1614"}, + {"ATtiny1616", "tiny1616"}, + {"ATtiny1617", "tiny1617"}, + {"ATtiny1634", "tiny1634"}, + {"ATtiny167", "tiny167"}, + {"ATtiny20", "tiny20"}, + {"ATtiny202", "tiny202"}, + {"ATtiny204", "tiny204"}, + {"ATtiny212", "tiny212"}, + {"ATtiny214", "tiny214"}, + {"ATtiny22", "tiny22"}, + {"ATtiny2313", "tiny2313"}, + {"ATtiny2313A", "tiny2313a"}, + {"ATtiny23U", "tiny23u"}, + {"ATtiny24", "tiny24"}, + {"ATtiny24A", "tiny24a"}, + {"ATtiny25", "tiny25"}, + {"ATtiny26", "tiny26"}, + {"ATtiny261", "tiny261"}, + {"ATtiny261A", "tiny261a"}, + {"ATtiny28", "tiny28"}, + {"ATtiny3214", "tiny3214"}, + {"ATtiny3216", "tiny3216"}, + {"ATtiny3217", "tiny3217"}, + {"ATtiny4", "tiny4"}, + {"ATtiny40", "tiny40"}, + {"ATtiny402", "tiny402"}, + {"ATtiny404", "tiny404"}, + {"ATtiny406", "tiny406"}, + {"ATtiny412", "tiny412"}, + {"ATtiny414", "tiny414"}, + {"ATtiny416", "tiny416"}, + {"ATtiny417", "tiny417"}, + {"ATtiny4313", "tiny4313"}, + {"ATtiny43U", "tiny43u"}, + {"ATtiny44", "tiny44"}, + {"ATtiny441", "tiny441"}, + {"ATtiny44A", "tiny44a"}, + {"ATtiny45", "tiny45"}, + {"ATtiny461", "tiny461"}, + {"ATtiny461A", "tiny461a"}, + {"ATtiny474", "tiny474"}, + {"ATtiny48", "tiny48"}, + {"ATtiny5", "tiny5"}, + {"ATtiny80", "tiny80"}, + {"ATtiny804", "tiny804"}, + {"ATtiny806", "tiny806"}, + {"ATtiny807", "tiny807"}, + {"ATtiny80_pre_2015", "tiny80_pre_2015"}, + {"ATtiny814", "tiny814"}, + {"ATtiny816", "tiny816"}, + {"ATtiny817", "tiny817"}, + {"ATtiny828", "tiny828"}, + {"ATtiny84", "tiny84"}, + {"ATtiny840", "tiny840"}, + {"ATtiny841", "tiny841"}, + {"ATtiny84A", "tiny84a"}, + {"ATtiny85", "tiny85"}, + {"ATtiny861", "tiny861"}, + {"ATtiny861A", "tiny861a"}, + {"ATtiny87", "tiny87"}, + {"ATtiny88", "tiny88"}, + {"ATtiny9", "tiny9"}, + {"ATxmega128A1", "xm128a1"}, + {"ATxmega128A1U", "xm128a1u"}, + {"ATxmega128A3", "xm128a3"}, + {"ATxmega128A3U", "xm128a3u"}, + {"ATxmega128A4", "xm128a4"}, + {"ATxmega128A4U", "xm128a4u"}, + {"ATxmega128B1", "xm128b1"}, + {"ATxmega128B3", "xm128b3"}, + {"ATxmega128C3", "xm128c3"}, + {"ATxmega128D3", "xm128d3"}, + {"ATxmega128D4", "xm128d4"}, + {"ATxmega16A4", "xm16a4"}, + {"ATxmega16A4U", "xm16a4u"}, + {"ATxmega16C4", "xm16c4"}, + {"ATxmega16D4", "xm16d4"}, + {"ATxmega16E5", "xm16e5"}, + {"ATxmega192A1", "xm192a1"}, + {"ATxmega192A3", "xm192a3"}, + {"ATxmega192A3U", "xm192a3u"}, + {"ATxmega192C3", "xm192c3"}, + {"ATxmega192D3", "xm192d3"}, + {"ATxmega256A1", "xm256a1"}, + {"ATxmega256A3", "xm256a3"}, + {"ATxmega256A3B", "xm256a3b"}, + {"ATxmega256A3BU", "xm256a3bu"}, + {"ATxmega256A3U", "xm256a3u"}, + {"ATxmega256B1", "xm256b1"}, + {"ATxmega256C3", "xm256c3"}, + {"ATxmega256D3", "xm256d3"}, + {"ATxmega32A4", "xm32a4"}, + {"ATxmega32A4U", "xm32a4u"}, + {"ATxmega32C3", "xm32c3"}, + {"ATxmega32C4", "xm32c4"}, + {"ATxmega32D3", "xm32d3"}, + {"ATxmega32D4", "xm32d4"}, + {"ATxmega32D4P", "xm32d4p"}, + {"ATxmega32E5", "xm32e5"}, + {"ATxmega32X1", "xm32x1"}, + {"ATxmega384A1", "xm384a1"}, + {"ATxmega384C3", "xm384c3"}, + {"ATxmega384D3", "xm384d3"}, + {"ATxmega64A1", "xm64a1"}, + {"ATxmega64A1U", "xm64a1u"}, + {"ATxmega64A3", "xm64a3"}, + {"ATxmega64A3U", "xm64a3u"}, + {"ATxmega64A4", "xm64a4"}, + {"ATxmega64A4U", "xm64a4u"}, + {"ATxmega64B1", "xm64b1"}, + {"ATxmega64B3", "xm64b3"}, + {"ATxmega64C3", "xm64c3"}, + {"ATxmega64D3", "xm64d3"}, + {"ATxmega64D4", "xm64d4"}, + {"ATxmega8E5", "xm8e5"}, + {"M3000", "m3000"}, + {"MaxBSE", "maxbse"}, +}; + +// Target page options. + +struct TargetPageOptions final +{ + enum MemoryModel { + TinyModel, + SmallModel, + LargeModel, + HugeModel + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target MCU record. + const QString mcuValue = IarewUtils::flagValue( + flags, QStringLiteral("--cpu")).toLower(); + targetMcu = mcuStringFromFlagValue(mcuValue); + // Detect target memory model. + const QString modelValue = IarewUtils::flagValue( + flags, QStringLiteral("-m")); + if (modelValue == QLatin1Char('t')) + memoryModel = TargetPageOptions::TinyModel; + else if (modelValue == QLatin1Char('s')) + memoryModel = TargetPageOptions::SmallModel; + else if (modelValue == QLatin1Char('l')) + memoryModel = TargetPageOptions::LargeModel; + else if (modelValue == QLatin1Char('h')) + memoryModel = TargetPageOptions::HugeModel; + // Detect target EEPROM util size. + eepromUtilSize = IarewUtils::flagValue( + flags, QStringLiteral("--eeprom_size")).toInt(); + } + + static QString mcuStringFromFlagValue(const QString &mcuValue) + { + const auto targetBegin = std::cbegin(mcusDict); + const auto targetEnd = std::cend(mcusDict); + const auto targetIt = std::find_if(targetBegin, targetEnd, + [mcuValue]( + const TargetMcuEntry &entry) { + return entry.targetFlag == mcuValue.toLatin1(); + }); + if (targetIt != targetEnd) { + return QStringLiteral("%1\t%2") + .arg(QString::fromLatin1(targetIt->targetFlag), + QString::fromLatin1(targetIt->targetName)); + } + return {}; + } + + QString targetMcu; + MemoryModel memoryModel = TinyModel; + int eepromUtilSize = 0; +}; + +// System page options. + +struct SystemPageOptions final +{ + explicit SystemPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags"), + QStringLiteral("defines")}); + cstackSize = IarewUtils::flagValue( + flags, QStringLiteral("_..X_CSTACK_SIZE")).toInt(); + rstackSize = IarewUtils::flagValue( + flags, QStringLiteral("_..X_RSTACK_SIZE")).toInt(); + } + + int cstackSize = 0; + int rstackSize = 0; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter = 0, + PrintfFullFormatter = 1, + PrintfFullNoMultibytesFormatter = 2, + PrintfLargeFormatter = 3, + PrintfLargeNoMultibytesFormatter = 4, + PrintfSmallFormatter = 6, + PrintfSmallNoMultibytesFormatter = 7, + PrintfTinyFormatter = 8 + }; + + enum ScanfFormatter { + ScanfAutoFormatter = 0, + ScanfFullFormatter = 1, + ScanfFullNoMultibytesFormatter = 2, + ScanfLargeFormatter = 3, + ScanfLargeNoMultibytesFormatter = 4, + ScanfSmallFormatter = 6, + ScanfSmallNoMultibytesFormatter = 7 + }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (const QString &flag : flags) { + if (flag.endsWith(QLatin1String("_printf"), Qt::CaseInsensitive)) { + const QString prop = flag.split(QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("-e_printffull")) + printfFormatter = LibraryOptionsPageOptions::PrintfFullFormatter; + else if (prop == QLatin1String("-e_printffullnomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfFullNoMultibytesFormatter; + else if (prop == QLatin1String("-e_printflarge")) + printfFormatter = LibraryOptionsPageOptions::PrintfLargeFormatter; + else if (prop == QLatin1String("-e_printflargenomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfLargeNoMultibytesFormatter; + else if (prop == QLatin1String("-e_printfsmall")) + printfFormatter = LibraryOptionsPageOptions::PrintfSmallFormatter; + else if (prop == QLatin1String("-e_printfsmallnomb")) + printfFormatter = LibraryOptionsPageOptions::PrintfSmallNoMultibytesFormatter; + else if (prop == QLatin1String("-printftiny")) + printfFormatter = LibraryOptionsPageOptions::PrintfTinyFormatter; + } else if (flag.endsWith(QLatin1String("_scanf"), Qt::CaseInsensitive)) { + const QString prop = flag.split(QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("-e_scanffull")) + scanfFormatter = LibraryOptionsPageOptions::ScanfFullFormatter; + else if (prop == QLatin1String("-e_scanffullnomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfFullNoMultibytesFormatter; + else if (prop == QLatin1String("-e_scanflarge")) + scanfFormatter = LibraryOptionsPageOptions::ScanfLargeFormatter; + else if (prop == QLatin1String("-e_scanflargenomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfLargeNoMultibytesFormatter; + else if (prop == QLatin1String("-e_scanfsmall")) + scanfFormatter = LibraryOptionsPageOptions::ScanfSmallFormatter; + else if (prop == QLatin1String("-e_scanfsmallnomb")) + scanfFormatter = LibraryOptionsPageOptions::ScanfSmallNoMultibytesFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalDlibLibrary, + FullDlibLibrary, + CustomDlibLibrary, + ClibLibrary, + CustomClibLibrary, + ThirdPartyLibrary + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QStringList libraryPaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + const auto libraryBegin = libraryPaths.cbegin(); + const auto libraryEnd = libraryPaths.cend(); + + if (flags.contains(QLatin1String("--dlib"))) { + const QString dlibToolkitPath = + IarewUtils::dlibToolkitRootPath(qbsProduct); + const QFileInfo configInfo(IarewUtils::flagValue( + flags, + QStringLiteral("--dlib_config"))); + const QString configFilePath = configInfo.absoluteFilePath(); + if (configFilePath.startsWith(dlibToolkitPath, + Qt::CaseInsensitive)) { + if (configFilePath.endsWith(QLatin1String("-n.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalDlibLibrary; + } else if (configFilePath.endsWith(QLatin1String("-f.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::FullDlibLibrary; + } else { + libraryType = LibraryConfigPageOptions::CustomDlibLibrary; + } + + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, configFilePath); + + // Find dlib library inside of IAR toolkit directory. + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [dlibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(dlibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that dlib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } + } else { + // This means that dlib library is 'custom' + // (but we don't know its path). + libraryType = LibraryConfigPageOptions::CustomDlibLibrary; + configPath = IarewUtils::projectRelativeFilePath( + baseDirectory, configFilePath); + } + } else if (flags.contains(QLatin1String("--clib"))) { + const QString clibToolkitPath = + IarewUtils::clibToolkitRootPath(qbsProduct); + // Find clib library inside of IAR toolkit directory. + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [clibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(clibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that clib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryType = LibraryConfigPageOptions::ClibLibrary; + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } else { + // This means that clib library is 'custom' + // (but we don't know its path). + libraryType = LibraryConfigPageOptions::CustomClibLibrary; + } + } else { + libraryType = LibraryConfigPageOptions::NoLibrary; + } + } + + RuntimeLibrary libraryType = NoLibrary; + QString configPath; + QString libraryPath; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +} // namespace + +// AvrGeneralSettingsGroup + +AvrGeneralSettingsGroup::AvrGeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildSystemPage(qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void AvrGeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'GenDeviceSelectMenu' item + // (Processor configuration chooser). + addOptionsGroup(QByteArrayLiteral("GenDeviceSelectMenu"), + {opts.targetMcu}); + // Add 'Variant Memory' item + // (Memory model: tiny/small/large/huge). + addOptionsGroup(QByteArrayLiteral("Variant Memory"), + {opts.memoryModel}); + // Add 'GGEepromUtilSize' item + // (Utilize inbuilt EEPROM size, in bytes). + addOptionsGroup(QByteArrayLiteral("GGEepromUtilSize"), + {opts.eepromUtilSize}); +} + +void AvrGeneralSettingsGroup::buildSystemPage( + const ProductData &qbsProduct) +{ + const SystemPageOptions opts (qbsProduct); + // Add 'SCCStackSize' item (Data stack + // - CSTACK size in bytes). + addOptionsGroup(QByteArrayLiteral("SCCStackSize"), + {opts.cstackSize}); + // Add 'SCRStackSize' item (Return address stack + // - RSTACK depth in bytes). + addOptionsGroup(QByteArrayLiteral("SCRStackSize"), + {opts.rstackSize}); +} + +void AvrGeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const LibraryOptionsPageOptions opts(qbsProduct); + // Add 'Output variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Output variant"), + {opts.printfFormatter}); + // Add 'Input variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Input variant"), + {opts.scanfFormatter}); +} + +void AvrGeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GRuntimeLibSelect' and 'GRuntimeLibSelectSlave' items + // (Link with runtime: none/dlib/clib/etc). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelect"), + {opts.libraryType}); + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelectSlave"), + {opts.libraryType}); + // Add 'RTConfigPath' item (Runtime configuration file). + addOptionsGroup(QByteArrayLiteral("RTConfigPath"), + {opts.configPath}); + // Add 'RTLibraryPath' item (Runtime library file). + addOptionsGroup(QByteArrayLiteral("RTLibraryPath"), + {opts.libraryPath}); +} + +void AvrGeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {opts.binaryType}); + // Add 'ExePath' item (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {opts.binaryDirectory}); + // Add 'ObjPath' item (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {opts.objectDirectory}); + // Add 'ListPath' item (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {opts.listingDirectory}); +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h new file mode 100644 index 00000000..5411eeae --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrgeneralsettingsgroup_v7.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRGENERALSETTINGSGROUP_V7_H +#define QBS_IAREWAVRGENERALSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrGeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrGeneralSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildSystemPage(const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRGENERALSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp new file mode 100644 index 00000000..0af4f088 --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.cpp @@ -0,0 +1,387 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "avrlinkersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +constexpr int kLinkerArchiveVersion = 3; +constexpr int kLinkerDataVersion = 16; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '-f' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("-f")); + for (const QVariant &configPathValue : configPathValues) { + const QString fullConfigPath = configPathValue.toString(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } + } + + // Add libraries search paths. + const QStringList libraryPaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + for (const QString &libraryPath : libraryPaths) { + const QFileInfo libraryPathInfo(libraryPath); + const QString fullLibrarySearchPath = + libraryPathInfo.absoluteFilePath(); + if (fullLibrarySearchPath.startsWith(toolkitPath, + Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } + } + + // Add static libraries paths. + const QStringList staticLibrariesProps = + gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + for (const QString &staticLibrary : staticLibrariesProps) { + const QFileInfo staticLibraryInfo(staticLibrary); + if (staticLibraryInfo.isAbsolute()) { + const QString fullStaticLibraryPath = + staticLibraryInfo.absoluteFilePath(); + if (fullStaticLibraryPath.startsWith(toolkitPath, + Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullStaticLibraryPath); + staticLibraries.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullStaticLibraryPath); + staticLibraries.push_back(path); + } + } else { + staticLibraries.push_back(staticLibrary); + } + } + + // Add static libraries from product dependencies. + for (const ProductData &qbsProductDep : qbsProductDeps) { + const QString depBinaryPath = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, + qbsProductDep); + staticLibraries.push_back(depBinaryPath); + } + } + + QVariantList configFilePaths; + QVariantList librarySearchPaths; + QVariantList staticLibraries; + QString entryPoint; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = gen::utils::targetBinary(qbsProduct); + } + + QString outputFile; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { + NoListing, + GenerateListing + }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = NoListing; +}; + +// Define page options. + +struct DefinePageOptions final +{ + explicit DefinePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + // Enumerate all linker defines. + for (const QString &flag : flags) { + if (!flag.startsWith(QLatin1String("-D"))) + continue; + const auto symbol = flag.mid(2); + // Ignore system-defined macroses. + if (symbol.startsWith(QLatin1String("_..X_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_TINY_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_NEAR_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_FAR_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_HUGE_HEAP_SIZE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_SIZE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_SIZE")) + || symbol.startsWith(QLatin1String("_..X_FLASH_CODE_END")) + || symbol.startsWith(QLatin1String("_..X_FLASH_BASE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_CSTACK_END")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_END")) + || symbol.startsWith(QLatin1String("_..X_EXT_SRAM_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_SRAM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_EXT_ROM_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_ROM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_EXT_NV_BASE")) + || symbol.startsWith(QLatin1String("_..X_EXT_NV_SIZE")) + || symbol.startsWith(QLatin1String("_..X_SRAM_BASE")) + || symbol.startsWith(QLatin1String("_..X_SRAM_SIZE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_BASE")) + || symbol.startsWith(QLatin1String("_..X_RSTACK_SIZE")) + ) { + continue; + } + defineSymbols.push_back(symbol); + } + } + + QVariantList defineSymbols; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + suppressAllWarnings = (warningLevel == QLatin1String("none")); + } + + int suppressAllWarnings = 0; +}; + +} // namespace + +// AvrLinkerSettingsGroup + +AvrLinkerSettingsGroup::AvrLinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + setName(QByteArrayLiteral("XLINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct, qbsProductDeps); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + buildDiagnosticsPage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void AvrLinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct, qbsProductDeps); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add 'XclOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XclOverride"), + {1}); + // Add 'XclFile' item (Linke configuration file). + addOptionsGroup(QByteArrayLiteral("XclFile"), + {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("-f ") + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } + + if (opts.staticLibraries.count() > 0) + m_extraOptions << opts.staticLibraries; + + if (!opts.entryPoint.isEmpty()) { + // Add 'xcProgramEntryLabel' item (Entry symbol). + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabel"), + {opts.entryPoint}); + // Add 'xcOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("xcOverrideProgramEntryLabel"), + {1}); + // Add 'xcProgramEntryLabelSelect' item. + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabelSelect"), + {0}); + } + + // Add 'XIncludes' item (Libraries search paths). + addOptionsGroup(QByteArrayLiteral("XIncludes"), + opts.librarySearchPaths); +} + +void AvrLinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'XOutOverride' item (Override default output file). + addOptionsGroup(QByteArrayLiteral("XOutOverride"), + {1}); + // Add 'OutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {opts.outputFile}); +} + +void AvrLinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'XList' item (Generate linker listing). + addOptionsGroup(QByteArrayLiteral("XList"), + {opts.generateMap}); +} + +void AvrLinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const DefinePageOptions opts(qbsProduct); + // Add 'XDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("XDefines"), + opts.defineSymbols); +} + +void AvrLinkerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'SuppressAllWarn' item (Suppress all warnings). + addOptionsGroup(QByteArrayLiteral("SuppressAllWarn"), + {opts.suppressAllWarnings}); +} + +void AvrLinkerSettingsGroup::buildExtraOptionsPage(const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + if (!m_extraOptions.isEmpty()) { + // Add 'XExtraOptionsCheck' (Use command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptionsCheck"), + {1}); + // Add 'XExtraOptions' item (Command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptions"), + m_extraOptions); + } +} + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h new file mode 100644 index 00000000..5427937b --- /dev/null +++ b/src/plugins/generator/iarew/archs/avr/avrlinkersettingsgroup_v7.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWAVRLINKERSETTINGSGROUP_V7_H +#define QBS_IAREWAVRLINKERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace avr { +namespace v7 { + +class AvrLinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit AvrLinkerSettingsGroup(const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + void buildOutputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildDefinePage(const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v7 +} // namespace avr +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWAVRLINKERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.cpp new file mode 100644 index 00000000..38264c65 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51archiversettingsgroup_v10.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +constexpr int kArchiverArchiveVersion = 2; +constexpr int kArchiverDataVersion = 1; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +// Mcs51ArchiverSettingsGroup + +Mcs51ArchiverSettingsGroup::Mcs51ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XAR")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void Mcs51ArchiverSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'XAROverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XAROverride"), + {1}); + // Add 'XAROutput2' item (Output filename). + addOptionsGroup(QByteArrayLiteral("XAROutput2"), + {opts.outputFile}); +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.h new file mode 100644 index 00000000..21c66433 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51archiversettingsgroup_v10.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51ARCHIVERSETTINGSGROUP_V10_H +#define QBS_IAREWMCS51ARCHIVERSETTINGSGROUP_V10_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51ArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Mcs51ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51ARCHIVERSETTINGSGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.cpp new file mode 100644 index 00000000..a840b29c --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.cpp @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51assemblersettingsgroup_v10.h" + +//#include "../../iarewproperty.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +constexpr int kAssemblerArchiveVersion = 2; +constexpr int kAssemblerDataVersion = 6; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = flags.contains(QLatin1String("-s+")); + enableMultibyteSupport = flags.contains(QLatin1String("-n")); + + if (flags.contains(QLatin1String("-M<>"))) + macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote; + else if (flags.contains(QLatin1String("-M()"))) + macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote; + else if (flags.contains(QLatin1String("-M[]"))) + macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote; + else if (flags.contains(QLatin1String("-M{}"))) + macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote; + } + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; + int enableSymbolsCaseSensitive = 0; + int enableMultibyteSupport = 0; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const auto &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (warningLevel == QLatin1String("all")) { + enableWarnings = 0; + enableAllWarnings = 0; + } else if (warningLevel == QLatin1String("none")) { + enableWarnings = 1; + enableAllWarnings = 0; + } else { + enableWarnings = 0; + enableAllWarnings = 1; + } + } + + int enableWarnings = 0; + int enableAllWarnings = 0; +}; + +} // namespace + +// Mcs51AssemblerSettingsGroup + +Mcs51AssemblerSettingsGroup::Mcs51AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("A8051")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Mcs51AssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {opts.enableSymbolsCaseSensitive}); + // Add 'Asm multibyte support' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("Asm multibyte support"), + {opts.enableMultibyteSupport}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {!opts.macroQuoteCharacter}, 0); +} + +void Mcs51AssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'Debug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("Debug"), + {opts.debugInfo}); +} + +void Mcs51AssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + opts.defineSymbols); + // Add 'Include directories' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("Include directories"), + opts.includePaths); +} + +void Mcs51AssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'AWarnEnable' item (Enable/disable warnings). + addOptionsGroup(QByteArrayLiteral("AWarnEnable"), + {opts.enableWarnings}); + // Add 'AWarnWhat' item (Enable/disable all warnings). + addOptionsGroup(QByteArrayLiteral("AWarnWhat"), + {opts.enableAllWarnings}); +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.h new file mode 100644 index 00000000..bb9f4b61 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51assemblersettingsgroup_v10.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51ASSEMBLERSETTINGSGROUP_V10_H +#define QBS_IAREWMCS51ASSEMBLERSETTINGSGROUP_V10_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51AssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Mcs51AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildLanguagePage(const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51ASSEMBLERSETTINGSGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.cpp new file mode 100644 index 00000000..ba86bc54 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51archiversettingsgroup_v10.h" +#include "mcs51assemblersettingsgroup_v10.h" +#include "mcs51buildconfigurationgroup_v10.h" +#include "mcs51compilersettingsgroup_v10.h" +#include "mcs51generalsettingsgroup_v10.h" +#include "mcs51linkersettingsgroup_v10.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +Mcs51BuildConfigurationGroup::Mcs51BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("8051"); + + // Append debug info item. + const int debugBuild = gen::utils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool Mcs51BuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Mcs51 + && version.majorVersion() == 10; +} + +std::unique_ptr +Mcs51BuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new Mcs51BuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.h new file mode 100644 index 00000000..edd16d5d --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51buildconfigurationgroup_v10.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51BUILDCONFIGURATIONGROUP_V10_H +#define QBS_IAREWMCS51BUILDCONFIGURATIONGROUP_V10_H + +#include + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51BuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit Mcs51BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class Mcs51BuildConfigurationGroupFactory; +}; + +class Mcs51BuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51BUILDCONFIGURATIONGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.cpp new file mode 100644 index 00000000..649350a9 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.cpp @@ -0,0 +1,476 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51compilersettingsgroup_v10.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +constexpr int kCompilerArchiveVersion = 7; +constexpr int kCompilerDataVersion = 12; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + enum ModuleType { + ProgramModule, + LibraryModule + }; + + explicit OutputPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + moduleType = flags.contains(QLatin1String("--library_module")) + ? OutputPageOptions::LibraryModule + : OutputPageOptions::ProgramModule; + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; + ModuleType moduleType = ProgramModule; +}; + +// Language one page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C99LanguageDialect + }; + + enum CxxLanguageDialect { + EmbeddedCPlusPlus, + ExtendedEmbeddedCPlusPlus + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // C language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + cLanguageDialect = cLanguageVersion.contains(QLatin1String("c89")) + ? LanguageOnePageOptions::C89LanguageDialect + : LanguageOnePageOptions::C99LanguageDialect; + // C++ language dialect. + if (flags.contains(QLatin1String("--ec++"))) + cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus; + else if (flags.contains(QLatin1String("--eec++"))) + cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus; + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + + allowVla = flags.contains(QLatin1String("--vla")); + useCppInlineSemantics = flags.contains( + QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains( + QLatin1String("--require_prototypes")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C89LanguageDialect; + CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus; + LanguageConformance languageConformance = AllowIarExtension; + int allowVla = 0; + int useCppInlineSemantics = 0; + int requirePrototypes = 0; + int destroyStaticObjects = 0; +}; + +// Language two page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains( + QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains( + QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + } + + PlainCharacter plainCharacter = SignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; + int enableMultibyteSupport = 0; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + // Optimizations level radio-buttons with combo-box + // on "level" widget. + enum Strategy { + StrategyBalanced, + StrategySize, + StrategySpeed + }; + + enum Level { + LevelNone, + LevelLow, + LevelMedium, + LevelHigh + }; + + enum LevelSlave { + LevelSlave0, + LevelSlave1, + LevelSlave2, + LevelSlave3 + }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableLoopUnroll = !flags.contains(QLatin1String("--no_unroll")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + enableCrossCall = !flags.contains(QLatin1String("--no_cross_call")); + disableRegisterBanks = flags.contains( + QLatin1String("--disable_register_banks")); + + disableSizeConstrains = flags.contains( + QLatin1String("--no_size_constraints")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Seven bit-field flags on "enabled transformations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableLoopUnroll = 0; // Loop unrolling. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. + int enableCrossCall = 0; // Cross call optimization. + int disableRegisterBanks = 0; // Disabled register banks. + int disableSizeConstrains = 0; // No size constraints. +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + // TODO: Need to exclude the pre-defined maroses which are handled + // in 'General Options'. + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + const QString dlibToolkitPath = IarewUtils::dlibToolkitRootPath(qbsProduct); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + // Exclude dlib config includes because it already handled in + // 'General Options->Library configuration page'. + if (includeFilePath.startsWith(dlibToolkitPath)) + continue; + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + paddingForRomMonitorBreakpoints = flags.contains( + QLatin1String("--rom_mon_bp_padding")); + excludeUbrofMessagesInOutput = flags.contains( + QLatin1String("--no_ubrof_messages")); + } + + int paddingForRomMonitorBreakpoints = 0; + int excludeUbrofMessagesInOutput = 0; +}; + +} // namespace + +// Mcs51CompilerSettingsGroup + +Mcs51CompilerSettingsGroup::Mcs51CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICC8051")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Mcs51CompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {opts.debugInfo}); + // Add 'CCOverrideModuleTypeDefault' item + // (Override default module type). + addOptionsGroup(QByteArrayLiteral("CCOverrideModuleTypeDefault"), + {1}); + // Add 'CCRadioModuleType' item (Module type: program/library). + addOptionsGroup(QByteArrayLiteral("CCRadioModuleType"), + {opts.moduleType}); +} + +void Mcs51CompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {opts.cLanguageDialect}); + // Add 'IccCppDialect' item (C++ dialect: embedded/extended). + addOptionsGroup(QByteArrayLiteral("IccCppDialect"), + {opts.cxxLanguageDialect}); + // Add 'CCExt' item (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("LangConform"), + {opts.languageConformance}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {opts.useCppInlineSemantics}); + // Add 'CCRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {opts.destroyStaticObjects}); +} + +void Mcs51CompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'CharIs' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("CharIs"), + {opts.plainCharacter}); + // Add 'IccFloatSemantics' item + // (Floatic-point semantics: strict/relaxed conformance). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {opts.floatingPointSemantic}); + // Add 'CCMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("CCMultibyteSupport"), + {opts.enableMultibyteSupport}); +} + +void Mcs51CompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'CCOptStrategy', 'CCOptLevel' and + // 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("CCOptStrategy"), + {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("CCOptLevel"), + {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("CCOptLevelSlave"), + {opts.optimizationLevelSlave}); + // Add 'CCAllowList2' item (Enabled transformations: 7 check boxes). + const QString transformations = QStringLiteral("%1%2%3%4%5%6%7") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableLoopUnroll) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableTypeBasedAliasAnalysis) + .arg(opts.enableCrossCall) + .arg(opts.disableRegisterBanks); + addOptionsGroup(QByteArrayLiteral("CCAllowList2"), + {transformations}); + // Add 'NoSizeConstraints' item (No size constraints). + addOptionsGroup(QByteArrayLiteral("NoSizeConstraints"), + {opts.disableSizeConstrains}); +} + +void Mcs51CompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'CCDefines' item (Defines symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + opts.defineSymbols); + // Add 'CCIncludePath2' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("CCIncludePath2"), + opts.includePaths); +} + +void Mcs51CompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"), + {opts.warningsAsErrors}); +} + +void Mcs51CompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const CodePageOptions opts(qbsProduct); + // Add 'RomMonBpPadding' item (Padding for ROM-monitor breakpoints). + addOptionsGroup(QByteArrayLiteral("RomMonBpPadding"), + {opts.paddingForRomMonitorBreakpoints}); + // Add 'NoUBROFMessages' item (No UBROF messages in output files). + addOptionsGroup(QByteArrayLiteral("NoUBROFMessages"), + {opts.excludeUbrofMessagesInOutput}); +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.h new file mode 100644 index 00000000..e68a7628 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51compilersettingsgroup_v10.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51COMPILERSETTINGSGROUP_V10_H +#define QBS_IAREWMCS51COMPILERSETTINGSGROUP_V10_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51CompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Mcs51CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const ProductData &qbsProduct); + void buildLanguageOnePage(const ProductData &qbsProduct); + void buildLanguageTwoPage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildCodePage(const ProductData &qbsProduct); +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51COMPILERSETTINGSGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.cpp new file mode 100644 index 00000000..b0c4b936 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.cpp @@ -0,0 +1,1013 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51generalsettingsgroup_v10.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +constexpr int kGeneralArchiveVersion = 4; +constexpr int kGeneralDataVersion = 9; + +namespace { + +// Target page options. + +struct TargetPageOptions final +{ + enum CpuCore { + CorePlain = 1, + CoreExtended1, + CoreExtended2 + }; + + enum CodeModel { + CodeModelNear = 1, + CodeModelBanked, + CodeModelFar, + CodeModelBankedExtended2 + }; + + enum DataModel { + DataModelTiny = 0, + DataModelSmall, + DataModelLarge, + DataModelGeneric, + DataModelFarGeneric, + DataModelFar + }; + + enum ConstantsMemoryPlacement { + RamMemoryPlace = 0, + RomMemoryPlace, + CodeMemoryPlace + }; + + enum CallingConvention { + DataOverlayConvention = 0, + IDataOverlayConvention, + IDataReentrantConvention, + PDataReentrantConvention, + XDataReentrantConvention, + ExtendedStackReentrantConvention + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + chipInfoPath = detectChipInfoPath(qbsProduct); + + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + // Should be parsed before the 'code_model' and + // 'data_model' options, as that options are depends on it. + const QString core = IarewUtils::flagValue( + flags, QStringLiteral("--core")) + .toLower(); + if (core == QLatin1String("plain")) { + cpuCore = TargetPageOptions::CorePlain; + } else if (core == QLatin1String("extended1")) { + cpuCore = TargetPageOptions::CoreExtended1; + } else if (core == QLatin1String("extended2")) { + cpuCore = TargetPageOptions::CoreExtended2; + } else { + // If the core variant is not set, then choose the + // default values (see the compiler datasheet for + // '--core' option). + cpuCore = TargetPageOptions::CorePlain; + } + + const QString cm = IarewUtils::flagValue( + flags, QStringLiteral("--code_model")) + .toLower(); + if (cm == QLatin1String("near")) { + codeModel = TargetPageOptions::CodeModelNear; + } else if (cm == QLatin1String("banked")) { + codeModel = TargetPageOptions::CodeModelBanked; + } else if (cm == QLatin1String("far")) { + codeModel = TargetPageOptions::CodeModelFar; + } else if (cm == QLatin1String("banked_ext2")) { + codeModel = TargetPageOptions::CodeModelBankedExtended2; + } else { + // If the code model is not set, then choose the + // default values (see the compiler datasheet for + // '--code_model' option). + if (cpuCore == TargetPageOptions::CorePlain) + codeModel = TargetPageOptions::CodeModelNear; + else if (cpuCore == TargetPageOptions::CoreExtended1) + codeModel = TargetPageOptions::CodeModelFar; + else if (cpuCore == TargetPageOptions::CoreExtended2) + codeModel = TargetPageOptions::CodeModelBankedExtended2; + } + + const QString dm = IarewUtils::flagValue( + flags, QStringLiteral("--data_model")).toLower(); + if (dm == QLatin1String("tiny")) { + dataModel = TargetPageOptions::DataModelTiny; + } else if (dm == QLatin1String("small")) { + dataModel = TargetPageOptions::DataModelSmall; + } else if (dm == QLatin1String("large")) { + dataModel = TargetPageOptions::DataModelLarge; + } else if (dm == QLatin1String("generic")) { + dataModel = TargetPageOptions::DataModelGeneric; + } else if (dm == QLatin1String("far_generic")) { + dataModel = TargetPageOptions::DataModelFarGeneric; + } else if (dm == QLatin1String("far")) { + dataModel = TargetPageOptions::DataModelFar; + } else { + // If the data model is not set, then choose the + // default values (see the compiler datasheet for + // '--data_model' option). + if (cpuCore == TargetPageOptions::CorePlain) + dataModel = TargetPageOptions::DataModelSmall; + else if (cpuCore == TargetPageOptions::CoreExtended1) + dataModel = TargetPageOptions::DataModelFar; + else if (cpuCore == TargetPageOptions::CoreExtended2) + dataModel = TargetPageOptions::DataModelLarge; + } + + useExtendedStack = flags.contains(QLatin1String("--extended_stack")); + + const int regsCount = IarewUtils::flagValue( + flags, QStringLiteral("--nr_virtual_regs")) + .toInt(); + enum { MinVRegsCount = 8, MaxVRegsCount = 32, VRegsOffset = 8 }; + // The registers index starts with 0: 0 - means 8 registers, + // 1 - means 9 registers and etc. Any invalid values we interpret + // as a default value in 8 registers. + virtualRegisters = (regsCount < MinVRegsCount || regsCount > MaxVRegsCount) + ? 0 : (regsCount - VRegsOffset); + + const QString constPlace = IarewUtils::flagValue( + flags, QStringLiteral("--place_constants")) + .toLower(); + if (constPlace == QLatin1String("data")) { + constPlacement = TargetPageOptions::RamMemoryPlace; + } else if (constPlace == QLatin1String("data_rom")) { + constPlacement = TargetPageOptions::RomMemoryPlace; + } else if (constPlace == QLatin1String("code")) { + constPlacement = TargetPageOptions::CodeMemoryPlace; + } else { + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--place_constants' option). + constPlacement = TargetPageOptions::RamMemoryPlace; + } + + const QString cc = IarewUtils::flagValue( + flags, QStringLiteral("--calling_convention")).toLower(); + if (cc == QLatin1String("data_overlay")) { + callingConvention = TargetPageOptions::DataOverlayConvention; + } else if (cc == QLatin1String("idata_overlay")) { + callingConvention = TargetPageOptions::IDataOverlayConvention; + } else if (cc == QLatin1String("idata_reentrant")) { + callingConvention = TargetPageOptions::IDataReentrantConvention; + } else if (cc == QLatin1String("pdata_reentrant")) { + callingConvention = TargetPageOptions::PDataReentrantConvention; + } else if (cc == QLatin1String("xdata_reentrant")) { + callingConvention = TargetPageOptions::XDataReentrantConvention; + } else if (cc == QLatin1String("ext_stack_reentrant")) { + callingConvention = TargetPageOptions::ExtendedStackReentrantConvention; + } else { + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--calling_convention' option). + callingConvention = TargetPageOptions::IDataReentrantConvention; + } + } + + // Trying to indirectly detect and build the chip config path, + // which uses to show a device name in "Device information" group box. + static QString detectChipInfoPath(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + + QVariantList configPaths; + + // Enumerate all product linker config files + // (which are set trough '-f' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + configPaths << IarewUtils::flagValues(flags, QStringLiteral("-f")); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const auto configPath = qbsArtifact.filePath(); + // Skip duplicates. + if (configPaths.contains(configPath)) + continue; + configPaths << qbsArtifact.filePath(); + } + } + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + for (const QVariant &configPath : qAsConst(configPaths)) { + const QString fullConfigPath = configPath.toString(); + // We interested only in a config paths shipped inside of a toolkit. + if (!fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) + continue; + // Extract the chip name from the linker script name. + const int underscoreIndex = fullConfigPath.lastIndexOf(QLatin1Char('_')); + if (underscoreIndex == -1) + continue; + const int dotIndex = fullConfigPath.lastIndexOf(QLatin1Char('.')); + if (dotIndex == -1) + continue; + if (dotIndex <= underscoreIndex) + continue; + const QString chipName = fullConfigPath.mid( + underscoreIndex + 1, + dotIndex - underscoreIndex - 1); + // Construct full chip info path. + const QFileInfo fullChipInfoPath(QFileInfo(fullConfigPath).absolutePath() + + QLatin1Char('/') + chipName + + QLatin1String(".i51")); + if (fullChipInfoPath.exists()) + return fullChipInfoPath.absoluteFilePath(); + } + + return {}; + } + + QString chipInfoPath; + CpuCore cpuCore = CorePlain; + CodeModel codeModel = CodeModelNear; + DataModel dataModel = DataModelTiny; + int useExtendedStack = 0; + int virtualRegisters = 0; + ConstantsMemoryPlacement constPlacement = RamMemoryPlace; + CallingConvention callingConvention = DataOverlayConvention; +}; + +// System page options. + +struct StackHeapPageOptions final +{ + explicit StackHeapPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList defineSymbols = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("defines")}); + const QStringList linkerFlags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags")}); + + idataStack = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_IDATA_STACK_SIZE")); + if (idataStack.isEmpty()) + idataStack = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_IDATA_STACK_SIZE")); + if (idataStack.isEmpty()) + idataStack = QLatin1String("0x40"); // Default IDATA stack size. + pdataStack = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_PDATA_STACK_SIZE")); + if (pdataStack.isEmpty()) + pdataStack = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_PDATA_STACK_SIZE")); + if (pdataStack.isEmpty()) + pdataStack = QLatin1String("0x80"); // Default PDATA stack size. + xdataStack = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_XDATA_STACK_SIZE")); + if (xdataStack.isEmpty()) + xdataStack = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_XDATA_STACK_SIZE")); + if (xdataStack.isEmpty()) + xdataStack = QLatin1String("0xEFF"); // Default XDATA stack size. + extendedStack = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_EXTENDED_STACK_SIZE")); + if (extendedStack.isEmpty()) + extendedStack = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_EXTENDED_STACK_SIZE")); + if (extendedStack.isEmpty()) + extendedStack = QLatin1String("0x3FF"); // Default EXTENDED stack size. + + xdataHeap = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_XDATA_HEAP_SIZE")); + if (xdataHeap.isEmpty()) + xdataHeap = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_XDATA_HEAP_SIZE")); + if (xdataHeap.isEmpty()) + xdataHeap = QLatin1String("0xFF"); // Default XDATA heap size. + farHeap = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_FAR_HEAP_SIZE")); + if (farHeap.isEmpty()) + farHeap = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_FAR_HEAP_SIZE")); + if (farHeap.isEmpty()) + farHeap = QLatin1String("0xFFF"); // Default FAR heap size. + far22Heap = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_FAR22_HEAP_SIZE")); + if (far22Heap.isEmpty()) + far22Heap = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_FAR22_HEAP_SIZE")); + if (far22Heap.isEmpty()) + far22Heap = QLatin1String("0xFFF"); // Default FAR22 heap size. + hugeHeap = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_HUGE_HEAP_SIZE")); + if (hugeHeap.isEmpty()) + hugeHeap = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_HUGE_HEAP_SIZE")); + if (hugeHeap.isEmpty()) + hugeHeap = QLatin1String("0xFFF"); // Default HUGE heap size. + + extStackAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?ESP")); + if (extStackAddress.isEmpty()) + extStackAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?ESP")); + if (extStackAddress.isEmpty()) + extStackAddress = QLatin1String("0x9B"); // Default extended stack pointer address. + extStackMask = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?ESP_MASK")); + if (extStackMask.isEmpty()) + extStackMask = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?ESP_MASK")); + if (extStackMask.isEmpty()) + extStackMask = QLatin1String("0x03"); // Default extended stack pointer mask. + } + + // Stack sizes. + QString idataStack; + QString pdataStack; + QString xdataStack; + QString extendedStack; + // Heap sizes. + QString xdataHeap; + QString farHeap; + QString far22Heap; + QString hugeHeap; + // Extended stack. + QString extStackAddress; + QString extStackMask; + int extStackOffset = 0; + int extStackStartAddress = 0; +}; + +// Data pointer page options. + +struct DptrPageOptions final +{ + enum DptrSize { + Dptr16, + Dptr24 + }; + + enum DptrVisibility { + DptrShadowed, + DptrSeparate + }; + + enum SwitchMethod { + DptrIncludeMethod, + DptrMaskMethod + }; + + explicit DptrPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QString core = IarewUtils::flagValue( + flags, QStringLiteral("--core")); + + const QString dptr = IarewUtils::flagValue( + flags, QStringLiteral("--dptr")); + enum ValueIndex { SizeIndex, NumbersIndex, + VisibilityIndex, SwitchMethodIndex }; + const QStringList dptrparts = dptr.split(QLatin1Char(',')); + for (auto index = 0; index < dptrparts.count(); ++index) { + const QString part = dptrparts.at(index).toLower(); + switch (index) { + case SizeIndex: + if (part == QLatin1String("16")) { + dptrSize = DptrPageOptions::Dptr16; + } else if (part == QLatin1String("24")) { + dptrSize = DptrPageOptions::Dptr24; + } else { + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--dptr' option). + if (core == QLatin1String("extended1")) + dptrSize = DptrPageOptions::Dptr24; + else + dptrSize = DptrPageOptions::Dptr16; + } + break; + case NumbersIndex: { + const int count = part.toInt(); + if (count < 1 || count > 8) { + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--dptr' option). + if (core == QLatin1String("extended1")) + dptrsCountIndex = 1; // 2 DPTR's + else + dptrsCountIndex = 0; // 1 DPTR's + } else { + dptrsCountIndex = (count - 1); // DPTR's count - 1 + } + } + break; + case VisibilityIndex: + if (part == QLatin1String("shadowed")) + dptrVisibility = DptrPageOptions::DptrShadowed; + else if (part == QLatin1String("separate")) + dptrVisibility = DptrPageOptions::DptrSeparate; + else + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--dptr' option). + dptrVisibility = DptrPageOptions::DptrSeparate; + break; + case SwitchMethodIndex: + if (part == QLatin1String("inc")) { + dptrSwitchMethod = DptrPageOptions::DptrIncludeMethod; + } else if (part.startsWith(QLatin1String("xor"))) { + dptrSwitchMethod = DptrPageOptions::DptrMaskMethod; + const int firstIndex = part.indexOf(QLatin1Char('(')); + const int lastIndex = part.indexOf(QLatin1Char(')')); + dptrMask = part.mid(firstIndex + 1, part.size() - lastIndex); + } else { + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '--dptr' option). + if (core == QLatin1String("extended1")) { + dptrSwitchMethod = DptrPageOptions::DptrIncludeMethod; + } else if (core == QLatin1String("plain")) { + dptrSwitchMethod = DptrPageOptions::DptrMaskMethod; + dptrMask = QLatin1String("0x01"); + } + } + break; + default: + break; + } + } + + const QStringList defineSymbols = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("defines")}); + const QStringList linkerFlags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags")}); + + dptrPbank = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?PBANK")); + if (dptrPbank.isEmpty()) + dptrPbank = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?PBANK")); + if (dptrPbank.isEmpty()) + dptrPbank = QLatin1String("0x93"); // Default 8-15 regs address. + dptrPbankExt = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?PBANK_EXT")); + if (dptrPbankExt.isEmpty()) + dptrPbankExt = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?PBANK_EXT")); + + dpsAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPS")); + if (dpsAddress.isEmpty()) + dpsAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPS")); + dpcAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPC")); + if (dpcAddress.isEmpty()) + dpcAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPC")); + + for (auto index = 0; index < 8; ++index) { + if (index == 0) { + QString dpxAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPX")); + if (dpxAddress.isEmpty()) + dpxAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPX")); + if (!dpxAddress.isEmpty()) + dpxAddress.prepend(QLatin1String("-D?DPX=")); + if (!dptrAddresses.contains(dpxAddress)) + dptrAddresses.push_back(dpxAddress); + } else { + QString dplAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPL%1").arg(index)); + if (dplAddress.isEmpty()) + dplAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPL%1").arg(index)); + if (!dplAddress.isEmpty()) + dplAddress.prepend(QStringLiteral("-D?DPL%1=").arg(index)); + if (!dptrAddresses.contains(dplAddress)) + dptrAddresses.push_back(dplAddress); + + QString dphAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPH%1").arg(index)); + if (dphAddress.isEmpty()) + dphAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPH%1").arg(index)); + if (!dphAddress.isEmpty()) + dphAddress.prepend(QStringLiteral("-D?DPH%1=").arg(index)); + if (!dptrAddresses.contains(dphAddress)) + dptrAddresses.push_back(dphAddress); + + QString dpxAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?DPX%1").arg(index)); + if (dpxAddress.isEmpty()) + dpxAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?DPX%1").arg(index)); + if (!dpxAddress.isEmpty()) + dpxAddress.prepend(QStringLiteral("-D?DPX%1=").arg(index)); + if (!dptrAddresses.contains(dpxAddress)) + dptrAddresses.push_back(dpxAddress); + } + } + } + + int dptrsCountIndex = 0; + DptrSize dptrSize = Dptr16; + DptrVisibility dptrVisibility = DptrShadowed; + SwitchMethod dptrSwitchMethod = DptrIncludeMethod; + QString dptrMask; + QString dptrPbank; + QString dptrPbankExt; + QString dpsAddress; + QString dpcAddress; + QStringList dptrAddresses; +}; + +// Code bank page options. + +struct CodeBankPageOptions final +{ + explicit CodeBankPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList defineSymbols = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("defines")}); + const QStringList linkerFlags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags")}); + + banksCount = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_NR_OF_BANKS")); + if (banksCount.isEmpty()) + banksCount = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_NR_OF_BANKS")); + if (banksCount.isEmpty()) + banksCount = QLatin1String("0x03"); + registerAddress = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?CBANK")); + if (registerAddress.isEmpty()) + registerAddress = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?CBANK")); + if (registerAddress.isEmpty()) + registerAddress = QLatin1String("0xF0"); + registerMask = IarewUtils::flagValue( + defineSymbols, QStringLiteral("?CBANK_MASK")); + if (registerMask.isEmpty()) + registerMask = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D?CBANK_MASK")); + if (registerMask.isEmpty()) + registerMask = QLatin1String("0xFF"); + bankStart = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_CODEBANK_START")); + if (bankStart.isEmpty()) + bankStart = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_CODEBANK_START")); + if (bankStart.isEmpty()) + bankStart = QLatin1String("0x8000"); + bankEnd = IarewUtils::flagValue( + defineSymbols, QStringLiteral("_CODEBANK_END")); + if (bankEnd.isEmpty()) + bankEnd = IarewUtils::flagValue( + linkerFlags, QStringLiteral("-D_CODEBANK_END")); + if (bankEnd.isEmpty()) + bankEnd = QLatin1String("0xFFFF"); + } + + QString banksCount; + QString registerAddress; + QString registerMask; + QString bankStart; + QString bankEnd; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter = 0, + PrintfLargeFormatter = 3, + PrintfMediumFormatter = 5, + PrintfSmallFormatter = 6 + }; + + enum ScanfFormatter { + ScanfAutoFormatter = 0, + ScanfLargeFormatter = 3, + ScanfMediumFormatter = 5 + }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (const QString &flag : flags) { + if (flag.endsWith(QLatin1String("_formatted_write"), + Qt::CaseInsensitive)) { + const QString prop = flag.split( + QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("-e_large_write")) + printfFormatter = LibraryOptionsPageOptions::PrintfLargeFormatter; + else if (prop == QLatin1String("-e_medium_write")) + printfFormatter = LibraryOptionsPageOptions::PrintfMediumFormatter; + else if (prop == QLatin1String("-e_small_write")) + printfFormatter = LibraryOptionsPageOptions::PrintfSmallFormatter; + else + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '_formatted_write' option). + printfFormatter = LibraryOptionsPageOptions::PrintfMediumFormatter; + } else if (flag.endsWith(QLatin1String("_formatted_read"), + Qt::CaseInsensitive)) { + const QString prop = flag.split(QLatin1Char('=')) + .at(0).toLower(); + if (prop == QLatin1String("-e_large_read")) + scanfFormatter = LibraryOptionsPageOptions::ScanfLargeFormatter; + else if (prop == QLatin1String("-e_medium_read")) + scanfFormatter = LibraryOptionsPageOptions::ScanfMediumFormatter; + else + // If this option is not set, then choose the + // default value (see the compiler datasheet for + // '_formatted_read' option). + scanfFormatter = LibraryOptionsPageOptions::ScanfMediumFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalDlibLibrary, + CustomDlibLibrary, + ClibLibrary, + CustomClibLibrary + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QStringList libraryPaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + const auto libraryBegin = libraryPaths.cbegin(); + const auto libraryEnd = libraryPaths.cend(); + + const QFileInfo dlibConfigInfo(IarewUtils::flagValue( + flags, QStringLiteral("--dlib_config"))); + const QString dlibConfigFilePath = dlibConfigInfo.absoluteFilePath(); + if (!dlibConfigFilePath.isEmpty()) { + const QString dlibToolkitPath = IarewUtils::dlibToolkitRootPath( + qbsProduct); + if (dlibConfigFilePath.startsWith(dlibToolkitPath, + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalDlibLibrary; + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, dlibConfigFilePath); + + // Find dlib library inside of IAR toolkit directory. + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [dlibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(dlibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that dlib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } + } else { + // This means that dlib library is 'custom' + // (but we don't know its path). + libraryType = LibraryConfigPageOptions::CustomDlibLibrary; + configPath = IarewUtils::projectRelativeFilePath( + baseDirectory, dlibConfigFilePath); + } + } else { + // Find clib library inside of IAR toolkit directory. + const QString clibToolkitPath = IarewUtils::clibToolkitRootPath( + qbsProduct); + const auto libraryIt = std::find_if(libraryBegin, libraryEnd, + [clibToolkitPath]( + const QString &libraryPath) { + return libraryPath.startsWith(clibToolkitPath); + }); + if (libraryIt != libraryEnd) { + // This means that clib library is 'standard' (placed inside + // of IAR toolkit directory). + libraryType = LibraryConfigPageOptions::ClibLibrary; + libraryPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, *libraryIt); + } else { + // This means that no any libraries are used . + libraryType = LibraryConfigPageOptions::NoLibrary; + } + } + } + + RuntimeLibrary libraryType = NoLibrary; + QString configPath; + QString libraryPath; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +} // namespace + +// Mcs51GeneralSettingsGroup + +Mcs51GeneralSettingsGroup::Mcs51GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildStackHeapPage(qbsProduct); + buildDataPointerPage(qbsProduct); + buildCodeBankPage(qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void Mcs51GeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'OGChipConfigPath' item (Device: ). + addOptionsGroup(QByteArrayLiteral("OGChipConfigPath"), + {opts.chipInfoPath}); + + // Add 'CPU Core' and 'CPU Core Slave' items + // (CPU core: plain/extended{1|2}). + addOptionsGroup(QByteArrayLiteral("CPU Core"), + {opts.cpuCore}); + addOptionsGroup(QByteArrayLiteral("CPU Core Slave"), + {opts.cpuCore}); + // Add 'Code Memory Model' and 'Code Memory Model slave' items + // (Code model: near/banked/far/banked extended). + addOptionsGroup(QByteArrayLiteral("Code Memory Model"), + {opts.codeModel}); + addOptionsGroup(QByteArrayLiteral("Code Memory Model slave"), + {opts.codeModel}); + // Add 'Data Memory Model' and 'Data Memory Model slave' items + // (Data model: tiny/small/large/generic/far). + addOptionsGroup(QByteArrayLiteral("Data Memory Model"), + {opts.dataModel}); + addOptionsGroup(QByteArrayLiteral("Data Memory Model slave"), + {opts.dataModel}); + // Add 'Use extended stack' and 'Use extended stack slave' items + // (Use extended stack). + addOptionsGroup(QByteArrayLiteral("Use extended stack"), + {opts.useExtendedStack}); + addOptionsGroup(QByteArrayLiteral("Use extended stack slave"), + {opts.useExtendedStack}); + // Add 'Workseg Size' item (Number of virtual registers: 8...32). + addOptionsGroup(QByteArrayLiteral("Workseg Size"), + {opts.virtualRegisters}); + // Add 'Constant Placement' item + // (Location of constants and strings: ram/rom/code memories). + addOptionsGroup(QByteArrayLiteral("Constant Placement"), + {opts.constPlacement}); + // Add 'Calling convention' item (Calling convention). + addOptionsGroup(QByteArrayLiteral("Calling convention"), + {opts.callingConvention}); +} + +void Mcs51GeneralSettingsGroup::buildStackHeapPage( + const ProductData &qbsProduct) +{ + const StackHeapPageOptions opts(qbsProduct); + // Add 'General Idata Stack Size' item (Stack size: IDATA). + addOptionsGroup(QByteArrayLiteral("General Idata Stack Size"), + {opts.idataStack}); + // Add 'General Pdata Stack Size' item (Stack size: PDATA). + addOptionsGroup(QByteArrayLiteral("General Pdata Stack Size"), + {opts.pdataStack}); + // Add 'General Xdata Stack Size' item (Stack size: XDATA). + addOptionsGroup(QByteArrayLiteral("General Xdata Stack Size"), + {opts.xdataStack}); + // Add 'General Ext Stack Size' item (Stack size: Extended). + addOptionsGroup(QByteArrayLiteral("General Ext Stack Size"), + {opts.extendedStack}); + + // Add 'General Xdata Heap Size' item (Heap size: XDATA). + addOptionsGroup(QByteArrayLiteral("General Xdata Heap Size"), + {opts.xdataHeap}); + // Add 'General Far Heap Size' item (Heap size: Far). + addOptionsGroup(QByteArrayLiteral("General Far Heap Size"), + {opts.farHeap}); + // Add 'General Far22 Heap Size' item (Heap size: Far22). + addOptionsGroup(QByteArrayLiteral("General Far22 Heap Size"), + {opts.far22Heap}); + // Add 'General Huge Heap Size' item (Heap size: Huge). + addOptionsGroup(QByteArrayLiteral("General Huge Heap Size"), + {opts.hugeHeap}); + + // Add 'Extended stack address' item + // (Extended stack pointer address). + addOptionsGroup(QByteArrayLiteral("Extended stack address"), + {opts.extStackAddress}); + // Add 'Extended stack mask' item (Extended stack pointer mask). + addOptionsGroup(QByteArrayLiteral("Extended stack mask"), + {opts.extStackMask}); + // Add 'Extended stack is offset' item + // (Extended stack pointer is an offset). + addOptionsGroup(QByteArrayLiteral("Extended stack is offset"), + {opts.extStackOffset}); +} + +void Mcs51GeneralSettingsGroup::buildDataPointerPage( + const ProductData &qbsProduct) +{ + const DptrPageOptions opts(qbsProduct); + // Add 'Nr of Datapointers' item (Number of DPTRs: 1...8). + addOptionsGroup(QByteArrayLiteral("Nr of Datapointers"), + {opts.dptrsCountIndex}); + // Add 'Datapointer Size' item (DPTR size: 16/24). + addOptionsGroup(QByteArrayLiteral("Datapointer Size"), + {opts.dptrSize}); + // Add 'Sfr Visibility' item (DPTR address: shadowed/separate). + addOptionsGroup(QByteArrayLiteral("Sfr Visibility"), + {opts.dptrVisibility}); + // Add 'Switch Method' item (Switch method: inc/mask). + addOptionsGroup(QByteArrayLiteral("Switch Method"), + {opts.dptrSwitchMethod}); + // Add 'Mask Value' item (Switch method mask). + addOptionsGroup(QByteArrayLiteral("Mask Value"), + {opts.dptrMask}); + // Add 'PDATA 8-15 register address' item (Page register + // address (for bits 8-15). + addOptionsGroup(QByteArrayLiteral("PDATA 8-15 register address"), + {opts.dptrPbank}); + // Add 'PDATA 16-31 register address' item (Page register + // address (for bits 16-31). + addOptionsGroup(QByteArrayLiteral("PDATA 16-31 register address"), + {opts.dptrPbankExt}); + // Add 'DPS Address' item (Selected DPTR register). + addOptionsGroup(QByteArrayLiteral("DPS Address"), + {opts.dpsAddress}); + // Add 'DPC Address' item (Separate DPTR control register). + addOptionsGroup(QByteArrayLiteral("DPC Address"), + {opts.dpcAddress}); + // Add 'DPTR Addresses' item (DPTR addresses: Low/High/Ext). + const QString dptrAddresses = opts.dptrAddresses.join(QLatin1Char(' ')); + addOptionsGroup(QByteArrayLiteral("DPTR Addresses"), + {dptrAddresses}); +} + +void Mcs51GeneralSettingsGroup::buildCodeBankPage( + const ProductData &qbsProduct) +{ + const CodeBankPageOptions opts(qbsProduct); + // Add 'CodeBankReg' item (Register address). + addOptionsGroup(QByteArrayLiteral("CodeBankReg"), + {opts.registerAddress}); + // Add 'CodeBankRegMask' item (Register mask). + addOptionsGroup(QByteArrayLiteral("CodeBankRegMask"), + {opts.registerMask}); + // Add 'CodeBankNrOfs' item (Number of banks). + addOptionsGroup(QByteArrayLiteral("CodeBankNrOfs"), + {opts.banksCount}); + // Add 'CodeBankStart' item (Bank start). + addOptionsGroup(QByteArrayLiteral("CodeBankStart"), + {opts.bankStart}); + // Add 'CodeBankSize' item (Bank end). + addOptionsGroup(QByteArrayLiteral("CodeBankSize"), + {opts.bankEnd}); +} + +void Mcs51GeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const LibraryOptionsPageOptions opts(qbsProduct); + // Add 'Output variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Output variant"), + {opts.printfFormatter}); + // Add 'Input variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Input variant"), + {opts.scanfFormatter}); +} + +void Mcs51GeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GRuntimeLibSelect2' and 'GRuntimeLibSelectSlave2' items + // (Link with runtime: none/dlib/clib/etc). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelect2"), + {opts.libraryType}); + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelectSlave2"), + {opts.libraryType}); + // Add 'RTConfigPath' item (Runtime configuration file). + addOptionsGroup(QByteArrayLiteral("RTConfigPath"), + {opts.configPath}); + // Add 'RTLibraryPath' item (Runtime library file). + addOptionsGroup(QByteArrayLiteral("RTLibraryPath"), + {opts.libraryPath}); +} + +void Mcs51GeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {opts.binaryType}); + // Add 'ExePath' item (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {opts.binaryDirectory}); + // Add 'ObjPath' item (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {opts.objectDirectory}); + // Add 'ListPath' item (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {opts.listingDirectory}); +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.h new file mode 100644 index 00000000..1805a87a --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51generalsettingsgroup_v10.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51GENERALSETTINGSGROUP_V10_H +#define QBS_IAREWMCS51GENERALSETTINGSGROUP_V10_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51GeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Mcs51GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildStackHeapPage(const ProductData &qbsProduct); + void buildDataPointerPage(const ProductData &qbsProduct); + void buildCodeBankPage(const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51GENERALSETTINGSGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.cpp b/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.cpp new file mode 100644 index 00000000..d2c7f384 --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.cpp @@ -0,0 +1,335 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51linkersettingsgroup_v10.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +constexpr int kLinkerArchiveVersion = 4; +constexpr int kLinkerDataVersion = 21; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '-f' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("-f")); + for (const QVariant &configPathValue : configPathValues) { + const QString fullConfigPath = configPathValue.toString(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } else { + const QString path =IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } + } + + // Add libraries search paths. + const QStringList libraryPaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + for (const QString &libraryPath : libraryPaths) { + const QFileInfo libraryPathInfo(libraryPath); + const QString fullLibrarySearchPath = libraryPathInfo.absoluteFilePath(); + if (fullLibrarySearchPath.startsWith(toolkitPath, + Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullLibrarySearchPath); + librarySearchPaths.push_back(path); + } + } + } + + QVariantList configFilePaths; + QVariantList librarySearchPaths; + QString entryPoint; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = gen::utils::targetBinary(qbsProduct); + } + + QString outputFile; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { + NoListing, + GenerateListing + }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = NoListing; +}; + +// Define page options. + +struct DefinePageOptions final +{ + explicit DefinePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + // Enumerate all linker defines. + for (const QString &flag : flags) { + if (!flag.startsWith(QLatin1String("-D"))) + continue; + const QString symbol = flag.mid(2); + // Ignore system-defined macroses, because its already + // handled in "General Options" page. + if (symbol.startsWith(QLatin1Char('?')) + || symbol.startsWith(QLatin1Char('_')) + ) { + continue; + } + defineSymbols.push_back(symbol); + } + } + + QVariantList defineSymbols; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + suppressAllWarnings = (warningLevel == QLatin1String("none")); + } + + int suppressAllWarnings = 0; +}; + +} // namespace + +// Mcs51LinkerSettingsGroup + +Mcs51LinkerSettingsGroup::Mcs51LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XLINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + buildDiagnosticsPage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void Mcs51LinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add 'XclOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XclOverride"), + {1}); + // Add 'XclFile' item (Linke configuration file). + addOptionsGroup(QByteArrayLiteral("XclFile"), + {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("-f ") + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } + + // Add 'xcProgramEntryLabel' item (Entry symbol). + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabel"), + {opts.entryPoint}); + // Add 'xcOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("xcOverrideProgramEntryLabel"), + {1}); + // Add 'xcProgramEntryLabelSelect' item. + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabelSelect"), + {0}); + + // Add 'XIncludes' item (Libraries search paths). + addOptionsGroup(QByteArrayLiteral("XIncludes"), + opts.librarySearchPaths); +} + +void Mcs51LinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'XOutOverride' item (Override default output file). + addOptionsGroup(QByteArrayLiteral("XOutOverride"), + {1}); + // Add 'OutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {opts.outputFile}); +} + +void Mcs51LinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'XList' item (Generate linker listing). + addOptionsGroup(QByteArrayLiteral("XList"), + {opts.generateMap}); +} + +void Mcs51LinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const DefinePageOptions opts(qbsProduct); + // Add 'XDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("XDefines"), + opts.defineSymbols); +} + +void Mcs51LinkerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'SuppressAllWarn' item (Suppress all warnings). + addOptionsGroup(QByteArrayLiteral("SuppressAllWarn"), + {opts.suppressAllWarnings}); +} + +void Mcs51LinkerSettingsGroup::buildExtraOptionsPage( + const ProductData &qbsProduct) +{ + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (const QString &flag : flags) { + if (flag.startsWith(QLatin1String("-Z"))) + m_extraOptions.push_back(flag); + } + + if (!m_extraOptions.isEmpty()) { + // Add 'Linker Extra Options Check' (Use command line options). + addOptionsGroup(QByteArrayLiteral("Linker Extra Options Check"), + {1}); + // Add 'Linker Extra Options Edit' item (Command line options). + addOptionsGroup(QByteArrayLiteral("Linker Extra Options Edit"), + m_extraOptions); + } +} + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.h b/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.h new file mode 100644 index 00000000..fec80e5e --- /dev/null +++ b/src/plugins/generator/iarew/archs/mcs51/mcs51linkersettingsgroup_v10.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMCS51LINKERSETTINGSGROUP_V10_H +#define QBS_IAREWMCS51LINKERSETTINGSGROUP_V10_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace mcs51 { +namespace v10 { + +class Mcs51LinkerSettingsGroupPrivate; + +class Mcs51LinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Mcs51LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildDefinePage(const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v10 +} // namespace mcs51 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMCS51LINKERSETTINGSGROUP_V10_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp new file mode 100644 index 00000000..1258412d --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430archiversettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kArchiverArchiveVersion = 4; +constexpr int kArchiverDataVersion = 0; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +//Msp430ArchiverSettingsGroup + +Msp430ArchiverSettingsGroup::Msp430ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("XAR")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void Msp430ArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'XAROutOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XAROutOverride"), + {1}); + // Add 'OutputFile' item (Output filename). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {opts.outputFile}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h new file mode 100644 index 00000000..9da8d344 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430archiversettingsgroup_v7.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430ArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430ARCHIVERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp new file mode 100644 index 00000000..51108e63 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430assemblersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kAssemblerArchiveVersion = 5; +constexpr int kAssemblerDataVersion = 14; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = flags.contains( + QLatin1String("-s+")); + enableMultibyteSupport = flags.contains( + QLatin1String("-n")); + + if (flags.contains(QLatin1String("-M<>"))) + macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote; + else if (flags.contains(QLatin1String("-M()"))) + macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote; + else if (flags.contains(QLatin1String("-M[]"))) + macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote; + else if (flags.contains(QLatin1String("-M{}"))) + macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote; + } + + int enableSymbolsCaseSensitive = 1; + int enableMultibyteSupport = 0; + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const auto &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString warningLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (warningLevel == QLatin1String("all")) { + enableWarnings = 0; + enableAllWarnings = 0; + } else if (warningLevel == QLatin1String("none")) { + enableWarnings = 1; + enableAllWarnings = 0; + } else { + enableWarnings = 0; + enableAllWarnings = 1; + } + } + + int enableWarnings = 0; + int enableAllWarnings = 0; +}; + +} // namespace + +//Msp430AssemblerSettingsGroup + +Msp430AssemblerSettingsGroup::Msp430AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("A430")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Msp430AssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'ACaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("ACaseSensitivity"), + {opts.enableSymbolsCaseSensitive}); + // Add 'AMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("AMultibyteSupport"), + {opts.enableMultibyteSupport}); + // Add 'MacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("MacroChars"), + {opts.macroQuoteCharacter}); +} + +void Msp430AssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'ADebug' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("ADebug"), + {opts.debugInfo}); +} + +void Msp430AssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'ADefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("ADefines"), + opts.defineSymbols); + // Add 'AUserIncludes' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("AUserIncludes"), + opts.includePaths); +} + +void Msp430AssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'AWarnEnable' item (Enable/disable warnings). + addOptionsGroup(QByteArrayLiteral("AWarnEnable"), + {opts.enableWarnings}); + // Add 'AWarnWhat' item (Enable/disable all warnings). + addOptionsGroup(QByteArrayLiteral("AWarnWhat"), + {opts.enableAllWarnings}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h new file mode 100644 index 00000000..97a59f4c --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430assemblersettingsgroup_v7.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430AssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildLanguagePage(const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430ASSEMBLERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp new file mode 100644 index 00000000..bd80cdd7 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430archiversettingsgroup_v7.h" +#include "msp430assemblersettingsgroup_v7.h" +#include "msp430buildconfigurationgroup_v7.h" +#include "msp430compilersettingsgroup_v7.h" +#include "msp430generalsettingsgroup_v7.h" +#include "msp430linkersettingsgroup_v7.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +Msp430BuildConfigurationGroup::Msp430BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("MSP430"); + + // Append debug info item. + const int debugBuild = gen::utils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool Msp430BuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Msp430 + && version.majorVersion() == 7; +} + +std::unique_ptr +Msp430BuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new Msp430BuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h new file mode 100644 index 00000000..ba0404c0 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430buildconfigurationgroup_v7.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H +#define QBS_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H + +#include +#include + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430BuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit Msp430BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class Msp430BuildConfigurationGroupFactory; +}; + +class Msp430BuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430BUILDCONFIGURATIONGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp new file mode 100644 index 00000000..5728578b --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.cpp @@ -0,0 +1,486 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430compilersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kCompilerArchiveVersion = 4; +constexpr int kCompilerDataVersion = 38; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Language one page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C99LanguageDialect + }; + + enum CxxLanguageDialect { + EmbeddedCPlusPlus, + ExtendedEmbeddedCPlusPlus + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // C language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + if (cLanguageVersion.contains(QLatin1String("c89"))) + cLanguageDialect = LanguageOnePageOptions::C89LanguageDialect; + else if (cLanguageVersion.contains(QLatin1String("c99"))) + cLanguageDialect = LanguageOnePageOptions::C99LanguageDialect; + // C++ language dialect. + if (flags.contains(QLatin1String("--ec++"))) + cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus; + else if (flags.contains(QLatin1String("--eec++"))) + cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus; + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + + allowVla = flags.contains(QLatin1String("--vla")); + useCppInlineSemantics = flags.contains( + QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains( + QLatin1String("--require_prototypes")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C99LanguageDialect; + CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus; + LanguageConformance languageConformance = AllowIarExtension; + int allowVla = 0; + int useCppInlineSemantics = 0; + int requirePrototypes = 0; + int destroyStaticObjects = 0; +}; + +// Language two page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains(QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + guardCalls = flags.contains( + QLatin1String("--guard_calls")); + } + + PlainCharacter plainCharacter = UnsignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; + int enableMultibyteSupport = 0; + int guardCalls = 0; +}; + +// Code page options. + +struct CodePageOptions final +{ + enum Utilization { + UtilizationNormalUse, + UtilizationRegVarVariables, + UtilizationNotUsed + }; + + explicit CodePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // Detect R4 utilization. + if (flags.contains(QLatin1String("--lock_r4"))) + r4utilization = UtilizationNotUsed; + else if (flags.contains(QLatin1String("--regvar_r4"))) + r4utilization = UtilizationRegVarVariables; + // Detect R5 utilization. + if (flags.contains(QLatin1String("--lock_r5"))) + r5utilization = UtilizationNotUsed; + else if (flags.contains(QLatin1String("--regvar_r54"))) + r5utilization = UtilizationRegVarVariables; + // Detect reduce stack usage. + reduceStackUsage = flags.contains( + QLatin1String("--reduce_stack_usage")); + // Detect 20-bit context save on interrupt. + save20BitContextOnInterrupt = flags.contains( + QLatin1String("--save_reg20")); + } + + Utilization r4utilization = UtilizationNormalUse; + Utilization r5utilization = UtilizationNormalUse; + int reduceStackUsage = 0; + int save20BitContextOnInterrupt = 0; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + // Optimizations level radio-buttons with + // combo-box on "level" widget. + enum Strategy { + StrategyBalanced, + StrategySize, + StrategySpeed + }; + + enum Level { + LevelNone, + LevelLow, + LevelMedium, + LevelHigh + }; + + enum LevelSlave { + LevelSlave0, + LevelSlave1, + LevelSlave2, + LevelSlave3 + }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + disableSizeConstraints = flags.contains( + QLatin1String("--no_size_constraints")); + + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableLoopUnroll = !flags.contains(QLatin1String("--no_unroll")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Separate "no size constraints" checkbox. + int disableSizeConstraints = 0; + + // Five bit-field flags on "enabled transformations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableLoopUnroll = 0; // Loop unrolling. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +} // namespace + +//Msp430CompilerSettingsGroup + +Msp430CompilerSettingsGroup::Msp430CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICC430")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Msp430CompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'CCDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("CCDebugInfo"), + {opts.debugInfo}); +} + +void Msp430CompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {opts.cLanguageDialect}); + // Add 'IccCppDialect' item (C++ dialect: embedded/extended). + addOptionsGroup(QByteArrayLiteral("IccCppDialect"), + {opts.cxxLanguageDialect}); + // Add 'CCExt' item + // (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("CCExt"), + {opts.languageConformance}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {opts.useCppInlineSemantics}); + // Add 'IccRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("CCRequirePrototypes"), + {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {opts.destroyStaticObjects}); +} + +void Msp430CompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'IccCharIs' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("CCCharIs"), + {opts.plainCharacter}); + // Add 'IccFloatSemantics' item (Floatic-point + // semantics: strict/relaxed conformance). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {opts.floatingPointSemantic}); + // Add 'IccMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("CCMultibyteSupport"), + {opts.enableMultibyteSupport}); + // Add 'CCGuardCalls' and 'OCGuardCallsSlave' item (Guard calls). + addOptionsGroup(QByteArrayLiteral("CCGuardCalls"), + {opts.guardCalls}); +} + +void Msp430CompilerSettingsGroup::buildCodePage( + const ProductData &qbsProduct) +{ + const CodePageOptions opts(qbsProduct); + // Add 'OCCR4Utilize' item + // (R4 utilization: normal/regvar/disabled). + addOptionsGroup(QByteArrayLiteral("OCCR4Utilize"), + {opts.r4utilization}); + // Add 'OCCR5Utilize' item + // (R5 utilization: normal/regvar/disabled). + addOptionsGroup(QByteArrayLiteral("OCCR5Utilize"), + {opts.r5utilization}); + // Add 'ReduceStack' item + // (Reduce stack usage). + addOptionsGroup(QByteArrayLiteral("ReduceStack"), + {opts.reduceStackUsage}); + // Add 'Save20bit' item + // (20-bit context save on interrupt). + addOptionsGroup(QByteArrayLiteral("Save20bit"), + {opts.save20BitContextOnInterrupt}); +} + +void Msp430CompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'CCOptStrategy', 'CCOptLevel' and + // 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("CCOptStrategy"), + {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("CCOptLevel"), + {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("CCOptLevelSlave"), + {opts.optimizationLevelSlave}); + + // Add 'CCOptimizationNoSizeConstraints' item (no size constraints). + addOptionsGroup(QByteArrayLiteral("CCOptimizationNoSizeConstraints"), + {opts.disableSizeConstraints}); + + // Add 'CCAllowList' item + // (Enabled transformations: 5 check boxes). + const QString bitflags = QStringLiteral("%1%2%3%4%5%6") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableLoopUnroll) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableTypeBasedAliasAnalysis); + addOptionsGroup(QByteArrayLiteral("CCAllowList"), + {bitflags}); +} + +void Msp430CompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'CCDefines' item (Defines symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + opts.defineSymbols); + // Add 'newCCIncludePaths' item + // (Additional include directories). + addOptionsGroup(QByteArrayLiteral("newCCIncludePaths"), + opts.includePaths); +} + +void Msp430CompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"), + {opts.warningsAsErrors}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h new file mode 100644 index 00000000..49810088 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430compilersettingsgroup_v7.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430COMPILERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430COMPILERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430CompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const ProductData &qbsProduct); + void buildLanguageOnePage(const ProductData &qbsProduct); + void buildLanguageTwoPage(const ProductData &qbsProduct); + void buildCodePage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430COMPILERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp new file mode 100644 index 00000000..d99e15bb --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.cpp @@ -0,0 +1,482 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430generalsettingsgroup_v7.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kGeneralArchiveVersion = 21; +constexpr int kGeneralDataVersion = 34; + +namespace { + +// Target page options. + +struct TargetPageOptions final +{ + enum CodeModel { + SmallCodeModel, + LargeCodeModel + }; + + enum DataModel { + SmallDataModel, + MediumDataModel, + LargeDataModel + }; + + enum FloatingPointDoubleSize { + DoubleSize32Bits, + DoubleSize64Bits + }; + + enum HardwareMultiplierType { + AllowDirectAccessMultiplier, + UseOnlyLibraryCallsMultiplier + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target code model. + const QString codeModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--code_model")); + if (codeModelValue == QLatin1String("small")) + codeModel = TargetPageOptions::SmallCodeModel; + else if (codeModelValue == QLatin1String("large")) + codeModel = TargetPageOptions::LargeCodeModel; + // Detect target data model. + const QString dataModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--data_model")); + if (dataModelValue == QLatin1String("small")) + dataModel = TargetPageOptions::SmallDataModel; + else if (dataModelValue == QLatin1String("medium")) + dataModel = TargetPageOptions::MediumDataModel; + else if (dataModelValue == QLatin1String("large")) + dataModel = TargetPageOptions::LargeDataModel; + // Detect floating point double size. + const int doubleSize = IarewUtils::flagValue( + flags, QStringLiteral("--double")).toInt(); + if (doubleSize == 32) + floatingPointDoubleSize = DoubleSize32Bits; + else if (doubleSize == 64) + floatingPointDoubleSize = DoubleSize64Bits; + // Detect hardware multiplier. + const QString multiplier = IarewUtils::flagValue( + flags, QStringLiteral("--multiplier")); + enableHardwareMultiplier = (multiplier.compare(QLatin1String("16")) == 0 + || multiplier.compare(QLatin1String("16s")) == 0 + || multiplier.compare(QLatin1String("32")) == 0); + // Detect code and read-only data position-independence. + enableRopi = flags.contains(QLatin1String("--ropi")); + // No dynamic read-write initialization. + disableDynamicReadWriteInitialization = flags.contains( + QLatin1String("--no_rw_dynamic_init")); + + // Detect target device name. + detectDeviceMenu(qbsProduct); + } + + void detectDeviceMenu(const ProductData &qbsProduct) + { + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (!fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) + continue; + + const QFileInfo configInfo(fullConfigPath); + const QString configBase = configInfo.baseName(); + if (!configBase.startsWith(QLatin1String("lnk"))) + continue; + + // Remove 'lnk' prefix. + const QString deviceName = QStringLiteral("MSP%1") + .arg(configBase.mid(3).toUpper()); + + deviceMenu = QStringLiteral("%1\t%1").arg(deviceName); + return; + } + } + + // Falling back to generic menu. + if (deviceMenu.isEmpty()) { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + const QString cpuCore = IarewUtils::flagValue(flags, QStringLiteral("--core")); + if (cpuCore.isEmpty()) + return; + deviceMenu = QStringLiteral("MSP%1\tGeneric MSP%1 device").arg(cpuCore); + return; + } + } + + CodeModel codeModel = LargeCodeModel; + DataModel dataModel = SmallDataModel; + FloatingPointDoubleSize floatingPointDoubleSize = DoubleSize32Bits; + HardwareMultiplierType hardwareMultiplierType = AllowDirectAccessMultiplier; + int enableHardwareMultiplier = 0; + int enableRopi = 0; + int disableDynamicReadWriteInitialization = 0; + QString deviceMenu; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalDLibrary, + FullDLibrary, + CustomDLibrary, + CLibrary, // deprecated + CustomCLibrary, // deprecated + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QFileInfo configInfo(IarewUtils::flagValue( + flags, + QStringLiteral("--dlib_config"))); + const QString configFilePath = configInfo.absoluteFilePath(); + + if (!configFilePath.isEmpty()) { + const QString libToolkitPath = + IarewUtils::libToolkitRootPath(qbsProduct); + + if (configFilePath.startsWith(libToolkitPath, + Qt::CaseInsensitive)) { + if (configFilePath.endsWith(QLatin1String("n.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalDLibrary; + } else if (configFilePath.endsWith(QLatin1String("f.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::FullDLibrary; + } else { + libraryType = LibraryConfigPageOptions::CustomDLibrary; + } + + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, configFilePath); + } else { + libraryType = LibraryConfigPageOptions::CustomDLibrary; + + configPath = configFilePath; + } + } + } + + RuntimeLibrary libraryType = NormalDLibrary; + QString libraryPath; + QString configPath; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter = 0, + PrintfFullFormatter = 1, + PrintfFullNoMultibytesFormatter = 2, + PrintfLargeFormatter = 3, + PrintfLargeNoMultibytesFormatter = 4, + PrintfSmallFormatter = 5, + PrintfSmallNoMultibytesFormatter = 6, + PrintfTinyFormatter = 7 + }; + + enum ScanfFormatter { + ScanfAutoFormatter = 0, + ScanfFullFormatter = 1, + ScanfFullNoMultibytesFormatter = 2, + ScanfLargeFormatter = 3, + ScanfLargeNoMultibytesFormatter = 4, + ScanfSmallFormatter = 5, + ScanfSmallNoMultibytesFormatter = 6 + }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (flagIt->endsWith(QLatin1String("=_printf"), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("_printffull")) + printfFormatter = PrintfFullFormatter; + else if (prop == QLatin1String("_printffullnomb")) + printfFormatter = PrintfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_printflarge")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printflargenomb")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printfsmall")) + printfFormatter = PrintfSmallFormatter; + else if (prop == QLatin1String("_printfsmallnomb")) + printfFormatter = PrintfSmallNoMultibytesFormatter; + else if (prop == QLatin1String("_printftiny")) + printfFormatter = PrintfTinyFormatter; + } else if (flagIt->endsWith(QLatin1String("=_scanf"), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(0).toLower(); + if (prop == QLatin1String("_scanffull")) + scanfFormatter = ScanfFullFormatter; + else if (prop == QLatin1String("_scanffullnomb")) + scanfFormatter = ScanfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_scanflarge")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanflargenomb")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanfsmall")) + scanfFormatter = ScanfSmallFormatter; + else if (prop == QLatin1String("_scanfsmallnomb")) + scanfFormatter = ScanfSmallNoMultibytesFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Stack/heap page options. + +struct StackHeapPageOptions final +{ + explicit StackHeapPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + + // Detect stack size. + stackSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_STACK_SIZE")); + if (stackSize.isEmpty()) + stackSize = QLatin1String("A0"); + // Detect data heap16 size. + data16HeapSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_DATA16_HEAP_SIZE")); + if (data16HeapSize.isEmpty()) + stackSize = QLatin1String("A0"); + // Detect data heap20 size. + data20HeapSize = IarewUtils::flagValue( + flags, QStringLiteral("-D_DATA20_HEAP_SIZE")); + if (data20HeapSize.isEmpty()) + stackSize = QLatin1String("50"); + } + + QString stackSize; + QString data16HeapSize; + QString data20HeapSize; +}; + +} // namespace + +//Msp430GeneralSettingsGroup + +Msp430GeneralSettingsGroup::Msp430GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildStackHeapPage(qbsProduct); +} + +void Msp430GeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'OGChipSelectMenu' item + // (Device: xxx). + addOptionsGroup(QByteArrayLiteral("OGChipSelectMenu"), + {opts.deviceMenu}); + + // Add 'RadioCodeModelType' item + // (Code model: small/large). + addOptionsGroup(QByteArrayLiteral("RadioCodeModelType"), + {opts.codeModel}); + // Add 'RadioDataModelType' item + // (Data model: small/medium/large). + addOptionsGroup(QByteArrayLiteral("RadioDataModelType"), + {opts.dataModel}); + // Add 'OGDouble' item + // (Floating point double size: 32/64 bits). + addOptionsGroup(QByteArrayLiteral("OGDouble"), + {opts.floatingPointDoubleSize}); + // Add 'Hardware Multiplier' item + // (Hardware multiplier). + addOptionsGroup(QByteArrayLiteral("Hardware Multiplier"), + {opts.enableHardwareMultiplier}); + if (opts.enableHardwareMultiplier) { + // Add 'RadioHardwareMultiplierType' item. + addOptionsGroup(QByteArrayLiteral("Hardware RadioHardwareMultiplierType"), + {opts.hardwareMultiplierType}); + } + // Add 'Ropi' item. + // (Position independence: Code and read-only data). + addOptionsGroup(QByteArrayLiteral("Ropi"), + {opts.enableRopi}); + // Add 'NoRwDynamicInit' item. + // (Position independence: No dynamic read/write initialization). + addOptionsGroup(QByteArrayLiteral("NoRwDynamicInit"), + {opts.disableDynamicReadWriteInitialization}); +} + +void Msp430GeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {opts.binaryType}); + // Add 'ExePath' item (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {opts.binaryDirectory}); + // Add 'ObjPath' item (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {opts.objectDirectory}); + // Add 'ListPath' item (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {opts.listingDirectory}); +} + +void Msp430GeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GRuntimeLibSelect' and 'GRuntimeLibSelectSlave' items + // (Link with runtime: none/normal/full/custom). + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelect"), + {opts.libraryType}); + addOptionsGroup(QByteArrayLiteral("GRuntimeLibSelectSlave"), + {opts.libraryType}); + // Add 'RTConfigPath' item (Runtime configuration file). + addOptionsGroup(QByteArrayLiteral("RTConfigPath"), + {opts.configPath}); + // Add 'RTLibraryPath' item (Runtime library file). + addOptionsGroup(QByteArrayLiteral("RTLibraryPath"), + {opts.libraryPath}); +} + +void Msp430GeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const LibraryOptionsPageOptions opts(qbsProduct); + // Add 'Output variant' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("Output variant"), + {opts.printfFormatter}); + // Add 'Input variant' item (Scanf formatter). + addOptionsGroup(QByteArrayLiteral("Input variant"), + {opts.scanfFormatter}); +} + +void Msp430GeneralSettingsGroup::buildStackHeapPage( + const ProductData &qbsProduct) +{ + const StackHeapPageOptions opts(qbsProduct); + // Add 'GStackHeapOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("GStackHeapOverride"), + {1}); + // Add 'GStackSize2' item (Stack size). + addOptionsGroup(QByteArrayLiteral("GStackSize2"), + {opts.stackSize}); + // Add 'GHeapSize2' item (Heap16 size). + addOptionsGroup(QByteArrayLiteral("GHeapSize2"), + {opts.data16HeapSize}); + // Add 'GHeap20Size' item (Heap16 size). + addOptionsGroup(QByteArrayLiteral("GHeap20Size"), + {opts.data20HeapSize}); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h new file mode 100644 index 00000000..35e9e7b3 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430generalsettingsgroup_v7.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430GENERALSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430GENERALSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430GeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildStackHeapPage(const ProductData &qbsProduct); +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430GENERALSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp new file mode 100644 index 00000000..85aac7e8 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.cpp @@ -0,0 +1,289 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msp430linkersettingsgroup_v7.h" + +#include "../../iarewutils.h" + +#include + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +constexpr int kLinkerArchiveVersion = 4; +constexpr int kLinkerDataVersion = 30; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '-f' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("-f")); + for (const QVariant &configPathValue : configPathValues) { + const QString fullConfigPath = configPathValue.toString(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } + } + + // Library search paths. + librarySearchPaths = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("libraryPaths")}); + + // Entry point. + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + } + + QVariantList configFilePaths; + QVariantList librarySearchPaths; + QString entryPoint; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = gen::utils::targetBinary(qbsProduct); + } + + QString outputFile; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { + NoListing, + GenerateListing + }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = NoListing; +}; + +// Define page options. + +struct DefinePageOptions final +{ + explicit DefinePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + // Enumerate all linker defines. + for (const QString &flag : flags) { + if (!flag.startsWith(QLatin1String("-D"))) + continue; + const QString symbol = flag.mid(2); + // Ignore system-defined macroses, because its already + // handled in "General Options" page. + if (symbol.startsWith(QLatin1Char('?')) + || symbol.startsWith(QLatin1Char('_')) + ) { + continue; + } + defineSymbols.push_back(symbol); + } + } + + QVariantList defineSymbols; +}; + +} // namespace + +//Msp430LinkerSettingsGroup + +Msp430LinkerSettingsGroup::Msp430LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + setName(QByteArrayLiteral("XLINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void Msp430LinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add 'XclOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("XclOverride"), + {1}); + // Add 'XclFile' item (Linke configuration file). + addOptionsGroup(QByteArrayLiteral("XclFile"), + {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("-f ") + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } + + // Add 'xcOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("xcOverrideProgramEntryLabel"), + {1}); + // Add 'xcProgramEntryLabel' item (Entry point name). + addOptionsGroup(QByteArrayLiteral("xcProgramEntryLabel"), + {opts.entryPoint}); + + // Add 'XIncludes' item (Entry point name). + addOptionsGroup(QByteArrayLiteral("XIncludes"), + {opts.librarySearchPaths}); +} + +void Msp430LinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + + // Add 'XOutOverride' item (Output file name). + addOptionsGroup(QByteArrayLiteral("XOutOverride"), + {1}); + // Add 'OutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("OutputFile"), + {opts.outputFile}); +} + +void Msp430LinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'XList' item (Generate linker map file). + addOptionsGroup(QByteArrayLiteral("XList"), + {opts.generateMap}); +} + +void Msp430LinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const DefinePageOptions opts(qbsProduct); + // Add 'XDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("XDefines"), + opts.defineSymbols); +} + +void Msp430LinkerSettingsGroup::buildExtraOptionsPage( + const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + if (m_extraOptions.isEmpty()) + return; + + // Add 'XExtraOptionsCheck' (Use command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptionsCheck"), + {1}); + // Add 'XExtraOptions' item (Command line options). + addOptionsGroup(QByteArrayLiteral("XExtraOptions"), + m_extraOptions); +} + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h new file mode 100644 index 00000000..2b6f1151 --- /dev/null +++ b/src/plugins/generator/iarew/archs/msp430/msp430linkersettingsgroup_v7.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWMSP430LINKERSETTINGSGROUP_V7_H +#define QBS_IAREWMSP430LINKERSETTINGSGROUP_V7_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace msp430 { +namespace v7 { + +class Msp430LinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Msp430LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildDefinePage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v7 +} // namespace msp430 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWMSP430LINKERSETTINGSGROUP_V7_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp new file mode 100644 index 00000000..b08b70bc --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8archiversettingsgroup_v3.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +constexpr int kArchiverArchiveVersion = 3; +constexpr int kArchiverDataVersion = 0; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + outputFile = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, qbsProduct); + } + + QString outputFile; +}; + +} // namespace + +// Stm8ArchiverSettingsGroup + +Stm8ArchiverSettingsGroup::Stm8ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("IARCHIVE")); + setArchiveVersion(kArchiverArchiveVersion); + setDataVersion(kArchiverDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + buildOutputPage(buildRootDirectory, qbsProduct); +} + +void Stm8ArchiverSettingsGroup::buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'IarchiveOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("IarchiveOverride"), + {1}); + // Add 'IarchiveOutput' item (Output filename). + addOptionsGroup(QByteArrayLiteral("IarchiveOutput"), + {opts.outputFile}); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h new file mode 100644 index 00000000..754add3c --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8archiversettingsgroup_v3.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H +#define QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8ArchiverSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Stm8ArchiverSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8ARCHIVERSETTINGSGROUP_V3_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp new file mode 100644 index 00000000..396ee7db --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8assemblersettingsgroup_v3.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +constexpr int kAssemblerArchiveVersion = 3; +constexpr int kAssemblerDataVersion = 2; + +namespace { + +// Language page options. + +struct LanguagePageOptions final +{ + enum MacroQuoteCharacter { + AngleBracketsQuote, + RoundBracketsQuote, + SquareBracketsQuote, + FigureBracketsQuote + }; + + explicit LanguagePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); + enableSymbolsCaseSensitive = !flags.contains( + QLatin1String("--case_insensitive")); + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + allowFirstColumnMnemonics = flags.contains( + QLatin1String("--mnem_first")); + allowFirstColumnDirectives = flags.contains( + QLatin1String("--dir_first")); + + if (flags.contains(QLatin1String("-M<>"))) + macroQuoteCharacter = LanguagePageOptions::AngleBracketsQuote; + else if (flags.contains(QLatin1String("-M()"))) + macroQuoteCharacter = LanguagePageOptions::RoundBracketsQuote; + else if (flags.contains(QLatin1String("-M[]"))) + macroQuoteCharacter = LanguagePageOptions::SquareBracketsQuote; + else if (flags.contains(QLatin1String("-M{}"))) + macroQuoteCharacter = LanguagePageOptions::FigureBracketsQuote; + } + + int enableSymbolsCaseSensitive = 1; + int enableMultibyteSupport = 0; + int allowFirstColumnMnemonics = 0; + int allowFirstColumnDirectives = 0; + + MacroQuoteCharacter macroQuoteCharacter = AngleBracketsQuote; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const auto &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +} // namespace + +// Stm8AssemblerSettingsGroup + +Stm8AssemblerSettingsGroup::Stm8AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ASTM8")); + setArchiveVersion(kAssemblerArchiveVersion); + setDataVersion(kAssemblerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildLanguagePage(qbsProduct); + buildOutputPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Stm8AssemblerSettingsGroup::buildLanguagePage( + const ProductData &qbsProduct) +{ + const LanguagePageOptions opts(qbsProduct); + // Add 'AsmCaseSensitivity' item (User symbols are case sensitive). + addOptionsGroup(QByteArrayLiteral("AsmCaseSensitivity"), + {opts.enableSymbolsCaseSensitive}); + // Add 'AsmMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("AsmMultibyteSupport"), + {opts.enableMultibyteSupport}); + // Add 'AsmAllowMnemonics' item (Allow mnemonics in first column). + addOptionsGroup(QByteArrayLiteral("AsmAllowMnemonics"), + {opts.allowFirstColumnMnemonics}); + // Add 'AsmAllowDirectives' item (Allow directives in first column). + addOptionsGroup(QByteArrayLiteral("AsmAllowDirectives"), + {opts.allowFirstColumnDirectives}); + + // Add 'AsmMacroChars' item (Macro quote characters: ()/[]/{}/<>). + addOptionsGroup(QByteArrayLiteral("AsmMacroChars"), + {opts.macroQuoteCharacter}); +} + +void Stm8AssemblerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'AsmDebugInfo' item (Generate debug information). + addOptionsGroup(QByteArrayLiteral("AsmDebugInfo"), + {opts.debugInfo}); +} + +void Stm8AssemblerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'AsmDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("AsmDefines"), + opts.defineSymbols); + // Add 'AsmIncludePath' item (Additional include directories). + addOptionsGroup(QByteArrayLiteral("AsmIncludePath"), + opts.includePaths); +} + +void Stm8AssemblerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'AsmDiagnosticsWarningsAreErrors' item. + // (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("AsmDiagnosticsWarningsAreErrors"), + {opts.warningsAsErrors}); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h new file mode 100644 index 00000000..4d7d0485 --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8assemblersettingsgroup_v3.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H +#define QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8AssemblerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Stm8AssemblerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildLanguagePage(const ProductData &qbsProduct); + void buildOutputPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8ASSEMBLERSETTINGSGROUP_V3_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp new file mode 100644 index 00000000..06167f91 --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8archiversettingsgroup_v3.h" +#include "stm8assemblersettingsgroup_v3.h" +#include "stm8buildconfigurationgroup_v3.h" +#include "stm8compilersettingsgroup_v3.h" +#include "stm8generalsettingsgroup_v3.h" +#include "stm8linkersettingsgroup_v3.h" + +#include "../../iarewtoolchainpropertygroup.h" +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +Stm8BuildConfigurationGroup::Stm8BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("configuration") +{ + // Append configuration name item. + const QString cfgName = gen::utils::buildConfigurationName(qbsProject); + appendProperty("name", cfgName); + + // Apend toolchain name group item. + appendChild("STM8"); + + // Append debug info item. + const int debugBuild = gen::utils::debugInformation(qbsProduct); + appendProperty("debug", debugBuild); + + // Append settings group items. + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); + appendChild( + qbsProject, qbsProduct, qbsProductDeps); +} + +bool Stm8BuildConfigurationGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Stm8 + && version.majorVersion() == 3; +} + +std::unique_ptr +Stm8BuildConfigurationGroupFactory::create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new Stm8BuildConfigurationGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h new file mode 100644 index 00000000..c47819fe --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8buildconfigurationgroup_v3.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H +#define QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H + +#include +#include + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8BuildConfigurationGroup final + : public gen::xml::PropertyGroup +{ +private: + explicit Stm8BuildConfigurationGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class Stm8BuildConfigurationGroupFactory; +}; + +class Stm8BuildConfigurationGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8BUILDCONFIGURATIONGROUP_V3_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp new file mode 100644 index 00000000..912d94bd --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.cpp @@ -0,0 +1,442 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8compilersettingsgroup_v3.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +constexpr int kCompilerArchiveVersion = 3; +constexpr int kCompilerDataVersion = 9; + +namespace { + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + debugInfo = gen::utils::debugInformation(qbsProduct); + } + + int debugInfo = 0; +}; + +// Language one page options. + +struct LanguageOnePageOptions final +{ + enum LanguageExtension { + CLanguageExtension, + CxxLanguageExtension, + AutoLanguageExtension + }; + + enum CLanguageDialect { + C89LanguageDialect, + C99LanguageDialect + }; + + enum CxxLanguageDialect { + EmbeddedCPlusPlus, + ExtendedEmbeddedCPlusPlus + }; + + enum LanguageConformance { + AllowIarExtension, + RelaxedStandard, + StrictStandard + }; + + explicit LanguageOnePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + // File extension based by default. + languageExtension = LanguageOnePageOptions::AutoLanguageExtension; + // C language dialect. + const QStringList cLanguageVersion = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("cLanguageVersion")}); + if (cLanguageVersion.contains(QLatin1String("c89"))) + cLanguageDialect = LanguageOnePageOptions::C89LanguageDialect; + else if (cLanguageVersion.contains(QLatin1String("c99"))) + cLanguageDialect = LanguageOnePageOptions::C99LanguageDialect; + // C++ language dialect. + if (flags.contains(QLatin1String("--ec++"))) + cxxLanguageDialect = LanguageOnePageOptions::EmbeddedCPlusPlus; + else if (flags.contains(QLatin1String("--eec++"))) + cxxLanguageDialect = LanguageOnePageOptions::ExtendedEmbeddedCPlusPlus; + // Language conformance. + if (flags.contains(QLatin1String("-e"))) + languageConformance = LanguageOnePageOptions::AllowIarExtension; + else if (flags.contains(QLatin1String("--strict"))) + languageConformance = LanguageOnePageOptions::StrictStandard; + else + languageConformance = LanguageOnePageOptions::RelaxedStandard; + + allowVla = flags.contains(QLatin1String("--vla")); + useCppInlineSemantics = flags.contains( + QLatin1String("--use_c++_inline")); + requirePrototypes = flags.contains( + QLatin1String("--require_prototypes")); + destroyStaticObjects = !flags.contains( + QLatin1String("--no_static_destruction")); + } + + LanguageExtension languageExtension = AutoLanguageExtension; + CLanguageDialect cLanguageDialect = C99LanguageDialect; + CxxLanguageDialect cxxLanguageDialect = EmbeddedCPlusPlus; + LanguageConformance languageConformance = AllowIarExtension; + int allowVla = 0; + int useCppInlineSemantics = 0; + int requirePrototypes = 0; + int destroyStaticObjects = 0; +}; + +// Language two page options. + +struct LanguageTwoPageOptions final +{ + enum PlainCharacter { + SignedCharacter, + UnsignedCharacter + }; + + enum FloatingPointSemantic { + StrictSemantic, + RelaxedSemantic + }; + + explicit LanguageTwoPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + plainCharacter = flags.contains(QLatin1String("--char_is_signed")) + ? LanguageTwoPageOptions::SignedCharacter + : LanguageTwoPageOptions::UnsignedCharacter; + floatingPointSemantic = flags.contains(QLatin1String("--relaxed_fp")) + ? LanguageTwoPageOptions::RelaxedSemantic + : LanguageTwoPageOptions::StrictSemantic; + enableMultibyteSupport = flags.contains( + QLatin1String("--enable_multibytes")); + } + + PlainCharacter plainCharacter = UnsignedCharacter; + FloatingPointSemantic floatingPointSemantic = StrictSemantic; + int enableMultibyteSupport = 0; +}; + +// Optimizations page options. + +struct OptimizationsPageOptions final +{ + // Optimizations level radio-buttons with + // combo-box on "level" widget. + enum Strategy { + StrategyBalanced, + StrategySize, + StrategySpeed + }; + + enum Level { + LevelNone, + LevelLow, + LevelMedium, + LevelHigh + }; + + enum LevelSlave { + LevelSlave0, + LevelSlave1, + LevelSlave2, + LevelSlave3 + }; + + enum VRegsNumber { + VRegs12, + VRegs16 + }; + + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("none")) { + optimizationStrategy = OptimizationsPageOptions::StrategyBalanced; + optimizationLevel = OptimizationsPageOptions::LevelNone; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave0; + } else if (optimization == QLatin1String("fast")) { + optimizationStrategy = OptimizationsPageOptions::StrategySpeed; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } else if (optimization == QLatin1String("small")) { + optimizationStrategy = OptimizationsPageOptions::StrategySize; + optimizationLevel = OptimizationsPageOptions::LevelHigh; + optimizationLevelSlave = OptimizationsPageOptions::LevelSlave3; + } + + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + disableSizeConstraints = flags.contains( + QLatin1String("--no_size_constraints")); + + enableCommonSubexpressionElimination = !flags.contains( + QLatin1String("--no_cse")); + enableLoopUnroll = !flags.contains(QLatin1String("--no_unroll")); + enableFunctionInlining = !flags.contains(QLatin1String("--no_inline")); + enableCodeMotion = !flags.contains(QLatin1String("--no_code_motion")); + enableTypeBasedAliasAnalysis = !flags.contains( + QLatin1String("--no_tbaa")); + enableCrossCall = !flags.contains(QLatin1String("--no_cross_call")); + + const auto vregsCount = IarewUtils::flagValue( + flags, QStringLiteral("--vregs")).toInt(); + if (vregsCount == 12) + vregsNumber = VRegs12; + else if (vregsCount == 16) + vregsNumber = VRegs16; + } + + Strategy optimizationStrategy = StrategyBalanced; + Level optimizationLevel = LevelNone; + LevelSlave optimizationLevelSlave = LevelSlave0; + // Separate "no size constraints" checkbox. + int disableSizeConstraints = 0; + + // Six bit-field flags on "enabled transformations" widget. + int enableCommonSubexpressionElimination = 0; // Common sub-expression elimination. + int enableLoopUnroll = 0; // Loop unrolling. + int enableFunctionInlining = 0; // Function inlining. + int enableCodeMotion = 0; // Code motion. + int enableTypeBasedAliasAnalysis = 0; // Type based alias analysis. + int enableCrossCall = 0; // Cross call. + + VRegsNumber vregsNumber = VRegs16; +}; + +// Preprocessor page options. + +struct PreprocessorPageOptions final +{ + explicit PreprocessorPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + defineSymbols = gen::utils::cppVariantModuleProperties( + qbsProps, {QStringLiteral("defines")}); + + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + const QStringList fullIncludePaths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + for (const QString &fullIncludePath : fullIncludePaths) { + const QFileInfo includeFileInfo(fullIncludePath); + const QString includeFilePath = includeFileInfo.absoluteFilePath(); + if (includeFilePath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, includeFilePath); + includePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, includeFilePath); + includePaths.push_back(path); + } + } + } + + QVariantList defineSymbols; + QVariantList includePaths; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +} // namespace + +// Stm8CompilerSettingsGroup + +Stm8CompilerSettingsGroup::Stm8CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("ICCSTM8")); + setArchiveVersion(kCompilerArchiveVersion); + setDataVersion(kCompilerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildOutputPage(qbsProduct); + buildLanguageOnePage(qbsProduct); + buildLanguageTwoPage(qbsProduct); + buildOptimizationsPage(qbsProduct); + buildPreprocessorPage(buildRootDirectory, qbsProduct); + buildDiagnosticsPage(qbsProduct); +} + +void Stm8CompilerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + // Add 'IccGenerateDebugInfo' item (Generate debug info). + addOptionsGroup(QByteArrayLiteral("IccGenerateDebugInfo"), + {opts.debugInfo}); +} + +void Stm8CompilerSettingsGroup::buildLanguageOnePage( + const ProductData &qbsProduct) +{ + const LanguageOnePageOptions opts(qbsProduct); + // Add 'IccLang' item with 'auto-extension based' + // value (Language: C/C++/Auto). + addOptionsGroup(QByteArrayLiteral("IccLang"), + {opts.languageExtension}); + // Add 'IccCDialect' item (C dialect: c89/99/11). + addOptionsGroup(QByteArrayLiteral("IccCDialect"), + {opts.cLanguageDialect}); + // Add 'IccCppDialect' item (C++ dialect: embedded/extended). + addOptionsGroup(QByteArrayLiteral("IccCppDialect"), + {opts.cxxLanguageDialect}); + // Add 'IccLanguageConformance' item + // (Language conformance: IAR/relaxed/strict). + addOptionsGroup(QByteArrayLiteral("IccLanguageConformance"), + {opts.languageConformance}); + // Add 'IccAllowVLA' item (Allow VLA). + addOptionsGroup(QByteArrayLiteral("IccAllowVLA"), + {opts.allowVla}); + // Add 'IccCppInlineSemantics' item (C++ inline semantics). + addOptionsGroup(QByteArrayLiteral("IccCppInlineSemantics"), + {opts.useCppInlineSemantics}); + // Add 'IccRequirePrototypes' item (Require prototypes). + addOptionsGroup(QByteArrayLiteral("IccRequirePrototypes"), + {opts.requirePrototypes}); + // Add 'IccStaticDestr' item (Destroy static objects). + addOptionsGroup(QByteArrayLiteral("IccStaticDestr"), + {opts.destroyStaticObjects}); +} + +void Stm8CompilerSettingsGroup::buildLanguageTwoPage( + const ProductData &qbsProduct) +{ + const LanguageTwoPageOptions opts(qbsProduct); + // Add 'IccCharIs' item (Plain char is: signed/unsigned). + addOptionsGroup(QByteArrayLiteral("IccCharIs"), + {opts.plainCharacter}); + // Add 'IccFloatSemantics' item (Floatic-point + // semantics: strict/relaxed conformance). + addOptionsGroup(QByteArrayLiteral("IccFloatSemantics"), + {opts.floatingPointSemantic}); + // Add 'IccMultibyteSupport' item (Enable multibyte support). + addOptionsGroup(QByteArrayLiteral("IccMultibyteSupport"), + {opts.enableMultibyteSupport}); +} + +void Stm8CompilerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + const OptimizationsPageOptions opts(qbsProduct); + // Add 'IccOptStrategy', 'IccOptLevel' and + // 'CCOptLevelSlave' items (Level). + addOptionsGroup(QByteArrayLiteral("IccOptStrategy"), + {opts.optimizationStrategy}); + addOptionsGroup(QByteArrayLiteral("IccOptLevel"), + {opts.optimizationLevel}); + addOptionsGroup(QByteArrayLiteral("IccOptLevelSlave"), + {opts.optimizationLevelSlave}); + + // Add 'IccOptNoSizeConstraints' iten (no size constraints). + addOptionsGroup(QByteArrayLiteral("IccOptNoSizeConstraints"), + {opts.disableSizeConstraints}); + + // Add 'IccOptAllowList' item + // (Enabled optimizations: 6 check boxes). + const QString bitflags = QStringLiteral("%1%2%3%4%5%6") + .arg(opts.enableCommonSubexpressionElimination) + .arg(opts.enableLoopUnroll) + .arg(opts.enableFunctionInlining) + .arg(opts.enableCodeMotion) + .arg(opts.enableTypeBasedAliasAnalysis) + .arg(opts.enableCrossCall); + addOptionsGroup(QByteArrayLiteral("IccOptAllowList"), + {bitflags}); + + // Add 'IccNoVregs' item + // (Number of virtual registers (12/16). + addOptionsGroup(QByteArrayLiteral("IccNoVregs"), + {opts.vregsNumber}); +} + +void Stm8CompilerSettingsGroup::buildPreprocessorPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const PreprocessorPageOptions opts(baseDirectory, qbsProduct); + // Add 'CCDefines' item (Defines symbols). + addOptionsGroup(QByteArrayLiteral("CCDefines"), + opts.defineSymbols); + // Add 'CCIncludePath2' item + // (Additional include directories). + addOptionsGroup(QByteArrayLiteral("CCIncludePath2"), + opts.includePaths); +} + +void Stm8CompilerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'CCDiagWarnAreErr' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("CCDiagWarnAreErr"), + {opts.warningsAsErrors}); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h new file mode 100644 index 00000000..29bb5c2b --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8compilersettingsgroup_v3.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H +#define QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8CompilerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Stm8CompilerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildOutputPage(const ProductData &qbsProduct); + void buildLanguageOnePage(const ProductData &qbsProduct); + void buildLanguageTwoPage(const ProductData &qbsProduct); + void buildOptimizationsPage(const ProductData &qbsProduct); + void buildPreprocessorPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8COMPILERSETTINGSGROUP_V3_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp new file mode 100644 index 00000000..9477bc36 --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.cpp @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8generalsettingsgroup_v3.h" + +#include "../../iarewutils.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +constexpr int kGeneralArchiveVersion = 4; +constexpr int kGeneralDataVersion = 2; + +namespace { + +// Target page options. + +struct TargetPageOptions final +{ + enum CodeModel { + SmallCodeModel, + MediumCodeModel, + LargeCodeModel + }; + + enum DataModel { + SmallDataModel, + MediumDataModel, + LargeDataModel + }; + + explicit TargetPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags")}); + // Detect target code model. + const QString codeModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--code_model")); + if (codeModelValue == QLatin1String("small")) + codeModel = TargetPageOptions::SmallCodeModel; + else if (codeModelValue == QLatin1String("medium")) + codeModel = TargetPageOptions::MediumCodeModel; + else if (codeModelValue == QLatin1String("large")) + codeModel = TargetPageOptions::LargeCodeModel; + // Detect target data model. + const QString dataModelValue = IarewUtils::flagValue( + flags, QStringLiteral("--data_model")); + if (dataModelValue == QLatin1String("small")) + dataModel = TargetPageOptions::SmallDataModel; + else if (dataModelValue == QLatin1String("medium")) + dataModel = TargetPageOptions::MediumDataModel; + else if (dataModelValue == QLatin1String("large")) + dataModel = TargetPageOptions::LargeDataModel; + } + + CodeModel codeModel = MediumCodeModel; + DataModel dataModel = MediumDataModel; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + binaryType = IarewUtils::outputBinaryType(qbsProduct); + binaryDirectory = gen::utils::binaryOutputDirectory( + baseDirectory, qbsProduct); + objectDirectory = gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct); + listingDirectory = gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct); + } + + IarewUtils::OutputBinaryType binaryType = IarewUtils::ApplicationOutputType; + QString binaryDirectory; + QString objectDirectory; + QString listingDirectory; +}; + +// Library configuration page options. + +struct LibraryConfigPageOptions final +{ + enum RuntimeLibrary { + NoLibrary, + NormalLibrary, + FullLibrary, + CustomLibrary + }; + + explicit LibraryConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleCompilerFlags(qbsProps); + + const QFileInfo configInfo(IarewUtils::flagValue( + flags, + QStringLiteral("--dlib_config"))); + const QString configFilePath = configInfo.absoluteFilePath(); + + if (!configFilePath.isEmpty()) { + const QString libToolkitPath = + IarewUtils::libToolkitRootPath(qbsProduct); + + if (configFilePath.startsWith(libToolkitPath, + Qt::CaseInsensitive)) { + if (configFilePath.endsWith(QLatin1String("n.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::NormalLibrary; + } else if (configFilePath.endsWith(QLatin1String("f.h"), + Qt::CaseInsensitive)) { + libraryType = LibraryConfigPageOptions::FullLibrary; + } else { + libraryType = LibraryConfigPageOptions::CustomLibrary; + } + + configPath = IarewUtils::toolkitRelativeFilePath( + baseDirectory, configFilePath); + } else { + libraryType = LibraryConfigPageOptions::CustomLibrary; + + configPath = configFilePath; + } + } else { + libraryType = LibraryConfigPageOptions::NoLibrary; + } + } + + RuntimeLibrary libraryType = NoLibrary; + QString configPath; +}; + +// Library options page options. + +struct LibraryOptionsPageOptions final +{ + enum PrintfFormatter { + PrintfAutoFormatter = 0, + PrintfFullFormatter = 1, + PrintfFullNoMultibytesFormatter = 2, + PrintfLargeFormatter = 3, + PrintfLargeNoMultibytesFormatter = 4, + PrintfSmallFormatter = 5, + PrintfSmallNoMultibytesFormatter = 6, + PrintfTinyFormatter = 7 + }; + + enum ScanfFormatter { + ScanfAutoFormatter = 0, + ScanfFullFormatter = 1, + ScanfFullNoMultibytesFormatter = 2, + ScanfLargeFormatter = 3, + ScanfLargeNoMultibytesFormatter = 4, + ScanfSmallFormatter = 5, + ScanfSmallNoMultibytesFormatter = 6 + }; + + explicit LibraryOptionsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (*flagIt != QLatin1String("--redirect")) + continue; + ++flagIt; + if (flagIt->startsWith(QLatin1String("_printf="), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(1).toLower(); + if (prop == QLatin1String("_printffull")) + printfFormatter = PrintfFullFormatter; + else if (prop == QLatin1String("_printffullnomb")) + printfFormatter = PrintfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_printflarge")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printflargenomb")) + printfFormatter = PrintfLargeFormatter; + else if (prop == QLatin1String("_printfsmall")) + printfFormatter = PrintfSmallFormatter; + else if (prop == QLatin1String("_printfsmallnomb")) + printfFormatter = PrintfSmallNoMultibytesFormatter; + else if (prop == QLatin1String("_printftiny")) + printfFormatter = PrintfTinyFormatter; + } else if (flagIt->startsWith(QLatin1String("_scanf="), + Qt::CaseInsensitive)) { + const QString prop = flagIt->split( + QLatin1Char('=')).at(1).toLower(); + if (prop == QLatin1String("_scanffull")) + scanfFormatter = ScanfFullFormatter; + else if (prop == QLatin1String("_scanffullnomb")) + scanfFormatter = ScanfFullNoMultibytesFormatter; + else if (prop == QLatin1String("_scanflarge")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanflargenomb")) + scanfFormatter = ScanfLargeFormatter; + else if (prop == QLatin1String("_scanfsmall")) + scanfFormatter = ScanfSmallFormatter; + else if (prop == QLatin1String("_scanfsmallnomb")) + scanfFormatter = ScanfSmallNoMultibytesFormatter; + } + } + } + + PrintfFormatter printfFormatter = PrintfAutoFormatter; + ScanfFormatter scanfFormatter = ScanfAutoFormatter; +}; + +// Stack/heap page options. + +struct StackHeapPageOptions final +{ + explicit StackHeapPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const auto configDefs = IarewUtils::flagValues( + flags, QStringLiteral("--config_def")); + for (const auto &configDef : configDefs) { + const auto def = configDef.toString(); + if (def.startsWith(QLatin1String("_CSTACK_SIZE="))) { + stackSize = def.split(QLatin1Char('=')).at(1); + } else if (def.startsWith(QLatin1String("_HEAP_SIZE="))) { + heapSize = def.split(QLatin1Char('=')).at(1); + } + } + } + + QString stackSize; + QString heapSize; +}; + +} // namespace + +// Stm8GeneralSettingsGroup + +Stm8GeneralSettingsGroup::Stm8GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + Q_UNUSED(qbsProductDeps) + + setName(QByteArrayLiteral("General")); + setArchiveVersion(kGeneralArchiveVersion); + setDataVersion(kGeneralDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildTargetPage(qbsProduct); + buildOutputPage(buildRootDirectory, qbsProduct); + buildLibraryConfigPage(buildRootDirectory, qbsProduct); + buildLibraryOptionsPage(qbsProduct); + buildStackHeapPage(qbsProduct); +} + +void Stm8GeneralSettingsGroup::buildTargetPage( + const ProductData &qbsProduct) +{ + const TargetPageOptions opts(qbsProduct); + // Add 'GenCodeModel' item + // (Code model: small/medium/large). + addOptionsGroup(QByteArrayLiteral("GenCodeModel"), + {opts.codeModel}); + // Add 'GenDataModel' item + // (Data model: small/medium/large). + addOptionsGroup(QByteArrayLiteral("GenDataModel"), + {opts.dataModel}); +} + +void Stm8GeneralSettingsGroup::buildOutputPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(baseDirectory, qbsProduct); + // Add 'GOutputBinary' item (Output file: executable/library). + addOptionsGroup(QByteArrayLiteral("GOutputBinary"), + {opts.binaryType}); + // Add 'ExePath' item (Executable/binaries output directory). + addOptionsGroup(QByteArrayLiteral("ExePath"), + {opts.binaryDirectory}); + // Add 'ObjPath' item (Object files output directory). + addOptionsGroup(QByteArrayLiteral("ObjPath"), + {opts.objectDirectory}); + // Add 'ListPath' item (List files output directory). + addOptionsGroup(QByteArrayLiteral("ListPath"), + {opts.listingDirectory}); +} + +void Stm8GeneralSettingsGroup::buildLibraryConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + const LibraryConfigPageOptions opts(baseDirectory, qbsProduct); + // Add 'GenRuntimeLibSelect' and 'GenRuntimeLibSelectSlave' items + // (Link with runtime: none/normal/full/custom). + addOptionsGroup(QByteArrayLiteral("GenRuntimeLibSelect"), + {opts.libraryType}); + addOptionsGroup(QByteArrayLiteral("GenRuntimeLibSelectSlave"), + {opts.libraryType}); + // Add 'GenRTConfigPath' item (Runtime configuration file). + addOptionsGroup(QByteArrayLiteral("GenRTConfigPath"), + {opts.configPath}); +} + +void Stm8GeneralSettingsGroup::buildLibraryOptionsPage( + const ProductData &qbsProduct) +{ + const LibraryOptionsPageOptions opts(qbsProduct); + // Add 'GenLibOutFormatter' item (Printf formatter). + addOptionsGroup(QByteArrayLiteral("GenLibOutFormatter"), + {opts.printfFormatter}); + // Add 'GenLibInFormatter' item (Scanf formatter). + addOptionsGroup(QByteArrayLiteral("GenLibInFormatter"), + {opts.scanfFormatter}); +} + +void Stm8GeneralSettingsGroup::buildStackHeapPage( + const ProductData &qbsProduct) +{ + const StackHeapPageOptions opts(qbsProduct); + // Add 'GenStackSize' item (Stack size). + addOptionsGroup(QByteArrayLiteral("GenStackSize"), + {opts.stackSize}); + // Add 'GenHeapSize' item (Heap size). + addOptionsGroup(QByteArrayLiteral("GenHeapSize"), + {opts.heapSize}); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h new file mode 100644 index 00000000..20def0fd --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8generalsettingsgroup_v3.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H +#define QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8GeneralSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Stm8GeneralSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildTargetPage(const ProductData &qbsProduct); + void buildOutputPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryOptionsPage(const ProductData &qbsProduct); + void buildStackHeapPage(const ProductData &qbsProduct); +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8GENERALSETTINGSGROUP_V3_H diff --git a/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp new file mode 100644 index 00000000..44133397 --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.cpp @@ -0,0 +1,409 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "stm8linkersettingsgroup_v3.h" + +#include "../../iarewutils.h" + +#include + +#include + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +constexpr int kLinkerArchiveVersion = 5; +constexpr int kLinkerDataVersion = 4; + +namespace { + +// Config page options. + +struct ConfigPageOptions final +{ + explicit ConfigPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString fullConfigPath = qbsArtifact.filePath(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + configFilePaths.push_back(path); + } + } + } + + // Enumerate all product linker config files + // (which are set trough '-config' option). + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + const QVariantList configPathValues = IarewUtils::flagValues( + flags, QStringLiteral("--config")); + for (const QVariant &configPathValue : configPathValues) { + const QString fullConfigPath = configPathValue.toString(); + if (fullConfigPath.startsWith(toolkitPath, Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullConfigPath); + if (!configFilePaths.contains(path)) + configFilePaths.push_back(path); + } + } + + // Enumerate all config definition symbols (except + // the CSTACK_SIZE and HEAP_SIZE which are handles + // on the general page). + configDefinitions = IarewUtils::flagValues( + flags, QStringLiteral("--config_def")); + Internal::removeIf(configDefinitions, [](const auto &definition){ + const auto def = definition.toString(); + return def.startsWith(QLatin1String("_CSTACK_SIZE")) + || def.startsWith(QLatin1String("_HEAP_SIZE")); + }); + } + + QVariantList configFilePaths; + QVariantList configDefinitions; +}; + +struct LibraryPageOptions final +{ + explicit LibraryPageOptions(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QString toolkitPath = IarewUtils::toolkitRootPath(qbsProduct); + + entryPoint = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("entryPoint")); + + // Add static libraries paths. + const QStringList staticLibrariesProps = + gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + for (const QString &staticLibrary : staticLibrariesProps) { + const QFileInfo staticLibraryInfo(staticLibrary); + if (staticLibraryInfo.isAbsolute()) { + const QString fullStaticLibraryPath = + staticLibraryInfo.absoluteFilePath(); + if (fullStaticLibraryPath.startsWith(toolkitPath, + Qt::CaseInsensitive)) { + const QString path = IarewUtils::toolkitRelativeFilePath( + toolkitPath, fullStaticLibraryPath); + staticLibraries.push_back(path); + } else { + const QString path = IarewUtils::projectRelativeFilePath( + baseDirectory, fullStaticLibraryPath); + staticLibraries.push_back(path); + } + } else { + staticLibraries.push_back(staticLibrary); + } + } + + // Add static libraries from product dependencies. + for (const ProductData &qbsProductDep : qbsProductDeps) { + const QString depBinaryPath = QLatin1String("$PROJ_DIR$/") + + gen::utils::targetBinaryPath(baseDirectory, + qbsProductDep); + staticLibraries.push_back(depBinaryPath); + } + } + + QString entryPoint; + QVariantList staticLibraries; +}; + +struct OptimizationsPageOptions final +{ + explicit OptimizationsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + + mergeDuplicateSections = flags.contains( + QLatin1String("--merge_duplicate_sections")); + } + + bool mergeDuplicateSections = true; +}; + +// Output page options. + +struct OutputPageOptions final +{ + explicit OutputPageOptions(const ProductData &qbsProduct) + { + outputFile = gen::utils::targetBinary(qbsProduct); + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + + enableDebugInfo = !flags.contains(QLatin1String("--strip")); + } + + QString outputFile; + bool enableDebugInfo = true; +}; + +// List page options. + +struct ListPageOptions final +{ + enum ListingAction { + NoListing, + GenerateListing + }; + + explicit ListPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + generateMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")) + ? ListPageOptions::GenerateListing + : ListPageOptions::NoListing; + } + + ListingAction generateMap = NoListing; +}; + +// Define page options. + +struct DefinePageOptions final +{ + explicit DefinePageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + const QStringList flags = IarewUtils::cppModuleLinkerFlags(qbsProps); + + defineSymbols = IarewUtils::flagValues( + flags, QStringLiteral("--define_symbol")); + } + + QVariantList defineSymbols; +}; + +// Diagnostics page options. + +struct DiagnosticsPageOptions final +{ + explicit DiagnosticsPageOptions(const ProductData &qbsProduct) + { + const auto &qbsProps = qbsProduct.moduleProperties(); + warningsAsErrors = gen::utils::cppIntegerModuleProperty( + qbsProps, QStringLiteral("treatWarningsAsErrors")); + } + + int warningsAsErrors = 0; +}; + +} // namespace + +// Stm8LinkerSettingsGroup + +Stm8LinkerSettingsGroup::Stm8LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + setName(QByteArrayLiteral("ILINK")); + setArchiveVersion(kLinkerArchiveVersion); + setDataVersion(kLinkerDataVersion); + setDataDebugInfo(gen::utils::debugInformation(qbsProduct)); + + const QString buildRootDirectory = gen::utils::buildRootPath(qbsProject); + + buildConfigPage(buildRootDirectory, qbsProduct); + buildLibraryPage(buildRootDirectory, qbsProduct, qbsProductDeps); + buildOptimizationsPage(qbsProduct); + buildOutputPage(qbsProduct); + buildListPage(qbsProduct); + buildDefinePage(qbsProduct); + buildDiagnosticsPage(qbsProduct); + + // Should be called as latest stage! + buildExtraOptionsPage(qbsProduct); +} + +void Stm8LinkerSettingsGroup::buildConfigPage( + const QString &baseDirectory, + const ProductData &qbsProduct) +{ + ConfigPageOptions opts(baseDirectory, qbsProduct); + + if (opts.configFilePaths.count() > 0) { + // Note: IAR IDE does not allow to specify a multiple config files, + // although the IAR linker support it. So, we use followig 'trick': + // we take a first config file and to add it as usual to required items; + // and then an other remainders we forward to the "Extra options page". + const QVariant configPath = opts.configFilePaths.takeFirst(); + // Add 'IlinkIcfOverride' item (Override default). + addOptionsGroup(QByteArrayLiteral("IlinkIcfOverride"), + {1}); + // Add 'IlinkIcfFile' item (Linke configuration file). + addOptionsGroup(QByteArrayLiteral("IlinkIcfFile"), + {configPath}); + + // Add remainder configuration files to the "Extra options page". + if (!opts.configFilePaths.isEmpty()) { + for (QVariant &configPath : opts.configFilePaths) + configPath = QLatin1String("--config ") + configPath.toString(); + + m_extraOptions << opts.configFilePaths; + } + } + + // Add 'IlinkConfigDefines' item (Configuration file + // symbol definitions). + addOptionsGroup(QByteArrayLiteral("IlinkConfigDefines"), + opts.configDefinitions); +} + +void Stm8LinkerSettingsGroup::buildLibraryPage( + const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) +{ + LibraryPageOptions opts(baseDirectory, qbsProduct, qbsProductDeps); + + // Add 'IlinkOverrideProgramEntryLabel' item + // (Override default program entry). + addOptionsGroup(QByteArrayLiteral("IlinkOverrideProgramEntryLabel"), + {1}); + + if (opts.entryPoint.isEmpty()) { + // Add 'IlinkProgramEntryLabelSelect' item + // (Defined by application). + addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabelSelect"), + {1}); + } else { + // Add 'IlinkProgramEntryLabel' item + // (Entry symbol). + addOptionsGroup(QByteArrayLiteral("IlinkProgramEntryLabel"), + {opts.entryPoint}); + } + + // Add 'IlinkAdditionalLibs' item (Additional libraries). + addOptionsGroup(QByteArrayLiteral("IlinkAdditionalLibs"), + {opts.staticLibraries}); +} + +void Stm8LinkerSettingsGroup::buildOptimizationsPage( + const ProductData &qbsProduct) +{ + OptimizationsPageOptions opts(qbsProduct); + + // Add 'IlinkOptMergeDuplSections' item + // (Merge duplicate sections). + addOptionsGroup(QByteArrayLiteral("IlinkOptMergeDuplSections"), + {opts.mergeDuplicateSections}); +} + +void Stm8LinkerSettingsGroup::buildOutputPage( + const ProductData &qbsProduct) +{ + const OutputPageOptions opts(qbsProduct); + + // Add 'IlinkOutputFile' item (Output file name). + addOptionsGroup(QByteArrayLiteral("IlinkOutputFile"), + {opts.outputFile}); + // Add 'IlinkDebugInfoEnable' item + // (Include debug information in output). + addOptionsGroup(QByteArrayLiteral("IlinkDebugInfoEnable"), + {opts.enableDebugInfo}); +} + +void Stm8LinkerSettingsGroup::buildListPage( + const ProductData &qbsProduct) +{ + const ListPageOptions opts(qbsProduct); + // Add 'IlinkMapFile' item (Generate linker map file). + addOptionsGroup(QByteArrayLiteral("IlinkMapFile"), + {opts.generateMap}); +} + +void Stm8LinkerSettingsGroup::buildDefinePage( + const ProductData &qbsProduct) +{ + const DefinePageOptions opts(qbsProduct); + // Add 'IlinkDefines' item (Defined symbols). + addOptionsGroup(QByteArrayLiteral("IlinkDefines"), + opts.defineSymbols); +} + +void Stm8LinkerSettingsGroup::buildDiagnosticsPage( + const ProductData &qbsProduct) +{ + const DiagnosticsPageOptions opts(qbsProduct); + // Add 'IlinkWarningsAreErrors' item (Treat all warnings as errors). + addOptionsGroup(QByteArrayLiteral("IlinkWarningsAreErrors"), + {opts.warningsAsErrors}); +} + +void Stm8LinkerSettingsGroup::buildExtraOptionsPage( + const ProductData &qbsProduct) +{ + Q_UNUSED(qbsProduct) + + if (m_extraOptions.isEmpty()) + return; + + // Add 'IlinkUseExtraOptions' (Use command line options). + addOptionsGroup(QByteArrayLiteral("IlinkUseExtraOptions"), + {1}); + // Add 'IlinkExtraOptions' item (Command line options). + addOptionsGroup(QByteArrayLiteral("IlinkExtraOptions"), + m_extraOptions); +} + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs diff --git a/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h new file mode 100644 index 00000000..b214ebe3 --- /dev/null +++ b/src/plugins/generator/iarew/archs/stm8/stm8linkersettingsgroup_v3.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H +#define QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H + +#include "../../iarewsettingspropertygroup.h" + +namespace qbs { +namespace iarew { +namespace stm8 { +namespace v3 { + +class Stm8LinkerSettingsGroup final : public IarewSettingsPropertyGroup +{ +public: + explicit Stm8LinkerSettingsGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + +private: + void buildConfigPage(const QString &baseDirectory, + const ProductData &qbsProduct); + void buildLibraryPage(const QString &baseDirectory, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps); + void buildOptimizationsPage(const ProductData &qbsProduct); + + + + void buildOutputPage(const ProductData &qbsProduct); + void buildListPage(const ProductData &qbsProduct); + void buildDefinePage(const ProductData &qbsProduct); + void buildDiagnosticsPage(const ProductData &qbsProduct); + void buildExtraOptionsPage(const ProductData &qbsProduct); + + QVariantList m_extraOptions; +}; + +} // namespace v3 +} // namespace stm8 +} // namespace iarew +} // namespace qbs + +#endif // QBS_IAREWSTM8LINKERSETTINGSGROUP_V3_H diff --git a/src/plugins/generator/iarew/iarew.pri b/src/plugins/generator/iarew/iarew.pri new file mode 100644 index 00000000..68a3593f --- /dev/null +++ b/src/plugins/generator/iarew/iarew.pri @@ -0,0 +1 @@ +qbsPluginTarget = iarewgenerator diff --git a/src/plugins/generator/iarew/iarew.pro b/src/plugins/generator/iarew/iarew.pro new file mode 100644 index 00000000..54244951 --- /dev/null +++ b/src/plugins/generator/iarew/iarew.pro @@ -0,0 +1,131 @@ +include(iarew.pri) +include(../../plugins.pri) +include(../../../shared/json/json.pri) + +QT = core + +# Plugin file. + +SOURCES += \ + $$PWD/iarewgeneratorplugin.cpp \ + +# Common files. + +HEADERS += \ + $$PWD/iarewfileversionproperty.h \ + $$PWD/iarewgenerator.h \ + $$PWD/iarewoptionpropertygroup.h \ + $$PWD/iarewproject.h \ + $$PWD/iarewprojectwriter.h \ + $$PWD/iarewsettingspropertygroup.h \ + $$PWD/iarewsourcefilepropertygroup.h \ + $$PWD/iarewsourcefilespropertygroup.h \ + $$PWD/iarewtoolchainpropertygroup.h \ + $$PWD/iarewutils.h \ + $$PWD/iarewversioninfo.h \ + $$PWD/iarewworkspace.h \ + $$PWD/iarewworkspacewriter.h + +SOURCES += \ + $$PWD/iarewfileversionproperty.cpp \ + $$PWD/iarewgenerator.cpp \ + $$PWD/iarewoptionpropertygroup.cpp \ + $$PWD/iarewproject.cpp \ + $$PWD/iarewprojectwriter.cpp \ + $$PWD/iarewsettingspropertygroup.cpp \ + $$PWD/iarewsourcefilepropertygroup.cpp \ + $$PWD/iarewsourcefilespropertygroup.cpp \ + $$PWD/iarewtoolchainpropertygroup.cpp \ + $$PWD/iarewutils.cpp \ + $$PWD/iarewworkspace.cpp \ + $$PWD/iarewworkspacewriter.cpp + +# For ARM architecture. + +HEADERS += \ + $$PWD/archs/arm/armarchiversettingsgroup_v8.h \ + $$PWD/archs/arm/armassemblersettingsgroup_v8.h \ + $$PWD/archs/arm/armbuildconfigurationgroup_v8.h \ + $$PWD/archs/arm/armcompilersettingsgroup_v8.h \ + $$PWD/archs/arm/armgeneralsettingsgroup_v8.h \ + $$PWD/archs/arm/armlinkersettingsgroup_v8.h + +SOURCES += \ + $$PWD/archs/arm/armarchiversettingsgroup_v8.cpp \ + $$PWD/archs/arm/armassemblersettingsgroup_v8.cpp \ + $$PWD/archs/arm/armbuildconfigurationgroup_v8.cpp \ + $$PWD/archs/arm/armcompilersettingsgroup_v8.cpp \ + $$PWD/archs/arm/armgeneralsettingsgroup_v8.cpp \ + $$PWD/archs/arm/armlinkersettingsgroup_v8.cpp + +# For AVR architecture. + +HEADERS += \ + $$PWD/archs/avr/avrarchiversettingsgroup_v7.h \ + $$PWD/archs/avr/avrassemblersettingsgroup_v7.h \ + $$PWD/archs/avr/avrbuildconfigurationgroup_v7.h \ + $$PWD/archs/avr/avrcompilersettingsgroup_v7.h \ + $$PWD/archs/avr/avrgeneralsettingsgroup_v7.h \ + $$PWD/archs/avr/avrlinkersettingsgroup_v7.h + +SOURCES += \ + $$PWD/archs/avr/avrarchiversettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrassemblersettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrbuildconfigurationgroup_v7.cpp \ + $$PWD/archs/avr/avrcompilersettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrgeneralsettingsgroup_v7.cpp \ + $$PWD/archs/avr/avrlinkersettingsgroup_v7.cpp + +# For MCS51 architecture. + +HEADERS += \ + $$PWD/archs/mcs51/mcs51archiversettingsgroup_v10.h \ + $$PWD/archs/mcs51/mcs51assemblersettingsgroup_v10.h \ + $$PWD/archs/mcs51/mcs51buildconfigurationgroup_v10.h \ + $$PWD/archs/mcs51/mcs51compilersettingsgroup_v10.h \ + $$PWD/archs/mcs51/mcs51generalsettingsgroup_v10.h \ + $$PWD/archs/mcs51/mcs51linkersettingsgroup_v10.h + +SOURCES += \ + $$PWD/archs/mcs51/mcs51archiversettingsgroup_v10.cpp \ + $$PWD/archs/mcs51/mcs51assemblersettingsgroup_v10.cpp \ + $$PWD/archs/mcs51/mcs51buildconfigurationgroup_v10.cpp \ + $$PWD/archs/mcs51/mcs51compilersettingsgroup_v10.cpp \ + $$PWD/archs/mcs51/mcs51generalsettingsgroup_v10.cpp \ + $$PWD/archs/mcs51/mcs51linkersettingsgroup_v10.cpp + +# For STM8 architecture. + +HEADERS += \ + $$PWD/archs/stm8/stm8archiversettingsgroup_v3.h \ + $$PWD/archs/stm8/stm8assemblersettingsgroup_v3.h \ + $$PWD/archs/stm8/stm8buildconfigurationgroup_v3.h \ + $$PWD/archs/stm8/stm8compilersettingsgroup_v3.h \ + $$PWD/archs/stm8/stm8generalsettingsgroup_v3.h \ + $$PWD/archs/stm8/stm8linkersettingsgroup_v3.h + +SOURCES += \ + $$PWD/archs/stm8/stm8archiversettingsgroup_v3.cpp \ + $$PWD/archs/stm8/stm8assemblersettingsgroup_v3.cpp \ + $$PWD/archs/stm8/stm8buildconfigurationgroup_v3.cpp \ + $$PWD/archs/stm8/stm8compilersettingsgroup_v3.cpp \ + $$PWD/archs/stm8/stm8generalsettingsgroup_v3.cpp \ + $$PWD/archs/stm8/stm8linkersettingsgroup_v3.cpp + +# For MSP430 architecture. + +HEADERS += \ + $$PWD/archs/msp430/msp430archiversettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430assemblersettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430buildconfigurationgroup_v7.h \ + $$PWD/archs/msp430/msp430compilersettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430generalsettingsgroup_v7.h \ + $$PWD/archs/msp430/msp430linkersettingsgroup_v7.h + +SOURCES += \ + $$PWD/archs/msp430/msp430archiversettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430assemblersettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430buildconfigurationgroup_v7.cpp \ + $$PWD/archs/msp430/msp430compilersettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430generalsettingsgroup_v7.cpp \ + $$PWD/archs/msp430/msp430linkersettingsgroup_v7.cpp diff --git a/src/plugins/generator/iarew/iarew.qbs b/src/plugins/generator/iarew/iarew.qbs new file mode 100644 index 00000000..cf1af83b --- /dev/null +++ b/src/plugins/generator/iarew/iarew.qbs @@ -0,0 +1,130 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + Depends { name: "qbsjson" } + + name: "iarewgenerator" + + files: ["iarewgeneratorplugin.cpp"] + + Group { + name: "IAR EW generator common" + files: [ + "iarewfileversionproperty.cpp", + "iarewfileversionproperty.h", + "iarewgenerator.cpp", + "iarewgenerator.h", + "iarewoptionpropertygroup.cpp", + "iarewoptionpropertygroup.h", + "iarewproject.cpp", + "iarewproject.h", + "iarewprojectwriter.cpp", + "iarewprojectwriter.h", + "iarewsettingspropertygroup.cpp", + "iarewsettingspropertygroup.h", + "iarewsourcefilepropertygroup.cpp", + "iarewsourcefilepropertygroup.h", + "iarewsourcefilespropertygroup.cpp", + "iarewsourcefilespropertygroup.h", + "iarewtoolchainpropertygroup.cpp", + "iarewtoolchainpropertygroup.h", + "iarewutils.cpp", + "iarewutils.h", + "iarewversioninfo.h", + "iarewworkspace.cpp", + "iarewworkspace.h", + "iarewworkspacewriter.cpp", + "iarewworkspacewriter.h", + ] + } + Group { + name: "IAR EW generator for ARM" + prefix: "archs/arm/" + files: [ + "armarchiversettingsgroup_v8.cpp", + "armarchiversettingsgroup_v8.h", + "armassemblersettingsgroup_v8.cpp", + "armassemblersettingsgroup_v8.h", + "armbuildconfigurationgroup_v8.cpp", + "armbuildconfigurationgroup_v8.h", + "armcompilersettingsgroup_v8.cpp", + "armcompilersettingsgroup_v8.h", + "armgeneralsettingsgroup_v8.cpp", + "armgeneralsettingsgroup_v8.h", + "armlinkersettingsgroup_v8.cpp", + "armlinkersettingsgroup_v8.h", + ] + } + Group { + name: "IAR EW generator for AVR" + prefix: "archs/avr/" + files: [ + "avrarchiversettingsgroup_v7.cpp", + "avrarchiversettingsgroup_v7.h", + "avrassemblersettingsgroup_v7.cpp", + "avrassemblersettingsgroup_v7.h", + "avrbuildconfigurationgroup_v7.cpp", + "avrbuildconfigurationgroup_v7.h", + "avrcompilersettingsgroup_v7.cpp", + "avrcompilersettingsgroup_v7.h", + "avrgeneralsettingsgroup_v7.cpp", + "avrgeneralsettingsgroup_v7.h", + "avrlinkersettingsgroup_v7.cpp", + "avrlinkersettingsgroup_v7.h", + ] + } + Group { + name: "IAR EW generator for MCS51" + prefix: "archs/mcs51/" + files: [ + "mcs51archiversettingsgroup_v10.cpp", + "mcs51archiversettingsgroup_v10.h", + "mcs51assemblersettingsgroup_v10.cpp", + "mcs51assemblersettingsgroup_v10.h", + "mcs51buildconfigurationgroup_v10.cpp", + "mcs51buildconfigurationgroup_v10.h", + "mcs51compilersettingsgroup_v10.cpp", + "mcs51compilersettingsgroup_v10.h", + "mcs51generalsettingsgroup_v10.cpp", + "mcs51generalsettingsgroup_v10.h", + "mcs51linkersettingsgroup_v10.cpp", + "mcs51linkersettingsgroup_v10.h", + ] + } + Group { + name: "IAR EW generator for STM8" + prefix: "archs/stm8/" + files: [ + "stm8archiversettingsgroup_v3.cpp", + "stm8archiversettingsgroup_v3.h", + "stm8assemblersettingsgroup_v3.cpp", + "stm8assemblersettingsgroup_v3.h", + "stm8buildconfigurationgroup_v3.cpp", + "stm8buildconfigurationgroup_v3.h", + "stm8compilersettingsgroup_v3.cpp", + "stm8compilersettingsgroup_v3.h", + "stm8generalsettingsgroup_v3.cpp", + "stm8generalsettingsgroup_v3.h", + "stm8linkersettingsgroup_v3.cpp", + "stm8linkersettingsgroup_v3.h", + ] + } + Group { + name: "IAR EW generator for MSP430" + prefix: "archs/msp430/" + files: [ + "msp430archiversettingsgroup_v7.cpp", + "msp430archiversettingsgroup_v7.h", + "msp430assemblersettingsgroup_v7.cpp", + "msp430assemblersettingsgroup_v7.h", + "msp430buildconfigurationgroup_v7.cpp", + "msp430buildconfigurationgroup_v7.h", + "msp430compilersettingsgroup_v7.cpp", + "msp430compilersettingsgroup_v7.h", + "msp430generalsettingsgroup_v7.cpp", + "msp430generalsettingsgroup_v7.h", + "msp430linkersettingsgroup_v7.cpp", + "msp430linkersettingsgroup_v7.h", + ] + } +} diff --git a/src/plugins/generator/iarew/iarewfileversionproperty.cpp b/src/plugins/generator/iarew/iarewfileversionproperty.cpp new file mode 100644 index 00000000..4324405a --- /dev/null +++ b/src/plugins/generator/iarew/iarewfileversionproperty.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewfileversionproperty.h" +#include "iarewversioninfo.h" + +namespace qbs { + +static QByteArray buildFileVersion(const gen::VersionInfo &versionInfo) +{ + switch (versionInfo.marketingVersion()) { + case 3: + case 7: + case 8: + case 10: + return QByteArrayLiteral("3"); + default: + return {}; + } +} + +IarewFileVersionProperty::IarewFileVersionProperty( + const gen::VersionInfo &versionInfo) +{ + setName(QByteArrayLiteral("fileVersion")); + const QByteArray fileVersion = buildFileVersion(versionInfo); + setValue(fileVersion); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewfileversionproperty.h b/src/plugins/generator/iarew/iarewfileversionproperty.h new file mode 100644 index 00000000..2ed56c1e --- /dev/null +++ b/src/plugins/generator/iarew/iarewfileversionproperty.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWFILEVERSIONPROPERTY_H +#define QBS_IAREWFILEVERSIONPROPERTY_H + +#include +#include + +namespace qbs { + +class IarewFileVersionProperty final : public gen::xml::Property +{ +public: + explicit IarewFileVersionProperty( + const gen::VersionInfo &versionInfo); +}; + +} // namespace qbs + +#endif // QBS_IAREWFILEVERSIONPROPERTY_H diff --git a/src/plugins/generator/iarew/iarewgenerator.cpp b/src/plugins/generator/iarew/iarewgenerator.cpp new file mode 100644 index 00000000..c5345a6d --- /dev/null +++ b/src/plugins/generator/iarew/iarewgenerator.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewgenerator.h" +#include "iarewproject.h" +#include "iarewprojectwriter.h" +#include "iarewworkspace.h" +#include "iarewworkspacewriter.h" + +#include + +#include +#include + +#include + +namespace qbs { + +static QString targetFilePath(const QString &baseName, + const QString &baseBuildDirectory) +{ + return QDir(baseBuildDirectory).absoluteFilePath( + baseName + QStringLiteral(".ewp")); +} + +static QString targetFilePath(const GeneratableProductData &product, + const QString &baseBuildDirectory) +{ + return targetFilePath(product.name(), baseBuildDirectory); +} + +static void writeProjectFiles(const std::map> &projects, + const Internal::Logger &logger) +{ + for (const auto &item : projects) { + const QString projectFilePath = item.first; + Internal::FileSaver file(projectFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Internal::Tr::tr("Cannot open %s for writing") + .arg(projectFilePath)); + + std::shared_ptr project = item.second; + IarewProjectWriter writer(file.device()); + if (!(writer.write(project.get()) && file.commit())) + throw ErrorInfo(Internal::Tr::tr("Failed to generate %1") + .arg(projectFilePath)); + + logger.qbsInfo() << Internal::Tr::tr("Generated %1").arg( + QFileInfo(projectFilePath).fileName()); + } +} + +static void writeWorkspace(const std::shared_ptr &wokspace, + const QString &workspaceFilePath, + const Internal::Logger &logger) +{ + Internal::FileSaver file(workspaceFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Internal::Tr::tr("Cannot open %s for writing") + .arg(workspaceFilePath)); + + IarewWorkspaceWriter writer(file.device()); + if (!(writer.write(wokspace.get()) && file.commit())) + throw ErrorInfo(Internal::Tr::tr("Failed to generate %1") + .arg(workspaceFilePath)); + + logger.qbsInfo() << Internal::Tr::tr("Generated %1").arg( + QFileInfo(workspaceFilePath).fileName()); +} + +IarewGenerator::IarewGenerator(const gen::VersionInfo &versionInfo) + : m_versionInfo(versionInfo) +{ +} + +QString IarewGenerator::generatorName() const +{ + return QStringLiteral("iarew%1").arg(m_versionInfo.marketingVersion()); +} + +void IarewGenerator::reset() +{ + m_workspace.reset(); + m_workspaceFilePath.clear(); + m_projects.clear(); +} + +void IarewGenerator::generate() +{ + GeneratableProjectIterator it(project()); + it.accept(this); + + writeProjectFiles(m_projects, logger()); + writeWorkspace(m_workspace, m_workspaceFilePath, logger()); + + reset(); +} + +void IarewGenerator::visitProject(const GeneratableProject &project) +{ + const QDir buildDir = project.baseBuildDirectory(); + + m_workspaceFilePath = buildDir.absoluteFilePath( + project.name() + QStringLiteral(".eww")); + m_workspace = std::make_shared(m_workspaceFilePath); +} + +void IarewGenerator::visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) +{ + Q_UNUSED(project) + Q_UNUSED(projectData) +} + +void IarewGenerator::visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) +{ + Q_UNUSED(projectData); + const QString projectFilePath = targetFilePath( + productData, project.baseBuildDirectory().absolutePath()); + const auto targetProject = std::make_shared( + project, productData, + m_versionInfo); + + m_projects.insert({projectFilePath, targetProject}); + m_workspace->addProject(projectFilePath); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewgenerator.h b/src/plugins/generator/iarew/iarewgenerator.h new file mode 100644 index 00000000..fa1d93bc --- /dev/null +++ b/src/plugins/generator/iarew/iarewgenerator.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWGENERATOR_H +#define QBS_IAREWGENERATOR_H + +#include "iarewversioninfo.h" + +#include +#include + +namespace qbs { + +class IarewProject; +class IarewWorkspace; + +class IarewGenerator final : public ProjectGenerator, private IGeneratableProjectVisitor +{ +public: + explicit IarewGenerator(const gen::VersionInfo &versionInfo); + + QString generatorName() const final; + void generate() final; + +private: + void reset(); + + void visitProject(const GeneratableProject &project) final; + void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) final; + void visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) final; + + const gen::VersionInfo m_versionInfo; + std::shared_ptr m_workspace; + QString m_workspaceFilePath; + std::map> m_projects; +}; + +} // namespace qbs + +#endif // QBS_IAREWGENERATOR_H diff --git a/src/plugins/generator/iarew/iarewgeneratorplugin.cpp b/src/plugins/generator/iarew/iarewgeneratorplugin.cpp new file mode 100644 index 00000000..bdd15c48 --- /dev/null +++ b/src/plugins/generator/iarew/iarewgeneratorplugin.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "iarewgenerator.h" +#include "iarewversioninfo.h" + +#include +#include + +static void QbsIarewGeneratorPluginLoad() +{ + for (const auto &info : qbs::IarewVersionInfo::knownVersions) { + qbs::ProjectGeneratorManager::registerGenerator( + std::make_shared(info)); + } +} + +static void QbsIarewGeneratorPluginUnload() +{ +} + +#ifndef GENERATOR_EXPORT +#if defined(WIN32) || defined(_WIN32) +#define GENERATOR_EXPORT __declspec(dllexport) +#else +#define GENERATOR_EXPORT __attribute__((visibility("default"))) +#endif +#endif + +QBS_REGISTER_STATIC_PLUGIN(extern "C" GENERATOR_EXPORT, iarewgenerator, + QbsIarewGeneratorPluginLoad, QbsIarewGeneratorPluginUnload) diff --git a/src/plugins/generator/iarew/iarewoptionpropertygroup.cpp b/src/plugins/generator/iarew/iarewoptionpropertygroup.cpp new file mode 100644 index 00000000..c44b30ed --- /dev/null +++ b/src/plugins/generator/iarew/iarewoptionpropertygroup.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewoptionpropertygroup.h" + +namespace qbs { + +IarewOptionPropertyGroup::IarewOptionPropertyGroup( + const QByteArray &name, QVariantList states, int version) + : gen::xml::PropertyGroup(QByteArrayLiteral("option")) +{ + // Append name property item. + appendChild(QByteArrayLiteral("name"), + name); + + // Append version property item. + if (version >= 0) + appendChild(QByteArrayLiteral("version"), + version); + + // Append state property items. + for (auto &state : states) { + if (state.isNull()) + continue; + appendChild(QByteArrayLiteral("state"), + std::move(state)); + } +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewoptionpropertygroup.h b/src/plugins/generator/iarew/iarewoptionpropertygroup.h new file mode 100644 index 00000000..d80df283 --- /dev/null +++ b/src/plugins/generator/iarew/iarewoptionpropertygroup.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWOPTIONPROPERTYGROUP_H +#define QBS_IAREWOPTIONPROPERTYGROUP_H + +#include + +//#include + +namespace qbs { + +class IarewOptionPropertyGroup final + : public gen::xml::PropertyGroup +{ +public: + explicit IarewOptionPropertyGroup(const QByteArray &name, QVariantList states, + int version = -1); +}; + +} // namespace qbs + +#endif // QBS_IAREWOPTIONPROPERTYGROUP_H diff --git a/src/plugins/generator/iarew/iarewproject.cpp b/src/plugins/generator/iarew/iarewproject.cpp new file mode 100644 index 00000000..0387ae11 --- /dev/null +++ b/src/plugins/generator/iarew/iarewproject.cpp @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewfileversionproperty.h" +#include "iarewproject.h" +#include "iarewsourcefilespropertygroup.h" +#include "iarewutils.h" +#include "iarewversioninfo.h" + +#include "archs/arm/armbuildconfigurationgroup_v8.h" +#include "archs/avr/avrbuildconfigurationgroup_v7.h" +#include "archs/mcs51/mcs51buildconfigurationgroup_v10.h" +#include "archs/stm8/stm8buildconfigurationgroup_v3.h" +#include "archs/msp430/msp430buildconfigurationgroup_v7.h" + +#include + +#include + +namespace qbs { + +IarewProject::IarewProject(const GeneratableProject &genProject, + const GeneratableProductData &genProduct, + const gen::VersionInfo &versionInfo) +{ + Q_ASSERT(genProject.projects.size() == genProject.commandLines.size()); + Q_ASSERT(genProject.projects.size() == genProduct.data.size()); + + // Create available configuration group factories. + m_factories.push_back(std::make_unique< + iarew::arm::v8::ArmBuildConfigurationGroupFactory>()); + m_factories.push_back(std::make_unique< + iarew::avr::v7::AvrBuildConfigurationGroupFactory>()); + m_factories.push_back(std::make_unique< + iarew::mcs51::v10::Mcs51BuildConfigurationGroupFactory>()); + m_factories.push_back(std::make_unique< + iarew::stm8::v3::Stm8BuildConfigurationGroupFactory>()); + m_factories.push_back(std::make_unique< + iarew::msp430::v7::Msp430BuildConfigurationGroupFactory>()); + + // Construct file version item. + appendChild(versionInfo); + + // Construct all build configurations items. + const int configsCount = std::max(genProject.projects.size(), + genProduct.data.size()); + for (auto configIndex = 0; configIndex < configsCount; ++configIndex) { + const qbs::Project qbsProject = genProject.projects + .values().at(configIndex); + const ProductData qbsProduct = genProduct.data.values().at(configIndex); + const QString confName = gen::utils::buildConfigurationName(qbsProject); + const std::vector qbsProductDeps = gen::utils::dependenciesOf + (qbsProduct, genProject, confName); + + const auto arch = gen::utils::architecture(qbsProject); + if (arch == gen::utils::Architecture::Unknown) + throw ErrorInfo(Internal::Tr::tr("Target architecture is not set," + " please use the 'profile' option")); + + // Construct the build configuration item, which are depend from + // the architecture and the version. + const auto factoryEnd = m_factories.cend(); + const auto factoryIt = std::find_if( + m_factories.cbegin(), factoryEnd, + [arch, versionInfo](const auto &factory) { + return factory->canCreate(arch, versionInfo.version()); + }); + if (factoryIt == factoryEnd) { + throw ErrorInfo(Internal::Tr::tr("Incompatible target architecture '%1'" + " for IAR EW version %2xxx") + .arg(gen::utils::architectureName(arch)) + .arg(versionInfo.marketingVersion())); + } + auto configGroup = (*factoryIt)->create( + qbsProject, qbsProduct, qbsProductDeps); + appendChild(std::move(configGroup)); + } + + // Construct all file groups items. + QMapIterator dataIt(genProduct.data); + while (dataIt.hasNext()) { + dataIt.next(); + const auto groups = dataIt.value().groups(); + for (const auto &group : groups) { + // Ignore disabled groups (e.g. when its condition property is false). + if (!group.isEnabled()) + continue; + auto sourceArtifacts = group.sourceArtifacts(); + // Remove the linker script artifacts. + Internal::removeIf(sourceArtifacts, [](const auto &artifact) { + const auto tags = artifact.fileTags(); + return tags.contains(QLatin1String("linkerscript")); + }); + + if (sourceArtifacts.isEmpty()) + continue; + appendChild( + genProject, group.name(), sourceArtifacts); + } + } +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewproject.h b/src/plugins/generator/iarew/iarewproject.h new file mode 100644 index 00000000..df260fcd --- /dev/null +++ b/src/plugins/generator/iarew/iarewproject.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWPROJECT_H +#define QBS_IAREWPROJECT_H + +#include +#include +#include + +#include + +namespace qbs { + +class IarewProject final : public gen::xml::Project +{ +public: + explicit IarewProject(const GeneratableProject &genProject, + const GeneratableProductData &genProduct, + const gen::VersionInfo &versionInfo); +private: + std::vector> m_factories; +}; + +} // namespace qbs + +#endif // QBS_IAREWPROJECT_H diff --git a/src/plugins/generator/iarew/iarewprojectwriter.cpp b/src/plugins/generator/iarew/iarewprojectwriter.cpp new file mode 100644 index 00000000..fcb2103f --- /dev/null +++ b/src/plugins/generator/iarew/iarewprojectwriter.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewprojectwriter.h" + +namespace qbs { + +IarewProjectWriter::IarewProjectWriter(std::ostream *device) + : gen::xml::ProjectWriter(device) +{ +} + +void IarewProjectWriter::visitProjectStart(const gen::xml::Project *project) +{ + Q_UNUSED(project) + writer()->writeStartElement(QStringLiteral("project")); +} + +void IarewProjectWriter::visitProjectEnd(const gen::xml::Project *project) +{ + Q_UNUSED(project) + writer()->writeEndElement(); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewprojectwriter.h b/src/plugins/generator/iarew/iarewprojectwriter.h new file mode 100644 index 00000000..9356dbec --- /dev/null +++ b/src/plugins/generator/iarew/iarewprojectwriter.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWPROJECTWRITER_H +#define QBS_IAREWPROJECTWRITER_H + +#include + +namespace qbs { + +class IarewProjectWriter final : public gen::xml::ProjectWriter +{ + Q_DISABLE_COPY(IarewProjectWriter) +public: + explicit IarewProjectWriter(std::ostream *device); + +private: + void visitProjectStart(const gen::xml::Project *project) final; + void visitProjectEnd(const gen::xml::Project *project) final; +}; + +} // namespace qbs + +#endif // QBS_IAREWPROJECTWRITER_H diff --git a/src/plugins/generator/iarew/iarewsettingspropertygroup.cpp b/src/plugins/generator/iarew/iarewsettingspropertygroup.cpp new file mode 100644 index 00000000..a07d59e0 --- /dev/null +++ b/src/plugins/generator/iarew/iarewsettingspropertygroup.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewoptionpropertygroup.h" +#include "iarewsettingspropertygroup.h" + +namespace qbs { + +constexpr int kDataWantNonLocalPropertyValue = 1; + +IarewSettingsPropertyGroup::IarewSettingsPropertyGroup() + : gen::xml::PropertyGroup(QByteArrayLiteral("settings")) +{ + // Append name property item. + m_nameProperty = appendChild( + QByteArrayLiteral("name"), QVariant{}); + + // Append archive version property item. + m_archiveVersionProperty = appendChild( + QByteArrayLiteral("archiveVersion"), QVariant{}); + + // Append data property group item. + m_dataPropertyGroup = appendChild( + QByteArrayLiteral("data")); + // Append data version property item. + m_dataVersionProperty = m_dataPropertyGroup->appendChild< + gen::xml::Property>( + QByteArrayLiteral("version"), QVariant{}); + // Append data want non-local property item. + m_dataPropertyGroup->appendChild( + QByteArrayLiteral("wantNonLocal"), + kDataWantNonLocalPropertyValue); + // Append data debug property item. + m_dataDebugProperty = m_dataPropertyGroup->appendChild< + gen::xml::Property>( + QByteArrayLiteral("debug"), QVariant{}); +} + +void IarewSettingsPropertyGroup::setName(const QByteArray &name) +{ + // There is no way to move-construct a QVariant from T, thus name is shallow-copied + m_nameProperty->setValue(QVariant(name)); +} + +QByteArray IarewSettingsPropertyGroup::name() const +{ + return m_nameProperty->value().toByteArray(); +} + +void IarewSettingsPropertyGroup::setArchiveVersion( + int archiveVersion) +{ + m_archiveVersionProperty->setValue(archiveVersion); +} + +int IarewSettingsPropertyGroup::archiveVersion() const +{ + return m_archiveVersionProperty->value().toInt(); +} + +void IarewSettingsPropertyGroup::setDataVersion(int dataVersion) +{ + m_dataVersionProperty->setValue(dataVersion); +} + +void IarewSettingsPropertyGroup::setDataDebugInfo(int debugInfo) +{ + m_dataDebugProperty->setValue(debugInfo); +} + +void IarewSettingsPropertyGroup::addOptionsGroup( + const QByteArray &name, + QVariantList states, + int version) +{ + m_dataPropertyGroup->appendChild(name, std::move(states), version); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewsettingspropertygroup.h b/src/plugins/generator/iarew/iarewsettingspropertygroup.h new file mode 100644 index 00000000..b1feebcc --- /dev/null +++ b/src/plugins/generator/iarew/iarewsettingspropertygroup.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSETTINGSPROPERTYGROUP_H +#define QBS_IAREWSETTINGSPROPERTYGROUP_H + +#include + +namespace qbs { + +class IarewSettingsPropertyGroup : public gen::xml::PropertyGroup +{ +public: + explicit IarewSettingsPropertyGroup(); + + void setName(const QByteArray &name); + QByteArray name() const; + + void setArchiveVersion(int archiveVersion); + int archiveVersion() const; + +protected: + void setDataVersion(int dataVersion); + void setDataDebugInfo(int debugInfo); + + void addOptionsGroup(const QByteArray &name, QVariantList states, + int version = -1); + +private: + // Don't delete all this RAW pointers explicitly! + gen::xml::Property *m_nameProperty = nullptr; + gen::xml::Property *m_archiveVersionProperty = nullptr; + + gen::xml::Property *m_dataPropertyGroup = nullptr; + gen::xml::Property *m_dataVersionProperty = nullptr; + gen::xml::Property *m_dataDebugProperty = nullptr; +}; + +} // namespace qbs + +#endif // QBS_IAREWSETTINGSPROPERTYGROUP_H diff --git a/src/plugins/generator/iarew/iarewsourcefilepropertygroup.cpp b/src/plugins/generator/iarew/iarewsourcefilepropertygroup.cpp new file mode 100644 index 00000000..33c26e8b --- /dev/null +++ b/src/plugins/generator/iarew/iarewsourcefilepropertygroup.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewsourcefilepropertygroup.h" +#include "iarewutils.h" + +#include + +#include + +namespace qbs { + +IarewSourceFilePropertyGroup::IarewSourceFilePropertyGroup( + const GeneratableProject &genProject, + const ArtifactData &sourceArtifact) + : gen::xml::PropertyGroup(QByteArrayLiteral("file")) +{ + // Create file path property item. + const QString fullFilePath = sourceArtifact.filePath(); + const QString relativeFilePath = IarewUtils::projectRelativeFilePath( + genProject.baseBuildDirectory().absolutePath(), + fullFilePath); + appendChild(QByteArrayLiteral("name"), + relativeFilePath); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewsourcefilepropertygroup.h b/src/plugins/generator/iarew/iarewsourcefilepropertygroup.h new file mode 100644 index 00000000..6d008357 --- /dev/null +++ b/src/plugins/generator/iarew/iarewsourcefilepropertygroup.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSOURCEFILEPROPERTYGROUP_H +#define QBS_IAREWSOURCEFILEPROPERTYGROUP_H + +#include + +namespace qbs { + +class ArtifactData; +struct GeneratableProject; + +class IarewSourceFilePropertyGroup final + : public gen::xml::PropertyGroup +{ +public: + explicit IarewSourceFilePropertyGroup( + const GeneratableProject &genProject, + const ArtifactData &sourceArtifact); +}; + +} // namespace qbs + +#endif // QBS_IAREWSOURCEFILEPROPERTYGROUP_H diff --git a/src/plugins/generator/iarew/iarewsourcefilespropertygroup.cpp b/src/plugins/generator/iarew/iarewsourcefilespropertygroup.cpp new file mode 100644 index 00000000..adb5925b --- /dev/null +++ b/src/plugins/generator/iarew/iarewsourcefilespropertygroup.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewsourcefilepropertygroup.h" +#include "iarewsourcefilespropertygroup.h" + +#include + +#include + +namespace qbs { + +IarewSourceFilesPropertyGroup::IarewSourceFilesPropertyGroup( + const GeneratableProject &genProject, + const QString &filesGroupName, + const QList &sourceFiles) + : gen::xml::PropertyGroup(QByteArrayLiteral("group")) +{ + // Create group name property item. + appendChild(QByteArrayLiteral("name"), + filesGroupName); + + // Create file paths property items. + for (const auto &sourceFile : sourceFiles) + appendChild(genProject, + sourceFile); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewsourcefilespropertygroup.h b/src/plugins/generator/iarew/iarewsourcefilespropertygroup.h new file mode 100644 index 00000000..8d8a4be0 --- /dev/null +++ b/src/plugins/generator/iarew/iarewsourcefilespropertygroup.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWSOURCEFILESPROPERTYGROUP_H +#define QBS_IAREWSOURCEFILESPROPERTYGROUP_H + +#include + +namespace qbs { + +class IarewSourceFilesPropertyGroup final + : public gen::xml::PropertyGroup +{ +public: + explicit IarewSourceFilesPropertyGroup( + const GeneratableProject &genProject, + const QString &filesGroupName, + const QList &sourceFiles); +}; + +} // namespace qbs + +#endif // QBS_IAREWSOURCEFILESPROPERTYGROUP_H diff --git a/src/plugins/generator/iarew/iarewtoolchainpropertygroup.cpp b/src/plugins/generator/iarew/iarewtoolchainpropertygroup.cpp new file mode 100644 index 00000000..dba5015b --- /dev/null +++ b/src/plugins/generator/iarew/iarewtoolchainpropertygroup.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewtoolchainpropertygroup.h" + +namespace qbs { + +IarewToolchainPropertyGroup::IarewToolchainPropertyGroup( + const QByteArray &toolchainName) + : gen::xml::PropertyGroup(QByteArrayLiteral("toolchain")) +{ + // Append toolchain name property item. + appendProperty(QByteArrayLiteral("name"), toolchainName); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewtoolchainpropertygroup.h b/src/plugins/generator/iarew/iarewtoolchainpropertygroup.h new file mode 100644 index 00000000..e5bd6f07 --- /dev/null +++ b/src/plugins/generator/iarew/iarewtoolchainpropertygroup.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWTOOLCHAINPROPERTYGROUP_H +#define QBS_IAREWTOOLCHAINPROPERTYGROUP_H + +#include + +namespace qbs { + +class IarewToolchainPropertyGroup final + : public gen::xml::PropertyGroup +{ +public: + explicit IarewToolchainPropertyGroup( + const QByteArray &toolchainName); +}; + +} // namespace qbs + +#endif // QBS_IAREWTOOLCHAINPROPERTYGROUP_H diff --git a/src/plugins/generator/iarew/iarewutils.cpp b/src/plugins/generator/iarew/iarewutils.cpp new file mode 100644 index 00000000..7196a391 --- /dev/null +++ b/src/plugins/generator/iarew/iarewutils.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewutils.h" + +#include + +namespace qbs { +namespace IarewUtils { + +QString toolkitRootPath(const ProductData &qbsProduct) +{ + QDir dir(qbsProduct.moduleProperties() + .getModuleProperty(Internal::StringConstants::cppModule(), + QStringLiteral("toolchainInstallPath")) + .toString()); + dir.cdUp(); + return dir.absolutePath(); +} + +QString dlibToolkitRootPath(const ProductData &qbsProduct) +{ + return toolkitRootPath(qbsProduct) + QLatin1String("/lib/dlib"); +} + +QString clibToolkitRootPath(const ProductData &qbsProduct) +{ + return toolkitRootPath(qbsProduct) + QLatin1String("/lib/clib"); +} + +QString libToolkitRootPath(const ProductData &qbsProduct) +{ + return toolkitRootPath(qbsProduct) + QLatin1String("/lib"); +} + +QString toolkitRelativeFilePath(const QString &basePath, + const QString &fullFilePath) +{ + return QLatin1String("$TOOLKIT_DIR$/") + + gen::utils::relativeFilePath(basePath, fullFilePath); +} + +QString projectRelativeFilePath(const QString &basePath, + const QString &fullFilePath) +{ + return QLatin1String("$PROJ_DIR$/") + + gen::utils::relativeFilePath(basePath, fullFilePath); +} + +OutputBinaryType outputBinaryType(const ProductData &qbsProduct) +{ + const auto &qbsProductType = qbsProduct.type(); + if (qbsProductType.contains(QLatin1String("application"))) + return ApplicationOutputType; + if (qbsProductType.contains(QLatin1String("staticlibrary"))) + return LibraryOutputType; + return ApplicationOutputType; +} + +QString flagValue(const QStringList &flags, const QString &flagKey) +{ + // Seach for full 'flagKey' option matching. + const auto flagBegin = flags.cbegin(); + const auto flagEnd = flags.cend(); + auto flagIt = std::find_if(flagBegin, flagEnd, [flagKey](const QString &flag) { + return flag == flagKey; + }); + if (flagIt == flagEnd) { + // Search for start/end of 'flagKey' matching. + flagIt = std::find_if(flagBegin, flagEnd, [flagKey](const QString &flag) { + return flag.startsWith(flagKey) || flag.endsWith(flagKey); + }); + if (flagIt == flagEnd) + return {}; + } + + QString value; + // Check that option is in form of 'flagKey='. + if (flagIt->contains(QLatin1Char('='))) { + value = flagIt->split(QLatin1Char('=')).at(1).trimmed(); + } else if (flagKey.count() < flagIt->count()) { + // In this case an option is in form of 'flagKey'. + value = flagIt->mid(flagKey.count()).trimmed(); + } else { + // In this case an option is in form of 'flagKey '. + ++flagIt; + if (flagIt < flagEnd) + value = (*flagIt).trimmed(); + else + return {}; + } + return value; +} + +QVariantList flagValues(const QStringList &flags, const QString &flagKey) +{ + QVariantList values; + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (*flagIt != flagKey) + continue; + ++flagIt; + values.push_back(*flagIt); + } + return values; +} + +QStringList cppModuleCompilerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags"), QStringLiteral("cFlags"), + QStringLiteral("cppFlags"), QStringLiteral("cxxFlags"), + QStringLiteral("commonCompilerFlags")}); +} + +QStringList cppModuleAssemblerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); +} + +QStringList cppModuleLinkerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags"), + QStringLiteral("driverLinkerFlags")}); +} + +} // namespace IarewUtils +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewutils.h b/src/plugins/generator/iarew/iarewutils.h new file mode 100644 index 00000000..2d32ac18 --- /dev/null +++ b/src/plugins/generator/iarew/iarewutils.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWUTILS_H +#define QBS_IAREWUTILS_H + +#include + +#include + +namespace qbs { +namespace IarewUtils { + +enum OutputBinaryType { + ApplicationOutputType, + LibraryOutputType +}; + +OutputBinaryType outputBinaryType(const ProductData &qbsProduct); + +QString toolkitRootPath(const ProductData &qbsProduct); + +QString dlibToolkitRootPath(const ProductData &qbsProduct); + +QString clibToolkitRootPath(const ProductData &qbsProduct); + +QString libToolkitRootPath(const ProductData &qbsProduct); + +QString toolkitRelativeFilePath(const QString &basePath, + const QString &fullFilePath); + +QString projectRelativeFilePath(const QString &basePath, + const QString &fullFilePath); + +QString flagValue(const QStringList &flags, const QString &flagKey); + +QVariantList flagValues(const QStringList &flags, const QString &flagKey); + +QStringList cppModuleCompilerFlags(const PropertyMap &qbsProps); + +QStringList cppModuleAssemblerFlags(const PropertyMap &qbsProps); + +QStringList cppModuleLinkerFlags(const PropertyMap &qbsProps); + +} // namespace IarewUtils +} // namespace qbs + +#endif // QBS_IAREWUTILS_H diff --git a/src/plugins/generator/iarew/iarewversioninfo.h b/src/plugins/generator/iarew/iarewversioninfo.h new file mode 100644 index 00000000..3dc45955 --- /dev/null +++ b/src/plugins/generator/iarew/iarewversioninfo.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_IAREWVERSIONINFO_H +#define QBS_IAREWVERSIONINFO_H + +#include +#include + +namespace qbs { +namespace IarewVersionInfo { + +constexpr gen::VersionInfo knownVersions[] = { + {Version(8), {gen::utils::Architecture::Arm}}, + {Version(7), {gen::utils::Architecture::Avr, + gen::utils::Architecture::Msp430}}, + {Version(10), {gen::utils::Architecture::Mcs51}}, + {Version(3), {gen::utils::Architecture::Stm8}}, +}; + +} // namespace IarewVersionInfo +} // namespace qbs + +#endif // QBS_IAREWVERSIONINFO_H diff --git a/src/plugins/generator/iarew/iarewworkspace.cpp b/src/plugins/generator/iarew/iarewworkspace.cpp new file mode 100644 index 00000000..bfe22aea --- /dev/null +++ b/src/plugins/generator/iarew/iarewworkspace.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "iarewworkspace.h" + +#include + +namespace qbs { + +IarewWorkspace::IarewWorkspace(const QString &workspacePath) + : gen::xml::Workspace(workspacePath) +{ + appendChild( + QByteArrayLiteral("batchBuild")); +} + +void IarewWorkspace::addProject(const QString &projectFilePath) +{ + const QString relativeProjectPath = QLatin1String("$WS_DIR$/") + + m_baseDirectory.relativeFilePath(projectFilePath); + + const auto projectGroup = appendChild( + QByteArrayLiteral("project")); + projectGroup->appendProperty("path", relativeProjectPath); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewworkspace.h b/src/plugins/generator/iarew/iarewworkspace.h new file mode 100644 index 00000000..ea14e417 --- /dev/null +++ b/src/plugins/generator/iarew/iarewworkspace.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_IAREWWORKSPACE_H +#define QBS_IAREWWORKSPACE_H + +#include + +#include + +namespace qbs { + +class IarewWorkspace final : public gen::xml::Workspace +{ +public: + explicit IarewWorkspace(const QString &workspacePath); + void addProject(const QString &projectPath) final; +}; + +} // namespace qbs + +#endif // QBS_IAREWWORKSPACE_H diff --git a/src/plugins/generator/iarew/iarewworkspacewriter.cpp b/src/plugins/generator/iarew/iarewworkspacewriter.cpp new file mode 100644 index 00000000..b06080e3 --- /dev/null +++ b/src/plugins/generator/iarew/iarewworkspacewriter.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "iarewworkspacewriter.h" + +namespace qbs { + +IarewWorkspaceWriter::IarewWorkspaceWriter(std::ostream *device) + : gen::xml::WorkspaceWriter(device) +{ +} + +void IarewWorkspaceWriter::visitWorkspaceStart(const gen::xml::Workspace *workspace) +{ + Q_UNUSED(workspace) + writer()->writeStartElement(QStringLiteral("workspace")); +} + +void IarewWorkspaceWriter::visitWorkspaceEnd(const gen::xml::Workspace *workspace) +{ + Q_UNUSED(workspace) + writer()->writeEndElement(); +} + +} // namespace qbs diff --git a/src/plugins/generator/iarew/iarewworkspacewriter.h b/src/plugins/generator/iarew/iarewworkspacewriter.h new file mode 100644 index 00000000..e60b102d --- /dev/null +++ b/src/plugins/generator/iarew/iarewworkspacewriter.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_IAREWWORKSPACEWRITER_H +#define QBS_IAREWWORKSPACEWRITER_H + +#include + +namespace qbs { + +class IarewWorkspaceWriter final : public gen::xml::WorkspaceWriter +{ + Q_DISABLE_COPY(IarewWorkspaceWriter) +public: + explicit IarewWorkspaceWriter(std::ostream *device); + +private: + void visitWorkspaceStart(const gen::xml::Workspace *workspace) final; + void visitWorkspaceEnd(const gen::xml::Workspace *workspace) final; +}; + +} // namespace qbs + +#endif // QBS_IAREWWORKSPACEWRITER_H diff --git a/src/plugins/generator/keiluv/CMakeLists.txt b/src/plugins/generator/keiluv/CMakeLists.txt new file mode 100644 index 00000000..3b4afbe1 --- /dev/null +++ b/src/plugins/generator/keiluv/CMakeLists.txt @@ -0,0 +1,80 @@ +set(COMMON_SOURCES + keiluvfilesgroupspropertygroup.cpp + keiluvfilesgroupspropertygroup.h + keiluvgenerator.cpp + keiluvgenerator.h + keiluvgeneratorplugin.cpp + keiluvproject.cpp + keiluvproject.h + keiluvprojectwriter.cpp + keiluvprojectwriter.h + keiluvutils.cpp + keiluvutils.h + keiluvversioninfo.h + keiluvworkspace.cpp + keiluvworkspace.h + keiluvworkspacewriter.cpp + keiluvworkspacewriter.h + ) + +set(ARCHS_ARM_SOURCES + armbuildtargetgroup_v5.cpp + armbuildtargetgroup_v5.h + armcommonpropertygroup_v5.cpp + armcommonpropertygroup_v5.h + armdebugoptiongroup_v5.cpp + armdebugoptiongroup_v5.h + armdlloptiongroup_v5.cpp + armdlloptiongroup_v5.h + armtargetassemblergroup_v5.cpp + armtargetassemblergroup_v5.h + armtargetcommonoptionsgroup_v5.cpp + armtargetcommonoptionsgroup_v5.h + armtargetcompilergroup_v5.cpp + armtargetcompilergroup_v5.h + armtargetgroup_v5.cpp + armtargetgroup_v5.h + armtargetlinkergroup_v5.cpp + armtargetlinkergroup_v5.h + armtargetmiscgroup_v5.cpp + armtargetmiscgroup_v5.h + armutilitiesgroup_v5.cpp + armutilitiesgroup_v5.h + ) +list_transform_prepend(ARCHS_ARM_SOURCES archs/arm/) + +set(ARCHS_MCS51_SOURCES + mcs51buildtargetgroup_v5.cpp + mcs51buildtargetgroup_v5.h + mcs51commonpropertygroup_v5.cpp + mcs51commonpropertygroup_v5.h + mcs51debugoptiongroup_v5.cpp + mcs51debugoptiongroup_v5.h + mcs51dlloptiongroup_v5.cpp + mcs51dlloptiongroup_v5.h + mcs51targetassemblergroup_v5.cpp + mcs51targetassemblergroup_v5.h + mcs51targetcommonoptionsgroup_v5.cpp + mcs51targetcommonoptionsgroup_v5.h + mcs51targetcompilergroup_v5.cpp + mcs51targetcompilergroup_v5.h + mcs51targetgroup_v5.cpp + mcs51targetgroup_v5.h + mcs51targetlinkergroup_v5.cpp + mcs51targetlinkergroup_v5.h + mcs51targetmiscgroup_v5.cpp + mcs51targetmiscgroup_v5.h + mcs51utilitiesgroup_v5.cpp + mcs51utilitiesgroup_v5.h + mcs51utils.cpp + mcs51utils.h + ) +list_transform_prepend(ARCHS_MCS51_SOURCES archs/mcs51/) + +add_qbs_plugin(keiluvgenerator + DEPENDS qbscore qbsjson + SOURCES + ${COMMON_SOURCES} + ${ARCHS_ARM_SOURCES} + ${ARCHS_MCS51_SOURCES} + ) diff --git a/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.cpp new file mode 100644 index 00000000..c5cb5f04 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armbuildtargetgroup_v5.h" +#include "armcommonpropertygroup_v5.h" +#include "armdebugoptiongroup_v5.h" +#include "armdlloptiongroup_v5.h" +#include "armtargetcommonoptionsgroup_v5.h" +#include "armtargetgroup_v5.h" +#include "armutilitiesgroup_v5.h" + +#include "../../keiluvconstants.h" +#include "../../keiluvfilesgroupspropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmBuildTargetGroup::ArmBuildTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("Target") +{ + // Append target name item (it is a build configuration name). + const QString targetName = gen::utils::buildConfigurationName( + qbsProject); + appendProperty(QByteArrayLiteral("TargetName"), targetName); + // Append toolset number group item. + appendChild(QByteArrayLiteral("ToolsetNumber"), + QByteArrayLiteral("0x4")); + // Append toolset name group item. + appendChild(QByteArrayLiteral("ToolsetName"), + QByteArrayLiteral("ARM-ADS")); + + // Append target option group item. + const auto targetOptionGroup = appendChild( + QByteArrayLiteral("TargetOption")); + + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + + // Append files group. + appendChild(qbsProject, qbsProduct, + qbsProductDeps); +} + +bool ArmBuildTargetGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Arm + && version.majorVersion() == qbs::KeiluvConstants::v5::kUVisionVersion; +} + +std::unique_ptr +ArmBuildTargetGroupFactory::create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new ArmBuildTargetGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.h new file mode 100644 index 00000000..9b8d9fe2 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armbuildtargetgroup_v5.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMBUILDTARGETGROUP_V5_H +#define QBS_KEILUVARMBUILDTARGETGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmBuildTargetGroup final : public gen::xml::PropertyGroup +{ +private: + explicit ArmBuildTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class ArmBuildTargetGroupFactory; +}; + +class ArmBuildTargetGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMBUILDTARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.cpp new file mode 100644 index 00000000..e7a73823 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armcommonpropertygroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmCommonPropertyGroup::ArmCommonPropertyGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("CommonProperty") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.h new file mode 100644 index 00000000..4d45decc --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armcommonpropertygroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMCOMMONPROPERTYGROUP_V5_H +#define QBS_KEILUVARMCOMMONPROPERTYGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmCommonPropertyGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmCommonPropertyGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_MCS51COMMONPROPERTYGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.cpp new file mode 100644 index 00000000..553df646 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armdebugoptiongroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmDebugOptionGroup::ArmDebugOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("DebugOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.h new file mode 100644 index 00000000..22d5bb88 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armdebugoptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMDEBUGOPTIONGROUP_V5_H +#define QBS_KEILUVARMDEBUGOPTIONGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmDebugOptionGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmDebugOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMDEBUGOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.cpp new file mode 100644 index 00000000..9e1bdff0 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armdlloptiongroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmDllOptionGroup::ArmDllOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("DllOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.h new file mode 100644 index 00000000..948eb156 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armdlloptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMDLLOPTIONGROUP_V5_H +#define QBS_KEILUVARMDLLOPTIONGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmDllOptionGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmDllOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMDLLOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.cpp new file mode 100644 index 00000000..424cb335 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetassemblergroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +namespace { + +struct AssemblerPageOptions final +{ + explicit AssemblerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleAssemblerFlags(qbsProps); + + // Read-only position independent. + enableRopi = flags.contains(QLatin1String("/ropi")); + // Read-write position independent. + enableRwpi = flags.contains(QLatin1String("/rwpi")); + // Enable thumb mode. + enableThumbMode = flags.contains(QLatin1String("--16")); + // Split load and store multiple. + splitLdm = flags.contains(QLatin1String("--split_ldm")); + // Generation code. + generateExecuteOnlyCode = flags.contains(QLatin1String("--execute_only")); + + // Warning levels. + const QString wLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + disableWarnings = wLevel == QLatin1String("none"); + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other compiler flags as a misc controls (exclude only + // that flags which are was already handled). + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (flagIt->contains(QLatin1String("/ropi")) + || flagIt->contains(QLatin1String("/rwpi")) + || flagIt->contains(QLatin1String("--16")) + || flagIt->contains(QLatin1String("--split_ldm")) + || flagIt->contains(QLatin1String("--execute_only")) + || flagIt->contains(QLatin1String("--nowarn")) + ) { + continue; + } + if (flagIt->startsWith(QLatin1String("-I")) + || flagIt->startsWith(QLatin1String("--cpu")) + || flagIt->startsWith(QLatin1String("--fpu")) + || flagIt->startsWith(QLatin1String("-pd")) + ) { + ++flagIt; + continue; + } + miscControls.push_back(*flagIt); + } + } + + int enableRopi = 0; + int enableRwpi = 0; + int enableThumbMode = 0; + int disableWarnings = 0; + int splitLdm = 0; + int generateExecuteOnlyCode = 0; + + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +ArmTargetAssemblerGroup::ArmTargetAssemblerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Aads") +{ + const AssemblerPageOptions opts(qbsProject, qbsProduct); + + // Add 'ROPI' item. + appendProperty(QByteArrayLiteral("Ropi"), opts.enableRopi); + // Add 'RWPI' item. + appendProperty(QByteArrayLiteral("Rwpi"), opts.enableRwpi); + // Add 'Use thumb mode' item. + appendProperty(QByteArrayLiteral("thumb"), opts.enableThumbMode); + // Add 'Slpit LDM' item. + appendProperty(QByteArrayLiteral("SplitLS"), opts.splitLdm); + // Add 'Disable warnings' item. + appendProperty(QByteArrayLiteral("NoWarn"), opts.disableWarnings); + // Add 'Generate code exedutable only' item. + appendProperty(QByteArrayLiteral("useXo"), opts.generateExecuteOnlyCode); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.h new file mode 100644 index 00000000..d61b11fe --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetassemblergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETASSEMBLERGROUP_V3 +#define QBS_KEILUVARMTARGETASSEMBLERGROUP_V3 + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetAssemblerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetAssemblerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETASSEMBLERGROUP_V3 diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.cpp new file mode 100644 index 00000000..f7e3de3d --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.cpp @@ -0,0 +1,208 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetcommonoptionsgroup_v5.h" + +#include "../../keiluvutils.h" + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +namespace { + +const struct DeviceEntry { + QByteArray cpu; // CPU option. + std::set fpus; // FPU's options. + QByteArray device; // Project file entry. +} deviceDict[] = { + {"8-M.Base", {}, "ARMv8MBL"}, + {"8-M.Main", {"FPv5-SP"}, "ARMv8MML_SP"}, + {"8-M.Main", {"FPv5_D16"}, "ARMv8MML_DP"}, + {"8-M.Main", {"SoftVFP"},"ARMv8MML"}, + {"8-M.Main.dsp", {"FPv5-SP"}, "ARMv8MML_DSP_SP"}, + {"8-M.Main.dsp", {"FPv5_D16"}, "ARMv8MML_DSP_DP"}, + {"8-M.Main.dsp", {"SoftVFP"}, "ARMv8MML_DSP"}, + {"Cortex-M0", {}, "ARMCM0"}, + {"Cortex-M0+", {}, "ARMCM0P"}, + {"Cortex-M0plus", {}, "ARMCM0P"}, + {"Cortex-M23", {}, "ARMCM23"}, // same as ARMCM23_TZ + {"Cortex-M3", {}, "ARMCM3"}, + {"Cortex-M4", {}, "ARMCM4"}, + {"Cortex-M4.fp", {}, "ARMCM4_FP"}, + {"Cortex-M7", {"SoftVFP"}, "ARMCM7"}, + {"Cortex-M7.fp.dp", {}, "ARMCM7_DP"}, + {"Cortex-M7.fp.sp", {}, "ARMCM7_SP"}, + {"SC000", {}, "ARMSC000"}, + {"SC300", {}, "ARMSC300"}, + {"Cortex-M33.no_dsp", {"SoftVFP"}, "ARMCM33"}, // same as ARMCM33_TZ + {"Cortex-M33", {"FPv5-SP", "softvfp+vfpv2"}, "ARMCM33_DSP_FP"}, // same as ARMCM33_DSP_FP_TZ +}; + +struct CommonPageOptions final +{ + explicit CommonPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Browse information. + // ??? + + // Debug information. + debugInfo = gen::utils::debugInformation(qbsProduct); + + // Output parameters. + executableName = gen::utils::targetBinary(qbsProduct); + // Fix output binary name if it is a library. Because + // the IDE appends an additional suffix (.LIB) to end + // of an output library name. + if (executableName.endsWith(QLatin1String(".lib"))) + executableName = qbsProduct.targetName(); + + const QString baseDirectory = gen::utils::buildRootPath(qbsProject); + objectDirectory = QDir::toNativeSeparators( + gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct)); + listingDirectory = QDir::toNativeSeparators( + gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct)); + + // Target type. + targetType = KeiluvUtils::outputBinaryType(qbsProduct); + + // Detect the device name from the command line options + // (like --cpu and --fpu). + const auto cpu = gen::utils::firstFlagValue( + flags, QStringLiteral("--cpu")).toLatin1(); + const auto fpus = gen::utils::allFlagValues( + flags, QStringLiteral("--fpu")); + + for (const auto &deviceEntry : deviceDict) { + // Since Qt 5.12 we can use QByteArray::compare(..., Qt::CaseInsensitive) + // instead. + if (cpu.toLower() != deviceEntry.cpu.toLower()) + continue; + + size_t fpuMatches = 0; + const auto dictFpuBegin = std::cbegin(deviceDict->fpus); + const auto dictFpuEnd = std::cend(deviceDict->fpus); + for (const auto &fpu : fpus) { + const auto dictFpuIt = std::find_if( + dictFpuBegin, dictFpuEnd, + [fpu](const QByteArray &dictFpu) { + return fpu.compare(QString::fromLatin1(dictFpu), + Qt::CaseInsensitive) == 0; + }); + if (dictFpuIt != dictFpuEnd) + ++fpuMatches; + } + + if (fpuMatches < deviceEntry.fpus.size()) + continue; + + deviceName = QString::fromLatin1(deviceEntry.device); + cpuType = QString::fromLatin1(deviceEntry.cpu); + break; + } + } + + int debugInfo = false; + int browseInfo = false; + QString deviceName; + QString cpuType; + QString executableName; + QString objectDirectory; + QString listingDirectory; + KeiluvUtils::OutputBinaryType targetType = + KeiluvUtils::ApplicationOutputType; +}; + +} // namespace + +ArmTargetCommonOptionsGroup::ArmTargetCommonOptionsGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("TargetCommonOption") +{ + const CommonPageOptions opts(qbsProject, qbsProduct); + + // Fill device items. + appendProperty(QByteArrayLiteral("Device"), + opts.deviceName); + appendProperty(QByteArrayLiteral("Vendor"), + QByteArrayLiteral("ARM")); + appendProperty(QByteArrayLiteral("PackID"), + QByteArrayLiteral("ARM.CMSIS.5.6.0")); + appendProperty(QByteArrayLiteral("PackURL"), + QByteArrayLiteral("http://www.keil.com/pack/")); + + const auto cpuType = QStringLiteral("CPUTYPE(\"%1\")") + .arg(opts.cpuType); + appendProperty(QByteArrayLiteral("Cpu"), cpuType); + + // Add 'Debug Information' item. + appendProperty(QByteArrayLiteral("DebugInformation"), + opts.debugInfo); + // Add 'Browse Information' item. + appendProperty(QByteArrayLiteral("BrowseInformation"), + opts.browseInfo); + + // Add 'Name of Executable'. + appendProperty(QByteArrayLiteral("OutputName"), + opts.executableName); + // Add 'Output objects directory'. + appendProperty(QByteArrayLiteral("OutputDirectory"), + opts.objectDirectory); + // Add 'Output listing directory'. + appendProperty(QByteArrayLiteral("ListingPath"), + opts.listingDirectory); + + // Add 'Create Executable/Library' item. + const int isExecutable = (opts.targetType + == KeiluvUtils::ApplicationOutputType); + const int isLibrary = (opts.targetType + == KeiluvUtils::LibraryOutputType); + appendProperty(QByteArrayLiteral("CreateExecutable"), + isExecutable); + appendProperty(QByteArrayLiteral("CreateLib"), + isLibrary); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.h new file mode 100644 index 00000000..b7d4ffee --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetcommonoptionsgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETCOMMONOPTIONSGROUP_V5_H +#define QBS_KEILUVARMTARGETCOMMONOPTIONSGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetCommonOptionsGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetCommonOptionsGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETCOMMONOPTIONSGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.cpp new file mode 100644 index 00000000..c923bd9b --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetcompilergroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +namespace { + +struct CompilerPageOptions final +{ + enum WarningLevel { + WarningLevelUnspecified = 0, + WarningLevelNone, + WarningLevelAll + }; + + enum OptimizationLevel { + OptimizationLevelUnspecified = 0, + OptimizationLevelNone, + OptimizationLevelOne, + OptimizationLevelTwo, + OptimizationLevelThree, + }; + + explicit CompilerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Warning levels. + const QString wLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (wLevel == QLatin1String("none")) + warningLevel = WarningLevelNone; + else if (wLevel == QLatin1String("all")) + warningLevel = WarningLevelAll; + else + warningLevel = WarningLevelUnspecified; + + // Generation code. + generateExecuteOnlyCode = flags.contains(QLatin1String("--execute_only")); + + // Optimization levels. + const QString oLevel = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (oLevel == QLatin1String("fast")) + enableTimeOptimization = 1; + else if (oLevel == QLatin1String("small")) + optimizationLevel = OptimizationLevelThree; + else if (oLevel == QLatin1String("none")) + optimizationLevel = OptimizationLevelNone; + + // Split load and store multiple. + splitLdm = flags.contains(QLatin1String("--split_ldm")); + // One ELF section per function. + splitSections = flags.contains(QLatin1String("--split_sections")); + // String ANSI C. + useStrictAnsiC = flags.contains(QLatin1String("--strict")); + // Enum container always int. + forceEnumAsInt = flags.contains(QLatin1String("--enum_is_int")); + // Plain char is signed. + useSignedChar = flags.contains(QLatin1String("--signed_chars")); + // Read-only position independent. + enableRopi = flags.contains(QLatin1String("/ropi")); + // Read-write position independent. + enableRwpi = flags.contains(QLatin1String("/rwpi")); + + // C-language version. + const QString clVersion = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("cLanguageVersion")); + // C99 mode. + useC99Language = clVersion.contains(QLatin1String("c99")); + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other compiler flags as a misc controls (exclude only + // that flags which are was already handled). + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (flagIt->contains(QLatin1String("--execute_only")) + || flagIt->contains(QLatin1String("--split_ldm")) + || flagIt->contains(QLatin1String("--split_sections")) + || flagIt->contains(QLatin1String("--strict")) + || flagIt->contains(QLatin1String("--enum_is_int")) + || flagIt->contains(QLatin1String("--signed_chars")) + || flagIt->contains(QLatin1String("/ropi")) + || flagIt->contains(QLatin1String("/rwpi")) + || flagIt->contains(QLatin1String("--c99")) + ) { + continue; + } + if (flagIt->startsWith(QLatin1String("-O")) + || flagIt->startsWith(QLatin1String("-W")) + || flagIt->startsWith(QLatin1String("-D")) + || flagIt->startsWith(QLatin1String("-I")) + || flagIt->startsWith(QLatin1String("--cpu")) + || flagIt->startsWith(QLatin1String("--fpu")) + ) { + ++flagIt; + continue; + } + miscControls.push_back(*flagIt); + } + } + + WarningLevel warningLevel = WarningLevelAll; + OptimizationLevel optimizationLevel = OptimizationLevelUnspecified; + int enableTimeOptimization = 0; + int generateExecuteOnlyCode = 0; + int splitLdm = 0; + int splitSections = 0; + int useStrictAnsiC = 0; + int forceEnumAsInt = 0; + int useSignedChar = 0; + int enableRopi = 0; + int enableRwpi = 0; + int useC99Language = 0; + + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +ArmTargetCompilerGroup::ArmTargetCompilerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Cads") +{ + const CompilerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Code Optimization' items. + appendProperty(QByteArrayLiteral("Optim"), opts.optimizationLevel); + appendProperty(QByteArrayLiteral("oTime"), opts.enableTimeOptimization); + // Add 'Slpit LDM' item. + appendProperty(QByteArrayLiteral("SplitLS"), opts.splitLdm); + // Add 'Slpit sections' item. + appendProperty(QByteArrayLiteral("OneElfS"), opts.splitSections); + // Add 'Strict ANSI C' item. + appendProperty(QByteArrayLiteral("Strict"), opts.useStrictAnsiC); + // Add 'Enums as int' item. + appendProperty(QByteArrayLiteral("EnumInt"), opts.forceEnumAsInt); + // Add 'Plain char as signed' item. + appendProperty(QByteArrayLiteral("PlainCh"), opts.useSignedChar); + // Add 'ROPI' item. + appendProperty(QByteArrayLiteral("Ropi"), opts.enableRopi); + // Add 'RWPI' item. + appendProperty(QByteArrayLiteral("Rwpi"), opts.enableRwpi); + // Add 'Warnings' item. + appendProperty(QByteArrayLiteral("wLevel"), opts.warningLevel); + // Add 'Use C99' item. + appendProperty(QByteArrayLiteral("uC99"), opts.useC99Language); + // Add 'Generate code exedutable only' item. + appendProperty(QByteArrayLiteral("useXo"), opts.generateExecuteOnlyCode); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.h new file mode 100644 index 00000000..89759ee0 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetcompilergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETCOMPILERGROUP_V5_H +#define QBS_KEILUVARMTARGETCOMPILERGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetCompilerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetCompilerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETCOMPILERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.cpp new file mode 100644 index 00000000..61c7b566 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetassemblergroup_v5.h" +#include "armtargetcompilergroup_v5.h" +#include "armtargetgroup_v5.h" +#include "armtargetlinkergroup_v5.h" +#include "armtargetmiscgroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmTargetGroup::ArmTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("TargetArmAds") +{ + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.h new file mode 100644 index 00000000..7472fe67 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETGROUP_V5_H +#define QBS_KEILUVARMTARGETGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.cpp new file mode 100644 index 00000000..52a19cf8 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetlinkergroup_v5.h" + +#include "../../keiluvutils.h" + +#include + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +namespace { + +struct LinkerPageOptions final +{ + explicit LinkerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleLinkerFlags(qbsProps); + + // Read-only position independent. + enableRopi = flags.contains(QLatin1String("--ropi")); + // Read-write position independent. + enableRwpi = flags.contains(QLatin1String("--rwpi")); + // Don't search standard libraries. + dontSearchLibs = flags.contains(QLatin1String("--noscanlib")); + // Report 'might fail' conditions as errors. + enableReportMightFail = flags.contains(QLatin1String("--strict")); + + QStringList scatterFiles; + + // Enumerate all product linker config files + // (which are set trough 'linkerscript' tag). + for (const auto &qbsGroup : qbsProduct.groups()) { + if (!qbsGroup.isEnabled()) + continue; + const auto qbsArtifacts = qbsGroup.sourceArtifacts(); + for (const auto &qbsArtifact : qbsArtifacts) { + const auto qbsTags = qbsArtifact.fileTags(); + if (!qbsTags.contains(QLatin1String("linkerscript"))) + continue; + const QString scatterFile = QFileInfo(qbsArtifact.filePath()) + .absoluteFilePath(); + scatterFiles.push_back(scatterFile); + } + } + + // Enumerate all scatter files + // (which are set trough '--scatter' option). + const QStringList scatters = gen::utils::allFlagValues( + flags, QStringLiteral("--scatter")); + for (const auto &scatter : scatters) { + const QString scatterFile = QFileInfo(scatter) + .absoluteFilePath(); + if (!scatterFiles.contains(scatterFile)) + scatterFiles.push_back(scatterFile); + } + + // Transform all paths to relative. + const QString baseDirectory = qbs::gen::utils::buildRootPath(qbsProject); + Internal::transform(scatterFiles, [&baseDirectory](const auto &file) { + return gen::utils::relativeFilePath(baseDirectory, file); }); + + // Make a first scatter file as a main scatter file. + // Other scatter files will be interpretes as a misc controls. + if (scatterFiles.count() > 0) + mainScatterFile = scatterFiles.takeFirst(); + + for (const auto &scatterFile : qAsConst(scatterFiles)) { + const auto control = QStringLiteral("--scatter %1").arg(scatterFile); + miscControls.push_back(control); + } + + // Interpret other compiler flags as a misc controls (exclude only + // that flags which are was already handled). + for (auto flagIt = flags.cbegin(); flagIt < flags.cend(); ++flagIt) { + if (flagIt->contains(QLatin1String("--ropi")) + || flagIt->contains(QLatin1String("--rwpi")) + || flagIt->contains(QLatin1String("--noscanlib")) + || flagIt->contains(QLatin1String("--strict")) + ) { + continue; + } + if (flagIt->startsWith(QLatin1String("--scatter")) + ) { + ++flagIt; + continue; + } + miscControls.push_back(*flagIt); + } + } + + int enableRopi = 0; + int enableRwpi = 0; + int dontSearchLibs = 0; + int enableReportMightFail = 0; + + QString mainScatterFile; + QStringList miscControls; +}; + +} // namespace + +ArmTargetLinkerGroup::ArmTargetLinkerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("LDads") +{ + const LinkerPageOptions opts(qbsProject, qbsProduct); + + // Add 'ROPI' item. + appendProperty(QByteArrayLiteral("Ropi"), opts.enableRopi); + // Add 'RWPI' item. + appendProperty(QByteArrayLiteral("Rwpi"), opts.enableRwpi); + // Add 'Don't search standard libraries' item. + appendProperty(QByteArrayLiteral("noStLib"), opts.dontSearchLibs); + // Add 'Report might fail' item. + appendProperty(QByteArrayLiteral("RepFail"), opts.enableReportMightFail); + // Add 'Scatter file' item. + appendProperty(QByteArrayLiteral("ScatterFile"), + QDir::toNativeSeparators(opts.mainScatterFile)); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.h new file mode 100644 index 00000000..db82d4bc --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetlinkergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETLINKERGROUP_V5_H +#define QBS_KEILUVARMTARGETLINKERGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetLinkerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetLinkerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETLINKERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.cpp new file mode 100644 index 00000000..18da47c8 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armtargetmiscgroup_v5.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +namespace { + +struct MiscPageOptions final +{ + explicit MiscPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + generateLinkerMap = gen::utils::cppBooleanModuleProperty( + qbsProps, QStringLiteral("generateLinkerMapFile")); + } + + int generateLinkerMap = 0; +}; + +} // namespace + +ArmTargetMiscGroup::ArmTargetMiscGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("ArmAdsMisc") +{ + const MiscPageOptions opts(qbsProject, qbsProduct); + + // Add 'Generate linker map file' item. + appendProperty(QByteArrayLiteral("AdsLLst"), opts.generateLinkerMap); +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.h new file mode 100644 index 00000000..025b2796 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armtargetmiscgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMTARGETMISCGROUP_V5_H +#define QBS_KEILUVARMTARGETMISCGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmTargetMiscGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmTargetMiscGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMTARGETMISCGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.cpp b/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.cpp new file mode 100644 index 00000000..eab3cc56 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "armutilitiesgroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +ArmUtilitiesGroup::ArmUtilitiesGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Utilities") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.h b/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.h new file mode 100644 index 00000000..a34a3a39 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/arm/armutilitiesgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVARMUTILITIESGROUP_V5_H +#define QBS_KEILUVARMUTILITIESGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace arm { +namespace v5 { + +class ArmUtilitiesGroup final : public gen::xml::PropertyGroup +{ +public: + explicit ArmUtilitiesGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace arm +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVARMUTILITIESGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp new file mode 100644 index 00000000..87b3100d --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51buildtargetgroup_v5.h" +#include "mcs51commonpropertygroup_v5.h" +#include "mcs51debugoptiongroup_v5.h" +#include "mcs51dlloptiongroup_v5.h" +#include "mcs51targetcommonoptionsgroup_v5.h" +#include "mcs51targetgroup_v5.h" +#include "mcs51utilitiesgroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvconstants.h" +#include "../../keiluvfilesgroupspropertygroup.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51BuildTargetGroup::Mcs51BuildTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup("Target") +{ + // Append target name item (it is a build configuration name). + const QString targetName = gen::utils::buildConfigurationName( + qbsProject); + appendProperty(QByteArrayLiteral("TargetName"), targetName); + // Append toolset number group item. + appendChild(QByteArrayLiteral("ToolsetNumber"), + QByteArrayLiteral("0x0")); + // Append toolset name group item. + appendChild(QByteArrayLiteral("ToolsetName"), + QByteArrayLiteral("MCS-51")); + + // Append target option group item. + const auto targetOptionGroup = appendChild( + QByteArrayLiteral("TargetOption")); + + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + targetOptionGroup->appendChild( + qbsProject, qbsProduct); + + // Append files group. + appendChild(qbsProject, qbsProduct, + qbsProductDeps); +} + +bool Mcs51BuildTargetGroupFactory::canCreate( + gen::utils::Architecture arch, + const Version &version) const +{ + return arch == gen::utils::Architecture::Mcs51 + && version.majorVersion() == qbs::KeiluvConstants::v5::kUVisionVersion; +} + +std::unique_ptr +Mcs51BuildTargetGroupFactory::create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const +{ + const auto group = new Mcs51BuildTargetGroup( + qbsProject, qbsProduct, qbsProductDeps); + return std::unique_ptr(group); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h new file mode 100644 index 00000000..ef0c0ccb --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51buildtargetgroup_v5.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H +#define QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51BuildTargetGroup final : public gen::xml::PropertyGroup +{ +private: + explicit Mcs51BuildTargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps); + + friend class Mcs51BuildTargetGroupFactory; +}; + +class Mcs51BuildTargetGroupFactory final + : public gen::xml::PropertyGroupFactory +{ +public: + bool canCreate(gen::utils::Architecture arch, + const Version &version) const final; + + std::unique_ptr create( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps) const final; +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51BUILDTARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp new file mode 100644 index 00000000..3d4d3304 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51commonpropertygroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51CommonPropertyGroup::Mcs51CommonPropertyGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("CommonProperty") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h new file mode 100644 index 00000000..66dfc7a3 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51commonpropertygroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51COMMONPROPERTYGROUP_V5_H +#define QBS_KEILUVMCS51COMMONPROPERTYGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51CommonPropertyGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51CommonPropertyGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_MCS51COMMONPROPERTYGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp new file mode 100644 index 00000000..2175cc48 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51debugoptiongroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51DebugOptionGroup::Mcs51DebugOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("DebugOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h new file mode 100644 index 00000000..473cf605 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51debugoptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H +#define QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51DebugOptionGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51DebugOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51DEBUGOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp new file mode 100644 index 00000000..59aec721 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51dlloptiongroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51DllOptionGroup::Mcs51DllOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("DllOption") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h new file mode 100644 index 00000000..e16833ac --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51dlloptiongroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H +#define QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51DllOptionGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51DllOptionGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51DLLOPTIONGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp new file mode 100644 index 00000000..8d725771 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetassemblergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct AssemblerPageOptions final +{ + explicit AssemblerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleAssemblerFlags(qbsProps); + + // Don't use standard macro. + if (flags.contains(QLatin1String("NOMACRO"), Qt::CaseInsensitive)) + useStandardMacroProcessor = false; + + // Use MPL. + if (flags.contains(QLatin1String("MPL"), Qt::CaseInsensitive)) + useMacroProcessingLanguage = true; + + // Define 8051 SFR names. + if (flags.contains(QLatin1String("NOMOD51"), Qt::CaseInsensitive)) + suppressSfrNames = true; + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other assembler flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.compare(QLatin1String("NOMACRO"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MACRO"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOMPL"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MPL"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOMOD51"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("MOD51"), + Qt::CaseInsensitive) == 0 + ) { + continue; + } + miscControls.push_back(flag); + } + } + + int useStandardMacroProcessor = true; + int useMacroProcessingLanguage = false; + int suppressSfrNames = false; + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetAssemblerGroup::Mcs51TargetAssemblerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Ax51") +{ + const AssemblerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Macro processor (Standard)' + appendProperty(QByteArrayLiteral("UseStandard"), + opts.useStandardMacroProcessor); + // Add 'Macro processor (MPL)' + appendProperty(QByteArrayLiteral("UseMpl"), + opts.useMacroProcessingLanguage); + // Add 'Define 8051 SFR names' + appendProperty(QByteArrayLiteral("UseMod51"), + opts.suppressSfrNames); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), + opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h new file mode 100644 index 00000000..f9a82304 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetassemblergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 +#define QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetAssemblerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetAssemblerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETASSEMBLERGROUP_V3 diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp new file mode 100644 index 00000000..de1be1ef --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetcommonoptionsgroup_v5.h" + +#include "../../keiluvutils.h" + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct CommonPageOptions final +{ + explicit CommonPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Browse information. + if (flags.contains(QLatin1String("BROWSE"), Qt::CaseInsensitive)) + browseInfo = true; + + // Debug information. + debugInfo = gen::utils::debugInformation(qbsProduct); + + // Output parameters. + executableName = gen::utils::targetBinary(qbsProduct); + // Fix output binary name if it is a library. Because + // the IDE appends an additional suffix (.LIB) to end + // of an output library name. + if (executableName.endsWith(QLatin1String(".lib"))) + executableName = qbsProduct.targetName(); + + const QString baseDirectory = gen::utils::buildRootPath(qbsProject); + objectDirectory = QDir::toNativeSeparators( + gen::utils::objectsOutputDirectory( + baseDirectory, qbsProduct)); + listingDirectory = QDir::toNativeSeparators( + gen::utils::listingOutputDirectory( + baseDirectory, qbsProduct)); + + // Target type. + targetType = KeiluvUtils::outputBinaryType(qbsProduct); + } + + int browseInfo = false; + int debugInfo = false; + QString executableName; + QString objectDirectory; + QString listingDirectory; + KeiluvUtils::OutputBinaryType targetType = + KeiluvUtils::ApplicationOutputType; +}; + +} // namespace + +Mcs51TargetCommonOptionsGroup::Mcs51TargetCommonOptionsGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("TargetCommonOption") +{ + const CommonPageOptions opts(qbsProject, qbsProduct); + + // Add 'Generic 8051 device' items, + // because we can't detect a target device + // form the present command lines. + appendProperty(QByteArrayLiteral("Device"), + QByteArrayLiteral("8051 (all Variants)")); + appendProperty(QByteArrayLiteral("Vendor"), + QByteArrayLiteral("Generic")); + appendProperty(QByteArrayLiteral("DeviceId"), + QByteArrayLiteral("2994")); + + // Add 'Debug Information' item. + appendProperty(QByteArrayLiteral("DebugInformation"), + opts.debugInfo); + // Add 'Browse Information' item. + appendProperty(QByteArrayLiteral("BrowseInformation"), + opts.browseInfo); + + // Add 'Name of Executable'. + appendProperty(QByteArrayLiteral("OutputName"), + opts.executableName); + // Add 'Output objects directory'. + appendProperty(QByteArrayLiteral("OutputDirectory"), + opts.objectDirectory); + // Add 'Output listing directory'. + appendProperty(QByteArrayLiteral("ListingPath"), + opts.listingDirectory); + + // Add 'Create Executable/Library' item. + const int isExecutable = (opts.targetType + == KeiluvUtils::ApplicationOutputType); + const int isLibrary = (opts.targetType + == KeiluvUtils::LibraryOutputType); + appendProperty(QByteArrayLiteral("CreateExecutable"), + isExecutable); + appendProperty(QByteArrayLiteral("CreateLib"), + isLibrary); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h new file mode 100644 index 00000000..eccd9d42 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H +#define QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetCommonOptionsGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetCommonOptionsGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETCOMMONOPTIONSGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp new file mode 100644 index 00000000..e33c0c21 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.cpp @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetcompilergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct CompilerPageOptions final +{ + enum WarningLevel { + WarningLevelNone = 0, + WarningLevelOne, + WarningLevelTwo + }; + + enum OptimizationLevel { + ConstantFoldingOptimizationLevel = 0, + DeadCodeEliminationOptimizationLevel, + DataOverlayingOptimizationLevel, + PeepholeOptimizationLevel, + RegisterVariablesOptimizationLevel, + CommonSubexpressionEliminationOptimizationLevel, + LoopRotationOptimizationLevel, + ExtendedIndexAccessOptimizationLevel, + ReuseCommonEntryCodeOptimizationLevel, + CommonBlockSubroutinesOptimizationLevel, + RearrangeCodeOptimizationLevel, + ReuseCommonExitCodeOptimizationLevel + }; + + enum OptimizationEmphasis { + FavorSizeOptimizationEmphasis = 0, + FavorSpeedOptimizationEmphasis + }; + + enum FloatFuzzyBits { + NoFloatFuzzyBits = 0, + OneFloatFuzzyBit, + TwoFloatFuzzyBits, + ThreeFloatFuzzyBits, + FourFloatFuzzyBits, + FiveFloatFuzzyBits, + SixFloatFuzzyBits, + SevenFloatFuzzyBits + }; + + explicit CompilerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Warnings. + const QString level = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("warningLevel")); + if (level == QLatin1String("none")) { + warningLevel = WarningLevelNone; + } else if (level == QLatin1String("all")) { + warningLevel = WarningLevelTwo; + } else { + // In this case take it directly from the compiler command line, + // e.g. parse the line in a form: 'WARNINGLEVEL (2)' + const auto warnValue = KeiluvUtils::flagValue( + flags, QStringLiteral("WARNINGLEVEL")); + bool ok = false; + const auto level = warnValue.toInt(&ok); + if (ok && gen::utils::inBounds( + level, int(WarningLevelNone),int(WarningLevelTwo))) { + warningLevel = static_cast(level); + } + } + + // Optimizations. + const QString optimization = gen::utils::cppStringModuleProperty( + qbsProps, QStringLiteral("optimization")); + if (optimization == QLatin1String("fast")) { + optimizationEmphasis = FavorSpeedOptimizationEmphasis; + } else if (level == QLatin1String("small")) { + optimizationEmphasis = FavorSizeOptimizationEmphasis; + } else if (level == QLatin1String("small")) { + // Don't supported by C51 compiler. + } else { + // In this case take it directly from the compiler command line, + // e.g. parse the line in a form: 'OPTIMIZE (8, SPEED)' + const auto optValue = KeiluvUtils::flagValue( + flags, QStringLiteral("OPTIMIZE")); + const auto parts = KeiluvUtils::flagValueParts(optValue); + for (const auto &part : parts) { + bool ok = false; + const auto level = part.toInt(&ok); + if (ok && (level >= ConstantFoldingOptimizationLevel) + && (level <= ReuseCommonExitCodeOptimizationLevel)) { + optimizationLevel = static_cast(level); + } else if (part.compare(QLatin1String("SIZE"), + Qt::CaseInsensitive) == 0) { + optimizationEmphasis = FavorSizeOptimizationEmphasis; + } else if (part.compare(QLatin1String("SPEED"), + Qt::CaseInsensitive) == 0) { + optimizationEmphasis = FavorSpeedOptimizationEmphasis; + } + } + } + + // Don't use absolute register accesses. + if (flags.contains(QLatin1String("NOAREGS"), Qt::CaseInsensitive)) + dontuseAbsoluteRegsAccess = true; + + // Enable ANSI integer promotion rules. + if (flags.contains(QLatin1String("NOINTPROMOTE"), Qt::CaseInsensitive)) + enableIntegerPromotionRules = false; + + // Keep variables in order. + if (flags.contains(QLatin1String("ORDER"), Qt::CaseInsensitive)) + keepVariablesInOrder = true; + + // Don't use interrupt vector. + if (flags.contains(QLatin1String("NOINTVECTOR"), Qt::CaseInsensitive)) + useInterruptVector = false; + + // Interrupt vector address. + interruptVectorAddress = KeiluvUtils::flagValue( + flags, QStringLiteral("INTVECTOR")); + + // Float fuzzy bits count. + const auto bitsValue = KeiluvUtils::flagValue( + flags, QStringLiteral("FLOATFUZZY")); + bool ok = false; + const auto bits = bitsValue.toInt(&ok); + if (ok && gen::utils::inBounds( + bits, int(NoFloatFuzzyBits), int(SevenFloatFuzzyBits))) { + floatFuzzyBits = static_cast(bits); + } + + // Define symbols. + defineSymbols = qbs::KeiluvUtils::defines(qbsProps); + // Include paths. + includePaths = qbs::KeiluvUtils::includes(qbsProps); + + // Interpret other compiler flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.startsWith(QLatin1String("WARNINGLEVEL"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("OPTIMIZE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("FLOATFUZZY"), + Qt::CaseInsensitive) + || flag.compare(QLatin1String("NOAREGS"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("AREGS"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOINTPROMOTE"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("INTPROMOTE"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("NOINTVECTOR"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("INTVECTOR"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("ORDER"), + Qt::CaseInsensitive) == 0 + || flag.compare(QLatin1String("BROSWE"), + Qt::CaseInsensitive) == 0 + ) { + continue; + } + miscControls.push_back(flag); + } + } + + WarningLevel warningLevel = WarningLevelTwo; + OptimizationLevel optimizationLevel = ReuseCommonEntryCodeOptimizationLevel; + OptimizationEmphasis optimizationEmphasis = FavorSpeedOptimizationEmphasis; + FloatFuzzyBits floatFuzzyBits = ThreeFloatFuzzyBits; + int dontuseAbsoluteRegsAccess = false; + int enableIntegerPromotionRules = true; + int keepVariablesInOrder = false; + int useInterruptVector = true; + QString interruptVectorAddress; + QStringList defineSymbols; + QStringList includePaths; + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetCompilerGroup::Mcs51TargetCompilerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("C51") +{ + const CompilerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Code Optimization' options. + appendProperty(QByteArrayLiteral("Optimize"), + opts.optimizationLevel); + appendProperty(QByteArrayLiteral("SizeSpeed"), + opts.optimizationEmphasis); + // Add 'Warnings' options. + appendProperty(QByteArrayLiteral("WarningLevel"), + opts.warningLevel); + // Add 'Don't use absolute register access' item. + appendProperty(QByteArrayLiteral("uAregs"), + opts.dontuseAbsoluteRegsAccess); + // Add 'Enable integer promotion rules' item. + appendProperty(QByteArrayLiteral("IntegerPromotion"), + opts.enableIntegerPromotionRules); + // Add 'Keep variables in order' item. + appendProperty(QByteArrayLiteral("VariablesInOrder"), + opts.keepVariablesInOrder); + // Add 'Use interrupt vector' item. + appendProperty(QByteArrayLiteral("UseInterruptVector"), + opts.useInterruptVector); + appendProperty(QByteArrayLiteral("InterruptVectorAddress"), + opts.interruptVectorAddress); + // Add 'Float fuzzy bits' item. + appendProperty(QByteArrayLiteral("Fuzzy"), + opts.floatFuzzyBits); + + // Add other various controls. + // Note: A sub-items order makes sense! + const auto variousControlsGroup = appendChild( + QByteArrayLiteral("VariousControls")); + // Add 'Misc Controls' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + // Add 'Define' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("Define"), + opts.defineSymbols); + // Add an empty 'Undefine' item. + variousControlsGroup->appendProperty( + QByteArrayLiteral("Undefine"), {}); + // Add 'Include Paths' item. + variousControlsGroup->appendMultiLineProperty( + QByteArrayLiteral("IncludePath"), + opts.includePaths, QLatin1Char(';')); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h new file mode 100644 index 00000000..0f1e52ce --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetcompilergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H +#define QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetCompilerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetCompilerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETCOMPILERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp new file mode 100644 index 00000000..2a05649d --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetassemblergroup_v5.h" +#include "mcs51targetcompilergroup_v5.h" +#include "mcs51targetgroup_v5.h" +#include "mcs51targetlinkergroup_v5.h" +#include "mcs51targetmiscgroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51TargetGroup::Mcs51TargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Target51") +{ + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); + appendChild(qbsProject, qbsProduct); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h new file mode 100644 index 00000000..d256dfcc --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETGROUP_V5_H +#define QBS_KEILUVMCS51TARGETGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp new file mode 100644 index 00000000..4d52b627 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.cpp @@ -0,0 +1,240 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetlinkergroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct LinkerPageOptions final +{ + explicit LinkerPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleLinkerFlags(qbsProps); + + // Handle all 'BIT' memory flags. + parseMemory(flags, QStringLiteral("BIT"), + bitAddresses, bitSegments); + // Handle all 'CODE' memory flags. + parseMemory(flags, QStringLiteral("CODE"), + codeAddresses, codeSegments); + // Handle all 'DATA' memory flags. + parseMemory(flags, QStringLiteral("DATA"), + dataAddresses, dataSegments); + // Handle all 'IDATA' memory flags. + parseMemory(flags, QStringLiteral("IDATA"), + idataAddresses, idataSegments); + // Handle all 'PDATA' memory flags. + parseMemory(flags, QStringLiteral("PDATA"), + pdataAddresses, pdataSegments); + // Handle all 'XDATA' memory flags. + parseMemory(flags, QStringLiteral("XDATA"), + xdataAddresses, xdataSegments); + + // Enumerate all flags in a form like: + // 'PRECEDE(foo, bar) PRECEDE(baz)'. + const auto precedeValues = KeiluvUtils::flagValues( + flags, QStringLiteral("PRECEDE")); + for (const auto &precedeValue : precedeValues) { + const auto parts = KeiluvUtils::flagValueParts(precedeValue); + precedeSegments.reserve(precedeSegments.size() + parts.count()); + std::copy(parts.cbegin(), parts.cend(), + std::back_inserter(precedeSegments)); + } + + // Enumerate all flags in a form like: + // 'STACK(foo, bar) STACK(baz)'. + const auto stackValues = KeiluvUtils::flagValues( + flags, QStringLiteral("STACK")); + for (const auto &stackValue : stackValues) { + const auto parts = KeiluvUtils::flagValueParts(stackValue); + stackSegments.reserve(stackSegments.size() + parts.count()); + std::copy(parts.cbegin(), parts.cend(), + std::back_inserter(stackSegments)); + } + + // Interpret other linker flags as a misc controls (exclude only + // that flags which are was already handled). + for (const auto &flag : flags) { + if (flag.startsWith(QLatin1String("BIT"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("CODE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("DATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("IDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("PDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("XDATA"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("PRECEDE"), + Qt::CaseInsensitive) + || flag.startsWith(QLatin1String("STACK"), + Qt::CaseInsensitive) + ) { + continue; + } + miscControls.push_back(flag); + } + } + + static void parseMemory(const QStringList &flags, + const QString &flagKey, + QStringList &destAddresses, + QStringList &destSegments) + { + // Handle all flags in a form like: + // 'FLAGKEY(0x00-0x20, 30, foo, bar(0x40)) FLAGKEY(baz)'. + const auto values = KeiluvUtils::flagValues(flags, flagKey); + for (const auto &value : values) { + const auto parts = KeiluvUtils::flagValueParts(value); + for (const auto &part : parts) { + if (part.contains(QLatin1Char('-'))) { + // Seems, it is an address range. + destAddresses.push_back(part); + } else { + // Check on address (specified in decimal + // or hexadecimal form). + bool ok = false; + part.toInt(&ok, 16); + if (!ok) + part.toInt(&ok, 10); + if (ok) { + // Seems, it is just a single address. + destAddresses.push_back(part); + } else { + // Seems it is a segment name. + destSegments.push_back(part); + } + } + } + } + } + + QStringList bitAddresses; + QStringList bitSegments; + QStringList codeAddresses; + QStringList codeSegments; + QStringList dataAddresses; + QStringList dataSegments; + QStringList idataAddresses; + QStringList idataSegments; + QStringList pdataAddresses; + QStringList pdataSegments; + QStringList xdataAddresses; + QStringList xdataSegments; + + QStringList precedeSegments; + QStringList stackSegments; + + QStringList miscControls; +}; + +} // namespace + +Mcs51TargetLinkerGroup::Mcs51TargetLinkerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Lx51") +{ + const LinkerPageOptions opts(qbsProject, qbsProduct); + + // Add 'Misc Controls' item. + appendMultiLineProperty(QByteArrayLiteral("MiscControls"), + opts.miscControls, QLatin1Char(' ')); + + // Add 'Use Memory Layout from Target Dialog' item. + // Note: we always disable it, as we expect that + // the layout will be specified from the linker's + // command line. + appendProperty(QByteArrayLiteral("UseMemoryFromTarget"), + 0); + + // Add 'Bit Range' item. + appendMultiLineProperty(QByteArrayLiteral("BitBaseAddress"), + opts.bitAddresses); + // Add 'Code Range' item. + appendMultiLineProperty(QByteArrayLiteral("CodeBaseAddress"), + opts.codeAddresses); + // Add 'Data Range' item. + appendMultiLineProperty(QByteArrayLiteral("DataBaseAddress"), + opts.dataAddresses); + // Add 'IData Range' item. + appendMultiLineProperty(QByteArrayLiteral("IDataBaseAddress"), + opts.idataAddresses); + // Add 'PData Range' item. + appendMultiLineProperty(QByteArrayLiteral("PDataBaseAddress"), + opts.pdataAddresses); + // Add 'XData Range' item. + appendMultiLineProperty(QByteArrayLiteral("XDataBaseAddress"), + opts.xdataAddresses); + + // Add 'Bit Segment' item. + appendMultiLineProperty(QByteArrayLiteral("BitSegmentName"), + opts.bitSegments); + // Add 'Code Segment' item. + appendMultiLineProperty(QByteArrayLiteral("CodeSegmentName"), + opts.codeSegments); + // Add 'Data Segment' item. + appendMultiLineProperty(QByteArrayLiteral("DataSegmentName"), + opts.dataSegments); + // Add 'IData Segment' item. + appendMultiLineProperty(QByteArrayLiteral("IDataSegmentName"), + opts.idataSegments); + + // Note: PData has not segments! + + // Add 'XData Segment' item. + appendMultiLineProperty(QByteArrayLiteral("XDataSegmentName"), + opts.xdataSegments); + // Add 'Precede' item. + appendMultiLineProperty(QByteArrayLiteral("Precede"), + opts.precedeSegments); + // Add 'Stack' item. + appendMultiLineProperty(QByteArrayLiteral("Stack"), + opts.stackSegments); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h new file mode 100644 index 00000000..d701c5e0 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetlinkergroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H +#define QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetLinkerGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetLinkerGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETLINKERGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp new file mode 100644 index 00000000..5d95d443 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51targetmiscgroup_v5.h" +#include "mcs51utils.h" + +#include "../../keiluvutils.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +namespace { + +struct MiscPageOptions final +{ + enum MemoryModel { + SmallMemoryModel = 0, + CompactMemoryModel, + LargeMemoryModel + }; + + enum CodeRomSize { + SmallCodeRomSize = 0, + CompactCodeRomSize, + LargeCodeRomSize + }; + + explicit MiscPageOptions(const Project &qbsProject, + const ProductData &qbsProduct) + { + Q_UNUSED(qbsProject) + + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto flags = qbs::KeiluvUtils::cppModuleCompilerFlags(qbsProps); + + // Memory model. + if (flags.contains(QLatin1String("COMPACT"), Qt::CaseInsensitive)) + memoryModel = CompactMemoryModel; + else if (flags.contains(QLatin1String("LARGE"), Qt::CaseInsensitive)) + memoryModel = LargeMemoryModel; + + // Code ROM size. + const auto sizeValue = KeiluvUtils::flagValue( + flags, QStringLiteral("ROM")); + if (sizeValue == QLatin1String("SMALL")) + coderomSize = SmallCodeRomSize; + else if (sizeValue == QLatin1String("COMPACT")) + coderomSize = CompactCodeRomSize; + } + + MemoryModel memoryModel = SmallMemoryModel; + CodeRomSize coderomSize = LargeCodeRomSize; +}; + +} // namespace + +Mcs51TargetMiscGroup::Mcs51TargetMiscGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Target51Misc") +{ + const MiscPageOptions opts(qbsProject, qbsProduct); + + // Add 'Memory Model' options item. + appendProperty(QByteArrayLiteral("MemoryModel"), + opts.memoryModel); + // Add 'ROM Size' options item. + appendProperty(QByteArrayLiteral("RomSize"), + opts.coderomSize); +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h new file mode 100644 index 00000000..f1680d92 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51targetmiscgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51TARGETMISCGROUP_V5_H +#define QBS_KEILUVMCS51TARGETMISCGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51TargetMiscGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51TargetMiscGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51TARGETMISCGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp new file mode 100644 index 00000000..8e8307f7 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51utilitiesgroup_v5.h" + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +Mcs51UtilitiesGroup::Mcs51UtilitiesGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct) + : gen::xml::PropertyGroup("Utilities") +{ + Q_UNUSED(qbsProject) + Q_UNUSED(qbsProduct) +} + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h new file mode 100644 index 00000000..f95ec67c --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utilitiesgroup_v5.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51UTILITIESGROUP_V5_H +#define QBS_KEILUVMCS51UTILITIESGROUP_V5_H + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { +namespace v5 { + +class Mcs51UtilitiesGroup final : public gen::xml::PropertyGroup +{ +public: + explicit Mcs51UtilitiesGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct); +}; + +} // namespace v5 +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51UTILITIESGROUP_V5_H diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp new file mode 100644 index 00000000..70ec47a6 --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "mcs51utils.h" + +#include + +namespace qbs { +namespace keiluv { +namespace mcs51 { + +namespace KeiluvUtils { + +static QString extractValue(const QString &flag) +{ + const auto openBracketIndex = flag.indexOf(QLatin1Char('(')); + const auto closeBracketIndex = flag.indexOf(QLatin1Char(')')); + const auto n = closeBracketIndex - openBracketIndex - 1; + return flag.mid(openBracketIndex + 1, n); +} + +QStringList flagValues(const QStringList &flags, const QString &flagKey) +{ + QStringList values; + for (const auto &flag : flags) { + if (!flag.startsWith(flagKey, Qt::CaseInsensitive)) + continue; + const auto value = extractValue(flag); + values.push_back(value); + } + return values; +} + +QString flagValue(const QStringList &flags, const QString &flagKey) +{ + const auto flagEnd = flags.cend(); + const auto flagIt = std::find_if(flags.cbegin(), flagEnd, + [flagKey](const auto &flag) { + return flag.startsWith(flagKey, Qt::CaseInsensitive); + }); + if (flagIt == flagEnd) + return {}; // Flag key not found. + return extractValue(*flagIt); +} + +QStringList flagValueParts(const QString &flagValue, const QLatin1Char &sep) +{ + auto parts = flagValue.split(sep); + Internal::transform(parts, [](const auto &part) { return part.trimmed(); }); + return parts; +} + +} // namespace KeiluvUtils + +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs diff --git a/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h new file mode 100644 index 00000000..a1a9706e --- /dev/null +++ b/src/plugins/generator/keiluv/archs/mcs51/mcs51utils.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVMCS51UTILS_H +#define QBS_KEILUVMCS51UTILS_H + +#include + +namespace qbs { + +namespace keiluv { +namespace mcs51 { + +namespace KeiluvUtils { + +QStringList flagValues(const QStringList &flags, const QString &flagKey); + +QString flagValue(const QStringList &flags, const QString &flagKey); + +QStringList flagValueParts(const QString &flagValue, + const QLatin1Char &sep = QLatin1Char(',')); + +} // namespace KeiluvUtils + +} // namespace mcs51 +} // namespace keiluv +} // namespace qbs + +#endif // QBS_KEILUVMCS51UTILS_H diff --git a/src/plugins/generator/keiluv/keiluv.pri b/src/plugins/generator/keiluv/keiluv.pri new file mode 100644 index 00000000..6995fb05 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluv.pri @@ -0,0 +1 @@ +qbsPluginTarget = keiluvgenerator diff --git a/src/plugins/generator/keiluv/keiluv.pro b/src/plugins/generator/keiluv/keiluv.pro new file mode 100644 index 00000000..052277ef --- /dev/null +++ b/src/plugins/generator/keiluv/keiluv.pro @@ -0,0 +1,90 @@ +include(keiluv.pri) +include(../../plugins.pri) +include(../../../shared/json/json.pri) + +QT = core + +# Plugin file. + +SOURCES += \ + $$PWD/keiluvgeneratorplugin.cpp \ + +# Common files. + +HEADERS += \ + $$PWD/keiluvconstants.h \ + $$PWD/keiluvfilesgroupspropertygroup.h \ + $$PWD/keiluvgenerator.h \ + $$PWD/keiluvproject.h \ + $$PWD/keiluvprojectwriter.h \ + $$PWD/keiluvutils.h \ + $$PWD/keiluvversioninfo.h \ + $$PWD/keiluvworkspace.h \ + $$PWD/keiluvworkspacewriter.h + +SOURCES += \ + $$PWD/keiluvfilesgroupspropertygroup.cpp \ + $$PWD/keiluvgenerator.cpp \ + $$PWD/keiluvproject.cpp \ + $$PWD/keiluvprojectwriter.cpp \ + $$PWD/keiluvutils.cpp \ + $$PWD/keiluvworkspace.cpp \ + $$PWD/keiluvworkspacewriter.cpp + +# For MCS51 architecture. + +HEADERS += \ + $$PWD/archs/mcs51/mcs51buildtargetgroup_v5.h \ + $$PWD/archs/mcs51/mcs51commonpropertygroup_v5.h \ + $$PWD/archs/mcs51/mcs51debugoptiongroup_v5.h \ + $$PWD/archs/mcs51/mcs51dlloptiongroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetassemblergroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetcommonoptionsgroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetcompilergroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetgroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetlinkergroup_v5.h \ + $$PWD/archs/mcs51/mcs51targetmiscgroup_v5.h \ + $$PWD/archs/mcs51/mcs51utilitiesgroup_v5.h \ + $$PWD/archs/mcs51/mcs51utils.h + +SOURCES += \ + $$PWD/archs/mcs51/mcs51buildtargetgroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51commonpropertygroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51debugoptiongroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51dlloptiongroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetassemblergroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetcommonoptionsgroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetcompilergroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetgroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetlinkergroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51targetmiscgroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51utilitiesgroup_v5.cpp \ + $$PWD/archs/mcs51/mcs51utils.cpp + +# For ARM architecture. + +HEADERS += \ + $$PWD/archs/arm/armbuildtargetgroup_v5.h \ + $$PWD/archs/arm/armcommonpropertygroup_v5.h \ + $$PWD/archs/arm/armdebugoptiongroup_v5.h \ + $$PWD/archs/arm/armdlloptiongroup_v5.h \ + $$PWD/archs/arm/armtargetassemblergroup_v5.h \ + $$PWD/archs/arm/armtargetcommonoptionsgroup_v5.h \ + $$PWD/archs/arm/armtargetcompilergroup_v5.h \ + $$PWD/archs/arm/armtargetgroup_v5.h \ + $$PWD/archs/arm/armtargetlinkergroup_v5.h \ + $$PWD/archs/arm/armtargetmiscgroup_v5.h \ + $$PWD/archs/arm/armutilitiesgroup_v5.h + +SOURCES += \ + $$PWD/archs/arm/armbuildtargetgroup_v5.cpp \ + $$PWD/archs/arm/armcommonpropertygroup_v5.cpp \ + $$PWD/archs/arm/armdebugoptiongroup_v5.cpp \ + $$PWD/archs/arm/armdlloptiongroup_v5.cpp \ + $$PWD/archs/arm/armtargetassemblergroup_v5.cpp \ + $$PWD/archs/arm/armtargetcommonoptionsgroup_v5.cpp \ + $$PWD/archs/arm/armtargetcompilergroup_v5.cpp \ + $$PWD/archs/arm/armtargetgroup_v5.cpp \ + $$PWD/archs/arm/armtargetlinkergroup_v5.cpp \ + $$PWD/archs/arm/armtargetmiscgroup_v5.cpp \ + $$PWD/archs/arm/armutilitiesgroup_v5.cpp diff --git a/src/plugins/generator/keiluv/keiluv.qbs b/src/plugins/generator/keiluv/keiluv.qbs new file mode 100644 index 00000000..6074380b --- /dev/null +++ b/src/plugins/generator/keiluv/keiluv.qbs @@ -0,0 +1,88 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + Depends { name: "qbsjson" } + + name: "keiluvgenerator" + + files: ["keiluvgeneratorplugin.cpp"] + + Group { + name: "KEIL UV generator common" + files: [ + "keiluvfilesgroupspropertygroup.cpp", + "keiluvfilesgroupspropertygroup.h", + "keiluvgenerator.cpp", + "keiluvgenerator.h", + "keiluvproject.cpp", + "keiluvproject.h", + "keiluvprojectwriter.cpp", + "keiluvprojectwriter.h", + "keiluvutils.cpp", + "keiluvutils.h", + "keiluvversioninfo.h", + "keiluvworkspace.cpp", + "keiluvworkspace.h", + "keiluvworkspacewriter.cpp", + "keiluvworkspacewriter.h", + ] + } + Group { + name: "KEIL UV generator for MCS51" + prefix: "archs/mcs51/" + files: [ + "mcs51buildtargetgroup_v5.cpp", + "mcs51buildtargetgroup_v5.h", + "mcs51commonpropertygroup_v5.cpp", + "mcs51commonpropertygroup_v5.h", + "mcs51debugoptiongroup_v5.cpp", + "mcs51debugoptiongroup_v5.h", + "mcs51dlloptiongroup_v5.cpp", + "mcs51dlloptiongroup_v5.h", + "mcs51targetassemblergroup_v5.cpp", + "mcs51targetassemblergroup_v5.h", + "mcs51targetcommonoptionsgroup_v5.cpp", + "mcs51targetcommonoptionsgroup_v5.h", + "mcs51targetcompilergroup_v5.cpp", + "mcs51targetcompilergroup_v5.h", + "mcs51targetgroup_v5.cpp", + "mcs51targetgroup_v5.h", + "mcs51targetlinkergroup_v5.cpp", + "mcs51targetlinkergroup_v5.h", + "mcs51targetmiscgroup_v5.cpp", + "mcs51targetmiscgroup_v5.h", + "mcs51utilitiesgroup_v5.cpp", + "mcs51utilitiesgroup_v5.h", + "mcs51utils.cpp", + "mcs51utils.h", + ] + } + Group { + name: "KEIL UV generator for ARM" + prefix: "archs/arm/" + files: [ + "armbuildtargetgroup_v5.cpp", + "armbuildtargetgroup_v5.h", + "armcommonpropertygroup_v5.cpp", + "armcommonpropertygroup_v5.h", + "armdebugoptiongroup_v5.cpp", + "armdebugoptiongroup_v5.h", + "armdlloptiongroup_v5.cpp", + "armdlloptiongroup_v5.h", + "armtargetassemblergroup_v5.cpp", + "armtargetassemblergroup_v5.h", + "armtargetcommonoptionsgroup_v5.cpp", + "armtargetcommonoptionsgroup_v5.h", + "armtargetcompilergroup_v5.cpp", + "armtargetcompilergroup_v5.h", + "armtargetgroup_v5.cpp", + "armtargetgroup_v5.h", + "armtargetlinkergroup_v5.cpp", + "armtargetlinkergroup_v5.h", + "armtargetmiscgroup_v5.cpp", + "armtargetmiscgroup_v5.h", + "armutilitiesgroup_v5.cpp", + "armutilitiesgroup_v5.h", + ] + } +} diff --git a/src/plugins/generator/keiluv/keiluvconstants.h b/src/plugins/generator/keiluv/keiluvconstants.h new file mode 100644 index 00000000..0d27ab81 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvconstants.h @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVCONSTANTS_H +#define QBS_KEILUVCONSTANTS_H + +namespace qbs { +namespace KeiluvConstants { + +namespace v5 { +constexpr int kUVisionVersion = 5; +} + +} // namespace KeiluvConstants +} // namespace qbs + +#endif // QBS_KEILUVCONSTANTS_H diff --git a/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.cpp b/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.cpp new file mode 100644 index 00000000..79281a15 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.cpp @@ -0,0 +1,197 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvfilesgroupspropertygroup.h" +#include "keiluvutils.h" + +#include + +#include +#include + +namespace qbs { + +class KeiluvFilePropertyGroup final : public gen::xml::PropertyGroup +{ +public: + explicit KeiluvFilePropertyGroup( + const QString &fullFilePath, + const QString &baseDirectory) + : gen::xml::PropertyGroup("File") + { + const QFileInfo fileInfo(fullFilePath); + const auto fileName = fileInfo.fileName(); + const auto fileType = encodeFileType(fileInfo.suffix()); + const auto filePath = QDir::toNativeSeparators( + gen::utils::relativeFilePath( + baseDirectory, + fileInfo.absoluteFilePath())); + + appendChild(QByteArrayLiteral("FileName"), + fileName); + appendChild(QByteArrayLiteral("FileType"), + fileType); + appendChild(QByteArrayLiteral("FilePath"), + filePath); + } + +private: + enum FileType { + UnknownFileType = 0, + CSourceFileType = 1, + AssemblerFileType = 2, + LibraryFileType = 4, + TextFileType = 5, + CppSourceFileType = 8, + }; + + static FileType encodeFileType(const QString &fileSuffix) + { + if (fileSuffix.compare(QLatin1String("c"), + Qt::CaseInsensitive) == 0) { + return CSourceFileType; + } + if (fileSuffix.compare(QLatin1String("cpp"), + Qt::CaseInsensitive) == 0) { + return CppSourceFileType; + } + if (fileSuffix.compare(QLatin1String("s"), + Qt::CaseInsensitive) == 0 + || fileSuffix.compare(QLatin1String("a51"), + Qt::CaseInsensitive) == 0) { + return AssemblerFileType; + } + if (fileSuffix.compare(QLatin1String("lib"), + Qt::CaseInsensitive) == 0) { + return LibraryFileType; + } + // All header files, text files and include files + // interpretes as a text file types. + return TextFileType; + } +}; + +class KeiluvFilesPropertyGroup final : public gen::xml::PropertyGroup +{ +public: + explicit KeiluvFilesPropertyGroup( + const QList &sourceArtifacts, + const QString &baseDirectory) + : gen::xml::PropertyGroup("Files") + { + for (const auto &artifact : sourceArtifacts) + appendChild(artifact.filePath(), + baseDirectory); + } + + explicit KeiluvFilesPropertyGroup( + const QStringList &filePaths, + const QString &baseDirectory) + : gen::xml::PropertyGroup("Files") + { + for (const auto &filePath : filePaths) + appendChild(filePath, + baseDirectory); + } +}; + +class KeiluvFileGroupPropertyGroup final : public gen::xml::PropertyGroup +{ +public: + explicit KeiluvFileGroupPropertyGroup( + const QString &groupName, + const QList &sourceArtifacts, + const QString &baseDirectory) + : gen::xml::PropertyGroup("Group") + { + appendChild(QByteArrayLiteral("GroupName"), + groupName); + + appendChild(sourceArtifacts, + baseDirectory); + } + + explicit KeiluvFileGroupPropertyGroup( + const QString &groupName, + const QStringList &filePaths, + const QString &baseDirectory) + : gen::xml::PropertyGroup("Group") + { + appendChild(QByteArrayLiteral("GroupName"), + groupName); + + appendChild(filePaths, + baseDirectory); + } +}; + +KeiluvFilesGroupsPropertyGroup::KeiluvFilesGroupsPropertyGroup( + const Project &qbsProject, + const ProductData &qbsProduct, + const std::vector &qbsProductDeps) + : gen::xml::PropertyGroup(QByteArrayLiteral("Groups")) +{ + const auto baseDirectory = gen::utils::buildRootPath(qbsProject); + + // Build source items. + for (const auto &group : qbsProduct.groups()) { + // Ignore disabled groups (e.g. when its condition property is false). + if (!group.isEnabled()) + continue; + auto sourceArtifacts = group.sourceArtifacts(); + // Remove the linker script artifacts. + Internal::removeIf(sourceArtifacts, [](const auto &artifact){ + const auto tags = artifact.fileTags(); + return tags.contains(QLatin1String("linkerscript")); + }); + + if (sourceArtifacts.isEmpty()) + continue; + appendChild( + group.name(), sourceArtifacts, baseDirectory); + } + + // Build local static library items. + const auto &qbsProps = qbsProduct.moduleProperties(); + const auto staticLibs = KeiluvUtils::staticLibraries(qbsProps); + if (!staticLibs.isEmpty()) { + appendChild( + QStringLiteral("Static Libs"), staticLibs, baseDirectory); + } + + // Build dependency library items. + const auto deps = KeiluvUtils::dependencies(qbsProductDeps); + if (!deps.isEmpty()) { + appendChild( + QStringLiteral("Dependencies"), deps, baseDirectory); + } +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.h b/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.h new file mode 100644 index 00000000..bde86b89 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvfilesgroupspropertygroup.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVFILESGROUPSPROPERTYGROUP_H +#define QBS_KEILUVFILESGROUPSPROPERTYGROUP_H + +#include + +#include + +namespace qbs { + +class KeiluvFilesGroupsPropertyGroup final + : public gen::xml::PropertyGroup +{ +public: + explicit KeiluvFilesGroupsPropertyGroup( + const qbs::Project &qbsProject, + const qbs::ProductData &qbsProduct, + const std::vector &qbsProductDeps); +}; + +} // namespace qbs + +#endif // QBS_KEILUVFILESGROUPSPROPERTYGROUP_H diff --git a/src/plugins/generator/keiluv/keiluvgenerator.cpp b/src/plugins/generator/keiluv/keiluvgenerator.cpp new file mode 100644 index 00000000..f98f55ab --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvgenerator.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvgenerator.h" +#include "keiluvproject.h" +#include "keiluvprojectwriter.h" +#include "keiluvworkspace.h" +#include "keiluvworkspacewriter.h" + +#include +#include + +#include +#include + +#include + +namespace qbs { + +static void writeProjectFiles(const std::map> &projects, + const Internal::Logger &logger) +{ + for (const auto &item : projects) { + const QString projectFilePath = item.first; + Internal::FileSaver file(projectFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Internal::Tr::tr("Cannot open %s for writing") + .arg(projectFilePath)); + + std::shared_ptr project = item.second; + KeiluvProjectWriter writer(file.device()); + if (!(writer.write(project.get()) && file.commit())) + throw ErrorInfo(Internal::Tr::tr("Failed to generate %1") + .arg(projectFilePath)); + + logger.qbsInfo() << Internal::Tr::tr("Generated %1").arg( + QFileInfo(projectFilePath).fileName()); + } +} + +static void writeWorkspace(const std::shared_ptr &wokspace, + const QString &workspaceFilePath, + const Internal::Logger &logger) +{ + Internal::FileSaver file(workspaceFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Internal::Tr::tr("Cannot open %s for writing") + .arg(workspaceFilePath)); + + KeiluvWorkspaceWriter writer(file.device()); + if (!(writer.write(wokspace.get()) && file.commit())) + throw ErrorInfo(Internal::Tr::tr("Failed to generate %1") + .arg(workspaceFilePath)); + + logger.qbsInfo() << Internal::Tr::tr("Generated %1").arg( + QFileInfo(workspaceFilePath).fileName()); +} + +KeiluvGenerator::KeiluvGenerator(const gen::VersionInfo &versionInfo) + : m_versionInfo(versionInfo) +{ +} + +QString KeiluvGenerator::generatorName() const +{ + return QStringLiteral("keiluv%1").arg(m_versionInfo.marketingVersion()); +} + +void KeiluvGenerator::reset() +{ + m_workspace.reset(); + m_workspaceFilePath.clear(); + m_projects.clear(); +} + +void KeiluvGenerator::generate() +{ + GeneratableProjectIterator it(project()); + it.accept(this); + + writeProjectFiles(m_projects, logger()); + writeWorkspace(m_workspace, m_workspaceFilePath, logger()); + + reset(); +} + +void KeiluvGenerator::visitProject(const GeneratableProject &project) +{ + const QDir buildDir = project.baseBuildDirectory(); + + m_workspaceFilePath = buildDir.absoluteFilePath( + project.name() + QStringLiteral(".uvmpw")); + m_workspace = std::make_shared(m_workspaceFilePath); +} + +void KeiluvGenerator::visitProjectData( + const GeneratableProject &project, + const GeneratableProjectData &projectData) +{ + Q_UNUSED(project) + Q_UNUSED(projectData) +} + +void KeiluvGenerator::visitProduct( + const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) +{ + Q_UNUSED(projectData); + + const QDir baseBuildDir(project.baseBuildDirectory().absolutePath()); + const QString projFileName = productData.name() + QLatin1String(".uvprojx"); + const QString projectFilePath = baseBuildDir.absoluteFilePath(projFileName); + const auto targetProject = std::make_shared( + project, productData, m_versionInfo); + + m_projects.insert({projectFilePath, targetProject}); + m_workspace->addProject(projectFilePath); +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvgenerator.h b/src/plugins/generator/keiluv/keiluvgenerator.h new file mode 100644 index 00000000..25b89b9c --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvgenerator.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVGENERATOR_H +#define QBS_KEILUVGENERATOR_H + +#include "keiluvversioninfo.h" + +#include +#include + +namespace qbs { + +class KeiluvProject; +class KeiluvWorkspace; + +class KeiluvGenerator final : public ProjectGenerator, + private IGeneratableProjectVisitor +{ +public: + explicit KeiluvGenerator(const gen::VersionInfo &versionInfo); + + QString generatorName() const final; + void generate() final; + +private: + void reset(); + + void visitProject(const GeneratableProject &project) final; + void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) final; + void visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) final; + + const gen::VersionInfo m_versionInfo; + std::shared_ptr m_workspace; + QString m_workspaceFilePath; + std::map> m_projects; +}; + +} // namespace qbs + +#endif // QBS_KEILUVGENERATOR_H diff --git a/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp b/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp new file mode 100644 index 00000000..abbccc3d --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvgeneratorplugin.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "keiluvgenerator.h" +#include "keiluvversioninfo.h" + +#include +#include + +static void QbsKeiluvGeneratorPluginLoad() +{ + for (const auto &info : qbs::KeiluvVersionInfo::knownVersions) { + qbs::ProjectGeneratorManager::registerGenerator( + std::make_shared(info)); + } +} + +static void QbsKeiluvGeneratorPluginUnload() +{ +} + +#ifndef GENERATOR_EXPORT +#if defined(WIN32) || defined(_WIN32) +#define GENERATOR_EXPORT __declspec(dllexport) +#else +#define GENERATOR_EXPORT __attribute__((visibility("default"))) +#endif +#endif + +QBS_REGISTER_STATIC_PLUGIN(extern "C" GENERATOR_EXPORT, keiluvgenerator, + QbsKeiluvGeneratorPluginLoad, QbsKeiluvGeneratorPluginUnload) diff --git a/src/plugins/generator/keiluv/keiluvproject.cpp b/src/plugins/generator/keiluv/keiluvproject.cpp new file mode 100644 index 00000000..89db73b1 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvproject.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvconstants.h" +#include "keiluvproject.h" +#include "keiluvutils.h" +#include "keiluvversioninfo.h" + +#include "archs/mcs51/mcs51buildtargetgroup_v5.h" +#include "archs/arm/armbuildtargetgroup_v5.h" + +#include + +namespace qbs { + +static QString keilProjectSchema(const gen::VersionInfo &info) +{ + const auto v = info.marketingVersion(); + switch (v) { + case KeiluvConstants::v5::kUVisionVersion: + return QStringLiteral("2.1"); + default: + return {}; + } +} + +KeiluvProject::KeiluvProject(const qbs::GeneratableProject &genProject, + const qbs::GeneratableProductData &genProduct, + const gen::VersionInfo &versionInfo) +{ + Q_ASSERT(genProject.projects.size() == genProject.commandLines.size()); + Q_ASSERT(genProject.projects.size() == genProduct.data.size()); + + // Create available configuration group factories. + m_factories.push_back(std::make_unique< + keiluv::mcs51::v5::Mcs51BuildTargetGroupFactory>()); + m_factories.push_back(std::make_unique< + keiluv::arm::v5::ArmBuildTargetGroupFactory>()); + + // Construct schema version item (is it depends on a project version?). + const auto schema = keilProjectSchema(versionInfo); + appendChild(QByteArrayLiteral("SchemaVersion"), + schema); + + // Construct targets group. + const auto targetsGroup = appendChild( + QByteArrayLiteral("Targets")); + + // Construct all build target items. + const int configsCount = std::max(genProject.projects.size(), + genProduct.data.size()); + for (auto configIndex = 0; configIndex < configsCount; ++configIndex) { + const qbs::Project qbsProject = genProject.projects + .values().at(configIndex); + const qbs::ProductData qbsProduct = genProduct.data + .values().at(configIndex); + const QString confName = gen::utils::buildConfigurationName(qbsProject); + const std::vector qbsProductDeps = gen::utils::dependenciesOf + (qbsProduct, genProject, confName); + + const auto arch = gen::utils::architecture(qbsProject); + if (arch == gen::utils::Architecture::Unknown) + throw ErrorInfo(Internal::Tr::tr("Target architecture is not set," + " please use the 'profile' option")); + + // Construct the build target item, which are depend from + // the architecture and the version. + const auto factoryEnd = m_factories.cend(); + const auto factoryIt = std::find_if(m_factories.cbegin(), factoryEnd, + [arch, versionInfo](const auto &factory) { + return factory->canCreate(arch, versionInfo.version()); + }); + if (factoryIt == factoryEnd) { + throw ErrorInfo(Internal::Tr::tr("Incompatible target architecture '%1'" + " for KEIL UV version %2") + .arg(gen::utils::architectureName(arch)) + .arg(versionInfo.marketingVersion())); + } + + auto targetGroup = (*factoryIt)->create( + qbsProject, qbsProduct, qbsProductDeps); + targetsGroup->appendChild(std::move(targetGroup)); + } +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvproject.h b/src/plugins/generator/keiluv/keiluvproject.h new file mode 100644 index 00000000..da86f71f --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvproject.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVPROJECT_H +#define QBS_KEILUVPROJECT_H + +#include + +#include +#include + +#include + +namespace qbs { + +class KeiluvProject final : public gen::xml::Project +{ +public: + explicit KeiluvProject( + const qbs::GeneratableProject &genProject, + const qbs::GeneratableProductData &genProduct, + const gen::VersionInfo &versionInfo); +private: + std::vector> m_factories; +}; + +} // namespace qbs + +#endif // QBS_KEILUVPROJECT_H diff --git a/src/plugins/generator/keiluv/keiluvprojectwriter.cpp b/src/plugins/generator/keiluv/keiluvprojectwriter.cpp new file mode 100644 index 00000000..77616335 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvprojectwriter.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvprojectwriter.h" + +namespace qbs { + +KeiluvProjectWriter::KeiluvProjectWriter(std::ostream *device) + : gen::xml::ProjectWriter(device) +{ +} + +void KeiluvProjectWriter::visitProjectStart(const gen::xml::Project *project) +{ + Q_UNUSED(project) + writer()->writeStartElement(QStringLiteral("Project")); + writer()->writeAttribute( + QStringLiteral("xmlns:xsi"), + QStringLiteral("http://www.w3.org/2001/XMLSchema-instance")); + writer()->writeAttribute( + QStringLiteral("xsi:noNamespaceSchemaLocation"), + QStringLiteral("project_proj.xsd")); +} + +void KeiluvProjectWriter::visitProjectEnd(const gen::xml::Project *project) +{ + Q_UNUSED(project) + writer()->writeEndElement(); +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvprojectwriter.h b/src/plugins/generator/keiluv/keiluvprojectwriter.h new file mode 100644 index 00000000..6f890c8e --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvprojectwriter.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVPROJECTWRITER_H +#define QBS_KEILUVPROJECTWRITER_H + +#include + +namespace qbs { + +class KeiluvProjectWriter final : public gen::xml::ProjectWriter +{ + Q_DISABLE_COPY(KeiluvProjectWriter) +public: + explicit KeiluvProjectWriter(std::ostream *device); + +private: + void visitProjectStart(const gen::xml::Project *project) final; + void visitProjectEnd(const gen::xml::Project *project) final; +}; + +} // namespace qbs + +#endif // QBS_KEILUVPROJECTWRITER_H diff --git a/src/plugins/generator/keiluv/keiluvutils.cpp b/src/plugins/generator/keiluv/keiluvutils.cpp new file mode 100644 index 00000000..628a8e98 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvutils.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvutils.h" + +#include + +#include + +namespace qbs { +namespace KeiluvUtils { + +OutputBinaryType outputBinaryType(const ProductData &qbsProduct) +{ + const auto &qbsProductType = qbsProduct.type(); + if (qbsProductType.contains(QLatin1String("application"))) + return ApplicationOutputType; + if (qbsProductType.contains(QLatin1String("staticlibrary"))) + return LibraryOutputType; + return ApplicationOutputType; +} + +QString toolkitRootPath(const ProductData &qbsProduct) +{ + QDir dir(qbsProduct.moduleProperties() + .getModuleProperty(Internal::StringConstants::cppModule(), + QStringLiteral("toolchainInstallPath")) + .toString()); + dir.cdUp(); + const auto path = dir.absolutePath(); + return QDir::toNativeSeparators(path); +} + +QStringList cppModuleCompilerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverFlags"), QStringLiteral("cFlags"), + QStringLiteral("cppFlags"), QStringLiteral("cxxFlags"), + QStringLiteral("commonCompilerFlags")}); +} + +QStringList cppModuleAssemblerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("assemblerFlags")}); +} + +QStringList cppModuleLinkerFlags(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("driverLinkerFlags")}); +} + +QStringList includes(const PropertyMap &qbsProps) +{ + auto paths = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("includePaths"), + QStringLiteral("systemIncludePaths")}); + // Transform include path separators to native. + Internal::transform(paths, [](const auto &path) { + return QDir::toNativeSeparators(path); }); + return paths; +} + +QStringList defines(const PropertyMap &qbsProps) +{ + return gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("defines")}); +} + +QStringList staticLibraries(const PropertyMap &qbsProps) +{ + auto libs = gen::utils::cppStringModuleProperties( + qbsProps, {QStringLiteral("staticLibraries")}); + // Transform library path separators to native. + Internal::transform(libs, [](const auto &path) { + return QDir::toNativeSeparators(path); }); + return libs; +} + +QStringList dependencies(const std::vector &qbsProductDeps) +{ + return Internal::transformed(qbsProductDeps, [](const auto &dep) { + const auto path = dep.buildDirectory() + QLatin1String("/obj/") + + gen::utils::targetBinary(dep); + return QDir::toNativeSeparators(path); + }); +} + +} // namespace KeiluvUtils +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvutils.h b/src/plugins/generator/keiluv/keiluvutils.h new file mode 100644 index 00000000..92209dc5 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvutils.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVUTILS_H +#define QBS_KEILUVUTILS_H + +#include + +#include + +namespace qbs { +namespace KeiluvUtils { + +enum OutputBinaryType { + ApplicationOutputType, + LibraryOutputType +}; + +OutputBinaryType outputBinaryType(const ProductData &qbsProduct); + +QString toolkitRootPath(const ProductData &qbsProduct); + +QStringList cppModuleCompilerFlags(const PropertyMap &qbsProps); + +QStringList cppModuleAssemblerFlags(const PropertyMap &qbsProps); + +QStringList cppModuleLinkerFlags(const PropertyMap &qbsProps); + +QStringList includes(const PropertyMap &qbsProps); +QStringList defines(const PropertyMap &qbsProps); +QStringList staticLibraries(const PropertyMap &qbsProps); +QStringList dependencies(const std::vector &qbsProductDeps); + +} // namespace KeiluvUtils +} // namespace qbs + +#endif // QBS_KEILUVUTILS_H diff --git a/src/plugins/generator/keiluv/keiluvversioninfo.h b/src/plugins/generator/keiluv/keiluvversioninfo.h new file mode 100644 index 00000000..cc379c3d --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvversioninfo.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_KEILUVVERSIONINFO_H +#define QBS_KEILUVVERSIONINFO_H + +#include "keiluvconstants.h" + +#include +#include + +namespace qbs { +namespace KeiluvVersionInfo { + +constexpr gen::VersionInfo knownVersions[] = { + {Version(KeiluvConstants::v5::kUVisionVersion), + {gen::utils::Architecture::Mcs51, + gen::utils::Architecture::Arm}}, +}; + +} // namespace KeiluvVersionInfo +} // namespace qbs + +#endif // QBS_KEILUVVERSIONINFO_H diff --git a/src/plugins/generator/keiluv/keiluvworkspace.cpp b/src/plugins/generator/keiluv/keiluvworkspace.cpp new file mode 100644 index 00000000..b4df9200 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvworkspace.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "keiluvworkspace.h" + +#include + +namespace qbs { + +KeiluvWorkspace::KeiluvWorkspace(const QString &workspacePath) + : gen::xml::Workspace(workspacePath) +{ + // Construct schema version item. + appendChild(QByteArrayLiteral("SchemaVersion"), + QStringLiteral("1.0")); + + // Construct workspace name item. + appendChild(QByteArrayLiteral("WorkspaceName"), + QStringLiteral("WorkSpace")); +} + +void KeiluvWorkspace::addProject(const QString &projectFilePath) +{ + const QString relativeProjectPath = QDir::toNativeSeparators( + m_baseDirectory.relativeFilePath(projectFilePath)); + + const auto projectGroup = appendChild( + QByteArrayLiteral("project")); + projectGroup->appendProperty("PathAndName", relativeProjectPath); +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvworkspace.h b/src/plugins/generator/keiluv/keiluvworkspace.h new file mode 100644 index 00000000..2b274c99 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvworkspace.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_KEILUVWORKSPACE_H +#define QBS_KEILUVWORKSPACE_H + +#include + +namespace qbs { + +class KeiluvWorkspace final : public gen::xml::Workspace +{ +public: + explicit KeiluvWorkspace(const QString &workspacePath); + void addProject(const QString &projectPath) final; +}; + +} // namespace qbs + +#endif // QBS_KEILUVWORKSPACE_H diff --git a/src/plugins/generator/keiluv/keiluvworkspacewriter.cpp b/src/plugins/generator/keiluv/keiluvworkspacewriter.cpp new file mode 100644 index 00000000..c886b0e6 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvworkspacewriter.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "keiluvworkspacewriter.h" + +namespace qbs { + +KeiluvWorkspaceWriter::KeiluvWorkspaceWriter(std::ostream *device) + : gen::xml::WorkspaceWriter(device) +{ +} + +void KeiluvWorkspaceWriter::visitWorkspaceStart(const gen::xml::Workspace *workspace) +{ + Q_UNUSED(workspace) + writer()->writeStartElement(QStringLiteral("ProjectWorkspace")); + writer()->writeAttribute( + QStringLiteral("xmlns:xsi"), + QStringLiteral("http://www.w3.org/2001/XMLSchema-instance")); + writer()->writeAttribute( + QStringLiteral("xsi:noNamespaceSchemaLocation"), + QStringLiteral("project_mpw.xsd")); +} + +void KeiluvWorkspaceWriter::visitWorkspaceEnd(const gen::xml::Workspace *workspace) +{ + Q_UNUSED(workspace) + writer()->writeEndElement(); +} + +} // namespace qbs diff --git a/src/plugins/generator/keiluv/keiluvworkspacewriter.h b/src/plugins/generator/keiluv/keiluvworkspacewriter.h new file mode 100644 index 00000000..2419ad76 --- /dev/null +++ b/src/plugins/generator/keiluv/keiluvworkspacewriter.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Denis Shienkov +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_KEILUVWORKSPACEWRITER_H +#define QBS_KEILUVWORKSPACEWRITER_H + +#include + +namespace qbs { + +class KeiluvWorkspaceWriter final : public gen::xml::WorkspaceWriter +{ + Q_DISABLE_COPY(KeiluvWorkspaceWriter) +public: + explicit KeiluvWorkspaceWriter(std::ostream *device); + +private: + void visitWorkspaceStart(const gen::xml::Workspace *workspace) final; + void visitWorkspaceEnd(const gen::xml::Workspace *workspace) final; +}; + +} // namespace qbs + +#endif // QBS_KEILUVWORKSPACEWRITER_H diff --git a/src/plugins/generator/makefilegenerator/CMakeLists.txt b/src/plugins/generator/makefilegenerator/CMakeLists.txt new file mode 100644 index 00000000..8e6e3510 --- /dev/null +++ b/src/plugins/generator/makefilegenerator/CMakeLists.txt @@ -0,0 +1,10 @@ +set(SOURCES + makefilegenerator.cpp + makefilegenerator.h + makefilegeneratorplugin.cpp + ) + +add_qbs_plugin(makefilegenerator + DEPENDS qbscore + SOURCES ${SOURCES} + ) diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.cpp b/src/plugins/generator/makefilegenerator/makefilegenerator.cpp new file mode 100644 index 00000000..c53dccd3 --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegenerator.cpp @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "makefilegenerator.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +using namespace Internal; + +QString qbs::MakefileGenerator::generatorName() const +{ + return QStringLiteral("makefile"); +} + +static QString quote(const QString &s) +{ + QString quoted = shellQuote(s); + quoted.replace(QLatin1Char('$'), QLatin1String("$$")); // For make + quoted.replace(QLatin1String("$$(SRCDIR)"), QLatin1String("$(SRCDIR)")); + quoted.replace(QLatin1String("$$(BUILD_ROOT)"), QLatin1String("$(BUILD_ROOT)")); + quoted.replace(QLatin1String("$$(INSTALL_ROOT)"), QLatin1String("$(INSTALL_ROOT)")); + return quoted; +} + +enum class TargetType { Product, Path }; +static QString makeValidTargetName(const QString &name, TargetType targetType) +{ + QString modifiedName = name; + switch (targetType) { + case TargetType::Product: { + static const QRegularExpression illegalChar(QStringLiteral("[^_.0-9A-Za-z]")); + modifiedName.replace(illegalChar, QStringLiteral("_")); + break; + } + case TargetType::Path: + if (HostOsInfo::isWindowsHost()) { + modifiedName = QDir::toNativeSeparators(modifiedName); + modifiedName = quote(modifiedName); + } else { + modifiedName.replace(QLatin1Char(' '), QStringLiteral("\\ ")); + } + } + return modifiedName; +} + +static QString makeValidTargetName(const ProductData &product) +{ + QString name = makeValidTargetName(product.name(), TargetType::Product); + if (!product.multiplexConfigurationId().isEmpty()) + name.append(QLatin1Char('_')).append(product.multiplexConfigurationId()); + return name; +} + +using PrefixSpec = std::pair; +static QString replacePrefix(const QString &path, const std::vector &candidates) +{ + for (const PrefixSpec &prefixSpec : candidates) { + if (path.startsWith(prefixSpec.first) + && (path.size() == prefixSpec.first.size() + || path.at(prefixSpec.first.size()) == QLatin1Char('/'))) { + QString p = path; + return p.replace(0, prefixSpec.first.size(), + QLatin1String("$(") + prefixSpec.second + QLatin1Char(')')); + } + } + return path; +} + +static QString bruteForcePathReplace(const QString &value, const QString &srcDir, + const QString &buildDir, const QString &installRoot) +{ + QString transformedValue = value; + if (!installRoot.isEmpty()) + transformedValue.replace(installRoot, QStringLiteral("$(INSTALL_ROOT)")); + transformedValue.replace(buildDir, QStringLiteral("$(BUILD_ROOT)")); + transformedValue.replace(srcDir, QStringLiteral("$(SRCDIR)")); + return transformedValue; +} + +static QString mkdirCmdLine(const QString &dir) +{ + if (HostOsInfo::isWindowsHost()) + return QStringLiteral("if not exist %1 mkdir %1 & if not exist %1 exit 1").arg(dir); + return QStringLiteral("mkdir -p ") + dir; +} + +static QString installFileCommand() +{ + return HostOsInfo::isWindowsHost() ? QStringLiteral("copy /Y") + : QStringLiteral("install -m 644 -p"); +} + +static QString installProgramCommand() +{ + return HostOsInfo::isWindowsHost() ? installFileCommand() + : QStringLiteral("install -m 755 -p"); +} + +static QString removeCommand() +{ + return HostOsInfo::isWindowsHost() ? QStringLiteral("del") : QStringLiteral("rm -f"); +} + +void qbs::MakefileGenerator::generate() +{ + const auto projects = project().projects.values(); + for (const Project &theProject : projects) { + const QString makefileFilePath = theProject.projectData().buildDirectory() + + QLatin1String("/Makefile"); + QFile makefile(makefileFilePath); + if (!makefile.open(QIODevice::WriteOnly)) { + throw ErrorInfo(Tr::tr("Failed to create '%1': %2") + .arg(makefileFilePath, makefile.errorString())); + } + QTextStream stream(&makefile); + ErrorInfo error; + const ProjectTransformerData projectTransformerData = theProject.transformerData(&error); + if (error.hasError()) + throw error; + stream << "# This file was generated by qbs" << "\n\n"; + stream << "INSTALL_FILE = " << installFileCommand() << '\n'; + stream << "INSTALL_PROGRAM = " << installProgramCommand() << '\n'; + stream << "RM = " << removeCommand() << '\n'; + stream << '\n'; + const ProjectData projectData = theProject.projectData(); + const QString srcDir = QFileInfo(projectData.location().filePath()).path(); + if (srcDir.contains(QLatin1Char(' '))) { + throw ErrorInfo(Tr::tr("The project directory '%1' contains space characters, which" + "is not supported by this generator.").arg(srcDir)); + } + stream << "SRCDIR = " << QDir::toNativeSeparators(srcDir) << '\n'; + const QString &buildDir = projectData.buildDirectory(); + if (buildDir.contains(QLatin1Char(' '))) { + throw ErrorInfo(Tr::tr("The build directory '%1' contains space characters, which" + "is not supported by this generator.").arg(buildDir)); + } + stream << "BUILD_ROOT = " << QDir::toNativeSeparators(buildDir) << '\n'; + QString installRoot; + const QList allInstallables = projectData.installableArtifacts(); + if (!allInstallables.empty()) { + installRoot = allInstallables.first().installData().installRoot(); + if (installRoot.contains(QLatin1Char(' '))) { + throw ErrorInfo(Tr::tr("The install root '%1' contains space characters, which" + "is not supported by this generator.").arg(installRoot)); + } + stream << "INSTALL_ROOT = " << QDir::toNativeSeparators(installRoot) << '\n'; + } + stream << "\nall:\n"; + const std::vector srcDirPrefixSpecs{std::make_pair(srcDir, + QStringLiteral("SRCDIR"))}; + const auto prefixifiedSrcDirPath = [&srcDirPrefixSpecs](const QString &path) { + return replacePrefix(path, srcDirPrefixSpecs); + }; + const std::vector buildRootPrefixSpecs{ + std::make_pair(buildDir, QStringLiteral("BUILD_ROOT"))}; + const auto prefixifiedBuildDirPath = [&buildRootPrefixSpecs](const QString &path) { + return replacePrefix(path, buildRootPrefixSpecs); + }; + const std::vector installRootPrefixSpecs{ + std::make_pair(installRoot, QStringLiteral("INSTALL_ROOT"))}; + const auto prefixifiedInstallDirPath + = [&installRoot, &installRootPrefixSpecs](const QString &path) { + if (installRoot.isEmpty()) + return path; + return replacePrefix(path, installRootPrefixSpecs); + }; + const auto transformedOutputFilePath = [=](const ArtifactData &output) { + return makeValidTargetName(prefixifiedBuildDirPath(output.filePath()), + TargetType::Path); + }; + const auto transformedInputFilePath = [=](const ArtifactData &input) { + return makeValidTargetName(prefixifiedSrcDirPath(input.filePath()), TargetType::Path); + }; + const auto transformedArtifactFilePath = [=](const ArtifactData &artifact) { + return artifact.isGenerated() ? transformedOutputFilePath(artifact) + : transformedInputFilePath(artifact); + }; + QStringList allTargets; + QStringList allDefaultTargets; + QStringList filesCreatedByJsCommands; + bool jsCommandsEncountered = false; + for (const auto &d : projectTransformerData) { + const ProductData productData = d.first; + const QString productTarget = makeValidTargetName(productData); + const ProductTransformerData productTransformerData = d.second; + const bool builtByDefault = productData.properties().value( + StringConstants::builtByDefaultProperty()).toBool(); + if (builtByDefault) + allDefaultTargets.push_back(productTarget); + allTargets.push_back(productTarget); + stream << productTarget << ':'; + const auto targetArtifacts = productData.targetArtifacts(); + for (const ArtifactData &ta : targetArtifacts) + stream << ' ' << transformedOutputFilePath(ta); + stream << '\n'; + for (const TransformerData &transformerData : productTransformerData) { + stream << transformedOutputFilePath(transformerData.outputs().constFirst()) << ":"; + const auto inputs = transformerData.inputs(); + for (const ArtifactData &input : inputs) + stream << ' ' << transformedArtifactFilePath(input); + stream << '\n'; + Set createdDirs; + const auto outputs = transformerData.outputs(); + for (const ArtifactData &output : outputs) { + const QString outputDir = QFileInfo(output.filePath()).path(); + if (createdDirs.insert(outputDir).second) + stream << "\t" << mkdirCmdLine(QDir::toNativeSeparators( + prefixifiedBuildDirPath(outputDir))) + << '\n'; + } + bool processCommandEncountered = false; + const auto commands = transformerData.commands(); + for (const RuleCommand &command : commands) { + if (command.type() == RuleCommand::JavaScriptCommandType) { + jsCommandsEncountered = true; + continue; + } + processCommandEncountered = true; + stream << '\t' << QDir::toNativeSeparators( + quote(bruteForcePathReplace(command.executable(), srcDir, + buildDir, installRoot))); + // TODO: Optionally use environment? + const auto args = command.arguments(); + for (const QString &arg : args) { + stream << ' ' + << quote(bruteForcePathReplace(arg, srcDir, buildDir, installRoot)); + } + stream << '\n'; + } + for (int i = 1; i < transformerData.outputs().size(); ++i) { + stream << transformedOutputFilePath(transformerData.outputs().at(i)) << ": " + << transformedOutputFilePath(transformerData.outputs().at(i-1)) << '\n'; + } + if (!processCommandEncountered && builtByDefault) { + const auto outputs = transformerData.outputs(); + transform(outputs, filesCreatedByJsCommands, [](const auto &output) { + return output.filePath(); }); + } + } + stream << "install-" << productTarget << ": " << productTarget << '\n'; + Set createdDirs; + const auto installableArtifacts = productData.installableArtifacts(); + for (const ArtifactData &artifact : installableArtifacts) { + const QString &outputDir = artifact.installData().localInstallDir(); + if (outputDir.contains(QLatin1Char(' '))) { + logger().qbsWarning() << Tr::tr("Skipping installation of '%1', because " + "target directory '%2' contains spaces.") + .arg(artifact.filePath(), outputDir); + continue; + } + if (createdDirs.insert(outputDir).second) + stream << "\t" << mkdirCmdLine(QDir::toNativeSeparators( + prefixifiedInstallDirPath(outputDir))) + << '\n'; + const QFileInfo fileInfo(artifact.filePath()); + const QString transformedInputFilePath + = QDir::toNativeSeparators((artifact.isGenerated() + ? prefixifiedBuildDirPath(fileInfo.path()) + : prefixifiedSrcDirPath(fileInfo.path())) + + QLatin1Char('/') + quote(fileInfo.fileName())); + const QString transformedOutputDir + = QDir::toNativeSeparators(prefixifiedInstallDirPath( + artifact.installData().localInstallDir())); + stream << "\t" + << (artifact.isExecutable() ? "$(INSTALL_PROGRAM) " : "$(INSTALL_FILE) ") + << transformedInputFilePath << ' ' << transformedOutputDir << '\n'; + } + stream << "clean-" << productTarget << ":\n"; + for (const ArtifactData &artifact : productData.generatedArtifacts()) { + const QFileInfo fileInfo(artifact.filePath()); + const QString transformedFilePath = QDir::toNativeSeparators( + prefixifiedBuildDirPath(fileInfo.path()) + + QLatin1Char('/') + quote(fileInfo.fileName())); + stream << '\t'; + if (HostOsInfo::isWindowsHost()) + stream << '-'; + stream << "$(RM) " << transformedFilePath << '\n'; + } + } + + stream << "all:"; + for (const QString &target : qAsConst(allDefaultTargets)) + stream << ' ' << target; + stream << '\n'; + stream << "install:"; + for (const QString &target : qAsConst(allDefaultTargets)) + stream << ' ' << "install-" << target; + stream << '\n'; + stream << "clean:"; + for (const QString &target : qAsConst(allTargets)) + stream << ' ' << "clean-" << target; + stream << '\n'; + if (!filesCreatedByJsCommands.empty()) { + logger().qbsWarning() << Tr::tr("Some rules used by this project are not " + "Makefile-compatible, because they depend entirely on JavaScriptCommands. " + "The build is probably not fully functional. " + "Affected build artifacts:\n\t%1") + .arg(filesCreatedByJsCommands.join(QLatin1String("\n\t"))); + } else if (jsCommandsEncountered) { + logger().qbsWarning() << Tr::tr("Some rules in this project use JavaScriptCommands, " + "which cannot be converted to Makefile-compatible constructs. The build may " + "not be fully functional."); + } + logger().qbsInfo() << Tr::tr("Makefile successfully generated at '%1'.") + .arg(makefileFilePath); + } +} + +} // namespace qbs diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.h b/src/plugins/generator/makefilegenerator/makefilegenerator.h new file mode 100644 index 00000000..b2b23f08 --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegenerator.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QBS_MAKEFILEGENERATOR_H +#define QBS_MAKEFILEGENERATOR_H + +#include + +namespace qbs { + +class MakefileGenerator : public ProjectGenerator +{ + QString generatorName() const override; + void generate() override; +}; + +} // namespace qbs + +#endif // Include guard. diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.pri b/src/plugins/generator/makefilegenerator/makefilegenerator.pri new file mode 100644 index 00000000..971e63d2 --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegenerator.pri @@ -0,0 +1 @@ +qbsPluginTarget = makefilegenerator diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.pro b/src/plugins/generator/makefilegenerator/makefilegenerator.pro new file mode 100644 index 00000000..c03191c3 --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegenerator.pro @@ -0,0 +1,11 @@ +include(makefilegenerator.pri) +include(../../plugins.pri) + +QT = core + +HEADERS += \ + $$PWD/makefilegenerator.h + +SOURCES += \ + $$PWD/makefilegenerator.cpp \ + $$PWD/makefilegeneratorplugin.cpp diff --git a/src/plugins/generator/makefilegenerator/makefilegenerator.qbs b/src/plugins/generator/makefilegenerator/makefilegenerator.qbs new file mode 100644 index 00000000..8d61defe --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegenerator.qbs @@ -0,0 +1,10 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + name: "makefilegenerator" + files: [ + "makefilegenerator.cpp", + "makefilegenerator.h", + "makefilegeneratorplugin.cpp", + ] +} diff --git a/src/plugins/generator/makefilegenerator/makefilegeneratorplugin.cpp b/src/plugins/generator/makefilegenerator/makefilegeneratorplugin.cpp new file mode 100644 index 00000000..5789414b --- /dev/null +++ b/src/plugins/generator/makefilegenerator/makefilegeneratorplugin.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "makefilegenerator.h" + +#include +#include + +static void MakefileGeneratorPluginLoad() +{ + qbs::ProjectGeneratorManager::registerGenerator( + std::make_shared()); +} + +static void MakefileGeneratorPluginUnload() +{ +} + +#ifndef GENERATOR_EXPORT +#if defined(WIN32) || defined(_WIN32) +#define GENERATOR_EXPORT __declspec(dllexport) +#else +#define GENERATOR_EXPORT __attribute__((visibility("default"))) +#endif +#endif + +QBS_REGISTER_STATIC_PLUGIN(extern "C" GENERATOR_EXPORT, makefilegenerator, + MakefileGeneratorPluginLoad, MakefileGeneratorPluginUnload) diff --git a/src/plugins/generator/visualstudio/CMakeLists.txt b/src/plugins/generator/visualstudio/CMakeLists.txt new file mode 100644 index 00000000..01d0abbf --- /dev/null +++ b/src/plugins/generator/visualstudio/CMakeLists.txt @@ -0,0 +1,25 @@ +set(SOURCES + msbuildfiltersproject.cpp + msbuildfiltersproject.h + msbuildqbsgenerateproject.cpp + msbuildqbsgenerateproject.h + msbuildqbsproductproject.cpp + msbuildqbsproductproject.h + msbuildsharedsolutionpropertiesproject.cpp + msbuildsharedsolutionpropertiesproject.h + msbuildsolutionpropertiesproject.cpp + msbuildsolutionpropertiesproject.h + msbuildtargetproject.cpp + msbuildtargetproject.h + msbuildutils.h + visualstudiogenerator.cpp + visualstudiogenerator.h + visualstudioguidpool.cpp + visualstudioguidpool.h + visualstudiogeneratorplugin.cpp + ) + +add_qbs_plugin(visualstudiogenerator + DEPENDS qbscore qbsmsbuild qbsjson + SOURCES ${SOURCES} + ) diff --git a/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp b/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp new file mode 100644 index 00000000..039b1173 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildfiltersproject.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfiltersproject.h" + +#include "msbuild/msbuilditemgroup.h" + +#include "msbuild/items/msbuildclcompile.h" +#include "msbuild/items/msbuildclinclude.h" +#include "msbuild/items/msbuildfilter.h" +#include "msbuild/items/msbuildnone.h" + +#include + +#include + +#include + +namespace qbs { + +static QStringList sourceFileExtensions() +{ + return {QStringLiteral("c"), QStringLiteral("C"), QStringLiteral("cpp"), + QStringLiteral("cxx"), QStringLiteral("c++"), QStringLiteral("cc"), + QStringLiteral("cs"), QStringLiteral("def"), QStringLiteral("java"), + QStringLiteral("m"), QStringLiteral("mm")}; +} + +static QStringList headerFileExtensions() +{ + return {QStringLiteral("h"), QStringLiteral("H"), QStringLiteral("hpp"), + QStringLiteral("hxx"), QStringLiteral("h++")}; +} + +static std::vector defaultItemGroupFilters(IMSBuildItemGroup *parent = nullptr) +{ + const auto sourceFilter = new MSBuildFilter(QStringLiteral("Source Files"), sourceFileExtensions(), parent); + const auto headerFilter = new MSBuildFilter(QStringLiteral("Header Files"), headerFileExtensions(), parent); + + const auto formFilter = new MSBuildFilter(QStringLiteral("Form Files"), + QStringList() << QStringLiteral("ui"), parent); + const auto resourceFilter = new MSBuildFilter(QStringLiteral("Resource Files"), + QStringList() + << QStringLiteral("qrc") + << QStringLiteral("rc") + << QStringLiteral("*"), parent); + resourceFilter->setParseFiles(false); + const auto generatedFilter = new MSBuildFilter(QStringLiteral("Generated Files"), + QStringList() << QStringLiteral("moc"), parent); + generatedFilter->setSourceControlFiles(false); + const auto translationFilter = new MSBuildFilter(QStringLiteral("Translation Files"), + QStringList() << QStringLiteral("ts"), parent); + translationFilter->setParseFiles(false); + + return std::vector { + sourceFilter, headerFilter, formFilter, resourceFilter, generatedFilter, translationFilter + }; +} + +static bool matchesFilter(const MSBuildFilter *filter, const QString &filePath) +{ + return filter->extensions().contains(QFileInfo(filePath).completeSuffix()); +} + +MSBuildFiltersProject::MSBuildFiltersProject(const GeneratableProductData &product, + QObject *parent) + : MSBuildProject(parent) +{ + // Normally this would be versionInfo.toolsVersion() but for some reason it seems + // filters projects are always v4.0 + setToolsVersion(QStringLiteral("4.0")); + + const auto itemGroup = new MSBuildItemGroup(this); + const auto filterOptions = defaultItemGroupFilters(); + for (const auto options : filterOptions) { + const auto filter = new MSBuildFilter(options->include(), options->extensions(), itemGroup); + filter->appendProperty(QStringLiteral("ParseFiles"), options->parseFiles()); + filter->appendProperty(QStringLiteral("SourceControlFiles"), options->sourceControlFiles()); + } + + using StringSet = Internal::Set; + StringSet allFiles; + const auto productDatas = product.data.values(); + for (const auto &productData : productDatas) { + for (const auto &groupData : productData.groups()) + if (groupData.isEnabled()) + allFiles.unite(Internal::rangeTo(groupData.allFilePaths())); + } + + MSBuildItemGroup *headerFilesGroup = nullptr; + MSBuildItemGroup *sourceFilesGroup = nullptr; + MSBuildItemGroup *filesGroup = nullptr; + + for (const auto &filePath : allFiles) { + MSBuildFileItem *fileItem = nullptr; + + for (const MSBuildFilter *options : filterOptions) { + if (matchesFilter(options, filePath)) { + if (options->include() == QStringLiteral("Header Files")) { + if (!headerFilesGroup) + headerFilesGroup = new MSBuildItemGroup(this); + fileItem = new MSBuildClInclude(headerFilesGroup); + } else if (options->include() == QStringLiteral("Source Files")) { + if (!sourceFilesGroup) + sourceFilesGroup = new MSBuildItemGroup(this); + fileItem = new MSBuildClCompile(sourceFilesGroup); + } + + if (fileItem) { + fileItem->setFilterName(options->include()); + break; + } + } + } + + if (!fileItem) { + if (!filesGroup) + filesGroup = new MSBuildItemGroup(this); + fileItem = new MSBuildNone(filesGroup); + } + fileItem->setFilePath(filePath); + } + + qDeleteAll(filterOptions); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildfiltersproject.h b/src/plugins/generator/visualstudio/msbuildfiltersproject.h new file mode 100644 index 00000000..5d67bfaa --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildfiltersproject.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDFILTERSPROJECT_H +#define MSBUILDFILTERSPROJECT_H + +#include "msbuild/msbuildproject.h" + +#include +#include + +namespace qbs { + +class MSBuildFilter; + +class MSBuildFiltersProject : public MSBuildProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildFiltersProject) +public: + explicit MSBuildFiltersProject(const GeneratableProductData &product, + QObject *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDFILTERSPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.cpp b/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.cpp new file mode 100644 index 00000000..24fc991a --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildqbsgenerateproject.h" + +#include "msbuild/msbuildimport.h" +#include "msbuild/msbuildproperty.h" +#include "msbuild/msbuildpropertygroup.h" + +#include +#include +#include + +namespace qbs { + +MSBuildQbsGenerateProject::MSBuildQbsGenerateProject( + const GeneratableProject &project, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent) + : MSBuildTargetProject(project, versionInfo, parent) +{ + const auto cppDefaultProps = new MSBuildImport(this); + cppDefaultProps->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.Default.props")); + + const auto group = new MSBuildPropertyGroup(this); + group->setLabel(QStringLiteral("Configuration")); + group->appendProperty(QStringLiteral("PlatformToolset"), + versionInfo.platformToolsetVersion()); + group->appendProperty(QStringLiteral("ConfigurationType"), + QStringLiteral("Makefile")); + const auto params = Internal::shellQuote(project.commandLine(), + Internal::HostOsInfo::HostOsWindows); + group->appendProperty(QStringLiteral("NMakeBuildCommandLine"), + QStringLiteral("$(QbsGenerateCommandLine) ") + params); + + const auto cppProps = new MSBuildImport(this); + cppProps->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.props")); + + const auto import = new MSBuildImport(this); + import->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.targets")); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.h b/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.h new file mode 100644 index 00000000..8c5ef80c --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildqbsgenerateproject.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDQBSGENERATEPROJECT_H +#define MSBUILDQBSGENERATEPROJECT_H + +#include "msbuildtargetproject.h" + +#include +#include + +namespace qbs { + +class MSBuildQbsGenerateProject : public MSBuildTargetProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildQbsGenerateProject) +public: + MSBuildQbsGenerateProject(const GeneratableProject &project, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent = nullptr); +}; + +} // namespace qbs + +#endif // MSBUILDQBSGENERATEPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp b/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp new file mode 100644 index 00000000..6f77212d --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildqbsproductproject.cpp @@ -0,0 +1,428 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildqbsproductproject.h" + +#include "msbuild/msbuildimport.h" +#include "msbuild/msbuildimportgroup.h" +#include "msbuild/msbuilditemdefinitiongroup.h" +#include "msbuild/msbuilditemgroup.h" +#include "msbuild/msbuilditemmetadata.h" +#include "msbuild/msbuildproperty.h" +#include "msbuild/msbuildpropertygroup.h" + +#include "msbuild/items/msbuildclcompile.h" +#include "msbuild/items/msbuildclinclude.h" +#include "msbuild/items/msbuildlink.h" +#include "msbuild/items/msbuildnone.h" + +#include "msbuildutils.h" +#include "visualstudiogenerator.h" + +#include +#include +#include +#include +#include + +#include +#include + +namespace qbs { +using namespace Internal; + +MSBuildQbsProductProject::MSBuildQbsProductProject( + const GeneratableProject &project, + const GeneratableProductData &product, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent) + : MSBuildTargetProject(project, versionInfo, parent) +{ + Q_ASSERT(project.projects.size() == project.commandLines.size()); + Q_ASSERT(project.projects.size() == product.data.size()); + + const int count = std::max(project.projects.size(), product.data.size()); + + globalsPropertyGroup()->appendProperty(QStringLiteral("QbsProductName"), product.name()); + + const auto cppDefaultProps = new MSBuildImport(this); + cppDefaultProps->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.Default.props")); + + for (int i = 0; i < count; ++i) { + addConfiguration( + project, + project.projects.values().at(i), + product.data.values().at(i), + project.commandLines.values().at(i)); + } + + const auto cppProps = new MSBuildImport(this); + cppProps->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.props")); + + for (int i = 0; i < count; ++i) + addItemDefGroup(project.projects.values().at(i), product.data.values().at(i)); + + addFiles(project, product); +} + +static QString productTargetPath(const qbs::ProductData &productData) +{ + const QString fullPath = productData.targetExecutable(); + if (!fullPath.isEmpty()) + return QFileInfo(fullPath).absolutePath(); + return productData.properties().value(QStringLiteral("buildDirectory")).toString(); +} + +static bool listEnvironmentVariableContainsValue(const QString &environmentVariable, + const QString &value) +{ + return environmentVariable.contains(QLatin1Char(';') + value + QLatin1Char(';')) + || environmentVariable.startsWith(value + QLatin1Char(';')) + || environmentVariable.endsWith(QLatin1Char(';') + value); +} + +void MSBuildQbsProductProject::addConfiguration(const GeneratableProject &project, + const Project &buildTask, + const ProductData &productData, + const QStringList &buildConfigurationCommandLine) +{ + const auto targetDir = Internal::PathUtils::toNativeSeparators( + productTargetPath(productData), Internal::HostOsInfo::HostOsWindows); + + auto configurationDir = Internal::PathUtils::toNativeSeparators( + project.baseBuildDirectory().absolutePath() + + QLatin1Char('\\') + + MSBuildUtils::configurationName(buildTask), + Internal::HostOsInfo::HostOsWindows); + auto relativeTargetDir = targetDir; + if (targetDir.startsWith(configurationDir)) + relativeTargetDir = QStringLiteral("$(SolutionDir)$(Configuration)") + + relativeTargetDir.mid(configurationDir.size()); + + const auto &properties = productData.moduleProperties(); + + const bool debugBuild = properties.getModuleProperty(StringConstants::qbsModule(), + QStringLiteral("debugInformation")) + .toBool(); + + const auto includePaths = QStringList() + << properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("includePaths")) + << properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("systemIncludePaths")); + const auto cppDefines = properties + .getModulePropertiesAsStringList(QStringLiteral("cpp"), QStringLiteral("defines")); + + const auto sep = Internal::HostOsInfo::pathListSeparator(Internal::HostOsInfo::HostOsWindows); + + const auto propertyGroup1 = new MSBuildPropertyGroup(this); + propertyGroup1->setCondition(MSBuildUtils::buildTaskCondition(buildTask)); + propertyGroup1->setLabel(QStringLiteral("Configuration")); + propertyGroup1->appendProperty(QStringLiteral("UseDebugLibraries"), + debugBuild ? QStringLiteral("true") : QStringLiteral("false")); + + // General - General + // We need a trailing backslash for $(OutDir); See also the VS documentation: + // https://docs.microsoft.com/en-us/cpp/ide/common-macros-for-build-commands-and-properties + propertyGroup1->appendProperty(QStringLiteral("OutDir"), relativeTargetDir + QLatin1Char('\\')); + propertyGroup1->appendProperty(QStringLiteral("TargetName"), productData.targetName()); + propertyGroup1->appendProperty(QStringLiteral("PlatformToolset"), + versionInfo().platformToolsetVersion()); + propertyGroup1->appendProperty(QStringLiteral("ConfigurationType"), QStringLiteral("Makefile")); + + // VS possible values: Unicode|MultiByte|NotSet + propertyGroup1->appendProperty(QStringLiteral("CharacterSet"), + properties.getModuleProperty(QStringLiteral("cpp"), + QStringLiteral("windowsApiCharacterSet")) == QStringLiteral("unicode") + ? QStringLiteral("MultiByte") : QStringLiteral("NotSet")); + + // Debugging + propertyGroup1->appendProperty(QStringLiteral("DebuggerFlavor"), + QStringLiteral("WindowsLocalDebugger")); + propertyGroup1->appendProperty(QStringLiteral("LocalDebuggerCommand"), + QStringLiteral("$(OutDir)$(TargetName)$(TargetExt)")); + propertyGroup1->appendProperty(QStringLiteral("LocalDebuggerWorkingDirectory"), + QStringLiteral("$(OutDir)")); + + auto env = buildTask.getRunEnvironment(productData, project.installOptions, + QProcessEnvironment(), QStringList(), nullptr) + .runEnvironment(); + if (!env.isEmpty()) { + const auto systemEnv = QProcessEnvironment::systemEnvironment(); + const auto keys = systemEnv.keys(); + for (const auto &key : keys) { + if (!env.contains(key)) + continue; + + // Don't duplicate keys from the system environment + if (env.value(key) == systemEnv.value(key)) { + env.remove(key); + continue; + } + + // Cleverly concatenate list variables to avoid duplicating system environment + const QString systemValue = systemEnv.value(key); + QString overriddenValue = env.value(key); + if (listEnvironmentVariableContainsValue(overriddenValue, systemValue)) { + env.insert(key, overriddenValue.replace(systemValue, + QLatin1Char('%') + key + QLatin1Char('%'))); + } + + QString installRoot = project.installOptions.installRoot(); + if (!installRoot.isEmpty()) { + if (listEnvironmentVariableContainsValue(overriddenValue, installRoot)) { + env.insert(key, overriddenValue.replace(installRoot, + QStringLiteral("$(QbsInstallRoot)"))); + } + } else { + installRoot = Internal::PathUtils::toNativeSeparators( + QDir(buildTask.projectData().buildDirectory()).absoluteFilePath( + project.installOptions.defaultInstallRoot()), + Internal::HostOsInfo::HostOsWindows); + if (listEnvironmentVariableContainsValue(overriddenValue, installRoot)) { + env.insert(key, overriddenValue.replace(installRoot, + QStringLiteral("$(SolutionDir)$(Configuration)\\install-root"))); + } + } + } + + propertyGroup1->appendProperty(QStringLiteral("LocalDebuggerEnvironment"), + env.toStringList().join(QLatin1String("\n"))); + } + + // NMake - General + // Skip configuration name, that's handled in qbs-shared.props + const auto params = Internal::shellQuote(buildConfigurationCommandLine.mid(1), + Internal::HostOsInfo::HostOsWindows); + propertyGroup1->appendProperty(QStringLiteral("NMakeBuildCommandLine"), + QStringLiteral("$(QbsBuildCommandLine) ") + params); + propertyGroup1->appendProperty(QStringLiteral("NMakeReBuildCommandLine"), + QStringLiteral("$(QbsReBuildCommandLine) ") + params); + propertyGroup1->appendProperty(QStringLiteral("NMakeCleanCommandLine"), + QStringLiteral("$(QbsCleanCommandLine) ") + params); + propertyGroup1->appendProperty(QStringLiteral("NMakeOutput"), + QStringLiteral("$(OutDir)$(TargetName)$(TargetExt)")); + + // NMake - IntelliSense + propertyGroup1->appendProperty(QStringLiteral("NMakePreprocessorDefinitions"), + cppDefines.join(sep)); + propertyGroup1->appendProperty(QStringLiteral("NMakeIncludeSearchPath"), + includePaths.join(sep)); +} + +static QString subsystemVersion(const QString &version) +{ + const auto v = Version::fromString(version); + return QStringLiteral("%1.%2").arg( + QString::number(v.majorVersion()), + QString::number(v.minorVersion()).rightJustified(2, QLatin1Char('0'))); +} + +void MSBuildQbsProductProject::addItemDefGroup(const Project &project, + const ProductData &productData) +{ + const auto &properties = productData.moduleProperties(); + + const bool consoleApp = productData.properties().value(QStringLiteral("consoleApplication")) + .toBool(); + const bool debugBuild = properties.getModuleProperty(StringConstants::qbsModule(), + QStringLiteral("debugInformation")) + .toBool(); + const auto optimizationLevel = properties.getModuleProperty(StringConstants::qbsModule(), + QStringLiteral("optimization")) + .toString(); + const auto warningLevel = properties.getModuleProperty(StringConstants::qbsModule(), + QStringLiteral("warningLevel")) + .toString(); + + const auto includePaths = QStringList() + << properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("includePaths")) + << properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("systemIncludePaths")); + const auto cppDefines = properties.getModulePropertiesAsStringList( + QStringLiteral("cpp"), QStringLiteral("defines")); + + const auto sep = Internal::HostOsInfo::pathListSeparator(Internal::HostOsInfo::HostOsWindows); + + const auto itemDefGroup = new MSBuildItemDefinitionGroup(this); + itemDefGroup->setCondition(MSBuildUtils::buildTaskCondition(project)); + + const auto compile = new MSBuildClCompile(itemDefGroup); + + // C++ - General + compile->appendProperty(QStringLiteral("AdditionalIncludeDirectories"), + includePaths.join(sep) + + sep + + QStringLiteral("%(AdditionalIncludeDirectories)")); + if (warningLevel == QStringLiteral("none")) + compile->appendProperty(QStringLiteral("WarningLevel"), + QStringLiteral("TurnOffAllWarnings")); + else if (warningLevel == QStringLiteral("all")) + compile->appendProperty(QStringLiteral("WarningLevel"), + QStringLiteral("EnableAllWarnings")); + else + compile->appendProperty(QStringLiteral("WarningLevel"), + QStringLiteral("Level3")); // this is VS default. + + // C++ - Optimization + compile->appendProperty(QStringLiteral("Optimization"), + optimizationLevel == QStringLiteral("none") + ? QStringLiteral("Disabled") + : QStringLiteral("MaxSpeed")); + + // C++ - Preprocessor + compile->appendProperty(QStringLiteral("PreprocessorDefinitions"), + cppDefines.join(sep) + + sep + + QStringLiteral("%(PreprocessorDefinitions)")); + + // C++ - Code Generation + compile->appendProperty(QStringLiteral("RuntimeLibrary"), debugBuild + ? QStringLiteral("MultiThreadedDebugDLL") + : QStringLiteral("MultiThreadedDLL")); + + const auto link = new MSBuildLink(itemDefGroup); + + // Linker - General + link->appendProperty(QStringLiteral("AdditionalLibraryDirectories"), + properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("libraryPaths")).join(sep)); + + // Linker - Input + link->appendProperty(QStringLiteral("AdditionalDependencies"), + properties.getModulePropertiesAsStringList(QStringLiteral("cpp"), + QStringLiteral("staticLibraries")).join(sep) + + sep + QStringLiteral("%(AdditionalDependencies)")); + + // Linker - Debugging + link->appendProperty(QStringLiteral("GenerateDebugInformation"), + debugBuild ? QStringLiteral("true") : QStringLiteral("false")); + + // Linker - System + link->appendProperty(QStringLiteral("SubSystem"), + consoleApp ? QStringLiteral("Console") : QStringLiteral("Windows")); + const auto subsysVersion = properties.getModuleProperty( + QStringLiteral("cpp"), QStringLiteral("minimumWindowsVersion")).toString(); + if (!subsysVersion.isEmpty()) + link->appendProperty(QStringLiteral("MinimumRequiredVersion"), + subsystemVersion(subsysVersion)); + + // Linker - Optimization + link->appendProperty(QStringLiteral("OptimizeReferences"), + debugBuild ? QStringLiteral("false") : QStringLiteral("true")); +} + +static MSBuildFileItem *fileItemForFileTags(const QList &fileTags, + IMSBuildItemGroup *parent = nullptr) +{ + if (fileTags.contains(QStringLiteral("hpp"))) + return new MSBuildClInclude(parent); + if (fileTags.contains(QStringLiteral("c")) || fileTags.contains(QStringLiteral("cpp"))) + return new MSBuildClCompile(parent); + return new MSBuildNone(parent); +} + +void MSBuildQbsProductProject::addFiles(const GeneratableProject &project, + const GeneratableProductData &product) +{ + const auto itemGroup = new MSBuildItemGroup(this); + + addQbsFile(project, product, itemGroup); + + std::map sourceFileNodes; + std::map sourceFileEnabledConfigurations; + + // Create a ClCompile item for each source file, keeping track of which configurations that + // file's containing group is enabled in + QMapIterator productDataIt(product.data); + while (productDataIt.hasNext()) { + productDataIt.next(); + const auto groups = productDataIt.value().groups(); + for (const auto &group : groups) { + const auto sourceArtifacts = group.allSourceArtifacts(); + for (const auto &sourceArtifact : sourceArtifacts) { + const auto filePath = sourceArtifact.filePath(); + if (sourceFileNodes.find(filePath) == sourceFileNodes.end()) { + sourceFileNodes.insert({ + filePath, + fileItemForFileTags(sourceArtifact.fileTags(), itemGroup) + }); + } + auto fileItem = sourceFileNodes[filePath]; + QString path = project.baseBuildDirectory().relativeFilePath(filePath); + // The path still might not be relative (for example if the file item is + // located on a different drive) + if (QFileInfo(path).isRelative()) + path = QStringLiteral("$(ProjectDir)") + path; + fileItem->setFilePath(path); + if (group.isEnabled()) + sourceFileEnabledConfigurations[filePath] << productDataIt.key(); + } + } + } + + // Add ExcludedFromBuild item metadata to each file for each configuration + // where that file's containing group is disabled + for (const auto &sourceFileNode : sourceFileNodes) { + QMapIterator projIt(project.projects); + while (projIt.hasNext()) { + projIt.next(); + if (!sourceFileEnabledConfigurations[sourceFileNode.first].contains(projIt.key())) { + const auto metadata = new MSBuildItemMetadata( + QStringLiteral("ExcludedFromBuild"), + QStringLiteral("true"), + sourceFileNode.second); + metadata->setCondition(QStringLiteral("'$(Configuration)|$(Platform)'=='") + + MSBuildUtils::fullName(projIt.value()) + + QStringLiteral("'")); + } + } + } + + const auto import = new MSBuildImport(this); + import->setProject(QStringLiteral("$(VCTargetsPath)\\Microsoft.Cpp.targets")); +} + +void MSBuildQbsProductProject::addQbsFile(const GeneratableProject &project, + const GeneratableProductData &product, + MSBuildItemGroup *itemGroup) +{ + const auto fileItem = new MSBuildNone(itemGroup); + QString path = project.baseBuildDirectory().relativeFilePath(product.location().filePath()); + // The path still might not be relative (for example if the file item is + // located on a different drive) + if (QFileInfo(path).isRelative()) + path = QStringLiteral("$(ProjectDir)") + path; + fileItem->setFilePath(path); +} + + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildqbsproductproject.h b/src/plugins/generator/visualstudio/msbuildqbsproductproject.h new file mode 100644 index 00000000..f1a815f3 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildqbsproductproject.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDQBSPRODUCTPROJECT_H +#define MSBUILDQBSPRODUCTPROJECT_H + +#include "msbuildtargetproject.h" + +#include +#include + +#include + +namespace qbs { + +class MSBuildImportGroup; +class MSBuildItemGroup; +class MSBuildProperty; + +class VisualStudioGenerator; + +class MSBuildQbsProductProject : public MSBuildTargetProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildQbsProductProject) +public: + MSBuildQbsProductProject(const GeneratableProject &project, + const GeneratableProductData &product, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent = nullptr); + +private: + using ProjectConfigurations = QHash>; + + void addConfiguration(const GeneratableProject &project, const Project &buildTask, + const ProductData &productData, + const QStringList &buildConfigurationCommandLine); + void addItemDefGroup(const Project &project, + const ProductData &productData); + void addFiles(const GeneratableProject &project, const GeneratableProductData &product); + void addQbsFile(const GeneratableProject &project, const GeneratableProductData &product, + MSBuildItemGroup *itemGroup); +}; + +} // namespace qbs + +#endif // MSBUILDQBSPRODUCTPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.cpp b/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.cpp new file mode 100644 index 00000000..878ebbcd --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.cpp @@ -0,0 +1,151 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildsharedsolutionpropertiesproject.h" + +#include "msbuild/msbuildpropertygroup.h" + +#include +#include + +#include + +namespace qbs { + +static QString qbsCommandLine(const GeneratableProject &project, + const QString &subCommand, + const QString &qbsSettingsDir, + const Internal::VisualStudioVersionInfo &versionInfo) +{ + auto addEnvironmentVariableArgument = [](Internal::CommandLine &cl, const QString &var, + const QString &prefix = QString()) { + cl.appendRawArgument(QStringLiteral("\"%1$(%2)\"").arg(prefix, var)); + }; + + auto realSubCommand = subCommand; + if (subCommand == QStringLiteral("rebuild")) + realSubCommand = QStringLiteral("build"); + + // "path/to/qbs.exe" {build|clean} + // --settings-dir "path/to/settings/directory/" + // -f "path/to/project.qbs" -d "/build/directory/" + // -p product_name [[configuration key:value]...] + Internal::CommandLine commandLine; + commandLine.setProgram(QStringLiteral("\"$(QbsExecutablePath)\""), true); + commandLine.appendArgument(realSubCommand); + + if (!qbsSettingsDir.isEmpty()) { + commandLine.appendArgument(QStringLiteral("--settings-dir")); + addEnvironmentVariableArgument(commandLine, QStringLiteral("QbsSettingsDir")); + } + + commandLine.appendArgument(QStringLiteral("-f")); + addEnvironmentVariableArgument(commandLine, QStringLiteral("QbsProjectFile")); + commandLine.appendArgument(QStringLiteral("-d")); + addEnvironmentVariableArgument(commandLine, QStringLiteral("QbsBuildDir")); + + if (subCommand == QStringLiteral("generate")) { + commandLine.appendArgument(QStringLiteral("-g")); + commandLine.appendArgument(QStringLiteral("visualstudio%1") + .arg(versionInfo.marketingVersion())); + } else { + commandLine.appendArgument(QStringLiteral("-p")); + addEnvironmentVariableArgument(commandLine, QStringLiteral("QbsProductName")); + + commandLine.appendArgument(QStringLiteral("--wait-lock")); + } + + if (realSubCommand == QStringLiteral("build") + && !project.installOptions.installRoot().isEmpty()) { + commandLine.appendArgument(QStringLiteral("--install-root")); + addEnvironmentVariableArgument(commandLine, QStringLiteral("QbsInstallRoot")); + } + + if (realSubCommand == QStringLiteral("build") && subCommand == QStringLiteral("rebuild")) { + commandLine.appendArgument(QStringLiteral("--check-timestamps")); + commandLine.appendArgument(QStringLiteral("--force-probe-execution")); + } + + addEnvironmentVariableArgument(commandLine, QStringLiteral("Configuration"), + QStringLiteral("config:")); + + return commandLine.toCommandLine(Internal::HostOsInfo::HostOsWindows); +} + +MSBuildSharedSolutionPropertiesProject::MSBuildSharedSolutionPropertiesProject( + const Internal::VisualStudioVersionInfo &versionInfo, + const GeneratableProject &project, + const QFileInfo &qbsExecutable, + const QString &qbsSettingsDir) +{ + setDefaultTargets(QStringLiteral("Build")); + setToolsVersion(versionInfo.toolsVersion()); + + const auto group = new MSBuildPropertyGroup(this); + group->setLabel(QStringLiteral("UserMacros")); + + // Order's important here... a variable must be listed before one that uses it + group->appendProperty(QStringLiteral("QbsExecutablePath"), + QStringLiteral("$(QbsExecutableDir)") + qbsExecutable.fileName()); + if (!project.installOptions.installRoot().isEmpty()) { + group->appendProperty(QStringLiteral("QbsInstallRoot"), + Internal::PathUtils::toNativeSeparators( + project.installOptions.installRoot(), + Internal::HostOsInfo::HostOsWindows)); + } + + group->appendProperty(QStringLiteral("QbsProjectFile"), + QStringLiteral("$(QbsProjectDir)") + + project.filePath().fileName()); + + // Trailing '.' is not a typo. It prevents the trailing slash from combining with the closing + // quote to form an escape sequence. Unfortunately, Visual Studio expands variables *before* + // passing them to the underlying command shell, so there's not much we can do with regard to + // doing it "properly". Setting environment variables through MSBuild and using them in place + // of actual arguments does not work either, as Visual Studio apparently expands the environment + // variables as well, before passing them to the underlying shell. + group->appendProperty(QStringLiteral("QbsBuildDir"), + QStringLiteral("$(SolutionDir).")); + + group->appendProperty(QStringLiteral("QbsBuildCommandLine"), + qbsCommandLine(project, QStringLiteral("build"), + qbsSettingsDir, versionInfo)); + group->appendProperty(QStringLiteral("QbsReBuildCommandLine"), + qbsCommandLine(project, QStringLiteral("rebuild"), + qbsSettingsDir, versionInfo)); + group->appendProperty(QStringLiteral("QbsCleanCommandLine"), + qbsCommandLine(project, QStringLiteral("clean"), + qbsSettingsDir, versionInfo)); + group->appendProperty(QStringLiteral("QbsGenerateCommandLine"), + qbsCommandLine(project, QStringLiteral("generate"), + qbsSettingsDir, versionInfo)); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.h b/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.h new file mode 100644 index 00000000..f3848ce2 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildsharedsolutionpropertiesproject.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDSHAREDSOLUTIONPROPERTIESPROJECT_H +#define MSBUILDSHAREDSOLUTIONPROPERTIESPROJECT_H + +#include "msbuild/msbuildproject.h" + +#include +#include + +namespace qbs { + +class MSBuildSharedSolutionPropertiesProject : public MSBuildProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildSharedSolutionPropertiesProject) +public: + MSBuildSharedSolutionPropertiesProject(const Internal::VisualStudioVersionInfo &versionInfo, + const GeneratableProject &project, + const QFileInfo &qbsExecutable, const QString &qbsSettingsDir); +}; + +} // namespace qbs + +#endif // MSBUILDSHAREDSOLUTIONPROPERTIESPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.cpp b/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.cpp new file mode 100644 index 00000000..ea5546c7 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildsolutionpropertiesproject.h" + +#include "msbuild/msbuildpropertygroup.h" + +#include + +#include + +namespace qbs { + +MSBuildSolutionPropertiesProject::MSBuildSolutionPropertiesProject( + const Internal::VisualStudioVersionInfo &versionInfo, + const GeneratableProject &project, + const QFileInfo &qbsExecutable, + const QString &qbsSettingsDir) +{ + setDefaultTargets(QStringLiteral("Build")); + setToolsVersion(versionInfo.toolsVersion()); + + const auto group = new MSBuildPropertyGroup(this); + group->setLabel(QStringLiteral("UserMacros")); + + static const auto win = Internal::HostOsInfo::HostOsWindows; + + group->appendProperty(QStringLiteral("QbsExecutableDir"), + Internal::PathUtils::toNativeSeparators(qbsExecutable.path(), win) + + Internal::HostOsInfo::pathSeparator(win)); + group->appendProperty(QStringLiteral("QbsProjectDir"), + Internal::PathUtils::toNativeSeparators(project.filePath().path(), win) + + Internal::HostOsInfo::pathSeparator(win)); + + if (!qbsSettingsDir.isEmpty()) { + group->appendProperty(QStringLiteral("QbsSettingsDir"), + Internal::PathUtils::toNativeSeparators(qbsSettingsDir, win) + + Internal::HostOsInfo::pathSeparator(win) + QLatin1Char('.')); + } +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.h b/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.h new file mode 100644 index 00000000..1c49f790 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildsolutionpropertiesproject.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDSOLUTIONPROPERTIESPROJECT_H +#define MSBUILDSOLUTIONPROPERTIESPROJECT_H + +#include "msbuild/msbuildproject.h" + +#include +#include + +#include + +namespace qbs { + +class MSBuildSolutionPropertiesProject : public MSBuildProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildSolutionPropertiesProject) +public: + MSBuildSolutionPropertiesProject(const Internal::VisualStudioVersionInfo &versionInfo, + const GeneratableProject &project, + const QFileInfo &qbsExecutable, + const QString &qbsSettingsDir); +}; + +} // namespace qbs + +#endif // MSBUILDSOLUTIONPROPERTIESPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildtargetproject.cpp b/src/plugins/generator/visualstudio/msbuildtargetproject.cpp new file mode 100644 index 00000000..33ce9d9a --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildtargetproject.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildtargetproject.h" +#include "msbuildutils.h" +#include "visualstudiogenerator.h" + +#include "msbuild/msbuildimport.h" +#include "msbuild/msbuildimportgroup.h" +#include "msbuild/msbuilditem.h" +#include "msbuild/msbuilditemgroup.h" +#include "msbuild/msbuildproperty.h" +#include "msbuild/msbuildpropertygroup.h" + +namespace qbs { + +class MSBuildTargetProjectPrivate +{ +public: + MSBuildTargetProjectPrivate(const Internal::VisualStudioVersionInfo &versionInfo) + : versionInfo(versionInfo) {} + MSBuildPropertyGroup *globalsPropertyGroup = nullptr; + MSBuildProperty *projectGuidProperty = nullptr; + const Internal::VisualStudioVersionInfo &versionInfo; +}; + +MSBuildTargetProject::MSBuildTargetProject(const GeneratableProject &project, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent) + : MSBuildProject(parent) + , d(new MSBuildTargetProjectPrivate(versionInfo)) +{ + setDefaultTargets(QStringLiteral("Build")); + setToolsVersion(versionInfo.toolsVersion()); + + const auto projectConfigurationsGroup = new MSBuildItemGroup(this); + projectConfigurationsGroup->setLabel(QStringLiteral("ProjectConfigurations")); + + QMapIterator it(project.projects); + while (it.hasNext()) { + it.next(); + const auto item = new MSBuildItem(QStringLiteral("ProjectConfiguration"), + projectConfigurationsGroup); + item->setInclude(MSBuildUtils::fullName(it.value())); + item->appendProperty(QStringLiteral("Configuration"), it.key()); + item->appendProperty(QStringLiteral("Platform"), MSBuildUtils::platform(it.value())); + } + + d->globalsPropertyGroup = new MSBuildPropertyGroup(this); + d->globalsPropertyGroup->setLabel(QStringLiteral("Globals")); + d->projectGuidProperty = new MSBuildProperty(QStringLiteral("ProjectGuid"), + QUuid::createUuid().toString(), + d->globalsPropertyGroup); + + // Trigger creation of the property sheets ImportGroup + propertySheetsImportGroup(); +} + +MSBuildTargetProject::~MSBuildTargetProject() = default; + +const Internal::VisualStudioVersionInfo &MSBuildTargetProject::versionInfo() const +{ + return d->versionInfo; +} + +QUuid MSBuildTargetProject::guid() const +{ + return QUuid{d->projectGuidProperty->value().toString()}; +} + +void MSBuildTargetProject::setGuid(const QUuid &guid) +{ + d->projectGuidProperty->setValue(guid.toString()); +} + +MSBuildPropertyGroup *MSBuildTargetProject::globalsPropertyGroup() +{ + return d->globalsPropertyGroup; +} + +MSBuildImportGroup *MSBuildTargetProject::propertySheetsImportGroup() +{ + MSBuildImportGroup *importGroup = nullptr; + for (const auto &child : children()) { + if (auto group = qobject_cast(child)) { + if (group->label() == QStringLiteral("PropertySheets")) { + importGroup = group; + break; + } + } + } + + if (!importGroup) { + importGroup = new MSBuildImportGroup(this); + importGroup->setLabel(QStringLiteral("PropertySheets")); + } + + return importGroup; +} + +void MSBuildTargetProject::appendPropertySheet(const QString &path, bool optional) +{ + const auto import = new MSBuildImport(propertySheetsImportGroup()); + import->setProject(path); + if (optional) + import->setCondition(QStringLiteral("Exists('%1')").arg(path)); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/msbuildtargetproject.h b/src/plugins/generator/visualstudio/msbuildtargetproject.h new file mode 100644 index 00000000..496441a8 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildtargetproject.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDTARGETPROJECT_H +#define MSBUILDTARGETPROJECT_H + +#include "msbuild/msbuildproject.h" + +#include +#include + +namespace qbs { + +class MSBuildImportGroup; +class MSBuildPropertyGroup; +class MSBuildTargetProjectPrivate; +class VisualStudioGenerator; + +class MSBuildTargetProject : public MSBuildProject +{ + Q_OBJECT + Q_DISABLE_COPY(MSBuildTargetProject) +protected: + MSBuildTargetProject(const GeneratableProject &project, + const Internal::VisualStudioVersionInfo &versionInfo, + VisualStudioGenerator *parent = nullptr); + +public: + ~MSBuildTargetProject() override; + + const Internal::VisualStudioVersionInfo &versionInfo() const; + + QUuid guid() const; + void setGuid(const QUuid &guid); + + MSBuildPropertyGroup *globalsPropertyGroup(); + MSBuildImportGroup *propertySheetsImportGroup(); + void appendPropertySheet(const QString &path, bool optional = false); + +private: + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // MSBUILDTARGETPROJECT_H diff --git a/src/plugins/generator/visualstudio/msbuildutils.h b/src/plugins/generator/visualstudio/msbuildutils.h new file mode 100644 index 00000000..cf4c7eb0 --- /dev/null +++ b/src/plugins/generator/visualstudio/msbuildutils.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef MSBUILDUTILS_H +#define MSBUILDUTILS_H + +#include + +namespace qbs { + +class MSBuildUtils +{ +public: + static QString _qbsArchitecture(const qbs::Project &project) + { + return project.projectConfiguration() + .value(QStringLiteral("qbs")).toMap() + .value(QStringLiteral("architecture")).toString(); + } + + static const QString visualStudioArchitectureName(const QString &qbsArch, bool useDisplayName) + { + if (qbsArch == QStringLiteral("x86") && useDisplayName) + return qbsArch; + + // map of qbs architecture names to MSBuild architecture names + static const QMap map { + {QStringLiteral("x86"), QStringLiteral("Win32")}, + {QStringLiteral("x86_64"), QStringLiteral("x64")}, + {QStringLiteral("ia64"), QStringLiteral("Itanium")}, + {QStringLiteral("arm"), QStringLiteral("ARM")}, + {QStringLiteral("arm64"), QStringLiteral("ARM64")} + }; + return map[qbsArch]; + } + + static QString configurationName(const qbs::Project &project) + { + return project.projectConfiguration() + .value(QStringLiteral("qbs")).toMap() + .value(QStringLiteral("configurationName")).toString(); + } + + static QString displayPlatform(const qbs::Project &project) + { + const auto architecture = _qbsArchitecture(project); + auto displayPlatform = visualStudioArchitectureName(architecture, true); + if (displayPlatform.isEmpty()) + displayPlatform = architecture; + return displayPlatform; + } + + static QString platform(const qbs::Project &project) + { + const auto architecture = _qbsArchitecture(project); + auto platform = visualStudioArchitectureName(architecture, false); + if (platform.isEmpty()) { + qWarning() << "WARNING: Unsupported architecture \"" + << architecture << "\"; using \"Win32\" platform."; + platform = QStringLiteral("Win32"); + } + + return platform; + } + + static QString fullDisplayName(const qbs::Project &project) + { + return QStringLiteral("%1|%2").arg(configurationName(project), displayPlatform(project)); + } + + static QString fullName(const qbs::Project &project) + { + return QStringLiteral("%1|%2").arg(configurationName(project), platform(project)); + } + + static QString buildTaskCondition(const Project &buildTask) + { + return QStringLiteral("'$(Configuration)|$(Platform)'=='") + + MSBuildUtils::fullName(buildTask) + + QStringLiteral("'"); + } +}; + +} // namespace qbs + +#endif // MSBUILDUTILS_H diff --git a/src/plugins/generator/visualstudio/visualstudio.pri b/src/plugins/generator/visualstudio/visualstudio.pri new file mode 100644 index 00000000..13a48e85 --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudio.pri @@ -0,0 +1 @@ +qbsPluginTarget = visualstudiogenerator diff --git a/src/plugins/generator/visualstudio/visualstudio.pro b/src/plugins/generator/visualstudio/visualstudio.pro new file mode 100644 index 00000000..49aee0eb --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudio.pro @@ -0,0 +1,32 @@ +include(visualstudio.pri) +include(../../plugins.pri) +include(../../../shared/json/json.pri) +include(../../../lib/msbuild/use_msbuild.pri) +# Using the indirect usage of corelib via plugins.pri breaks linking on mingw +include(../../../lib/corelib/use_corelib.pri) + +INCLUDEPATH += ../../../lib/msbuild + +QT = core + +HEADERS += \ + $$PWD/msbuildfiltersproject.h \ + $$PWD/msbuildqbsgenerateproject.h \ + $$PWD/msbuildqbsproductproject.h \ + $$PWD/msbuildsharedsolutionpropertiesproject.h \ + $$PWD/msbuildsolutionpropertiesproject.h \ + $$PWD/msbuildtargetproject.h \ + $$PWD/msbuildutils.h \ + $$PWD/visualstudiogenerator.h \ + $$PWD/visualstudioguidpool.h + +SOURCES += \ + $$PWD/msbuildfiltersproject.cpp \ + $$PWD/msbuildqbsgenerateproject.cpp \ + $$PWD/msbuildqbsproductproject.cpp \ + $$PWD/msbuildsharedsolutionpropertiesproject.cpp \ + $$PWD/msbuildsolutionpropertiesproject.cpp \ + $$PWD/msbuildtargetproject.cpp \ + $$PWD/visualstudiogenerator.cpp \ + $$PWD/visualstudiogeneratorplugin.cpp \ + $$PWD/visualstudioguidpool.cpp diff --git a/src/plugins/generator/visualstudio/visualstudio.qbs b/src/plugins/generator/visualstudio/visualstudio.qbs new file mode 100644 index 00000000..718c8523 --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudio.qbs @@ -0,0 +1,33 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + Depends { name: "qbsjson" } + Depends { name: "qbsmsbuild" } + + name: "visualstudiogenerator" + + files: ["visualstudiogeneratorplugin.cpp"] + + Group { + name: "Visual Studio generator" + files: [ + "msbuildfiltersproject.cpp", + "msbuildfiltersproject.h", + "msbuildqbsgenerateproject.cpp", + "msbuildqbsgenerateproject.h", + "msbuildqbsproductproject.cpp", + "msbuildqbsproductproject.h", + "msbuildsharedsolutionpropertiesproject.cpp", + "msbuildsharedsolutionpropertiesproject.h", + "msbuildsolutionpropertiesproject.cpp", + "msbuildsolutionpropertiesproject.h", + "msbuildtargetproject.cpp", + "msbuildtargetproject.h", + "msbuildutils.h", + "visualstudiogenerator.cpp", + "visualstudiogenerator.h", + "visualstudioguidpool.cpp", + "visualstudioguidpool.h", + ] + } +} diff --git a/src/plugins/generator/visualstudio/visualstudiogenerator.cpp b/src/plugins/generator/visualstudio/visualstudiogenerator.cpp new file mode 100644 index 00000000..d0c367dd --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudiogenerator.cpp @@ -0,0 +1,365 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "msbuildfiltersproject.h" +#include "msbuildqbsgenerateproject.h" +#include "msbuildsharedsolutionpropertiesproject.h" +#include "msbuildsolutionpropertiesproject.h" +#include "msbuildqbsproductproject.h" +#include "msbuildutils.h" +#include "visualstudiogenerator.h" +#include "visualstudioguidpool.h" + +#include "msbuild/msbuildpropertygroup.h" +#include "msbuild/msbuildproject.h" + +#include "solution/visualstudiosolution.h" +#include "solution/visualstudiosolutionfileproject.h" +#include "solution/visualstudiosolutionglobalsection.h" +#include "solution/visualstudiosolutionfolderproject.h" + +#include "io/msbuildprojectwriter.h" +#include "io/visualstudiosolutionwriter.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace qbs { + +using namespace Internal; + +class VisualStudioGeneratorPrivate +{ + friend class SolutionDependenciesVisitor; +public: + VisualStudioGeneratorPrivate(const Internal::VisualStudioVersionInfo &versionInfo) + : versionInfo(versionInfo) {} + + Internal::VisualStudioVersionInfo versionInfo; + + std::shared_ptr guidPool; + std::shared_ptr solution; + QString solutionFilePath; + QMap> msbuildProjects; + QMap solutionProjects; + QMap solutionFolders; + QList> propertySheetNames; + + void reset(); +}; + +void VisualStudioGeneratorPrivate::reset() +{ + guidPool.reset(); + solution.reset(); + solutionFilePath.clear(); + msbuildProjects.clear(); + solutionProjects.clear(); + solutionFolders.clear(); + propertySheetNames.clear(); +} + +class SolutionDependenciesVisitor : public IGeneratableProjectVisitor +{ +public: + SolutionDependenciesVisitor(VisualStudioGenerator *generator) + : generator(generator) { + } + + void visitProject(const GeneratableProject &project) override { + Q_UNUSED(project); + nestedProjects = new VisualStudioSolutionGlobalSection( + QStringLiteral("NestedProjects"), generator->d->solution.get()); + generator->d->solution->appendGlobalSection(nestedProjects); + } + + void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &parentProjectData, + const GeneratableProjectData &projectData) override { + Q_UNUSED(project); + // The root project will have a null GeneratableProjectData + // as its parent object (so skip giving it a parent folder) + if (!parentProjectData.name().isEmpty()) { + nestedProjects->appendProperty( + generator->d->solutionFolders.value(projectData.uniqueName())->guid() + .toString(), + generator->d->solutionFolders.value(parentProjectData.uniqueName())->guid() + .toString()); + } + } + + void visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) override { + Q_UNUSED(project); + Q_UNUSED(projectData); + const auto dependencies = productData.dependencies(); + for (const auto &dep : dependencies) { + generator->d->solution->addDependency( + generator->d->solutionProjects.value(productData.name()), + generator->d->solutionProjects.value(dep)); + } + + nestedProjects->appendProperty( + generator->d->solutionProjects.value(productData.name())->guid().toString(), + generator->d->solutionFolders.value(projectData.uniqueName())->guid() + .toString()); + } + +private: + VisualStudioGenerator *generator = nullptr; + VisualStudioSolutionGlobalSection *nestedProjects = nullptr; +}; + +VisualStudioGenerator::VisualStudioGenerator(const VisualStudioVersionInfo &versionInfo) + : d(new VisualStudioGeneratorPrivate(versionInfo)) +{ + if (d->versionInfo.usesVcBuild()) + throw ErrorInfo(Tr::tr("VCBuild (Visual Studio 2008 and below) is not supported")); + if (!d->versionInfo.usesMsBuild()) + throw ErrorInfo(Tr::tr("Unknown/unsupported build engine")); + Q_ASSERT(d->versionInfo.usesSolutions()); +} + +VisualStudioGenerator::~VisualStudioGenerator() = default; + +QString VisualStudioGenerator::generatorName() const +{ + return QStringLiteral("visualstudio%1").arg(d->versionInfo.marketingVersion()); +} + +void VisualStudioGenerator::addPropertySheets(const GeneratableProject &project) +{ + { + const auto fileName = QStringLiteral("qbs.props"); + d->propertySheetNames.push_back({ fileName, true }); + d->msbuildProjects.insert(project.baseBuildDirectory().absoluteFilePath(fileName), + std::make_shared( + d->versionInfo, project, + qbsExecutableFilePath(), qbsSettingsDir())); + } + + { + const auto fileName = QStringLiteral("qbs-shared.props"); + d->propertySheetNames.push_back({ fileName, false }); + d->msbuildProjects.insert(project.baseBuildDirectory().absoluteFilePath(fileName), + std::make_shared( + d->versionInfo, project, + qbsExecutableFilePath(), qbsSettingsDir())); + } +} + +void VisualStudioGenerator::addPropertySheets( + const std::shared_ptr &targetProject) +{ + for (const auto &pair : qAsConst(d->propertySheetNames)) { + targetProject->appendPropertySheet( + QStringLiteral("$(SolutionDir)\\") + pair.first, pair.second); + } +} + +static QString targetFilePath(const QString &baseName, const QString &baseBuildDirectory) +{ + return QDir(baseBuildDirectory).absoluteFilePath(baseName + QStringLiteral(".vcxproj")); +} + +static QString targetFilePath(const GeneratableProductData &product, + const QString &baseBuildDirectory) +{ + return targetFilePath(product.name(), baseBuildDirectory); +} + +static void addDefaultGlobalSections(const GeneratableProject &topLevelProject, + VisualStudioSolution *solution) +{ + const auto configurationPlatformsSection = new VisualStudioSolutionGlobalSection( + QStringLiteral("SolutionConfigurationPlatforms"), solution); + solution->appendGlobalSection(configurationPlatformsSection); + for (const auto &qbsProject : topLevelProject.projects) + configurationPlatformsSection->appendProperty(MSBuildUtils::fullName(qbsProject), + MSBuildUtils::fullName(qbsProject)); + + const auto projectConfigurationPlatformsSection = new VisualStudioSolutionGlobalSection( + QStringLiteral("ProjectConfigurationPlatforms"), solution); + solution->appendGlobalSection(projectConfigurationPlatformsSection); + projectConfigurationPlatformsSection->setPost(true); + const auto projects = solution->fileProjects(); + for (const auto project : projects) { + for (const auto &qbsProject : topLevelProject.projects) { + projectConfigurationPlatformsSection->appendProperty( + QStringLiteral("%1.%2.ActiveCfg").arg(project->guid().toString(), + MSBuildUtils::fullDisplayName(qbsProject)), + MSBuildUtils::fullName(qbsProject)); + projectConfigurationPlatformsSection->appendProperty( + QStringLiteral("%1.%2.Build.0").arg(project->guid().toString(), + MSBuildUtils::fullDisplayName(qbsProject)), + MSBuildUtils::fullName(qbsProject)); + } + } + + const auto solutionPropsSection = new VisualStudioSolutionGlobalSection( + QStringLiteral("SolutionProperties"), solution); + solution->appendGlobalSection(solutionPropsSection); + solutionPropsSection->appendProperty(QStringLiteral("HideSolutionNode"), + QStringLiteral("FALSE")); +} + +static void writeProjectFiles(const QMap> &projects) +{ + // Write out all the MSBuild project files to disk + QMapIterator> it(projects); + while (it.hasNext()) { + it.next(); + const auto projectFilePath = it.key(); + Internal::FileSaver file(projectFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Tr::tr("Cannot open %s for writing").arg(projectFilePath)); + + std::shared_ptr project = it.value(); + MSBuildProjectWriter writer(file.device()); + if (!(writer.write(project.get()) && file.commit())) + throw ErrorInfo(Tr::tr("Failed to generate %1").arg(projectFilePath)); + } +} + +static void writeSolution(const std::shared_ptr &solution, + const QString &solutionFilePath, + const Internal::Logger &logger) +{ + Internal::FileSaver file(solutionFilePath.toStdString()); + if (!file.open()) + throw ErrorInfo(Tr::tr("Cannot open %s for writing").arg(solutionFilePath)); + + VisualStudioSolutionWriter writer(file.device()); + writer.setProjectBaseDirectory(QFileInfo(solutionFilePath).path().toStdString()); + if (!(writer.write(solution.get()) && file.commit())) + throw ErrorInfo(Tr::tr("Failed to generate %1").arg(solutionFilePath)); + + logger.qbsInfo() << Tr::tr("Generated %1").arg(QFileInfo(solutionFilePath).fileName()); +} + +void VisualStudioGenerator::generate() +{ + GeneratableProjectIterator it(project()); + it.accept(this); + + addDefaultGlobalSections(project(), d->solution.get()); + + // Second pass: connection solution project interdependencies and project nesting hierarchy + SolutionDependenciesVisitor solutionDependenciesVisitor(this); + it.accept(&solutionDependenciesVisitor); + + writeProjectFiles(d->msbuildProjects); + writeSolution(d->solution, d->solutionFilePath, logger()); + + d->reset(); +} + +void VisualStudioGenerator::visitProject(const GeneratableProject &project) +{ + addPropertySheets(project); + + const auto buildDir = project.baseBuildDirectory(); + + d->guidPool = std::make_shared( + buildDir.absoluteFilePath(project.name() + + QStringLiteral(".guid.txt")).toStdString()); + + d->solutionFilePath = buildDir.absoluteFilePath(project.name() + QStringLiteral(".sln")); + d->solution = std::make_shared(d->versionInfo); + + // Create a helper project to re-run qbs generate + const auto qbsGenerate = QStringLiteral("qbs-generate"); + const auto projectFilePath = targetFilePath(qbsGenerate, buildDir.absolutePath()); + const auto relativeProjectFilePath = QFileInfo(d->solutionFilePath).dir() + .relativeFilePath(projectFilePath); + auto targetProject = std::make_shared(project, d->versionInfo); + targetProject->setGuid(d->guidPool->drawProductGuid(relativeProjectFilePath.toStdString())); + d->msbuildProjects.insert(projectFilePath, targetProject); + + addPropertySheets(targetProject); + + const auto solutionProject = new VisualStudioSolutionFileProject( + targetFilePath(qbsGenerate, project.baseBuildDirectory().absolutePath()), + d->solution.get()); + solutionProject->setGuid(targetProject->guid()); + d->solution->appendProject(solutionProject); + d->solutionProjects.insert(qbsGenerate, solutionProject); +} + +void VisualStudioGenerator::visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) +{ + Q_UNUSED(project); + const auto solutionFolder = new VisualStudioSolutionFolderProject(d->solution.get()); + solutionFolder->setName(projectData.name()); + d->solution->appendProject(solutionFolder); + QBS_CHECK(!d->solutionFolders.contains(projectData.uniqueName())); + d->solutionFolders.insert(projectData.uniqueName(), solutionFolder); +} + +void VisualStudioGenerator::visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) +{ + Q_UNUSED(projectData); + const auto projectFilePath = targetFilePath(productData, + project.baseBuildDirectory().absolutePath()); + const auto relativeProjectFilePath = QFileInfo(d->solutionFilePath) + .dir().relativeFilePath(projectFilePath); + auto targetProject = std::make_shared(project, productData, + d->versionInfo); + targetProject->setGuid(d->guidPool->drawProductGuid(relativeProjectFilePath.toStdString())); + + addPropertySheets(targetProject); + + d->msbuildProjects.insert(projectFilePath, targetProject); + d->msbuildProjects.insert(projectFilePath + QStringLiteral(".filters"), + std::make_shared(productData)); + + const auto solutionProject = new VisualStudioSolutionFileProject( + targetFilePath(productData, project.baseBuildDirectory().absolutePath()), + d->solution.get()); + solutionProject->setGuid(targetProject->guid()); + d->solution->appendProject(solutionProject); + d->solutionProjects.insert(productData.name(), solutionProject); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/visualstudiogenerator.h b/src/plugins/generator/visualstudio/visualstudiogenerator.h new file mode 100644 index 00000000..e104ca42 --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudiogenerator.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_VISUALSTUDIOGENERATOR_H +#define QBS_VISUALSTUDIOGENERATOR_H + +#include +#include +#include +#include "visualstudioguidpool.h" + +#include +#include +#include + +namespace qbs { + +namespace Internal { class VisualStudioVersionInfo; } + +class MSBuildProject; +class MSBuildTargetProject; + +class VisualStudioGeneratorPrivate; +class VisualStudioSolution; +class VisualStudioSolutionFileProject; +class VisualStudioSolutionFolderProject; + +class VisualStudioGenerator : public ProjectGenerator, private IGeneratableProjectVisitor +{ + friend class SolutionDependenciesVisitor; +public: + explicit VisualStudioGenerator(const Internal::VisualStudioVersionInfo &versionInfo); + ~VisualStudioGenerator() override; + QString generatorName() const override; + void generate() override; + +private: + void visitProject(const GeneratableProject &project) override; + void visitProjectData(const GeneratableProject &project, + const GeneratableProjectData &projectData) override; + void visitProduct(const GeneratableProject &project, + const GeneratableProjectData &projectData, + const GeneratableProductData &productData) override; + + void addPropertySheets(const GeneratableProject &project); + void addPropertySheets(const std::shared_ptr &targetProject); + + std::unique_ptr d; +}; + +} // namespace qbs + +#endif // QBS_VISUALSTUDIOGENERATOR_H diff --git a/src/plugins/generator/visualstudio/visualstudiogeneratorplugin.cpp b/src/plugins/generator/visualstudio/visualstudiogeneratorplugin.cpp new file mode 100644 index 00000000..ef4e39fc --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudiogeneratorplugin.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "visualstudiogenerator.h" + +#include +#include + +static void QbsVisualStudioGeneratorPluginLoad() +{ + for (const auto &info : qbs::Internal::VisualStudioVersionInfo::knownVersions()) { + if (info.usesMsBuild()) + qbs::ProjectGeneratorManager::registerGenerator( + std::make_shared(info)); + } +} + +static void QbsVisualStudioGeneratorPluginUnload() +{ +} + +#ifndef GENERATOR_EXPORT +#if defined(WIN32) || defined(_WIN32) +#define GENERATOR_EXPORT __declspec(dllexport) +#else +#define GENERATOR_EXPORT __attribute__((visibility("default"))) +#endif +#endif + +QBS_REGISTER_STATIC_PLUGIN(extern "C" GENERATOR_EXPORT, visualstudiogenerator, + QbsVisualStudioGeneratorPluginLoad, QbsVisualStudioGeneratorPluginUnload) diff --git a/src/plugins/generator/visualstudio/visualstudioguidpool.cpp b/src/plugins/generator/visualstudio/visualstudioguidpool.cpp new file mode 100644 index 00000000..d770a448 --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudioguidpool.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "visualstudioguidpool.h" +#include +#include +#include + +#include +#include +#include + +#include + +using namespace Json; + +namespace qbs { + +class VisualStudioGuidPoolPrivate +{ +public: + std::string storeFilePath; + std::map productGuids; +}; + +VisualStudioGuidPool::VisualStudioGuidPool(const std::string &storeFilePath) + : d(std::make_shared()) +{ + // Read any existing GUIDs from the on-disk store + std::ifstream file(Internal::utf8_to_native_path(d->storeFilePath = storeFilePath)); + if (file.is_open()) { + const auto data = JsonDocument::fromJson(std::string { + std::istreambuf_iterator(file), + std::istreambuf_iterator() + }).object(); + for (auto it = data.constBegin(), end = data.constEnd(); it != end; ++it) { + d->productGuids.insert({ + it.key(), + QUuid(QString::fromStdString(it.value().toString())) + }); + } + } +} + +VisualStudioGuidPool::~VisualStudioGuidPool() +{ + Internal::FileSaver file(d->storeFilePath); + if (file.open()) { + JsonObject productData; + for (const auto &it : d->productGuids) + productData.insert(it.first, it.second.toString().toStdString()); + + const auto data = JsonDocument(productData).toJson(); + file.write({data.data(), data.size()}); + file.commit(); + } +} + +QUuid VisualStudioGuidPool::drawProductGuid(const std::string &productName) +{ + if (d->productGuids.find(productName) == d->productGuids.cend()) + d->productGuids.insert({ productName, QUuid::createUuid() }); + return d->productGuids.at(productName); +} + +} // namespace qbs diff --git a/src/plugins/generator/visualstudio/visualstudioguidpool.h b/src/plugins/generator/visualstudio/visualstudioguidpool.h new file mode 100644 index 00000000..dd6dc9eb --- /dev/null +++ b/src/plugins/generator/visualstudio/visualstudioguidpool.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qbs. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef VISUALSTUDIOGUIDPOOL_H +#define VISUALSTUDIOGUIDPOOL_H + +#include + +#include + +namespace qbs { + +class VisualStudioGuidPoolPrivate; + +/*! + * Provides persistent storage for GUIDs related to Visual Studio project file nodes. + * These are stored on disk separately from project files and so allow projects to be + * regenerated while retaining the same GUIDs. This helps avoid unnecessary project + * reloads in Visual Studio, and helps ease source control usage. + */ +class VisualStudioGuidPool +{ +public: + explicit VisualStudioGuidPool(const std::string &storeFilePath); + ~VisualStudioGuidPool(); + + QUuid drawProductGuid(const std::string &productName); + +private: + std::shared_ptr d; +}; + +} // namespace qbs + +#endif // VISUALSTUDIOGUIDPOOL_H diff --git a/src/plugins/plugins.pri b/src/plugins/plugins.pri new file mode 100644 index 00000000..65de9bc1 --- /dev/null +++ b/src/plugins/plugins.pri @@ -0,0 +1,21 @@ +include(qbs_plugin_common.pri) + +TARGET = $$qbsPluginTarget +DESTDIR = $$qbsPluginDestDir + +isEmpty(QBSLIBDIR): QBSLIBDIR = $$OUT_PWD/../../../../$${QBS_LIBRARY_DIRNAME} +isEmpty(QBS_RPATH): QBS_RPATH = ../.. +include($${PWD}/../lib/corelib/use_corelib.pri) + +TEMPLATE = lib + +CONFIG += c++17 +CONFIG(static, static|shared): CONFIG += create_prl +CONFIG += plugin + +!isEmpty(QBS_PLUGINS_INSTALL_DIR): \ + installPrefix = $${QBS_PLUGINS_INSTALL_DIR} +else: \ + installPrefix = $${QBS_INSTALL_PREFIX}/$${QBS_LIBRARY_DIRNAME} +target.path = $${installPrefix}/qbs/plugins +INSTALLS += target diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro new file mode 100644 index 00000000..9fe2e6b5 --- /dev/null +++ b/src/plugins/plugins.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = generator scanner diff --git a/src/plugins/plugins.qbs b/src/plugins/plugins.qbs new file mode 100644 index 00000000..55fafe90 --- /dev/null +++ b/src/plugins/plugins.qbs @@ -0,0 +1,12 @@ +Project { + name: "qbs plugins" + references: [ + "generator/clangcompilationdb/clangcompilationdb.qbs", + "generator/makefilegenerator/makefilegenerator.qbs", + "generator/visualstudio/visualstudio.qbs", + "generator/iarew/iarew.qbs", + "generator/keiluv/keiluv.qbs", + "scanner/cpp/cpp.qbs", + "scanner/qt/qt.qbs" + ] +} diff --git a/src/plugins/qbs_plugin_common.pri b/src/plugins/qbs_plugin_common.pri new file mode 100644 index 00000000..45ade498 --- /dev/null +++ b/src/plugins/qbs_plugin_common.pri @@ -0,0 +1,9 @@ +include(../library_dirname.pri) +include(../install_prefix.pri) + +!isEmpty(QBS_PLUGINS_BUILD_DIR) { + destdirPrefix = $${QBS_PLUGINS_BUILD_DIR} +} else { + destdirPrefix = $$shadowed($$PWD)/../../$${QBS_LIBRARY_DIRNAME} +} +qbsPluginDestDir = $${destdirPrefix}/qbs/plugins diff --git a/src/plugins/qbsplugin.qbs b/src/plugins/qbsplugin.qbs new file mode 100644 index 00000000..b4721198 --- /dev/null +++ b/src/plugins/qbsplugin.qbs @@ -0,0 +1,48 @@ +import qbs.FileInfo + +QbsProduct { + property bool isForDarwin: qbs.targetOS.contains("darwin") + property bool staticBuild: Qt.core.staticBuild || qbsbuildconfig.staticBuild + Depends { name: "cpp" } + Depends { name: "bundle"; condition: isForDarwin } + Depends { name: "Qt.core" } + Depends { name: "qbsbuildconfig" } + Depends { name: "qbscore"; condition: !staticBuild } + type: (staticBuild ? ["staticlibrary"] : [isForDarwin ? "loadablemodule" : "dynamiclibrary"]) + .concat(["qbsplugin"]) + Properties { + condition: staticBuild + cpp.defines: ["QBS_STATIC_LIB"] + } + cpp.includePaths: base.concat(["../../../lib/corelib"]) + cpp.visibility: "minimal" + Group { + fileTagsFilter: [isForDarwin ? "loadablemodule" : "dynamiclibrary"] + .concat(qbs.buildVariant === "debug" + ? [isForDarwin ? "debuginfo_loadablemodule" : "debuginfo_dll"] : []) + qbs.install: true + qbs.installDir: targetInstallDir + qbs.installSourceBase: buildDirectory + } + targetInstallDir: qbsbuildconfig.pluginsInstallDir + Properties { + condition: isForDarwin + bundle.isBundle: false + } + + Export { + Depends { name: "cpp" } + Properties { + condition: qbs.targetOS.contains("darwin") + cpp.linkerFlags: ["-u", "_qbs_static_plugin_register_" + name] + } + Properties { + condition: qbs.toolchain.contains("gcc") + cpp.linkerFlags: "--require-defined=qbs_static_plugin_register_" + name + } + Properties { + condition: qbs.toolchain.contains("msvc") + cpp.linkerFlags: "/INCLUDE:qbs_static_plugin_register_" + name + } + } +} diff --git a/src/plugins/scanner/CMakeLists.txt b/src/plugins/scanner/CMakeLists.txt new file mode 100644 index 00000000..e4cbfb9e --- /dev/null +++ b/src/plugins/scanner/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(cpp) +add_subdirectory(qt) diff --git a/src/plugins/scanner/cpp/CMakeLists.txt b/src/plugins/scanner/cpp/CMakeLists.txt new file mode 100644 index 00000000..a05b70a2 --- /dev/null +++ b/src/plugins/scanner/cpp/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SOURCES + ../scanner.h + CPlusPlusForwardDeclarations.h + Lexer.cpp + Lexer.h + Token.cpp + Token.h + cpp_global.h + cppscanner.cpp + ) + +add_qbs_plugin(qbs_cpp_scanner + DEFINES "CPLUSPLUS_NO_PARSER" + DEPENDS qbscore + SOURCES ${SOURCES} + ) diff --git a/src/plugins/scanner/cpp/CPlusPlusForwardDeclarations.h b/src/plugins/scanner/cpp/CPlusPlusForwardDeclarations.h new file mode 100644 index 00000000..d0d7f663 --- /dev/null +++ b/src/plugins/scanner/cpp/CPlusPlusForwardDeclarations.h @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H +#define CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H + +#include +#include + +#ifndef CPLUSPLUS_WITHOUT_QT +# include + +//# if defined(CPLUSPLUS_BUILD_LIB) +//# define CPLUSPLUS_EXPORT Q_DECL_EXPORT +//# elif defined(CPLUSPLUS_BUILD_STATIC_LIB) +//# define CPLUSPLUS_EXPORT +//# else +//# define CPLUSPLUS_EXPORT Q_DECL_IMPORT +//# endif +//#else +# define CPLUSPLUS_EXPORT +#endif + +namespace CPlusPlus { + +class TranslationUnit; +class Control; +class MemoryPool; +class DiagnosticClient; + +class Identifier; +class Literal; +class StringLiteral; +class NumericLiteral; + +class SymbolTable; + +// names +class NameVisitor; +class Name; +class Identifier; +class TemplateNameId; +class DestructorNameId; +class OperatorNameId; +class ConversionNameId; +class QualifiedNameId; +class SelectorNameId; + +// types +class TypeMatcher; +class FullySpecifiedType; +class TypeVisitor; +class Type; +class UndefinedType; +class VoidType; +class IntegerType; +class FloatType; +class PointerToMemberType; +class PointerType; +class ReferenceType; +class ArrayType; +class NamedType; + +// symbols +class SymbolVisitor; +class Symbol; +class Scope; +class UsingNamespaceDirective; +class UsingDeclaration; +class Declaration; +class Argument; +class TypenameArgument; +class Function; +class Namespace; +class NamespaceAlias; +class Template; +class BaseClass; +class Block; +class Class; +class Enum; +class ForwardClassDeclaration; + +class Token; + +// Objective-C symbols +class ObjCBaseClass; +class ObjCBaseProtocol; +class ObjCClass; +class ObjCForwardClassDeclaration; +class ObjCProtocol; +class ObjCForwardProtocolDeclaration; +class ObjCMethod; +class ObjCPropertyDeclaration; + +} // end of namespace CPlusPlus + +#endif // CPLUSPLUS_CPLUSPLUSFORWARDDECLARATIONS_H diff --git a/src/plugins/scanner/cpp/Lexer.cpp b/src/plugins/scanner/cpp/Lexer.cpp new file mode 100644 index 00000000..6bad85c5 --- /dev/null +++ b/src/plugins/scanner/cpp/Lexer.cpp @@ -0,0 +1,670 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "Lexer.h" +#include + +namespace CPlusPlus { + +Lexer::Lexer(const char *firstChar, const char *lastChar) + : _state(State_Default), + _currentLine(1) +{ + setSource(firstChar, lastChar); +} + +Lexer::~Lexer() = default; + +void Lexer::setSource(const char *firstChar, const char *lastChar) +{ + _firstChar = firstChar; + _lastChar = lastChar; + _currentChar = _firstChar - 1; + _tokenStart = _currentChar; + _yychar = '\n'; +} + +void Lexer::setStartWithNewline(bool enabled) +{ + if (enabled) + _yychar = '\n'; + else + _yychar = ' '; +} + +int Lexer::state() const +{ return _state; } + +void Lexer::setState(int state) +{ _state = state; } + +bool Lexer::qtMocRunEnabled() const +{ return f._qtMocRunEnabled; } + +void Lexer::setQtMocRunEnabled(bool onoff) +{ f._qtMocRunEnabled = onoff; } + +bool Lexer::cxx0xEnabled() const +{ return f._cxx0xEnabled; } + +void Lexer::setCxxOxEnabled(bool onoff) +{ f._cxx0xEnabled = onoff; } + +bool Lexer::objCEnabled() const +{ return f._objCEnabled; } + +void Lexer::setObjCEnabled(bool onoff) +{ f._objCEnabled = onoff; } + +bool Lexer::isIncremental() const +{ return f._isIncremental; } + +void Lexer::setIncremental(bool isIncremental) +{ f._isIncremental = isIncremental; } + +bool Lexer::scanCommentTokens() const +{ return f._scanCommentTokens; } + +void Lexer::setScanCommentTokens(bool onoff) +{ f._scanCommentTokens = onoff; } + +void Lexer::setScanAngleStringLiteralTokens(bool onoff) +{ f._scanAngleStringLiteralTokens = onoff; } + +void Lexer::pushLineStartOffset() +{ + ++_currentLine; +} + +unsigned Lexer::tokenOffset() const +{ return _tokenStart - _firstChar; } + +unsigned Lexer::tokenLength() const +{ return _currentChar - _tokenStart; } + +const char *Lexer::tokenBegin() const +{ return _tokenStart; } + +const char *Lexer::tokenEnd() const +{ return _currentChar; } + +unsigned Lexer::currentLine() const +{ return _currentLine; } + +void Lexer::scan(Token *tok) +{ + tok->reset(); + scan_helper(tok); + tok->f.length = _currentChar - _tokenStart; +} + +void Lexer::scan_helper(Token *tok) +{ + _Lagain: + while (_yychar && std::isspace(_yychar)) { + if (_yychar == '\n') { + tok->f.joined = false; + tok->f.newline = true; + } else { + tok->f.whitespace = true; + } + yyinp(); + } + + tok->lineno = _currentLine; + _tokenStart = _currentChar; + tok->offset = _currentChar - _firstChar; + + if (_state == State_MultiLineComment || _state == State_MultiLineDoxyComment) { + const int originalState = _state; + + if (! _yychar) { + tok->f.kind = T_EOF_SYMBOL; + return; + } + + while (_yychar) { + if (_yychar != '*') + yyinp(); + else { + yyinp(); + if (_yychar == '/') { + yyinp(); + _state = State_Default; + break; + } + } + } + + if (! f._scanCommentTokens) + goto _Lagain; + + else if (originalState == State_MultiLineComment) + tok->f.kind = T_COMMENT; + else + tok->f.kind = T_DOXY_COMMENT; + return; // done + } + + if (! _yychar) { + tok->f.kind = T_EOF_SYMBOL; + return; + } + + unsigned char ch = _yychar; + yyinp(); + + switch (ch) { + case '\\': + while (_yychar != '\n' && std::isspace(_yychar)) + yyinp(); + // ### assert(! _yychar || _yychar == '\n'); + if (_yychar == '\n') { + tok->f.joined = true; + tok->f.newline = false; + yyinp(); + } + goto _Lagain; + + case '"': case '\'': { + const unsigned char quote = ch; + + tok->f.kind = quote == '"' + ? T_STRING_LITERAL + : T_CHAR_LITERAL; + + while (_yychar && _yychar != quote) { + if (_yychar == '\n') + break; + if (_yychar != '\\') + yyinp(); + else { + yyinp(); // skip `\\' + + if (_yychar) + yyinp(); + } + } + // assert(_yychar == quote); + + if (_yychar == quote) + yyinp(); + } break; + + case '{': + tok->f.kind = T_LBRACE; + break; + + case '}': + tok->f.kind = T_RBRACE; + break; + + case '[': + tok->f.kind = T_LBRACKET; + break; + + case ']': + tok->f.kind = T_RBRACKET; + break; + + case '#': + if (_yychar == '#') { + tok->f.kind = T_POUND_POUND; + yyinp(); + } else { + tok->f.kind = T_POUND; + } + break; + + case '(': + tok->f.kind = T_LPAREN; + break; + + case ')': + tok->f.kind = T_RPAREN; + break; + + case ';': + tok->f.kind = T_SEMICOLON; + break; + + case ':': + if (_yychar == ':') { + yyinp(); + tok->f.kind = T_COLON_COLON; + } else { + tok->f.kind = T_COLON; + } + break; + + case '.': + if (_yychar == '*') { + yyinp(); + tok->f.kind = T_DOT_STAR; + } else if (_yychar == '.') { + yyinp(); + // ### assert(_yychar); + if (_yychar == '.') { + yyinp(); + tok->f.kind = T_DOT_DOT_DOT; + } else { + tok->f.kind = T_ERROR; + } + } else if (std::isdigit(_yychar)) { + do { + if (_yychar == 'e' || _yychar == 'E') { + yyinp(); + if (_yychar == '-' || _yychar == '+') { + yyinp(); + // ### assert(std::isdigit(_yychar)); + } + } else if (std::isalnum(_yychar) || _yychar == '.') { + yyinp(); + } else { + break; + } + } while (_yychar); + tok->f.kind = T_NUMERIC_LITERAL; + } else { + tok->f.kind = T_DOT; + } + break; + + case '?': + tok->f.kind = T_QUESTION; + break; + + case '+': + if (_yychar == '+') { + yyinp(); + tok->f.kind = T_PLUS_PLUS; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_PLUS_EQUAL; + } else { + tok->f.kind = T_PLUS; + } + break; + + case '-': + if (_yychar == '-') { + yyinp(); + tok->f.kind = T_MINUS_MINUS; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_MINUS_EQUAL; + } else if (_yychar == '>') { + yyinp(); + if (_yychar == '*') { + yyinp(); + tok->f.kind = T_ARROW_STAR; + } else { + tok->f.kind = T_ARROW; + } + } else { + tok->f.kind = T_MINUS; + } + break; + + case '*': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_STAR_EQUAL; + } else { + tok->f.kind = T_STAR; + } + break; + + case '/': + if (_yychar == '/') { + yyinp(); + + bool doxy = false; + + if (_yychar == '/' || _yychar == '!') { + yyinp(); + + if (_yychar == '<') + yyinp(); + + if (_yychar != '\n' && std::isspace(_yychar)) + doxy = true; + } + + while (_yychar && _yychar != '\n') + yyinp(); + + if (! f._scanCommentTokens) + goto _Lagain; + + tok->f.kind = doxy ? T_CPP_DOXY_COMMENT : T_CPP_COMMENT; + + } else if (_yychar == '*') { + yyinp(); + + bool doxy = false; + + if (_yychar == '*' || _yychar == '!') { + const unsigned char ch = _yychar; + + yyinp(); + + if (ch == '*' && _yychar == '/') + goto _Ldone; + + if (_yychar == '<') + yyinp(); + + if (! _yychar || std::isspace(_yychar)) + doxy = true; + } + + while (_yychar) { + if (_yychar != '*') { + yyinp(); + } else { + yyinp(); + if (_yychar == '/') + break; + } + } + + _Ldone: + if (_yychar) + yyinp(); + else + _state = doxy ? State_MultiLineDoxyComment : State_MultiLineComment; + + if (! f._scanCommentTokens) + goto _Lagain; + + tok->f.kind = doxy ? T_DOXY_COMMENT : T_COMMENT; + + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_SLASH_EQUAL; + } else { + tok->f.kind = T_SLASH; + } + break; + + case '%': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_PERCENT_EQUAL; + } else { + tok->f.kind = T_PERCENT; + } + break; + + case '^': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_CARET_EQUAL; + } else { + tok->f.kind = T_CARET; + } + break; + + case '&': + if (_yychar == '&') { + yyinp(); + tok->f.kind = T_AMPER_AMPER; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_AMPER_EQUAL; + } else { + tok->f.kind = T_AMPER; + } + break; + + case '|': + if (_yychar == '|') { + yyinp(); + tok->f.kind = T_PIPE_PIPE; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_PIPE_EQUAL; + } else { + tok->f.kind = T_PIPE; + } + break; + + case '~': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_TILDE_EQUAL; + } else { + tok->f.kind = T_TILDE; + } + break; + + case '!': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_EXCLAIM_EQUAL; + } else { + tok->f.kind = T_EXCLAIM; + } + break; + + case '=': + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_EQUAL_EQUAL; + } else { + tok->f.kind = T_EQUAL; + } + break; + + case '<': + if (f._scanAngleStringLiteralTokens) { + //const char *yytext = _currentChar; + while (_yychar && _yychar != '>') + yyinp(); + //int yylen = _currentChar - yytext; + // ### assert(_yychar == '>'); + if (_yychar == '>') + yyinp(); + tok->f.kind = T_ANGLE_STRING_LITERAL; + } else if (_yychar == '<') { + yyinp(); + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_LESS_LESS_EQUAL; + } else + tok->f.kind = T_LESS_LESS; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_LESS_EQUAL; + } else { + tok->f.kind = T_LESS; + } + break; + + case '>': + if (_yychar == '>') { + yyinp(); + if (_yychar == '=') { + yyinp(); + tok->f.kind = T_GREATER_GREATER_EQUAL; + } else + tok->f.kind = T_LESS_LESS; + tok->f.kind = T_GREATER_GREATER; + } else if (_yychar == '=') { + yyinp(); + tok->f.kind = T_GREATER_EQUAL; + } else { + tok->f.kind = T_GREATER; + } + break; + + case ',': + tok->f.kind = T_COMMA; + break; + + default: { + if (f._objCEnabled) { + if (ch == '@' && _yychar >= 'a' && _yychar <= 'z') { + //const char *yytext = _currentChar; + + do { + yyinp(); + if (! (isalnum(_yychar) || _yychar == '_' || _yychar == '$')) + break; + } while (_yychar); + + // const int yylen = _currentChar - yytext; + //tok->f.kind = classifyObjCAtKeyword(yytext, yylen); /// ### FIXME + break; + } + if (ch == '@' && _yychar == '"') { + // objc @string literals + ch = _yychar; + yyinp(); + tok->f.kind = T_AT_STRING_LITERAL; + + //const char *yytext = _currentChar; + + while (_yychar && _yychar != '"') { + if (_yychar != '\\') + yyinp(); + else { + yyinp(); // skip `\\' + + if (_yychar) + yyinp(); + } + } + // assert(_yychar == '"'); + + //int yylen = _currentChar - yytext; + + if (_yychar == '"') + yyinp(); + + break; + } + } + + if (ch == 'L' && (_yychar == '"' || _yychar == '\'')) { + // wide char/string literals + ch = _yychar; + yyinp(); + + const unsigned char quote = ch; + + tok->f.kind = quote == '"' + ? T_WIDE_STRING_LITERAL + : T_WIDE_CHAR_LITERAL; + + //const char *yytext = _currentChar; + + while (_yychar && _yychar != quote) { + if (_yychar != '\\') + yyinp(); + else { + yyinp(); // skip `\\' + + if (_yychar) + yyinp(); + } + } + // assert(_yychar == quote); + + //int yylen = _currentChar - yytext; + + if (_yychar == quote) + yyinp(); + + } else if (std::isalpha(ch) || ch == '_' || ch == '$') { + //const char *yytext = _currentChar - 1; + while (std::isalnum(_yychar) || _yychar == '_' || _yychar == '$') + yyinp(); + //int yylen = _currentChar - yytext; + tok->f.kind = T_IDENTIFIER; + break; + } else if (std::isdigit(ch)) { + //const char *yytext = _currentChar - 1; + while (_yychar) { + if (_yychar == 'e' || _yychar == 'E') { + yyinp(); + if (_yychar == '-' || _yychar == '+') { + yyinp(); + // ### assert(std::isdigit(_yychar)); + } + } else if (std::isalnum(_yychar) || _yychar == '.') { + yyinp(); + } else { + break; + } + } + //int yylen = _currentChar - yytext; + tok->f.kind = T_NUMERIC_LITERAL; + break; + } else { + tok->f.kind = T_ERROR; + break; + } + } // default + + } // switch +} + +} // namespace CPlusPlus diff --git a/src/plugins/scanner/cpp/Lexer.h b/src/plugins/scanner/cpp/Lexer.h new file mode 100644 index 00000000..8f55f84e --- /dev/null +++ b/src/plugins/scanner/cpp/Lexer.h @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef CPLUSPLUS_LEXER_H +#define CPLUSPLUS_LEXER_H + +#include "CPlusPlusForwardDeclarations.h" +#include "Token.h" + + +namespace CPlusPlus { + +class CPLUSPLUS_EXPORT Lexer +{ + Lexer(const Lexer &other); + void operator =(const Lexer &other); + +public: + enum State { + State_Default, + State_MultiLineComment, + State_MultiLineDoxyComment + }; + + Lexer(const char *firstChar, const char *lastChar); + ~Lexer(); + + bool qtMocRunEnabled() const; + void setQtMocRunEnabled(bool onoff); + + bool cxx0xEnabled() const; + void setCxxOxEnabled(bool onoff); + + bool objCEnabled() const; + void setObjCEnabled(bool onoff); + + void scan(Token *tok); + + inline void operator()(Token *tok) + { scan(tok); } + + unsigned tokenOffset() const; + unsigned tokenLength() const; + const char *tokenBegin() const; + const char *tokenEnd() const; + unsigned currentLine() const; + + bool scanCommentTokens() const; + void setScanCommentTokens(bool onoff); + + bool scanAngleStringLiteralTokens() const; + void setScanAngleStringLiteralTokens(bool onoff); + + void setStartWithNewline(bool enabled); + + int state() const; + void setState(int state); + + bool isIncremental() const; + void setIncremental(bool isIncremental); + +private: + void scan_helper(Token *tok); + void setSource(const char *firstChar, const char *lastChar); + static int classify(const char *string, int length, bool q, bool cxx0x); + static int classifyObjCAtKeyword(const char *s, int n); + static int classifyOperator(const char *string, int length); + + inline void yyinp() + { + if (++_currentChar == _lastChar) + _yychar = 0; + else { + _yychar = *_currentChar; + if (_yychar == '\n') + pushLineStartOffset(); + } + } + + void pushLineStartOffset(); + +private: + struct Flags { + unsigned _isIncremental: 1; + unsigned _scanCommentTokens: 1; + unsigned _scanAngleStringLiteralTokens: 1; + unsigned _qtMocRunEnabled: 1; + unsigned _cxx0xEnabled: 1; + unsigned _objCEnabled: 1; + }; + + const char *_firstChar = nullptr; + const char *_currentChar = nullptr; + const char *_lastChar = nullptr; + const char *_tokenStart = nullptr; + unsigned char _yychar = 0; + int _state = 0; + Flags f{}; + unsigned _currentLine = 0; +}; + +} // end of namespace CPlusPlus + + +#endif // CPLUSPLUS_LEXER_H diff --git a/src/plugins/scanner/cpp/Token.cpp b/src/plugins/scanner/cpp/Token.cpp new file mode 100644 index 00000000..b488bf0d --- /dev/null +++ b/src/plugins/scanner/cpp/Token.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#include "Token.h" +#ifndef CPLUSPLUS_NO_PARSER +# include "Literals.h" +#endif + +using namespace CPlusPlus; + +static const char *token_names[] = { + (""), (""), + + (""), (""), + (""), (""), + + (""), (""), (""), + (""), (""), (""), + ("<@string literal>"), (""), + + ("&"), ("&&"), ("&="), ("->"), ("->*"), ("^"), ("^="), (":"), ("::"), + (","), ("/"), ("/="), ("."), ("..."), (".*"), ("="), ("=="), ("!"), + ("!="), (">"), (">="), (">>"), (">>="), ("{"), ("["), ("<"), ("<="), + ("<<"), ("<<="), ("("), ("-"), ("-="), ("--"), ("%"), ("%="), ("|"), + ("|="), ("||"), ("+"), ("+="), ("++"), ("#"), ("##"), ("?"), ("}"), + ("]"), (")"), (";"), ("*"), ("*="), ("~"), ("~="), + + ("asm"), ("auto"), ("bool"), ("break"), ("case"), ("catch"), ("char"), + ("class"), ("const"), ("const_cast"), ("continue"), ("default"), + ("delete"), ("do"), ("double"), ("dynamic_cast"), ("else"), ("enum"), + ("explicit"), ("export"), ("extern"), ("false"), ("float"), ("for"), + ("friend"), ("goto"), ("if"), ("inline"), ("int"), ("long"), + ("mutable"), ("namespace"), ("new"), ("operator"), ("private"), + ("protected"), ("public"), ("register"), ("reinterpret_cast"), + ("return"), ("short"), ("signed"), ("sizeof"), ("static"), + ("static_cast"), ("struct"), ("switch"), ("template"), ("this"), + ("throw"), ("true"), ("try"), ("typedef"), ("typeid"), ("typename"), + ("union"), ("unsigned"), ("using"), ("virtual"), ("void"), + ("volatile"), ("wchar_t"), ("while"), + + // gnu + ("__attribute__"), ("__typeof__"), + + // objc @keywords + ("@catch"), ("@class"), ("@compatibility_alias"), ("@defs"), ("@dynamic"), + ("@encode"), ("@end"), ("@finally"), ("@implementation"), ("@interface"), + ("@not_keyword"), ("@optional"), ("@package"), ("@private"), ("@property"), + ("@protected"), ("@protocol"), ("@public"), ("@required"), ("@selector"), + ("@synchronized"), ("@synthesize"), ("@throw"), ("@try"), + + // Qt keywords + ("SIGNAL"), ("SLOT"), ("Q_SIGNAL"), ("Q_SLOT"), ("signals"), ("slots"), + ("Q_FOREACH"), ("Q_D"), ("Q_Q"), + ("Q_INVOKABLE"), ("Q_PROPERTY"), ("Q_INTERFACES"), ("Q_ENUMS"), ("Q_FLAGS"), + ("Q_PRIVATE_SLOT"), ("Q_DECLARE_INTERFACE"), ("Q_OBJECT"), ("Q_GADGET"), + ("Q_NAMESPACE"), + +}; + +void Token::reset() +{ + f = {}; + offset = 0; + ptr = nullptr; +} + +const char *Token::name(int kind) +{ return token_names[kind]; } + +#ifndef CPLUSPLUS_NO_PARSER +const char *Token::spell() const +{ + switch (f.kind) { + case T_IDENTIFIER: + return identifier->chars(); + + case T_NUMERIC_LITERAL: + case T_CHAR_LITERAL: + case T_STRING_LITERAL: + case T_AT_STRING_LITERAL: + case T_ANGLE_STRING_LITERAL: + case T_WIDE_CHAR_LITERAL: + case T_WIDE_STRING_LITERAL: + return literal->chars(); + + default: + return token_names[f.kind]; + } // switch +} +#endif + + diff --git a/src/plugins/scanner/cpp/Token.h b/src/plugins/scanner/cpp/Token.h new file mode 100644 index 00000000..a042c108 --- /dev/null +++ b/src/plugins/scanner/cpp/Token.h @@ -0,0 +1,368 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Copyright (c) 2008 Roberto Raggi +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#ifndef CPLUSPLUS_TOKEN_H +#define CPLUSPLUS_TOKEN_H + +#include "CPlusPlusForwardDeclarations.h" + +namespace CPlusPlus { + +enum Kind { + T_EOF_SYMBOL = 0, + T_ERROR, + + T_CPP_COMMENT, + T_CPP_DOXY_COMMENT, + T_COMMENT, + T_DOXY_COMMENT, + T_IDENTIFIER, + + T_FIRST_LITERAL, + T_NUMERIC_LITERAL = T_FIRST_LITERAL, + T_CHAR_LITERAL, + T_WIDE_CHAR_LITERAL, + T_STRING_LITERAL, + T_WIDE_STRING_LITERAL, + T_AT_STRING_LITERAL, + T_ANGLE_STRING_LITERAL, + T_LAST_LITERAL = T_ANGLE_STRING_LITERAL, + + T_FIRST_OPERATOR, + T_AMPER = T_FIRST_OPERATOR, + T_AMPER_AMPER, + T_AMPER_EQUAL, + T_ARROW, + T_ARROW_STAR, + T_CARET, + T_CARET_EQUAL, + T_COLON, + T_COLON_COLON, + T_COMMA, + T_SLASH, + T_SLASH_EQUAL, + T_DOT, + T_DOT_DOT_DOT, + T_DOT_STAR, + T_EQUAL, + T_EQUAL_EQUAL, + T_EXCLAIM, + T_EXCLAIM_EQUAL, + T_GREATER, + T_GREATER_EQUAL, + T_GREATER_GREATER, + T_GREATER_GREATER_EQUAL, + T_LBRACE, + T_LBRACKET, + T_LESS, + T_LESS_EQUAL, + T_LESS_LESS, + T_LESS_LESS_EQUAL, + T_LPAREN, + T_MINUS, + T_MINUS_EQUAL, + T_MINUS_MINUS, + T_PERCENT, + T_PERCENT_EQUAL, + T_PIPE, + T_PIPE_EQUAL, + T_PIPE_PIPE, + T_PLUS, + T_PLUS_EQUAL, + T_PLUS_PLUS, + T_POUND, + T_POUND_POUND, + T_QUESTION, + T_RBRACE, + T_RBRACKET, + T_RPAREN, + T_SEMICOLON, + T_STAR, + T_STAR_EQUAL, + T_TILDE, + T_TILDE_EQUAL, + T_LAST_OPERATOR = T_TILDE_EQUAL, + + T_FIRST_KEYWORD, + T_ASM = T_FIRST_KEYWORD, + T_AUTO, + T_BOOL, + T_BREAK, + T_CASE, + T_CATCH, + T_CHAR, + T_CLASS, + T_CONST, + T_CONST_CAST, + T_CONTINUE, + T_DEFAULT, + T_DELETE, + T_DO, + T_DOUBLE, + T_DYNAMIC_CAST, + T_ELSE, + T_ENUM, + T_EXPLICIT, + T_EXPORT, + T_EXTERN, + T_FALSE, + T_FLOAT, + T_FOR, + T_FRIEND, + T_GOTO, + T_IF, + T_INLINE, + T_INT, + T_LONG, + T_MUTABLE, + T_NAMESPACE, + T_NEW, + T_OPERATOR, + T_PRIVATE, + T_PROTECTED, + T_PUBLIC, + T_REGISTER, + T_REINTERPRET_CAST, + T_RETURN, + T_SHORT, + T_SIGNED, + T_SIZEOF, + T_STATIC, + T_STATIC_CAST, + T_STRUCT, + T_SWITCH, + T_TEMPLATE, + T_THIS, + T_THROW, + T_TRUE, + T_TRY, + T_TYPEDEF, + T_TYPEID, + T_TYPENAME, + T_UNION, + T_UNSIGNED, + T_USING, + T_VIRTUAL, + T_VOID, + T_VOLATILE, + T_WCHAR_T, + T_WHILE, + + T___ATTRIBUTE__, + T___TYPEOF__, + + // obj c++ @ keywords + T_FIRST_OBJC_AT_KEYWORD, + + T_AT_CATCH = T_FIRST_OBJC_AT_KEYWORD, + T_AT_CLASS, + T_AT_COMPATIBILITY_ALIAS, + T_AT_DEFS, + T_AT_DYNAMIC, + T_AT_ENCODE, + T_AT_END, + T_AT_FINALLY, + T_AT_IMPLEMENTATION, + T_AT_INTERFACE, + T_AT_NOT_KEYWORD, + T_AT_OPTIONAL, + T_AT_PACKAGE, + T_AT_PRIVATE, + T_AT_PROPERTY, + T_AT_PROTECTED, + T_AT_PROTOCOL, + T_AT_PUBLIC, + T_AT_REQUIRED, + T_AT_SELECTOR, + T_AT_SYNCHRONIZED, + T_AT_SYNTHESIZE, + T_AT_THROW, + T_AT_TRY, + + T_LAST_OBJC_AT_KEYWORD = T_AT_TRY, + + T_FIRST_QT_KEYWORD, + + // Qt keywords + T_SIGNAL = T_FIRST_QT_KEYWORD, + T_SLOT, + T_Q_SIGNAL, + T_Q_SLOT, + T_Q_SIGNALS, + T_Q_SLOTS, + T_Q_FOREACH, + T_Q_D, + T_Q_Q, + T_Q_INVOKABLE, + T_Q_PROPERTY, + T_Q_INTERFACES, + T_Q_ENUMS, + T_Q_FLAGS, + T_Q_PRIVATE_SLOT, + T_Q_DECLARE_INTERFACE, + T_Q_OBJECT, + T_Q_GADGET, + T_Q_NAMESPACE, + T_LAST_KEYWORD = T_Q_NAMESPACE, + + // aliases + T_OR = T_PIPE_PIPE, + T_AND = T_AMPER_AMPER, + T_NOT = T_EXCLAIM, + T_XOR = T_CARET, + T_BITOR = T_PIPE, + T_COMPL = T_TILDE, + T_OR_EQ = T_PIPE_EQUAL, + T_AND_EQ = T_AMPER_EQUAL, + T_BITAND = T_AMPER, + T_NOT_EQ = T_EXCLAIM_EQUAL, + T_XOR_EQ = T_CARET_EQUAL, + + T___ASM = T_ASM, + T___ASM__ = T_ASM, + + T_TYPEOF = T___TYPEOF__, + T___TYPEOF = T___TYPEOF__, + + T___INLINE = T_INLINE, + T___INLINE__ = T_INLINE, + + T___CONST = T_CONST, + T___CONST__ = T_CONST, + + T___VOLATILE = T_VOLATILE, + T___VOLATILE__ = T_VOLATILE, + + T___ATTRIBUTE = T___ATTRIBUTE__ +}; + +class CPLUSPLUS_EXPORT Token +{ +public: + inline bool is(unsigned k) const { return f.kind == k; } + inline bool isNot(unsigned k) const { return f.kind != k; } +#ifndef CPLUSPLUS_NO_PARSER + const char *spell() const; +#endif + void reset(); + + inline unsigned kind() const { return f.kind; } + inline bool newline() const { return f.newline; } + inline bool whitespace() const { return f.whitespace; } + inline bool joined() const { return f.joined; } + inline bool expanded() const { return f.expanded; } + inline bool generated() const { return f.generated; } + inline unsigned length() const { return f.length; } + + inline unsigned begin() const + { return offset; } + + inline unsigned end() const + { return offset + f.length; } + + inline bool isLiteral() const + { return f.kind >= T_FIRST_LITERAL && f.kind <= T_LAST_LITERAL; } + + inline bool isOperator() const + { return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; } + + inline bool isKeyword() const + { return f.kind >= T_FIRST_KEYWORD && f.kind < T_FIRST_QT_KEYWORD; } + + inline bool isComment() const + { return f.kind == T_COMMENT || f.kind == T_DOXY_COMMENT || + f.kind == T_CPP_COMMENT || f.kind == T_CPP_DOXY_COMMENT; } + + inline bool isObjCAtKeyword() const + { return f.kind >= T_FIRST_OBJC_AT_KEYWORD && f.kind <= T_LAST_OBJC_AT_KEYWORD; } + + static const char *name(int kind); + +public: + struct Flags { + unsigned kind : 8; + unsigned newline : 1; + unsigned whitespace : 1; + unsigned joined : 1; + unsigned expanded : 1; + unsigned generated : 1; + unsigned pad : 3; + unsigned length : 16; + }; + Flags f{}; + + unsigned offset = 0; + + union { + void *ptr = nullptr; +#ifndef CPLUSPLUS_NO_PARSER + const Literal *literal; + const NumericLiteral *number; + const StringLiteral *string; + const Identifier *identifier; +#endif + unsigned close_brace; + unsigned lineno; + }; +}; + +} // end of namespace CPlusPlus + + +#endif // CPLUSPLUS_TOKEN_H diff --git a/src/plugins/scanner/cpp/cpp.pri b/src/plugins/scanner/cpp/cpp.pri new file mode 100644 index 00000000..515e6563 --- /dev/null +++ b/src/plugins/scanner/cpp/cpp.pri @@ -0,0 +1 @@ +qbsPluginTarget = qbs_cpp_scanner diff --git a/src/plugins/scanner/cpp/cpp.pro b/src/plugins/scanner/cpp/cpp.pro new file mode 100644 index 00000000..12a6d7b6 --- /dev/null +++ b/src/plugins/scanner/cpp/cpp.pro @@ -0,0 +1,10 @@ +include(cpp.pri) +include(../../plugins.pri) +DEFINES += CPLUSPLUS_NO_PARSER + +QT = core + +HEADERS += CPlusPlusForwardDeclarations.h Lexer.h Token.h ../scanner.h \ + cpp_global.h +SOURCES += Lexer.cpp Token.cpp \ + cppscanner.cpp diff --git a/src/plugins/scanner/cpp/cpp.qbs b/src/plugins/scanner/cpp/cpp.qbs new file mode 100644 index 00000000..a274e0bb --- /dev/null +++ b/src/plugins/scanner/cpp/cpp.qbs @@ -0,0 +1,17 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + cpp.defines: base.concat(["CPLUSPLUS_NO_PARSER"]) + name: "qbs_cpp_scanner" + files: [ + "../scanner.h", + "CPlusPlusForwardDeclarations.h", + "Lexer.cpp", + "Lexer.h", + "Token.cpp", + "Token.h", + "cpp_global.h", + "cppscanner.cpp" + ] +} + diff --git a/src/plugins/scanner/cpp/cpp_global.h b/src/plugins/scanner/cpp/cpp_global.h new file mode 100644 index 00000000..80b10145 --- /dev/null +++ b/src/plugins/scanner/cpp/cpp_global.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CPP_GLOBAL_H +#define CPP_GLOBAL_H + +#if defined(WIN32) || defined(_WIN32) +#define CPPSCANNER_EXPORT __declspec(dllexport) +#else +#define CPPSCANNER_EXPORT __attribute__((visibility("default"))) +#endif + +#endif // CPP_GLOBAL_H diff --git a/src/plugins/scanner/cpp/cppscanner.cpp b/src/plugins/scanner/cpp/cppscanner.cpp new file mode 100644 index 00000000..6a500f01 --- /dev/null +++ b/src/plugins/scanner/cpp/cppscanner.cpp @@ -0,0 +1,335 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "../scanner.h" +#include "cpp_global.h" +#include "Lexer.h" + +using namespace CPlusPlus; + +#include +#include + +#ifdef Q_OS_UNIX +#include +#include +#include +#include +#include +#else +#include +#endif + +#include +#include +#include + +#include +#include + +struct ScanResult +{ + char *fileName = nullptr; + int size = 0; + int flags = 0; +}; + +struct Opaq +{ + enum FileType + { + FT_UNKNOWN, FT_HPP, FT_CPP, FT_C, FT_OBJC, FT_OBJCPP, FT_RC + }; + + Opaq() + : +#ifdef Q_OS_UNIX + fd(0), + mapl(0), +#endif + fileContent(nullptr), + fileType(FT_UNKNOWN), + hasQObjectMacro(false), + hasPluginMetaDataMacro(false), + currentResultIndex(0) + {} + + ~Opaq() + { +#ifdef Q_OS_UNIX + if (fileContent) + munmap(fileContent, mapl); + if (fd) + close(fd); +#endif + } + +#ifdef Q_OS_WIN + QFile file; +#endif +#ifdef Q_OS_UNIX + int fd; + size_t mapl; +#endif + + QString fileName; + char *fileContent; + FileType fileType; + QList includedFiles; + bool hasQObjectMacro; + bool hasPluginMetaDataMacro; + int currentResultIndex; +}; + +class TokenComparator +{ + const char * const m_fileContent; +public: + TokenComparator(const char *fileContent) + : m_fileContent(fileContent) + { + } + + bool equals(const Token &tk, const QLatin1String &literal) const + { + return static_cast(tk.length()) == literal.size() + && memcmp(m_fileContent + tk.begin(), literal.data(), literal.size()) == 0; + } +}; + +static void scanCppFile(void *opaq, CPlusPlus::Lexer &yylex, bool scanForFileTags, + bool scanForDependencies) +{ + const QLatin1String includeLiteral("include"); + const QLatin1String importLiteral("import"); + const QLatin1String defineLiteral("define"); + const QLatin1String qobjectLiteral("Q_OBJECT"); + const QLatin1String qgadgetLiteral("Q_GADGET"); + const QLatin1String qnamespaceLiteral("Q_NAMESPACE"); + const QLatin1String pluginMetaDataLiteral("Q_PLUGIN_METADATA"); + const auto opaque = static_cast(opaq); + const TokenComparator tc(opaque->fileContent); + Token tk; + Token oldTk; + ScanResult scanResult; + + yylex(&tk); + + while (tk.isNot(T_EOF_SYMBOL)) { + if (tk.newline() && tk.is(T_POUND)) { + yylex(&tk); + + if (scanForDependencies && !tk.newline() && tk.is(T_IDENTIFIER)) { + if (tc.equals(tk, includeLiteral) || tc.equals(tk, importLiteral)) + { + yylex.setScanAngleStringLiteralTokens(true); + yylex(&tk); + yylex.setScanAngleStringLiteralTokens(false); + + if (!tk.newline() && (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL))) { + scanResult.size = int(tk.length() - 2); + if (tk.is(T_STRING_LITERAL)) + scanResult.flags = SC_LOCAL_INCLUDE_FLAG; + else + scanResult.flags = SC_GLOBAL_INCLUDE_FLAG; + scanResult.fileName = opaque->fileContent + tk.begin() + 1; + opaque->includedFiles.push_back(scanResult); + } + } + } + } else if (tk.is(T_IDENTIFIER)) { + if (scanForFileTags) { + if (oldTk.is(T_IDENTIFIER) && tc.equals(oldTk, defineLiteral)) { + // Someone was clever and redefined Q_OBJECT or Q_PLUGIN_METADATA. + // Example: iplugin.h in Qt Creator. + } else { + if (tc.equals(tk, qobjectLiteral) || tc.equals(tk, qgadgetLiteral) || + tc.equals(tk, qnamespaceLiteral)) + { + opaque->hasQObjectMacro = true; + } else if (tc.equals(tk, pluginMetaDataLiteral)) + { + opaque->hasPluginMetaDataMacro = true; + } + if (!scanForDependencies && opaque->hasQObjectMacro + && (opaque->hasPluginMetaDataMacro + || opaque->fileType == Opaq::FT_CPP + || opaque->fileType == Opaq::FT_OBJCPP)) + break; + } + } + + } + oldTk = tk; + yylex(&tk); + } +} + +static void *openScanner(const unsigned short *filePath, const char *fileTags, int flags) +{ + std::unique_ptr opaque(new Opaq); + opaque->fileName = QString::fromUtf16(reinterpret_cast(filePath)); + const int fileTagsLength = static_cast(std::strlen(fileTags)); + const QList &tagList = QByteArray::fromRawData(fileTags, fileTagsLength).split(','); + if (tagList.contains("hpp")) + opaque->fileType = Opaq::FT_HPP; + else if (tagList.contains("cpp")) + opaque->fileType = Opaq::FT_CPP; + else if (tagList.contains("objcpp")) + opaque->fileType = Opaq::FT_OBJCPP; + else + opaque->fileType = Opaq::FT_UNKNOWN; + + size_t mapl = 0; +#ifdef Q_OS_UNIX + QString filePathS = opaque->fileName; + + opaque->fd = open(qPrintable(filePathS), O_RDONLY); + if (opaque->fd == -1) { + opaque->fd = 0; + return nullptr; + } + + struct stat s{}; + int r = fstat(opaque->fd, &s); + if (r != 0) + return nullptr; + mapl = s.st_size; + opaque->mapl = mapl; + + void *vmap = mmap(nullptr, s.st_size, PROT_READ, MAP_PRIVATE, opaque->fd, 0); + if (vmap == MAP_FAILED) // NOLINT(cppcoreguidelines-pro-type-cstyle-cast) + return nullptr; +#else + opaque->file.setFileName(opaque->fileName); + if (!opaque->file.open(QFile::ReadOnly)) + return nullptr; + + uchar *vmap = opaque->file.map(0, opaque->file.size()); + mapl = opaque->file.size(); +#endif + if (!vmap) + return nullptr; + + opaque->fileContent = reinterpret_cast(vmap); + + // Check for UTF-8 Byte Order Mark (BOM). Skip if found. + if (mapl >= 3 + && opaque->fileContent[0] == char(0xef) + && opaque->fileContent[1] == char(0xbb) + && opaque->fileContent[2] == char(0xbf)) { + opaque->fileContent += 3; + mapl -= 3; + } + + CPlusPlus::Lexer lex(opaque->fileContent, opaque->fileContent + mapl); + scanCppFile(opaque.get(), lex, flags & ScanForFileTagsFlag, flags & ScanForDependenciesFlag); + return opaque.release(); +} + +static void closeScanner(void *ptr) +{ + const auto opaque = static_cast(ptr); + delete opaque; +} + +static const char *next(void *opaq, int *size, int *flags) +{ + const auto opaque = static_cast(opaq); + if (opaque->currentResultIndex < opaque->includedFiles.size()) { + const ScanResult &result = opaque->includedFiles.at(opaque->currentResultIndex); + ++opaque->currentResultIndex; + *size = result.size; + *flags = result.flags; + return result.fileName; + } + *size = 0; + *flags = 0; + return nullptr; +} + +static const char **additionalFileTags(void *opaq, int *size) +{ + static const char *thMocCpp[] = { "moc_cpp" }; + static const char *thMocHpp[] = { "moc_hpp" }; + static const char *thMocPluginHpp[] = { "moc_hpp_plugin" }; + static const char *thMocPluginCpp[] = { "moc_cpp_plugin" }; + + const auto opaque = static_cast(opaq); + if (opaque->hasQObjectMacro) { + *size = 1; + switch (opaque->fileType) { + case Opaq::FT_CPP: + case Opaq::FT_OBJCPP: + return opaque->hasPluginMetaDataMacro ? thMocPluginCpp : thMocCpp; + case Opaq::FT_HPP: + return opaque->hasPluginMetaDataMacro ? thMocPluginHpp : thMocHpp; + default: + break; + } + } + *size = 0; + return nullptr; +} + +ScannerPlugin includeScanner = +{ + "include_scanner", + "cpp,cpp_pch_src,c,c_pch_src,objcpp,objcpp_pch_src,objc,objc_pch_src,rc", + openScanner, + closeScanner, + next, + additionalFileTags, + ScannerUsesCppIncludePaths | ScannerRecursiveDependencies +}; + +ScannerPlugin *cppScanners[] = { &includeScanner, nullptr }; + +static void QbsCppScannerPluginLoad() +{ + qbs::Internal::ScannerPluginManager::instance()->registerPlugins(cppScanners); +} + +static void QbsCppScannerPluginUnload() +{ +} + +QBS_REGISTER_STATIC_PLUGIN(extern "C" CPPSCANNER_EXPORT, qbs_cpp_scanner, + QbsCppScannerPluginLoad, QbsCppScannerPluginUnload) + diff --git a/src/plugins/scanner/qt/CMakeLists.txt b/src/plugins/scanner/qt/CMakeLists.txt new file mode 100644 index 00000000..9a3649ad --- /dev/null +++ b/src/plugins/scanner/qt/CMakeLists.txt @@ -0,0 +1,4 @@ +add_qbs_plugin(qbs_qt_scanner + DEPENDS qbscore + SOURCES ../scanner.h qtscanner.cpp + ) diff --git a/src/plugins/scanner/qt/qt.pri b/src/plugins/scanner/qt/qt.pri new file mode 100644 index 00000000..71e3a8a4 --- /dev/null +++ b/src/plugins/scanner/qt/qt.pri @@ -0,0 +1 @@ +qbsPluginTarget = qbs_qt_scanner diff --git a/src/plugins/scanner/qt/qt.pro b/src/plugins/scanner/qt/qt.pro new file mode 100644 index 00000000..f231ea9e --- /dev/null +++ b/src/plugins/scanner/qt/qt.pro @@ -0,0 +1,8 @@ +include(qt.pri) +include(../../plugins.pri) + +QT = core + +HEADERS += ../scanner.h +SOURCES += \ + qtscanner.cpp diff --git a/src/plugins/scanner/qt/qt.qbs b/src/plugins/scanner/qt/qt.qbs new file mode 100644 index 00000000..94144665 --- /dev/null +++ b/src/plugins/scanner/qt/qt.qbs @@ -0,0 +1,10 @@ +import "../../qbsplugin.qbs" as QbsPlugin + +QbsPlugin { + name: "qbs_qt_scanner" + files: [ + "../scanner.h", + "qtscanner.cpp" + ] +} + diff --git a/src/plugins/scanner/qt/qtscanner.cpp b/src/plugins/scanner/qt/qtscanner.cpp new file mode 100644 index 00000000..81f0d602 --- /dev/null +++ b/src/plugins/scanner/qt/qtscanner.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if defined(WIN32) || defined(_WIN32) +#define SCANNER_EXPORT __declspec(dllexport) +#else +#define SCANNER_EXPORT __attribute__((visibility("default"))) +#endif + +#include "../scanner.h" + +#include +#include + +#include + +#ifdef Q_OS_UNIX +#include +#include +#include +#include +#include +#else +#include +#endif + +#include +#include + +#include + +struct OpaqQrc +{ +#ifdef Q_OS_UNIX + int fd = 0; + int mapl = 0; +#else + std::unique_ptr file; +#endif + + char *map = nullptr; + std::unique_ptr xml; + QByteArray current; + OpaqQrc() = default; + + ~OpaqQrc() + { +#ifdef Q_OS_UNIX + if (map) + munmap (map, mapl); + if (fd) + close (fd); +#endif + } +}; + +static void *openScannerQrc(const unsigned short *filePath, const char *fileTags, int flags) +{ + Q_UNUSED(flags); + Q_UNUSED(fileTags); + std::unique_ptr opaque(new OpaqQrc); + +#ifdef Q_OS_UNIX + QString filePathS = QString::fromUtf16(reinterpret_cast(filePath)); + opaque->fd = open(qPrintable(filePathS), O_RDONLY); + if (opaque->fd == -1) { + opaque->fd = 0; + return nullptr; + } + + struct stat s{}; + int r = fstat(opaque->fd, &s); + if (r != 0) + return nullptr; + const int fileSize = static_cast(s.st_size); + opaque->mapl = fileSize; + + void *map = mmap(nullptr, s.st_size, PROT_READ, MAP_PRIVATE, opaque->fd, 0); + if (map == nullptr) + return nullptr; +#else + opaque->file = std::make_unique( + QString::fromUtf16(reinterpret_cast(filePath))); + if (!opaque->file->open(QFile::ReadOnly)) + return nullptr; + + const int fileSize = opaque->file->size(); + uchar *map = opaque->file->map(0, fileSize); + if (!map) + return nullptr; +#endif + + opaque->map = reinterpret_cast(map); + opaque->xml = std::make_unique( + QByteArray::fromRawData(opaque->map, fileSize)); + + return static_cast(opaque.release()); +} + +static void closeScannerQrc(void *ptr) +{ + const auto opaque = static_cast(ptr); + delete opaque; +} + +static const char *nextQrc(void *opaq, int *size, int *flags) +{ + const auto o = static_cast(opaq); + while (!o->xml->atEnd()) { + o->xml->readNext(); + switch (o->xml->tokenType()) { + case QXmlStreamReader::StartElement: + if (o->xml->name() == QLatin1String("file")) { + o->current = o->xml->readElementText(QXmlStreamReader::ErrorOnUnexpectedElement).toUtf8(); + *flags = SC_LOCAL_INCLUDE_FLAG; + *size = o->current.size(); + return o->current.data(); + } + break; + case QXmlStreamReader::EndDocument: + return nullptr; + default: + break; + } + } + return nullptr; +} + +static const char **additionalFileTagsQrc(void *, int *size) +{ + *size = 0; + return nullptr; +} + +ScannerPlugin qrcScanner = +{ + "qt_qrc_scanner", + "qrc", + openScannerQrc, + closeScannerQrc, + nextQrc, + additionalFileTagsQrc, + NoScannerFlags +}; + +ScannerPlugin *qtScanners[] = {&qrcScanner, nullptr}; + +static void QbsQtScannerPluginLoad() +{ + qbs::Internal::ScannerPluginManager::instance()->registerPlugins(qtScanners); +} + +static void QbsQtScannerPluginUnload() +{ +} + +QBS_REGISTER_STATIC_PLUGIN(extern "C" SCANNER_EXPORT, qbs_qt_scanner, + QbsQtScannerPluginLoad, QbsQtScannerPluginUnload) diff --git a/src/plugins/scanner/scanner.h b/src/plugins/scanner/scanner.h new file mode 100644 index 00000000..0d62a2ea --- /dev/null +++ b/src/plugins/scanner/scanner.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef SCANNER_H +#define SCANNER_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#define SC_LOCAL_INCLUDE_FLAG 0x1 +#define SC_GLOBAL_INCLUDE_FLAG 0x2 + +enum OpenScannerFlags +{ + ScanForDependenciesFlag = 0x01, + ScanForFileTagsFlag = 0x02 +}; + +/** + * Open a file that's going to be scanned. + * The file path encoding is UTF-16 on all platforms. + * The file tags are in CSV format. + * + * Returns a scanner handle. + */ +typedef void *(*scanOpen_f) (const unsigned short *filePath, const char *fileTags, int flags); + +/** + * Closes the given scanner handle. + */ +typedef void (*scanClose_f) (void *opaq); + +/** + * Return the next result (filename) of the scan. + */ +typedef const char *(*scanNext_f) (void *opaq, int *size, int *flags); + +/** + * Returns a list of type hints for the scanned file. + * May return null. + * + * Example: if a C++ header file contains Q_OBJECT, + * the type hint 'moc_hpp' is returned. + */ +typedef const char** (*scanAdditionalFileTags_f) (void *opaq, int *size); + +enum ScannerFlags +{ + NoScannerFlags = 0x00, + ScannerUsesCppIncludePaths = 0x01, + ScannerRecursiveDependencies = 0x02 +}; + +class ScannerPlugin +{ +public: + const char *name; + const char *fileTags; // CSV + scanOpen_f open; + scanClose_f close; + scanNext_f next; + scanAdditionalFileTags_f additionalFileTags; + int flags; +}; + +#ifdef __cplusplus +} +#endif +#endif // SCANNER_H diff --git a/src/plugins/scanner/scanner.pro b/src/plugins/scanner/scanner.pro new file mode 100644 index 00000000..68acae7d --- /dev/null +++ b/src/plugins/scanner/scanner.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = cpp qt + diff --git a/src/plugins/use_plugin.pri b/src/plugins/use_plugin.pri new file mode 100644 index 00000000..53be9f4d --- /dev/null +++ b/src/plugins/use_plugin.pri @@ -0,0 +1,10 @@ +include(qbs_plugin_common.pri) + +qbsPluginLibName = $$qbsPluginTarget +win32:CONFIG(debug, debug|release):CONFIG(static, static|shared): \ + qbsPluginLibName = $${qbsPluginLibName}d +LIBS += -l$$qbsPluginLibName + +macos: QMAKE_LFLAGS += -Wl,-u,_qbs_static_plugin_register_$$qbsPluginTarget +!macos:gcc: QMAKE_LFLAGS += -Wl,--require-defined=qbs_static_plugin_register_$$qbsPluginTarget +msvc: QMAKE_LFLAGS += /INCLUDE:qbs_static_plugin_register_$$qbsPluginTarget diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt new file mode 100644 index 00000000..b77e01b4 --- /dev/null +++ b/src/shared/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(json) +add_subdirectory(variant) diff --git a/src/shared/bundledqt/bundledqt.qbs b/src/shared/bundledqt/bundledqt.qbs new file mode 100644 index 00000000..e0f79df5 --- /dev/null +++ b/src/shared/bundledqt/bundledqt.qbs @@ -0,0 +1,188 @@ +import qbs.File +import qbs.FileInfo +import qbs.Utilities + +Product { + Depends { name: "qbsbuildconfig" } + Depends { name: "Qt"; submodules: ["core", "gui", "network", "printsupport", "widgets", "xml"] } + Depends { name: "Qt.test"; condition: project.withTests === true } + Depends { name: "Qt.script"; condition: !qbsbuildconfig.useBundledQtScript; required: false } + Depends { + name: "Qt.core5compat"; + condition: Utilities.versionCompare(Qt.core.version, "6") >= 0 + } + Depends { + name: "Qt"; + submodules: [ "dbus", "xcb_qpa_lib-private" ]; + required: false + } + + condition: { + if (!qbsbuildconfig.enableBundledQt) + return false; + if (Qt.core.staticBuild) + throw("Cannot bundle static Qt libraries"); + return true; + } + + readonly property string qtDebugLibrarySuffix: { + if (Qt.core.qtBuildVariant !== "debug") + return ""; + if (qbs.targetOS.contains("windows")) + return "d"; + if (qbs.targetOS.contains("darwin")) + return "_debug"; + return ""; + } + + Group { + name: "qt.conf" + files: ["qt.conf"] + qbs.install: true + qbs.installDir: qbsbuildconfig.appInstallDir + } + + Group { + name: "Qt libraries" + files: { + function getLibsForQtModule(mod) { + if (mod === "script" && !Qt[mod].present) + return []; + if ((mod !== "core") && !Qt[mod].hasLibrary) + return []; + if (Qt[mod].isStaticLibrary) + return []; + + var list = []; + if (qbs.targetOS.contains("windows")) { + var basename = FileInfo.baseName(Qt[mod].libNameForLinker); + var dir = Qt.core.binPath; + list.push(dir + "/" + basename + ".dll"); + + } else if (qbs.targetOS.contains("linux")) { + var fp = Qt[mod].libFilePath; + var basename = FileInfo.baseName(fp); + var dir = FileInfo.path(fp); + list.push(dir + "/" + basename + ".so"); + list.push(dir + "/" + basename + ".so." + Qt.core.versionMajor); + if (Utilities.versionCompare(Qt.core.version, "6") < 0) { + list.push(dir + "/" + basename + ".so." + + Qt.core.versionMajor + "." + + Qt.core.versionMinor); + } + list.push(dir + "/" + basename + ".so." + + Qt.core.versionMajor + "." + + Qt.core.versionMinor + "." + + Qt.core.versionPatch); + + } else if (Qt.core.frameworkBuild) { + var fp = Qt[mod].libFilePathRelease; + var fpd = fp + "_debug"; + + if (qtDebugLibrarySuffix) + list.push(fpd); + + var suffix = ".framework/"; + var frameworkPath = fp.substr(0, fp.lastIndexOf(suffix) + suffix.length - 1); + var versionsPath = frameworkPath + "/Versions"; + var versionName = Utilities.versionCompare(Qt.core.version, "6") >= 0 + ? "A" : Qt.core.versionMajor; + var versionPath = versionsPath + "/" + versionName; + list.push(frameworkPath + "/Resources"); + list.push(versionPath + "/Resources/Info.plist"); + list.push(versionPath + "/" + FileInfo.fileName(fp)); + if (qtDebugLibrarySuffix) + list.push(versionPath + "/" + FileInfo.fileName(fpd)); + if (qbsbuildconfig.installApiHeaders) { + list.push(frameworkPath + "/Headers"); + list.push(versionPath + "/Headers/**"); + } + } + return list; + } + + var qtModules = Object.getOwnPropertyNames(Qt); + var libraries = Array.prototype.concat.apply([], qtModules.map(getLibsForQtModule)); + + // Qt might be bundled with additional libraries + if (qbs.targetOS.contains("linux")) { + var dir = FileInfo.path(Qt.core.libFilePathRelease); + var addons = [ "libicui18n", "libicuuc", "libicudata" ]; + addons.forEach(function(lib) { + var fp = dir + "/" + lib + ".so"; + if (File.exists(fp)) + libraries.push(fp + "*"); + }); + } + + return libraries; + } + + fileTags: [] + + qbs.install: true + qbs.installDir: qbsbuildconfig.libInstallDir + qbs.installSourceBase: qbs.targetOS.contains("windows") ? Qt.core.binPath : Qt.core.libPath + } + + Group { + name: "Windows Plugins" + condition: qbs.targetOS.contains("windows") + prefix: Qt.core.pluginPath + "/" + files: [ + "platforms/qwindows" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix, + "styles/qwindowsvistastyle" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix + ] + qbs.install: true + qbs.installDir: "plugins" + qbs.installSourceBase: prefix + } + + Group { + name: "macOS Plugins" + condition: qbs.targetOS.contains("darwin") + prefix: Qt.core.pluginPath + "/" + files: [ + "platforms/libqcocoa" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix, + "styles/libqmacstyle" + qtDebugLibrarySuffix + cpp.dynamicLibrarySuffix + ] + qbs.install: true + qbs.installDir: "plugins" + qbs.installSourceBase: prefix + } + + Group { + name: "Linux Plugins" + condition: qbs.targetOS.contains("linux") + prefix: Qt.core.pluginPath + "/" + files: [ + "platforms/libqxcb" + cpp.dynamicLibrarySuffix, + "platformthemes/libqgtk3" + cpp.dynamicLibrarySuffix + ] + qbs.install: true + qbs.installDir: "plugins" + qbs.installSourceBase: prefix + } + + Group { + name: "MinGW Runtime DLLs" + condition: qbs.targetOS.contains("windows") && qbs.toolchain.contains("mingw") + + files: { + var libFileGlobs = [ + "*libgcc_s*.dll", + "*libstdc++-6.dll", + "*libwinpthread-1.dll" + ]; + var searchPaths = cpp.compilerLibraryPaths; + return Array.prototype.concat.apply([], searchPaths.map(function(path) { + return libFileGlobs.map(function(glob) { + return path + "/" + glob; + }); + })); + } + + qbs.install: true + qbs.installDir: "bin" + } +} diff --git a/src/shared/bundledqt/qt.conf b/src/shared/bundledqt/qt.conf new file mode 100644 index 00000000..7963d664 --- /dev/null +++ b/src/shared/bundledqt/qt.conf @@ -0,0 +1,2 @@ +[Paths] +Prefix = .. diff --git a/src/shared/json/CMakeLists.txt b/src/shared/json/CMakeLists.txt new file mode 100644 index 00000000..a25124cd --- /dev/null +++ b/src/shared/json/CMakeLists.txt @@ -0,0 +1,4 @@ +add_qbs_library(qbsjson + STATIC + SOURCES json.cpp json.h + ) diff --git a/src/shared/json/README.md b/src/shared/json/README.md new file mode 100644 index 00000000..fa4a151a --- /dev/null +++ b/src/shared/json/README.md @@ -0,0 +1,2 @@ +This is QJson without Qt, to be used in circumstances +where a Qt dependency is not desirable. diff --git a/src/shared/json/json.cpp b/src/shared/json/json.cpp new file mode 100644 index 00000000..7ab85cba --- /dev/null +++ b/src/shared/json/json.cpp @@ -0,0 +1,4979 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#if defined(_MSC_VER) && _MSC_VER > 0 +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "json.h" + + +//#define PARSER_DEBUG +#ifdef PARSER_DEBUG +static int indent = 0; +#define BEGIN std::cerr << std::string(4*indent++, ' ').data() << " pos=" << current +#define END --indent +#define DEBUG std::cerr << std::string(4*indent, ' ').data() +#else +#define BEGIN if (1) ; else std::cerr +#define END do {} while (0) +#define DEBUG if (1) ; else std::cerr +#endif + +static const int nestingLimit = 1024; + + +namespace Json { +namespace Internal { + +/* + This defines a binary data structure for Json data. The data structure is optimised for fast reading + and minimum allocations. The whole data structure can be mmap'ed and used directly. + + In most cases the binary structure is not as space efficient as a utf8 encoded text representation, but + much faster to access. + + The size requirements are: + + String: 4 bytes header + 2*(string.length()) + + Values: 4 bytes + size of data (size can be 0 for some data) + bool: 0 bytes + double: 8 bytes (0 if integer with less than 27bits) + string: see above + array: size of array + object: size of object + Array: 12 bytes + 4*length + size of Value data + Object: 12 bytes + 8*length + size of Key Strings + size of Value data + + For an example such as + + { // object: 12 + 5*8 = 52 + "firstName": "John", // key 12, value 8 = 20 + "lastName" : "Smith", // key 12, value 8 = 20 + "age" : 25, // key 8, value 0 = 8 + "address" : // key 12, object below = 140 + { // object: 12 + 4*8 + "streetAddress": "21 2nd Street", // key 16, value 16 + "city" : "New York", // key 8, value 12 + "state" : "NY", // key 8, value 4 + "postalCode" : "10021" // key 12, value 8 + }, // object total: 128 + "phoneNumber": // key: 16, value array below = 172 + [ // array: 12 + 2*4 + values below: 156 + { // object 12 + 2*8 + "type" : "home", // key 8, value 8 + "number": "212 555-1234" // key 8, value 16 + }, // object total: 68 + { // object 12 + 2*8 + "type" : "fax", // key 8, value 8 + "number": "646 555-4567" // key 8, value 16 + } // object total: 68 + ] // array total: 156 + } // great total: 412 bytes + + The uncompressed text file used roughly 500 bytes, so in this case we end up using about + the same space as the text representation. + + Other measurements have shown a slightly bigger binary size than a compact text + representation where all possible whitespace was stripped out. +*/ + +class Array; +class Object; +class Value; +class Entry; + +template +class qle_bitfield +{ +public: + uint32_t val; + + enum { + mask = ((1u << width) - 1) << pos + }; + + void operator=(uint32_t t) { + uint32_t i = val; + i &= ~mask; + i |= t << pos; + val = i; + } + operator uint32_t() const { + uint32_t t = val; + t &= mask; + t >>= pos; + return t; + } + bool operator!() const { return !operator uint32_t(); } + bool operator==(uint32_t t) { return uint32_t(*this) == t; } + bool operator!=(uint32_t t) { return uint32_t(*this) != t; } + bool operator<(uint32_t t) { return uint32_t(*this) < t; } + bool operator>(uint32_t t) { return uint32_t(*this) > t; } + bool operator<=(uint32_t t) { return uint32_t(*this) <= t; } + bool operator>=(uint32_t t) { return uint32_t(*this) >= t; } + void operator+=(uint32_t i) { *this = (uint32_t(*this) + i); } + void operator-=(uint32_t i) { *this = (uint32_t(*this) - i); } +}; + +template +class qle_signedbitfield +{ +public: + uint32_t val; + + enum { + mask = ((1u << width) - 1) << pos + }; + + void operator=(int t) { + uint32_t i = val; + i &= ~mask; + i |= t << pos; + val = i; + } + operator int() const { + uint32_t i = val; + i <<= 32 - width - pos; + int t = (int) i; + t >>= pos; + return t; + } + + bool operator!() const { return !operator int(); } + bool operator==(int t) { return int(*this) == t; } + bool operator!=(int t) { return int(*this) != t; } + bool operator<(int t) { return int(*this) < t; } + bool operator>(int t) { return int(*this) > t; } + bool operator<=(int t) { return int(*this) <= t; } + bool operator>=(int t) { return int(*this) >= t; } + void operator+=(int i) { *this = (int(*this) + i); } + void operator-=(int i) { *this = (int(*this) - i); } +}; + +using offset = uint32_t; + +// round the size up to the next 4 byte boundary +int alignedSize(int size) { return (size + 3) & ~3; } + +static int qStringSize(const std::string &ba) +{ + int l = 4 + static_cast(ba.length()); + return alignedSize(l); +} + +// returns INT_MAX if it can't compress it into 28 bits +static int compressedNumber(double d) +{ + // this relies on details of how ieee floats are represented + const int exponent_off = 52; + const uint64_t fraction_mask = 0x000fffffffffffffull; + const uint64_t exponent_mask = 0x7ff0000000000000ull; + + uint64_t val; + memcpy (&val, &d, sizeof(double)); + int exp = (int)((val & exponent_mask) >> exponent_off) - 1023; + if (exp < 0 || exp > 25) + return INT_MAX; + + uint64_t non_int = val & (fraction_mask >> exp); + if (non_int) + return INT_MAX; + + bool neg = (val >> 63) != 0; + val &= fraction_mask; + val |= ((uint64_t)1 << 52); + int res = (int)(val >> (52 - exp)); + return neg ? -res : res; +} + +static void toInternal(char *addr, const char *data, int size) +{ + memcpy(addr, &size, 4); + memcpy(addr + 4, data, size); +} + +class String +{ +public: + String(const char *data) { d = (Data *)data; } + + struct Data { + int length; + char utf8[1]; + }; + + Data *d; + + void operator=(const std::string &ba) + { + d->length = static_cast(ba.length()); + memcpy(d->utf8, ba.data(), ba.length()); + } + + bool operator==(const std::string &ba) const { + return toString() == ba; + } + bool operator!=(const std::string &str) const { + return !operator==(str); + } + bool operator>=(const std::string &str) const { + // ### + return toString() >= str; + } + + bool operator==(const String &str) const { + if (d->length != str.d->length) + return false; + return !memcmp(d->utf8, str.d->utf8, d->length); + } + bool operator<(const String &other) const; + bool operator>=(const String &other) const { return !(*this < other); } + + std::string toString() const { + return std::string(d->utf8, d->length); + } + +}; + +bool String::operator<(const String &other) const +{ + int alen = d->length; + int blen = other.d->length; + int l = std::min(alen, blen); + char *a = d->utf8; + char *b = other.d->utf8; + + while (l-- && *a == *b) + a++,b++; + if (l==-1) + return (alen < blen); + return (unsigned char)(*a) < (unsigned char)(*b); +} + +static void copyString(char *dest, const std::string &str) +{ + String string(dest); + string = str; +} + + +/* + Base is the base class for both Object and Array. Both classe work more or less the same way. + The class starts with a header (defined by the struct below), then followed by data (the data for + values in the Array case and Entry's (see below) for objects. + + After the data a table follows (tableOffset points to it) containing Value objects for Arrays, and + offsets from the beginning of the object to Entry's in the case of Object. + + Entry's in the Object's table are lexicographically sorted by key in the table(). This allows the usage + of a binary search over the keys in an Object. + */ +class Base +{ +public: + uint32_t size; + union { + uint32_t _dummy; + qle_bitfield<0, 1> is_object; + qle_bitfield<1, 31> length; + }; + offset tableOffset; + // content follows here + + bool isObject() const { return !!is_object; } + bool isArray() const { return !isObject(); } + + offset *table() const { return (offset *) (((char *) this) + tableOffset); } + + int reserveSpace(uint32_t dataSize, int posInTable, uint32_t numItems, bool replace); + void removeItems(int pos, int numItems); +}; + +class Object : public Base +{ +public: + Entry *entryAt(int i) const { + return reinterpret_cast(((char *)this) + table()[i]); + } + int indexOf(const std::string &key, bool *exists); + + bool isValid() const; +}; + + +class Value +{ +public: + enum { + MaxSize = (1<<27) - 1 + }; + union { + uint32_t _dummy; + qle_bitfield<0, 3> type; + qle_bitfield<3, 1> intValue; + qle_bitfield<4, 1> _; // Ex-latin1Key + qle_bitfield<5, 27> value; // Used as offset in case of Entry(?) + qle_signedbitfield<5, 27> int_value; + }; + + char *data(const Base *b) const { return ((char *)b) + value; } + int usedStorage(const Base *b) const; + + bool toBoolean() const { return value != 0; } + double toDouble(const Base *b) const; + std::string toString(const Base *b) const; + Base *base(const Base *b) const; + + bool isValid(const Base *b) const; + + static int requiredStorage(JsonValue &v, bool *compressed); + static uint32_t valueToStore(const JsonValue &v, uint32_t offset); + static void copyData(const JsonValue &v, char *dest, bool compressed); +}; + +class Array : public Base +{ +public: + Value at(int i) const { return *(Value *) (table() + i); } + Value &operator[](int i) { return *(Value *) (table() + i); } + + bool isValid() const; +}; + +class Entry { +public: + Value value; + // key + // value data follows key + + int size() const + { + int s = sizeof(Entry); + s += sizeof(uint32_t) + (*(int *) ((const char *)this + sizeof(Entry))); + return alignedSize(s); + } + + int usedStorage(Base *b) const + { + return size() + value.usedStorage(b); + } + + String shallowKey() const + { + return {(const char *)this + sizeof(Entry)}; + } + + std::string key() const + { + return shallowKey().toString(); + } + + bool operator==(const std::string &key) const; + bool operator!=(const std::string &key) const { return !operator==(key); } + bool operator>=(const std::string &key) const { return shallowKey() >= key; } + + bool operator==(const Entry &other) const; + bool operator>=(const Entry &other) const; +}; + +bool operator<(const std::string &key, const Entry &e) +{ + return e >= key; +} + + +class Header +{ +public: + uint32_t tag; // 'qbjs' + uint32_t version; // 1 + Base *root() { return (Base *)(this + 1); } +}; + + +double Value::toDouble(const Base *b) const +{ + // assert(type == JsonValue::Double); + if (intValue) + return int_value; + + double d; + memcpy(&d, (const char *)b + value, 8); + return d; +} + +std::string Value::toString(const Base *b) const +{ + String s(data(b)); + return s.toString(); +} + +Base *Value::base(const Base *b) const +{ + // assert(type == JsonValue::Array || type == JsonValue::Object); + return reinterpret_cast(data(b)); +} + +class AtomicInt +{ +public: + bool ref() { return ++x != 0; } + bool deref() { return --x != 0; } + int load() { return x.load(std::memory_order_seq_cst); } +private: + std::atomic x { 0 }; +}; + + +class SharedString +{ +public: + AtomicInt ref; + std::string s; +}; + +class Data { +public: + enum Validation { + Unchecked, + Validated, + Invalid + }; + + AtomicInt ref; + int alloc; + union { + char *rawData; + Header *header; + }; + uint32_t compactionCounter : 31; + uint32_t ownsData : 1; + + Data(char *raw, int a) + : alloc(a), rawData(raw), compactionCounter(0), ownsData(true) + { + } + Data(int reserved, JsonValue::Type valueType) + : rawData(nullptr), compactionCounter(0), ownsData(true) + { + // assert(valueType == JsonValue::Array || valueType == JsonValue::Object); + + alloc = sizeof(Header) + sizeof(Base) + reserved + sizeof(offset); + header = (Header *)malloc(alloc); + header->tag = JsonDocument::BinaryFormatTag; + header->version = 1; + Base *b = header->root(); + b->size = sizeof(Base); + b->is_object = (valueType == JsonValue::Object); + b->tableOffset = sizeof(Base); + b->length = 0; + } + ~Data() + { if (ownsData) free(rawData); } + + uint32_t offsetOf(const void *ptr) const { return (uint32_t)(((char *)ptr - rawData)); } + + JsonObject toObject(Object *o) const + { + return JsonObject(const_cast(this), o); + } + + JsonArray toArray(Array *a) const + { + return JsonArray(const_cast(this), a); + } + + Data *clone(Base *b, int reserve = 0) + { + int size = sizeof(Header) + b->size; + if (b == header->root() && ref.load() == 1 && alloc >= size + reserve) + return this; + + if (reserve) { + if (reserve < 128) + reserve = 128; + size = std::max(size + reserve, size *2); + } + char *raw = (char *)malloc(size); + memcpy(raw + sizeof(Header), b, b->size); + const auto h = (Header *)raw; + h->tag = JsonDocument::BinaryFormatTag; + h->version = 1; + const auto d = new Data(raw, size); + d->compactionCounter = (b == header->root()) ? compactionCounter : 0; + return d; + } + + void compact(); + bool valid() const; + +private: + Data(const Data &); + void operator=(const Data &); +}; + + +void objectToJson(const Object *o, std::string &json, int indent, bool compact = false); +void arrayToJson(const Array *a, std::string &json, int indent, bool compact = false); + +class Parser +{ +public: + Parser(const char *json, int length); + + JsonDocument parse(JsonParseError *error); + + class ParsedObject + { + public: + ParsedObject(Parser *p, int pos) : parser(p), objectPosition(pos) { + offsets.reserve(64); + } + void insert(uint32_t offset); + + Parser *parser; + int objectPosition; + std::vector offsets; + + Entry *entryAt(size_t i) const { + return reinterpret_cast(parser->data + objectPosition + offsets[i]); + } + }; + + +private: + void eatBOM(); + bool eatSpace(); + char nextToken(); + + bool parseObject(); + bool parseArray(); + bool parseMember(int baseOffset); + bool parseString(); + bool parseEscapeSequence(); + bool parseValue(Value *val, int baseOffset); + bool parseNumber(Value *val, int baseOffset); + + void addChar(char c) { + const int pos = reserveSpace(1); + data[pos] = c; + } + + const char *head; + const char *json; + const char *end; + + char *data; + int dataLength; + int current; + int nestingLevel; + JsonParseError::ParseError lastError; + + int reserveSpace(int space) { + if (current + space >= dataLength) { + dataLength = 2*dataLength + space; + data = (char *)realloc(data, dataLength); + } + int pos = current; + current += space; + return pos; + } +}; + +} // namespace Internal + +using namespace Internal; + +/*! + \class JsonValue + \inmodule QtCore + \ingroup json + \ingroup shared + \reentrant + \since 5.0 + + \brief The JsonValue class encapsulates a value in JSON. + + A value in JSON can be one of 6 basic types: + + JSON is a format to store structured data. It has 6 basic data types: + + \list + \li bool JsonValue::Bool + \li double JsonValue::Double + \li string JsonValue::String + \li array JsonValue::Array + \li object JsonValue::Object + \li null JsonValue::Null + \endlist + + A value can represent any of the above data types. In addition, JsonValue has one special + flag to represent undefined values. This can be queried with isUndefined(). + + The type of the value can be queried with type() or accessors like isBool(), isString(), and so on. + Likewise, the value can be converted to the type stored in it using the toBool(), toString() and so on. + + Values are strictly typed internally and contrary to QVariant will not attempt to do any implicit type + conversions. This implies that converting to a type that is not stored in the value will return a default + constructed return value. + + \section1 JsonValueRef + + JsonValueRef is a helper class for JsonArray and JsonObject. + When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the element in the JsonArray or JsonObject + from which you got the reference. + + The following methods return JsonValueRef: + \list + \li \l {JsonArray}::operator[](int i) + \li \l {JsonObject}::operator[](const QString & key) const + \endlist + + \sa {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! + Creates a JsonValue of type \a type. + + The default is to create a Null value. + */ +JsonValue::JsonValue(Type type) + : ui(0), d(nullptr), t(type) +{ +} + +/*! + \internal + */ +JsonValue::JsonValue(Internal::Data *data, Internal::Base *base, const Internal::Value &v) + : d(nullptr), t((Type)(uint32_t)v.type) +{ + switch (t) { + case Undefined: + case Null: + dbl = 0; + break; + case Bool: + b = v.toBoolean(); + break; + case Double: + dbl = v.toDouble(base); + break; + case String: { + stringData = new Internal::SharedString; + stringData->s = v.toString(base); + stringData->ref.ref(); + break; + } + case Array: + case Object: + d = data; + this->base = v.base(base); + break; + } + if (d) + d->ref.ref(); +} + +/*! + Creates a value of type Bool, with value \a b. + */ +JsonValue::JsonValue(bool b) + : d(nullptr), t(Bool) +{ + this->b = b; +} + +/*! + Creates a value of type Double, with value \a n. + */ +JsonValue::JsonValue(double n) + : d(nullptr), t(Double) +{ + this->dbl = n; +} + +/*! + \overload + Creates a value of type Double, with value \a n. + */ +JsonValue::JsonValue(int n) + : d(nullptr), t(Double) +{ + this->dbl = n; +} + +/*! + \overload + Creates a value of type Double, with value \a n. + NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992). + If you pass in values outside this range expect a loss of precision to occur. + */ +JsonValue::JsonValue(int64_t n) + : d(nullptr), t(Double) +{ + this->dbl = double(n); +} + +/*! + Creates a value of type String, with value \a s. + */ +JsonValue::JsonValue(const std::string &s) + : d(nullptr), t(String) +{ + stringData = new Internal::SharedString; + stringData->s = s; + stringData->ref.ref(); +} + +JsonValue::JsonValue(const char *s) + : d(nullptr), t(String) +{ + stringData = new Internal::SharedString; + stringData->s = s; + stringData->ref.ref(); +} + +/*! + Creates a value of type Array, with value \a a. + */ +JsonValue::JsonValue(const JsonArray &a) + : d(a.d), t(Array) +{ + base = a.a; + if (d) + d->ref.ref(); +} + +/*! + Creates a value of type Object, with value \a o. + */ +JsonValue::JsonValue(const JsonObject &o) + : d(o.d), t(Object) +{ + base = o.o; + if (d) + d->ref.ref(); +} + + +/*! + Destroys the value. + */ +JsonValue::~JsonValue() +{ + if (t == String && stringData && !stringData->ref.deref()) + delete stringData; + + if (d && !d->ref.deref()) + delete d; +} + +/*! + Creates a copy of \a other. + */ +JsonValue::JsonValue(const JsonValue &other) + : t(other.t) +{ + d = other.d; + ui = other.ui; + if (d) + d->ref.ref(); + + if (t == String && stringData) + stringData->ref.ref(); +} + +/*! + Assigns the value stored in \a other to this object. + */ +JsonValue &JsonValue::operator=(const JsonValue &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + if (t == String && stringData && !stringData->ref.deref()) + delete stringData; + + t = other.t; + dbl = other.dbl; + + if (d != other.d) { + + if (d && !d->ref.deref()) + delete d; + d = other.d; + if (d) + d->ref.ref(); + + } + + if (t == String && stringData) + stringData->ref.ref(); + + return *this; +} + +/*! + \fn bool JsonValue::isNull() const + + Returns \c true if the value is null. +*/ + +/*! + \fn bool JsonValue::isBool() const + + Returns \c true if the value contains a boolean. + + \sa toBool() + */ + +/*! + \fn bool JsonValue::isDouble() const + + Returns \c true if the value contains a double. + + \sa toDouble() + */ + +/*! + \fn bool JsonValue::isString() const + + Returns \c true if the value contains a string. + + \sa toString() + */ + +/*! + \fn bool JsonValue::isArray() const + + Returns \c true if the value contains an array. + + \sa toArray() + */ + +/*! + \fn bool JsonValue::isObject() const + + Returns \c true if the value contains an object. + + \sa toObject() + */ + +/*! + \fn bool JsonValue::isUndefined() const + + Returns \c true if the value is undefined. This can happen in certain + error cases as e.g. accessing a non existing key in a JsonObject. + */ + + +/*! + \enum JsonValue::Type + + This enum describes the type of the JSON value. + + \value Null A Null value + \value Bool A boolean value. Use toBool() to convert to a bool. + \value Double A double. Use toDouble() to convert to a double. + \value String A string. Use toString() to convert to a QString. + \value Array An array. Use toArray() to convert to a JsonArray. + \value Object An object. Use toObject() to convert to a JsonObject. + \value Undefined The value is undefined. This is usually returned as an + error condition, when trying to read an out of bounds value + in an array or a non existent key in an object. +*/ + +/*! + Returns the type of the value. + + \sa JsonValue::Type + */ + + +/*! + Converts the value to a bool and returns it. + + If type() is not bool, the \a defaultValue will be returned. + */ +bool JsonValue::toBool(bool defaultValue) const +{ + if (t != Bool) + return defaultValue; + return b; +} + +/*! + Converts the value to an int and returns it. + + If type() is not Double or the value is not a whole number, + the \a defaultValue will be returned. + */ +int JsonValue::toInt(int defaultValue) const +{ + if (t == Double && int(dbl) == dbl) + return int(dbl); + return defaultValue; +} + +/*! + Converts the value to a double and returns it. + + If type() is not Double, the \a defaultValue will be returned. + */ +double JsonValue::toDouble(double defaultValue) const +{ + if (t != Double) + return defaultValue; + return dbl; +} + +/*! + Converts the value to a QString and returns it. + + If type() is not String, the \a defaultValue will be returned. + */ +std::string JsonValue::toString(const std::string &defaultValue) const +{ + if (t != String) + return defaultValue; + return stringData->s; +} + +/*! + Converts the value to an array and returns it. + + If type() is not Array, the \a defaultValue will be returned. + */ +JsonArray JsonValue::toArray(const JsonArray &defaultValue) const +{ + if (!d || t != Array) + return defaultValue; + + return JsonArray(d, static_cast(base)); +} + +/*! + \overload + + Converts the value to an array and returns it. + + If type() is not Array, a \l{JsonArray::}{JsonArray()} will be returned. + */ +JsonArray JsonValue::toArray() const +{ + return toArray(JsonArray()); +} + +/*! + Converts the value to an object and returns it. + + If type() is not Object, the \a defaultValue will be returned. + */ +JsonObject JsonValue::toObject(const JsonObject &defaultValue) const +{ + if (!d || t != Object) + return defaultValue; + + return JsonObject(d, static_cast(base)); +} + +/*! + \overload + + Converts the value to an object and returns it. + + If type() is not Object, the \l {JsonObject::}{JsonObject()} will be returned. +*/ +JsonObject JsonValue::toObject() const +{ + return toObject({}); +} + +/*! + Returns \c true if the value is equal to \a other. + */ +bool JsonValue::operator==(const JsonValue &other) const +{ + if (t != other.t) + return false; + + switch (t) { + case Undefined: + case Null: + break; + case Bool: + return b == other.b; + case Double: + return dbl == other.dbl; + case String: + return toString() == other.toString(); + case Array: + if (base == other.base) + return true; + if (!base) + return !other.base->length; + if (!other.base) + return !base->length; + return JsonArray(d, static_cast(base)) + == JsonArray(other.d, static_cast(other.base)); + case Object: + if (base == other.base) + return true; + if (!base) + return !other.base->length; + if (!other.base) + return !base->length; + return JsonObject(d, static_cast(base)) + == JsonObject(other.d, static_cast(other.base)); + } + return true; +} + +/*! + Returns \c true if the value is not equal to \a other. + */ +bool JsonValue::operator!=(const JsonValue &other) const +{ + return !(*this == other); +} + +/*! + \internal + */ +void JsonValue::detach() +{ + if (!d) + return; + + Internal::Data *x = d->clone(base); + x->ref.ref(); + if (!d->ref.deref()) + delete d; + d = x; + base = static_cast(d->header->root()); +} + + +/*! + \class JsonValueRef + \inmodule QtCore + \reentrant + \brief The JsonValueRef class is a helper class for JsonValue. + + \internal + + \ingroup json + + When you get an object of type JsonValueRef, if you can assign to it, + the assignment will apply to the character in the string from + which you got the reference. That is its whole purpose in life. + + You can use it exactly in the same way as a reference to a JsonValue. + + The JsonValueRef becomes invalid once modifications are made to the + string: if you want to keep the character, copy it into a JsonValue. + + Most of the JsonValue member functions also exist in JsonValueRef. + However, they are not explicitly documented here. +*/ + + +JsonValueRef &JsonValueRef::operator=(const JsonValue &val) +{ + if (is_object) + o->setValueAt(index, val); + else + a->replace(index, val); + + return *this; +} + +JsonValueRef &JsonValueRef::operator=(const JsonValueRef &ref) +{ + if (is_object) + o->setValueAt(index, ref); + else + a->replace(index, ref); + + return *this; +} + +JsonArray JsonValueRef::toArray() const +{ + return toValue().toArray(); +} + +JsonObject JsonValueRef::toObject() const +{ + return toValue().toObject(); +} + +JsonValue JsonValueRef::toValue() const +{ + if (!is_object) + return a->at(index); + return o->valueAt(index); +} + +/*! + \class JsonArray + \inmodule QtCore + \ingroup json + \ingroup shared + \reentrant + \since 5.0 + + \brief The JsonArray class encapsulates a JSON array. + + A JSON array is a list of values. The list can be manipulated by inserting and + removing JsonValue's from the array. + + A JsonArray can be converted to and from a QVariantList. You can query the + number of entries with size(), insert(), and removeAt() entries from it + and iterate over its content using the standard C++ iterator pattern. + + JsonArray is an implicitly shared class and shares the data with the document + it has been created from as long as it is not being modified. + + You can convert the array to and from text based JSON through JsonDocument. + + \sa {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! + \typedef JsonArray::Iterator + + Qt-style synonym for JsonArray::iterator. +*/ + +/*! + \typedef JsonArray::ConstIterator + + Qt-style synonym for JsonArray::const_iterator. +*/ + +/*! + \typedef JsonArray::size_type + + Typedef for int. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::value_type + + Typedef for JsonValue. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::difference_type + + Typedef for int. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::pointer + + Typedef for JsonValue *. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::const_pointer + + Typedef for const JsonValue *. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::reference + + Typedef for JsonValue &. Provided for STL compatibility. +*/ + +/*! + \typedef JsonArray::const_reference + + Typedef for const JsonValue &. Provided for STL compatibility. +*/ + +/*! + Creates an empty array. + */ +JsonArray::JsonArray() + : d(nullptr), a(nullptr) +{ +} + +JsonArray::JsonArray(std::initializer_list args) + : d(nullptr), a(nullptr) +{ + for (const auto &arg : args) + append(arg); +} + +/*! + \fn JsonArray::JsonArray(std::initializer_list args) + \since 5.4 + Creates an array initialized from \a args initialization list. + + JsonArray can be constructed in a way similar to JSON notation, + for example: + \code + JsonArray array = { 1, 2.2, QString() }; + \endcode + */ + +/*! + \internal + */ +JsonArray::JsonArray(Internal::Data *data, Internal::Array *array) + : d(data), a(array) +{ + // assert(data); + // assert(array); + d->ref.ref(); +} + +/*! + Deletes the array. + */ +JsonArray::~JsonArray() +{ + if (d && !d->ref.deref()) + delete d; +} + +/*! + Creates a copy of \a other. + + Since JsonArray is implicitly shared, the copy is shallow + as long as the object doesn't get modified. + */ +JsonArray::JsonArray(const JsonArray &other) +{ + d = other.d; + a = other.a; + if (d) + d->ref.ref(); +} + +/*! + Assigns \a other to this array. + */ +JsonArray &JsonArray::operator=(const JsonArray &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + if (d != other.d) { + if (d && !d->ref.deref()) + delete d; + d = other.d; + if (d) + d->ref.ref(); + } + a = other.a; + + return *this; +} + +/*! \fn JsonArray &JsonArray::operator+=(const JsonValue &value) + + Appends \a value to the array, and returns a reference to the array itself. + + \since 5.3 + \sa append(), operator<<() +*/ + +/*! \fn JsonArray JsonArray::operator+(const JsonValue &value) const + + Returns an array that contains all the items in this array followed + by the provided \a value. + + \since 5.3 + \sa operator+=() +*/ + +/*! \fn JsonArray &JsonArray::operator<<(const JsonValue &value) + + Appends \a value to the array, and returns a reference to the array itself. + + \since 5.3 + \sa operator+=(), append() +*/ + +/*! + Returns the number of values stored in the array. + */ +int JsonArray::size() const +{ + if (!d) + return 0; + + return (int)a->length; +} + +/*! + \fn JsonArray::count() const + + Same as size(). + + \sa size() +*/ + +/*! + Returns \c true if the object is empty. This is the same as size() == 0. + + \sa size() + */ +bool JsonArray::isEmpty() const +{ + if (!d) + return true; + + return !a->length; +} + +/*! + Returns a JsonValue representing the value for index \a i. + + The returned JsonValue is \c Undefined, if \a i is out of bounds. + + */ +JsonValue JsonArray::at(int i) const +{ + if (!a || i < 0 || i >= (int)a->length) + return {JsonValue::Undefined}; + + return {d, a, a->at(i)}; +} + +/*! + Returns the first value stored in the array. + + Same as \c at(0). + + \sa at() + */ +JsonValue JsonArray::first() const +{ + return at(0); +} + +/*! + Returns the last value stored in the array. + + Same as \c{at(size() - 1)}. + + \sa at() + */ +JsonValue JsonArray::last() const +{ + return at(a ? (a->length - 1) : 0); +} + +/*! + Inserts \a value at the beginning of the array. + + This is the same as \c{insert(0, value)} and will prepend \a value to the array. + + \sa append(), insert() + */ +void JsonArray::prepend(const JsonValue &value) +{ + insert(0, value); +} + +/*! + Inserts \a value at the end of the array. + + \sa prepend(), insert() + */ +void JsonArray::append(const JsonValue &value) +{ + insert(a ? (int)a->length : 0, value); +} + +/*! + Removes the value at index position \a i. \a i must be a valid + index position in the array (i.e., \c{0 <= i < size()}). + + \sa insert(), replace() + */ +void JsonArray::removeAt(int i) +{ + if (!a || i < 0 || i >= (int)a->length) + return; + + detach(); + a->removeItems(i, 1); + ++d->compactionCounter; + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(a->length) / 2u) + compact(); +} + +/*! \fn void JsonArray::removeFirst() + + Removes the first item in the array. Calling this function is + equivalent to calling \c{removeAt(0)}. The array must not be empty. If + the array can be empty, call isEmpty() before calling this + function. + + \sa removeAt(), removeLast() +*/ + +/*! \fn void JsonArray::removeLast() + + Removes the last item in the array. Calling this function is + equivalent to calling \c{removeAt(size() - 1)}. The array must not be + empty. If the array can be empty, call isEmpty() before calling + this function. + + \sa removeAt(), removeFirst() +*/ + +/*! + Removes the item at index position \a i and returns it. \a i must + be a valid index position in the array (i.e., \c{0 <= i < size()}). + + If you don't use the return value, removeAt() is more efficient. + + \sa removeAt() + */ +JsonValue JsonArray::takeAt(int i) +{ + if (!a || i < 0 || i >= (int)a->length) + return {JsonValue::Undefined}; + + JsonValue v(d, a, a->at(i)); + removeAt(i); // detaches + return v; +} + +/*! + Inserts \a value at index position \a i in the array. If \a i + is \c 0, the value is prepended to the array. If \a i is size(), the + value is appended to the array. + + \sa append(), prepend(), replace(), removeAt() + */ +void JsonArray::insert(int i, const JsonValue &value) +{ + // assert (i >= 0 && i <= (a ? (int)a->length : 0)); + JsonValue val = value; + + bool compressed; + int valueSize = Internal::Value::requiredStorage(val, &compressed); + + detach(valueSize + sizeof(Internal::Value)); + + if (!a->length) + a->tableOffset = sizeof(Internal::Array); + + int valueOffset = a->reserveSpace(valueSize, i, 1, false); + if (!valueOffset) + return; + + Internal::Value &v = (*a)[i]; + v.type = (val.t == JsonValue::Undefined ? JsonValue::Null : val.t); + v.intValue = compressed; + v.value = Internal::Value::valueToStore(val, valueOffset); + if (valueSize) + Internal::Value::copyData(val, (char *)a + valueOffset, compressed); +} + +/*! + \fn JsonArray::iterator JsonArray::insert(iterator before, const JsonValue &value) + + Inserts \a value before the position pointed to by \a before, and returns an iterator + pointing to the newly inserted item. + + \sa erase(), insert() +*/ + +/*! + \fn JsonArray::iterator JsonArray::erase(iterator it) + + Removes the item pointed to by \a it, and returns an iterator pointing to the + next item. + + \sa removeAt() +*/ + +/*! + Replaces the item at index position \a i with \a value. \a i must + be a valid index position in the array (i.e., \c{0 <= i < size()}). + + \sa operator[](), removeAt() + */ +void JsonArray::replace(int i, const JsonValue &value) +{ + // assert (a && i >= 0 && i < (int)(a->length)); + JsonValue val = value; + + bool compressed; + int valueSize = Internal::Value::requiredStorage(val, &compressed); + + detach(valueSize); + + if (!a->length) + a->tableOffset = sizeof(Internal::Array); + + int valueOffset = a->reserveSpace(valueSize, i, 1, true); + if (!valueOffset) + return; + + Internal::Value &v = (*a)[i]; + v.type = (val.t == JsonValue::Undefined ? JsonValue::Null : val.t); + v.intValue = compressed; + v.value = Internal::Value::valueToStore(val, valueOffset); + if (valueSize) + Internal::Value::copyData(val, (char *)a + valueOffset, compressed); + + ++d->compactionCounter; + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(a->length) / 2u) + compact(); +} + +/*! + Returns \c true if the array contains an occurrence of \a value, otherwise \c false. + + \sa count() + */ +bool JsonArray::contains(const JsonValue &value) const +{ + for (int i = 0; i < size(); i++) { + if (at(i) == value) + return true; + } + return false; +} + +/*! + Returns the value at index position \a i as a modifiable reference. + \a i must be a valid index position in the array (i.e., \c{0 <= i < + size()}). + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the character in the JsonArray of JsonObject + from which you got the reference. + + \sa at() + */ +JsonValueRef JsonArray::operator[](int i) +{ + // assert(a && i >= 0 && i < (int)a->length); + return {this, i}; +} + +/*! + \overload + + Same as at(). + */ +JsonValue JsonArray::operator[](int i) const +{ + return at(i); +} + +/*! + Returns \c true if this array is equal to \a other. + */ +bool JsonArray::operator==(const JsonArray &other) const +{ + if (a == other.a) + return true; + + if (!a) + return !other.a->length; + if (!other.a) + return !a->length; + if (a->length != other.a->length) + return false; + + for (int i = 0; i < (int)a->length; ++i) { + if (JsonValue(d, a, a->at(i)) != JsonValue(other.d, other.a, other.a->at(i))) + return false; + } + return true; +} + +/*! + Returns \c true if this array is not equal to \a other. + */ +bool JsonArray::operator!=(const JsonArray &other) const +{ + return !(*this == other); +} + +/*! \fn JsonArray::iterator JsonArray::begin() + + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in + the array. + + \sa constBegin(), end() +*/ + +/*! \fn JsonArray::const_iterator JsonArray::begin() const + + \overload +*/ + +/*! \fn JsonArray::const_iterator JsonArray::constBegin() const + + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item + in the array. + + \sa begin(), constEnd() +*/ + +/*! \fn JsonArray::iterator JsonArray::end() + + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item + after the last item in the array. + + \sa begin(), constEnd() +*/ + +/*! \fn const_iterator JsonArray::end() const + + \overload +*/ + +/*! \fn JsonArray::const_iterator JsonArray::constEnd() const + + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary + item after the last item in the array. + + \sa constBegin(), end() +*/ + +/*! \fn void JsonArray::push_back(const JsonValue &value) + + This function is provided for STL compatibility. It is equivalent + to \l{JsonArray::append()}{append(value)} and will append \a value to the array. +*/ + +/*! \fn void JsonArray::push_front(const JsonValue &value) + + This function is provided for STL compatibility. It is equivalent + to \l{JsonArray::prepend()}{prepend(value)} and will prepend \a value to the array. +*/ + +/*! \fn void JsonArray::pop_front() + + This function is provided for STL compatibility. It is equivalent + to removeFirst(). The array must not be empty. If the array can be + empty, call isEmpty() before calling this function. +*/ + +/*! \fn void JsonArray::pop_back() + + This function is provided for STL compatibility. It is equivalent + to removeLast(). The array must not be empty. If the array can be + empty, call isEmpty() before calling this function. +*/ + +/*! \fn bool JsonArray::empty() const + + This function is provided for STL compatibility. It is equivalent + to isEmpty() and returns \c true if the array is empty. +*/ + +/*! \class JsonArray::iterator + \inmodule QtCore + \brief The JsonArray::iterator class provides an STL-style non-const iterator for JsonArray. + + JsonArray::iterator allows you to iterate over a JsonArray + and to modify the array item associated with the + iterator. If you want to iterate over a const JsonArray, use + JsonArray::const_iterator instead. It is generally a good practice to + use JsonArray::const_iterator on a non-const JsonArray as well, unless + you need to change the JsonArray through the iterator. Const + iterators are slightly faster and improves code readability. + + The default JsonArray::iterator constructor creates an uninitialized + iterator. You must initialize it using a JsonArray function like + JsonArray::begin(), JsonArray::end(), or JsonArray::insert() before you can + start iterating. + + Most JsonArray functions accept an integer index rather than an + iterator. For that reason, iterators are rarely useful in + connection with JsonArray. One place where STL-style iterators do + make sense is as arguments to \l{generic algorithms}. + + Multiple iterators can be used on the same array. However, be + aware that any non-const function call performed on the JsonArray + will render all existing iterators undefined. + + \sa JsonArray::const_iterator +*/ + +/*! \typedef JsonArray::iterator::iterator_category + + A synonym for \e {std::random_access_iterator_tag} indicating + this iterator is a random access iterator. +*/ + +/*! \typedef JsonArray::iterator::difference_type + + \internal +*/ + +/*! \typedef JsonArray::iterator::value_type + + \internal +*/ + +/*! \typedef JsonArray::iterator::reference + + \internal +*/ + +/*! \typedef JsonArray::iterator::pointer + + \internal +*/ + +/*! \fn JsonArray::iterator::iterator() + + Constructs an uninitialized iterator. + + Functions like operator*() and operator++() should not be called + on an uninitialized iterator. Use operator=() to assign a value + to it before using it. + + \sa JsonArray::begin(), JsonArray::end() +*/ + +/*! \fn JsonArray::iterator::iterator(JsonArray *array, int index) + \internal +*/ + +/*! \fn JsonValueRef JsonArray::iterator::operator*() const + + + Returns a modifiable reference to the current item. + + You can change the value of an item by using operator*() on the + left side of an assignment. + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the character in the JsonArray of JsonObject + from which you got the reference. +*/ + +/*! \fn JsonValueRef *JsonArray::iterator::operator->() const + + Returns a pointer to a modifiable reference to the current item. +*/ + +/*! \fn JsonValueRef JsonArray::iterator::operator[](int j) const + + Returns a modifiable reference to the item at offset \a j from the + item pointed to by this iterator (the item at position \c{*this + j}). + + This function is provided to make JsonArray iterators behave like C++ + pointers. + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the character in the JsonArray of JsonObject + from which you got the reference. + + \sa operator+() +*/ + +/*! + \fn bool JsonArray::iterator::operator==(const iterator &other) const + \fn bool JsonArray::iterator::operator==(const const_iterator &other) const + + Returns \c true if \a other points to the same item as this + iterator; otherwise returns \c false. + + \sa operator!=() +*/ + +/*! + \fn bool JsonArray::iterator::operator!=(const iterator &other) const + \fn bool JsonArray::iterator::operator!=(const const_iterator &other) const + + Returns \c true if \a other points to a different item than this + iterator; otherwise returns \c false. + + \sa operator==() +*/ + +/*! + \fn bool JsonArray::iterator::operator<(const iterator& other) const + \fn bool JsonArray::iterator::operator<(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is less than + the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::iterator::operator<=(const iterator& other) const + \fn bool JsonArray::iterator::operator<=(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is less than + or equal to the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::iterator::operator>(const iterator& other) const + \fn bool JsonArray::iterator::operator>(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is greater + than the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::iterator::operator>=(const iterator& other) const + \fn bool JsonArray::iterator::operator>=(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is greater + than or equal to the item pointed to by the \a other iterator. +*/ + +/*! \fn JsonArray::iterator &JsonArray::iterator::operator++() + + The prefix ++ operator, \c{++it}, advances the iterator to the + next item in the array and returns an iterator to the new current + item. + + Calling this function on JsonArray::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn JsonArray::iterator JsonArray::iterator::operator++(int) + + \overload + + The postfix ++ operator, \c{it++}, advances the iterator to the + next item in the array and returns an iterator to the previously + current item. +*/ + +/*! \fn JsonArray::iterator &JsonArray::iterator::operator--() + + The prefix -- operator, \c{--it}, makes the preceding item + current and returns an iterator to the new current item. + + Calling this function on JsonArray::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! \fn JsonArray::iterator JsonArray::iterator::operator--(int) + + \overload + + The postfix -- operator, \c{it--}, makes the preceding item + current and returns an iterator to the previously current item. +*/ + +/*! \fn JsonArray::iterator &JsonArray::iterator::operator+=(int j) + + Advances the iterator by \a j items. If \a j is negative, the + iterator goes backward. + + \sa operator-=(), operator+() +*/ + +/*! \fn JsonArray::iterator &JsonArray::iterator::operator-=(int j) + + Makes the iterator go back by \a j items. If \a j is negative, + the iterator goes forward. + + \sa operator+=(), operator-() +*/ + +/*! \fn JsonArray::iterator JsonArray::iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. If \a j is negative, the iterator goes backward. + + \sa operator-(), operator+=() +*/ + +/*! \fn JsonArray::iterator JsonArray::iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. If \a j is negative, the iterator goes forward. + + \sa operator+(), operator-=() +*/ + +/*! \fn int JsonArray::iterator::operator-(iterator other) const + + Returns the number of items between the item pointed to by \a + other and the item pointed to by this iterator. +*/ + +/*! \class JsonArray::const_iterator + \inmodule QtCore + \brief The JsonArray::const_iterator class provides an STL-style const iterator for JsonArray. + + JsonArray::const_iterator allows you to iterate over a + JsonArray. If you want to modify the JsonArray as + you iterate over it, use JsonArray::iterator instead. It is generally a + good practice to use JsonArray::const_iterator on a non-const JsonArray + as well, unless you need to change the JsonArray through the + iterator. Const iterators are slightly faster and improves + code readability. + + The default JsonArray::const_iterator constructor creates an + uninitialized iterator. You must initialize it using a JsonArray + function like JsonArray::constBegin(), JsonArray::constEnd(), or + JsonArray::insert() before you can start iterating. + + Most JsonArray functions accept an integer index rather than an + iterator. For that reason, iterators are rarely useful in + connection with JsonArray. One place where STL-style iterators do + make sense is as arguments to \l{generic algorithms}. + + Multiple iterators can be used on the same array. However, be + aware that any non-const function call performed on the JsonArray + will render all existing iterators undefined. + + \sa JsonArray::iterator +*/ + +/*! \fn JsonArray::const_iterator::const_iterator() + + Constructs an uninitialized iterator. + + Functions like operator*() and operator++() should not be called + on an uninitialized iterator. Use operator=() to assign a value + to it before using it. + + \sa JsonArray::constBegin(), JsonArray::constEnd() +*/ + +/*! \fn JsonArray::const_iterator::const_iterator(const JsonArray *array, int index) + \internal +*/ + +/*! \typedef JsonArray::const_iterator::iterator_category + + A synonym for \e {std::random_access_iterator_tag} indicating + this iterator is a random access iterator. +*/ + +/*! \typedef JsonArray::const_iterator::difference_type + + \internal +*/ + +/*! \typedef JsonArray::const_iterator::value_type + + \internal +*/ + +/*! \typedef JsonArray::const_iterator::reference + + \internal +*/ + +/*! \typedef JsonArray::const_iterator::pointer + + \internal +*/ + +/*! \fn JsonArray::const_iterator::const_iterator(const const_iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn JsonArray::const_iterator::const_iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn JsonValue JsonArray::const_iterator::operator*() const + + Returns the current item. +*/ + +/*! \fn JsonValue *JsonArray::const_iterator::operator->() const + + Returns a pointer to the current item. +*/ + +/*! \fn JsonValue JsonArray::const_iterator::operator[](int j) const + + Returns the item at offset \a j from the item pointed to by this iterator (the item at + position \c{*this + j}). + + This function is provided to make JsonArray iterators behave like C++ + pointers. + + \sa operator+() +*/ + +/*! \fn bool JsonArray::const_iterator::operator==(const const_iterator &other) const + + Returns \c true if \a other points to the same item as this + iterator; otherwise returns \c false. + + \sa operator!=() +*/ + +/*! \fn bool JsonArray::const_iterator::operator!=(const const_iterator &other) const + + Returns \c true if \a other points to a different item than this + iterator; otherwise returns \c false. + + \sa operator==() +*/ + +/*! + \fn bool JsonArray::const_iterator::operator<(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is less than + the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::const_iterator::operator<=(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is less than + or equal to the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::const_iterator::operator>(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is greater + than the item pointed to by the \a other iterator. +*/ + +/*! + \fn bool JsonArray::const_iterator::operator>=(const const_iterator& other) const + + Returns \c true if the item pointed to by this iterator is greater + than or equal to the item pointed to by the \a other iterator. +*/ + +/*! \fn JsonArray::const_iterator &JsonArray::const_iterator::operator++() + + The prefix ++ operator, \c{++it}, advances the iterator to the + next item in the array and returns an iterator to the new current + item. + + Calling this function on JsonArray::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn JsonArray::const_iterator JsonArray::const_iterator::operator++(int) + + \overload + + The postfix ++ operator, \c{it++}, advances the iterator to the + next item in the array and returns an iterator to the previously + current item. +*/ + +/*! \fn JsonArray::const_iterator &JsonArray::const_iterator::operator--() + + The prefix -- operator, \c{--it}, makes the preceding item + current and returns an iterator to the new current item. + + Calling this function on JsonArray::begin() leads to undefined results. + + \sa operator++() +*/ + +/*! \fn JsonArray::const_iterator JsonArray::const_iterator::operator--(int) + + \overload + + The postfix -- operator, \c{it--}, makes the preceding item + current and returns an iterator to the previously current item. +*/ + +/*! \fn JsonArray::const_iterator &JsonArray::const_iterator::operator+=(int j) + + Advances the iterator by \a j items. If \a j is negative, the + iterator goes backward. + + \sa operator-=(), operator+() +*/ + +/*! \fn JsonArray::const_iterator &JsonArray::const_iterator::operator-=(int j) + + Makes the iterator go back by \a j items. If \a j is negative, + the iterator goes forward. + + \sa operator+=(), operator-() +*/ + +/*! \fn JsonArray::const_iterator JsonArray::const_iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. If \a j is negative, the iterator goes backward. + + \sa operator-(), operator+=() +*/ + +/*! \fn JsonArray::const_iterator JsonArray::const_iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. If \a j is negative, the iterator goes forward. + + \sa operator+(), operator-=() +*/ + +/*! \fn int JsonArray::const_iterator::operator-(const_iterator other) const + + Returns the number of items between the item pointed to by \a + other and the item pointed to by this iterator. +*/ + + +/*! + \internal + */ +void JsonArray::detach(uint32_t reserve) +{ + if (!d) { + d = new Internal::Data(reserve, JsonValue::Array); + a = static_cast(d->header->root()); + d->ref.ref(); + return; + } + if (reserve == 0 && d->ref.load() == 1) + return; + + Internal::Data *x = d->clone(a, reserve); + x->ref.ref(); + if (!d->ref.deref()) + delete d; + d = x; + a = static_cast(d->header->root()); +} + +/*! + \internal + */ +void JsonArray::compact() +{ + if (!d || !d->compactionCounter) + return; + + detach(); + d->compact(); + a = static_cast(d->header->root()); +} + +/*! + \class JsonObject + \inmodule QtCore + \ingroup json + \ingroup shared + \reentrant + \since 5.0 + + \brief The JsonObject class encapsulates a JSON object. + + A JSON object is a list of key value pairs, where the keys are unique strings + and the values are represented by a JsonValue. + + A JsonObject can be converted to and from a QVariantMap. You can query the + number of (key, value) pairs with size(), insert(), and remove() entries from it + and iterate over its content using the standard C++ iterator pattern. + + JsonObject is an implicitly shared class, and shares the data with the document + it has been created from as long as it is not being modified. + + You can convert the object to and from text based JSON through JsonDocument. + + \sa {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! + \typedef JsonObject::Iterator + + Qt-style synonym for JsonObject::iterator. +*/ + +/*! + \typedef JsonObject::ConstIterator + + Qt-style synonym for JsonObject::const_iterator. +*/ + +/*! + \typedef JsonObject::key_type + + Typedef for QString. Provided for STL compatibility. +*/ + +/*! + \typedef JsonObject::mapped_type + + Typedef for JsonValue. Provided for STL compatibility. +*/ + +/*! + \typedef JsonObject::size_type + + Typedef for int. Provided for STL compatibility. +*/ + + +/*! + Constructs an empty JSON object. + + \sa isEmpty() + */ +JsonObject::JsonObject() + : d(nullptr), o(nullptr) +{ +} + +JsonObject::JsonObject(std::initializer_list > args) + : d(nullptr), o(nullptr) +{ + for (const auto &arg : args) + insert(arg.first, arg.second); +} + +/*! + \fn JsonObject::JsonObject(std::initializer_list > args) + \since 5.4 + Constructs a JsonObject instance initialized from \a args initialization list. + For example: + \code + JsonObject object + { + {"property1", 1}, + {"property2", 2} + }; + \endcode +*/ + +/*! + \internal + */ +JsonObject::JsonObject(Internal::Data *data, Internal::Object *object) + : d(data), o(object) +{ + // assert(d); + // assert(o); + d->ref.ref(); +} + +/*! + This method replaces part of the JsonObject(std::initializer_list> args) body. + The constructor needs to be inline, but we do not want to leak implementation details + of this class. + \note this method is called for an uninitialized object + \internal + */ + +/*! + Destroys the object. + */ +JsonObject::~JsonObject() +{ + if (d && !d->ref.deref()) + delete d; +} + +/*! + Creates a copy of \a other. + + Since JsonObject is implicitly shared, the copy is shallow + as long as the object does not get modified. + */ +JsonObject::JsonObject(const JsonObject &other) +{ + d = other.d; + o = other.o; + if (d) + d->ref.ref(); +} + +/*! + Assigns \a other to this object. + */ +JsonObject &JsonObject::operator=(const JsonObject &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + if (d != other.d) { + if (d && !d->ref.deref()) + delete d; + d = other.d; + if (d) + d->ref.ref(); + } + o = other.o; + + return *this; +} + +/*! + Returns a list of all keys in this object. + + The list is sorted lexographically. + */ +JsonObject::Keys JsonObject::keys() const +{ + Keys keys; + if (!d) + return keys; + + keys.reserve(o->length); + for (uint32_t i = 0; i < o->length; ++i) { + Internal::Entry *e = o->entryAt(i); + keys.push_back(e->key().data()); + } + + return keys; +} + +/*! + Returns the number of (key, value) pairs stored in the object. + */ +int JsonObject::size() const +{ + if (!d) + return 0; + + return o->length; +} + +/*! + Returns \c true if the object is empty. This is the same as size() == 0. + + \sa size() + */ +bool JsonObject::isEmpty() const +{ + if (!d) + return true; + + return !o->length; +} + +/*! + Returns a JsonValue representing the value for the key \a key. + + The returned JsonValue is JsonValue::Undefined if the key does not exist. + + \sa JsonValue, JsonValue::isUndefined() + */ +JsonValue JsonObject::value(const std::string &key) const +{ + if (!d) + return {JsonValue::Undefined}; + + bool keyExists; + int i = o->indexOf(key, &keyExists); + if (!keyExists) + return {JsonValue::Undefined}; + return {d, o, o->entryAt(i)->value}; +} + +/*! + Returns a JsonValue representing the value for the key \a key. + + This does the same as value(). + + The returned JsonValue is JsonValue::Undefined if the key does not exist. + + \sa value(), JsonValue, JsonValue::isUndefined() + */ +JsonValue JsonObject::operator[](const std::string &key) const +{ + return value(key); +} + +/*! + Returns a reference to the value for \a key. + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the element in the JsonArray or JsonObject + from which you got the reference. + + \sa value() + */ +JsonValueRef JsonObject::operator[](const std::string &key) +{ + // ### somewhat inefficient, as we lookup the key twice if it doesn't yet exist + bool keyExists = false; + int index = o ? o->indexOf(key, &keyExists) : -1; + if (!keyExists) { + iterator i = insert(key, JsonValue()); + index = i.i; + } + return {this, index}; +} + +/*! + Inserts a new item with the key \a key and a value of \a value. + + If there is already an item with the key \a key, then that item's value + is replaced with \a value. + + Returns an iterator pointing to the inserted item. + + If the value is JsonValue::Undefined, it will cause the key to get removed + from the object. The returned iterator will then point to end(). + + \sa remove(), take(), JsonObject::iterator, end() + */ +JsonObject::iterator JsonObject::insert(const std::string &key, const JsonValue &value) +{ + if (value.t == JsonValue::Undefined) { + remove(key); + return end(); + } + JsonValue val = value; + + bool isIntValue; + int valueSize = Internal::Value::requiredStorage(val, &isIntValue); + + int valueOffset = sizeof(Internal::Entry) + Internal::qStringSize(key); + int requiredSize = valueOffset + valueSize; + + detach(requiredSize + sizeof(Internal::offset)); // offset for the new index entry + + if (!o->length) + o->tableOffset = sizeof(Internal::Object); + + bool keyExists = false; + int pos = o->indexOf(key, &keyExists); + if (keyExists) + ++d->compactionCounter; + + uint32_t off = o->reserveSpace(requiredSize, pos, 1, keyExists); + if (!off) + return end(); + + Internal::Entry *e = o->entryAt(pos); + e->value.type = val.t; + e->value.intValue = isIntValue; + e->value.value = Internal::Value::valueToStore(val, static_cast((char *)e - (char *)o) + + valueOffset); + Internal::copyString((char *)(e + 1), key); + if (valueSize) + Internal::Value::copyData(val, (char *)e + valueOffset, isIntValue); + + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u) + compact(); + + return {this, pos}; +} + +/*! + Removes \a key from the object. + + \sa insert(), take() + */ +void JsonObject::remove(const std::string &key) +{ + if (!d) + return; + + bool keyExists; + int index = o->indexOf(key, &keyExists); + if (!keyExists) + return; + + detach(); + o->removeItems(index, 1); + ++d->compactionCounter; + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u) + compact(); +} + +/*! + Removes \a key from the object. + + Returns a JsonValue containing the value referenced by \a key. + If \a key was not contained in the object, the returned JsonValue + is JsonValue::Undefined. + + \sa insert(), remove(), JsonValue + */ +JsonValue JsonObject::take(const std::string &key) +{ + if (!o) + return {JsonValue::Undefined}; + + bool keyExists; + int index = o->indexOf(key, &keyExists); + if (!keyExists) + return {JsonValue::Undefined}; + + JsonValue v(d, o, o->entryAt(index)->value); + detach(); + o->removeItems(index, 1); + ++d->compactionCounter; + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u) + compact(); + + return v; +} + +/*! + Returns \c true if the object contains key \a key. + + \sa insert(), remove(), take() + */ +bool JsonObject::contains(const std::string &key) const +{ + if (!o) + return false; + + bool keyExists; + o->indexOf(key, &keyExists); + return keyExists; +} + +/*! + Returns \c true if \a other is equal to this object. + */ +bool JsonObject::operator==(const JsonObject &other) const +{ + if (o == other.o) + return true; + + if (!o) + return !other.o->length; + if (!other.o) + return !o->length; + if (o->length != other.o->length) + return false; + + for (uint32_t i = 0; i < o->length; ++i) { + Internal::Entry *e = o->entryAt(i); + JsonValue v(d, o, e->value); + if (other.value(e->key()) != v) + return false; + } + + return true; +} + +/*! + Returns \c true if \a other is not equal to this object. + */ +bool JsonObject::operator!=(const JsonObject &other) const +{ + return !(*this == other); +} + +/*! + Removes the (key, value) pair pointed to by the iterator \a it + from the map, and returns an iterator to the next item in the + map. + + \sa remove() + */ +JsonObject::iterator JsonObject::erase(JsonObject::iterator it) +{ + // assert(d && d->ref.load() == 1); + if (it.o != this || it.i < 0 || it.i >= (int)o->length) + return {this, int(o->length)}; + + int index = it.i; + + o->removeItems(index, 1); + ++d->compactionCounter; + if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u) + compact(); + + // iterator hasn't changed + return it; +} + +/*! + Returns an iterator pointing to the item with key \a key in the + map. + + If the map contains no item with key \a key, the function + returns end(). + */ +JsonObject::iterator JsonObject::find(const std::string &key) +{ + bool keyExists = false; + int index = o ? o->indexOf(key, &keyExists) : 0; + if (!keyExists) + return end(); + detach(); + return {this, index}; +} + +/*! \fn JsonObject::const_iterator JsonObject::find(const QString &key) const + + \overload +*/ + +/*! + Returns a const iterator pointing to the item with key \a key in the + map. + + If the map contains no item with key \a key, the function + returns constEnd(). + */ +JsonObject::const_iterator JsonObject::constFind(const std::string &key) const +{ + bool keyExists = false; + int index = o ? o->indexOf(key, &keyExists) : 0; + if (!keyExists) + return end(); + return {this, index}; +} + +/*! \fn int JsonObject::count() const + + \overload + + Same as size(). +*/ + +/*! \fn int JsonObject::length() const + + \overload + + Same as size(). +*/ + +/*! \fn JsonObject::iterator JsonObject::begin() + + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in + the object. + + \sa constBegin(), end() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::begin() const + + \overload +*/ + +/*! \fn JsonObject::const_iterator JsonObject::constBegin() const + + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item + in the object. + + \sa begin(), constEnd() +*/ + +/*! \fn JsonObject::iterator JsonObject::end() + + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item + after the last item in the object. + + \sa begin(), constEnd() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::end() const + + \overload +*/ + +/*! \fn JsonObject::const_iterator JsonObject::constEnd() const + + Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary + item after the last item in the object. + + \sa constBegin(), end() +*/ + +/*! + \fn bool JsonObject::empty() const + + This function is provided for STL compatibility. It is equivalent + to isEmpty(), returning \c true if the object is empty; otherwise + returning \c false. +*/ + +/*! \class JsonObject::iterator + \inmodule QtCore + \ingroup json + \reentrant + \since 5.0 + + \brief The JsonObject::iterator class provides an STL-style non-const iterator for JsonObject. + + JsonObject::iterator allows you to iterate over a JsonObject + and to modify the value (but not the key) stored under + a particular key. If you want to iterate over a const JsonObject, you + should use JsonObject::const_iterator. It is generally good practice to + use JsonObject::const_iterator on a non-const JsonObject as well, unless you + need to change the JsonObject through the iterator. Const iterators are + slightly faster, and improve code readability. + + The default JsonObject::iterator constructor creates an uninitialized + iterator. You must initialize it using a JsonObject function like + JsonObject::begin(), JsonObject::end(), or JsonObject::find() before you can + start iterating. + + Multiple iterators can be used on the same object. Existing iterators will however + become dangling once the object gets modified. + + \sa JsonObject::const_iterator, {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! \typedef JsonObject::iterator::difference_type + + \internal +*/ + +/*! \typedef JsonObject::iterator::iterator_category + + A synonym for \e {std::bidirectional_iterator_tag} indicating + this iterator is a bidirectional iterator. +*/ + +/*! \typedef JsonObject::iterator::reference + + \internal +*/ + +/*! \typedef JsonObject::iterator::value_type + + \internal +*/ + +/*! \fn JsonObject::iterator::iterator() + + Constructs an uninitialized iterator. + + Functions like key(), value(), and operator++() must not be + called on an uninitialized iterator. Use operator=() to assign a + value to it before using it. + + \sa JsonObject::begin(), JsonObject::end() +*/ + +/*! \fn JsonObject::iterator::iterator(JsonObject *obj, int index) + \internal +*/ + +/*! \fn QString JsonObject::iterator::key() const + + Returns the current item's key. + + There is no direct way of changing an item's key through an + iterator, although it can be done by calling JsonObject::erase() + followed by JsonObject::insert(). + + \sa value() +*/ + +/*! \fn JsonValueRef JsonObject::iterator::value() const + + Returns a modifiable reference to the current item's value. + + You can change the value of an item by using value() on + the left side of an assignment. + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the element in the JsonArray or JsonObject + from which you got the reference. + + \sa key(), operator*() +*/ + +/*! \fn JsonValueRef JsonObject::iterator::operator*() const + + Returns a modifiable reference to the current item's value. + + Same as value(). + + The return value is of type JsonValueRef, a helper class for JsonArray + and JsonObject. When you get an object of type JsonValueRef, you can + use it as if it were a reference to a JsonValue. If you assign to it, + the assignment will apply to the element in the JsonArray or JsonObject + from which you got the reference. + + \sa key() +*/ + +/*! \fn JsonValueRef *JsonObject::iterator::operator->() const + + Returns a pointer to a modifiable reference to the current item. +*/ + +/*! + \fn bool JsonObject::iterator::operator==(const iterator &other) const + \fn bool JsonObject::iterator::operator==(const const_iterator &other) const + + Returns \c true if \a other points to the same item as this + iterator; otherwise returns \c false. + + \sa operator!=() +*/ + +/*! + \fn bool JsonObject::iterator::operator!=(const iterator &other) const + \fn bool JsonObject::iterator::operator!=(const const_iterator &other) const + + Returns \c true if \a other points to a different item than this + iterator; otherwise returns \c false. + + \sa operator==() +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator++() + + The prefix ++ operator, \c{++i}, advances the iterator to the + next item in the object and returns an iterator to the new current + item. + + Calling this function on JsonObject::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator++(int) + + \overload + + The postfix ++ operator, \c{i++}, advances the iterator to the + next item in the object and returns an iterator to the previously + current item. +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator--() + + The prefix -- operator, \c{--i}, makes the preceding item + current and returns an iterator pointing to the new current item. + + Calling this function on JsonObject::begin() leads to undefined + results. + + \sa operator++() +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator--(int) + + \overload + + The postfix -- operator, \c{i--}, makes the preceding item + current and returns an iterator pointing to the previously + current item. +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. If \a j is negative, the iterator goes backward. + + \sa operator-() + +*/ + +/*! \fn JsonObject::iterator JsonObject::iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. If \a j is negative, the iterator goes forward. + + \sa operator+() +*/ + +/*! \fn JsonObject::iterator &JsonObject::iterator::operator+=(int j) + + Advances the iterator by \a j items. If \a j is negative, the + iterator goes backward. + + \sa operator-=(), operator+() +*/ + +/*! \fn JsonObject::iterator &JsonObject::iterator::operator-=(int j) + + Makes the iterator go back by \a j items. If \a j is negative, + the iterator goes forward. + + \sa operator+=(), operator-() +*/ + +/*! + \class JsonObject::const_iterator + \inmodule QtCore + \ingroup json + \since 5.0 + \brief The JsonObject::const_iterator class provides an STL-style const iterator for JsonObject. + + JsonObject::const_iterator allows you to iterate over a JsonObject. + If you want to modify the JsonObject as you iterate + over it, you must use JsonObject::iterator instead. It is generally + good practice to use JsonObject::const_iterator on a non-const JsonObject as + well, unless you need to change the JsonObject through the iterator. + Const iterators are slightly faster and improve code + readability. + + The default JsonObject::const_iterator constructor creates an + uninitialized iterator. You must initialize it using a JsonObject + function like JsonObject::constBegin(), JsonObject::constEnd(), or + JsonObject::find() before you can start iterating. + + Multiple iterators can be used on the same object. Existing iterators + will however become dangling if the object gets modified. + + \sa JsonObject::iterator, {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! \typedef JsonObject::const_iterator::difference_type + + \internal +*/ + +/*! \typedef JsonObject::const_iterator::iterator_category + + A synonym for \e {std::bidirectional_iterator_tag} indicating + this iterator is a bidirectional iterator. +*/ + +/*! \typedef JsonObject::const_iterator::reference + + \internal +*/ + +/*! \typedef JsonObject::const_iterator::value_type + + \internal +*/ + +/*! \fn JsonObject::const_iterator::const_iterator() + + Constructs an uninitialized iterator. + + Functions like key(), value(), and operator++() must not be + called on an uninitialized iterator. Use operator=() to assign a + value to it before using it. + + \sa JsonObject::constBegin(), JsonObject::constEnd() +*/ + +/*! \fn JsonObject::const_iterator::const_iterator(const JsonObject *obj, int index) + \internal +*/ + +/*! \fn JsonObject::const_iterator::const_iterator(const iterator &other) + + Constructs a copy of \a other. +*/ + +/*! \fn QString JsonObject::const_iterator::key() const + + Returns the current item's key. + + \sa value() +*/ + +/*! \fn JsonValue JsonObject::const_iterator::value() const + + Returns the current item's value. + + \sa key(), operator*() +*/ + +/*! \fn JsonValue JsonObject::const_iterator::operator*() const + + Returns the current item's value. + + Same as value(). + + \sa key() +*/ + +/*! \fn JsonValue *JsonObject::const_iterator::operator->() const + + Returns a pointer to the current item. +*/ + +/*! \fn bool JsonObject::const_iterator::operator==(const const_iterator &other) const + \fn bool JsonObject::const_iterator::operator==(const iterator &other) const + + Returns \c true if \a other points to the same item as this + iterator; otherwise returns \c false. + + \sa operator!=() +*/ + +/*! \fn bool JsonObject::const_iterator::operator!=(const const_iterator &other) const + \fn bool JsonObject::const_iterator::operator!=(const iterator &other) const + + Returns \c true if \a other points to a different item than this + iterator; otherwise returns \c false. + + \sa operator==() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::const_iterator::operator++() + + The prefix ++ operator, \c{++i}, advances the iterator to the + next item in the object and returns an iterator to the new current + item. + + Calling this function on JsonObject::end() leads to undefined results. + + \sa operator--() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::const_iterator::operator++(int) + + \overload + + The postfix ++ operator, \c{i++}, advances the iterator to the + next item in the object and returns an iterator to the previously + current item. +*/ + +/*! \fn JsonObject::const_iterator &JsonObject::const_iterator::operator--() + + The prefix -- operator, \c{--i}, makes the preceding item + current and returns an iterator pointing to the new current item. + + Calling this function on JsonObject::begin() leads to undefined + results. + + \sa operator++() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::const_iterator::operator--(int) + + \overload + + The postfix -- operator, \c{i--}, makes the preceding item + current and returns an iterator pointing to the previously + current item. +*/ + +/*! \fn JsonObject::const_iterator JsonObject::const_iterator::operator+(int j) const + + Returns an iterator to the item at \a j positions forward from + this iterator. If \a j is negative, the iterator goes backward. + + This operation can be slow for large \a j values. + + \sa operator-() +*/ + +/*! \fn JsonObject::const_iterator JsonObject::const_iterator::operator-(int j) const + + Returns an iterator to the item at \a j positions backward from + this iterator. If \a j is negative, the iterator goes forward. + + This operation can be slow for large \a j values. + + \sa operator+() +*/ + +/*! \fn JsonObject::const_iterator &JsonObject::const_iterator::operator+=(int j) + + Advances the iterator by \a j items. If \a j is negative, the + iterator goes backward. + + This operation can be slow for large \a j values. + + \sa operator-=(), operator+() +*/ + +/*! \fn JsonObject::const_iterator &JsonObject::const_iterator::operator-=(int j) + + Makes the iterator go back by \a j items. If \a j is negative, + the iterator goes forward. + + This operation can be slow for large \a j values. + + \sa operator+=(), operator-() +*/ + + +/*! + \internal + */ +void JsonObject::detach(uint32_t reserve) +{ + if (!d) { + d = new Internal::Data(reserve, JsonValue::Object); + o = static_cast(d->header->root()); + d->ref.ref(); + return; + } + if (reserve == 0 && d->ref.load() == 1) + return; + + Internal::Data *x = d->clone(o, reserve); + x->ref.ref(); + if (!d->ref.deref()) + delete d; + d = x; + o = static_cast(d->header->root()); +} + +/*! + \internal + */ +void JsonObject::compact() +{ + if (!d || !d->compactionCounter) + return; + + detach(); + d->compact(); + o = static_cast(d->header->root()); +} + +/*! + \internal + */ +std::string JsonObject::keyAt(int i) const +{ + // assert(o && i >= 0 && i < (int)o->length); + + Internal::Entry *e = o->entryAt(i); + return e->key(); +} + +/*! + \internal + */ +JsonValue JsonObject::valueAt(int i) const +{ + if (!o || i < 0 || i >= (int)o->length) + return {JsonValue::Undefined}; + + Internal::Entry *e = o->entryAt(i); + return {d, o, e->value}; +} + +/*! + \internal + */ +void JsonObject::setValueAt(int i, const JsonValue &val) +{ + // assert(o && i >= 0 && i < (int)o->length); + + Internal::Entry *e = o->entryAt(i); + insert(e->key(), val); +} + + +/*! \class JsonDocument + \inmodule QtCore + \ingroup json + \ingroup shared + \reentrant + \since 5.0 + + \brief The JsonDocument class provides a way to read and write JSON documents. + + JsonDocument is a class that wraps a complete JSON document and can read and + write this document both from a UTF-8 encoded text based representation as well + as Qt's own binary format. + + A JSON document can be converted from its text-based representation to a JsonDocument + using JsonDocument::fromJson(). toJson() converts it back to text. The parser is very + fast and efficient and converts the JSON to the binary representation used by Qt. + + Validity of the parsed document can be queried with !isNull() + + A document can be queried as to whether it contains an array or an object using isArray() + and isObject(). The array or object contained in the document can be retrieved using + array() or object() and then read or manipulated. + + A document can also be created from a stored binary representation using fromBinaryData() or + fromRawData(). + + \sa {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! + * Constructs an empty and invalid document. + */ +JsonDocument::JsonDocument() + : d(nullptr) +{ +} + +/*! + * Creates a JsonDocument from \a object. + */ +JsonDocument::JsonDocument(const JsonObject &object) + : d(nullptr) +{ + setObject(object); +} + +/*! + * Constructs a JsonDocument from \a array. + */ +JsonDocument::JsonDocument(const JsonArray &array) + : d(nullptr) +{ + setArray(array); +} + +/*! + \internal + */ +JsonDocument::JsonDocument(Internal::Data *data) + : d(data) +{ + // assert(d); + d->ref.ref(); +} + +/*! + Deletes the document. + + Binary data set with fromRawData is not freed. + */ +JsonDocument::~JsonDocument() +{ + if (d && !d->ref.deref()) + delete d; +} + +/*! + * Creates a copy of the \a other document. + */ +JsonDocument::JsonDocument(const JsonDocument &other) +{ + d = other.d; + if (d) + d->ref.ref(); +} + +/*! + * Assigns the \a other document to this JsonDocument. + * Returns a reference to this object. + */ +JsonDocument &JsonDocument::operator=(const JsonDocument &other) +{ + if (this == &other) // Self assignment guard. + return *this; + + if (d != other.d) { + if (d && !d->ref.deref()) + delete d; + d = other.d; + if (d) + d->ref.ref(); + } + + return *this; +} + +/*! \enum JsonDocument::DataValidation + + This value is used to tell JsonDocument whether to validate the binary data + when converting to a JsonDocument using fromBinaryData() or fromRawData(). + + \value Validate Validate the data before using it. This is the default. + \value BypassValidation Bypasses data validation. Only use if you received the + data from a trusted place and know it's valid, as using of invalid data can crash + the application. + */ + +/*! + Creates a JsonDocument that uses the first \a size bytes from + \a data. It assumes \a data contains a binary encoded JSON document. + The created document does not take ownership of \a data and the caller + has to guarantee that \a data will not be deleted or modified as long as + any JsonDocument, JsonObject or JsonArray still references the data. + + \a data has to be aligned to a 4 byte boundary. + + \a validation decides whether the data is checked for validity before being used. + By default the data is validated. If the \a data is not valid, the method returns + a null document. + + Returns a JsonDocument representing the data. + + \sa rawData(), fromBinaryData(), isNull(), DataValidation + */ +JsonDocument JsonDocument::fromRawData(const char *data, int size, DataValidation validation) +{ + if (std::uintptr_t(data) & 3) { + std::cerr <<"JsonDocument::fromRawData: data has to have 4 byte alignment\n"; + return {}; + } + + const auto d = new Internal::Data((char *)data, size); + d->ownsData = false; + + if (validation != BypassValidation && !d->valid()) { + delete d; + return {}; + } + + return {d}; +} + +/*! + Returns the raw binary representation of the data + \a size will contain the size of the returned data. + + This method is useful to e.g. stream the JSON document + in it's binary form to a file. + */ +const char *JsonDocument::rawData(int *size) const +{ + if (!d) { + *size = 0; + return nullptr; + } + *size = d->alloc; + return d->rawData; +} + +/*! + Creates a JsonDocument from \a data. + + \a validation decides whether the data is checked for validity before being used. + By default the data is validated. If the \a data is not valid, the method returns + a null document. + + \sa toBinaryData(), fromRawData(), isNull(), DataValidation + */ +JsonDocument JsonDocument::fromBinaryData(const std::string &data, DataValidation validation) +{ + if (data.size() < (int)(sizeof(Internal::Header) + sizeof(Internal::Base))) + return {}; + + Internal::Header h; + memcpy(&h, data.data(), sizeof(Internal::Header)); + Internal::Base root; + memcpy(&root, data.data() + sizeof(Internal::Header), sizeof(Internal::Base)); + + // do basic checks here, so we don't try to allocate more memory than we can. + if (h.tag != JsonDocument::BinaryFormatTag || h.version != 1u || + sizeof(Internal::Header) + root.size > (uint32_t)data.size()) + return {}; + + const uint32_t size = sizeof(Internal::Header) + root.size; + char *raw = (char *)malloc(size); + if (!raw) + return {}; + + memcpy(raw, data.data(), size); + const auto d = new Internal::Data(raw, size); + + if (validation != BypassValidation && !d->valid()) { + delete d; + return {}; + } + + return {d}; +} + +/*! + \enum JsonDocument::JsonFormat + + This value defines the format of the JSON byte array produced + when converting to a JsonDocument using toJson(). + + \value Indented Defines human readable output as follows: + \code + { + "Array": [ + true, + 999, + "string" + ], + "Key": "Value", + "null": null + } + \endcode + + \value Compact Defines a compact output as follows: + \code + {"Array":[true,999,"string"],"Key":"Value","null":null} + \endcode + */ + +/*! + Converts the JsonDocument to a UTF-8 encoded JSON document in the provided \a format. + + \sa fromJson(), JsonFormat + */ +#ifndef QT_JSON_READONLY +std::string JsonDocument::toJson(JsonFormat format) const +{ + std::string json; + + if (!d) + return json; + + if (d->header->root()->isArray()) + Internal::arrayToJson(static_cast(d->header->root()), json, 0, (format == Compact)); + else + Internal::objectToJson(static_cast(d->header->root()), json, 0, (format == Compact)); + + return json; +} +#endif + +/*! + Parses a UTF-8 encoded JSON document and creates a JsonDocument + from it. + + \a json contains the json document to be parsed. + + The optional \a error variable can be used to pass in a JsonParseError data + structure that will contain information about possible errors encountered during + parsing. + + \sa toJson(), JsonParseError + */ +JsonDocument JsonDocument::fromJson(const std::string &json, JsonParseError *error) +{ + Internal::Parser parser(json.data(), static_cast(json.length())); + return parser.parse(error); +} + +/*! + Returns \c true if the document doesn't contain any data. + */ +bool JsonDocument::isEmpty() const +{ + if (!d) + return true; + + return false; +} + +/*! + Returns a binary representation of the document. + + The binary representation is also the native format used internally in Qt, + and is very efficient and fast to convert to and from. + + The binary format can be stored on disk and interchanged with other applications + or computers. fromBinaryData() can be used to convert it back into a + JSON document. + + \sa fromBinaryData() + */ +std::string JsonDocument::toBinaryData() const +{ + if (!d || !d->rawData) + return std::string(); + + return std::string(d->rawData, d->header->root()->size + sizeof(Internal::Header)); +} + +/*! + Returns \c true if the document contains an array. + + \sa array(), isObject() + */ +bool JsonDocument::isArray() const +{ + if (!d) + return false; + + const auto h = (Internal::Header *)d->rawData; + return h->root()->isArray(); +} + +/*! + Returns \c true if the document contains an object. + + \sa object(), isArray() + */ +bool JsonDocument::isObject() const +{ + if (!d) + return false; + + const auto h = (Internal::Header *)d->rawData; + return h->root()->isObject(); +} + +/*! + Returns the JsonObject contained in the document. + + Returns an empty object if the document contains an + array. + + \sa isObject(), array(), setObject() + */ +JsonObject JsonDocument::object() const +{ + if (d) { + Internal::Base *b = d->header->root(); + if (b->isObject()) + return JsonObject(d, static_cast(b)); + } + return {}; +} + +/*! + Returns the JsonArray contained in the document. + + Returns an empty array if the document contains an + object. + + \sa isArray(), object(), setArray() + */ +JsonArray JsonDocument::array() const +{ + if (d) { + Internal::Base *b = d->header->root(); + if (b->isArray()) + return JsonArray(d, static_cast(b)); + } + return {}; +} + +/*! + Sets \a object as the main object of this document. + + \sa setArray(), object() + */ +void JsonDocument::setObject(const JsonObject &object) +{ + if (d && !d->ref.deref()) + delete d; + + d = object.d; + + if (!d) { + d = new Internal::Data(0, JsonValue::Object); + } else if (d->compactionCounter || object.o != d->header->root()) { + JsonObject o(object); + if (d->compactionCounter) + o.compact(); + else + o.detach(); + d = o.d; + d->ref.ref(); + return; + } + d->ref.ref(); +} + +/*! + Sets \a array as the main object of this document. + + \sa setObject(), array() + */ +void JsonDocument::setArray(const JsonArray &array) +{ + if (d && !d->ref.deref()) + delete d; + + d = array.d; + + if (!d) { + d = new Internal::Data(0, JsonValue::Array); + } else if (d->compactionCounter || array.a != d->header->root()) { + JsonArray a(array); + if (d->compactionCounter) + a.compact(); + else + a.detach(); + d = a.d; + d->ref.ref(); + return; + } + d->ref.ref(); +} + +/*! + Returns \c true if the \a other document is equal to this document. + */ +bool JsonDocument::operator==(const JsonDocument &other) const +{ + if (d == other.d) + return true; + + if (!d || !other.d) + return false; + + if (d->header->root()->isArray() != other.d->header->root()->isArray()) + return false; + + if (d->header->root()->isObject()) + return JsonObject(d, static_cast(d->header->root())) + == JsonObject(other.d, static_cast(other.d->header->root())); + return JsonArray(d, static_cast(d->header->root())) + == JsonArray(other.d, static_cast(other.d->header->root())); +} + +/*! + \fn bool JsonDocument::operator!=(const JsonDocument &other) const + + returns \c true if \a other is not equal to this document + */ + +/*! + returns \c true if this document is null. + + Null documents are documents created through the default constructor. + + Documents created from UTF-8 encoded text or the binary format are + validated during parsing. If validation fails, the returned document + will also be null. + */ +bool JsonDocument::isNull() const +{ + return (d == nullptr); +} + + +static void objectContentToJson(const Object *o, std::string &json, int indent, bool compact); +static void arrayContentToJson(const Array *a, std::string &json, int indent, bool compact); + +static uint8_t hexdig(uint32_t u) +{ + return (u < 0xa ? '0' + u : 'a' + u - 0xa); +} + +static std::string escapedString(const std::string &in) +{ + std::string ba; + ba.reserve(in.length()); + + auto src = in.begin(); + auto end = in.end(); + + while (src != end) { + uint8_t u = (*src++); + if (u < 0x20 || u == 0x22 || u == 0x5c) { + ba.push_back('\\'); + switch (u) { + case 0x22: + ba.push_back('"'); + break; + case 0x5c: + ba.push_back('\\'); + break; + case 0x8: + ba.push_back('b'); + break; + case 0xc: + ba.push_back('f'); + break; + case 0xa: + ba.push_back('n'); + break; + case 0xd: + ba.push_back('r'); + break; + case 0x9: + ba.push_back('t'); + break; + default: + ba.push_back('u'); + ba.push_back('0'); + ba.push_back('0'); + ba.push_back(hexdig(u>>4)); + ba.push_back(hexdig(u & 0xf)); + } + } else { + ba.push_back(u); + } + } + + return ba; +} + +static void valueToJson(const Base *b, const Value &v, std::string &json, int indent, bool compact) +{ + const auto type = (JsonValue::Type)(uint32_t)v.type; + switch (type) { + case JsonValue::Bool: + json += v.toBoolean() ? "true" : "false"; + break; + case JsonValue::Double: { + const double d = v.toDouble(b); + if (std::isfinite(d)) { + // +2 to format to ensure the expected precision + const int n = std::numeric_limits::digits10 + 2; + char buf[30] = {0}; + std::sprintf(buf, "%.*g", n, d); + // Hack: + if (buf[0] == '-' && buf[1] == '0' && buf[2] == '\0') + json += "0"; + else + json += buf; + } else { + json += "null"; // +INF || -INF || NaN (see RFC4627#section2.4) + } + break; + } + case JsonValue::String: + json += '"'; + json += escapedString(v.toString(b)); + json += '"'; + break; + case JsonValue::Array: + json += compact ? "[" : "[\n"; + arrayContentToJson(static_cast(v.base(b)), json, indent + (compact ? 0 : 1), compact); + json += std::string(4*indent, ' '); + json += ']'; + break; + case JsonValue::Object: + json += compact ? "{" : "{\n"; + objectContentToJson(static_cast(v.base(b)), json, indent + (compact ? 0 : 1), compact); + json += std::string(4*indent, ' '); + json += '}'; + break; + case JsonValue::Null: + default: + json += "null"; + } +} + +static void arrayContentToJson(const Array *a, std::string &json, int indent, bool compact) +{ + if (!a || !a->length) + return; + + std::string indentString(4*indent, ' '); + + uint32_t i = 0; + while (1) { + json += indentString; + valueToJson(a, a->at(i), json, indent, compact); + + if (++i == a->length) { + if (!compact) + json += '\n'; + break; + } + + json += compact ? "," : ",\n"; + } +} + +static void objectContentToJson(const Object *o, std::string &json, int indent, bool compact) +{ + if (!o || !o->length) + return; + + std::string indentString(4*indent, ' '); + + uint32_t i = 0; + while (1) { + Entry *e = o->entryAt(i); + json += indentString; + json += '"'; + json += escapedString(e->key()); + json += compact ? "\":" : "\": "; + valueToJson(o, e->value, json, indent, compact); + + if (++i == o->length) { + if (!compact) + json += '\n'; + break; + } + + json += compact ? "," : ",\n"; + } +} + +namespace Internal { + +void objectToJson(const Object *o, std::string &json, int indent, bool compact) +{ + json.reserve(json.size() + (o ? (int)o->size : 16)); + json += compact ? "{" : "{\n"; + objectContentToJson(o, json, indent + (compact ? 0 : 1), compact); + json += std::string(4*indent, ' '); + json += compact ? "}" : "}\n"; +} + +void arrayToJson(const Array *a, std::string &json, int indent, bool compact) +{ + json.reserve(json.size() + (a ? (int)a->size : 16)); + json += compact ? "[" : "[\n"; + arrayContentToJson(a, json, indent + (compact ? 0 : 1), compact); + json += std::string(4*indent, ' '); + json += compact ? "]" : "]\n"; +} + +} + + + +/*! + \class JsonParseError + \inmodule QtCore + \ingroup json + \ingroup shared + \reentrant + \since 5.0 + + \brief The JsonParseError class is used to report errors during JSON parsing. + + \sa {JSON Support in Qt}, {JSON Save Game Example} +*/ + +/*! + \enum JsonParseError::ParseError + + This enum describes the type of error that occurred during the parsing of a JSON document. + + \value NoError No error occurred + \value UnterminatedObject An object is not correctly terminated with a closing curly bracket + \value MissingNameSeparator A comma separating different items is missing + \value UnterminatedArray The array is not correctly terminated with a closing square bracket + \value MissingValueSeparator A colon separating keys from values inside objects is missing + \value IllegalValue The value is illegal + \value TerminationByNumber The input stream ended while parsing a number + \value IllegalNumber The number is not well formed + \value IllegalEscapeSequence An illegal escape sequence occurred in the input + \value IllegalUTF8String An illegal UTF8 sequence occurred in the input + \value UnterminatedString A string wasn't terminated with a quote + \value MissingObject An object was expected but couldn't be found + \value DeepNesting The JSON document is too deeply nested for the parser to parse it + \value DocumentTooLarge The JSON document is too large for the parser to parse it + \value GarbageAtEnd The parsed document contains additional garbage characters at the end + +*/ + +/*! + \variable JsonParseError::error + + Contains the type of the parse error. Is equal to JsonParseError::NoError if the document + was parsed correctly. + + \sa ParseError, errorString() +*/ + + +/*! + \variable JsonParseError::offset + + Contains the offset in the input string where the parse error occurred. + + \sa error, errorString() +*/ + +using namespace Internal; + +Parser::Parser(const char *json, int length) + : head(json), json(json), data(nullptr), dataLength(0), current(0), nestingLevel(0), lastError(JsonParseError::NoError) +{ + end = json + length; +} + + + +/* + +begin-array = ws %x5B ws ; [ left square bracket + +begin-object = ws %x7B ws ; { left curly bracket + +end-array = ws %x5D ws ; ] right square bracket + +end-object = ws %x7D ws ; } right curly bracket + +name-separator = ws %x3A ws ; : colon + +value-separator = ws %x2C ws ; , comma + +Insignificant whitespace is allowed before or after any of the six +structural characters. + +ws = *( + %x20 / ; Space + %x09 / ; Horizontal tab + %x0A / ; Line feed or New line + %x0D ; Carriage return + ) + +*/ + +enum { + Space = 0x20, + Tab = 0x09, + LineFeed = 0x0a, + Return = 0x0d, + BeginArray = 0x5b, + BeginObject = 0x7b, + EndArray = 0x5d, + EndObject = 0x7d, + NameSeparator = 0x3a, + ValueSeparator = 0x2c, + Quote = 0x22 +}; + +void Parser::eatBOM() +{ + // eat UTF-8 byte order mark + if (end - json > 3 + && (unsigned char)json[0] == 0xef + && (unsigned char)json[1] == 0xbb + && (unsigned char)json[2] == 0xbf) + json += 3; +} + +bool Parser::eatSpace() +{ + while (json < end) { + if (*json > Space) + break; + if (*json != Space && + *json != Tab && + *json != LineFeed && + *json != Return) + break; + ++json; + } + return (json < end); +} + +char Parser::nextToken() +{ + if (!eatSpace()) + return 0; + char token = *json++; + switch (token) { + case BeginArray: + case BeginObject: + case NameSeparator: + case ValueSeparator: + case EndArray: + case EndObject: + eatSpace(); + case Quote: + break; + default: + token = 0; + break; + } + return token; +} + +/* + JSON-text = object / array +*/ +JsonDocument Parser::parse(JsonParseError *error) +{ +#ifdef PARSER_DEBUG + indent = 0; + std::cerr << ">>>>> parser begin"; +#endif + // allocate some space + dataLength = static_cast(std::max(end - json, std::ptrdiff_t(256))); + data = (char *)malloc(dataLength); + + // fill in Header data + const auto h = (Header *)data; + h->tag = JsonDocument::BinaryFormatTag; + h->version = 1u; + + current = sizeof(Header); + + eatBOM(); + char token = nextToken(); + + DEBUG << std::hex << (uint32_t)token; + if (token == BeginArray) { + if (!parseArray()) + goto error; + } else if (token == BeginObject) { + if (!parseObject()) + goto error; + } else { + lastError = JsonParseError::IllegalValue; + goto error; + } + + eatSpace(); + if (json < end) { + lastError = JsonParseError::GarbageAtEnd; + goto error; + } + + END; + { + if (error) { + error->offset = 0; + error->error = JsonParseError::NoError; + } + const auto d = new Data(data, current); + return {d}; + } + +error: +#ifdef PARSER_DEBUG + std::cerr << ">>>>> parser error"; +#endif + if (error) { + error->offset = static_cast(json - head); + error->error = lastError; + } + free(data); + return {}; +} + + +void Parser::ParsedObject::insert(uint32_t offset) +{ + const auto newEntry = reinterpret_cast(parser->data + objectPosition + offset); + size_t min = 0; + size_t n = offsets.size(); + while (n > 0) { + size_t half = n >> 1; + size_t middle = min + half; + if (*entryAt(middle) >= *newEntry) { + n = half; + } else { + min = middle + 1; + n -= half + 1; + } + } + if (min < offsets.size() && *entryAt(min) == *newEntry) { + offsets[min] = offset; + } else { + offsets.insert(offsets.begin() + min, offset); + } +} + +/* + object = begin-object [ member *( value-separator member ) ] + end-object +*/ + +bool Parser::parseObject() +{ + if (++nestingLevel > nestingLimit) { + lastError = JsonParseError::DeepNesting; + return false; + } + + int objectOffset = reserveSpace(sizeof(Object)); + BEGIN << "parseObject pos=" << objectOffset << current << json; + + ParsedObject parsedObject(this, objectOffset); + + char token = nextToken(); + while (token == Quote) { + int off = current - objectOffset; + if (!parseMember(objectOffset)) + return false; + parsedObject.insert(off); + token = nextToken(); + if (token != ValueSeparator) + break; + token = nextToken(); + if (token == EndObject) { + lastError = JsonParseError::MissingObject; + return false; + } + } + + DEBUG << "end token=" << token; + if (token != EndObject) { + lastError = JsonParseError::UnterminatedObject; + return false; + } + + DEBUG << "numEntries" << parsedObject.offsets.size(); + int table = objectOffset; + // finalize the object + if (!parsedObject.offsets.empty()) { + int tableSize = static_cast(parsedObject.offsets.size()) * sizeof(uint32_t); + table = reserveSpace(tableSize); + memcpy(data + table, &*parsedObject.offsets.begin(), tableSize); + } + + const auto o = (Object *)(data + objectOffset); + o->tableOffset = table - objectOffset; + o->size = current - objectOffset; + o->is_object = true; + o->length = static_cast(parsedObject.offsets.size()); + + DEBUG << "current=" << current; + END; + + --nestingLevel; + return true; +} + +/* + member = string name-separator value +*/ +bool Parser::parseMember(int baseOffset) +{ + int entryOffset = reserveSpace(sizeof(Entry)); + BEGIN << "parseMember pos=" << entryOffset; + + if (!parseString()) + return false; + char token = nextToken(); + if (token != NameSeparator) { + lastError = JsonParseError::MissingNameSeparator; + return false; + } + Value val; + if (!parseValue(&val, baseOffset)) + return false; + + // finalize the entry + const auto e = (Entry *)(data + entryOffset); + e->value = val; + + END; + return true; +} + +/* + array = begin-array [ value *( value-separator value ) ] end-array +*/ +bool Parser::parseArray() +{ + BEGIN << "parseArray"; + + if (++nestingLevel > nestingLimit) { + lastError = JsonParseError::DeepNesting; + return false; + } + + int arrayOffset = reserveSpace(sizeof(Array)); + + std::vector values; + values.reserve(64); + + if (!eatSpace()) { + lastError = JsonParseError::UnterminatedArray; + return false; + } + if (*json == EndArray) { + nextToken(); + } else { + while (1) { + Value val; + if (!parseValue(&val, arrayOffset)) + return false; + values.push_back(val); + char token = nextToken(); + if (token == EndArray) + break; + if (token != ValueSeparator) { + if (!eatSpace()) + lastError = JsonParseError::UnterminatedArray; + else + lastError = JsonParseError::MissingValueSeparator; + return false; + } + } + } + + DEBUG << "size =" << values.size(); + int table = arrayOffset; + // finalize the object + if (!values.empty()) { + int tableSize = static_cast(values.size() * sizeof(Value)); + table = reserveSpace(tableSize); + memcpy(data + table, values.data(), tableSize); + } + + const auto a = (Array *)(data + arrayOffset); + a->tableOffset = table - arrayOffset; + a->size = current - arrayOffset; + a->is_object = false; + a->length = static_cast(values.size()); + + DEBUG << "current=" << current; + END; + + --nestingLevel; + return true; +} + +/* +value = false / null / true / object / array / number / string + +*/ + +bool Parser::parseValue(Value *val, int baseOffset) +{ + BEGIN << "parse Value" << json; + val->_dummy = 0; + + switch (*json++) { + case 'n': + if (end - json < 4) { + lastError = JsonParseError::IllegalValue; + return false; + } + if (*json++ == 'u' && + *json++ == 'l' && + *json++ == 'l') { + val->type = JsonValue::Null; + DEBUG << "value: null"; + END; + return true; + } + lastError = JsonParseError::IllegalValue; + return false; + case 't': + if (end - json < 4) { + lastError = JsonParseError::IllegalValue; + return false; + } + if (*json++ == 'r' && + *json++ == 'u' && + *json++ == 'e') { + val->type = JsonValue::Bool; + val->value = true; + DEBUG << "value: true"; + END; + return true; + } + lastError = JsonParseError::IllegalValue; + return false; + case 'f': + if (end - json < 5) { + lastError = JsonParseError::IllegalValue; + return false; + } + if (*json++ == 'a' && + *json++ == 'l' && + *json++ == 's' && + *json++ == 'e') { + val->type = JsonValue::Bool; + val->value = false; + DEBUG << "value: false"; + END; + return true; + } + lastError = JsonParseError::IllegalValue; + return false; + case Quote: { + val->type = JsonValue::String; + if (current - baseOffset >= Value::MaxSize) { + lastError = JsonParseError::DocumentTooLarge; + return false; + } + val->value = current - baseOffset; + if (!parseString()) + return false; + val->intValue = false; + DEBUG << "value: string"; + END; + return true; + } + case BeginArray: + val->type = JsonValue::Array; + if (current - baseOffset >= Value::MaxSize) { + lastError = JsonParseError::DocumentTooLarge; + return false; + } + val->value = current - baseOffset; + if (!parseArray()) + return false; + DEBUG << "value: array"; + END; + return true; + case BeginObject: + val->type = JsonValue::Object; + if (current - baseOffset >= Value::MaxSize) { + lastError = JsonParseError::DocumentTooLarge; + return false; + } + val->value = current - baseOffset; + if (!parseObject()) + return false; + DEBUG << "value: object"; + END; + return true; + case EndArray: + lastError = JsonParseError::MissingObject; + return false; + default: + --json; + if (!parseNumber(val, baseOffset)) + return false; + DEBUG << "value: number"; + END; + } + + return true; +} + + + + + +/* + number = [ minus ] int [ frac ] [ exp ] + decimal-point = %x2E ; . + digit1-9 = %x31-39 ; 1-9 + e = %x65 / %x45 ; e E + exp = e [ minus / plus ] 1*DIGIT + frac = decimal-point 1*DIGIT + int = zero / ( digit1-9 *DIGIT ) + minus = %x2D ; - + plus = %x2B ; + + zero = %x30 ; 0 + +*/ + +bool Parser::parseNumber(Value *val, int baseOffset) +{ + BEGIN << "parseNumber" << json; + val->type = JsonValue::Double; + + const char *start = json; + bool isInt = true; + + // minus + if (json < end && *json == '-') + ++json; + + // int = zero / ( digit1-9 *DIGIT ) + if (json < end && *json == '0') { + ++json; + } else { + while (json < end && *json >= '0' && *json <= '9') + ++json; + } + + // frac = decimal-point 1*DIGIT + if (json < end && *json == '.') { + isInt = false; + ++json; + while (json < end && *json >= '0' && *json <= '9') + ++json; + } + + // exp = e [ minus / plus ] 1*DIGIT + if (json < end && (*json == 'e' || *json == 'E')) { + isInt = false; + ++json; + if (json < end && (*json == '-' || *json == '+')) + ++json; + while (json < end && *json >= '0' && *json <= '9') + ++json; + } + + if (json >= end) { + lastError = JsonParseError::TerminationByNumber; + return false; + } + + if (isInt) { + char *endptr = const_cast(json); + long long int n = strtoll(start, &endptr, 0); + if (endptr != start && n < (1<<25) && n > -(1<<25)) { + val->int_value = int(n); + val->intValue = true; + END; + return true; + } + } + + char *endptr = const_cast(json); + double d = strtod(start, &endptr); + + if (start == endptr || std::isinf(d)) { + lastError = JsonParseError::IllegalNumber; + return false; + } + + int pos = reserveSpace(sizeof(double)); + memcpy(data + pos, &d, sizeof(double)); + if (current - baseOffset >= Value::MaxSize) { + lastError = JsonParseError::DocumentTooLarge; + return false; + } + val->value = pos - baseOffset; + val->intValue = false; + + END; + return true; +} + +/* + + string = quotation-mark *char quotation-mark + + char = unescaped / + escape ( + %x22 / ; " quotation mark U+0022 + %x5C / ; \ reverse solidus U+005C + %x2F / ; / solidus U+002F + %x62 / ; b backspace U+0008 + %x66 / ; f form feed U+000C + %x6E / ; n line feed U+000A + %x72 / ; r carriage return U+000D + %x74 / ; t tab U+0009 + %x75 4HEXDIG ) ; uXXXX U+XXXX + + escape = %x5C ; \ + + quotation-mark = %x22 ; " + + unescaped = %x20-21 / %x23-5B / %x5D-10FFFF + */ +static bool addHexDigit(char digit, uint32_t *result) +{ + *result <<= 4; + if (digit >= '0' && digit <= '9') + *result |= (digit - '0'); + else if (digit >= 'a' && digit <= 'f') + *result |= (digit - 'a') + 10; + else if (digit >= 'A' && digit <= 'F') + *result |= (digit - 'A') + 10; + else + return false; + return true; +} + +bool Parser::parseEscapeSequence() +{ + DEBUG << "scan escape" << (char)*json; + const char escaped = *json++; + switch (escaped) { + case '"': + addChar('"'); break; + case '\\': + addChar('\\'); break; + case '/': + addChar('/'); break; + case 'b': + addChar(0x8); break; + case 'f': + addChar(0xc); break; + case 'n': + addChar(0xa); break; + case 'r': + addChar(0xd); break; + case 't': + addChar(0x9); break; + case 'u': { + uint32_t c = 0; + if (json > end - 4) + return false; + for (int i = 0; i < 4; ++i) { + if (!addHexDigit(*json, &c)) + return false; + ++json; + } + if (c < 0x80) { + addChar(c); + break; + } + if (c < 0x800) { + addChar(192 + c / 64); + addChar(128 + c % 64); + break; + } + if (c - 0xd800u < 0x800) { + return false; + } + if (c < 0x10000) { + addChar(224 + c / 4096); + addChar(128 + c / 64 % 64); + addChar(128 + c % 64); + break; + } + if (c < 0x110000) { + addChar(240 + c / 262144); + addChar(128 + c / 4096 % 64); + addChar(128 + c / 64 % 64); + addChar(128 + c % 64); + break; + } + return false; + } + default: + // this is not as strict as one could be, but allows for more Json files + // to be parsed correctly. + addChar(escaped); + break; + } + return true; +} + +bool Parser::parseString() +{ + const char *inStart = json; + + // First try quick pass without escapes. + if (true) { + while (1) { + if (json >= end) { + ++json; + lastError = JsonParseError::UnterminatedString; + return false; + } + + const char c = *json; + if (c == '"') { + // write string length and padding. + const int len = static_cast(json - inStart); + const int pos = reserveSpace(4 + alignedSize(len)); + toInternal(data + pos, inStart, len); + END; + + ++json; + return true; + } + + if (c == '\\') + break; + ++json; + } + } + + // Try again with escapes. + const int outStart = reserveSpace(4); + json = inStart; + while (1) { + if (json >= end) { + ++json; + lastError = JsonParseError::UnterminatedString; + return false; + } + + if (*json == '"') { + ++json; + // write string length and padding. + *(int *)(data + outStart) = current - outStart - 4; + reserveSpace((4 - current) & 3); + END; + return true; + } + + if (*json == '\\') { + ++json; + if (json >= end || !parseEscapeSequence()) { + lastError = JsonParseError::IllegalEscapeSequence; + return false; + } + } else { + addChar(*json++); + } + } +} + +namespace Internal { + +static const Base emptyArray = {sizeof(Base), {0}, 0}; +static const Base emptyObject = {sizeof(Base), {0}, 0}; + + +void Data::compact() +{ + // assert(sizeof(Value) == sizeof(offset)); + + if (!compactionCounter) + return; + + Base *base = header->root(); + int reserve = 0; + if (base->is_object) { + const auto o = static_cast(base); + for (int i = 0; i < (int)o->length; ++i) + reserve += o->entryAt(i)->usedStorage(o); + } else { + const auto a = static_cast(base); + for (int i = 0; i < (int)a->length; ++i) + reserve += (*a)[i].usedStorage(a); + } + + int size = sizeof(Base) + reserve + base->length*sizeof(offset); + int alloc = sizeof(Header) + size; + const auto h = (Header *) malloc(alloc); + h->tag = JsonDocument::BinaryFormatTag; + h->version = 1; + Base *b = h->root(); + b->size = size; + b->is_object = header->root()->is_object; + b->length = base->length; + b->tableOffset = reserve + sizeof(Array); + + int offset = sizeof(Base); + if (b->is_object) { + const auto o = static_cast(base); + const auto no = static_cast(b); + + for (int i = 0; i < (int)o->length; ++i) { + no->table()[i] = offset; + + const Entry *e = o->entryAt(i); + Entry *ne = no->entryAt(i); + int s = e->size(); + memcpy(ne, e, s); + offset += s; + int dataSize = e->value.usedStorage(o); + if (dataSize) { + memcpy((char *)no + offset, e->value.data(o), dataSize); + ne->value.value = offset; + offset += dataSize; + } + } + } else { + const auto a = static_cast(base); + const auto na = static_cast(b); + + for (int i = 0; i < (int)a->length; ++i) { + const Value &v = (*a)[i]; + Value &nv = (*na)[i]; + nv = v; + int dataSize = v.usedStorage(a); + if (dataSize) { + memcpy((char *)na + offset, v.data(a), dataSize); + nv.value = offset; + offset += dataSize; + } + } + } + // assert(offset == (int)b->tableOffset); + + free(header); + header = h; + this->alloc = alloc; + compactionCounter = 0; +} + +bool Data::valid() const +{ + if (header->tag != JsonDocument::BinaryFormatTag || header->version != 1u) + return false; + + bool res = false; + if (header->root()->is_object) + res = static_cast(header->root())->isValid(); + else + res = static_cast(header->root())->isValid(); + + return res; +} + + +int Base::reserveSpace(uint32_t dataSize, int posInTable, uint32_t numItems, bool replace) +{ + // assert(posInTable >= 0 && posInTable <= (int)length); + if (size + dataSize >= Value::MaxSize) { + std::fprintf(stderr, "Json: Document too large to store in data structure %d %d %d\n", (uint32_t)size, dataSize, Value::MaxSize); + return 0; + } + + offset off = tableOffset; + // move table to new position + if (replace) { + memmove((char *)(table()) + dataSize, table(), length*sizeof(offset)); + } else { + memmove((char *)(table() + posInTable + numItems) + dataSize, table() + posInTable, (length - posInTable)*sizeof(offset)); + memmove((char *)(table()) + dataSize, table(), posInTable*sizeof(offset)); + } + tableOffset += dataSize; + for (int i = 0; i < (int)numItems; ++i) + table()[posInTable + i] = off; + size += dataSize; + if (!replace) { + length += numItems; + size += numItems * sizeof(offset); + } + return off; +} + +void Base::removeItems(int pos, int numItems) +{ + // assert(pos >= 0 && pos <= (int)length); + if (pos + numItems < (int)length) + memmove(table() + pos, table() + pos + numItems, (length - pos - numItems)*sizeof(offset)); + length -= numItems; +} + +int Object::indexOf(const std::string &key, bool *exists) +{ + int min = 0; + int n = length; + while (n > 0) { + int half = n >> 1; + int middle = min + half; + if (*entryAt(middle) >= key) { + n = half; + } else { + min = middle + 1; + n -= half + 1; + } + } + if (min < (int)length && *entryAt(min) == key) { + *exists = true; + return min; + } + *exists = false; + return min; +} + +bool Object::isValid() const +{ + if (tableOffset + length*sizeof(offset) > size) + return false; + + std::string lastKey; + for (uint32_t i = 0; i < length; ++i) { + offset entryOffset = table()[i]; + if (entryOffset + sizeof(Entry) >= tableOffset) + return false; + Entry *e = entryAt(i); + int s = e->size(); + if (table()[i] + s > tableOffset) + return false; + std::string key = e->key(); + if (key < lastKey) + return false; + if (!e->value.isValid(this)) + return false; + lastKey = key; + } + return true; +} + +bool Array::isValid() const +{ + if (tableOffset + length*sizeof(offset) > size) + return false; + + for (uint32_t i = 0; i < length; ++i) { + if (!at(i).isValid(this)) + return false; + } + return true; +} + + +bool Entry::operator==(const std::string &key) const +{ + return shallowKey() == key; +} + +bool Entry::operator==(const Entry &other) const +{ + return shallowKey() == other.shallowKey(); +} + +bool Entry::operator>=(const Entry &other) const +{ + return shallowKey() >= other.shallowKey(); +} + + +int Value::usedStorage(const Base *b) const +{ + int s = 0; + switch (type) { + case JsonValue::Double: + if (intValue) + break; + s = sizeof(double); + break; + case JsonValue::String: { + char *d = data(b); + s = sizeof(int) + (*(int *)d); + break; + } + case JsonValue::Array: + case JsonValue::Object: + s = base(b)->size; + break; + case JsonValue::Null: + case JsonValue::Bool: + default: + break; + } + return alignedSize(s); +} + +bool Value::isValid(const Base *b) const +{ + int offset = 0; + switch (type) { + case JsonValue::Double: + if (intValue) + break; + // fall through + case JsonValue::String: + case JsonValue::Array: + case JsonValue::Object: + offset = value; + break; + case JsonValue::Null: + case JsonValue::Bool: + default: + break; + } + + if (!offset) + return true; + if (offset + sizeof(uint32_t) > b->tableOffset) + return false; + + int s = usedStorage(b); + if (!s) + return true; + if (s < 0 || offset + s > (int)b->tableOffset) + return false; + if (type == JsonValue::Array) + return static_cast(base(b))->isValid(); + if (type == JsonValue::Object) + return static_cast(base(b))->isValid(); + return true; +} + +/*! + \internal + */ +int Value::requiredStorage(JsonValue &v, bool *compressed) +{ + *compressed = false; + switch (v.t) { + case JsonValue::Double: + if (Internal::compressedNumber(v.dbl) != INT_MAX) { + *compressed = true; + return 0; + } + return sizeof(double); + case JsonValue::String: { + std::string s = v.toString(); + *compressed = false; + return Internal::qStringSize(s); + } + case JsonValue::Array: + case JsonValue::Object: + if (v.d && v.d->compactionCounter) { + v.detach(); + v.d->compact(); + v.base = static_cast(v.d->header->root()); + } + return v.base ? v.base->size : sizeof(Internal::Base); + case JsonValue::Undefined: + case JsonValue::Null: + case JsonValue::Bool: + break; + } + return 0; +} + +/*! + \internal + */ +uint32_t Value::valueToStore(const JsonValue &v, uint32_t offset) +{ + switch (v.t) { + case JsonValue::Undefined: + case JsonValue::Null: + break; + case JsonValue::Bool: + return v.b; + case JsonValue::Double: { + int c = Internal::compressedNumber(v.dbl); + if (c != INT_MAX) + return c; + } + // fall through + case JsonValue::String: + case JsonValue::Array: + case JsonValue::Object: + return offset; + } + return 0; +} + +/*! + \internal + */ + +void Value::copyData(const JsonValue &v, char *dest, bool compressed) +{ + switch (v.t) { + case JsonValue::Double: + if (!compressed) + memcpy(dest, &v.ui, 8); + break; + case JsonValue::String: { + std::string str = v.toString(); + Internal::copyString(dest, str); + break; + } + case JsonValue::Array: + case JsonValue::Object: { + const Internal::Base *b = v.base; + if (!b) + b = (v.t == JsonValue::Array ? &emptyArray : &emptyObject); + memcpy(dest, b, b->size); + break; + } + default: + break; + } +} + +} // namespace Internal +} // namespace Json diff --git a/src/shared/json/json.h b/src/shared/json/json.h new file mode 100644 index 00000000..6cb6ec1a --- /dev/null +++ b/src/shared/json/json.h @@ -0,0 +1,589 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef JSON_H +#define JSON_H + +#include +#include +#include +#include + +namespace Json { + +class JsonArray; +class JsonObject; + +namespace Internal { +class Data; +class Base; +class Object; +class Header; +class Array; +class Value; +class Entry; +class SharedString; +class Parser; +} + +class JsonValue +{ +public: + enum Type { + Null = 0x0, + Bool = 0x1, + Double = 0x2, + String = 0x3, + Array = 0x4, + Object = 0x5, + Undefined = 0x80 + }; + + JsonValue(Type = Null); + JsonValue(bool b); + JsonValue(double n); + JsonValue(int n); + JsonValue(int64_t n); + JsonValue(const std::string &s); + JsonValue(const char *s); + JsonValue(const JsonArray &a); + JsonValue(const JsonObject &o); + + ~JsonValue(); + + JsonValue(const JsonValue &other); + JsonValue &operator =(const JsonValue &other); + + Type type() const { return t; } + bool isNull() const { return t == Null; } + bool isBool() const { return t == Bool; } + bool isDouble() const { return t == Double; } + bool isString() const { return t == String; } + bool isArray() const { return t == Array; } + bool isObject() const { return t == Object; } + bool isUndefined() const { return t == Undefined; } + + bool toBool(bool defaultValue = false) const; + int toInt(int defaultValue = 0) const; + double toDouble(double defaultValue = 0) const; + std::string toString(const std::string &defaultValue = std::string()) const; + JsonArray toArray() const; + JsonArray toArray(const JsonArray &defaultValue) const; + JsonObject toObject() const; + JsonObject toObject(const JsonObject &defaultValue) const; + + bool operator==(const JsonValue &other) const; + bool operator!=(const JsonValue &other) const; + +private: + // avoid implicit conversions from char * to bool + JsonValue(const void *) : t(Null) {} + friend class Internal::Value; + friend class JsonArray; + friend class JsonObject; + + JsonValue(Internal::Data *d, Internal::Base *b, const Internal::Value& v); + + void detach(); + + union { + uint64_t ui; + bool b; + double dbl; + Internal::SharedString *stringData; + Internal::Base *base; + }; + Internal::Data *d; // needed for Objects and Arrays + Type t; +}; + +class JsonValueRef +{ +public: + JsonValueRef(JsonArray *array, int idx) + : a(array), is_object(false), index(idx) {} + JsonValueRef(JsonObject *object, int idx) + : o(object), is_object(true), index(idx) {} + + operator JsonValue() const { return toValue(); } + JsonValueRef &operator=(const JsonValue &val); + JsonValueRef &operator=(const JsonValueRef &val); + + JsonValue::Type type() const { return toValue().type(); } + bool isNull() const { return type() == JsonValue::Null; } + bool isBool() const { return type() == JsonValue::Bool; } + bool isDouble() const { return type() == JsonValue::Double; } + bool isString() const { return type() == JsonValue::String; } + bool isArray() const { return type() == JsonValue::Array; } + bool isObject() const { return type() == JsonValue::Object; } + bool isUndefined() const { return type() == JsonValue::Undefined; } + + std::string toString() const { return toValue().toString(); } + JsonArray toArray() const; + JsonObject toObject() const; + + bool toBool(bool defaultValue = false) const { return toValue().toBool(defaultValue); } + int toInt(int defaultValue = 0) const { return toValue().toInt(defaultValue); } + double toDouble(double defaultValue = 0) const { return toValue().toDouble(defaultValue); } + std::string toString(const std::string &defaultValue) const { return toValue().toString(defaultValue); } + + bool operator==(const JsonValue &other) const { return toValue() == other; } + bool operator!=(const JsonValue &other) const { return toValue() != other; } + +private: + JsonValue toValue() const; + + union { + JsonArray *a; + JsonObject *o; + }; + uint32_t is_object : 1; + uint32_t index : 31; +}; + +class JsonValuePtr +{ + JsonValue value; +public: + explicit JsonValuePtr(const JsonValue& val) + : value(val) {} + + JsonValue& operator*() { return value; } + JsonValue* operator->() { return &value; } +}; + +class JsonValueRefPtr +{ + JsonValueRef valueRef; +public: + JsonValueRefPtr(JsonArray *array, int idx) + : valueRef(array, idx) {} + JsonValueRefPtr(JsonObject *object, int idx) + : valueRef(object, idx) {} + + JsonValueRef& operator*() { return valueRef; } + JsonValueRef* operator->() { return &valueRef; } +}; + + + +class JsonArray +{ +public: + JsonArray(); + JsonArray(std::initializer_list args); + + ~JsonArray(); + + JsonArray(const JsonArray &other); + JsonArray &operator=(const JsonArray &other); + + int size() const; + int count() const { return size(); } + + bool isEmpty() const; + JsonValue at(int i) const; + JsonValue first() const; + JsonValue last() const; + + void prepend(const JsonValue &value); + void append(const JsonValue &value); + void removeAt(int i); + JsonValue takeAt(int i); + void removeFirst() { removeAt(0); } + void removeLast() { removeAt(size() - 1); } + + void insert(int i, const JsonValue &value); + void replace(int i, const JsonValue &value); + + bool contains(const JsonValue &element) const; + JsonValueRef operator[](int i); + JsonValue operator[](int i) const; + + bool operator==(const JsonArray &other) const; + bool operator!=(const JsonArray &other) const; + + class const_iterator; + + class iterator { + public: + JsonArray *a; + int i; + using iterator_category = std::random_access_iterator_tag; + using difference_type = int; + using value_type = JsonValue; + using reference = JsonValueRef; + using pointer = JsonValueRefPtr; + + iterator() : a(nullptr), i(0) { } + explicit iterator(JsonArray *array, int index) : a(array), i(index) { } + + JsonValueRef operator*() const { return JsonValueRef(a, i); } + JsonValueRefPtr operator->() const { return JsonValueRefPtr(a, i); } + JsonValueRef operator[](int j) const { return JsonValueRef(a, i + j); } + + bool operator==(const iterator &o) const { return i == o.i; } + bool operator!=(const iterator &o) const { return i != o.i; } + bool operator<(const iterator& other) const { return i < other.i; } + bool operator<=(const iterator& other) const { return i <= other.i; } + bool operator>(const iterator& other) const { return i > other.i; } + bool operator>=(const iterator& other) const { return i >= other.i; } + bool operator==(const const_iterator &o) const { return i == o.i; } + bool operator!=(const const_iterator &o) const { return i != o.i; } + bool operator<(const const_iterator& other) const { return i < other.i; } + bool operator<=(const const_iterator& other) const { return i <= other.i; } + bool operator>(const const_iterator& other) const { return i > other.i; } + bool operator>=(const const_iterator& other) const { return i >= other.i; } + iterator &operator++() { ++i; return *this; } + iterator operator++(int) { iterator n = *this; ++i; return n; } + iterator &operator--() { i--; return *this; } + iterator operator--(int) { iterator n = *this; i--; return n; } + iterator &operator+=(int j) { i+=j; return *this; } + iterator &operator-=(int j) { i-=j; return *this; } + iterator operator+(int j) const { return iterator(a, i+j); } + iterator operator-(int j) const { return iterator(a, i-j); } + int operator-(iterator j) const { return i - j.i; } + }; + friend class iterator; + + class const_iterator { + public: + const JsonArray *a; + int i; + using iterator_category = std::random_access_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = JsonValue; + using reference = JsonValue; + using pointer = JsonValuePtr; + + const_iterator() : a(nullptr), i(0) { } + explicit const_iterator(const JsonArray *array, int index) : a(array), i(index) { } + const_iterator(const iterator &o) : a(o.a), i(o.i) {} + + JsonValue operator*() const { return a->at(i); } + JsonValuePtr operator->() const { return JsonValuePtr(a->at(i)); } + JsonValue operator[](int j) const { return a->at(i+j); } + bool operator==(const const_iterator &o) const { return i == o.i; } + bool operator!=(const const_iterator &o) const { return i != o.i; } + bool operator<(const const_iterator& other) const { return i < other.i; } + bool operator<=(const const_iterator& other) const { return i <= other.i; } + bool operator>(const const_iterator& other) const { return i > other.i; } + bool operator>=(const const_iterator& other) const { return i >= other.i; } + const_iterator &operator++() { ++i; return *this; } + const_iterator operator++(int) { const_iterator n = *this; ++i; return n; } + const_iterator &operator--() { i--; return *this; } + const_iterator operator--(int) { const_iterator n = *this; i--; return n; } + const_iterator &operator+=(int j) { i+=j; return *this; } + const_iterator &operator-=(int j) { i-=j; return *this; } + const_iterator operator+(int j) const { return const_iterator(a, i+j); } + const_iterator operator-(int j) const { return const_iterator(a, i-j); } + int operator-(const_iterator j) const { return i - j.i; } + }; + friend class const_iterator; + + // stl style + iterator begin() { detach(); return iterator(this, 0); } + const_iterator begin() const { return const_iterator(this, 0); } + const_iterator constBegin() const { return const_iterator(this, 0); } + iterator end() { detach(); return iterator(this, size()); } + const_iterator end() const { return const_iterator(this, size()); } + const_iterator constEnd() const { return const_iterator(this, size()); } + iterator insert(iterator before, const JsonValue &value) { insert(before.i, value); return before; } + iterator erase(iterator it) { removeAt(it.i); return it; } + + void push_back(const JsonValue &t) { append(t); } + void push_front(const JsonValue &t) { prepend(t); } + void pop_front() { removeFirst(); } + void pop_back() { removeLast(); } + bool empty() const { return isEmpty(); } + using size_type = int ; + using value_type = JsonValue; + using pointer = value_type *; + using const_pointer = const value_type *; + using reference = JsonValueRef; + using const_reference = JsonValue; + using difference_type = int; + +private: + friend class Internal::Data; + friend class JsonValue; + friend class JsonDocument; + + JsonArray(Internal::Data *data, Internal::Array *array); + void compact(); + void detach(uint32_t reserve = 0); + + Internal::Data *d; + Internal::Array *a; +}; + + +class JsonObject +{ +public: + JsonObject(); + JsonObject(std::initializer_list > args); + ~JsonObject(); + + JsonObject(const JsonObject &other); + JsonObject &operator =(const JsonObject &other); + + using Keys = std::vector; + Keys keys() const; + int size() const; + int count() const { return size(); } + int length() const { return size(); } + bool isEmpty() const; + + JsonValue value(const std::string &key) const; + JsonValue operator[] (const std::string &key) const; + JsonValueRef operator[] (const std::string &key); + + void remove(const std::string &key); + JsonValue take(const std::string &key); + bool contains(const std::string &key) const; + + bool operator==(const JsonObject &other) const; + bool operator!=(const JsonObject &other) const; + + class const_iterator; + + class iterator + { + friend class const_iterator; + friend class JsonObject; + JsonObject *o; + int i; + + public: + using iterator_category = std::bidirectional_iterator_tag; + using difference_type = int; + using value_type = JsonValue; + using reference = JsonValueRef; + + iterator() : o(nullptr), i(0) {} + iterator(JsonObject *obj, int index) : o(obj), i(index) {} + + std::string key() const { return o->keyAt(i); } + JsonValueRef value() const { return JsonValueRef(o, i); } + JsonValueRef operator*() const { return JsonValueRef(o, i); } + JsonValueRefPtr operator->() const { return JsonValueRefPtr(o, i); } + bool operator==(const iterator &other) const { return i == other.i; } + bool operator!=(const iterator &other) const { return i != other.i; } + + iterator &operator++() { ++i; return *this; } + iterator operator++(int) { iterator r = *this; ++i; return r; } + iterator &operator--() { --i; return *this; } + iterator operator--(int) { iterator r = *this; --i; return r; } + iterator operator+(int j) const + { iterator r = *this; r.i += j; return r; } + iterator operator-(int j) const { return operator+(-j); } + iterator &operator+=(int j) { i += j; return *this; } + iterator &operator-=(int j) { i -= j; return *this; } + + public: + bool operator==(const const_iterator &other) const { return i == other.i; } + bool operator!=(const const_iterator &other) const { return i != other.i; } + }; + friend class iterator; + + class const_iterator + { + friend class iterator; + const JsonObject *o; + int i; + + public: + using iterator_category = std::bidirectional_iterator_tag; + using difference_type = int; + using value_type = JsonValue; + using reference = JsonValue; + + const_iterator() : o(nullptr), i(0) {} + const_iterator(const JsonObject *obj, int index) + : o(obj), i(index) {} + const_iterator(const iterator &other) + : o(other.o), i(other.i) {} + + std::string key() const { return o->keyAt(i); } + JsonValue value() const { return o->valueAt(i); } + JsonValue operator*() const { return o->valueAt(i); } + JsonValuePtr operator->() const { return JsonValuePtr(o->valueAt(i)); } + bool operator==(const const_iterator &other) const { return i == other.i; } + bool operator!=(const const_iterator &other) const { return i != other.i; } + + const_iterator &operator++() { ++i; return *this; } + const_iterator operator++(int) { const_iterator r = *this; ++i; return r; } + const_iterator &operator--() { --i; return *this; } + const_iterator operator--(int) { const_iterator r = *this; --i; return r; } + const_iterator operator+(int j) const + { const_iterator r = *this; r.i += j; return r; } + const_iterator operator-(int j) const { return operator+(-j); } + const_iterator &operator+=(int j) { i += j; return *this; } + const_iterator &operator-=(int j) { i -= j; return *this; } + + bool operator==(const iterator &other) const { return i == other.i; } + bool operator!=(const iterator &other) const { return i != other.i; } + }; + friend class const_iterator; + + // STL style + iterator begin() { detach(); return iterator(this, 0); } + const_iterator begin() const { return const_iterator(this, 0); } + const_iterator constBegin() const { return const_iterator(this, 0); } + iterator end() { detach(); return iterator(this, size()); } + const_iterator end() const { return const_iterator(this, size()); } + const_iterator constEnd() const { return const_iterator(this, size()); } + iterator erase(iterator it); + + // more Qt + iterator find(const std::string &key); + const_iterator find(const std::string &key) const { return constFind(key); } + const_iterator constFind(const std::string &key) const; + iterator insert(const std::string &key, const JsonValue &value); + + // STL compatibility + using mapped_type = JsonValue; + using key_type = std::string; + using size_type = int; + + bool empty() const { return isEmpty(); } + +private: + friend class Internal::Data; + friend class JsonValue; + friend class JsonDocument; + friend class JsonValueRef; + + JsonObject(Internal::Data *data, Internal::Object *object); + void detach(uint32_t reserve = 0); + void compact(); + + std::string keyAt(int i) const; + JsonValue valueAt(int i) const; + void setValueAt(int i, const JsonValue &val); + + Internal::Data *d; + Internal::Object *o; +}; + +struct JsonParseError +{ + enum ParseError { + NoError = 0, + UnterminatedObject, + MissingNameSeparator, + UnterminatedArray, + MissingValueSeparator, + IllegalValue, + TerminationByNumber, + IllegalNumber, + IllegalEscapeSequence, + IllegalUTF8String, + UnterminatedString, + MissingObject, + DeepNesting, + DocumentTooLarge, + GarbageAtEnd + }; + + int offset; + ParseError error; +}; + +class JsonDocument +{ +public: + static const uint32_t BinaryFormatTag = ('q') | ('b' << 8) | ('j' << 16) | ('s' << 24); + JsonDocument(); + explicit JsonDocument(const JsonObject &object); + explicit JsonDocument(const JsonArray &array); + ~JsonDocument(); + + JsonDocument(const JsonDocument &other); + JsonDocument &operator =(const JsonDocument &other); + + enum DataValidation { + Validate, + BypassValidation + }; + + static JsonDocument fromRawData(const char *data, int size, DataValidation validation = Validate); + const char *rawData(int *size) const; + + static JsonDocument fromBinaryData(const std::string &data, DataValidation validation = Validate); + std::string toBinaryData() const; + + enum JsonFormat { + Indented, + Compact + }; + + static JsonDocument fromJson(const std::string &json, JsonParseError *error = nullptr); + + std::string toJson(JsonFormat format = Indented) const; + + bool isEmpty() const; + bool isArray() const; + bool isObject() const; + + JsonObject object() const; + JsonArray array() const; + + void setObject(const JsonObject &object); + void setArray(const JsonArray &array); + + bool operator==(const JsonDocument &other) const; + bool operator!=(const JsonDocument &other) const { return !(*this == other); } + + bool isNull() const; + +private: + friend class JsonValue; + friend class Internal::Data; + friend class Internal::Parser; + + JsonDocument(Internal::Data *data); + + Internal::Data *d; +}; + +} // namespace Json + +#endif // JSON_H diff --git a/src/shared/json/json.pri b/src/shared/json/json.pri new file mode 100644 index 00000000..1b44027c --- /dev/null +++ b/src/shared/json/json.pri @@ -0,0 +1,3 @@ +INCLUDEPATH += $$PWD +HEADERS += $$PWD/json.h +SOURCES += $$PWD/json.cpp diff --git a/src/shared/json/json.qbs b/src/shared/json/json.qbs new file mode 100644 index 00000000..f5b2517a --- /dev/null +++ b/src/shared/json/json.qbs @@ -0,0 +1,7 @@ +QbsStaticLibrary { + name: "qbsjson" + files: [ + "json.cpp", + "json.h", + ] +} diff --git a/src/shared/qtscript/.gitattributes b/src/shared/qtscript/.gitattributes new file mode 100644 index 00000000..a96f8f54 --- /dev/null +++ b/src/shared/qtscript/.gitattributes @@ -0,0 +1,3 @@ +.tag export-subst +.gitignore export-ignore +.gitattributes export-ignore diff --git a/src/shared/qtscript/.gitignore b/src/shared/qtscript/.gitignore new file mode 100644 index 00000000..375ab189 --- /dev/null +++ b/src/shared/qtscript/.gitignore @@ -0,0 +1,265 @@ +# This file is used to ignore files which are generated in the Qt build system +# ---------------------------------------------------------------------------- + +examples/*/*/* +!examples/*/*/*[.]* +!examples/*/*/README +examples/*/*/*[.]app +!examples/declarative/* +!examples/tutorials/* +!examples/tutorials/*/* +!examples/ja_JP/*/* +demos/*/* +!demos/spectrum/* +demos/spectrum/bin +!demos/*/*[.]* +demos/*/*[.]app +!demos/declarative/* +config.tests/*/*/* +!config.tests/*/*/*[.]* +config.tests/*/*/*[.]app + +callgrind.out.* +pcviewer.cfg +*~ +*.a +*.la +*.core +*.moc +*.o +*.obj +*.orig +*.swp +*.rej +*.so +*.pbxuser +*.mode1 +*.mode1v3 +*_pch.h.cpp +*_resource.rc +.#* +*.*# +core +.qmake.cache +.qmake.vars +*.prl +tags +.DS_Store +*.debug +Makefile* +!qmake/Makefile.win32* +!qmake/Makefile.unix +*.prl +*.app +*.pro.user +*.qmlproject.user +*.gcov +bin/Qt*.dll +bin/assistant* +bin/designer* +bin/dumpcpp* +bin/idc* +bin/linguist* +bin/lrelease* +bin/lupdate* +bin/lconvert* +bin/moc* +bin/makeqpf* +bin/pixeltool* +bin/qmake* +bin/qdoc3* +bin/qt3to4* +bin/qttracereplay* +bin/rcc* +bin/uic* +bin/patternist* +bin/phonon* +bin/qcollectiongenerator* +bin/qdbus* +bin/qhelpconverter* +bin/qhelpgenerator* +bin/qtconfig* +bin/xmlpatterns* +bin/cetest* +bin/collectiongenerator +bin/helpconverter +bin/helpgenerator +bin/kmap2qmap* +bin/qlalr* +bin/qmlconv* +bin/qmldebugger* +bin/qml* +bin/qttracereplay* +configure.cache +config.status +mkspecs/default +mkspecs/qconfig.pri +moc_*.cpp +qmake/qmake.exe +qmake/Makefile.bak +src/corelib/global/qconfig.cpp +src/corelib/global/qconfig.h +src/corelib/global/qconfig.h.qmake +ui_*.h +tests/auto/qprocess/test*/*.exe +tests/auto/qtcpsocket/stressTest/*.exe +tests/auto/qprocess/fileWriterProcess/*.exe +tests/auto/qmake/testdata/quotedfilenames/*.exe +tests/auto/compilerwarnings/*.exe +tests/auto/qmake/testdata/quotedfilenames/test.cpp +tests/auto/qprocess/fileWriterProcess.txt +.com.apple.timemachine.supported +tests/auto/qlibrary/libmylib.so* +tests/auto/qresourceengine/runtime_resource.rcc +tools/activeqt/testcon/testcon.tlb +translations/*.qm +translations/*_untranslated.ts +qrc_*.cpp + +src/script/qtscriptversion.h +src/scripttools/qtscripttoolsversion.h + +# Test generated files +QObject.log +tst_* +!tst_*.* +tst_*.log +tst_*.debug +tst_*~ + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.vcxproj +*.vcxproj.filters +*.vcxproj.user + +# MinGW generated files +*.Debug +*.Release + +# WebKit temp files +src/3rdparty/webkit/WebCore/mocinclude.tmp +src/3rdparty/webkit/includes.txt +src/3rdparty/webkit/includes2.txt + +# Symlinks generated by configure +tools/qvfb/qvfbhdr.h +tools/qvfb/qlock_p.h +tools/qvfb/qlock.cpp +tools/qvfb/qwssignalhandler.cpp +tools/qvfb/qwssignalhandler_p.h +.DS_Store +.pch +.rcc +*.app +config.status +config.tests/unix/cups/cups +config.tests/unix/getaddrinfo/getaddrinfo +config.tests/unix/getifaddrs/getifaddrs +config.tests/unix/iconv/iconv +config.tests/unix/ipv6/ipv6 +config.tests/unix/ipv6ifname/ipv6ifname +config.tests/unix/largefile/largefile +config.tests/unix/nis/nis +config.tests/unix/odbc/odbc +config.tests/unix/openssl/openssl +config.tests/unix/stl/stl +config.tests/unix/zlib/zlib +config.tests/unix/3dnow/3dnow +config.tests/unix/mmx/mmx +config.tests/unix/sse/sse +config.tests/unix/sse2/sse2 + + + +# Directories to ignore +# --------------------- + +debug +examples/tools/plugandpaint/plugins +include/* +include/*/* +lib/* +!lib/fonts +!lib/README +plugins/*/* +release +tmp +doc-build +doc/html/* +doc/qch +doc-build +doc/qtscript +.rcc +.pch +.metadata + +# Symbian build system generated files +# --------------------- + +ABLD.BAT +bld.inf* +*.mmp +*.mk +*.rss +*.loc +!s60main.rss +*.pkg +plugin_commonu.def +*.qtplugin +*.sis +*.sisx +*.lst +*.exe +*.mif +*.rsc +*.sym +*.lib + +# runonphone crash dumps +d_exc_*.txt +d_exc_*.stk + +# Generated by abldfast.bat from devtools. +.abldsteps.* + +# Carbide project files +# --------------------- +.project +.cproject +.make.cache +*.d + +qtc-debugging-helper +src/corelib/lib +src/network/lib +src/xml/lib/ + +.pc/ + +# INTEGRITY generated files +*.gpj +*.int +*.ael +*.dla +*.dnm +*.dep +*.map +work + +# Generated static plugin import sources +*_plugin_import.cpp diff --git a/src/shared/qtscript/.qmake.conf b/src/shared/qtscript/.qmake.conf new file mode 100644 index 00000000..faa94bb9 --- /dev/null +++ b/src/shared/qtscript/.qmake.conf @@ -0,0 +1,6 @@ +load(qt_build_config) +android|boot2qt: CONFIG -= headersclean + +DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS + +MODULE_VERSION = 6.0.0 diff --git a/src/shared/qtscript/.tag b/src/shared/qtscript/.tag new file mode 100644 index 00000000..6828f88d --- /dev/null +++ b/src/shared/qtscript/.tag @@ -0,0 +1 @@ +$Format:%H$ diff --git a/src/shared/qtscript/LICENSE.FDL b/src/shared/qtscript/LICENSE.FDL new file mode 100644 index 00000000..938bb8da --- /dev/null +++ b/src/shared/qtscript/LICENSE.FDL @@ -0,0 +1,450 @@ + GNU Free Documentation License + Version 1.3, 3 November 2008 + + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The "publisher" means any person or entity that distributes copies of +the Document to the public. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no +other conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to +give them a chance to provide you with an updated version of the +Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other +documents released under this License, and replace the individual +copies of this License in the various documents with a single copy +that is included in the collection, provided that you follow the rules +of this License for verbatim copying of each of the documents in all +other respects. + +You may extract a single document from such a collection, and +distribute it individually under this License, provided you insert a +copy of this License into the extracted document, and follow this +License in all other respects regarding verbatim copying of that +document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions of the +GNU Free Documentation License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. See +http://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +11. RELICENSING + +"Massive Multiauthor Collaboration Site" (or "MMC Site") means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +"Massive Multiauthor Collaboration" (or "MMC") contained in the site +means any set of copyrightable works thus published on the MMC site. + +"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +"Incorporate" means to publish or republish a Document, in whole or in +part, as part of another Document. + +An MMC is "eligible for relicensing" if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole or +in part into the MMC, (1) had no cover texts or invariant sections, and +(2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. diff --git a/src/shared/qtscript/LICENSE.GPL2 b/src/shared/qtscript/LICENSE.GPL2 new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/src/shared/qtscript/LICENSE.GPL2 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/src/shared/qtscript/LICENSE.GPL3 b/src/shared/qtscript/LICENSE.GPL3 new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/src/shared/qtscript/LICENSE.GPL3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/src/shared/qtscript/LICENSE.GPL3-EXCEPT b/src/shared/qtscript/LICENSE.GPL3-EXCEPT new file mode 100644 index 00000000..b1cb1bec --- /dev/null +++ b/src/shared/qtscript/LICENSE.GPL3-EXCEPT @@ -0,0 +1,704 @@ +This is the GNU General Public License version 3, annotated with The +Qt Company GPL Exception 1.0: + +------------------------------------------------------------------------- + +The Qt Company GPL Exception 1.0 + +Exception 1: + +As a special exception you may create a larger work which contains the +output of this application and distribute that work under terms of your +choice, so long as the work is not otherwise derived from or based on +this application and so long as the work does not in itself generate +output that contains the output from this application in its original +or modified form. + +Exception 2: + +As a special exception, you have permission to combine this application +with Plugins licensed under the terms of your choice, to produce an +executable, and to copy and distribute the resulting executable under +the terms of your choice. However, the executable must be accompanied +by a prominent notice offering all users of the executable the entire +source code to this application, excluding the source code of the +independent modules, but including any changes you have made to this +application, under the terms of this license. + + +------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/src/shared/qtscript/LICENSE.LGPL3 b/src/shared/qtscript/LICENSE.LGPL3 new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/src/shared/qtscript/LICENSE.LGPL3 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/src/shared/qtscript/configure.json b/src/shared/qtscript/configure.json new file mode 100644 index 00000000..63ea5752 --- /dev/null +++ b/src/shared/qtscript/configure.json @@ -0,0 +1,5 @@ +{ + "subconfigs": [ + "src/script" + ] +} diff --git a/src/shared/qtscript/dependencies.yaml b/src/shared/qtscript/dependencies.yaml new file mode 100644 index 00000000..236aeacf --- /dev/null +++ b/src/shared/qtscript/dependencies.yaml @@ -0,0 +1,7 @@ +dependencies: + ../qtbase: + ref: 40143c189b7c1bf3c2058b77d00ea5c4e3be8b28 + required: true + ../qttools: + ref: cc52debd905e0ed061290d6fd00a5f1ab67478a5 + required: false diff --git a/src/shared/qtscript/dist/changes-5.0.1 b/src/shared/qtscript/dist/changes-5.0.1 new file mode 100644 index 00000000..c21590a9 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.0.1 @@ -0,0 +1,48 @@ +Qt 5.0.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.0.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.0/ + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +-modularized Qt Script Tools documentation; did not exist previously + +Third party components +---------------------- + +**************************************************************************** +* Library * +**************************************************************************** + + - no changes for this version + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Compiler Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Plugins * +**************************************************************************** diff --git a/src/shared/qtscript/dist/changes-5.0.2 b/src/shared/qtscript/dist/changes-5.0.2 new file mode 100644 index 00000000..f29fa49c --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.0.2 @@ -0,0 +1,25 @@ +Qt 5.0.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.0.0 and 5.0.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.0/ + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.1.0 b/src/shared/qtscript/dist/changes-5.1.0 new file mode 100644 index 00000000..505b0cc5 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.1.0 @@ -0,0 +1,22 @@ +Qt 5.1 introduces many new features and improvements as well as bugfixes +over the 5.0.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.1 + +The Qt version 5.1 series is binary compatible with the 5.0.x series. +Applications compiled for 5.0 will continue to run with 5.1. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.1.1 b/src/shared/qtscript/dist/changes-5.1.1 new file mode 100644 index 00000000..e233af4a --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.1.1 @@ -0,0 +1,25 @@ +Qt 5.1.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.1.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.1/ + +The Qt version 5.1 series is binary compatible with the 5.0.x series. +Applications compiled for 5.0 will continue to run with 5.1. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + +**************************************************************************** +* General * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.10.1 b/src/shared/qtscript/dist/changes-5.10.1 new file mode 100644 index 00000000..695c4e36 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.10.1 @@ -0,0 +1,26 @@ +Qt 5.10.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.10.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.10 series is binary compatible with the 5.9.x series. +Applications compiled for 5.9 will continue to run with 5.10. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +This release contains all fixes included in the Qt 5.9.4 release. + +**************************************************************************** +* Qt 5.10.1 Changes * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.11.0 b/src/shared/qtscript/dist/changes-5.11.0 new file mode 100644 index 00000000..162ab57c --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.11.0 @@ -0,0 +1,22 @@ +Qt 5.11 introduces many new features and improvements as well as bugfixes +over the 5.10.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.11 series is binary compatible with the 5.10.x series. +Applications compiled for 5.10 will continue to run with 5.11. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.11.0 Changes * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.11.1 b/src/shared/qtscript/dist/changes-5.11.1 new file mode 100644 index 00000000..42ece52b --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.11.1 @@ -0,0 +1,29 @@ +Qt 5.11.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.11.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.11 series is binary compatible with the 5.10.x series. +Applications compiled for 5.10 will continue to run with 5.11. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.11.1 Changes * +**************************************************************************** + +**************************************************************************** +* QtScript * +**************************************************************************** + + - [QTBUG-68367] Fix incorrect script evaluations on 64-bit systems with + gcc 8. diff --git a/src/shared/qtscript/dist/changes-5.11.2 b/src/shared/qtscript/dist/changes-5.11.2 new file mode 100644 index 00000000..8efdf5ea --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.11.2 @@ -0,0 +1,24 @@ +Qt 5.11.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.11.0 through 5.11.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.11 series is binary compatible with the 5.10.x series. +Applications compiled for 5.10 will continue to run with 5.11. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.11.2 Changes * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.11.3 b/src/shared/qtscript/dist/changes-5.11.3 new file mode 100644 index 00000000..f71fa341 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.11.3 @@ -0,0 +1,20 @@ +Qt 5.11.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.11.0 through 5.11.2. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.11 series is binary compatible with the 5.10.x series. +Applications compiled for 5.10 will continue to run with 5.11. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.0 b/src/shared/qtscript/dist/changes-5.12.0 new file mode 100644 index 00000000..4f6c63ed --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.0 @@ -0,0 +1,18 @@ +Qt 5.12 introduces many new features and improvements as well as bugfixes +over the 5.11.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.1 b/src/shared/qtscript/dist/changes-5.12.1 new file mode 100644 index 00000000..1cb4dd73 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.1 @@ -0,0 +1,20 @@ +Qt 5.12.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.2 b/src/shared/qtscript/dist/changes-5.12.2 new file mode 100644 index 00000000..0c8bd857 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.2 @@ -0,0 +1,20 @@ +Qt 5.12.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.3 b/src/shared/qtscript/dist/changes-5.12.3 new file mode 100644 index 00000000..88033201 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.3 @@ -0,0 +1,20 @@ +Qt 5.12.3 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.2. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.4 b/src/shared/qtscript/dist/changes-5.12.4 new file mode 100644 index 00000000..a285cd8e --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.4 @@ -0,0 +1,20 @@ +Qt 5.12.4 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.3. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.12.5 b/src/shared/qtscript/dist/changes-5.12.5 new file mode 100644 index 00000000..e8be9316 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.12.5 @@ -0,0 +1,20 @@ +Qt 5.12.5 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.4. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.13.0 b/src/shared/qtscript/dist/changes-5.13.0 new file mode 100644 index 00000000..ebb4be18 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.13.0 @@ -0,0 +1,18 @@ +Qt 5.13 introduces many new features and improvements as well as bugfixes +over the 5.12.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.13.1 b/src/shared/qtscript/dist/changes-5.13.1 new file mode 100644 index 00000000..57ebdbeb --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.13.1 @@ -0,0 +1,20 @@ +Qt 5.13.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.13.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.13.2 b/src/shared/qtscript/dist/changes-5.13.2 new file mode 100644 index 00000000..e3bb833f --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.13.2 @@ -0,0 +1,20 @@ +Qt 5.13.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.13.0 through 5.13.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.14.0 b/src/shared/qtscript/dist/changes-5.14.0 new file mode 100644 index 00000000..29a2c83b --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.14.0 @@ -0,0 +1,18 @@ +Qt 5.14 introduces many new features and improvements as well as bugfixes +over the 5.13.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.14 series is binary compatible with the 5.13.x series. +Applications compiled for 5.13 will continue to run with 5.14. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.14.1 b/src/shared/qtscript/dist/changes-5.14.1 new file mode 100644 index 00000000..d0086381 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.14.1 @@ -0,0 +1,20 @@ +Qt 5.14.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.14.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.14 series is binary compatible with the 5.13.x series. +Applications compiled for 5.13 will continue to run with 5.14. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.9.4 b/src/shared/qtscript/dist/changes-5.9.4 new file mode 100644 index 00000000..d49a42f5 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.9.4 @@ -0,0 +1,25 @@ +Qt 5.9.4 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.9.4 Changes * +**************************************************************************** + + - This release contains only minor code improvements. + diff --git a/src/shared/qtscript/dist/changes-5.9.5 b/src/shared/qtscript/dist/changes-5.9.5 new file mode 100644 index 00000000..876af5f3 --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.9.5 @@ -0,0 +1,24 @@ +Qt 5.9.5 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.9.5 Changes * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/dist/changes-5.9.6 b/src/shared/qtscript/dist/changes-5.9.6 new file mode 100644 index 00000000..f0179a5a --- /dev/null +++ b/src/shared/qtscript/dist/changes-5.9.6 @@ -0,0 +1,24 @@ +Qt 5.9.6 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.9.0 through 5.9.5. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.9 series is binary compatible with the 5.8.x series. +Applications compiled for 5.8 will continue to run with 5.9. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.9.6 Changes * +**************************************************************************** + + - This release contains only minor code improvements. diff --git a/src/shared/qtscript/examples/examples.pro b/src/shared/qtscript/examples/examples.pro new file mode 100644 index 00000000..cb8b5a24 --- /dev/null +++ b/src/shared/qtscript/examples/examples.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS += script diff --git a/src/shared/qtscript/examples/script/README b/src/shared/qtscript/examples/script/README new file mode 100644 index 00000000..9d37dec7 --- /dev/null +++ b/src/shared/qtscript/examples/script/README @@ -0,0 +1,9 @@ +Qt is provided with a powerful embedded scripting environment through the Qt Script +classes. + +These examples demonstrate the fundamental aspects of scripting applications +with Qt. + + +Documentation for these examples can be found via the Examples +link in the main Qt documentation. diff --git a/src/shared/qtscript/examples/script/calculator/calculator.js b/src/shared/qtscript/examples/script/calculator/calculator.js new file mode 100644 index 00000000..ac3c1b69 --- /dev/null +++ b/src/shared/qtscript/examples/script/calculator/calculator.js @@ -0,0 +1,281 @@ +Function.prototype.bind = function() { + var func = this; + var thisObject = arguments[0]; + var args = Array.prototype.slice.call(arguments, 1); + return function() { + return func.apply(thisObject, args); + } +} + +//! [0] +function Calculator(ui) +{ + this.ui = ui; + + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; + this.sumInMemory = 0; + this.sumSoFar = 0; + this.factorSoFar = 0; + this.waitingForOperand = true; + + with (ui) { + display.text = "0"; + + zeroButton.clicked.connect(this.digitClicked.bind(this, 0)); + oneButton.clicked.connect(this.digitClicked.bind(this, 1)); + twoButton.clicked.connect(this.digitClicked.bind(this, 2)); + threeButton.clicked.connect(this.digitClicked.bind(this, 3)); + fourButton.clicked.connect(this.digitClicked.bind(this, 4)); + fiveButton.clicked.connect(this.digitClicked.bind(this, 5)); + sixButton.clicked.connect(this.digitClicked.bind(this, 6)); + sevenButton.clicked.connect(this.digitClicked.bind(this, 7)); + eightButton.clicked.connect(this.digitClicked.bind(this, 8)); + nineButton.clicked.connect(this.digitClicked.bind(this, 9)); + + pointButton.clicked.connect(this, "pointClicked"); + changeSignButton.clicked.connect(this, "changeSignClicked"); + + backspaceButton.clicked.connect(this, "backspaceClicked"); + clearButton.clicked.connect(this, "clear"); + clearAllButton.clicked.connect(this, "clearAll"); + + clearMemoryButton.clicked.connect(this, "clearMemory"); + readMemoryButton.clicked.connect(this, "readMemory"); + setMemoryButton.clicked.connect(this, "setMemory"); + addToMemoryButton.clicked.connect(this, "addToMemory"); + + divisionButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.DIVISION_OPERATOR)); + timesButton.clicked.connect(this.multiplicativeOperatorClicked.bind(this, Calculator.TIMES_OPERATOR)); + minusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.MINUS_OPERATOR)); + plusButton.clicked.connect(this.additiveOperatorClicked.bind(this, Calculator.PLUS_OPERATOR)); + + squareRootButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.SQUARE_OPERATOR)); + powerButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.POWER_OPERATOR)); + reciprocalButton.clicked.connect(this.unaryOperatorClicked.bind(this, Calculator.RECIPROCAL_OPERATOR)); + equalButton.clicked.connect(this, "equalClicked"); + } +} +//! [0] + +Calculator.NO_OPERATOR = 0; +Calculator.SQUARE_OPERATOR = 1; +Calculator.POWER_OPERATOR = 2; +Calculator.RECIPROCAL_OPERATOR = 3; +Calculator.DIVISION_OPERATOR = 4; +Calculator.TIMES_OPERATOR = 5; +Calculator.MINUS_OPERATOR = 6; +Calculator.PLUS_OPERATOR = 7; + +Calculator.prototype.abortOperation = function() +{ + this.clearAll(); + this.ui.display.text = "####"; +} + +Calculator.prototype.calculate = function(rightOperand, pendingOperator) +{ + if (pendingOperator == Calculator.PLUS_OPERATOR) { + this.sumSoFar += rightOperand; + } else if (pendingOperator == Calculator.MINUS_OPERATOR) { + this.sumSoFar -= rightOperand; + } else if (pendingOperator == Calculator.TIMES_OPERATOR) { + this.factorSoFar *= rightOperand; + } else if (pendingOperator == Calculator.DIVISION_OPERATOR) { + if (rightOperand == 0) + return false; + this.factorSoFar /= rightOperand; + } + return true; +} + +//! [1] +Calculator.prototype.digitClicked = function(digitValue) +{ + if ((digitValue == 0) && (this.ui.display.text == "0")) + return; + if (this.waitingForOperand) { + this.ui.display.clear(); + this.waitingForOperand = false; + } + this.ui.display.text += digitValue; +} +//! [1] + +Calculator.prototype.unaryOperatorClicked = function(op) +{ + var operand = this.ui.display.text - 0; + var result = 0; + if (op == Calculator.SQUARE_OPERATOR) { + if (operand < 0) { + this.abortOperation(); + return; + } + result = Math.sqrt(operand); + } else if (op == Calculator.POWER_OPERATOR) { + result = Math.pow(operand, 2); + } else if (op == Calculator.RECIPROCAL_OPERATOR) { + if (operand == 0.0) { + this.abortOperation(); + return; + } + result = 1 / operand; + } + this.ui.display.text = result + ""; + this.waitingForOperand = true; +} + +Calculator.prototype.additiveOperatorClicked = function(op) +{ + var operand = this.ui.display.text - 0; + + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { + if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { + this.abortOperation(); + return; + } + this.ui.display.text = this.factorSoFar + ""; + operand = this.factorSoFar; + this.factorSoFar = 0; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; + } + + if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) { + if (!this.calculate(operand, this.pendingAdditiveOperator)) { + this.abortOperation(); + return; + } + this.ui.display.text = this.sumSoFar + ""; + } else { + this.sumSoFar = operand; + } + + this.pendingAdditiveOperator = op; + this.waitingForOperand = true; +} + +Calculator.prototype.multiplicativeOperatorClicked = function(op) +{ + var operand = this.ui.display.text - 0; + + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { + if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { + this.abortOperation(); + return; + } + this.ui.display.text = this.factorSoFar + ""; + } else { + this.factorSoFar = operand; + } + + this.pendingMultiplicativeOperator = op; + this.waitingForOperand = true; +} + +Calculator.prototype.equalClicked = function() +{ + var operand = this.ui.display.text - 0; + + if (this.pendingMultiplicativeOperator != Calculator.NO_OPERATOR) { + if (!this.calculate(operand, this.pendingMultiplicativeOperator)) { + this.abortOperation(); + return; + } + operand = this.factorSoFar; + this.factorSoFar = 0.0; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; + } + if (this.pendingAdditiveOperator != Calculator.NO_OPERATOR) { + if (!this.calculate(operand, this.pendingAdditiveOperator)) { + this.abortOperation(); + return; + } + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; + } else { + this.sumSoFar = operand; + } + + this.ui.display.text = this.sumSoFar + ""; + this.sumSoFar = 0.0; + this.waitingForOperand = true; +} + +Calculator.prototype.pointClicked = function() +{ + if (this.waitingForOperand) + this.ui.display.text = "0"; + if (this.ui.display.text.indexOf(".") == -1) + this.ui.display.text += "."; + this.waitingForOperand = false; +} + +//! [2] +Calculator.prototype.changeSignClicked = function() +{ + var text = this.ui.display.text; + var value = text - 0; + + if (value > 0) { + text = "-" + text; + } else if (value < 0) { + text = text.slice(1); + } + this.ui.display.text = text; +} +//! [2] + +Calculator.prototype.backspaceClicked = function() +{ + if (this.waitingForOperand) + return; + + var text = this.ui.display.text; + text = text.slice(0, -1); + if (text.length == 0) { + text = "0"; + this.waitingForOperand = true; + } + this.ui.display.text = text; +} + +Calculator.prototype.clear = function() +{ + if (this.waitingForOperand) + return; + + this.ui.display.text = "0"; + this.waitingForOperand = true; +} + +Calculator.prototype.clearAll = function() +{ + this.sumSoFar = 0.0; + this.factorSoFar = 0.0; + this.pendingAdditiveOperator = Calculator.NO_OPERATOR; + this.pendingMultiplicativeOperator = Calculator.NO_OPERATOR; + this.ui.display.text = "0"; + this.waitingForOperand = true; +} + +Calculator.prototype.clearMemory = function() +{ + this.sumInMemory = 0.0; +} + +Calculator.prototype.readMemory = function() +{ + this.ui.display.text = this.sumInMemory + ""; + this.waitingForOperand = true; +} + +Calculator.prototype.setMemory = function() +{ + this.equalClicked(); + this.sumInMemory = this.ui.display.text - 0; +} + +Calculator.prototype.addToMemory = function() +{ + this.equalClicked(); + this.sumInMemory += this.ui.display.text - 0; +} diff --git a/src/shared/qtscript/examples/script/calculator/calculator.pro b/src/shared/qtscript/examples/script/calculator/calculator.pro new file mode 100644 index 00000000..985147af --- /dev/null +++ b/src/shared/qtscript/examples/script/calculator/calculator.pro @@ -0,0 +1,11 @@ +QT += script widgets uitools +RESOURCES += calculator.qrc +SOURCES += main.cpp +QMAKE_PROJECT_NAME = scripted_calculator + +qtHaveModule(scripttools): QT += scripttools + +target.path = $$[QT_INSTALL_EXAMPLES]/script/calculator +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/calculator/calculator.qrc b/src/shared/qtscript/examples/script/calculator/calculator.qrc new file mode 100644 index 00000000..afa66866 --- /dev/null +++ b/src/shared/qtscript/examples/script/calculator/calculator.qrc @@ -0,0 +1,6 @@ + + + calculator.js + calculator.ui + + diff --git a/src/shared/qtscript/examples/script/calculator/calculator.ui b/src/shared/qtscript/examples/script/calculator/calculator.ui new file mode 100644 index 00000000..88cddeab --- /dev/null +++ b/src/shared/qtscript/examples/script/calculator/calculator.ui @@ -0,0 +1,416 @@ + + + Calculator + + + + 0 + 0 + 314 + 301 + + + + + 0 + 0 + + + + + 314 + 301 + + + + + 1024 + 768 + + + + Calculator + + + + + + 10 + + + + + + 0 + 0 + + + + Backspace + + + + + + + + 0 + 0 + + + + MC + + + + + + + + 0 + 0 + + + + 7 + + + + + + + + 0 + 0 + + + + 8 + + + + + + + + 0 + 0 + + + + 9 + + + + + + + + 0 + 0 + + + + / + + + + + + + + 0 + 0 + + + + Sqrt + + + + + + + + 0 + 0 + + + + Clear + + + + + + + + 0 + 0 + + + + Clear All + + + + + + + + 0 + 0 + + + + 24 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + 0 + 0 + + + + MR + + + + + + + + 0 + 0 + + + + 4 + + + + + + + + 0 + 0 + + + + 5 + + + + + + + + 0 + 0 + + + + 6 + + + + + + + + 0 + 0 + + + + * + + + + + + + + 0 + 0 + + + + x^2 + + + + + + + + 0 + 0 + + + + MS + + + + + + + + 0 + 0 + + + + 1 + + + + + + + + 0 + 0 + + + + 2 + + + + + + + + 0 + 0 + + + + 3 + + + + + + + + 0 + 0 + + + + - + + + + + + + + 0 + 0 + + + + 1/x + + + + + + + + 0 + 0 + + + + M+ + + + + + + + + 0 + 0 + + + + 0 + + + + + + + + 0 + 0 + + + + . + + + + + + + + 0 + 0 + + + + +- + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + = + + + + + + + + + + diff --git a/src/shared/qtscript/examples/script/calculator/main.cpp b/src/shared/qtscript/examples/script/calculator/main.cpp new file mode 100644 index 00000000..a50ed989 --- /dev/null +++ b/src/shared/qtscript/examples/script/calculator/main.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef QT_NO_SCRIPTTOOLS +#include +#endif + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(calculator); + + QApplication app(argc, argv); +//! [0a] + QScriptEngine engine; +//! [0a] + +#if !defined(QT_NO_SCRIPTTOOLS) + QScriptEngineDebugger debugger; + debugger.attachTo(&engine); + QMainWindow *debugWindow = debugger.standardWindow(); + debugWindow->resize(1024, 640); +#endif + +//! [0b] + QString scriptFileName(":/calculator.js"); + QFile scriptFile(scriptFileName); + scriptFile.open(QIODevice::ReadOnly); + engine.evaluate(scriptFile.readAll(), scriptFileName); + scriptFile.close(); +//! [0b] + +//! [1] + QUiLoader loader; + QFile uiFile(":/calculator.ui"); + uiFile.open(QIODevice::ReadOnly); + QWidget *ui = loader.load(&uiFile); + uiFile.close(); +//! [1] + +//! [2] + QScriptValue ctor = engine.evaluate("Calculator"); + QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership); + QScriptValue calc = ctor.construct(QScriptValueList() << scriptUi); +//! [2] + +#if !defined(QT_NO_SCRIPTTOOLS) + QLineEdit *display = ui->findChild("display"); + QObject::connect(display, SIGNAL(returnPressed()), + debugWindow, SLOT(show())); +#endif +//! [3] + ui->show(); + return app.exec(); +//! [3] +} diff --git a/src/shared/qtscript/examples/script/context2d/context2d.cpp b/src/shared/qtscript/examples/script/context2d/context2d.cpp new file mode 100644 index 00000000..beaa7174 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/context2d.cpp @@ -0,0 +1,830 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "context2d.h" + +#include +#include + +#define qClamp(val, min, max) qMin(qMax(val, min), max) +static QList parseNumbersList(QString::const_iterator &itr) +{ + QList points; + QString temp; + while ((*itr).isSpace()) + ++itr; + while ((*itr).isNumber() || + (*itr) == '-' || (*itr) == '+' || (*itr) == '.') { + temp = QString(); + + if ((*itr) == '-') + temp += *itr++; + else if ((*itr) == '+') + temp += *itr++; + while ((*itr).isDigit()) + temp += *itr++; + if ((*itr) == '.') + temp += *itr++; + while ((*itr).isDigit()) + temp += *itr++; + while ((*itr).isSpace()) + ++itr; + if ((*itr) == ',') + ++itr; + points.append(temp.toDouble()); + //eat spaces + while ((*itr).isSpace()) + ++itr; + } + + return points; +} + +QColor colorFromString(const QString &name) +{ + QString::const_iterator itr = name.constBegin(); + QList compo; + if (name.startsWith("rgba(")) { + ++itr; ++itr; ++itr; ++itr; ++itr; + compo = parseNumbersList(itr); + if (compo.size() != 4) { + return QColor(); + } + //alpha seems to be always between 0-1 + compo[3] *= 255; + return QColor((int)compo[0], (int)compo[1], + (int)compo[2], (int)compo[3]); + } else if (name.startsWith("rgb(")) { + ++itr; ++itr; ++itr; ++itr; + compo = parseNumbersList(itr); + if (compo.size() != 3) { + return QColor(); + } + return QColor((int)qClamp(compo[0], qreal(0), qreal(255)), + (int)qClamp(compo[1], qreal(0), qreal(255)), + (int)qClamp(compo[2], qreal(0), qreal(255))); + } else { + //QRgb color; + //CSSParser::parseColor(name, color); + return QColor(name); + } +} + + +static QPainter::CompositionMode compositeOperatorFromString(const QString &compositeOperator) +{ + if ( compositeOperator == "source-over" ) { + return QPainter::CompositionMode_SourceOver; + } else if ( compositeOperator == "source-out" ) { + return QPainter::CompositionMode_SourceOut; + } else if ( compositeOperator == "source-in" ) { + return QPainter::CompositionMode_SourceIn; + } else if ( compositeOperator == "source-atop" ) { + return QPainter::CompositionMode_SourceAtop; + } else if ( compositeOperator == "destination-atop" ) { + return QPainter::CompositionMode_DestinationAtop; + } else if ( compositeOperator == "destination-in" ) { + return QPainter::CompositionMode_DestinationIn; + } else if ( compositeOperator == "destination-out" ) { + return QPainter::CompositionMode_DestinationOut; + } else if ( compositeOperator == "destination-over" ) { + return QPainter::CompositionMode_DestinationOver; + } else if ( compositeOperator == "darker" ) { + return QPainter::CompositionMode_SourceOver; + } else if ( compositeOperator == "lighter" ) { + return QPainter::CompositionMode_SourceOver; + } else if ( compositeOperator == "copy" ) { + return QPainter::CompositionMode_Source; + } else if ( compositeOperator == "xor" ) { + return QPainter::CompositionMode_Xor; + } + + return QPainter::CompositionMode_SourceOver; +} + +static QString compositeOperatorToString(QPainter::CompositionMode op) +{ + switch (op) { + case QPainter::CompositionMode_SourceOver: + return "source-over"; + case QPainter::CompositionMode_DestinationOver: + return "destination-over"; + case QPainter::CompositionMode_Clear: + return "clear"; + case QPainter::CompositionMode_Source: + return "source"; + case QPainter::CompositionMode_Destination: + return "destination"; + case QPainter::CompositionMode_SourceIn: + return "source-in"; + case QPainter::CompositionMode_DestinationIn: + return "destination-in"; + case QPainter::CompositionMode_SourceOut: + return "source-out"; + case QPainter::CompositionMode_DestinationOut: + return "destination-out"; + case QPainter::CompositionMode_SourceAtop: + return "source-atop"; + case QPainter::CompositionMode_DestinationAtop: + return "destination-atop"; + case QPainter::CompositionMode_Xor: + return "xor"; + case QPainter::CompositionMode_Plus: + return "plus"; + case QPainter::CompositionMode_Multiply: + return "multiply"; + case QPainter::CompositionMode_Screen: + return "screen"; + case QPainter::CompositionMode_Overlay: + return "overlay"; + case QPainter::CompositionMode_Darken: + return "darken"; + case QPainter::CompositionMode_Lighten: + return "lighten"; + case QPainter::CompositionMode_ColorDodge: + return "color-dodge"; + case QPainter::CompositionMode_ColorBurn: + return "color-burn"; + case QPainter::CompositionMode_HardLight: + return "hard-light"; + case QPainter::CompositionMode_SoftLight: + return "soft-light"; + case QPainter::CompositionMode_Difference: + return "difference"; + case QPainter::CompositionMode_Exclusion: + return "exclusion"; + default: + break; + } + return QString(); +} + +void Context2D::save() +{ + m_stateStack.push(m_state); +} + + +void Context2D::restore() +{ + if (!m_stateStack.isEmpty()) { + m_state = m_stateStack.pop(); + m_state.flags = AllIsFullOfDirt; + } +} + + +void Context2D::scale(qreal x, qreal y) +{ + m_state.matrix.scale(x, y); + m_state.flags |= DirtyTransformationMatrix; +} + + +void Context2D::rotate(qreal angle) +{ + m_state.matrix.rotate(qRadiansToDegrees(angle)); + m_state.flags |= DirtyTransformationMatrix; +} + + +void Context2D::translate(qreal x, qreal y) +{ + m_state.matrix.translate(x, y); + m_state.flags |= DirtyTransformationMatrix; +} + + +void Context2D::transform(qreal m11, qreal m12, qreal m21, qreal m22, + qreal dx, qreal dy) +{ + QTransform mat(m11, m12, + m21, m22, + dx, dy); + m_state.matrix *= mat; + m_state.flags |= DirtyTransformationMatrix; +} + + +void Context2D::setTransform(qreal m11, qreal m12, qreal m21, qreal m22, + qreal dx, qreal dy) +{ + QTransform mat(m11, m12, + m21, m22, + dx, dy); + m_state.matrix = mat; + m_state.flags |= DirtyTransformationMatrix; +} + + +QString Context2D::globalCompositeOperation() const +{ + return compositeOperatorToString(m_state.globalCompositeOperation); +} + +void Context2D::setGlobalCompositeOperation(const QString &op) +{ + QPainter::CompositionMode mode = + compositeOperatorFromString(op); + m_state.globalCompositeOperation = mode; + m_state.flags |= DirtyGlobalCompositeOperation; +} + +QVariant Context2D::strokeStyle() const +{ + return m_state.strokeStyle; +} + +void Context2D::setStrokeStyle(const QVariant &style) +{ + if (style.canConvert()) { + CanvasGradient cg = qvariant_cast(style); + m_state.strokeStyle = cg.value; + } else { + QColor color = colorFromString(style.toString()); + m_state.strokeStyle = color; + } + m_state.flags |= DirtyStrokeStyle; +} + +QVariant Context2D::fillStyle() const +{ + return m_state.fillStyle; +} + +//! [3] +void Context2D::setFillStyle(const QVariant &style) +{ + if (style.canConvert()) { + CanvasGradient cg = qvariant_cast(style); + m_state.fillStyle = cg.value; + } else { + QColor color = colorFromString(style.toString()); + m_state.fillStyle = color; + } + m_state.flags |= DirtyFillStyle; +} +//! [3] + +qreal Context2D::globalAlpha() const +{ + return m_state.globalAlpha; +} + +void Context2D::setGlobalAlpha(qreal alpha) +{ + m_state.globalAlpha = alpha; + m_state.flags |= DirtyGlobalAlpha; +} + + +CanvasGradient Context2D::createLinearGradient(qreal x0, qreal y0, + qreal x1, qreal y1) +{ + QLinearGradient g(x0, y0, x1, y1); + return CanvasGradient(g); +} + + +CanvasGradient Context2D::createRadialGradient(qreal x0, qreal y0, + qreal r0, qreal x1, + qreal y1, qreal r1) +{ + QRadialGradient g(QPointF(x1, y1), r0+r1, QPointF(x0, y0)); + return CanvasGradient(g); +} + +qreal Context2D::lineWidth() const +{ + return m_state.lineWidth; +} + +void Context2D::setLineWidth(qreal w) +{ + m_state.lineWidth = w; + m_state.flags |= DirtyLineWidth; +} + +//! [0] +QString Context2D::lineCap() const +{ + switch (m_state.lineCap) { + case Qt::FlatCap: + return "butt"; + case Qt::SquareCap: + return "square"; + case Qt::RoundCap: + return "round"; + default: ; + } + return QString(); +} + +void Context2D::setLineCap(const QString &capString) +{ + Qt::PenCapStyle style; + if (capString == "round") + style = Qt::RoundCap; + else if (capString == "square") + style = Qt::SquareCap; + else //if (capString == "butt") + style = Qt::FlatCap; + m_state.lineCap = style; + m_state.flags |= DirtyLineCap; +} +//! [0] + +QString Context2D::lineJoin() const +{ + switch (m_state.lineJoin) { + case Qt::RoundJoin: + return "round"; + case Qt::BevelJoin: + return "bevel"; + case Qt::MiterJoin: + return "miter"; + default: ; + } + return QString(); +} + +void Context2D::setLineJoin(const QString &joinString) +{ + Qt::PenJoinStyle style; + if (joinString == "round") + style = Qt::RoundJoin; + else if (joinString == "bevel") + style = Qt::BevelJoin; + else //if (joinString == "miter") + style = Qt::MiterJoin; + m_state.lineJoin = style; + m_state.flags |= DirtyLineJoin; +} + +qreal Context2D::miterLimit() const +{ + return m_state.miterLimit; +} + +void Context2D::setMiterLimit(qreal m) +{ + m_state.miterLimit = m; + m_state.flags |= DirtyMiterLimit; +} + +void Context2D::setShadowOffsetX(qreal x) +{ + m_state.shadowOffsetX = x; + m_state.flags |= DirtyShadowOffsetX; +} + +void Context2D::setShadowOffsetY(qreal y) +{ + m_state.shadowOffsetY = y; + m_state.flags |= DirtyShadowOffsetY; +} + +void Context2D::setShadowBlur(qreal b) +{ + m_state.shadowBlur = b; + m_state.flags |= DirtyShadowBlur; +} + +void Context2D::setShadowColor(const QString &str) +{ + m_state.shadowColor = colorFromString(str); + m_state.flags |= DirtyShadowColor; +} + +qreal Context2D::shadowOffsetX() const +{ + return m_state.shadowOffsetX; +} + +qreal Context2D::shadowOffsetY() const +{ + return m_state.shadowOffsetY; +} + + +qreal Context2D::shadowBlur() const +{ + return m_state.shadowBlur; +} + + +QString Context2D::shadowColor() const +{ + return m_state.shadowColor.name(); +} + + +void Context2D::clearRect(qreal x, qreal y, qreal w, qreal h) +{ + beginPainting(); + m_painter.save(); + m_painter.setTransform(QTransform(m_state.matrix), false); + m_painter.setCompositionMode(QPainter::CompositionMode_Source); + m_painter.fillRect(QRectF(x, y, w, h), QColor(0, 0, 0, 0)); + m_painter.restore(); + scheduleChange(); +} + + +//! [1] +void Context2D::fillRect(qreal x, qreal y, qreal w, qreal h) +{ + beginPainting(); + m_painter.save(); + m_painter.setTransform(QTransform(m_state.matrix), false); + m_painter.fillRect(QRectF(x, y, w, h), m_painter.brush()); + m_painter.restore(); + scheduleChange(); +} +//! [1] + + +void Context2D::strokeRect(qreal x, qreal y, qreal w, qreal h) +{ + QPainterPath path; + path.addRect(x, y, w, h); + beginPainting(); + m_painter.save(); + m_painter.setTransform(QTransform(m_state.matrix), false); + m_painter.strokePath(path, m_painter.pen()); + m_painter.restore(); + scheduleChange(); +} + + +void Context2D::beginPath() +{ + m_path = QPainterPath(); +} + + +void Context2D::closePath() +{ + m_path.closeSubpath(); +} + + +void Context2D::moveTo(qreal x, qreal y) +{ + QPointF pt = m_state.matrix.map(QPointF(x, y)); + m_path.moveTo(pt); +} + + +void Context2D::lineTo(qreal x, qreal y) +{ + QPointF pt = m_state.matrix.map(QPointF(x, y)); + m_path.lineTo(pt); +} + + +void Context2D::quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y) +{ + QPointF cp = m_state.matrix.map(QPointF(cpx, cpy)); + QPointF xy = m_state.matrix.map(QPointF(x, y)); + m_path.quadTo(cp, xy); +} + + +void Context2D::bezierCurveTo(qreal cp1x, qreal cp1y, + qreal cp2x, qreal cp2y, qreal x, qreal y) +{ + QPointF cp1 = m_state.matrix.map(QPointF(cp1x, cp1y)); + QPointF cp2 = m_state.matrix.map(QPointF(cp2x, cp2y)); + QPointF end = m_state.matrix.map(QPointF(x, y)); + m_path.cubicTo(cp1, cp2, end); +} + + +void Context2D::arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius) +{ + //FIXME: this is surely busted + QPointF st = m_state.matrix.map(QPointF(x1, y1)); + QPointF end = m_state.matrix.map(QPointF(x2, y2)); + m_path.arcTo(st.x(), st.y(), + end.x()-st.x(), end.y()-st.y(), + radius, 90); +} + + +void Context2D::rect(qreal x, qreal y, qreal w, qreal h) +{ + QPainterPath path; path.addRect(x, y, w, h); + path = m_state.matrix.map(path); + m_path.addPath(path); +} + +void Context2D::arc(qreal xc, qreal yc, qreal radius, + qreal sar, qreal ear, + bool anticlockwise) +{ + //### HACK + // In Qt we don't switch the coordinate system for degrees + // and still use the 0,0 as bottom left for degrees so we need + // to switch + sar = -sar; + ear = -ear; + anticlockwise = !anticlockwise; + //end hack + + float sa = qRadiansToDegrees(sar); + float ea = qRadiansToDegrees(ear); + + double span = 0; + + double xs = xc - radius; + double ys = yc - radius; + double width = radius*2; + double height = radius*2; + + if (!anticlockwise && (ea < sa)) { + span += 360; + } else if (anticlockwise && (sa < ea)) { + span -= 360; + } + + //### this is also due to switched coordinate system + // we would end up with a 0 span instead of 360 + if (!(qFuzzyCompare(span + (ea - sa) + 1, 1) && + qFuzzyCompare(qAbs(span), 360))) { + span += ea - sa; + } + + QPainterPath path; + path.moveTo(QPointF(xc + radius * cos(sar), + yc - radius * sin(sar))); + + path.arcTo(xs, ys, width, height, sa, span); + path = m_state.matrix.map(path); + m_path.addPath(path); +} + + +void Context2D::fill() +{ + beginPainting(); + m_painter.fillPath(m_path, m_painter.brush()); + scheduleChange(); +} + + +void Context2D::stroke() +{ + beginPainting(); + m_painter.save(); + m_painter.setTransform(QTransform(m_state.matrix), false); + QPainterPath tmp = m_state.matrix.inverted().map(m_path); + m_painter.strokePath(tmp, m_painter.pen()); + m_painter.restore(); + scheduleChange(); +} + + +void Context2D::clip() +{ + m_state.clipPath = m_path; + m_state.flags |= DirtyClippingRegion; +} + + +bool Context2D::isPointInPath(qreal x, qreal y) const +{ + return m_path.contains(QPointF(x, y)); +} + + +ImageData Context2D::getImageData(qreal sx, qreal sy, qreal sw, qreal sh) +{ + Q_UNUSED(sx); + Q_UNUSED(sy); + Q_UNUSED(sw); + Q_UNUSED(sh); + return ImageData(); +} + + +void Context2D::putImageData(ImageData image, qreal dx, qreal dy) +{ + Q_UNUSED(image); + Q_UNUSED(dx); + Q_UNUSED(dy); +} + +Context2D::Context2D(QObject *parent) + : QObject(parent), m_changeTimerId(-1) +{ + reset(); +} + +const QImage &Context2D::endPainting() +{ + if (m_painter.isActive()) + m_painter.end(); + return m_image; +} + +void Context2D::beginPainting() +{ + if (!m_painter.isActive()) { + m_painter.begin(&m_image); + m_painter.setRenderHint(QPainter::Antialiasing); + if (!m_state.clipPath.isEmpty()) + m_painter.setClipPath(m_state.clipPath); + m_painter.setBrush(m_state.fillStyle); + m_painter.setOpacity(m_state.globalAlpha); + QPen pen; + pen.setBrush(m_state.strokeStyle); + if (pen.style() == Qt::NoPen) + pen.setStyle(Qt::SolidLine); + pen.setCapStyle(m_state.lineCap); + pen.setJoinStyle(m_state.lineJoin); + pen.setWidthF(m_state.lineWidth); + pen.setMiterLimit(m_state.miterLimit); + m_painter.setPen(pen); + } else { + if ((m_state.flags & DirtyClippingRegion) && !m_state.clipPath.isEmpty()) + m_painter.setClipPath(m_state.clipPath); + if (m_state.flags & DirtyFillStyle) + m_painter.setBrush(m_state.fillStyle); + if (m_state.flags & DirtyGlobalAlpha) + m_painter.setOpacity(m_state.globalAlpha); + if (m_state.flags & DirtyGlobalCompositeOperation) + m_painter.setCompositionMode(m_state.globalCompositeOperation); + if (m_state.flags & MDirtyPen) { + QPen pen = m_painter.pen(); + if (m_state.flags & DirtyStrokeStyle) + pen.setBrush(m_state.strokeStyle); + if (m_state.flags & DirtyLineWidth) + pen.setWidthF(m_state.lineWidth); + if (m_state.flags & DirtyLineCap) + pen.setCapStyle(m_state.lineCap); + if (m_state.flags & DirtyLineJoin) + pen.setJoinStyle(m_state.lineJoin); + if (m_state.flags & DirtyMiterLimit) + pen.setMiterLimit(m_state.miterLimit); + m_painter.setPen(pen); + } + m_state.flags = 0; + } +} + +void Context2D::clear() +{ + endPainting(); + m_image.fill(qRgba(0,0,0,0)); + scheduleChange(); +} + +void Context2D::reset() +{ + m_stateStack.clear(); + m_state.matrix = QTransform(); + m_state.clipPath = QPainterPath(); + m_state.globalAlpha = 1.0; + m_state.globalCompositeOperation = QPainter::CompositionMode_SourceOver; + m_state.strokeStyle = Qt::black; + m_state.fillStyle = Qt::black; + m_state.lineWidth = 1; + m_state.lineCap = Qt::FlatCap; + m_state.lineJoin = Qt::MiterJoin; + m_state.miterLimit = 10; + m_state.shadowOffsetX = 0; + m_state.shadowOffsetY = 0; + m_state.shadowBlur = 0; + m_state.shadowColor = qRgba(0, 0, 0, 0); + m_state.flags = AllIsFullOfDirt; + clear(); +} + +void Context2D::setSize(int width, int height) +{ + endPainting(); + QImage newi(width, height, QImage::Format_ARGB32_Premultiplied); + newi.fill(qRgba(0,0,0,0)); + QPainter p(&newi); + p.drawImage(0, 0, m_image); + p.end(); + m_image = newi; + scheduleChange(); +} + +void Context2D::setSize(const QSize &size) +{ + setSize(size.width(), size.height()); +} + +QSize Context2D::size() const +{ + return m_image.size(); +} + +void Context2D::drawImage(DomImage *image, qreal dx, qreal dy) +{ + if (!image) + return; + if (dx < 0) { + qreal sx = qAbs(dx); + qreal sy = qAbs(dy); + qreal sw = image->width() - sx; + qreal sh = image->height() - sy; + + drawImage(image, sx, sy, sw, sh, 0, 0, sw, sh); + } else { + beginPainting(); + m_painter.drawImage(QPointF(dx, dy), image->image()); + scheduleChange(); + } +} + +void Context2D::drawImage(DomImage *image, qreal dx, qreal dy, + qreal dw, qreal dh) +{ + if (!image) + return; + beginPainting(); + m_painter.drawImage(QRectF(dx, dy, dw, dh).toRect(), image->image()); + scheduleChange(); +} + +void Context2D::drawImage(DomImage *image, qreal sx, qreal sy, + qreal sw, qreal sh, qreal dx, qreal dy, + qreal dw, qreal dh) +{ + if (!image) + return; + beginPainting(); + m_painter.drawImage(QRectF(dx, dy, dw, dh), image->image(), + QRectF(sx, sy, sw, sh)); + scheduleChange(); +} + +//! [2] +void Context2D::scheduleChange() +{ + if (m_changeTimerId == -1) + m_changeTimerId = startTimer(0); +} + +void Context2D::timerEvent(QTimerEvent *e) +{ + if (e->timerId() == m_changeTimerId) { + killTimer(m_changeTimerId); + m_changeTimerId = -1; + emit changed(endPainting()); + } else { + QObject::timerEvent(e); + } +} +//! [2] diff --git a/src/shared/qtscript/examples/script/context2d/context2d.h b/src/shared/qtscript/examples/script/context2d/context2d.h new file mode 100644 index 00000000..108e6b5e --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/context2d.h @@ -0,0 +1,270 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef CONTEXT2D_H +#define CONTEXT2D_H + +#include "domimage.h" + +#include +#include +#include +#include +#include +#include + +// [3] +class CanvasGradient +{ +public: + CanvasGradient(const QGradient &v) + : value(v) {} + CanvasGradient() {} + + QGradient value; +}; +// [3] + +Q_DECLARE_METATYPE(CanvasGradient) +Q_DECLARE_METATYPE(CanvasGradient*) + +class ImageData { +}; + +class QContext2DCanvas; + +//! [0] +class Context2D : public QObject +{ + Q_OBJECT + // compositing + Q_PROPERTY(qreal globalAlpha READ globalAlpha WRITE setGlobalAlpha) + Q_PROPERTY(QString globalCompositeOperation READ globalCompositeOperation WRITE setGlobalCompositeOperation) + Q_PROPERTY(QVariant strokeStyle READ strokeStyle WRITE setStrokeStyle) + Q_PROPERTY(QVariant fillStyle READ fillStyle WRITE setFillStyle) + // line caps/joins + Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth) + Q_PROPERTY(QString lineCap READ lineCap WRITE setLineCap) + Q_PROPERTY(QString lineJoin READ lineJoin WRITE setLineJoin) + Q_PROPERTY(qreal miterLimit READ miterLimit WRITE setMiterLimit) + // shadows + Q_PROPERTY(qreal shadowOffsetX READ shadowOffsetX WRITE setShadowOffsetX) + Q_PROPERTY(qreal shadowOffsetY READ shadowOffsetY WRITE setShadowOffsetY) + Q_PROPERTY(qreal shadowBlur READ shadowBlur WRITE setShadowBlur) + Q_PROPERTY(QString shadowColor READ shadowColor WRITE setShadowColor) +//! [0] + +public: + Context2D(QObject *parent = 0); + void setSize(int width, int height); + void setSize(const QSize &size); + QSize size() const; + + void clear(); + void reset(); + + // compositing + qreal globalAlpha() const; // (default 1.0) + QString globalCompositeOperation() const; // (default over) + QVariant strokeStyle() const; // (default black) + QVariant fillStyle() const; // (default black) + + void setGlobalAlpha(qreal alpha); + void setGlobalCompositeOperation(const QString &op); + void setStrokeStyle(const QVariant &style); + void setFillStyle(const QVariant &style); + + // line caps/joins + qreal lineWidth() const; // (default 1) + QString lineCap() const; // "butt", "round", "square" (default "butt") + QString lineJoin() const; // "round", "bevel", "miter" (default "miter") + qreal miterLimit() const; // (default 10) + + void setLineWidth(qreal w); + void setLineCap(const QString &s); + void setLineJoin(const QString &s); + void setMiterLimit(qreal m); + + // shadows + qreal shadowOffsetX() const; // (default 0) + qreal shadowOffsetY() const; // (default 0) + qreal shadowBlur() const; // (default 0) + QString shadowColor() const; // (default black) + + void setShadowOffsetX(qreal x); + void setShadowOffsetY(qreal y); + void setShadowBlur(qreal b); + void setShadowColor(const QString &str); + +//! [1] +public slots: + void save(); // push state on state stack + void restore(); // pop state stack and restore state + + void scale(qreal x, qreal y); + void rotate(qreal angle); + void translate(qreal x, qreal y); + void transform(qreal m11, qreal m12, qreal m21, qreal m22, + qreal dx, qreal dy); + void setTransform(qreal m11, qreal m12, qreal m21, qreal m22, + qreal dx, qreal dy); + + CanvasGradient createLinearGradient(qreal x0, qreal y0, + qreal x1, qreal y1); + CanvasGradient createRadialGradient(qreal x0, qreal y0, + qreal r0, qreal x1, + qreal y1, qreal r1); + + // rects + void clearRect(qreal x, qreal y, qreal w, qreal h); + void fillRect(qreal x, qreal y, qreal w, qreal h); + void strokeRect(qreal x, qreal y, qreal w, qreal h); + + // path API + void beginPath(); + void closePath(); + void moveTo(qreal x, qreal y); + void lineTo(qreal x, qreal y); + void quadraticCurveTo(qreal cpx, qreal cpy, qreal x, qreal y); + void bezierCurveTo(qreal cp1x, qreal cp1y, + qreal cp2x, qreal cp2y, qreal x, qreal y); + void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius); + void rect(qreal x, qreal y, qreal w, qreal h); + void arc(qreal x, qreal y, qreal radius, + qreal startAngle, qreal endAngle, + bool anticlockwise); + void fill(); + void stroke(); + void clip(); + bool isPointInPath(qreal x, qreal y) const; +//! [1] + + // drawing images + void drawImage(DomImage *image, qreal dx, qreal dy); + void drawImage(DomImage *image, qreal dx, qreal dy, + qreal dw, qreal dh); + void drawImage(DomImage *image, qreal sx, qreal sy, + qreal sw, qreal sh, qreal dx, qreal dy, + qreal dw, qreal dh); + + // pixel manipulation + ImageData getImageData(qreal sx, qreal sy, qreal sw, qreal sh); + void putImageData(ImageData image, qreal dx, qreal dy); + +//! [2] +signals: + void changed(const QImage &image); +//! [2] + +protected: + void timerEvent(QTimerEvent *e); + +private: + void beginPainting(); + const QImage &endPainting(); + void scheduleChange(); + + int m_changeTimerId; + QImage m_image; + QPainter m_painter; + QPainterPath m_path; + + enum DirtyFlag { + DirtyTransformationMatrix = 0x00001, + DirtyClippingRegion = 0x00002, + DirtyStrokeStyle = 0x00004, + DirtyFillStyle = 0x00008, + DirtyGlobalAlpha = 0x00010, + DirtyLineWidth = 0x00020, + DirtyLineCap = 0x00040, + DirtyLineJoin = 0x00080, + DirtyMiterLimit = 0x00100, + MDirtyPen = DirtyStrokeStyle + | DirtyLineWidth + | DirtyLineCap + | DirtyLineJoin + | DirtyMiterLimit, + DirtyShadowOffsetX = 0x00200, + DirtyShadowOffsetY = 0x00400, + DirtyShadowBlur = 0x00800, + DirtyShadowColor = 0x01000, + DirtyGlobalCompositeOperation = 0x2000, + DirtyFont = 0x04000, + DirtyTextAlign = 0x08000, + DirtyTextBaseline = 0x10000, + AllIsFullOfDirt = 0xfffff + }; + + struct State { + State() : flags(0) {} + QTransform matrix; + QPainterPath clipPath; + QBrush strokeStyle; + QBrush fillStyle; + qreal globalAlpha; + qreal lineWidth; + Qt::PenCapStyle lineCap; + Qt::PenJoinStyle lineJoin; + qreal miterLimit; + qreal shadowOffsetX; + qreal shadowOffsetY; + qreal shadowBlur; + QColor shadowColor; + QPainter::CompositionMode globalCompositeOperation; + QFont font; + int textAlign; + int textBaseline; + int flags; + }; + State m_state; + QStack m_stateStack; +}; + +#endif diff --git a/src/shared/qtscript/examples/script/context2d/context2d.pro b/src/shared/qtscript/examples/script/context2d/context2d.pro new file mode 100644 index 00000000..483f45b5 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/context2d.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +QT += widgets script +# Input +HEADERS += qcontext2dcanvas.h \ + context2d.h \ + domimage.h \ + environment.h \ + window.h +SOURCES += qcontext2dcanvas.cpp \ + context2d.cpp \ + domimage.cpp \ + environment.cpp \ + window.cpp \ + main.cpp +RESOURCES += context2d.qrc + +qtHaveModule(scripttools): QT += scripttools + +target.path = $$[QT_INSTALL_EXAMPLES]/script/context2d +INSTALLS += target + +maemo5: CONFIG += qt_example + diff --git a/src/shared/qtscript/examples/script/context2d/context2d.qrc b/src/shared/qtscript/examples/script/context2d/context2d.qrc new file mode 100644 index 00000000..75e570cd --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/context2d.qrc @@ -0,0 +1,5 @@ + + + scripts + + diff --git a/src/shared/qtscript/examples/script/context2d/doc/images/context2d-example-smileysmile.png b/src/shared/qtscript/examples/script/context2d/doc/images/context2d-example-smileysmile.png new file mode 100644 index 0000000000000000000000000000000000000000..369f32eaa196aec85085bfe3f012e2688e3e3c17 GIT binary patch literal 3457 zcmYLM2{c=4*UoKKLqkbXQ%TiaMe(VK8fvE0+@PX{n2JQqp>i8FR}~FcqkO6{&oQ($ zU1F%2n$@hSp_EcXjNiF;{cHVut#`kB?Q_;yXT8rp&-0u(GgEywR(@6x2*hS+pko2- z{=fK2P+9$(4~7Vi8Z3V zGtP>1XfaEx1N^&FZ5QrN%QfNeZ~PJa?XYid{+E}%-SO&j`&$}_xid`j&XLA(#F-L= z24X#DkT3e**Ob?kf75HqgeEhbkT(9K#;$Z{XGb!=tfVAFEsI3r27x@3?1F-n6ZOt( zy=r+3W+L7V+k3Uc^ThxAB*h-p7Ys*Ve zi-Tk&mfo`(fcN*O+7$0H!jTFF1yx{TrUoJ6?DQlsFfd8zt{n;`{?o3frw6Euii^KC z6V4br%YN%>IH@PfWNy|Asa@-GHFYtnk>Y#u(`oNerJ zRVa6;*DH_{F`LYPkd6B|JvL^O-V>D!N$(k*n(C(GveloyG3x#_zzTs`Cd*yLoK4?-1z zKr7g0TEcH1PHMuoev~&?O|CzC_RQy_2=?bRJiTXkIh%0$d-ws%+w8l+KQo6{M?92n zJO1?z7@V}UwCU;T2@?rs1mR%I$;2da{6~B3e^BLhd3oO#XfZ6?R5vPILt}0=z!?F` zAI`|m7XCWz63~rT%Q}CNeI-EEyYs)ptL%a*^S?r3pAu_oYJfwVBb+_eFU1502M_f1 zv9Ys5>F&Gu6X0=vf@c)gA3uJ?ToxYtvHLtE61cyrs;aBY&|6;t4!5nmb)oO`c4tz0dNY1kdM{AE#%^Y6%E*v$ zx3sj>t46gWW0OJ=d!{L`sHolcDQ93=Kv=kL(i;TQjzS3~x!2h3 zZ+yL4)5m`KGEM&e^AfvK9wLllu^OQI)->Ou@Hxz&cr@iBee){bi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<^dGJKs$jL_!nV zp($M+N~cGg%>XZOFwwt#b9MhG&Vv9tR1+F#Z6)@(X>$O|V{Ky-t$L$3h~%-lwx+#Q!SF|iun&;|O;7wdymiowda<6^yjvH8}+LbDkeE^3kDhUEzkMqajU|=Yi z>BBNU%DE&tIeBPk$T5N;He0*cvJqq~3Jo6+GvvupbQXoO$mYwL=NEGXUR4ntk3gjB zh$Qy{a`~=AQBe^Z$F!{IjD?66T9#mA-3e_+`#;AuL4=_(Fc&$Akg>2 z2rgTNRU*}H-@bk4js#CaXGh29^*;a@+nj#^{-mw#IZ~$M>>N|Z`M_4Rsuqvm`owMO zWUm_)Fr1q+^~<|>LnvsvKDfN0A+yho-1pt3^Cf4MOI7WrOa4om+r=L!Jh(#jm_T^0BsG&VLiI2>*mZYORznW*xA z9{!%fQ^q!>q5|;vf5HrMhpMPl?Km1BCxF1C(HH*T%JZ#3Dv=Nxmh0$`pxCOp7=4@K zz=#MT-64$EInb5~nuCcC60He?Z3uE0l4h9STSCpcExIlKP2CpW^BNk;pj!#)abJLc PC6J-6sZQCw$He~u-}A6d literal 0 HcmV?d00001 diff --git a/src/shared/qtscript/examples/script/context2d/doc/images/context2d-example.png b/src/shared/qtscript/examples/script/context2d/doc/images/context2d-example.png new file mode 100644 index 0000000000000000000000000000000000000000..0c12754563d34e6354d23551d4d2142a89f8275f GIT binary patch literal 14160 zcmZv@by!qi)ITaxqBIHu(p`fzNJ$975K4nX2n^jRtw=XR3>{L^4MR&v4K3Z>-OW9G z-}gSx?{}a32XHvg-fQg@d#$zC{+!@XO0qc5$(}!X@&rfjqqNGCCn)v6^Wn3n!0#&> zek8%Sp=C+8S!( z^hC-5`qc?)Ozmp!WJaxK2BnsjQ~Y#b%wY5634f=Yw1nEX>Ah4ePX*1JE^Awos+t<7 zOb)LG3-IuHPQBKb%xWSsKiYVD7=C&D@0T3%LAr%ik|BiP4vm6%9r$d!s63VtS9!{%yU*c?rai!iR#eft<}`hkBdtkA%p_lp&7v z2Aw*k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Ty>n8WJC+OYY5W_tHw@H4D;5eo zq64ZojXJXlVA2SI9-uX3`rz^PJG(7OUtsJ{@Xh05Mnvs_rFUb%&;MiWu}lbbsBu7h z7mqRm*G*_si-Z_9k5Jz?Js38=MSefX0ZmJyYo0=hs~WSrHUZofVl?~_`nv^|(x*WC z^&Z`8Zwra%@&sU&k5BZ2`4b9Ix5xk#03g&O8tVTKOZA5viQESz=@Ll;-~R`N<>Kl9 literal 0 HcmV?d00001 diff --git a/src/shared/qtscript/examples/script/context2d/doc/src/context2d.qdoc b/src/shared/qtscript/examples/script/context2d/doc/src/context2d.qdoc new file mode 100644 index 00000000..ee6d6ace --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/doc/src/context2d.qdoc @@ -0,0 +1,339 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example script/context2d + \title Context2D Example + + This Qt Script example is an implementation of the Context2D API. + + \image context2d-example.png + + Context2D is part of the specification for the HTML \c{} + element. It can be used to draw graphics via scripting. A good + resource for learning more about the HTML \c{} element is + the \l{http://developer.mozilla.org/en/docs/HTML:Canvas}{Mozilla Developer Center}. + + \section1 Using The HTML Canvas Element in a Web Browser + + First, let's look at how the \c{} element is typically + used in a web browser. The following HTML snippet defines a + canvas of size 400x400 pixels with id \c{mycanvas}: + + \code + Fallback content goes here. + \endcode + + To draw on the canvas, we must first obtain a reference to the + DOM element corresponding to the \c{} tag and then call + the element's getContext() function. The resulting object + implements the Context2D API that we use to draw. + + \code + + \endcode + + When the page is rendered by a browser that supports the + \c{} tag, this would be the result: + + \image context2d-example-smileysmile.png + + \section1 Using Qt Script to script a Canvas + + The goal of this example is to be able to evaluate scripts + that use the Context2D API, and render the results. Basic + interaction (mouse, keyboard) should also be supported. + In other words, we want to present scripts with an execution + environment that very much resembles that of a web browser. Of + course, our environment is only a small subset of what a browser + provides; i.e. we don't provide a full DOM API, only what is + needed to run "self-contained" Context2D scripts (i.e. scripts + that don't depend on other parts of the DOM document). + + Our "Context2D-browser" is set up through the following steps: + \list + \li Create an Environment. + \li Create a Context2D, and a QContext2DCanvas widget to render it. + \li Add the canvas object to the environment; this will enable + scripts to obtain a reference to it. + \li Evaluate scripts in the environment. + \endlist + + Once a script has been evaluated, the application handles any + timer events and input events that occur subsequently + (i.e. forwards events to their associated script targets). + + \section1 The Context2D Class + + The "heart" of this example is the Context2D C++ class that implements + the drawing API. Its interface is defined in terms of properties + and slots. Note that this class isn't tied to Qt Script in any + way. + + \snippet script/context2d/context2d.h 0 + + The properties define various aspects of the Context2D + configuration. + + \snippet script/context2d/context2d.h 1 + + The slots define the operations that can be performed. + + \snippet script/context2d/context2d.h 2 + + The changed() signal is emitted when the contents of the drawing + area has changed, so that clients associated with the Context2D + object (i.e. the canvas widget that renders it) are notified. + + \section2 Implementation + + Conveniently enough, the concepts, data structures and operations + of the Context2D API map more or less directly to Qt's painting + API. Conceptually, all we have to do is initialize a QPainter + according to the Context2D properties, and use functions like + QPainter::strokePath() to do the painting. Painting is done on a + QImage. + + \snippet script/context2d/context2d.cpp 0 + + The property accessors and most of the slots manipulate the + internal Context2D state in some way. For the \c{lineCap} + property, Context2D uses a string representation; we therefore + have to map it from/to a Qt::PenCapStyle. The \c{lineJoin} + property is handled in the same fashion. All the property setters + also set a \e{dirty flag} for the property; this is used to + decide which aspects of the QPainter that need to be updated + before doing the next painting operation. + + \snippet script/context2d/context2d.cpp 3 + + The implementation of the \c{fillStyle} property is interesting, + since the value can be either a string or a \c{CanvasGradient}. + We handle this by having the property be of type QVariant, + and check the actual type of the value to see how to handle the + write. + + \snippet script/context2d/context2d.cpp 1 + + Context2D does not have a concept of a paint event; painting + operations can happen at any time. We would like to be efficient, + and not have to call QPainter::begin() and QPainter::end() for + every painting operation, since typically many painting operations + will follow in quick succession. The implementations of the + painting operations use a helper function, beginPainting(), that + activates the QPainter if it isn't active already, and updates + the state of the QPainter (brush, pen, etc.) so that it reflects + the current Context2D state. + + \snippet script/context2d/context2d.cpp 2 + + The implementation of each painting operation ends by calling + scheduleChange(), which will post a zero-timer event if one is + not already pending. When the application returns to the event + loop later (presumably after all the drawing operations have + finished), the timer will trigger, QPainter::end() will be + called, and the changed() signal is emitted with the new + image as argument. The net effect is that there will typically + be only a single (QPainter::begin(), QPainter::end()) pair + executed for the full sequence of painting operations. + + \section1 The Canvas Widget + + \snippet script/context2d/qcontext2dcanvas.h 0 + + The QContext2DCanvas class provides a widget that renders + the contents of a Context2D object. It also provides a + minimal scripting API, most notably the getContext() function. + + \snippet script/context2d/qcontext2dcanvas.cpp 3 + + The constructor connects to the changed() signal of the + Context2D object, so that the widget can update itself + when it needs to do so. Mouse tracking is enabled so that + mouse move events will be received even when no mouse + buttons are depressed. + + \snippet script/context2d/qcontext2dcanvas.cpp 0 + + The getContext() function asks the environment to wrap the + Context2D object; the resulting proxy object makes the + Context2D API available to scripts. + + \snippet script/context2d/qcontext2dcanvas.cpp 1 + + The paintEvent() function simply paints the contents that + was last received from the Context2D object. + + \snippet script/context2d/qcontext2dcanvas.cpp 2 + + The canvas widget reimplements mouse and key event handlers, and + forwards these events to the scripting environment. The + environment will take care of delivering the event to the proper + script target, if any. + + \section1 The Environment + + \snippet script/context2d/environment.h 0 + + The Environment class provides a scripting environment where a + Canvas C++ object can be registered, looked up by ID (name), + and where scripts can be evaluated. The environment has a + \c{document} property, just like the scripting environment of a + web browser, so that scripts can call + \c{document.getElementById()} to obtain a reference to a canvas. + + \snippet script/context2d/environment.h 1 + + The Environment class provides the timer attributes of the DOM + Window Object interface. This enables us to support scripts that + do animation, for example. + + \snippet script/context2d/environment.h 2 + + The scriptError() signal is emitted when evaluation of a script + causes a script exception. For example, if a mouse press handler + or timeout handler causes an exception, the environment's client(s) + will be notified of this and can report the error. + + \snippet script/context2d/environment.cpp 0 + + The constructor initializes the environment. First it creates + the QScriptEngine that will be used to evaluate scripts. It + creates the Document object that provides the getElementById() + function. Note that the QScriptEngine::ExcludeSuperClassContents + flag is specified to avoid the wrapper objects from exposing properties + and methods inherited from QObject. Next, the environment wraps + a pointer to \e{itself}; this is to prepare for setting this object + as the script engine's Global Object. The properties of the standard + Global Object are copied, so that these will also be available in + our custom Global Object. We also create two self-references to the + object; again, this is to provide a minimal level of compabilitity + with the scripting environment that web browsers provide. + + \snippet script/context2d/environment.cpp 5 + + The addCanvas() function adds the given canvas to the list of + registered canvas objects. The canvasByName() function looks up + a canvas by QObject::objectName(). This function is used to + implement the \c{document.getElementById()} script function. + + \snippet script/context2d/environment.cpp 1 + + The setInterval() and clearInterval() implementations use a QHash + to map from timer ID to the QScriptValue that holds the expression + to evaluate when the timer is triggered. A helper function, + maybeEmitScriptError(), is called after invoking the script handler; + it will emit the scriptError() signal if the script engine has an + uncaught exception. + + \snippet script/context2d/environment.cpp 2 + + The toWrapper() functions creates a QScriptValue that wraps the + given QObject. Note that the QScriptEngine::PreferExistingWrapperObject + flag is specified; this guarantees that a single, unique wrapper + object will be returned, even if toWrapper() is called several times + with the same argument. This is important, since it is possible that + a script can set new properties on the resulting wrapper object (e.g. + event handlers like \c{onmousedown}), and we want these to persist. + + \snippet script/context2d/environment.cpp 3 + + The handleEvent() function determines if there exists a handler + for the given event in the environment, and if so, invokes that + handler. Since the script expects a DOM event, the Qt C++ event + must be converted to a DOM event before it is passed to the + script. This mapping is relatively straightforward, but again, + we only implement a subset of the full DOM API; just enough to + get most scripts to work. + + \snippet script/context2d/environment.cpp 4 + + The newFakeDomEvent() function is a helper function that creates + a new script object and initializes it with default values for + the attributes defined in the DOM Event and DOM UIEvent + interfaces. + + \snippet script/context2d/environment.h 3 + + The Document class defines two slots that become available to + scripts: getElementById() and getElementsByTagName(). + When the tag name is "canvas", getElementsByTagName() will + return a list of all canvas objects that are registered in + the environment. + + \section1 The Application Window + + \snippet script/context2d/window.cpp 0 + + The Window constructor creates an Environment object and + connects to its scriptError() signal. It then creates a + Context2D object, and a QContext2DCanvas widget to hold it. + The canvas widget is given the name \c{tutorial}, and added to the + environment; scripts can access the canvas by e.g. + \c{document.getElementById('tutorial')}. + + \snippet script/context2d/window.cpp 1 + + The window contains a list widget that is populated with + available scripts (read from a \c{scripts/} folder). + + \snippet script/context2d/window.cpp 2 + + When an item is selected, the corresponding script is + evaluated in the environment. + + \snippet script/context2d/window.cpp 3 + + When the "Run in Debugger" button is clicked, the Qt Script debugger will + automatically be invoked when the first statement of the script is + reached. This enables the user to inspect the scripting environment and + control further execution of the script; e.g. he can single-step through + the script and/or set breakpoints. It is also possible to enter script + statements in the debugger's console widget, e.g. to perform custom + Context2D drawing operations, interactively. + + \snippet script/context2d/window.cpp 4 + + If the evaluation of a script causes an uncaught exception, the Qt Script + debugger will automatically be invoked; this enables the user to get an + idea of what went wrong. + +*/ diff --git a/src/shared/qtscript/examples/script/context2d/domimage.cpp b/src/shared/qtscript/examples/script/context2d/domimage.cpp new file mode 100644 index 00000000..d91587fa --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/domimage.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "domimage.h" + +#include + +#include + +QScriptValue DomImage::s_self; + +DomImage::DomImage() +{ +} + + +int DomImage::width() const +{ + return m_image.width(); +} + + +int DomImage::height() const +{ + return m_image.height(); +} + + +QString DomImage::src() const +{ + return m_src; +} + +void DomImage::setSrc(const QString &src) +{ + m_src = src; + m_image = QImage(m_src); +} + + +QString DomImage::name() const +{ + return m_src; +} + +static QScriptValue Image(QScriptContext *context, QScriptEngine *env) +{ + QScriptValue val = context->thisObject(); + DomImage *image = new DomImage(); + QScriptValue klass = env->newVariant(QVariant::fromValue(image)); + klass.setPrototype(DomImage::s_self); + return klass; +} + + +static QScriptValue width(QScriptContext *context, QScriptEngine *) +{ + QScriptValue val = context->thisObject(); + + DomImage *image = qvariant_cast (val.toVariant()); + if (image) + return image->width(); + + return 0; +} + + +static QScriptValue height(QScriptContext *context, QScriptEngine *) +{ + QScriptValue val = context->thisObject(); + + DomImage *image = qvariant_cast (val.toVariant()); + if (image) + return image->height(); + + return 0; +} + + +static QScriptValue setSrc(QScriptContext *context, QScriptEngine *env) +{ + QScriptValue val = context->thisObject(); + QString src = context->argument(0).toString(); + + DomImage *image = qvariant_cast (val.toVariant()); + if (image) + image->setSrc(src); + + return env->undefinedValue(); +} + + +static QScriptValue name(QScriptContext *context, QScriptEngine *) +{ + QScriptValue val = context->thisObject(); + + DomImage *image = qvariant_cast (val.toVariant()); + if (image) + return image->name(); + + return QString(); +} + + +void DomImage::setup(QScriptEngine *e) +{ + qRegisterMetaType(); + + e->globalObject().setProperty("Image", + e->newFunction(::Image, 0)); + + s_self = e->newObject(); + s_self.setProperty("setSrc", e->newFunction(&::setSrc, 1)); + s_self.setProperty("width", e->newFunction(&::width)); + s_self.setProperty("height", e->newFunction(&::height)); + s_self.setProperty("name", e->newFunction(&::name)); + + e->setDefaultPrototype(qMetaTypeId(), s_self); +} diff --git a/src/shared/qtscript/examples/script/context2d/domimage.h b/src/shared/qtscript/examples/script/context2d/domimage.h new file mode 100644 index 00000000..da63a982 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/domimage.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef DOMIMAGE_H +#define DOMIMAGE_H + +#include +#include +#include + +#include + +class DomImage +{ +public: + DomImage(); + static void setup(QScriptEngine *e); + + int width() const; + int height() const; + + QString src() const; + void setSrc(const QString &src); + + QString name() const; + + static QScriptValue s_self; + + const QImage &image() const + { + return m_image; + } +private: + QImage m_image; + QString m_src; + //attribute boolean isMap; + //attribute DOMString longDesc; + //attribute DOMString useMap; + //attribute DOMString align; + //attribute DOMString alt; + //attribute DOMString border; + //attribute long vspace; + //attribute long hspace; +}; + +Q_DECLARE_METATYPE(DomImage) +Q_DECLARE_METATYPE(DomImage*) + +#endif diff --git a/src/shared/qtscript/examples/script/context2d/environment.cpp b/src/shared/qtscript/examples/script/context2d/environment.cpp new file mode 100644 index 00000000..3afb759d --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/environment.cpp @@ -0,0 +1,587 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "environment.h" +#include "qcontext2dcanvas.h" +#include "context2d.h" +#include +#include + +struct FakeDomEvent +{ + enum KeyCodes { + DOM_VK_UNDEFINED = 0x0, + DOM_VK_RIGHT_ALT = 0x12, + DOM_VK_LEFT_ALT = 0x12, + DOM_VK_LEFT_CONTROL = 0x11, + DOM_VK_RIGHT_CONTROL = 0x11, + DOM_VK_LEFT_SHIFT = 0x10, + DOM_VK_RIGHT_SHIFT = 0x10, + DOM_VK_META = 0x9D, + DOM_VK_BACK_SPACE = 0x08, + DOM_VK_CAPS_LOCK = 0x14, + DOM_VK_DELETE = 0x7F, + DOM_VK_END = 0x23, + DOM_VK_ENTER = 0x0D, + DOM_VK_ESCAPE = 0x1B, + DOM_VK_HOME = 0x24, + DOM_VK_NUM_LOCK = 0x90, + DOM_VK_PAUSE = 0x13, + DOM_VK_PRINTSCREEN = 0x9A, + DOM_VK_SCROLL_LOCK = 0x91, + DOM_VK_SPACE = 0x20, + DOM_VK_TAB = 0x09, + DOM_VK_LEFT = 0x25, + DOM_VK_RIGHT = 0x27, + DOM_VK_UP = 0x26, + DOM_VK_DOWN = 0x28, + DOM_VK_PAGE_DOWN = 0x22, + DOM_VK_PAGE_UP = 0x21, + DOM_VK_F1 = 0x70, + DOM_VK_F2 = 0x71, + DOM_VK_F3 = 0x72, + DOM_VK_F4 = 0x73, + DOM_VK_F5 = 0x74, + DOM_VK_F6 = 0x75, + DOM_VK_F7 = 0x76, + DOM_VK_F8 = 0x77, + DOM_VK_F9 = 0x78, + DOM_VK_F10 = 0x79, + DOM_VK_F11 = 0x7A, + DOM_VK_F12 = 0x7B, + DOM_VK_F13 = 0xF000, + DOM_VK_F14 = 0xF001, + DOM_VK_F15 = 0xF002, + DOM_VK_F16 = 0xF003, + DOM_VK_F17 = 0xF004, + DOM_VK_F18 = 0xF005, + DOM_VK_F19 = 0xF006, + DOM_VK_F20 = 0xF007, + DOM_VK_F21 = 0xF008, + DOM_VK_F22 = 0xF009, + DOM_VK_F23 = 0xF00A, + DOM_VK_F24 = 0xF00B + }; + + static int qtToDomKey(int keyCode); +}; + +int FakeDomEvent::qtToDomKey(int keyCode) +{ + switch (keyCode) { + case Qt::Key_Backspace: + return DOM_VK_BACK_SPACE; + case Qt::Key_Enter: + return DOM_VK_ENTER; + case Qt::Key_Return: + return DOM_VK_ENTER; + case Qt::Key_NumLock: + return DOM_VK_NUM_LOCK; + case Qt::Key_Alt: + return DOM_VK_RIGHT_ALT; + case Qt::Key_Control: + return DOM_VK_LEFT_CONTROL; + case Qt::Key_Shift: + return DOM_VK_LEFT_SHIFT; + case Qt::Key_Meta: + return DOM_VK_META; + case Qt::Key_CapsLock: + return DOM_VK_CAPS_LOCK; + case Qt::Key_Delete: + return DOM_VK_DELETE; + case Qt::Key_End: + return DOM_VK_END; + case Qt::Key_Escape: + return DOM_VK_ESCAPE; + case Qt::Key_Home: + return DOM_VK_HOME; + case Qt::Key_Pause: + return DOM_VK_PAUSE; + case Qt::Key_Print: + return DOM_VK_PRINTSCREEN; + case Qt::Key_ScrollLock: + return DOM_VK_SCROLL_LOCK; + case Qt::Key_Left: + return DOM_VK_LEFT; + case Qt::Key_Right: + return DOM_VK_RIGHT; + case Qt::Key_Up: + return DOM_VK_UP; + case Qt::Key_Down: + return DOM_VK_DOWN; + case Qt::Key_PageDown: + return DOM_VK_PAGE_DOWN; + case Qt::Key_PageUp: + return DOM_VK_PAGE_UP; + case Qt::Key_F1: + return DOM_VK_F1; + case Qt::Key_F2: + return DOM_VK_F2; + case Qt::Key_F3: + return DOM_VK_F3; + case Qt::Key_F4: + return DOM_VK_F4; + case Qt::Key_F5: + return DOM_VK_F5; + case Qt::Key_F6: + return DOM_VK_F6; + case Qt::Key_F7: + return DOM_VK_F7; + case Qt::Key_F8: + return DOM_VK_F8; + case Qt::Key_F9: + return DOM_VK_F9; + case Qt::Key_F10: + return DOM_VK_F10; + case Qt::Key_F11: + return DOM_VK_F11; + case Qt::Key_F12: + return DOM_VK_F12; + case Qt::Key_F13: + return DOM_VK_F13; + case Qt::Key_F14: + return DOM_VK_F14; + case Qt::Key_F15: + return DOM_VK_F15; + case Qt::Key_F16: + return DOM_VK_F16; + case Qt::Key_F17: + return DOM_VK_F17; + case Qt::Key_F18: + return DOM_VK_F18; + case Qt::Key_F19: + return DOM_VK_F19; + case Qt::Key_F20: + return DOM_VK_F20; + case Qt::Key_F21: + return DOM_VK_F21; + case Qt::Key_F22: + return DOM_VK_F22; + case Qt::Key_F23: + return DOM_VK_F23; + case Qt::Key_F24: + return DOM_VK_F24; + } + return keyCode; +} + +//! [0] +Environment::Environment(QObject *parent) + : QObject(parent) +{ + m_engine = new QScriptEngine(this); + + m_document = m_engine->newQObject( + new Document(this), QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSuperClassContents); + + CanvasGradientPrototype::setup(m_engine); + + m_originalGlobalObject = m_engine->globalObject(); + reset(); +} +//! [0] + +Environment::~Environment() +{ +} + +QScriptEngine *Environment::engine() const +{ + return m_engine; +} + +QScriptValue Environment::document() const +{ + return m_document; +} + +int Environment::setTimeout(const QScriptValue &expression, int delay) +{ + if (expression.isString() || expression.isFunction()) { + int timerId = startTimer(delay); + m_timeoutHash.insert(timerId, expression); + return timerId; + } + return -1; +} + +void Environment::clearTimeout(int timerId) +{ + killTimer(timerId); + m_timeoutHash.remove(timerId); +} + +//! [1] +int Environment::setInterval(const QScriptValue &expression, int delay) +{ + if (expression.isString() || expression.isFunction()) { + int timerId = startTimer(delay); + m_intervalHash.insert(timerId, expression); + return timerId; + } + return -1; +} + +void Environment::clearInterval(int timerId) +{ + killTimer(timerId); + m_intervalHash.remove(timerId); +} + +void Environment::timerEvent(QTimerEvent *event) +{ + int id = event->timerId(); + QScriptValue expression = m_intervalHash.value(id); + if (!expression.isValid()) { + expression = m_timeoutHash.value(id); + if (expression.isValid()) + killTimer(id); + } + if (expression.isString()) { + evaluate(expression.toString()); + } else if (expression.isFunction()) { + expression.call(); + } + maybeEmitScriptError(); +} +//! [1] + +//! [5] +void Environment::addCanvas(QContext2DCanvas *canvas) +{ + m_canvases.append(canvas); +} + +QContext2DCanvas *Environment::canvasByName(const QString &name) const +{ + for (int i = 0; i < m_canvases.size(); ++i) { + QContext2DCanvas *canvas = m_canvases.at(i); + if (canvas->objectName() == name) + return canvas; + } + return 0; +} +//! [5] + +QList Environment::canvases() const +{ + return m_canvases; +} + +void Environment::reset() +{ + if (m_engine->isEvaluating()) + m_engine->abortEvaluation(); + + { + QHash::const_iterator it; + for (it = m_intervalHash.constBegin(); it != m_intervalHash.constEnd(); ++it) + killTimer(it.key()); + m_intervalHash.clear(); + for (it = m_timeoutHash.constBegin(); it != m_timeoutHash.constEnd(); ++it) + killTimer(it.key()); + m_timeoutHash.clear(); + } + + for (int i = 0; i < m_canvases.size(); ++i) + m_canvases.at(i)->reset(); + + QScriptValue self = m_engine->newQObject( + this, QScriptEngine::QtOwnership, + QScriptEngine::ExcludeSuperClassContents); + + { + QScriptValueIterator it(m_originalGlobalObject); + while (it.hasNext()) { + it.next(); + self.setProperty(it.scriptName(), it.value(), it.flags()); + } + } + + self.setProperty("self", self); + self.setProperty("window", self); + + QScriptValue navigator = m_engine->newObject(); + navigator.setProperty("appCodeName", "context2d"); + navigator.setProperty("appMinorVersion", 1); + navigator.setProperty("appVersion", 1); + navigator.setProperty("browserLanguage", "en_US"); + navigator.setProperty("cookieEnabled", false); + navigator.setProperty("cpuClass", "i686"); + navigator.setProperty("onLine", false); + navigator.setProperty("platform", "bogus OS"); + navigator.setProperty("systemLanguage", "en_US"); + navigator.setProperty("userAgent", "Context2D/1.1"); + navigator.setProperty("userLanguage", "en_US"); + self.setProperty("navigator", navigator); + + m_engine->setGlobalObject(self); + + m_engine->collectGarbage(); +} + +QScriptValue Environment::evaluate(const QString &code, const QString &fileName) +{ + return m_engine->evaluate(code, fileName); +} + +bool Environment::hasIntervalTimers() const +{ + return !m_intervalHash.isEmpty(); +} + +// This is used by the Context2D Qt Script benchmark. +void Environment::triggerTimers() +{ + for (int x = 0; x < 2; ++x) { + QList timerIds = x ? m_intervalHash.keys() : m_timeoutHash.keys(); + for (int i = 0; i < timerIds.size(); ++i) { + QTimerEvent fakeEvent(timerIds.at(i)); + timerEvent(&fakeEvent); + } + } +} + +//! [2] +QScriptValue Environment::toWrapper(QObject *object) +{ + return m_engine->newQObject(object, QScriptEngine::QtOwnership, + QScriptEngine::PreferExistingWrapperObject + | QScriptEngine::ExcludeSuperClassContents); +} +//! [2] + +//! [3] +void Environment::handleEvent(QContext2DCanvas *canvas, QMouseEvent *e) +{ + QString type; + switch (e->type()) { + case QEvent::MouseButtonPress: + type = "mousedown"; break; + case QEvent::MouseButtonRelease: + type = "mouseup"; break; + case QEvent::MouseMove: + type = "mousemove"; break; + default: break; + } + if (type.isEmpty()) + return; + + QScriptValue handlerObject; + QScriptValue handler = eventHandler(canvas, type, &handlerObject); + if (!handler.isFunction()) + return; + + QScriptValue scriptEvent = newFakeDomEvent(type, toWrapper(canvas)); + // MouseEvent + scriptEvent.setProperty("screenX", e->globalX(), QScriptValue::ReadOnly); + scriptEvent.setProperty("screenY", e->globalY(), QScriptValue::ReadOnly); + scriptEvent.setProperty("clientX", e->x(), QScriptValue::ReadOnly); + scriptEvent.setProperty("clientY", e->y(), QScriptValue::ReadOnly); + scriptEvent.setProperty("layerX", e->x(), QScriptValue::ReadOnly); + scriptEvent.setProperty("layerY", e->y(), QScriptValue::ReadOnly); + scriptEvent.setProperty("pageX", e->x(), QScriptValue::ReadOnly); + scriptEvent.setProperty("pageY", e->y(), QScriptValue::ReadOnly); + scriptEvent.setProperty("altKey", (e->modifiers() & Qt::AltModifier) != 0, + QScriptValue::ReadOnly); + scriptEvent.setProperty("ctrlKey", (e->modifiers() & Qt::ControlModifier) != 0, + QScriptValue::ReadOnly); + scriptEvent.setProperty("metaKey", (e->modifiers() & Qt::MetaModifier) != 0, + QScriptValue::ReadOnly); + scriptEvent.setProperty("shiftKey", (e->modifiers() & Qt::ShiftModifier) != 0, + QScriptValue::ReadOnly); + int button = 0; + if (e->button() == Qt::RightButton) + button = 2; + else if (e->button() == Qt::MidButton) + button = 1; + scriptEvent.setProperty("button", button); + scriptEvent.setProperty("relatedTarget", m_engine->nullValue(), + QScriptValue::ReadOnly); + handler.call(handlerObject, QScriptValueList() << scriptEvent); + maybeEmitScriptError(); +} +//! [3] + +void Environment::handleEvent(QContext2DCanvas *canvas, QKeyEvent *e) +{ + QString type; + switch (e->type()) { + case QEvent::KeyPress: + type = "keydown"; break; + case QEvent::KeyRelease: + type = "keyup"; break; + default: break; + } + if (type.isEmpty()) + return; + + QScriptValue handlerObject; + QScriptValue handler = eventHandler(canvas, type, &handlerObject); + if (!handler.isFunction()) + return; + + QScriptValue scriptEvent = newFakeDomEvent(type, toWrapper(canvas)); + // KeyEvent + scriptEvent.setProperty("isChar", !e->text().isEmpty()); + scriptEvent.setProperty("charCode", e->text()); + scriptEvent.setProperty("keyCode", FakeDomEvent::qtToDomKey(e->key())); + scriptEvent.setProperty("which", e->key()); + + handler.call(handlerObject, QScriptValueList() << scriptEvent); + maybeEmitScriptError(); +} + +QScriptValue Environment::eventHandler(QContext2DCanvas *canvas, const QString &type, + QScriptValue *who) +{ + QString handlerName = "on" + type; + QScriptValue obj = toWrapper(canvas); + QScriptValue handler = obj.property(handlerName); + if (!handler.isValid()) { + obj = m_document; + handler = obj.property(handlerName); + } + if (who && handler.isFunction()) + *who = obj; + return handler; +} + +//! [4] +QScriptValue Environment::newFakeDomEvent(const QString &type, const QScriptValue &target) +{ + QScriptValue e = m_engine->newObject(); + // Event + e.setProperty("type", type, QScriptValue::ReadOnly); + e.setProperty("bubbles", true, QScriptValue::ReadOnly); + e.setProperty("cancelable", false, QScriptValue::ReadOnly); + e.setProperty("target", target, QScriptValue::ReadOnly); + e.setProperty("currentTarget", target, QScriptValue::ReadOnly); + e.setProperty("eventPhase", 3); // bubbling + e.setProperty("timeStamp", static_cast(QDateTime::currentDateTime().toSecsSinceEpoch())); + // UIEvent + e.setProperty("detail", 0, QScriptValue::ReadOnly); + e.setProperty("view", m_engine->globalObject(), QScriptValue::ReadOnly); + return e; +} +//! [4] + +void Environment::maybeEmitScriptError() +{ + if (m_engine->hasUncaughtException()) + emit scriptError(m_engine->uncaughtException()); +} + + +Document::Document(Environment *env) + : QObject(env) +{ +} + +Document::~Document() +{ +} + +QScriptValue Document::getElementById(const QString &id) const +{ + Environment *env = qobject_cast(parent()); + QContext2DCanvas *canvas = env->canvasByName(id); + if (!canvas) + return QScriptValue(); + return env->toWrapper(canvas); +} + +QScriptValue Document::getElementsByTagName(const QString &name) const +{ + if (name != "canvas") + return QScriptValue(); + Environment *env = qobject_cast(parent()); + QList list = env->canvases(); + QScriptValue result = env->engine()->newArray(list.size()); + for (int i = 0; i < list.size(); ++i) + result.setProperty(i, env->toWrapper(list.at(i))); + return result; +} + +void Document::addEventListener(const QString &type, const QScriptValue &listener, + bool useCapture) +{ + Q_UNUSED(useCapture); + if (listener.isFunction()) { + Environment *env = qobject_cast(parent()); + QScriptValue self = env->toWrapper(this); + self.setProperty("on" + type, listener); + } +} + + +QColor colorFromString(const QString &name); + +CanvasGradientPrototype::CanvasGradientPrototype(QObject *parent) + : QObject(parent) +{ +} + +void CanvasGradientPrototype::addColorStop(qreal offset, const QString &color) +{ + CanvasGradient *self = qscriptvalue_cast(thisObject()); + if (!self || (self->value.type() == QGradient::NoGradient)) + return; + self->value.setColorAt(offset, colorFromString(color)); +} + +void CanvasGradientPrototype::setup(QScriptEngine *engine) +{ + CanvasGradientPrototype *proto = new CanvasGradientPrototype(); + engine->setDefaultPrototype(qMetaTypeId(), + engine->newQObject(proto, QScriptEngine::ScriptOwnership, + QScriptEngine::ExcludeSuperClassContents)); +} diff --git a/src/shared/qtscript/examples/script/context2d/environment.h b/src/shared/qtscript/examples/script/context2d/environment.h new file mode 100644 index 00000000..34aab59b --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/environment.h @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef ENVIRONMENT_H +#define ENVIRONMENT_H + +#include +#include +#include +#include +#include +#include +#include +#include +class QContext2DCanvas; + +//! [0] +class Environment : public QObject +{ + Q_OBJECT + Q_PROPERTY(QScriptValue document READ document) +public: + Environment(QObject *parent = 0); + ~Environment(); + + QScriptValue document() const; + + void addCanvas(QContext2DCanvas *canvas); + QContext2DCanvas *canvasByName(const QString &name) const; + QList canvases() const; + + QScriptValue evaluate(const QString &code, + const QString &fileName = QString()); + + QScriptValue toWrapper(QObject *object); + + void handleEvent(QContext2DCanvas *canvas, QMouseEvent *e); + void handleEvent(QContext2DCanvas *canvas, QKeyEvent *e); + + void reset(); +//! [0] + + QScriptEngine *engine() const; + bool hasIntervalTimers() const; + void triggerTimers(); + +//! [1] +public slots: + int setInterval(const QScriptValue &expression, int delay); + void clearInterval(int timerId); + + int setTimeout(const QScriptValue &expression, int delay); + void clearTimeout(int timerId); +//! [1] + +//! [2] +signals: + void scriptError(const QScriptValue &error); +//! [2] + +protected: + void timerEvent(QTimerEvent *event); + +private: + QScriptValue eventHandler(QContext2DCanvas *canvas, + const QString &type, QScriptValue *who); + QScriptValue newFakeDomEvent(const QString &type, + const QScriptValue &target); + void maybeEmitScriptError(); + + QScriptEngine *m_engine; + QScriptValue m_originalGlobalObject; + QScriptValue m_document; + QList m_canvases; + QHash m_intervalHash; + QHash m_timeoutHash; +}; + +//! [3] +class Document : public QObject +{ + Q_OBJECT +public: + Document(Environment *env); + ~Document(); + +public slots: + QScriptValue getElementById(const QString &id) const; + QScriptValue getElementsByTagName(const QString &name) const; + + // EventTarget + void addEventListener(const QString &type, const QScriptValue &listener, + bool useCapture); +}; +//! [3] + +class CanvasGradientPrototype : public QObject, public QScriptable +{ + Q_OBJECT +protected: + CanvasGradientPrototype(QObject *parent = 0); +public: + static void setup(QScriptEngine *engine); + +public slots: + void addColorStop(qreal offset, const QString &color); +}; + +#endif diff --git a/src/shared/qtscript/examples/script/context2d/main.cpp b/src/shared/qtscript/examples/script/context2d/main.cpp new file mode 100644 index 00000000..9cdea370 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/main.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "window.h" +#include + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(context2d); + + QApplication app(argc, argv); + Window win; + + bool smallScreen = QApplication::arguments().contains("-small-screen"); +#if defined(Q_WS_MAEMO_5) + win.showMaximized(); +#else + if (!smallScreen) { + win.show(); + } else { + win.showFullScreen(); + } +#endif + + return app.exec(); +} diff --git a/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.cpp b/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.cpp new file mode 100644 index 00000000..8f565640 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "qcontext2dcanvas.h" + +#include "context2d.h" +#include "environment.h" +#include "domimage.h" + +#include +#include + +//! [3] +QContext2DCanvas::QContext2DCanvas(Context2D *context, Environment *env, QWidget *parent) + : QWidget(parent), m_context(context), m_env(env) +{ + QObject::connect(context, SIGNAL(changed(QImage)), this, SLOT(contentsChanged(QImage))); + setMouseTracking(true); +} +//! [3] + +QContext2DCanvas::~QContext2DCanvas() +{ +} + +Context2D *QContext2DCanvas::context() const +{ + return m_context; +} + +//! [0] +QScriptValue QContext2DCanvas::getContext(const QString &str) +{ + if (str != "2d") + return QScriptValue(); + return m_env->toWrapper(m_context); +} +//! [0] + +//! [1] +void QContext2DCanvas::contentsChanged(const QImage &image) +{ + m_image = image; + update(); +} + +void QContext2DCanvas::paintEvent(QPaintEvent *e) +{ + QPainter p(this); + p.setClipRect(e->rect()); + p.drawImage(0, 0, m_image); +} +//! [1] + +//! [2] +void QContext2DCanvas::mouseMoveEvent(QMouseEvent *e) +{ + m_env->handleEvent(this, e); +} + +void QContext2DCanvas::mousePressEvent(QMouseEvent *e) +{ + m_env->handleEvent(this, e); +} + +void QContext2DCanvas::mouseReleaseEvent(QMouseEvent *e) +{ + m_env->handleEvent(this, e); +} + +void QContext2DCanvas::keyPressEvent(QKeyEvent *e) +{ + m_env->handleEvent(this, e); +} + +void QContext2DCanvas::keyReleaseEvent(QKeyEvent *e) +{ + m_env->handleEvent(this, e); +} +//! [2] + +void QContext2DCanvas::resizeEvent(QResizeEvent *e) +{ + m_context->setSize(e->size().width(), e->size().height()); +} + +void QContext2DCanvas::resize(int width, int height) +{ + QWidget::resize(width, height); +} + +void QContext2DCanvas::reset() +{ + m_context->reset(); +} + +void QContext2DCanvas::addEventListener(const QString &type, const QScriptValue &listener, + bool useCapture) +{ + Q_UNUSED(useCapture); + if (listener.isFunction()) { + QScriptValue self = m_env->toWrapper(this); + self.setProperty("on" + type, listener); + } +} diff --git a/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.h b/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.h new file mode 100644 index 00000000..6e6ad340 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/qcontext2dcanvas.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef QCONTEXT2DCANVAS_H +#define QCONTEXT2DCANVAS_H + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QPaintEvent; +class QResizeEvent; +class QMouseEvent; +class QKeyEvent; +QT_END_NAMESPACE +class Environment; +class Context2D; + +//! [0] +class QContext2DCanvas : public QWidget +{ + Q_OBJECT +public: + QContext2DCanvas(Context2D *context, Environment *env, QWidget *parent = 0); + ~QContext2DCanvas(); + + Context2D *context() const; + void reset(); + +public slots: + QScriptValue getContext(const QString &str); + void resize(int width, int height); + + // EventTarget + void addEventListener(const QString &type, const QScriptValue &listener, + bool useCapture); + +protected: + virtual void paintEvent(QPaintEvent *e); + virtual void mouseMoveEvent(QMouseEvent *e); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e); + virtual void keyPressEvent(QKeyEvent *e); + virtual void keyReleaseEvent(QKeyEvent *e); + virtual void resizeEvent(QResizeEvent *e); + +private slots: + void contentsChanged(const QImage &image); +//! [0] + +private: + Context2D *m_context; + Environment *m_env; + QImage m_image; +}; + +#endif diff --git a/src/shared/qtscript/examples/script/context2d/scripts/alpha.js b/src/shared/qtscript/examples/script/context2d/scripts/alpha.js new file mode 100644 index 00000000..23fa5d4d --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/alpha.js @@ -0,0 +1,21 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + // draw background + ctx.fillStyle = '#FD0'; + ctx.fillRect(0,0,75,75); + ctx.fillStyle = '#6C0'; + ctx.fillRect(75,0,75,75); + ctx.fillStyle = '#09F'; + ctx.fillRect(0,75,75,75); + ctx.fillStyle = '#F30'; + ctx.fillRect(75,75,75,75); + ctx.fillStyle = '#FFF'; + + // set transparency value + ctx.globalAlpha = 0.2; + + // Draw semi transparent circles + for (i=0;i<7;i++){ + ctx.beginPath(); + ctx.arc(75,75,10+10*i,0,Math.PI*2,true); + ctx.fill(); + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/arc.js b/src/shared/qtscript/examples/script/context2d/scripts/arc.js new file mode 100644 index 00000000..650bcda4 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/arc.js @@ -0,0 +1,30 @@ +var canvas = document.getElementById('tutorial'); + + // Make sure we don't execute when canvas isn't supported + if (canvas.getContext){ + + // use getContext to use the canvas for drawing + var ctx = canvas.getContext('2d'); + + // Draw shapes + for (i=0;i<4;i++){ + for(j=0;j<3;j++){ + ctx.beginPath(); + var x = 25+j*50; // x coordinate + var y = 25+i*50; // y coordinate + var radius = 20; // Arc radius + var startAngle = 0; // Starting point on circle + var endAngle = Math.PI+(Math.PI*j)/2; // End point on circle + var clockwise = i%2==0 ? false : true; // clockwise or anticlockwise + + ctx.arc(x,y,radius,startAngle,endAngle, clockwise); + + if (i>1){ + ctx.fill(); + } else { + ctx.stroke(); + } + } + } + + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/bezier.js b/src/shared/qtscript/examples/script/context2d/scripts/bezier.js new file mode 100644 index 00000000..719800eb --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/bezier.js @@ -0,0 +1,26 @@ +function drawShape() { +// get the canvas element using the DOM +var canvas = document.getElementById('tutorial'); + + // Make sure we don't execute when canvas isn't supported + if (canvas.getContext){ + + // use getContext to use the canvas for drawing + var ctx = canvas.getContext('2d'); + + // Draw shapes + + ctx.beginPath(); + ctx.moveTo(75,40); + ctx.bezierCurveTo(75,37,70,25,50,25); + ctx.bezierCurveTo(20,25,20,62.5,20,62.5); + ctx.bezierCurveTo(20,80,40,102,75,120); + ctx.bezierCurveTo(110,102,130,80,130,62.5); + ctx.bezierCurveTo(130,62.5,130,25,100,25); + ctx.bezierCurveTo(85,25,75,37,75,40); + ctx.fill(); + ctx.globalAlpha = 0.5; + } +} + +drawShape(); diff --git a/src/shared/qtscript/examples/script/context2d/scripts/clock.js b/src/shared/qtscript/examples/script/context2d/scripts/clock.js new file mode 100644 index 00000000..ad287d82 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/clock.js @@ -0,0 +1,99 @@ +function init(){ + clock(); + setInterval('clock()',1000); +} +function clock(){ + var now = new Date(); + var ctx = document.getElementById('tutorial').getContext('2d'); + ctx.save(); + ctx.clearRect(0,0,150,150); + ctx.translate(75,75); + ctx.scale(0.4,0.4); + ctx.rotate(-Math.PI/2); + ctx.strokeStyle = "black"; + ctx.fillStyle = "white"; + ctx.lineWidth = 8; + ctx.lineCap = "round"; + + // Hour marks + ctx.save(); + ctx.beginPath(); + for (i=0;i<12;i++){ + ctx.rotate(Math.PI/6); + ctx.moveTo(100,0); + ctx.lineTo(120,0); + } + ctx.stroke(); + ctx.restore(); + + // Minute marks + ctx.save(); + ctx.lineWidth = 5; + ctx.beginPath(); + for (i=0;i<60;i++){ + if (i%5!=0) { + ctx.moveTo(117,0); + ctx.lineTo(120,0); + } + ctx.rotate(Math.PI/30); + } + ctx.stroke(); + ctx.restore(); + + var sec = now.getSeconds(); + var min = now.getMinutes(); + var hr = now.getHours(); + hr = hr>=12 ? hr-12 : hr; + + ctx.fillStyle = "black"; + + // write Hours + ctx.save(); + ctx.rotate( hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec ) + ctx.lineWidth = 14; + ctx.beginPath(); + ctx.moveTo(-20,0); + ctx.lineTo(80,0); + ctx.stroke(); + ctx.restore(); + + // write Minutes + ctx.save(); + ctx.rotate( (Math.PI/30)*min + (Math.PI/1800)*sec ) + ctx.lineWidth = 10; + ctx.beginPath(); + ctx.moveTo(-28,0); + ctx.lineTo(112,0); + ctx.stroke(); + ctx.restore(); + + // Write seconds + ctx.save(); + ctx.rotate(sec * Math.PI/30); + ctx.strokeStyle = "#D40000"; + ctx.fillStyle = "#D40000"; + ctx.lineWidth = 6; + ctx.beginPath(); + ctx.moveTo(-30,0); + ctx.lineTo(83,0); + ctx.stroke(); + ctx.beginPath(); + ctx.arc(0,0,10,0,Math.PI*2,true); + ctx.fill(); + ctx.beginPath(); + ctx.arc(95,0,10,0,Math.PI*2,true); + ctx.stroke(); + ctx.fillStyle = "#555"; + ctx.arc(0,0,3,0,Math.PI*2,true); + ctx.fill(); + ctx.restore(); + + ctx.beginPath(); + ctx.lineWidth = 14; + ctx.strokeStyle = '#325FA2'; + ctx.arc(0,0,142,0,Math.PI*2,true); + ctx.stroke(); + + ctx.restore(); +} +init(); diff --git a/src/shared/qtscript/examples/script/context2d/scripts/fill1.js b/src/shared/qtscript/examples/script/context2d/scripts/fill1.js new file mode 100644 index 00000000..db5eeb7c --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/fill1.js @@ -0,0 +1,8 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + for (i=0;i<6;i++){ + for (j=0;j<6;j++){ + ctx.fillStyle = 'rgb(' + Math.floor(255-42.5*i) + ',' + + Math.floor(255-42.5*j) + ',0)'; + ctx.fillRect(j*25,i*25,25,25); + } + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/grad.js b/src/shared/qtscript/examples/script/context2d/scripts/grad.js new file mode 100644 index 00000000..24ccfbbd --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/grad.js @@ -0,0 +1,20 @@ + var ctx = document.getElementById('tutorial').getContext('2d'); + + // Create gradients + var lingrad = ctx.createLinearGradient(0,0,0,150); + lingrad.addColorStop(0, '#00ABEB'); + lingrad.addColorStop(0.5, '#fff'); + lingrad.addColorStop(0.5, '#66CC00'); + lingrad.addColorStop(1, '#fff'); + + var lingrad2 = ctx.createLinearGradient(0,50,0,95); + lingrad2.addColorStop(0.5, '#000'); + lingrad2.addColorStop(1, 'rgba(0,0,0,0)'); + + // assign gradients to fill and stroke styles + ctx.fillStyle = lingrad; + ctx.strokeStyle = lingrad2; + + // draw shapes + ctx.fillRect(10,10,130,130); + ctx.strokeRect(50,50,50,50); diff --git a/src/shared/qtscript/examples/script/context2d/scripts/linecap.js b/src/shared/qtscript/examples/script/context2d/scripts/linecap.js new file mode 100644 index 00000000..18ceb235 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/linecap.js @@ -0,0 +1,24 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + var lineCap = ['butt','round','square']; + + // Draw guides + ctx.save(); + ctx.strokeStyle = '#09f'; + ctx.beginPath(); + ctx.moveTo(10,10); + ctx.lineTo(140,10); + ctx.moveTo(10,140); + ctx.lineTo(140,140); + ctx.stroke(); + + // Draw lines + ctx.strokeStyle = 'black'; + for (i=0;i exitTime) + return; + } +} + +function init() +{ + pa['width'] = 150; + pa['height'] = 140; + pa['player_margin'] = 10; //area behind player paddles + pa['foreground'] = "#FFFFFF"; + pa['background'] = "#000000"; + + divider['pos'] = pa['width']/2; + divider['width'] = 4; + + paddle_1['width'] = 8; + paddle_1['height'] = 64; + paddle_1['x'] = pa['player_margin']; + paddle_1['y'] = (pa['height'] /2 ) - (paddle_1['height'] / 2); + + paddle_2['width'] = 8; + paddle_2['height'] = 64; + paddle_2['x'] = (pa['width'] - pa['player_margin'] - paddle_2['width']); + paddle_2['y'] = (pa['height'] /2 ) - (paddle_2['height'] / 2); + + ball['width'] = 10; + ball['height'] = 10; + ball['x'] = (pa['width']/2) - (ball['width'] / 2); + ball['y'] = (pa['height']/2) - (ball['height'] / 2); + + ball_direction = Math.random() * 360; //initialize ball direction, which is determined by angle, at random + speed = 2; +} + +function renderPlayarea() +{ + playarea.beginPath(); + + playarea.clearRect(0,0,pa['width'],pa['height']); + playarea.fillStyle = pa['background']; + playarea.strokeStyle = pa['foreground']; + playarea.fillRect(0,0, pa['width'], pa['height']); + + //move paddles + if(player_1_direction != null) + { + if(player_1_direction == up) + paddle_1['y'] = paddle_1['y'] - paddle_inc; + else + paddle_1['y'] = paddle_1['y'] + paddle_inc; + } + if(player_2_direction != null) + { + if(player_2_direction == up) + paddle_2['y'] = paddle_2['y'] - paddle_inc; + else + paddle_2['y'] = paddle_2['y'] + paddle_inc; + } + playarea.rect(paddle_1['x'],paddle_1['y'],paddle_1['width'],paddle_1['height']); + playarea.rect(paddle_2['x'],paddle_2['y'],paddle_2['width'],paddle_2['height']); + + //move ball + playarea.rect(ball['x'], ball['y'], ball['width'], ball['height']); + ball['x'] = ball['x'] + Math.cos((ball_direction)*Math.PI/180) * speed; + ball['y'] = ball['y'] + Math.sin((ball_direction)*Math.PI/180) * speed; + + playarea.fillStyle = pa['foreground']; + playarea.fill(); + + playarea.beginPath(); + //redraw divider + playarea.lineWidth = divider['width']; + playarea.lineTo(divider['pos'], 0); + playarea.lineTo(divider['pos'], pa['height'] = 200); + playarea.lineWidth = 1; + + playarea.stroke(); + playarea.closePath(); +} + +function testCollisions() +{ + //make sure paddles don't go beyond play area + if(((paddle_1['y'] <= 0) && (player_1_direction == up)) || ((paddle_1['y'] >= (pa['height'] - paddle_1['height'])) && (player_1_direction == down))) + player_1_direction = null; + if(((paddle_2['y'] <= 0) && (player_2_direction == up)) || ((paddle_2['y'] >= (pa['height'] - paddle_2['height'])) && (player_2_direction == down))) + player_2_direction = null; + + //check to see if ball went beyond paddles, and if so, score accordingly and reset playarea + if(ball['x'] <= 0) + { + setScore(player_2); + init() + sleep(1000); + } + if(ball['x'] >= (pa['width'] - ball['width'])) + { + setScore(player_1); + init(); + sleep(1000); + } + + //check to see if ball hit top or bottom wall. if so, change direction + if((ball['y'] >= (pa['height'] - ball['height'])) || ball['y'] <= 0) + ball_direction = -ball_direction; + + //check to see if the ball hit a paddle, and if so, change ball angle dependant on where it hit the paddle + if((ball['x'] <= (paddle_1['x'] + paddle_1['width'])) && (ball['y'] >= paddle_1['y']) && (ball['y'] <= (paddle_1['y'] + paddle_1['height']))) + { + ball_direction = -ball_direction/2; + speed += .5; + } + if(((ball['x'] + ball['width']) >= paddle_2['x']) && (ball['y'] >= paddle_2['y']) && (ball['y'] <= (paddle_2['y'] + paddle_2['height']))) + { + ball_direction = (180+ball_direction)/2; + speed += .5; + } +} + +function setScore(p) +{ + if(p == player_1) + { + player_1_scr++; + //p1_scr.firstChild.nodeValue = player_1_scr; + } + if(p == player_2) + { + player_2_scr++; + //p2_scr.firstChild.nodeValue = player_2_scr; + } +} + + +//handle input +document.onkeydown = function(ev) +{ + switch(ev.keyCode) + { + case key_W: + player_1_direction = up; + break; + case key_S: + player_1_direction = down; + break; + case key_up: + player_2_direction = up; + break; + case key_down: + player_2_direction = down; + break; + } +} + +document.onkeyup = function(ev) +{ + switch(ev.keyCode) + { + case key_W: + case key_S: + player_1_direction = null; + break; + case key_up: + case key_down: + player_2_direction = null; + break; + case key_pause: + if(pause == false) + { + clearInterval(game); + //status_msg.style.visibility = "visible"; + pause = true; + } + else + { + game = setInterval(main, 25); + //status_msg.style.visibility = "hidden"; + pause = false; + } + break; + } +} + +function main() +{ + testCollisions(); + renderPlayarea(); +} + +init(); +game = setInterval(main, 25); diff --git a/src/shared/qtscript/examples/script/context2d/scripts/quad.js b/src/shared/qtscript/examples/script/context2d/scripts/quad.js new file mode 100644 index 00000000..ad3a0d57 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/quad.js @@ -0,0 +1,21 @@ +var canvas = document.getElementById('tutorial'); + + // Make sure we don't execute when canvas isn't supported + if (canvas.getContext){ + + // use getContext to use the canvas for drawing + var ctx = canvas.getContext('2d'); + + // Draw shapes + + ctx.beginPath(); + ctx.moveTo(75,25); + ctx.quadraticCurveTo(25,25,25,62.5); + ctx.quadraticCurveTo(25,100,50,100); + ctx.quadraticCurveTo(50,120,30,125); + ctx.quadraticCurveTo(60,120,65,100); + ctx.quadraticCurveTo(125,100,125,62.5); + ctx.quadraticCurveTo(125,25,75,25); + ctx.stroke(); + + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/rgba.js b/src/shared/qtscript/examples/script/context2d/scripts/rgba.js new file mode 100644 index 00000000..a4e5e9a5 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/rgba.js @@ -0,0 +1,19 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + + // Draw background + ctx.fillStyle = 'rgb(255,221,0)'; + ctx.fillRect(0,0,150,37.5); + ctx.fillStyle = 'rgb(102,204,0)'; + ctx.fillRect(0,37.5,150,37.5); + ctx.fillStyle = 'rgb(0,153,255)'; + ctx.fillRect(0,75,150,37.5); + ctx.fillStyle = 'rgb(255,51,0)'; + ctx.fillRect(0,112.5,150,37.5); + + // Draw semi transparent rectangles + for (i=0;i<10;i++){ + ctx.fillStyle = 'rgba(255,255,255,'+(i+1)/10+')'; + for (j=0;j<4;j++){ + ctx.fillRect(5+i*14,5+j*37.5,14,27.5) + } + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/rotate.js b/src/shared/qtscript/examples/script/context2d/scripts/rotate.js new file mode 100644 index 00000000..c7ef369d --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/rotate.js @@ -0,0 +1,16 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + ctx.translate(75,75); + + for (i=1;i<6;i++){ // Loop through rings (from inside to out) + ctx.save(); + ctx.fillStyle = 'rgb('+(51*i)+','+(255-51*i)+',255)'; + + for (j=0;j20000) break; + var x2 = (R+r)*Math.cos(i*Math.PI/72) - (r+O)*Math.cos(((R+r)/r)*(i*Math.PI/72)) + var y2 = (R+r)*Math.sin(i*Math.PI/72) - (r+O)*Math.sin(((R+r)/r)*(i*Math.PI/72)) + ctx.lineTo(x2,y2); + x1 = x2; + y1 = y2; + i++; + } while (x2 != R-O && y2 != 0 ); + ctx.stroke(); +} diff --git a/src/shared/qtscript/examples/script/context2d/scripts/stroke1.js b/src/shared/qtscript/examples/script/context2d/scripts/stroke1.js new file mode 100644 index 00000000..0561a52e --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/stroke1.js @@ -0,0 +1,10 @@ +var ctx = document.getElementById('tutorial').getContext('2d'); + for (i=0;i<6;i++){ + for (j=0;j<6;j++){ + ctx.strokeStyle = 'rgb(0,' + Math.floor(255-42.5*i) + ',' + + Math.floor(255-42.5*j) + ')'; + ctx.beginPath(); + ctx.arc(12.5+j*25,12.5+i*25,10,0,Math.PI*2,true); + ctx.stroke(); + } + } diff --git a/src/shared/qtscript/examples/script/context2d/scripts/translate.js b/src/shared/qtscript/examples/script/context2d/scripts/translate.js new file mode 100644 index 00000000..7c944330 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/scripts/translate.js @@ -0,0 +1,29 @@ + var ctx = document.getElementById('tutorial').getContext('2d'); + ctx.fillRect(0,0,300,300); + for (var i=0;i<3;i++) { + for (var j=0;j<3;j++) { + ctx.save(); + ctx.strokeStyle = "#9CFF00"; + ctx.translate(50+j*100,50+i*100); + drawSpirograph(ctx,20*(j+2)/(j+1),-8*(i+3)/(i+1),10); + ctx.restore(); + } + } + +function drawSpirograph(ctx,R,r,O){ + var x1 = R-O; + var y1 = 0; + var i = 1; + ctx.beginPath(); + ctx.moveTo(x1,y1); + do { + if (i>20000) break; + var x2 = (R+r)*Math.cos(i*Math.PI/72) - (r+O)*Math.cos(((R+r)/r)*(i*Math.PI/72)) + var y2 = (R+r)*Math.sin(i*Math.PI/72) - (r+O)*Math.sin(((R+r)/r)*(i*Math.PI/72)) + ctx.lineTo(x2,y2); + x1 = x2; + y1 = y2; + i++; + } while (x2 != R-O && y2 != 0 ); + ctx.stroke(); +} diff --git a/src/shared/qtscript/examples/script/context2d/window.cpp b/src/shared/qtscript/examples/script/context2d/window.cpp new file mode 100644 index 00000000..2f92982b --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/window.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "window.h" +#include "environment.h" +#include "context2d.h" +#include "qcontext2dcanvas.h" +#include +#include +#include +#include + +#ifndef QT_NO_SCRIPTTOOLS +#include +#include +#include +#include +#include +#include +#endif + +static QString scriptsDir() +{ + if (QFile::exists("./scripts")) + return "./scripts"; + return ":/scripts"; +} + +//! [0] +Window::Window(QWidget *parent) + : QWidget(parent) +#ifndef QT_NO_SCRIPTTOOLS + , m_debugger(0), m_debugWindow(0) +#endif +{ + m_env = new Environment(this); + QObject::connect(m_env, SIGNAL(scriptError(QScriptValue)), + this, SLOT(reportScriptError(QScriptValue))); + + Context2D *context = new Context2D(this); + context->setSize(150, 150); + m_canvas = new QContext2DCanvas(context, m_env, this); + m_canvas->setFixedSize(context->size()); + m_canvas->setObjectName("tutorial"); + m_env->addCanvas(m_canvas); +//! [0] + +#ifndef QT_NO_SCRIPTTOOLS + QVBoxLayout *vbox = new QVBoxLayout(); + vbox->addWidget(m_canvas); + m_debugButton = new QPushButton(tr("Run in Debugger")); + connect(m_debugButton, SIGNAL(clicked()), this, SLOT(runInDebugger())); + vbox->addWidget(m_debugButton); +#endif + + QHBoxLayout *hbox = new QHBoxLayout(this); + m_view = new QListWidget(this); + m_view->setEditTriggers(QAbstractItemView::NoEditTriggers); + hbox->addWidget(m_view); +#ifndef QT_NO_SCRIPTTOOLS + hbox->addLayout(vbox); +#else + hbox->addWidget(m_canvas); +#endif + +//! [1] + QDir dir(scriptsDir()); + QFileInfoList entries = dir.entryInfoList(QStringList() << "*.js"); + for (int i = 0; i < entries.size(); ++i) + m_view->addItem(entries.at(i).fileName()); + connect(m_view, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + this, SLOT(selectScript(QListWidgetItem*))); +//! [1] + + setWindowTitle(tr("Context 2D")); +} + +//! [2] +void Window::selectScript(QListWidgetItem *item) +{ + QString fileName = item->text(); + runScript(fileName, /*debug=*/false); +} +//! [2] + +void Window::reportScriptError(const QScriptValue &error) +{ + QMessageBox::warning(this, tr("Context 2D"), tr("Line %0: %1") + .arg(error.property("lineNumber").toInt32()) + .arg(error.toString())); +} + +#ifndef QT_NO_SCRIPTTOOLS +//! [3] +void Window::runInDebugger() +{ + QListWidgetItem *item = m_view->currentItem(); + if (item) { + QString fileName = item->text(); + runScript(fileName, /*debug=*/true); + } +} +//! [3] +#endif + +//! [4] +void Window::runScript(const QString &fileName, bool debug) +{ + QFile file(scriptsDir() + "/" + fileName); + file.open(QIODevice::ReadOnly); + QString contents = file.readAll(); + file.close(); + m_env->reset(); + +#ifndef QT_NO_SCRIPTTOOLS + if (debug) { + if (!m_debugger) { + m_debugger = new QScriptEngineDebugger(this); + m_debugWindow = m_debugger->standardWindow(); + m_debugWindow->setWindowModality(Qt::ApplicationModal); + m_debugWindow->resize(1280, 704); + } + m_debugger->attachTo(m_env->engine()); + m_debugger->action(QScriptEngineDebugger::InterruptAction)->trigger(); + } else { + if (m_debugger) + m_debugger->detach(); + } +#else + Q_UNUSED(debug); +#endif + + QScriptValue ret = m_env->evaluate(contents, fileName); + +#ifndef QT_NO_SCRIPTTOOLS + if (m_debugWindow) + m_debugWindow->hide(); +#endif + + if (ret.isError()) + reportScriptError(ret); +} +//! [4] diff --git a/src/shared/qtscript/examples/script/context2d/window.h b/src/shared/qtscript/examples/script/context2d/window.h new file mode 100644 index 00000000..dfd521c7 --- /dev/null +++ b/src/shared/qtscript/examples/script/context2d/window.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include +class Environment; +class QContext2DCanvas; +QT_BEGIN_NAMESPACE +class QListWidget; +class QListWidgetItem; +class QMainWindow; +class QPushButton; +class QScriptValue; +class QScriptEngineDebugger; +QT_END_NAMESPACE + +class Window : public QWidget +{ + Q_OBJECT +public: + Window(QWidget *parent = 0); +private slots: + void selectScript(QListWidgetItem *item); + void reportScriptError(const QScriptValue &value); +#ifndef QT_NO_SCRIPTTOOLS + void runInDebugger(); +#endif +private: + void runScript(const QString &fileName, bool debug); + + QListWidget *m_view; + Environment *m_env; + QContext2DCanvas *m_canvas; +#ifndef QT_NO_SCRIPTTOOLS + QScriptEngineDebugger *m_debugger; + QPushButton *m_debugButton; + QMainWindow *m_debugWindow; +#endif +}; + +#endif // WINDOW_H diff --git a/src/shared/qtscript/examples/script/customclass/bytearrayclass.cpp b/src/shared/qtscript/examples/script/customclass/bytearrayclass.cpp new file mode 100644 index 00000000..6adef37d --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/bytearrayclass.cpp @@ -0,0 +1,319 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include +#include +#include "bytearrayclass.h" +#include "bytearrayprototype.h" + +#include + +Q_DECLARE_METATYPE(QByteArray*) +Q_DECLARE_METATYPE(ByteArrayClass*) + +class ByteArrayClassPropertyIterator : public QScriptClassPropertyIterator +{ +public: + ByteArrayClassPropertyIterator(const QScriptValue &object); + ~ByteArrayClassPropertyIterator(); + + bool hasNext() const; + void next(); + + bool hasPrevious() const; + void previous(); + + void toFront(); + void toBack(); + + QScriptString name() const; + uint id() const; + +private: + int m_index; + int m_last; +}; + +//! [0] +ByteArrayClass::ByteArrayClass(QScriptEngine *engine) + : QObject(engine), QScriptClass(engine) +{ + qScriptRegisterMetaType(engine, toScriptValue, fromScriptValue); + + length = engine->toStringHandle(QLatin1String("length")); + + proto = engine->newQObject(new ByteArrayPrototype(this), + QScriptEngine::QtOwnership, + QScriptEngine::SkipMethodsInEnumeration + | QScriptEngine::ExcludeSuperClassMethods + | QScriptEngine::ExcludeSuperClassProperties); + QScriptValue global = engine->globalObject(); + proto.setPrototype(global.property("Object").property("prototype")); + + ctor = engine->newFunction(construct, proto); + ctor.setData(engine->toScriptValue(this)); +} +//! [0] + +ByteArrayClass::~ByteArrayClass() +{ +} + +//! [3] +QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id) +{ + QByteArray *ba = qscriptvalue_cast(object.data()); + if (!ba) + return {}; + if (name == length) { + return flags; + } else { + bool isArrayIndex; + qint32 pos = name.toArrayIndex(&isArrayIndex); + if (!isArrayIndex) + return {}; + *id = pos; + if ((flags & HandlesReadAccess) && (pos >= ba->size())) + flags &= ~HandlesReadAccess; + return flags; + } +} +//! [3] + +//! [4] +QScriptValue ByteArrayClass::property(const QScriptValue &object, + const QScriptString &name, uint id) +{ + QByteArray *ba = qscriptvalue_cast(object.data()); + if (!ba) + return QScriptValue(); + if (name == length) { + return ba->length(); + } else { + qint32 pos = id; + if ((pos < 0) || (pos >= ba->size())) + return QScriptValue(); + return uint(ba->at(pos)) & 255; + } + return QScriptValue(); +} +//! [4] + +//! [5] +void ByteArrayClass::setProperty(QScriptValue &object, + const QScriptString &name, + uint id, const QScriptValue &value) +{ + QByteArray *ba = qscriptvalue_cast(object.data()); + if (!ba) + return; + if (name == length) { + resize(*ba, value.toInt32()); + } else { + qint32 pos = id; + if (pos < 0) + return; + if (ba->size() <= pos) + resize(*ba, pos + 1); + (*ba)[pos] = char(value.toInt32()); + } +} +//! [5] + +//! [6] +QScriptValue::PropertyFlags ByteArrayClass::propertyFlags( + const QScriptValue &/*object*/, const QScriptString &name, uint /*id*/) +{ + if (name == length) { + return QScriptValue::Undeletable + | QScriptValue::SkipInEnumeration; + } + return QScriptValue::Undeletable; +} +//! [6] + +//! [7] +QScriptClassPropertyIterator *ByteArrayClass::newIterator(const QScriptValue &object) +{ + return new ByteArrayClassPropertyIterator(object); +} +//! [7] + +QString ByteArrayClass::name() const +{ + return QLatin1String("ByteArray"); +} + +QScriptValue ByteArrayClass::prototype() const +{ + return proto; +} + +QScriptValue ByteArrayClass::constructor() +{ + return ctor; +} + +//! [10] +QScriptValue ByteArrayClass::newInstance(int size) +{ + engine()->reportAdditionalMemoryCost(size); + return newInstance(QByteArray(size, /*ch=*/0)); +} +//! [10] + +//! [1] +QScriptValue ByteArrayClass::newInstance(const QByteArray &ba) +{ + QScriptValue data = engine()->newVariant(QVariant::fromValue(ba)); + return engine()->newObject(this, data); +} +//! [1] + +//! [2] +QScriptValue ByteArrayClass::construct(QScriptContext *ctx, QScriptEngine *) +{ + ByteArrayClass *cls = qscriptvalue_cast(ctx->callee().data()); + if (!cls) + return QScriptValue(); + QScriptValue arg = ctx->argument(0); + if (arg.instanceOf(ctx->callee())) + return cls->newInstance(qscriptvalue_cast(arg)); + int size = arg.toInt32(); + return cls->newInstance(size); +} +//! [2] + +QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray &ba) +{ + QScriptValue ctor = eng->globalObject().property("ByteArray"); + ByteArrayClass *cls = qscriptvalue_cast(ctor.data()); + if (!cls) + return eng->newVariant(QVariant::fromValue(ba)); + return cls->newInstance(ba); +} + +void ByteArrayClass::fromScriptValue(const QScriptValue &obj, QByteArray &ba) +{ + ba = qvariant_cast(obj.data().toVariant()); +} + +//! [9] +void ByteArrayClass::resize(QByteArray &ba, int newSize) +{ + int oldSize = ba.size(); + ba.resize(newSize); + if (newSize > oldSize) + engine()->reportAdditionalMemoryCost(newSize - oldSize); +} +//! [9] + + + +ByteArrayClassPropertyIterator::ByteArrayClassPropertyIterator(const QScriptValue &object) + : QScriptClassPropertyIterator(object) +{ + toFront(); +} + +ByteArrayClassPropertyIterator::~ByteArrayClassPropertyIterator() +{ +} + +//! [8] +bool ByteArrayClassPropertyIterator::hasNext() const +{ + QByteArray *ba = qscriptvalue_cast(object().data()); + return m_index < ba->size(); +} + +void ByteArrayClassPropertyIterator::next() +{ + m_last = m_index; + ++m_index; +} + +bool ByteArrayClassPropertyIterator::hasPrevious() const +{ + return (m_index > 0); +} + +void ByteArrayClassPropertyIterator::previous() +{ + --m_index; + m_last = m_index; +} + +void ByteArrayClassPropertyIterator::toFront() +{ + m_index = 0; + m_last = -1; +} + +void ByteArrayClassPropertyIterator::toBack() +{ + QByteArray *ba = qscriptvalue_cast(object().data()); + m_index = ba->size(); + m_last = -1; +} + +QScriptString ByteArrayClassPropertyIterator::name() const +{ + return object().engine()->toStringHandle(QString::number(m_last)); +} + +uint ByteArrayClassPropertyIterator::id() const +{ + return m_last; +} +//! [8] diff --git a/src/shared/qtscript/examples/script/customclass/bytearrayclass.h b/src/shared/qtscript/examples/script/customclass/bytearrayclass.h new file mode 100644 index 00000000..e77eab47 --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/bytearrayclass.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef BYTEARRAYCLASS_H +#define BYTEARRAYCLASS_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QScriptContext; +QT_END_NAMESPACE + +class ByteArrayClass : public QObject, public QScriptClass +{ + Q_OBJECT +public: + ByteArrayClass(QScriptEngine *engine); + ~ByteArrayClass(); + + QScriptValue constructor(); + + QScriptValue newInstance(int size = 0); + QScriptValue newInstance(const QByteArray &ba); + + QueryFlags queryProperty(const QScriptValue &object, + const QScriptString &name, + QueryFlags flags, uint *id); + + QScriptValue property(const QScriptValue &object, + const QScriptString &name, uint id); + + void setProperty(QScriptValue &object, const QScriptString &name, + uint id, const QScriptValue &value); + + QScriptValue::PropertyFlags propertyFlags( + const QScriptValue &object, const QScriptString &name, uint id); + + QScriptClassPropertyIterator *newIterator(const QScriptValue &object); + + QString name() const; + + QScriptValue prototype() const; + +private: + static QScriptValue construct(QScriptContext *ctx, QScriptEngine *eng); + + static QScriptValue toScriptValue(QScriptEngine *eng, const QByteArray &ba); + static void fromScriptValue(const QScriptValue &obj, QByteArray &ba); + + void resize(QByteArray &ba, int newSize); + + QScriptString length; + QScriptValue proto; + QScriptValue ctor; +}; + +#endif diff --git a/src/shared/qtscript/examples/script/customclass/bytearrayclass.pri b/src/shared/qtscript/examples/script/customclass/bytearrayclass.pri new file mode 100644 index 00000000..05fdeb4e --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/bytearrayclass.pri @@ -0,0 +1,6 @@ +SOURCES += $$PWD/bytearrayclass.cpp \ + $$PWD/bytearrayprototype.cpp +HEADERS += $$PWD/bytearrayclass.h \ + $$PWD/bytearrayprototype.h + +INCLUDEPATH += $$PWD diff --git a/src/shared/qtscript/examples/script/customclass/bytearrayprototype.cpp b/src/shared/qtscript/examples/script/customclass/bytearrayprototype.cpp new file mode 100644 index 00000000..14446f43 --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/bytearrayprototype.cpp @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "bytearrayprototype.h" +#include + +Q_DECLARE_METATYPE(QByteArray*) + +ByteArrayPrototype::ByteArrayPrototype(QObject *parent) + : QObject(parent) +{ +} + +ByteArrayPrototype::~ByteArrayPrototype() +{ +} + +//! [0] +QByteArray *ByteArrayPrototype::thisByteArray() const +{ + return qscriptvalue_cast(thisObject().data()); +} +//! [0] + +void ByteArrayPrototype::chop(int n) +{ + thisByteArray()->chop(n); +} + +bool ByteArrayPrototype::equals(const QByteArray &other) +{ + return *thisByteArray() == other; +} + +QByteArray ByteArrayPrototype::left(int len) const +{ + return thisByteArray()->left(len); +} + +//! [1] +QByteArray ByteArrayPrototype::mid(int pos, int len) const +{ + return thisByteArray()->mid(pos, len); +} + +QScriptValue ByteArrayPrototype::remove(int pos, int len) +{ + thisByteArray()->remove(pos, len); + return thisObject(); +} +//! [1] + +QByteArray ByteArrayPrototype::right(int len) const +{ + return thisByteArray()->right(len); +} + +QByteArray ByteArrayPrototype::simplified() const +{ + return thisByteArray()->simplified(); +} + +QByteArray ByteArrayPrototype::toBase64() const +{ + return thisByteArray()->toBase64(); +} + +QByteArray ByteArrayPrototype::toLower() const +{ + return thisByteArray()->toLower(); +} + +QByteArray ByteArrayPrototype::toUpper() const +{ + return thisByteArray()->toUpper(); +} + +QByteArray ByteArrayPrototype::trimmed() const +{ + return thisByteArray()->trimmed(); +} + +void ByteArrayPrototype::truncate(int pos) +{ + thisByteArray()->truncate(pos); +} + +QString ByteArrayPrototype::toLatin1String() const +{ + return QString::fromLatin1(*thisByteArray()); +} + +//! [2] +QScriptValue ByteArrayPrototype::valueOf() const +{ + return thisObject().data(); +} +//! [2] diff --git a/src/shared/qtscript/examples/script/customclass/bytearrayprototype.h b/src/shared/qtscript/examples/script/customclass/bytearrayprototype.h new file mode 100644 index 00000000..23a83c42 --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/bytearrayprototype.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef BYTEARRAYPROTOTYPE_H +#define BYTEARRAYPROTOTYPE_H + +#include +#include +#include +#include + +//! [0] +class ByteArrayPrototype : public QObject, public QScriptable +{ +Q_OBJECT +public: + ByteArrayPrototype(QObject *parent = 0); + ~ByteArrayPrototype(); + +public slots: + void chop(int n); + bool equals(const QByteArray &other); + QByteArray left(int len) const; + QByteArray mid(int pos, int len = -1) const; + QScriptValue remove(int pos, int len); + QByteArray right(int len) const; + QByteArray simplified() const; + QByteArray toBase64() const; + QByteArray toLower() const; + QByteArray toUpper() const; + QByteArray trimmed() const; + void truncate(int pos); + QString toLatin1String() const; + QScriptValue valueOf() const; + +private: + QByteArray *thisByteArray() const; +}; +//! [0] + + +#endif diff --git a/src/shared/qtscript/examples/script/customclass/customclass.pro b/src/shared/qtscript/examples/script/customclass/customclass.pro new file mode 100644 index 00000000..1edc5112 --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/customclass.pro @@ -0,0 +1,12 @@ +QT = core script +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + +include(bytearrayclass.pri) + +target.path = $$[QT_INSTALL_EXAMPLES]/script/customclass +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/customclass/main.cpp b/src/shared/qtscript/examples/script/customclass/main.cpp new file mode 100644 index 00000000..09d653ea --- /dev/null +++ b/src/shared/qtscript/examples/script/customclass/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include +#include +#include "bytearrayclass.h" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + QScriptEngine eng; + + ByteArrayClass *baClass = new ByteArrayClass(&eng); + eng.globalObject().setProperty("ByteArray", baClass->constructor()); + + qDebug() << "ba = new ByteArray(4):" << eng.evaluate("ba = new ByteArray(4)").toString(); + qDebug() << "ba instanceof ByteArray:" << eng.evaluate("ba instanceof ByteArray").toBool(); + qDebug() << "ba.length:" << eng.evaluate("ba.length").toNumber(); + qDebug() << "ba[1] = 123; ba[1]:" << eng.evaluate("ba[1] = 123; ba[1]").toNumber(); + qDebug() << "ba[7] = 224; ba.length:" << eng.evaluate("ba[7] = 224; ba.length").toNumber(); + qDebug() << "for-in loop:" << eng.evaluate("result = '';\n" + "for (var p in ba) {\n" + " if (result.length > 0)\n" + " result += ', ';\n" + " result += '(' + p + ',' + ba[p] + ')';\n" + "} result").toString(); + qDebug() << "ba.toBase64():" << eng.evaluate("b64 = ba.toBase64()").toString(); + qDebug() << "ba.toBase64().toLatin1String():" << eng.evaluate("b64.toLatin1String()").toString(); + qDebug() << "ba.valueOf():" << eng.evaluate("ba.valueOf()").toString(); + qDebug() << "ba.chop(2); ba.length:" << eng.evaluate("ba.chop(2); ba.length").toNumber(); + qDebug() << "ba2 = new ByteArray(ba):" << eng.evaluate("ba2 = new ByteArray(ba)").toString(); + qDebug() << "ba2.equals(ba):" << eng.evaluate("ba2.equals(ba)").toBool(); + qDebug() << "ba2.equals(new ByteArray()):" << eng.evaluate("ba2.equals(new ByteArray())").toBool(); + + return 0; +} diff --git a/src/shared/qtscript/examples/script/defaultprototypes/code.js b/src/shared/qtscript/examples/script/defaultprototypes/code.js new file mode 100644 index 00000000..5f776fbb --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/code.js @@ -0,0 +1,18 @@ +//! [0] +listWidget.addItem("Red"); +listWidget.addItem("Blue"); +listWidget.addItem("Green"); +listWidget.addItem("Cyan"); +listWidget.addItem("Yellow"); +listWidget.addItem("Purple"); +listWidget.addItems(["Orange", "Gray"]); +//! [0] + +//! [1] +listWidget.currentItemChanged.connect( + function(item) + { + listWidget.setBackgroundColor(item.text); + } +); +//! [1] diff --git a/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.pro b/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.pro new file mode 100644 index 00000000..8fa008d4 --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.pro @@ -0,0 +1,9 @@ +QT += widgets script +RESOURCES += defaultprototypes.qrc +SOURCES += main.cpp prototypes.cpp +HEADERS += prototypes.h + +target.path = $$[QT_INSTALL_EXAMPLES]/script/defaultprototypes +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.qrc b/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.qrc new file mode 100644 index 00000000..ada405b1 --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/defaultprototypes.qrc @@ -0,0 +1,5 @@ + + + code.js + + diff --git a/src/shared/qtscript/examples/script/defaultprototypes/doc/images/defaultprototypes-example.png b/src/shared/qtscript/examples/script/defaultprototypes/doc/images/defaultprototypes-example.png new file mode 100644 index 0000000000000000000000000000000000000000..72fe3c401288b1094eb3ec9a46c9e808d944856c GIT binary patch literal 5840 zcmai21yodByB-9Q7(&V+q(da6d*~358bKNyVvv>?N=gK2K~g{%U>G_D1|*f1knZkK z8tJ&B-}nFbyS46G?>cMmeb(7;@8{VkTw7Cxh=7Iw000oFK30SP09bgK@f6-I%yX1d zT?_!AN>){r)AgF#PRBQ(P?_rF(%CnuG(;-1h1xeMBH3w#Lpy$b^C6rIGogR1NY#e- zfUH3*=#C=4*@L2n;g;E!VICTGw`J_162ErX^uJ z9ruDi#&WqDNJ`t+_qwjTLV>_KWN)&E^wV6;G;n8Y_o(xirFiT&O9?T=+5K#J$^qNw zXE<7kN>cR8a<4jxd#oNq$&~36srgg?KHGn4Lq^_|^_L&P zNMd3+O9^k?x&`Y!*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RVQq4%?=CnfYwK#KBmNAFM^B}HajV3ShRXE(~b3Xy#I zevyxuk&Y95NvYlDJwjG^Zl3zpC;L!r+`SW?)zy6j#M4!t4XcsHQpm9zm)Oe1Wt5PG zZ8haG7{@!cgJXNDV5<2KhUKZslo%s1Tf>GfQGJ9r z2|2)r6KFS}q;%j8%N2n>Pyt$6>Iu?BYs(N&VsC}z*uQq$!}+qt!J0SEeJW9(5V^;J*Q3kRNt4#;G2 zb`XydYXG5Fjg!N?v@RK6AjiCy85Se(H=6&3Dh#Im7eE`y#41;J(iqd*HaQn607?iqfS@1sQtYqiqPRV39F0j>rtbdm(*LLggvo0;| zoic*LU>$h_R8$Avp^ZM@4rga3_7=Ip=@+8H?L%yt`Yo9+7lI<80nEpf%CPrUFqc1_V$kn{1!OV zpOh-pmx*W|zi`;^=x{i3N=onheLfBe+%9 zKj`CWQX-@xYjHLkeBgU|x)ma~OiE)pKpOIvI^he(LYsbmVum&BAGkyYd72o+ab4q1 zfp2_~l;57NthO(@hZ`;G;BZ=!_pD@MsXc;W?duR5CO582OSK=h!GM+pG0Dne?&DMb zX44-_L0ed)%9KU=hyJ>iu-@*7)pexLUts-@XV$_w{QBv2Us|Pd^r=Jsn>#M|Uwj{i67Hb%F1RKnS*2&mG1}EF#=ch$d{fK9Llp1uuwoAJk$1>5<=UMYyn0F z!uxZaQ`vnQ007gqFc`O(0SELkk8VUb6#VMb;d)B?{fB@NO6W|( zw_UaEnQzlRs`!#_$`BBQFfq*k%3ycy(nJ@KFWJwZjWoQuZipGl!QbT$w@-98$yW>x z*$+{nP}Ro5kTS~RKX~)&pLkP5g29{jJ{Y`-!NbBZGXSQ({~>=BK8El7zfwx^-+JTU ztnYst{BEXysQIVL|2h6YjR=549i&bIiR14AaBmC0vb&6H>H7YistPMmPOdM5ra6ZX k@VDK4*&oF literal 0 HcmV?d00001 diff --git a/src/shared/qtscript/examples/script/defaultprototypes/doc/src/defaultprototypes.qdoc b/src/shared/qtscript/examples/script/defaultprototypes/doc/src/defaultprototypes.qdoc new file mode 100644 index 00000000..89a11def --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/doc/src/defaultprototypes.qdoc @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example script/defaultprototypes + \title Default Prototypes Example + + This Qt Script example shows how to use default prototypes + to make a non-QObject-based type scriptable. + + \image defaultprototypes-example.png + + With QScriptEngine::setDefaultPrototype() you can specify + a Qt Script object that defines a scripting interface for + a C++ type; Qt Script operations on values of such types + will then be delegated to your prototype object. In this + example, a simple scripting interface for QListWidgetItem is + defined, so that the text of items can easily be accessed from + script code. + + To define a scripting API for QListWidgetItem in terms of + Qt properties and slots, we subclass QObject and QScriptable. + + \snippet script/defaultprototypes/prototypes.h 0 + + A single property, \c{text}, is defined, along with a slot, + \c{toString}. + + \snippet script/defaultprototypes/prototypes.cpp 0 + + The implementation of the property accessors use + the qscriptvalue_cast() function to cast the script object + to a QListWidgetItem pointer. The normal C++ QListWidgetItem + API is then used to implement the desired functionality. + + Although not shown here, it is possible to throw a script + exception from a prototype function; for example, you could throw + a TypeError exception if the qscriptvalue_cast() fails. + + QListWidgetItems are usually added to a QListWidget. While + QListWidget is a QObject-based class, not all the functionality + needed for this example are present. We can solve this by creating + a default prototype for the QListWidget class as well. The + prototype will augment the functionality already provided by the + Qt Script QObject integration; i.e. if a property or slot is not + found in the QListWidget object itself, the prototype will be used + as a fallback. + + \snippet script/defaultprototypes/prototypes.h 1 + + The additional slots will make it possible to add items to + a QListWidget from script code, and to set the background + color of the widget from a string. + + \snippet script/defaultprototypes/prototypes.cpp 1 + + Again, we use qscriptvalue_cast() to cast the script object + to the relevant C++ type, in this case a QListWidget pointer. + The addItem() and addItems() functions simply forward their + arguments to the corresponding functions in the QListWidget + class. setBackgroundColor() gets the widget's palette, creates + a QColor from the given string argument and changes the palette + accordingly. + + \snippet script/defaultprototypes/main.cpp 0 + + The relevant C++ types must be made known to Qt's meta type + system. + + \snippet script/defaultprototypes/main.cpp 1 + + For each type that we want to associate a prototype object with, + we create an instance of the prototype class, pass it to + QScriptEngine::newQObject(), and then create the link between + the C++ type and the resulting script object by calling + QScriptEngine::setDefaultPrototype(). + + \snippet script/defaultprototypes/main.cpp 2 + + In this example, a single QListWidget object is added as + a global script variable, called \c{listWidget}. Script code + can add items to this widget by calling addItem() or addItems(). + + \snippet script/defaultprototypes/code.js 0 + + Script code can connect to signals of the QListWidget object; + signal handlers can use the interface defined in + the QListWidgetItem prototype to manipulate item arguments. + + \snippet script/defaultprototypes/code.js 1 + + Not shown in this example is how to make QListWidgetItem + constructible from Qt Script code, i.e. to be able to + write "new QListWidgetItem()" in a script. In order to do + this, you have to define your own script constructor for + the type. The constructor would just be a factory function + that constructs a new C++ QListWidgetItem and returns it + back to the script. See QScriptEngine::newFunction() for more + information. +*/ diff --git a/src/shared/qtscript/examples/script/defaultprototypes/main.cpp b/src/shared/qtscript/examples/script/defaultprototypes/main.cpp new file mode 100644 index 00000000..f5bf0538 --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/main.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include +#include +#include "prototypes.h" + +//! [0] +Q_DECLARE_METATYPE(QListWidgetItem*) +Q_DECLARE_METATYPE(QListWidget*) +//! [0] + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(defaultprototypes); + + QApplication app(argc, argv); +//! [1] + QScriptEngine engine; + + ListWidgetItemPrototype lwiProto; + engine.setDefaultPrototype(qMetaTypeId(), + engine.newQObject(&lwiProto)); + + ListWidgetPrototype lwProto; + engine.setDefaultPrototype(qMetaTypeId(), + engine.newQObject(&lwProto)); +//! [1] + +//! [2] + QListWidget listWidget; + engine.globalObject().setProperty("listWidget", + engine.newQObject(&listWidget)); +//! [2] + + QFile file(":/code.js"); + file.open(QIODevice::ReadOnly); + QScriptValue result = engine.evaluate(file.readAll()); + file.close(); + if (engine.hasUncaughtException()) { + int lineNo = engine.uncaughtExceptionLineNumber(); + qWarning() << "line" << lineNo << ":" << result.toString(); + } + + listWidget.show(); + return app.exec(); +} diff --git a/src/shared/qtscript/examples/script/defaultprototypes/prototypes.cpp b/src/shared/qtscript/examples/script/defaultprototypes/prototypes.cpp new file mode 100644 index 00000000..13dcb4ea --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/prototypes.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "prototypes.h" +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QListWidgetItem*) +Q_DECLARE_METATYPE(QListWidget*) + +//! [0] +ListWidgetItemPrototype::ListWidgetItemPrototype(QObject *parent) + : QObject(parent) +{ +} + +QString ListWidgetItemPrototype::text() const +{ + QListWidgetItem *item = qscriptvalue_cast(thisObject()); + if (item) + return item->text(); + return QString(); +} + +void ListWidgetItemPrototype::setText(const QString &text) +{ + QListWidgetItem *item = qscriptvalue_cast(thisObject()); + if (item) + item->setText(text); +} + +QString ListWidgetItemPrototype::toString() const +{ + return QString("ListWidgetItem(text = %0)").arg(text()); +} +//! [0] + + + +//! [1] +ListWidgetPrototype::ListWidgetPrototype(QObject *parent) + : QObject(parent) +{ +} + +void ListWidgetPrototype::addItem(const QString &text) +{ + QListWidget *widget = qscriptvalue_cast(thisObject()); + if (widget) + widget->addItem(text); +} + +void ListWidgetPrototype::addItems(const QStringList &texts) +{ + QListWidget *widget = qscriptvalue_cast(thisObject()); + if (widget) + widget->addItems(texts); +} + +void ListWidgetPrototype::setBackgroundColor(const QString &colorName) +{ + QListWidget *widget = qscriptvalue_cast(thisObject()); + if (widget) { +#ifdef Q_WS_MAEMO_5 + QString style = QString("QListWidget::item {background-color: %1;}").arg(colorName); + style += "QListWidget::item {selection-color: black;}"; + widget->setStyleSheet(style); +#else + QPalette palette = widget->palette(); + QColor color(colorName); + palette.setBrush(QPalette::Base, color); + widget->setPalette(palette); +#endif + } +} +//! [1] diff --git a/src/shared/qtscript/examples/script/defaultprototypes/prototypes.h b/src/shared/qtscript/examples/script/defaultprototypes/prototypes.h new file mode 100644 index 00000000..9ce8b18f --- /dev/null +++ b/src/shared/qtscript/examples/script/defaultprototypes/prototypes.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef PROTOTYPES_H +#define PROTOTYPES_H + +#include +#include + +//! [0] +class ListWidgetItemPrototype : public QObject, public QScriptable +{ + Q_OBJECT + Q_PROPERTY(QString text READ text WRITE setText) +public: + ListWidgetItemPrototype(QObject *parent = 0); + + QString text() const; + void setText(const QString &text); + +public slots: + QString toString() const; +}; +//! [0] + +//! [1] +class ListWidgetPrototype : public QObject, public QScriptable +{ + Q_OBJECT +public: + ListWidgetPrototype(QObject *parent = 0); + +public slots: + void addItem(const QString &text); + void addItems(const QStringList &texts); + void setBackgroundColor(const QString &colorName); +}; +//! [1] + +#endif diff --git a/src/shared/qtscript/examples/script/helloscript/doc/src/helloscript.qdoc b/src/shared/qtscript/examples/script/helloscript/doc/src/helloscript.qdoc new file mode 100644 index 00000000..2af7ad18 --- /dev/null +++ b/src/shared/qtscript/examples/script/helloscript/doc/src/helloscript.qdoc @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example script/helloscript + \title Hello Script Example + + The Hello Script example shows the basic use of Qt Script: How to embed + a script engine into the application, how to evaluate a script, and how + to process the result of the evaluation. The example also shows how to + apply internationalization to scripts. + + \snippet script/helloscript/main.cpp 0 + + The application will load the script file to evaluate from a resource, so + we first make sure that the resource is initialized. + + \snippet script/helloscript/main.cpp 1 + + We attempt to load a translation, and install translation functions in the + script engine. How to produce a translation is explained later. + + \snippet script/helloscript/main.cpp 2 + + A push button is created and exported to the script environment as a + global variable, \c button. Scripts will be able to access properties, + signals and slots of the button as properties of the \c button script + object; the script object acts as a proxy to the C++ button object. + + \snippet script/helloscript/main.cpp 3 + + The contents of the script file are read. + + \snippet script/helloscript/helloscript.js 0 + + The script sets the \c text (note that the qTr() function is used to allow + for translation) and \c styleSheet properties of the button, and calls the + button's \c show() slot. + + \snippet script/helloscript/main.cpp 4 + + The script is evaluated. Note that the file name is passed as the + (optional) second parameter; this makes it possible for the script engine + to produce a meaningful backtrace if something goes wrong, and makes the + qTr() function be able to resolve the translations that are associated + with this script. + + \snippet script/helloscript/main.cpp 5 + + If the result is an Error object (e.g. the script contained a syntax + error, or tried to call a function that doesn't exist), we obtain + the line number and string representation of the error and display + it in a message box. + + \snippet script/helloscript/main.cpp 6 + + If the evaluation went well, the application event loop is entered. + + \section1 Translating the Application + + The Qt Script internalization support builds on what Qt already provides + for C++; see the \l{Hello tr() Example} for an introduction. + + Since we haven't made the translation file \c helloscript_la.qm, the + source text is shown when we run the application ("Hello world!"). + + To generate the translation file, run \c lupdate as follows: + + \code + lupdate helloscript.js -ts helloscript_la.ts + \endcode + + You should now have a file \c helloscript_la.ts in the current + directory. Run \c linguist to edit the translation: + + \code + linguist helloscript_la.ts + \endcode + + You should now see the text "helloscript.js" in the top left pane. + Double-click it, then click on "Hello world!" and enter "Orbis, te + saluto!" in the \gui Translation pane (the middle right of the + window). Don't forget the exclamation mark! + + Click the \gui Done checkbox and choose \gui File|Save from the + menu bar. The TS file will no longer contain + + \snippet code/doc_src_examples_hellotr.qdoc 3 + + but instead will have + + \snippet code/doc_src_examples_hellotr.qdoc 4 + + To see the application running in Latin, we have to generate a QM + file from the TS file. Generating a QM file can be achieved + either from within \e {Qt Linguist} (for a single TS file), or + by using the command line program \c lrelease which will produce one + QM file for each of the TS files listed in the project file. + Generate \c hellotr_la.qm from \c hellotr_la.ts by choosing + \gui File|Release from \e {Qt Linguist}'s menu bar and pressing + \gui Save in the file save dialog that pops up. Now run the \c helloscript + program again. This time the button will be labelled "Orbis, te + saluto!". +*/ diff --git a/src/shared/qtscript/examples/script/helloscript/helloscript.js b/src/shared/qtscript/examples/script/helloscript/helloscript.js new file mode 100644 index 00000000..6d8e87cb --- /dev/null +++ b/src/shared/qtscript/examples/script/helloscript/helloscript.js @@ -0,0 +1,5 @@ +//! [0] +button.text = qsTr('Hello World!'); +button.styleSheet = 'font-style: italic'; +button.show(); +//! [0] diff --git a/src/shared/qtscript/examples/script/helloscript/helloscript.pro b/src/shared/qtscript/examples/script/helloscript/helloscript.pro new file mode 100644 index 00000000..780c8a49 --- /dev/null +++ b/src/shared/qtscript/examples/script/helloscript/helloscript.pro @@ -0,0 +1,8 @@ +QT += widgets script +RESOURCES += helloscript.qrc +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/script/helloscript +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/helloscript/helloscript.qrc b/src/shared/qtscript/examples/script/helloscript/helloscript.qrc new file mode 100644 index 00000000..c52fa155 --- /dev/null +++ b/src/shared/qtscript/examples/script/helloscript/helloscript.qrc @@ -0,0 +1,5 @@ + + + helloscript.js + + diff --git a/src/shared/qtscript/examples/script/helloscript/main.cpp b/src/shared/qtscript/examples/script/helloscript/main.cpp new file mode 100644 index 00000000..2d788090 --- /dev/null +++ b/src/shared/qtscript/examples/script/helloscript/main.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +//! [0] +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(helloscript); +//! [0] + +//! [1] + QApplication app(argc, argv); + + QScriptEngine engine; + + QTranslator translator; + translator.load("helloscript_la"); + app.installTranslator(&translator); + engine.installTranslatorFunctions(); +//! [1] + +//! [2] + QPushButton button; + QScriptValue scriptButton = engine.newQObject(&button); + engine.globalObject().setProperty("button", scriptButton); +//! [2] + +//! [3] + QString fileName(":/helloscript.js"); + QFile scriptFile(fileName); + scriptFile.open(QIODevice::ReadOnly); + QTextStream stream(&scriptFile); + QString contents = stream.readAll(); + scriptFile.close(); +//! [3] + +//! [4] + QScriptValue result = engine.evaluate(contents, fileName); +//! [4] + +//! [5] + if (result.isError()) { + QMessageBox::critical(0, "Hello Script", + QString::fromLatin1("%0:%1: %2") + .arg(fileName) + .arg(result.property("lineNumber").toInt32()) + .arg(result.toString())); + return -1; + } +//! [5] + +//! [6] + return app.exec(); +} +//! [6] diff --git a/src/shared/qtscript/examples/script/marshal/main.cpp b/src/shared/qtscript/examples/script/marshal/main.cpp new file mode 100644 index 00000000..122ecb6f --- /dev/null +++ b/src/shared/qtscript/examples/script/marshal/main.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include + +template +QScriptValue toScriptValue(QScriptEngine *eng, const Container &cont) +{ + QScriptValue a = eng->newArray(); + typename Container::const_iterator begin = cont.begin(); + typename Container::const_iterator end = cont.end(); + typename Container::const_iterator it; + for (it = begin; it != end; ++it) + a.setProperty(quint32(it - begin), eng->toScriptValue(*it)); + return a; +} + +template +void fromScriptValue(const QScriptValue &value, Container &cont) +{ + quint32 len = value.property("length").toUInt32(); + for (quint32 i = 0; i < len; ++i) { + QScriptValue item = value.property(i); + typedef typename Container::value_type ContainerValue; + cont.push_back(qscriptvalue_cast(item)); + } +} + +typedef QVector IntVector; +typedef QVector StringVector; + +Q_DECLARE_METATYPE(IntVector) +Q_DECLARE_METATYPE(StringVector) + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + QScriptEngine eng; + // register our custom types + qScriptRegisterMetaType(&eng, toScriptValue, fromScriptValue); + qScriptRegisterMetaType(&eng, toScriptValue, fromScriptValue); + + QScriptValue val = eng.evaluate("[1, 4, 7, 11, 50, 3, 19, 60]"); + + fprintf(stdout, "Script array: %s\n", qPrintable(val.toString())); + + IntVector iv = qscriptvalue_cast(val); + + fprintf(stdout, "qscriptvalue_cast to QVector: "); + for (int i = 0; i < iv.size(); ++i) + fprintf(stdout, "%s%d", (i > 0) ? "," : "", iv.at(i)); + fprintf(stdout, "\n"); + + val = eng.evaluate("[9, 'foo', 46.5, 'bar', 'Qt', 555, 'hello']"); + + fprintf(stdout, "Script array: %s\n", qPrintable(val.toString())); + + StringVector sv = qscriptvalue_cast(val); + + fprintf(stdout, "qscriptvalue_cast to QVector: "); + for (int i = 0; i < sv.size(); ++i) + fprintf(stdout, "%s%s", (i > 0) ? "," : "", qPrintable(sv.at(i))); + fprintf(stdout, "\n"); + + return 0; +} diff --git a/src/shared/qtscript/examples/script/marshal/marshal.pro b/src/shared/qtscript/examples/script/marshal/marshal.pro new file mode 100644 index 00000000..39654e10 --- /dev/null +++ b/src/shared/qtscript/examples/script/marshal/marshal.pro @@ -0,0 +1,8 @@ +QT = core script +CONFIG += console +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/script/marshal +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/qscript/main.cpp b/src/shared/qtscript/examples/script/qscript/main.cpp new file mode 100644 index 00000000..ae911da0 --- /dev/null +++ b/src/shared/qtscript/examples/script/qscript/main.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + + +#include + +#include +#include +#include +#include + +#include + +#include "bytearrayclass.h" + +static bool wantsToQuit; + +static QScriptValue qtscript_quit(QScriptContext *ctx, QScriptEngine *eng) +{ + Q_UNUSED(ctx); + wantsToQuit = true; + return eng->undefinedValue(); +} + +static void interactive(QScriptEngine *eng) +{ + QScriptValue global = eng->globalObject(); + QScriptValue quitFunction = eng->newFunction(qtscript_quit); + if (!global.property(QLatin1String("exit")).isValid()) + global.setProperty(QLatin1String("exit"), quitFunction); + if (!global.property(QLatin1String("quit")).isValid()) + global.setProperty(QLatin1String("quit"), quitFunction); + wantsToQuit = false; + + QTextStream qin(stdin, QFile::ReadOnly); + + const char *qscript_prompt = "qs> "; + const char *dot_prompt = ".... "; + const char *prompt = qscript_prompt; + + QString code; + + forever { + QString line; + + printf("%s", prompt); + fflush(stdout); + + line = qin.readLine(); + if (line.isNull()) + break; + + code += line; + code += QLatin1Char('\n'); + + if (line.trimmed().isEmpty()) { + continue; + + } else if (! eng->canEvaluate(code)) { + prompt = dot_prompt; + + } else { + QScriptValue result = eng->evaluate(code, QLatin1String("typein")); + + code.clear(); + prompt = qscript_prompt; + + if (! result.isUndefined()) + fprintf(stderr, "%s\n", qPrintable(result.toString())); + + if (wantsToQuit) + break; + } + } +} + +static QScriptValue importExtension(QScriptContext *context, QScriptEngine *engine) +{ + return engine->importExtension(context->argument(0).toString()); +} + +static QScriptValue loadScripts(QScriptContext *context, QScriptEngine *engine) +{ + for (int i = 0; i < context->argumentCount(); ++i) { + QString fileName = context->argument(i).toString(); + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + return context->throwError(QString::fromLatin1("could not open %0 for reading").arg(fileName)); + QTextStream ts(&file); + QString contents = ts.readAll(); + file.close(); + QScriptContext *pc = context->parentContext(); + context->setActivationObject(pc->activationObject()); + context->setThisObject(pc->thisObject()); + QScriptValue ret = engine->evaluate(contents); + if (engine->hasUncaughtException()) + return ret; + } + return engine->undefinedValue(); +} + +int main(int argc, char *argv[]) +{ + QCoreApplication *app = new QCoreApplication(argc, argv); + QScriptEngine *eng = new QScriptEngine(); + + QScriptValue globalObject = eng->globalObject(); + + globalObject.setProperty("load", eng->newFunction(loadScripts, /*length=*/1)); + + { + if (!globalObject.property("qt").isObject()) + globalObject.setProperty("qt", eng->newObject()); + QScriptValue qscript = eng->newObject(); + qscript.setProperty("importExtension", eng->newFunction(importExtension)); + globalObject.property("qt").setProperty("script", qscript); + } + + ByteArrayClass *byteArrayClass = new ByteArrayClass(eng); + globalObject.setProperty("ByteArray", byteArrayClass->constructor()); + + if (! *++argv) { + interactive(eng); + return EXIT_SUCCESS; + } + + while (const char *arg = *argv++) { + QString fn = QString::fromLocal8Bit(arg); + + if (fn == QLatin1String("-i")) { + interactive(eng); + break; + } + + QString contents; + int lineNumber = 1; + + if (fn == QLatin1String("-")) { + QTextStream stream(stdin, QFile::ReadOnly); + contents = stream.readAll(); + } + + else { + QFile file(fn); + + if (file.open(QFile::ReadOnly)) { + QTextStream stream(&file); + contents = stream.readAll(); + file.close(); + + // strip off #!/usr/bin/env qscript line + if (contents.startsWith("#!")) { + contents.remove(0, contents.indexOf("\n")); + ++lineNumber; + } + } + } + + if (contents.isEmpty()) + continue; + + QScriptValue r = eng->evaluate(contents, fn, lineNumber); + if (eng->hasUncaughtException()) { + QStringList backtrace = eng->uncaughtExceptionBacktrace(); + fprintf (stderr, " %s\n%s\n\n", qPrintable(r.toString()), + qPrintable(backtrace.join("\n"))); + return EXIT_FAILURE; + } + } + + delete eng; + delete app; + + return EXIT_SUCCESS; +} diff --git a/src/shared/qtscript/examples/script/qscript/qscript.pro b/src/shared/qtscript/examples/script/qscript/qscript.pro new file mode 100644 index 00000000..697d71bc --- /dev/null +++ b/src/shared/qtscript/examples/script/qscript/qscript.pro @@ -0,0 +1,13 @@ + +QT += script +win32:CONFIG += console no_batch +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + +include(../customclass/bytearrayclass.pri) + +target.path = $$[QT_INSTALL_EXAMPLES]/script/qscript +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/qsdbg/example.js b/src/shared/qtscript/examples/script/qsdbg/example.js new file mode 100644 index 00000000..47c1363d --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/example.js @@ -0,0 +1,17 @@ +function bar() { + var x = 1; + var y = 2; + return x + y; +} + +function foo(a, b, c) { + var i = a + bar(); + var j = b - bar(); + var k = c * bar(); + return Math.cos(i) + Math.sin(j) - Math.atan(k); +} + +var first = foo(1, 2, 3); +var second = foo(4, 5, 6); +print("first was:", first, ", and second was:", second); + diff --git a/src/shared/qtscript/examples/script/qsdbg/main.cpp b/src/shared/qtscript/examples/script/qsdbg/main.cpp new file mode 100644 index 00000000..a84460f1 --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/main.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include +#include + +#include "scriptdebugger.h" + +int main(int argc, char **argv) +{ + QCoreApplication app(argc, argv); + + if (argc < 2) { + fprintf(stderr, "*** you must specify a script file to evaluate (try example.js)\n"); + return(-1); + } + + QString fileName = QString::fromLatin1(argv[1]); + QFile file(fileName); + if (!file.open(QFile::ReadOnly)) { + fprintf(stderr, "*** failed to open `%s' for reading\n", argv[1]); + return(-1); + } + + QScriptEngine engine; + QString code = QTextStream(&file).readAll(); + file.close(); + + fprintf(stdout, "\n*** Welcome to qsdbg. Debugger commands start with a . (period)\n"); + fprintf(stdout, "*** Any other input will be evaluated by the script interpreter.\n"); + fprintf(stdout, "*** Type .help for help.\n\n"); + + ScriptDebugger *dbg = new ScriptDebugger(&engine); + dbg->breakAtNextStatement(); + + engine.evaluate(code, fileName); + + return 0; +} diff --git a/src/shared/qtscript/examples/script/qsdbg/qsdbg.pri b/src/shared/qtscript/examples/script/qsdbg/qsdbg.pri new file mode 100644 index 00000000..618e623e --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/qsdbg.pri @@ -0,0 +1,9 @@ +SOURCES += \ + $$PWD/scriptdebugger.cpp \ + $$PWD/scriptbreakpointmanager.cpp + +HEADERS += \ + $$PWD/scriptdebugger.h \ + $$PWD/scriptbreakpointmanager.h + +INCLUDEPATH += $$PWD diff --git a/src/shared/qtscript/examples/script/qsdbg/qsdbg.pro b/src/shared/qtscript/examples/script/qsdbg/qsdbg.pro new file mode 100644 index 00000000..e685e897 --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/qsdbg.pro @@ -0,0 +1,14 @@ +QT = core script +win32: CONFIG += console +mac: CONFIG -= app_bundle + +SOURCES += main.cpp + +include(qsdbg.pri) + +EXAMPLE_FILES = *.js + +target.path = $$[QT_INSTALL_EXAMPLES]/script/qsdbg +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.cpp b/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.cpp new file mode 100644 index 00000000..5a50396e --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "scriptbreakpointmanager.h" + +ScriptBreakpointManager::ScriptBreakpointManager() +{ +} + +ScriptBreakpointManager::~ScriptBreakpointManager() +{ +} + +bool ScriptBreakpointManager::hasBreakpoints() const +{ + return !breakpoints.isEmpty(); +} + +int ScriptBreakpointManager::setBreakpoint(const QString &fileName, int lineNumber) +{ + breakpoints.append(ScriptBreakpointInfo(fileName, lineNumber)); + return breakpoints.size() - 1; +} + +int ScriptBreakpointManager::setBreakpoint(const QString &functionName, const QString &fileName) +{ + breakpoints.append(ScriptBreakpointInfo(functionName, fileName)); + return breakpoints.size() - 1; +} + +int ScriptBreakpointManager::setBreakpoint(const QScriptValue &function) +{ + breakpoints.append(ScriptBreakpointInfo(function)); + return breakpoints.size() - 1; +} + +void ScriptBreakpointManager::removeBreakpoint(int id) +{ + if (id >= 0 && id < breakpoints.size()) + breakpoints[id] = ScriptBreakpointInfo(); +} + +int ScriptBreakpointManager::findBreakpoint(const QString &fileName, int lineNumber) const +{ + for (int i = 0; i < breakpoints.size(); ++i) { + const ScriptBreakpointInfo &brk = breakpoints.at(i); + if (brk.type != ScriptBreakpointInfo::File) + continue; + if (brk.fileName == fileName && brk.lineNumber == lineNumber) + return i; + } + return -1; +} + +int ScriptBreakpointManager::findBreakpoint(const QString &functionName, const QString &fileName) const +{ + for (int i = 0; i < breakpoints.size(); ++i) { + const ScriptBreakpointInfo &brk = breakpoints.at(i); + if (brk.type != ScriptBreakpointInfo::FunctionName) + continue; + if (brk.functionName == functionName && brk.fileName == fileName) + return i; + } + return -1; +} + +int ScriptBreakpointManager::findBreakpoint(const QScriptValue &function) const +{ + for (int i = 0; i < breakpoints.size(); ++i) { + const ScriptBreakpointInfo &brk = breakpoints.at(i); + if (brk.type != ScriptBreakpointInfo::Function) + continue; + if (brk.function.strictlyEquals(function)) + return i; + } + return -1; +} + +bool ScriptBreakpointManager::isBreakpointEnabled(int id) const +{ + return breakpoints.value(id).enabled; +} + +void ScriptBreakpointManager::setBreakpointEnabled(int id, bool enabled) +{ + if (id >= 0 && id < breakpoints.size()) + breakpoints[id].enabled = enabled; +} + +QString ScriptBreakpointManager::breakpointCondition(int id) const +{ + return breakpoints.value(id).condition; +} + +void ScriptBreakpointManager::setBreakpointCondition(int id, const QString &expression) +{ + if (id >= 0 && id < breakpoints.size()) + breakpoints[id].condition = expression; +} + +int ScriptBreakpointManager::breakpointIgnoreCount(int id) const +{ + return breakpoints.value(id).ignoreCount; +} + +void ScriptBreakpointManager::setBreakpointIgnoreCount(int id, int ignoreCount) +{ + if (id >= 0 && id < breakpoints.size()) + breakpoints[id].ignoreCount = ignoreCount; +} + +bool ScriptBreakpointManager::isBreakpointSingleShot(int id) const +{ + return breakpoints.value(id).singleShot; +} + +void ScriptBreakpointManager::setBreakpointSingleShot(int id, bool singleShot) +{ + if (id >= 0 && id < breakpoints.size()) + breakpoints[id].singleShot = singleShot; +} diff --git a/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.h b/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.h new file mode 100644 index 00000000..7896200a --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/scriptbreakpointmanager.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SCRIPTBREAKPOINTMANAGER_H +#define SCRIPTBREAKPOINTMANAGER_H + +#include +#include +#include + +class ScriptBreakpointInfo +{ +public: + enum Type { + File, + FunctionName, + Function, + Invalid + }; + + Type type; + QString functionName; + QString fileName; + int lineNumber; + QScriptValue function; + bool enabled; + QString condition; + int ignoreCount; + bool singleShot; + + ScriptBreakpointInfo(const QString &fileName, int lineNumber) + : type(File), fileName(fileName), lineNumber(lineNumber), + enabled(true), ignoreCount(0), singleShot(false) + { } + ScriptBreakpointInfo(const QString &functionName, const QString &fileName = QString()) + : type(FunctionName), functionName(functionName), fileName(fileName), + enabled(true), ignoreCount(0), singleShot(false) + { } + ScriptBreakpointInfo(const QScriptValue &function) + : type(Function), function(function), + enabled(true), ignoreCount(0), singleShot(false) + { } + ScriptBreakpointInfo() + : type(Invalid) + { } +}; + +class ScriptBreakpointManager +{ +public: + ScriptBreakpointManager(); + ~ScriptBreakpointManager(); + + bool hasBreakpoints() const; + + int setBreakpoint(const QString &fileName, int lineNumber); + int setBreakpoint(const QString &functionName, const QString &fileName = QString()); + int setBreakpoint(const QScriptValue &function); + + void removeBreakpoint(int id); + + int findBreakpoint(const QString &fileName, int lineNumber) const; + int findBreakpoint(const QString &functionName, const QString &fileName = QString()) const; + int findBreakpoint(const QScriptValue &function) const; + + bool isBreakpointEnabled(int id) const; + void setBreakpointEnabled(int id, bool enabled); + + QString breakpointCondition(int id) const; + void setBreakpointCondition(int id, const QString &expression); + + int breakpointIgnoreCount(int id) const; + void setBreakpointIgnoreCount(int id, int ignoreCount); + + bool isBreakpointSingleShot(int id) const; + void setBreakpointSingleShot(int id, bool singleShot); + +private: + QList breakpoints; + + Q_DISABLE_COPY(ScriptBreakpointManager) +}; + +#endif // SCRIPTBREAKPOINTMANAGER_H diff --git a/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.cpp b/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.cpp new file mode 100644 index 00000000..81ab8c1e --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.cpp @@ -0,0 +1,747 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "scriptdebugger.h" +#include "scriptbreakpointmanager.h" + +#include +#include +#include +#include +#include +#include + +static QString safeValueToString(const QScriptValue &value) +{ + if (value.isObject()) + return QLatin1String("[object Object]"); + else + return value.toString(); +} + +class ScriptInfo; +class ScriptBreakpointManager; + +class ScriptDebuggerPrivate + : public QScriptEngineAgent +{ + Q_DECLARE_PUBLIC(ScriptDebugger) +public: + enum Mode { + Run, + StepInto, + StepOver + }; + + ScriptDebuggerPrivate(QScriptEngine *engine); + ~ScriptDebuggerPrivate(); + + // QScriptEngineAgent interface + void scriptLoad(qint64 id, const QString &program, + const QString &fileName, int lineNumber); + void scriptUnload(qint64 id); + + void positionChange(qint64 scriptId, + int lineNumber, int columnNumber); + + void functionEntry(qint64 scriptId); + void functionExit(qint64 scriptId, + const QScriptValue &returnValue); + + void exceptionThrow(qint64 scriptId, + const QScriptValue &exception, bool hasHandler); + + + void interactive(); + bool executeCommand(const QString &command, const QStringList &args); + + void setMode(Mode mode); + Mode mode() const; + + int frameCount() const; + void setCurrentFrameIndex(int index); + int currentFrameIndex() const; + + QScriptContext *frameContext(int index) const; + QScriptContext *currentFrameContext() const; + + ScriptInfo *scriptInfo(QScriptContext *context) const; + + int listLineNumber() const; + void setListLineNumber(int lineNumber); + + QString readLine(); + void output(const QString &text); + void message(const QString &text); + void errorMessage(const QString &text); + + // attributes + QTextStream *m_defaultInputStream; + QTextStream *m_defaultOutputStream; + QTextStream *m_defaultErrorStream; + QTextStream *m_inputStream; + QTextStream *m_outputStream; + QTextStream *m_errorStream; + + ScriptBreakpointManager *m_bpManager; + Mode m_mode; + QMap m_scripts; + QMap > m_contextProgramIds; + + QString m_lastInteractiveCommand; + QString m_commandPrefix; + int m_stepDepth; + int m_currentFrameIndex; + int m_listLineNumber; + + ScriptDebugger *q_ptr; +}; + +class ScriptInfo +{ +public: + ScriptInfo(const QString &code, const QString &fileName, int lineNumber) + : m_code(code), m_fileName(fileName), m_lineNumber(lineNumber) + { } + + inline QString code() const + { return m_code; } + inline QString fileName() const + { return m_fileName; } + inline int lineNumber() const + { return m_lineNumber; } + + QString lineText(int lineNumber); + QMap m_lineOffsets; + +private: + int lineOffset(int lineNumber); + + QString m_code; + QString m_fileName; + int m_lineNumber; +}; + +int ScriptInfo::lineOffset(int lineNumber) +{ + QMap::const_iterator it = m_lineOffsets.constFind(lineNumber); + if (it != m_lineOffsets.constEnd()) + return it.value(); + + int offset; + it = m_lineOffsets.constFind(lineNumber - 1); + if (it != m_lineOffsets.constEnd()) { + offset = it.value(); + offset = m_code.indexOf(QLatin1Char('\n'), offset); + if (offset != -1) + ++offset; + m_lineOffsets.insert(lineNumber, offset); + } else { + int index; + it = m_lineOffsets.lowerBound(lineNumber); + if (it != m_lineOffsets.constBegin()) + --it; + if (it != m_lineOffsets.constBegin()) { + index = it.key(); + offset = it.value(); + } else { + index = m_lineNumber; + offset = 0; + } + int j = index; + for ( ; j < lineNumber; ++j) { + m_lineOffsets.insert(j, offset); + offset = m_code.indexOf(QLatin1Char('\n'), offset); + if (offset == -1) + break; + ++offset; + } + m_lineOffsets.insert(j, offset); + } + return offset; +} + +QString ScriptInfo::lineText(int lineNumber) +{ + int startOffset = lineOffset(lineNumber); + if (startOffset == -1) + return QString(); + int endOffset = lineOffset(lineNumber + 1); + if (endOffset == -1) + return m_code.mid(startOffset); + else + return m_code.mid(startOffset, endOffset - startOffset - 1); +} + + + +ScriptDebuggerPrivate::ScriptDebuggerPrivate(QScriptEngine *engine) + : QScriptEngineAgent(engine), m_mode(Run) +{ + m_commandPrefix = QLatin1String("."); + m_bpManager = new ScriptBreakpointManager; + m_defaultInputStream = new QTextStream(stdin); + m_defaultOutputStream = new QTextStream(stdout); + m_defaultErrorStream = new QTextStream(stderr); + m_inputStream = m_defaultInputStream; + m_outputStream = m_defaultOutputStream; + m_errorStream = m_defaultErrorStream; +} + +ScriptDebuggerPrivate::~ScriptDebuggerPrivate() +{ + delete m_defaultInputStream; + delete m_defaultOutputStream; + delete m_defaultErrorStream; + delete m_bpManager; + qDeleteAll(m_scripts); +} + +QString ScriptDebuggerPrivate::readLine() +{ + return m_inputStream->readLine(); +} + +void ScriptDebuggerPrivate::output(const QString &text) +{ + *m_outputStream << text; +} + +void ScriptDebuggerPrivate::message(const QString &text) +{ + *m_outputStream << text << Qt::endl; + m_outputStream->flush(); +} + +void ScriptDebuggerPrivate::errorMessage(const QString &text) +{ + *m_errorStream << text << Qt::endl; + m_errorStream->flush(); +} + +void ScriptDebuggerPrivate::setMode(Mode mode) +{ + m_mode = mode; +} + +ScriptDebuggerPrivate::Mode ScriptDebuggerPrivate::mode() const +{ + return m_mode; +} + +QScriptContext *ScriptDebuggerPrivate::frameContext(int index) const +{ + QScriptContext *ctx = engine()->currentContext(); + for (int i = 0; i < index; ++i) { + ctx = ctx->parentContext(); + if (!ctx) + break; + } + return ctx; +} + +int ScriptDebuggerPrivate::currentFrameIndex() const +{ + return m_currentFrameIndex; +} + +void ScriptDebuggerPrivate::setCurrentFrameIndex(int index) +{ + m_currentFrameIndex = index; + m_listLineNumber = -1; +} + +int ScriptDebuggerPrivate::listLineNumber() const +{ + return m_listLineNumber; +} + +void ScriptDebuggerPrivate::setListLineNumber(int lineNumber) +{ + m_listLineNumber = lineNumber; +} + +QScriptContext *ScriptDebuggerPrivate::currentFrameContext() const +{ + return frameContext(currentFrameIndex()); +} + +int ScriptDebuggerPrivate::frameCount() const +{ + int count = 0; + QScriptContext *ctx = engine()->currentContext(); + while (ctx) { + ++count; + ctx = ctx->parentContext(); + } + return count; +} + +ScriptInfo *ScriptDebuggerPrivate::scriptInfo(QScriptContext *context) const +{ + QStack pids = m_contextProgramIds.value(context); + if (pids.isEmpty()) + return 0; + return m_scripts.value(pids.top()); +} + +void ScriptDebuggerPrivate::interactive() +{ + setCurrentFrameIndex(0); + + QString qsdbgPrompt = QString::fromLatin1("(qsdbg) "); + QString dotPrompt = QString::fromLatin1(".... "); + QString prompt = qsdbgPrompt; + + QString code; + + forever { + + *m_outputStream << prompt; + m_outputStream->flush(); + + QString line = readLine(); + + if (code.isEmpty() && (line.isEmpty() || line.startsWith(m_commandPrefix))) { + if (line.isEmpty()) + line = m_lastInteractiveCommand; + else + m_lastInteractiveCommand = line; + + QStringList parts = line.split(QLatin1Char(' '), Qt::SkipEmptyParts); + if (!parts.isEmpty()) { + QString command = parts.takeFirst().mid(1); + if (executeCommand(command, parts)) + break; + } + + } else { + if (line.isEmpty()) + continue; + + code += line; + code += QLatin1Char('\n'); + + if (line.trimmed().isEmpty()) { + continue; + + } else if (! engine()->canEvaluate(code)) { + prompt = dotPrompt; + + } else { + setMode(Run); + QScriptValue result = engine()->evaluate(code, QLatin1String("typein")); + + code.clear(); + prompt = qsdbgPrompt; + + if (! result.isUndefined()) { + errorMessage(result.toString()); + engine()->clearExceptions(); + } + } + } + } +} + +bool ScriptDebuggerPrivate::executeCommand(const QString &command, const QStringList &args) +{ + if (command == QLatin1String("c") + || command == QLatin1String("continue")) { + setMode(Run); + return true; + } else if (command == QLatin1String("s") + || command == QLatin1String("step")) { + setMode(StepInto); + return true; + } else if (command == QLatin1String("n") + || command == QLatin1String("next")) { + setMode(StepOver); + m_stepDepth = 0; + return true; + } else if (command == QLatin1String("f") + || command == QLatin1String("frame")) { + bool ok = false; + int index = args.value(0).toInt(&ok); + if (ok) { + if (index < 0 || index >= frameCount()) { + errorMessage("No such frame."); + } else { + setCurrentFrameIndex(index); + QScriptContext *ctx = currentFrameContext(); + message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); + } + } + } else if (command == QLatin1String("bt") + || command == QLatin1String("backtrace")) { + QScriptContext *ctx = engine()->currentContext(); + int index = -1; + while (ctx) { + ++index; + QString line = ctx->toString(); + message(QString::fromLatin1("#%0 %1").arg(index).arg(line)); + ctx = ctx->parentContext(); + } + } else if (command == QLatin1String("up")) { + int index = currentFrameIndex() + 1; + if (index == frameCount()) { + errorMessage(QString::fromLatin1("Initial frame selected; you cannot go up.")); + } else { + setCurrentFrameIndex(index); + QScriptContext *ctx = currentFrameContext(); + message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); + } + } else if (command == QLatin1String("down")) { + int index = currentFrameIndex() - 1; + if (index < 0) { + errorMessage(QString::fromLatin1("Bottom (innermost) frame selected; you cannot go down.")); + } else { + setCurrentFrameIndex(index); + QScriptContext *ctx = currentFrameContext(); + message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); + } + } else if (command == QLatin1String("b") + || command == QLatin1String("break")) { + QString str = args.value(0); + int colonIndex = str.indexOf(QLatin1Char(':')); + if (colonIndex != -1) { + // filename:line form + QString fileName = str.left(colonIndex); + int lineNumber = str.mid(colonIndex+1).toInt(); + int id = m_bpManager->setBreakpoint(fileName, lineNumber); + message(QString::fromLatin1("Breakpoint %0 at %1, line %2.").arg(id+1).arg(fileName).arg(lineNumber)); + } else { + // function + QScriptValue fun = engine()->globalObject().property(str); + if (fun.isFunction()) { + int id = m_bpManager->setBreakpoint(fun); + message(QString::fromLatin1("Breakpoint %0 at %1().").arg(id+1).arg(str)); + } + } + } else if (command == QLatin1String("d") + || command == QLatin1String("delete")) { + int id = args.value(0).toInt() - 1; + m_bpManager->removeBreakpoint(id); + } else if (command == QLatin1String("disable")) { + int id = args.value(0).toInt() - 1; + m_bpManager->setBreakpointEnabled(id, false); + } else if (command == QLatin1String("enable")) { + int id = args.value(0).toInt() - 1; + m_bpManager->setBreakpointEnabled(id, true); + } else if (command == QLatin1String("list")) { + QScriptContext *ctx = currentFrameContext(); + ScriptInfo *progInfo = scriptInfo(ctx); + if (!progInfo) { + errorMessage("No source text available for this frame."); + } else { + QScriptContextInfo ctxInfo(ctx); + bool ok; + int line = args.value(0).toInt(&ok); + if (ok) { + line = qMax(1, line - 5); + } else { + line = listLineNumber(); + if (line == -1) + line = qMax(progInfo->lineNumber(), ctxInfo.lineNumber() - 5); + } + for (int i = line; i < line + 10; ++i) { + message(QString::fromLatin1("%0\t%1").arg(i).arg(progInfo->lineText(i))); + } + setListLineNumber(line + 10); + } + } else if (command == QLatin1String("info")) { + if (args.size() < 1) { + } else { + QString what = args.value(0); + if (what == QLatin1String("locals")) { + QScriptValueIterator it(currentFrameContext()->activationObject()); + while (it.hasNext()) { + it.next(); + QString line; + line.append(it.name()); + line.append(QLatin1String(" = ")); + line.append(safeValueToString(it.value())); + message(line); + } + } + } + } else if (command == QLatin1String("help")) { + message("continue - continue execution\n" + "step - step into statement\n" + "next - step over statement\n" + "list - show where you are\n" + "\n" + "break - set breakpoint\n" + "delete - remove breakpoint\n" + "disable - disable breakpoint\n" + "enable - enable breakpoint\n" + "\n" + "backtrace - show backtrace\n" + "up - one frame up\n" + "down - one frame down\n" + "frame - set frame\n" + "\n" + "info locals - show local variables"); + } else { + errorMessage(QString::fromLatin1("Undefined command \"%0\". Try \"help\".") + .arg(command)); + } + + return false; +} + + +// QScriptEngineAgent interface + +void ScriptDebuggerPrivate::scriptLoad(qint64 id, const QString &program, + const QString &fileName, int lineNumber) +{ + ScriptInfo *info = new ScriptInfo(program, fileName, lineNumber); + m_scripts.insert(id, info); +} + +void ScriptDebuggerPrivate::scriptUnload(qint64 id) +{ + ScriptInfo *info = m_scripts.take(id); + delete info; +} + +void ScriptDebuggerPrivate::functionEntry(qint64 scriptId) +{ + if (scriptId != -1) { + QScriptContext *ctx = engine()->currentContext(); + QStack ids = m_contextProgramIds.value(ctx); + ids.push(scriptId); + m_contextProgramIds.insert(ctx, ids); + } + + if (mode() == StepOver) + ++m_stepDepth; +} + +void ScriptDebuggerPrivate::functionExit(qint64 scriptId, + const QScriptValue &/*returnValue*/) +{ + if (scriptId != -1) { + QScriptContext *ctx = engine()->currentContext(); + QStack ids = m_contextProgramIds.value(ctx); + Q_ASSERT(!ids.isEmpty()); + Q_ASSERT(ids.top() == scriptId); + ids.pop(); + m_contextProgramIds.insert(ctx, ids); + } + + if (mode() == StepOver) + --m_stepDepth; +} + +void ScriptDebuggerPrivate::positionChange(qint64 scriptId, + int lineNumber, int /*columnNumber*/) +{ + ScriptInfo *info = 0; + bool enterInteractiveMode = false; + + if (m_bpManager->hasBreakpoints()) { + // check if we hit a breakpoint + info = m_scripts.value(scriptId); + QScriptContext *ctx = engine()->currentContext(); + QScriptContextInfo ctxInfo(ctx); + QScriptValue callee = ctx->callee(); + + // try fileName:lineNumber + int bpid = m_bpManager->findBreakpoint(info->fileName(), lineNumber); + if ((bpid != -1) && m_bpManager->isBreakpointEnabled(bpid)) { + message(QString::fromLatin1("Breakpoint %0 at %1:%2") + .arg(bpid + 1).arg(info->fileName()).arg(lineNumber)); + if (m_bpManager->isBreakpointSingleShot(bpid)) + m_bpManager->removeBreakpoint(bpid); + } + if (bpid == -1) { + // try function + bpid = m_bpManager->findBreakpoint(callee); + if ((bpid != -1) && m_bpManager->isBreakpointEnabled(bpid)) { + message(QString::fromLatin1("Breakpoint %0, %1()") + .arg(bpid + 1).arg(ctxInfo.functionName())); + if (m_bpManager->isBreakpointSingleShot(bpid)) + m_bpManager->removeBreakpoint(bpid); + } + } + if ((bpid == -1) && !ctxInfo.functionName().isEmpty()) { + // try functionName:fileName + bpid = m_bpManager->findBreakpoint(ctxInfo.functionName(), ctxInfo.fileName()); + if ((bpid != -1) && m_bpManager->isBreakpointEnabled(bpid)) { + message(QString::fromLatin1("Breakpoint %0, %1():%2").arg(bpid + 1) + .arg(ctxInfo.functionName()).arg(ctxInfo.fileName())); + if (m_bpManager->isBreakpointSingleShot(bpid)) + m_bpManager->removeBreakpoint(bpid); + } + } + + enterInteractiveMode = (bpid != -1); + } + + switch (mode()) { + case Run: + break; + + case StepInto: + enterInteractiveMode = true; + break; + + case StepOver: + enterInteractiveMode = enterInteractiveMode || (m_stepDepth <= 0); + break; + } + + if (enterInteractiveMode) { + if (!info) + info = m_scripts.value(scriptId); + Q_ASSERT(info); + message(QString::fromLatin1("%0\t%1").arg(lineNumber).arg(info->lineText(lineNumber))); + interactive(); + } +} + +void ScriptDebuggerPrivate::exceptionThrow(qint64 /*scriptId*/, + const QScriptValue &exception, + bool hasHandler) +{ + if (!hasHandler) { + errorMessage(QString::fromLatin1("uncaught exception: %0").arg(exception.toString())); + QScriptContext *ctx = engine()->currentContext(); + int lineNumber = QScriptContextInfo(ctx).lineNumber(); + ScriptInfo *info = scriptInfo(ctx); + QString lineText = info ? info->lineText(lineNumber) : QString("(no source text available)"); + message(QString::fromLatin1("%0\t%1").arg(lineNumber).arg(lineText)); + interactive(); + } +} + + + +ScriptDebugger::ScriptDebugger(QScriptEngine *engine) + : d_ptr(new ScriptDebuggerPrivate(engine)) +{ + d_ptr->q_ptr = this; + engine->setAgent(d_ptr); +} + +ScriptDebugger::ScriptDebugger(QScriptEngine *engine, ScriptDebuggerPrivate &dd) + : d_ptr(&dd) +{ + d_ptr->q_ptr = this; + engine->setAgent(d_ptr); +} + +ScriptDebugger::~ScriptDebugger() +{ + delete d_ptr; + d_ptr = 0; +} + +void ScriptDebugger::breakAtNextStatement() +{ + Q_D(ScriptDebugger); + d->setMode(ScriptDebuggerPrivate::StepInto); +} + +void ScriptDebugger::setBreakpoint(const QString &fileName, int lineNumber) +{ + Q_D(ScriptDebugger); + d->m_bpManager->setBreakpoint(fileName, lineNumber); +} + +void ScriptDebugger::setBreakpoint(const QString &functionName, const QString &fileName) +{ + Q_D(ScriptDebugger); + d->m_bpManager->setBreakpoint(functionName, fileName); +} + +void ScriptDebugger::setBreakpoint(const QScriptValue &function) +{ + Q_D(ScriptDebugger); + d->m_bpManager->setBreakpoint(function); +} + +QTextStream *ScriptDebugger::inputStream() const +{ + Q_D(const ScriptDebugger); + return d->m_inputStream; +} + +void ScriptDebugger::setInputStream(QTextStream *inputStream) +{ + Q_D(ScriptDebugger); + d->m_inputStream = inputStream; +} + +QTextStream *ScriptDebugger::outputStream() const +{ + Q_D(const ScriptDebugger); + return d->m_outputStream; +} + +void ScriptDebugger::setOutputStream(QTextStream *outputStream) +{ + Q_D(ScriptDebugger); + d->m_outputStream = outputStream; +} + +QTextStream *ScriptDebugger::errorStream() const +{ + Q_D(const ScriptDebugger); + return d->m_errorStream; +} + +void ScriptDebugger::setErrorStream(QTextStream *errorStream) +{ + Q_D(ScriptDebugger); + d->m_errorStream = errorStream; +} diff --git a/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.h b/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.h new file mode 100644 index 00000000..3c0c2a5c --- /dev/null +++ b/src/shared/qtscript/examples/script/qsdbg/scriptdebugger.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef SCRIPTDEBUGGER_H +#define SCRIPTDEBUGGER_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QScriptEngine; +class QScriptValue; +class QTextStream; +QT_END_NAMESPACE + +class ScriptDebuggerPrivate; +class ScriptDebugger +{ +public: + ScriptDebugger(QScriptEngine *engine); + virtual ~ScriptDebugger(); + + void breakAtNextStatement(); + + void setBreakpoint(const QString &fileName, int lineNumber); + void setBreakpoint(const QString &functionName, const QString &fileName = QString()); + void setBreakpoint(const QScriptValue &function); + + QTextStream *inputStream() const; + void setInputStream(QTextStream *inputStream); + + QTextStream *outputStream() const; + void setOutputStream(QTextStream *outputStream); + + QTextStream *errorStream() const; + void setErrorStream(QTextStream *errorStream); + +protected: + ScriptDebugger(QScriptEngine *engine, ScriptDebuggerPrivate &dd); + ScriptDebuggerPrivate *d_ptr; + +private: + Q_DECLARE_PRIVATE(ScriptDebugger) + Q_DISABLE_COPY(ScriptDebugger) +}; + +#endif // SCRIPTDEBUGGER_H diff --git a/src/shared/qtscript/examples/script/qstetrix/main.cpp b/src/shared/qtscript/examples/script/qstetrix/main.cpp new file mode 100644 index 00000000..43f32b4e --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/main.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "tetrixboard.h" + +#include +#include +#include +#include +#include +#include + +#ifndef QT_NO_SCRIPTTOOLS +#include +#endif + +struct QtMetaObject : private QObject +{ +public: + static const QMetaObject *get() + { return &static_cast(0)->staticQtMetaObject; } +}; + +//! [0] +class TetrixUiLoader : public QUiLoader +{ +public: + TetrixUiLoader(QObject *parent = 0) + : QUiLoader(parent) + { } + virtual QWidget *createWidget(const QString &className, QWidget *parent = 0, + const QString &name = QString()) + { + if (className == QLatin1String("TetrixBoard")) { + QWidget *board = new TetrixBoard(parent); + board->setObjectName(name); + return board; + } + return QUiLoader::createWidget(className, parent, name); + } +}; +//! [0] + +static QScriptValue evaluateFile(QScriptEngine &engine, const QString &fileName) +{ + QFile file(fileName); + file.open(QIODevice::ReadOnly); + return engine.evaluate(file.readAll(), fileName); +} + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(tetrix); + +//! [1] + QApplication app(argc, argv); + QScriptEngine engine; + + QScriptValue Qt = engine.newQMetaObject(QtMetaObject::get()); + Qt.setProperty("App", engine.newQObject(&app)); + engine.globalObject().setProperty("Qt", Qt); +//! [1] + +#if !defined(QT_NO_SCRIPTTOOLS) + QScriptEngineDebugger debugger; + debugger.attachTo(&engine); + QMainWindow *debugWindow = debugger.standardWindow(); + debugWindow->resize(1024, 640); +#endif + +//! [2] + evaluateFile(engine, ":/tetrixpiece.js"); + evaluateFile(engine, ":/tetrixboard.js"); + evaluateFile(engine, ":/tetrixwindow.js"); +//! [2] + +//! [3] + TetrixUiLoader loader; + QFile uiFile(":/tetrixwindow.ui"); + uiFile.open(QIODevice::ReadOnly); + QWidget *ui = loader.load(&uiFile); + uiFile.close(); + + QScriptValue ctor = engine.evaluate("TetrixWindow"); + QScriptValue scriptUi = engine.newQObject(ui, QScriptEngine::ScriptOwnership); + QScriptValue tetrix = ctor.construct(QScriptValueList() << scriptUi); +//! [3] + + QPushButton *debugButton = ui->findChild("debugButton"); +#if !defined(QT_NO_SCRIPTTOOLS) + QObject::connect(debugButton, SIGNAL(clicked()), + debugger.action(QScriptEngineDebugger::InterruptAction), + SIGNAL(triggered())); + QObject::connect(debugButton, SIGNAL(clicked()), + debugWindow, SLOT(show())); +#else + debugButton->hide(); +#endif + +//! [4] + ui->resize(550, 370); + ui->show(); + + return app.exec(); +//! [4] +} diff --git a/src/shared/qtscript/examples/script/qstetrix/qstetrix.pro b/src/shared/qtscript/examples/script/qstetrix/qstetrix.pro new file mode 100644 index 00000000..6d4bb1c4 --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/qstetrix.pro @@ -0,0 +1,14 @@ +QT += widgets script uitools + +HEADERS = tetrixboard.h +SOURCES = main.cpp \ + tetrixboard.cpp + +RESOURCES = tetrix.qrc + +qtHaveModule(scripttools): QT += scripttools + +target.path = $$[QT_INSTALL_EXAMPLES]/script/qstetrix +INSTALLS += target + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrix.qrc b/src/shared/qtscript/examples/script/qstetrix/tetrix.qrc new file mode 100644 index 00000000..58d085aa --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrix.qrc @@ -0,0 +1,8 @@ + + + tetrixwindow.js + tetrixwindow.ui + tetrixboard.js + tetrixpiece.js + + diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixboard.cpp b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.cpp new file mode 100644 index 00000000..914c6df8 --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#include "tetrixboard.h" + +#include + +Q_DECLARE_METATYPE(QPainter*) + +TetrixBoard::TetrixBoard(QWidget *parent) + : QFrame(parent) +{ + timer = new QTimer(this); + qMetaTypeId(); +} + +void TetrixBoard::setNextPieceLabel(QWidget *label) +{ + nextPieceLbl = qobject_cast(label); +} + +QLabel *TetrixBoard::nextPieceLabel() const +{ + return nextPieceLbl; +} + +QObject *TetrixBoard::getTimer() +{ + return timer; +} + +QSize TetrixBoard::minimumSizeHint() const +{ + return QSize(BoardWidth * 5 + frameWidth() * 2, + BoardHeight * 5 + frameWidth() * 2); +} + +void TetrixBoard::paintEvent(QPaintEvent *event) +{ + QFrame::paintEvent(event); + QPainter painter(this); + painter.drawImage(0, 0, image); +} + +void TetrixBoard::keyPressEvent(QKeyEvent *event) +{ + emit keyPressed(event->key()); +} + +void TetrixBoard::showNextPiece(int width, int height) +{ + if (!nextPieceLabel()) + return; + + QPixmap pixmap(width * squareWidth(), height * squareHeight()); + QPainter painter(&pixmap); + painter.fillRect(pixmap.rect(), nextPieceLabel()->palette().window()); + + emit paintNextPieceRequested(&painter); + + nextPieceLabel()->setPixmap(pixmap); +} + +void TetrixBoard::drawPauseScreen(QPainter *painter) +{ + painter->drawText(contentsRect(), Qt::AlignCenter, tr("Pause")); +} + +void TetrixBoard::drawSquare(QPainter *painter, int x, int y, int shape) +{ + static const QRgb colorTable[8] = { + 0x000000, 0xCC6666, 0x66CC66, 0x6666CC, + 0xCCCC66, 0xCC66CC, 0x66CCCC, 0xDAAA00 + }; + + x = x*squareWidth(); + y = y*squareHeight(); + + QColor color = colorTable[shape]; + painter->fillRect(x + 1, y + 1, squareWidth() - 2, squareHeight() - 2, + color); + + painter->setPen(color.lighter()); + painter->drawLine(x, y + squareHeight() - 1, x, y); + painter->drawLine(x, y, x + squareWidth() - 1, y); + + painter->setPen(color.darker()); + painter->drawLine(x + 1, y + squareHeight() - 1, + x + squareWidth() - 1, y + squareHeight() - 1); + painter->drawLine(x + squareWidth() - 1, y + squareHeight() - 1, + x + squareWidth() - 1, y + 1); +} + +void TetrixBoard::update() +{ + QRect rect = contentsRect(); + if (image.size() != rect.size()) + image = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied); + image.fill(qRgba(0,0,0,0)); + QPainter painter; + painter.begin(&image); + int boardTop = rect.bottom() - BoardHeight*squareHeight(); + painter.translate(rect.left(), boardTop); + emit paintRequested(&painter); + QFrame::update(); +} diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixboard.h b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.h new file mode 100644 index 00000000..e33c97f6 --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, 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$ +** +****************************************************************************/ + +#ifndef TETRIXBOARD_H +#define TETRIXBOARD_H + +#include +#include +#include +#include + +class TetrixBoard : public QFrame +{ + Q_OBJECT + Q_PROPERTY(QObject* timer READ getTimer) + Q_PROPERTY(QWidget* nextPieceLabel READ nextPieceLabel WRITE setNextPieceLabel) + +public: + TetrixBoard(QWidget *parent = 0); + + void setNextPieceLabel(QWidget *label); + QLabel *nextPieceLabel() const; + void setBoardWidth(int width); + void setBoardHeight(int height); + QSize minimumSizeHint() const; + + QObject *getTimer(); + +signals: + void scoreChanged(int score); + void levelChanged(int level); + void linesRemovedChanged(int numLines); + +#if !defined(Q_MOC_RUN) +private: // can only be emitted by TetrixBoard +#endif + void keyPressed(int key); + void paintRequested(QPainter *painter); + void paintNextPieceRequested(QPainter *painter); + +protected: + void paintEvent(QPaintEvent *event); + void keyPressEvent(QKeyEvent *event); + +protected slots: + void showNextPiece(int width, int height); + void drawPauseScreen(QPainter *painter); + void drawSquare(QPainter *painter, int x, int y, int shape); + void update(); + +private: + enum { BoardWidth = 10, BoardHeight = 22 }; + + int squareWidth() { return contentsRect().width() / BoardWidth; } + int squareHeight() { return contentsRect().height() / BoardHeight; } + + QTimer *timer; + QPointer nextPieceLbl; + QImage image; +}; + +#endif diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixboard.js b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.js new file mode 100644 index 00000000..f1983976 --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixboard.js @@ -0,0 +1,261 @@ +function TetrixBoard(ui) +{ + this.ui = ui; + + this.isStarted = false; + this.isPaused = false; + this.inKeyPress = false; + + this._board = new Array(TetrixBoard.BoardWidth * TetrixBoard.BoardHeight); + this.clearBoard(); + + this.curPiece = new TetrixPiece(); + this.nextPiece = new TetrixPiece(); + this.nextPiece.setRandomShape(); + + ui.timer.singleShot = true; + ui.timer.timeout.connect(this, this.onTimer); + ui.keyPressed.connect(this, this.onKeyPress); + ui.paintRequested.connect(this, this.onPaint); + ui.paintNextPieceRequested.connect(this, this.onPaintNextPiece); +} + +TetrixBoard.BoardWidth = 10; +TetrixBoard.BoardHeight = 22; + +TetrixBoard.prototype.start = function() { + if (this.isPaused) + return; + + this.isStarted = true; + this.isWaitingAfterLine = false; + this.numLinesRemoved = 0; + this.numPiecesDropped = 0; + this.score = 0; + this.level = 1; + this.clearBoard(); + + this.ui.linesRemovedChanged(this.numLinesRemoved); + this.ui.scoreChanged(this.score); + this.ui.levelChanged(this.level); + + this.newPiece(); + this.ui.timer.start(this.timeoutTime()); +} + +TetrixBoard.prototype.pause = function() { + if (!this.isStarted) + return; + + this.isPaused = !this.isPaused; + if (this.isPaused) { + this.ui.timer.stop(); + } else { + this.ui.timer.start(this.timeoutTime()); + } + this.ui.update(); +} + +TetrixBoard.prototype.getShapeAt = function(x, y) { + return this._board[(y * TetrixBoard.BoardWidth) + x]; +} + +TetrixBoard.prototype.setShapeAt = function(x, y, newShape) { + this._board[(y * TetrixBoard.BoardWidth) + x] = newShape; +} + +TetrixBoard.prototype.clearBoard = function() { + for (var i = 0; i < TetrixBoard.BoardHeight * TetrixBoard.BoardWidth; ++i) + this._board[i] = TetrixShape.NoShape; +} + +TetrixBoard.prototype.dropDown = function() { + var dropHeight = 0; + var newY = this.curY; + while (newY > 0) { + if (!this.tryMove(this.curPiece, this.curX, newY - 1)) + break; + --newY; + ++dropHeight; + } + this.pieceDropped(dropHeight); +} + +TetrixBoard.prototype.oneLineDown = function() { + if (!this.tryMove(this.curPiece, this.curX, this.curY - 1)) + this.pieceDropped(0); +} + +TetrixBoard.prototype.pieceDropped = function(dropHeight) { + for (var i = 0; i < 4; ++i) { + var x = this.curX + this.curPiece.getX(i); + var y = this.curY - this.curPiece.getY(i); + this.setShapeAt(x, y, this.curPiece.shape); + } + + ++this.numPiecesDropped; + if ((this.numPiecesDropped % 25) == 0) { + ++this.level; + this.ui.timer.start(this.timeoutTime()); + this.ui.levelChanged(this.level); + } + + this.score += dropHeight + 7; + this.ui.scoreChanged(this.score); + this.removeFullLines(); + + if (!this.isWaitingAfterLine) + this.newPiece(); + + if (this.isStarted && !this.ui.timer.active) + this.ui.timer.start(this.timeoutTime()); +} + +TetrixBoard.prototype.removeFullLines = function() { + var numFullLines = 0; + + for (var i = TetrixBoard.BoardHeight - 1; i >= 0; --i) { + var lineIsFull = true; + + for (var j = 0; j < TetrixBoard.BoardWidth; ++j) { + if (this.getShapeAt(j, i) == TetrixShape.NoShape) { + lineIsFull = false; + break; + } + } + + if (lineIsFull) { + ++numFullLines; + for (var k = i; k < TetrixBoard.BoardHeight - 1; ++k) { + for (var j = 0; j < TetrixBoard.BoardWidth; ++j) + this.setShapeAt(j, k, this.getShapeAt(j, k + 1)); + } + for (var j = 0; j < TetrixBoard.BoardWidth; ++j) + this.setShapeAt(j, TetrixBoard.BoardHeight - 1, TetrixShape.NoShape); + } + } + + if (numFullLines > 0) { + this.numLinesRemoved += numFullLines; + this.score += 10 * numFullLines; + this.ui.linesRemovedChanged(this.numLinesRemoved); + this.ui.scoreChanged(this.score); + + this.ui.timer.start(500); + this.isWaitingAfterLine = true; + this.curPiece.shape = TetrixShape.NoShape; + this.ui.update(); + } +} + +TetrixBoard.prototype.newPiece = function() { + this.curPiece = this.nextPiece; + this.nextPiece = new TetrixPiece(); + this.nextPiece.setRandomShape(); + this.ui.showNextPiece(this.nextPiece.maxX - this.nextPiece.minX + 1, + this.nextPiece.maxY - this.nextPiece.minY + 1); + this.curX = TetrixBoard.BoardWidth / 2 + 1; + this.curY = TetrixBoard.BoardHeight - 1 + this.curPiece.minY; + + if (!this.tryMove(this.curPiece, this.curX, this.curY)) { + this.curPiece.shape = TetrixShape.NoShape; + this.ui.timer.stop(); + this.isStarted = false; + } +} + +TetrixBoard.prototype.tryMove = function(newPiece, newX, newY) { + for (var i = 0; i < 4; ++i) { + var x = newX + newPiece.getX(i); + var y = newY - newPiece.getY(i); + if ((x < 0) || (x >= TetrixBoard.BoardWidth) || (y < 0) || (y >= TetrixBoard.BoardHeight)) + return false; + if (this.getShapeAt(x, y) != TetrixShape.NoShape) + return false; + } + + this.curPiece = newPiece; + this.curX = newX; + this.curY = newY; + this.ui.update(); + return true; +} + +TetrixBoard.prototype.onPaint = function(painter) { + if (this.isPaused) { + this.ui.drawPauseScreen(painter); + return; + } + + for (var i = 0; i < TetrixBoard.BoardHeight; ++i) { + for (var j = 0; j < TetrixBoard.BoardWidth; ++j) { + var shape = this.getShapeAt(j, TetrixBoard.BoardHeight - i - 1); + if (shape != TetrixShape.NoShape) + this.ui.drawSquare(painter, j, i, shape); + } + } + + if (this.curPiece.shape != TetrixShape.NoShape) { + for (var i = 0; i < 4; ++i) { + var x = this.curX + this.curPiece.getX(i); + var y = this.curY - this.curPiece.getY(i); + this.ui.drawSquare(painter, x, TetrixBoard.BoardHeight - y - 1, + this.curPiece.shape); + } + } +} + +TetrixBoard.prototype.onPaintNextPiece = function(painter) { + for (var i = 0; i < 4; ++i) { + var x = this.nextPiece.getX(i) - this.nextPiece.minX; + var y = this.nextPiece.getY(i) - this.nextPiece.minY; + this.ui.drawSquare(painter, x, y, this.nextPiece.shape); + } +} + +TetrixBoard.prototype.onKeyPress = function(key) { + if (!this.isStarted || this.isPaused || (this.curPiece.shape == TetrixShape.NoShape)) + return; + this.inKeyPress = true; + switch (key) { + case Qt.Key_Left: + this.tryMove(this.curPiece, this.curX - 1, this.curY); + break; + case Qt.Key_Right: + this.tryMove(this.curPiece, this.curX + 1, this.curY); + break; + case Qt.Key_Down: + this.tryMove(this.curPiece.rotatedRight(), this.curX, this.curY); + break; + case Qt.Key_Up: + this.tryMove(this.curPiece.rotatedLeft(), this.curX, this.curY); + break; + case Qt.Key_Space: + this.dropDown(); + break; + case Qt.Key_D: + this.oneLineDown(); + break; + } + this.inKeyPress = false; + if (this.isStarted && !this.ui.timer.active) + this.ui.timer.start(this.timeoutTime()); +} + +TetrixBoard.prototype.onTimer = function() { + if (this.isWaitingAfterLine) { + this.isWaitingAfterLine = false; + this.newPiece(); + this.ui.timer.start(this.timeoutTime()); + } else { + if (!this.inKeyPress) { + this.oneLineDown(); + if (this.isStarted && !this.ui.timer.active) + this.ui.timer.start(this.timeoutTime()); + } + } +} + +TetrixBoard.prototype.timeoutTime = function() { + return 1000 / (1 + this.level); +} diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixpiece.js b/src/shared/qtscript/examples/script/qstetrix/tetrixpiece.js new file mode 100644 index 00000000..e99fa8a1 --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixpiece.js @@ -0,0 +1,131 @@ +TetrixShape = { + NoShape:0, + ZShape:1, + SShape:2, + LineShape:3, + TShape:4, + SquareShape:5, + LShape:6, + MirroredLShape:7 +} + +TetrixCoordsTable = [ + [ [ 0, 0 ], [ 0, 0 ], [ 0, 0 ], [ 0, 0 ] ], + [ [ 0, -1 ], [ 0, 0 ], [ -1, 0 ], [ -1, 1 ] ], + [ [ 0, -1 ], [ 0, 0 ], [ 1, 0 ], [ 1, 1 ] ], + [ [ 0, -1 ], [ 0, 0 ], [ 0, 1 ], [ 0, 2 ] ], + [ [ -1, 0 ], [ 0, 0 ], [ 1, 0 ], [ 0, 1 ] ], + [ [ 0, 0 ], [ 1, 0 ], [ 0, 1 ], [ 1, 1 ] ], + [ [ -1, -1 ], [ 0, -1 ], [ 0, 0 ], [ 0, 1 ] ], + [ [ 1, -1 ], [ 0, -1 ], [ 0, 0 ], [ 0, 1 ] ] +] + +function TetrixPiece() +{ + this.shape = TetrixShape.NoShape; +} + +TetrixPiece.prototype.__defineGetter__( + "shape", + function() { + return this._shape; + } +); + +TetrixPiece.prototype.__defineSetter__( + "shape", + function(shape) { + this._shape = shape; + this._coords = new Array(4); + for (var i = 0; i < 4; ++i) + this._coords[i] = TetrixCoordsTable[shape][i].slice(); + } +); + +TetrixPiece.prototype.setRandomShape = function() { + this.shape = Math.floor(((Math.random() * 100000) % 7) + 1); +} + +TetrixPiece.prototype.getX = function(index) { + return this._coords[index][0]; +} + +TetrixPiece.prototype.getY = function(index) { + return this._coords[index][1]; +} + +TetrixPiece.prototype._setX = function(index, x) { + this._coords[index][0] = x; +} + +TetrixPiece.prototype._setY = function(index, y) { + this._coords[index][1] = y; +} + +TetrixPiece.prototype.__defineGetter__( + "minX", + function() { + var min = this._coords[0][0]; + for (var i = 1; i < 4; ++i) + min = Math.min(min, this._coords[i][0]); + return min; + } +); + +TetrixPiece.prototype.__defineGetter__( + "maxX", + function() { + var max = this._coords[0][0]; + for (var i = 1; i < 4; ++i) + max = Math.max(max, this._coords[i][0]); + return max; + } +); + +TetrixPiece.prototype.__defineGetter__( + "minY", + function() { + var min = this._coords[0][1]; + for (var i = 1; i < 4; ++i) + min = Math.min(min, this._coords[i][1]); + return min; + } +); + +TetrixPiece.prototype.__defineGetter__( + "maxY", + function() { + var max = this._coords[0][1]; + for (var i = 1; i < 4; ++i) + max = Math.max(max, this._coords[i][1]); + return max; + } +); + +TetrixPiece.prototype.rotatedLeft = function() { + var result = new TetrixPiece(); + if (this._shape == TetrixShape.SquareShape) { + result.shape = this._shape; + return result; + } + result._shape = this._shape; + for (var i = 0; i < 4; ++i) { + result._setX(i, this.getY(i)); + result._setY(i, -this.getX(i)); + } + return result; +} + +TetrixPiece.prototype.rotatedRight = function() { + var result = new TetrixPiece(); + if (this._shape == TetrixShape.SquareShape) { + result.shape = this._shape; + return result; + } + result._shape = this._shape; + for (var i = 0; i < 4; ++i) { + result._setX(i, -this.getY(i)); + result._setY(i, this.getX(i)); + } + return result; +} diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.js b/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.js new file mode 100644 index 00000000..6157a8ce --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.js @@ -0,0 +1,16 @@ +function TetrixWindow(ui) +{ + this.ui = ui; + + var boardUi = ui.findChild("board"); + boardUi.nextPieceLabel = ui.findChild("nextPieceLabel"); + + this.board = new TetrixBoard(boardUi); + + ui.findChild("startButton").clicked.connect(this.board, this.board.start); + ui.findChild("quitButton").clicked.connect(Qt.App.quit); + ui.findChild("pauseButton").clicked.connect(this.board, this.board.pause); + boardUi.scoreChanged.connect(ui.findChild("scoreLcd")["display(int)"]); + boardUi.levelChanged.connect(ui.findChild("levelLcd")["display(int)"]); + boardUi.linesRemovedChanged.connect(ui.findChild("linesLcd")["display(int)"]); +} diff --git a/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.ui b/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.ui new file mode 100644 index 00000000..a53e94fa --- /dev/null +++ b/src/shared/qtscript/examples/script/qstetrix/tetrixwindow.ui @@ -0,0 +1,175 @@ + + + TetrixWindow + + + + 0 + 0 + 537 + 475 + + + + Tetrix + + + + 6 + + + 9 + + + + + 0 + + + 6 + + + + + Qt::NoFocus + + + &Start + + + + + + + QLCDNumber::Filled + + + + + + + LINES REMOVED + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + QLCDNumber::Filled + + + + + + + Qt::StrongFocus + + + QFrame::Panel + + + QFrame::Sunken + + + + + + + LEVEL + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + NEXT + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + QLCDNumber::Filled + + + + + + + SCORE + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + + + QFrame::Box + + + QFrame::Raised + + + + + + Qt::AlignCenter + + + + + + + Qt::NoFocus + + + &Quit + + + + + + + Qt::NoFocus + + + &Pause + + + + + + + Qt::NoFocus + + + &Debug + + + + + + + + + + TetrixBoard + QFrame +
tetrixboard.h
+ 1 +
+
+ + +
diff --git a/src/shared/qtscript/examples/script/script.pro b/src/shared/qtscript/examples/script/script.pro new file mode 100644 index 00000000..cc972331 --- /dev/null +++ b/src/shared/qtscript/examples/script/script.pro @@ -0,0 +1,28 @@ +TEMPLATE = subdirs +SUBDIRS = customclass + +qtHaveModule(gui): SUBDIRS += qsdbg + +qtHaveModule(widgets) { + SUBDIRS += \ + helloscript \ + context2d \ + defaultprototypes + + qtHaveModule(uitools) { + SUBDIRS += \ + calculator \ + qstetrix + } + + !wince { + SUBDIRS += \ + qscript + } +} + +!wince { + qtHaveModule(gui): SUBDIRS += marshal +} + +maemo5: CONFIG += qt_example diff --git a/src/shared/qtscript/qtscript.pro b/src/shared/qtscript/qtscript.pro new file mode 100644 index 00000000..3fc1579e --- /dev/null +++ b/src/shared/qtscript/qtscript.pro @@ -0,0 +1,3 @@ +requires(!integrity:!vxworks:!winrt:!tvos:!watchos) + +load(qt_parts) diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APICast.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APICast.h new file mode 100644 index 00000000..4284c448 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APICast.h @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef APICast_h +#define APICast_h + +#include "JSAPIValueWrapper.h" +#include "JSGlobalObject.h" +#include "JSValue.h" +#include +#include + +namespace JSC { + class ExecState; + class PropertyNameArray; + class JSGlobalData; + class JSObject; + class JSValue; +} + +typedef const struct OpaqueJSContextGroup* JSContextGroupRef; +typedef const struct OpaqueJSContext* JSContextRef; +typedef struct OpaqueJSContext* JSGlobalContextRef; +typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; +typedef const struct OpaqueJSValue* JSValueRef; +typedef struct OpaqueJSValue* JSObjectRef; + +/* Opaque typing convenience methods */ + +inline JSC::ExecState* toJS(JSContextRef c) +{ + ASSERT(c); + return reinterpret_cast(const_cast(c)); +} + +inline JSC::ExecState* toJS(JSGlobalContextRef c) +{ + ASSERT(c); + return reinterpret_cast(c); +} + +inline JSC::JSValue toJS(JSC::ExecState* exec, JSValueRef v) +{ + ASSERT_UNUSED(exec, exec); + ASSERT(v); +#if USE(JSVALUE32_64) + JSC::JSCell* jsCell = reinterpret_cast(const_cast(v)); + if (!jsCell) + return JSC::JSValue(); + if (jsCell->isAPIValueWrapper()) + return static_cast(jsCell)->value(); + return jsCell; +#else + return JSC::JSValue::decode(reinterpret_cast(const_cast(v))); +#endif +} + +inline JSC::JSValue toJSForGC(JSC::ExecState* exec, JSValueRef v) +{ + ASSERT_UNUSED(exec, exec); + ASSERT(v); +#if USE(JSVALUE32_64) + JSC::JSCell* jsCell = reinterpret_cast(const_cast(v)); + if (!jsCell) + return JSC::JSValue(); + return jsCell; +#else + return JSC::JSValue::decode(reinterpret_cast(const_cast(v))); +#endif +} + +inline JSC::JSObject* toJS(JSObjectRef o) +{ + return reinterpret_cast(o); +} + +inline JSC::PropertyNameArray* toJS(JSPropertyNameAccumulatorRef a) +{ + return reinterpret_cast(a); +} + +inline JSC::JSGlobalData* toJS(JSContextGroupRef g) +{ + return reinterpret_cast(const_cast(g)); +} + +inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v) +{ +#if USE(JSVALUE32_64) + if (!v) + return 0; + if (!v.isCell()) + return reinterpret_cast(asCell(JSC::jsAPIValueWrapper(exec, v))); + return reinterpret_cast(asCell(v)); +#else + UNUSED_PARAM(exec); + return reinterpret_cast(JSC::JSValue::encode(v)); +#endif +} + +inline JSObjectRef toRef(JSC::JSObject* o) +{ + return reinterpret_cast(o); +} + +inline JSObjectRef toRef(const JSC::JSObject* o) +{ + return reinterpret_cast(const_cast(o)); +} + +inline JSContextRef toRef(JSC::ExecState* e) +{ + return reinterpret_cast(e); +} + +inline JSGlobalContextRef toGlobalRef(JSC::ExecState* e) +{ + ASSERT(e == e->lexicalGlobalObject()->globalExec()); + return reinterpret_cast(e); +} + +inline JSPropertyNameAccumulatorRef toRef(JSC::PropertyNameArray* l) +{ + return reinterpret_cast(l); +} + +inline JSContextGroupRef toRef(JSC::JSGlobalData* g) +{ + return reinterpret_cast(g); +} + +#endif // APICast_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APIShims.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APIShims.h new file mode 100644 index 00000000..f809d5d0 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/APIShims.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef APIShims_h +#define APIShims_h + +#include "CallFrame.h" +#include "JSLock.h" + +namespace JSC { + +class APIEntryShimWithoutLock { +protected: + APIEntryShimWithoutLock(JSGlobalData* globalData, bool registerThread) + : m_globalData(globalData) + , m_entryIdentifierTable(setCurrentIdentifierTable(globalData->identifierTable)) + { + if (registerThread) + globalData->heap.registerThread(); + m_globalData->timeoutChecker->start(); + } + + ~APIEntryShimWithoutLock() + { + m_globalData->timeoutChecker->stop(); + setCurrentIdentifierTable(m_entryIdentifierTable); + } + +private: + JSGlobalData* m_globalData; + IdentifierTable* m_entryIdentifierTable; +}; + +class APIEntryShim : public APIEntryShimWithoutLock { +public: + // Normal API entry + APIEntryShim(ExecState* exec, bool registerThread = true) + : APIEntryShimWithoutLock(&exec->globalData(), registerThread) + , m_lock(exec) + { + } + + // JSPropertyNameAccumulator only has a globalData. + APIEntryShim(JSGlobalData* globalData, bool registerThread = true) + : APIEntryShimWithoutLock(globalData, registerThread) + , m_lock(globalData->isSharedInstance ? LockForReal : SilenceAssertionsOnly) + { + } + +private: + JSLock m_lock; +}; + +class APICallbackShim { +public: + APICallbackShim(ExecState* exec) + : m_dropAllLocks(exec) + , m_globalData(&exec->globalData()) + { + resetCurrentIdentifierTable(); + m_globalData->timeoutChecker->start(); + } + + ~APICallbackShim() + { + m_globalData->timeoutChecker->stop(); + setCurrentIdentifierTable(m_globalData->identifierTable); + } + +private: + JSLock::DropAllLocks m_dropAllLocks; + JSGlobalData* m_globalData; +}; + +} + +#endif diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp new file mode 100644 index 00000000..ebfeafa8 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSBase.h" +#include "JSBasePrivate.h" + +#include "APICast.h" +#include "APIShims.h" +#include "Completion.h" +#include "OpaqueJSString.h" +#include "SourceCode.h" +#include +#include +#include +#include +#include +#include + +using namespace JSC; + +JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsThisObject = toJS(thisObject); + + // evaluate sets "this" to the global object if it is NULL + JSGlobalObject* globalObject = exec->dynamicGlobalObject(); + SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); + Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject); + + if (completion.complType() == Throw) { + if (exception) + *exception = toRef(exec, completion.value()); + return 0; + } + + if (completion.value()) + return toRef(exec, completion.value()); + + // happens, for example, when the only statement is an empty (';') statement + return toRef(exec, jsUndefined()); +} + +bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); + Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); + if (completion.complType() == Throw) { + if (exception) + *exception = toRef(exec, completion.value()); + return false; + } + + return true; +} + +void JSGarbageCollect(JSContextRef ctx) +{ + // We used to recommend passing NULL as an argument here, which caused the only heap to be collected. + // As there is no longer a shared heap, the previously recommended usage became a no-op (but the GC + // will happen when the context group is destroyed). + // Because the function argument was originally ignored, some clients may pass their released context here, + // in which case there is a risk of crashing if another thread performs GC on the same heap in between. + if (!ctx) + return; + + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec, false); + + JSGlobalData& globalData = exec->globalData(); + if (!globalData.heap.isBusy()) + globalData.heap.collectAllGarbage(); + + // FIXME: Perhaps we should trigger a second mark and sweep + // once the garbage collector is done if this is called when + // the collector is busy. +} + +void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + exec->globalData().heap.reportExtraMemoryCost(size); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h new file mode 100644 index 00000000..2e16720c --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSBase_h +#define JSBase_h + +#ifndef __cplusplus +#include +#endif + +/* JavaScript engine interface */ + +/*! @typedef JSContextGroupRef A group that associates JavaScript contexts with one another. Contexts in the same group may share and exchange JavaScript objects. */ +typedef const struct OpaqueJSContextGroup* JSContextGroupRef; + +/*! @typedef JSContextRef A JavaScript execution context. Holds the global object and other execution state. */ +typedef const struct OpaqueJSContext* JSContextRef; + +/*! @typedef JSGlobalContextRef A global JavaScript execution context. A JSGlobalContext is a JSContext. */ +typedef struct OpaqueJSContext* JSGlobalContextRef; + +/*! @typedef JSStringRef A UTF16 character buffer. The fundamental string representation in JavaScript. */ +typedef struct OpaqueJSString* JSStringRef; + +/*! @typedef JSClassRef A JavaScript class. Used with JSObjectMake to construct objects with custom behavior. */ +typedef struct OpaqueJSClass* JSClassRef; + +/*! @typedef JSPropertyNameArrayRef An array of JavaScript property names. */ +typedef struct OpaqueJSPropertyNameArray* JSPropertyNameArrayRef; + +/*! @typedef JSPropertyNameAccumulatorRef An ordered set used to collect the names of a JavaScript object's properties. */ +typedef struct OpaqueJSPropertyNameAccumulator* JSPropertyNameAccumulatorRef; + + +/* JavaScript data types */ + +/*! @typedef JSValueRef A JavaScript value. The base type for all JavaScript values, and polymorphic functions on them. */ +typedef const struct OpaqueJSValue* JSValueRef; + +/*! @typedef JSObjectRef A JavaScript object. A JSObject is a JSValue. */ +typedef struct OpaqueJSValue* JSObjectRef; + +/* JavaScript symbol exports */ + +#undef JS_EXPORT +#if defined(JS_NO_EXPORT) + #define JS_EXPORT +#elif defined(__GNUC__) && !defined(__CC_ARM) && !defined(__ARMCC__) + #define JS_EXPORT __attribute__((visibility("default"))) +#elif defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE) + #if defined(BUILDING_JavaScriptCore) || defined(BUILDING_WTF) + #define JS_EXPORT __declspec(dllexport) + #else + #define JS_EXPORT __declspec(dllimport) + #endif +#else + #define JS_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Script Evaluation */ + +/*! +@function JSEvaluateScript +@abstract Evaluates a string of JavaScript. +@param ctx The execution context to use. +@param script A JSString containing the script to evaluate. +@param thisObject The object to use as "this," or NULL to use the global object as "this." +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSValue that results from evaluating script, or NULL if an exception is thrown. +*/ +JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function JSCheckScriptSyntax +@abstract Checks for syntax errors in a string of JavaScript. +@param ctx The execution context to use. +@param script A JSString containing the script to check for syntax errors. +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. +@result true if the script is syntactically correct, otherwise false. +*/ +JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function JSGarbageCollect +@abstract Performs a JavaScript garbage collection. +@param ctx The execution context to use. +@discussion JavaScript values that are on the machine stack, in a register, + protected by JSValueProtect, set as the global object of an execution context, + or reachable from any such value will not be collected. + + During JavaScript execution, you are not required to call this function; the + JavaScript engine will garbage collect as needed. JavaScript values created + within a context group are automatically destroyed when the last reference + to the context group is released. +*/ +JS_EXPORT void JSGarbageCollect(JSContextRef ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* JSBase_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h new file mode 100644 index 00000000..befa3164 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSBasePrivate_h +#define JSBasePrivate_h + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Reports an object's non-GC memory payload to the garbage collector. +@param ctx The execution context to use. +@param size The payload's size, in bytes. +@discussion Use this function to notify the garbage collector that a GC object +owns a large non-GC memory region. Calling this function will encourage the +garbage collector to collect soon, hoping to reclaim that large non-GC memory +region. +*/ +JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +#ifdef __cplusplus +} +#endif + +#endif /* JSBasePrivate_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.cpp new file mode 100644 index 00000000..9c5f6d73 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSCallbackConstructor.h" + +#include "APIShims.h" +#include "APICast.h" +#include +#include +#include +#include + +namespace JSC { + +const ClassInfo JSCallbackConstructor::info = { "CallbackConstructor", 0, 0, 0 }; + +JSCallbackConstructor::JSCallbackConstructor(NonNullPassRefPtr structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback) + : JSObject(structure) + , m_class(jsClass) + , m_callback(callback) +{ + if (m_class) + JSClassRetain(jsClass); +} + +JSCallbackConstructor::~JSCallbackConstructor() +{ + if (m_class) + JSClassRelease(m_class); +} + +static JSObject* constructJSCallback(ExecState* exec, JSObject* constructor, const ArgList& args) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef constructorRef = toRef(constructor); + + JSObjectCallAsConstructorCallback callback = static_cast(constructor)->callback(); + if (callback) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(exec, args.at(i)); + + JSValueRef exception = 0; + JSObjectRef result; + { + APICallbackShim callbackShim(exec); + result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + return toJS(result); + } + + return toJS(JSObjectMake(ctx, static_cast(constructor)->classRef(), 0)); +} + +ConstructType JSCallbackConstructor::getConstructData(ConstructData& constructData) +{ + constructData.native.function = constructJSCallback; + return ConstructTypeHost; +} + +} // namespace JSC diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.h new file mode 100644 index 00000000..c4bd7ad3 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackConstructor.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSCallbackConstructor_h +#define JSCallbackConstructor_h + +#include "JSObjectRef.h" +#include + +namespace JSC { + +class JSCallbackConstructor : public JSObject { +public: + JSCallbackConstructor(NonNullPassRefPtr, JSClassRef, JSObjectCallAsConstructorCallback); + virtual ~JSCallbackConstructor(); + JSClassRef classRef() const { return m_class; } + JSObjectCallAsConstructorCallback callback() const { return m_callback; } + static const ClassInfo info; + + static PassRefPtr createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); + } + +protected: + static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags; + +private: + virtual ConstructType getConstructData(ConstructData&); + virtual const ClassInfo* classInfo() const { return &info; } + + JSClassRef m_class; + JSObjectCallAsConstructorCallback m_callback; +}; + +} // namespace JSC + +#endif // JSCallbackConstructor_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.cpp new file mode 100644 index 00000000..0e434d96 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include +#include "JSCallbackFunction.h" + +#include "APIShims.h" +#include "APICast.h" +#include "CodeBlock.h" +#include "JSFunction.h" +#include "FunctionPrototype.h" +#include +#include +#include + +namespace JSC { + +ASSERT_CLASS_FITS_IN_CELL(JSCallbackFunction); + +const ClassInfo JSCallbackFunction::info = { "CallbackFunction", &InternalFunction::info, 0, 0 }; + +JSCallbackFunction::JSCallbackFunction(ExecState* exec, JSObjectCallAsFunctionCallback callback, const Identifier& name) + : InternalFunction(&exec->globalData(), exec->lexicalGlobalObject()->callbackFunctionStructure(), name) + , m_callback(callback) +{ +} + +JSValue JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef functionRef = toRef(functionObject); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); + + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(exec, args.at(i)); + + JSValueRef exception = 0; + JSValueRef result; + { + APICallbackShim callbackShim(exec); + result = static_cast(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + + return toJS(exec, result); +} + +CallType JSCallbackFunction::getCallData(CallData& callData) +{ + callData.native.function = call; + return CallTypeHost; +} + +} // namespace JSC diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.h new file mode 100644 index 00000000..0cf25c43 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackFunction.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSCallbackFunction_h +#define JSCallbackFunction_h + +#include "InternalFunction.h" +#include "JSObjectRef.h" + +namespace JSC { + +class JSCallbackFunction : public InternalFunction { +public: + JSCallbackFunction(ExecState*, JSObjectCallAsFunctionCallback, const Identifier& name); + + static const ClassInfo info; + + // InternalFunction mish-mashes constructor and function behavior -- we should + // refactor the code so this override isn't necessary + static PassRefPtr createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); + } + +private: + virtual CallType getCallData(CallData&); + virtual const ClassInfo* classInfo() const { return &info; } + + static JSValue JSC_HOST_CALL call(ExecState*, JSObject*, JSValue, const ArgList&); + + JSObjectCallAsFunctionCallback m_callback; +}; + +} // namespace JSC + +#endif // JSCallbackFunction_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.cpp new file mode 100644 index 00000000..2fde0f8e --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSCallbackObject.h" + +#include "Collector.h" + +namespace JSC { + +ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject); +ASSERT_CLASS_FITS_IN_CELL(JSCallbackObject); + +// Define the two types of JSCallbackObjects we support. +template <> const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 }; +template <> const ClassInfo JSCallbackObject::info = { "CallbackGlobalObject", 0, 0, 0 }; + +} // namespace JSC diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.h new file mode 100644 index 00000000..2e25991c --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObject.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSCallbackObject_h +#define JSCallbackObject_h + +#include "JSObjectRef.h" +#include "JSValueRef.h" +#include "JSObject.h" + +namespace JSC { + +template +class JSCallbackObject : public Base { +public: + JSCallbackObject(ExecState*, NonNullPassRefPtr, JSClassRef, void* data); + JSCallbackObject(JSClassRef); + virtual ~JSCallbackObject(); + + void setPrivate(void* data); + void* getPrivate(); + + static const ClassInfo info; + + JSClassRef classRef() const { return m_callbackObjectData->jsClass; } + bool inherits(JSClassRef) const; + + static PassRefPtr createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | Base::StructureFlags; + +private: + virtual UString className() const; + + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertySlot(ExecState*, unsigned, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + + virtual void put(ExecState*, const Identifier&, JSValue, PutPropertySlot&); + + virtual bool deleteProperty(ExecState*, const Identifier&); + virtual bool deleteProperty(ExecState*, unsigned); + + virtual bool hasInstance(ExecState* exec, JSValue value, JSValue proto); + + virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties); + + virtual double toNumber(ExecState*) const; + virtual UString toString(ExecState*) const; + + virtual ConstructType getConstructData(ConstructData&); + virtual CallType getCallData(CallData&); + virtual const ClassInfo* classInfo() const { return &info; } + + void init(ExecState*); + + static JSCallbackObject* asCallbackObject(JSValue); + + static JSValue JSC_HOST_CALL call(ExecState*, JSObject* functionObject, JSValue thisValue, const ArgList&); + static JSObject* construct(ExecState*, JSObject* constructor, const ArgList&); + + static JSValue staticValueGetter(ExecState*, const Identifier&, const PropertySlot&); + static JSValue staticFunctionGetter(ExecState*, const Identifier&, const PropertySlot&); + static JSValue callbackGetter(ExecState*, const Identifier&, const PropertySlot&); + + struct JSCallbackObjectData { + JSCallbackObjectData(void* privateData, JSClassRef jsClass) + : privateData(privateData) + , jsClass(jsClass) + { + JSClassRetain(jsClass); + } + + ~JSCallbackObjectData() + { + JSClassRelease(jsClass); + } + + void* privateData; + JSClassRef jsClass; + }; + + OwnPtr m_callbackObjectData; +}; + +} // namespace JSC + +// include the actual template class implementation +#include "JSCallbackObjectFunctions.h" + +#endif // JSCallbackObject_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObjectFunctions.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObjectFunctions.h new file mode 100644 index 00000000..4b28a992 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -0,0 +1,603 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2007 Eric Seidel + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "APIShims.h" +#include "APICast.h" +#include "Error.h" +#include "JSCallbackFunction.h" +#include "JSClassRef.h" +#include "JSGlobalObject.h" +#include "JSLock.h" +#include "JSObjectRef.h" +#include "JSString.h" +#include "JSStringRef.h" +#include "OpaqueJSString.h" +#include "PropertyNameArray.h" +#include + +namespace JSC { + +template +inline JSCallbackObject* JSCallbackObject::asCallbackObject(JSValue value) +{ + ASSERT(asObject(value)->inherits(&info)); + return static_cast(asObject(value)); +} + +template +JSCallbackObject::JSCallbackObject(ExecState* exec, NonNullPassRefPtr structure, JSClassRef jsClass, void* data) + : Base(structure) + , m_callbackObjectData(new JSCallbackObjectData(data, jsClass)) +{ + init(exec); +} + +// Global object constructor. +// FIXME: Move this into a separate JSGlobalCallbackObject class derived from this one. +template +JSCallbackObject::JSCallbackObject(JSClassRef jsClass) + : Base() + , m_callbackObjectData(new JSCallbackObjectData(0, jsClass)) +{ + ASSERT(Base::isGlobalObject()); + init(static_cast(this)->globalExec()); +} + +template +void JSCallbackObject::init(ExecState* exec) +{ + ASSERT(exec); + + Vector initRoutines; + JSClassRef jsClass = classRef(); + do { + if (JSObjectInitializeCallback initialize = jsClass->initialize) + initRoutines.append(initialize); + } while ((jsClass = jsClass->parentClass)); + + // initialize from base to derived + for (int i = static_cast(initRoutines.size()) - 1; i >= 0; i--) { + APICallbackShim callbackShim(exec); + JSObjectInitializeCallback initialize = initRoutines[i]; + initialize(toRef(exec), toRef(this)); + } +} + +template +JSCallbackObject::~JSCallbackObject() +{ + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + if (JSObjectFinalizeCallback finalize = jsClass->finalize) + finalize(thisRef); +} + +template +UString JSCallbackObject::className() const +{ + UString thisClassName = classRef()->className(); + if (!thisClassName.isEmpty()) + return thisClassName; + + return Base::className(); +} + +template +bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + RefPtr propertyNameRef; + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + // optional optimization to bypass getProperty in cases when we only need to know if the property exists + if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + APICallbackShim callbackShim(exec); + if (hasProperty(ctx, thisRef, propertyNameRef.get())) { + slot.setCustom(this, callbackGetter); + return true; + } + } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + exec->setException(toJS(exec, exception)); + slot.setValue(jsUndefined()); + return true; + } + if (value) { + slot.setValue(toJS(exec, value)); + return true; + } + } + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (staticValues->contains(propertyName.ustring().rep())) { + slot.setCustom(this, staticValueGetter); + return true; + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (staticFunctions->contains(propertyName.ustring().rep())) { + slot.setCustom(this, staticFunctionGetter); + return true; + } + } + } + + return Base::getOwnPropertySlot(exec, propertyName, slot); +} + +template +bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) +{ + return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); +} + +template +bool JSCallbackObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + PropertySlot slot; + if (getOwnPropertySlot(exec, propertyName, slot)) { + // Ideally we should return an access descriptor, but returning a value descriptor is better than nothing. + JSValue value = slot.getValue(exec, propertyName); + if (!exec->hadException()) + descriptor.setValue(value); + // We don't know whether the property is configurable, but assume it is. + descriptor.setConfigurable(true); + // We don't know whether the property is enumerable (we could call getOwnPropertyNames() to find out), but assume it isn't. + descriptor.setEnumerable(false); + return true; + } + + return Base::getOwnPropertyDescriptor(exec, propertyName, descriptor); +} + +template +void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + RefPtr propertyNameRef; + JSValueRef valueRef = toRef(exec, value); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + if (result || exception) + return; + } + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + if (result || exception) + return; + } else + throwError(exec, ReferenceError, "Attempt to set a property that is not settable."); + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeReadOnly) + return; + JSCallbackObject::putDirect(propertyName, value); // put as override property + return; + } + } + } + + return Base::put(exec, propertyName, value, slot); +} + +template +bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName) +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + RefPtr propertyNameRef; + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + if (result || exception) + return true; + } + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (entry->attributes & kJSPropertyAttributeDontDelete) + return false; + return true; + } + } + } + + return Base::deleteProperty(exec, propertyName); +} + +template +bool JSCallbackObject::deleteProperty(ExecState* exec, unsigned propertyName) +{ + return deleteProperty(exec, Identifier::from(exec, propertyName)); +} + +template +ConstructType JSCallbackObject::getConstructData(ConstructData& constructData) +{ + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (jsClass->callAsConstructor) { + constructData.native.function = construct; + return ConstructTypeHost; + } + } + return ConstructTypeNone; +} + +template +JSObject* JSCallbackObject::construct(ExecState* exec, JSObject* constructor, const ArgList& args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef constructorRef = toRef(constructor); + + for (JSClassRef jsClass = static_cast*>(constructor)->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(exec, args.at(i)); + JSValueRef exception = 0; + JSObject* result; + { + APICallbackShim callbackShim(exec); + result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception)); + } + if (exception) + exec->setException(toJS(exec, exception)); + return result; + } + } + + ASSERT_NOT_REACHED(); // getConstructData should prevent us from reaching here + return 0; +} + +template +bool JSCallbackObject::hasInstance(ExecState* exec, JSValue value, JSValue) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { + JSValueRef valueRef = toRef(exec, value); + JSValueRef exception = 0; + bool result; + { + APICallbackShim callbackShim(exec); + result = hasInstance(execRef, thisRef, valueRef, &exception); + } + if (exception) + exec->setException(toJS(exec, exception)); + return result; + } + } + return false; +} + +template +CallType JSCallbackObject::getCallData(CallData& callData) +{ + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (jsClass->callAsFunction) { + callData.native.function = call; + return CallTypeHost; + } + } + return CallTypeNone; +} + +template +JSValue JSCallbackObject::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef functionRef = toRef(functionObject); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); + + for (JSClassRef jsClass = static_cast*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { + int argumentCount = static_cast(args.size()); + Vector arguments(argumentCount); + for (int i = 0; i < argumentCount; i++) + arguments[i] = toRef(exec, args.at(i)); + JSValueRef exception = 0; + JSValue result; + { + APICallbackShim callbackShim(exec); + result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception)); + } + if (exception) + exec->setException(toJS(exec, exception)); + return result; + } + } + + ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here + return JSValue(); +} + +template +void JSCallbackObject::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +{ + JSContextRef execRef = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { + if (JSObjectGetPropertyNamesCallback getPropertyNames = jsClass->getPropertyNames) { + APICallbackShim callbackShim(exec); + getPropertyNames(execRef, thisRef, toRef(&propertyNames)); + } + + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) { + typedef OpaqueJSClassStaticValuesTable::const_iterator iterator; + iterator end = staticValues->end(); + for (iterator it = staticValues->begin(); it != end; ++it) { + UString::Rep* name = it->first.get(); + StaticValueEntry* entry = it->second; + if (entry->getProperty && (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties))) + propertyNames.add(Identifier(exec, name)); + } + } + + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + typedef OpaqueJSClassStaticFunctionsTable::const_iterator iterator; + iterator end = staticFunctions->end(); + for (iterator it = staticFunctions->begin(); it != end; ++it) { + UString::Rep* name = it->first.get(); + StaticFunctionEntry* entry = it->second; + if (!(entry->attributes & kJSPropertyAttributeDontEnum) || (mode == IncludeDontEnumProperties)) + propertyNames.add(Identifier(exec, name)); + } + } + } + + Base::getOwnPropertyNames(exec, propertyNames, mode); +} + +template +double JSCallbackObject::toNumber(ExecState* exec) const +{ + // We need this check to guard against the case where this object is rhs of + // a binary expression where lhs threw an exception in its conversion to + // primitive + if (exec->hadException()) + return NaN; + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = convertToType(ctx, thisRef, kJSTypeNumber, &exception); + } + if (exception) { + exec->setException(toJS(exec, exception)); + return 0; + } + + double dValue; + if (value) + return toJS(exec, value).getNumber(dValue) ? dValue : NaN; + } + + return Base::toNumber(exec); +} + +template +UString JSCallbackObject::toString(ExecState* exec) const +{ + JSContextRef ctx = toRef(exec); + JSObjectRef thisRef = toRef(this); + + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = convertToType(ctx, thisRef, kJSTypeString, &exception); + } + if (exception) { + exec->setException(toJS(exec, exception)); + return ""; + } + if (value) + return toJS(exec, value).getString(exec); + } + + return Base::toString(exec); +} + +template +void JSCallbackObject::setPrivate(void* data) +{ + m_callbackObjectData->privateData = data; +} + +template +void* JSCallbackObject::getPrivate() +{ + return m_callbackObjectData->privateData; +} + +template +bool JSCallbackObject::inherits(JSClassRef c) const +{ + for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) + if (jsClass == c) + return true; + + return false; +} + +template +JSValue JSCallbackObject::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +{ + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); + + JSObjectRef thisRef = toRef(thisObj); + RefPtr propertyNameRef; + + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) + if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) + if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) + if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + exec->setException(toJS(exec, exception)); + return jsUndefined(); + } + if (value) + return toJS(exec, value); + } + + return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback."); +} + +template +JSValue JSCallbackObject::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +{ + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); + + // Check for cached or override property. + PropertySlot slot2(thisObj); + if (thisObj->Base::getOwnPropertySlot(exec, propertyName, slot2)) + return slot2.getValue(exec, propertyName); + + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) { + if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) { + if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) { + if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) { + JSObject* o = new (exec) JSCallbackFunction(exec, callAsFunction, propertyName); + thisObj->putDirect(propertyName, o, entry->attributes); + return o; + } + } + } + } + + return throwError(exec, ReferenceError, "Static function property defined with NULL callAsFunction callback."); +} + +template +JSValue JSCallbackObject::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +{ + JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); + + JSObjectRef thisRef = toRef(thisObj); + RefPtr propertyNameRef; + + for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) + if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { + if (!propertyNameRef) + propertyNameRef = OpaqueJSString::create(propertyName.ustring()); + JSValueRef exception = 0; + JSValueRef value; + { + APICallbackShim callbackShim(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + if (exception) { + exec->setException(toJS(exec, exception)); + return jsUndefined(); + } + if (value) + return toJS(exec, value); + } + + return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist."); +} + +} // namespace JSC diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.cpp new file mode 100644 index 00000000..c6685bfa --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSClassRef.h" + +#include "APICast.h" +#include "JSCallbackObject.h" +#include "JSObjectRef.h" +#include +#include +#include +#include + +using namespace std; +using namespace JSC; + +const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + +OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass) + : parentClass(definition->parentClass) + , prototypeClass(0) + , initialize(definition->initialize) + , finalize(definition->finalize) + , hasProperty(definition->hasProperty) + , getProperty(definition->getProperty) + , setProperty(definition->setProperty) + , deleteProperty(definition->deleteProperty) + , getPropertyNames(definition->getPropertyNames) + , callAsFunction(definition->callAsFunction) + , callAsConstructor(definition->callAsConstructor) + , hasInstance(definition->hasInstance) + , convertToType(definition->convertToType) + , m_className(UString::createFromUTF8(definition->className).rep()->ref()) + , m_staticValues(0) + , m_staticFunctions(0) +{ + initializeThreading(); + + if (const JSStaticValue* staticValue = definition->staticValues) { + m_staticValues = new OpaqueJSClassStaticValuesTable(); + while (staticValue->name) { + // Use a local variable here to sidestep an RVCT compiler bug. + StaticValueEntry* entry = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); + m_staticValues->add(UString::createFromUTF8(staticValue->name).rep()->ref(), entry); + ++staticValue; + } + } + + if (const JSStaticFunction* staticFunction = definition->staticFunctions) { + m_staticFunctions = new OpaqueJSClassStaticFunctionsTable(); + while (staticFunction->name) { + // Use a local variable here to sidestep an RVCT compiler bug. + StaticFunctionEntry* entry = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); + m_staticFunctions->add(UString::createFromUTF8(staticFunction->name).rep()->ref(), entry); + ++staticFunction; + } + } + + if (protoClass) + prototypeClass = JSClassRetain(protoClass); +} + +OpaqueJSClass::~OpaqueJSClass() +{ + ASSERT(!m_className.rep()->isIdentifier()); + + if (m_staticValues) { + OpaqueJSClassStaticValuesTable::const_iterator end = m_staticValues->end(); + for (OpaqueJSClassStaticValuesTable::const_iterator it = m_staticValues->begin(); it != end; ++it) { + ASSERT(!it->first->isIdentifier()); + delete it->second; + } + delete m_staticValues; + } + + if (m_staticFunctions) { + OpaqueJSClassStaticFunctionsTable::const_iterator end = m_staticFunctions->end(); + for (OpaqueJSClassStaticFunctionsTable::const_iterator it = m_staticFunctions->begin(); it != end; ++it) { + ASSERT(!it->first->isIdentifier()); + delete it->second; + } + delete m_staticFunctions; + } + + if (prototypeClass) + JSClassRelease(prototypeClass); +} + +PassRefPtr OpaqueJSClass::createNoAutomaticPrototype(const JSClassDefinition* definition) +{ + return adoptRef(new OpaqueJSClass(definition, 0)); +} + +static void clearReferenceToPrototype(JSObjectRef prototype) +{ + OpaqueJSClassContextData* jsClassData = static_cast(JSObjectGetPrivate(prototype)); + ASSERT(jsClassData); + jsClassData->cachedPrototype = 0; +} + +PassRefPtr OpaqueJSClass::create(const JSClassDefinition* clientDefinition) +{ + JSClassDefinition definition = *clientDefinition; // Avoid modifying client copy. + + JSClassDefinition protoDefinition = kJSClassDefinitionEmpty; + protoDefinition.finalize = clearReferenceToPrototype; + swap(definition.staticFunctions, protoDefinition.staticFunctions); // Move static functions to the prototype. + + // We are supposed to use JSClassRetain/Release but since we know that we currently have + // the only reference to this class object we cheat and use a RefPtr instead. + RefPtr protoClass = adoptRef(new OpaqueJSClass(&protoDefinition, 0)); + return adoptRef(new OpaqueJSClass(&definition, protoClass.get())); +} + +OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) + : m_class(jsClass) +{ + if (jsClass->m_staticValues) { + staticValues = new OpaqueJSClassStaticValuesTable; + OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end(); + for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) { + ASSERT(!it->first->isIdentifier()); + // Use a local variable here to sidestep an RVCT compiler bug. + StaticValueEntry* entry = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes); + staticValues->add(UString::Rep::create(it->first->data(), it->first->size()), entry); + + } + + } else + staticValues = 0; + + + if (jsClass->m_staticFunctions) { + staticFunctions = new OpaqueJSClassStaticFunctionsTable; + OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end(); + for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) { + ASSERT(!it->first->isIdentifier()); + // Use a local variable here to sidestep an RVCT compiler bug. + StaticFunctionEntry* entry = new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes); + staticFunctions->add(UString::Rep::create(it->first->data(), it->first->size()), entry); + } + + } else + staticFunctions = 0; +} + +OpaqueJSClassContextData::~OpaqueJSClassContextData() +{ + if (staticValues) { + deleteAllValues(*staticValues); + delete staticValues; + } + + if (staticFunctions) { + deleteAllValues(*staticFunctions); + delete staticFunctions; + } +} + +OpaqueJSClassContextData& OpaqueJSClass::contextData(ExecState* exec) +{ + OpaqueJSClassContextData*& contextData = exec->globalData().opaqueJSClassData.add(this, 0).first->second; + if (!contextData) + contextData = new OpaqueJSClassContextData(this); + return *contextData; +} + +UString OpaqueJSClass::className() +{ + // Make a deep copy, so that the caller has no chance to put the original into IdentifierTable. + return UString(m_className.data(), m_className.size()); +} + +OpaqueJSClassStaticValuesTable* OpaqueJSClass::staticValues(JSC::ExecState* exec) +{ + OpaqueJSClassContextData& jsClassData = contextData(exec); + return jsClassData.staticValues; +} + +OpaqueJSClassStaticFunctionsTable* OpaqueJSClass::staticFunctions(JSC::ExecState* exec) +{ + OpaqueJSClassContextData& jsClassData = contextData(exec); + return jsClassData.staticFunctions; +} + +/*! +// Doc here in case we make this public. (Hopefully we won't.) +@function + @abstract Returns the prototype that will be used when constructing an object with a given class. + @param ctx The execution context to use. + @param jsClass A JSClass whose prototype you want to get. + @result The JSObject prototype that was automatically generated for jsClass, or NULL if no prototype was automatically generated. This is the prototype that will be used when constructing an object using jsClass. +*/ +JSObject* OpaqueJSClass::prototype(ExecState* exec) +{ + /* Class (C++) and prototype (JS) inheritance are parallel, so: + * (C++) | (JS) + * ParentClass | ParentClassPrototype + * ^ | ^ + * | | | + * DerivedClass | DerivedClassPrototype + */ + + if (!prototypeClass) + return 0; + + OpaqueJSClassContextData& jsClassData = contextData(exec); + + if (!jsClassData.cachedPrototype) { + // Recursive, but should be good enough for our purposes + jsClassData.cachedPrototype = new (exec) JSCallbackObject(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData); // set jsClassData as the object's private data, so it can clear our reference on destruction + if (parentClass) { + if (JSObject* prototype = parentClass->prototype(exec)) + jsClassData.cachedPrototype->setPrototype(prototype); + } + } + return jsClassData.cachedPrototype.get(); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.h new file mode 100644 index 00000000..ae60aade --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSClassRef.h @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSClassRef_h +#define JSClassRef_h + +#include "JSObjectRef.h" + +#include +#include +#include +#include +#include +#include + +struct StaticValueEntry : FastAllocBase { + StaticValueEntry(JSObjectGetPropertyCallback _getProperty, JSObjectSetPropertyCallback _setProperty, JSPropertyAttributes _attributes) + : getProperty(_getProperty), setProperty(_setProperty), attributes(_attributes) + { + } + + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSPropertyAttributes attributes; +}; + +struct StaticFunctionEntry : FastAllocBase { + StaticFunctionEntry(JSObjectCallAsFunctionCallback _callAsFunction, JSPropertyAttributes _attributes) + : callAsFunction(_callAsFunction), attributes(_attributes) + { + } + + JSObjectCallAsFunctionCallback callAsFunction; + JSPropertyAttributes attributes; +}; + +typedef HashMap, StaticValueEntry*> OpaqueJSClassStaticValuesTable; +typedef HashMap, StaticFunctionEntry*> OpaqueJSClassStaticFunctionsTable; + +struct OpaqueJSClass; + +// An OpaqueJSClass (JSClass) is created without a context, so it can be used with any context, even across context groups. +// This structure holds data members that vary across context groups. +struct OpaqueJSClassContextData : Noncopyable { + OpaqueJSClassContextData(OpaqueJSClass*); + ~OpaqueJSClassContextData(); + + // It is necessary to keep OpaqueJSClass alive because of the following rare scenario: + // 1. A class is created and used, so its context data is stored in JSGlobalData hash map. + // 2. The class is released, and when all JS objects that use it are collected, OpaqueJSClass + // is deleted (that's the part prevented by this RefPtr). + // 3. Another class is created at the same address. + // 4. When it is used, the old context data is found in JSGlobalData and used. + RefPtr m_class; + + OpaqueJSClassStaticValuesTable* staticValues; + OpaqueJSClassStaticFunctionsTable* staticFunctions; + JSC::WeakGCPtr cachedPrototype; +}; + +struct OpaqueJSClass : public ThreadSafeShared { + static PassRefPtr create(const JSClassDefinition*); + static PassRefPtr createNoAutomaticPrototype(const JSClassDefinition*); + ~OpaqueJSClass(); + + JSC::UString className(); + OpaqueJSClassStaticValuesTable* staticValues(JSC::ExecState*); + OpaqueJSClassStaticFunctionsTable* staticFunctions(JSC::ExecState*); + JSC::JSObject* prototype(JSC::ExecState*); + + OpaqueJSClass* parentClass; + OpaqueJSClass* prototypeClass; + + JSObjectInitializeCallback initialize; + JSObjectFinalizeCallback finalize; + JSObjectHasPropertyCallback hasProperty; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSObjectDeletePropertyCallback deleteProperty; + JSObjectGetPropertyNamesCallback getPropertyNames; + JSObjectCallAsFunctionCallback callAsFunction; + JSObjectCallAsConstructorCallback callAsConstructor; + JSObjectHasInstanceCallback hasInstance; + JSObjectConvertToTypeCallback convertToType; + +private: + friend struct OpaqueJSClassContextData; + + OpaqueJSClass(); + OpaqueJSClass(const OpaqueJSClass&); + OpaqueJSClass(const JSClassDefinition*, OpaqueJSClass* protoClass); + + OpaqueJSClassContextData& contextData(JSC::ExecState*); + + // UStrings in these data members should not be put into any IdentifierTable. + JSC::UString m_className; + OpaqueJSClassStaticValuesTable* m_staticValues; + OpaqueJSClassStaticFunctionsTable* m_staticFunctions; +}; + +#endif // JSClassRef_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.cpp new file mode 100644 index 00000000..6bdc3c80 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSContextRef.h" +#include "JSContextRefPrivate.h" + +#include "APICast.h" +#include "InitializeThreading.h" +#include "JSCallbackObject.h" +#include "JSClassRef.h" +#include "JSGlobalObject.h" +#include "JSObject.h" +#include + +#if OS(DARWIN) +#include + +static const int32_t webkitFirstVersionWithConcurrentGlobalContexts = 0x2100500; // 528.5.0 +#endif + +using namespace JSC; + +JSContextGroupRef JSContextGroupCreate() +{ + initializeThreading(); + return toRef(JSGlobalData::createNonDefault().releaseRef()); +} + +JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) +{ + toJS(group)->ref(); + return group; +} + +void JSContextGroupRelease(JSContextGroupRef group) +{ + toJS(group)->deref(); +} + +JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) +{ + initializeThreading(); +#if OS(DARWIN) + // When running on Tiger or Leopard, or if the application was linked before JSGlobalContextCreate was changed + // to use a unique JSGlobalData, we use a shared one for compatibility. +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + if (NSVersionOfLinkTimeLibrary("JavaScriptCore") <= webkitFirstVersionWithConcurrentGlobalContexts) { +#else + { +#endif + JSLock lock(LockForReal); + return JSGlobalContextCreateInGroup(toRef(&JSGlobalData::sharedInstance()), globalObjectClass); + } +#endif // OS(DARWIN) + + return JSGlobalContextCreateInGroup(0, globalObjectClass); +} + +JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) +{ + initializeThreading(); + + JSLock lock(LockForReal); + RefPtr globalData = group ? PassRefPtr(toJS(group)) : JSGlobalData::createNonDefault(); + + APIEntryShim entryShim(globalData.get(), false); + +#if ENABLE(JSC_MULTIPLE_THREADS) + globalData->makeUsableFromMultipleThreads(); +#endif + + if (!globalObjectClass) { + JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject; + return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec())); + } + + JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject(globalObjectClass); + ExecState* exec = globalObject->globalExec(); + JSValue prototype = globalObjectClass->prototype(exec); + if (!prototype) + prototype = jsNull(); + globalObject->resetPrototype(prototype); + return JSGlobalContextRetain(toGlobalRef(exec)); +} + +JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSGlobalData& globalData = exec->globalData(); + gcProtect(exec->dynamicGlobalObject()); + globalData.ref(); + return ctx; +} + +void JSGlobalContextRelease(JSGlobalContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec, false); + + gcUnprotect(exec->dynamicGlobalObject()); + + JSGlobalData& globalData = exec->globalData(); + if (globalData.refCount() == 2) { // One reference is held by JSGlobalObject, another added by JSGlobalContextRetain(). + // The last reference was released, this is our last chance to collect. + globalData.heap.destroy(); + } else + globalData.heap.collectAllGarbage(); + + globalData.deref(); +} + +JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + // It is necessary to call toThisObject to get the wrapper object when used with WebCore. + return toRef(exec->lexicalGlobalObject()->toThisObject(exec)); +} + +JSContextGroupRef JSContextGetGroup(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + return toRef(&exec->globalData()); +} + +JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toGlobalRef(exec->lexicalGlobalObject()->globalExec()); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.h new file mode 100644 index 00000000..c5c8a71e --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRef.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSContextRef_h +#define JSContextRef_h + +#include +#include +#include + +#ifndef __cplusplus +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Creates a JavaScript context group. +@discussion A JSContextGroup associates JavaScript contexts with one another. + Contexts in the same group may share and exchange JavaScript objects. Sharing and/or exchanging + JavaScript objects between contexts in different groups will produce undefined behavior. + When objects from the same context group are used in multiple threads, explicit + synchronization is required. +@result The created JSContextGroup. +*/ +JS_EXPORT JSContextGroupRef JSContextGroupCreate() AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! +@function +@abstract Retains a JavaScript context group. +@param group The JSContextGroup to retain. +@result A JSContextGroup that is the same as group. +*/ +JS_EXPORT JSContextGroupRef JSContextGroupRetain(JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! +@function +@abstract Releases a JavaScript context group. +@param group The JSContextGroup to release. +*/ +JS_EXPORT void JSContextGroupRelease(JSContextGroupRef group) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! +@function +@abstract Creates a global JavaScript execution context. +@discussion JSGlobalContextCreate allocates a global object and populates it with all the + built-in JavaScript objects, such as Object, Function, String, and Array. + + In WebKit version 4.0 and later, the context is created in a unique context group. + Therefore, scripts may execute in it concurrently with scripts executing in other contexts. + However, you may not use values created in the context in other contexts. +@param globalObjectClass The class to use when creating the global object. Pass + NULL to use the default object class. +@result A JSGlobalContext with a global object of class globalObjectClass. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; + +/*! +@function +@abstract Creates a global JavaScript execution context in the context group provided. +@discussion JSGlobalContextCreateInGroup allocates a global object and populates it with + all the built-in JavaScript objects, such as Object, Function, String, and Array. +@param globalObjectClass The class to use when creating the global object. Pass + NULL to use the default object class. +@param group The context group to use. The created global context retains the group. + Pass NULL to create a unique group for the context. +@result A JSGlobalContext with a global object of class globalObjectClass and a context + group equal to group. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClassRef globalObjectClass) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! +@function +@abstract Retains a global JavaScript execution context. +@param ctx The JSGlobalContext to retain. +@result A JSGlobalContext that is the same as ctx. +*/ +JS_EXPORT JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx); + +/*! +@function +@abstract Releases a global JavaScript execution context. +@param ctx The JSGlobalContext to release. +*/ +JS_EXPORT void JSGlobalContextRelease(JSGlobalContextRef ctx); + +/*! +@function +@abstract Gets the global object of a JavaScript execution context. +@param ctx The JSContext whose global object you want to get. +@result ctx's global object. +*/ +JS_EXPORT JSObjectRef JSContextGetGlobalObject(JSContextRef ctx); + +/*! +@function +@abstract Gets the context group to which a JavaScript execution context belongs. +@param ctx The JSContext whose group you want to get. +@result ctx's group. +*/ +JS_EXPORT JSContextGroupRef JSContextGetGroup(JSContextRef ctx) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +#ifdef __cplusplus +} +#endif + +#endif /* JSContextRef_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRefPrivate.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRefPrivate.h new file mode 100644 index 00000000..ff014ec6 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSContextRefPrivate.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSContextRefPrivate_h +#define JSContextRefPrivate_h + +#include +#include +#include + +#ifndef __cplusplus +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Gets the global context of a JavaScript execution context. +@param ctx The JSContext whose global context you want to get. +@result ctx's global context. +*/ +JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* JSContextRefPrivate_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.cpp new file mode 100644 index 00000000..faaa4eb6 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.cpp @@ -0,0 +1,496 @@ +/* + * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSObjectRef.h" + +#include "APICast.h" +#include "CodeBlock.h" +#include "DateConstructor.h" +#include "ErrorConstructor.h" +#include "FunctionConstructor.h" +#include "Identifier.h" +#include "InitializeThreading.h" +#include "JSArray.h" +#include "JSCallbackConstructor.h" +#include "JSCallbackFunction.h" +#include "JSCallbackObject.h" +#include "JSClassRef.h" +#include "JSFunction.h" +#include "JSGlobalObject.h" +#include "JSObject.h" +#include "JSRetainPtr.h" +#include "JSString.h" +#include "JSValueRef.h" +#include "ObjectPrototype.h" +#include "PropertyNameArray.h" +#include "RegExpConstructor.h" +#include + +using namespace JSC; + +JSClassRef JSClassCreate(const JSClassDefinition* definition) +{ + initializeThreading(); + RefPtr jsClass = (definition->attributes & kJSClassAttributeNoAutomaticPrototype) + ? OpaqueJSClass::createNoAutomaticPrototype(definition) + : OpaqueJSClass::create(definition); + + return jsClass.release().releaseRef(); +} + +JSClassRef JSClassRetain(JSClassRef jsClass) +{ + jsClass->ref(); + return jsClass; +} + +void JSClassRelease(JSClassRef jsClass) +{ + jsClass->deref(); +} + +JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + if (!jsClass) + return toRef(new (exec) JSObject(exec->lexicalGlobalObject()->emptyObjectStructure())); // slightly more efficient + + JSCallbackObject* object = new (exec) JSCallbackObject(exec, exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data); + if (JSObject* prototype = jsClass->prototype(exec)) + object->setPrototype(prototype); + + return toRef(object); +} + +JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous"); + + return toRef(new (exec) JSCallbackFunction(exec, callAsFunction, nameID)); +} + +JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsPrototype = jsClass ? jsClass->prototype(exec) : 0; + if (!jsPrototype) + jsPrototype = exec->lexicalGlobalObject()->objectPrototype(); + + JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor); + constructor->putDirect(exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly); + return toRef(constructor); +} + +JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous"); + + MarkedArgumentBuffer args; + for (unsigned i = 0; i < parameterCount; i++) + args.append(jsString(exec, parameterNames[i]->ustring())); + args.append(jsString(exec, body->ustring())); + + JSObject* result = constructFunction(exec, args, nameID, sourceURL->ustring(), startingLineNumber); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + return toRef(result); +} + +JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* result; + if (argumentCount) { + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(exec, arguments[i])); + + result = constructArray(exec, argList); + } else + result = constructEmptyArray(exec); + + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(exec, arguments[i])); + + JSObject* result = constructDate(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(exec, arguments[i])); + + JSObject* result = constructError(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; ++i) + argList.append(toJS(exec, arguments[i])); + + JSObject* result = constructRegExp(exec, argList); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + + return toRef(result); +} + +JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + return toRef(exec, jsObject->prototype()); +} + +void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + JSValue jsValue = toJS(exec, value); + + jsObject->setPrototype(jsValue.isObject() ? jsValue : jsNull()); +} + +bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + + return jsObject->hasProperty(exec, propertyName->identifier(&exec->globalData())); +} + +JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + + JSValue jsValue = jsObject->get(exec, propertyName->identifier(&exec->globalData())); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } + return toRef(exec, jsValue); +} + +void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + Identifier name(propertyName->identifier(&exec->globalData())); + JSValue jsValue = toJS(exec, value); + + if (attributes && !jsObject->hasProperty(exec, name)) + jsObject->putWithAttributes(exec, name, jsValue, attributes); + else { + PutPropertySlot slot; + jsObject->put(exec, name, jsValue, slot); + } + + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } +} + +JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + + JSValue jsValue = jsObject->get(exec, propertyIndex); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } + return toRef(exec, jsValue); +} + + +void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + JSValue jsValue = toJS(exec, value); + + jsObject->put(exec, propertyIndex, jsValue); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } +} + +bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + + bool result = jsObject->deleteProperty(exec, propertyName->identifier(&exec->globalData())); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } + return result; +} + +void* JSObjectGetPrivate(JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + + if (jsObject->inherits(&JSCallbackObject::info)) + return static_cast*>(jsObject)->getPrivate(); + else if (jsObject->inherits(&JSCallbackObject::info)) + return static_cast*>(jsObject)->getPrivate(); + + return 0; +} + +bool JSObjectSetPrivate(JSObjectRef object, void* data) +{ + JSObject* jsObject = toJS(object); + + if (jsObject->inherits(&JSCallbackObject::info)) { + static_cast*>(jsObject)->setPrivate(data); + return true; + } else if (jsObject->inherits(&JSCallbackObject::info)) { + static_cast*>(jsObject)->setPrivate(data); + return true; + } + + return false; +} + +bool JSObjectIsFunction(JSContextRef, JSObjectRef object) +{ + CallData callData; + return toJS(object)->getCallData(callData) != CallTypeNone; +} + +JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + JSObject* jsThisObject = toJS(thisObject); + + if (!jsThisObject) + jsThisObject = exec->globalThisValue(); + + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; i++) + argList.append(toJS(exec, arguments[i])); + + CallData callData; + CallType callType = jsObject->getCallData(callData); + if (callType == CallTypeNone) + return 0; + + JSValueRef result = toRef(exec, call(exec, jsObject, callType, callData, jsThisObject, argList)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + return result; +} + +bool JSObjectIsConstructor(JSContextRef, JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + ConstructData constructData; + return jsObject->getConstructData(constructData) != ConstructTypeNone; +} + +JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSObject* jsObject = toJS(object); + + ConstructData constructData; + ConstructType constructType = jsObject->getConstructData(constructData); + if (constructType == ConstructTypeNone) + return 0; + + MarkedArgumentBuffer argList; + for (size_t i = 0; i < argumentCount; i++) + argList.append(toJS(exec, arguments[i])); + JSObjectRef result = toRef(construct(exec, jsObject, constructType, constructData, argList)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + result = 0; + } + return result; +} + +struct OpaqueJSPropertyNameArray : FastAllocBase { + OpaqueJSPropertyNameArray(JSGlobalData* globalData) + : refCount(0) + , globalData(globalData) + { + } + + unsigned refCount; + JSGlobalData* globalData; + Vector > array; +}; + +JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object) +{ + JSObject* jsObject = toJS(object); + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSGlobalData* globalData = &exec->globalData(); + + JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray(globalData); + PropertyNameArray array(globalData); + jsObject->getPropertyNames(exec, array); + + size_t size = array.size(); + propertyNames->array.reserveInitialCapacity(size); + for (size_t i = 0; i < size; ++i) + propertyNames->array.append(JSRetainPtr(Adopt, OpaqueJSString::create(array[i].ustring()).releaseRef())); + + return JSPropertyNameArrayRetain(propertyNames); +} + +JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array) +{ + ++array->refCount; + return array; +} + +void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array) +{ + if (--array->refCount == 0) { + APIEntryShim entryShim(array->globalData, false); + delete array; + } +} + +size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array) +{ + return array->array.size(); +} + +JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index) +{ + return array->array[static_cast(index)].get(); +} + +void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName) +{ + PropertyNameArray* propertyNames = toJS(array); + APIEntryShim entryShim(propertyNames->globalData()); + propertyNames->add(propertyName->identifier(propertyNames->globalData())); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.h new file mode 100644 index 00000000..3e8b0eb6 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSObjectRef.h @@ -0,0 +1,694 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Kelvin W Sherlock (ksherlock@gmail.com) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSObjectRef_h +#define JSObjectRef_h + +#include +#include +#include + +#ifndef __cplusplus +#include +#endif +#include /* for size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@enum JSPropertyAttribute +@constant kJSPropertyAttributeNone Specifies that a property has no special attributes. +@constant kJSPropertyAttributeReadOnly Specifies that a property is read-only. +@constant kJSPropertyAttributeDontEnum Specifies that a property should not be enumerated by JSPropertyEnumerators and JavaScript for...in loops. +@constant kJSPropertyAttributeDontDelete Specifies that the delete operation should fail on a property. +*/ +enum { + kJSPropertyAttributeNone = 0, + kJSPropertyAttributeReadOnly = 1 << 1, + kJSPropertyAttributeDontEnum = 1 << 2, + kJSPropertyAttributeDontDelete = 1 << 3 +}; + +/*! +@typedef JSPropertyAttributes +@abstract A set of JSPropertyAttributes. Combine multiple attributes by logically ORing them together. +*/ +typedef unsigned JSPropertyAttributes; + +/*! +@enum JSClassAttribute +@constant kJSClassAttributeNone Specifies that a class has no special attributes. +@constant kJSClassAttributeNoAutomaticPrototype Specifies that a class should not automatically generate a shared prototype for its instance objects. Use kJSClassAttributeNoAutomaticPrototype in combination with JSObjectSetPrototype to manage prototypes manually. +*/ +enum { + kJSClassAttributeNone = 0, + kJSClassAttributeNoAutomaticPrototype = 1 << 1 +}; + +/*! +@typedef JSClassAttributes +@abstract A set of JSClassAttributes. Combine multiple attributes by logically ORing them together. +*/ +typedef unsigned JSClassAttributes; + +/*! +@typedef JSObjectInitializeCallback +@abstract The callback invoked when an object is first created. +@param ctx The execution context to use. +@param object The JSObject being created. +@discussion If you named your function Initialize, you would declare it like this: + +void Initialize(JSContextRef ctx, JSObjectRef object); + +Unlike the other object callbacks, the initialize callback is called on the least +derived class (the parent class) first, and the most derived class last. +*/ +typedef void +(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object); + +/*! +@typedef JSObjectFinalizeCallback +@abstract The callback invoked when an object is finalized (prepared for garbage collection). An object may be finalized on any thread. +@param object The JSObject being finalized. +@discussion If you named your function Finalize, you would declare it like this: + +void Finalize(JSObjectRef object); + +The finalize callback is called on the most derived class first, and the least +derived class (the parent class) last. + +You must not call any function that may cause a garbage collection or an allocation +of a garbage collected object from within a JSObjectFinalizeCallback. This includes +all functions that have a JSContextRef parameter. +*/ +typedef void +(*JSObjectFinalizeCallback) (JSObjectRef object); + +/*! +@typedef JSObjectHasPropertyCallback +@abstract The callback invoked when determining whether an object has a property. +@param ctx The execution context to use. +@param object The JSObject to search for the property. +@param propertyName A JSString containing the name of the property look up. +@result true if object has the property, otherwise false. +@discussion If you named your function HasProperty, you would declare it like this: + +bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. + +This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive. + +If this callback is NULL, the getProperty callback will be used to service hasProperty requests. +*/ +typedef bool +(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +/*! +@typedef JSObjectGetPropertyCallback +@abstract The callback invoked when getting a property's value. +@param ctx The execution context to use. +@param object The JSObject to search for the property. +@param propertyName A JSString containing the name of the property to get. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result The property's value if object has the property, otherwise NULL. +@discussion If you named your function GetProperty, you would declare it like this: + +JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain. +*/ +typedef JSValueRef +(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@typedef JSObjectSetPropertyCallback +@abstract The callback invoked when setting a property's value. +@param ctx The execution context to use. +@param object The JSObject on which to set the property's value. +@param propertyName A JSString containing the name of the property to set. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if the property was set, otherwise false. +@discussion If you named your function SetProperty, you would declare it like this: + +bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + +If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). +*/ +typedef bool +(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); + +/*! +@typedef JSObjectDeletePropertyCallback +@abstract The callback invoked when deleting a property. +@param ctx The execution context to use. +@param object The JSObject in which to delete the property. +@param propertyName A JSString containing the name of the property to delete. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if propertyName was successfully deleted, otherwise false. +@discussion If you named your function DeleteProperty, you would declare it like this: + +bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class). +*/ +typedef bool +(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@typedef JSObjectGetPropertyNamesCallback +@abstract The callback invoked when collecting the names of an object's properties. +@param ctx The execution context to use. +@param object The JSObject whose property names are being collected. +@param accumulator A JavaScript property name accumulator in which to accumulate the names of object's properties. +@discussion If you named your function GetPropertyNames, you would declare it like this: + +void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); + +Property name accumulators are used by JSObjectCopyPropertyNames and JavaScript for...in loops. + +Use JSPropertyNameAccumulatorAddName to add property names to accumulator. A class's getPropertyNames callback only needs to provide the names of properties that the class vends through a custom getProperty or setProperty callback. Other properties, including statically declared properties, properties vended by other classes, and properties belonging to object's prototype, are added independently. +*/ +typedef void +(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); + +/*! +@typedef JSObjectCallAsFunctionCallback +@abstract The callback invoked when an object is called as a function. +@param ctx The execution context to use. +@param function A JSObject that is the function being called. +@param thisObject A JSObject that is the 'this' variable in the function's scope. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of the arguments passed to the function. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result A JSValue that is the function's return value. +@discussion If you named your function CallAsFunction, you would declare it like this: + +JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'myObject.myFunction()', function would be set to myFunction, and thisObject would be set to myObject. + +If this callback is NULL, calling your object as a function will throw an exception. +*/ +typedef JSValueRef +(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@typedef JSObjectCallAsConstructorCallback +@abstract The callback invoked when an object is used as a constructor in a 'new' expression. +@param ctx The execution context to use. +@param constructor A JSObject that is the constructor being called. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of the arguments passed to the function. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result A JSObject that is the constructor's return value. +@discussion If you named your function CallAsConstructor, you would declare it like this: + +JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'new myConstructor()', constructor would be set to myConstructor. + +If this callback is NULL, using your object as a constructor in a 'new' expression will throw an exception. +*/ +typedef JSObjectRef +(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@typedef JSObjectHasInstanceCallback +@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. +@param ctx The execution context to use. +@param constructor The JSObject that is the target of the 'instanceof' expression. +@param possibleInstance The JSValue being tested to determine if it is an instance of constructor. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result true if possibleInstance is an instance of constructor, otherwise false. +@discussion If you named your function HasInstance, you would declare it like this: + +bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + +If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue. + +If this callback is NULL, 'instanceof' expressions that target your object will return false. + +Standard JavaScript practice calls for objects that implement the callAsConstructor callback to implement the hasInstance callback as well. +*/ +typedef bool +(*JSObjectHasInstanceCallback) (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception); + +/*! +@typedef JSObjectConvertToTypeCallback +@abstract The callback invoked when converting an object to a particular JavaScript type. +@param ctx The execution context to use. +@param object The JSObject to convert. +@param type A JSType specifying the JavaScript type to convert to. +@param exception A pointer to a JSValueRef in which to return an exception, if any. +@result The objects's converted value, or NULL if the object was not converted. +@discussion If you named your function ConvertToType, you would declare it like this: + +JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); + +If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class). + +This function is only invoked when converting an object to number or string. An object converted to boolean is 'true.' An object converted to object is itself. +*/ +typedef JSValueRef +(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception); + +/*! +@struct JSStaticValue +@abstract This structure describes a statically declared value property. +@field name A null-terminated UTF8 string containing the property's name. +@field getProperty A JSObjectGetPropertyCallback to invoke when getting the property's value. +@field setProperty A JSObjectSetPropertyCallback to invoke when setting the property's value. May be NULL if the ReadOnly attribute is set. +@field attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +typedef struct { + const char* const name; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSPropertyAttributes attributes; +} JSStaticValue; + +/*! +@struct JSStaticFunction +@abstract This structure describes a statically declared function property. +@field name A null-terminated UTF8 string containing the property's name. +@field callAsFunction A JSObjectCallAsFunctionCallback to invoke when the property is called as a function. +@field attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +typedef struct { + const char* const name; + JSObjectCallAsFunctionCallback callAsFunction; + JSPropertyAttributes attributes; +} JSStaticFunction; + +/*! +@struct JSClassDefinition +@abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL. +@field version The version number of this structure. The current version is 0. +@field attributes A logically ORed set of JSClassAttributes to give to the class. +@field className A null-terminated UTF8 string containing the class's name. +@field parentClass A JSClass to set as the class's parent class. Pass NULL use the default object class. +@field staticValues A JSStaticValue array containing the class's statically declared value properties. Pass NULL to specify no statically declared value properties. The array must be terminated by a JSStaticValue whose name field is NULL. +@field staticFunctions A JSStaticFunction array containing the class's statically declared function properties. Pass NULL to specify no statically declared function properties. The array must be terminated by a JSStaticFunction whose name field is NULL. +@field initialize The callback invoked when an object is first created. Use this callback to initialize the object. +@field finalize The callback invoked when an object is finalized (prepared for garbage collection). Use this callback to release resources allocated for the object, and perform other cleanup. +@field hasProperty The callback invoked when determining whether an object has a property. If this field is NULL, getProperty is called instead. The hasProperty callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value is expensive. +@field getProperty The callback invoked when getting a property's value. +@field setProperty The callback invoked when setting a property's value. +@field deleteProperty The callback invoked when deleting a property. +@field getPropertyNames The callback invoked when collecting the names of an object's properties. +@field callAsFunction The callback invoked when an object is called as a function. +@field hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression. +@field callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression. +@field convertToType The callback invoked when converting an object to a particular JavaScript type. +@discussion The staticValues and staticFunctions arrays are the simplest and most efficient means for vending custom properties. Statically declared properties autmatically service requests like getProperty, setProperty, and getPropertyNames. Property access callbacks are required only to implement unusual properties, like array indexes, whose names are not known at compile-time. + +If you named your getter function "GetX" and your setter function "SetX", you would declare a JSStaticValue array containing "X" like this: + +JSStaticValue StaticValueArray[] = { + { "X", GetX, SetX, kJSPropertyAttributeNone }, + { 0, 0, 0, 0 } +}; + +Standard JavaScript practice calls for storing function objects in prototypes, so they can be shared. The default JSClass created by JSClassCreate follows this idiom, instantiating objects with a shared, automatically generating prototype containing the class's function objects. The kJSClassAttributeNoAutomaticPrototype attribute specifies that a JSClass should not automatically generate such a prototype. The resulting JSClass instantiates objects with the default object prototype, and gives each instance object its own copy of the class's function objects. + +A NULL callback specifies that the default object callback should substitute, except in the case of hasProperty, where it specifies that getProperty should substitute. +*/ +typedef struct { + int version; /* current (and only) version is 0 */ + JSClassAttributes attributes; + + const char* className; + JSClassRef parentClass; + + const JSStaticValue* staticValues; + const JSStaticFunction* staticFunctions; + + JSObjectInitializeCallback initialize; + JSObjectFinalizeCallback finalize; + JSObjectHasPropertyCallback hasProperty; + JSObjectGetPropertyCallback getProperty; + JSObjectSetPropertyCallback setProperty; + JSObjectDeletePropertyCallback deleteProperty; + JSObjectGetPropertyNamesCallback getPropertyNames; + JSObjectCallAsFunctionCallback callAsFunction; + JSObjectCallAsConstructorCallback callAsConstructor; + JSObjectHasInstanceCallback hasInstance; + JSObjectConvertToTypeCallback convertToType; +} JSClassDefinition; + +/*! +@const kJSClassDefinitionEmpty +@abstract A JSClassDefinition structure of the current version, filled with NULL pointers and having no attributes. +@discussion Use this constant as a convenience when creating class definitions. For example, to create a class definition with only a finalize method: + +JSClassDefinition definition = kJSClassDefinitionEmpty; +definition.finalize = Finalize; +*/ +JS_EXPORT extern const JSClassDefinition kJSClassDefinitionEmpty; + +/*! +@function +@abstract Creates a JavaScript class suitable for use with JSObjectMake. +@param definition A JSClassDefinition that defines the class. +@result A JSClass with the given definition. Ownership follows the Create Rule. +*/ +JS_EXPORT JSClassRef JSClassCreate(const JSClassDefinition* definition); + +/*! +@function +@abstract Retains a JavaScript class. +@param jsClass The JSClass to retain. +@result A JSClass that is the same as jsClass. +*/ +JS_EXPORT JSClassRef JSClassRetain(JSClassRef jsClass); + +/*! +@function +@abstract Releases a JavaScript class. +@param jsClass The JSClass to release. +*/ +JS_EXPORT void JSClassRelease(JSClassRef jsClass); + +/*! +@function +@abstract Creates a JavaScript object. +@param ctx The execution context to use. +@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class. +@param data A void* to set as the object's private data. Pass NULL to specify no private data. +@result A JSObject with the given class and private data. +@discussion The default object class does not allocate storage for private data, so you must provide a non-NULL jsClass to JSObjectMake if you want your object to be able to store private data. + +data is set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate. +*/ +JS_EXPORT JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data); + +/*! +@function +@abstract Convenience method for creating a JavaScript function with a given callback as its implementation. +@param ctx The execution context to use. +@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. +@param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called. +@result A JSObject that is a function. The object's prototype will be the default function prototype. +*/ +JS_EXPORT JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction); + +/*! +@function +@abstract Convenience method for creating a JavaScript constructor. +@param ctx The execution context to use. +@param jsClass A JSClass that is the class your constructor will assign to the objects its constructs. jsClass will be used to set the constructor's .prototype property, and to evaluate 'instanceof' expressions. Pass NULL to use the default object class. +@param callAsConstructor A JSObjectCallAsConstructorCallback to invoke when your constructor is used in a 'new' expression. Pass NULL to use the default object constructor. +@result A JSObject that is a constructor. The object's prototype will be the default object prototype. +@discussion The default object constructor takes no arguments and constructs an object of class jsClass with no private data. +*/ +JS_EXPORT JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor); + +/*! + @function + @abstract Creates a JavaScript Array object. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of data to populate the Array with. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is an Array. + @discussion The behavior of this function does not exactly match the behavior of the built-in Array constructor. Specifically, if one argument + is supplied, this function returns an array with one element. + */ +JS_EXPORT JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! + @function + @abstract Creates a JavaScript Date object, as if by invoking the built-in Date constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the Date Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a Date. + */ +JS_EXPORT JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! + @function + @abstract Creates a JavaScript Error object, as if by invoking the built-in Error constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the Error Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a Error. + */ +JS_EXPORT JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! + @function + @abstract Creates a JavaScript RegExp object, as if by invoking the built-in RegExp constructor. + @param ctx The execution context to use. + @param argumentCount An integer count of the number of arguments in arguments. + @param arguments A JSValue array of arguments to pass to the RegExp Constructor. Pass NULL if argumentCount is 0. + @param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. + @result A JSObject that is a RegExp. + */ +JS_EXPORT JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) AVAILABLE_IN_WEBKIT_VERSION_4_0; + +/*! +@function +@abstract Creates a function with a given script as its body. +@param ctx The execution context to use. +@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function. +@param parameterCount An integer count of the number of parameter names in parameterNames. +@param parameterNames A JSString array containing the names of the function's parameters. Pass NULL if parameterCount is 0. +@param body A JSString containing the script to use as the function's body. +@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. +@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. +@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. +@result A JSObject that is a function, or NULL if either body or parameterNames contains a syntax error. The object's prototype will be the default function prototype. +@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution. +*/ +JS_EXPORT JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); + +/*! +@function +@abstract Gets an object's prototype. +@param ctx The execution context to use. +@param object A JSObject whose prototype you want to get. +@result A JSValue that is the object's prototype. +*/ +JS_EXPORT JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Sets an object's prototype. +@param ctx The execution context to use. +@param object The JSObject whose prototype you want to set. +@param value A JSValue to set as the object's prototype. +*/ +JS_EXPORT void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value); + +/*! +@function +@abstract Tests whether an object has a given property. +@param object The JSObject to test. +@param propertyName A JSString containing the property's name. +@result true if the object has a property whose name matches propertyName, otherwise false. +*/ +JS_EXPORT bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + +/*! +@function +@abstract Gets a property from an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to get. +@param propertyName A JSString containing the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The property's value if object has the property, otherwise the undefined value. +*/ +JS_EXPORT JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@function +@abstract Sets a property on an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to set. +@param propertyName A JSString containing the property's name. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@param attributes A logically ORed set of JSPropertyAttributes to give to the property. +*/ +JS_EXPORT void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception); + +/*! +@function +@abstract Deletes a property from an object. +@param ctx The execution context to use. +@param object The JSObject whose property you want to delete. +@param propertyName A JSString containing the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set). +*/ +JS_EXPORT bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + +/*! +@function +@abstract Gets a property from an object by numeric index. +@param ctx The execution context to use. +@param object The JSObject whose property you want to get. +@param propertyIndex An integer value that is the property's name. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The property's value if object has the property, otherwise the undefined value. +@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but JSObjectGetPropertyAtIndex provides optimized access to numeric properties. +*/ +JS_EXPORT JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception); + +/*! +@function +@abstract Sets a property on an object by numeric index. +@param ctx The execution context to use. +@param object The JSObject whose property you want to set. +@param propertyIndex The property's name as a number. +@param value A JSValue to use as the property's value. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but JSObjectSetPropertyAtIndex provides optimized access to numeric properties. +*/ +JS_EXPORT void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Gets an object's private data. +@param object A JSObject whose private data you want to get. +@result A void* that is the object's private data, if the object has private data, otherwise NULL. +*/ +JS_EXPORT void* JSObjectGetPrivate(JSObjectRef object); + +/*! +@function +@abstract Sets a pointer to private data on an object. +@param object The JSObject whose private data you want to set. +@param data A void* to set as the object's private data. +@result true if object can store private data, otherwise false. +@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data. +*/ +JS_EXPORT bool JSObjectSetPrivate(JSObjectRef object, void* data); + +/*! +@function +@abstract Tests whether an object can be called as a function. +@param ctx The execution context to use. +@param object The JSObject to test. +@result true if the object can be called as a function, otherwise false. +*/ +JS_EXPORT bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Calls an object as a function. +@param ctx The execution context to use. +@param object The JSObject to call as a function. +@param thisObject The object to use as "this," or NULL to use the global object as "this." +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of arguments to pass to the function. Pass NULL if argumentCount is 0. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function. +*/ +JS_EXPORT JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@function +@abstract Tests whether an object can be called as a constructor. +@param ctx The execution context to use. +@param object The JSObject to test. +@result true if the object can be called as a constructor, otherwise false. +*/ +JS_EXPORT bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Calls an object as a constructor. +@param ctx The execution context to use. +@param object The JSObject to call as a constructor. +@param argumentCount An integer count of the number of arguments in arguments. +@param arguments A JSValue array of arguments to pass to the constructor. Pass NULL if argumentCount is 0. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor. +*/ +JS_EXPORT JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); + +/*! +@function +@abstract Gets the names of an object's enumerable properties. +@param ctx The execution context to use. +@param object The object whose property names you want to get. +@result A JSPropertyNameArray containing the names object's enumerable properties. Ownership follows the Create Rule. +*/ +JS_EXPORT JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Retains a JavaScript property name array. +@param array The JSPropertyNameArray to retain. +@result A JSPropertyNameArray that is the same as array. +*/ +JS_EXPORT JSPropertyNameArrayRef JSPropertyNameArrayRetain(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Releases a JavaScript property name array. +@param array The JSPropetyNameArray to release. +*/ +JS_EXPORT void JSPropertyNameArrayRelease(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Gets a count of the number of items in a JavaScript property name array. +@param array The array from which to retrieve the count. +@result An integer count of the number of names in array. +*/ +JS_EXPORT size_t JSPropertyNameArrayGetCount(JSPropertyNameArrayRef array); + +/*! +@function +@abstract Gets a property name at a given index in a JavaScript property name array. +@param array The array from which to retrieve the property name. +@param index The index of the property name to retrieve. +@result A JSStringRef containing the property name. +*/ +JS_EXPORT JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index); + +/*! +@function +@abstract Adds a property name to a JavaScript property name accumulator. +@param accumulator The accumulator object to which to add the property name. +@param propertyName The property name to add. +*/ +JS_EXPORT void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef accumulator, JSStringRef propertyName); + +#ifdef __cplusplus +} +#endif + +#endif /* JSObjectRef_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.cpp new file mode 100644 index 00000000..ea277f05 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSProfilerPrivate.h" + +#include "APICast.h" +#include "OpaqueJSString.h" +#include "Profiler.h" + +using namespace JSC; + +void JSStartProfiling(JSContextRef ctx, JSStringRef title) +{ + Profiler::profiler()->startProfiling(toJS(ctx), title->ustring()); +} + +void JSEndProfiling(JSContextRef ctx, JSStringRef title) +{ + ExecState* exec = toJS(ctx); + Profiler* profiler = Profiler::profiler(); + profiler->stopProfiling(exec, title->ustring()); +} + diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.h new file mode 100644 index 00000000..b3fe533a --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSProfilerPrivate.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSProfiler_h +#define JSProfiler_h + +#include + +#ifndef __cplusplus +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function JSStartProfiling +@abstract Enables the profler. +@param ctx The execution context to use. +@param title The title of the profile. +@result The profiler is turned on. +*/ +JS_EXPORT void JSStartProfiling(JSContextRef ctx, JSStringRef title); + +/*! +@function JSEndProfiling +@abstract Disables the profler. +@param ctx The execution context to use. +@param title The title of the profile. +@result The profiler is turned off. If there is no name, the most recently started + profile is stopped. If the name does not match any profile then no profile + is stopped. +*/ +JS_EXPORT void JSEndProfiling(JSContextRef ctx, JSStringRef title); + +#ifdef __cplusplus +} +#endif + +#endif /* JSProfiler_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h new file mode 100644 index 00000000..69c6de19 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSRetainPtr.h @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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. + */ + +#ifndef JSRetainPtr_h +#define JSRetainPtr_h + +#include +#include + +inline void JSRetain(JSStringRef string) { JSStringRetain(string); } +inline void JSRelease(JSStringRef string) { JSStringRelease(string); } + +enum AdoptTag { Adopt }; + +template class JSRetainPtr { +public: + JSRetainPtr() : m_ptr(0) {} + JSRetainPtr(T ptr) : m_ptr(ptr) { if (ptr) JSRetain(ptr); } + + JSRetainPtr(AdoptTag, T ptr) : m_ptr(ptr) { } + + JSRetainPtr(const JSRetainPtr& o) : m_ptr(o.m_ptr) { if (T ptr = m_ptr) JSRetain(ptr); } + + ~JSRetainPtr() { if (T ptr = m_ptr) JSRelease(ptr); } + + template JSRetainPtr(const JSRetainPtr& o) : m_ptr(o.get()) { if (T ptr = m_ptr) JSRetain(ptr); } + + T get() const { return m_ptr; } + + T releaseRef() { T tmp = m_ptr; m_ptr = 0; return tmp; } + + T operator->() const { return m_ptr; } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T JSRetainPtr::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &JSRetainPtr::m_ptr : 0; } + + JSRetainPtr& operator=(const JSRetainPtr&); + template JSRetainPtr& operator=(const JSRetainPtr&); + JSRetainPtr& operator=(T); + template JSRetainPtr& operator=(U*); + + void adopt(T); + + void swap(JSRetainPtr&); + +private: + T m_ptr; +}; + +template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) +{ + T optr = o.get(); + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template template inline JSRetainPtr& JSRetainPtr::operator=(const JSRetainPtr& o) +{ + T optr = o.get(); + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline JSRetainPtr& JSRetainPtr::operator=(T optr) +{ + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline void JSRetainPtr::adopt(T optr) +{ + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); +} + +template template inline JSRetainPtr& JSRetainPtr::operator=(U* optr) +{ + if (optr) + JSRetain(optr); + T ptr = m_ptr; + m_ptr = optr; + if (ptr) + JSRelease(ptr); + return *this; +} + +template inline void JSRetainPtr::swap(JSRetainPtr& o) +{ + std::swap(m_ptr, o.m_ptr); +} + +template inline void swap(JSRetainPtr& a, JSRetainPtr& b) +{ + a.swap(b); +} + +template inline bool operator==(const JSRetainPtr& a, const JSRetainPtr& b) +{ + return a.get() == b.get(); +} + +template inline bool operator==(const JSRetainPtr& a, U* b) +{ + return a.get() == b; +} + +template inline bool operator==(T* a, const JSRetainPtr& b) +{ + return a == b.get(); +} + +template inline bool operator!=(const JSRetainPtr& a, const JSRetainPtr& b) +{ + return a.get() != b.get(); +} + +template inline bool operator!=(const JSRetainPtr& a, U* b) +{ + return a.get() != b; +} + +template inline bool operator!=(T* a, const JSRetainPtr& b) +{ + return a != b.get(); +} + + +#endif // JSRetainPtr_h diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.cpp new file mode 100644 index 00000000..fc337ef1 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.cpp @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSStringRef.h" + +#include "InitializeThreading.h" +#include "OpaqueJSString.h" +#include + +using namespace JSC; +using namespace WTF::Unicode; + +JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars) +{ + initializeThreading(); + return OpaqueJSString::create(chars, numChars).releaseRef(); +} + +JSStringRef JSStringCreateWithUTF8CString(const char* string) +{ + initializeThreading(); + if (string) { + size_t length = strlen(string); + Vector buffer(length); + UChar* p = buffer.data(); + if (conversionOK == convertUTF8ToUTF16(&string, string + length, &p, p + length)) + return OpaqueJSString::create(buffer.data(), p - buffer.data()).releaseRef(); + } + + // Null string. + return OpaqueJSString::create().releaseRef(); +} + +JSStringRef JSStringRetain(JSStringRef string) +{ + string->ref(); + return string; +} + +void JSStringRelease(JSStringRef string) +{ + string->deref(); +} + +size_t JSStringGetLength(JSStringRef string) +{ + return string ? string->length() : 0; +} + +const JSChar* JSStringGetCharactersPtr(JSStringRef string) +{ + return string ? string->characters() : nullptr; +} + +size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string) +{ + // Any UTF8 character > 3 bytes encodes as a UTF16 surrogate pair. + return string ? string->length() * 3 + 1 : 1; // + 1 for terminating '\0' +} + +size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize) +{ + if (!bufferSize) + return 0; + + char* p = buffer; + ConversionResult result = conversionOK; + if (string) { + const UChar* d = string->characters(); + result = convertUTF16ToUTF8(&d, d + string->length(), &p, p + bufferSize - 1, true); + } + *p++ = '\0'; + if (result != conversionOK && result != targetExhausted) + return 0; + + return p - buffer; +} + +bool JSStringIsEqual(JSStringRef a, JSStringRef b) +{ + if (!a) + return (!b || b->length() == 0); + if (!b) + return (!a || a->length() == 0); + unsigned len = a->length(); + return len == b->length() && 0 == memcmp(a->characters(), b->characters(), len * sizeof(UChar)); +} + +bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b) +{ + JSStringRef bBuf = JSStringCreateWithUTF8CString(b); + bool result = JSStringIsEqual(a, bBuf); + JSStringRelease(bBuf); + + return result; +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.h new file mode 100644 index 00000000..92135b15 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRef.h @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSStringRef_h +#define JSStringRef_h + +#include + +#ifndef __cplusplus +#include +#endif +#include /* for size_t */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(WIN32) && !defined(_WIN32) && !defined(__WINSCW__) \ + && !(defined(__CC_ARM) || defined(__ARMCC__)) /* RVCT */ +/*! +@typedef JSChar +@abstract A Unicode character. +*/ + typedef unsigned short JSChar; +#else + typedef wchar_t JSChar; +#endif + +/*! +@function +@abstract Creates a JavaScript string from a buffer of Unicode characters. +@param chars The buffer of Unicode characters to copy into the new JSString. +@param numChars The number of characters to copy from the buffer pointed to by chars. +@result A JSString containing chars. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars); +/*! +@function +@abstract Creates a JavaScript string from a null-terminated UTF8 string. +@param string The null-terminated UTF8 string to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithUTF8CString(const char* string); + +/*! +@function +@abstract Retains a JavaScript string. +@param string The JSString to retain. +@result A JSString that is the same as string. +*/ +JS_EXPORT JSStringRef JSStringRetain(JSStringRef string); +/*! +@function +@abstract Releases a JavaScript string. +@param string The JSString to release. +*/ +JS_EXPORT void JSStringRelease(JSStringRef string); + +/*! +@function +@abstract Returns the number of Unicode characters in a JavaScript string. +@param string The JSString whose length (in Unicode characters) you want to know. +@result The number of Unicode characters stored in string. +*/ +JS_EXPORT size_t JSStringGetLength(JSStringRef string); +/*! +@function +@abstract Returns a pointer to the Unicode character buffer that + serves as the backing store for a JavaScript string. +@param string The JSString whose backing store you want to access. +@result A pointer to the Unicode character buffer that serves as string's + backing store, which will be deallocated when string is deallocated. +*/ +JS_EXPORT const JSChar* JSStringGetCharactersPtr(JSStringRef string); + +/*! +@function +@abstract Returns the maximum number of bytes a JavaScript string will + take up if converted into a null-terminated UTF8 string. +@param string The JSString whose maximum converted size (in bytes) you + want to know. +@result The maximum number of bytes that could be required to convert string into a + null-terminated UTF8 string. The number of bytes that the conversion actually ends + up requiring could be less than this, but never more. +*/ +JS_EXPORT size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string); +/*! +@function +@abstract Converts a JavaScript string into a null-terminated UTF8 string, + and copies the result into an external byte buffer. +@param string The source JSString. +@param buffer The destination byte buffer into which to copy a null-terminated + UTF8 representation of string. On return, buffer contains a UTF8 string + representation of string. If bufferSize is too small, buffer will contain only + partial results. If buffer is not at least bufferSize bytes in size, + behavior is undefined. +@param bufferSize The size of the external buffer in bytes. +@result The number of bytes written into buffer (including the null-terminator byte). +*/ +JS_EXPORT size_t JSStringGetUTF8CString(JSStringRef string, char* buffer, size_t bufferSize); + +/*! +@function +@abstract Tests whether two JavaScript strings match. +@param a The first JSString to test. +@param b The second JSString to test. +@result true if the two strings match, otherwise false. +*/ +JS_EXPORT bool JSStringIsEqual(JSStringRef a, JSStringRef b); +/*! +@function +@abstract Tests whether a JavaScript string matches a null-terminated UTF8 string. +@param a The JSString to test. +@param b The null-terminated UTF8 string to test. +@result true if the two strings match, otherwise false. +*/ +JS_EXPORT bool JSStringIsEqualToUTF8CString(JSStringRef a, const char* b); + +#ifdef __cplusplus +} +#endif + +#endif /* JSStringRef_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.cpp new file mode 100644 index 00000000..a7d3e992 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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. + */ + +#include "config.h" +#include "JSStringRefBSTR.h" + +#include "JSStringRef.h" + +JSStringRef JSStringCreateWithBSTR(BSTR string) +{ + return JSStringCreateWithCharacters(string ? string : L"", string ? SysStringLen(string) : 0); +} + +BSTR JSStringCopyBSTR(const JSStringRef string) +{ + return SysAllocStringLen(JSStringGetCharactersPtr(string), JSStringGetLength(string)); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.h new file mode 100644 index 00000000..59f19b76 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefBSTR.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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. + */ + +#ifndef JSStringRefBSTR_h +#define JSStringRefBSTR_h + +#include "JSBase.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* COM convenience methods */ + +/*! +@function +@abstract Creates a JavaScript string from a BSTR. +@param string The BSTR to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithBSTR(const BSTR string); + +/*! +@function +@abstract Creates a BSTR from a JavaScript string. +@param string The JSString to copy into the new BSTR. +@result A BSTR containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT BSTR JSStringCopyBSTR(const JSStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif /* JSStringRefBSTR_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.cpp new file mode 100644 index 00000000..d1f6fe33 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSStringRefCF.h" + +#include "APICast.h" +#include "InitializeThreading.h" +#include "JSStringRef.h" +#include "OpaqueJSString.h" +#include +#include +#include + +JSStringRef JSStringCreateWithCFString(CFStringRef string) +{ + JSC::initializeThreading(); + + // We cannot use CFIndex here since CFStringGetLength can return values larger than + // it can hold. () + size_t length = CFStringGetLength(string); + if (length) { + OwnArrayPtr buffer(new UniChar[length]); + CFStringGetCharacters(string, CFRangeMake(0, length), buffer.get()); + COMPILE_ASSERT(sizeof(UniChar) == sizeof(UChar), unichar_and_uchar_must_be_same_size); + return OpaqueJSString::create(reinterpret_cast(buffer.get()), length).releaseRef(); + } else { + return OpaqueJSString::create(0, 0).releaseRef(); + } +} + +CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string) +{ + return CFStringCreateWithCharacters(alloc, reinterpret_cast(string->characters()), string->length()); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.h new file mode 100644 index 00000000..a4247656 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSStringRefCF.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSStringRefCF_h +#define JSStringRefCF_h + +#include "JSBase.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* CFString convenience methods */ + +/*! +@function +@abstract Creates a JavaScript string from a CFString. +@discussion This function is optimized to take advantage of cases when + CFStringGetCharactersPtr returns a valid pointer. +@param string The CFString to copy into the new JSString. +@result A JSString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSStringCreateWithCFString(CFStringRef string); +/*! +@function +@abstract Creates a CFString from a JavaScript string. +@param alloc The alloc parameter to pass to CFStringCreate. +@param string The JSString to copy into the new CFString. +@result A CFString containing string. Ownership follows the Create Rule. +*/ +JS_EXPORT CFStringRef JSStringCopyCFString(CFAllocatorRef alloc, JSStringRef string); + +#ifdef __cplusplus +} +#endif + +#endif /* JSStringRefCF_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.cpp new file mode 100644 index 00000000..a12cc340 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.cpp @@ -0,0 +1,301 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "JSValueRef.h" + +#include +#include "APICast.h" +#include "APIShims.h" +#include "JSCallbackObject.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include // for std::min + +using namespace JSC; + +::JSType JSValueGetType(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + if (jsValue.isUndefined()) + return kJSTypeUndefined; + if (jsValue.isNull()) + return kJSTypeNull; + if (jsValue.isBoolean()) + return kJSTypeBoolean; + if (jsValue.isNumber()) + return kJSTypeNumber; + if (jsValue.isString()) + return kJSTypeString; + ASSERT(jsValue.isObject()); + return kJSTypeObject; +} + +bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isUndefined(); +} + +bool JSValueIsNull(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isNull(); +} + +bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isBoolean(); +} + +bool JSValueIsNumber(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isNumber(); +} + +bool JSValueIsString(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isString(); +} + +bool JSValueIsObject(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.isObject(); +} + +bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + if (JSObject* o = jsValue.getObject()) { + if (o->inherits(&JSCallbackObject::info)) + return static_cast*>(o)->inherits(jsClass); + else if (o->inherits(&JSCallbackObject::info)) + return static_cast*>(o)->inherits(jsClass); + } + return false; +} + +bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsA = toJS(exec, a); + JSValue jsB = toJS(exec, b); + + bool result = JSValue::equal(exec, jsA, jsB); // false if an exception is thrown + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } + return result; +} + +bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsA = toJS(exec, a); + JSValue jsB = toJS(exec, b); + + return JSValue::strictEqual(exec, jsA, jsB); +} + +bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + JSObject* jsConstructor = toJS(constructor); + if (!jsConstructor->structure()->typeInfo().implementsHasInstance()) + return false; + bool result = jsConstructor->hasInstance(exec, jsValue, jsConstructor->get(exec, exec->propertyNames().prototype)); // false if an exception is thrown + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + } + return result; +} + +JSValueRef JSValueMakeUndefined(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toRef(exec, jsUndefined()); +} + +JSValueRef JSValueMakeNull(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toRef(exec, jsNull()); +} + +JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toRef(exec, jsBoolean(value)); +} + +JSValueRef JSValueMakeNumber(JSContextRef ctx, double value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toRef(exec, jsNumber(exec, value)); +} + +JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + return toRef(exec, jsString(exec, string->ustring())); +} + +bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + return jsValue.toBoolean(exec); +} + +double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + double number = jsValue.toNumber(exec); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + number = NaN; + } + return number; +} + +JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + RefPtr stringRef(OpaqueJSString::create(jsValue.toString(exec))); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + stringRef.clear(); + } + return stringRef.release().releaseRef(); +} + +JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJS(exec, value); + + JSObjectRef objectRef = toRef(jsValue.toObject(exec)); + if (exec->hadException()) { + if (exception) + *exception = toRef(exec, exec->exception()); + exec->clearException(); + objectRef = 0; + } + return objectRef; +} + +void JSValueProtect(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJSForGC(exec, value); + gcProtect(jsValue); +} + +void JSValueUnprotect(JSContextRef ctx, JSValueRef value) +{ + ExecState* exec = toJS(ctx); + APIEntryShim entryShim(exec); + + JSValue jsValue = toJSForGC(exec, value); + gcUnprotect(jsValue); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.h new file mode 100644 index 00000000..7a7bf93a --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JSValueRef.h @@ -0,0 +1,278 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JSValueRef_h +#define JSValueRef_h + +#include + +#ifndef __cplusplus +#include +#endif + +/*! +@enum JSType +@abstract A constant identifying the type of a JSValue. +@constant kJSTypeUndefined The unique undefined value. +@constant kJSTypeNull The unique null value. +@constant kJSTypeBoolean A primitive boolean value, one of true or false. +@constant kJSTypeNumber A primitive number value. +@constant kJSTypeString A primitive string value. +@constant kJSTypeObject An object value (meaning that this JSValueRef is a JSObjectRef). +*/ +typedef enum { + kJSTypeUndefined, + kJSTypeNull, + kJSTypeBoolean, + kJSTypeNumber, + kJSTypeString, + kJSTypeObject +} JSType; + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Returns a JavaScript value's type. +@param ctx The execution context to use. +@param value The JSValue whose type you want to obtain. +@result A value of type JSType that identifies value's type. +*/ +JS_EXPORT JSType JSValueGetType(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the undefined type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the undefined type, otherwise false. +*/ +JS_EXPORT bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the null type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the null type, otherwise false. +*/ +JS_EXPORT bool JSValueIsNull(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the boolean type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the boolean type, otherwise false. +*/ +JS_EXPORT bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the number type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the number type, otherwise false. +*/ +JS_EXPORT bool JSValueIsNumber(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the string type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the string type, otherwise false. +*/ +JS_EXPORT bool JSValueIsString(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value's type is the object type. +@param ctx The execution context to use. +@param value The JSValue to test. +@result true if value's type is the object type, otherwise false. +*/ +JS_EXPORT bool JSValueIsObject(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Tests whether a JavaScript value is an object with a given class in its class chain. +@param ctx The execution context to use. +@param value The JSValue to test. +@param jsClass The JSClass to test against. +@result true if value is an object and has jsClass in its class chain, otherwise false. +*/ +JS_EXPORT bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass); + +/* Comparing values */ + +/*! +@function +@abstract Tests whether two JavaScript values are equal, as compared by the JS == operator. +@param ctx The execution context to use. +@param a The first value to test. +@param b The second value to test. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if the two values are equal, false if they are not equal or an exception is thrown. +*/ +JS_EXPORT bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception); + +/*! +@function +@abstract Tests whether two JavaScript values are strict equal, as compared by the JS === operator. +@param ctx The execution context to use. +@param a The first value to test. +@param b The second value to test. +@result true if the two values are strict equal, otherwise false. +*/ +JS_EXPORT bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b); + +/*! +@function +@abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator. +@param ctx The execution context to use. +@param value The JSValue to test. +@param constructor The constructor to test against. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false. +*/ +JS_EXPORT bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception); + +/* Creating values */ + +/*! +@function +@abstract Creates a JavaScript value of the undefined type. +@param ctx The execution context to use. +@result The unique undefined value. +*/ +JS_EXPORT JSValueRef JSValueMakeUndefined(JSContextRef ctx); + +/*! +@function +@abstract Creates a JavaScript value of the null type. +@param ctx The execution context to use. +@result The unique null value. +*/ +JS_EXPORT JSValueRef JSValueMakeNull(JSContextRef ctx); + +/*! +@function +@abstract Creates a JavaScript value of the boolean type. +@param ctx The execution context to use. +@param boolean The bool to assign to the newly created JSValue. +@result A JSValue of the boolean type, representing the value of boolean. +*/ +JS_EXPORT JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean); + +/*! +@function +@abstract Creates a JavaScript value of the number type. +@param ctx The execution context to use. +@param number The double to assign to the newly created JSValue. +@result A JSValue of the number type, representing the value of number. +*/ +JS_EXPORT JSValueRef JSValueMakeNumber(JSContextRef ctx, double number); + +/*! +@function +@abstract Creates a JavaScript value of the string type. +@param ctx The execution context to use. +@param string The JSString to assign to the newly created JSValue. The + newly created JSValue retains string, and releases it upon garbage collection. +@result A JSValue of the string type, representing the value of string. +*/ +JS_EXPORT JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string); + +/* Converting to primitive values */ + +/*! +@function +@abstract Converts a JavaScript value to boolean and returns the resulting boolean. +@param ctx The execution context to use. +@param value The JSValue to convert. +@result The boolean result of conversion. +*/ +JS_EXPORT bool JSValueToBoolean(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Converts a JavaScript value to number and returns the resulting number. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The numeric result of conversion, or NaN if an exception is thrown. +*/ +JS_EXPORT double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Converts a JavaScript value to string and copies the result into a JavaScript string. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule. +*/ +JS_EXPORT JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +/*! +@function +@abstract Converts a JavaScript value to object and returns the resulting object. +@param ctx The execution context to use. +@param value The JSValue to convert. +@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. +@result The JSObject result of conversion, or NULL if an exception is thrown. +*/ +JS_EXPORT JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception); + +/* Garbage collection */ +/*! +@function +@abstract Protects a JavaScript value from garbage collection. +@param ctx The execution context to use. +@param value The JSValue to protect. +@discussion Use this method when you want to store a JSValue in a global or on the heap, where the garbage collector will not be able to discover your reference to it. + +A value may be protected multiple times and must be unprotected an equal number of times before becoming eligible for garbage collection. +*/ +JS_EXPORT void JSValueProtect(JSContextRef ctx, JSValueRef value); + +/*! +@function +@abstract Unprotects a JavaScript value from garbage collection. +@param ctx The execution context to use. +@param value The JSValue to unprotect. +@discussion A value may be protected multiple times and must be unprotected an + equal number of times before becoming eligible for garbage collection. +*/ +JS_EXPORT void JSValueUnprotect(JSContextRef ctx, JSValueRef value); + +#ifdef __cplusplus +} +#endif + +#endif /* JSValueRef_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScript.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScript.h new file mode 100644 index 00000000..f8d92d8f --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScript.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2006 Apple Inc. All rights reserved. + * Copyright (C) 2008 Alp Toker + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JavaScript_h +#define JavaScript_h + +#include +#include +#include +#include +#include + +#endif /* JavaScript_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScriptCore.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScriptCore.h new file mode 100644 index 00000000..87d60185 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/JavaScriptCore.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef JavaScriptCore_h +#define JavaScriptCore_h + +#include +#include + +#endif /* JavaScriptCore_h */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.cpp b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.cpp new file mode 100644 index 00000000..f740abe3 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#include "config.h" +#include "OpaqueJSString.h" + +#include +#include +#include + +using namespace JSC; + +PassRefPtr OpaqueJSString::create(const UString& ustring) +{ + if (!ustring.isNull()) + return adoptRef(new OpaqueJSString(ustring.data(), ustring.size())); + return 0; +} + +UString OpaqueJSString::ustring() const +{ + if (this && m_characters) + return UString(m_characters, m_length); + return UString::null(); +} + +Identifier OpaqueJSString::identifier(JSGlobalData* globalData) const +{ + if (!this || !m_characters) + return Identifier(globalData, static_cast(0)); + + return Identifier(globalData, m_characters, m_length); +} diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.h new file mode 100644 index 00000000..6aa7b99f --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/OpaqueJSString.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2008 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. + */ + +#ifndef OpaqueJSString_h +#define OpaqueJSString_h + +#include + +namespace JSC { + class Identifier; + class JSGlobalData; +} + +struct OpaqueJSString : public ThreadSafeShared { + + static PassRefPtr create() // null + { + return adoptRef(new OpaqueJSString); + } + + static PassRefPtr create(const UChar* characters, unsigned length) + { + return adoptRef(new OpaqueJSString(characters, length)); + } + + static PassRefPtr create(const JSC::UString&); + + UChar* characters() { return m_characters; } + unsigned length() { return m_length; } + + JSC::UString ustring() const; + JSC::Identifier identifier(JSC::JSGlobalData*) const; + +private: + friend class WTF::ThreadSafeShared; + + OpaqueJSString() + : m_characters(0) + , m_length(0) + { + } + + OpaqueJSString(const UChar* characters, unsigned length) + : m_length(length) + { + m_characters = new UChar[length]; + memcpy(m_characters, characters, length * sizeof(UChar)); + } + + ~OpaqueJSString() + { + delete[] m_characters; + } + + UChar* m_characters; + unsigned m_length; +}; + +#endif diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/WebKitAvailability.h b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/WebKitAvailability.h new file mode 100644 index 00000000..84025283 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/API/WebKitAvailability.h @@ -0,0 +1,764 @@ +/* + * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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. + */ + +#ifndef __WebKitAvailability__ +#define __WebKitAvailability__ + +/* The structure of this header is based on AvailabilityMacros.h. The major difference is that the availability + macros are defined in terms of WebKit version numbers rather than Mac OS X system version numbers, as WebKit + releases span multiple versions of Mac OS X. +*/ + +#define WEBKIT_VERSION_1_0 0x0100 +#define WEBKIT_VERSION_1_1 0x0110 +#define WEBKIT_VERSION_1_2 0x0120 +#define WEBKIT_VERSION_1_3 0x0130 +#define WEBKIT_VERSION_2_0 0x0200 +#define WEBKIT_VERSION_3_0 0x0300 +#define WEBKIT_VERSION_3_1 0x0310 +#define WEBKIT_VERSION_4_0 0x0400 +#define WEBKIT_VERSION_LATEST 0x9999 + +#ifdef __APPLE__ +#import +#else +/* + * For non-Mac platforms, require the newest version. + */ +#define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST +/* + * only certain compilers support __attribute__((deprecated)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) +#else + #define DEPRECATED_ATTRIBUTE +#endif +#endif + +/* The versions of GCC that shipped with Xcode prior to 3.0 (GCC build number < 5400) did not support attributes on methods. + If we are building with one of these versions, we need to omit the attribute. We achieve this by wrapping the annotation + in WEBKIT_OBJC_METHOD_ANNOTATION, which will remove the annotation when an old version of GCC is in use and will otherwise + expand to the annotation. The same is needed for protocol methods. +*/ +#if defined(__APPLE_CC__) && __APPLE_CC__ < 5400 + #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) +#else + #define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION +#endif + + +/* If minimum WebKit version is not specified, assume the version that shipped with the target Mac OS X version */ +#ifndef WEBKIT_VERSION_MIN_REQUIRED + #if !defined(MAC_OS_X_VERSION_10_2) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2 + #error WebKit was not available prior to Mac OS X 10.2 + #elif !defined(MAC_OS_X_VERSION_10_3) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 + /* WebKit 1.0 is the only version available on Mac OS X 10.2. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_0 + #elif !defined(MAC_OS_X_VERSION_10_4) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 + /* WebKit 1.1 is the version that shipped on Mac OS X 10.3. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_1_1 + #elif !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + /* WebKit 2.0 is the version that shipped on Mac OS X 10.4. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_2_0 + #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 + /* WebKit 3.0 is the version that shipped on Mac OS X 10.5. */ + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_3_0 + #else + #define WEBKIT_VERSION_MIN_REQUIRED WEBKIT_VERSION_LATEST + #endif +#endif + + +/* If maximum WebKit version is not specified, assume largerof(latest, minimum) */ +#ifndef WEBKIT_VERSION_MAX_ALLOWED + #if WEBKIT_VERSION_MIN_REQUIRED > WEBKIT_VERSION_LATEST + #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_MIN_REQUIRED + #else + #define WEBKIT_VERSION_MAX_ALLOWED WEBKIT_VERSION_LATEST + #endif +#endif + + +/* Sanity check the configured values */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_MIN_REQUIRED + #error WEBKIT_VERSION_MAX_ALLOWED must be >= WEBKIT_VERSION_MIN_REQUIRED +#endif +#if WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_0 + #error WEBKIT_VERSION_MIN_REQUIRED must be >= WEBKIT_VERSION_1_0 +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER + * + * Used on functions introduced in WebKit 1.0 + */ +#define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED + * + * Used on functions introduced in WebKit 1.0, + * and deprecated in WebKit 1.0 + */ +#define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER + * + * Used on types deprecated in WebKit 1.0 + */ +#define DEPRECATED_IN_WEBKIT_VERSION_1_0_AND_LATER DEPRECATED_ATTRIBUTE + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER + * + * Used on declarations introduced in WebKit 1.1 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.1, + * and deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER + * + * Used on types deprecated in WebKit 1.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_1 + #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_1_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER + * + * Used on declarations introduced in WebKit 1.2 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.2, + * and deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_2 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER + * + * Used on types deprecated in WebKit 1.2 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_2 + #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_2_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER + * + * Used on declarations introduced in WebKit 1.3 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 1.3, + * and deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_1_3 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER + * + * Used on types deprecated in WebKit 1.3 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_1_3 + #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_1_3_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER + * + * Used on declarations introduced in WebKit 2.0 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 2.0, + * and deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_2_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER + * + * Used on types deprecated in WebKit 2.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_2_0 + #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_2_0_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER + * + * Used on declarations introduced in WebKit 3.0 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 3.0, + * and deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER + * + * Used on types deprecated in WebKit 3.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_0 + #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_3_0_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER + * + * Used on declarations introduced in WebKit 3.1 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 3.1, + * and deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 + * + * Used on declarations introduced in WebKit 3.0, + * but later deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_3_1 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER + * + * Used on types deprecated in WebKit 3.1 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_3_1 + #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_3_1_AND_LATER +#endif + + + + + + +/* + * AVAILABLE_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 4.0 + */ +#if WEBKIT_VERSION_MAX_ALLOWED < WEBKIT_VERSION_LATEST + #define AVAILABLE_IN_WEBKIT_VERSION_4_0 UNAVAILABLE_ATTRIBUTE +#elif WEBKIT_VERSION_MIN_REQUIRED < WEBKIT_VERSION_LATEST + #define AVAILABLE_IN_WEBKIT_VERSION_4_0 WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_IN_WEBKIT_VERSION_4_0 +#endif + +/* + * AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED + * + * Used on declarations introduced in WebKit 4.0, + * and deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_IN_WEBKIT_VERSION_4_0_BUT_DEPRECATED AVAILABLE_IN_WEBKIT_VERSION_4_0 +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 1.0, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 1.1, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_1_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 1.2, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_2_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 1.3, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_1_3_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 2.0, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_2_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 3.0, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER +#endif + +/* + * AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on declarations introduced in WebKit 3.1, + * but later deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER_BUT_DEPRECATED_IN_WEBKIT_VERSION_4_0 AVAILABLE_WEBKIT_VERSION_3_1_AND_LATER +#endif + +/* + * DEPRECATED_IN_WEBKIT_VERSION_4_0 + * + * Used on types deprecated in WebKit 4.0 + */ +#if WEBKIT_VERSION_MIN_REQUIRED >= WEBKIT_VERSION_LATEST + #define DEPRECATED_IN_WEBKIT_VERSION_4_0 DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_WEBKIT_VERSION_4_0 +#endif + + +#endif /* __WebKitAvailability__ */ diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/AUTHORS b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/AUTHORS new file mode 100644 index 00000000..e50da8c5 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/AUTHORS @@ -0,0 +1,2 @@ +Harri Porten (porten@kde.org) +Peter Kelly (pmk@post.com) diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/COPYING.LIB b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/COPYING.LIB new file mode 100644 index 00000000..87c4a33d --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/COPYING.LIB @@ -0,0 +1,488 @@ + + +NOTE! The LGPL below is copyrighted by the Free Software Foundation, but +the instance of code that it refers to (the kde libraries) are copyrighted +by the authors who actually wrote it. + +--------------------------------------------------------------------------- + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog new file mode 100644 index 00000000..00d34991 --- /dev/null +++ b/src/shared/qtscript/src/3rdparty/javascriptcore/JavaScriptCore/ChangeLog @@ -0,0 +1,19026 @@ +2012-08-08 Patrick Gansterer + + [WIN] Use GetTimeZoneInformation() for getting the timezone name + https://bugs.webkit.org/show_bug.cgi?id=91936 + + Reviewed by Ryosuke Niwa. + + The MS CRT implementation of strftime calls the same functions in the background. + Using them directly avoids the overhead of parsing the format string and removes + the dependency on strftime() for WinCE where this function does not exist. + + * runtime/DateConversion.cpp: + (JSC::formatTime): + +2010-07-08 Gavin Barraclough + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=41641 + + Update compile flags to allow use of ExecutableAllocatorFixedVMPool on platforms + other than x86-64 (this may be useful on 32-bit platforms, too). + + Simplify ifdefs by dividing into thwo broad allocation strategies + (ENABLE_EXECUTABLE_ALLOCATOR_FIXED & ENABLE_EXECUTABLE_ALLOCATOR_DEMAND). + + Rename constant used in the code to have names descriptive of their purpose, + rather than their specific value on a given platform. + + * jit/ExecutableAllocator.cpp: + (JSC::ExecutableAllocator::reprotectRegion): + (JSC::ExecutableAllocator::cacheFlush): + * jit/ExecutableAllocatorFixedVMPool.cpp: + (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): + (JSC::FixedVMPoolAllocator::free): + (JSC::ExecutablePool::systemAlloc): + * jit/ExecutableAllocatorPosix.cpp: + * jit/ExecutableAllocatorSymbian.cpp: + * jit/ExecutableAllocatorWin.cpp: + * wtf/Platform.h: + +2010-08-24 Oliver Hunt + + Reviewed by Geoff Garen. + + Don't seed the JS random number generator from time() + https://bugs.webkit.org/show_bug.cgi?id=41868 + + + Switch to using the secure random number generator to + seed the fast random generator, and make the generator + be per global object. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + (JSC::JSGlobalObject::weakRandomNumber): + * runtime/MathObject.cpp: + (JSC::mathProtoFuncRandom): + +2010-06-18 Tucker Jay + + Reviewed by NOBODY (OOPS!). + + [Symbian] Lazy commit of memory required in JSC register file + https://bugs.webkit.org/show_bug.cgi?id=34349 + + * JavaScriptCore.pro: Added 1 new Symbian source file + * interpreter/RegisterFile.cpp: + (JSC::RegisterFile::~RegisterFile): + * interpreter/RegisterFile.h: + (JSC::RegisterFile::): + (JSC::RegisterFile::start): + (JSC::RegisterFile::end): + (JSC::RegisterFile::size): + (JSC::RegisterFile::setNumGlobals): + (JSC::RegisterFile::numGlobals): + (JSC::RegisterFile::maxGlobals): + (JSC::RegisterFile::lastGlobal): + (JSC::RegisterFile::markGlobals): + (JSC::RegisterFile::markCallFrames): + (JSC::isPageAligned): + (JSC::RegisterFile::RegisterFile): + (JSC::RegisterFile::shrink): + (JSC::RegisterFile::grow): + * wtf/symbian/RegisterFileAllocatorSymbian.cpp: Added. + (WTF::RegisterFileAllocator::RegisterFileAllocator): + Helper class to allocate memory required by RegisterFile + more efficiently. + (WTF::RegisterFileAllocator::~RegisterFileAllocator): + (WTF::RegisterFileAllocator::buffer): + (WTF::RegisterFileAllocator::grow): + (WTF::RegisterFileAllocator::shrink): + * wtf/symbian/RegisterFileAllocatorSymbian.h: Added. + * wtf/symbian/SymbianDefines.h: Added. + +2010-06-19 Thiago Macieira + + Reviewed by Kenneth Rohde Christiansen. + + Don't use __attribute__((may_alias)) with the Intel compiler, + as it doesn't understand it. + + * wtf/Vector.h: + +2010-06-19 Thiago Macieira + + Reviewed by Kenneth Rohde Christiansen. + + Fix compilation with the Intel C++ compiler (11.1.072). + + Like RVCT, label pointers must be void*, not const void*. + + * bytecode/Opcode.h: + +2010-06-19 Thiago Macieira + + Reviewed by Kenneth Rohde Christiansen. + + Add the WTF_COMPILER_INTEL for when the Intel compiler is used + for building. Usually, the Intel compiler masquerades as + another compiler in the system and gets away with it, but some + times specific fixes are required (such as when using language + extensions). + + * wtf/Platform.h: + +2010-06-07 Benjamin Poulain + + Reviewed by Simon Hausmann. + + [Qt] Crash when compiling on Snow Leopard and running on Leopard + https://bugs.webkit.org/show_bug.cgi?id=31403 + + Disable the use of pthread_setname_np and other symbols + when targetting Leopard. + + Use the defines TARGETING_XX instead of BUILDING_ON_XX + for features that cannot be used before Snow Leopard. + + * wtf/Platform.h: + +2010-05-10 Laszlo Gombos + + Reviewed by Darin Adler. + + [Qt] Disable JIT support for mingw-w64 + https://bugs.webkit.org/show_bug.cgi?id=38747 + + Disale JIT for mingw-w64 as it is reportedly + unstable. + + Thanks for Vanboxem Rruben for the investigation. + + * wtf/Platform.h: + +2010-05-06 Fumitoshi Ukai + + Reviewed by Alexey Proskuryakov. + + JavaScriptCore/wtf/RandomNumber.h should provide using WTF::* + https://bugs.webkit.org/show_bug.cgi?id=38719 + + * wtf/RandomNumber.h: + Add using directives. + +2010-04-28 Simon Hausmann , Kent Hansen + + Reviewed by Darin Adler. + + JSC's currentThreadStackBase is not reentrant on some platforms + https://bugs.webkit.org/show_bug.cgi?id=37195 + + This function needs to be reentrant to avoid memory corruption on platforms where + the implementation uses global variables. + + This patch adds a mutex lock where necessary and makes the Symbian implementation + reentrant. + + * runtime/Collector.cpp: + (JSC::currentThreadStackBaseMutex): + (JSC::currentThreadStackBase): + +2010-04-14 Kent Hansen + + Reviewed by Maciej Stachowiak. + + Mac OS X: Use deployment target to determine whether memory tagging should be enabled + https://bugs.webkit.org/show_bug.cgi?id=34888 + + When building on (Snow) Leopard but targeting Tiger + (TARGETING_TIGER defined, BUILDING_ON_TIGER not defined), + WebKit would crash on Tiger because the tags passed to mmap + caused those function calls to fail. + + Conversely, when building on Tiger but targeting Leopard + (BUILDING_ON_TIGER defined, TARGETING_LEOPARD defined), WebKit + would crash on Leopard because the tags passed to vm_map and + vm_allocate caused those function calls to fail. + + Solution: Use TARGETING_TIGER rather than BUILDING_ON_TIGER to + govern the tag definitions. Use the same tags for vm_map and + vm_allocate regardless of target, since they work on + both. Fall back to the mmap tags that work on Tiger (that is, + "no tags") if targeting Tiger, since those tags also work on + Leopard. + + * wtf/VMTags.h: + +2010-04-02 Ruben Van Boxem + + Reviewed by Eric Seidel. + + Mingw-w64 fixes for JavaScriptCore + https://bugs.webkit.org/show_bug.cgi?id=35607 + + * runtime/Collector.cpp: use the msvc code for mingw-w64 (but not mingw-w32) + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlockPtr): + (JSC::currentThreadStackBase): + (JSC::currentThreadStackBase): + * wtf/Platform.h: added COMPILER(MINGW64) check to differentiate between mingw.org and mingw-w64 functions + +2010-03-29 Patrick Gansterer + + Reviewed by Darin Adler. + + Corrected name of (u)int64_t compile time assert. + https://bugs.webkit.org/show_bug.cgi?id=36739 + + int64_t_is_four_bytes -> int64_t_is_eight_bytes + + * os-win32/stdint.h: + +2010-03-29 Thomas Zander + + Reviewed by Simon Hausmann. + + https://bugs.webkit.org/show_bug.cgi?id=36742 + + gcc for Symbian doesn't support gcc extensions like atomicity.h - disable + + * wtf/Threading.h: also detect os symbian + +2010-03-23 Mark Rowe + + Build fix. + + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncSplice): Some versions of GCC emit a warning about the implicit 64- to 32-bit truncation + that takes place here. An explicit cast is sufficient to silence it. + +2010-03-23 Alexey Proskuryakov + + Build fix. + + * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncSplice): Fixed a typo - length doesn't + need to be converted with toInteger(). + +2010-03-23 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + https://bugs.webkit.org/show_bug.cgi?id=36511 + Safari freezes when using SPUTNIK JavaScript conformance check + + Test: fast/js/sputnik-S15.4.4.12_A3_T3.html + + * runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncSplice): We were incorrectly computing + the start offset, and iterated over (almost) all integers. Note that this can be fixed + without using doubles, but the code would be much more complicated, and there is no important + reason to stick to integers here. + +2010-03-22 Siddharth Mathur + + Reviewed by Laszlo Gombos. + + [Symbian] More efficient aligned memory allocation for JSC Collector + https://bugs.webkit.org/show_bug.cgi?id=34350 + + * JavaScriptCore.pri: Added 2 new Symbian source files and HAL linkage + + * runtime/Collector.cpp: Reduced port-specific code and added private data member + (JSC::Heap::Heap): + (JSC::Heap::~Heap): + (JSC::Heap::destroy): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlockPtr): + + * runtime/Collector.h: Added private data member + + * wtf/symbian: Added. + * wtf/symbian/BlockAllocatorSymbian.cpp: Added. + (WTF::AlignedBlockAllocator::AlignedBlockAllocator): Helper class to allocate + aligned blocks more efficiently as required by Collector + (WTF::AlignedBlockAllocator::alloc): + (WTF::AlignedBlockAllocator::free): + (WTF::AlignedBlockAllocator::destroy): + (WTF::AlignedBlockAllocator::~AlignedBlockAllocator): + * wtf/symbian/BlockAllocatorSymbian.h: Added. + +2010-03-22 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed REGRESSION (r46701): -(-2147483648) + evaluates to -2147483648 on 32 bit (35842) + + Two ways to fix the same bug: + + 1. Check for overflow when negating, since negating the largest negative + int causes overflow. + + 2. Constant-fold even when negating a negative, since, like they say in + high school, "math works." + + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::branchNeg32): + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::branchNeg32): Added a branching version + of the negate operator. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): Use the branching version of the negate + operator to check for overflow. + + (JSC::JIT::emitSlow_op_negate): Link the check for overflow to a slow case. + (We could emit inline code for this, since we know what the result would + be, but that's probably just a waste of generated code.) + + * parser/Grammar.y: Constant fold even when negating a negative. + +2010-03-17 Mike Homey + + Reviewed by Gustavo Noronha. + + Build fix for SPARC. Fix missing macro value. + + * wtf/Platform.h: + +2010-03-03 Mark Rowe + + Reviewed by Geoff Garen. + + Add virtual memory tags for TCMalloc and WebCore's purgeable buffers. + + * wtf/TCSystemAlloc.cpp: + (TryMmap): Use the VM tag. + * wtf/VMTags.h: Make use of VM_MEMORY_TCMALLOC and VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS. + +2010-03-01 Tor Arne Vestbø + + Reviewed by Simon Hausmann. + + Fix the Qt build on Mac OS X/Cocoa 64-bit + + * JavaScriptCore.pri: Add missing implementation file to resolve JSC symbols + +2010-02-26 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] Symbian specific getCPUTime implemetation + https://bugs.webkit.org/show_bug.cgi?id=34742 + + Default implementation doesn't work on Symbian devices. + This change adds a proper implementation by + asking thread execution time from the current thread. + + * runtime/TimeoutChecker.cpp: + (JSC::getCPUTime): + +2010-02-15 Gabor Loki + + Reviewed by Gavin Barraclough. + + Fix the SP at ctiOpThrowNotCaught on Thumb2 (JSVALUE32) + https://bugs.webkit.org/show_bug.cgi?id=34939 + + * jit/JITStubs.cpp: + +2010-02-15 Gavin Barraclough + + Reviewed by NOBODY (Build fix). + + Add missing cast for !YARR (PPC) builds. + + * runtime/RegExp.cpp: + (JSC::RegExp::match): + +2010-02-14 Laszlo Gombos + + Reviewed by Adam Barth. + + Implement NEVER_INLINE and NO_RETURN for RVCT + https://bugs.webkit.org/show_bug.cgi?id=34740 + + * wtf/AlwaysInline.h: + +2010-02-12 Gavin Barraclough + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=33731 + Many false leaks in release builds due to PtrAndFlags + + Remove UntypedPtrAndBitfield (similar to PtrAndFlags) in UStringImpl, + and steal bits from the refCount instead. + + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::baseSharedBuffer): + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UStringImpl::cost): + (JSC::UStringImpl::isIdentifier): + (JSC::UStringImpl::setIsIdentifier): + (JSC::UStringImpl::ref): + (JSC::UStringImpl::deref): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::bufferOwnership): + (JSC::UStringImpl::isStatic): + (JSC::UStringImpl::): + +2010-02-12 Kwang Yul Seo + + Reviewed by Adam Barth. + + Typedef both JSChar and UChar to wchar_t in RVCT. + https://bugs.webkit.org/show_bug.cgi?id=34560 + + Define both JSChar and UChar to wchar_t as the size + of wchar_t is 2 bytes in RVCT. + + * API/JSStringRef.h: + * wtf/unicode/qt4/UnicodeQt4.h: + +2009-10-06 Yongjun Zhang + + Reviewed by Simon Hausmann. + + Get rid of WINSCW hack for UnSpecifiedBoolType + + Add parenthesis around (RefPtr::*UnspecifiedBoolType) to make the WINSCW + compiler work with the default UnSpecifiedBoolType() operator. + + https://bugs.webkit.org/show_bug.cgi?id=28054 + + * wtf/RefPtr.h: + +2010-02-09 Janne Koskinen + + Reviewed by Laszlo Gombos. + + [Qt] use nanval() for Symbian as nonInlineNaN + https://bugs.webkit.org/show_bug.cgi?id=34170 + + numeric_limits::quiet_NaN is broken in Symbian + causing NaN to be evaluated as a number. + + * runtime/JSValue.cpp: + (JSC::nonInlineNaN): + +2010-02-01 Kent Tamura + + Reviewed by Darin Adler. + + Date.UTC() should apply TimeClip operation. + https://bugs.webkit.org/show_bug.cgi?id=34461 + + ECMAScript 5 15.9.4.3: + > 9 Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + * runtime/DateConstructor.cpp: + (JSC::dateUTC): Calls WTF::timeClip(). + +2010-02-01 Kent Tamura + + Reviewed by Darin Adler. + + Fix a bug that Math.round() retunrs incorrect results for huge integers + https://bugs.webkit.org/show_bug.cgi?id=34462 + + * runtime/MathObject.cpp: + (JSC::mathProtoFuncRound): Avoid "arg + 0.5". + +2010-02-01 Patrick Gansterer + + Reviewed by Darin Adler. + + [Qt] WinCE buildfix after r52729 and fix for Q_BIG_ENDIAN typo. + https://bugs.webkit.org/show_bug.cgi?id=34378 + + * wtf/Platform.h: + +2010-01-31 Patrick Gansterer + + Reviewed by Darin Adler. + + Buildfix for WinCE + style fixes (TLS_OUT_OF_INDEXES is not defined). + https://bugs.webkit.org/show_bug.cgi?id=34380 + + * wtf/ThreadSpecific.h: + +2010-01-31 Kent Tamura + + Reviewed by Darin Adler. + + [Windows] Fix a bug of round() with huge integral numbers + https://bugs.webkit.org/show_bug.cgi?id=34297 + + Fix a bug that round() for huge integral numbers returns incorrect + results. For example, round(8639999913600001) returns + 8639999913600002 without this change though the double type can + represent 8639999913600001 precisely. + + Math.round() of JavaScript has a similar problem. But this change + doesn't fix it because Math.round() doesn't use round() of + MathExtra.h. + + * wtf/MathExtras.h: + (round): Avoid to do "num + 0.5" or "num - 0.5". + (roundf): Fixed similarly. + (llround): Calls round(). + (llroundf): Calls roundf(). + (lround): Calls round(). + (lroundf): Calls roundf(). + +2010-01-27 Anton Muhin + + Reviewed by Darin Adler. + + Remove trailing \ from inline function code + https://bugs.webkit.org/show_bug.cgi?id=34223 + + * assembler/ARMv7Assembler.h: + (JSC::ARMThumbImmediate::countLeadingZerosPartial): + +2010-01-27 Kwang Yul Seo + + Reviewed by Oliver Hunt. + + [BREWMP] Add MarkStack fastMalloc implementation for platforms without VirtualAlloc or mmap. + https://bugs.webkit.org/show_bug.cgi?id=33582 + + Use fastMalloc and fastFree to implement MarkStack::allocateStack and + MarkStack::releaseStack for platforms without page level allocation. + + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackNone.cpp: Added. + (JSC::MarkStack::initializePagesize): + (JSC::MarkStack::allocateStack): + (JSC::MarkStack::releaseStack): + +2010-01-27 Kwang Yul Seo + + Reviewed by Eric Seidel. + + [BREWMP] Don't use time function + https://bugs.webkit.org/show_bug.cgi?id=33577 + + Calling time(0) in BREW devices causes a crash because time + is not properly ported in most devices. Cast currentTime() to + time_t to get the same result as time(0). + + * wtf/DateMath.cpp: + (WTF::calculateUTCOffset): + +2010-01-27 Alexey Proskuryakov + + Revert r53899 (HashMap key checks) and subsequent build fixes, + because they make SVG tests crash in release builds. + + * wtf/HashMap.h: + (WTF::::remove): + * wtf/HashSet.h: + (WTF::::remove): + * wtf/HashTable.h: + (WTF::::add): + (WTF::::addPassingHashCode): + (WTF::::removeAndInvalidate): + (WTF::::remove): + (WTF::::rehash): + (WTF::::checkTableConsistency): + (WTF::::checkTableConsistencyExceptSize): + * wtf/HashTraits.h: + (WTF::GenericHashTraits::emptyValue): + (WTF::): + * wtf/RefPtrHashMap.h: + (WTF::::remove): + +2010-01-26 Alexey Proskuryakov + + More Windows build fixing. + + * wtf/HashTraits.h: _msize takes void*, remove const qualifier from type. + +2010-01-26 Alexey Proskuryakov + + Windows build fix. + + * wtf/HashTraits.h: Include malloc.h for _msize(). + +2010-01-26 Alexey Proskuryakov + + Build fix. + + * wtf/HashTable.h: (WTF::HashTable::checkTableConsistencyExceptSize): Remove const from a + static (empty) version of this function. + +2010-01-26 Alexey Proskuryakov + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=34150 + WebKit needs a mechanism to catch stale HashMap entries + + It is very difficult to catch stale pointers that are HashMap keys - since a pointer's hash + is just its value, it is very unlikely that any observable problem is reproducible. + + This extends hash table consistency checks to check that pointers are referencing allocated + memory blocks, and makes it possible to invoke the checks explicitly (it is not feasible + to enable CHECK_HASHTABLE_CONSISTENCY by default, because that affects performance too much). + + * wtf/HashMap.h: (WTF::::checkConsistency): Call through to HashTable implementation. We can + add similar calls to HashSet and HashCountedSet, but I haven't seen hard to debug problems + with those yet. + + * wtf/HashSet.h: (WTF::::remove): The version of checkTableConsistency that's guarded by + CHECK_HASHTABLE_CONSISTENCY is now called internalCheckTableConsistency(). + + * wtf/HashTable.h: + (WTF::HashTable::internalCheckTableConsistency): + (WTF::HashTable::internalCheckTableConsistencyExceptSize): + (WTF::HashTable::checkTableConsistencyExceptSize): + Expose checkTableConsistency() even if CHECK_HASHTABLE_CONSISTENCY is off. + (WTF::::add): Updated for checkTableConsistency renaming. + (WTF::::addPassingHashCode): Ditto. + (WTF::::removeAndInvalidate): Ditto. + (WTF::::remove): Ditto. + (WTF::::rehash): Ditto. + (WTF::::checkTableConsistency): The assertion for !shouldExpand() was not correct - this + function returns true for tables with m_table == 0. + (WTF::::checkTableConsistencyExceptSize): Call checkValueConsistency for key. Potentially, + we could do the same for values. + + * wtf/HashTraits.h: + (WTF::GenericHashTraits::checkValueConsistency): An empty function that can be overridden + to add checks. Currently, the only override is for pointer hashes. + + * wtf/RefPtrHashMap.h: (WTF::::remove): Updated for checkTableConsistency renaming. + +2010-01-26 Lyon Chen + + Reviewed by Maciej Stachowiak. + + Opcode.h use const void* for Opcode cause error #1211 for RVCT compiler + https://bugs.webkit.org/show_bug.cgi?id=33902 + + * bytecode/Opcode.h: + +2010-01-26 Steve Falkenburg + + Reviewed by Oliver Hunt. + + Windows build references non-existent include paths + https://bugs.webkit.org/show_bug.cgi?id=34175 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: + +2010-01-26 Oliver Hunt + + Reviewed by Geoffrey Garen. + + Using JavaScriptCore API with a webkit vended context can result in slow script dialog + https://bugs.webkit.org/show_bug.cgi?id=34172 + + Make the APIShim correctly increment and decrement the timeout + entry counter. + + * API/APIShims.h: + (JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock): + (JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock): + (JSC::APICallbackShim::APICallbackShim): + (JSC::APICallbackShim::~APICallbackShim): + +2010-01-26 Simon Hausmann + + [Qt] Fix compilation of QtScript with non-gcc compilers + + Variable length stack arrays are a gcc extension. Use QVarLengthArray + as a more portable solution that still tries to allocate on the stack + first. + + * qt/api/qscriptvalue_p.h: + (QScriptValuePrivate::call): + +2010-01-26 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + [Qt] Fix the build on platforms without JIT support. + + The JIT support should be determined at compile-time via wtf/Platform.h + + * qt/api/QtScript.pro: + +2010-01-26 Jedrzej Nowacki + + Reviewed by Simon Hausmann. + + First steps of the QtScript API. + + Two new classes were created; QScriptEngine and QScriptValue. + The first should encapsulate a javascript context and the second a script + value. + + This API is still in development, so it isn't compiled by default. + To trigger compilation, pass --qmakearg="CONFIG+=build-qtscript" to + build-webkit. + + https://bugs.webkit.org/show_bug.cgi?id=32565 + + * qt/api/QtScript.pro: Added. + * qt/api/qscriptconverter_p.h: Added. + (QScriptConverter::toString): + * qt/api/qscriptengine.cpp: Added. + (QScriptEngine::QScriptEngine): + (QScriptEngine::~QScriptEngine): + (QScriptEngine::evaluate): + (QScriptEngine::collectGarbage): + * qt/api/qscriptengine.h: Added. + * qt/api/qscriptengine_p.cpp: Added. + (QScriptEnginePrivate::QScriptEnginePrivate): + (QScriptEnginePrivate::~QScriptEnginePrivate): + (QScriptEnginePrivate::evaluate): + * qt/api/qscriptengine_p.h: Added. + (QScriptEnginePrivate::get): + (QScriptEnginePrivate::collectGarbage): + (QScriptEnginePrivate::makeJSValue): + (QScriptEnginePrivate::context): + * qt/api/qscriptvalue.cpp: Added. + (QScriptValue::QScriptValue): + (QScriptValue::~QScriptValue): + (QScriptValue::isValid): + (QScriptValue::isBool): + (QScriptValue::isBoolean): + (QScriptValue::isNumber): + (QScriptValue::isNull): + (QScriptValue::isString): + (QScriptValue::isUndefined): + (QScriptValue::isError): + (QScriptValue::isObject): + (QScriptValue::isFunction): + (QScriptValue::toString): + (QScriptValue::toNumber): + (QScriptValue::toBool): + (QScriptValue::toBoolean): + (QScriptValue::toInteger): + (QScriptValue::toInt32): + (QScriptValue::toUInt32): + (QScriptValue::toUInt16): + (QScriptValue::call): + (QScriptValue::engine): + (QScriptValue::operator=): + (QScriptValue::equals): + (QScriptValue::strictlyEquals): + * qt/api/qscriptvalue.h: Added. + (QScriptValue::): + * qt/api/qscriptvalue_p.h: Added. + (QScriptValuePrivate::): + (QScriptValuePrivate::get): + (QScriptValuePrivate::QScriptValuePrivate): + (QScriptValuePrivate::isValid): + (QScriptValuePrivate::isBool): + (QScriptValuePrivate::isNumber): + (QScriptValuePrivate::isNull): + (QScriptValuePrivate::isString): + (QScriptValuePrivate::isUndefined): + (QScriptValuePrivate::isError): + (QScriptValuePrivate::isObject): + (QScriptValuePrivate::isFunction): + (QScriptValuePrivate::toString): + (QScriptValuePrivate::toNumber): + (QScriptValuePrivate::toBool): + (QScriptValuePrivate::toInteger): + (QScriptValuePrivate::toInt32): + (QScriptValuePrivate::toUInt32): + (QScriptValuePrivate::toUInt16): + (QScriptValuePrivate::equals): + (QScriptValuePrivate::strictlyEquals): + (QScriptValuePrivate::assignEngine): + (QScriptValuePrivate::call): + (QScriptValuePrivate::engine): + (QScriptValuePrivate::context): + (QScriptValuePrivate::value): + (QScriptValuePrivate::object): + (QScriptValuePrivate::inherits): + (QScriptValuePrivate::isJSBased): + (QScriptValuePrivate::isNumberBased): + (QScriptValuePrivate::isStringBased): + * qt/api/qtscriptglobal.h: Added. + * qt/tests/qscriptengine/qscriptengine.pro: Added. + * qt/tests/qscriptengine/tst_qscriptengine.cpp: Added. + (tst_QScriptEngine::tst_QScriptEngine): + (tst_QScriptEngine::~tst_QScriptEngine): + (tst_QScriptEngine::init): + (tst_QScriptEngine::cleanup): + (tst_QScriptEngine::collectGarbage): + (tst_QScriptEngine::evaluate): + * qt/tests/qscriptvalue/qscriptvalue.pro: Added. + * qt/tests/qscriptvalue/tst_qscriptvalue.cpp: Added. + (tst_QScriptValue::tst_QScriptValue): + (tst_QScriptValue::~tst_QScriptValue): + (tst_QScriptValue::init): + (tst_QScriptValue::cleanup): + (tst_QScriptValue::ctor): + (tst_QScriptValue::toString_data): + (tst_QScriptValue::toString): + (tst_QScriptValue::copyConstructor_data): + (tst_QScriptValue::copyConstructor): + (tst_QScriptValue::assignOperator_data): + (tst_QScriptValue::assignOperator): + (tst_QScriptValue::dataSharing): + (tst_QScriptValue::constructors_data): + (tst_QScriptValue::constructors): + (tst_QScriptValue::call): + * qt/tests/tests.pri: Added. + * qt/tests/tests.pro: Added. + +2010-01-25 Dmitry Titov + + Reviewed by David Levin. + + Fix Chromium Linux tests: the pthread functions on Linux produce segfault if they receive 0 thread handle. + After r53714, we can have 0 thread handles passed to pthread_join and pthread_detach if corresponding threads + were already terminated and their threadMap entries cleared. + Add a 0 check. + + * wtf/ThreadingPthreads.cpp: + (WTF::waitForThreadCompletion): + (WTF::detachThread): + +2010-01-24 Laszlo Gombos + + Reviewed by Maciej Stachowiak. + + Refactor JITStubs.cpp so that DEFINE_STUB_FUNCTION is only used once for each function + https://bugs.webkit.org/show_bug.cgi?id=33866 + + Place the guard USE(JSVALUE32_64) inside the body of the DEFINE_STUB_FUNCTION + macro for those functions that are always present. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + +2010-01-22 Kevin Watters + + Reviewed by Kevin Ollivier. + + [wx] Remove the Bakefile build system, which is no longer being used. + + https://bugs.webkit.org/show_bug.cgi?id=34022 + + * JavaScriptCoreSources.bkl: Removed. + * jscore.bkl: Removed. + +2010-01-22 Steve Falkenburg + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=34025 + Enable client-based Geolocation abstraction for Mac, Windows AppleWebKit targets. + + * Configurations/FeatureDefines.xcconfig: + +2010-01-22 Dmitry Titov + + Not reviewed, attempted Snow Leopard build fix. + + * wtf/ThreadingPthreads.cpp: Add a forward declaration of a function which is not 'static'. + +2009-01-22 Dmitry Titov + + Reviewed by Maciej Stachowiak. + + Fix the leak of ThreadIdentifiers in threadMap across threads. + https://bugs.webkit.org/show_bug.cgi?id=32689 + + Test is added to DumpRenderTree.mm. + + * Android.mk: Added file ThreadIdentifierDataPthreads.(h|cpp) to build. + * Android.v8.wtf.mk: Ditto. + * GNUmakefile.am: Ditto. + * JavaScriptCore.gyp/JavaScriptCore.gyp: Ditto. + * JavaScriptCore.gypi: Ditto. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + + * wtf/ThreadIdentifierDataPthreads.cpp: Added. Contains custom implementation of thread-specific data that uses custom destructor. + (WTF::ThreadIdentifierData::~ThreadIdentifierData): Removes the ThreadIdentifier from the threadMap. + (WTF::ThreadIdentifierData::identifier): + (WTF::ThreadIdentifierData::initialize): + (WTF::ThreadIdentifierData::destruct): Custom thread-specific destructor. Resets the value for the key again to cause second invoke. + (WTF::ThreadIdentifierData::initializeKeyOnceHelper): + (WTF::ThreadIdentifierData::initializeKeyOnce): Need to use pthread_once since initialization may come on any thread(s). + * wtf/ThreadIdentifierDataPthreads.h: Added. + (WTF::ThreadIdentifierData::ThreadIdentifierData): + + * wtf/Threading.cpp: + (WTF::threadEntryPoint): Move initializeCurrentThreadInternal to after the lock to make + sure it is invoked when ThreadIdentifier is already established. + + * wtf/Threading.h: Rename setThreadNameInternal -> initializeCurrentThreadInternal since it does more then only set the name now. + * wtf/ThreadingNone.cpp: + (WTF::initializeCurrentThreadInternal): Ditto. + * wtf/ThreadingWin.cpp: + (WTF::initializeCurrentThreadInternal): Ditto. + (WTF::initializeThreading): Ditto. + * wtf/gtk/ThreadingGtk.cpp: + (WTF::initializeCurrentThreadInternal): Ditto. + * wtf/qt/ThreadingQt.cpp: + (WTF::initializeCurrentThreadInternal): Ditto. + + * wtf/ThreadingPthreads.cpp: + (WTF::establishIdentifierForPthreadHandle): + (WTF::clearPthreadHandleForIdentifier): Make it not 'static' so the ~ThreadIdentifierData() in another file can call it. + (WTF::initializeCurrentThreadInternal): Set the thread-specific data. The ThreadIdentifier is already established by creating thread. + (WTF::waitForThreadCompletion): Remove call to clearPthreadHandleForIdentifier(threadID) since it is now done in ~ThreadIdentifierData(). + (WTF::detachThread): Ditto. + (WTF::currentThread): Use the thread-specific data to get the ThreadIdentifier. It's many times faster then Mutex-protected iteration through the map. + Also, set the thread-specific data if called first time on the thread. + +2010-01-21 Kwang Yul Seo + + Reviewed by Alexey Proskuryakov. + + Add ThreadSpecific for ENABLE(SINGLE_THREADED) + https://bugs.webkit.org/show_bug.cgi?id=33878 + + Implement ThreadSpecific with a simple getter/setter + when ENABLE(SINGLE_THREADED) is true. + + Due to the change in https://bugs.webkit.org/show_bug.cgi?id=33236, + an implementation of ThreadSpecific must be available to build WebKit. + This causes a build failure for platforms without a proper + ThreadSpecific implementation. + + * wtf/ThreadSpecific.h: + (WTF::::ThreadSpecific): + (WTF::::~ThreadSpecific): + (WTF::::get): + (WTF::::set): + (WTF::::destroy): + +2010-01-21 Kwang Yul Seo + + Reviewed by Maciej Stachowiak. + + Add fastStrDup to FastMalloc + https://bugs.webkit.org/show_bug.cgi?id=33937 + + The new string returned by fastStrDup is obtained with fastMalloc, + and can be freed with fastFree. This makes the memory management + more consistent because we don't need to keep strdup allocated pointers + and free them with free(). Instead we can use fastFree everywhere. + + * wtf/FastMalloc.cpp: + (WTF::fastStrDup): + * wtf/FastMalloc.h: + +2010-01-21 Brady Eidson + + Reviewed by Maciej Stachowiak. + + history.back() for same-document history traversals isn't synchronous as the specification states. + and https://bugs.webkit.org/show_bug.cgi?id=33538 + + * wtf/Platform.h: Add a "HISTORY_ALWAYS_ASYNC" enable and turn it on for Chromium. + +2010-01-21 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Always create a prototype for automatically managed classes. + + This fixes some errors where prototype chains were not correctly hooked + up, and also ensures that API classes work correctly with features like + instanceof. + + * API/JSClassRef.cpp: + (OpaqueJSClass::create): Cleaned up some of this code. Also changed it + to always create a prototype class. + + * API/tests/testapi.c: + (Derived2_class): + (main): Fixed a null value crash in the exception checking code. + * API/tests/testapi.js: Added some tests for the case where a prototype + chain would not be hooked up correctly. + +2010-01-21 Oliver Hunt + + Reviewed by Geoff Garen. + + Force JSC to create a prototype chain for API classes with a + parent class but no static functions. + + * API/JSClassRef.cpp: + (OpaqueJSClass::create): + +2010-01-21 Kent Hansen + + Reviewed by Geoffrey Garen. + + Object.getOwnPropertyDescriptor always returns undefined for JS API objects + https://bugs.webkit.org/show_bug.cgi?id=33946 + + Ideally the getOwnPropertyDescriptor() reimplementation should return an + access descriptor that wraps the property getter and setter callbacks, but + that approach is much more involved than returning a value descriptor. + Keep it simple for now. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (JSC::::getOwnPropertyDescriptor): + * API/tests/testapi.js: + +2010-01-20 Mark Rowe + + Build fix. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::initializeScavenger): Remove unnecessary function call. + +2010-01-20 Mark Rowe + + Reviewed by Oliver Hunt. + + Use the inline i386 assembly for x86_64 as well rather than falling back to using pthread mutexes. + + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Lock): + (TCMalloc_SpinLock::Unlock): + (TCMalloc_SlowLock): + +2010-01-20 Mark Rowe + + Reviewed by Oliver Hunt. + + Use GCD instead of an extra thread for FastMalloc scavenging on platforms where it is supported + + Abstract the background scavenging slightly so that an alternate implementation that uses GCD can be used on platforms + where it is supported. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::init): + (WTF::TCMalloc_PageHeap::initializeScavenger): + (WTF::TCMalloc_PageHeap::signalScavenger): + (WTF::TCMalloc_PageHeap::shouldContinueScavenging): + (WTF::TCMalloc_PageHeap::Delete): + (WTF::TCMalloc_PageHeap::periodicScavenge): + * wtf/Platform.h: + +2010-01-20 Geoffrey Garen + + Reviewed by Oliver Hunt. + + REGRESSION(53460): Heap::destroy may not run + all destructors + + * runtime/Collector.cpp: + (JSC::Heap::freeBlocks): Instead of fully marking protected objects, + just set their mark bits. This prevents protected objects from keeping + unprotected objects alive. Destructor order is not guaranteed, so it's + OK to destroy objects pointed to by protected objects before destroying + protected objects. + +2010-01-19 David Levin + + Reviewed by Oliver Hunt. + + CrossThreadCopier needs to support ThreadSafeShared better. + https://bugs.webkit.org/show_bug.cgi?id=33698 + + * wtf/TypeTraits.cpp: Added tests for the new type traits. + * wtf/TypeTraits.h: + (WTF::IsSubclass): Determines if a class is a derived from another class. + (WTF::IsSubclassOfTemplate): Determines if a class is a derived from a + template class (with one parameter that is unknown). + (WTF::RemoveTemplate): Reveals the type for a template parameter. + +2010-01-20 Steve Falkenburg + + Reviewed by Darin Adler and Adam Roben. + + Feature defines are difficult to maintain on Windows builds + https://bugs.webkit.org/show_bug.cgi?id=33883 + + FeatureDefines.vsprops are now maintained in a way similar to + Configurations/FeatureDefines.xcconfig, with the added advantage + of having a single FeatureDefines file across all projects. + + * Configurations/FeatureDefines.xcconfig: Add comments about keeping feature definitions in sync. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add FeatureDefines.vsprops inherited property sheet. + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Add FeatureDefines.vsprops inherited property sheet. + +2010-01-20 Csaba Osztrogonác + + [Qt] Unreviewed buildfix for r53547. + + * DerivedSources.pro: + +2010-01-20 Tor Arne Vestbø + + Reviewed by Simon Hausmann. + + [Qt] Make extraCompilers for generated sources depend on their scripts + + * DerivedSources.pro: + +2010-01-19 Brian Weinstein + + Reviewed by Tim Hatcher. + + When JavaScriptCore calls Debugger::Exception, have it pass a + hasHandler variable that represents if exception is being handled + in the same function (not in a parent on the call stack). + + This just adds a new parameter, no behavior is changed. + + * debugger/Debugger.h: + * interpreter/Interpreter.cpp: + (JSC::Interpreter::throwException): + +2010-01-18 Maciej Stachowiak + + Reviewed by Adam Barth. + + Inline functions that are hot in DOM manipulation + https://bugs.webkit.org/show_bug.cgi?id=33820 + + (3% speedup on Dromaeo DOM Core tests) + + * runtime/WeakGCMap.h: + (JSC::::get): inline + +2010-01-19 Laszlo Gombos + + Unreviewed build fix for JIT with RVCT. + + Remove IMPORT statement; cti_vm_throw is already defined in JITStubs.h. + Remove extra ')'. + + * jit/JITStubs.cpp: + (JSC::ctiVMThrowTrampoline): + +2010-01-19 Geoffrey Garen + + Reviewed by Oliver Hunt. + + REGRESSION (52082): Crash on worker thread when reloading http://radnan.public.iastate.edu/procedural/ + https://bugs.webkit.org/show_bug.cgi?id=33826 + + This bug was caused by a GC-protected object being destroyed early by + Heap::destroy. Clients of the GC protect APIs (reasonably) expect pointers + to GC-protected memory to be valid. + + The solution is to do two passes of tear-down in Heap::destroy. The first + pass tears down all unprotected objects. The second pass ASSERTs that all + previously protected objects are now unprotected, and then tears down + all perviously protected objects. These two passes simulate the two passes + that would have been required to free a protected object during normal GC. + + * API/JSContextRef.cpp: Removed some ASSERTs that have moved into Heap. + + * runtime/Collector.cpp: + (JSC::Heap::destroy): Moved ASSERTs to here. + (JSC::Heap::freeBlock): Tidied up the use of didShrink by moving its + setter to the function that does the shrinking. + (JSC::Heap::freeBlocks): Implemented above algorithm. + (JSC::Heap::shrinkBlocks): Tidied up the use of didShrink. + +2010-01-19 Gavin Barraclough + + Reviewed by NOBODY (build fix). + + Reverting r53455, breaks 2 javascriptcore tests. + + * API/JSContextRef.cpp: + * runtime/Collector.cpp: + (JSC::Heap::destroy): + (JSC::Heap::freeBlock): + (JSC::Heap::freeBlocks): + (JSC::Heap::shrinkBlocks): + +2010-01-18 Gavin Barraclough + + Reviewed by NOBODY (build fix). + + Revert r53454, since it causes much sadness in this world. + + * runtime/UString.cpp: + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::baseSharedBuffer): + (JSC::UStringImpl::sharedBuffer): + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield): + (JSC::UntypedPtrAndBitfield::asPtr): + (JSC::UntypedPtrAndBitfield::operator&=): + (JSC::UntypedPtrAndBitfield::operator|=): + (JSC::UntypedPtrAndBitfield::operator&): + (JSC::UStringImpl::create): + (JSC::UStringImpl::cost): + (JSC::UStringImpl::isIdentifier): + (JSC::UStringImpl::setIsIdentifier): + (JSC::UStringImpl::ref): + (JSC::UStringImpl::deref): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::bufferOwnership): + (JSC::UStringImpl::isStatic): + * wtf/StringHashFunctions.h: + (WTF::stringHash): + +2010-01-18 Geoffrey Garen + + Reviewed by Oliver Hunt. + + REGRESSION (52082): Crash on worker thread when reloading http://radnan.public.iastate.edu/procedural/ + https://bugs.webkit.org/show_bug.cgi?id=33826 + + This bug was caused by a GC-protected object being destroyed early by + Heap::destroy. Clients of the GC protect APIs (reasonably) expect pointers + to GC-protected memory to be valid. + + The solution is to do two passes of tear-down in Heap::destroy. The first + pass tears down all unprotected objects. The second pass ASSERTs that all + previously protected objects are now unprotected, and then tears down + all perviously protected objects. These two passes simulate the two passes + that would have been required to free a protected object during normal GC. + + * API/JSContextRef.cpp: Removed some ASSERTs that have moved into Heap. + + * runtime/Collector.cpp: + (JSC::Heap::destroy): Moved ASSERTs to here. + (JSC::Heap::freeBlock): Tidied up the use of didShrink by moving its + setter to the function that does the shrinking. + (JSC::Heap::freeBlocks): Implemented above algorithm. + (JSC::Heap::shrinkBlocks): Tidied up the use of didShrink. + +2010-01-18 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=33731 + Remove UntypedPtrAndBitfield from UStringImpl (akin to PtrAndFlags). + + This break the OS X Leaks tool. Instead, free up some more bits from the refCount. + + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::sharedBuffer): + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UStringImpl::cost): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::): + * wtf/StringHashFunctions.h: + (WTF::stringHash): + +2010-01-18 Kent Tamura + + Reviewed by Darin Adler. + + HTMLInputElement::valueAsDate setter support for type=month. + https://bugs.webkit.org/show_bug.cgi?id=33021 + + Expose the following functions to be used by WebCore: + - WTF::msToyear() + - WTF::dayInYear() + - WTF::monthFromDayInYear() + - WTF::dayInMonthFromDayInYear() + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * wtf/DateMath.cpp: + (WTF::msToYear): Remove "static inline". + (WTF::dayInYear): Remove "static inline". + (WTF::monthFromDayInYear): Remove "static inline". + (WTF::dayInMonthFromDayInYear): Remove "static inline". + * wtf/DateMath.h: Declare the above functions. + +2010-01-18 Darin Adler + + Fix build by reverting the previous change. + + * runtime/UString.h: Rolled out the FastAllocBase base class. + It was making UString larger, and therefore JSString larger, + and too big for a garbage collection cell. + + This raises the unpleasant possibility that many classes became + larger because we added the FastAllocBase base class. I am + worried about this, and it needs to be investigated. + +2010-01-18 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for UString class + https://bugs.webkit.org/show_bug.cgi?id=27831 + + Inherits the following class from FastAllocBase because it is + instantiated by 'new' and no need to be copyable: + + class name - instantiated at: + classs UString - JavaScriptCore/runtime/UString.cpp:160 + + * runtime/UString.h: + +2010-01-18 Evan Cheng + + Reviewed by Darin Adler. + + Add some ALWAYS_INLINE for key functions not inlined by some versions of GCC. + rdar://problem/7553780 + + * runtime/JSObject.h: + (JSC::JSObject::getPropertySlot): ALWAYS_INLINE both overloads. + * runtime/JSString.h: + (JSC::JSString::JSString): ALWAYS_INLINE the version that takes a UString. + * runtime/UString.h: + (JSC::operator==): ALWAYS_INLINE the version that compares two UString objects. + +2010-01-18 Csaba Osztrogonác + + Reviewed by Darin Adler. + + Delete dftables-xxxxxxxx.in files automatically. + https://bugs.webkit.org/show_bug.cgi?id=33796 + + * pcre/dftables: unlink unnecessary temporary file. + +2010-01-18 Tor Arne Vestbø + + Reviewed by Simon Hausmann. + + [Qt] Force qmake to generate a single makefile for DerivedSources.pro + + * DerivedSources.pro: + +2010-01-18 Csaba Osztrogonác + + Rubber-stamped by Gustavo Noronha Silva. + + Rolling out r53391 and r53392 because of random crashes on buildbots. + https://bugs.webkit.org/show_bug.cgi?id=33731 + + * bytecode/CodeBlock.h: + (JSC::CallLinkInfo::seenOnce): + (JSC::CallLinkInfo::setSeen): + (JSC::MethodCallLinkInfo::MethodCallLinkInfo): + (JSC::MethodCallLinkInfo::seenOnce): + (JSC::MethodCallLinkInfo::setSeen): + * jit/JIT.cpp: + (JSC::JIT::unlinkCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::patchMethodCallProto): + * runtime/UString.cpp: + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + * runtime/UString.h: + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::baseSharedBuffer): + (JSC::UStringImpl::sharedBuffer): + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield): + (JSC::UntypedPtrAndBitfield::asPtr): + (JSC::UntypedPtrAndBitfield::operator&=): + (JSC::UntypedPtrAndBitfield::operator|=): + (JSC::UntypedPtrAndBitfield::operator&): + (JSC::UStringImpl::create): + (JSC::UStringImpl::cost): + (JSC::UStringImpl::isIdentifier): + (JSC::UStringImpl::setIsIdentifier): + (JSC::UStringImpl::ref): + (JSC::UStringImpl::deref): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::bufferOwnership): + (JSC::UStringImpl::isStatic): + * wtf/StringHashFunctions.h: + (WTF::stringHash): + +2010-01-18 Simon Hausmann + + Reviewed by Kenneth Rohde Christiansen. + + Fix the build with strict gcc and RVCT versions: It's not legal to cast a + pointer to a function to a void* without an intermediate cast to a non-pointer + type. A cast to a ptrdiff_t inbetween fixes it. + + * runtime/JSString.h: + (JSC::Fiber::JSString): + +2010-01-15 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=33731 + Remove UntypedPtrAndBitfield from UStringImpl (akin to PtrAndFlags). + + This break the OS X Leaks tool. Instead, free up some more bits from the refCount. + + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::sharedBuffer): + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UStringImpl::cost): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::): + * wtf/StringHashFunctions.h: + (WTF::stringHash): + +2010-01-15 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=33731 + Remove uses of PtrAndFlags from JIT data stuctures. + + These break the OS X Leaks tool. Free up a bit in CallLinkInfo, and invalid + permutation of pointer states in MethodCallLinkInfo to represent the removed bits. + + * bytecode/CodeBlock.h: + (JSC::CallLinkInfo::seenOnce): + (JSC::CallLinkInfo::setSeen): + (JSC::MethodCallLinkInfo::MethodCallLinkInfo): + (JSC::MethodCallLinkInfo::seenOnce): + (JSC::MethodCallLinkInfo::setSeen): + * jit/JIT.cpp: + (JSC::JIT::unlinkCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::patchMethodCallProto): + * runtime/UString.h: + +2010-01-16 Maciej Stachowiak + + Reviewed by Oliver Hunt. + + Cache JS string values made from DOM strings (Dromaeo speedup) + https://bugs.webkit.org/show_bug.cgi?id=33768 + + + * runtime/JSString.h: + (JSC::jsStringWithFinalizer): Added new mechanism for a string to have an optional + finalizer callback, for the benefit of weak-referencing caches. + (JSC::): + (JSC::Fiber::JSString): + (JSC::Fiber::~JSString): + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): Clear fibers so this doesn't look like a string with a finalizer. + * runtime/WeakGCMap.h: Include "Collector.h" to make this header includable by itself. + +2010-01-15 Sam Weinig + + Reviewed by Maciej Stachowiak. + + Fix for + Add ALWAYS_INLINE to jsLess for a 1% speedup on llvm-gcc. + + * runtime/Operations.h: + (JSC::jsLess): + +2010-01-14 Geoffrey Garen + + Reviewed by Oliver Hunt. + + REGRESISON: Google maps buttons not working properly + https://bugs.webkit.org/show_bug.cgi?id=31871 + + REGRESSION(r52948): JavaScript exceptions thrown on Google Maps when + getting directions for a second time + https://bugs.webkit.org/show_bug.cgi?id=33446 + + SunSpider and v8 report no change. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCacheGetByID): Update our cached offset in case + flattening the dictionary changed any of its offsets. + + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCacheGetByID): + (JSC::DEFINE_STUB_FUNCTION): + * runtime/Operations.h: + (JSC::normalizePrototypeChain): ditto + +2010-01-14 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=33705 + UStringImpl::create() should use internal storage + + When creating a UStringImpl copying of a UChar*, we can use an internal buffer, + by calling UStringImpl::tryCreateUninitialized(). + + Also, remove duplicate of copyChars from JSString, call UStringImpl's version. + + Small (max 0.5%) progression on Sunspidey. + + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): + * runtime/UStringImpl.h: + (JSC::UStringImpl::create): + +2010-01-14 Gavin Barraclough + + Reviewed by Sam Weinig. + + Make naming & behaviour of UString[Impl] methods more consistent. + https://bugs.webkit.org/show_bug.cgi?id=33702 + + UString::create() creates a copy of the UChar* passed, but UStringImpl::create() assumes + that it should assume ownership of the provided buffer (with UString::createNonCopying() + and UStringImpl::createCopying() providing the alternate behaviours). Unify on create() + taking a copy of the provided buffer. For non-copying cases, use the name 'adopt', and + make this method take a Vector&. For cases where non-copying construction was being + used, other than from a Vector, change the code to allocate the storage along with + the UStringImpl using UStringImpl::createUninitialized(). (The adopt() method also more + closely matches that of WebCore::StringImpl). + + Also, UString::createUninitialized() and UStringImpl::createUninitialized() have incompatible + behaviours, in that the UString form sets the provided UChar* to a null or non-null value to + indicate success or failure, but UStringImpl uses the returned PassRefPtr to + indicate when allocation has failed (potentially leaving the output Char* uninitialized). + This is also incompatible with WebCore::StringImpl's behaviour, in that + StringImpl::createUninitialized() will CRASH() if unable to allocate. Some uses of + createUninitialized() in JSC are unsafe, since they do not test the result for null. + UStringImpl's indication is preferable, since we may want a successful call to set the result + buffer to 0 (specifically, StringImpl returns 0 for the buffer where createUninitialized() + returns the empty string, which seems reasonable to catch bugs early). UString's method + cannot support UStringImpl's behaviour directly, since it returns an object rather than a + pointer. + - remove UString::createUninitialized(), replace with calls to UStringImpl::createUninitialized() + - create a UStringImpl::tryCreateUninitialized() form UStringImpl::createUninitialized(), + with current behaviour, make createUninitialized() crash on failure to allocate. + - make cases in JSC that do not check the result call createUninitialized(), and cases that do + check call tryCreateUninitialized(). + + Rename computedHash() to existingHash(), to bring this in line wih WebCore::StringImpl. + + * API/JSClassRef.cpp: + (OpaqueJSClassContextData::OpaqueJSClassContextData): + * JavaScriptCore.exp: + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): + * runtime/Identifier.cpp: + (JSC::CStringTranslator::translate): + (JSC::UCharBufferTranslator::translate): + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): + * runtime/Lookup.cpp: + (JSC::HashTable::createTable): + * runtime/Lookup.h: + (JSC::HashTable::entry): + * runtime/StringBuilder.h: + (JSC::StringBuilder::release): + * runtime/StringConstructor.cpp: + (JSC::stringFromCharCodeSlowCase): + * runtime/StringPrototype.cpp: + (JSC::substituteBackreferencesSlow): + (JSC::stringProtoFuncToLowerCase): + (JSC::stringProtoFuncToUpperCase): + (JSC::stringProtoFuncFontsize): + (JSC::stringProtoFuncLink): + * runtime/Structure.cpp: + (JSC::Structure::despecifyDictionaryFunction): + (JSC::Structure::get): + (JSC::Structure::despecifyFunction): + (JSC::Structure::put): + (JSC::Structure::remove): + (JSC::Structure::insertIntoPropertyMapHashTable): + (JSC::Structure::checkConsistency): + * runtime/Structure.h: + (JSC::Structure::get): + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTableHash::hash): + * runtime/UString.cpp: + (JSC::createRep): + (JSC::UString::UString): + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + (JSC::UString::operator=): + * runtime/UString.h: + (JSC::UString::adopt): + (JSC::IdentifierRepHash::hash): + (JSC::makeString): + * runtime/UStringImpl.h: + (JSC::UStringImpl::adopt): + (JSC::UStringImpl::create): + (JSC::UStringImpl::createUninitialized): + (JSC::UStringImpl::tryCreateUninitialized): + (JSC::UStringImpl::existingHash): + +2010-01-13 Kent Hansen + + Reviewed by Oliver Hunt. + + JSON.stringify and JSON.parse needlessly process properties in the prototype chain + https://bugs.webkit.org/show_bug.cgi?id=33053 + + * runtime/JSONObject.cpp: + (JSC::Stringifier::Holder::appendNextProperty): + (JSC::Walker::walk): + +2010-01-13 Gavin Barraclough + + Reviewed by NOBODY (buildfix). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-13 Alexey Proskuryakov + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=33641 + Assertion failure in Lexer.cpp if input stream ends while in string escape + + Test: fast/js/end-in-string-escape.html + + * parser/Lexer.cpp: (JSC::Lexer::lex): Bail out quickly on end of stream, not giving the + assertion a chance to fire. + +2010-01-13 Gavin Barraclough + + Reviewed by NOBODY (buildfix). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-13 Gavin Barraclough + + Rubber stamped by Sam Weinig & Darin Adler. + + Three quick fixes to UStringImpl. + - The destroy() method can be switched back to a normal destructor; since we've switched + the way we protect static strings to be using an odd ref-count the destroy() won't abort. + - The cost() calculation logic was wrong. If you have multiple JSStrings wrapping substrings + of a base string, they would each report the full cost of the base string to the heap. + Instead we should only be reporting once for the base string. + - Remove the overloaded new operator calling fastMalloc, replace this with a 'using' to pick + up the implementation from the parent class. + + * JavaScriptCore.exp: + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::~UStringImpl): + * runtime/UStringImpl.h: + (JSC::UStringImpl::cost): + (JSC::UStringImpl::deref): + +2010-01-13 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Split the build process in two different .pro files. + This allows qmake to be run once all source files are available. + + * DerivedSources.pro: Added. + * JavaScriptCore.pri: Moved source generation to DerivedSources.pro + * pcre/pcre.pri: Moved source generation to DerivedSources.pro + +2010-01-12 Kent Hansen + + Reviewed by Geoffrey Garen. + + [ES5] Implement Object.getOwnPropertyNames + https://bugs.webkit.org/show_bug.cgi?id=32242 + + Add an extra argument to getPropertyNames() and getOwnPropertyNames() + (and all reimplementations thereof) that indicates whether non-enumerable + properties should be added. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (JSC::::getOwnPropertyNames): + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * debugger/DebuggerActivation.cpp: + (JSC::DebuggerActivation::getOwnPropertyNames): + * debugger/DebuggerActivation.h: + * runtime/Arguments.cpp: + (JSC::Arguments::getOwnPropertyNames): + * runtime/Arguments.h: + * runtime/CommonIdentifiers.h: + * runtime/JSArray.cpp: + (JSC::JSArray::getOwnPropertyNames): + * runtime/JSArray.h: + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::getOwnPropertyNames): + * runtime/JSByteArray.h: + * runtime/JSFunction.cpp: + (JSC::JSFunction::getOwnPropertyNames): + * runtime/JSFunction.h: + * runtime/JSNotAnObject.cpp: + (JSC::JSNotAnObject::getOwnPropertyNames): + * runtime/JSNotAnObject.h: + * runtime/JSObject.cpp: + (JSC::getClassPropertyNames): + (JSC::JSObject::getPropertyNames): + (JSC::JSObject::getOwnPropertyNames): + * runtime/JSObject.h: + * runtime/JSVariableObject.cpp: + (JSC::JSVariableObject::getOwnPropertyNames): + * runtime/JSVariableObject.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConstructorGetOwnPropertyNames): + * runtime/RegExpMatchesArray.h: + (JSC::RegExpMatchesArray::getOwnPropertyNames): + * runtime/StringObject.cpp: + (JSC::StringObject::getOwnPropertyNames): + * runtime/StringObject.h: + * runtime/Structure.cpp: Rename getEnumerablePropertyNames() to getPropertyNames(), which takes an extra argument. + (JSC::Structure::getPropertyNames): + * runtime/Structure.h: + (JSC::): + +2010-01-12 Alexey Proskuryakov + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=33540 + Make it possible to build in debug mode with assertions disabled + + * jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION): + * runtime/Identifier.cpp: (JSC::Identifier::checkSameIdentifierTable): + * wtf/FastMalloc.cpp: + * wtf/HashTable.h: (WTF::HashTableConstIterator::checkValidity): + * yarr/RegexCompiler.cpp: (JSC::Yarr::compileRegex): + +2009-11-23 Yong Li + + Reviewed by Adam Treat. + + Make GIF decoder support down-sampling + https://bugs.webkit.org/show_bug.cgi?id=31806 + + * platform/image-decoders/ImageDecoder.cpp: + (WebCore::ImageDecoder::upperBoundScaledY): + (WebCore::ImageDecoder::lowerBoundScaledY): + * platform/image-decoders/ImageDecoder.h: + (WebCore::RGBA32Buffer::scaledRect): + (WebCore::RGBA32Buffer::setScaledRect): + (WebCore::ImageDecoder::scaledSize): + * platform/image-decoders/gif/GIFImageDecoder.cpp: + (WebCore::GIFImageDecoder::sizeNowAvailable): + (WebCore::GIFImageDecoder::initFrameBuffer): + (WebCore::copyOnePixel): + (WebCore::GIFImageDecoder::haveDecodedRow): + (WebCore::GIFImageDecoder::frameComplete): + +2010-01-12 Adam Barth + + Reviewed by Eric Seidel. + + ecma/Date/15.9.5.12-1.js fails every night at midnight + https://bugs.webkit.org/show_bug.cgi?id=28041 + + Change the test to use a concrete time instead of "now". + + * tests/mozilla/ecma/Date/15.9.5.10-1.js: + * tests/mozilla/ecma/Date/15.9.5.12-1.js: + +2010-01-11 Csaba Osztrogonác + + Reviewed by Ariya Hidayat. + + [Qt] Enable JIT and YARR_JIT if (CPU(X86_64) && OS(LINUX) && GCC_VERSION >= 40100) + + * wtf/Platform.h: + +2010-01-11 Geoffrey Garen + + Reviewed by Alexey Proskuryakov. + + https://bugs.webkit.org/show_bug.cgi?id=33481 + Uninitialized data members in ArrayStorage + + SunSpider reports no change. + + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): Initialize missing data members in the two cases + where we don't use fastZeroedMalloc, so it doesn't happen automatically. + +2010-01-11 Steve Falkenburg + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=33480 + + Improve debugging reliability for WTF on Windows. + Store WTF static library's PDB file into a better location. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + +2010-01-11 Steve Falkenburg + + Windows build fix. + Remove extraneous entries from def file causing build warning. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-10 Kent Hansen + + Reviewed by Darin Adler. + + RegExp.prototype.toString returns "//" for empty regular expressions + https://bugs.webkit.org/show_bug.cgi?id=33319 + + "//" starts a single-line comment, hence "/(?:)/" should be used, according to ECMA. + + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncToString): + + * tests/mozilla/ecma_2/RegExp/properties-001.js: + (AddRegExpCases): + * tests/mozilla/js1_2/regexp/toString.js: + Update relevant Mozilla tests (Mozilla has had this behavior since November 2003). + +2010-01-10 Darin Adler + + * tests/mozilla/ecma/Array/15.4.1.1.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.1.2.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.2.1-1.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.2.2-1.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.2.2-2.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.2.3.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.3.2.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.3.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.4.1.js: Added property allow-tabs. + * tests/mozilla/ecma/Array/15.4.4.js: Added property allow-tabs. + * tests/mozilla/ecma/LexicalConventions/7.7.4.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.13.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.16.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.18.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.2.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.4.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.5.js: Added property allow-tabs. + * tests/mozilla/ecma/Math/15.8.2.7.js: Added property allow-tabs. + * tests/mozilla/ecma/String/15.5.1.js: Added property allow-tabs. + * tests/mozilla/ecma/String/15.5.2.js: Added property allow-tabs. + * tests/mozilla/ecma/String/15.5.3.1-3.js: Added property allow-tabs. + * tests/mozilla/ecma/String/15.5.3.1-4.js: Added property allow-tabs. + * tests/mozilla/ecma/String/15.5.3.js: Added property allow-tabs. + * tests/mozilla/ecma/TypeConversion/9.5-2.js: Added property allow-tabs. + * tests/mozilla/ecma/jsref.js: Modified property allow-tabs. + * tests/mozilla/ecma/shell.js: Modified property allow-tabs. + * tests/mozilla/ecma_2/LexicalConventions/keywords-001.js: Added property allow-tabs. + * tests/mozilla/ecma_2/RegExp/exec-001.js: Added property allow-tabs. + * tests/mozilla/ecma_2/String/match-004.js: Added property allow-tabs. + * tests/mozilla/ecma_2/String/replace-001.js: Added property allow-tabs. + * tests/mozilla/ecma_2/String/split-002.js: Added property allow-tabs. + * tests/mozilla/ecma_2/jsref.js: Modified property allow-tabs. + * tests/mozilla/ecma_2/shell.js: Added property allow-tabs. + * tests/mozilla/ecma_3/Date/shell.js: Modified property allow-tabs. + * tests/mozilla/ecma_3/Exceptions/regress-181654.js: Added property allow-tabs. + * tests/mozilla/ecma_3/RegExp/regress-209067.js: Added property allow-tabs. + * tests/mozilla/ecma_3/RegExp/regress-85721.js: Added property allow-tabs. + * tests/mozilla/importList.html: Added property allow-tabs. + * tests/mozilla/js1_1/shell.js: Added property allow-tabs. + * tests/mozilla/js1_2/Array/general1.js: Added property allow-tabs. + * tests/mozilla/js1_2/Array/general2.js: Added property allow-tabs. + * tests/mozilla/js1_2/Array/slice.js: Added property allow-tabs. + * tests/mozilla/js1_2/Array/splice1.js: Added property allow-tabs. + * tests/mozilla/js1_2/Array/splice2.js: Added property allow-tabs. + * tests/mozilla/js1_2/Objects/toString-001.js: Added property allow-tabs. + * tests/mozilla/js1_2/String/charCodeAt.js: Added property allow-tabs. + * tests/mozilla/js1_2/String/concat.js: Modified property allow-tabs. + * tests/mozilla/js1_2/String/match.js: Added property allow-tabs. + * tests/mozilla/js1_2/String/slice.js: Added property allow-tabs. + * tests/mozilla/js1_2/function/Function_object.js: Added property allow-tabs. + * tests/mozilla/js1_2/function/Number.js: Modified property allow-tabs. + * tests/mozilla/js1_2/function/String.js: Modified property allow-tabs. + * tests/mozilla/js1_2/function/nesting.js: Added property allow-tabs. + * tests/mozilla/js1_2/function/regexparg-1.js: Added property allow-tabs. + * tests/mozilla/js1_2/function/regexparg-2-n.js: Added property allow-tabs. + * tests/mozilla/js1_2/jsref.js: Added property allow-tabs. + * tests/mozilla/js1_2/operator/equality.js: Added property allow-tabs. + * tests/mozilla/js1_2/operator/strictEquality.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_dollar_number.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_input.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_input_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_lastIndex.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_lastMatch.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_lastMatch_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_lastParen.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_lastParen_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_leftContext.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_leftContext_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_multiline.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_multiline_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_object.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_rightContext.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/RegExp_rightContext_as_array.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/alphanumeric.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/asterisk.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/backslash.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/backspace.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/beginLine.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/character_class.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/compile.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/control_characters.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/digit.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/dot.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/endLine.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/everything.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/exec.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/flags.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/global.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/hexadecimal.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/ignoreCase.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/interval.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/octal.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/parentheses.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/plus.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/question_mark.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/simple_form.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/source.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/special_characters.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/string_replace.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/string_search.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/string_split.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/test.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/toString.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/vertical_bar.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/whitespace.js: Added property allow-tabs. + * tests/mozilla/js1_2/regexp/word_boundary.js: Added property allow-tabs. + * tests/mozilla/js1_2/shell.js: Added property allow-tabs. + * tests/mozilla/js1_2/statements/break.js: Added property allow-tabs. + * tests/mozilla/js1_2/statements/continue.js: Added property allow-tabs. + * tests/mozilla/js1_2/statements/do_while.js: Added property allow-tabs. + * tests/mozilla/js1_2/statements/switch.js: Added property allow-tabs. + * tests/mozilla/js1_2/statements/switch2.js: Added property allow-tabs. + * tests/mozilla/js1_3/shell.js: Added property allow-tabs. + * tests/mozilla/js1_4/shell.js: Added property allow-tabs. + * tests/mozilla/js1_5/Regress/regress-111557.js: Added property allow-tabs. + * tests/mozilla/js1_5/Regress/regress-216320.js: Added property allow-tabs. + * tests/mozilla/menuhead.html: Added property allow-tabs. + * tests/mozilla/mklistpage.pl: Added property allow-tabs. + * tests/mozilla/runtests.pl: Added property allow-tabs. + +2010-01-08 Daniel Bates + + Reviewed by Adam Barth. + + https://bugs.webkit.org/show_bug.cgi?id=33417 + + Cleans up style errors exposed by the patch for bug #33198. + Moreover, fixes all "Weird number of spaces at line-start. Are you using a 4-space indent?" + errors reported by check-webkit-style. + + No functionality was changed. So, no new tests. + + * wtf/Platform.h: + +2010-01-08 Kent Hansen + + Reviewed by Eric Seidel. + + Don't store RegExp flags string representation + https://bugs.webkit.org/show_bug.cgi?id=33321 + + It's unused; the string representation is reconstructed from flags. + + * runtime/RegExp.cpp: + (JSC::RegExp::RegExp): + * runtime/RegExp.h: + +2010-01-08 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Memory use grows grows possibly unbounded in this JavaScript Array test case + https://bugs.webkit.org/show_bug.cgi?id=31675 + + This fixes one observed bug in this test case, which is that + arrays don't report extra cost for the sparse value maps. + + SunSpider reports a small speedup. + + * runtime/JSArray.cpp: + (JSC::JSArray::putSlowCase): Report extra memory cost for + the sparse value map. + * runtime/JSArray.h: + +2010-01-08 Yong Li + + Reviewed by Darin Adler. + + Remove unnecessary #include from FastMalloc.cpp + https://bugs.webkit.org/show_bug.cgi?id=33393 + + * wtf/FastMalloc.cpp: + +2010-01-08 Eric Seidel + + No review, rolling out r52983. + http://trac.webkit.org/changeset/52983 + https://bugs.webkit.org/show_bug.cgi?id=33321 + + Broke 59 JavaScriptCore tests. I don't think Kent knew about + run-javascriptcore-tests. Sadly neither does the commit-bot, + yet. + + * runtime/RegExp.cpp: + (JSC::RegExp::RegExp): + * runtime/RegExp.h: + (JSC::RegExp::flags): + +2010-01-08 Eric Seidel + + No review, rolling out r52981. + http://trac.webkit.org/changeset/52981 + https://bugs.webkit.org/show_bug.cgi?id=33319 + + Caused two JS tests to start failing: + ecma_2/RegExp/properties-001.js and js1_2/regexp/toString.js + + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncToString): + +2010-01-08 Kent Hansen + + Reviewed by Darin Adler. + + Don't store RegExp flags string representation + https://bugs.webkit.org/show_bug.cgi?id=33321 + + It's unused; the string representation is reconstructed from flags. + + * runtime/RegExp.cpp: + (JSC::RegExp::RegExp): + * runtime/RegExp.h: + +2010-01-08 Kent Hansen + + Reviewed by Darin Adler. + + RegExp.prototype.toString returns "//" for empty regular expressions + https://bugs.webkit.org/show_bug.cgi?id=33319 + + "//" starts a single-line comment, hence "/(?:)/" should be used, according to ECMA. + + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncToString): + +2010-01-08 Norbert Leser + + Reviewed by Darin Adler. + + RVCT compiler with "-Otime -O3" optimization tries to optimize out + inline new'ed pointers that are passed as arguments. + Proposed patch assigns new'ed pointer explicitly outside function call. + + https://bugs.webkit.org/show_bug.cgi?id=33084 + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + (OpaqueJSClassContextData::OpaqueJSClassContextData): + +2010-01-08 Gabor Loki + + Reviewed by Gavin Barraclough. + + Remove an unnecessary cacheFlush from ARM_TRADITIONAL JIT + https://bugs.webkit.org/show_bug.cgi?id=33203 + + * assembler/ARMAssembler.cpp: Remove obsolete linkBranch function. + (JSC::ARMAssembler::executableCopy): Inline a clean linkBranch code. + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::getLdrImmAddress): Use inline function. + (JSC::ARMAssembler::getLdrImmAddressOnPool): Ditto. + (JSC::ARMAssembler::patchPointerInternal): Remove an unnecessary cacheFlush. + (JSC::ARMAssembler::linkJump): Use patchPointerInternal instead of linkBranch. + (JSC::ARMAssembler::linkCall): Ditto. + (JSC::ARMAssembler::relinkCall): Ditto. + +2010-01-07 Gabor Loki + + Reviewed by Gavin Barraclough. + + Build fix for JSVALUE32 when ENABLE_JIT_OPTIMIZE* are disabled + https://bugs.webkit.org/show_bug.cgi?id=33311 + + Move compileGetDirectOffset function to common part of JSVALUE32 + + * jit/JITPropertyAccess.cpp: + (JSC::JIT::compileGetDirectOffset): + +2010-01-07 Laszlo Gombos + + Reviewed by Maciej Stachowiak. + + Allow call sites to determine if ASSERT_* and LOG_* macros are operational + https://bugs.webkit.org/show_bug.cgi?id=33020 + + * wtf/Assertions.h: Set ASSERT_MSG_DISABLED, FATAL_DISABLED, + ERROR_DISABLED, LOG_DISABLED to 1 if the compiler does not support + variadic macros. Refactor for better readibility. + +2010-01-07 Daniel Bates + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=32987 + + Added ENABLE_XHTMLMP flag. Disabled by default. + + * Configurations/FeatureDefines.xcconfig: + +2010-01-07 Laszlo Gombos + + Reviewed by Gavin Barraclough. + + [Symbian] Port ARM traditional JIT Trampolines to RVCT + https://bugs.webkit.org/show_bug.cgi?id=30552 + + Take the GCC implementation and mechanically convert + it to RVCT syntax. + + Use 'bx rX' instead of 'mov pc, rX' when it is available. + + Developed in cooperation with Iain Campbell and Gabor Loki. + + * JavaScriptCore.pri: Extra step to generate RVCT stubs. The + script generation intentionally executed all the time not just + for RVCT targets. + + * create_rvct_stubs: Added. Perl script to expand precompiler macros + for RVCT assembler - the template is defined in JITStubs.cpp. + + * jit/JITStubs.cpp: + (JSC::ctiTrampoline): + (JSC::ctiVMThrowTrampoline): + (JSC::ctiOpThrowNotCaught): + +2010-01-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fix a crash seen on the buildbots. + + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::init): Disable specific function tracking here, + instead of in WebCore, to ensure that the disabling happens before a + specific function can be registered. + +2010-01-07 Alexey Proskuryakov + + Mac build fix. + + * JavaScriptCore.exp: Export new JSGlobalData static data members. + +2010-01-07 Alexey Proskuryakov + + Reviewed by Geoffrey Garen. + + https://bugs.webkit.org/show_bug.cgi?id=33057 + REGRESSION(r49365): typeof(xhr.responseText) != "string" in Windows + + REGRESSION: WebKit fails to start PeaceKeeper benchmark + + Test: fast/js/webcore-string-comparison.html + + In r49365, some code was moved from JSString.cpp to JSString.h, and as a result, WebCore + got a way to directly instantiate JSStrings over DLL borders. Since vftable for JSString was + not exported, objects created from WebCore got a different vptr, and JavaScriptCore + optimizations that relied on vptr of all JSString objects being equal failed. + + * config.h: Added a JS_EXPORTCLASS macro for exporting classes. It's currently the same as + JS_EXPORTDATA, but it clearly needed a new name. + + * runtime/InitializeThreading.cpp: + (JSC::initializeThreadingOnce): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::storeVPtrs): + (JSC::JSGlobalData::JSGlobalData): + (JSC::JSGlobalData::createNonDefault): + (JSC::JSGlobalData::create): + (JSC::JSGlobalData::sharedInstance): + * runtime/JSGlobalData.h: + Store vptrs just once, no need to repeatedly pick and copy them. This makes it possible to + assert vptr correctness in object destructors (which don't have access to JSGlobalData, + and even Heap::heap(this) will fail for fake objects created from storeVPtrs()). + + * runtime/JSArray.cpp: (JSC::JSArray::~JSArray): Assert that vptr is what we expect it to be. + It's important to assert in destructor, because MSVC changes the vptr after constructor + is invoked. + * runtime/JSByteArray.cpp: (JSC::JSByteArray::~JSByteArray): Ditto. + * runtime/JSByteArray.h: Ditto. + * runtime/JSFunction.h: Ditto. + * runtime/JSFunction.cpp: (JSC::JSFunction::~JSFunction): Ditto. + + * runtime/JSCell.h: (JSC::JSCell::setVPtr): Added a method to substitute vptr for another + one. + + * runtime/JSString.h: Export JSString class together with its vftable, and tell other + libraries tp import it. This is needed on platforms that have a separate JavaScriptCore + dynamic library - and on Mac, we already did the export via JavaScriptCore.exp. + (JSC::JSString::~JSString): Assert tha vptr is what we expect it to be. + (JSC::fixupVPtr): Store a previously saved primary vftable pointer (do nothing if building + JavaScriptCore itself). + (JSC::jsSingleCharacterString): Call fixupVPtr in case this is call across DLL boundary. + (JSC::jsSingleCharacterSubstring): Ditto. + (JSC::jsNontrivialString): Ditto. + (JSC::jsString): Ditto. + (JSC::jsSubstring): Ditto. + (JSC::jsOwnedString): Ditto. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export the new static + JSGlobalData members that are used in WebCore via inline functions. + +2010-01-07 Geoffrey Garen + + Reviewed by Sam Weinig. + + Safari memory usage skyrockets using new Google AdWords interface + https://bugs.webkit.org/show_bug.cgi?id=33343 + + The memory use was caused by the global object creating too many structures + as it thrashed between different specific functions. + + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::changePrototypeTransition): + (JSC::Structure::despecifyFunctionTransition): + (JSC::Structure::addAnonymousSlotsTransition): + (JSC::Structure::getterSetterTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::despecifyAllFunctions): + * runtime/Structure.h: + (JSC::Structure::disableSpecificFunctionTracking): Track a thrash count + for specific functions. Disable specific function tracking once the + thrash count has been hit. + +2010-01-07 Csaba Osztrogonác + + Reviewed by Simon Hausmann. + + [Qt] Enable JIT in debug mode on win32 after r51141 fixed the crashes. + + * JavaScriptCore.pri: + +2010-01-07 Zoltan Horvath + + Reviewed by Holger Freyther. + + [Mac] Build fix when FAST_MALLOC_MATCH_VALIDATION=1 + https://bugs.webkit.org/show_bug.cgi?id=33312 + + Using of operator += cause compile error on Mac, so it is changed to + "= static_cast(old_ptr) + 1". + + * wtf/FastMalloc.cpp: + (WTF::TCMallocStats::realloc): + +2010-01-07 Zoltan Horvath + + Reviewed by Holger Freyther. + + [Qt] Build fix when FAST_MALLOC_MATCH_VALIDATION=1 + https://bugs.webkit.org/show_bug.cgi?id=33312 + + Remove pByte (committed in r42344 from #20422), because pByte doesn't + exist and it is unnecessary. + + * wtf/FastMalloc.cpp: + (WTF::TCMallocStats::realloc): + +2010-01-06 Gavin Barraclough + + QT build fix. + + * runtime/Identifier.cpp: + (JSC::createIdentifierTableSpecific): + +2010-01-06 Gavin Barraclough + + Windows build fix part I. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-06 Dan Bernstein + + Build fix + + * runtime/Identifier.cpp: + (JSC::createIdentifierTableSpecificCallback): + +2010-01-05 Gavin Barraclough + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=33236 + Remove m_identifierTable pointer from UString + + Currently every string holds a pointer so that during destruction, + if a string has been used as an identifier, it can remove itself + from the table. By instead accessing the identifierTable via a + thread specific tracking the table associated with the current + globaldata, we can save the memory cost of this pointer. + + * API/APIShims.h: + (JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock): + (JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock): + (JSC::APICallbackShim::APICallbackShim): + (JSC::APICallbackShim::~APICallbackShim): + + - change the API shims to track the identifierTable of the current JSGlobalData. + + * API/JSContextRef.cpp: + (JSContextGroupCreate): + + - update creation of JSGlobalData for API usage to use new create method. + - fix shim instanciation bug in JSGlobalContextCreateInGroup. + + * JavaScriptCore.exp: + * runtime/Completion.cpp: + (JSC::checkSyntax): + (JSC::evaluate): + + - add asserts to check the identifierTable is being tracked correctly. + + * runtime/Identifier.cpp: + (JSC::IdentifierTable::~IdentifierTable): + (JSC::IdentifierTable::add): + (JSC::Identifier::remove): + (JSC::Identifier::checkSameIdentifierTable): + (JSC::createIdentifierTableSpecificCallback): + (JSC::createIdentifierTableSpecific): + (JSC::createDefaultDataSpecific): + + - Use currentIdentifierTable() instead of UStringImpl::m_identifierTable. + - Define methods to access the thread specific identifier tables. + + * runtime/Identifier.h: + (JSC::ThreadIdentifierTableData::ThreadIdentifierTableData): + (JSC::defaultIdentifierTable): + (JSC::setDefaultIdentifierTable): + (JSC::currentIdentifierTable): + (JSC::setCurrentIdentifierTable): + (JSC::resetCurrentIdentifierTable): + + - Declare methods to access the thread specific identifier tables. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::createNonDefault): + (JSC::JSGlobalData::create): + (JSC::JSGlobalData::sharedInstance): + + - creation of JSGlobalData objects, other than for API usage, associate themselves with the current thread. + + * runtime/JSGlobalData.h: + * runtime/UStringImpl.cpp: + (JSC::UStringImpl::destroy): + + - destroy() method should be using isIdentifier(). + + * runtime/UStringImpl.h: + (JSC::UStringImpl::isIdentifier): + (JSC::UStringImpl::setIsIdentifier): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::UStringImpl): + + - replace m_identifierTable with a single m_isIdentifier bit. + + * wtf/StringHashFunctions.h: + (WTF::stringHash): + + - change string hash result from 32-bit to 31-bit, to free a bit in UStringImpl for m_isIdentifier. + +2009-12-25 Patrick Gansterer + + Reviewed by Eric Seidel. + + Buildfix for WinCE + style fixes. + https://bugs.webkit.org/show_bug.cgi?id=32939 + + * jsc.cpp: + (functionPrint): + (functionQuit): + (parseArguments): + (fillBufferWithContentsOfFile): + +2010-01-05 Patrick Gansterer + + Reviewed by Eric Seidel. + + WinCE buildfix after r52791 (renamed PLATFORM(WINCE) to OS(WINCE)). + https://bugs.webkit.org/show_bug.cgi?id=33205 + + * jit/ExecutableAllocator.h: + +2010-01-05 Patrick Gansterer + + Reviewed by Darin Adler. + + Added compiler error for unsupported platforms. + https://bugs.webkit.org/show_bug.cgi?id=33112 + + * jit/JITStubs.cpp: + +2010-01-05 Gabor Loki + + Reviewed by Maciej Stachowiak. + + Follow r52729 in ARMAssembler. + https://bugs.webkit.org/show_bug.cgi?id=33208 + + Use WTF_ARM_ARCH_AT_LEAST instead of ARM_ARCH_VERSION + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::encodeComplexImm): Move tmp declaration to ARMv7 + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::): + (JSC::ARMAssembler::bkpt): + +2010-01-05 Maciej Stachowiak + + Unreviewed build fix for Gtk+ + + Don't use // comments in Platform.h, at least some of them seem to make the version of GCC + used on the Gtk buildbot unhappy. + + * wtf/Platform.h: + +2010-01-04 Maciej Stachowiak + + Reviewed by Darin Fisher. + + Reorganize, document and rename OS() platform macros. + https://bugs.webkit.org/show_bug.cgi?id=33198 + + * wtf/Platform.h: Rename, reorganize and document OS() macros. + + Adapt to name changes. Also fixed a few incorrect OS checks. + + * API/JSContextRef.cpp: + * assembler/MacroAssemblerARM.cpp: + (JSC::isVFPPresent): + * assembler/MacroAssemblerX86Common.h: + * bytecode/SamplingTool.cpp: + * config.h: + * interpreter/RegisterFile.cpp: + (JSC::RegisterFile::~RegisterFile): + * interpreter/RegisterFile.h: + (JSC::RegisterFile::RegisterFile): + (JSC::RegisterFile::grow): + * jit/ExecutableAllocator.h: + * jit/ExecutableAllocatorFixedVMPool.cpp: + * jit/ExecutableAllocatorPosix.cpp: + * jit/ExecutableAllocatorSymbian.cpp: + * jit/ExecutableAllocatorWin.cpp: + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITStubs.cpp: + * jsc.cpp: + (main): + * parser/Grammar.y: + * profiler/ProfileNode.cpp: + (JSC::getCount): + * runtime/Collector.cpp: + (JSC::Heap::Heap): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlockPtr): + (JSC::currentThreadStackBase): + (JSC::getCurrentPlatformThread): + (JSC::suspendThread): + (JSC::resumeThread): + (JSC::getPlatformThreadRegisters): + (JSC::otherThreadStackPointer): + * runtime/Collector.h: + * runtime/DateConstructor.cpp: + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + * runtime/InitializeThreading.cpp: + (JSC::initializeThreading): + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackPosix.cpp: + * runtime/MarkStackSymbian.cpp: + * runtime/MarkStackWin.cpp: + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncLastIndexOf): + * runtime/TimeoutChecker.cpp: + (JSC::getCPUTime): + * runtime/UString.cpp: + (JSC::UString::from): + * wtf/Assertions.cpp: + * wtf/Assertions.h: + * wtf/CurrentTime.cpp: + (WTF::lowResUTCTime): + * wtf/CurrentTime.h: + (WTF::getLocalTime): + * wtf/DateMath.cpp: + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_ThreadCache::InitModule): + (WTF::TCMallocStats::): + * wtf/FastMalloc.h: + * wtf/MathExtras.h: + * wtf/RandomNumber.cpp: + (WTF::randomNumber): + * wtf/RandomNumberSeed.h: + (WTF::initializeRandomNumberGenerator): + * wtf/StringExtras.h: + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Unlock): + (TCMalloc_SlowLock): + * wtf/TCSystemAlloc.cpp: + * wtf/ThreadSpecific.h: + (WTF::::destroy): + * wtf/Threading.h: + * wtf/ThreadingPthreads.cpp: + (WTF::initializeThreading): + (WTF::isMainThread): + * wtf/ThreadingWin.cpp: + (WTF::wtfThreadEntryPoint): + (WTF::createThreadInternal): + * wtf/VMTags.h: + * wtf/unicode/icu/CollatorICU.cpp: + (WTF::Collator::userDefault): + * wtf/win/MainThreadWin.cpp: + (WTF::initializeMainThreadPlatform): + +2010-01-04 Gustavo Noronha Silva + + Add missing files to the build system - make distcheck build fix. + + * GNUmakefile.am: + +2010-01-04 Gavin Barraclough + + Reviewed by Sam Weinig, additional coding by Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=33163 + Add string hashing functions to WTF. + Use WTF's string hashing functions from UStringImpl. + + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.gypi: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/UStringImpl.cpp: + * runtime/UStringImpl.h: + (JSC::UStringImpl::computeHash): + * wtf/HashFunctions.h: + * wtf/StringHashFunctions.h: Added. + (WTF::stringHash): + +2010-01-04 Dmitry Titov + + Not reviewed, attempt to fix ARM bulid. + + * wtf/Platform.h: + +2010-01-04 Gavin Barraclough + + Rubber stamped by Geoff Garen. + + Add an 'isIdentifier' to UStringImpl, use this where appropriate + (where previously 'identifierTable' was being tested). + + * API/JSClassRef.cpp: + (OpaqueJSClass::~OpaqueJSClass): + (OpaqueJSClassContextData::OpaqueJSClassContextData): + * runtime/Identifier.cpp: + (JSC::Identifier::addSlowCase): + * runtime/Identifier.h: + (JSC::Identifier::add): + * runtime/PropertyNameArray.cpp: + (JSC::PropertyNameArray::add): + * runtime/UStringImpl.h: + (JSC::UStringImpl::isIdentifier): + +2010-01-04 Gavin Barraclough + + Reviewed by Sam "Shimmey Shimmey" Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=33158 + Refactor JSC API entry/exit to use RAII instead of copy/pasting code. + Make it easier to change set of actions taken when passing across the API boundary. + + * API/APIShims.h: Added. + (JSC::APIEntryShimWithoutLock::APIEntryShimWithoutLock): + (JSC::APIEntryShimWithoutLock::~APIEntryShimWithoutLock): + (JSC::APIEntryShim::APIEntryShim): + (JSC::APICallbackShim::APICallbackShim): + (JSC::APICallbackShim::~APICallbackShim): + * API/JSBase.cpp: + (JSEvaluateScript): + (JSCheckScriptSyntax): + (JSGarbageCollect): + (JSReportExtraMemoryCost): + * API/JSCallbackConstructor.cpp: + (JSC::constructJSCallback): + * API/JSCallbackFunction.cpp: + (JSC::JSCallbackFunction::call): + * API/JSCallbackObjectFunctions.h: + (JSC::::init): + (JSC::::getOwnPropertySlot): + (JSC::::put): + (JSC::::deleteProperty): + (JSC::::construct): + (JSC::::hasInstance): + (JSC::::call): + (JSC::::getOwnPropertyNames): + (JSC::::toNumber): + (JSC::::toString): + (JSC::::staticValueGetter): + (JSC::::callbackGetter): + * API/JSContextRef.cpp: + * API/JSObjectRef.cpp: + (JSObjectMake): + (JSObjectMakeFunctionWithCallback): + (JSObjectMakeConstructor): + (JSObjectMakeFunction): + (JSObjectMakeArray): + (JSObjectMakeDate): + (JSObjectMakeError): + (JSObjectMakeRegExp): + (JSObjectGetPrototype): + (JSObjectSetPrototype): + (JSObjectHasProperty): + (JSObjectGetProperty): + (JSObjectSetProperty): + (JSObjectGetPropertyAtIndex): + (JSObjectSetPropertyAtIndex): + (JSObjectDeleteProperty): + (JSObjectCallAsFunction): + (JSObjectCallAsConstructor): + (JSObjectCopyPropertyNames): + (JSPropertyNameArrayRelease): + (JSPropertyNameAccumulatorAddName): + * API/JSValueRef.cpp: + (JSValueGetType): + (JSValueIsUndefined): + (JSValueIsNull): + (JSValueIsBoolean): + (JSValueIsNumber): + (JSValueIsString): + (JSValueIsObject): + (JSValueIsObjectOfClass): + (JSValueIsEqual): + (JSValueIsStrictEqual): + (JSValueIsInstanceOfConstructor): + (JSValueMakeUndefined): + (JSValueMakeNull): + (JSValueMakeBoolean): + (JSValueMakeNumber): + (JSValueMakeString): + (JSValueToBoolean): + (JSValueToNumber): + (JSValueToStringCopy): + (JSValueToObject): + (JSValueProtect): + (JSValueUnprotect): + * JavaScriptCore.xcodeproj/project.pbxproj: + +2010-01-04 Dan Bernstein + + Reviewed by Ada Chan and Mark Rowe. + + Updated copyright string + + * Info.plist: + * JavaScriptCore.vcproj/JavaScriptCore.resources/Info.plist: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: + +2010-01-04 Adam Roben + + No review, rolling out r52741. + http://trac.webkit.org/changeset/52741 + https://bugs.webkit.org/show_bug.cgi?id=33056 + + * wtf/AlwaysInline.h: + +2010-01-04 Patrick Gansterer + + Reviewed by Darin Adler. + + Add cacheFlush support for WinCE + https://bugs.webkit.org/show_bug.cgi?id=33110 + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2010-01-04 Patrick Gansterer + + Reviewed by Adam Roben. + + Implement NO_RETURN for COMPILER(MSVC). + https://bugs.webkit.org/show_bug.cgi?id=33056 + + * wtf/AlwaysInline.h: + +2010-01-04 Maciej Stachowiak + + Reviewed by Simon Hausmann. + + Fix some PLATFORM(*_ENDIAN) uses to CPU() + https://bugs.webkit.org/show_bug.cgi?id=33148 + + * runtime/JSCell.cpp: + (JSC::): + * runtime/JSValue.h: + (JSC::JSValue::): + +2010-01-04 Maciej Stachowiak + + Reviewed by Adam Barth. + + Document CPU() macros in comments. + https://bugs.webkit.org/show_bug.cgi?id=33147 + + * wtf/Platform.h: + +2010-01-04 Maciej Stachowiak + + Reviewed by Adam Barth. + + Reorganize, document and rename CPU() platform macros. + https://bugs.webkit.org/show_bug.cgi?id=33145 + ExecutableAllocatorSymbian appears to have buggy ARM version check + https://bugs.webkit.org/show_bug.cgi?id=33138 + + * wtf/Platform.h: + Rename all macros related to detection of particular CPUs or + classes of CPUs to CPU(), reorganize and document them. + + All remaining changes are adapting to the renames, plus fixing the + second bug cited above. + + * assembler/ARMAssembler.cpp: + * assembler/ARMAssembler.h: + * assembler/ARMv7Assembler.h: + * assembler/AbstractMacroAssembler.h: + (JSC::AbstractMacroAssembler::Imm32::Imm32): + * assembler/MacroAssembler.h: + * assembler/MacroAssemblerARM.cpp: + * assembler/MacroAssemblerARM.h: + * assembler/MacroAssemblerCodeRef.h: + (JSC::MacroAssemblerCodePtr::MacroAssemblerCodePtr): + * assembler/MacroAssemblerX86.h: + * assembler/MacroAssemblerX86Common.h: + * assembler/MacroAssemblerX86_64.h: + * assembler/X86Assembler.h: + (JSC::X86Registers::): + (JSC::X86Assembler::): + (JSC::X86Assembler::movl_mEAX): + (JSC::X86Assembler::movl_EAXm): + (JSC::X86Assembler::repatchLoadPtrToLEA): + (JSC::X86Assembler::X86InstructionFormatter::memoryModRM): + * jit/ExecutableAllocator.h: + * jit/ExecutableAllocatorFixedVMPool.cpp: + * jit/ExecutableAllocatorPosix.cpp: + * jit/ExecutableAllocatorSymbian.cpp: + (JSC::ExecutableAllocator::intializePageSize): + * jit/JIT.cpp: + * jit/JIT.h: + * jit/JITArithmetic.cpp: + * jit/JITInlineMethods.h: + (JSC::JIT::beginUninterruptedSequence): + (JSC::JIT::restoreArgumentReferenceForTrampoline): + (JSC::JIT::emitCount): + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::privateCompileGetByIdProto): + (JSC::JIT::privateCompileGetByIdProtoList): + (JSC::JIT::privateCompileGetByIdChainList): + (JSC::JIT::privateCompileGetByIdChain): + * jit/JITStubs.cpp: + (JSC::JITThunks::JITThunks): + * jit/JITStubs.h: + * runtime/Collector.cpp: + (JSC::currentThreadStackBase): + (JSC::getPlatformThreadRegisters): + (JSC::otherThreadStackPointer): + * wrec/WREC.h: + * wrec/WRECGenerator.cpp: + (JSC::WREC::Generator::generateEnter): + (JSC::WREC::Generator::generateReturnSuccess): + (JSC::WREC::Generator::generateReturnFailure): + * wrec/WRECGenerator.h: + * wtf/FastMalloc.cpp: + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::Lock): + (TCMalloc_SpinLock::Unlock): + (TCMalloc_SlowLock): + * wtf/Threading.h: + * wtf/dtoa.cpp: + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateEnter): + (JSC::Yarr::RegexGenerator::generateReturn): + * yarr/RegexJIT.h: + +2010-01-04 Maciej Stachowiak + + Reviewed by Adam Barth. + + Clean up COMPILER macros and remove unused ones. + https://bugs.webkit.org/show_bug.cgi?id=33132 + + Removed values are COMPILER(BORLAND) and COMPILER(CYGWIN) - they were + not used anywhere. + + * wtf/Platform.h: + +2010-01-03 Maciej Stachowiak + + Reviewed by Eric Seidel. + + Update wtf/Platform.h to document the new system for porting macros. + https://bugs.webkit.org/show_bug.cgi?id=33130 + + * wtf/Platform.h: + +2009-12-29 Laszlo Gombos + + Reviewed by Maciej Stachowiak. + + PLATFORM(CAIRO) should be defined by WIN_CAIRO define + https://bugs.webkit.org/show_bug.cgi?id=22250 + + * wtf/Platform.h: Define WTF_PLATFORM_CAIRO for GTK port only + For the WinCairo port WTF_PLATFORM_CAIRO is already defined in config.h + +2009-12-28 Shu Chang + + Reviewed by Laszlo Gombos. + + [Qt] Delete ThreadPrivate instance after it is finished. + https://bugs.webkit.org/show_bug.cgi?id=32614 + + * wtf/qt/ThreadingQt.cpp: + (WTF::ThreadMonitor::instance): + (WTF::ThreadMonitor::threadFinished): + (WTF::createThreadInternal): + (WTF::detachThread): + +2009-12-28 Patrick Gansterer + + Reviewed by Maciej Stachowiak. + + Cleanup of #define JS_EXPORT. + + * API/JSBase.h: + +2009-12-27 Patrick Gansterer + + Reviewed by Adam Barth. + + WinCE buildfix (HWND_MESSAGE isn't supported there) + + * wtf/win/MainThreadWin.cpp: + (WTF::initializeMainThreadPlatform): + +2009-12-27 Patrick Gansterer + + Reviewed by Adam Barth. + + Added a file with WinMain function to link agains in WinCE. + + * os-win32/WinMain.cpp: Added. + (convertToUtf8): + (WinMain): + +2009-12-24 Laszlo Gombos + + Unreviewed; revert of r52550. + + The change regressed the following LayoutTests for QtWebKit. + + fast/workers/worker-call.html -> crashed + fast/workers/worker-close.html -> crashed + + * wtf/qt/ThreadingQt.cpp: + (WTF::waitForThreadCompletion): + (WTF::detachThread): + +2009-12-24 Shu Chang + + Reviewed by Laszlo Gombos. + + [Qt] Fix memory leak by deleting instance of ThreadPrivate + in function waitForThreadCompletion(), synchronously, or in + detachThread(), asynchronously. + https://bugs.webkit.org/show_bug.cgi?id=32614 + + * wtf/qt/ThreadingQt.cpp: + (WTF::waitForThreadCompletion): + (WTF::detachThread): + +2009-12-23 Kwang Yul Seo + + Reviewed by Laszlo Gombos. + + Include stddef.h for ptrdiff_t + https://bugs.webkit.org/show_bug.cgi?id=32891 + + ptrdiff_t is typedef-ed in stddef.h. + Include stddef.h in jit/ExecutableAllocator.h. + + * jit/ExecutableAllocator.h: + +2009-12-23 Patrick Gansterer + + Reviewed by Eric Seidel. + + Buildfix after r47092. + + * wtf/wince/MemoryManager.cpp: + (WTF::tryFastMalloc): + (WTF::tryFastZeroedMalloc): + (WTF::tryFastCalloc): + (WTF::tryFastRealloc): + +2009-12-23 Kent Tamura + + Reviewed by Darin Adler. + + HTMLInputElement::valueAsDate getter support. + https://bugs.webkit.org/show_bug.cgi?id=32876 + + Expose dateToDaysFrom1970(). + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * wtf/DateMath.cpp: + (WTF::dateToDaysFrom1970): + * wtf/DateMath.h: + +2009-12-22 Darin Adler + + Reviewed by Mark Rowe. + + Turn off datagrid by default, at least for all platforms Apple ships. + The datagrid implementation isn't ready for general web use yet. + + * Configurations/FeatureDefines.xcconfig: Turn off datagrid by default. + +2009-12-22 Steve Block + + Reviewed by David Levin. + + Updates Android's scheduleDispatchFunctionsOnMainThread() to use new + AndroidThreading class, rather than using JavaSharedClient directly. + This fixes the current layering violation. + https://bugs.webkit.org/show_bug.cgi?id=32651 + + The pattern is copied from Chromium, which uses the ChromiumThreading + class. This patch also fixes the style in ChromiumThreading.h. + + * wtf/android/AndroidThreading.h: Added. Declares AndroidThreading. + * wtf/android/MainThreadAndroid.cpp: Modified + (WTF::scheduleDispatchFunctionsOnMainThread): Uses AndroidThreading. + * wtf/chromium/ChromiumThreading.h: Modified. Fixes style. + +2009-12-22 Gavin Barraclough + + Reviewed by Sam Weinig. + + Fix a couple of problems with UntypedPtrAndBitfield. + + Add a m_leaksPtr to reduce false positives from leaks in debug builds + (this isn't perfect because we'd like a solution for release builds, + but this is now at least as good as a PtrAndFlags would be). + + Switch SmallStringsto use a regular string for the base, rather than + a static one. UntypedPtrAndBitfield assumes all strings are at least + 8 byte aligned; this migt not be true of static strings. Shared buffers + are heap allocated, as are all UStringImpls other than static strings. + Static strings cannot end up being the owner string of substrings, + since the only static strings are length 0. + + * runtime/SmallStrings.cpp: + (JSC::SmallStringsStorage::SmallStringsStorage): + * runtime/UStringImpl.h: + (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield): + (JSC::UStringImpl::UStringImpl): + +2009-12-22 Kwang Yul Seo + + Reviewed by Darin Adler. + + RVCT (__ARMCC_VERSION < 400000) does not provide strcasecmp and strncasecmp + https://bugs.webkit.org/show_bug.cgi?id=32857 + + Add implementation of strcasecmp and strncasecmp for RVCT < 4.0 + because earlier versions of RVCT 4.0 does not provide these functions. + + * wtf/StringExtras.cpp: Added. + (strcasecmp): + (strncasecmp): + * wtf/StringExtras.h: + +2009-12-22 Kwang Yul Seo + + Reviewed by Darin Adler. + + Define ALWAYS_INLINE and WTF_PRIVATE_INLINE to __forceinline for RVCT + https://bugs.webkit.org/show_bug.cgi?id=32853 + + Use __forceinline forces RVCT to compile a C or C++ function + inline. The compiler attempts to inline the function, regardless of + the characteristics of the function. + + * wtf/AlwaysInline.h: + * wtf/FastMalloc.h: + +2009-12-21 Simon Hausmann + + Prospective GTK build fix: Add UStringImpl.cpp/h to the build. + + * GNUmakefile.am: + +2009-12-21 Simon Hausmann + + Fix the Qt build, add UStringImpl.cpp to the build. + + * JavaScriptCore.pri: + +2009-12-21 Gavin Barraclough + + Windows Build fix part 5. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + +2009-12-21 Gavin Barraclough + + Reviewed by NOBODY (build fix). + Fix breakage of world introduced in build fix to r52463. + + * runtime/UStringImpl.h: + +2009-12-21 Gavin Barraclough + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=32831 + Replace UString::Rep implementation, following introduction of ropes to JSC. + + * Remove redundant overcapacity mechanisms. + * Reduce memory cost of Rep's. + * Add an inline storage mechanism akin to that in WebCore's StringImpl. + + ~1% Sunspider progression. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): + * runtime/SmallStrings.cpp: + (JSC::SmallStringsStorage::SmallStringsStorage): + * runtime/UString.cpp: + (JSC::initializeUString): + (JSC::createRep): + (JSC::UString::createFromUTF8): + (JSC::UString::createUninitialized): + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + (JSC::UString::ascii): + (JSC::UString::operator=): + (JSC::UString::toStrictUInt32): + (JSC::equal): + * runtime/UString.h: + (JSC::UString::isEmpty): + (JSC::UString::cost): + (JSC::makeString): + * runtime/UStringImpl.cpp: Added. + (JSC::UStringImpl::baseSharedBuffer): + (JSC::UStringImpl::sharedBuffer): + (JSC::UStringImpl::destroy): + (JSC::UStringImpl::computeHash): + * runtime/UStringImpl.h: Added. + (JSC::UntypedPtrAndBitfield::UntypedPtrAndBitfield): + (JSC::UntypedPtrAndBitfield::asPtr): + (JSC::UntypedPtrAndBitfield::operator&=): + (JSC::UntypedPtrAndBitfield::operator|=): + (JSC::UntypedPtrAndBitfield::operator&): + (JSC::UStringImpl::create): + (JSC::UStringImpl::createCopying): + (JSC::UStringImpl::createUninitialized): + (JSC::UStringImpl::data): + (JSC::UStringImpl::size): + (JSC::UStringImpl::cost): + (JSC::UStringImpl::hash): + (JSC::UStringImpl::computedHash): + (JSC::UStringImpl::setHash): + (JSC::UStringImpl::identifierTable): + (JSC::UStringImpl::setIdentifierTable): + (JSC::UStringImpl::ref): + (JSC::UStringImpl::deref): + (JSC::UStringImpl::allocChars): + (JSC::UStringImpl::copyChars): + (JSC::UStringImpl::computeHash): + (JSC::UStringImpl::null): + (JSC::UStringImpl::empty): + (JSC::UStringImpl::checkConsistency): + (JSC::UStringImpl::): + (JSC::UStringImpl::UStringImpl): + (JSC::UStringImpl::operator new): + (JSC::UStringImpl::bufferOwnerString): + (JSC::UStringImpl::bufferOwnership): + (JSC::UStringImpl::isStatic): + +2009-12-18 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + Move some build decisions from Qt build system into source files + https://bugs.webkit.org/show_bug.cgi?id=31956 + + * JavaScriptCore.pri: Compile files unconditionally + * jit/ExecutableAllocatorPosix.cpp: Guard with PLATFORM(UNIX) && !PLATFORM(SYMBIAN) + * jit/ExecutableAllocatorWin.cpp: Guard with PLATFORM(WIN_OS) + * runtime/MarkStackPosix.cpp: Guard with PLATFORM(UNIX) && !PLATFORM(SYMBIAN) + * runtime/MarkStackSymbian.cpp: Guard with PLATFORM(SYMBIAN) + * runtime/MarkStackWin.cpp: Guard with PLATFORM(WIN_OS) + * wtf/Platform.h: Guard ENABLE_JSC_MULTIPLE_THREADS with ENABLE_SINGLE_THREADED for the Qt port + * wtf/ThreadingNone.cpp: Guard with ENABLE(SINGLE_THREADED) + * wtf/qt/ThreadingQt.cpp: Guard with !ENABLE(SINGLE_THREADED) + +2009-12-18 Gavin Barraclough + + Reviewed by Sam Weinig. + + Add createNonCopying method to UString to make replace constructor passed bool, + to make behaviour more explicit. Add createFromUTF8 to UString (wrapping method + on UString::Rep), since other cases of transliteration (e.g. from ascii) are + performed in UString constructors. Add/use setHash & size() accessors on Rep, + rather than accessing _hash/len directly. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + * API/OpaqueJSString.cpp: + (OpaqueJSString::ustring): + * JavaScriptCore.exp: + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): + * runtime/Identifier.cpp: + (JSC::Identifier::equal): + (JSC::CStringTranslator::translate): + (JSC::UCharBufferTranslator::translate): + (JSC::Identifier::addSlowCase): + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): + * runtime/JSString.h: + (JSC::JSString::Rope::Fiber::refAndGetLength): + (JSC::JSString::Rope::append): + * runtime/StringBuilder.h: + (JSC::StringBuilder::release): + * runtime/StringConstructor.cpp: + (JSC::stringFromCharCodeSlowCase): + * runtime/StringPrototype.cpp: + (JSC::substituteBackreferencesSlow): + (JSC::stringProtoFuncToLowerCase): + (JSC::stringProtoFuncToUpperCase): + (JSC::stringProtoFuncFontsize): + (JSC::stringProtoFuncLink): + * runtime/UString.cpp: + (JSC::UString::UString): + (JSC::UString::createNonCopying): + (JSC::UString::createFromUTF8): + * runtime/UString.h: + (JSC::UString::Rep::setHash): + (JSC::UString::~UString): + (JSC::makeString): + +2009-12-18 Geoffrey Garen + + Reviewed by Cameron Zwarich and Gavin Barraclough. + + Changed Register constructors to assignment operators, to streamline + moving values into registers. (In theory, there's no difference between + the two, since the constructor should just inline away, but there seems + to be a big difference in the addled mind of the GCC optimizer.) + + In the interpreter, this is a 3.5% SunSpider speedup and a 1K-2K + reduction in stack usage per privateExecute stack frame. + + * interpreter/CallFrame.h: + (JSC::ExecState::setCalleeArguments): + (JSC::ExecState::setCallerFrame): + (JSC::ExecState::setScopeChain): + (JSC::ExecState::init): + (JSC::ExecState::setArgumentCount): + (JSC::ExecState::setCallee): + (JSC::ExecState::setCodeBlock): Added a little bit of casting so these + functions could use the new Register assignment operators. + + * interpreter/Register.h: + (JSC::Register::withInt): + (JSC::Register::Register): + (JSC::Register::operator=): Swapped in assignment operators for constructors. + +2009-12-18 Yongjun Zhang + + Reviewed by Simon Hausmann. + + https://bugs.webkit.org/show_bug.cgi?id=32713 + [Qt] make wtf/Assertions.h compile in winscw compiler. + + Add string arg before ellipsis to help winscw compiler resolve variadic + macro definitions in wtf/Assertions.h. + + * wtf/Assertions.h: + +2009-12-18 Geoffrey Garen + + Reviewed by Adam Roben. + + Fixed intermittent failure seen on Windows buildbot, and in other JSC + API clients. + + Added a WeakGCPtr class and changed OpaqueJSClass::cachedPrototype to + use it, to avoid vending a stale object as a prototype. + + * API/JSClassRef.cpp: + (OpaqueJSClassContextData::OpaqueJSClassContextData): + (OpaqueJSClass::prototype): + * API/JSClassRef.h: Use WeakGCPtr. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/WeakGCPtr.h: Added. + (JSC::WeakGCPtr::WeakGCPtr): + (JSC::WeakGCPtr::get): + (JSC::WeakGCPtr::clear): + (JSC::WeakGCPtr::operator*): + (JSC::WeakGCPtr::operator->): + (JSC::WeakGCPtr::operator!): + (JSC::WeakGCPtr::operator bool): + (JSC::WeakGCPtr::operator UnspecifiedBoolType): + (JSC::WeakGCPtr::assign): + (JSC::::operator): + (JSC::operator==): + (JSC::operator!=): + (JSC::static_pointer_cast): + (JSC::const_pointer_cast): + (JSC::getPtr): Added WeakGCPtr to the project. + +2009-12-18 Gavin Barraclough + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=32720 + + * JavaScriptCore.exp: + - Remove exports for UString::append + * JavaScriptCore.xcodeproj/project.pbxproj: + - Make StringBuilder a private header (was project). + +2009-12-18 Martin Robinson + + Reviewed by Gustavo Noronha Silva. + + [GTK] GRefPtr does not take a reference when assigned a raw pointer + https://bugs.webkit.org/show_bug.cgi?id=32709 + + Ensure that when assigning a raw pointer to a GRefPtr, the reference + count is incremented. Also remove the GRefPtr conversion overload as + GRefPtr types have necessarily incompatible reference counting. + + * wtf/gtk/GRefPtr.h: + (WTF::GRefPtr::operator=): + +2009-12-18 Simon Hausmann + + Reviewed by Tor Arne Vestbø. + + [Qt] Clean up the qmake build system to distinguish between trunk builds and package builds + + https://bugs.webkit.org/show_bug.cgi?id=32716 + + * pcre/pcre.pri: Use standalone_package instead of QTDIR_build + +2009-12-18 Martin Robinson + + Reviewed by Gustavo Noronha Silva. + + [GTK] Compile warning from line 29 of GRefPtr.cpp + https://bugs.webkit.org/show_bug.cgi?id=32703 + + Fix memory leak and compiler warning in GRefPtr GHashTable template + specialization. + + * wtf/gtk/GRefPtr.cpp: + (WTF::refGPtr): + +2009-12-17 Sam Weinig + + Reviewed by Mark Rowe. + + Add BUILDING_ON_SNOW_LEOPARD and TARGETING_SNOW_LEOPARD #defines. + + * wtf/Platform.h: + +2009-12-17 Adam Roben + + Sync JavaScriptCore.vcproj with JavaScriptCore.xcodeproj and the + source tree + + Fixes . + + Reviewed by Ada Chan. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Moved + around files and filters so that the structure matches + JavaScriptCore.xcodeproj and the source tree. A few headers that were + previously omitted have been added, as well as JSZombie.{cpp,h}. + +2009-12-17 Adam Roben + + Remove HeavyProfile and TreeProfile completely + + These were mostly removed in r42808, but the empty files were left in + place. + + Fixes . + + Reviewed by John Sullivan. + + * Android.mk: + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCoreSources.bkl: + Removed HeavyProfile/TreeProfile source files. + + * profiler/HeavyProfile.cpp: Removed. + * profiler/HeavyProfile.h: Removed. + * profiler/TreeProfile.cpp: Removed. + * profiler/TreeProfile.h: Removed. + +2009-12-17 Martin Robinson + + Reviewed by Gustavo Noronha Silva. + + [GTK] WebKit GTK needs a wrapper for ref counted glib/gobject structs + https://bugs.webkit.org/show_bug.cgi?id=21599 + + Implement GRefPtr, a smart pointer for reference counted GObject types. + + * GNUmakefile.am: + * wtf/gtk/GOwnPtr.cpp: + (WTF::GDir): + * wtf/gtk/GRefPtr.h: Added. + (WTF::): + (WTF::GRefPtr::GRefPtr): + (WTF::GRefPtr::~GRefPtr): + (WTF::GRefPtr::clear): + (WTF::GRefPtr::get): + (WTF::GRefPtr::operator*): + (WTF::GRefPtr::operator->): + (WTF::GRefPtr::operator!): + (WTF::GRefPtr::operator UnspecifiedBoolType): + (WTF::GRefPtr::hashTableDeletedValue): + (WTF::::operator): + (WTF::::swap): + (WTF::swap): + (WTF::operator==): + (WTF::operator!=): + (WTF::static_pointer_cast): + (WTF::const_pointer_cast): + (WTF::getPtr): + (WTF::adoptGRef): + (WTF::refGPtr): + (WTF::derefGPtr): + +2009-12-17 Gustavo Noronha Silva + + Unreviewed. Build fixes for make distcheck. + + * GNUmakefile.am: + +2009-12-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed Interpreter::privateExecute macro generates + bloated code + + This patch cuts Interpreter stack use by about a third. + + * bytecode/Opcode.h: Changed Opcode to const void* to work with the + const static initiliazation we want to do in Interpreter::privateExecute. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::Interpreter): Moved hashtable initialization here to + avoid polluting Interpreter::privateExecute's stack, and changed it from a + series of add() calls to one add() call in a loop, to cut down on code size. + + (JSC::Interpreter::privateExecute): Changed a series of label computations + to a copy of a compile-time constant array to cut down on code size. + +2009-12-16 Mark Rowe + + Build fix. Disable debug variants of WebKit frameworks. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-12-15 Geoffrey Garen + + Reviewed by Sam "r=me" Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=32498 + + REGRESSION(r51978-r52039): AJAX "Mark This Forum Read" function no longer + works + + Fixed a tyop. + + * runtime/Operations.h: + (JSC::jsAdd): Use the '&&' operator, not the ',' operator. + +2009-12-15 Geoffrey Garen + + Try to fix the windows build: don't export this inlined function. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-12-15 Geoffrey Garen + + Reviewed by Beth Dakin. + + Inlined JSCell's operator new. + + 3.7% speedup on bench-allocate-nonretained.js. + + * JavaScriptCore.exp: + * runtime/JSCell.cpp: + * runtime/JSCell.h: + (JSC::JSCell::operator new): + +2009-12-15 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Removed the number heap, replacing it with a one-item free list for + numbers, taking advantage of the fact that two number cells fit inside + the space for one regular cell, and number cells don't require destruction. + + SunSpider says 1.6% faster in JSVALUE32 mode (the only mode that + heap-allocates numbers). + + SunSpider says 1.1% faster in JSVALUE32_64 mode. v8 says 0.8% faster + in JSVALUE32_64 mode. 10% speedup on bench-alloc-nonretained.js. 6% + speedup on bench-alloc-retained.js. + + There's a lot of formulaic change in this patch, but not much substance. + + * JavaScriptCore.exp: + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + * runtime/Collector.cpp: + (JSC::Heap::Heap): + (JSC::Heap::destroy): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlock): + (JSC::Heap::freeBlockPtr): + (JSC::Heap::freeBlocks): + (JSC::Heap::recordExtraCost): + (JSC::Heap::allocate): + (JSC::Heap::resizeBlocks): + (JSC::Heap::growBlocks): + (JSC::Heap::shrinkBlocks): + (JSC::Heap::markConservatively): + (JSC::Heap::clearMarkBits): + (JSC::Heap::markedCells): + (JSC::Heap::sweep): + (JSC::Heap::markRoots): + (JSC::Heap::objectCount): + (JSC::Heap::addToStatistics): + (JSC::Heap::statistics): + (JSC::Heap::isBusy): + (JSC::Heap::reset): + (JSC::Heap::collectAllGarbage): + (JSC::Heap::primaryHeapBegin): + (JSC::Heap::primaryHeapEnd): + * runtime/Collector.h: + (JSC::): Removed all code pertaining to the number heap, and changed all + heap template functions and classes to non-template functions and classes. + + (JSC::Heap::allocateNumber): A new optimization to replace the number + heap: allocate half-sized number cells in pairs, returning the first + cell and caching the second cell for the next allocation. + + * runtime/CollectorHeapIterator.h: + (JSC::LiveObjectIterator::LiveObjectIterator): + (JSC::LiveObjectIterator::operator++): + (JSC::DeadObjectIterator::DeadObjectIterator): + (JSC::DeadObjectIterator::operator++): + (JSC::ObjectIterator::ObjectIterator): + (JSC::ObjectIterator::operator++): + * runtime/JSCell.h: + (JSC::JSCell::isNumber): Removed all code pertaining to the number heap, + and changed all heap template functions and classes to non-template functions + and classes. + +2009-12-15 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for WeakGCMap class + https://bugs.webkit.org/show_bug.cgi?id=32547 + + Inherits WeakGCMap from FastAllocBase because it is instantiated by + 'new' at: WebCore/dom/Document.cpp:512. + + * runtime/WeakGCMap.h: + +2009-12-15 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for dtoa's P5Node struct + https://bugs.webkit.org/show_bug.cgi?id=32544 + + Inherits P5Node struct from Noncopyable because it is instantiated by + 'new' at wtf/dtoa.cpp:588 and don't need to be copyable. + + * wtf/dtoa.cpp: + +2009-12-14 Geoffrey Garen + + Reviewed by Simon Fraser. + + https://bugs.webkit.org/show_bug.cgi?id=32524 + REGRESSION(52084): fast/dom/prototypes.html failing two CSS tests + + * wtf/StdLibExtras.h: + (WTF::bitCount): The original patch put the parentheses in the wrong + place, completely changing the calculation and making it almost always + wrong. Moved the parentheses around the '+' operation, like the original + compiler warning suggested. + +2009-12-14 Gabor Loki + + Unreviewed trivial buildfix. + + Fix crosses initialization of usedPrimaryBlocks for JSValue32 + + * runtime/Collector.cpp: + (JSC::Heap::markConservatively): + +2009-12-14 Csaba Osztrogonác + + Reviewed by Simon Hausmann. + + GCC 4.3.x warning fixed. Suggested parantheses added. + warning: ../../../JavaScriptCore/wtf/StdLibExtras.h:77: warning: suggest parentheses around + or - in operand of & + + * wtf/StdLibExtras.h: + (WTF::bitCount): + +2009-12-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Changed GC from mark-sweep to mark-allocate. + + Added WeakGCMap to keep WebCore blissfully ignorant about objects that + have become garbage but haven't run their destructors yet. + + 1% SunSpider speedup. + 7.6% v8 speedup (37% splay speedup). + 17% speedup on bench-alloc-nonretained.js. + 18% speedup on bench-alloc-retained.js. + + * API/JSBase.cpp: + (JSGarbageCollect): + * API/JSContextRef.cpp: + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: Updated for renames and new + files. + + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): Updated to use the Collector + iterator abstraction. + + * jsc.cpp: + (functionGC): Updated for rename. + + * runtime/Collector.cpp: Slightly reduced the number of allocations per + collection, so that small workloads only allocate on collector block, + rather than two. + + (JSC::Heap::Heap): Updated to use the new allocateBlock function. + + (JSC::Heap::destroy): Updated to use the new freeBlocks function. + + (JSC::Heap::allocateBlock): New function to initialize a block when + allocating it. + + (JSC::Heap::freeBlock): Consolidated the responsibility for running + destructors into this function. + + (JSC::Heap::freeBlocks): Updated to use freeBlock. + + (JSC::Heap::recordExtraCost): Sweep the heap in this reporting function, + so that allocation, which is more common, doesn't have to check extraCost. + + (JSC::Heap::heapAllocate): Run destructors right before recycling a + garbage cell. This has better cache utilization than a separate sweep phase. + + (JSC::Heap::resizeBlocks): + (JSC::Heap::growBlocks): + (JSC::Heap::shrinkBlocks): New set of functions for managing the size of + the heap, now that the heap doesn't maintain any information about its + size. + + (JSC::isPointerAligned): + (JSC::isHalfCellAligned): + (JSC::isPossibleCell): + (JSC::isCellAligned): + (JSC::Heap::markConservatively): Cleaned up this code a bit. + + (JSC::Heap::clearMarkBits): + (JSC::Heap::markedCells): Some helper functions for examining the the mark + bitmap. + + (JSC::Heap::sweep): Simplified this function by using a DeadObjectIterator. + + (JSC::Heap::markRoots): Reordered some operations for clarity. + + (JSC::Heap::objectCount): + (JSC::Heap::addToStatistics): + (JSC::Heap::statistics): Rewrote these functions to calculate an object + count on demand, since the heap doesn't maintain this information by + itself. + + (JSC::Heap::reset): New function for resetting the heap once we've + exhausted heap space. + + (JSC::Heap::collectAllGarbage): This function matches the old collect() + behavior, but it's now an uncommon function used only by API. + + * runtime/Collector.h: + (JSC::CollectorBitmap::count): + (JSC::CollectorBitmap::isEmpty): Added some helper functions for managing + the collector mark bitmap. + + (JSC::Heap::reportExtraMemoryCost): Changed reporting from cell equivalents + to bytes, so it's easier to understand. + + * runtime/CollectorHeapIterator.h: + (JSC::CollectorHeapIterator::CollectorHeapIterator): + (JSC::CollectorHeapIterator::operator!=): + (JSC::CollectorHeapIterator::operator*): + (JSC::CollectorHeapIterator::advance): + (JSC::::LiveObjectIterator): + (JSC::::operator): + (JSC::::DeadObjectIterator): + (JSC::::ObjectIterator): New iterators for encapsulating details about + heap layout, and what's live and dead on the heap. + + * runtime/JSArray.cpp: + (JSC::JSArray::putSlowCase): + (JSC::JSArray::increaseVectorLength): Delay reporting extra cost until + we're fully constructed, so the heap mark phase won't visit us in an + invalid state. + + * runtime/JSCell.h: + (JSC::JSCell::): + (JSC::JSCell::createDummyStructure): + (JSC::JSCell::JSCell): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: Added a dummy cell to simplify allocation logic. + + * runtime/JSString.h: + (JSC::jsSubstring): Don't report extra cost for substrings, since they + share a buffer that's already reported extra cost. + + * runtime/Tracing.d: + * runtime/Tracing.h: Changed these dtrace hooks not to report object + counts, since they're no longer cheap to compute. + + * runtime/UString.h: Updated for renames. + + * runtime/WeakGCMap.h: Added. + (JSC::WeakGCMap::isEmpty): + (JSC::WeakGCMap::uncheckedGet): + (JSC::WeakGCMap::uncheckedBegin): + (JSC::WeakGCMap::uncheckedEnd): + (JSC::::get): + (JSC::::take): + (JSC::::set): + (JSC::::uncheckedRemove): Mentioned above. + + * wtf/StdLibExtras.h: + (WTF::bitCount): Added a bit population count function, so the heap can + count live objects to fulfill statistics questions. + +The very last cell in the block is not allocated -- should not be marked. + +2009-12-13 Geoffrey Garen + + Windows build fix: Export some new symbols. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-12-13 Geoffrey Garen + + Windows build fix: Removed some old exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-12-13 Geoffrey Garen + + Windows build fix: Use unsigned instead of uint32_t to avoid dependencies. + + * wtf/StdLibExtras.h: + (WTF::bitCount): + +2009-12-13 Gavin Barraclough + + Reviewed by NOBODY (speculative Windows build fix). + + * runtime/JSGlobalObjectFunctions.cpp: + +2009-12-13 Gavin Barraclough + + Reviewed by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=32496 + Switch remaining cases of string construction to use StringBuilder. + Builds strings using a vector rather than using string append / addition. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/Executable.cpp: + (JSC::FunctionExecutable::paramString): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::encode): + (JSC::decode): + (JSC::globalFuncEscape): + (JSC::globalFuncUnescape): + * runtime/JSONObject.cpp: + (JSC::Stringifier::stringify): + (JSC::Stringifier::indent): + * runtime/JSString.h: + * runtime/LiteralParser.cpp: + (JSC::LiteralParser::Lexer::lexString): + * runtime/NumberPrototype.cpp: + (JSC::integerPartNoExp): + (JSC::numberProtoFuncToFixed): + (JSC::numberProtoFuncToPrecision): + * runtime/Operations.h: + (JSC::jsString): + * runtime/StringPrototype.cpp: + (JSC::substituteBackreferencesSlow): + (JSC::substituteBackreferences): + (JSC::stringProtoFuncConcat): + +2009-12-08 Jeremy Moskovich + + Reviewed by Eric Seidel. + + Add code to allow toggling ATSUI/Core Text rendering at runtime in ComplexTextController. + https://bugs.webkit.org/show_bug.cgi?id=31802 + + The goal here is to allow for a zero runtime hit for ports that decide to select + the API at compile time. + When both USE(ATSUI) and USE(CORE_TEXT) are true, the API is toggled + at runtime. Core Text is used for OS Versions >= 10.6. + + * wtf/Platform.h: #define USE_CORE_TEXT and USE_ATSUI on Chrome/Mac. + +2009-12-11 Maciej Stachowiak + + Reviewed by Oliver Hunt. + + Unify codegen for forward and backward variants of branches + https://bugs.webkit.org/show_bug.cgi?id=32463 + + * jit/JIT.h: + (JSC::JIT::emit_op_loop): Implemented in terms of forward variant. + (JSC::JIT::emit_op_loop_if_true): ditto + (JSC::JIT::emitSlow_op_loop_if_true): ditto + (JSC::JIT::emit_op_loop_if_false): ditto + (JSC::JIT::emitSlow_op_loop_if_false): ditto + (JSC::JIT::emit_op_loop_if_less): ditto + (JSC::JIT::emitSlow_op_loop_if_less): ditto + * jit/JITOpcodes.cpp: + +2009-12-11 Sam Weinig + + Reviewed by Anders Carlsson. + + Allow WTFs concept of the main thread to differ from pthreads when necessary. + + * wtf/ThreadingPthreads.cpp: + (WTF::initializeThreading): + (WTF::isMainThread): + * wtf/mac/MainThreadMac.mm: + (WTF::initializeMainThreadPlatform): + (WTF::scheduleDispatchFunctionsOnMainThread): + +2009-12-11 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32454 + Refactor construction of simple strings to avoid string concatenation. + + Building strings through concatenation has a memory and performance cost - + a memory cost since we must over-allocate the buffer to leave space to append + into, and performance in that the string may still require reallocation (and + thus copying during construction). Instead move the full construction to + within a single function call (makeString), so that the arguments' lengths + can be calculated and an appropriate sized buffer allocated before copying + any characters. + + ~No performance change (~2% progression on date tests). + + * bytecode/CodeBlock.cpp: + (JSC::escapeQuotes): + (JSC::valueToSourceString): + (JSC::constantName): + (JSC::idName): + (JSC::CodeBlock::registerName): + (JSC::regexpToSourceString): + (JSC::regexpName): + * bytecompiler/NodesCodegen.cpp: + (JSC::substitute): + * profiler/Profiler.cpp: + (JSC::Profiler::createCallIdentifier): + * runtime/DateConstructor.cpp: + (JSC::callDate): + * runtime/DateConversion.cpp: + (JSC::formatDate): + (JSC::formatDateUTCVariant): + (JSC::formatTime): + (JSC::formatTimeUTC): + * runtime/DateConversion.h: + (JSC::): + * runtime/DatePrototype.cpp: + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncToGMTString): + * runtime/ErrorPrototype.cpp: + (JSC::errorProtoFuncToString): + * runtime/ExceptionHelpers.cpp: + (JSC::createUndefinedVariableError): + (JSC::createErrorMessage): + (JSC::createInvalidParamError): + * runtime/FunctionPrototype.cpp: + (JSC::insertSemicolonIfNeeded): + (JSC::functionProtoFuncToString): + * runtime/ObjectPrototype.cpp: + (JSC::objectProtoFuncToString): + * runtime/RegExpConstructor.cpp: + (JSC::constructRegExp): + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::match): + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncCompile): + (JSC::regExpProtoFuncToString): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncBig): + (JSC::stringProtoFuncSmall): + (JSC::stringProtoFuncBlink): + (JSC::stringProtoFuncBold): + (JSC::stringProtoFuncFixed): + (JSC::stringProtoFuncItalics): + (JSC::stringProtoFuncStrike): + (JSC::stringProtoFuncSub): + (JSC::stringProtoFuncSup): + (JSC::stringProtoFuncFontcolor): + (JSC::stringProtoFuncFontsize): + (JSC::stringProtoFuncAnchor): + * runtime/UString.h: + (JSC::): + (JSC::makeString): + +2009-12-10 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32400 + Switch remaining cases of string addition to use ropes. + + Re-landing r51975 - added toPrimitiveString method, + performs toPrimitive then subsequent toString operations. + + ~1% progression on Sunspidey. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/JSString.h: + (JSC::JSString::JSString): + (JSC::JSString::appendStringInConstruct): + * runtime/Operations.cpp: + (JSC::jsAddSlowCase): + * runtime/Operations.h: + (JSC::jsString): + (JSC::jsAdd): + +2009-12-11 Adam Roben + + Windows build fix + + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: Added + $(WebKitOutputDir)/include/private to the include path. + +2009-12-11 Adam Roben + + Move QuartzCorePresent.h to include/private + + This fixes other projects that use wtf/Platform.h + + Rubber-stamped by Steve Falkenburg. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Let VS do its thang. + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: Write + QuartzCorePresent.h to $(WebKitOutputDir)/include/private. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: + Added $(WebKitOutputDir)/include/private to the include path. + +2009-12-11 Adam Roben + + Fix clean builds and everything rebuilding on every build + + Reviewed by Sam Weinig. + + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: Don't + write out QuartzCorePresent.h if it exists but is older than + QuartzCore.h. Also, create the directory we write QuartzCorePresent.h + into first. + +2009-12-11 Adam Roben + + Windows build fix for systems with spaces in their paths + + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: Quote some paths. + +2009-12-11 Chris Marrin + + Reviewed by Adam Roben. + + Add check for presence of QuartzCore headers + https://bugs.webkit.org/show_bug.cgi?id=31856 + + The script now checks for the presence of QuartzCore.h. If present + it will turn on ACCELERATED_COMPOSITING and 3D_RENDERING to enable + HW compositing on Windows. The script writes QuartzCorePresent.h to + the build directory which has a define telling whether QuartzCore is + present. + + * JavaScriptCore.vcproj/JavaScriptCore/build-generated-files.sh: + * wtf/Platform.h: + +2009-12-11 Kent Tamura + + Reviewed by Darin Adler. + + Fix a problem that JSC::gregorianDateTimeToMS() returns a negative + value for a huge year value. + https://bugs.webkit.org/show_bug.cgi?id=32304 + + * wtf/DateMath.cpp: + (WTF::dateToDaysFrom1970): Renamed from dateToDayInYear, and changed the return type to double. + (WTF::calculateDSTOffset): Follow the dateToDaysFrom1970() change. + (WTF::timeClip): Use maxECMAScriptTime. + (JSC::gregorianDateTimeToMS): Follow the dateToDaysFrom1970() change. + +2009-12-10 Adam Barth + + No review, rolling out r51975. + http://trac.webkit.org/changeset/51975 + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/JSString.h: + (JSC::JSString::JSString): + (JSC::JSString::appendStringInConstruct): + * runtime/Operations.cpp: + (JSC::jsAddSlowCase): + * runtime/Operations.h: + (JSC::jsString): + (JSC::jsAdd): + +2009-12-10 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Incorrect caching of prototype lookup with dictionary base + https://bugs.webkit.org/show_bug.cgi?id=32402 + + Make sure we don't add cached prototype lookup to the proto_list + lookup chain if the top level object is a dictionary. + + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCacheGetByID): + +2009-12-10 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32400 + Switch remaining cases of string addition to use ropes. + + ~1% progression on Sunspidey. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/JSString.h: + (JSC::JSString::JSString): + (JSC::JSString::appendStringInConstruct): + * runtime/Operations.cpp: + (JSC::jsAddSlowCase): + * runtime/Operations.h: + (JSC::jsString): + (JSC::jsAdd): + +2009-12-10 Kent Hansen + + Reviewed by Geoffrey Garen. + + Remove JSObject::getPropertyAttributes() and all usage of it. + https://bugs.webkit.org/show_bug.cgi?id=31933 + + getOwnPropertyDescriptor() should be used instead. + + * JavaScriptCore.exp: + * JavaScriptCore.order: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * debugger/DebuggerActivation.cpp: + (JSC::DebuggerActivation::getOwnPropertyDescriptor): + * debugger/DebuggerActivation.h: + * runtime/JSObject.cpp: + (JSC::JSObject::propertyIsEnumerable): + * runtime/JSObject.h: + * runtime/JSVariableObject.cpp: + * runtime/JSVariableObject.h: + +2009-12-10 Gavin Barraclough + + Reviewed by Oliver Hunt & Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=32367 + Add support for short Ropes (up to 3 entries) inline within JSString. + (rather than externally allocating an object to hold the rope). + Switch jsAdd of (JSString* + JSString*) to now make use of Ropes. + + ~1% progression on Sunspidey. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/JSString.cpp: + (JSC::JSString::resolveRope): + (JSC::JSString::toBoolean): + (JSC::JSString::getStringPropertyDescriptor): + * runtime/JSString.h: + (JSC::JSString::Rope::Fiber::deref): + (JSC::JSString::Rope::Fiber::ref): + (JSC::JSString::Rope::Fiber::refAndGetLength): + (JSC::JSString::Rope::append): + (JSC::JSString::JSString): + (JSC::JSString::~JSString): + (JSC::JSString::value): + (JSC::JSString::tryGetValue): + (JSC::JSString::length): + (JSC::JSString::canGetIndex): + (JSC::JSString::appendStringInConstruct): + (JSC::JSString::appendValueInConstructAndIncrementLength): + (JSC::JSString::isRope): + (JSC::JSString::string): + (JSC::JSString::ropeLength): + (JSC::JSString::getStringPropertySlot): + * runtime/Operations.h: + (JSC::jsString): + (JSC::jsAdd): + (JSC::resolveBase): + +2009-12-09 Anders Carlsson + + Reviewed by Geoffrey Garen. + + Fix three more things found by compiling with clang++. + + * runtime/Structure.h: + (JSC::StructureTransitionTable::reifySingleTransition): + Add the 'std' qualifier to the call to make_pair. + + * wtf/DateMath.cpp: + (WTF::initializeDates): + Incrementing a bool is deprecated according to the C++ specification. + + * wtf/PtrAndFlags.h: + (WTF::PtrAndFlags::PtrAndFlags): + Name lookup should not be done in dependent bases, so explicitly qualify the call to set. + +2009-12-09 Maciej Stachowiak + + Reviewed by Oliver Hunt. + + Google reader gets stuck in the "Loading..." state and does not complete + https://bugs.webkit.org/show_bug.cgi?id=32256 + + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_jless): Fix some backward branches. + +2009-12-09 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32228 + Make destruction of ropes non-recursive to prevent stack exhaustion. + Also, pass a UString& into initializeFiber rather than a Ustring::Rep*, + since the Rep is not being ref counted this could result in usage of a + Rep with refcount zero (where the Rep comes from a temporary UString + returned from a function). + + * runtime/JSString.cpp: + (JSC::JSString::Rope::destructNonRecursive): + (JSC::JSString::Rope::~Rope): + * runtime/JSString.h: + (JSC::JSString::Rope::initializeFiber): + * runtime/Operations.h: + (JSC::concatenateStrings): + +2009-12-09 Zoltan Herczeg + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=31930 + + Update to r51457. ASSERTs changed to COMPILE_ASSERTs. + The speedup is 25%. + + * runtime/JSGlobalData.cpp: + (JSC::VPtrSet::VPtrSet): + +2009-12-09 Steve Block + + Reviewed by Adam Barth. + + Updates Android Makefiles with latest additions. + https://bugs.webkit.org/show_bug.cgi?id=32278 + + * Android.mk: Modified. + * Android.v8.wtf.mk: Modified. + +2009-12-09 Sam Weinig + + Reviewed by Gavin Barraclough. + + Fix a bug found while trying to compile JavaScriptCore with clang++. + + * yarr/RegexPattern.h: + (JSC::Yarr::PatternTerm::PatternTerm): Don't self assign here. Use false instead. + +2009-12-09 Anders Carlsson + + Reviewed by Sam Weinig. + + Attempt to fix the Windows build. + + * wtf/FastMalloc.h: + +2009-12-09 Anders Carlsson + + Reviewed by Sam Weinig. + + Fix some things found while trying to compile JavaScriptCore with clang++. + + * wtf/FastMalloc.h: + Add correct exception specifications for the allocation/deallocation operators. + + * wtf/Vector.h: + * wtf/VectorTraits.h: + Fix a bunch of struct/class mismatches. + +2009-12-08 Maciej Stachowiak + + Reviewed by Darin Adler. + + move code generation portions of Nodes.cpp to bytecompiler directory + https://bugs.webkit.org/show_bug.cgi?id=32284 + + * bytecompiler/NodesCodegen.cpp: Copied from parser/Nodes.cpp. Removed parts that + are not about codegen. + * parser/Nodes.cpp: Removed everything that is about codegen. + + Update build systems: + + * Android.mk: + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * JavaScriptCoreSources.bkl: + +2009-12-08 Kevin Watters + + Reviewed by Kevin Ollivier. + + [wx] Mac plugins support. + + https://bugs.webkit.org/show_bug.cgi?id=32236 + + * wtf/Platform.h: + +2009-12-08 Dmitry Titov + + Rubber-stamped by David Levin. + + Revert and reopen "Add asserts to RefCounted to make sure ref/deref happens on the right thread." + It may have caused massive increase of reported leaks on the bots. + https://bugs.webkit.org/show_bug.cgi?id=31639 + + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.vcproj/WTF/WTF.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/Structure.cpp: + (JSC::Structure::Structure): + * wtf/RefCounted.h: + (WTF::RefCountedBase::ref): + (WTF::RefCountedBase::hasOneRef): + (WTF::RefCountedBase::refCount): + (WTF::RefCountedBase::derefBase): + * wtf/ThreadVerifier.h: Removed. + +2009-12-08 Gustavo Noronha Silva + + Reviewed by Darin Adler. + + Make WebKit build correctly on FreeBSD, IA64, and Alpha. + Based on work by Petr Salinger , + and Colin Watson . + + * wtf/Platform.h: + +2009-12-08 Dmitry Titov + + Reviewed by Darin Adler. + + Add asserts to RefCounted to make sure ref/deref happens on the right thread. + https://bugs.webkit.org/show_bug.cgi?id=31639 + + * runtime/Structure.cpp: + (JSC::Structure::Structure): Disable thread verification on this class since it uses addressOfCount(). + * wtf/RefCounted.h: + (WTF::RefCountedBase::ref): Add ASSERT. + (WTF::RefCountedBase::hasOneRef): Ditto. + (WTF::RefCountedBase::refCount): Ditto. + (WTF::RefCountedBase::derefBase): Ditto. + (WTF::RefCountedBase::disableThreadVerification): delegate to ThreadVerifier method. + * wtf/ThreadVerifier.h: Added. + (WTF::ThreadVerifier::ThreadVerifier): New Debug-only class to verify that ref/deref of RefCounted is done on the same thread. + (WTF::ThreadVerifier::activate): Activates checks. Called when ref count becomes above 2. + (WTF::ThreadVerifier::deactivate): Deactivates checks. Called when ref count drops below 2. + (WTF::ThreadVerifier::disableThreadVerification): used on objects that should not be checked (StringImpl etc) + (WTF::ThreadVerifier::verifyThread): + * GNUmakefile.am: Add ThreadVerifier.h to the build file. + * JavaScriptCore.gypi: Ditto. + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Ditto. + * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. + +2009-12-08 Steve Block + + Reviewed by Adam Barth. + + [Android] Adds Makefiles for Android port. + https://bugs.webkit.org/show_bug.cgi?id=31325 + + * Android.mk: Added. + * Android.v8.wtf.mk: Added. + +2009-12-07 Dmitry Titov + + Rubber-stamped by Darin Adler. + + Remove ENABLE_SHARED_SCRIPT flags + https://bugs.webkit.org/show_bug.cgi?id=32245 + This patch was obtained by "git revert" command and then un-reverting of ChangeLog files. + + * Configurations/FeatureDefines.xcconfig: + * wtf/Platform.h: + +2009-12-07 Gavin Barraclough + + Reviewed by NOBODY (Windows build fixage part I). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-12-05 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32184 + Handle out-of-memory conditions with JSC Ropes with a JS exception, rather than crashing. + Switch from using fastMalloc to tryFastMalloc, pass an ExecState to record the exception on. + + * API/JSCallbackObjectFunctions.h: + (JSC::::toString): + * API/JSValueRef.cpp: + (JSValueIsStrictEqual): + * JavaScriptCore.exp: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitEqualityOp): + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::functionName): + (JSC::DebuggerCallFrame::calculatedFunctionName): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::callEval): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * profiler/ProfileGenerator.cpp: + (JSC::ProfileGenerator::addParentForConsoleStart): + * profiler/Profiler.cpp: + (JSC::Profiler::willExecute): + (JSC::Profiler::didExecute): + (JSC::Profiler::createCallIdentifier): + (JSC::createCallIdentifierFromFunctionImp): + * profiler/Profiler.h: + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncIndexOf): + (JSC::arrayProtoFuncLastIndexOf): + * runtime/DateConstructor.cpp: + (JSC::constructDate): + * runtime/FunctionPrototype.cpp: + (JSC::functionProtoFuncToString): + * runtime/InternalFunction.cpp: + (JSC::InternalFunction::name): + (JSC::InternalFunction::displayName): + (JSC::InternalFunction::calculatedDisplayName): + * runtime/InternalFunction.h: + * runtime/JSCell.cpp: + (JSC::JSCell::getString): + * runtime/JSCell.h: + (JSC::JSValue::getString): + * runtime/JSONObject.cpp: + (JSC::gap): + (JSC::Stringifier::Stringifier): + (JSC::Stringifier::appendStringifiedValue): + * runtime/JSObject.cpp: + (JSC::JSObject::putDirectFunction): + (JSC::JSObject::putDirectFunctionWithoutTransition): + (JSC::JSObject::defineOwnProperty): + * runtime/JSObject.h: + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::get): + * runtime/JSString.cpp: + (JSC::JSString::Rope::~Rope): + (JSC::JSString::resolveRope): + (JSC::JSString::getPrimitiveNumber): + (JSC::JSString::toNumber): + (JSC::JSString::toString): + (JSC::JSString::toThisString): + (JSC::JSString::getStringPropertyDescriptor): + * runtime/JSString.h: + (JSC::JSString::Rope::createOrNull): + (JSC::JSString::Rope::operator new): + (JSC::JSString::value): + (JSC::JSString::tryGetValue): + (JSC::JSString::getIndex): + (JSC::JSString::getStringPropertySlot): + (JSC::JSValue::toString): + * runtime/JSValue.h: + * runtime/NativeErrorConstructor.cpp: + (JSC::NativeErrorConstructor::NativeErrorConstructor): + * runtime/Operations.cpp: + (JSC::JSValue::strictEqualSlowCase): + * runtime/Operations.h: + (JSC::JSValue::equalSlowCaseInline): + (JSC::JSValue::strictEqualSlowCaseInline): + (JSC::JSValue::strictEqual): + (JSC::jsLess): + (JSC::jsLessEq): + (JSC::jsAdd): + (JSC::concatenateStrings): + * runtime/PropertyDescriptor.cpp: + (JSC::PropertyDescriptor::equalTo): + * runtime/PropertyDescriptor.h: + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncReplace): + (JSC::stringProtoFuncToLowerCase): + (JSC::stringProtoFuncToUpperCase): + +2009-12-07 Nikolas Zimmermann + + Reviewed by Holger Freyther. + + Turn on (SVG) Filters support, by default. + https://bugs.webkit.org/show_bug.cgi?id=32224 + + * Configurations/FeatureDefines.xcconfig: Enable FILTERS build flag. + +2009-12-07 Steve Falkenburg + + Build fix. Be flexible about which version of ICU is used on Windows. + + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: Add optional xcopy commands to copy ICU 4.2. + +2009-12-07 Maciej Stachowiak + + Reviewed by Oliver Hunt. + + op_loop_if_less JIT codegen is broken for 64-bit + https://bugs.webkit.org/show_bug.cgi?id=32221 + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_false): Fix codegen in this version - test was backwards. + +2009-12-07 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Object.create fails if properties on the descriptor are getters + https://bugs.webkit.org/show_bug.cgi?id=32219 + + Correctly initialise the PropertySlots with the descriptor object. + + * runtime/ObjectConstructor.cpp: + (JSC::toPropertyDescriptor): + +2009-12-06 Maciej Stachowiak + + Not reviewed, build fix. + + Actually tested 64-bit *and* 32-bit build this time. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_false): + +2009-12-06 Maciej Stachowiak + + Not reviewed, build fix. + + Really really fix 64-bit build for prior patch (actually tested this time). + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_false): + (JSC::JIT::emitSlow_op_loop_if_false): + +2009-12-06 Maciej Stachowiak + + Not reviewed, build fix. + + Really fix 64-bit build for prior patch. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_jless): + +2009-12-06 Maciej Stachowiak + + Not reviewed, build fix. + + Fix 64-bit build for prior patch. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_loop_if_less): + +2009-12-05 Maciej Stachowiak + + Reviewed by Oliver Hunt. + + conway benchmark spends half it's time in op_less (jump fusion fails) + https://bugs.webkit.org/show_bug.cgi?id=32190 + + <1% speedup on SunSpider and V8 + 2x speedup on "conway" benchmark + + Two optimizations: + 1) Improve codegen for logical operators &&, || and ! in a condition context + + When generating code for combinations of &&, || and !, in a + condition context (i.e. in an if statement or loop condition), we + used to produce a value, and then separately jump based on its + truthiness. Now we pass the false and true targets in, and let the + logical operators generate jumps directly. This helps in four + ways: + + a) Individual clauses of a short-circuit logical operator can now + jump directly to the then or else clause of an if statement (or to + the top or exit of a loop) instead of jumping to a jump. + + b) It used to be that jump fusion with the condition of the first + clause of a logical operator was inhibited, because the register + was ref'd to be used later, in the actual condition jump; this no + longer happens since a jump straight to the final target is + generated directly. + + c) It used to be that jump fusion with the condition of the second + clause of a logical operator was inhibited, because there was a + jump target right after the second clause and before the actual + condition jump. But now it's no longer necessary for the first + clause to jump there so jump fusion is not blocked. + + d) We avoid generating excess mov statements in some cases. + + As a concrete example this source: + + if (!((x < q && y < q) || (t < q && z < q))) { + // ... + } + + Used to generate this bytecode: + + [ 34] less r1, r-15, r-19 + [ 38] jfalse r1, 7(->45) + [ 41] less r1, r-16, r-19 + [ 45] jtrue r1, 14(->59) + [ 48] less r1, r-17, r-19 + [ 52] jfalse r1, 7(->59) + [ 55] less r1, r-18, r-19 + [ 59] jtrue r1, 17(->76) + + And now generates this bytecode (also taking advantage of the second optimization below): + + [ 34] jnless r-15, r-19, 8(->42) + [ 38] jless r-16, r-19, 26(->64) + [ 42] jnless r-17, r-19, 8(->50) + [ 46] jless r-18, r-19, 18(->64) + + Note the jump fusion and the fact that there's less jump + indirection - three of the four jumps go straight to the target + clause instead of indirecting through another jump. + + 2) Implement jless opcode to take advantage of the above, since we'll now often generate + a less followed by a jtrue where fusion is not forbidden. + + * parser/Nodes.h: + (JSC::ExpressionNode::hasConditionContextCodegen): Helper function to determine + whether a node supports special conditional codegen. Return false as this is the default. + (JSC::ExpressionNode::emitBytecodeInConditionContext): Assert not reached - only really + defined for nodes that do have conditional codegen. + (JSC::UnaryOpNode::expr): Add const version. + (JSC::LogicalNotNode::hasConditionContextCodegen): Returne true only if subexpression + supports it. + (JSC::LogicalOpNode::hasConditionContextCodegen): Return true. + * parser/Nodes.cpp: + (JSC::LogicalNotNode::emitBytecodeInConditionContext): Implemented - just swap + the true and false targets for the child node. + (JSC::LogicalOpNode::emitBytecodeInConditionContext): Implemented - handle jumps + directly, improving codegen quality. Also handles further nested conditional codegen. + (JSC::ConditionalNode::emitBytecode): Use condition context codegen when available. + (JSC::IfNode::emitBytecode): ditto + (JSC::IfElseNode::emitBytecode): ditto + (JSC::DoWhileNode::emitBytecode): ditto + (JSC::WhileNode::emitBytecode): ditto + (JSC::ForNode::emitBytecode): ditto + + * bytecode/Opcode.h: + - Added loop_if_false opcode - needed now that falsey jumps can be backwards. + - Added jless opcode to take advantage of new fusion opportunities. + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): Handle above. + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitJumpIfTrue): Add peephole for less + jtrue ==> jless. + (JSC::BytecodeGenerator::emitJumpIfFalse): Add handling of backwrds falsey jumps. + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::emitNodeInConditionContext): Wrapper to handle tracking of + overly deep expressions etc. + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): Implement the two new opcodes (loop_if_false, jless). + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): Implement JIT support for the two new opcodes. + (JSC::JIT::privateCompileSlowCases): ditto + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jless): + (JSC::JIT::emitSlow_op_jless): ditto + (JSC::JIT::emitBinaryDoubleOp): ditto + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_loop_if_less): ditto + (JSC::JIT::emit_op_loop_if_false): ditto + (JSC::JIT::emitSlow_op_loop_if_false): ditto + * jit/JITStubs.cpp: + * jit/JITStubs.h: + (JSC::): + +2009-12-04 Kent Hansen + + Reviewed by Darin Adler. + + JavaScript delete operator should return false for string properties + https://bugs.webkit.org/show_bug.cgi?id=32012 + + * runtime/StringObject.cpp: + (JSC::StringObject::deleteProperty): + +2009-12-03 Drew Wilson + + Rolled back r51633 because it causes a perf regression in Chromium. + + * wtf/Platform.h: + +2009-12-03 Gavin Barraclough + + Try and fix the Windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export a symbol that should be exported. + +2009-12-03 Mark Rowe + + Try and fix the Mac build. + + * JavaScriptCore.exp: Export a symbol that should be exported. + +2009-12-03 Oliver Hunt + + Reviewed by Gavin Barraclough. + + REGRESSION(4.0.3-48777): Crash in JSC::ExecState::propertyNames() (Debug-only?) + https://bugs.webkit.org/show_bug.cgi?id=32133 + + Work around odd GCC-ism and correct the scopechain for use by + calls made while a cachedcall is active on the callstack. + + * interpreter/CachedCall.h: + (JSC::CachedCall::newCallFrame): + * runtime/JSArray.cpp: + (JSC::AVLTreeAbstractorForArrayCompare::compare_key_key): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncReplace): + +2009-12-03 Gavin Barraclough + + Reviewed by Oliver "Brraaaaiiiinnnnnzzzzzzzz" Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=32136 + Add a rope representation to JSString. Presently JSString always holds its data in UString form. + Instead, allow the result of a string concatenation to be represented in a tree form - with a + variable sized, reference-counted rope node retaining a set of UString::Reps (or other rope nopes). + + Strings must still currently be resolved down to a flat UString representation before being used, + but by holding the string in a rope representation during construction we can avoid copying data + until we know the final size of the string. + + ~2% progression on SunSpider (~25% on date-format-xparb, ~20% on string-validate-input). + + * JavaScriptCore.exp: + + - Update exports. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + + - Make use of new JSString::length() method to avoid prematurely resolving ropes. + + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + + - Switch the string length trampoline to read the length directly from JSString::m_length, + rather than from the JSString's UString::Rep's 'len' property. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + + - Modify op_add such that addition of two strings, where either or both strings are already + in rope representation, produces a rope as a result. + + * runtime/JSString.cpp: + (JSC::JSString::Rope::~Rope): + (JSC::copyChars): + (JSC::JSString::resolveRope): + (JSC::JSString::getPrimitiveNumber): + (JSC::JSString::toBoolean): + (JSC::JSString::toNumber): + (JSC::JSString::toString): + (JSC::JSString::toThisString): + (JSC::JSString::getStringPropertyDescriptor): + * runtime/JSString.h: + (JSC::JSString::Rope::Fiber::Fiber): + (JSC::JSString::Rope::Fiber::destroy): + (JSC::JSString::Rope::Fiber::isRope): + (JSC::JSString::Rope::Fiber::rope): + (JSC::JSString::Rope::Fiber::string): + (JSC::JSString::Rope::create): + (JSC::JSString::Rope::initializeFiber): + (JSC::JSString::Rope::ropeLength): + (JSC::JSString::Rope::stringLength): + (JSC::JSString::Rope::fibers): + (JSC::JSString::Rope::Rope): + (JSC::JSString::Rope::operator new): + (JSC::JSString::JSString): + (JSC::JSString::value): + (JSC::JSString::length): + (JSC::JSString::isRope): + (JSC::JSString::rope): + (JSC::JSString::string): + (JSC::JSString::canGetIndex): + (JSC::jsSingleCharacterSubstring): + (JSC::JSString::getIndex): + (JSC::jsSubstring): + (JSC::JSString::getStringPropertySlot): + + - Add rope form. + + * runtime/Operations.h: + (JSC::jsAdd): + (JSC::concatenateStrings): + + - Update string concatenation, and addition of ropes, to produce ropes. + + * runtime/StringObject.cpp: + (JSC::StringObject::getOwnPropertyNames): + + - Make use of new JSString::length() method to avoid prematurely resolving ropes. + +2009-11-23 Jeremy Moskovich + + Reviewed by Eric Seidel. + + Switch Chrome/Mac to use Core Text APIs rather than ATSUI APIs. + https://bugs.webkit.org/show_bug.cgi?id=31802 + + No test since this is already covered by existing pixel tests. + + * wtf/Platform.h: #define USE_CORE_TEXT for Chrome/Mac. + +2009-12-02 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Add files missed in prior patch. + + * runtime/JSZombie.cpp: + (JSC::): + (JSC::JSZombie::leakedZombieStructure): + * runtime/JSZombie.h: Added. + (JSC::JSZombie::JSZombie): + (JSC::JSZombie::isZombie): + (JSC::JSZombie::classInfo): + (JSC::JSZombie::isGetterSetter): + (JSC::JSZombie::isAPIValueWrapper): + (JSC::JSZombie::isPropertyNameIterator): + (JSC::JSZombie::getCallData): + (JSC::JSZombie::getConstructData): + (JSC::JSZombie::getUInt32): + (JSC::JSZombie::toPrimitive): + (JSC::JSZombie::getPrimitiveNumber): + (JSC::JSZombie::toBoolean): + (JSC::JSZombie::toNumber): + (JSC::JSZombie::toString): + (JSC::JSZombie::toObject): + (JSC::JSZombie::markChildren): + (JSC::JSZombie::put): + (JSC::JSZombie::deleteProperty): + (JSC::JSZombie::toThisObject): + (JSC::JSZombie::toThisString): + (JSC::JSZombie::toThisJSString): + (JSC::JSZombie::getJSNumber): + (JSC::JSZombie::getOwnPropertySlot): + +2009-12-02 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Add zombies to JSC + https://bugs.webkit.org/show_bug.cgi?id=32103 + + Add a compile time flag to make the JSC collector replace "unreachable" + objects with zombie objects. The zombie object is a JSCell subclass that + ASSERTs on any attempt to use the JSCell methods. In addition there are + a number of additional assertions in bottleneck code to catch zombie usage + as quickly as possible. + + Grrr. Argh. Brains. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * interpreter/Register.h: + (JSC::Register::Register): + * runtime/ArgList.h: + (JSC::MarkedArgumentBuffer::append): + (JSC::ArgList::ArgList): + * runtime/Collector.cpp: + (JSC::Heap::destroy): + (JSC::Heap::sweep): + * runtime/Collector.h: + * runtime/JSCell.h: + (JSC::JSCell::isZombie): + (JSC::JSValue::isZombie): + * runtime/JSValue.h: + (JSC::JSValue::decode): + (JSC::JSValue::JSValue): + * wtf/Platform.h: + +2009-12-01 Jens Alfke + + Reviewed by Darin Adler. + + Added variants of find/contains/add that allow a foreign key type to be used. + This will allow AtomicString-keyed maps to be queried by C string without + having to create a temporary AtomicString (see HTTPHeaderMap.) + The code for this is adapted from the equivalent in HashSet.h. + + * wtf/HashMap.h: + (WTF::HashMap::find): + (WTF::HashMap::contains): + (WTF::HashMap::add): + * wtf/HashSet.h: Changed "method" to "function member" in a comment. + +2009-12-01 Gustavo Noronha Silva + + Revert 51551 because it broke GTK+. + + * wtf/Platform.h: + +2009-11-30 Gavin Barraclough + + Windows Build fix. Reviewed by NOBODY. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-11-24 Gavin Barraclough + + Reviewed by Geoff Garen. + + Bug 31859 - Make world selection for JSC IsolatedWorlds automagical. + + WebCore presently has to explicitly specify the world before entering into JSC, + which is a little fragile (particularly since property access via a + getter/setter might invoke execution). Instead derive the current world from + the lexical global object. + + Remove the temporary duct tape of willExecute/didExecute virtual hooks on the JSGlobalData::ClientData - these are no longer necessary. + + * API/JSBase.cpp: + (JSEvaluateScript): + * API/JSObjectRef.cpp: + (JSObjectCallAsFunction): + * JavaScriptCore.exp: + * runtime/JSGlobalData.cpp: + * runtime/JSGlobalData.h: + +2009-11-30 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove obsolete PLATFORM(KDE) code + https://bugs.webkit.org/show_bug.cgi?id=31958 + + KDE is now using unpatched QtWebKit. + + * parser/Lexer.cpp: Remove obsolete KDE_USE_FINAL guard + * wtf/Platform.h: Remove PLATFORM(KDE) definition and code + section that is guarded with it. + +2009-11-30 Jan-Arve Sæther + + Reviewed by Simon Hausmann. + + [Qt] Fix compilation with win32-icc + + The Intel compiler does not support the __has_trivial_constructor type + trait. The Intel Compiler can report itself as _MSC_VER >= 1400. The + reason for that is that the Intel Compiler depends on the Microsoft + Platform SDK, and in order to try to be "fully" MS compatible it will + "pretend" to be the same MS compiler as was shipped with the MS PSDK. + (Thus, compiling with win32-icc with VC8 SDK will make the source code + "think" the compiler at hand supports this type trait). + + * wtf/TypeTraits.h: + +2009-11-29 Laszlo Gombos + + Reviewed by Eric Seidel. + + [Qt] Mac build has JIT disabled + https://bugs.webkit.org/show_bug.cgi?id=31828 + + * wtf/Platform.h: Enable JIT for Qt Mac builds + +2009-11-28 Laszlo Gombos + + Reviewed by Eric Seidel. + + Apply workaround for the limitation of VirtualFree with MEM_RELEASE to all ports running on Windows + https://bugs.webkit.org/show_bug.cgi?id=31943 + + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + +2009-11-28 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + https://bugs.webkit.org/show_bug.cgi?id=31930 + + Seems a typo. We don't need ~270k memory to determine the vptrs. + + * runtime/JSGlobalData.cpp: + (JSC::VPtrSet::VPtrSet): + +2009-11-27 Shinichiro Hamaji + + Unreviewed. + + Move GOwnPtr* from wtf to wtf/gtk + https://bugs.webkit.org/show_bug.cgi?id=31793 + + Build fix for chromium after r51423. + Exclude gtk directory from chromium build. + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + +2009-11-25 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Incorrect behaviour of jneq_null in the interpreter + https://bugs.webkit.org/show_bug.cgi?id=31901 + + Correct the logic of jneq_null. This is already covered by existing tests. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + +2009-11-26 Laszlo Gombos + + Reviewed by Oliver Hunt. + + Move GOwnPtr* from wtf to wtf/gtk + https://bugs.webkit.org/show_bug.cgi?id=31793 + + * GNUmakefile.am: Change the path for GOwnPtr.*. + * JavaScriptCore.gyp/JavaScriptCore.gyp: Remove + GOwnPtr.cpp from the exclude list. + * JavaScriptCore.gypi: Change the path for GOwnPtr.*. + * wscript: Remove GOwnPtr.cpp from the exclude list. + * wtf/GOwnPtr.cpp: Removed. + * wtf/GOwnPtr.h: Removed. + * wtf/Threading.h: Change the path for GOwnPtr.h. + * wtf/gtk/GOwnPtr.cpp: Copied from JavaScriptCore/wtf/GOwnPtr.cpp. + * wtf/gtk/GOwnPtr.h: Copied from JavaScriptCore/wtf/GOwnPtr.h. + * wtf/unicode/glib/UnicodeGLib.h: Change the path for GOwnPtr.h. + +2009-11-24 Dmitry Titov + + Reviewed by Eric Seidel. + + Add ENABLE_SHARED_SCRIPT feature define and flag for build-webkit + https://bugs.webkit.org/show_bug.cgi?id=31444 + + * Configurations/FeatureDefines.xcconfig: + * wtf/Platform.h: + +2009-11-24 Chris Marrin + + Reviewed by Simon Fraser. + + Add ability to enable ACCELERATED_COMPOSITING on Windows (currently disabled) + https://bugs.webkit.org/show_bug.cgi?id=27314 + + * wtf/Platform.h: + +2009-11-24 Jason Smith + + Reviewed by Alexey Proskuryakov. + + RegExp#exec's returned Array-like object behaves differently from + regular Arrays + https://bugs.webkit.org/show_bug.cgi?id=31689 + + * JavaScriptCore/runtime/RegExpConstructor.cpp: ensure that undefined + values are added to the returned RegExpMatchesArray + +2009-11-24 Oliver Hunt + + Reviewed by Alexey Proskuryakov. + + JSON.stringify performance on undefined is very poor + https://bugs.webkit.org/show_bug.cgi?id=31839 + + Switch from a UString to a Vector when building + the JSON string, allowing us to safely remove the substr-copy + we otherwise did when unwinding an undefined property. + + Also turns out to be a ~5% speedup on stringification. + + * runtime/JSONObject.cpp: + (JSC::Stringifier::StringBuilder::append): + (JSC::Stringifier::stringify): + (JSC::Stringifier::Holder::appendNextProperty): + +2009-11-24 Mark Rowe + + Fix production builds where the source tree may be read-only. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-11-23 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + Include "config.h" to meet Coding Style Guidelines + https://bugs.webkit.org/show_bug.cgi?id=31792 + + * wtf/unicode/UTF8.cpp: + * wtf/unicode/glib/UnicodeGLib.cpp: + * wtf/unicode/wince/UnicodeWince.cpp: + +2009-11-23 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Streamlined some Math functions where we expect or know the result not + to be representable as an int. + + SunSpider says 0.6% faster. + + * runtime/JSNumberCell.h: + (JSC::JSValue::JSValue): + * runtime/JSValue.h: + (JSC::JSValue::): + (JSC::jsDoubleNumber): + (JSC::JSValue::JSValue): Added a function for making a numeric JSValue + and skipping the "can I encode this as an int?" check, avoiding the + overhead of int <-> double roundtripping and double <-> double comparison + and branching. + + * runtime/MathObject.cpp: + (JSC::mathProtoFuncACos): + (JSC::mathProtoFuncASin): + (JSC::mathProtoFuncATan): + (JSC::mathProtoFuncATan2): + (JSC::mathProtoFuncCos): + (JSC::mathProtoFuncExp): + (JSC::mathProtoFuncLog): + (JSC::mathProtoFuncRandom): + (JSC::mathProtoFuncSin): + (JSC::mathProtoFuncSqrt): + (JSC::mathProtoFuncTan): For these functions, which we expect or know + to produce results not representable as ints, call jsDoubleNumber instead + of jsNumber. + +2009-11-23 Mark Rowe + + Unreviewed. Unbreak the regression tests after r51329. + + * API/JSBase.cpp: + (JSEvaluateScript): Null-check clientData before dereferencing it. + * API/JSObjectRef.cpp: + (JSObjectCallAsFunction): Ditto. + +2009-11-23 Gavin Barraclough + + Reviewed by Geoff Garen. + + Part 1/3 of REGRESSION: Many web pages fail to render after interesting script runs in isolated world + + Some clients of the JavaScriptCore API expect to be able to make callbacks over the JSC API, + and for this to automagically cause execution to take place in the world associated with the + global object associated with the ExecState (JSContextRef) passed. However this is not how + things work - the world must be explicitly set within WebCore. + + Making this work just for API calls to evaluate & call will be a far from perfect solution, + since direct (non-API) use of JSC still relies on WebCore setting the current world correctly. + A better solution would be to make this all work automagically all throughout WebCore, but this + will require more refactoring. + + Since the API is in JSC but worlds only exist in WebCore, add callbacks on the JSGlobalData::ClientData + to allow it to update the current world on entry/exit via the JSC API. This is temporary duck + tape, and should be removed once the current world no longer needs to be explicitly tracked. + + * API/JSBase.cpp: + (JSEvaluateScript): + * API/JSObjectRef.cpp: + (JSObjectCallAsFunction): + * JavaScriptCore.exp: + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::ClientData::beginningExecution): + (JSC::JSGlobalData::ClientData::completedExecution): + * runtime/JSGlobalData.h: + +2009-11-23 Steve Block + + Reviewed by Dmitry Titov. + + Adds MainThreadAndroid.cpp with Android-specific WTF threading functions. + https://bugs.webkit.org/show_bug.cgi?id=31807 + + * wtf/android: Added. + * wtf/android/MainThreadAndroid.cpp: Added. + (WTF::timeoutFired): + (WTF::initializeMainThreadPlatform): + (WTF::scheduleDispatchFunctionsOnMainThread): + +2009-11-23 Alexey Proskuryakov + + Reviewed by Brady Eidson. + + https://bugs.webkit.org/show_bug.cgi?id=31748 + Make WebSocketHandleCFNet respect proxy auto-configuration files via CFProxySupport + + * JavaScriptCore.exp: Export callOnMainThreadAndWait. + +2009-11-23 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Symbian] Fix lastIndexOf() for Symbian + https://bugs.webkit.org/show_bug.cgi?id=31773 + + Symbian soft floating point library has problems with operators + comparing NaN to numbers. Without a workaround lastIndexOf() + function does not work. + + Patch developed by David Leong. + + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncLastIndexOf):Add an extra test + to check for NaN for Symbian. + +2009-11-23 Steve Block + + Reviewed by Eric Seidel. + + Android port lacks implementation of atomicIncrement and atomicDecrement. + https://bugs.webkit.org/show_bug.cgi?id=31715 + + * wtf/Threading.h: Modified. + (WTF::atomicIncrement): Added Android implementation. + (WTF::atomicDecrement): Added Android implementation. + +2009-11-22 Laszlo Gombos + + Unreviewed. + + [Qt] Sort source lists and remove obsolete comments + from the build system. + + * JavaScriptCore.pri: + +2009-11-21 Laszlo Gombos + + Reviewed by Eric Seidel. + + [Qt][Mac] Turn on multiple JavaScript threads for QtWebkit on Mac + https://bugs.webkit.org/show_bug.cgi?id=31753 + + * wtf/Platform.h: + +2009-11-19 Steve Block + + Android port lacks configuration in Platform.h and config.h. + https://bugs.webkit.org/show_bug.cgi?id=31671 + + * wtf/Platform.h: Modified. Added Android-specific configuration. + +2009-11-19 Alexey Proskuryakov + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=31690 + Make SocketStreamHandleCFNet work on Windows + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * wtf/MainThread.cpp: + (WTF::FunctionWithContext::FunctionWithContext): + (WTF::dispatchFunctionsFromMainThread): + (WTF::callOnMainThreadAndWait): + * wtf/MainThread.h: + Re-add callOnMainThreadAndWait(), which was removed in bug 23926. + +2009-11-19 Dmitry Titov + + Reviewed by David Levin. + + isMainThread() on Chromium (Mac and Linux) is so slow it timeouts LayoutTests.. + https://bugs.webkit.org/show_bug.cgi?id=31693 + + * wtf/ThreadingPthreads.cpp: + (WTF::initializeThreading): grab and use the pthread_t of the main thread instead of ThreadIdentifier. + (WTF::isMainThread): Ditto. + +2009-11-19 Laszlo Gombos + + Reviewed by Darin Adler. + + Remove HAVE(STRING_H) guard from JavaScriptCore + https://bugs.webkit.org/show_bug.cgi?id=31668 + + * config.h: + * runtime/UString.cpp: + +2009-11-19 Dumitru Daniliuc + + Reviewed by Dmitry Titov. + + Fixing a bug in MessageQueue::removeIf() that leads to an + assertion failure. + + https://bugs.webkit.org/show_bug.cgi?id=31657 + + * wtf/MessageQueue.h: + (WTF::MessageQueue::removeIf): + +2009-11-19 Laszlo Gombos + + Reviewed by Darin Adler. + + Remove HAVE(FLOAT_H) guard + https://bugs.webkit.org/show_bug.cgi?id=31661 + + JavaScriptCore has a dependency on float.h, there is + no need to guard float.h. + + * runtime/DatePrototype.cpp: Remove include directive + for float.h as it is included in MathExtras.h already. + * runtime/Operations.cpp: Ditto. + * runtime/UString.cpp: Ditto. + * wtf/dtoa.cpp: Ditto. + * wtf/MathExtras.h: Remove HAVE(FLOAT_H) guard. + * wtf/Platform.h: Ditto. + +2009-11-19 Thiago Macieira + + Reviewed by Simon Hausmann. + + Build fix for 32-bit Sparc machines: these machines are big-endian. + + * wtf/Platform.h: + +2009-11-18 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove support for Qt v4.3 or older versions + https://bugs.webkit.org/show_bug.cgi?id=29469 + + * JavaScriptCore.pro: + * jsc.pro: + * wtf/unicode/qt4/UnicodeQt4.h: + +2009-11-18 Kent Tamura + + Reviewed by Darin Adler. + + Move UString::from(double) implementation to new + WTF::doubleToStringInJavaScriptFormat(), and expose it because WebCore + code will use it. + https://bugs.webkit.org/show_bug.cgi?id=31330 + + - Introduce new function createRep(const char*, unsigned) and + UString::UString(const char*, unsigned) to reduce 2 calls to strlen(). + - Fix a bug that dtoa() doesn't update *rve if the input value is NaN + or Infinity. + + No new tests because this doesn't change the behavior. + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * runtime/UString.cpp: + (JSC::createRep): + (JSC::UString::UString): + (JSC::UString::from): Move the code to doubleToStringInJavaScriptFormat(). + * runtime/UString.h: + * wtf/dtoa.cpp: + (WTF::dtoa): Fix a bug about rve. + (WTF::append): A helper for doubleToStringInJavaScriptFormat(). + (WTF::doubleToStringInJavaScriptFormat): Move the code from UString::from(double). + * wtf/dtoa.h: + +2009-11-18 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Remove WTF_USE_JAVASCRIPTCORE_BINDINGS as it is no longer used + https://bugs.webkit.org/show_bug.cgi?id=31643 + + * JavaScriptCore.pro: + +2009-11-18 Nate Chapin + + Reviewed by Darin Fisher. + + Remove Chromium's unnecessary dependency on wtf's tcmalloc files. + + https://bugs.webkit.org/show_bug.cgi?id=31648 + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + +2009-11-18 Thiago Macieira + + Reviewed by Gavin Barraclough. + + [Qt] Implement symbol hiding for JSC's JIT functions. + + These functions are implemented directly in assembly, so they need the + proper directives to enable/disable visibility. On ELF systems, it's + .hidden, whereas on Mach-O systems (Mac) it's .private_extern. On + Windows, it's not necessary since you have to explicitly export. I + also implemented the AIX idiom, though it's unlikely anyone will + implement AIX/POWER JIT. + https://bugs.webkit.org/show_bug.cgi?id=30864 + + * jit/JITStubs.cpp: + +2009-11-18 Oliver Hunt + + Reviewed by Alexey Proskuryakov. + + Interpreter may do an out of range access when throwing an exception in the profiler. + https://bugs.webkit.org/show_bug.cgi?id=31635 + + Add bounds check. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::throwException): + +2009-11-18 Gabor Loki + + Reviewed by Darin Adler. + + Fix the clobber list of cacheFlush for ARM and Thumb2 on Linux + https://bugs.webkit.org/show_bug.cgi?id=31631 + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-11-18 Harald Fernengel + + Reviewed by Simon Hausmann. + + [Qt] Fix detection of linux-g++ + + Never use "linux-g++*" to check for linux-g++, since this will break embedded + builds which use linux-arm-g++ and friends. Use 'linux*-g++*' to check for any + g++ on linux mkspec. + + * JavaScriptCore.pri: + +2009-11-17 Jon Honeycutt + + Add JSContextRefPrivate.h to list of copied files. + + Reviewed by Mark Rowe. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + +2009-11-17 Martin Robinson + + Reviewed by Adam Barth. + + [GTK] Style cleanup for GOwnPtr + https://bugs.webkit.org/show_bug.cgi?id=31506 + + Remove forward declaration in GOwnPtr and do some style cleanup. + + * wtf/GOwnPtr.cpp: + * wtf/GOwnPtr.h: + (WTF::GOwnPtr::GOwnPtr): + (WTF::GOwnPtr::~GOwnPtr): + (WTF::GOwnPtr::get): + (WTF::GOwnPtr::release): + (WTF::GOwnPtr::outPtr): + (WTF::GOwnPtr::set): + (WTF::GOwnPtr::clear): + (WTF::GOwnPtr::operator*): + (WTF::GOwnPtr::operator->): + (WTF::GOwnPtr::operator!): + (WTF::GOwnPtr::operator UnspecifiedBoolType): + (WTF::GOwnPtr::swap): + (WTF::swap): + (WTF::operator==): + (WTF::operator!=): + (WTF::getPtr): + (WTF::freeOwnedGPtr): + +2009-11-17 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Incorrect use of JavaScriptCore API in DumpRenderTree + https://bugs.webkit.org/show_bug.cgi?id=31577 + + Add assertions to the 'toJS' functions to catch mistakes like + this early. Restructure existing code which blindly passed potentially + null values to toJS when forwarding exceptions so that a null check is + performed first. + + * API/APICast.h: + (toJS): + (toJSForGC): + * API/JSCallbackObjectFunctions.h: + (JSC::::getOwnPropertySlot): + (JSC::::put): + (JSC::::deleteProperty): + (JSC::::construct): + (JSC::::hasInstance): + (JSC::::call): + (JSC::::toNumber): + (JSC::::toString): + (JSC::::staticValueGetter): + (JSC::::callbackGetter): + * API/tests/testapi.c: Fix errors in the API tester. + (MyObject_getProperty): + (MyObject_convertToType): + (EvilExceptionObject_convertToType): + +2009-11-16 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + https://bugs.webkit.org/show_bug.cgi?id=31050 + + Minor fixes for JSVALUE32_64: branchConvertDoubleToInt32 + failed on a CortexA8 CPU, but not on a simulator; and + JITCall.cpp modifications was somehow not committed to mainline. + + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::fmrs_r): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::branchConvertDoubleToInt32): + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + +2009-11-16 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Fix Qt build on Windows CE 6. + + * JavaScriptCore.pri: Add missing include path. + * wtf/Platform.h: Include ce_time.h for Windows CE 6. + +2009-11-13 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + https://bugs.webkit.org/show_bug.cgi?id=31050 + + Adding optimization support for mode JSVALUE32_64 + on ARM systems. + + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compileGetByIdSlowCase): + (JSC::JIT::emit_op_put_by_id): + +2009-11-14 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + https://bugs.webkit.org/show_bug.cgi?id=31050 + + Adding JSVALUE32_64 support for ARM (but not turning it + on by default). All optimizations must be disabled, since + this patch is only the first of a series of patches. + + During the work, a lot of x86 specific code revealed and + made platform independent. + See revisions: 50531 50541 50593 50594 50595 + + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::): + (JSC::ARMAssembler::fdivd_r): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::lshift32): + (JSC::MacroAssemblerARM::neg32): + (JSC::MacroAssemblerARM::rshift32): + (JSC::MacroAssemblerARM::branchOr32): + (JSC::MacroAssemblerARM::set8): + (JSC::MacroAssemblerARM::setTest8): + (JSC::MacroAssemblerARM::loadDouble): + (JSC::MacroAssemblerARM::divDouble): + (JSC::MacroAssemblerARM::convertInt32ToDouble): + (JSC::MacroAssemblerARM::zeroDouble): + * jit/JIT.cpp: + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITStubs.cpp: + * wtf/StdLibExtras.h: + +2009-11-13 Dominik Röttsches + + Reviewed by Eric Seidel. + + Unify TextBoundaries implementations by only relying on WTF Unicode abstractions + https://bugs.webkit.org/show_bug.cgi?id=31468 + + Adding isAlphanumeric abstraction, required + by TextBoundaries.cpp. + + * wtf/unicode/glib/UnicodeGLib.h: + (WTF::Unicode::isAlphanumeric): + * wtf/unicode/icu/UnicodeIcu.h: + (WTF::Unicode::isAlphanumeric): + +2009-11-13 Norbert Leser + + Reviewed by Eric Seidel. + + Added macros for USERINCLUDE paths within symbian blocks + to guarantee inclusion of respective header files from local path + first (to avoid clashes with same names of header files in system include path). + + * JavaScriptCore.pri: + +2009-11-13 Oliver Hunt + + Reviewed by Geoff Garen. + + JSValueProtect and JSValueUnprotect don't protect API wrapper values + https://bugs.webkit.org/show_bug.cgi?id=31485 + + Make JSValueProtect/Unprotect use a new 'toJS' function, 'toJSForGC' that + does not attempt to to strip out API wrapper objects. + + * API/APICast.h: + (toJSForGC): + * API/JSValueRef.cpp: + (JSValueProtect): + (JSValueUnprotect): + * API/tests/testapi.c: + (makeGlobalNumberValue): + (main): + +2009-11-13 İsmail Dönmez + + Reviewed by Antti Koivisto. + + Fix typo, ce_time.cpp should be ce_time.c + + * JavaScriptCore.pri: + +2009-11-12 Steve VanDeBogart + + Reviewed by Adam Barth. + + Calculate the time offset only if we were able to parse + the date string. This saves an IPC in Chromium for + invalid date strings. + https://bugs.webkit.org/show_bug.cgi?id=31416 + + * wtf/DateMath.cpp: + (WTF::parseDateFromNullTerminatedCharacters): + (JSC::parseDateFromNullTerminatedCharacters): + +2009-11-12 Oliver Hunt + + Rollout r50896 until i can work out why it causes failures. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitReturn): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + * parser/Nodes.cpp: + (JSC::EvalNode::emitBytecode): + +2009-11-12 Steve Falkenburg + + Reviewed by Stephanie Lewis. + + Remove LIBRARY directive from def file to fix Debug_All target. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-11-12 Gustavo Noronha Silva + + Rubber-stamped by Holger Freyther. + + Revert r50204, since it makes DRT crash on 32 bits release builds + for GTK+. + + * wtf/FastMalloc.h: + +2009-11-12 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Start unifying entry logic for function and eval code. + + Eval now uses a ret instruction to end execution, and sets up + a callframe more in line with what we do for function entry. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitReturn): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + * parser/Nodes.cpp: + (JSC::EvalNode::emitBytecode): + +2009-11-12 Richard Moe Gustavsen + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Disable pthread_setname_np. + + This allows Qt builds on Mac from 10.6 to run on earlier version + where this symbol is not present. + https://bugs.webkit.org/show_bug.cgi?id=31403 + + * wtf/Platform.h: + +2009-11-12 Thiago Macieira + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Fix linking on Linux 32-bit. + + It was missing the ".text" directive at the top of the file, + indicating that code would follow. Without it, the assembler created + "NOTYPE" symbols, which would result in linker errors. + https://bugs.webkit.org/show_bug.cgi?id=30863 + + * jit/JITStubs.cpp: + +2009-11-11 Laszlo Gombos + + Reviewed by Alexey Proskuryakov. + + Refactor multiple JavaScriptCore threads + https://bugs.webkit.org/show_bug.cgi?id=31328 + + Remove the id field from the PlatformThread structure + as it is not used. + + * runtime/Collector.cpp: + (JSC::getCurrentPlatformThread): + (JSC::suspendThread): + (JSC::resumeThread): + (JSC::getPlatformThreadRegisters): + +2009-11-10 Geoffrey Garen + + Linux build fix: Added an #include for UINT_MAX. + + * runtime/WeakRandom.h: + +2009-11-10 Geoffrey Garen + + JavaScriptGlue build fix: Marked a file 'private' instead of 'project'. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-11-10 Geoffrey Garen + + Reviewed by Gavin "avGni arBalroguch" Barraclough. + + Faster Math.random, based on GameRand. + + SunSpider says 1.4% faster. + + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: Added the header to the project. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: Use an object to track random number generation + state, initialized to the current time. + + * runtime/MathObject.cpp: + (JSC::MathObject::MathObject): + (JSC::mathProtoFuncRandom): Use the new hotness. + + * runtime/WeakRandom.h: Added. + (JSC::WeakRandom::WeakRandom): + (JSC::WeakRandom::get): + (JSC::WeakRandom::advance): The new hotness. + +2009-11-09 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Imported the v8 DST cache. + + SunSpider says 1.5% faster. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::resetDateCache): Reset the DST cache when resetting + other date data. + + * runtime/JSGlobalData.h: + (JSC::DSTOffsetCache::DSTOffsetCache): + (JSC::DSTOffsetCache::reset): Added a struct for the DST cache. + + * wtf/DateMath.cpp: + (WTF::calculateDSTOffsetSimple): + (WTF::calculateDSTOffset): + (WTF::parseDateFromNullTerminatedCharacters): + (JSC::getDSTOffset): + (JSC::gregorianDateTimeToMS): + (JSC::msToGregorianDateTime): + (JSC::parseDateFromNullTerminatedCharacters): + * wtf/DateMath.h: The imported code for probing and updating the cache. + +2009-11-09 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed an edge case that could cause the engine not to notice a timezone + change. + + No test because this case would require manual intervention to change + the timezone during the test. + + SunSpider reports no change. + + * runtime/DateInstanceCache.h: + (JSC::DateInstanceCache::DateInstanceCache): + (JSC::DateInstanceCache::reset): Added a helper function for resetting + this cache. Also, shrank the cache, since we'll be resetting it often. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::resetDateCache): Include resetting the DateInstanceCache + in resetting Date data. (Otherwise, a cache hit could bypass a necessary + timezone update check.) + +2009-11-09 Geoffrey Garen + + Reviewed by Sam Weinig. + + Some manual inlining and constant propogation in Date code. + + SunSpider reports a 0.4% speedup on date-*, no overall speedup. Shark + says some previously evident stalls are now gone. + + * runtime/DateConstructor.cpp: + (JSC::callDate): + * runtime/DateConversion.cpp: + (JSC::formatTime): + (JSC::formatTimeUTC): Split formatTime into UTC and non-UTC variants. + + * runtime/DateConversion.h: + * runtime/DateInstance.cpp: + (JSC::DateInstance::calculateGregorianDateTime): + (JSC::DateInstance::calculateGregorianDateTimeUTC): + * runtime/DateInstance.h: + (JSC::DateInstance::gregorianDateTime): + (JSC::DateInstance::gregorianDateTimeUTC): Split gregorianDateTime into + a UTC and non-UTC variant, and split each variant into a fast inline + case and a slow out-of-line case. + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Updated for the gregorianDateTime change above. + +2009-11-09 Geoffrey Garen + + Build fix: export a new symbol. + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-11-09 Geoffrey Garen + + Reviewed by Sam "Home Wrecker" Weinig. + + Added a tiny cache for Date parsing. + + SunSpider says 1.2% faster. + + * runtime/DateConversion.cpp: + (JSC::parseDate): Try to reuse the last parsed Date, if present. + + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::resetDateCache): + * runtime/JSGlobalData.h: Added storage for last parsed Date. Refactored + this code to make resetting the date cache easier. + + * runtime/JSGlobalObject.h: + (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Updated for + refactoring. + + * wtf/DateMath.cpp: + (JSC::parseDateFromNullTerminatedCharacters): + * wtf/DateMath.h: Changed ExecState to be first parameter, as is the JSC custom. + +2009-11-09 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Can cache prototype lookups on uncacheable dictionaries. + https://bugs.webkit.org/show_bug.cgi?id=31198 + + Replace fromDictionaryTransition with flattenDictionaryObject and + flattenDictionaryStructure. This change is necessary as we need to + guarantee that our attempt to convert away from a dictionary structure + will definitely succeed, and in some cases this requires mutating the + object storage itself. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCacheGetByID): + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCacheGetByID): + (JSC::DEFINE_STUB_FUNCTION): + * runtime/BatchedTransitionOptimizer.h: + (JSC::BatchedTransitionOptimizer::~BatchedTransitionOptimizer): + * runtime/JSObject.h: + (JSC::JSObject::flattenDictionaryObject): + * runtime/Operations.h: + (JSC::normalizePrototypeChain): + * runtime/Structure.cpp: + (JSC::Structure::flattenDictionaryStructure): + (JSC::comparePropertyMapEntryIndices): + * runtime/Structure.h: + +2009-11-09 Laszlo Gombos + + Not reviewed, build fix. + + Remove extra character from r50701. + + * JavaScriptCore.pri: + +2009-11-09 Laszlo Gombos + + Not reviewed, build fix. + + Revert r50695 because it broke QtWebKit (clean builds). + + * JavaScriptCore.pri: + +2009-11-09 Norbert Leser + + Reviewed by Kenneth Rohde Christiansen. + + Prepended $$PWD to GENERATED_SOURCES_DIR to avoid potential ambiguities when included from WebCore.pro. + Some preprocessors consider this GENERATED_SOURCES_DIR relative to current invoking dir (e.g., ./WebCore), + and not the working dir of JavaCriptCore.pri (i.e., ../JavaScriptCore/). + + * JavaScriptCore.pri: + +2009-11-09 Laszlo Gombos + + Reviewed by Kenneth Rohde Christiansen. + + Use explicit parentheses to silence gcc 4.4 -Wparentheses warnings + https://bugs.webkit.org/show_bug.cgi?id=31040 + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + +2009-11-08 David Levin + + Reviewed by NOBODY (speculative snow leopard and windows build fixes). + + * wtf/DateMath.cpp: + (WTF::parseDateFromNullTerminatedCharacters): + (JSC::gregorianDateTimeToMS): + (JSC::msToGregorianDateTime): + (JSC::parseDateFromNullTerminatedCharacters): + * wtf/DateMath.h: + (JSC::GregorianDateTime::GregorianDateTime): + +2009-11-08 David Levin + + Reviewed by NOBODY (chromium build fix). + + Hopefully, the last build fix. + + Create better separation in DateMath about the JSC + and non-JSC portions. Also, only expose the non-JSC + version in the exports. + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * wtf/DateMath.cpp: + (WTF::parseDateFromNullTerminatedCharacters): + (JSC::getUTCOffset): + (JSC::gregorianDateTimeToMS): + (JSC::msToGregorianDateTime): + (JSC::parseDateFromNullTerminatedCharacters): + * wtf/DateMath.h: + (JSC::gmtoffset): + +2009-11-08 David Levin + + Reviewed by NOBODY (chromium build fix). + + For the change in DateMath. + + * config.h: + * wtf/DateMath.cpp: + +2009-11-06 Geoffrey Garen + + Windows build fix: export some symbols. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-11-06 Geoffrey Garen + + Build fix: updated export file. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2009-11-06 Geoffrey Garen + + Build fix: added some #includes. + + * wtf/CurrentTime.h: + * wtf/DateMath.h: + +2009-11-06 Geoffrey Garen + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=31197 + Implemented a timezone cache not based on Mac OS X's notify_check API. + + If the VM calculates the local timezone offset from UTC, it caches the + result until the end of the current VM invocation. (We don't want to cache + forever, because the user's timezone may change over time.) + + This removes notify_* overhead on Mac, and, more significantly, removes + OS time and date call overhead on non-Mac platforms. + + ~8% speedup on Date microbenchmark on Mac. SunSpider reports maybe a tiny + speedup on Mac. (Speedup on non-Mac platforms should be even more noticeable.) + + * JavaScriptCore.exp: + + * interpreter/CachedCall.h: + (JSC::CachedCall::CachedCall): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + * runtime/JSGlobalObject.h: + (JSC::DynamicGlobalObjectScope::DynamicGlobalObjectScope): Made the + DynamicGlobalObjectScope constructor responsible for checking whether a + dynamicGlobalObject has already been set. This eliminated some duplicate + client code, and allowed me to avoid adding even more duplicate client + code. Made DynamicGlobalObjectScope responsible for resetting the + local timezone cache upon first entry to the VM. + + * runtime/DateConstructor.cpp: + (JSC::constructDate): + (JSC::callDate): + (JSC::dateParse): + (JSC::dateUTC): + * runtime/DateConversion.cpp: + (JSC::parseDate): + * runtime/DateConversion.h: + * runtime/DateInstance.cpp: + (JSC::DateInstance::gregorianDateTime): + * runtime/DateInstance.h: + * runtime/DateInstanceCache.h: + * runtime/DatePrototype.cpp: + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + * runtime/InitializeThreading.cpp: + (JSC::initializeThreadingOnce): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + * wtf/DateMath.cpp: + (WTF::getCurrentUTCTime): + (WTF::getCurrentUTCTimeWithMicroseconds): + (WTF::getLocalTime): + (JSC::getUTCOffset): Use the new cache. Also, see below. + (JSC::gregorianDateTimeToMS): + (JSC::msToGregorianDateTime): + (JSC::initializeDates): + (JSC::parseDateFromNullTerminatedCharacters): Simplified the way this function + accounts for the local timezone offset, to accomodate our new caching API, + and a (possibly misguided) caller in WebCore. Also, see below. + * wtf/DateMath.h: + (JSC::GregorianDateTime::GregorianDateTime): Moved most of the code in + DateMath.* into the JSC namespace. The code needed to move so it could + naturally interact with ExecState and JSGlobalData to support caching. + Logically, it seemed right to move it, too, since this code is not really + as low-level as the WTF namespace might imply -- it implements a set of + date parsing and conversion quirks that are finely tuned to the JavaScript + language. Also removed the Mac OS X notify_* infrastructure. + + * wtf/CurrentTime.h: + (WTF::currentTimeMS): + (WTF::getLocalTime): Moved the rest of the DateMath code here, and renamed + it to make it consistent with WTF's currentTime function. + +2009-11-06 Gabor Loki + + Unreviewed trivial buildfix after r50595. + + Rename the remaining rshiftPtr calls to rshift32 + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_rshift): + * jit/JITInlineMethods.h: + (JSC::JIT::emitFastArithImmToInt): + +2009-11-06 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Tidy up the shift methods on the macro-assembler interface. + + Currently behaviour of shifts of a magnitude > 0x1f is undefined. + Instead defined that all shifts are masked to this range. This makes a lot of + practical sense, both since having undefined behaviour is not particularly + desirable, and because this behaviour is commonly required (particularly since + it is required bt ECMA-262 for shifts). + + Update the ARM assemblers to provide this behaviour. Remove (now) redundant + masks from JITArithmetic, and remove rshiftPtr (this was used in case that + could be rewritten in a simpler form using rshift32, only optimized JSVALUE32 + on x86-64, which uses JSVALUE64!) + + * assembler/MacroAssembler.h: + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::lshift32): + (JSC::MacroAssemblerARM::rshift32): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::lshift32): + (JSC::MacroAssemblerARMv7::rshift32): + * assembler/MacroAssemblerX86_64.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emit_op_rshift): + +2009-11-05 Gavin Barraclough + + Rubber Stamped by Oliver Hunt. + + Remove a magic number (1) from the JIT, instead compute the value with OBJECT_OFFSET. + + * jit/JITInlineMethods.h: + (JSC::JIT::emitPutJITStubArg): + (JSC::JIT::emitPutJITStubArgConstant): + (JSC::JIT::emitGetJITStubArg): + (JSC::JIT::emitPutJITStubArgFromVirtualRegister): + * jit/JITStubCall.h: + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::getArgument): + * jit/JITStubs.h: + +2009-11-05 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + https://bugs.webkit.org/show_bug.cgi?id=31159 + Fix branchDouble behaviour on ARM THUMB2 JIT. + + The x86 branchDouble behaviour is reworked, and all JIT + ports should follow the x86 port. See bug 31104 and 31151 + + This patch contains a fix for the traditional ARM port + + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::): + (JSC::ARMAssembler::fmrs_r): + (JSC::ARMAssembler::ftosid_r): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::): + (JSC::MacroAssemblerARM::branchDouble): + (JSC::MacroAssemblerARM::branchConvertDoubleToInt32): + +2009-11-05 Chris Jerdonek + + Reviewed by Eric Seidel. + + Removed the "this is part of the KDE project" comments from + all *.h, *.cpp, *.idl, and *.pm files. + + https://bugs.webkit.org/show_bug.cgi?id=31167 + + The maintenance and architecture page in the project wiki lists + this as a task. + + This change includes no changes or additions to test cases + since the change affects only comments. + + * wtf/wince/FastMallocWince.h: + +2009-11-05 Gabor Loki + + Reviewed by Gavin Barraclough. + + Use ARMv7 specific encoding for immediate constants on ARMv7 target + https://bugs.webkit.org/show_bug.cgi?id=31060 + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::getOp2): Use INVALID_IMM + (JSC::ARMAssembler::getImm): Use encodeComplexImm for complex immediate + (JSC::ARMAssembler::moveImm): Ditto. + (JSC::ARMAssembler::encodeComplexImm): Encode a constant by one or two + instructions or a PC relative load. + * assembler/ARMAssembler.h: Use INVALID_IMM if a constant cannot be + encoded as an immediate constant. + (JSC::ARMAssembler::): + (JSC::ARMAssembler::movw_r): 16-bit immediate load + (JSC::ARMAssembler::movt_r): High halfword 16-bit immediate load + (JSC::ARMAssembler::getImm16Op2): Encode immediate constant for + movw_r and mowt_r + +2009-11-04 Mark Mentovai + + Reviewed by Mark Rowe. + + Provide TARGETING_TIGER and TARGETING_LEOPARD as analogues to + BUILDING_ON_TIGER and BUILDING_ON_LEOPARD. The TARGETING_ macros + consider the deployment target; the BUILDING_ON_ macros consider the + headers being built against. + + * wtf/Platform.h: + +2009-11-04 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=31151 + Fix branchDouble behaviour on ARM THUMB2 JIT. + + The ARMv7 JIT is currently using ARMv7Assembler::ConditionEQ to branch + for DoubleEqualOrUnordered, however this is incorrect – ConditionEQ won't + branch on unordered operands. Similarly, DoubleLessThanOrUnordered & + DoubleLessThanOrEqualOrUnordered use ARMv7Assembler::ConditionLO & + ARMv7Assembler::ConditionLS, whereas they should be using + ARMv7Assembler::ConditionLT & ARMv7Assembler::ConditionLE. + + Fix these, and fill out the missing DoubleConditions. + + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::): + (JSC::MacroAssemblerARMv7::branchDouble): + +2009-11-04 Gavin Barraclough + + Rubber Stamped by Oliver Hunt. + + Enable native call optimizations on ARMv7. (Existing ARM_TRADITIONAL + implementation was generic, worked perfectly, just needed turning on). + + * jit/JITOpcodes.cpp: + * wtf/Platform.h: + +2009-11-04 Gavin Barraclough + + Rubber Stamped by Mark Rowe, Oliver Hunt, and Sam Weinig. + + Add a missing assert to the ARMv7 JIT. + + * assembler/ARMv7Assembler.h: + (JSC::ARMThumbImmediate::ARMThumbImmediate): + +2009-11-04 Mark Rowe + + Rubber-stamped by Oliver Hunt. + + Remove bogus op_ prefix on dumped version of three opcodes. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + +2009-11-04 Mark Rowe + + Reviewed by Sam Weinig. + + Fix dumping of constants in bytecode so that they aren't printed as large positive register numbers. + + We do this by having the registerName function return information about the constant if the register + number corresponds to a constant. This requires that registerName, and several functions that call it, + be converted to member functions of CodeBlock so that the constant value can be retrieved. The + ExecState also needs to be threaded down through these functions so that it can be passed on to + constantName when needed. + + * bytecode/CodeBlock.cpp: + (JSC::constantName): + (JSC::CodeBlock::registerName): + (JSC::CodeBlock::printUnaryOp): + (JSC::CodeBlock::printBinaryOp): + (JSC::CodeBlock::printConditionalJump): + (JSC::CodeBlock::printGetByIdOp): + (JSC::CodeBlock::printPutByIdOp): + (JSC::CodeBlock::dump): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::isConstantRegisterIndex): + +2009-11-04 Pavel Heimlich + + Reviewed by Alexey Proskuryakov. + + https://bugs.webkit.org/show_bug.cgi?id=30647 + Solaris build failure due to strnstr. + + * wtf/StringExtras.h: Enable strnstr on Solaris, too. + +2009-11-04 Gavin Barraclough + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=31104 + Refactor x86-specific behaviour out of the JIT. + + - Add explicit double branch conditions for ordered and unordered comparisons (presently the brehaviour is a mix). + - Refactor double to int conversion out into the MacroAssembler. + - Remove broken double to int conversion for !JSVALUE32_64 builds - this code was broken and slowing us down, fixing it showed it not to be an improvement. + - Remove exclusion of double to int conversion from (1 % X) cases in JSVALUE32_64 builds - if this was of benefit this is no longer the case; simplify. + + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::): + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::): + (JSC::MacroAssemblerX86Common::convertInt32ToDouble): + (JSC::MacroAssemblerX86Common::branchDouble): + (JSC::MacroAssemblerX86Common::branchConvertDoubleToInt32): + * jit/JITArithmetic.cpp: + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_div): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emitSlow_op_jnlesseq): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jfalse): + +2009-11-04 Mark Mentovai + + Reviewed by Eric Seidel. + + Remove BUILDING_ON_LEOPARD from JavaScriptCore.gyp. This is supposed + to be set as needed only in wtf/Platform.h. + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + +2009-11-02 Oliver Hunt + + Reviewed by Gavin Barraclough. + + REGRESSION (r48573): JSC may incorrectly cache chain lookups with a dictionary at the head of the chain + https://bugs.webkit.org/show_bug.cgi?id=31045 + + Add guards to prevent caching of prototype chain lookups with dictionaries at the + head of the chain. Also add a few tighter assertions to cached prototype lookups + to catch this in future. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCacheGetByID): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCacheGetByID): + +2009-11-02 Laszlo Gombos + + Reviewed by Darin Adler. + + PLATFORM(CF) should be set when building for Qt on Darwin + https://bugs.webkit.org/show_bug.cgi?id=23671 + + * wtf/Platform.h: Turn on CF support if both QT and DARWIN + platforms are defined. + +2009-11-02 Dmitry Titov + + Reviewed by David Levin. + + Remove threadsafe refcounting from tasks used with WTF::MessageQueue. + https://bugs.webkit.org/show_bug.cgi?id=30612 + + * wtf/MessageQueue.h: + (WTF::MessageQueue::alwaysTruePredicate): + (WTF::MessageQueue::~MessageQueue): + (WTF::MessageQueue::append): + (WTF::MessageQueue::appendAndCheckEmpty): + (WTF::MessageQueue::prepend): + (WTF::MessageQueue::waitForMessage): + (WTF::MessageQueue::waitForMessageFilteredWithTimeout): + (WTF::MessageQueue::tryGetMessage): + (WTF::MessageQueue::removeIf): + The MessageQueue is changed to act as a queue of OwnPtr. It takes ownership + of posted tasks and passes it to the new owner (in another thread) when the task is fetched. + All methods have arguments of type PassOwnPtr and return the same type. + + * wtf/Threading.cpp: + (WTF::createThread): + Superficial change to trigger rebuild of JSC project on Windows, + workaround for https://bugs.webkit.org/show_bug.cgi?id=30890 + +2009-10-30 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed failing layout test: restore a special case I accidentally deleted. + + * runtime/DatePrototype.cpp: + (JSC::setNewValueFromDateArgs): In the case of applying a change to a date + that is NaN, reset the date to 0 *and* then apply the change; don't just + reset the date to 0. + +2009-10-30 Geoffrey Garen + + Windows build fix: update for object-to-pointer change. + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + +2009-10-29 Geoffrey Garen + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=30942 + Use pointers instead of copies to pass GregorianDateTime objects around. + + SunSpider reports a shocking 4.5% speedup on date-format-xparb, and 1.3% + speedup on date-format-tofte. + + * runtime/DateInstance.cpp: + (JSC::DateInstance::gregorianDateTime): + * runtime/DateInstance.h: + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Renamed getGregorianDateTime to gregorianDateTime, + since it no longer has an out parameter. Uses 0 to indicate invalid dates. + +2009-10-30 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's ListHashSet + https://bugs.webkit.org/show_bug.cgi?id=30853 + + Inherits ListHashSet class from FastAllocBase because it is + instantiated by 'new' in WebCore/rendering/RenderBlock.cpp:1813. + + * wtf/ListHashSet.h: + +2009-10-30 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Regression: crash enumerating properties of an object with getters or setters + https://bugs.webkit.org/show_bug.cgi?id=30948 + + Add a guard to prevent us trying to cache property enumeration on + objects with getters or setters. + + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::create): + +2009-10-30 Roland Steiner + + Reviewed by Eric Seidel. + + Remove ENABLE_RUBY guards as discussed with Dave Hyatt and Maciej Stachowiak. + + Bug 28420 - Implement HTML5 rendering + (https://bugs.webkit.org/show_bug.cgi?id=28420) + + No new tests (no functional change). + + * Configurations/FeatureDefines.xcconfig: + +2009-10-29 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + REGRESSION (r50218-r50262): E*TRADE accounts page is missing content + https://bugs.webkit.org/show_bug.cgi?id=30947 + + + The logic for flagging that a structure has non-enumerable properties + was in addPropertyWithoutTransition, rather than in the core Structure::put + method. Despite this I was unable to produce a testcase that caused + the failure that etrade was experiencing, but the new assertion in + getEnumerablePropertyNames triggers on numerous layout tests without + the fix, so in effecti all for..in enumeration in any test ends up + doing the required consistency check. + + * runtime/Structure.cpp: + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::put): + (JSC::Structure::getEnumerablePropertyNames): + (JSC::Structure::checkConsistency): + +2009-10-29 Gabor Loki + + Reviewed by Gavin Barraclough. + + Add cacheFlush support for Thumb-2 on Linux + https://bugs.webkit.org/show_bug.cgi?id=30865 + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-10-28 Gavin Barraclough + + Reviewed by Oliver Hunt. + + JSC JIT on ARMv7 cannot link jumps >16Mb range + https://bugs.webkit.org/show_bug.cgi?id=30891 + + Start planing all relative jumps as move-32-bit-immediate-to-register-BX. + In the cases where the jump would fall within a relative jump range, use a relative jump. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * assembler/ARMv7Assembler.h: + (JSC::ARMv7Assembler::~ARMv7Assembler): + (JSC::ARMv7Assembler::LinkRecord::LinkRecord): + (JSC::ARMv7Assembler::): + (JSC::ARMv7Assembler::executableCopy): + (JSC::ARMv7Assembler::linkJump): + (JSC::ARMv7Assembler::relinkJump): + (JSC::ARMv7Assembler::setInt32): + (JSC::ARMv7Assembler::isB): + (JSC::ARMv7Assembler::isBX): + (JSC::ARMv7Assembler::isMOV_imm_T3): + (JSC::ARMv7Assembler::isMOVT): + (JSC::ARMv7Assembler::isNOP_T1): + (JSC::ARMv7Assembler::isNOP_T2): + (JSC::ARMv7Assembler::linkJumpAbsolute): + (JSC::ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmFirst): + (JSC::ARMv7Assembler::twoWordOp5i6Imm4Reg4EncodedImmSecond): + (JSC::ARMv7Assembler::ARMInstructionFormatter::twoWordOp5i6Imm4Reg4EncodedImm): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::makeJump): + (JSC::MacroAssemblerARMv7::makeBranch): + * jit/JIT.h: + * wtf/Platform.h: + +2009-10-28 Oliver Hunt + + Reviewed by Geoff Garen. + + Improve for..in enumeration performance + https://bugs.webkit.org/show_bug.cgi?id=30887 + + Improve indexing of an object with a for..in iterator by + identifying cases where get_by_val is being used with a iterator + as the subscript and replace it with a new get_by_pname + bytecode. get_by_pname then optimizes lookups that directly access + the base object. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetByVal): + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::pushOptimisedForIn): + (JSC::BytecodeGenerator::popOptimisedForIn): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::compileGetDirectOffset): + (JSC::JIT::emit_op_get_by_pname): + (JSC::JIT::emitSlow_op_get_by_pname): + * parser/Nodes.cpp: + (JSC::ForInNode::emitBytecode): + * runtime/JSObject.h: + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::create): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::getOffset): + (JSC::JSPropertyNameIterator::JSPropertyNameIterator): + * runtime/JSValue.h: + (JSC::JSValue::): + * runtime/Structure.cpp: + (JSC::Structure::addPropertyTransition): + (JSC::Structure::changePrototypeTransition): + (JSC::Structure::despecifyFunctionTransition): + (JSC::Structure::addAnonymousSlotsTransition): + (JSC::Structure::getterSetterTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::addPropertyWithoutTransition): + Track the existence (or not) of non-enumerable properties. + * runtime/Structure.h: + (JSC::Structure::propertyStorageCapacity): + (JSC::Structure::propertyStorageSize): + (JSC::Structure::hasNonEnumerableProperties): + (JSC::Structure::hasAnonymousSlots): + +2009-10-28 Dmitry Titov + + Not reviewed, attemp to fix Windows build. + + Touch the cpp file to cause recompile. + + * wtf/Threading.cpp: + (WTF::threadEntryPoint): + +2009-10-28 Dmitry Titov + + Reviewed by David Levin. + + https://bugs.webkit.org/show_bug.cgi?id=30805 + Add MessageQueue::removeIf(Predicate&) to remove certain tasks without pulling them from the queue. + Existing Database tests cover this since Database removes tasks when it is stopped. + + * wtf/MessageQueue.h: + (WTF::::removeIf): + +2009-10-28 Afonso R. Costa Jr. + + Reviewed by Oliver Hunt. + + [Qt] Enable YARR when YARR_JIT is enabled + https://bugs.webkit.org/show_bug.cgi?id=30730 + + When enabling or disabling JIT using JAVASCRIPTCORE_JIT, the ENABLE_YARR should + be toggled also. + + * JavaScriptCore.pri: + +2009-10-24 Martin Robinson + + Reviewed by Oliver Hunt. + + Fix strict aliasing warning by switching reinterpret_cast to bitwise_cast. + + strict-aliasing warnings in JSFunction.h + https://bugs.webkit.org/show_bug.cgi?id=27869 + + * runtime/JSFunction.h: + (JSC::JSFunction::nativeFunction): + (JSC::JSFunction::scopeChain): + (JSC::JSFunction::setScopeChain): + (JSC::JSFunction::setNativeFunction): + +2009-10-28 Jan-Arve Sæther + + Reviewed by Tor Arne Vestbø. + + Build-fix for 64-bit Windows + + * wtf/Platform.h: Make sure to use WTF_USE_JSVALUE64 + +2009-10-28 Gavin Barraclough + + Reviewed by NOBODY (build fix!). + + * jit/JIT.h: + +2009-10-26 Holger Hans Peter Freyther + + Rubber-stamped by Darin Adler. + + Export fastMalloc, fastCalloc, fastRealloc and fastFree on GCC/Unix + https://bugs.webkit.org/show_bug.cgi?id=30769 + + When using -fvisibility=hidden to hide all internal symbols by default + the malloc symbols will be hidden as well. For memory instrumentation + it is needed to provide an instrumented version of these symbols and + override the normal routines and by changing the visibility back to + default this becomes possible. + + The only other solution would be to use system malloc instead of the + TCmalloc implementation but this will not allow to analyze memory + behavior with the default allocator. + + * wtf/FastMalloc.h: Define WTF_FAST_MALLOC_EXPORT for GCC and !darwin + +2009-10-27 Gavin Barraclough + + Rubber Stamped by Samuel Q. Weinig. + + Make the asserts protecting the offsets in the JIT more descriptive. + + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compileGetByIdSlowCase): + (JSC::JIT::emit_op_put_by_id): + +2009-10-27 Geoffrey Garen + + Reviewed by Sam Weinig. + + A little bit of refactoring in the date code. + + * JavaScriptCore.exp: Don't export this unused symbol. + + * runtime/DateConstructor.cpp: + (JSC::constructDate): + + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + * runtime/DateInstance.h: Removed some unused functions. Changed the default + constructor to ensure that a DateInstance is always initialized. + + * runtime/DatePrototype.cpp: + (JSC::DatePrototype::DatePrototype): Pass an initializer to our constructor, + since it now requires one. + + * wtf/DateMath.cpp: + (WTF::msToGregorianDateTime): Only compute our offset from UTC if our + output will require it. Otherwise, our offset is 0. + +2009-10-27 Geoffrey Garen + + Build fix: Mark DateInstaceCache.h private, so other frameworks can see it. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-10-27 Geoffrey Garen + + Build fix: re-readded this file. + + * runtime/DateInstanceCache.h: Added. + (JSC::DateInstanceData::create): + (JSC::DateInstanceData::DateInstanceData): + (JSC::DateInstanceCache::DateInstanceCache): + (JSC::DateInstanceCache::add): + (JSC::DateInstanceCache::lookup): + +2009-10-27 Geoffrey Garen + + Reviewed by Darin Adler and Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=30800 + Cache recently computed date data. + + SunSpider reports a ~0.5% speedup, mostly from date-format-tofte.js. + + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: Added new file. + + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + (JSC::DateInstance::getGregorianDateTime): Use the shared cache. + + * runtime/DateInstance.h: Renamed m_cache to m_data, to avoid the confusion + of a "cache cache". + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Pass an ExecState to these functions, so they + can access the DateInstanceCache. + + * runtime/JSGlobalData.h: Keep a DateInstanceCache. + +2009-10-27 James Robinson + + Reviewed by Darin Fisher. + + Ensures that JavaScriptCore/wtf/CurrentTime.cpp is not built in PLATFORM(CHROMIUM) builds. + + Chromium uses a different method to calculate the current time than is used in + JavaScriptCore/wtf/CurrentTime.cpp. This can lead to time skew when calls to currentTime() and Chromium's time + function are mixed. In particular, timers can get scheduled in the past which leads to 100% CPU use. + See http://code.google.com/p/chromium/issues/detail?id=25892 for an example. + + https://bugs.webkit.org/show_bug.cgi?id=30833 + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + * wtf/CurrentTime.cpp: + +2009-10-27 Peter Varga + + Rubber-stamped by Tor Arne Vestbø. + + Fix typo in RegexInterpreter.cpp and RegexJIT.cpp alterantive to + alternative. + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::ByteCompiler::alternativeBodyDisjunction): + (JSC::Yarr::ByteCompiler::alternativeDisjunction): + (JSC::Yarr::ByteCompiler::emitDisjunction): + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateDisjunction): + +2009-10-26 Laszlo Gombos + + Reviewed by Darin Adler. + + Make .rc files compile on Windows without depending on MFC headers + https://bugs.webkit.org/show_bug.cgi?id=30750 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: Use + winresrc.h because it exists even when MFC is not installed, and is + all that's needed here. + +2009-10-26 Gabor Loki + + Reviewed by Gavin Barraclough. + + The thunkReturnAddress is on JITStackFrame on ARM JIT as well + https://bugs.webkit.org/show_bug.cgi?id=30782 + + Move the thunkReturnAddress from top of the stack into the JITStackFrame + structure. This is a requirement for JSValue32_64 support on ARM. + + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::ret): Return with link register + (JSC::MacroAssemblerARM::prepareCall): Store the return address in link register + * jit/JIT.h: Remove unused ctiReturnRegister + * jit/JITInlineMethods.h: Same as ARMv7 + (JSC::JIT::restoreArgumentReference): Ditto. + (JSC::JIT::restoreArgumentReferenceForTrampoline): Ditto. + * jit/JITOpcodes.cpp: Remove ctiReturnRegister related instruction + * jit/JITStubs.cpp: Store thunkReturnAddress on JITStackFrame. Use + small trampoline functions which handle return addresses for each + CTI_STUB_FUNCTION. + * jit/JITStubs.h: Store thunkReturnAddress on JITStackFrame + (JSC::JITStackFrame::returnAddressSlot): Return with the address of thunkReturnAddress + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateEnter): Remove the unnecessary instruction + +2009-10-26 Steve Block + + Reviewed by Darin Adler. + + Adds ability to disable ReadWriteLock on platforms (eg Android) that use pthreads but do not support pthread_rwlock. + https://bugs.webkit.org/show_bug.cgi?id=30713 + + * wtf/Platform.h: Modified. Defines HAVE_PTHREAD_RWLOCK for all platforms currently using pthreads. + * wtf/Threading.h: Modified. Use pthread_rwlock_t only when HAVE_PTHREAD_RWLOCK is defined. + * wtf/ThreadingPthreads.cpp: Modified. Build ReadWriteLock methods only when HAVE_PTHREAD_RWLOCK is defined. + +2009-10-24 Laszlo Gombos + + Reviewed by Holger Freyther. + + [Qt] [Symbian] Set the capability and memory required to run QtWebKit for Symbian + https://bugs.webkit.org/show_bug.cgi?id=30476 + + Assign ReadUserData WriteUserData NetworkServices Symbian capabilities + to jsc.exe. + + * jsc.pro: + +2009-10-23 Steve Block + + Reviewed by Dmitry Titov. + + Fixes a leak in createThreadInternal on Android. + https://bugs.webkit.org/show_bug.cgi?id=30698 + + * wtf/ThreadingPthreads.cpp: Modified. + (WTF::createThreadInternal): Avoid leaking a ThreadData object on failure. + +2009-10-22 Geoffrey Garen + + Reviewed by Alexey Proskuryakov. + + Fixed ASSERT when opening Safari's Caches window while the Web Inspector + is open. + + * runtime/Collector.cpp: + (JSC::typeName): Added two new types to the type name list in the Collector. + These types have been around for a while, but nobody remembered to consider them here. + + * runtime/JSCell.h: + (JSC::JSCell::isPropertyNameIterator): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::isPropertyNameIterator): Give the Collector + a way to tell if a cell is a JSPropertyNameIterator. + +2009-10-22 Steve Falkenburg + + Reviewed by Jon Honeycutt. + + https://bugs.webkit.org/show_bug.cgi?id=30686 + Remove debug-specific def file. + Only Debug_All target uses JavaScriptCore_debug.dll naming, and since + that target is only used internally, maintaining two files just to + suppress a single link warning isn't worthwhile. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Removed. + +2009-10-21 Jon Honeycutt + + Screenshots of off-screen plug-ins are blank + After halting a transparent PluginView on + Windows, the transparency is applied twice + + Reviewed by Dan Bernstein. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + Export WTF::deleteOwnedPtr(HDC). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + Ditto. + +2009-10-20 Geoffrey Garen + + Windows build fix: updated variable name. + + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + +2009-10-20 Geoffrey Garen + + Reviewed by Mark Rowe. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): Slightly tweaked this #ifdef to match the + size of a JSValue because m_jsStrings is an array of JSValues. + +2009-10-20 Geoffrey Garen + + Reviewed by Mark Rowe. + + Fixed a 64-bit regression caused by the fix for + https://bugs.webkit.org/show_bug.cgi?id=30570. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): Use TimesEight stepping on 64-bit, since + 64-bit pointers are eight bytes long. + +2009-10-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Refactored DateInstance::msToGregorianDateTime so that a DateInstance's + caller doesn't need to supply the DateInstance's own internal value to + the DateInstance. + + * runtime/DateInstance.cpp: + (JSC::DateInstance::getGregorianDateTime): Renamed from "msToGregorianDateTime". + + * runtime/DateInstance.h: + * runtime/DatePrototype.cpp: + (JSC::formatLocaleDate): + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncToLocaleString): + (JSC::dateProtoFuncToLocaleDateString): + (JSC::dateProtoFuncToLocaleTimeString): + (JSC::dateProtoFuncGetTime): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): Also renamed "utc" to "outputIsUTC", for clarity. + +2009-10-20 Gabor Loki + + Reviewed by Geoffrey Garen. + + The op_next_pname should use 4 bytes addressing mode in case of JSValue32 + https://bugs.webkit.org/show_bug.cgi?id=30570 + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_next_pname): + +2009-10-20 Gabor Loki + + Reviewed by Oliver Hunt. + + Move OverridesMarkChildren flag from DatePrototype to its parent class + https://bugs.webkit.org/show_bug.cgi?id=30372 + + * runtime/DateInstance.h: + (JSC::DateInstance::createStructure): + * runtime/DatePrototype.h: + +2009-10-19 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Tightened up some put_by_id_transition code generation. + https://bugs.webkit.org/show_bug.cgi?id=30539 + + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::testPrototype): + (JSC::JIT::privateCompilePutByIdTransition): No need to do object type + checks or read Structures and prototypes from objects: they're all known + constants at compile time. + +2009-10-19 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added a private API for getting a global context from a context, for + clients who want to preserve a context for a later callback. + + * API/APICast.h: + (toGlobalRef): Added an ASSERT, since this function is used more often + than before. + + * API/JSContextRef.cpp: + * API/JSContextRefPrivate.h: Added. The new API. + + * API/tests/testapi.c: + (print_callAsFunction): + (main): Test the new API. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: Build and export the new API. + +2009-10-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Tightened up some instanceof code generation. + https://bugs.webkit.org/show_bug.cgi?id=30488 + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emitSlow_op_instanceof): No need to do object type checks - + cell type checks and ImplementsDefaultHasIntance checks implicitly + supersede object type checks. + +2009-10-18 Kwang Yul Seo + + Reviewed by Darin Adler. + + Use _stricmp and _strnicmp instead of deprecated stricmp and strnicmp. + https://bugs.webkit.org/show_bug.cgi?id=30474 + + stricmp and strnicmp are deprecated beginning in Visual + C++ 2005. Use _stricmp and _strnicmp instead in StringExtras.h. + + * wtf/StringExtras.h: + (strncasecmp): + (strcasecmp): + +2009-10-16 Geoffrey Garen + + Build fix: apparently we shouldn't export those symbols? + + * JavaScriptCore.exp: + +2009-10-16 Geoffrey Garen + + Build fix: export some symbols. + + * JavaScriptCore.exp: + +2009-10-16 Oliver Hunt + + Reviewed by Gavin Barraclough. + + structure typeinfo flags should be inherited. + https://bugs.webkit.org/show_bug.cgi?id=30468 + + Add StructureFlag constant to the various JSC classes and use + it for the TypeInfo construction. This allows us to simply + accumulate flags by basing each classes StructureInfo on its parents. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSByteArray.h: + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fast for-in enumeration: Cache JSPropertyNameIterator; cache JSStrings + in JSPropertyNameIterator; inline more code. + + 1.024x as fast on SunSpider (fasta: 1.43x as fast). + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetPropertyNames): + (JSC::BytecodeGenerator::emitNextPropertyName): + * bytecompiler/BytecodeGenerator.h: Added a few extra operands to + op_get_pnames and op_next_pname so that we can track iteration state + in the register file instead of in the JSPropertyNameIterator. (To be + cacheable, the JSPropertyNameIterator must be stateless.) + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCachePutByID): + (JSC::Interpreter::tryCacheGetByID): Updated for rename to + "normalizePrototypeChain" and removal of "isCacheable". + + (JSC::Interpreter::privateExecute): Updated for in-RegisterFile + iteration state tracking. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_get_pnames): Updated for in-RegisterFile + iteration state tracking. + + (JSC::JIT::emit_op_next_pname): Inlined code generation for op_next_pname. + + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): Updated for rename to + "normalizePrototypeChain" and removal of "isCacheable". + + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): Added has_property and to_object stubs. Removed op_next_pname + stub, since has_property is all we need anymore. + + * parser/Nodes.cpp: + (JSC::ForInNode::emitBytecode): Updated for in-RegisterFile + iteration state tracking. + + * runtime/JSCell.h: + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): Don't do caching at this layer + anymore, since we don't create a JSPropertyNameIterator at this layer. + + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::create): Do do caching at this layer. + (JSC::JSPropertyNameIterator::get): Updated for in-RegisterFile + iteration state tracking. + (JSC::JSPropertyNameIterator::markChildren): Mark our JSStrings. + + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::size): + (JSC::JSPropertyNameIterator::setCachedStructure): + (JSC::JSPropertyNameIterator::cachedStructure): + (JSC::JSPropertyNameIterator::setCachedPrototypeChain): + (JSC::JSPropertyNameIterator::cachedPrototypeChain): + (JSC::JSPropertyNameIterator::JSPropertyNameIterator): + (JSC::Structure::setEnumerationCache): Don't store iteration state in + a JSPropertyNameIterator. Do cache a JSPropertyNameIterator in a + Structure. + + * runtime/JSValue.h: + (JSC::asCell): + * runtime/MarkStack.h: Make those mischievous #include gods happy. + + * runtime/ObjectConstructor.cpp: + + * runtime/Operations.h: + (JSC::normalizePrototypeChain): Renamed countPrototypeChainEntriesAndCheckForProxies + to normalizePrototypeChain, since it changes dictionary prototypes to + non-dictionary objects. + + * runtime/PropertyNameArray.cpp: + (JSC::PropertyNameArray::add): + * runtime/PropertyNameArray.h: + (JSC::PropertyNameArrayData::PropertyNameArrayData): + (JSC::PropertyNameArray::data): + (JSC::PropertyNameArray::size): + (JSC::PropertyNameArray::begin): + (JSC::PropertyNameArray::end): Simplified some code here to help with + current and future refactoring. + + * runtime/Protect.h: + * runtime/Structure.cpp: + (JSC::Structure::~Structure): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::removePropertyWithoutTransition): No need to clear + the enumeration cache with adding / removing properties without + transition. It is an error to add / remove properties without transition + once an object has been observed, and we can ASSERT to catch that. + + * runtime/Structure.h: + (JSC::Structure::enumerationCache): Changed the enumeration cache to + hold a JSPropertyNameIterator. + + * runtime/StructureChain.cpp: + * runtime/StructureChain.h: + (JSC::StructureChain::head): Removed StructureChain::isCacheable because + it was wrong-headed in two ways: (1) It gave up when a prototype was a + dictionary, but instead we want un-dictionary heavily accessed + prototypes; (2) It folded a test for hasDefaultGetPropertyNames() into + a generic test for "cacheable-ness", but hasDefaultGetPropertyNames() + is only releavant to for-in caching. + +2009-10-16 Steve Falkenburg + + Reviewed by Adam Roben. + + Add a Debug_All configuration to build entire stack as debug. + Change Debug_Internal to: + - stop using _debug suffix for all WebKit/Safari binaries + - not use _debug as a DLL naming suffix + - use non-debug C runtime lib. + + * JavaScriptCore.vcproj/JavaScriptCore.make: Debug build in makefile should build Debug_All. + * JavaScriptCore.vcproj/JavaScriptCore.sln: Add Debug_All configuration. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: Renamed single configuration from "Release" to "all". + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: Add Debug_All configuration. + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/jsc/jsc.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Add Debug_All configuration. + +2009-10-16 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Last part -- replace HasDefaultGetPropertyNames with OverridesGetPropertyNames + flag. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/JSAPIValueWrapper.h: + (JSC::JSAPIValueWrapper::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesGetPropertyNames): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + * runtime/StructureChain.cpp: + (JSC::StructureChain::isCacheable): + +2009-10-16 Kevin Ollivier + + wxMSW build fix, we can't use the simple hash there because the PlatformModuleVersion + structure differs. + + * wtf/Platform.h: + +2009-10-16 Laszlo Gombos + + Reviewed by Simon Hausmann. + + [Qt] Implement ExecutableAllocator for Symbian + https://bugs.webkit.org/show_bug.cgi?id=29946 + + Tested with YARR JIT enabled for Symbian; + This patch does not (yet) enable YARR JIT by default. + + * JavaScriptCore.pri: + * jit/ExecutableAllocator.h: + * jit/ExecutableAllocatorSymbian.cpp: Added. + (JSC::ExecutableAllocator::intializePageSize): + (JSC::ExecutablePool::systemAlloc): + (JSC::ExecutablePool::systemRelease): + +2009-10-15 Oliver Hunt + + Reviewed by Darin Adler. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Part 2 -- Reverse the TypeInfo HasDefaultMark flag to OverridesMarkChildren, etc + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GetterSetter.h: + (JSC::GetterSetter::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSAPIValueWrapper.h: + (JSC::JSAPIValueWrapper::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + (JSC::MarkStack::markChildren): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSString.h: + (JSC::JSString::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesMarkChildren): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-14 Oliver Hunt + + Reviewed by Geoff Garen. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Part 1. Reverse the HasStandardGetOwnPropertySlot flag. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + (JSC::JSCell::fastGetOwnPropertySlot): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSString.h: + (JSC::JSString::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesGetOwnPropertySlot): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-14 Kevin Ollivier +2009-10-14 Darin Adler + + Additions so fix for https://bugs.webkit.org/show_bug.cgi?id=18994 + can build on Windows. + + * wtf/MathExtras.h: Added llround and llroundf for Windows. + +2009-10-14 Kevin Ollivier + + wx build fix. Set ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH for plugins while we're still building stubs. + + * wtf/Platform.h: + +2009-10-13 Laszlo Gombos + + Reviewed by Simon Hausmann. + + Refactor ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH + https://bugs.webkit.org/show_bug.cgi?id=30278 + + Move the definition of ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH + from the make system into common code. + + * wtf/Platform.h: + +2009-10-13 Laszlo Gombos + + Reviewed by Darin Adler. + + ARM compiler does not understand reinterpret_cast + https://bugs.webkit.org/show_bug.cgi?id=29034 + + Change reinterpret_cast to regular C style (void*) cast + for the ARM RVCT compiler. + + * assembler/MacroAssemblerCodeRef.h: + (JSC::FunctionPtr::FunctionPtr): + * jit/JITOpcodes.cpp: Cast to FunctionPtr first + instead of directly casting to reinterpret_cast + * jit/JITStubCall.h: Ditto + change the type of m_stub + from void* to FunctionPtr. + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::call): + * jit/JITStubs.cpp: Ditto. + (JSC::DEFINE_STUB_FUNCTION(EncodedJSValue, op_throw)): + +2009-10-11 Oliver Hunt + + Re-enable the JIT. + + * wtf/Platform.h: + +2009-10-10 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Support for String.trim(), String.trimLeft() and String.trimRight() methods + https://bugs.webkit.org/show_bug.cgi?id=26590 + + Implement trim, trimLeft, and trimRight + + * runtime/StringPrototype.cpp: + (JSC::isTrimWhitespace): + Our normal string whitespace function does not include U+200B which + is needed for compatibility with mozilla's implementation of trim. + U+200B does not appear to be expected according to spec, however I am + choosing to be lax, and match mozilla behavior so have added this + exception. + (JSC::trimString): + +2009-10-09 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Eliminated some legacy bytecode weirdness. + + Use vPC[x] subscripting instead of ++vPC to access instruction operands. + This is simpler, and often more efficient. + + To support this, and to remove use of hard-coded offsets in bytecode and + JIT code generation and dumping, calculate jump offsets from the beginning + of an instruction, rather than the middle or end. + + Also, use OPCODE_LENGTH instead of hard-coded constants for the sizes of + opcodes. + + SunSpider reports no change in JIT mode, and a 1.01x speedup in Interpreter + mode. + + * bytecode/CodeBlock.cpp: + (JSC::printConditionalJump): + (JSC::CodeBlock::dump): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitJump): + (JSC::BytecodeGenerator::emitJumpIfTrue): + (JSC::BytecodeGenerator::emitJumpIfFalse): + (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall): + (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply): + (JSC::BytecodeGenerator::emitComplexJumpScopes): + (JSC::BytecodeGenerator::emitJumpScopes): + (JSC::BytecodeGenerator::emitNextPropertyName): + (JSC::BytecodeGenerator::emitCatch): + (JSC::BytecodeGenerator::emitJumpSubroutine): + (JSC::prepareJumpTableForImmediateSwitch): + (JSC::prepareJumpTableForCharacterSwitch): + (JSC::prepareJumpTableForStringSwitch): + (JSC::BytecodeGenerator::endSwitch): + * bytecompiler/Label.h: + (JSC::Label::setLocation): + (JSC::Label::bind): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::resolve): + (JSC::Interpreter::resolveSkip): + (JSC::Interpreter::resolveGlobal): + (JSC::Interpreter::resolveBase): + (JSC::Interpreter::resolveBaseAndProperty): + (JSC::Interpreter::createExceptionScope): + (JSC::Interpreter::privateExecute): + * interpreter/Interpreter.h: + * jit/JIT.cpp: + (JSC::JIT::privateCompile): + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emitBinaryDoubleOp): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_loop): + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emitSlow_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emitSlow_op_loop_if_lesseq): + (JSC::JIT::emit_op_loop_if_true): + (JSC::JIT::emitSlow_op_loop_if_true): + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emitSlow_op_jfalse): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emitSlow_op_jtrue): + (JSC::JIT::emit_op_jeq_null): + (JSC::JIT::emit_op_jneq_null): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_jsr): + (JSC::JIT::emit_op_next_pname): + (JSC::JIT::emit_op_jmp_scopes): + +2009-10-09 Geoffrey Garen + + Reviewed by Sam Weinig. + + Migrated some code that didn't belong out of Structure. + + SunSpider says maybe 1.03x faster. + + * runtime/JSCell.h: Nixed Structure::markAggregate, and made marking of + a Structure's prototype the direct responsility of the object using it. + (Giving Structure a mark function was misleading because it implied that + all live structures get marked during GC, when they don't.) + + * runtime/JSGlobalObject.cpp: + (JSC::markIfNeeded): + (JSC::JSGlobalObject::markChildren): Added code to mark prototypes stored + on the global object. Maybe this wasn't necessary, but now we don't have + to wonder. + + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): + (JSC::JSObject::getOwnPropertyNames): + (JSC::JSObject::getEnumerableNamesFromClassInfoTable): + * runtime/JSObject.h: + (JSC::JSObject::markChildrenDirect): + * runtime/PropertyNameArray.h: + * runtime/Structure.cpp: + * runtime/Structure.h: + (JSC::Structure::setEnumerationCache): + (JSC::Structure::enumerationCache): Moved property name gathering code + from Structure to JSObject because having a Structure iterate its JSObject + was a layering violation. A JSObject is implemented using a Structure; not + the other way around. + +2009-10-09 Mark Rowe + + Attempt to fix the GTK release build. + + * GNUmakefile.am: Include Grammar.cpp in release builds now that + AllInOneFile.cpp is gone. + +2009-10-09 Gabor Loki + + Rubber-stamped by Eric Seidel. + + Add ARM JIT support for Gtk port (disabled by default) + https://bugs.webkit.org/show_bug.cgi?id=30228 + + * GNUmakefile.am: + +2009-10-08 Geoffrey Garen + + Tiger build fix: added a few more variable initializations. + + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncReplace): + (JSC::stringProtoFuncSearch): + +2009-10-08 Geoffrey Garen + + Qt build fix: added missing #include. + + * jsc.cpp: + +2009-10-08 Geoffrey Garen + + Tiger build fix: initialize variable whose initialization the compiler + can't otherwise figure out. + + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::match): + +2009-10-08 Geoffrey Garen + + Windows build fix: updated exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-08 Geoffrey Garen + + Tiger build fix: fixed file name case. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-10-08 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + At long last, I pronounce the death of AllInOneFile.cpp. + + SunSpider reports a 1.01x speedup. + + * AllInOneFile.cpp: Removed. + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.gypi: + * JavaScriptCore.xcodeproj/project.pbxproj: Added missing project files + to compilation stages. + + * parser/Grammar.y: + * parser/Lexer.cpp: + * parser/Lexer.h: + (JSC::jscyylex): + * runtime/ArrayConstructor.cpp: + (JSC::constructArrayWithSizeQuirk): + * runtime/Collector.h: + * runtime/JSCell.cpp: + (JSC::JSCell::operator new): + * runtime/JSCell.h: + (JSC::JSCell::operator new): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::operator new): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::operator new): + * runtime/JSString.cpp: + * runtime/JSString.h: + (JSC::jsString): + (JSC::jsSubstring): + (JSC::jsOwnedString): + * runtime/RegExpConstructor.cpp: + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructorPrivate::RegExpConstructorPrivate): + (JSC::RegExpConstructorPrivate::lastOvector): + (JSC::RegExpConstructorPrivate::tempOvector): + (JSC::RegExpConstructorPrivate::changeLastOvector): + (JSC::RegExpConstructor::performMatch): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncMatch): + * yarr/RegexJIT.cpp: + * yarr/RegexJIT.h: + (JSC::Yarr::executeRegex): Inlined a few things that Shark said + were hot, on the presumption that AllInOneFile.cpp used to inline them + automatically. + +2009-10-08 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + Fix for JIT'ed op_call instructions (evals, constructs, etc.) + when !ENABLE(JIT_OPTIMIZE_CALL) && USE(JSVALUE32_64) + + https://bugs.webkit.org/show_bug.cgi?id=30201 + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + +2009-10-07 Geoffrey Garen + + Windows build fix: removed no longer exported symbol. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-07 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed Database code takes JSLock on secondary + thread, permanently slowing down JavaScript + + Removed the optional lock from Heap::protect, Heap::unprotect, and friends, + since WebCore no longer uses it. + + * JavaScriptCore.exp: + * runtime/Collector.cpp: + (JSC::Heap::protect): + (JSC::Heap::unprotect): + (JSC::Heap::markProtectedObjects): + (JSC::Heap::protectedGlobalObjectCount): + (JSC::Heap::protectedObjectCount): + (JSC::Heap::protectedObjectTypeCounts): + * runtime/Collector.h: + +2009-10-07 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's IdentifierArena + https://bugs.webkit.org/show_bug.cgi?id=30158 + + Inherits IdentifierArena class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/parser/ParserArena.cpp:36. + + * parser/ParserArena.h: + +2009-10-07 Adam Roben + + Export DateInstance::info in a way that works on Windows + + Fixes + fast/dom/Window/window-postmessage-clone.html fails on Windows + + Reviewed by Anders Carlsson. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + Removed the export of DateInstance::info from here. + + * runtime/DateInstance.h: Use JS_EXPORTDATA to export + DateInstance::info, which is the required way of exporting data on + Windows. + +2009-10-07 Jørgen Lind + + Reviewed by Simon Hausmann. + + When enabling or disabling the JIT through .qmake.cache, make sure + to also toggle ENABLE_YARR_JIT. + + * JavaScriptCore.pri: + +2009-10-06 Priit Laes + + Reviewed by Gavin Barraclough. + + Linking fails with "relocation R_X86_64_PC32 against symbol + `cti_vm_throw'" + https://bugs.webkit.org/show_bug.cgi?id=28422 + + * jit/JITStubs.cpp: + Mark cti_vm_throw symbol as PLT-indirect symbol, so it doesn't end up + in text segment causing relocation errors on amd64 architecture. + Introduced new define SYMBOL_STRING_RELOCATION for such symbols. + +2009-10-06 Oliver Hunt + + Windows linking fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-06 Oliver Hunt + + Reviewed by NOBODY (build fix). + + Windows build fix. + + * runtime/DateInstance.cpp: + +2009-10-05 Oliver Hunt + + Reviewed by Gavin Barraclough. + + It should be possible to post (clone) built-in JS objects to Workers + https://bugs.webkit.org/show_bug.cgi?id=22878 + + Expose helpers to throw correct exceptions during object graph walk + used for cloning and add a helper function to create Date instances + without going through the JS Date constructor function. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + * runtime/DateInstance.h: + * runtime/ExceptionHelpers.cpp: + (JSC::createTypeError): + * runtime/ExceptionHelpers.h: + +2009-10-06 David Levin + + Reviewed by Oliver Hunt. + + StringImpl needs a method to get an instance for another thread which doesn't copy the underlying buffer. + https://bugs.webkit.org/show_bug.cgi?id=30095 + + * wtf/CrossThreadRefCounted.h: + Removed an unused function and assert improvement. + (WTF::CrossThreadRefCounted::isOwnedByCurrentThread): Moved out common code from asserts. + (WTF::CrossThreadRefCounted::ref): Changed assert to use the common method. + (WTF::CrossThreadRefCounted::deref): Changed assert to use the common method. + (WTF::CrossThreadRefCounted::crossThreadCopy): Since this includes a potentially + non-threadsafe operation, add an assert that the class is owned by the current thread. + +2009-10-05 Kevin Ollivier + + wx build fix. Add Symbian files to the list of excludes. + + * wscript: + +2009-10-05 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Remove precompiled header from JavaScriptCore compilation to + prevent qmake warning during autonomous compilation. + https://bugs.webkit.org/show_bug.cgi?id=30069 + + * JavaScriptCore.pro: + +2009-10-02 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed the concept of a "fast access cutoff" in arrays, because it + punished some patterns of array access too much, and made things too + complex for inlining in some cases. + + 1.3% speedup on SunSpider. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + * jit/JITStubs.cpp: + * jit/JITStubs.h: + (JSC::): Check m_vectorLength instead of m_fastAccessCutoff when + getting / putting from / to an array. Inline putting past the end of + the array. + + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): + (JSC::JSArray::getOwnPropertySlot): + (JSC::JSArray::getOwnPropertyDescriptor): + (JSC::JSArray::put): + (JSC::JSArray::putSlowCase): + (JSC::JSArray::deleteProperty): + (JSC::JSArray::getOwnPropertyNames): + (JSC::JSArray::increaseVectorLength): + (JSC::JSArray::setLength): + (JSC::JSArray::pop): + (JSC::JSArray::push): + (JSC::JSArray::sort): + (JSC::JSArray::fillArgList): + (JSC::JSArray::copyToRegisters): + (JSC::JSArray::compactForSorting): + (JSC::JSArray::checkConsistency): + * runtime/JSArray.h: + (JSC::JSArray::canGetIndex): + (JSC::JSArray::canSetIndex): + (JSC::JSArray::setIndex): + (JSC::JSArray::markChildrenDirect): Removed m_fastAccessCutoff, and + replaced with checks for JSValue() to detect reads and writes from / to + uninitialized parts of the array. + +2009-10-02 Jonni Rainisto + + Reviewed by Darin Adler. + + Math.random() gives too low values on Win32 when _CRT_RAND_S is not defined + https://bugs.webkit.org/show_bug.cgi?id=29956 + + * wtf/RandomNumber.cpp: + (WTF::randomNumber): Added PLATFORM(WIN_OS) to handle 15bit rand() + +2009-10-02 Geoffrey Garen + + Reviewed by Sam Weinig. + + Take one branch instead of two to test for JSValue(). + + 1.1% SunSpider speedup. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emit_op_create_arguments): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): Test for the empty value tag, instead + of testing for the cell tag with a 0 payload. + + * runtime/JSValue.cpp: + (JSC::JSValue::description): Added support for dumping the new empty value, + and deleted values, in debug builds. + + * runtime/JSValue.h: + (JSC::JSValue::JSValue()): Construct JSValue() with the empty value tag. + + (JSC::JSValue::JSValue(JSCell*)): Convert null pointer to the empty value + tag, to avoid having two different c++ versions of null / empty. + + (JSC::JSValue::operator bool): Test for the empty value tag, instead + of testing for the cell tag with a 0 payload. + +2009-10-02 Steve Falkenburg + + Reviewed by Mark Rowe. + + + Safari version number shouldn't be exposed in WebKit code + + For a WebKit version of 532.3.4: + Product version is: 5.32.3.4 (was 4.0.3.0) + File version is: 5.32.3.4 (was 4.532.3.4) + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: + +2009-10-02 Tor Arne Vestbø + + Rubber-stamped by Simon Hausmann. + + Fix the Qt on Mac OS X build. + + * wtf/FastMalloc.cpp: + +2009-10-02 Jørgen Lind + + Reviewed by Simon Hausmann. + + Allow enabling and disabling of the JIT through a qmake variable. + + Qt's configure may set this variable through .qmake.cache if a + commandline option is given and/or the compile test for hwcap.h + failed/succeeded. + + * JavaScriptCore.pri: + +2009-10-01 Mark Rowe + + Fix the Tiger build. Don't unconditionally enable 3D canvas as it is not supported on Tiger. + + * Configurations/FeatureDefines.xcconfig: + +2009-10-01 Yongjun Zhang + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=29187 + + Don't inline ~ListRefPtr() to work around winscw compiler forward declaration + bug regarding templated classes. + + The compiler bug is reported at: + https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=9812 + + The change will be reverted when the above bug is fixed in winscw compiler. + + * wtf/ListRefPtr.h: + (WTF::::~ListRefPtr): + +2009-10-01 Zoltan Horvath + + Reviewed by Simon Hausmann. + + [Qt] Allow custom memory allocation control for the whole JavaScriptCore + https://bugs.webkit.org/show_bug.cgi?id=27029 + + Since in JavaScriptCore almost every class which has been instantiated by operator new is + inherited from FastAllocBase (bug #20422), we disable customizing global operator new for the Qt-port + when USE_SYSTEM_MALLOC=0. + + Add #include to FastMalloc.cpp because it's used by TCMalloc_PageHeap::scavengerThread(). + (It's needed for the functionality of TCmalloc.) + + Add TCSystemAlloc.cpp to JavaScriptCore.pri if USE_SYSTEM_MALLOC is disabled. + + * JavaScriptCore.pri: + * wtf/FastMalloc.cpp: + (WTF::sleep): + * wtf/FastMalloc.h: + +2009-09-30 Gabor Loki + + Reviewed by George Staikos. + + Defines two pseudo-platforms for ARM and Thumb-2 instruction set. + https://bugs.webkit.org/show_bug.cgi?id=29122 + + Introduces WTF_PLATFORM_ARM_TRADITIONAL and WTF_PLATFORM_ARM_THUMB2 + macros on ARM platforms. The PLATFORM(ARM_THUMB2) should be used + when Thumb-2 instruction set is the required target. The + PLATFORM(ARM_TRADITIONAL) is for generic ARM instruction set. In + case where the code is common the PLATFORM(ARM) have to be used. + + Modified by George Wright to correctly work + with the RVCT-defined __TARGET_ARCH_ARM and __TARGET_ARCH_THUMB + compiler macros, as well as adding readability changes. + + * wtf/Platform.h: + +2009-09-30 Oliver Hunt + + Reviewed by Geoff Garen. + + Devirtualise array toString conversion + + Tweak the implementation of Array.prototype.toString to have a fast path + when acting on a true JSArray. + + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): + +2009-09-30 Csaba Osztrogonac + + Reviewed by Geoffrey Garen. + + Buildfix for platforms using JSVALUE32. + https://bugs.webkit.org/show_bug.cgi?id=29915 + + After http://trac.webkit.org/changeset/48905 the build broke in JSVALUE32 case. + Also removed unreachable code. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_add): + - Declaration of "OperandTypes types" moved before first use. + - Typos fixed: dst modified to result, regT2 added. + - Unreachable code removed. + (JSC::JIT::emitSlow_op_add): + - Missing declaration of "OperandTypes types" added. + +2009-09-30 Janne Koskinen + + Reviewed by Simon Hausmann. + + Reduce heap size on Symbian from 64MB to 8MB. + + This is not a perfect fix, it requires more fine tuning. + But this makes it possible again to debug in the emulator, + which is more important in order to be able to fix other + run-time issues. + + * runtime/Collector.h: + +2009-09-30 Janne Koskinen + + Reviewed by Simon Hausmann. + + Fix CRASH() macro for Symbian build. + + * wtf/Assertions.h: Added missing } + +2009-09-29 Geoffrey Garen + + Reviewed by Gavin Barraclough. + + Inlined a few math operations. + + ~1% SunSpider speedup. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::compileBinaryArithOpSlowCase): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSlow_op_sub): Don't take a stub call when operating on + a constant int and a double. + +2009-09-28 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Tidy up codeblock sampler + https://bugs.webkit.org/show_bug.cgi?id=29836 + + Some rather simple refactoring of codeblock sampler so that + it's easier for us to use it to find problems in non-jsc + environments + + * JavaScriptCore.exp: + * bytecode/SamplingTool.h: + * debugger/Debugger.cpp: + (JSC::evaluateInGlobalCallFrame): + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::evaluate): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::Interpreter): + (JSC::Interpreter::execute): + (JSC::Interpreter::privateExecute): + (JSC::Interpreter::enableSampler): + (JSC::Interpreter::dumpSampleData): + (JSC::Interpreter::startSampling): + (JSC::Interpreter::stopSampling): + * interpreter/Interpreter.h: + (JSC::Interpreter::sampler): + * jit/JIT.h: + * jsc.cpp: + (runWithScripts): + * runtime/Completion.cpp: + (JSC::checkSyntax): + (JSC::evaluate): + * runtime/Executable.h: + (JSC::EvalExecutable::EvalExecutable): + (JSC::ProgramExecutable::create): + (JSC::ProgramExecutable::ProgramExecutable): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::startSampling): + (JSC::JSGlobalData::stopSampling): + (JSC::JSGlobalData::dumpSampleData): + * runtime/JSGlobalData.h: + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::globalFuncEval): + +2009-09-29 Jeremy Orlow + + Reviewed by Dimitri Glazkov. + + Add GYP generated files to svn:ignore + https://bugs.webkit.org/show_bug.cgi?id=29895 + + The following files are generated by JavaScriptCore's GYP file and should be ignored: + + pcre.mk + wtf.scons + wtf.mk + SConstruct + wtf_config.scons + wtf_config.mk + pcre.scons + + * JavaScriptCore.gyp: Changed property svn:ignore. + +2009-09-29 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized an optimization for adding non-numbers. + + SunSpider says maybe a tiny speedup. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_add): + (JSC::JIT::emitSlow_op_add): + +2009-09-29 Geoffrey Garen + + Windows build fix: export a new symbol. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-28 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed virtual destructor from JSGlobalObjectData to eliminate pointer + fix-ups when accessing JSGlobalObject::d. + + Replaced with an explicit destructor function pointer. + + 6% speedup on bench-alloc-nonretained.js. + + * JavaScriptCore.exp: + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::~JSGlobalObject): + (JSC::JSGlobalObject::destroyJSGlobalObjectData): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + (JSC::JSGlobalObject::JSGlobalObject): + +2009-09-29 Janne Koskinen + + Reviewed by David Kilzer. + + [Qt] Assert messages prints visible in Symbian + https://bugs.webkit.org/show_bug.cgi?id=29808 + + Asserts use vprintf to print the messages to stderr. + In Symbian Open C it is not possible to see stderr so + I routed the messages to stdout instead. + + * wtf/Assertions.cpp: + +2009-09-29 Janne Koskinen + + Reviewed by Darin Adler. + + [Qt] Symbian CRASH macro implementation + + Added Symbian specific crash macro that + stops to crash line if JIT debugging is used. + Additional differentiation of access violation + (KERN-EXEC 3) and CRASH panic. + + * wtf/Assertions.h: + +2009-09-28 Mark Rowe + + Fix the PowerPC build. + + * JavaScriptCore.exp: + +2009-09-28 Mark Rowe + + Reviewed by Gavin Barraclough. + + JavaScriptCore fails to mark registers when built for x86_64 using LLVM GCC. + + * runtime/Collector.cpp: + (JSC::Heap::markCurrentThreadConservatively): Force jmp_buf to use the appropriate alignment for a pointer + to ensure that we correctly interpret the contents of registers during marking. + +2009-09-28 Geoffrey Garen + + Windows build fix: added new exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-28 Geoffrey Garen + + Windows build fix: removed exports that no longer exist. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-28 Geoffrey Garen + + Reviewed by Darin Adler. + + NotNullPassRefPtr: smart pointer optimized for passing references that are not null + https://bugs.webkit.org/show_bug.cgi?id=29822 + + Added NotNullPassRefPtr, and deployed it in all places that initialize + JavaScript objects. + + 2.2% speedup on bench-allocate-nonretained.js. + + * API/JSCallbackConstructor.cpp: + (JSC::JSCallbackConstructor::JSCallbackConstructor): + * API/JSCallbackConstructor.h: + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (JSC::JSCallbackObject::JSCallbackObject): + * JavaScriptCore.exp: + * bytecode/CodeBlock.h: + (JSC::CodeBlock::addFunctionDecl): + (JSC::CodeBlock::addFunctionExpr): + * runtime/ArrayConstructor.cpp: + (JSC::ArrayConstructor::ArrayConstructor): + * runtime/ArrayConstructor.h: + * runtime/ArrayPrototype.cpp: + (JSC::ArrayPrototype::ArrayPrototype): + * runtime/ArrayPrototype.h: + * runtime/BooleanConstructor.cpp: + (JSC::BooleanConstructor::BooleanConstructor): + * runtime/BooleanConstructor.h: + * runtime/BooleanObject.cpp: + (JSC::BooleanObject::BooleanObject): + * runtime/BooleanObject.h: + * runtime/BooleanPrototype.cpp: + (JSC::BooleanPrototype::BooleanPrototype): + * runtime/BooleanPrototype.h: + * runtime/DateConstructor.cpp: + (JSC::DateConstructor::DateConstructor): + * runtime/DateConstructor.h: + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + * runtime/DateInstance.h: + * runtime/DatePrototype.cpp: + (JSC::DatePrototype::DatePrototype): + * runtime/DatePrototype.h: + * runtime/ErrorConstructor.cpp: + (JSC::ErrorConstructor::ErrorConstructor): + * runtime/ErrorConstructor.h: + * runtime/ErrorInstance.cpp: + (JSC::ErrorInstance::ErrorInstance): + * runtime/ErrorInstance.h: + * runtime/ErrorPrototype.cpp: + (JSC::ErrorPrototype::ErrorPrototype): + * runtime/ErrorPrototype.h: + * runtime/FunctionConstructor.cpp: + (JSC::FunctionConstructor::FunctionConstructor): + * runtime/FunctionConstructor.h: + * runtime/FunctionPrototype.cpp: + (JSC::FunctionPrototype::FunctionPrototype): + * runtime/FunctionPrototype.h: + * runtime/GlobalEvalFunction.cpp: + (JSC::GlobalEvalFunction::GlobalEvalFunction): + * runtime/GlobalEvalFunction.h: + * runtime/InternalFunction.cpp: + (JSC::InternalFunction::InternalFunction): + * runtime/InternalFunction.h: + (JSC::InternalFunction::InternalFunction): + * runtime/JSActivation.cpp: + (JSC::JSActivation::JSActivation): + * runtime/JSActivation.h: + (JSC::JSActivation::JSActivationData::JSActivationData): + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): + * runtime/JSArray.h: + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::JSByteArray): + * runtime/JSByteArray.h: + * runtime/JSFunction.cpp: + (JSC::JSFunction::JSFunction): + * runtime/JSFunction.h: + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::JSGlobalObject): + * runtime/JSONObject.h: + (JSC::JSONObject::JSONObject): + * runtime/JSObject.h: + (JSC::JSObject::JSObject): + (JSC::JSObject::setStructure): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::JSVariableObject): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::JSWrapperObject): + * runtime/MathObject.cpp: + (JSC::MathObject::MathObject): + * runtime/MathObject.h: + * runtime/NativeErrorConstructor.cpp: + (JSC::NativeErrorConstructor::NativeErrorConstructor): + * runtime/NativeErrorConstructor.h: + * runtime/NativeErrorPrototype.cpp: + (JSC::NativeErrorPrototype::NativeErrorPrototype): + * runtime/NativeErrorPrototype.h: + * runtime/NumberConstructor.cpp: + (JSC::NumberConstructor::NumberConstructor): + * runtime/NumberConstructor.h: + * runtime/NumberObject.cpp: + (JSC::NumberObject::NumberObject): + * runtime/NumberObject.h: + * runtime/NumberPrototype.cpp: + (JSC::NumberPrototype::NumberPrototype): + * runtime/NumberPrototype.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + * runtime/ObjectConstructor.h: + * runtime/ObjectPrototype.cpp: + (JSC::ObjectPrototype::ObjectPrototype): + * runtime/ObjectPrototype.h: + * runtime/PropertyNameArray.h: + (JSC::PropertyNameArrayData::setCachedPrototypeChain): + * runtime/PrototypeFunction.cpp: + (JSC::PrototypeFunction::PrototypeFunction): + * runtime/PrototypeFunction.h: + * runtime/RegExpConstructor.cpp: + (JSC::RegExpConstructor::RegExpConstructor): + * runtime/RegExpConstructor.h: + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::RegExpObject): + * runtime/RegExpObject.h: + (JSC::RegExpObject::RegExpObjectData::RegExpObjectData): + * runtime/RegExpPrototype.cpp: + (JSC::RegExpPrototype::RegExpPrototype): + * runtime/RegExpPrototype.h: + * runtime/StringConstructor.cpp: + (JSC::StringConstructor::StringConstructor): + * runtime/StringConstructor.h: + * runtime/StringObject.cpp: + (JSC::StringObject::StringObject): + * runtime/StringObject.h: + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined): + * runtime/StringPrototype.cpp: + (JSC::StringPrototype::StringPrototype): + * runtime/StringPrototype.h: + * wtf/PassRefPtr.h: + (WTF::NotNullPassRefPtr::NotNullPassRefPtr): + (WTF::NotNullPassRefPtr::~NotNullPassRefPtr): + (WTF::NotNullPassRefPtr::get): + (WTF::NotNullPassRefPtr::clear): + (WTF::NotNullPassRefPtr::releaseRef): + (WTF::NotNullPassRefPtr::operator*): + (WTF::NotNullPassRefPtr::operator->): + (WTF::NotNullPassRefPtr::operator!): + (WTF::NotNullPassRefPtr::operator UnspecifiedBoolType): + * wtf/RefPtr.h: + (WTF::RefPtr::RefPtr): + (WTF::operator==): + +2009-09-28 Oliver Hunt + + Reviewed by Geoff Garen. + + Hard dependency on SSE2 instruction set with JIT + https://bugs.webkit.org/show_bug.cgi?id=29779 + + Add floating point support checks to op_jfalse and op_jtrue, and + fix the logic for the slow case of op_add + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_add): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + +2009-09-28 Yaar Schnitman + + Reviewed by Dimitri Glazkov. + + Chromium port - recognize we are being built independently + of chromium and look for dependencies under webkit/chromium rather + than chromium/src. + + https://bugs.webkit.org/show_bug.cgi?id=29722 + + * JavaScriptCore.gyp/JavaScriptCore.gyp: + +2009-09-28 Jakub Wieczorek + + Reviewed by Simon Hausmann. + + [Qt] Implement XSLT support with QtXmlPatterns. + https://bugs.webkit.org/show_bug.cgi?id=28303 + + * wtf/Platform.h: Add a WTF_USE_QXMLQUERY #define. + +2009-09-28 Gabor Loki + + Reviewed by Simon Hausmann. + + Remove __clear_cache which is an internal function of GCC + https://bugs.webkit.org/show_bug.cgi?id=28886 + + Although __clear_cache is exported from GCC, this is an internal + function. GCC makes no promises about it. + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-09-28 Sam Weinig + + Reviewed by Oliver Hunt. + + Fix an absolute path to somewhere in Oliver's machine to a relative path + for derived JSONObject.lut.h. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-09-28 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Add ARM version detection for Windows CE. + + * wtf/Platform.h: + +2009-09-26 Yongjun Zhang + + Reviewed by Simon Hausmann. + + Add MarkStackSymbian.cpp to build JavascriptCore for Symbian. + + Re-use Windows shrinkAllocation implementation because Symbian doesn't + support releasing part of memory region. + + Use fastMalloc and fastFree to implement allocateStack and releaseStack + for Symbian port. + + * JavaScriptCore.pri: + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackSymbian.cpp: Added. + (JSC::MarkStack::initializePagesize): + (JSC::MarkStack::allocateStack): + (JSC::MarkStack::releaseStack): + +2009-09-25 Gabor Loki + + Reviewed by Gavin Barraclough. + + Fix unaligned data access in YARR_JIT on ARMv5 and below. + https://bugs.webkit.org/show_bug.cgi?id=29695 + + On ARMv5 and below all data access should be naturally aligned. + In the YARR_JIT there is a case when character pairs are + loaded from the input string, but this data access is not + naturally aligned. This fix introduces load32WithUnalignedHalfWords + and branch32WithUnalignedHalfWords functions which contain + naturally aligned memory loads - half word loads - on ARMv5 and below. + + * assembler/MacroAssemblerARM.cpp: + (JSC::MacroAssemblerARM::load32WithUnalignedHalfWords): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerARM::branch32WithUnalignedHalfWords): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerARMv7::branch32): + (JSC::MacroAssemblerARMv7::branch32WithUnalignedHalfWords): + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::load32WithUnalignedHalfWords): + (JSC::MacroAssemblerX86Common::branch32WithUnalignedHalfWords): + * wtf/Platform.h: + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generatePatternCharacterPair): + +2009-09-25 Jeremy Orlow + + This is breaking Chromium try bots, so I'm counting this as a build fix. + + Add more svn:ignore exceptions. On different platforms, these files are + generated with different case for JavaScriptCore. Also there are some + wtf project files that get built apparently. + + * JavaScriptCore.gyp: Changed property svn:ignore. + +2009-09-25 Ada Chan + + Build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-25 Geoffrey Garen + + Reviewed by Darin Adler. + + Inlined some object creation code, including lexicalGlobalObject access + https://bugs.webkit.org/show_bug.cgi?id=29750 + + SunSpider says 0.5% faster. + + 0.8% speedup on bench-alloc-nonretained.js. + 2.5% speedup on v8-splay.js. + + * interpreter/CachedCall.h: + (JSC::CachedCall::CachedCall): + * interpreter/CallFrame.h: + (JSC::ExecState::lexicalGlobalObject): + (JSC::ExecState::globalThisValue): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::dumpRegisters): + (JSC::Interpreter::execute): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/ScopeChain.cpp: + (JSC::ScopeChainNode::print): + * runtime/ScopeChain.h: + (JSC::ScopeChainNode::ScopeChainNode): + (JSC::ScopeChainNode::~ScopeChainNode): + (JSC::ScopeChainNode::push): + (JSC::ScopeChain::ScopeChain): + (JSC::ScopeChain::globalObject): Added a globalObject data member to ScopeChainNode. + Replaced accessor function for globalObject() with data member. Replaced + globalThisObject() accessor with direct access to globalThis, to match. + + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::init): + * runtime/JSGlobalObject.h: Inlined array and object construction. + +2009-09-25 Laszlo Gombos + + Reviewed by Gavin Barraclough. + + Add ARM version detection rules for Symbian + https://bugs.webkit.org/show_bug.cgi?id=29715 + + * wtf/Platform.h: + +2009-09-24 Xan Lopez + + Reviewed by Mark "Do It!" Rowe. + + Some GCC versions don't like C++-style comments in preprocessor + directives, change to C-style to shut them up. + + * wtf/Platform.h: + +2009-09-24 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Division is needlessly slow in 64-bit + https://bugs.webkit.org/show_bug.cgi?id=29723 + + Add codegen for op_div on x86-64 + + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::compileBinaryArithOpSlowCase): + (JSC::JIT::emit_op_div): + (JSC::JIT::emitSlow_op_div): + * jit/JITInlineMethods.h: + (JSC::JIT::isOperandConstantImmediateDouble): + (JSC::JIT::addressFor): + (JSC::JIT::emitLoadDouble): + (JSC::JIT::emitLoadInt32ToDouble): + (JSC::JIT::emitJumpSlowCaseIfNotImmediateNumber): + +2009-09-24 Jeremy Orlow + + Reviewed by Dimitri Glazkov. + + Add GYP generated files to svn:ignore + https://bugs.webkit.org/show_bug.cgi?id=29724 + + Adding the following files to the svn:ignore list (all in the + JavaScriptCore/JavaScriptCore.gyp directory) + + JavaScriptCore.xcodeproj + JavaScriptCore.sln + JavaScriptCore.vcproj + JavaScriptCore_Debug.rules + JavaScriptCore_Release.rules + JavaScriptCore_Release - no tcmalloc.rules + JavaScriptCore_Purify.rules + JavaScriptCore.mk + JavaScriptCore_Debug_rules.mk + JavaScriptCore_Release_rules.mk + JavaScriptCore_Release - no tcmalloc_rules.mk + JavaScriptCore_Purify_rules.mk + JavaScriptCore.scons + JavaScriptCore_main.scons + + * JavaScriptCore.gyp: Changed property svn:ignore. + +2009-09-24 Yong Li + + Reviewed by Adam Barth. + + Replace platform-dependent code with WTF::currentTime() + https://bugs.webkit.org/show_bug.cgi?id=29148 + + * jsc.cpp: + (StopWatch::start): + (StopWatch::stop): + (StopWatch::getElapsedMS): + * runtime/TimeoutChecker.cpp: + (JSC::getCPUTime): + +2009-09-24 Mark Rowe + + Reviewed by Sam Weinig. + + FastMalloc scavenging thread should be named + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::scavengerThread): Set the thread name. + * wtf/Platform.h: Move the knowledge of whether pthread_setname_np exists to here as HAVE(PTHREAD_SETNAME_NP). + * wtf/ThreadingPthreads.cpp: + (WTF::setThreadNameInternal): Use HAVE(PTHREAD_SETNAME_NP). + +2009-09-24 Geoffrey Garen + + Reviewed by Sam Weinig. + + Renamed clear to removeAll, as suggested by Darin Adler. + + * wtf/HashCountedSet.h: + (WTF::::removeAll): + +2009-09-24 Mark Rowe + + Reviewed by Gavin Barraclough. + + Fix FastMalloc to build with assertions enabled. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_Central_FreeList::ReleaseToSpans): + * wtf/TCSpinLock.h: + (TCMalloc_SpinLock::IsHeld): + +2009-09-24 Geoffrey Garen + + Suggested by Darin Adler. + + Removed some unnecessary parameter names. + + * wtf/HashCountedSet.h: + +2009-09-24 Janne Koskinen + + Reviewed by Simon Hausmann. + + On Windows JSChar is typedef'ed to wchar_t. + + When building with WINSCW for Symbian we need to do the + same typedef. + + * API/JSStringRef.h: + +2009-09-23 Geoffrey Garen + + A piece of my last patch that I forgot. + + * wtf/HashCountedSet.h: + (WTF::::clear): Added HashCountedSet::clear. + +2009-09-24 Gabor Loki + + Reviewed by Gavin Barraclough. + + Avoid __clear_cache built-in function if DISABLE_BUILTIN_CLEAR_CACHE define is set + https://bugs.webkit.org/show_bug.cgi?id=28886 + + There are some GCC packages (for example GCC-2006q3 from CodeSourcery) + which contain __clear_cache built-in function only for C while the C++ + version of __clear_cache is missing on ARM architectures. + + Fixed a small bug in the inline assembly of cacheFlush function on + ARM_TRADITIONAL. + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-09-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added the ability to swap vectors with inline capacities, so you can + store a vector with inline capacity in a hash table. + + * wtf/Vector.h: + (WTF::swap): + (WTF::VectorBuffer::swap): + +2009-09-23 David Kilzer + + Move definition of USE(PLUGIN_HOST_PROCESS) from WebKitPrefix.h to Platform.h + + Reviewed by Mark Rowe. + + * wtf/Platform.h: Define WTF_USE_PLUGIN_HOST_PROCESS to 1 when + building on 64-bit SnowLeopard. Define to 0 elsewhere. + +2009-09-22 Oliver Hunt + + Reviewed by Geoff Garen. + + Code sampling builds are broken. + https://bugs.webkit.org/show_bug.cgi?id=29662 + + Fix build. + + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::get): + * bytecode/SamplingTool.cpp: + (JSC::ScriptSampleRecord::sample): + (JSC::SamplingTool::doRun): + (JSC::SamplingTool::notifyOfScope): + (JSC::compareScriptSampleRecords): + (JSC::SamplingTool::dump): + * bytecode/SamplingTool.h: + (JSC::ScriptSampleRecord::ScriptSampleRecord): + (JSC::ScriptSampleRecord::~ScriptSampleRecord): + (JSC::SamplingTool::SamplingTool): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + (JSC::BytecodeGenerator::emitNewFunction): + (JSC::BytecodeGenerator::emitNewFunctionExpression): + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::makeFunction): + * debugger/Debugger.cpp: + (JSC::evaluateInGlobalCallFrame): + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::evaluate): + * parser/Nodes.cpp: + (JSC::ScopeNode::ScopeNode): + * runtime/Completion.cpp: + (JSC::checkSyntax): + (JSC::evaluate): + * runtime/Executable.cpp: + (JSC::FunctionExecutable::fromGlobalCode): + * runtime/Executable.h: + (JSC::ScriptExecutable::ScriptExecutable): + (JSC::EvalExecutable::EvalExecutable): + (JSC::EvalExecutable::create): + (JSC::ProgramExecutable::ProgramExecutable): + (JSC::FunctionExecutable::create): + (JSC::FunctionExecutable::FunctionExecutable): + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::globalFuncEval): + +2009-09-22 Darin Adler + + Reviewed by Sam Weinig. + + * wtf/Forward.h: Added PassOwnPtr. + +2009-09-22 Yaar Schnitman + + Reviewed by David Levin. + + Ported chromium.org's javascriptcore.gyp for the webkit chromium port. + + https://bugs.webkit.org/show_bug.cgi?id=29617 + + * JavaScriptCore.gyp/JavaScriptCore.gyp: Added. + +2009-09-22 Thiago Macieira + + Reviewed by Simon Hausmann. + + Fix compilation with WINSCW: no varargs macros + + Disable variadic arguments for WINSCW just like we do + for MSVC7. + + * wtf/Assertions.h: + +2009-09-22 Kent Hansen + + Reviewed by Simon Hausmann. + + Disable variadic macros on MSVC7. + + This was originally added in r26589 but not extended + when LOG_DISABLED/ASSERT_DISABLED was introduced. + + * wtf/Assertions.h: + +2009-09-22 Simon Hausmann + + Unreviewed build fix for Windows CE < 5 + + Define WINCEBASIC to disable the IsDebuggerPresent() code in + wtf/Assertions.cpp. + + * JavaScriptCore.pri: + +2009-09-22 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Fix major memory leak in JavaScriptCore RegisterFile on Windows CE + + https://bugs.webkit.org/show_bug.cgi?id=29367 + + On Widows CE we must decommit all committed pages before we release + them. See VirtualFree documentation. + Desktop Windows behaves much smoother in this situation. + + * interpreter/RegisterFile.cpp: + (JSC::RegisterFile::~RegisterFile): + +2009-09-21 Greg Bolsinga + + Reviewed by Simon Fraser & Sam Weinig. + + Add ENABLE(ORIENTATION_EVENTS) + https://bugs.webkit.org/show_bug.cgi?id=29508 + + * wtf/Platform.h: Also sort PLATFORM(IPHONE) #defines. + +2009-09-21 Jedrzej Nowacki + + Reviewed by Eric Seidel. + + [Fix] SourceCode's uninitialized member + + Potential source of crashes and bugs was fixed. Default constructor + didn't initialized m_provider member. + + https://bugs.webkit.org/show_bug.cgi?id=29364 + + * parser/SourceCode.h: + (JSC::SourceCode::SourceCode): + +2009-09-21 Oliver Hunt + + Reviewed by Geoff Garen. + + REGRESSION (r48582): Crash in StructureStubInfo::initPutByIdTransition when reloading trac.webkit.org + https://bugs.webkit.org/show_bug.cgi?id=29599 + + It is unsafe to attempt to cache new property transitions on + dictionaries of any type. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCachePutByID): + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + +2009-09-21 Oliver Hunt + + RS=Maciej Stachowiak. + + Re-land SNES fix with corrected assertion. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::resolveGlobal): + (JSC::Interpreter::tryCachePutByID): + (JSC::Interpreter::tryCacheGetByID): + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): + (JSC::DEFINE_STUB_FUNCTION): + * runtime/BatchedTransitionOptimizer.h: + (JSC::BatchedTransitionOptimizer::BatchedTransitionOptimizer): + * runtime/JSObject.cpp: + (JSC::JSObject::removeDirect): + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::getEnumerablePropertyNames): + (JSC::Structure::despecifyDictionaryFunction): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::removePropertyTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::toCacheableDictionaryTransition): + (JSC::Structure::toUncacheableDictionaryTransition): + (JSC::Structure::fromDictionaryTransition): + (JSC::Structure::removePropertyWithoutTransition): + * runtime/Structure.h: + (JSC::Structure::isDictionary): + (JSC::Structure::isUncacheableDictionary): + (JSC::Structure::): + * runtime/StructureChain.cpp: + (JSC::StructureChain::isCacheable): + +2009-09-21 Adam Roben + + Revert r48573, as it caused many assertion failures + + * interpreter/Interpreter.cpp: + * jit/JITStubs.cpp: + * runtime/BatchedTransitionOptimizer.h: + * runtime/JSObject.cpp: + * runtime/Structure.cpp: + * runtime/Structure.h: + * runtime/StructureChain.cpp: + +2009-09-21 Gustavo Noronha Silva + + Unreviewed make dist build fix. Missing files. + + * GNUmakefile.am: + +2009-09-19 Gavin Barraclough + + Reviewed by Sam 'Cabin Boy' Weinig. + + Fix stack alignment with ARM THUMB2 JIT. + https://bugs.webkit.org/show_bug.cgi?id=29526 + + Stack is currently being decremented by 0x3c, bump this to 0x40 to make this a + multiple of 16 bytes. + + * jit/JITStubs.cpp: + (JSC::JITThunks::JITThunks): + * jit/JITStubs.h: + +2009-09-20 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + SNES is too slow + https://bugs.webkit.org/show_bug.cgi?id=29534 + + The problem was that the emulator used multiple classes with + more properties than our dictionary cutoff allowed, this resulted + in more or less all critical logic inside the emulator requiring + uncached property access. + + Rather than simply bumping the dictionary cutoff, this patch + recognises that there are two ways to create a "dictionary" + structure. Either by adding a large number of properties, or + by removing a property. In the case of adding properties we + know all the existing properties will maintain their existing + offsets, so we could cache access to those properties, if we + know they won't be removed. + + To make this possible, this patch adds the logic required to + distinguish a dictionary created by addition from one created + by removal. With this logic in place we can now cache access + to objects with large numbers of properties. + + SNES performance improved by more than 6x. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::resolveGlobal): + (JSC::Interpreter::tryCachePutByID): + (JSC::Interpreter::tryCacheGetByID): + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): + (JSC::DEFINE_STUB_FUNCTION): + * runtime/BatchedTransitionOptimizer.h: + (JSC::BatchedTransitionOptimizer::BatchedTransitionOptimizer): + * runtime/JSObject.cpp: + (JSC::JSObject::removeDirect): + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::getEnumerablePropertyNames): + (JSC::Structure::despecifyDictionaryFunction): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::removePropertyTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::toCacheableDictionaryTransition): + (JSC::Structure::toUncacheableDictionaryTransition): + (JSC::Structure::fromDictionaryTransition): + (JSC::Structure::removePropertyWithoutTransition): + * runtime/Structure.h: + (JSC::Structure::isDictionary): + (JSC::Structure::isUncacheableDictionary): + (JSC::Structure::): + * runtime/StructureChain.cpp: + (JSC::StructureChain::isCacheable): + +2009-09-19 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Implement ES5 Object.create function + https://bugs.webkit.org/show_bug.cgi?id=29524 + + Implement Object.create. Very simple patch, effectively Object.defineProperties + only creating the target object itself. + + * runtime/CommonIdentifiers.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConstructorCreate): + +2009-09-19 Dan Bernstein + + Fix clean debug builds. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-19 Joerg Bornemann + + Reviewed by George Staikos. + + QtWebKit Windows CE compile fix + + https://bugs.webkit.org/show_bug.cgi?id=29379 + + There is no _aligned_alloc or _aligned_free on Windows CE. + We just use the Windows code that was there before and use VirtualAlloc. + But that also means that the BLOCK_SIZE must be 64K as this function + allocates on 64K boundaries. + + * runtime/Collector.cpp: + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlock): + * runtime/Collector.h: + +2009-09-19 Oliver Hunt + + Reviewed by Sam Weinig. + + Implement ES5 Object.defineProperties function + https://bugs.webkit.org/show_bug.cgi?id=29522 + + Implement Object.defineProperties. Fairly simple patch, simply makes use of + existing functionality used for defineProperty. + + * runtime/CommonIdentifiers.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::defineProperties): + (JSC::objectConstructorDefineProperties): + +2009-09-19 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Windows build fix part2 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-19 Oliver Hunt + + Reviewed by NOBODY (Buildfix). + + Windows build fix part 1. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-18 Oliver Hunt + + Reviewed by Geoff Garen. + + Implement ES5 Object.defineProperty function + https://bugs.webkit.org/show_bug.cgi?id=29503 + + Implement Object.defineProperty. This requires adding the API to + ObjectConstructor, along with a helper function that implements the + ES5 internal [[ToPropertyDescriptor]] function. It then adds + JSObject::defineOwnProperty that implements the appropriate ES5 semantics. + Currently defineOwnProperty uses a delete followed by a put to redefine + attributes of a property, clearly this is less efficient than it could be + but we can improve this if it needs to be possible in future. + + * JavaScriptCore.exp: + * debugger/DebuggerActivation.cpp: + (JSC::DebuggerActivation::defineGetter): + (JSC::DebuggerActivation::defineSetter): + * debugger/DebuggerActivation.h: + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + Update defineGetter/Setter calls + * runtime/CommonIdentifiers.h: + * runtime/JSArray.cpp: + (JSC::JSArray::getOwnPropertySlot): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::defineGetter): + (JSC::JSGlobalObject::defineSetter): + * runtime/JSGlobalObject.h: + * runtime/JSObject.cpp: + (JSC::JSObject::defineGetter): + (JSC::JSObject::defineSetter): + (JSC::putDescriptor): + (JSC::JSObject::defineOwnProperty): + * runtime/JSObject.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConstructorGetOwnPropertyDescriptor): + (JSC::toPropertyDescriptor): + (JSC::objectConstructorDefineProperty): + * runtime/ObjectPrototype.cpp: + (JSC::objectProtoFuncDefineGetter): + (JSC::objectProtoFuncDefineSetter): + * runtime/PropertyDescriptor.cpp: + (JSC::PropertyDescriptor::writable): + (JSC::PropertyDescriptor::enumerable): + (JSC::PropertyDescriptor::configurable): + (JSC::PropertyDescriptor::isDataDescriptor): + (JSC::PropertyDescriptor::isGenericDescriptor): + (JSC::PropertyDescriptor::isAccessorDescriptor): + (JSC::PropertyDescriptor::getter): + (JSC::PropertyDescriptor::setter): + (JSC::PropertyDescriptor::setDescriptor): + (JSC::PropertyDescriptor::setAccessorDescriptor): + (JSC::PropertyDescriptor::setWritable): + (JSC::PropertyDescriptor::setEnumerable): + (JSC::PropertyDescriptor::setConfigurable): + (JSC::PropertyDescriptor::setSetter): + (JSC::PropertyDescriptor::setGetter): + (JSC::PropertyDescriptor::equalTo): + (JSC::PropertyDescriptor::attributesEqual): + (JSC::PropertyDescriptor::attributesWithOverride): + * runtime/PropertyDescriptor.h: + (JSC::PropertyDescriptor::PropertyDescriptor): + (JSC::PropertyDescriptor::value): + (JSC::PropertyDescriptor::setValue): + (JSC::PropertyDescriptor::isEmpty): + (JSC::PropertyDescriptor::writablePresent): + (JSC::PropertyDescriptor::enumerablePresent): + (JSC::PropertyDescriptor::configurablePresent): + (JSC::PropertyDescriptor::setterPresent): + (JSC::PropertyDescriptor::getterPresent): + (JSC::PropertyDescriptor::operator==): + (JSC::PropertyDescriptor::): + +2009-09-18 Gabor Loki + + Reviewed by Gavin Barraclough. + + Build fix to enable ARM_THUMB2 on Linux + https://bugs.webkit.org/show_bug.cgi?id= + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + * jit/JITStubs.cpp: + * wtf/Platform.h: + +2009-09-18 Gabor Loki + + Reviewed by Gavin Barraclough. + + Defines two pseudo-platforms for ARM and Thumb-2 instruction set. + https://bugs.webkit.org/show_bug.cgi?id=29122 + + Introduces WTF_PLATFORM_ARM_TRADITIONAL and WTF_PLATFORM_ARM_THUMB2 + macros on ARM platforms. The PLATFORM(ARM_THUMB2) should be used + when Thumb-2 instruction set is the required target. The + PLATFORM(ARM_TRADITIONAL) is for generic ARM instruction set. In + case where the code is common the PLATFORM(ARM) have to be used. + + * assembler/ARMAssembler.cpp: + * assembler/ARMAssembler.h: + * assembler/ARMv7Assembler.h: + * assembler/MacroAssembler.h: + * assembler/MacroAssemblerARM.cpp: + * assembler/MacroAssemblerARM.h: + * assembler/MacroAssemblerCodeRef.h: + (JSC::MacroAssemblerCodePtr::MacroAssemblerCodePtr): + * jit/ExecutableAllocator.h: + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::beginUninterruptedSequence): + (JSC::JIT::preserveReturnAddressAfterCall): + (JSC::JIT::restoreReturnAddressBeforeReturn): + (JSC::JIT::restoreArgumentReference): + (JSC::JIT::restoreArgumentReferenceForTrampoline): + * jit/JITOpcodes.cpp: + * jit/JITStubs.cpp: + (JSC::JITThunks::JITThunks): + * jit/JITStubs.h: + * wtf/Platform.h: + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateEnter): + +2009-09-18 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Fix the Qt/Windows CE build. + + * JavaScriptCore.pri: Build the ce_time.cpp functions from + within Qt externally. + * wtf/DateMath.cpp: Removed unnecessary Qt #ifdef, for the + Qt build these functions are no external, too. + +2009-09-17 Janne Koskinen + + Reviewed by Simon Hausmann. + + Symbian/WINSCW build fox. + + Repeat Q_OS_WIN wchar_t hack for WINSCW, similar to + revision 24774. + + WINSCW defines wchar_t, thus UChar has to be wchar_t + + * wtf/unicode/qt4/UnicodeQt4.h: + +2009-09-17 Janne Koskinen + + Reviewed by Simon Hausmann. + + Symbian/WINSCW build fix. + + https://bugs.webkit.org/show_bug.cgi?id=29186 + + WINSCW Template specialisation name in declaration must the be the same as in implementation. + + * runtime/LiteralParser.h: + +2009-09-15 Norbert Leser + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=27060 + + Symbian compiler for emulator target (WINSCW) fails with + "illegal operand" for m_attributesInPrevious in structure.ccp + (when calling make_pair functions). + This error is apparently due to the compiler not properly + resolving the unsigned type of the declared bitfield. + + Initial patch explicitly casted m_attributesInPrevious + to unsigned, but since bitfield optimization is not critical for + the emulator target, this conditional change in header file + appears to be least intrusive. + + * runtime/Structure.h: + +2009-09-16 Gabor Loki + + Reviewed by Darin Adler. + + Fix GCC warnings on ARM_THUMB2 platform + + * assembler/ARMv7Assembler.h: + (JSC::ARMThumbImmediate::countLeadingZerosPartial): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::branchTruncateDoubleToInt32): + (JSC::MacroAssemblerARMv7::moveFixedWidthEncoding): + +2009-09-16 Greg Bolsinga + + Add ENABLE(INSPECTOR) + https://bugs.webkit.org/show_bug.cgi?id=29260 + + Reviewed by David Kilzer. + + * wtf/Platform.h: + +2009-09-16 Greg Bolsinga + + Add ENABLE(CONTEXT_MENUS) + https://bugs.webkit.org/show_bug.cgi?id=29225 + + Reviewed by David Kilzer. + + * wtf/Platform.h: + +2009-09-16 Benjamin C Meyer + + Reviewed by Eric Seidel. + + The webkit stdint and stdbool headers exists because + the compiler MSVC doesn't include them. The check + should not check for PLATFORM(WIN_OS) but for MSVC. + + * os-win32/stdbool.h: + * os-win32/stdint.h: + +2009-09-16 Greg Bolsinga + + Add ENABLE(DRAG_SUPPORT) + https://bugs.webkit.org/show_bug.cgi?id=29233 + + Reviewed by David Kilzer. + + * wtf/Platform.h: + +2009-09-16 Kevin Ollivier + + waf build fix after flag was moved to correct place. + + * wscript: + +2009-09-16 Tor Arne Vestbø + + Reviewed by Simon Hausmann. + + [Qt] Build fix for 64-bit Qt on Mac OS X + + * wtf/Platform.h: Use JSVALUE64 on DARWIN, not only on MAC + +2009-09-16 Zoltan Herczeg + + Reviewed by Simon Hausmann. + + [Qt] Fix wtf/ThreadSpecific.h under Qt to free thread local objects. + https://bugs.webkit.org/show_bug.cgi?id=29295 + + This is an important fix when JavaScript workers are in use, since + unfreed ThreadGlobalDatas leak a big amount of memory (50-100k each). + QThreadStorage calls the destructor of a given object, which is the + ThreadSpecific::Data. Unlike pthread, Qt is object oriented, and does + not support the calling of a static utility function when the thread + is about to close. In this patch we call the ThreadSpecific::destroy() + utility function from the destructor of ThreadSpecific::Data. Moreover, + since Qt resets all thread local values to 0 before the calling of the + appropriate destructors, we set back the pointer to its original value. + This is necessary because the get() method of the ThreadSpecific + object may be called during the exuction of the destructor. + + * wtf/ThreadSpecific.h: + (WTF::ThreadSpecific::Data::~Data): + (WTF::::~ThreadSpecific): + (WTF::::set): + (WTF::::destroy): + +2009-09-10 Oliver Hunt + + Reviewed by Geoff Garen. + + Allow anonymous storage inside JSObject + https://bugs.webkit.org/show_bug.cgi?id=29168 + + Add the concept of anonymous slots to Structures so that it is + possible to store references to values that need marking in the + standard JSObject storage buffer. This allows us to reduce the + malloc overhead of some objects (by allowing them to store JS + values in the inline storage of the object) and reduce the + dependence of custom mark functions (if all an objects children + are in the standard object property storage there's no need to + mark them manually). + + * JavaScriptCore.exp: + * runtime/JSObject.h: + (JSC::JSObject::putAnonymousValue): + (JSC::JSObject::getAnonymousValue): + (JSC::JSObject::addAnonymousSlots): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + (JSC::JSWrapperObject::JSWrapperObject): + (JSC::JSWrapperObject::setInternalValue): + * runtime/PropertyMapHashTable.h: + * runtime/Structure.cpp: + (JSC::Structure::~Structure): + (JSC::Structure::materializePropertyMap): + (JSC::Structure::addAnonymousSlotsTransition): + (JSC::Structure::copyPropertyTable): + (JSC::Structure::put): + (JSC::Structure::rehashPropertyMapHashTable): + * runtime/Structure.h: + (JSC::Structure::propertyStorageSize): + (JSC::StructureTransitionTable::reifySingleTransition): + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTable::TransitionTable::addSlotTransition): + (JSC::StructureTransitionTable::TransitionTable::removeSlotTransition): + (JSC::StructureTransitionTable::TransitionTable::getSlotTransition): + (JSC::StructureTransitionTable::getAnonymousSlotTransition): + (JSC::StructureTransitionTable::addAnonymousSlotTransition): + (JSC::StructureTransitionTable::removeAnonymousSlotTransition): + +2009-09-15 Alex Milowski + + Reviewed by Tor Arne Vestbø. + + Added the ENABLE_MATHML define to the features + + * Configurations/FeatureDefines.xcconfig: + +2009-09-15 Csaba Osztrogonac + + Reviewed by Tor Arne Vestbø. + + [Qt] Build fix for windows. + + After http://trac.webkit.org/changeset/47795 the MinGW build broke, + because MinGW has __mingw_aligned_malloc instead of _aligned_malloc. + + * runtime/Collector.cpp: + (JSC::Heap::allocateBlock): MinGW case added. + (JSC::Heap::freeBlock): MinGW case added. + +2009-09-15 Csaba Osztrogonac + + Reviewed by Tor Arne Vestbø. + + [Qt] Build fix for Windows/MinGW + + https://bugs.webkit.org/show_bug.cgi?id=29268 + + * wtf/Platform.h: JSVALUE32_64 temporarily disabled on PLATFORM(WIN_OS) with COMPILER(MINGW) + +2009-09-14 Gabor Loki + + Reviewed by Gavin Barraclough. + + Detect VFP at runtime in generic ARM port on Linux platform. + https://bugs.webkit.org/show_bug.cgi?id=29076 + + * JavaScriptCore.pri: + * assembler/MacroAssemblerARM.cpp: Added. + (JSC::isVFPPresent): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::supportsFloatingPoint): + +2009-09-14 Csaba Osztrogonac + + Reviewed by Tor Arne Vestbø. + + [Qt] Build fix for windows build. + + * JavaScriptCore.pri: Correct a logic error. + * pcre/dftables: Add missing paranthesis for tmpdir function. + +2009-09-12 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Build fix for windows exports (again). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-12 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Build fix for windows exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-12 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Correct fix for non-allinonefile builds + + * runtime/ObjectConstructor.cpp: + +2009-09-12 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Fix non-allinonefile builds + + * runtime/ObjectConstructor.cpp: + +2009-09-12 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + [ES5] Implement Object.keys + https://bugs.webkit.org/show_bug.cgi?id=29170 + + This patch basically requires two separate steps, the first is to split getPropertyNames + into two functions -- getOwnPropertyNames and getPropertyNames, basically making them behave + in the same way as getOwnPropertySlot and getPropertySlot. In essence getOwnPropertyNames + produces the list of properties on an object excluding its prototype chain and getPropertyNames + just iterates the the object and its prototype chain calling getOwnPropertyNames at each level. + + * API/JSCallbackObject.h: + * API/JSCallbackObjectFunctions.h: + (JSC::::getOwnPropertyNames): + * JavaScriptCore.exp: + * debugger/DebuggerActivation.cpp: + (JSC::DebuggerActivation::getOwnPropertyNames): + * debugger/DebuggerActivation.h: + * runtime/CommonIdentifiers.h: + * runtime/JSArray.cpp: + (JSC::JSArray::getOwnPropertyNames): + * runtime/JSArray.h: + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::getOwnPropertyNames): + * runtime/JSByteArray.h: + * runtime/JSNotAnObject.cpp: + (JSC::JSNotAnObject::getOwnPropertyNames): + * runtime/JSNotAnObject.h: + * runtime/JSObject.cpp: + (JSC::JSObject::getOwnPropertyNames): + * runtime/JSObject.h: + * runtime/JSVariableObject.cpp: + (JSC::JSVariableObject::getOwnPropertyNames): + * runtime/JSVariableObject.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConstructorKeys): + * runtime/RegExpMatchesArray.h: + (JSC::RegExpMatchesArray::getOwnPropertyNames): + * runtime/StringObject.cpp: + (JSC::StringObject::getOwnPropertyNames): + * runtime/StringObject.h: + * runtime/Structure.cpp: + (JSC::Structure::getOwnEnumerablePropertyNames): + (JSC::Structure::getEnumerablePropertyNames): + * runtime/Structure.h: + +2009-09-11 Oliver Hunt + + Reviewed by Sam Weinig. + + getPropertyNames caching is invalid when the prototype chain contains objects with custom getPropertyNames + https://bugs.webkit.org/show_bug.cgi?id=29214 + + Add a flag to TypeInfo to indicate whether a type overrides getPropertyNames. + This flag is used to make sure that caching of the property name data is safe. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::hasDefaultGetPropertyNames): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StructureChain.cpp: + (JSC::StructureChain::isCacheable): + +2009-09-11 Alexey Proskuryakov + + Reviewed by Geoff Garen. + + https://bugs.webkit.org/show_bug.cgi?id=29207 + Add checks for using WebCore JS context on secondary threads + + * runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + Added a new mainThreadOnly flag that WebCore would set. + + * runtime/Collector.cpp: (JSC::Heap::registerThread): JSC API methods always call this, + so this is a good place to check that the API isn't used form a wrong thread. + +2009-09-11 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + Compiling JavaScriptCore on sparc 64 with gcc fails. + + ThreadSafeShared uses the atomic __gnu_cxx::__exchange_and_add with an int, + however on sparc 64 the _Atomic_word argument is typedefed to long (8 bytes). + + The patch disables WTF_USE_LOCKFREE_THREADSAFESHARED in ThreadSafeShared to use + a mutex instead when compiling for sparc 64 with gcc. + + https://bugs.webkit.org/show_bug.cgi?id=29175 + + * wtf/Platform.h: + __sparc64__ is not defined on all OS. + Uses instead: __sparc__ && __arch64__ || __sparcv9 + * wtf/Threading.h: + +2009-09-11 Prasanth Ullattil + + Reviewed by Simon Hausmann. + + Fix compile error on Windows7(64Bit) with latest SDK. + + Added the missing include file. + + * runtime/UString.cpp: + +2009-09-11 Joerg Bornemann + + Reviewed by Simon Hausmann. + + Qt/Windows CE compile fix, include the executable allocator and + markstack implementation in the windows build. + + * JavaScriptCore.pri: + +2009-09-08 John Abd-El-Malek + + Reviewed by Dimitri Glazkov. + + Remove unneeded define for ActiveX. + https://bugs.webkit.org/show_bug.cgi?id=29054 + + * wtf/Platform.h: + +2009-09-10 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Update JavaScriptCore and WebKit's FeatureDefines.xcconfig so that they are in sync with WebCore as they need to be. + + * Configurations/FeatureDefines.xcconfig: + +2009-09-10 Fumitoshi Ukai + + Reviewed by Alexey Proskuryakov. + + Export WTF::tryFastMalloc used in WebSocketChannel. + https://bugs.webkit.org/show_bug.cgi?id=28038 + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-10 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Make StructureTransitionTable use an enum for the PtrAndFlags member + used for the single transition slot optimisation. + + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTable::StructureTransitionTable): + (JSC::StructureTransitionTable::usingSingleTransitionSlot): + (JSC::StructureTransitionTable::): + +2009-09-10 Oliver Hunt + + Reviewed by Geoff Garen. + + Refactor StructureTransitionTable and Structure to unify handling of the single slot optimization + https://bugs.webkit.org/show_bug.cgi?id=29141 + + Make StructureTransitionTable encapsulate the single transition slot optimization. + + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::~Structure): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::removePropertyWithoutTransition): + (JSC::Structure::hasTransition): + * runtime/Structure.h: + (JSC::StructureTransitionTable::contains): + (JSC::StructureTransitionTable::get): + (JSC::StructureTransitionTable::hasTransition): + (JSC::StructureTransitionTable::reifySingleTransition): + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTable::StructureTransitionTable): + (JSC::StructureTransitionTable::~StructureTransitionTable): + (JSC::StructureTransitionTable::remove): + (JSC::StructureTransitionTable::add): + (JSC::StructureTransitionTable::table): + (JSC::StructureTransitionTable::singleTransition): + (JSC::StructureTransitionTable::usingSingleTransitionSlot): + (JSC::StructureTransitionTable::setSingleTransition): + (JSC::StructureTransitionTable::setTransitionTable): + (JSC::StructureTransitionTable::): + * wtf/PtrAndFlags.h: + (WTF::PtrAndFlags::PtrAndFlags): + +2009-09-10 Zoltan Horvath + + Reviewed by Darin Adler. + + Implement fastDeleteSkippingDestructor for FastAllocBase and fastDeleteAllValues for HashSet + https://bugs.webkit.org/show_bug.cgi?id=25930 + + FastAllocBase has been extended with fastDeleteSkippingDestructor function which + releases memory without destructor call. fastDeleteAllValues has been implemented + similar as deleteAllValues but it uses fastDelete function to release memory. + + * wtf/FastAllocBase.h: + (WTF::fastDeleteSkippingDestructor): + * wtf/HashSet.h: + (WTF::fastDeleteAllValues): + +2009-09-10 Laszlo Gombos + + Reviewed by Darin Adler. + + ARM compiler does not understand GCC visibility attribute + https://bugs.webkit.org/show_bug.cgi?id=29079 + + * API/JSBase.h: Make the test more specific to hit only + the GCC compiler + +2009-09-10 Adam Barth + + Unreviewed revert of the previous change. It broke the tests. + + * wtf/dtoa.cpp: + (WTF::dtoa): + +2009-09-10 Ben Laurie + + Reviewed by Adam Barth. + + + + If dtoa was given a small buffer and the number was either infinite or + NaN, then the buffer would be overflowed. + + * wtf/dtoa.cpp: + +2009-09-09 Laszlo Gombos + + Reviewed by Darin Adler. + + Change reinterpret_cast to static_cast in r48212. + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + +2009-09-09 Laszlo Gombos + + Reviewed by Darin Adler. + + Remove WTF_PLATFORM_FORCE_PACK as it is no longer used + https://bugs.webkit.org/show_bug.cgi?id=29066 + + * wtf/Platform.h: + +2009-09-09 Laszlo Gombos + + Reviewed by Ariya Hidayat. + + Implement flushing the instruction cache for Symbian + https://bugs.webkit.org/show_bug.cgi?id=29075 + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): Call IMB_Range to flush + the instruction cache on Symbian + +2009-09-09 Kent Hansen + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=29024 + Make JavaScriptCore compile on platforms with case-insensitive file systems and typeinfo.h in STL + + These platforms include Microsoft Visual Studio 2003, and Symbian with Metrowerks compiler. + + * JavaScriptCore.gypi: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/JSTypeInfo.h: Copied from JavaScriptCore/runtime/TypeInfo.h. + * runtime/Structure.h: + * runtime/TypeInfo.h: Removed. + +2009-09-08 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + JSON.stringify(Date) loses the milliseconds information + https://bugs.webkit.org/show_bug.cgi?id=29063 + + Make sure we include milliseconds in the output of toISOString. + + * runtime/DatePrototype.cpp: + (JSC::dateProtoFuncToISOString): + +2009-09-08 Kevin Ollivier + + wx build fix, generate derived sources earlier in order to make sure + they're found by the build system when generating the list of sources to build. + + * wscript: + +2009-09-08 Laszlo Gombos + + Reviewed by Simon Hausmann. + + Build fix when USE(LOCKFREE_THREADSAFESHARED) is not defined + https://bugs.webkit.org/show_bug.cgi?id=29011 + + * wtf/Threading.h: Use LOCKFREE_THREADSAFESHARED guard for + atomicIncrement and atomicDecrement + +2009-09-07 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control in Yarr's RegexInterpreter + https://bugs.webkit.org/show_bug.cgi?id=29025 + + Inherits RegexInterpreter classes from FastAllocBase (bug #20422), which has + been instantiated by 'new': + + class ByteDisjunction + -> instantiated in JavaScriptCore/yarr/RegexInterpreter.cpp:1462 + + struct BytecodePattern + -> instantiated in JavaScriptCore/yarr/RegexInterpreter.cpp:1279 + + * yarr/RegexInterpreter.h: + +2009-09-07 Drew Wilson + + Reverting r48121 to fix Windows build errors. + + * JavaScriptCore.exp: + +2009-09-07 Drew Wilson + + Reviewed by David Levin. + + Enable SHARED_WORKERS by default + https://bugs.webkit.org/show_bug.cgi?id=28959 + + * Configurations/FeatureDefines.xcconfig: + +2009-09-07 Fumitoshi Ukai + + Reviewed by Alexey Proskuryakov. + + Export WTF::tryFastMalloc used in WebSocketChannel. + https://bugs.webkit.org/show_bug.cgi?id=28038 + + * JavaScriptCore.exp: + +2009-09-04 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Fix windows export files + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-09-04 Oliver Hunt + + Reviewed by Gavin Barraclough. + + [[ToString]] conversion should use the actual toString function for String objects. + + Remove incorrect specialisations of toString conversions on StringObject. + + * JavaScriptCore.exp: + * runtime/StringObject.cpp: + * runtime/StringObject.h: + +2009-09-04 Steve Falkenburg + + Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Add new export. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Add new export. + +2009-09-04 Steve Falkenburg + + Windows build fix. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Remove unneeded export. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Remove unneeded export. + +2009-09-04 Darin Adler + + Reviewed by Geoff Garen. + + DateInstance object collected on ARM JIT (JSValue: WTF_USE_JSVALUE32) + https://bugs.webkit.org/show_bug.cgi?id=28909 + + Part two. + + Make some improvements to garbage collection code: + + 1) Create a runtime assertion that catches any classes that + override markChildren but have the HasDefaultMark bit set. + 2) Remove checks of the mark bit outside the MarkStack::append + function; they are redundant. + 3) Improve the efficiency of the asObject and asArray functions + when called on JSCell* to avoid a round trip to JSValue. + 4) Make more callers use the checked asCell and asObject + casting functions rather than unchecked casts. + 5) Removed the JSCell::marked function and other GC-related + functions because these operations are no longer things that + code other than the core GC code needs to do directly. Fixed + callers that were calling them. + + * runtime/Collector.cpp: + (JSC::Heap::markConservatively): Removed unneeded call to MarkStack::drain. + (JSC::Heap::markProtectedObjects): Removed unneeded check of the mark + bit and call to MarkStack::drain. + (JSC::Heap::collect): Removed unneeded checks of the mark bit and also + changed call to SmallStrings::mark to call markChildren instead to match + the rest of the objects. + (JSC::typeName): Removed unneeded cast to JSObject*. + + * runtime/JSArray.h: + (JSC::asArray): Added an overload for JSCell* and changed the JSValue + version to call it. Removed some unneeded casts. + (JSC::JSArray::markChildrenDirect): Marked this function inline. It's in + a header, and if not marked inline this could lead to linking problems. + (JSC::MarkStack::markChildren): Added. This helper function is used by + the drain function to avoid repating code. Also added the code here to + check fro default mark violations in debug code. If a markChildren + function adds something to the mark stack, but the type info claimed + hasDefaultMark was true, then we will get an assertion now. Also fixed + the assertion about the mark bit to use the Heap function directly + because we don't have a JSCell::marked function any more. + (JSC::MarkStack::drain): Changed a local variable from "v" to "value", + and from "currentCell" to "cell". Changed to call markChildren in two + places instead of repeating a chain of if statements twice. Changed + code that reads and writes the mark bit to use Heap::isCellMarked and + Heap::markCell so we can eliminate the JSCell::marked and + JSCell::markCellDirect functions. + + * runtime/JSCell.h: Removed JSCell's markCellDirect and marked member + functions. Added a comment explaining that asCell should be deprecated + in favor of the JSValue asCell member function. + (JSC::MarkStack::append): Added the assertion that catches callers + that have set the HasDefaultMark bit incorrectly. Changed + code that reads and writes the mark bit to use Heap::isCellMarked and + Heap::markCell so we can eliminate the JSCell::marked and + JSCell::markCellDirect functions. Moved the overload of + MarkStack::append for JSValue here so it can call through to the cell + version. The old version had a copy of all the code instead, but that + repeated the conversion from JSValue to JSCell* and the check for + whether a value is a cell multiple times. + (JSC::Structure::markAggregate): Moved this function here to avoid + dependencies for Structure.h, since this calls MarkStack::append. + + * runtime/JSObject.cpp: + (JSC::JSObject::markChildren): Added code to clear + m_isCheckingForDefaultMarkViolation so the marking done by JSObject + doesn't trigger the assertion. + + * runtime/JSValue.h: Moved some stray includes that were outside the + header guard inside it. Not sure how that happened! Removed the + GC-related member functions markChildren, hasChildren, marked, and + markDirect. + + * runtime/JSWrapperObject.h: Made markChildren private. + (JSC::JSWrapperObject::createStructure): Added. Fixes a bug where the + HasDefaultMark bit was set. + + * runtime/MarkStack.h: Added m_isCheckingForDefaultMarkViolation and + initialized it to false. Moved the append function body from here to + JSCell.h. Added a declaration of a private markChildren function used + inside the drain function. + + * runtime/SmallStrings.cpp: + (JSC::SmallStrings::markChildren): Changed the name and style of this + function to match other functions. This allows us to share the normal + mark stack code path. + + * runtime/SmallStrings.h: Changed the name and interface of mark to + the more-normal markChildren style. + + * runtime/Structure.h: Moved the body of markAggregate into the + JSCell.h to avoid a circular dependency with JSCell.h. + +2009-09-04 Darin Adler + + Reviewed by Geoff Garen. + + DateInstance object collected on ARM JIT (JSValue: WTF_USE_JSVALUE32) + https://bugs.webkit.org/show_bug.cgi?id=28909 + + Part one. + + Make some improvements to garbage collection code: + + 1) Fix the two classes that had the default mark bit set but + should not. + 2) Remove checks of the mark bit outside the MarkStack::append + function; they are redundant. + 3) Make more callers use the checked asCell and asObject + casting functions rather than unchecked casts. + 4) Removed some GC-related functions because these operations are + no longer things that code other than the core GC code needs + to do directly. Fixed callers that were calling them. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::markAggregate): Removed unneeded check of the mark + bit before calling MarkStack::append. + + * interpreter/Register.h: Removed unneeded marked and markChildren + functions. + + * jit/JITStubs.cpp: + (op_eq): Removed unneeded assertions, instead using checked casting + functions such as asObject. + + * runtime/ArgList.h: Added now-needed forward declaration of MarkStack. + + * runtime/GetterSetter.cpp: + (JSC::GetterSetter::markChildren): Remmoved unneeded check of the mark bit. + + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): Added. Fixes a bug where the + HasDefaultMark bit was set. + + * runtime/JSCell.cpp: + (JSC::JSCell::getObject): Use asObject to avoid a direct static_cast. + + * runtime/JSObject.h: + (JSC::asObject): Added an overload for JSCell* and changed the JSValue + version to call it. + (JSC::JSValue::get): Use asObject to avoid a direct static_cast. + + * runtime/JSWrapperObject.h: Made markChildren private. + (JSC::JSWrapperObject::createStructure): Added. Fixes a bug where the + HasDefaultMark bit was set. Later we may want to optimize this for + wrapper types that never have cells in their internal values, but there + is no measured performance regression in SunSpider or V8 doing this + all the time. + + * runtime/MarkStack.cpp: Tweaked formatting. + +2009-09-04 Kevin Ollivier + + wx build fix. Switch USE_ defines over to the compiler so that they can be + checked by files not including config.h (like WebCorePrefix.h). + + * wtf/Platform.h: + +2009-09-03 Yong Li + + Reviewed by David Levin. + + Remove unnecessary dependency on unistd.h + https://bugs.webkit.org/show_bug.cgi?id=28962 + + * runtime/Completion.cpp: + +2009-09-03 Fumitoshi Ukai + + Reviewed by Eric Seidel. + + Add strnstr for Linux and Windows in StringExtras.h + https://bugs.webkit.org/show_bug.cgi?id=28901 + + * wtf/StringExtras.h: + (strnstr): + +2009-09-03 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's HashEntry class + https://bugs.webkit.org/show_bug.cgi?id=27830 + + Inherits HashEntry class from FastAllocBase because it has been + instantiated by 'new' JavaScriptCore/runtime/Lookup.cpp:32. + + * runtime/Lookup.h: + +2009-09-02 Gavin Barraclough + + Should crash if JIT code buffer allocation fails. + + https://bugs.webkit.org/show_bug.cgi?id=28926 + + + * jit/ExecutableAllocatorPosix.cpp: + (JSC::ExecutablePool::systemAlloc): + * jit/ExecutableAllocatorWin.cpp: + (JSC::ExecutablePool::systemAlloc): + +2009-09-02 Kevin Ollivier + + waf build fixes for Windows/MSVC. + + * wscript: + +2009-09-02 Kevin Ollivier + + Build fix for building on Windows. + + * wtf/ThreadingPthreads.cpp: + +2009-09-02 Norbert Leser + + Reviewed by Eric Seidel. + + Use fastMalloc when neither MMAP nor VIRTUALALLOC are enabled + + RegisterFile constructor currently throws #error when both + MMAP and VIRTUALALLOC conditions fail. + On any platform that does not provide these features + (for instance, Symbian), + the fallback should be regular malloc (or fastMalloc). + It is functionally equivalent in this case, even though it may + have certain drawbacks such as lack of dynamic pre-allocation. + + * interpreter/RegisterFile.cpp: + (JSC::RegisterFile::~RegisterFile): + * interpreter/RegisterFile.h: + (JSC::RegisterFile::RegisterFile): + +2009-08-31 Robert Agoston + + Reviewed by Gavin Barraclough. + + Fixed typo. + https://bugs.webkit.org/show_bug.cgi?id=28691 + + * parser/Parser.h: + (JSC::Parser::parse): + +2009-08-27 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + JSON Stringifier does not follow ES5 spec for handling of Number, String and Boolean objects + https://bugs.webkit.org/show_bug.cgi?id=28797 + + Fixed unwrapBoxedPrimitive to do the right thing, which necessitated a couple of new exception + checks, and corrected the logic in gap to correctly convert Number and String objects. + + * runtime/JSONObject.cpp: + (JSC::unwrapBoxedPrimitive): + (JSC::gap): + (JSC::Stringifier::Stringifier): + (JSC::Stringifier::appendStringifiedValue): + +2009-08-27 Oliver Hunt + + Reviewed by Adam Roben. + + JSON.stringify replacer array does not accept values that are not string primitives. + https://bugs.webkit.org/show_bug.cgi?id=28788 + + Update the JSON stringifier to initialise its replacer array according to the most + recent version of the spec. + + * runtime/Identifier.h: + (JSC::Identifier::from): + * runtime/JSONObject.cpp: + (JSC::Stringifier::Stringifier): + +2009-08-27 Alexey Proskuryakov + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=28753 + Excessive number of threads (and a crash) + + * wtf/Threading.h: (WTF::atomicIncrement): Changed atomicIncrement to match decrement + and return the new value. Also added using directives for these functions, to match + te rest of WTF. + +2009-08-27 Brent Fulgham + + Reviewed by Adam Roben. + + Link the testapi against CFLite when building the WinCairo port. + + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Add new Release_CFLite + target. Update all targets to inherit from either the + JavaScriptCF.vsprops (Apple target) or the JavaScriptCFLite.vsprops + file (WinCairo target). + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: Remove + input file CoreFoundation.lib. This is provided by either the + JavaScriptCF.vsprops or JavaScriptCFLite.vsprops file. + +2009-08-27 Steve Falkenburg + + Reviewed by Geoff Garen. + + Fix Windows-specific crash due to missing memory clearing call. + + * runtime/Collector.cpp: + (JSC::Heap::allocateBlock): + +2009-08-27 Brent Fulgham + + Build fix: JavaScriptCore_debug.def missing some exports. Apple + Windows build does not use this file, so it was not noticed previously. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-27 Gavin Barraclough + + Reviewed by Oliver Hunt. + + x86-64 GTK broken due to code offsets changing, pointers sometimes packed into immediates. + https://bugs.webkit.org/show_bug.cgi?id=28317 + + Missed one, fix part II. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::move): + * assembler/X86Assembler.h: + (JSC::CAN_SIGN_EXTEND_8_32): + +2009-08-27 Oliver Hunt + + Reviewed by Adam Roben. + + JSON.stringify replacer array does not accept values that are not string primitives. + https://bugs.webkit.org/show_bug.cgi?id=28788 + + Update the JSON stringifier to initialise its replacer array according to the most + recent version of the spec. + + * runtime/Identifier.h: + (JSC::Identifier::from): + * runtime/JSONObject.cpp: + (JSC::Stringifier::Stringifier): + +2009-08-27 Oliver Hunt + + Reviewed by Alexey Proskuryakov. + + JSON parser accepts trailing comma in array literals + https://bugs.webkit.org/show_bug.cgi?id=28779 + + Update parser to correctly fail if there's a trailing comma. + + * runtime/LiteralParser.cpp: + (JSC::LiteralParser::parse): + +2009-08-26 Oliver Hunt + + Reviewed by Gavin Barraclough. + + 'this' in JSON.parse reviver is the global object + https://bugs.webkit.org/show_bug.cgi?id=28752 + + This is a technically simple change, we merely update the code for calling + the reviver function to pass the correct this object. Doing so however + exposes the holder to arbitrary mutation by the reviver function so it is + necessary for us to now guard all property accesses against the possibility + of failure. + + * runtime/JSArray.h: + JSON needs to delete a property from the array, so we friend its + Walker class so that we can make a non-virtual call to the arrays + delete and getOwnPropertySlot methods. + * runtime/JSONObject.cpp: + (JSC::Walker::callReviver): + We need to pass the correct this object + (JSC::Walker::walk): + Update calls to callReviver, and update property logic logic + to correctly handle the holder being mutated by the reviver + function. + +2009-08-26 Alice Liu + + Windows build fix: added some exported symbols + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-26 Geoffrey Garen + + Windows build fix: Removed some exported symbols that no longer exist. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-26 Gavin Barraclough + + Reviewed by Olliejver Hunt. + + x86-64 GTK broken due to code offsets changing, pointers sometimes packed into immediates. + https://bugs.webkit.org/show_bug.cgi?id=28317 + + We rely on a slightly OS X specific behaviour, that x86-64 applications have a 4Gb zero page, + so pointers are never representable as a 32-bit integer, and always have to be represented by + a separate immediate load instruction, rather than within the immediate field of an arithmetic + or memory operation. + + We explicitly check for a couple of cases where a value might be representable in 32-bit, but + these probably never kick in on Mac OS, and only kick in to hose GTK. Deleting these does not + show a performance degradation on SunSpider. Remove. + + * assembler/MacroAssemblerX86_64.h: + (JSC::MacroAssemblerX86_64::storePtr): + (JSC::MacroAssemblerX86_64::branchPtr): + +2009-08-26 Geoffrey Garen + + Reviewed by Oliver Hunt. + + A bit of Collector refatoring. + + SunSpider says no change. v8 says 1.003x faster (1.02x faster on splay). + + * JavaScriptCore.exp: + + * runtime/JSCell.cpp: + (JSC::JSCell::toPrimitive): + (JSC::JSCell::getPrimitiveNumber): + (JSC::JSCell::toBoolean): + (JSC::JSCell::toNumber): + (JSC::JSCell::toString): + (JSC::JSCell::toObject): Removed pure virtual functions from + JSCell, so the collector can construct one. This allowed + me to remove a bunch of ASSERT_NOT_REACHED throughout the + code, too. + + * runtime/JSCell.h: + (JSC::JSCell::JSCell): ditto + (JSC::Heap::heap): Inlined this function because it's trivial. + + * JavaScriptCore.exp: + + * runtime/Collector.cpp: + (JSC::Heap::destroy): + (JSC::Heap::allocateBlock): + (JSC::Heap::freeBlock): + (JSC::Heap::freeBlocks): Renamed freeHeap to freeBlocks, since + it doesn't actually free the Heap object. + (JSC::Heap::heapAllocate): + (JSC::Heap::sweep): + * runtime/Collector.h: Refactored block allocation and destruction + into helper functions. + + * runtime/GetterSetter.cpp: + * runtime/JSAPIValueWrapper.cpp: + * runtime/JSPropertyNameIterator.cpp: Removed dummy implementations + of pure virtual functions. (See above.) + +=== End re-roll-in of r47738:47740 with Windows crash fixed === + +2009-08-26 Geoffrey Garen + + Build fix: start out with a 32-bit value to avoid a shortening warning. + + * runtime/Collector.cpp: + (JSC::Heap::sweep): + +2009-08-24 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Substantially reduced VM thrash in the GC heap. + + 1.08x faster on v8 (1.60x faster on v8-splay). + + 1.40x faster on bench-alloc-nonretained. + + 1.90x faster on bench-alloc-retained. + + SunSpider says no change. + + * runtime/Collector.cpp: + (JSC::Heap::heapAllocate): Fixed a long-standing bug: update a few local + variables unconditionally after calling collect(), since they may be used + even if we don't "goto scan". (In the bug I saw, usedBlocks got out of + sync with heap.usedBlocks). + (JSC::Heap::sweep): Keep enough free heap space to accomodate + the number of objects we'll allocate before the next GC, plus 25%, for + good measure. + * runtime/Collector.h: Bumped the block size to 256k. This seems to give + the best cache performance, and it prevents us from initiating lots of + VM traffic to recover very small chunks of memory. + +=== Begin re-roll-in of r47738:47740 with Windows crash fixed === + +2009-08-25 Drew Wilson + + Reviewed by David Levin. + + postMessage() spec now supports sending arrays of ports + https://bugs.webkit.org/show_bug.cgi?id=26902 + + Added OwnPtr to VectorTraits so we can store OwnPtrs in Vectors. + + * wtf/VectorTraits.h: + +2009-08-26 Xan Lopez + + Rubber-stamped by Gustavo Noronha. + + Remove duplicated files from file list. + + * GNUmakefile.am: + +2009-08-26 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + More export fixes. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-26 Oliver Hunt + + Reviewed by NOBODY (Build fix). + + Hopefully fix all the exports from JSC on windows + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-26 Oliver Hunt + + Reviewed by NOBODY (Build fixes). + + Forgot I added files to JavaScriptCore. + + * GNUmakefile.am: + * JavaScriptCore.gypi: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCoreSources.bkl: + +2009-08-25 Oliver Hunt + + Reviewed by Gavin Barraclough. + + [ES5] Implement getOwnPropertyDescriptor + https://bugs.webkit.org/show_bug.cgi?id=28724 + + Implement the core runtime support for getOwnPropertyDescriptor. + This adds a virtual getOwnPropertyDescriptor method to every class + that implements getOwnPropertySlot that shadows the behaviour of + getOwnPropertySlot. The alternative would be to make getOwnPropertySlot + (or PropertySlots in general) provide property attribute information, + but quick testing showed this to be a regression. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/Arguments.cpp: + (JSC::Arguments::getOwnPropertyDescriptor): + * runtime/Arguments.h: + * runtime/ArrayPrototype.cpp: + (JSC::ArrayPrototype::getOwnPropertyDescriptor): + * runtime/ArrayPrototype.h: + * runtime/CommonIdentifiers.h: + * runtime/DatePrototype.cpp: + (JSC::DatePrototype::getOwnPropertyDescriptor): + * runtime/DatePrototype.h: + * runtime/JSArray.cpp: + (JSC::JSArray::getOwnPropertyDescriptor): + * runtime/JSArray.h: + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::getOwnPropertyDescriptor): + * runtime/JSByteArray.h: + * runtime/JSFunction.cpp: + (JSC::JSFunction::getOwnPropertyDescriptor): + * runtime/JSFunction.h: + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::getOwnPropertyDescriptor): + * runtime/JSNotAnObject.cpp: + (JSC::JSNotAnObject::getOwnPropertyDescriptor): + * runtime/JSNotAnObject.h: + * runtime/JSONObject.cpp: + (JSC::JSONObject::getOwnPropertySlot): + (JSC::JSONObject::getOwnPropertyDescriptor): + * runtime/JSONObject.h: + * runtime/JSObject.cpp: + (JSC::JSObject::getOwnPropertyDescriptor): + (JSC::JSObject::getPropertyDescriptor): + * runtime/JSObject.h: + * runtime/JSString.cpp: + (JSC::JSString::getStringPropertyDescriptor): + (JSC::JSString::getOwnPropertyDescriptor): + * runtime/JSString.h: + * runtime/JSVariableObject.cpp: + (JSC::JSVariableObject::symbolTableGet): + * runtime/JSVariableObject.h: + * runtime/Lookup.h: + (JSC::getStaticPropertyDescriptor): + (JSC::getStaticFunctionDescriptor): + (JSC::getStaticValueDescriptor): + Add property descriptor equivalents of the lookup + table access functions + + * runtime/MathObject.cpp: + (JSC::MathObject::getOwnPropertySlot): + (JSC::MathObject::getOwnPropertyDescriptor): + * runtime/MathObject.h: + * runtime/NumberConstructor.cpp: + (JSC::NumberConstructor::getOwnPropertyDescriptor): + * runtime/NumberConstructor.h: + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConstructorGetOwnPropertyDescriptor): + * runtime/PropertyDescriptor.cpp: Added. + (JSC::PropertyDescriptor::writable): + (JSC::PropertyDescriptor::enumerable): + (JSC::PropertyDescriptor::configurable): + (JSC::PropertyDescriptor::hasAccessors): + (JSC::PropertyDescriptor::setUndefined): + (JSC::PropertyDescriptor::getter): + (JSC::PropertyDescriptor::setter): + (JSC::PropertyDescriptor::setDescriptor): + (JSC::PropertyDescriptor::setAccessorDescriptor): + * runtime/PropertyDescriptor.h: Added. + (JSC::PropertyDescriptor::PropertyDescriptor): + (JSC::PropertyDescriptor::attributes): + (JSC::PropertyDescriptor::isValid): + (JSC::PropertyDescriptor::value): + * runtime/RegExpConstructor.cpp: + (JSC::RegExpConstructor::getOwnPropertyDescriptor): + * runtime/RegExpConstructor.h: + * runtime/RegExpMatchesArray.h: + (JSC::RegExpMatchesArray::getOwnPropertyDescriptor): + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::getOwnPropertyDescriptor): + * runtime/RegExpObject.h: + * runtime/StringObject.cpp: + (JSC::StringObject::getOwnPropertyDescriptor): + * runtime/StringObject.h: + * runtime/StringPrototype.cpp: + (JSC::StringPrototype::getOwnPropertyDescriptor): + * runtime/StringPrototype.h: + +2009-08-24 Gavin Barraclough + + Reviewed by Darin Adler. + + How many copies of the parameters do you need? + https://bugs.webkit.org/show_bug.cgi?id=28701 + + The function parameters in JSC get copied a lot - and unnecessarily so. + + Originally this happened due to duplicating FunctionBodyNodes on recompilation, + though the problem has been exacerbated by copying the parameters from the + original function body onto the executable, then back onto the real body that + will be generated (this happens on every function). And this is all made worse + since the data structures in question are a little ugly - C style arrays of C++ + objects containing ref counts, so they need a full copy-construct (rather than + a simple memcpy). + + This can all be greatly simplified by just punting the parameters off into + their own ref-counted object, and forgoing all the copying. + + ~no performance change, possible slight progression. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::makeFunction): + * parser/Nodes.cpp: + (JSC::FunctionParameters::FunctionParameters): + (JSC::FunctionBodyNode::FunctionBodyNode): + (JSC::FunctionBodyNode::finishParsing): + * parser/Nodes.h: + (JSC::FunctionBodyNode::parameters): + (JSC::FunctionBodyNode::parameterCount): + * runtime/Executable.cpp: + (JSC::FunctionExecutable::~FunctionExecutable): + (JSC::FunctionExecutable::compile): + (JSC::FunctionExecutable::reparseExceptionInfo): + (JSC::FunctionExecutable::fromGlobalCode): + (JSC::FunctionExecutable::paramString): + * runtime/Executable.h: + (JSC::FunctionExecutable::FunctionExecutable): + (JSC::FunctionExecutable::parameterCount): + +2009-08-25 Brent Fulgham + + Reviewed by NOBODY (Buildfix). + + * JavaScriptCore.vcproj/jsc/jsc.vcproj: Add Debug_CFLite target + that inherits from the debug_wincairo property sheet and therefore + links to the proper debug library. + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Add Debug_CFLite target + that inherits from the debug_wincairo property sheet and therefore + links to the proper debug library. + +2009-08-25 Chris Marrin + + Reviewed by Simon Fraser. + + Export tryFastMalloc for Canvas3D work + https://bugs.webkit.org/show_bug.cgi?id=28018 + + * JavaScriptCore.exp: + +2009-08-25 David Levin + + Reviewed by Adam Roben. + + PLATFORM(CFNETWORK) should be USE(CFNETWORK). + https://bugs.webkit.org/show_bug.cgi?id=28713 + + * wtf/Platform.h: Added a #define to catch this issue in the + future. The define would generate an error on gcc without the + space in the expansion, but Visual C++ needs the space to cause an error. + +2009-08-24 Brent Fulgham + + Reviewed by Steve Falkenburg. + + Revise CFLite Debug build to emit DLL's with _debug label. + https://bugs.webkit.org/show_bug.cgi?id=28695. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Modify + Cairo debug build to inherit from new debug_cairo property sheet. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCFLite.vsprops: + Modify to look for debug CFLite when in debug build. + +2009-08-24 Gavin Barraclough + + Reviewed by Oliver Adler & Darin Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=28691 + Do not retain ScopeNodes outside of parsing + + There is now no need for these to exist outside of parsing - their use in the runtime is replaced by Executable types. + + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::get): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + (JSC::BytecodeGenerator::emitNewFunction): + (JSC::BytecodeGenerator::emitNewFunctionExpression): + * bytecompiler/BytecodeGenerator.h: + (JSC::BytecodeGenerator::makeFunction): + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + (JSC::evaluateInGlobalCallFrame): + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::evaluate): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + (JSC::Interpreter::prepareForRepeatCall): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * parser/Nodes.cpp: + (JSC::ScopeNodeData::ScopeNodeData): + (JSC::ProgramNode::create): + (JSC::EvalNode::create): + (JSC::FunctionBodyNode::create): + * parser/Nodes.h: + (JSC::ScopeNode::adoptData): + (JSC::FunctionBodyNode::parameterCount): + * parser/Parser.cpp: + * parser/Parser.h: + (JSC::Parser::arena): + (JSC::Parser::Parser): + (JSC::Parser::parse): + * runtime/ArrayPrototype.cpp: + (JSC::isNumericCompareFunction): + (JSC::arrayProtoFuncSort): + * runtime/Completion.cpp: + (JSC::checkSyntax): + (JSC::evaluate): + * runtime/Executable.cpp: + (JSC::FunctionExecutable::~FunctionExecutable): + (JSC::EvalExecutable::compile): + (JSC::ProgramExecutable::checkSyntax): + (JSC::ProgramExecutable::compile): + (JSC::FunctionExecutable::compile): + (JSC::EvalExecutable::generateJITCode): + (JSC::ProgramExecutable::generateJITCode): + (JSC::FunctionExecutable::generateJITCode): + (JSC::FunctionExecutable::reparseExceptionInfo): + (JSC::EvalExecutable::reparseExceptionInfo): + (JSC::FunctionExecutable::recompile): + (JSC::FunctionExecutable::fromGlobalCode): + (JSC::FunctionExecutable::copyParameters): + (JSC::FunctionExecutable::paramString): + * runtime/Executable.h: + (JSC::ScriptExecutable::ScriptExecutable): + (JSC::ScriptExecutable::sourceID): + (JSC::ScriptExecutable::sourceURL): + (JSC::ScriptExecutable::lineNo): + (JSC::ScriptExecutable::lastLine): + (JSC::ScriptExecutable::usesEval): + (JSC::ScriptExecutable::usesArguments): + (JSC::ScriptExecutable::needsActivation): + (JSC::ScriptExecutable::recordParse): + (JSC::EvalExecutable::bytecode): + (JSC::EvalExecutable::jitCode): + (JSC::ProgramExecutable::bytecode): + (JSC::ProgramExecutable::reparseExceptionInfo): + (JSC::ProgramExecutable::jitCode): + (JSC::FunctionExecutable::FunctionExecutable): + (JSC::FunctionExecutable::make): + (JSC::FunctionExecutable::bytecode): + (JSC::FunctionExecutable::isGenerated): + (JSC::FunctionExecutable::name): + (JSC::FunctionExecutable::parameterCount): + (JSC::FunctionExecutable::jitCode): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::numericCompareFunction): + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::globalFuncEval): + +2009-08-24 Darin Adler + + * runtime/ObjectPrototype.cpp: + (JSC::ObjectPrototype::put): Landed revised version I had tested but forgot + to land. Leave out the branch, since we don't need one. + +2009-08-24 Darin Adler + + Reviewed by Geoff Garen. + + Array index miss case creates a string every time + https://bugs.webkit.org/show_bug.cgi?id=28664 + + SunSpider test results I saw: + + 0.5% faster overall + 1% faster on crypto-aes + 20% faster on crypto-md5 + 13% faster on crypto-sha1 + + * runtime/ObjectPrototype.cpp: + (JSC::ObjectPrototype::ObjectPrototype): Initialize m_hasNoPropertiesWithUInt32Names + to true. + (JSC::ObjectPrototype::put): Clearly m_hasNoPropertiesWithUInt32Names if the new + property has a name that is the string form of a UInt32. + (JSC::ObjectPrototype::getOwnPropertySlot): Don't call JSObject::getOwnPropertySlot + if m_hasNoPropertiesWithUInt32Names is true, and it is highly likely to be true. + + * runtime/ObjectPrototype.h: Added declarations for the above. + +2009-08-24 Gustavo Noronha Silva + + Unreviewed. Fix a typo in my distcheck build fix. + + * GNUmakefile.am: + +2009-08-23 Gustavo Noronha Silva + + Unreviewed build fix for make distcheck. + + * GNUmakefile.am: Added files required for the build. + +2009-08-22 Maciej Stachowiak + + Reviewed by Mark Rowe. + + REGRESSION(r47639-r47660): Webkit crashes on launch on PowerPC + https://bugs.webkit.org/show_bug.cgi?id=28655 + + * runtime/JSFunction.cpp: + (JSC::JSFunction::JSFunction): Initialize properly with a VPtrHackExecutable. + * wtf/Platform.h: + +2009-08-22 Darin Adler + + Fix storage leak from syntax tree arena allocation patch. + + * parser/Nodes.h: CommaNode needs to inherit from ParserArenaDeletable + because it has a vector. + +2009-08-21 Darin Adler + + Fix Qt build. + + * parser/Nodes.cpp: + (JSC::ScopeNodeData::ScopeNodeData): Made non-inline again. + This is used outside Nodes.cpp so can't be inline unless + it is in the header. + +2009-08-21 Darin Adler + + Two loose ends from the last commit. + + * JavaScriptCore.xcodeproj/project.pbxproj: Made ParserArena.h + and create_hash_table project-internal instead of "private". + * runtime/Executable.h: Removed accidentally-added constructor. + +2009-08-21 Darin Adler + + Reviewed by Gavin Barraclough. + + Syntax tree nodes should use arena allocation + https://bugs.webkit.org/show_bug.cgi?id=25674 + + Use an actual arena now. 0.6% speedup on SunSpider. + + New and improved with 100% less leaking of the universe. + + * JavaScriptCore.exp: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + Removed all exports involving the class FunctionBodyNode, which no + longer needs to be used outside JavaScriptCore. + + * JavaScriptCore.xcodeproj/project.pbxproj: Made Nodes.h and + Executable.h project-internal instead of "private". + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): Updated since VarStack + contains const Identifier* now. + + * parser/Grammar.y: Made identifiers from the lexer be const + Identifier* and updated since VarStack contains const Identifier* now. + + * parser/Lexer.cpp: + (JSC::Lexer::setCode): Pass in ParserArena, used for identifiers. + (JSC::Lexer::makeIdentifier): Changed return type to const Identifier* + and changed to call ParserArena. + (JSC::Lexer::clear): Removed the code to manage m_identifiers and + added code to set m_arena to 0. + * parser/Lexer.h: Updated for changes above. + + * parser/NodeConstructors.h: + (JSC::ParserArenaFreeable::operator new): Added. Calls allocateFreeable + on the arena. + (JSC::ParserArenaDeletable::operator new): Changed to call the + allocateDeletable function on the arena instead of deleteWithArena. + (JSC::PropertyNode::PropertyNode): Added new constructor that makes + numeric identifiers. Some day we might want to optimize this for + integers so it doesn't create a string for each one. + (JSC::ContinueNode::ContinueNode): Initialize m_ident to nullIdentifier + since it's now a const Identifier& so it can't be left uninitialized. + (JSC::BreakNode::BreakNode): Ditto. + (JSC::CaseClauseNode::CaseClauseNode): Updated to use SourceElements* + to keep track of the statements rather than a separate statement vector. + (JSC::BlockNode::BlockNode): Ditto. + (JSC::ForInNode::ForInNode): Initialize m_ident to nullIdentifier. + + * parser/Nodes.cpp: Moved the comment explaining emitBytecode in here. + It seemed strangely out of place in the header. + (JSC::ThrowableExpressionData::emitThrowError): Added an overload for + UString as well as Identifier. + (JSC::SourceElements::singleStatement): Added. + (JSC::SourceElements::lastStatement): Added. + (JSC::RegExpNode::emitBytecode): Changed the throwError code to use + the substitution mechanism instead of doing a string append. + (JSC::SourceElements::emitBytecode): Added. Replaces the old + statementListEmitCode function, since we now keep the SourceElements + objects around. + (JSC::BlockNode::lastStatement): Added. + (JSC::BlockNode::emitBytecode): Changed to use emitBytecode instead of + statementListEmitCode. + (JSC::CaseClauseNode::emitBytecode): Added. + (JSC::CaseBlockNode::emitBytecodeForBlock): Changed to use emitBytecode + instead of statementListEmitCode. + (JSC::ScopeNodeData::ScopeNodeData): Changed to store the + SourceElements* instead of using releaseContentsIntoVector. + (JSC::ScopeNode::emitStatementsBytecode): Added. + (JSC::ScopeNode::singleStatement): Added. + (JSC::ProgramNode::emitBytecode): Call emitStatementsBytecode instead + of statementListEmitCode. + (JSC::EvalNode::emitBytecode): Ditto. + (JSC::FunctionBodyNode::emitBytecode): Call emitStatementsBytecode + insetad of statementListEmitCode and check for the return node using + the new functions. + + * parser/Nodes.h: Changed VarStack to store const Identifier* instead + of Identifier and rely on the arena to control lifetime. Added a new + ParserArenaFreeable class. Made ParserArenaDeletable inherit from + FastAllocBase instead of having its own operator new. Base the Node + class on ParserArenaFreeable. Changed the various Node classes + to use const Identifier& instead of Identifier to avoid the need to + call their destructors and allow them to function as "freeable" in the + arena. Removed extraneous JSC_FAST_CALL on definitions of inline functions. + Changed ElementNode, PropertyNode, ArgumentsNode, ParameterNode, + CaseClauseNode, ClauseListNode, and CaseBlockNode to use ParserArenaFreeable + as a base class since they do not descend from Node. Eliminated the + StatementVector type and instead have various classes use SourceElements* + instead of StatementVector. This prevents those classes from having to + use ParserArenaDeletable to make sure the vector destructor is called. + + * parser/Parser.cpp: + (JSC::Parser::parse): Pass the arena to the lexer. + + * parser/Parser.h: Added an include of ParserArena.h, which is no longer + included by Nodes.h. + (JSC::Parser::parseFunctionFromGlobalCode): Changed to use the + singleStatement function, since there is no longer any children function. + Removed some unneeded use of RefPtr. + + * parser/ParserArena.cpp: + (JSC::ParserArena::ParserArena): Added. Initializes the new members, + m_freeableMemory, m_freeablePoolEnd, and m_identifiers. + (JSC::ParserArena::freeablePool): Added. Computes the pool pointer, + since we store only the current pointer and the end of pool pointer. + (JSC::ParserArena::deallocateObjects): Added. Contains the common + memory-deallocation logic used by both the destructor and the + reset function. + (JSC::ParserArena::~ParserArena): Changed to call deallocateObjects. + (JSC::ParserArena::reset): Ditto. Also added code to zero out the + new structures, and switched to use clear() instead of shrink(0) since + we don't really reuse arenas. + (JSC::ParserArena::makeNumericIdentifier): Added. + (JSC::ParserArena::allocateFreeablePool): Added. Used when the pool + is empty. + (JSC::ParserArena::isEmpty): Added. No longer inline, which is fine + since this is used only for assertions at the moment. + (JSC::ParserArena::derefWithArena): Make non-inline. + + * parser/ParserArena.h: Added an actual arena of "freeable" objects, + ones that don't need destructors to be called. Also added a separate + IdentifierArena object, a segmented vector of identifiers that used + to be in the Lexer. + + * runtime/Executable.h: Moved the definition of the + FunctionExecutable::make function here. It can't go in JSFunction.h + since that header has to be used outside JavaScriptCore and so can't + include this, which includes Nodes.h. The function could be moved + elswhere if we don't want to include JSFunction.h in this header, but + for now this seems to be the best place. + + * runtime/JSFunction.h: Removed the include of Executable.h and + definition of the FunctionExecutable::make function. + + * wtf/FastMalloc.cpp: Fixed an incorrect comment. + +2009-08-21 Mark Rowe + + Fix the non-JIT build. + + * runtime/Executable.cpp: + * runtime/Executable.h: + +2009-08-21 Gavin Barraclough + + Speculative QuickTime build fix. + + * runtime/JSArray.cpp: + +2009-08-21 Gavin Barraclough + + Speculative QT build fix. + + * runtime/StringPrototype.cpp: + +2009-08-21 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Restructure Executable types so that host functions do not hold a FunctionExecutable. + https://bugs.webkit.org/show_bug.cgi?id=28621 + + All JSFunction objects have a pointer to an Executable*. This is currently always a + FunctionExecutable, however this has a couple of drawbacks. Host functions do not + store a range of information that the FunctionExecutable provides (source, name, + CodeBlock & information presently held on the FunctionBodyNode). + + [ * nearly all... see below! ] + + Instead, make JSFunctions hold a pointer to an ExecutableBase, move fields specific + to JS sourced executable types (source, node) into a new subclass (ScriptExecutable), + and create a new NativeExecutable type. We now provide a new method in JSFunction + to access & downcast to FunctionExecutable, but in doing so we can make an early + check (with an ASSERT) to ensure that the Executable read from a function will only + be treated as a FunctionExecutable (and thus the JS sepcific fields will only be + accessed) if the JSFunction is not a host function. + + There is one JSFunction that currently does not have an Executable, which is the + object created to allow us to read out the vtable pointer. By making this change + we can also add a new Executable type fror this object (VPtrHackExecutable). + Since this means that really all JSFunctions have an Executable we no longer have + to null-check m_executable before us it - particularly in isHostFunction(). + + This patch removes CacheableEvalExecutable, since all subclasses of ExecutableBase + can now be ref-counted - since both JSFunction holds (and ref-counts) an ExecutableBase + that might be a FunctionExecutable or a NativeExecutable. This does now mean that all + ProgramExecutables and EvalExecutables (unnecessarily) provide an interface to be + ref-counted, however this seems less-bad than host functions unnecessarily providing + interface to access non-host specific information. + + The class hierarcy has changed from this: + + - ExecutableBase + - ProgramExecutable + - EvalExecutable + - CacheableEvalExecutable (also RefCounted by multiple-inheritance) + - FunctionExecutable (also RefCounted by multiple-inheritance, 'special' FunctionExecutable also used for host functions) + + To this: + + - RefCounted + - ExecutableBase + - NativeExecutable + - VPtrHackExecutable + - ScriptExecutable + - ProgramExecutable + - EvalExecutable + - FunctionExecutable + + This patch speeds up sunspidey by a couple of ms (presumably due to the changes to isHostFunction()). + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::CodeBlock): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::ownerExecutable): + (JSC::GlobalCodeBlock::GlobalCodeBlock): + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::get): + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + * interpreter/CachedCall.h: + (JSC::CachedCall::CachedCall): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::callEval): + (JSC::Interpreter::privateExecute): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * profiler/Profiler.cpp: + (JSC::createCallIdentifierFromFunctionImp): + * runtime/Arguments.h: + (JSC::Arguments::getArgumentsData): + (JSC::Arguments::Arguments): + * runtime/Executable.cpp: + (JSC::NativeExecutable::~NativeExecutable): + (JSC::VPtrHackExecutable::~VPtrHackExecutable): + * runtime/Executable.h: + (JSC::ExecutableBase::ExecutableBase): + (JSC::ExecutableBase::~ExecutableBase): + (JSC::ExecutableBase::isHostFunction): + (JSC::NativeExecutable::NativeExecutable): + (JSC::VPtrHackExecutable::VPtrHackExecutable): + (JSC::ScriptExecutable::ScriptExecutable): + (JSC::ScriptExecutable::source): + (JSC::ScriptExecutable::sourceID): + (JSC::ScriptExecutable::sourceURL): + (JSC::ScriptExecutable::lineNo): + (JSC::ScriptExecutable::lastLine): + (JSC::ScriptExecutable::usesEval): + (JSC::ScriptExecutable::usesArguments): + (JSC::ScriptExecutable::needsActivation): + (JSC::EvalExecutable::EvalExecutable): + (JSC::EvalExecutable::create): + (JSC::ProgramExecutable::ProgramExecutable): + (JSC::FunctionExecutable::FunctionExecutable): + * runtime/FunctionPrototype.cpp: + (JSC::functionProtoFuncToString): + * runtime/JSFunction.cpp: + (JSC::JSFunction::JSFunction): + (JSC::JSFunction::~JSFunction): + (JSC::JSFunction::markChildren): + (JSC::JSFunction::getCallData): + (JSC::JSFunction::call): + (JSC::JSFunction::lengthGetter): + (JSC::JSFunction::getConstructData): + (JSC::JSFunction::construct): + * runtime/JSFunction.h: + (JSC::JSFunction::executable): + (JSC::JSFunction::jsExecutable): + (JSC::JSFunction::isHostFunction): + +2009-08-20 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Browser hangs on opening Web Inspector. + https://bugs.webkit.org/show_bug.cgi?id=28438 + + Code generation needs to be able to walk the entire scopechain in some + cases, however the symbol table used by activations was a member of the + codeblock. Following recompilation this may no longer exist, leading + to a crash or hang on lookup. + + We fix this by introducing a refcounted SymbolTable subclass, SharedSymbolTable, + for the CodeBlocks used by function code. This allows activations to + maintain ownership of a copy of the symbol table even after recompilation so + they can continue to work. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::CodeBlock): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::symbolTable): + (JSC::CodeBlock::sharedSymbolTable): + (JSC::GlobalCodeBlock::GlobalCodeBlock): + (JSC::FunctionCodeBlock::FunctionCodeBlock): + (JSC::FunctionCodeBlock::~FunctionCodeBlock): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::retrieveArguments): + * runtime/Executable.cpp: + (JSC::EvalExecutable::generateBytecode): + (JSC::FunctionExecutable::generateBytecode): + (JSC::FunctionExecutable::reparseExceptionInfo): + (JSC::EvalExecutable::reparseExceptionInfo): + * runtime/JSActivation.h: + (JSC::JSActivation::JSActivationData::JSActivationData): + (JSC::JSActivation::JSActivationData::~JSActivationData): + * runtime/SymbolTable.h: + +2009-08-20 Xan Lopez + + Add new file to GTK+ build. + + * GNUmakefile.am: + +2009-08-20 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Added a number => string cache. + + 1.07x faster on v8 (1.7x faster on v8-splay). + 1.004x faster on SunSpider. + + * runtime/JSCell.h: Moved JSValue::toString to JSString.h. + * runtime/JSGlobalData.h: Holds the cache. + * runtime/JSNumberCell.cpp: + (JSC::JSNumberCell::toString): + (JSC::JSNumberCell::toThisString): Removed -0 special case. + UString handles this now, since too many clients were + special-casing it. + + * runtime/JSString.h: + (JSC::JSValue::toString): Use the cache when converting + an int or double to string. + + * runtime/Operations.h: + (JSC::concatenateStrings): Call toString to take advantage + of the cache. + + * runtime/SmallStrings.h: + (JSC::NumericStrings::add): + (JSC::NumericStrings::lookup): The cache. + + * runtime/UString.cpp: + (JSC::UString::from): Added -0 special case mentioned above. + Removed appendNumeric because it's mutually exclusive with the + cache. + +2009-08-20 Oliver Hunt + + Reviewed by Gavin Barraclough. + + REGRESSION: fast/profiler/call.html is crashing occasionally + https://bugs.webkit.org/show_bug.cgi?id=28476 + + Using the codeblock for information about how many parameters and + locals a function has is unsafe in certain circumstances. The + basic scenario is all function code being cleared in response to + the debugger or profiler being enabled, and then an activation is + marked before its associated function is re-executed. + + To deal with this scenario we store the variable count of a function + directly in the FunctionExecutable, and then use that information. + + * runtime/Arguments.h: + (JSC::Arguments::getArgumentsData): + * runtime/Executable.cpp: + (JSC::FunctionExecutable::generateBytecode): + * runtime/Executable.h: + (JSC::FunctionExecutable::FunctionExecutable): + (JSC::FunctionExecutable::variableCount): + * runtime/JSActivation.cpp: + (JSC::JSActivation::markChildren): + +2009-08-20 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Numbering of arguments to emitGetJITStubArg/emitPutJITStubArg incorrect + + + The argumentNumber argument to emitGetJITStubArg/emitPutJITStubArg should match + the argument number used within the stub functions in JITStubs.cpp, but it doesn't. + + Firstly, all the numbers changed when we added a void* 'reserved' as the first slot + (rather than leaving argument 0 unused), and secondly in 32_64 builds the index to + peek/poke needs to be multiplies by 2 (since the argument to peek/poke is a number + of machine words, and on 32_64 build the argument slots to stub functions are two + words wide). + + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallSetupArgs): + (JSC::JIT::compileOpConstructSetupArgs): + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpCall): + * jit/JITInlineMethods.h: + (JSC::JIT::emitPutJITStubArg): + (JSC::JIT::emitPutJITStubArgConstant): + (JSC::JIT::emitGetJITStubArg): + (JSC::JIT::emitPutJITStubArgFromVirtualRegister): + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::privateCompilePutByIdTransition): + +2009-08-20 Oliver Hunt + + Reviewed by Geoff Garen. + + REGRESSION: significant slowdown on Celtic Kane "AJAX declaration" subtest + https://bugs.webkit.org/show_bug.cgi?id=28332 + + Follow up style fixes that were missed in review. + + * runtime/Structure.cpp: + (JSC::Structure::hasTransition): + * runtime/Structure.h: + (JSC::Structure::get): + (JSC::StructureTransitionTable::contains): + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTable::add): + +2009-08-20 Oliver Hunt + + Add new exports to windows jsc build + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-20 Oliver Hunt + + Reviewed by Gavin Barraclough. + + REGRESSION: significant slowdown on Celtic Kane "AJAX declaration" subtest + https://bugs.webkit.org/show_bug.cgi?id=28332 + + The method check optimisation made transitions aware of the value being + assigned when a transition was assigning a function. This had the side + effect of making every assignment of a function expression result in a + new transition, and thus a new Structure. The net result of this is that + the common JS idiom of + + function MyObject() { + this.myFunction = function(...){...}; + } + new MyObject(); + + Will produce a unique structure on every iteration, meaning that all + caching is defeated and there is a significant amount of structure churn. + + The fix is to return the transition to its original form where it is + keyed off a property name + attributes tuple, but have each transition + support an optional transition on a specific value. + + * JavaScriptCore.exp: + * runtime/JSObject.h: + (JSC::JSObject::putDirectInternal): + * runtime/Structure.cpp: + (JSC::Structure::~Structure): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::hasTransition): + * runtime/Structure.h: + (JSC::Structure::transitionedFor): + (JSC::Structure::hasTransition): + (JSC::Structure::): + (JSC::StructureTransitionTable::contains): + (JSC::StructureTransitionTable::get): + * runtime/StructureTransitionTable.h: + (JSC::StructureTransitionTableHashTraits::emptyValue): + (JSC::StructureTransitionTable::hasTransition): + (JSC::StructureTransitionTable::remove): + (JSC::StructureTransitionTable::add): + +2009-08-20 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Remove FunctionCodeBlock. + https://bugs.webkit.org/show_bug.cgi?id=28502 + + These only exist to allow JIT code to dereference properties off the + CodeBlock for any callee, regardless of whether it is a host function. + + Instead just use the FunctionExecutable. Copy the m_parameters field + from the CodeBlock into the Executable, and use this to distinguish + between host functions, functions that have been bytecompiled, and + functions that have not. + + m_parameters is moved to ExecutableBase rather than FunctionExecutable + so that (as a separate change) we can move make a separate class of + executable for host code, which is not devived from FunctionExecutable + (host code does not feature any of the properties that normal executable + do and will provide, such as source, attributes, and a parsed name). + + 1% win on v8 tests, 0.5% on sunspider. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::derefStructures): + (JSC::CodeBlock::refStructures): + (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): + (JSC::CodeBlock::handlerForBytecodeOffset): + (JSC::CodeBlock::lineNumberForBytecodeOffset): + (JSC::CodeBlock::expressionRangeForBytecodeOffset): + (JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset): + (JSC::CodeBlock::functionRegisterForBytecodeOffset): + (JSC::CodeBlock::hasGlobalResolveInstructionAtBytecodeOffset): + (JSC::CodeBlock::hasGlobalResolveInfoAtBytecodeOffset): + * bytecode/CodeBlock.h: + (JSC::): + (JSC::CodeBlock::source): + (JSC::CodeBlock::sourceOffset): + (JSC::CodeBlock::evalCodeCache): + (JSC::CodeBlock::createRareDataIfNecessary): + + remove NativeCodeBlocks and the NativeCode code type. + + * jit/JIT.cpp: + (JSC::JIT::linkCall): + + Revert to previous behaviour (as currently still commented!) that Hhost functions have a null codeblock. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallInitializeCallFrame): + (JSC::JIT::compileOpCallSetupArgs): + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpConstructSetupArgs): + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::compileOpCall): + (JSC::JIT::compileOpCallSlowCase): + + Bring the 32_64 & non-32_64 JITs into line with each other, callee in regT0. + + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + + Rewrite call trampolines to not use the CodeBlock. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + + Make call_JSFunction & call_arityCheck return the callee, don't expect to be passed the CodeBlock. + + * runtime/Executable.cpp: + (JSC::FunctionExecutable::generateBytecode): + (JSC::FunctionExecutable::recompile): + (JSC::FunctionExecutable::FunctionExecutable): + * runtime/Executable.h: + (JSC::ExecutableBase::): + (JSC::ExecutableBase::ExecutableBase): + (JSC::FunctionExecutable::isHostFunction): + + Add m_numParameters. + + * runtime/JSFunction.cpp: + (JSC::JSFunction::~JSFunction): + + Only call generatedBytecode() on JSFunctions non-host FunctionExecutables. + +2009-08-20 Yongjun Zhang + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=28054 + + Use a helper function to work around winscw compiler forward declaration bug + regarding templated classes. + + Add parenthesis around (PassRefPtr::*UnspecifiedBoolType) to make winscw compiler + work with the default UnSpecifiedBoolType() operator, which removes the winscw + specific bool cast hack. + + * wtf/PassRefPtr.h: + (WTF::derefIfNotNull): + (WTF::PassRefPtr::~PassRefPtr): + +2009-08-19 Yong Li + + Reviewed by Gavin Barraclough. + + Change namespace ARM to ARMRegisters + X86 to X86Registers to avoid conflict with macros + https://bugs.webkit.org/show_bug.cgi?id=28428 + + * assembler/ARMAssembler.cpp: + * assembler/ARMAssembler.h: + * assembler/ARMv7Assembler.h: + * assembler/MacroAssemblerARM.h: + * assembler/MacroAssemblerARMv7.h: + * assembler/MacroAssemblerX86Common.h: + * assembler/MacroAssemblerX86_64.h: + * assembler/X86Assembler.h: + * jit/JIT.h: + * jit/JITArithmetic.cpp: + * jit/JITInlineMethods.h: + * jit/JITOpcodes.cpp: + * wrec/WRECGenerator.cpp: + * wrec/WRECGenerator.h: + * yarr/RegexJIT.cpp: + +2009-08-19 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Devirtualise marking + https://bugs.webkit.org/show_bug.cgi?id=28294 + + We actually need to mark the value in a number object if we're using the + 32bit number representation. + + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + +2009-08-19 Gavin Barraclough + + Reviewed by Darin Adler. + + We probably shouldn't be keeping the AST for eval nodes around forevar. + https://bugs.webkit.org/show_bug.cgi?id=28469 + + EvalNodes don't destroyData() (delete their parser data) since they need to hold onto + their varStack. Copy a list of variable onto EvalCodeBlock, and this can go away. + + * bytecode/CodeBlock.h: + (JSC::EvalCodeBlock::variable): + (JSC::EvalCodeBlock::numVariables): + (JSC::EvalCodeBlock::adoptVariables): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + * parser/Nodes.h: + * runtime/Executable.cpp: + (JSC::EvalExecutable::generateBytecode): + * runtime/Executable.h: + +2009-08-19 Jungshik Shin + + Reviewed by Darin Adler. + + http://bugs.webkit.org/show_bug.cgi?id=28441 + + Fix a build issue with ICU 4.2 or later on Windows with Visual C++. + Instead of defining all isXXX and toupper/tolower as + WTF_Please_use_ASCIICType_instead_of_ctype_see_comment_in_ASCIICType_h, + #define them to be different by prepending 'WTF_...ASCIIType_h' with + the originial names like 'toupper_WTF_...ASCIIType_h'. + + * wtf/DisallowCType.h: + +2009-08-18 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Assigning a function to an object should always use the existing transition, even if the transition is not specialized + https://bugs.webkit.org/show_bug.cgi?id=28442 + + Check for an unspecialized transition as an alternative to always failing if specialisation does not match. + + * runtime/Structure.cpp: + (JSC::Structure::addPropertyTransitionToExistingStructure): + +2009-08-18 Dirk Schulze + + Reviewed by Oliver Hunt. + + Added additional getter to ByteArray with an unsigned char as return. + ByteArray can take unsigned char directly now. + + * wtf/ByteArray.h: + (WTF::ByteArray::set): + (WTF::ByteArray::get): + +2009-08-18 Peter Kasting + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=28415 + Set svn:eol-style CRLF on all .sln and .vcproj files that don't already + have it. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + +2009-08-18 Xan Lopez + + Try to fix the GTK+ build. + + * GNUmakefile.am: + +2009-08-17 Gavin Barraclough + + Reviewed by Sam Weinig. + + No, silly runtime, AST nodes are not for you. + + We still use AST nodes (ScopeNodes, particularly FunctionBodyNodes) within + the runtime, which means that these nodes must be persisted outside of the + arena, contain both parser & runtime data, etc. This is all a bit of a mess. + + Move functionality into a new FunctionExecutable class. + + * API/JSCallbackFunction.cpp: + * API/JSObjectRef.cpp: + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::CodeBlock): + (JSC::CodeBlock::markAggregate): + (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): + (JSC::CodeBlock::lineNumberForBytecodeOffset): + (JSC::CodeBlock::shrinkToFit): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::getBytecodeIndex): + (JSC::CodeBlock::discardBytecode): + (JSC::CodeBlock::instructionCount): + (JSC::CodeBlock::getJITCode): + (JSC::CodeBlock::executablePool): + (JSC::CodeBlock::ownerExecutable): + (JSC::CodeBlock::extractExceptionInfo): + (JSC::CodeBlock::addFunctionDecl): + (JSC::CodeBlock::functionDecl): + (JSC::CodeBlock::numberOfFunctionDecls): + (JSC::CodeBlock::addFunctionExpr): + (JSC::CodeBlock::functionExpr): + (JSC::GlobalCodeBlock::GlobalCodeBlock): + (JSC::ProgramCodeBlock::ProgramCodeBlock): + (JSC::EvalCodeBlock::EvalCodeBlock): + (JSC::FunctionCodeBlock::FunctionCodeBlock): + (JSC::NativeCodeBlock::NativeCodeBlock): + * bytecode/EvalCodeCache.h: + * bytecode/SamplingTool.cpp: + (JSC::SamplingTool::doRun): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + (JSC::BytecodeGenerator::emitNewFunction): + (JSC::BytecodeGenerator::emitNewFunctionExpression): + * bytecompiler/BytecodeGenerator.h: + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + * interpreter/CachedCall.h: + (JSC::CachedCall::CachedCall): + * interpreter/CallFrameClosure.h: + * interpreter/Interpreter.cpp: + (JSC::Interpreter::unwindCallFrame): + (JSC::Interpreter::throwException): + (JSC::Interpreter::execute): + (JSC::Interpreter::prepareForRepeatCall): + (JSC::Interpreter::debug): + (JSC::Interpreter::privateExecute): + (JSC::Interpreter::retrieveLastCaller): + * interpreter/Interpreter.h: + * jit/JIT.cpp: + (JSC::JIT::privateCompile): + * jit/JIT.h: + (JSC::JIT::compile): + * jit/JITOpcodes.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + (JSC::JIT::emit_op_new_func): + (JSC::JIT::emit_op_new_func_exp): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): + * parser/Nodes.cpp: + (JSC::FunctionBodyNode::reparseDataIfNecessary): + * parser/Nodes.h: + (JSC::EvalNode::partialDestroyData): + * parser/Parser.h: + * profiler/ProfileGenerator.cpp: + * profiler/Profiler.cpp: + (JSC::Profiler::createCallIdentifier): + (JSC::createCallIdentifierFromFunctionImp): + * runtime/Arguments.h: + (JSC::Arguments::getArgumentsData): + (JSC::Arguments::Arguments): + (JSC::JSActivation::copyRegisters): + * runtime/ArrayPrototype.cpp: + (JSC::isNumericCompareFunction): + * runtime/CallData.h: + (JSC::): + * runtime/Collector.cpp: + (JSC::Heap::collect): + * runtime/ConstructData.h: + (JSC::): + * runtime/ExceptionHelpers.cpp: + (JSC::createUndefinedVariableError): + (JSC::createInvalidParamError): + (JSC::createNotAConstructorError): + (JSC::createNotAFunctionError): + (JSC::createNotAnObjectError): + * runtime/Executable.cpp: Added. + (JSC::EvalExecutable::generateBytecode): + (JSC::ProgramExecutable::generateBytecode): + (JSC::FunctionExecutable::generateBytecode): + (JSC::EvalExecutable::generateJITCode): + (JSC::ProgramExecutable::generateJITCode): + (JSC::FunctionExecutable::generateJITCode): + (JSC::FunctionExecutable::isHostFunction): + (JSC::FunctionExecutable::markAggregate): + (JSC::FunctionExecutable::reparseExceptionInfo): + (JSC::EvalExecutable::reparseExceptionInfo): + (JSC::FunctionExecutable::recompile): + (JSC::FunctionExecutable::FunctionExecutable): + * runtime/Executable.h: + (JSC::ExecutableBase::~ExecutableBase): + (JSC::ExecutableBase::ExecutableBase): + (JSC::ExecutableBase::source): + (JSC::ExecutableBase::sourceID): + (JSC::ExecutableBase::lastLine): + (JSC::ExecutableBase::usesEval): + (JSC::ExecutableBase::usesArguments): + (JSC::ExecutableBase::needsActivation): + (JSC::ExecutableBase::astNode): + (JSC::ExecutableBase::generatedJITCode): + (JSC::ExecutableBase::getExecutablePool): + (JSC::EvalExecutable::EvalExecutable): + (JSC::EvalExecutable::bytecode): + (JSC::EvalExecutable::varStack): + (JSC::EvalExecutable::evalNode): + (JSC::EvalExecutable::jitCode): + (JSC::ProgramExecutable::ProgramExecutable): + (JSC::ProgramExecutable::reparseExceptionInfo): + (JSC::ProgramExecutable::bytecode): + (JSC::ProgramExecutable::programNode): + (JSC::ProgramExecutable::jitCode): + (JSC::FunctionExecutable::FunctionExecutable): + (JSC::FunctionExecutable::name): + (JSC::FunctionExecutable::bytecode): + (JSC::FunctionExecutable::generatedBytecode): + (JSC::FunctionExecutable::usesEval): + (JSC::FunctionExecutable::usesArguments): + (JSC::FunctionExecutable::parameterCount): + (JSC::FunctionExecutable::paramString): + (JSC::FunctionExecutable::isGenerated): + (JSC::FunctionExecutable::body): + (JSC::FunctionExecutable::jitCode): + (JSC::FunctionExecutable::createNativeThunk): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/FunctionPrototype.cpp: + (JSC::functionProtoFuncToString): + * runtime/JSActivation.cpp: + (JSC::JSActivation::JSActivation): + (JSC::JSActivation::markChildren): + (JSC::JSActivation::isDynamicScope): + (JSC::JSActivation::argumentsGetter): + * runtime/JSActivation.h: + (JSC::JSActivation::JSActivationData::JSActivationData): + * runtime/JSFunction.cpp: + (JSC::JSFunction::isHostFunction): + (JSC::JSFunction::JSFunction): + (JSC::JSFunction::~JSFunction): + (JSC::JSFunction::markChildren): + (JSC::JSFunction::getCallData): + (JSC::JSFunction::call): + (JSC::JSFunction::lengthGetter): + (JSC::JSFunction::getConstructData): + (JSC::JSFunction::construct): + * runtime/JSFunction.h: + (JSC::JSFunction::executable): + (JSC::FunctionExecutable::make): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + (JSC::JSGlobalData::numericCompareFunction): + * runtime/JSGlobalData.h: + +2009-08-17 Mark Rowe + + Reviewed by Darin Adler. + + Fix 300,000+ leaks seen during the regression tests. + + EvalCodeCache::get was heap-allocating an EvalExecutable instance without adopting the initial reference. + While fixing this we noticed that EvalExecutable was a RefCounted type that was sometimes stack allocated. + To make this cleaner and to prevent clients from attempting to ref a stack-allocated instance, we move the + refcounting down to a new CacheableEvalExecutable class that derives from EvalExecutable. EvalCodeCache::get + now uses CacheableEvalExecutable::create and avoids the leak. + + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::get): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::callEval): + * runtime/Executable.h: + (JSC::CacheableEvalExecutable::create): + (JSC::CacheableEvalExecutable::CacheableEvalExecutable): + +2009-08-17 Oliver Hunt + + RS=Mark Rowe. + + REGRESSION (r47292): Prototype.js is broken by ES5 Arguments changes + https://bugs.webkit.org/show_bug.cgi?id=28341 + + + Reverting r47292. Alas Prototype.js breaks with Arguments inheriting + from Array as ES5 attempted. Prototype.js defines $A in terms of a + function it places on (among other global objects) the Array prototype, + thus breaking $A for arrays. + + * runtime/Arguments.h: + (JSC::Arguments::Arguments): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::reset): + (JSC::JSGlobalObject::markChildren): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + * runtime/ObjectPrototype.cpp: + (JSC::ObjectPrototype::ObjectPrototype): + * runtime/ObjectPrototype.h: + * tests/mozilla/ecma_3/Function/arguments-001.js: + +2009-08-17 Peter Kasting + + Reviewed by Steve Falkenburg. + + https://bugs.webkit.org/show_bug.cgi?id=27323 + Only add Cygwin to the path when it isn't already there. This avoids + causing problems for people who purposefully have non-Cygwin versions of + executables like svn in front of the Cygwin ones in their paths. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: + * JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: + +2009-08-17 Xan Lopez + + Reviewed by Mark Rowe. + + Fix build with FAST_MALLOC_MATCH_VALIDATION enabled. + + * wtf/FastMalloc.cpp: + (WTF::fastMalloc): + (WTF::fastCalloc): + (WTF::fastRealloc): + +2009-08-16 Holger Hans Peter Freyther + + Reviewed by Mark Rowe. + + Fix crash on ./ecma_2/RegExp/exec-002.js. + https://bugs.webkit.org/show_bug.cgi?id=28353 + + Change the order of freeParenthesesDisjunctionContext and + popParenthesesDisjunctionContext on all call sites as the pop + method is accessing backTrack->lastContext which is the context + that is about to be freed. + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::Interpreter::parenthesesDoBacktrack): + (JSC::Yarr::Interpreter::backtrackParentheses): + +2009-08-16 Holger Hans Peter Freyther + + Reviewed by Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=28352 + + Fix coding style violations. Use m_ for C++ class members. Remove + trailing whitespace on empty lines. + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::Interpreter::ParenthesesDisjunctionContext::ParenthesesDisjunctionContext): + (JSC::Yarr::Interpreter::tryConsumeCharacter): + (JSC::Yarr::Interpreter::tryConsumeBackReference): + (JSC::Yarr::Interpreter::parenthesesDoBacktrack): + (JSC::Yarr::Interpreter::backtrackParentheses): + (JSC::Yarr::ByteCompiler::ByteCompiler): + (JSC::Yarr::ByteCompiler::compile): + (JSC::Yarr::ByteCompiler::checkInput): + (JSC::Yarr::ByteCompiler::assertionBOL): + (JSC::Yarr::ByteCompiler::assertionEOL): + (JSC::Yarr::ByteCompiler::assertionWordBoundary): + (JSC::Yarr::ByteCompiler::atomPatternCharacter): + (JSC::Yarr::ByteCompiler::atomCharacterClass): + (JSC::Yarr::ByteCompiler::atomBackReference): + (JSC::Yarr::ByteCompiler::atomParenthesesSubpatternBegin): + (JSC::Yarr::ByteCompiler::atomParentheticalAssertionBegin): + (JSC::Yarr::ByteCompiler::popParenthesesStack): + (JSC::Yarr::ByteCompiler::closeAlternative): + (JSC::Yarr::ByteCompiler::closeBodyAlternative): + (JSC::Yarr::ByteCompiler::atomParenthesesEnd): + (JSC::Yarr::ByteCompiler::regexBegin): + (JSC::Yarr::ByteCompiler::alterantiveBodyDisjunction): + (JSC::Yarr::ByteCompiler::alterantiveDisjunction): + (JSC::Yarr::ByteCompiler::emitDisjunction): + +2009-08-15 Mark Rowe + + Fix the build with JIT disabled. + + * runtime/Arguments.h: Only compile the jitCode method when the JIT is enabled. + * runtime/Executable.h: Include PrototypeFunction.h so the compiler knows what + NativeFunctionWrapper is when the JIT is disabled. + +2009-08-15 Adam Bergkvist + + Reviewed by Sam Weinig. + + Added ENABLE_EVENTSOURCE flag. + https://bugs.webkit.org/show_bug.cgi?id=14997 + + * Configurations/FeatureDefines.xcconfig: + +2009-08-14 Gavin Barraclough + + * parser/Parser.h: + (JSC::EvalExecutable::parse): + (JSC::ProgramExecutable::parse): + * runtime/Executable.h: + +2009-08-14 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Remove AST nodes from use within the Runtime (outside of parsing), stage 1 + https://bugs.webkit.org/show_bug.cgi?id=28330 + + Remove the EvalNode and ProgramNode from use in the runtime. They still exist + after this patch, but are hidden behind EvalExecutable and FunctionExecutable, + and are also still reachable behind CodeBlock::m_ownerNode. + + The next step will be to beat back FunctionBodyNode in the same fashion. + Then remove the usage via CodeBlock, then only construct these nodes only on + demand during bytecode generation. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * bytecode/CodeBlock.h: + (JSC::GlobalCodeBlock::GlobalCodeBlock): + (JSC::GlobalCodeBlock::~GlobalCodeBlock): + (JSC::ProgramCodeBlock::ProgramCodeBlock): + (JSC::EvalCodeBlock::EvalCodeBlock): + (JSC::FunctionCodeBlock::FunctionCodeBlock): + (JSC::NativeCodeBlock::NativeCodeBlock): + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::get): + * debugger/Debugger.cpp: + (JSC::evaluateInGlobalCallFrame): + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::evaluate): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::callEval): + (JSC::Interpreter::execute): + * interpreter/Interpreter.h: + * parser/Nodes.cpp: + (JSC::FunctionBodyNode::createNativeThunk): + (JSC::FunctionBodyNode::generateBytecode): + (JSC::FunctionBodyNode::bytecodeForExceptionInfoReparse): + * parser/Parser.h: + (JSC::Parser::parse): + (JSC::Parser::reparse): + (JSC::Parser::parseFunctionFromGlobalCode): + (JSC::::parse): + * runtime/Completion.cpp: + (JSC::checkSyntax): + (JSC::evaluate): + * runtime/Error.cpp: + (JSC::throwError): + * runtime/Error.h: + * runtime/Executable.h: Added. + (JSC::TemplateExecutable::TemplateExecutable): + (JSC::TemplateExecutable::markAggregate): + (JSC::TemplateExecutable::sourceURL): + (JSC::TemplateExecutable::lineNo): + (JSC::TemplateExecutable::bytecode): + (JSC::TemplateExecutable::jitCode): + (JSC::EvalExecutable::EvalExecutable): + (JSC::ProgramExecutable::ProgramExecutable): + * runtime/FunctionConstructor.cpp: + (JSC::constructFunction): + * runtime/FunctionConstructor.h: + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::numericCompareFunction): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::~JSGlobalObject): + (JSC::JSGlobalObject::markChildren): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::codeBlocks): + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::globalFuncEval): + +2009-08-14 Darin Adler + + Reviewed by Sam Weinig. + + Rename the confusing isObject() to inherits(). + It still works on non-objects, returning false. + + * runtime/ArrayConstructor.cpp: + (JSC::arrayConstructorIsArray): Removed unneeded isObject call + and updated remaining isObject call to new name, inherits. + + * runtime/JSCell.h: Renamed isObject() to inherits() + but more importantly, made it non-virtual (it was already inline) + so it is now as fast as JSObject::inherits was. + + * runtime/JSObject.h: Removed inherits function since the one + in the base class is fine as-is. Also made various JSCell functions + that should not be called on JSObject uncallable by making them + both private and not implemented. + (JSC::JSCell::inherits): Updated name. + (JSC::JSValue::inherits): Ditto. + + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::unwindCallFrame): + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): + (JSC::arrayProtoFuncToLocaleString): + (JSC::arrayProtoFuncConcat): + * runtime/BooleanPrototype.cpp: + (JSC::booleanProtoFuncToString): + (JSC::booleanProtoFuncValueOf): + * runtime/DateConstructor.cpp: + (JSC::constructDate): + * runtime/DatePrototype.cpp: + (JSC::dateProtoFuncToString): + (JSC::dateProtoFuncToUTCString): + (JSC::dateProtoFuncToISOString): + (JSC::dateProtoFuncToDateString): + (JSC::dateProtoFuncToTimeString): + (JSC::dateProtoFuncToLocaleString): + (JSC::dateProtoFuncToLocaleDateString): + (JSC::dateProtoFuncToLocaleTimeString): + (JSC::dateProtoFuncGetTime): + (JSC::dateProtoFuncGetFullYear): + (JSC::dateProtoFuncGetUTCFullYear): + (JSC::dateProtoFuncToGMTString): + (JSC::dateProtoFuncGetMonth): + (JSC::dateProtoFuncGetUTCMonth): + (JSC::dateProtoFuncGetDate): + (JSC::dateProtoFuncGetUTCDate): + (JSC::dateProtoFuncGetDay): + (JSC::dateProtoFuncGetUTCDay): + (JSC::dateProtoFuncGetHours): + (JSC::dateProtoFuncGetUTCHours): + (JSC::dateProtoFuncGetMinutes): + (JSC::dateProtoFuncGetUTCMinutes): + (JSC::dateProtoFuncGetSeconds): + (JSC::dateProtoFuncGetUTCSeconds): + (JSC::dateProtoFuncGetMilliSeconds): + (JSC::dateProtoFuncGetUTCMilliseconds): + (JSC::dateProtoFuncGetTimezoneOffset): + (JSC::dateProtoFuncSetTime): + (JSC::setNewValueFromTimeArgs): + (JSC::setNewValueFromDateArgs): + (JSC::dateProtoFuncSetYear): + (JSC::dateProtoFuncGetYear): + * runtime/FunctionPrototype.cpp: + (JSC::functionProtoFuncToString): + * runtime/JSActivation.cpp: + (JSC::JSActivation::argumentsGetter): + * runtime/JSValue.h: + * runtime/RegExpConstructor.cpp: + (JSC::constructRegExp): + * runtime/RegExpPrototype.cpp: + (JSC::regExpProtoFuncTest): + (JSC::regExpProtoFuncExec): + (JSC::regExpProtoFuncCompile): + (JSC::regExpProtoFuncToString): + * runtime/ScopeChain.cpp: + (JSC::ScopeChain::localDepth): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncReplace): + (JSC::stringProtoFuncToString): + (JSC::stringProtoFuncMatch): + (JSC::stringProtoFuncSearch): + (JSC::stringProtoFuncSplit): + Updated to new name, inherits, from old name, isObject. + +2009-07-31 Harald Fernengel + + Reviewed by Simon Hausmann. + + Adding QNX as a platform. Currently only tested with Qt. + + https://bugs.webkit.org/show_bug.cgi?id=27885 + + * JavaScriptCore/runtime/Collector.cpp: Added retrieving of stack base + since QNX doesn't have the pthread _nt functions + * JavaScriptCore/wtf/Platform.h: Added WTF_PLATFORM_QNX and corresponding + defines + * WebCore/bridge/npapi.h: Build fix for missing typedefs on QNX + +2009-08-14 Gabor Loki + + Reviewed by Simon Hausmann. + + Currently generic ARM and ARMv7 platforms work only with JSVALUE32 + https://bugs.webkit.org/show_bug.cgi?id=28300 + + * wtf/Platform.h: + +2009-08-14 Gabor Loki + + Reviewed by Simon Hausmann. + + Enable JIT on ARM for QT by default + https://bugs.webkit.org/show_bug.cgi?id=28259 + + * wtf/Platform.h: + +2009-08-14 Gabor Loki + + Reviewed by Simon Hausmann. + + Enable YARR_JIT on ARM for QT by default + https://bugs.webkit.org/show_bug.cgi?id=28259 + + * wtf/Platform.h: + +2009-08-14 Oliver Hunt + + Reviewed by Gavin Barraclough. + + [ES5] Arguments object should inherit from Array + https://bugs.webkit.org/show_bug.cgi?id=28298 + + Make the Arguments object conform to the behaviour specified in ES5. + The simple portion of this is to make Arguments use Array.prototype + as its prototype rather than Object.prototype. + + The spec then requires us to set instance.constructor to the pristine + Object constructor, and instance.toString and instance.toLocaleString + to the pristine versions from Object.prototype. To do this we now + make the ObjectPrototype constructor return its toString and + toLocaleString functions (similar to the call and apply functions + from FunctionPrototype). + + Oddly enough this reports itself as a slight win, but given the code + isn't hit in the tests that claim to have improved I put this down to + code motion. + + * runtime/Arguments.h: + (JSC::Arguments::Arguments): + (JSC::Arguments::initializeStandardProperties): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::reset): + (JSC::JSGlobalObject::markChildren): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::JSGlobalObjectData::JSGlobalObjectData): + (JSC::JSGlobalObject::objectConstructor): + (JSC::JSGlobalObject::objectToStringFunction): + (JSC::JSGlobalObject::objectToLocaleStringFunction): + * runtime/ObjectPrototype.cpp: + (JSC::ObjectPrototype::ObjectPrototype): + * runtime/ObjectPrototype.h: + * tests/mozilla/ecma_3/Function/arguments-001.js: + Update test to new es5 behaviour + +2009-08-14 Oliver Hunt + + Remove MarkStack::drain from the JSC exports file + + MarkStack::drain is now marked inline, the including it in the exports file + produces an ld warning + + * JavaScriptCore.exp: + +2009-08-13 Sam Weinig + + Reviewed by Oliver Hunt. + + Remove accidentally left in debugging statement. + + * runtime/JSArray.h: + (JSC::MarkStack::drain): + +2009-08-13 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + [ES5] Implement Array.isArray + https://bugs.webkit.org/show_bug.cgi?id=28296 + + Add support for Array.isArray to the Array constructor + + * runtime/ArrayConstructor.cpp: + (JSC::ArrayConstructor::ArrayConstructor): + (JSC::arrayConstructorIsArray): + * runtime/ArrayConstructor.h: + * runtime/CommonIdentifiers.h: + * runtime/JSArray.h: + (JSC::MarkStack::drain): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::reset): + +2009-08-13 Oliver Hunt + + Reviewed by NOBODY (Buildfix). + + Attempt to fix windows build + + * runtime/Collector.cpp: + +2009-08-13 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Devirtualise marking + https://bugs.webkit.org/show_bug.cgi?id=28294 + + Add a bit to TypeInfo to indicate that an object uses the standard + JSObject::markChildren method. This allows us to devirtualise marking + of most objects (though a branch is still needed). We also add a branch + to identify arrays thus devirtualising marking in that case as well. + + In order to make the best use of this devirtualisation I've also reworked + the MarkStack::drain() logic to make the iteration more efficient. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * JavaScriptCore.exp: + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSAPIValueWrapper.h: + (JSC::JSAPIValueWrapper::JSAPIValueWrapper): + * runtime/JSArray.cpp: + (JSC::JSArray::markChildren): + * runtime/JSArray.h: + (JSC::JSArray::markChildrenDirect): + (JSC::MarkStack::drain): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSCell.h: + (JSC::MarkStack::append): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.cpp: + (JSC::JSObject::markChildren): + * runtime/JSObject.h: + (JSC::JSObject::markChildrenDirect): + (JSC::JSObject::createStructure): + * runtime/JSString.h: + (JSC::JSString::createStructure): + * runtime/JSType.h: + (JSC::): + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStack): + (JSC::MarkStack::MarkSet::MarkSet): + (JSC::MarkStack::MarkStackArray::last): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + * runtime/TypeInfo.h: + (JSC::TypeInfo::hasDefaultMark): + +2009-08-13 Darin Adler + + Reviewed by Mark Rowe. + + Some small bits of housekeeping. + + * JavaScriptCore.xcodeproj/project.pbxproj: Make Parser.h + project instead of private. Remove JSONObject.lut.h. + + * assembler/ARMAssembler.h: Remove unneeded WTF prefix. + * assembler/AssemblerBufferWithConstantPool.h: Ditto. + * bytecompiler/BytecodeGenerator.h: Ditto. + + * wtf/SegmentedVector.h: Add a "using" statement as we do + with the other WTF headers. + +2009-08-13 Darin Adler + + Fix Tiger build. + + * parser/Grammar.y: Use a template function so we can compile + setStatementLocation even if it comes before YYLTYPE is defined. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + Too much use of void* in Grammar.y + https://bugs.webkit.org/show_bug.cgi?id=28287 + + * parser/Grammar.y: Changed all the helper functions to + take a JSGlobalData* instead of a void*. A couple formatting + tweaks that I missed when breaking this into pieces. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + Another part of https://bugs.webkit.org/show_bug.cgi?id=28287 + + * parser/Grammar.y: Reduced and sorted includes. Tweaked comment + format. Marked a few more functions inline. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + Another part of https://bugs.webkit.org/show_bug.cgi?id=28287 + + * parser/Grammar.y: Pass the number to the PropertyNode instead of + first turning it into an Identifier. + + * parser/NodeConstructors.h: + (JSC::PropertyNode::PropertyNode): Add an overload that takes a double + so the code to convert to a string can be here instead of Grammar.y. + * parser/Nodes.h: Ditto. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + Another part of https://bugs.webkit.org/show_bug.cgi?id=28287 + + * parser/Grammar.y: Eliminate the DBG macro. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + Another part of https://bugs.webkit.org/show_bug.cgi?id=28287 + + * parser/Grammar.y: Eliminate the SET_EXCEPTION_LOCATION macro. + +2009-08-13 Darin Adler + + Reviewed by George Staikos. + + George asked me to break the patch from + https://bugs.webkit.org/show_bug.cgi?id=28287 + into smaller pieces and land it in stages. + + * parser/Grammar.y: Eliminate the LEXER macro. + +2009-08-13 Mark Rowe + + Try some more to fix the Windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export a new symbol. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Ditto. + +2009-08-13 Mark Rowe + + Try and fix the Windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Export a new symbol. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Ditto. + +2009-08-13 Darin Adler + + Reviewed by David Levin. + + JavaScriptCore tweaks to get ready for the parser arena + https://bugs.webkit.org/show_bug.cgi?id=28243 + + Eliminate dependencies on Nodes.h outside JavaScriptCore, + and cut down on them inside JavaScriptCore. + + Change regular expression parsing to use identifiers as + with other strings we parse. + + Fix a couple things that are needed to use const Identifier + more, which will be part of the parser arena work. + + * JavaScriptCore.exp: Resorted and updated. + + * JavaScriptCore.xcodeproj/project.pbxproj: Changed + CollectorHeapIterator.h to be project-internal. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitPushNewScope): Added const. + * bytecompiler/BytecodeGenerator.h: Ditto. + + * debugger/Debugger.cpp: + (JSC::Debugger::recompileAllJSFunctions): Moved this function + here from WebCore. Here is better since it uses so many internals. + Removed unimportant optimization for the no listener case. + * debugger/Debugger.h: Ditto. Also removed unneeded include + and tweaked formatting and comments. + + * debugger/DebuggerCallFrame.cpp: + (JSC::DebuggerCallFrame::functionName): Call asFunction instead + of doing the unchecked static_cast. + (JSC::DebuggerCallFrame::calculatedFunctionName): Ditto. + + * jit/JITStubs.cpp: + (JSC::op_call_JSFunction): Call isHostFunction on the body rather + than on the JSFunction. + (JSC::vm_lazyLinkCall): Ditto. + (JSC::op_construct_JSConstruct): Ditto. + + * parser/Grammar.y: Changed callers to use new scanRegExp with + out arguments instead of relying on state in the Lexer. And + callers that just want to skip a regular expression to use + skipRegExp. + + * parser/Lexer.cpp: + (JSC::Lexer::scanRegExp): Changed to use out arguments, and to + add a prefix argument so we can add in the "=" character as needed. + Also rewrote to streamline the logic a bit inspired by suggestions + by David Levin. + (JSC::Lexer::skipRegExp): Added. Version of the function above that + does not actually put the regular expression into a string. + (JSC::Lexer::clear): Removed code to clear m_pattern and m_flags. + * parser/Lexer.h: Changed scanRegExp to have out arguments. Added + skipRegExp. Eliminated pattern, flags, m_pattern, and m_flags. + + * parser/NodeConstructors.h: + (JSC::RegExpNode::RegExpNode): Changed to take const Identifier&. + * parser/Nodes.cpp: + (JSC::RegExpNode::emitBytecode): Changed since m_pattern and + m_flags are now Identifier instead of UString. + (JSC::FunctionBodyNode::make): Moved this function here instead + of putting it in the JSFunction.h header. + * parser/Nodes.h: Changed RegExpNode to use Identifier. + + * profiler/Profiler.cpp: + (JSC::Profiler::createCallIdentifier): Changed to use isHostFunction + on the body instead of on the JSFunction object. + * runtime/FunctionPrototype.cpp: + (JSC::functionProtoFuncToString): Ditto. + + * runtime/JSFunction.cpp: + (JSC::JSFunction::isHostFunction): Moved here from header. + (JSC::JSFunction::isHostFunctionNonInline): Added. + (JSC::JSFunction::JSFunction): Removed unneeded initialization of + m_body to 0. + (JSC::JSFunction::setBody): Moved here from header. + + * runtime/JSFunction.h: Removed unneeded includes. Moved private + constructor down to the private section. Made virtual functions + private. Removed unneeded overload of setBody and moved the body + of the function into the .cpp file. Changed assertions to use + the non-inline version of isHostFunction. + + * runtime/PropertySlot.cpp: + (JSC::PropertySlot::functionGetter): Use asFunction instead + of doing the unchecked static_cast. + + * wtf/SegmentedVector.h: + (WTF::SegmentedVector::isEmpty): Added. + +2009-08-13 Mark Rowe + + Rubber-stamped by Darin Adler. + + Use the version of operator new that takes a JSGlobalData when allocating FuncDeclNode and FuncExprNode + from within the grammar to prevent these nodes from being leaked. + + * parser/Grammar.y: + +2009-08-13 Simon Hausmann + + Reviewed by Ariya Hidayat. + + Remove the special-case for Qt wrt JSVALUE_32 introduced in + r46709. It must've been a dependency issue on the bot, as + after a manual build all the tests pass on amd64 and ia32. + + * wtf/Platform.h: + +2009-08-12 Gabor Loki + + Reviewed by Gavin Barraclough. + + Add optimize call and property access support for ARM JIT. + https://bugs.webkit.org/show_bug.cgi?id=24986 + + For tightly coupled sequences the BEGIN_UNINTERRUPTED_SEQUENCE and + END_UNINTERRUPTED_SEQUENCE macros have been introduced which ensure + space for instructions and constants of the named sequence. This + method is vital for those architecture which are using constant pool. + + The 'latePatch' method - which was linked to JmpSrc - is replaced with + a port specific solution (each calls are marked to place their address + on the constant pool). + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::linkBranch): + (JSC::ARMAssembler::executableCopy): Add extra align for constant pool. + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::JmpSrc::JmpSrc): + (JSC::ARMAssembler::sizeOfConstantPool): + (JSC::ARMAssembler::jmp): + (JSC::ARMAssembler::linkCall): + * assembler/ARMv7Assembler.h: + * assembler/AbstractMacroAssembler.h: + * assembler/AssemblerBufferWithConstantPool.h: + (JSC::AssemblerBufferWithConstantPool::flushIfNoSpaceFor): Fix the + computation of the remaining space. + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::branch32): + (JSC::MacroAssemblerARM::nearCall): + (JSC::MacroAssemblerARM::call): + (JSC::MacroAssemblerARM::branchPtrWithPatch): + (JSC::MacroAssemblerARM::ensureSpace): + (JSC::MacroAssemblerARM::sizeOfConstantPool): + (JSC::MacroAssemblerARM::prepareCall): + * assembler/X86Assembler.h: + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITInlineMethods.h: + (JSC::JIT::beginUninterruptedSequence): + (JSC::JIT::endUninterruptedSequence): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compileGetByIdSlowCase): + (JSC::JIT::emit_op_put_by_id): + +2009-08-12 Gavin Barraclough + + Rubber Stamped by Dave Kilzer. + + Disable WTF_USE_JSVALUE32_64 on iPhone for now (support not yet added for ARMv7). + + * wtf/Platform.h: + +2009-08-12 Gavin Barraclough + + Reviewed by Maciej Stachoviak. + + Ooops - moved code that had been accidentally added to op_new_func instead of + op_new_func_exp, to where it shoulds be. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * wtf/Platform.h: + +2009-08-12 Ada Chan + + Added workaround for the limitation that VirtualFree with MEM_RELEASE + can only accept the base address returned by VirtualAlloc when the region + was reserved and it can only free the entire region, and not a part of it. + + Reviewed by Oliver Hunt. + + * runtime/MarkStack.h: + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackWin.cpp: + (JSC::MarkStack::releaseStack): + +2009-08-12 Balazs Kelemen + + Reviewed by Ariya Hidayat. + + Build fix: use std::numeric_limits::min() instead of LLONG_MIN + since LLONG_MIN is not defined in standard c++. + + * runtime/UString.cpp: + (JSC::UString::from): + +2009-08-12 Benjamin Otte + + Reviewed by Jan Alonzo. + + Buildfix for Gtk platforms debug builds. + + * GNUmakefile.am: Choose MarkStackPosix.cpp or MarkStackWin.cpp + depending on platform. + +2009-08-12 Simon Hausmann + + Prospective build fix for Mac and 32-bit Windows. + + * runtime/UString.cpp: Include wtf/StringExtras.h for snprintf. + (JSC::UString::from): Use %lld instead of %I64d for snprintf + on non-windows platforms. + +2009-08-12 Prasanth Ullattil + + Reviewed by Simon Hausmann. + + Fix compile error on 64Bit Windows, when UString::from + is called with an intptr_t. + + Added new UString::From overload with long long parameter. + + Thanks to Holger for the long long idea. + + * runtime/UString.cpp: + (JSC::UString::from): + * runtime/UString.h: + +2009-08-11 Oliver Hunt + + Reviewed by Mark Rowe. + + Minor style fixes. + + * runtime/UString.h: + (JSC::UString::Rep::createEmptyBuffer): + * wtf/FastMalloc.h: + (WTF::TryMallocReturnValue::getValue): + +2009-08-11 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Make it harder to misuse try* allocation routines + https://bugs.webkit.org/show_bug.cgi?id=27469 + + Jump through a few hoops to make it much harder to accidentally + miss null-checking of values returned by the try-* allocation + routines. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/JSArray.cpp: + (JSC::JSArray::putSlowCase): + (JSC::JSArray::increaseVectorLength): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncFontsize): + (JSC::stringProtoFuncLink): + * runtime/UString.cpp: + (JSC::allocChars): + (JSC::reallocChars): + (JSC::expandCapacity): + (JSC::UString::Rep::reserveCapacity): + (JSC::UString::expandPreCapacity): + (JSC::createRep): + (JSC::concatenate): + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + (JSC::UString::append): + (JSC::UString::operator=): + * runtime/UString.h: + (JSC::UString::Rep::createEmptyBuffer): + * wtf/FastMalloc.cpp: + (WTF::tryFastZeroedMalloc): + (WTF::tryFastMalloc): + (WTF::tryFastCalloc): + (WTF::tryFastRealloc): + (WTF::TCMallocStats::tryFastMalloc): + (WTF::TCMallocStats::tryFastCalloc): + (WTF::TCMallocStats::tryFastRealloc): + * wtf/FastMalloc.h: + (WTF::TryMallocReturnValue::TryMallocReturnValue): + (WTF::TryMallocReturnValue::~TryMallocReturnValue): + (WTF::TryMallocReturnValue::operator PossiblyNull): + (WTF::TryMallocReturnValue::getValue): + * wtf/Platform.h: + * wtf/PossiblyNull.h: Added. + (WTF::PossiblyNull::PossiblyNull): + (WTF::PossiblyNull::~PossiblyNull): + (WTF::::getValue): + +2009-08-11 Gavin Barraclough + + Reviewed by NOBODY (build fix part deux). + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-11 Gavin Barraclough + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-11 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Restrict use of FuncDeclNode & FuncExprNode to the parser. + https://bugs.webkit.org/show_bug.cgi?id=28209 + + These objects were also being referenced from the CodeBlock. By changing this + to just retain pointers to FunctionBodyNodes these classes can be restricted to + use during parsing. + + No performance impact (or sub-percent progression). + + * JavaScriptCore.exp: + Update symbols. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::mark): + (JSC::CodeBlock::reparseForExceptionInfoIfNecessary): + (JSC::CodeBlock::shrinkToFit): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::addFunction): + (JSC::CodeBlock::function): + Unify m_functions & m_functionExpressions into a single Vector >. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::BytecodeGenerator): + (JSC::BytecodeGenerator::addConstant): + (JSC::BytecodeGenerator::emitNewFunction): + (JSC::BytecodeGenerator::emitNewFunctionExpression): + * bytecompiler/BytecodeGenerator.h: + FunctionStacks now contain FunctionBodyNodes not FuncDeclNodes. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::execute): + (JSC::Interpreter::privateExecute): + Update to reflect chnages in CodeBlock. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_new_func_exp): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): + Update to reflect chnages in CodeBlock. + + * parser/Grammar.y: + FunctionStacks now contain FunctionBodyNodes not FuncDeclNodes. + + * parser/NodeConstructors.h: + (JSC::FuncExprNode::FuncExprNode): + (JSC::FuncDeclNode::FuncDeclNode): + * parser/Nodes.cpp: + (JSC::ScopeNodeData::mark): + (JSC::FunctionBodyNode::finishParsing): + * parser/Nodes.h: + (JSC::FunctionBodyNode::ident): + Move m_ident & make methods from FuncDeclNode & FuncExprNode to FunctionBodyNode. + + * runtime/JSFunction.h: + (JSC::FunctionBodyNode::make): + Make this method inline (was FuncDeclNode::makeFunction). + +2009-08-11 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Native JSON.stringify does not omit functions + https://bugs.webkit.org/show_bug.cgi?id=28117 + + Objects that are callable should be treated as undefined when + serialising to JSON. + + * runtime/JSONObject.cpp: + (JSC::Stringifier::appendStringifiedValue): + +2009-08-11 Oliver Hunt + + Reviewed by Geoff Garen. + + REGRESSION: Hang/crash in BytecodeGenerator::constRegisterFor loading simple page + https://bugs.webkit.org/show_bug.cgi?id=28169 + + Handle the case where someone has attempted to shadow a property + on the global object with a constant. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::constRegisterFor): + * parser/Nodes.cpp: + (JSC::ConstDeclNode::emitCodeSingle): + +2009-08-11 John Gregg + + Reviewed by Maciej Stachowiak. + + Desktop Notifications API + https://bugs.webkit.org/show_bug.cgi?id=25463 + + Adds ENABLE_NOTIFICATION flag. + + * Configurations/FeatureDefines.xcconfig: + * wtf/Platform.h: + +2009-08-11 Maxime Simon + + Reviewed by Eric Seidel. + + Modifications on JavaScriptCore to allow Haiku port. + https://bugs.webkit.org/show_bug.cgi?id=28121 + + * runtime/Collector.cpp: Haiku doesn't have sys/mman.h, using OS.h instead. + (JSC::currentThreadStackBase): Haiku uses its own threading system. + * wtf/Platform.h: Defining all Haiku platform values. + * wtf/haiku/MainThreadHaiku.cpp: Adding a missing header (NotImplemented.h). + +2009-08-11 Jessie Berlin + + Reviewed by Adam Roben. + + Fix windows build. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-11 Csaba Osztrogonac + + Reviewed by Tor Arne Vestbø. + + Buildfix for Qt-win platforms. + + * JavaScriptCore.pri: Choose MarkStackPosix.cpp or MarkStackWin.cpp depend on platform. + +2009-08-10 Oliver Hunt + + Reviewed by NOBODY (And another build fix). + + Add new exports for MSVC + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-08-10 Oliver Hunt + + Reviewed by NOBODY (yet another build fix). + + Remove obsolete entries from MSVC exports file + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-10 Oliver Hunt + + Add includes needed for non-allinonefile builds + + * runtime/GetterSetter.h: + * runtime/ScopeChain.h: + +2009-08-10 Oliver Hunt + + Fix export file for last build fix + + * JavaScriptCore.exp: + +2009-08-10 Oliver Hunt + + Hoist page size initialization into platform specific code. + + * jit/ExecutableAllocatorPosix.cpp: + * jit/ExecutableAllocatorWin.cpp: + * runtime/MarkStack.h: + (JSC::MarkStack::pageSize): + * runtime/MarkStackPosix.cpp: + (JSC::MarkStack::initializePagesize): + * runtime/MarkStackWin.cpp: + (JSC::MarkStack::initializePagesize): + +2009-08-07 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Stack overflow crash in JavaScript garbage collector mark pass + https://bugs.webkit.org/show_bug.cgi?id=12216 + + Make the GC mark phase iterative by using an explicit mark stack. + To do this marking any single object is performed in multiple stages + * The object is appended to the MarkStack, this sets the marked + bit for the object using the new markDirect() function, and then + returns + * When the MarkStack is drain()ed the object is popped off the stack + and markChildren(MarkStack&) is called on the object to collect + all of its children. drain() then repeats until the stack is empty. + + Additionally I renamed a number of methods from 'mark' to 'markAggregate' + in order to make it more clear that marking of those object was not + going to result in an actual recursive mark. + + * GNUmakefile.am + * JavaScriptCore.exp: + * JavaScriptCore.gypi: + * JavaScriptCore.pri: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.xcodeproj/project.pbxproj: + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::markAggregate): + * bytecode/CodeBlock.h: + * bytecode/EvalCodeCache.h: + (JSC::EvalCodeCache::markAggregate): + * debugger/DebuggerActivation.cpp: + (JSC::DebuggerActivation::markChildren): + * debugger/DebuggerActivation.h: + * interpreter/Register.h: + * interpreter/RegisterFile.h: + (JSC::RegisterFile::markGlobals): + (JSC::RegisterFile::markCallFrames): + * parser/Nodes.cpp: + (JSC::ScopeNodeData::markAggregate): + (JSC::EvalNode::markAggregate): + (JSC::FunctionBodyNode::markAggregate): + * parser/Nodes.h: + (JSC::ScopeNode::markAggregate): + * runtime/ArgList.cpp: + (JSC::MarkedArgumentBuffer::markLists): + * runtime/ArgList.h: + * runtime/Arguments.cpp: + (JSC::Arguments::markChildren): + * runtime/Arguments.h: + * runtime/Collector.cpp: + (JSC::Heap::markConservatively): + (JSC::Heap::markCurrentThreadConservativelyInternal): + (JSC::Heap::markCurrentThreadConservatively): + (JSC::Heap::markOtherThreadConservatively): + (JSC::Heap::markStackObjectsConservatively): + (JSC::Heap::markProtectedObjects): + (JSC::Heap::collect): + * runtime/Collector.h: + * runtime/GetterSetter.cpp: + (JSC::GetterSetter::markChildren): + * runtime/GetterSetter.h: + (JSC::GetterSetter::GetterSetter): + (JSC::GetterSetter::createStructure): + * runtime/GlobalEvalFunction.cpp: + (JSC::GlobalEvalFunction::markChildren): + * runtime/GlobalEvalFunction.h: + * runtime/JSActivation.cpp: + (JSC::JSActivation::markChildren): + * runtime/JSActivation.h: + * runtime/JSArray.cpp: + (JSC::JSArray::markChildren): + * runtime/JSArray.h: + * runtime/JSCell.h: + (JSC::JSCell::markCellDirect): + (JSC::JSCell::markChildren): + (JSC::JSValue::markDirect): + (JSC::JSValue::markChildren): + (JSC::JSValue::hasChildren): + (JSC::MarkStack::append): + (JSC::MarkStack::drain): + * runtime/JSFunction.cpp: + (JSC::JSFunction::markChildren): + * runtime/JSFunction.h: + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + * runtime/JSGlobalObject.cpp: + (JSC::markIfNeeded): + (JSC::JSGlobalObject::markChildren): + * runtime/JSGlobalObject.h: + * runtime/JSNotAnObject.cpp: + (JSC::JSNotAnObject::markChildren): + * runtime/JSNotAnObject.h: + * runtime/JSONObject.cpp: + (JSC::Stringifier::markAggregate): + (JSC::JSONObject::markStringifiers): + * runtime/JSONObject.h: + * runtime/JSObject.cpp: + (JSC::JSObject::markChildren): + (JSC::JSObject::defineGetter): + (JSC::JSObject::defineSetter): + * runtime/JSObject.h: + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::markChildren): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::createStructure): + (JSC::JSPropertyNameIterator::JSPropertyNameIterator): + (JSC::JSPropertyNameIterator::create): + * runtime/JSStaticScopeObject.cpp: + (JSC::JSStaticScopeObject::markChildren): + * runtime/JSStaticScopeObject.h: + * runtime/JSType.h: + (JSC::): + * runtime/JSValue.h: + * runtime/JSWrapperObject.cpp: + (JSC::JSWrapperObject::markChildren): + * runtime/JSWrapperObject.h: + * runtime/MarkStack.cpp: Added. + (JSC::MarkStack::compact): + * runtime/MarkStack.h: Added. + (JSC::): + (JSC::MarkStack::MarkStack): + (JSC::MarkStack::append): + (JSC::MarkStack::appendValues): + (JSC::MarkStack::~MarkStack): + (JSC::MarkStack::MarkSet::MarkSet): + (JSC::MarkStack::pageSize): + + MarkStackArray is a non-shrinking, mmap-based vector type + used for storing objects to be marked. + (JSC::MarkStack::MarkStackArray::MarkStackArray): + (JSC::MarkStack::MarkStackArray::~MarkStackArray): + (JSC::MarkStack::MarkStackArray::expand): + (JSC::MarkStack::MarkStackArray::append): + (JSC::MarkStack::MarkStackArray::removeLast): + (JSC::MarkStack::MarkStackArray::isEmpty): + (JSC::MarkStack::MarkStackArray::size): + (JSC::MarkStack::MarkStackArray::shrinkAllocation): + * runtime/MarkStackPosix.cpp: Added. + (JSC::MarkStack::allocateStack): + (JSC::MarkStack::releaseStack): + * runtime/MarkStackWin.cpp: Added. + (JSC::MarkStack::allocateStack): + (JSC::MarkStack::releaseStack): + + * runtime/ScopeChain.h: + * runtime/ScopeChainMark.h: + (JSC::ScopeChain::markAggregate): + * runtime/SmallStrings.cpp: + (JSC::SmallStrings::mark): + * runtime/Structure.h: + (JSC::Structure::markAggregate): + +2009-08-10 Mark Rowe + + Reviewed by Darin Adler. + + Fix hundreds of "pointer being freed was not allocated" errors seen on the build bot. + + * wtf/FastMalloc.h: Implement nothrow variants of the delete and delete[] operators since + we implement the nothrow variants of new and new[]. The nothrow variant of delete is called + explicitly in the implementation of std::sort which was resulting in FastMalloc-allocated + memory being passed to the system allocator to free. + +2009-08-10 Jan Michael Alonzo + + [Gtk] Unreviewed build fix. Move JSAPIValueWrapper.cpp/.h in the debug + section. This file is already part of AllInOneFile in Release builds. + + * GNUmakefile.am: + +2009-08-10 Darin Adler + + * wtf/FastMalloc.h: Fix build. + +2009-08-10 Darin Adler + + Reviewed by Mark Rowe. + + FastMalloc.h has cross-platform code but marked as WinCE-only + https://bugs.webkit.org/show_bug.cgi?id=28160 + + 1) The support for nothrow was inside #if PLATFORM(WINCE) even though it is + not platform-specific. + 2) The code tried to override operator delete nothrow, which does not exist. + 3) The code in the header checks the value of USE_SYSTEM_MALLOC, but the code + in FastMalloc.cpp checks only if the macro is defined. + + * wtf/FastMalloc.h: See above. + * wtf/FastMalloc.cpp: Ditto. + +2009-08-10 Sam Weinig + + Reviewed by Anders Carlsson. + + Fix an annoying indentation issue. + + * runtime/DateConstructor.cpp: + (JSC::constructDate): + +2009-08-10 Xan Lopez + + Unreviewed build fix. + + Add new files to makefile. + + * GNUmakefile.am: + +2009-08-10 Simon Hausmann + + Fix compilation with the interpreter instead of the JIT by including + PrototypeFunction.h as forward-declared through NativeFunctionWrapper.h. + + * runtime/ObjectConstructor.cpp: + +2009-08-09 Oliver Hunt + + Reviewed by George Staikos. + + JSON.stringify replacer returning undefined does not omit object properties + https://bugs.webkit.org/show_bug.cgi?id=28118 + + Correct behaviour of stringify when using a replacer function that returns + undefined. This is a simple change to move the undefined value check to + after the replacer function is called. This means that the replacer function + is now called for properties with the value undefined, however i've confirmed + that this behaviour is correct. + + In addition I've made the cyclic object exception have a more useful error + message. + + * runtime/JSONObject.cpp: + (JSC::Stringifier::appendStringifiedValue): + +2009-08-08 Oliver Hunt + + Reviewed by Eric Seidel and Sam Weinig. + + [ES5] Implement Object.getPrototypeOf + https://bugs.webkit.org/show_bug.cgi?id=28114 + + Implement getPrototypeOf + + * runtime/CommonIdentifiers.h: + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::reset): + * runtime/ObjectConstructor.cpp: + (JSC::ObjectConstructor::ObjectConstructor): + (JSC::objectConsGetPrototypeOf): + * runtime/ObjectConstructor.h: + +2009-08-07 Zoltan Horvath + + Reviewed by Eric Seidel. + + Allow custom memory allocation control for Noncopyable class + https://bugs.webkit.org/show_bug.cgi?id=27879 + + Several classes which are inherited from Noncopyable are instantiated by + operator new, so Noncopyable class has been inherited from FastAllocBase. + + * wtf/Noncopyable.h: + +2009-08-07 George Staikos + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=27305 + Implement WinCE-specific unicode layer. + Written by George Staikos + with bug fixes by Yong Li + refactored by Joe Mason + + * wtf/Platform.h: + * wtf/unicode/Unicode.h: + * wtf/unicode/wince/UnicodeWince.cpp: Added. + (WTF::Unicode::toLower): + (WTF::Unicode::toUpper): + (WTF::Unicode::foldCase): + (WTF::Unicode::isPrintableChar): + (WTF::Unicode::isSpace): + (WTF::Unicode::isLetter): + (WTF::Unicode::isUpper): + (WTF::Unicode::isLower): + (WTF::Unicode::isDigit): + (WTF::Unicode::isPunct): + (WTF::Unicode::toTitleCase): + (WTF::Unicode::direction): + (WTF::Unicode::category): + (WTF::Unicode::decompositionType): + (WTF::Unicode::combiningClass): + (WTF::Unicode::mirroredChar): + (WTF::Unicode::digitValue): + * wtf/unicode/wince/UnicodeWince.h: Added. + (WTF::Unicode::): + (WTF::Unicode::isSeparatorSpace): + (WTF::Unicode::isHighSurrogate): + (WTF::Unicode::isLowSurrogate): + (WTF::Unicode::isArabicChar): + (WTF::Unicode::hasLineBreakingPropertyComplexContext): + (WTF::Unicode::umemcasecmp): + (WTF::Unicode::surrogateToUcs4): + +2009-08-07 Yongjun Zhang + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=28069 + + Add inline to help winscw compiler resolve specialized argument in + templated functions. + + * runtime/LiteralParser.cpp: + (JSC::LiteralParser::Lexer::lexString): + +2009-08-07 Zoltan Horvath + + Reviewed by Eric Seidel. + + Allow custom memory allocation control for RegExpObjectData struct + http://bugs.webkit.org/show_bug.cgi?id=26750 + + Inherits RegExpObjectData struct from FastAllocBase because + it has been instantiated by 'new' in JavaScriptCore/runtime/RegExpObject.cpp:62 + + * runtime/RegExpObject.h: + +2009-08-06 Norbert Leser + + Reviewed by Darin Adler. + + Updated patch for bug #27059: + Symbian platform always uses little endian encoding, + regardless of compiler. + We need to make sure that we correctly detect EABI architecture + for armv5 targets on Symbian, + where __EABI__ is set but not __ARM_EABI__ + + * wtf/Platform.h: + +2009-08-06 Adam Barth + + Unreviewed revert. + + http://bugs.webkit.org/show_bug.cgi?id=27879 + + Revert 46877 because it broke GTK. + + * wtf/Noncopyable.h: + +2009-08-06 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Make get_by_id/put_by_id/method_check/call defer optimization using a data flag rather than a code modification. + ( https://bugs.webkit.org/show_bug.cgi?id=27635 ) + + This improves performance of ENABLE(ASSEMBLER_WX_EXCLUSIVE) builds by 2-2.5%, reducing the overhead to about 2.5%. + (No performance impact with ASSEMBLER_WX_EXCLUSIVE disabled). + + * bytecode/CodeBlock.cpp: + (JSC::printStructureStubInfo): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * bytecode/CodeBlock.h: + (JSC::): + (JSC::CallLinkInfo::seenOnce): + (JSC::CallLinkInfo::setSeen): + (JSC::MethodCallLinkInfo::seenOnce): + (JSC::MethodCallLinkInfo::setSeen): + - Change a pointer in CallLinkInfo/MethodCallLinkInfo to use a PtrAndFlags, use a flag to track when an op has been executed once. + + * bytecode/StructureStubInfo.cpp: + (JSC::StructureStubInfo::deref): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * bytecode/StructureStubInfo.h: + (JSC::StructureStubInfo::StructureStubInfo): + (JSC::StructureStubInfo::initGetByIdSelf): + (JSC::StructureStubInfo::initGetByIdProto): + (JSC::StructureStubInfo::initGetByIdChain): + (JSC::StructureStubInfo::initGetByIdSelfList): + (JSC::StructureStubInfo::initGetByIdProtoList): + (JSC::StructureStubInfo::initPutByIdTransition): + (JSC::StructureStubInfo::initPutByIdReplace): + (JSC::StructureStubInfo::seenOnce): + (JSC::StructureStubInfo::setSeen): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID, add a flag to track when an op has been executed once. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetById): + (JSC::BytecodeGenerator::emitPutById): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + (JSC::JIT::unlinkCall): + - Remove the "don't lazy link" stage of calls. + + * jit/JIT.h: + (JSC::JIT::compileCTIMachineTrampolines): + - Remove the "don't lazy link" stage of calls. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallSlowCase): + - Remove the "don't lazy link" stage of calls. + + * jit/JITStubs.cpp: + (JSC::JITThunks::JITThunks): + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): + (JSC::JITStubs::DEFINE_STUB_FUNCTION): + (JSC::JITStubs::getPolymorphicAccessStructureListSlot): + - Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check. + + * jit/JITStubs.h: + (JSC::JITThunks::ctiStringLengthTrampoline): + (JSC::JITStubs::): + - Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check. + + * wtf/PtrAndFlags.h: + (WTF::PtrAndFlags::PtrAndFlags): + (WTF::PtrAndFlags::operator!): + (WTF::PtrAndFlags::operator->): + - Add ! and -> operators, add constuctor with pointer argument. + +2009-08-06 Zoltan Horvath + + Reviewed by Adam Barth. + + Allow custom memory allocation control for Noncopyable class + https://bugs.webkit.org/show_bug.cgi?id=27879 + + Several classes which inherited from Noncopyable are instantiated by + operator new, so Noncopyable class has been inherited from FastAllocBase. + + * wtf/Noncopyable.h: + +2009-08-06 Mark Rowe + + Rubber-stamped by Sam Weinig. + + Add explicit dependencies for our build verification scripts to ensure that they always run after linking has completed. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-08-06 Mark Rowe + + Bring a little order to our otherwise out of control lives. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-08-06 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's PolymorphicAccessStructureList struct + https://bugs.webkit.org/show_bug.cgi?id=27877 + + Inherits PolymorphicAccessStructureList struct from FastAllocBase because it has been instantiated by + 'new' in JavaScriptCore/jit/JITStubs.cpp:1229. + + * bytecode/Instruction.h: + +2009-08-05 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's ScopeNodeData struct + https://bugs.webkit.org/show_bug.cgi?id=27875 + + Inherits ScopeNodeData struct from FastAllocBase because it has been instantiated by + 'new' in JavaScriptCore/parser/Nodes.cpp:1848. + + * parser/Nodes.h: + +2009-08-05 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + Add floating point support for generic ARM port. + https://bugs.webkit.org/show_bug.cgi?id=24986 + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::doubleTransfer): + * assembler/ARMAssembler.h: + (JSC::ARM::): + (JSC::ARMAssembler::): + (JSC::ARMAssembler::faddd_r): + (JSC::ARMAssembler::fsubd_r): + (JSC::ARMAssembler::fmuld_r): + (JSC::ARMAssembler::fcmpd_r): + (JSC::ARMAssembler::fdtr_u): + (JSC::ARMAssembler::fdtr_d): + (JSC::ARMAssembler::fmsr_r): + (JSC::ARMAssembler::fsitod_r): + (JSC::ARMAssembler::fmstat): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::): + (JSC::MacroAssemblerARM::supportsFloatingPoint): + (JSC::MacroAssemblerARM::loadDouble): + (JSC::MacroAssemblerARM::storeDouble): + (JSC::MacroAssemblerARM::addDouble): + (JSC::MacroAssemblerARM::subDouble): + (JSC::MacroAssemblerARM::mulDouble): + (JSC::MacroAssemblerARM::convertInt32ToDouble): + (JSC::MacroAssemblerARM::branchDouble): + * jit/JIT.h: + +2009-08-05 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + Add JIT support for generic ARM port without optimizations. + https://bugs.webkit.org/show_bug.cgi?id=24986 + + All JIT optimizations are disabled. + + Signed off by Zoltan Herczeg + Signed off by Gabor Loki + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::baseIndexTransfer32): + * assembler/AbstractMacroAssembler.h: + (JSC::AbstractMacroAssembler::Imm32::Imm32): + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::store32): + (JSC::MacroAssemblerARM::move): + (JSC::MacroAssemblerARM::branch32): + (JSC::MacroAssemblerARM::add32): + (JSC::MacroAssemblerARM::sub32): + (JSC::MacroAssemblerARM::load32): + * bytecode/CodeBlock.h: + (JSC::CodeBlock::getBytecodeIndex): + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::restoreArgumentReference): + * jit/JITOpcodes.cpp: + * jit/JITStubs.cpp: + * jit/JITStubs.h: + (JSC::JITStackFrame::returnAddressSlot): + * wtf/Platform.h: + +2009-08-04 Gavin Barraclough + + Rubber Stamped by Oiver Hunt. + + Revert r46643 since this breaks the Yarr::Interpreter running the v8 tests. + https://bugs.webkit.org/show_bug.cgi?id=27874 + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::Interpreter::allocDisjunctionContext): + (JSC::Yarr::Interpreter::freeDisjunctionContext): + (JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext): + (JSC::Yarr::Interpreter::freeParenthesesDisjunctionContext): + +2009-08-04 Oliver Hunt + + PPC64 Build fix + + * wtf/Platform.h: + +2009-08-04 Benjamin C Meyer + + Reviewed by Adam Treat + + Explicitly include limits.h header when using INT_MAX and INT_MIN + + * interpreter/Interpreter.cpp + +2009-08-03 Harald Fernengel + + Reviewed by Darin Adler. + + Fix compile error for ambigous call to abs() + https://bugs.webkit.org/show_bug.cgi?id=27873 + + Fix ambiguity in abs(long int) call by calling labs() instead + + * wtf/DateMath.cpp: replace call to abs() with labs() + +2009-08-03 Laszlo Gombos + + Reviewed by Eric Seidel. + + [Qt] Consolidate common gcc flags to WebKit.pri + https://bugs.webkit.org/show_bug.cgi?id=27934 + + * JavaScriptCore.pro: + +2009-08-03 Ada Chan + + Fixed the Tiger build. + + * wtf/FastMalloc.cpp: + +2009-08-03 Ada Chan + + Reviewed by Darin Adler. + + Don't use background thread to scavenge memory on Tiger until we figure out why it causes a crash. + https://bugs.webkit.org/show_bug.cgi?id=27900 + + * wtf/FastMalloc.cpp: + +2009-08-03 Fumitoshi Ukai + + Reviewed by Jan Alonzo. + + Fix build break on Gtk/x86_64. + https://bugs.webkit.org/show_bug.cgi?id=27936 + + Use JSVALUE64 for X86_64 LINUX, except Qt. + + * wtf/Platform.h: + +2009-08-02 Xan Lopez + + Fix the GTK+ build. + + * wtf/Platform.h: + +2009-08-02 Geoffrey Garen + + Reviewed by Sam Weinig. + + Disabled JSVALUE32_64 on Qt builds, since all layout tests mysteriously + crash with it enabled. + + * wtf/Platform.h: + +2009-08-02 Geoffrey Garen + + Qt build fix. + + Added JSAPIValueWrapper.cpp to the build. + + * JavaScriptCore.pri: + +2009-08-02 Geoffrey Garen + + Windows build fix. + + Exported symbols for JSAPIValueWrapper. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-08-02 Geoffrey Garen + + GTK build fix. + + * jit/JITStubs.cpp: #include , for a definition of va_start. + +2009-08-02 Geoffrey Garen + + Qt build fix. + + * runtime/Collector.cpp: #include , for a definition of ULONG_MAX. + +2009-08-02 Geoffrey Garen + + Windows build fix: Nixed JSImmediate::prototype, JSImmediate::toObject, + and JSImmediate::toThisObject, and removed their exported symbols. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + * runtime/JSImmediate.cpp: + * runtime/JSImmediate.h: + +2009-08-02 Geoffrey Garen + + Reviewed by Mark Rowe. + + Enabled JSVALUE32_64 by default on all platforms other than x86_64 (which uses JSVALUE64). + + * wtf/Platform.h: + +2009-08-02 Kevin Ollivier + + Reviewed by Jan Alonzo. + + Script for building the JavaScriptCore library for wx. + https://bugs.webkit.org/show_bug.cgi?id=27619 + + * wscript: Added. + +2009-08-02 Yong Li + + Reviewed by George Staikos. + + DateMath depends on strftime and localtime, which need to be imported manually on WinCE + https://bugs.webkit.org/show_bug.cgi?id=26558 + + * wtf/DateMath.cpp: + +2009-08-01 David Kilzer + + wtf/Threading.h: added include of Platform.h + + Reviewed by Mark Rowe. + + * wtf/Threading.h: Added #include "Platform.h" since this header + uses PLATFORM() and other macros. + +2009-08-01 Mark Rowe + + Rubber-stamped by Oliver Hunt. + + Roll out r46668 as it was misinformed. ScopeChain is only used with placement new. + + * runtime/ScopeChain.h: + +2009-08-01 Zoltan Horvath + + Allow custom memory allocation control for JavaScriptCore's HashMap class + http://bugs.webkit.org/show_bug.cgi?id=27871 + + Inherits HashMap class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/API/JSClassRef.cpp:148. + + * wtf/RefPtrHashMap.h: + (WTF::): + +2009-08-01 Zoltan Horvath + + Allow custom memory allocation control for JavaScriptCore's ScopeChain class + https://bugs.webkit.org/show_bug.cgi?id=27834 + + Inherits ScopeChain class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/runtime/JSFunction.h:109. + + * runtime/ScopeChain.h: + +2009-08-01 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's RegExpConstructorPrivate struct + https://bugs.webkit.org/show_bug.cgi?id=27833 + + Inherits RegExpConstructorPrivate class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/runtime/RegExpConstructor.cpp:152. + + * runtime/RegExpConstructor.cpp: + +2009-07-31 Yong Li + + Reviewed by George Staikos. + + Resurrect the old GetTickCount implementation of currentTime, controlled by WTF_USE_QUERY_PERFORMANCE_COUNTER + currentSystemTime taken from older WebKit; currentTime written by Yong Li ; cleanup by Joe Mason + https://bugs.webkit.org/show_bug.cgi?id=27848 + + * wtf/CurrentTime.cpp: + (WTF::currentSystemTime): get current time with GetCurrentFT + (WTF::currentTime): track msec elapsed since first currentSystemTime call using GetTickCount + * wtf/Platform.h: + +2009-07-31 Ada Chan + + Fixes the Windows release-PGO build. + + Reviewed by Jon Honeycutt. + + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Suppresses the warning about unreachable code that we get by adding "return 0" to WTF::TCMalloc_PageHeap::runScavengerThread(). + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::runScavengerThread): Fixes the error about the method not returning a value in the release-PGO build. + +2009-07-31 Zoltan Horvath + + Change malloc to fastMalloc and free to fastFree in Yarr's RegexInterpreter.cpp + https://bugs.webkit.org/show_bug.cgi?id=27874 + + Use fastMalloc and fastFree instead of malloc and free in RegexInterpreter.cpp's methods. + + * yarr/RegexInterpreter.cpp: + (JSC::Yarr::Interpreter::allocDisjunctionContext): + (JSC::Yarr::Interpreter::freeDisjunctionContext): + (JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext): + (JSC::Yarr::Interpreter::freeParenthesesDisjunctionContext): + +2009-07-30 Xan Lopez + + Reviewed by Jan Alonzo. + + Fix compiler warning. + + GCC does not like C++-style comments in preprocessor directives. + + * wtf/Platform.h: + +2009-07-30 John McCall + + Reviewed by Gavin Barraclough. + + Optimize the X86_64 trampolines: avoid the need for filler arguments + and move the stub-args area closer to the stack pointer. + + * jit/JIT.h: adjust patch offsets because of slight code-size change + * jit/JITCode.h: + (JSC::JITCode::execute): don't pass filler args + * jit/JITStubs.cpp: + (ctiTrampoline): (X86_64): push args onto stack, use args directly + (ctiVMThrowTrampoline): (X86_64): adjust %rsp by correct displacement + (ctiOpThrowNotCaught): (X86_64): adjust %rsp by correct displacement + * jit/JITStubs.h: + (JITStackFrame): (X86_64): move args area earlier + (ctiTrampoline): remove filler args from prototype + +2009-07-30 Gavin Barraclough + + Temporarily revert r46618 since this is b0rking on Linux. + +2009-07-23 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Make get_by_id/put_by_id/method_check/call defer optimization using a data flag rather than a code modification. + ( https://bugs.webkit.org/show_bug.cgi?id=27635 ) + + This improves performance of ENABLE(ASSEMBLER_WX_EXCLUSIVE) builds by 2-2.5%, reducing the overhead to about 2.5%. + (No performance impact with ASSEMBLER_WX_EXCLUSIVE disabled). + + * bytecode/CodeBlock.cpp: + (JSC::printStructureStubInfo): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * bytecode/CodeBlock.h: + (JSC::): + (JSC::CallLinkInfo::seenOnce): + (JSC::CallLinkInfo::setSeen): + (JSC::MethodCallLinkInfo::seenOnce): + (JSC::MethodCallLinkInfo::setSeen): + - Change a pointer in CallLinkInfo/MethodCallLinkInfo to use a PtrAndFlags, use a flag to track when an op has been executed once. + + * bytecode/StructureStubInfo.cpp: + (JSC::StructureStubInfo::deref): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * bytecode/StructureStubInfo.h: + (JSC::StructureStubInfo::StructureStubInfo): + (JSC::StructureStubInfo::initGetByIdSelf): + (JSC::StructureStubInfo::initGetByIdProto): + (JSC::StructureStubInfo::initGetByIdChain): + (JSC::StructureStubInfo::initGetByIdSelfList): + (JSC::StructureStubInfo::initGetByIdProtoList): + (JSC::StructureStubInfo::initPutByIdTransition): + (JSC::StructureStubInfo::initPutByIdReplace): + (JSC::StructureStubInfo::seenOnce): + (JSC::StructureStubInfo::setSeen): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID, add a flag to track when an op has been executed once. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetById): + (JSC::BytecodeGenerator::emitPutById): + - Make StructureStubInfo store the type as an integer, rather than an OpcodeID. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + (JSC::JIT::unlinkCall): + - Remove the "don't lazy link" stage of calls. + + * jit/JIT.h: + (JSC::JIT::compileCTIMachineTrampolines): + - Remove the "don't lazy link" stage of calls. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallSlowCase): + - Remove the "don't lazy link" stage of calls. + + * jit/JITStubs.cpp: + (JSC::JITThunks::JITThunks): + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): + (JSC::JITStubs::DEFINE_STUB_FUNCTION): + (JSC::JITStubs::getPolymorphicAccessStructureListSlot): + - Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check. + + * jit/JITStubs.h: + (JSC::JITThunks::ctiStringLengthTrampoline): + (JSC::JITStubs::): + - Remove the "don't lazy link" stage of calls, and the "_second" stage of get_by_id/put_by_id/method_check. + + * wtf/PtrAndFlags.h: + (WTF::PtrAndFlags::PtrAndFlags): + (WTF::PtrAndFlags::operator!): + (WTF::PtrAndFlags::operator->): + - Add ! and -> operators, add constuctor with pointer argument. + +2009-07-30 Geoffrey Garen + + Reviewed by Gavin Barraclough. + + Fixed failing tests seen on Windows buildbot. + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): Use "int" instead of "bool" to guarantee a 32-bit result, + regardless of compiler. gcc on mac uses 32-bit values for bool, + but gcc on linux and MSVC on Windows use 8-bit values. + +2009-07-30 Geoffrey Garen + + Windows build fix: added missing symbols on Windows. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-30 Geoffrey Garen + + Windows build fix: removed stale symbols on Windows. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +=== End merge of nitro-extreme branch 2009-07-30 === + +2009-07-20 Geoffrey Garen + + Fixed a post-review typo in r46066 that caused tons of test failures. + + SunSpider reports no change. + + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): Initialize the full vector capacity, to avoid + uninitialized members at the end. + +2009-07-20 Geoffrey Garen + + Windows WebKit build fix: Added some missing exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-17 Geoffrey Garen + + Reviewed by Sam Weinig. + + Get the branch working on windows. + https://bugs.webkit.org/show_bug.cgi?id=27391 + + SunSpider says 0.3% faster. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: Updated + MSVC export lists to fix linker errors. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Added / removed + new / old project files. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): Used #pragma pack to tell + MSVC that these structures represent actual memory layout, and should not be + automatically aligned. Changed the return value load to load a 64bit quantity + into the canonical registers. + + * jit/JIT.h: Moved OBJECT_OFFSETOF definition to StdLibExtras.h because + it's needed by more than just the JIT, and it supplements a standard library + macro (offsetof). + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallInitializeCallFrame): Fixed an incorrectly signed + cast to resolve an MSVC warning. + + * jit/JITStubs.h: Used #pragma pack to tell MSVC that these structures + represent actual memory layout, and should not be automatically aligned. + + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): Replaced memset_pattern8 with a for loop, since + memset_pattern8 is not portable. (I verified that this version of the loop + gives the best performance / generated code in GCC.) + + * runtime/JSObject.h: + (JSC::JSObject::JSObject): Removed accidental usage of FIELD_OFFSET -- + OBJECT_OFFSETOF is our new macro name. (FIELD_OFFSET conflicts with a + definition in winnt.h.) + + * runtime/JSValue.cpp: Added some headers needed by non-all-in-one builds. + + * runtime/JSValue.h: + (JSC::JSValue::): Made the tag signed, to match MSVC's signed enum values. + (GCC doesn't seem to care one way or the other.) + + * wtf/MainThread.cpp: Moved the StdLibExtras.h #include -- I did this a + while ago to resolve a conflict with winnt.h. I can't remember if it's truly + still needed, but what the heck. + + * wtf/StdLibExtras.h: Moved OBJECT_OFFSETOF definition here. + +2009-07-06 Geoffrey Garen + + Reviewed by Sam Weinig (?). + + Fixed an assertion seen during the stress test. + + Don't assume that, if op1 is constant, op2 is not, and vice versa. Sadly, + not all constants get folded. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + +2009-07-06 Geoffrey Garen + + Reviewed by Sam Weinig. + + Include op_convert_this in result caching. + + No change on SunSpider or v8. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_convert_this): + + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): Made the op_convert_this JIT stub return an EncodedJSValue, so + to maintain the result caching contract that { tag, payload } can be + found in { regT1, regT0 }. + +2009-07-06 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented result chaining. + + 1% faster on SunSpider. 4%-5% faster on v8. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::move): + * assembler/X86Assembler.h: + (JSC::X86Assembler::movl_rr): Added an optimization to eliminate + no-op mov instructions, to simplify chaining. + + * jit/JIT.cpp: + (JSC::JIT::JIT): + * jit/JIT.h: Added data members and helper functions for recording + chained results. We record both a mapping from virtual to machine register + and the opcode for which the mapping is valid, to help ensure that the + mapping isn't used after the mapped register has been stomped by other + instructions. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::compileOpCallVarargsSlowCase): + (JSC::JIT::emit_op_ret): + (JSC::JIT::emit_op_construct_verify): + (JSC::JIT::compileOpCall): + (JSC::JIT::compileOpCallSlowCase): Chain function call results. + + * jit/JITInlineMethods.h: + (JSC::JIT::emitLoadTag): + (JSC::JIT::emitLoadPayload): + (JSC::JIT::emitLoad): + (JSC::JIT::emitLoad2): + (JSC::JIT::isLabeled): + (JSC::JIT::map): + (JSC::JIT::unmap): + (JSC::JIT::isMapped): + (JSC::JIT::getMappedPayload): + (JSC::JIT::getMappedTag): Use helper functions when loading virtual + registers into machine registers, in case the loads can be eliminated + by chaining. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_mov): + (JSC::JIT::emit_op_end): + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emit_op_get_global_var): + (JSC::JIT::emit_op_put_global_var): + (JSC::JIT::emit_op_get_scoped_var): + (JSC::JIT::emit_op_put_scoped_var): + (JSC::JIT::emit_op_to_primitive): + (JSC::JIT::emit_op_resolve_global): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_next_pname): + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emit_op_catch): Chain results from these opcodes. + + (JSC::JIT::emit_op_profile_will_call): + (JSC::JIT::emit_op_profile_did_call): Load the profiler into regT2 to + avoid stomping a chained result. + + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emit_op_get_by_id): Chain results from these opcodes. + + * jit/JITStubCall.h: + (JSC::JITStubCall::addArgument): Always use { regT1, regT0 }, to facilitate + chaining. + + (JSC::JITStubCall::call): Unmap all mapped registers, since our callee + stub might stomp them. + +2009-07-01 Sam Weinig + + Reviewed by Gavin Barraclough. + + Don't reload values in emitBinaryDoubleOp. + + SunSpider reports a 0.6% progression. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitBinaryDoubleOp): + +2009-07-01 Sam Weinig + + Reviewed by Geoffrey Garen. + + Convert op_div to load op1 and op2 up front. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_div): + +2009-07-01 Sam Weinig + + Reviewed by Geoffrey Garen. + + Don't emit code in emitBinaryDoubleOp if code is unreachable, observable + via an empty (unlinked) jumplist passed in. This only effects op_jnless + and op_jnlesseq at present. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emitBinaryDoubleOp): + +2009-07-01 Geoffrey Garen + + Reviewed by Sam Weinig. + + Converted op_mod to put { tag, payload } in { regT1, regT0 }, and + tidied up its constant case. + + SunSpider reports a 0.2% regression, but a micro-benchmark of op_mod + shows a 12% speedup, and the SunSpider test that uses op_mod most should + benefit a lot from result caching in the end, since it almost always + performs (expression) % constant. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mod): + (JSC::JIT::emitSlow_op_mod): + +2009-06-30 Sam Weinig + + Reviewed by Geoffrey Garen. + + Converted some more arithmetic ops to put { tag, payload } in + { regT1, regT0 }. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + +2009-06-30 Geoffrey Garen + + Reviewed by Sam Weinig. + + Converted some more arithmetic ops to put { tag, payload } in + { regT1, regT0 }, and added a case for subtract constant. + + SunSpider says no change. v8 says 0.3% slower. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_add): + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSub32Constant): + (JSC::JIT::emitSlow_op_sub): + +2009-06-30 Gavin Barraclough + + Reviewed by Sam Weinig. + + Remove more uses of addressFor(), load double constants directly from + the constantpool in the CodeBlock, rather than from the register file. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitBinaryDoubleOp): + +2009-06-30 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed a bug in postfix ops, where we would treat x = x++ and x = x-- + as a no-op, even if x were not an int, and the ++/-- could have side-effects. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emitSlow_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emitSlow_op_post_dec): + +2009-06-30 Geoffrey Garen + + Reviewed by Sam Weinig. + + Converted some arithmetic ops to put { tag, payload } in + { regT1, regT0 }. + + SunSpider says 0.7% faster. v8 says no change. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emit_op_rshift): + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emit_op_bitxor): + * jit/JITInlineMethods.h: + (JSC::JIT::isOperandConstantImmediateInt): + (JSC::JIT::getOperandConstantImmediateInt): + +2009-06-30 Gavin Barraclough + + Reviewed by Sam Weinig. + + Start removing cases of addressFor(). + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_div): + * jit/JITInlineMethods.h: + (JSC::JIT::emitLoadDouble): + (JSC::JIT::emitLoadInt32ToDouble): + (JSC::JIT::emitStoreDouble): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + +2009-06-30 Geoffrey Garen + + Rolled back in my last patch with regression fixed. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emit_op_resolve_global): + (JSC::JIT::emitSlow_op_resolve_global): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + +2009-06-30 Geoffrey Garen + + Rolled out my last patch because it was a 2% SunSpider regression. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emit_op_resolve_global): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + +2009-06-30 Geoffrey Garen + + Reviewed by Gavin "Sam Weinig" Barraclough. + + Standardized the rest of our opcodes to put { tag, payload } in + { regT1, regT0 } where possible. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emit_op_resolve_global): + (JSC::JIT::emitSlow_op_resolve_global): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + +2009-06-30 Gavin Barraclough + + Reviewed by Geoffrey Garen. + + Replace calls to store32(tagFor()) and store32(payloadFor()) + with emitStoreInt32(), emitStoreBool(), and emitStoreCell(). + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emit_op_rshift): + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emitBitAnd32Constant): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emitBitOr32Constant): + (JSC::JIT::emit_op_bitxor): + (JSC::JIT::emitBitXor32Constant): + (JSC::JIT::emit_op_bitnot): + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emit_op_pre_inc): + (JSC::JIT::emit_op_pre_dec): + (JSC::JIT::emit_op_add): + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSub32ConstantLeft): + (JSC::JIT::emitSub32ConstantRight): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emit_op_div): + (JSC::JIT::emit_op_mod): + * jit/JITCall.cpp: + (JSC::JIT::emit_op_load_varargs): + * jit/JITInlineMethods.h: + (JSC::JIT::emitStoreInt32): + (JSC::JIT::emitStoreCell): + (JSC::JIT::emitStoreBool): + (JSC::JIT::emitStore): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emit_op_not): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + (JSC::JIT::compileOpStrictEq): + (JSC::JIT::emit_op_eq_null): + (JSC::JIT::emit_op_neq_null): + * jit/JITStubCall.h: + (JSC::JITStubCall::call): + +2009-06-30 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized the rest of the property access instructions to put { tag, + payload } in { regT1, regT0 }. + + Small v8 speedup, 0.2% SunSpider slowdown. + + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::emitLoad): + (JSC::JIT::emitLoad2): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + (JSC::JIT::emit_op_put_by_id): + (JSC::JIT::emitSlow_op_put_by_id): + (JSC::JIT::patchPutByIdReplace): + +2009-06-29 Sam Weinig + + Reviewed by Gavin Barraclough. + + Various cleanups. + - Use fpRegT* instead of X86::xmm*. + - Use a switch statement in emitBinaryDoubleOp instead of a bunch of + if/elses. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_div): + +2009-06-29 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add inline code dealing with doubles for op_jfalse and op_jtrue. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::): + (JSC::MacroAssemblerX86Common::zeroDouble): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + +2009-06-28 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized op_get_by_id to put { tag, payload } in { regT1, regT0 }. + + SunSpider and v8 report maybe 0.2%-0.4% regressions, but the optimization + this enables will win much more than that back. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::emit_op_get_by_id): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compileGetByIdSlowCase): + (JSC::JIT::patchGetByIdSelf): + (JSC::JIT::privateCompilePatchGetArrayLength): + (JSC::JIT::privateCompileGetByIdProto): + (JSC::JIT::privateCompileGetByIdSelfList): + (JSC::JIT::privateCompileGetByIdProtoList): + (JSC::JIT::privateCompileGetByIdChainList): + (JSC::JIT::privateCompileGetByIdChain): + +2009-06-26 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Standardized op_call to put { tag, payload } in { regT1, regT0 }. + + SunSpider and v8 report no change. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallInitializeCallFrame): + (JSC::JIT::compileOpCallSetupArgs): + (JSC::JIT::compileOpConstructSetupArgs): + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::compileOpCall): + (JSC::JIT::compileOpCallSlowCase): + +2009-06-26 Sam Weinig + + Reviewed by Geoffrey Garen. + + Handle multiplying by zero a little better by + inlining the case that both operands are non-negative + into the slowpath. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::branchOr32): + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + Optimize x++ to ++x inside for loops. + + Sadly, no measurable speedup, but this should help with result chaining. + + * parser/Nodes.cpp: + (JSC::ForNode::emitBytecode): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized some more opcodes to put { tag, payload } in { regT1, regT0 }. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_bitnot): + (JSC::JIT::emit_op_post_inc): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized some more opcodes to put { tag, payload } in { regT1, regT0 }. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_bitnot): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emit_op_pre_inc): + (JSC::JIT::emitSlow_op_pre_inc): + (JSC::JIT::emit_op_pre_dec): + (JSC::JIT::emitSlow_op_pre_dec): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized some more opcodes to put { tag, payload } in { regT1, regT0 }. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): + (JSC::JIT::emitSlow_op_negate): + * jit/JITCall.cpp: + (JSC::JIT::emit_op_construct_verify): + (JSC::JIT::emitSlow_op_construct_verify): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig. + + Standardized some more opcodes to put { tag, payload } in { regT1, regT0 }. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_true): + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emit_op_jeq_null): + (JSC::JIT::emit_op_jneq_null): + (JSC::JIT::emit_op_eq_null): + (JSC::JIT::emit_op_neq_null): + +2009-06-25 Geoffrey Garen + + Reviewed by Sam Weinig (sort of, maybe). + + Fixed some ASSERTs in http/tests/security. + + These ASSERTs were introduced by http://trac.webkit.org/changeset/45057, + but the underlying problem was actually older. http://trac.webkit.org/changeset/45057 + just exposed the problem by enabling optimization in more cases. + + The ASSERTs fired because we tested PropertySlot::slotBase() for validity, + but slotBase() ASSERTs if it's invalid, so we would ASSERT before + the test could happen. Solution: Remove the ASSERT. Maybe it was valid + once, but it clearly goes against a pattern we've deployed of late. + + The underlying problem was that WebCore would re-use a PropertySlot in + the case of a forwarding access, and the second use would not completely + overwrite the first use. Solution: Make sure to overwrite m_offset when + setting a value on a PropertySlot. (Other values already get implicitly + overwritten during reuse.) + + * runtime/PropertySlot.h: + (JSC::PropertySlot::PropertySlot): + (JSC::PropertySlot::setValueSlot): + (JSC::PropertySlot::setValue): + (JSC::PropertySlot::setRegisterSlot): + (JSC::PropertySlot::setUndefined): + (JSC::PropertySlot::slotBase): + (JSC::PropertySlot::clearOffset): + +2009-06-24 Gavin Barraclough + + Reviewed by Geoff Garen. + + Enable JIT_OPTIMIZE_METHOD_CALLS on the branch, implementation matches current implemenatation in ToT. + + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_method_check): + (JSC::JIT::emitSlow_op_method_check): + (JSC::JIT::emit_op_get_by_id): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::emitSlow_op_get_by_id): + (JSC::JIT::compileGetByIdSlowCase): + +2009-06-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Bit off a tiny bit more of standardizing opcode behavior to help with result + caching. + + SunSpider reports no change, v8 maybe a tiny speedup. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emitSlow_op_to_jsnumber): + (JSC::JIT::emit_op_convert_this): + (JSC::JIT::emitSlow_op_convert_this): + +2009-06-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Bit off a tiny bit more of standardizing opcode behavior to help with result + caching -- including removing my old enemy, op_resolve_function, because + it was non-standard, and removing it felt better than helping it limp along. + + SunSpider reports no change, v8 maybe a tiny speedup. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + * bytecompiler/BytecodeGenerator.h: + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_get_scoped_var): + (JSC::JIT::emit_op_put_scoped_var): + (JSC::JIT::emit_op_to_primitive): + (JSC::JIT::emitSlow_op_to_primitive): + * jit/JITStubs.cpp: + * jit/JITStubs.h: + * parser/Nodes.cpp: + (JSC::FunctionCallResolveNode::emitBytecode): + +2009-06-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Bit off a tiny bit of standardizing opcode behavior to help with result + caching. + + 0.6% SunSpider speedup. 0.3% v8 speedup. + + * jit/JITInlineMethods.h: + (JSC::JIT::emitLoad): Accomodate a base register that overlaps with payload + by loading tag before payload, to avoid stomping base/payload. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_mov): Abide by the standard "tag in regT1, payload in + regT0" semantics. + + (JSC::JIT::emit_op_get_global_var): + (JSC::JIT::emit_op_put_global_var): Ditto. Also, removed some irrelevent + loads while I was at it. The global object's "d" pointer never changes + after construction. + +2009-06-23 Gavin Barraclough + + Reviewed by Sam Weinig. + + Remove 'arguments' field from Register union (again). + This time do so without breaking tests (radical, I know). + + * interpreter/CallFrame.h: + (JSC::ExecState::optionalCalleeArguments): + (JSC::ExecState::setArgumentCount): + (JSC::ExecState::init): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::dumpRegisters): + (JSC::Interpreter::unwindCallFrame): + (JSC::Interpreter::privateExecute): + (JSC::Interpreter::retrieveArguments): + * interpreter/Register.h: + (JSC::Register::withInt): + (JSC::Register::): + (JSC::Register::Register): + (JSC::Register::i): + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_tear_off_arguments): + * runtime/Arguments.h: + (JSC::JSActivation::copyRegisters): + (JSC::Register::arguments): + * runtime/JSActivation.cpp: + (JSC::JSActivation::argumentsGetter): + * runtime/JSActivation.h: + +2009-06-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed some result register tracking cruft in preparation for a new + result tracking mechanism. + + SunSpider reports no change. + + * assembler/AbstractMacroAssembler.h: + * assembler/X86Assembler.h: + (JSC::X86Assembler::JmpDst::JmpDst): No need to track jump targets in + machine code; we already do this in bytecode. + + * jit/JIT.cpp: + (JSC::JIT::JIT): + (JSC::JIT::emitTimeoutCheck): Make sure to save and restore the result + registers, so an opcode with a timeout check can still benefit from result + register caching. + + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): Removed calls to killLastResultRegister() + in preparation for something new. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + * jit/JITInlineMethods.h: + (JSC::JIT::emitGetFromCallFrameHeaderPtr): + (JSC::JIT::emitGetFromCallFrameHeader32): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emit_op_jeq_null): + (JSC::JIT::emit_op_jneq_null): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_jsr): + (JSC::JIT::emit_op_sret): + (JSC::JIT::emit_op_jmp_scopes): ditto + + * jit/JITStubCall.h: + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::getArgument): added a mechanism for reloading an argument + you passed to a JIT stub, for use in emitTimeoutCheck. + +2009-06-23 Sam Weinig + + Reviewed by Geoffrey Garen. + + Remove now-useless inplace variants of binary ops. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emit_op_bitxor): + (JSC::JIT::emit_op_add): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emit_op_mul): + +2009-06-23 Sam Weinig + + Reviewed by Geoffrey Garen. + + Move off memory operands to aid in re-enabling result caching. + + - No regression measured. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emit_op_rshift): + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emitBitAnd32Constant): + (JSC::JIT::emitBitAnd32InPlace): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emitBitOr32Constant): + (JSC::JIT::emitBitOr32InPlace): + (JSC::JIT::emit_op_bitxor): + (JSC::JIT::emitBitXor32Constant): + (JSC::JIT::emitBitXor32InPlace): + (JSC::JIT::emit_op_bitnot): + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emit_op_pre_inc): + (JSC::JIT::emitSlow_op_pre_inc): + (JSC::JIT::emit_op_pre_dec): + (JSC::JIT::emitSlow_op_pre_dec): + (JSC::JIT::emit_op_add): + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitAdd32InPlace): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlowAdd32Constant): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSlow_op_sub): + (JSC::JIT::emitSub32ConstantLeft): + (JSC::JIT::emitSub32ConstantRight): + (JSC::JIT::emitSub32InPlaceLeft): + (JSC::JIT::emitSub32InPlaceRight): + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitMul32InPlace): + (JSC::JIT::emit_op_div): + (JSC::JIT::emit_op_mod): + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargs): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emit_op_to_primitive): + (JSC::JIT::emit_op_not): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emit_op_to_jsnumber): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + +2009-06-23 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed some missing and/or misplaced labels in bytecode generation, so + we don't have to work around them in JIT code generation. + + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitJumpSubroutine): + * parser/Nodes.cpp: + (JSC::TryNode::emitBytecode): + +2009-06-22 Geoffrey Garen + + Reviewed by Sam Weinig. + + For member function calls, emit "this" directly into the "this" slot + for the function call, instead of moving it there later. This reduces + time spent in op_mov during certain calls, like "a.b.c()". + + 1%-2% speedup on v8, mostly richards and delta-blue. + + * parser/Nodes.cpp: + (JSC::FunctionCallDotNode::emitBytecode): + +2009-06-22 Gavin Barraclough + + Reviewed by Sam Weinig. + + Remove 'arguments' field from Register union. Having JSCell derived types in the union is + dangerous since it opens the possibility for the field to be written as a raw pointer but + then read as a JSValue. This will lead to statle data being read for the tag, which may + be dangerous. Having removed Arguments* types form Register, all arguments objects must + always explicitly be stored in the register file as JSValues. + + * interpreter/CallFrame.h: + (JSC::ExecState::optionalCalleeArguments): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::unwindCallFrame): + (JSC::Interpreter::privateExecute): + (JSC::Interpreter::retrieveArguments): + * interpreter/Register.h: + (JSC::Register::): + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_tear_off_arguments): + * runtime/Arguments.h: + (JSC::JSActivation::copyRegisters): + * runtime/JSActivation.cpp: + (JSC::JSActivation::argumentsGetter): + * runtime/JSActivation.h: + +2009-06-03 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add back known this value optimization by abstracting + slow case if not JSCell jumps. + + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::compileOpCallVarargsSlowCase): + (JSC::JIT::compileOpCall): + (JSC::JIT::compileOpCallSlowCase): + * jit/JITInlineMethods.h: + (JSC::JIT::emitJumpSlowCaseIfNotJSCell): + (JSC::JIT::linkSlowCaseIfNotJSCell): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emitSlow_op_instanceof): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + (JSC::JIT::emit_op_get_by_id): + (JSC::JIT::emitSlow_op_get_by_id): + (JSC::JIT::emit_op_put_by_id): + (JSC::JIT::emitSlow_op_put_by_id): + +2009-06-01 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed some of the regression in crypto-aes.js. (8.5% speedup in + crypto-aes.js.) + + SunSpider reports no change overall. + + Division was producing double results, which took the slow path through + array access code. + + Strangely, all my attempts at versions of this patch that modified array + access code to accept ints encoded as doubles along the fast or slow paths + were regressions. So I did this instead. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_div): When dividing an int by an int, go ahead and try + to turn the result into an int. Don't just do int division, though, because + testing shows it to be slower than SSE double division, and the corner + cases are pretty complicated / lengthy on top of that. Also, don't try + to canonicalize division of known tiny numerators into ints, since that's a + waste of time. + +2009-05-26 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed a regression caused by my recent fix for NaN. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitBinaryDoubleOp): Actually do the comparison in reverse + order, like the ChangeLog said we would, bokay? + +2009-05-26 Geoffrey Garen + + Reviewed by Sam Weinig and Oliver Hunt. + + Fixed two edge cases in %: + + - Don't do -2147483648 % x as a fast case, since you might do -2147483648 % -1, + which will signal a hardware exception due to overflow. + + - In the case of a zero remainder, be sure to store negative zero if the + dividend was zero. + + SunSpider reports no change. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mod): + (JSC::JIT::emitSlow_op_mod): + +2009-05-25 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Fixed a regression when comparing to NaN. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitBinaryDoubleOp): For op_jnless and op_jnless_eq, do the + comparison in reverse order, and jump if the result is below or + below-or-equal. This ensures that we do jump in the case of NaN. + +2009-05-25 Geoffrey Garen + + Reviewed by Oliver Hunt. + + SunSpider says no change. + + Fixed regressions in fast/js/var-declarations-shadowing.html and + fast/js/equality.html, caused by recent == and != optimizations. + + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_eq): Don't treat "compare to string" as always + numeric or string comparison. If the second operand is an object, you + need to ToPrimitive it, and start all over again. Also, I wrote out each + of the possible cases explicitly, to cut down on redundant branching. + +2009-05-25 Sam Weinig + + Reviewed by Mark Rowe. + + Fix bug in fast/js/constant-folding.html where we were not negating + -0 properly. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): + +2009-05-23 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Refactored new slow case codegen for == and !=. + + SunSpider reports no change, maybe a tiny speedup. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emitSlow_op_neq): Made a vptr comparison a *Ptr operation, + instead of *32, to make it portable to 64bit. Reorganized the string + and generic cases to make their control flow a little clearer. + +2009-05-23 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + Optimized == and != for our new value representation -- especially for strings. + + 14% speedup on date-format-tofte. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + * jit/JITStubCall.h: + (JSC::JITStubCall::JITStubCall): + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_eq): + (JSC::JITStubs::cti_op_eq_strings): + (JSC::JITStubs::cti_op_call_eval): + * jit/JITStubs.h: + (JSC::): + * runtime/JSValue.h: + +2009-05-22 Sam Weinig + + Reviewed by Gavin Barraclough. + + Fix non-SSE enabled builds. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_add): Don't early return here, we still need to call the JIT stub. + (JSC::JIT::emitSlow_op_sub): Ditto. + +2009-05-22 Geoffrey Garen + + Reviewed by Sam Weinig. + + Here's a thought: let's not take a jit stub call just to multiply by 1, + bokay? + + imul doesn't set the zero flag, so to test for a zero result, we need + an explicit instruction. (Luckily, it does set the overflow flag, so + we can still use that.) + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emitMul32InPlace): + +2009-05-22 Sam Weinig + + Reviewed by Geoffrey "Premature Commit" Garen. + + Add back constant integer cases for op_add. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_add): + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlowAdd32Constant): + * jit/JITInlineMethods.h: + (JSC::JIT::getConstantOperandImmediateDouble): + (JSC::JIT::isOperandConstantImmediateDouble): + +2009-05-22 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added fast double cases for op_jnless and op_jnlesseq. + + * assembler/AbstractMacroAssembler.h: + (JSC::AbstractMacroAssembler::JumpList::jumps): New accesor, used by + addSlowCase. + + * assembler/X86Assembler.h: + (JSC::X86Assembler::ucomisd_rm): New method for comparing register to + memory. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emit_op_add): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emit_op_div): Modified emitBinaryDoubleOp to accept comparison/jump + operations in addition to operations with explicit result registers. + + * jit/JITInlineMethods.h: + (JSC::JIT::addSlowCase): Added an "addSlowCase" for JumpLists, so clients + can track multiple jumps to the same slow case condition together. + +2009-05-21 Sam Weinig + + Reviewed by Gavin Barraclough. + + Implement op_negate inline fast cases. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::neg32): + * assembler/X86Assembler.h: + (JSC::X86Assembler::): + (JSC::X86Assembler::negl_m): + (JSC::X86Assembler::xorpd_rr): + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_negate): + (JSC::JIT::emitSlow_op_negate): + +2009-05-20 Sam Weinig + + Reviewed by Gavin Barraclough. + + Update the patchOffsetGetByIdSlowCaseCall constant for the + case that OPCODE_SAMPLING is enabled. + + * jit/JIT.h: + +2009-05-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added support for inline subtraction of doubles. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSlow_op_sub): + (JSC::JIT::emitSlowSub32InPlaceLeft): + (JSC::JIT::emitBinaryDoubleOp): + +2009-05-20 Sam Weinig + + Reviewed by Geoffrey Garen. + + Added support for inline division. + + * assembler/X86Assembler.h: + (JSC::X86Assembler::): + (JSC::X86Assembler::divsd_rr): + (JSC::X86Assembler::divsd_mr): + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitBinaryOp): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + (JSC::JIT::privateCompileSlowCases): + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_div): + (JSC::JIT::emitSlow_op_div): + +2009-05-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added support for inline addition of doubles. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_add): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlowAdd32InPlace): + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + +2009-05-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Factored inline double operations into a helper function, so that we + can reuse this code for other math operations. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emitBinaryDoubleOp): + (JSC::JIT::emit_op_mul): + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallInitializeCallFrame): + +2009-05-20 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added support for inline multiplication of doubles. + + * assembler/X86Assembler.h: + (JSC::X86Assembler::cvtsi2sd_mr): New function, useful for loading an + int32 into a double register. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): Filled out these cases for double arithmetic. + + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::addressFor): New function, useful for addressing a JSValue's + full 64bits as a double. + +2009-05-19 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement and enable optimized calls. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): Add ENABLE(JIT_OPTIMIZE_CALL) guards + around the the optimize call only trampolines (virtualCallPreLink and virtualCallLink). + Update the trampolines to account for the new JSValue representation. + (JSC::JIT::unlinkCall): Use NULL instead of JSValue noValue. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): Update to account for the new JSValue representation + (JSC::JIT::compileOpCallSlowCase): Ditto. + + * jit/JITStubs.h: Remove incorrect !ENABLE(JIT_OPTIMIZE_CALL) guard. + + * wtf/Platform.h: Enable ENABLE_JIT_OPTIMIZE_CALL. + +2009-05-19 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement and enable optimized property access. + + * assembler/AbstractMacroAssembler.h: Fix comment. + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): Remove array length trampoline + and implement the string length trampoline. + * jit/JIT.h: Add new constants for patch offsets. + * jit/JITInlineMethods.h: Remove FIELD_OFFSET which is now in StdLibExtras.h. + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_id): + (JSC::JIT::emitSlow_op_get_by_id): + (JSC::JIT::emit_op_put_by_id): + (JSC::JIT::emitSlow_op_put_by_id): + (JSC::JIT::compilePutDirectOffset): + (JSC::JIT::compileGetDirectOffset): + (JSC::JIT::privateCompilePutByIdTransition): + (JSC::JIT::patchGetByIdSelf): + (JSC::JIT::patchPutByIdReplace): + (JSC::JIT::privateCompilePatchGetArrayLength): + (JSC::JIT::privateCompileGetByIdProto): + (JSC::JIT::privateCompileGetByIdSelfList): + (JSC::JIT::privateCompileGetByIdProtoList): + (JSC::JIT::privateCompileGetByIdChainList): + (JSC::JIT::privateCompileGetByIdChain): + * jit/JITStubCall.h: + (JSC::JITStubCall::addArgument): Add version of addArgument that takes + two registers for the tag and payload. + * jit/JITStubs.cpp: + (JSC::JITStubs::JITStubs): Remove array length trampoline pointer. + (JSC::JITStubs::cti_op_get_by_id_self_fail): + * jit/JITStubs.h: + * runtime/JSObject.h: + (JSC::JSObject::JSObject): Move m_inheritorID below the property storage + to align it to a 16 byte boundary. + * wtf/Platform.h: Enable ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS + * wtf/StdLibExtras.h: Move FIELD_OFFSET here. + +2009-05-17 Sam Weinig + + Reviewed by Geoffrey Garen. + + Remove unneeded ExecState parameter from the number JSValue constructors. + + * runtime/JSValue.h: + (JSC::jsNumber): + (JSC::jsNaN): + (JSC::JSValue::JSValue): + +2009-05-15 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implemented fast path for op_put_by_val when putting to arrays. + + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + +2009-05-15 Geoffrey Garen (Mostly by Sam) + + Reviewed by Sam Weinig. + + Implemented fast path for op_get_by_val when accessing array. + + * jit/JIT.cpp: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed a failure in fast/js/math-transforms.html caused by failing to + preserve -0 in multiplication. + + * assembler/X86Assembler.h: + (JSC::X86Assembler::jz): + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emitMul32Constant): + (JSC::JIT::emitMul32InPlace): Check both for overflow and for zero when + doing multiplication. Use a slow case to get these right. + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed a bug in the varargs calling convention. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargs): Move the argument count into regT1, + since that's where ctiVirtualCall expects it to be. + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed a small bug in instanceof's looping code. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): NULL means the object has no prototype, + so only loop when *not* equal to NULL. + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed a small bug in instanceof's result writing code. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): Make sure to fill out the payload bits + in all cases. + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + Removed an invalid assertion in cti_op_urshift which + depended on a fast path for op_urshift which has + never existed. + + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_urshift): + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed loop_if_true, which had the same reversed test that jtrue had. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_true): + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + In op_neq, we apparently want to check that one value + does *not* equal another. Go figure. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_neq): + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + The slow case of op_mod should call op_mod's jit stub, + not op_mul. That would be dumb. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_mod): + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed problems when using 'arguments' due to a half-initialized register. + + * interpreter/CallFrame.h: + (JSC::ExecState::setCalleeArguments): + (JSC::ExecState::init): Require a full JSValue when setting up the + 'arguments' virtual register, since this register is accessible from JIT + code and bytecode, and needs to be a true JSValue. + + * interpreter/CallFrameClosure.h: + (JSC::CallFrameClosure::resetCallFrame): ditto + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): ditto + + * interpreter/Register.h: Removed the constructor that allowed assignment + of a JSArguments* to a register. That is not safe. See above. + + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_create_arguments): + (JSC::JITStubs::cti_op_create_arguments_no_params): ditto + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + We really want to go to the slow case in op_jfalse and + op_jtrue if the value is *not* boolean. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jtrue): + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + Flipped the condition when emitting a an op_loop_if_less or op_loop_if_lesseq + if the first operand is a constant. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + Added missing return in op_jnless and op_jnlesseq. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + +2009-05-14 Sam Weinig + + Reviewed by Geoffrey Garen. + + Load constants into the the register file as a temporary measure to + aid bring up. This allows us to use to treat constants like any + other virtual register. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_enter): + (JSC::JIT::emit_op_enter_with_activation): + +2009-05-14 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented op_strict_eq. Original patch by Snowy, by way of Sam and Gavin. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::set8): Added set8, since it's slightly + faster than set32, and the new value representation usually doesn't + need set32. + + * jit/JIT.cpp: + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::emitLoadTag): + (JSC::JIT::emitLoadPayload): Added helper functions for dealing with + constants. Eventually, we should write special cases for all constants, + but these are helpful in the short term. + + * jit/JITOpcodes.cpp: + (JSC::JIT::compileOpStrictEq): + (JSC::JIT::emitSlow_op_stricteq): + (JSC::JIT::emitSlow_op_nstricteq): teh opcodez. + + * runtime/JSValue.h: + (JSC::JSValue::): + (JSC::JSValue::isDouble): Added a LowestTag for clarity. + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Fixed some bugs in host function calls. + + testapi now passes! + + * jit/JIT.cpp: Changed some registers around to avoid overwriting edx:eax, + which is how JSValues are now returned. Also changed the code that + passes thisValue to pass the full 64bits of the value. Also added + an #error compiler directive to other platform builds, since the JSValue + return signature probably won't return in edx:eax on those platforms, + and we'll have to investigate a solution. + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed parameters from functions that are intended never to use their + parameters. + + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Ported op_instance_of from TOT. It's basically the same, but some register + stuff changed to memory stuff. + + * jit/JITInlineMethods.h: + (JSC::JIT::emitPutJITStubArgFromVirtualRegister): + (JSC::JIT::emitStore): Changed to use helper functions. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emitSlow_op_instanceof): Ported from TOT. + +2009-05-13 Geoffrey Garen + + Reviewed by Gavin Barraclough. + + Added a comment to explain an exception-handling subtelty that we found + hard to remember when reviewing my last patch. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_catch): + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented try/catch. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_throw): Updated to use JITStackFrame abstraction. + (JSC::JIT::emit_op_catch): Filled out. + +2009-05-13 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implemented op_loop_if_true, op_jfalse, op_jtrue, op_jeq_null and op_jneq_null + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_instanceof): Moved from below to be next to its + fast brother. + + (JSC::JIT::emit_op_loop_if_true): Similar to the old version + in that it tries to do the integer case first and reduce the + number of jumps you might need to take. + (JSC::JIT::emitSlow_op_loop_if_true): + + (JSC::JIT::emit_op_jfalse): Very similar to op_loop_if_true, only + the inverse and without a timeout check. + (JSC::JIT::emitSlow_op_jfalse): + + (JSC::JIT::emit_op_jtrue): Very similar to op_loop_if_true except + without the timeout check. + (JSC::JIT::emitSlow_op_jtrue): + + (JSC::JIT::emit_op_jeq_null): Very similar to the implementation + of op_eq, except it takes jumps instead of copying the condition + to a dst. + (JSC::JIT::emit_op_jneq_null): Ditto but for op_neq. + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented op_call_varargs. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::emit_op_call): + (JSC::JIT::emit_op_call_eval): + (JSC::JIT::emit_op_load_varargs): + (JSC::JIT::emit_op_call_varargs): + (JSC::JIT::emit_op_construct): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jneq_ptr): + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented op_call_eval. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpCall): + * jit/JITStubCall.h: + (JSC::CallEvalJITStub::CallEvalJITStub): + +2009-05-13 Sam Weinig + + Reviewed by Gavin Barraclough. + + Implemented op_not. (Gavin did most of the work!) + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_not): + (JSC::JIT::emitSlow_op_not): + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Implemented op_global_resolve. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): Added back accidentally removed + early returns. + + (JSC::JIT::emit_op_resolve_global): + * jit/JITStubs.cpp: + (JSC::JITStubs::cti_op_resolve_global): Pretty similar to the old code, + but we need two reads and a TimesEight step in order to account for the + 64bit value size. + + * jit/JITStubs.h: + (JSC::): Slightly tweaked this code to specialize for a JSGlobalObject*, + to avoid having to pass an irrelevant tag pointer to the stub. + +2009-05-13 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implemented op_to_jsnumber. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emitSlow_op_to_jsnumber): + +2009-05-13 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implemented op_convert_this. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_convert_this): + (JSC::JIT::emitSlow_op_convert_this): + +2009-05-13 Geoffrey Garen + + Reviewed by Sam Weinig. + + Got basic JS function and constructor calls working. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JIT.h: + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallSetupArgs): + (JSC::JIT::compileOpCallVarargsSetupArgs): + (JSC::JIT::compileOpConstructSetupArgs): + (JSC::JIT::emit_op_ret): + (JSC::JIT::emit_op_construct_verify): + (JSC::JIT::emitSlow_op_construct_verify): + (JSC::JIT::emitSlow_op_call): + (JSC::JIT::emitSlow_op_call_eval): + (JSC::JIT::emitSlow_op_call_varargs): + (JSC::JIT::emitSlow_op_construct): + (JSC::JIT::compileOpCall): Filled out these cases, with call_eval #if'd out. + + * jit/JITInlineMethods.h: + (JSC::JIT::emitPutJITStubArgFromVirtualRegister): + (JSC::JIT::emitLoad): Restored some legacy "*CTIArg*" functions, + since I wanted to avoid the complexity of revamping the API here while + trying to bring it up. Eventually, we should re-remove all of these functions. + + (JSC::JIT::recordJumpTarget): Removed unnecessary macro cruft. You will + not silence me, Sam Weinig! The world will know that you are a crufty, + crufty, crufty programmer!!! + + * jit/JITOpcodes.cpp: + * jit/JITStubs.cpp: + (JSC::): + * jit/JITStubs.h: Changed up some offsets in the JITStackFrame class, since + and off-by-one error was causing stack misalignment. + +2009-05-13 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement op_eq_null and op_neq_null. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::set8): + (JSC::MacroAssemblerX86Common::setTest8): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_stricteq): + (JSC::JIT::emitSlow_op_stricteq): + (JSC::JIT::emit_op_nstricteq): + (JSC::JIT::emitSlow_op_nstricteq): + (JSC::JIT::emit_op_eq_null): + (JSC::JIT::emit_op_neq_null): + * jsc.cpp: + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement op_new_error. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_new_error): + * jit/JITStubCall.h: + (JSC::JITStubCall::addArgument): Add a version of addArgument + that takes a constant JSValue. + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Remove now unused emitGetVariableObjectRegister and emitPutVariableObjectRegister. + + * jit/JIT.cpp: + * jit/JIT.h: + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement op_to_primitive and op_next_pname. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_construct_verify): + (JSC::JIT::emit_op_to_primitive): + (JSC::JIT::emitSlow_op_to_primitive): + (JSC::JIT::emitSlow_op_loop_if_true): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emit_op_next_pname): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add op_get_global_var, op_put_global_var, emit_op_get_scoped_var, emit_op_put_scoped_var and + op_unexpected_load. + + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::tagFor): + (JSC::JIT::payloadFor): + (JSC::JIT::emitLoad): + (JSC::JIT::emitStore): + (JSC::JIT::emitLoadReturnValue): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_get_global_var): + (JSC::JIT::emit_op_put_global_var): + (JSC::JIT::emit_op_get_scoped_var): + (JSC::JIT::emit_op_put_scoped_var): + (JSC::JIT::emit_op_unexpected_load): + +2009-05-12 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added overflow handling to op_sub. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_sub): + (JSC::JIT::emitSlowSub32InPlaceLeft): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Remove a function call by folding op_get_by_id and op_put_by_id into + their respective compile functions. + + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_id): + (JSC::JIT::emitSlow_op_get_by_id): + (JSC::JIT::emit_op_put_by_id): + (JSC::JIT::emitSlow_op_put_by_id): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Make JITStubCall work in 64bit by making the stack index + step dependent on the size of void*. + + * jit/JITStubCall.h: + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::addArgument): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement simple version of property access opcodes + which just call a stub functions. + + * jit/JITOpcodes.cpp: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emitSlow_op_put_by_id): + (JSC::JIT::emitSlow_op_get_by_id): + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + (JSC::JIT::emit_op_put_by_index): + (JSC::JIT::emit_op_put_getter): + (JSC::JIT::emit_op_put_setter): + (JSC::JIT::emit_op_del_by_id): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compilePutByIdHotPath): + * jit/JITStubCall.h: + (JSC::JITStubCall::addArgument): + * jsc.cpp: + +2009-05-12 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added work-around for XCode debugging echo problem. + + * jsc.cpp: + (runInteractive): + +2009-05-12 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added overflow handling to op_add. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlowAdd32InPlace): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add slow cases for op_jnless or emit_op_jnlesseq. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emitSlow_op_jnlesseq): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add implementations for op_jnless, emit_op_jnlesseq, op_loop_if_less and op_loop_if_lesseq. + No slow cases for op_jnless or emit_op_jnlesseq yet. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emitSlow_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emitSlow_op_loop_if_lesseq): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Turn the RECORD_JUMP_TARGET macro into an inline function. + + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::recordJumpTarget): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_jsr): + (JSC::JIT::emit_op_jmp_scopes): + +2009-05-12 Sam Weinig + + Add MacroAssemblerX86Common::set8 to fix the build. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::set8): + +2009-05-12 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added overflow recovery for pre_inc and pre_dec. + + Turned some short-circuit code into early returns, as is the WebKit style. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emitSlow_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emitSlow_op_post_dec): + (JSC::JIT::emitSlow_op_pre_inc): + (JSC::JIT::emitSlow_op_pre_dec): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement op_jmp, op_loop, op_eq and op_neq. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_loop): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emitSlow_op_eq): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emitSlow_op_neq): + (JSC::JIT::emit_op_enter): + (JSC::JIT::emit_op_enter_with_activation): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement the slow cases for arithmetic opcodes. + + * jit/JITArithmetic.cpp: + (JSC::JIT::emitSlow_op_lshift): + (JSC::JIT::emitSlow_op_rshift): + (JSC::JIT::emitSlow_op_bitand): + (JSC::JIT::emitSlow_op_bitor): + (JSC::JIT::emitSlow_op_bitxor): + (JSC::JIT::emitSlow_op_bitnot): + (JSC::JIT::emitSlow_op_sub): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emitSlow_op_mod): + (JSC::JIT::emit_op_mod): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Implement op_bitnot. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::not32): + * assembler/X86Assembler.h: + (JSC::X86Assembler::notl_m): + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_bitnot): + +2009-05-12 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add arithmetic opcode implementations from the old nitro-extreme branch. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emitSlow_op_lshift): + (JSC::JIT::emit_op_rshift): + (JSC::JIT::emitSlow_op_rshift): + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emitBitAnd32Constant): + (JSC::JIT::emitBitAnd32InPlace): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emitSlow_op_bitor): + (JSC::JIT::emitBitOr32Constant): + (JSC::JIT::emitBitOr32InPlace): + (JSC::JIT::emit_op_bitxor): + (JSC::JIT::emitSlow_op_bitxor): + (JSC::JIT::emitBitXor32Constant): + (JSC::JIT::emitBitXor32InPlace): + (JSC::JIT::emit_op_bitnot): + (JSC::JIT::emitSlow_op_bitnot): + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emitSlow_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emitSlow_op_post_dec): + (JSC::JIT::emit_op_pre_inc): + (JSC::JIT::emitSlow_op_pre_inc): + (JSC::JIT::emit_op_pre_dec): + (JSC::JIT::emitSlow_op_pre_dec): + (JSC::JIT::emit_op_add): + (JSC::JIT::emitAdd32Constant): + (JSC::JIT::emitAdd32InPlace): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emit_op_sub): + (JSC::JIT::emitSlow_op_sub): + (JSC::JIT::emitSub32ConstantLeft): + (JSC::JIT::emitSub32ConstantRight): + (JSC::JIT::emitSub32InPlaceLeft): + (JSC::JIT::emitSub32InPlaceRight): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emitSlow_op_mul): + (JSC::JIT::emitMul32Constant): + (JSC::JIT::emitMul32InPlace): + (JSC::JIT::emit_op_mod): + (JSC::JIT::emitSlow_op_mod): + * jit/JITOpcodes.cpp: + +2009-05-12 Geoffrey Garen + + Removed JIT_OPTIMIZE_ARITHMETIC setting, since it was all about 32bit + value representations. + + Added JSAPIValueWrapper to the repository. + + * jit/JIT.h: + * jit/JITArithmetic.cpp: + * runtime/JSAPIValueWrapper.cpp: Added. + (JSC::JSAPIValueWrapper::toPrimitive): + (JSC::JSAPIValueWrapper::getPrimitiveNumber): + (JSC::JSAPIValueWrapper::toBoolean): + (JSC::JSAPIValueWrapper::toNumber): + (JSC::JSAPIValueWrapper::toString): + (JSC::JSAPIValueWrapper::toObject): + * runtime/JSAPIValueWrapper.h: Added. + (JSC::JSAPIValueWrapper::value): + (JSC::JSAPIValueWrapper::isAPIValueWrapper): + (JSC::JSAPIValueWrapper::JSAPIValueWrapper): + (JSC::jsAPIValueWrapper): + * wtf/Platform.h: + +2009-05-12 Geoffrey Garen + + Turned on the JIT and got it building and running the most trivial of + programs. + + All configurable optimizations are turned off, and a few opcodes are ad + hoc #if'd out. + + So far, I've only merged op_mov and op_end, but some stub-reliant + opcodes work as-is from TOT. + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::~CodeBlock): + * bytecode/CodeBlock.h: + * jit/JIT.cpp: + (JSC::JIT::compileOpStrictEq): + * jit/JIT.h: + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_lshift): + (JSC::JIT::emitSlow_op_lshift): + (JSC::JIT::emit_op_rshift): + (JSC::JIT::emitSlow_op_rshift): + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emit_op_bitand): + (JSC::JIT::emitSlow_op_bitand): + (JSC::JIT::emit_op_post_inc): + (JSC::JIT::emitSlow_op_post_inc): + (JSC::JIT::emit_op_post_dec): + (JSC::JIT::emitSlow_op_post_dec): + (JSC::JIT::emit_op_pre_inc): + (JSC::JIT::emitSlow_op_pre_inc): + (JSC::JIT::emit_op_pre_dec): + (JSC::JIT::emitSlow_op_pre_dec): + (JSC::JIT::emit_op_mod): + (JSC::JIT::emitSlow_op_mod): + (JSC::JIT::emit_op_add): + (JSC::JIT::emit_op_mul): + (JSC::JIT::emit_op_sub): + (JSC::JIT::compileBinaryArithOpSlowCase): + (JSC::JIT::emitSlow_op_add): + (JSC::JIT::emitSlow_op_mul): + * jit/JITCall.cpp: + (JSC::JIT::compileOpCallInitializeCallFrame): + (JSC::JIT::compileOpConstructSetupArgs): + (JSC::JIT::compileOpCallVarargs): + (JSC::JIT::compileOpCall): + (JSC::JIT::compileOpCallSlowCase): + * jit/JITInlineMethods.h: + (JSC::JIT::getConstantOperandImmediateInt): + (JSC::JIT::isOperandConstantImmediateInt): + (JSC::JIT::emitInitRegister): + (JSC::JIT::addSlowCase): + (JSC::JIT::addJump): + (JSC::JIT::emitJumpSlowToHot): + (JSC::JIT::tagFor): + (JSC::JIT::payloadFor): + (JSC::JIT::emitLoad): + (JSC::JIT::emitLoadReturnValue): + (JSC::JIT::emitStore): + (JSC::JIT::emitStoreReturnValue): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_mov): + (JSC::JIT::emit_op_end): + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_loop): + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emit_op_get_global_var): + (JSC::JIT::emit_op_put_global_var): + (JSC::JIT::emit_op_get_scoped_var): + (JSC::JIT::emit_op_put_scoped_var): + (JSC::JIT::emit_op_tear_off_activation): + (JSC::JIT::emit_op_ret): + (JSC::JIT::emit_op_construct_verify): + (JSC::JIT::emit_op_to_primitive): + (JSC::JIT::emit_op_loop_if_true): + (JSC::JIT::emit_op_resolve_global): + (JSC::JIT::emit_op_not): + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emit_op_jeq_null): + (JSC::JIT::emit_op_jneq_null): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_unexpected_load): + (JSC::JIT::emit_op_eq): + (JSC::JIT::emit_op_bitnot): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emit_op_neq): + (JSC::JIT::emit_op_bitxor): + (JSC::JIT::emit_op_bitor): + (JSC::JIT::emit_op_throw): + (JSC::JIT::emit_op_next_pname): + (JSC::JIT::emit_op_push_scope): + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emit_op_push_new_scope): + (JSC::JIT::emit_op_catch): + (JSC::JIT::emit_op_switch_imm): + (JSC::JIT::emit_op_switch_char): + (JSC::JIT::emit_op_switch_string): + (JSC::JIT::emit_op_new_error): + (JSC::JIT::emit_op_eq_null): + (JSC::JIT::emit_op_neq_null): + (JSC::JIT::emit_op_convert_this): + (JSC::JIT::emit_op_profile_will_call): + (JSC::JIT::emit_op_profile_did_call): + (JSC::JIT::emitSlow_op_construct_verify): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emitSlow_op_loop_if_less): + (JSC::JIT::emitSlow_op_loop_if_lesseq): + (JSC::JIT::emitSlow_op_put_by_val): + (JSC::JIT::emitSlow_op_not): + (JSC::JIT::emitSlow_op_instanceof): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emit_op_put_by_index): + (JSC::JIT::emit_op_put_getter): + (JSC::JIT::emit_op_put_setter): + (JSC::JIT::emit_op_del_by_id): + (JSC::JIT::compileGetByIdHotPath): + (JSC::JIT::compilePutByIdHotPath): + * jit/JITStubCall.h: + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::addArgument): + (JSC::JITStubCall::call): + (JSC::JITStubCall::): + (JSC::CallEvalJITStub::CallEvalJITStub): + * jit/JITStubs.cpp: + (JSC::): + (JSC::JITStubs::cti_op_add): + (JSC::JITStubs::cti_op_pre_inc): + (JSC::JITStubs::cti_op_mul): + (JSC::JITStubs::cti_op_get_by_val): + (JSC::JITStubs::cti_op_get_by_val_string): + (JSC::JITStubs::cti_op_get_by_val_byte_array): + (JSC::JITStubs::cti_op_sub): + (JSC::JITStubs::cti_op_put_by_val): + (JSC::JITStubs::cti_op_put_by_val_array): + (JSC::JITStubs::cti_op_put_by_val_byte_array): + (JSC::JITStubs::cti_op_negate): + (JSC::JITStubs::cti_op_div): + (JSC::JITStubs::cti_op_pre_dec): + (JSC::JITStubs::cti_op_post_inc): + (JSC::JITStubs::cti_op_eq): + (JSC::JITStubs::cti_op_lshift): + (JSC::JITStubs::cti_op_bitand): + (JSC::JITStubs::cti_op_rshift): + (JSC::JITStubs::cti_op_bitnot): + (JSC::JITStubs::cti_op_mod): + (JSC::JITStubs::cti_op_neq): + (JSC::JITStubs::cti_op_post_dec): + (JSC::JITStubs::cti_op_urshift): + (JSC::JITStubs::cti_op_bitxor): + (JSC::JITStubs::cti_op_bitor): + (JSC::JITStubs::cti_op_switch_imm): + * jit/JITStubs.h: + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): + * runtime/JSFunction.cpp: + (JSC::JSFunction::~JSFunction): + * runtime/JSValue.h: + (JSC::JSValue::payload): + * wtf/Platform.h: + +2009-05-07 Sam Weinig + + Reviewed by Geoffrey Garen. + + Add some new MacroAssembler and assembler functions that will be needed shortly. + + * assembler/MacroAssemblerX86Common.h: + (JSC::MacroAssemblerX86Common::add32): + (JSC::MacroAssemblerX86Common::and32): + (JSC::MacroAssemblerX86Common::mul32): + (JSC::MacroAssemblerX86Common::neg32): + (JSC::MacroAssemblerX86Common::or32): + (JSC::MacroAssemblerX86Common::sub32): + (JSC::MacroAssemblerX86Common::xor32): + (JSC::MacroAssemblerX86Common::branchAdd32): + (JSC::MacroAssemblerX86Common::branchMul32): + (JSC::MacroAssemblerX86Common::branchSub32): + * assembler/X86Assembler.h: + (JSC::X86Assembler::): + (JSC::X86Assembler::addl_rm): + (JSC::X86Assembler::andl_mr): + (JSC::X86Assembler::andl_rm): + (JSC::X86Assembler::andl_im): + (JSC::X86Assembler::negl_r): + (JSC::X86Assembler::notl_r): + (JSC::X86Assembler::orl_rm): + (JSC::X86Assembler::orl_im): + (JSC::X86Assembler::subl_rm): + (JSC::X86Assembler::xorl_mr): + (JSC::X86Assembler::xorl_rm): + (JSC::X86Assembler::xorl_im): + (JSC::X86Assembler::imull_mr): + +2009-05-11 Sam Weinig + + Reviewed by Cameron Zwarich. + + Remove the NumberHeap. + + * JavaScriptCore.exp: + * runtime/Collector.cpp: + (JSC::Heap::Heap): + (JSC::Heap::destroy): + (JSC::Heap::recordExtraCost): + (JSC::Heap::heapAllocate): + (JSC::Heap::markConservatively): + (JSC::Heap::sweep): + (JSC::Heap::collect): + (JSC::Heap::objectCount): + (JSC::Heap::statistics): + (JSC::typeName): + (JSC::Heap::isBusy): + * runtime/Collector.h: + (JSC::Heap::globalData): + * runtime/JSCell.h: + +2009-05-11 Geoffrey Garen + + Reviewed by Sam Weinig. + + Land initial commit of new number representation for 32 bit platforms, + with JIT disabled. + + * API/APICast.h: + (toJS): + (toRef): + * API/JSCallbackObjectFunctions.h: + (JSC::::hasInstance): + (JSC::::toNumber): + (JSC::::toString): + * API/tests/testapi.c: + (EvilExceptionObject_convertToType): + * AllInOneFile.cpp: + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * bytecode/CodeBlock.cpp: + (JSC::valueToSourceString): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitLoad): + (JSC::BytecodeGenerator::emitUnexpectedLoad): + (JSC::keyForImmediateSwitch): + * bytecompiler/BytecodeGenerator.h: + * interpreter/Interpreter.cpp: + (JSC::Interpreter::dumpRegisters): + (JSC::Interpreter::privateExecute): + * parser/Nodes.cpp: + (JSC::ArrayNode::emitBytecode): + (JSC::processClauseList): + * runtime/ArgList.h: + * runtime/Collector.h: + (JSC::sizeof): + * runtime/DateMath.cpp: + * runtime/ExceptionHelpers.h: + * runtime/InitializeThreading.cpp: + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): + * runtime/JSCell.cpp: + * runtime/JSCell.h: + (JSC::JSCell::isAPIValueWrapper): + (JSC::JSValue::isString): + (JSC::JSValue::isGetterSetter): + (JSC::JSValue::isObject): + (JSC::JSValue::getString): + (JSC::JSValue::getObject): + (JSC::JSValue::getCallData): + (JSC::JSValue::getConstructData): + (JSC::JSValue::getUInt32): + (JSC::JSValue::marked): + (JSC::JSValue::toPrimitive): + (JSC::JSValue::getPrimitiveNumber): + (JSC::JSValue::toBoolean): + (JSC::JSValue::toNumber): + (JSC::JSValue::toString): + (JSC::JSValue::needsThisConversion): + (JSC::JSValue::toThisString): + (JSC::JSValue::getJSNumber): + (JSC::JSValue::toObject): + (JSC::JSValue::toThisObject): + * runtime/JSGlobalData.cpp: + (JSC::JSGlobalData::JSGlobalData): + * runtime/JSGlobalData.h: + * runtime/JSGlobalObject.h: + (JSC::Structure::prototypeForLookup): + * runtime/JSGlobalObjectFunctions.cpp: + (JSC::globalFuncParseInt): + * runtime/JSImmediate.h: + * runtime/JSNumberCell.cpp: Removed. + * runtime/JSNumberCell.h: Removed. + * runtime/JSObject.h: + (JSC::JSValue::get): + (JSC::JSValue::put): + * runtime/JSString.h: + (JSC::JSValue::toThisJSString): + * runtime/JSValue.cpp: + (JSC::JSValue::toInteger): + (JSC::JSValue::toIntegerPreserveNaN): + (JSC::JSValue::toObjectSlowCase): + (JSC::JSValue::toThisObjectSlowCase): + (JSC::JSValue::synthesizeObject): + (JSC::JSValue::synthesizePrototype): + (JSC::JSValue::description): + (JSC::nonInlineNaN): + * runtime/JSValue.h: + (JSC::JSValue::): + (JSC::EncodedJSValueHashTraits::emptyValue): + (JSC::jsNaN): + (JSC::operator==): + (JSC::operator!=): + (JSC::toInt32): + (JSC::toUInt32): + (JSC::JSValue::encode): + (JSC::JSValue::decode): + (JSC::JSValue::JSValue): + (JSC::JSValue::operator bool): + (JSC::JSValue::operator==): + (JSC::JSValue::operator!=): + (JSC::JSValue::isUndefined): + (JSC::JSValue::isNull): + (JSC::JSValue::isUndefinedOrNull): + (JSC::JSValue::isCell): + (JSC::JSValue::isInt32): + (JSC::JSValue::isUInt32): + (JSC::JSValue::isDouble): + (JSC::JSValue::isTrue): + (JSC::JSValue::isFalse): + (JSC::JSValue::tag): + (JSC::JSValue::asInt32): + (JSC::JSValue::asUInt32): + (JSC::JSValue::asDouble): + (JSC::JSValue::asCell): + (JSC::JSValue::isNumber): + (JSC::JSValue::isBoolean): + (JSC::JSValue::getBoolean): + (JSC::JSValue::uncheckedGetNumber): + (JSC::JSValue::toJSNumber): + (JSC::JSValue::getNumber): + (JSC::JSValue::toInt32): + (JSC::JSValue::toUInt32): + * runtime/Operations.h: + (JSC::JSValue::equal): + (JSC::JSValue::equalSlowCaseInline): + (JSC::JSValue::strictEqual): + (JSC::JSValue::strictEqualSlowCaseInline): + (JSC::jsLess): + (JSC::jsLessEq): + (JSC::jsAdd): + * runtime/PropertySlot.h: + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncCharAt): + (JSC::stringProtoFuncCharCodeAt): + (JSC::stringProtoFuncIndexOf): + * wtf/Platform.h: + +=== Start merge of nitro-extreme branch 2009-07-30 === + +2009-07-29 Laszlo Gombos + + Reviewed by George Staikos. + + Resolve class/struct mixup in forward declarations + https://bugs.webkit.org/show_bug.cgi?id=27708 + + * API/JSClassRef.h: + * bytecode/SamplingTool.h: + * interpreter/Interpreter.h: + * jit/JIT.h: + * profiler/ProfileGenerator.h: + * profiler/Profiler.h: + * runtime/ClassInfo.h: + * runtime/ExceptionHelpers.h: + * runtime/JSByteArray.h: + * runtime/JSCell.h: + * runtime/JSFunction.h: + * runtime/JSGlobalData.h: + * runtime/JSObject.h: + * runtime/JSString.h: + +2009-07-28 Ada Chan + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=27236 + - Implement TCMalloc_SystemRelease and TCMalloc_SystemCommit for Windows. + - Use a background thread to periodically scavenge memory to release back to the system. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::init): + (WTF::TCMalloc_PageHeap::runScavengerThread): + (WTF::TCMalloc_PageHeap::scavenge): + (WTF::TCMalloc_PageHeap::shouldContinueScavenging): + (WTF::TCMalloc_PageHeap::New): + (WTF::TCMalloc_PageHeap::AllocLarge): + (WTF::TCMalloc_PageHeap::Delete): + (WTF::TCMalloc_PageHeap::GrowHeap): + (WTF::sleep): + (WTF::TCMalloc_PageHeap::scavengerThread): + * wtf/TCSystemAlloc.cpp: + (TCMalloc_SystemRelease): + (TCMalloc_SystemCommit): + * wtf/TCSystemAlloc.h: + +2009-07-28 Xan Lopez + + Add new files, fixes distcheck. + + * GNUmakefile.am: + +2009-07-28 Csaba Osztrogonac + + Reviewed by Simon Hausmann. + + [Qt] Determining whether to use JIT or interpreter + moved from JavaScriptCore.pri to Platform.h + + * JavaScriptCore.pri: + * wtf/Platform.h: + +2009-07-27 Brian Weinstein + + Fix of misuse of sort command. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-27 Brian Weinstein + + Build fix for Windows. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-27 Gavin Barraclough + + Rubber stamped by Oliver Hunt. + + Fix tyop in JIT, renamed preverveReturnAddressAfterCall -> preserveReturnAddressAfterCall. + + * jit/JIT.cpp: + (JSC::JIT::privateCompile): + (JSC::JIT::privateCompileCTIMachineTrampolines): + * jit/JIT.h: + * jit/JITInlineMethods.h: + (JSC::JIT::preserveReturnAddressAfterCall): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::privateCompilePutByIdTransition): + +2009-07-27 Alexey Proskuryakov + + Gtk build fix. + + * runtime/JSLock.cpp: (JSC::JSLock::JSLock): Fix "no threading" case. + +2009-07-27 Alexey Proskuryakov + + Release build fix. + + * runtime/JSLock.h: (JSC::JSLock::~JSLock): + +2009-07-27 Alexey Proskuryakov + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=27735 + Give a helpful name to JSLock constructor argument + + * API/JSBase.cpp: + (JSGarbageCollect): + * API/JSContextRef.cpp: + * API/JSObjectRef.cpp: + (JSPropertyNameArrayRelease): + (JSPropertyNameAccumulatorAddName): + * JavaScriptCore.exp: + * jsc.cpp: + (functionGC): + (cleanupGlobalData): + (jscmain): + * runtime/Collector.cpp: + (JSC::Heap::destroy): + * runtime/JSLock.cpp: + (JSC::JSLock::JSLock): + (JSC::JSLock::lock): + (JSC::JSLock::unlock): + (JSC::JSLock::DropAllLocks::DropAllLocks): + (JSC::JSLock::DropAllLocks::~DropAllLocks): + * runtime/JSLock.h: + (JSC::): + (JSC::JSLock::JSLock): + (JSC::JSLock::~JSLock): + +2009-07-25 Zoltan Horvath + + Reviewed by Eric Seidel. + + Allow custom memory allocation control for OpaqueJSPropertyNameArray struct + https://bugs.webkit.org/show_bug.cgi?id=27342 + + Inherits OpaqueJSPropertyNameArray struct from FastAllocBase because it has been + instantiated by 'new' JavaScriptCore/API/JSObjectRef.cpp:473. + + * API/JSObjectRef.cpp: + +2009-07-24 Ada Chan + + In preparation for https://bugs.webkit.org/show_bug.cgi?id=27236: + Remove TCMALLOC_TRACK_DECOMMITED_SPANS. We'll always track decommitted spans. + We have tested this and show it has little impact on performance. + + Reviewed by Mark Rowe. + + * wtf/FastMalloc.cpp: + (WTF::TCMalloc_PageHeap::New): + (WTF::TCMalloc_PageHeap::AllocLarge): + (WTF::propagateDecommittedState): + (WTF::mergeDecommittedStates): + (WTF::TCMalloc_PageHeap::Delete): + (WTF::TCMalloc_PageHeap::IncrementalScavenge): + +2009-07-24 Csaba Osztrogonac + + Reviewed by Darin Adler and Adam Barth. + + Build fix for x86 platforms. + https://bugs.webkit.org/show_bug.cgi?id=27602 + + * jit/JIT.cpp: + +2009-07-23 Kevin Ollivier + + wx build fix, adding missing header. + + * jit/JIT.cpp: + +2009-07-22 Yong Li + + Reviewed by George Staikos. + + Add wince specific memory files into wtf/wince + https://bugs.webkit.org/show_bug.cgi?id=27550 + + * wtf/wince/FastMallocWince.h: Added. + * wtf/wince/MemoryManager.cpp: Added. + * wtf/wince/MemoryManager.h: Added. + +2009-07-23 Norbert Leser + + Reviewed by Simon Hausmann. + + Fix for missing mmap features in Symbian + https://bugs.webkit.org/show_bug.cgi?id=24540 + + Fix, conditionally for PLATFORM(SYMBIAN), as an alternative + to missing support for the MAP_ANON property flag in mmap. + It utilizes Symbian specific memory allocation features. + + * runtime/Collector.cpp + +2009-07-22 Gavin Barraclough + + Reviewed by Sam Weinig. + + With ENABLE(ASSEMBLER_WX_EXCLUSIVE), only change permissions once per repatch event. + ( https://bugs.webkit.org/show_bug.cgi?id=27564 ) + + Currently we change permissions forwards and backwards for each instruction modified, + instead we should only change permissions once per complete repatching event. + + 2.5% progression running with ENABLE(ASSEMBLER_WX_EXCLUSIVE) enabled, + which recoups 1/3 of the penalty of running with this mode enabled. + + * assembler/ARMAssembler.cpp: + (JSC::ARMAssembler::linkBranch): + - Replace usage of MakeWritable with cacheFlush. + + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::patchPointerInternal): + (JSC::ARMAssembler::repatchLoadPtrToLEA): + - Replace usage of MakeWritable with cacheFlush. + + * assembler/ARMv7Assembler.h: + (JSC::ARMv7Assembler::relinkJump): + (JSC::ARMv7Assembler::relinkCall): + (JSC::ARMv7Assembler::repatchInt32): + (JSC::ARMv7Assembler::repatchPointer): + (JSC::ARMv7Assembler::repatchLoadPtrToLEA): + (JSC::ARMv7Assembler::setInt32): + - Replace usage of MakeWritable with cacheFlush. + + * assembler/LinkBuffer.h: + (JSC::LinkBuffer::performFinalization): + - Make explicit call to cacheFlush. + + * assembler/MacroAssemblerCodeRef.h: + (JSC::MacroAssemblerCodeRef::MacroAssemblerCodeRef): + - Make size always available. + + * assembler/RepatchBuffer.h: + (JSC::RepatchBuffer::RepatchBuffer): + (JSC::RepatchBuffer::~RepatchBuffer): + - Add calls to MakeWritable & makeExecutable. + + * assembler/X86Assembler.h: + (JSC::X86Assembler::relinkJump): + (JSC::X86Assembler::relinkCall): + (JSC::X86Assembler::repatchInt32): + (JSC::X86Assembler::repatchPointer): + (JSC::X86Assembler::repatchLoadPtrToLEA): + - Remove usage of MakeWritable. + + * bytecode/CodeBlock.h: + (JSC::CodeBlock::getJITCode): + - Provide access to CodeBlock's JITCode. + + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::makeExecutable): + (JSC::ExecutableAllocator::cacheFlush): + - Remove MakeWritable, make cacheFlush public. + + * jit/JIT.cpp: + (JSC::ctiPatchNearCallByReturnAddress): + (JSC::ctiPatchCallByReturnAddress): + (JSC::JIT::privateCompile): + (JSC::JIT::unlinkCall): + (JSC::JIT::linkCall): + - Add CodeBlock argument to RepatchBuffer. + + * jit/JIT.h: + - Pass CodeBlock argument for use by RepatchBuffer. + + * jit/JITCode.h: + (JSC::JITCode::start): + (JSC::JITCode::size): + - Provide access to code start & size. + + * jit/JITPropertyAccess.cpp: + (JSC::JIT::privateCompilePutByIdTransition): + (JSC::JIT::patchGetByIdSelf): + (JSC::JIT::patchMethodCallProto): + (JSC::JIT::patchPutByIdReplace): + (JSC::JIT::privateCompilePatchGetArrayLength): + (JSC::JIT::privateCompileGetByIdProto): + (JSC::JIT::privateCompileGetByIdSelfList): + (JSC::JIT::privateCompileGetByIdProtoList): + (JSC::JIT::privateCompileGetByIdChainList): + (JSC::JIT::privateCompileGetByIdChain): + - Add CodeBlock argument to RepatchBuffer. + + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): + (JSC::JITStubs::DEFINE_STUB_FUNCTION): + - Pass CodeBlock argument for use by RepatchBuffer. + +2009-07-21 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + Cache not only the structure of the method, but the + structure of its prototype as well. + https://bugs.webkit.org/show_bug.cgi?id=27077 + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::~CodeBlock): + * bytecode/CodeBlock.h: + (JSC::MethodCallLinkInfo::MethodCallLinkInfo): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::patchMethodCallProto): + +2009-07-21 Gavin Barraclough + + Reviewed by Sam Weinig. + + Move call linking / repatching down from AbstractMacroAssembler into MacroAssemblerARCH classes. + ( https://bugs.webkit.org/show_bug.cgi?id=27527 ) + + This allows the implementation to be defined per architecture. Specifically this addresses the + fact that x86-64 MacroAssembler implements far calls as a load to register, followed by a call + to register. Patching the call actually requires the pointer load to be patched, rather than + the call to be patched. This is implementation detail specific to MacroAssemblerX86_64, and as + such is best handled there. + + * assembler/AbstractMacroAssembler.h: + * assembler/MacroAssemblerARM.h: + (JSC::MacroAssemblerARM::linkCall): + (JSC::MacroAssemblerARM::repatchCall): + * assembler/MacroAssemblerARMv7.h: + (JSC::MacroAssemblerARMv7::linkCall): + (JSC::MacroAssemblerARMv7::repatchCall): + * assembler/MacroAssemblerX86.h: + (JSC::MacroAssemblerX86::linkCall): + (JSC::MacroAssemblerX86::repatchCall): + * assembler/MacroAssemblerX86_64.h: + (JSC::MacroAssemblerX86_64::linkCall): + (JSC::MacroAssemblerX86_64::repatchCall): + +2009-07-21 Adam Treat + + Reviewed by George Staikos. + + Every wtf file includes other wtf files with <> style includes + except this one. Fix the exception. + + * wtf/ByteArray.h: + +2009-07-21 Gavin Barraclough + + Reviewed by Oliver Hunt. + + Move LinkBuffer/RepatchBuffer out of AbstractMacroAssembler. + ( https://bugs.webkit.org/show_bug.cgi?id=27485 ) + + This change is the first step in a process to move code that should be in + the architecture-specific MacroAssembler classes up out of Assmbler and + AbstractMacroAssembler. + + * JavaScriptCore.xcodeproj/project.pbxproj: + - added new files + + * assembler/ARMAssembler.h: + (JSC::ARMAssembler::linkPointer): + - rename patchPointer to bring it in line with the current link/repatch naming scheme + + * assembler/ARMv7Assembler.h: + (JSC::ARMv7Assembler::linkCall): + (JSC::ARMv7Assembler::linkPointer): + (JSC::ARMv7Assembler::relinkCall): + (JSC::ARMv7Assembler::repatchInt32): + (JSC::ARMv7Assembler::repatchPointer): + (JSC::ARMv7Assembler::setInt32): + (JSC::ARMv7Assembler::setPointer): + - rename patchPointer to bring it in line with the current link/repatch naming scheme + + * assembler/AbstractMacroAssembler.h: + (JSC::AbstractMacroAssembler::linkJump): + (JSC::AbstractMacroAssembler::linkCall): + (JSC::AbstractMacroAssembler::linkPointer): + (JSC::AbstractMacroAssembler::getLinkerAddress): + (JSC::AbstractMacroAssembler::getLinkerCallReturnOffset): + (JSC::AbstractMacroAssembler::repatchJump): + (JSC::AbstractMacroAssembler::repatchCall): + (JSC::AbstractMacroAssembler::repatchNearCall): + (JSC::AbstractMacroAssembler::repatchInt32): + (JSC::AbstractMacroAssembler::repatchPointer): + (JSC::AbstractMacroAssembler::repatchLoadPtrToLEA): + - remove the LinkBuffer/RepatchBuffer classes, but leave a set of (private, friended) methods to interface to the Assembler + + * assembler/LinkBuffer.h: Added. + (JSC::LinkBuffer::LinkBuffer): + (JSC::LinkBuffer::~LinkBuffer): + (JSC::LinkBuffer::link): + (JSC::LinkBuffer::patch): + (JSC::LinkBuffer::locationOf): + (JSC::LinkBuffer::locationOfNearCall): + (JSC::LinkBuffer::returnAddressOffset): + (JSC::LinkBuffer::finalizeCode): + (JSC::LinkBuffer::finalizeCodeAddendum): + (JSC::LinkBuffer::code): + (JSC::LinkBuffer::performFinalization): + - new file containing the LinkBuffer class, previously a member of AbstractMacroAssembler + + * assembler/RepatchBuffer.h: Added. + (JSC::RepatchBuffer::RepatchBuffer): + (JSC::RepatchBuffer::relink): + (JSC::RepatchBuffer::repatch): + (JSC::RepatchBuffer::repatchLoadPtrToLEA): + (JSC::RepatchBuffer::relinkCallerToTrampoline): + (JSC::RepatchBuffer::relinkCallerToFunction): + (JSC::RepatchBuffer::relinkNearCallerToTrampoline): + - new file containing the RepatchBuffer class, previously a member of AbstractMacroAssembler + + * assembler/X86Assembler.h: + (JSC::X86Assembler::linkJump): + (JSC::X86Assembler::linkCall): + (JSC::X86Assembler::linkPointerForCall): + (JSC::X86Assembler::linkPointer): + (JSC::X86Assembler::relinkJump): + (JSC::X86Assembler::relinkCall): + (JSC::X86Assembler::repatchInt32): + (JSC::X86Assembler::repatchPointer): + (JSC::X86Assembler::setPointer): + (JSC::X86Assembler::setInt32): + (JSC::X86Assembler::setRel32): + - rename patchPointer to bring it in line with the current link/repatch naming scheme + + * jit/JIT.cpp: + (JSC::ctiPatchNearCallByReturnAddress): + (JSC::ctiPatchCallByReturnAddress): + - include new headers + - remove MacroAssembler:: specification from RepatchBuffer usage + + * jit/JITPropertyAccess.cpp: + * yarr/RegexJIT.cpp: + - include new headers + +2009-07-21 Robert Agoston + + Reviewed by David Levin. + + Fixed #undef typo. + https://bugs.webkit.org/show_bug.cgi?id=27506 + + * bytecode/Opcode.h: + +2009-07-21 Adam Roben + + Roll out r46153, r46154, and r46155 + + These changes were causing build failures and assertion failures on + Windows. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/JSArray.cpp: + * runtime/StringPrototype.cpp: + * runtime/UString.cpp: + * runtime/UString.h: + * wtf/FastMalloc.cpp: + * wtf/FastMalloc.h: + * wtf/Platform.h: + * wtf/PossiblyNull.h: Removed. + +2009-07-21 Roland Steiner + + Reviewed by David Levin. + + Add ENABLE_RUBY to list of build options + https://bugs.webkit.org/show_bug.cgi?id=27324 + + * Configurations/FeatureDefines.xcconfig: Added flag ENABLE_RUBY. + +2009-07-20 Oliver Hunt + + Build fix attempt #2 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-20 Oliver Hunt + + Build fix attempt #1 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-07-20 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Make it harder to misuse try* allocation routines + https://bugs.webkit.org/show_bug.cgi?id=27469 + + Jump through a few hoops to make it much harder to accidentally + miss null-checking of values returned by the try-* allocation + routines. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/JSArray.cpp: + (JSC::JSArray::putSlowCase): + (JSC::JSArray::increaseVectorLength): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncFontsize): + (JSC::stringProtoFuncLink): + * runtime/UString.cpp: + (JSC::allocChars): + (JSC::reallocChars): + (JSC::expandCapacity): + (JSC::UString::Rep::reserveCapacity): + (JSC::UString::expandPreCapacity): + (JSC::createRep): + (JSC::concatenate): + (JSC::UString::spliceSubstringsWithSeparators): + (JSC::UString::replaceRange): + (JSC::UString::append): + (JSC::UString::operator=): + * runtime/UString.h: + (JSC::UString::Rep::createEmptyBuffer): + * wtf/FastMalloc.cpp: + (WTF::tryFastZeroedMalloc): + (WTF::tryFastMalloc): + (WTF::tryFastCalloc): + (WTF::tryFastRealloc): + (WTF::TCMallocStats::tryFastMalloc): + (WTF::TCMallocStats::tryFastCalloc): + (WTF::TCMallocStats::tryFastRealloc): + * wtf/FastMalloc.h: + (WTF::TryMallocReturnValue::TryMallocReturnValue): + (WTF::TryMallocReturnValue::~TryMallocReturnValue): + (WTF::TryMallocReturnValue::operator Maybe): + (WTF::TryMallocReturnValue::getValue): + * wtf/PossiblyNull.h: + (WTF::PossiblyNull::PossiblyNull): + (WTF::PossiblyNull::~PossiblyNull): + (WTF::PossiblyNull::getValue): + * wtf/Platform.h: + +2009-07-20 Gavin Barraclough + + RS Oliver Hunt. + + Add ARM assembler files to xcodeproj, for convenience editing. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-07-20 Jessie Berlin + + Reviewed by David Levin. + + Fix an incorrect assertion in Vector::remove. + + https://bugs.webkit.org/show_bug.cgi?id=27477 + + * wtf/Vector.h: + (WTF::::remove): + Assert that the position at which to start removing elements + the + length (the number of elements to remove) is less than or equal to the + size of the entire Vector. + +2009-07-20 Peter Kasting + + Reviewed by Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=27468 + Back out r46060, which caused problems for some Apple developers. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: + * JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: + +2009-07-20 Zoltan Horvath + + Reviewed by Oliver Hunt. + + Allow custom memory allocation control in NewThreadContext + https://bugs.webkit.org/show_bug.cgi?id=27338 + + Inherits NewThreadContext struct from FastAllocBase because it + has been instantiated by 'new' JavaScriptCore/wtf/Threading.cpp:76. + + * wtf/Threading.cpp: + +2009-07-20 Zoltan Horvath + + Reviewed by Oliver Hunt. + + Allow custom memory allocation control in JavaScriptCore's JSClassRef.h + https://bugs.webkit.org/show_bug.cgi?id=27340 + + Inherit StaticValueEntry and StaticFunctionEntry struct from FastAllocBase because these + have been instantiated by 'new' in JavaScriptCore/API/JSClassRef.cpp:153 + and in JavaScriptCore/API/JSClassRef.cpp:166. + + * API/JSClassRef.h: + +2009-07-20 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control in JavaScriptCore's RegexPattern.h + https://bugs.webkit.org/show_bug.cgi?id=27343 + + Inherits RegexPattern.h's structs (which have been instantiated by operator new) from FastAllocBase: + + CharacterClass (new call: JavaScriptCore/yarr/RegexCompiler.cpp:144) + PatternAlternative (new call: JavaScriptCore/yarr/RegexPattern.h:221) + PatternDisjunction (new call: JavaScriptCore/yarr/RegexCompiler.cpp:446) + + * yarr/RegexPattern.h: + +2009-07-20 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's MatchFrame struct + https://bugs.webkit.org/show_bug.cgi?id=27344 + + Inherits MatchFrame struct from FastAllocBase because it has + been instantiated by 'new' JavaScriptCore/pcre/pcre_exec.cpp:359. + + * pcre/pcre_exec.cpp: + +2009-07-20 Laszlo Gombos + + Reviewed by Holger Freyther. + + Remove some outdated S60 platform specific code + https://bugs.webkit.org/show_bug.cgi?id=27423 + + * wtf/Platform.h: + +2009-07-20 Csaba Osztrogonac + + Reviewed by Simon Hausmann. + + Qt build fix with MSVC and MinGW. + + * jsc.pro: Make sure jsc is a console application, and turn off + exceptions and stl support to fix the build. + +2009-07-20 Xan Lopez + + Reviewed by Gustavo Noronha. + + Do not use C++-style comments in preprocessor directives. + + GCC does not like this in some configurations, using C-style + comments is safer. + + * wtf/Platform.h: + +2009-07-17 Peter Kasting + + Reviewed by Steve Falkenburg. + + https://bugs.webkit.org/show_bug.cgi?id=27323 + Only add Cygwin to the path when it isn't already there. This avoids + causing problems for people who purposefully have non-Cygwin versions of + executables like svn in front of the Cygwin ones in their paths. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: + * JavaScriptCore.vcproj/WTF/WTFCommon.vsprops: + * JavaScriptCore.vcproj/jsc/jscCommon.vsprops: + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: + +2009-07-17 Gabor Loki + + Reviewed by Gavin Barraclough. + + Add YARR support for generic ARM platforms (disabled by default). + https://bugs.webkit.org/show_bug.cgi?id=24986 + + Add generic ARM port for MacroAssembler. It supports the whole + MacroAssembler functionality except floating point. + + The class JmpSrc is extended with a flag which enables to patch + the jump destination offset during execution. This feature is + required for generic ARM port. + + Signed off by Zoltan Herczeg + Signed off by Gabor Loki + + * JavaScriptCore.pri: + * assembler/ARMAssembler.cpp: Added. + (JSC::ARMAssembler::getLdrImmAddress): + (JSC::ARMAssembler::linkBranch): + (JSC::ARMAssembler::patchConstantPoolLoad): + (JSC::ARMAssembler::getOp2): + (JSC::ARMAssembler::genInt): + (JSC::ARMAssembler::getImm): + (JSC::ARMAssembler::moveImm): + (JSC::ARMAssembler::dataTransfer32): + (JSC::ARMAssembler::baseIndexTransfer32): + (JSC::ARMAssembler::executableCopy): + * assembler/ARMAssembler.h: Added. + (JSC::ARM::): + (JSC::ARMAssembler::ARMAssembler): + (JSC::ARMAssembler::): + (JSC::ARMAssembler::JmpSrc::JmpSrc): + (JSC::ARMAssembler::JmpSrc::enableLatePatch): + (JSC::ARMAssembler::JmpDst::JmpDst): + (JSC::ARMAssembler::JmpDst::isUsed): + (JSC::ARMAssembler::JmpDst::used): + (JSC::ARMAssembler::emitInst): + (JSC::ARMAssembler::and_r): + (JSC::ARMAssembler::ands_r): + (JSC::ARMAssembler::eor_r): + (JSC::ARMAssembler::eors_r): + (JSC::ARMAssembler::sub_r): + (JSC::ARMAssembler::subs_r): + (JSC::ARMAssembler::rsb_r): + (JSC::ARMAssembler::rsbs_r): + (JSC::ARMAssembler::add_r): + (JSC::ARMAssembler::adds_r): + (JSC::ARMAssembler::adc_r): + (JSC::ARMAssembler::adcs_r): + (JSC::ARMAssembler::sbc_r): + (JSC::ARMAssembler::sbcs_r): + (JSC::ARMAssembler::rsc_r): + (JSC::ARMAssembler::rscs_r): + (JSC::ARMAssembler::tst_r): + (JSC::ARMAssembler::teq_r): + (JSC::ARMAssembler::cmp_r): + (JSC::ARMAssembler::orr_r): + (JSC::ARMAssembler::orrs_r): + (JSC::ARMAssembler::mov_r): + (JSC::ARMAssembler::movs_r): + (JSC::ARMAssembler::bic_r): + (JSC::ARMAssembler::bics_r): + (JSC::ARMAssembler::mvn_r): + (JSC::ARMAssembler::mvns_r): + (JSC::ARMAssembler::mul_r): + (JSC::ARMAssembler::muls_r): + (JSC::ARMAssembler::mull_r): + (JSC::ARMAssembler::ldr_imm): + (JSC::ARMAssembler::ldr_un_imm): + (JSC::ARMAssembler::dtr_u): + (JSC::ARMAssembler::dtr_ur): + (JSC::ARMAssembler::dtr_d): + (JSC::ARMAssembler::dtr_dr): + (JSC::ARMAssembler::ldrh_r): + (JSC::ARMAssembler::ldrh_d): + (JSC::ARMAssembler::ldrh_u): + (JSC::ARMAssembler::strh_r): + (JSC::ARMAssembler::push_r): + (JSC::ARMAssembler::pop_r): + (JSC::ARMAssembler::poke_r): + (JSC::ARMAssembler::peek_r): + (JSC::ARMAssembler::clz_r): + (JSC::ARMAssembler::bkpt): + (JSC::ARMAssembler::lsl): + (JSC::ARMAssembler::lsr): + (JSC::ARMAssembler::asr): + (JSC::ARMAssembler::lsl_r): + (JSC::ARMAssembler::lsr_r): + (JSC::ARMAssembler::asr_r): + (JSC::ARMAssembler::size): + (JSC::ARMAssembler::ensureSpace): + (JSC::ARMAssembler::label): + (JSC::ARMAssembler::align): + (JSC::ARMAssembler::jmp): + (JSC::ARMAssembler::patchPointerInternal): + (JSC::ARMAssembler::patchConstantPoolLoad): + (JSC::ARMAssembler::patchPointer): + (JSC::ARMAssembler::repatchInt32): + (JSC::ARMAssembler::repatchPointer): + (JSC::ARMAssembler::repatchLoadPtrToLEA): + (JSC::ARMAssembler::linkJump): + (JSC::ARMAssembler::relinkJump): + (JSC::ARMAssembler::linkCall): + (JSC::ARMAssembler::relinkCall): + (JSC::ARMAssembler::getRelocatedAddress): + (JSC::ARMAssembler::getDifferenceBetweenLabels): + (JSC::ARMAssembler::getCallReturnOffset): + (JSC::ARMAssembler::getOp2Byte): + (JSC::ARMAssembler::placeConstantPoolBarrier): + (JSC::ARMAssembler::RM): + (JSC::ARMAssembler::RS): + (JSC::ARMAssembler::RD): + (JSC::ARMAssembler::RN): + (JSC::ARMAssembler::getConditionalField): + * assembler/ARMv7Assembler.h: + (JSC::ARMv7Assembler::JmpSrc::enableLatePatch): + * assembler/AbstractMacroAssembler.h: + (JSC::AbstractMacroAssembler::Call::enableLatePatch): + (JSC::AbstractMacroAssembler::Jump::enableLatePatch): + * assembler/MacroAssembler.h: + * assembler/MacroAssemblerARM.h: Added. + (JSC::MacroAssemblerARM::): + (JSC::MacroAssemblerARM::add32): + (JSC::MacroAssemblerARM::and32): + (JSC::MacroAssemblerARM::lshift32): + (JSC::MacroAssemblerARM::mul32): + (JSC::MacroAssemblerARM::not32): + (JSC::MacroAssemblerARM::or32): + (JSC::MacroAssemblerARM::rshift32): + (JSC::MacroAssemblerARM::sub32): + (JSC::MacroAssemblerARM::xor32): + (JSC::MacroAssemblerARM::load32): + (JSC::MacroAssemblerARM::load32WithAddressOffsetPatch): + (JSC::MacroAssemblerARM::loadPtrWithPatchToLEA): + (JSC::MacroAssemblerARM::load16): + (JSC::MacroAssemblerARM::store32WithAddressOffsetPatch): + (JSC::MacroAssemblerARM::store32): + (JSC::MacroAssemblerARM::pop): + (JSC::MacroAssemblerARM::push): + (JSC::MacroAssemblerARM::move): + (JSC::MacroAssemblerARM::swap): + (JSC::MacroAssemblerARM::signExtend32ToPtr): + (JSC::MacroAssemblerARM::zeroExtend32ToPtr): + (JSC::MacroAssemblerARM::branch32): + (JSC::MacroAssemblerARM::branch16): + (JSC::MacroAssemblerARM::branchTest32): + (JSC::MacroAssemblerARM::jump): + (JSC::MacroAssemblerARM::branchAdd32): + (JSC::MacroAssemblerARM::mull32): + (JSC::MacroAssemblerARM::branchMul32): + (JSC::MacroAssemblerARM::branchSub32): + (JSC::MacroAssemblerARM::breakpoint): + (JSC::MacroAssemblerARM::nearCall): + (JSC::MacroAssemblerARM::call): + (JSC::MacroAssemblerARM::ret): + (JSC::MacroAssemblerARM::set32): + (JSC::MacroAssemblerARM::setTest32): + (JSC::MacroAssemblerARM::tailRecursiveCall): + (JSC::MacroAssemblerARM::makeTailRecursiveCall): + (JSC::MacroAssemblerARM::moveWithPatch): + (JSC::MacroAssemblerARM::branchPtrWithPatch): + (JSC::MacroAssemblerARM::storePtrWithPatch): + (JSC::MacroAssemblerARM::supportsFloatingPoint): + (JSC::MacroAssemblerARM::supportsFloatingPointTruncate): + (JSC::MacroAssemblerARM::loadDouble): + (JSC::MacroAssemblerARM::storeDouble): + (JSC::MacroAssemblerARM::addDouble): + (JSC::MacroAssemblerARM::subDouble): + (JSC::MacroAssemblerARM::mulDouble): + (JSC::MacroAssemblerARM::convertInt32ToDouble): + (JSC::MacroAssemblerARM::branchDouble): + (JSC::MacroAssemblerARM::branchTruncateDoubleToInt32): + (JSC::MacroAssemblerARM::ARMCondition): + (JSC::MacroAssemblerARM::prepareCall): + (JSC::MacroAssemblerARM::call32): + * assembler/X86Assembler.h: + (JSC::X86Assembler::JmpSrc::enableLatePatch): + * jit/ExecutableAllocator.h: + (JSC::ExecutableAllocator::cacheFlush): + * wtf/Platform.h: + * yarr/RegexJIT.cpp: + (JSC::Yarr::RegexGenerator::generateEnter): + (JSC::Yarr::RegexGenerator::generateReturn): + +2009-07-17 Gabor Loki + + Reviewed by Gavin Barraclough. + + Extend AssemblerBuffer with constant pool handling mechanism. + https://bugs.webkit.org/show_bug.cgi?id=24986 + + Add a platform independed constant pool framework. + This pool can store 32 or 64 bits values which is enough to hold + any integer, pointer or double constant. + + * assembler/AssemblerBuffer.h: + (JSC::AssemblerBuffer::putIntUnchecked): + (JSC::AssemblerBuffer::putInt64Unchecked): + (JSC::AssemblerBuffer::append): + (JSC::AssemblerBuffer::grow): + * assembler/AssemblerBufferWithConstantPool.h: Added. + (JSC::): + +2009-07-17 Eric Roman + + Reviewed by Darin Adler. + + Build fix for non-Darwin. + Add a guard for inclusion of RetainPtr.h which includes CoreFoundation.h + + https://bugs.webkit.org/show_bug.cgi?id=27382 + + * wtf/unicode/icu/CollatorICU.cpp: + +2009-07-17 Alexey Proskuryakov + + Reviewed by John Sullivan. + + Get user default collation order via a CFLocale API when available. + + * wtf/unicode/icu/CollatorICU.cpp: (WTF::Collator::userDefault): + +2009-07-17 Laszlo Gombos + + Reviewed by Simon Hausmann. + + [Qt] Fix the include path for the Symbian port + https://bugs.webkit.org/show_bug.cgi?id=27358 + + * JavaScriptCore.pri: + +2009-07-17 Csaba Osztrogonac + + Reviewed by David Levin. + + Build fix on platforms don't have MMAP. + https://bugs.webkit.org/show_bug.cgi?id=27365 + + * interpreter/RegisterFile.h: Including stdio.h irrespectively of HAVE(MMAP) + +2009-07-16 Fumitoshi Ukai + + Reviewed by David Levin. + + Add --web-sockets flag and ENABLE_WEB_SOCKETS define. + https://bugs.webkit.org/show_bug.cgi?id=27206 + + Add ENABLE_WEB_SOCKETS + + * Configurations/FeatureDefines.xcconfig: add ENABLE_WEB_SOCKETS + +2009-07-16 Maxime Simon + + Reviewed by Eric Seidel. + + Added Haiku-specific files for JavaScriptCore. + https://bugs.webkit.org/show_bug.cgi?id=26620 + + * wtf/haiku/MainThreadHaiku.cpp: Added. + (WTF::initializeMainThreadPlatform): + (WTF::scheduleDispatchFunctionsOnMainThread): + +2009-07-16 Gavin Barraclough + + RS by Oliver Hunt. + + Revert r45969, this fix does not appear to be valid. + https://bugs.webkit.org/show_bug.cgi?id=27077 + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::~CodeBlock): + (JSC::CodeBlock::unlinkCallers): + * jit/JIT.cpp: + * jit/JIT.h: + +2009-07-16 Zoltan Horvath + + Reviewed by Oliver Hunt. + + Allow custom memory allocation control in ExceptionInfo and RareData struct + https://bugs.webkit.org/show_bug.cgi?id=27336 + + Inherits ExceptionInfo and RareData struct from FastAllocBase because these + have been instantiated by 'new' in JavaScriptCore/bytecode/CodeBlock.cpp:1289 and + in JavaScriptCore/bytecode/CodeBlock.h:453. + + Remove unnecessary WTF:: namespace from CodeBlock inheritance. + + * bytecode/CodeBlock.h: + +2009-07-16 Mark Rowe + + Rubber-stamped by Geoff Garen. + + Fix FeatureDefines.xcconfig to not be out of sync with the rest of the world. + + * Configurations/FeatureDefines.xcconfig: + +2009-07-16 Yong Li + + Reviewed by George Staikos. + + https://bugs.webkit.org/show_bug.cgi?id=27320 + _countof is only included in CE6; for CE5 we need to define it ourself + + * wtf/Platform.h: + +2009-07-16 Zoltan Herczeg + + Reviewed by Oliver Hunt. + + Workers + garbage collector: weird crashes + https://bugs.webkit.org/show_bug.cgi?id=27077 + + We need to unlink cached method call sites when a function is destroyed. + + * JavaScriptCore.xcodeproj/project.pbxproj: + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::~CodeBlock): + (JSC::CodeBlock::unlinkCallers): + * jit/JIT.cpp: + (JSC::JIT::unlinkMethodCall): + * jit/JIT.h: + +2009-07-15 Steve Falkenburg + + Windows Build fix. + + Visual Studio reset our intermediate directory on us. + This sets it back. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + +2009-07-15 Kwang Yul Seo + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=26794 + Make Yacc-generated parsers to use fastMalloc/fastFree. + + Define YYMALLOC and YYFREE to fastMalloc and fastFree + respectively. + + * parser/Grammar.y: + +2009-07-15 Darin Adler + + Fix a build for a particular Apple configuration. + + * wtf/FastAllocBase.h: Change include to use "" style for + including another wtf header. This is the style we use for + including other public headers in the same directory. + +2009-07-15 George Staikos + + Reviewed by Adam Treat. + + https://bugs.webkit.org/show_bug.cgi?id=27303 + Implement createThreadInternal for WinCE. + Contains changes by George Staikos and Joe Mason + + * wtf/ThreadingWin.cpp: + (WTF::createThreadInternal): + +2009-07-15 Joe Mason + + Reviewed by George Staikos. + + https://bugs.webkit.org/show_bug.cgi?id=27298 + Platform defines for WINCE. + Contains changes by Yong Li , + George Staikos and Joe Mason + + * wtf/Platform.h: + +2009-07-15 Yong Li + + Reviewed by Adam Treat. + + https://bugs.webkit.org/show_bug.cgi?id=27306 + Use RegisterClass instead of RegisterClassEx on WinCE. + + * wtf/win/MainThreadWin.cpp: + (WTF::initializeMainThreadPlatform): + +2009-07-15 Yong Li + + Reviewed by George Staikos. + + https://bugs.webkit.org/show_bug.cgi?id=27301 + Use OutputDebugStringW on WinCE since OutputDebugStringA is not supported + Originally written by Yong Li and refactored by + Joe Mason + + * wtf/Assertions.cpp: vprintf_stderr_common + +2009-07-15 Yong Li + + Reviewed by George Staikos. + + https://bugs.webkit.org/show_bug.cgi?id=27020 + msToGregorianDateTime should set utcOffset to 0 when outputIsUTC is false + + * wtf/DateMath.cpp: + (WTF::gregorianDateTimeToMS): + +2009-07-15 Laszlo Gombos + + Reviewed by Simon Hausmann. + + [Qt] Cleanup - Remove obsolete code from the make system + https://bugs.webkit.org/show_bug.cgi?id=27299 + + * JavaScriptCore.pro: + * jsc.pro: + +2009-07-07 Norbert Leser + + Reviewed by Simon Hausmann. + + https://bugs.webkit.org/show_bug.cgi?id=27056 + + Alternate bool operator for codewarrior compiler (WINSCW). + Compiler (latest b482) reports error for UnspecifiedBoolType construct: + "illegal explicit conversion from 'WTF::OwnArrayPtr' to 'bool'" + + Same fix as in r38391. + + * JavaScriptCore/wtf/OwnArrayPtr.h: + +2009-07-15 Norbert Leser + + Reviewed by Darin Adler. + + Qualify include path with wtf to fix compilation + on Symbian. + https://bugs.webkit.org/show_bug.cgi?id=27055 + + * interpreter/Interpreter.h: + +2009-07-15 Laszlo Gombos + + Reviewed by Dave Kilzer. + + Turn off non-portable date manipulations for SYMBIAN + https://bugs.webkit.org/show_bug.cgi?id=27064 + + Introduce HAVE(TM_GMTOFF), HAVE(TM_ZONE) and HAVE(TIMEGM) guards + and place the rules for controlling the guards in Platform.h. + Turn off these newly introduced guards for SYMBIAN. + + * wtf/DateMath.cpp: + (WTF::calculateUTCOffset): + * wtf/DateMath.h: + (WTF::GregorianDateTime::GregorianDateTime): + (WTF::GregorianDateTime::operator tm): + * wtf/Platform.h: + +2009-07-15 Norbert Leser + + Reviewed by Simon Hausmann. + + Undef ASSERT on Symbian, to avoid excessive warnings + https://bugs.webkit.org/show_bug.cgi?id=27052 + + * wtf/Assertions.h: + +2009-07-15 Oliver Hunt + + Reviewed by Simon Hausmann. + + REGRESSION: fast/js/postfix-syntax.html fails with interpreter + https://bugs.webkit.org/show_bug.cgi?id=27294 + + When postfix operators operating on locals assign to the same local + the order of operations has to be to store the incremented value, then + store the unmodified number. Rather than implementing this subtle + semantic in the interpreter I've just made the logic explicit in the + bytecode generator, so x=x++ effectively becomes x=ToNumber(x) (for a + local var x). + + * parser/Nodes.cpp: + (JSC::emitPostIncOrDec): + +2009-07-15 Oliver Hunt + + Reviewed by Simon Hausmann. + + REGRESSION(43559): fast/js/kde/arguments-scope.html fails with interpreter + https://bugs.webkit.org/show_bug.cgi?id=27259 + + The interpreter was incorrectly basing its need to create the arguments object + based on the presence of the callframe's argument reference rather than the local + arguments reference. Based on this it then overrode the local variable reference. + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::privateExecute): + +2009-07-14 Steve Falkenburg + + Reorganize JavaScriptCore headers into: + API: include/JavaScriptCore/ + Private: include/private/JavaScriptCore/ + + Reviewed by Darin Adler. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreCommon.vsprops: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.make: + * JavaScriptCore.vcproj/testapi/testapi.vcproj: + * JavaScriptCore.vcproj/testapi/testapiCommon.vsprops: + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Change JSCell's superclass to NoncopyableCustomAllocated + https://bugs.webkit.org/show_bug.cgi?id=27248 + + JSCell class customizes operator new, since Noncopyable will be + inherited from FastAllocBase, NoncopyableCustomAllocated has + to be used. + + * runtime/JSCell.h: + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Change all Noncopyable inheriting visibility to public. + https://bugs.webkit.org/show_bug.cgi?id=27225 + + Change all Noncopyable inheriting visibility to public because + it is needed to the custom allocation framework (bug #20422). + + * bytecode/SamplingTool.h: + * bytecompiler/RegisterID.h: + * interpreter/CachedCall.h: + * interpreter/RegisterFile.h: + * parser/Lexer.h: + * parser/Parser.h: + * runtime/ArgList.h: + * runtime/BatchedTransitionOptimizer.h: + * runtime/Collector.h: + * runtime/CommonIdentifiers.h: + * runtime/JSCell.h: + * runtime/JSGlobalObject.h: + * runtime/JSLock.h: + * runtime/JSONObject.cpp: + * runtime/SmallStrings.cpp: + * runtime/SmallStrings.h: + * wtf/CrossThreadRefCounted.h: + * wtf/GOwnPtr.h: + * wtf/Locker.h: + * wtf/MessageQueue.h: + * wtf/OwnArrayPtr.h: + * wtf/OwnFastMallocPtr.h: + * wtf/OwnPtr.h: + * wtf/RefCounted.h: + * wtf/ThreadSpecific.h: + * wtf/Threading.h: + * wtf/Vector.h: + * wtf/unicode/Collator.h: + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Change ParserArenaRefCounted's superclass to RefCountedCustomAllocated + https://bugs.webkit.org/show_bug.cgi?id=27249 + + ParserArenaDeletable customizes operator new, to avoid double inheritance + ParserArenaDeletable's superclass has been changed to RefCountedCustomAllocated. + + * parser/Nodes.h: + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Add RefCountedCustomAllocated to RefCounted.h + https://bugs.webkit.org/show_bug.cgi?id=27232 + + Some class which are inherited from RefCounted customize + operator new, but RefCounted is inherited from Noncopyable + which will be inherited from FastAllocBase. To avoid + conflicts Noncopyable inheriting was moved down to RefCounted + and to avoid double inheritance this class has been added. + + * wtf/RefCounted.h: + (WTF::RefCountedCustomAllocated::deref): + (WTF::RefCountedCustomAllocated::~RefCountedCustomAllocated): + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Add NoncopyableCustomAllocated to Noncopyable.h. + https://bugs.webkit.org/show_bug.cgi?id=27228 + + Some classes which inherited from Noncopyable overrides operator new + since Noncopyable'll be inherited from FastAllocBase, Noncopyable.h + needs to be extended with this new class to support the overriding. + + * wtf/Noncopyable.h: + (WTFNoncopyable::NoncopyableCustomAllocated::NoncopyableCustomAllocated): + (WTFNoncopyable::NoncopyableCustomAllocated::~NoncopyableCustomAllocated): + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's IdentifierTable class + https://bugs.webkit.org/show_bug.cgi?id=27260 + + Inherits IdentifierTable class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/runtime/Identifier.cpp:70. + + * runtime/Identifier.cpp: + +2009-07-14 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's Profiler class + https://bugs.webkit.org/show_bug.cgi?id=27253 + + Inherits Profiler class from FastAllocBase because it has been instantiated by + 'new' in JavaScriptCore/profiler/Profiler.cpp:56. + + * profiler/Profiler.h: + +2009-07-06 George Staikos + + Reviewed by Adam Treat. + + Authors: George Staikos , Joe Mason , Makoto Matsumoto , Takuji Nishimura + + https://bugs.webkit.org/show_bug.cgi?id=27030 + Implement custom RNG for WinCE using Mersenne Twister + + * wtf/RandomNumber.cpp: + (WTF::randomNumber): + * wtf/RandomNumberSeed.h: + (WTF::initializeRandomNumberGenerator): + * wtf/wince/mt19937ar.c: Added. + (init_genrand): + (init_by_array): + (genrand_int32): + (genrand_int31): + (genrand_real1): + (genrand_real2): + (genrand_real3): + (genrand_res53): + +2009-07-13 Gustavo Noronha Silva + + Unreviewed make dist build fix. + + * GNUmakefile.am: + +2009-07-13 Drew Wilson + + Reviewed by David Levin. + + Add ENABLE(SHARED_WORKERS) flag and define SharedWorker APIs + https://bugs.webkit.org/show_bug.cgi?id=26932 + + Added ENABLE(SHARED_WORKERS) flag (off by default). + + * Configurations/FeatureDefines.xcconfig: + +2009-07-07 Norbert Leser + + Reviewed by Maciej Stachoviak. + + https://bugs.webkit.org/show_bug.cgi?id=27058 + + Removed superfluous parenthesis around single expression. + Compilers on Symbian platform fail to properly parse and compile. + + * JavaScriptCore/wtf/Platform.h: + +2009-07-13 Norbert Leser + + Reviewed by Maciej Stachoviak. + + https://bugs.webkit.org/show_bug.cgi?id=27054 + + Renamed Translator to HashTranslator + + Codewarrior compiler (WINSCW) latest b482 cannot resolve typename + mismatch between template declaration and definition + (HashTranslator / Translator) + + * wtf/HashSet.h: + +2009-07-13 Norbert Leser + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=27053 + + Ambiguity in LabelScope initialization + + Codewarrior compiler (WINSCW) latest b482 on Symbian cannot resolve + type of "0" unambiguously. Set expression explicitly to + PassRefPtr